Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Created October 29, 2015 08:21
Show Gist options
  • Save Teino1978-Corp/f05109a6060582afb69c to your computer and use it in GitHub Desktop.
Save Teino1978-Corp/f05109a6060582afb69c to your computer and use it in GitHub Desktop.
This gist exceeds the recommended number of files (~10). To access all files, please clone this gist.
<?php
class AnythingButPhpFilterSimple extends FilterIterator {
protected $exclude = array(
'.svn',
'_lib',
'test',
// 'client',
'components'
);
protected $limit = 1000;
public function __construct( $recursiveIter) {
parent::__construct($recursiveIter);
}
public function accept() {
return $this->isValid();
}
/**
* True when the current element is valid
* @return boolean
*/
public function isValid(){
if(parent::valid()){
$current = $this->current();
$no = array('all-wcprops','svn-base');
$c1 = (strpos($current->getPathname(),$no[0])===false);
$c2 = (strpos($current->getPathname(),'svn')===false);
$c3 = (strpos($current->getPathname(),'php')!==false);
return $c1 && $c2 && $c3;
} else {
return false;
}
}
/**
*
* @return RecursiveDirectoryIterator
*/
public function current(){
return parent::current();
}
}
/**
* Autoloader Handler.
* - cache file real path indexing by filename
* - load all atf php folders as SPL Iterators.
* - allow .class.php extension
*
* @author Andrés Serrón <[email protected]>
*/
class AutoLoader {
private static $_instance;
/**
* @return AutoLoader
*/
public static function &getInstance() {
if(!(self::$_instance instanceof self) ) {
self::$_instance = new self();
self::$_instance->initialize();
return self::$_instance;
} else {
return self::$_instance;
}
}
////////////////////////////////////////////////////////////////////////////
// isntance
public $debug = false;
/**
*
* @var AnythingButPhpFilterSimple
*/
private $recDirItr = null;
public $cache = array();
/**
* Create a new AutoLoader instance.
*/
public function __construct() {
if($this->debug){
fb(__METHOD__." created");
fb($this->cache,__METHOD__.": cached at constructor");
}
}
/**
* @todo Persist across session
*/
public function __destruct() {
$this->cache = array();
}
private function initialize() {
if($this->debug) {
FB::group(__METHOD__,array('Collapsed'=>true));
fb(__METHOD__,"INFO");
}
$this->initClassPathCache();
if($this->debug) FB::groupEnd();
}
private function initClassPathCache() {
$dir = $this->getDirectoryList();
$count = 0;
$max = 100;
if($this->debug) FB::group(__METHOD__,array('Collapsed'=>true));
if($this->debug) fb("Walk the itereator: keys are full paths!","WARN");
foreach ($dir as $key => $fileInfo) {
if($this->debug) fb($fileInfo->getRealPath(),"key = $key");
$this->cache[$key] = $fileInfo->getRealPath();
}
if($this->debug) FB::groupEnd();
}
/**
* Register autoloader method.
*/
public function register() {
fb(__METHOD__." > Installing autoloader","WARN");
if(false === spl_autoload_register(array($this, 'loader'))){
fb("SPL ERROR","ERROR");
die("can't register autoloader");
};
}
/**
* Try to include the file for the Class Name passed.
* @param string $className Class Name to be included.
*/
public function loader($className) {
$path = $this->findClassRealPathByName($className);
if($path!==false){
if($this->debug) fb(__METHOD__." > Loading class='$className' realpath='$path'","WARN");
$this->cache[] = $className;
include_once $path;
} else {
throw new LogicException("Can't find the real path for class name ='$className'");
}
}
/**
* Get the autoloader base directory
* @return string
*/
public function getBaseDirectoryRealPath() {
$path[] = realpath('.');
$path[] = 'classes';
$fullpath = implode(DIRECTORY_SEPARATOR,$path);
return $fullpath;
}
/**
* Get the recursive directory iterator with only php file into it.
* The method create the object if needed.
* The iterator is filtered with an AnythingButPhpFilter instance.
* @param boolean $force Force rebuild.
* @return AnythingButPhpFilterSimple
*/
public function getDirectoryList($force=false){
if(($this->recDirItr==null) || $force){
$directoryPath = $this->getBaseDirectoryRealPath();
if($this->debug) fb(realpath($directoryPath),__METHOD__.": Creando dir=$directoryPath","INFO");
// /*
$directory = new RecursiveDirectoryIterator($directoryPath,
RecursiveDirectoryIterator::NEW_CURRENT_AND_KEY
);
// $directory->setFlags(RecursiveDirectoryIterator::NEW_CURRENT_AND_KEY);
$recursive = new RecursiveIteratorIterator($directory,RecursiveIteratorIterator::SELF_FIRST);
$filtered = new AnythingButPhpFilterSimple($recursive);
$itr = $filtered;
// */
$this->recDirItr = $itr;
};
return $this->recDirItr;
}
/**
* Try to find the real path of the class name passed.
*
* The file must be named after the class name with optional .class
* sufix
*
* throw LogicException if nothing found.
*
* @param string $className Real path to class file.
*/
private function findClassRealPathByName($className){
if($this->debug) fb(__METHOD__." > find class ='$className'","INFO");
$fileName1 = $className.".php";
$fileName2 = $className.".class.php";
foreach ($this->cache as $fileName => $fileRealPath) {
if(($fileName == $fileName1)||($fileName == $fileName2)){
return $fileRealPath;
} else {
continue;
}
}
return false;
}
}
?>
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of Action
*
* @author Andrés Serrón <[email protected]>
*/
class ActionController {
/**
*
* @var Request
*/
public $request;
/**
*
* @var Response
*/
public $response;
//put your code here
public function __construct(Request $request=null,Response $response=null, $invokeArgs=array()) {
if($request!=null) $this->setRequest($request);
if($response!=null) $this->setResponse($response);
}
/**
* Push a new action into the action stack.
* Set dispatched to false;
* @param string $action
* @param string $controller
* @param type $invodeArgs
*/
public function _queue ( $action, $controller=null,$invodeArgs=array()) {
$request = new Request();
$request->action = $action;
$request->controller = $controller."Controller";
$request->params = $invodeArgs;
ActionStack::getInstance()->push($request);
}
/**
* Forward a new action.
* Set dispatched to false;
* @param string $action
* @param string $controller
* @param type $invodeArgs
*/
public function _forward( $action, $controller=null,$invodeArgs=array()) {
$this->request->action = $action;
$this->request->controller = $controller."Controller";
$this->request->args = $invodeArgs;
$this->request->setDispatched(false);
}
public function dispatch(Request $request=null,Response $response=null){
if($request) $this->setRequest($request);
if($response) $this->setResponse($response);
$this->preDispatch();
$request->setDispatched(true);
$this->{$request->action}($request->data);
$this->postDispatch();
}
/**
* Override to gain pre dispatch logic.
* Note:
* The action could be skipped by fowarding from here based on some
* test.
*/
protected function preDispatch(){
$stack = ActionStack::getInstance();
}
/**
* Override to add post dispatch functionallity
*/
protected function postDispatch(){
}
public function setRequest($request){
$this->request = $request;
}
public function getRequest(){
return $this->request;
}
public function setResponse($response){
$this->response = $response;
}
public function getResponse(){
return $this->response;
}
}
?>
<?php
/**
*
* Front Controller
*
* @todo implement view to handle headers and other kind of outputs
*
*/
class FrontController {
static private $_instance;
/**
* @static
* @return FrontController
*/
public static function getInstance()
{
if (null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
private $_response;
private $_request;
private $_returnResponse = true;
/**
*
* @var ActionController[]
*/
private $_controllers = array();
/**
* @constructor
* @return FrontController
*/
public function __construct() {
// install filters and plug ins
}
private function route (Request $request){
$arr = explode('.',$request->action);
if (count($arr)>1){
$request->controller = $arr[0]."Controller";
$request->action = $arr[1];
}
}
/**
* Dispatch an action based on the request passed.
* @param Request $request
* @param Response $response
* @return type
*/
public function dispatch (Request $request,Response $response=null){
// FB::group("[".__METHOD__."] dispatch: $request->action");
$this->route($request);
if($response==null) $response = new Response();
// register request and response here and at plugs
$this->setRequest($request);
$this->setResponse($response);
do {
$request->setDispatched(true);
$this->preDispatch($request);
/**
* Skip requested action if preDispatch() has reset it
*/
if(!$this->getRequest()->isDispatched()){
continue;
};
fb($request,__METHOD__);
fb($response,__METHOD__);
try {
$controller = $this->getController($request,$response);
$controller->dispatch($request,$response);
} catch (Exception $exc) {
// FB::groupEnd();
// FB::groupEnd();
fb($exc);
fb($controller);
$o = DataRecord::createErrorOutSt();
$o['data'] = $exc;
$response->loadData($exc);
};
/**
* zend post dispatch with the plugin broker.
*/
$this->postDispatch($request);
}
while (!$request->isDispatched());
if ($this->returnResponse()) {
return $this->getResponse();
}
$this->getResponse()->sendResponse();
// FB::groupEnd();
}
/**
*
* @param Request $request
* @internal
* Both pre and post should be done by the plug in broker.
*/
private function preDispatch (Request $request){
ActionStack::getInstance()->preDispatch($request);
}
private function postDispatch(Request $request){
ActionStack::getInstance()->postDispatch($request);
}
/**
*
* @param Request $request
* @param Response $response
* @return ActionController
*/
private function createControllerInstance(/*Request*/ $request,/*Response*/ $response){
$class = $request->controller;
$c1 = class_exists($class);
if($c1===false){
throw new RuntimeException("class = '$class' can't be found by autoloader");
} else {
$request = $this->getRequest();
$response = $this->getResponse();
$controller = new $class($request,$response);
return $controller;
}
}
/**
* @internal This is work for the Dispacher class
* @param Request $request
* @return ActionController
*/
public function getController(Request $request,Response $response) {
if(!array_key_exists($request->controller,$this->_controllers)){
try {
$controller = $this->createControllerInstance($request, $response);
$this->_controllers[$request->controller] = $controller;
} catch (Exception $exc) {
fb($exc);
}
}
return $this->_controllers[$request->controller];
}
/**
* Set request here and at plug ins.
* @todo review helper broker at zend
* @param Request $request
*/
public function setRequest (Request $request){
$this->_request = $request;
ActionStack::getInstance()->setRequest($request);
}
public function setResponse(Response $response){
$this->_response = $response;
ActionStack::getInstance()->setResponse($response);
}
/**
* Pass Boolean to set.
* Otherwise get.
* @param boolean $flag
* @return FrontController||boolean front as setter, boolean as getter.
*/
public function returnResponse($flag = null) {
if (true === $flag) {
$this->_returnResponse = true;
return $this;
} elseif (false === $flag) {
$this->_returnResponse = false;
return $this;
}
return $this->_returnResponse;
}
/**
*
* @return Request
*/
public function getRequest(){
return $this->_request;
}
/**
*
* @return Response
*/
public function getResponse(){
return $this->_response;
}
}
?>
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of ActionStack
*
* @author Andrés Serrón <[email protected]>
*/
class ActionStack {
/**
* @var ActionStack
*/
static $_instance;
/**
*
* @return ActionStack
*/
public static function getInstance()
{
if (null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
*
* @var FrontController
*/
private $_front;
/**
*
* @var ActionController
*/
private $_current;
private $_request;
private $_response;
/**
* @var Request[]
*/
private $_stack = array();
public function __construct() {
$this->_front = FrontController::getInstance();
}
/**
*
* @param Request $request
* @return integer The new stack count
*/
public function push(Request $request){
return array_unshift($this->_stack,$request);
}
/**
* Pop the last request
* @return Request
*/
public function pop(){
return array_pop($this->_stack);
}
public function &getStack(){
return $this->_stack;
}
public function getCount(){
return count($this->_stack);
}
///////////////////////////////////////////////////////////////////////////
// should match current exucted
public function setRequest(Request $request){
$this->_request = $request;
}
public function setResponse(Response $response){
$this->_response = $response;
}
/**
*
* @return Request
*/
public function getRequest(){
return $this->_request;
}
/**
*
* @return Response
*/
public function getResponse(){
return $this->_response;
}
///////////////////////////////////////////////////////////////////////////
// controller workflow
public function setActionController(ActionController $ctrl){
$this->_current = $ctrl;
}
public function preDispatch(Request $request){
$this->setRequest($request);
}
public function postDispatch(Request $request){
if (!$request->isDispatched()) {
return false;
}
$this->setRequest($request);
$stack = $this->getStack();
if ($this->getCount()==0) {
return;
}
$next = $this->pop();
if (!$next||($next===null)) {
return;
}
$this->forward($next);
}
/**
* @param Request $next
* @return void
*/
public function forward(Request $next)
{
$request = $this->getRequest();
if ($this->getClearRequestParams()) {
// $request->clearParams();
}
$request->action = $next->action;
$request->controller = $next->controller;
$request->params = $next->params;
$request->setDispatched(false);
// continue dispatch loop >>>
}
public function getClearRequestParams($value=null){
return false;
}
}
?>
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of PlugInBroker
* @property ActionStack actionStack
* @author Andrés Serrón <[email protected]>
*/
class HelperBroker {
protected $_helpersByPriority = array();
protected $_helpersByNameRef = array();
protected $_nextDefaultPriority = 1;
/**
* Magic property overloading for returning helper by name
*
* @param string $helperName The helper name
* @return Zend_Controller_Action_Helper_Abstract
*/
public function __get($helperName) {
if (!array_key_exists($helperName, $this->_helpersByNameRef)) {
return false;
}
return $this->_helpersByNameRef[$helperName];
}
/**
* Magic property overloading for returning if helper is set by name
*
* @param string $helperName The helper name
* @return Zend_Controller_Action_Helper_Abstract
*/
public function __isset($helperName) {
return array_key_exists($helperName, $this->_helpersByNameRef);
}
/**
* Magic property overloading for unsetting if helper is exists by name
*
* @param string $helperName The helper name
* @return Zend_Controller_Action_Helper_Abstract
*/
public function __unset($helperName) {
return $this->offsetUnset($helperName);
}
}
?>
<?php
class InputSanitize {
// sanitization
static function sanitizeArray($value) {
$value = is_array($value) ?
array_map(array('InputSanitize', 'sanitizeArray'), $value) :
stripslashes($value);
return $value;
}
static function sanitizeVariables($item, $key)
{
if (!is_array($item))
{
$item = stripslashes($item);
//$item = self::sanitizeText($item);
}
return $item;
}
// does the actual 'html' and 'sql' sanitization. customize if you want.
static function sanitizeText($text)
{
$text = str_replace("<", "&lt;", $text);
$text = str_replace(">", "&gt;", $text);
$text = str_replace("\"", "&quot;", $text);
$text = str_replace("'", "&#039;", $text);
// it is recommended to replace 'addslashes' with 'mysql_real_escape_string' or whatever db specific fucntion used for escaping. However 'mysql_real_escape_string' is slower because it has to connect to mysql.
$text = addslashes($text);
return $text;
}
}
/**
* Description of Request
*
* @author Andrés Serrón <[email protected]>
*/
class Request {
public $action = 'Default';
public $controller = 'App';
public $data = array();
private $_get = array();
private $_post = array();
/**
* Internal controller parameters
* @var array
*/
public $params = array();
private $_dispatched = false;
public function __construct($config=null) {
if($config===null){
$config = $_POST;
}
$this->sanitize();
$this->action = $config['action'];
$this->data = json_decode($config['data']);
// handler ext.pagin settings.
$this->pager = new stdClass();
$this->pager->start = isset ($config['start']) ? $config['start'] : 0;
$this->pager->limit = isset ($config['limit']) ? $config['limit'] : 10;
}
/**
* Sanitize POST and GET arrays
*/
public function sanitize(){
if((function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) || (ini_get('magic_quotes_sybase') && (strtolower(ini_get('magic_quotes_sybase'))!="off")) ){
foreach ($_POST as $key => &$value) {
$value = InputSanitize::sanitizeVariables($value, $key);
}
foreach ($_GET as $key => &$value) {
$value = InputSanitize::sanitizeVariables($value, $key);
}
}
}
public function isDispatched() {
return ($this->_dispatched === true);
}
public function setDispatched($v){
$this->_dispatched = $v;
}
}
?>
<?php
/**
* Description of Response
*
* @author Andrés Serrón <[email protected]>
*/
class Response {
//put your code here
public $success = false;
public $total = 0;
public $data = array();
public $error = '';
public function loadData($o){
$o = (array) $o;
foreach ($o as $key => $value) {
if(property_exists($this, $key)){
$this->{$key} = $value;
}
}
}
/**
* @todo Implement view out from inside the Front controller calling this function
*/
public function sendResponse(){
// implemenet based on the zend framework implementation.
}
}
?>
.app-loader {
height: 187px;
width: 300px;
left: 50%;
}
@charset "utf-8";
/* CSS Document */
body,h1,h2,h3,p,span {
font-family: Verdana;
}
#loading-mask{
background-color:white;
height:100%;
position:absolute;
left:0;
top:0;
width:100%;
z-index:20000;
}
#loading{
height:auto;
position:absolute;
left:45%;
top:40%;
padding:2px;
z-index:20001;
}
#loading a {
color:#225588;
}
#loading .loading-indicator{
background:white;
color:#444;
font:bold 13px Helvetica, Arial, sans-serif;
height:auto;
margin:0;
padding:10px;
}
#loading-msg {
font-size: 12px;
font-weight: normal;
padding: 10px 0px;
clear: both;
text-align: center;
float: left;
}
.flickrlist {
font-family : Verdana;
min-width : 938px
}
.flickrlist .dataview-list {
width:100%;
height: 100%;
}
.flickrlist .items {
font-family: fantasy;
}
.flickrlist .items h1,h2,h3{
clear: both;
font-size: 0.6em;
}
.flickrlist .items .item {
margin : 20px 32px;
float : left;
clear : none;
background-image: url('../images/list/image_bkg.gif');
background-repeat: no-repeat;
background-position: 0px 0px;
}
.flickrlist .items .x-view-over {
background: url("../images/list/image_over_bkg.gif") no-repeat;
}
.flickrlist .items .item .thumb-wrap {
float: left;
clear: both;
width: 228px;
height: 146px;
padding:8px;
}
.flickrlist .item-over {
display : none;
position : absolute;
left :-100px;
top :-100px;
float : left;
background-image: url('../images/list/icon_detail.png');
width : 50px;
height : 50px;
z-index: 30000;
}
.app-list .x-grid3-scroller {
overflow: visible !important;
}
.app-list .x-grid3 {
background-color: black;
color:grey;
}
.app-list .x-grid3 .x-grid3-row {
border: 0px none;
cursor: pointer;
}
.app-list .x-grid3 .x-grid3-header {
display: none;
}
.app-list .x-grid3 .x-grid3-row-over {
border : 0px;
background-color : #8c8c8c !important;
background-image : url('../images/list/list_over_bkg.png');
background-position : left;
background-repeat : no-repeat;
color : black;
}
.app-list .x-grid3 .x-grid3-body .x-grid3-row-nostyle {
background-image: none !important;
background-color: white !important;
}
.x-grid3-row-body .x-grid3-row-nostyle {
background-image: none !important;
background-color: white !important;
}
.app-list .x-grid3 .x-grid3-col-list-title {
font-size : 16px;
line-height : 30px;
padding-left : 30px;
}
/* row first, cell first*/
.app-list .x-grid3-row-first {
background-color : white !important;
background : none !important;
}
.app-list .x-grid3-row-first .x-grid3-cell-first {
color : #ffa340;
font-weight : bold;
background-color : black !important;
border-radius : 10px 10px 0px 0px;
-moz-border-radius : 10px 10px 0px 0px;
}
.x-grid3-row-first .x-grid3-cell-first div {
border-bottom : solid 1px #ffa340;
padding: 0px !important;
margin : 5px 30px 5px 30px;
}
/* row sel, cell*/
.app-list .x-grid3 .x-grid3-row-selected {
border : 0px;
background-color : black !important;
background-image : url('../images/list/list_sel_bkg.png');
background-position : left;
background-repeat : no-repeat;
color :black;
}
.app-list .x-grid3-row-selected .x-grid3-cell-first{
background-color : white !important;
background-image : url('../images/list/list_sel_bkg.png');
background-position : left;
background-repeat : no-repeat;
color :black;
border-color : red;
border-radius : 10px 0px 0px 0px;
-moz-border-radius : 10px 0px 0px 0px;
}
.app-topbar {
background-color: black;
}
.app-topbar .x-panel-body {
min-width: 1054 px;
overflow: hidden;
}
.menu-button {
width: 50px;
height: 50px;
display: block;
float: left;
}
/** Custom btn*/
.main-nav-button{
background:#ffffff;
/* margin : 10px 0;*/
width : 46px !important;
height : 46px !important;
border : 1px solid rgba(0, 0, 0, 0.2);
-moz-border-radius : 5px;
-webkit-border-radius : 5px;
-moz-box-shadow : 0px 0px 5px rgba(255, 255, 255, 0.25);
}
.main-nav-button button{
position :absolute;
top :0;
left :0;
width :100%;
height :100%;
border :none;
opacity :0;
cursor :pointer;
}
.main-nav-button .main-nav-icon{
width :36px;
height :36px;
top :5px;
left :5px;
position :relative;
zoom :100%;
opacity :0.8
}
.main-nav-button .main-nav-button-overlay{
background : -moz-linear-gradient(top, rgba(0,0,0,0) 20%, rgba(0,0,0,0.1));
position :absolute;
top :0;
left :0;
width :100%;
height :100%;
-moz-border-radius :3px 3px 3px 3px;
}
.x-btn-over .main-nav-button-overlay{
background: -moz-linear-gradient(top, rgba(0,0,0,0) 20%, rgba(0,0,0,0));
}
.x-btn-click .main-nav-button-overlay, .x-btn-menu-active .main-nav-button-overlay{
background: -moz-linear-gradient(top, rgba(0,0,0,0.1) 80%, rgba(0,0,0,0));
}
.x-btn-menu-active.main-nav-button, .x-btn-menu-click.main-nav-button{
-moz-box-shadow:inset 0px 0px 5px rgba(0, 0, 0, 0.25);
}
.main-nav-button .contacts_large {
background: url('../images/list/icon_detail_36.png') no-repeat left center;
}
/* search */
.app-topbar {
font-size : 24px !important;
}
input.app-searchfield {
color : #8c8c8c;
font-size : 20px !important;
line-height : 30px;
height : 44px !important;
}
.app-topbar .app-topbar-searchlabel {
line-height : 30px;
}
/* footer */
.app-footer {
background-color: black;
color : #E5872C;
overflow: hidden;
}
.app-footer .footer {
padding : 20px 40px 20px 40px;
overflow: hidden;
}
�PNG

IHDR22?��tEXtSoftwareAdobe ImageReadyq�e<
bIDATx��{P���{o��}^��L��(�
"� �u* �X��;I�13񕎎�hfڎ��ئ:���錚�i�c�Tab+J��1*A8�r��8�{����ow�F9+�����������>{Pc�E4�/A����}����74�
�$#l@ � C��X*ߊG��J���fӋ4C)���Z�v@X`"X�������,{���7���X[����f���x]R��&!!�&%9ce�ye�<�M椀Z�a��8
(��c����}���tԹ\���� �����Z�/��Z�2���+˾6����՛��*D+Q��8� K��M�:�� ���̖��{���޾���� ��\��#}��Њ^RmX_�XR��֛�A�A\ �<�đ�n��I��i�������z������^���������I���U��^]_9��i�+ăւ ���`y+�02�Gnx`�x���}�|�Y��f� ���O,�33�}+ɜ���5�<��W�L)�|�m��� ��=�f��h8�1�%o���+���2��_�l-�@�Ø���a�X�a0W�{��ʆ�C�dmK�E3|V�3��)�C*�� l�n���ɉ�}>�/Z[?邙�YA��`6�W(��W:"([Srp+Y� ^��A(х��7�����on9[Z�*Dz���ebf��2�2K6l��w�qa�["B�`�5J�&f1�r���φ�� ��DB�Fg�)+{噶��5N�� ���9;ebb����� s��"��}G`�Xť�'җ'������� 0!R��8�E���b�Jt8���ܲ�J��,�����p8�����d2�C�[ub@�� ��g�`�0̺s�C�0��|X�LF�^ ����j��//�����
������ |%Ŵ���ɞ`hđ���H� ��O�8Gb&��pX�`D�#������ &��a�"p��9 v��R��b�b�9�'��
/^��y9d#�c�"=B�������!�b����A�� :m?�E�JE�V��2��&�:5x�T��0p���Վ��Ď���h��J��uxi ŔR�4~K��g���DvN@�?H+�A@Fɰ�t\���P��"�SX4�4� �����X��bF���HII�����4��U� &,ES��j�lC+���1 ZKʋq#����Hl@�f_��bY�
?�q�|q��Z�g�/#p��`0��D ��<�x�&�@�H�2��m�ee�A=�I���T_@�Cc���d������G �B�>��{���@+� �hp�E]B�gD�䘘����x��L�w������:X| >�[=�"a6��p�*�F=*�D'Y 1m $m�d � ʝ$K`YQx4�KS�c;�Y��퓰F�%�>s�k��q�i�h���a�&~<b�e@2�S�!��0���5jd� x<�V8�5�M#������y~w�$@�G ��C�,��
�"Dd_�І��&�h�����ᜫW�ikko��#1�~�\'��\3u\�� �y�#"+ �Ⱦ�����;�fhi�(��~��--�N�8����d||���o?�t�����EP΃��L)�FD��IW+LCJi7
\L�D���]%/�%���v>��~L�����[n4 ^���;l���lH�u>JfDb�X=��Uj���p���(��"��f�1}����w߸r�å?�x���f��$Q^����x�:2�g� )8?��:���ƕ_��ߚ��t��3�޽{_"�L�^o]��O~X[���g��𹆖�)��\ G����kd�)1�0��P���(�k�o��;u2�e!�8UVV�ݸq�o�ܸ'�N�ծ��}�ݒee9��6<�[�O�Z�ϲ�9t��‹���M+hX�C�P3(��\�s�VZ__�r�n��n�+�AD�֭C���ը�ܹ�'N����EV������5˗�T-�[~;55�=-=өPj�څU2(�`�����]i��P~c���[Z:���N���u���~ott���r��۷�]�v!�Z�����p���Mp��X����4]����m�uA��hZ������$'�Ѥ|C�D���h��z��č;mm�~��N�Nn�t�… ����B۶m#A�8�x���-�W�A���JVv�� >.�$��\0tAw��ێ.���g�XM^^�)X�mr:�"̎;PBB:r�ȭC�}����
"��Q�CEB DG����C~��}XXX�SRR������� �ǎ�NLL\�0�)�����&M�.]z���'%%�0�n2>}�;##�r^��� �KKK�H� � �,��s���� 2 k-Z�jU;�� �f.\`
ޜ d@+\�f��INN�Pc0$ �x�".))y{^��a0^\�v���@��{�왂������$��� �uUUUc4��ݻ���a�e�%N�z2 [m�L 0z�C A� ���y"�Ȕ����G`�J�f�ᦦ� ���З�d��͘��f�AV;%�+2���n(�P"}v�?N��D���� �(���xh�8_Ǘ�����0���f�Q{�IEND�B`�
�PNG

IHDR$$���tEXtSoftwareAdobe ImageReadyq�e<�IDATx��{LSW��}�`A
�R�E^N�NG�[�c�F�#K|d ssS���ɖ��,۲�%��5�c:��MA���@i)z{_��w�-�9u������������� !=M�EO�x��� �<�b�3�>�A�� b��#��EQ�
�:�\9�l6�5"�1k��6�l�7�N�D��n 64\���j����� 7� ���*d4�$&ZW?�=~�W�'�:�$�&vD ��q���24^o����ᤣG��+ί���B�
7;���οiϴz�]YEH�)� >��p^R�.Wԥ}�ݗ��{��oo�|� �ar���Y\�n����h^F%���a�=b`f���G�Ϩ���Y[TdԆ-?~+vt�68˨J�V��S��W��
�aA��,Z b�80^QXl��;�%+OL{u�zH��e���9�/�?��P��05����D�_��'*�/��KP�㇝�3g1_U}���ꚩp��o�8s��S^���GZ=����)�N�*y��w�*�(+�J���j����L���.WU�~���8ӈg�^p:�ae $Q���axṧ��^ ��˨&`Xwǐ��q�.��9�Vl���v��hH�$ج�k=�."�b��J\� �HXn^ �P|J��9�ö�g����f������2�g�9��Mӛ&���[A�d�:aq
ǩ��Z�QWjD i�1eM��K�%��V0o���Q�@1d�āK��dT ~���z�S?b0�ueH��h���eXC�6>ֿ^���@�1�y��'�
��K!!M��k,k�LA�f-�#U F�p�`���4Co}��3D^��V�Y�����C =Ah�'�\7Zఫ_Y]����j��zN$ȫ�E���U���E�єW)ҋ6�(����Ȧ��'�4�V����ғ�~v�2���`Ɛ1V吋DP"d�>L�fXĈ½�ӧ�2�<<������<s��_�� o
@Ջ�������������d@��]؛WVV� �]Ƹ�be��=[�*�NA�Ņ^�$x�2�0 �%#X�j.ϯ�>���C}q�#��]]����T�ͦE���LFPB�0HPs��״�����u��׶��z���?4nܸ�cx�4���3��~�m���޲f�����v�(ZƱ�6 �!�����Бu��p����Шh�|���k׮}n���1��vffdl��})c�s�m�m�!�ў�0�AQ�3�����9rxW <�������.(**B�6o�|aٲe�E����\,�N2C���)!��=����t��I!�e `�eYv��A�ZXX�֭[��n�zmɒ%s�~��B���>|a��� f:~��|Lvv�����f�(���۷�N||��Q@D�}z�}q�رck(��ի����رc>��V0(@�4"c�ĉ7���ɪU��r��q��n�3(@tDGG��<y��*�b�
"I9{������`P�舍�}1//ϛ��D �(������=�dP��X,������������ARYYI&�0��?�������3�;v�P��懸��L���D���E3g�TA1�y�q���z����\( �����04�`��R*�IEND�B`�
GIF89a���U�����������������ν��QQQ���������������������������������������������������������������������������������������RRRUUU��ѿ�������о��SSS���sss������YYY���������333���bbb��ͬ��������\\\kkkWWW�����ҝ����������ĸ����������ɢ��������������������!�U,����U���������������������������
 �������������������������� ��������������������� �����  ������������
H��Az�6H��A�r
(��d�PAÃB�I��ɓ(S�\ɲ�˗0cʜ�QC Hp0�9t�Tl��G���ӧP�J�J��իX�j�ʵ�ׯ_u�ф�%R^h�O�������)x���˷�߿� L���È+&�DF&P��‚B�]̹��ϠC� %�",�XEn �R�M���۸s��ͻ����� N��o�3.���`rP�m����سk߮� PC�[�C �P�ξ�������Q�B :Z�A���'��( ^1��x�@,0���f�ᆻ�� �m0��� q!�,��|S� � 0�\�'>�Ê/������
*<`c%
0��/��PB�W +�� @J���Q�)&�x`@`�%�x �p�_�g��e�m~9��|�9�f��&�n��硈bG��wn٥��F*�p�ڹ�oN�餕�h��n*ꡝ6�f����i���j���"�*���jk��~�ꭼ™멵�*�����)���,��b��вج��VKf�������8�݆ ߷��k.{�&{�Abk)��+/o�>;t�{�����o���Z���Vo�����&�pm?,q�;Lq��_�1�o�o�� r��L�&�ln�*��r�ܾ s�2� m�6+�s����3�>�lk�B�Jtѩ���J/�i�NK
uԉNM5� k;��=g ��\�ju�r�M��^ ��R��,�l�v�q�jv���/�x=7�}˭7À�����4�[+�)�k;���ZG.��w_.-�pk�5�_{�4�?�ڝ�^6�W�z�KxⰯ~�۵Ǟm���z�qf��y��G)|��"�<��?ߝ���}��]�}u�o_\��~����N7�.���o�O/���~��O�m��1���i~������Ѐ�C��x?�ρ��$�>
�ς��`�4�=nσ�a�D(=>τ�Ca�Th<υ��a�d�;�Ά��a�t�:�·��焨�i=��#�u�T�+�*G)H��#$"�F[:�j �)/2�ё!!
9��^�W@T��
��OИF���
b��a�$��ud�vP����9�yF��F:򑐌$^h���<��@dPIz���� %$i�(�9Ω�e0ӂ�`.�A ~`���̥.w��^��� �0�I�b��L�2K���;���p�Ԭ�r��`� p�# �P����L�:���v�����<�I�z���\
D@��8Md&�@�� A.�@��D'JъZ��ͨF7�юz�� �HGQ�� �@B����F4���d&8ͩNw�Ӟ��5�INvғ�B`�;�!��8��P��T�JU�$d! Ky�9X3�a��H�7�Jֲ���hMk6�!r��2�0(DA�\���xͫ^��W\�@�+'4A�����M�b +XA;
GIF89a����y���m�~���Z��33��|�Uu��������������������q����QQQ�������������������������������������������������������������������������������������p�����Ѿ�����i���SSS������UUURRR���ⴴ��kkk������ͬ������������bbbWWWsbc���YYYsss\\\������^|��������ss�����������������������������ɂ载��Đ������������!�,�������������������������������0&&8''���������������������8�0����-.:+))���������������������+:.-'�����.)*4/5((������������
H��Az�j���"��r&`v��
/P܈!� B�I��ɓ(S�\ɲ�˗0cʜ�ц�7P�P���9t�LTLq�I� z�\�2$�ӧP�J�J��իX�j�ʵ�ׯ_�L S� 6v�l`�#�O��LTXA#O�F8A�a�� L���È+^̸��ǐ#G�� ���"ŎL��q…
 ���c˞M���۸s��ͻ�����G@|I��q��!3$
.NH�#7ŋ��ν����ËO�����ӫ_Ͼ�y����"E�-T�2`���(��X`?|�� ϵ�8�@� w ��f��v@Xl0� 4��� '��B >pa�0�(�2~�=���'�A� +� C#@�H&���y�� ְ� �T�
6��Kv��1�A>a
�Uy% Wl �p��F hVP���D #�)蠄~�J� X�'�� �j�o�A`�裑^0i���j*��rꩣ{�Ji���*k��v�i���:뮼�W몠J�j��{ޯ�B*,��6�,wȲ����>k-��K���v;k���?�;m��[�������,��� ���ګ�lj��튻��I��.��h�� 7����:,���;���V���j����y ���L��㙌��ީ���.��r�2�Ls�#ߌ��:�q�>_ t�Mt�F�p�J�t��> u�RO�n�V��u��n�u�^mm�b;Kv�ƞ�6��l�����r�Jwݲލ��z�n��j{��Tl�q���oϫ��}?/�;.�Ք ���]g��Ŝ_y�p�N:��~��?kz�]����ώd?�����+��|�O��O��p��<��[�����;=��7n��yW?8��&~��޳>����k�/h�����O���;���_���KY��0N<�� �@Թ�r�k��(��P���`�Av��$`8B��p'�_
����}/T_ �7���|7�^������y?T^�7D�1xG�]s�D�5qvO�][7��U�tW ]9���uQr_|�œ��
�.{���`�/� ��bAP�6z�I�Z���4�*d��]�P��'5a) � ��"��L��Q�d(`�J"��%H��JHъ��4`2IcX�p�# "B�CfN�$ ,�
""���&�! e8 p�bz���L�2���f:�Ќ�4�I�jZ���f1��1H@\Â���`]�|~�N�����<�I�z���̧>���~��}�
��,� k��|�s�?��4L����,x! I0�>�юz�� �HGJҒ���(M�JW�Җ�T FH�`1t ΁�t !��1�A6��#�B�R��Ԧ:��P��T�JժZ��X�ͪV��U!�G@�r0�|&4@J R�S�`=�A�������xͫ^��׾���� �`K����uBrЃȀ�q�9A�`D#�Hf���z��� �h9[���d'=�I!�Qv��8�lgK������HBҐ��c:F�q�dx��M�r����f� �9D C�B�ȅv����z�����.z��rB�M�z�������D ;
�PNG

IHDR$�F�tEXtSoftwareAdobe ImageReadyq�e<�IDATx��ձCP���{+,�,"�j�0xo�L &1Il1=M��M������$>n �^�=Ƙ�8��i���:����u���45M��4ADQ$�0q�a�o�����n8�I�%溮��4��1�0�F�e��$�l�����O�y��fG�iۖl��"��,�a��u]�,#���{Q-�"��k�mۻ�Ծٶ�i��(��:<���0MS��]��+�eQe���?�U$MXIEND�B`�
�PNG

IHDR$�F�tEXtSoftwareAdobe ImageReadyq�e<�IDATx���� �0��T!3�A�9��cxu!c\�!:���zB���XZ��s��9<�!��<�Rc�aض-|�c���7��z]���m�;�R* J�s3UU�LA�2�9l��@��s��$�L�[�6�<�fG��}��c'Nӄ��+����6�j��{��7��`Y�]��� 0��P����IEND�B`�
GIF89a��������ݻ������!� NETSCAPE2.0!�,||�H���0�*�8�ͻ_���dibax�l���+�.\�x>ڗ��pHT��G`0I�� �a2KϏTJ�X��lg��j�ם J��3�G�isߓ��C���xzMskS���0��pz�)�v��q}��������y�������/����_������`� ����(�����h�Ǥ�ʨ�A��ѽ{�
������ ��˷�ȗx�+��7�ln��'�+�Zd:�hb�?v��pȐ���Ɣ����f2,e��bņU��(����� ���h!ʔ*��l��%�� f�a�fL��X��ghGC� 3�#�;^L�8u4�P�,�����K�Y��ѥ;q�]˶�۷p�ʝK��ݻx�B4��_a' ���h���qV��#��*�Me���9fY��ϠC�M���ӨS��A�r�Se1�~s8P�$&a�2��Uu��wn��]�Qq�:1?O�Xzt���6�s]����%�v�Z|v��̸�Rz���kd��y��G�/��~�����_I�aWt>P�3��gۀ�-� ��Aha|�Q�!�~a�!��5��䀈�%&Ƞ�������!�1J�����b���x����أ���#�+)��#2y$�ƥ5�x~�H��`��"[ �4�a��RNY&�X�x�:Nv���Tr�&of&�q�(�s�9�Q�}�iu�Vhj����i��֨�{��'��$!�,
W0�H���0�@��8�=+�`(J�7�(WVi�v�+��7�gm�<��#�P��H@k8DG�$����N���=CYi�+�^Ea�����Ai��-�n������.{!vx/�*o����xy�d�~��3{|��8����t����<�$����� ����
�@
�0%�=��� ���������������K�G� ��z�2����c\3� ���m�Y��se<Z�� P�/�� 2C�N!���HMb�-����"Î � �o�Ć&IZK�!!�,W0�H���KH��8�6��`�u�h�"�l[��+�L��i�|����p���@k8DE�$�����Q���4=AYm�+�^�a��}5i�:��K�Ͼ�+�tn|px.lDo~3��#����z�����~4�����9�������� �<�������/� �@ ��
�@��*��Ʈ�$ſ�%�a.��(�!��݁2� ���,����U8�"���9Q&�������C�@�8 �C�C�:� ��HC�D�3,j�X�"Lj
?�)r����L��D!�,<BB�H4<�0�I�����{͙'���hj2i;��+o�l�G�+�ݣ���\�x�I̦�)�JoԎ�j�r�A��F&MЭy\)��Z7�=���p�[�Cxv| ~Q��}dj�
t
z���u������!���1��.�;�(��:����7�"���L)���\���������ȷ�̱�в�ԭ��ب��������������������������������4&����*4�i�Á�J�p�Ä�(PA!�,N
0W�H����I+���}q���}a)�����Z����� �捇p�s��((��r�\V�NF/�Q'�kz�`��� ��͚y]Ũ����������;�~H�p|�fQ���`����Z�Z
�� �� ���g������������*������5����.�������&���û�Ʒ�ɲ���������2���ܢ��ڝ����������Z�������������W�����ؕK���s��QH!�,N0W�H���n���mN�;Ѡ'F`8�ez���b��V�<��vӹ��=�/� ��#1�D���R��L֫0��z��xL.��\�z�n�۳�|�^���~��z�{v�tq�oh���������
�f��c���`�����]�����\�������������Y���/��������Ƨ���7���Х���;���bؾ��a��_�c���������^�����]�����`����#���) !�,<<BB�H���P�I��6���'r`��c�Y�Jl�<��y�����pH,�Ȥr�l:�ШtJX��u�m�خ�G�`�MV3�mw^���W�v��vVz�F�7D���xC��;t���@l����u���A\����O����L����M����K������#���"ƾ�ɽH�(����͜J���G���Ե/�E����������B�)�A���D����.���vLb�J��|v�Q膡� |kb�!�,NW0�H���0�7�8�͉�](��g^d�J����׺qέ�kx���� Hti���,.-M�N5�,�'�
FO�V��z���x\3�IB�:�vwU8ɜ���H{t�~w+L�[�����Q������E����~I������������@����?�����;����5����0�›ʳ�͑���+����)���ܿ*���"��!�����X�"������"�B� �O�okR4���F���l�( /�ȨQǎ5>��!r�j&��K� !�,
NW0�H���I��8�ȵ��ǍRh�!9�lK��+��:�`m�<�ǽ����q��,�M�ڜR���6 x�dv��}�>�LƝϗZ��u��i%�^���qN.|e�xV�\�����V������K����O������������F����B�����A����8����3�›ʳ�͑��у���{�ڷ �c|!�ܿ������&� ��� �������&��o��cW�D=~mP��I`!�� jDmE+ /
ɨ�ǎ8>��!r���&�<�!�,<BB�H���I�����]��Ս\h�d*����@+O�:��x�����pH,�Ȥr�l:�ШtJ=��� �՚��7�/��.� m�:�>���;�����|��w;�Fz���Et?��DmA���x@���WC�� �R�����P����O�!��N����M�����'��K���L�DZJ�º��,���˶I�׫H���Fީ�G�������;�E�7�D�3���@��?�o& H``@�o�Qx�aCt10K!�,0W�H� ,�Ik{��M����a)�����Z������Ѥ}�.��v�E����4
�{�_&��z��xL.�ϡ�z�n�۶�|�v��s~7��z�{v�tq�oh���������h�f��c���`��_��]��Y��V��S�������������\�2��.���6���>��ͱ:��ҷB��b��a��`�������c��������������������������wf��!� ,||�H���0�I��8�ͻ�`(�di�h��l�p,�t
�@��8���^H�}�$�T:��sJ��X+���N�^��N���1�]���t;<�i�ή���3|��!���� �� ��s��������G���C�����&�������$���#�������"���!����ǹ��ˤͽ��·�������������������������������������������L'����*\Ȱ�ÇhHq�ċ/j��pP�F�7* �!ɒO�4��#˖M”�r&Ǘ0�\���I�$+��H#ѣH�*]ʴ�ӧP�J�J��իX�j�ʵ�ׯ`�I;
GIF89a��������ݻ������!� NETSCAPE2.0!�,||�H���0�*�8�ͻ_���dibax�l���+�.\�x>ڗ��pHT��G`0I�� �a2KϏTJ�X��lg��j�ם J��3�G�isߓ��C���xzMskS���0��pz�)�v��q}��������y�������/����_������`� ����(�����h�Ǥ�ʨ�A��ѽ{�
������ ��˷�ȗx�+��7�ln��'�+�Zd:�hb�?v��pȐ���Ɣ����f2,e��bņU��(����� ���h!ʔ*��l��%�� f�a�fL��X��ghGC� 3�#�;^L�8u4�P�,�����K�Y��ѥ;q�]˶�۷p�ʝK��ݻx�B4��_a' ���h���qV��#��*�Me���9fY��ϠC�M���ӨS��A�r�Se1�~s8P�$&a�2��Uu��wn��]�Qq�:1?O�Xzt���6�s]����%�v�Z|v��̸�Rz���kd��y��G�/��~�����_I�aWt>P�3��gۀ�-� ��Aha|�Q�!�~a�!��5��䀈�%&Ƞ�������!�1J�����b���x����أ���#�+)��#2y$�ƥ5�x~�H��`��"[ �4�a��RNY&�X�x�:Nv���Tr�&of&�q�(�s�9�Q�}�iu�Vhj����i��֨�{��'��$!�,
W0�H���0�@��8�=+�`(J�7�(WVi�v�+��7�gm�<��#�P��H@k8DG�$����N���=CYi�+�^Ea�����Ai��-�n������.{!vx/�*o����xy�d�~��3{|��8����t����<�$����� ����
�@
�0%�=��� ���������������K�G� ��z�2����c\3� ���m�Y��se<Z�� P�/�� 2C�N!���HMb�-����"Î � �o�Ć&IZK�!!�,W0�H���KH��8�6��`�u�h�"�l[��+�L��i�|����p���@k8DE�$�����Q���4=AYm�+�^�a��}5i�:��K�Ͼ�+�tn|px.lDo~3��#����z�����~4�����9�������� �<�������/� �@ ��
�@��*��Ʈ�$ſ�%�a.��(�!��݁2� ���,����U8�"���9Q&�������C�@�8 �C�C�:� ��HC�D�3,j�X�"Lj
?�)r����L��D!�,<BB�H4<�0�I�����{͙'���hj2i;��+o�l�G�+�ݣ���\�x�I̦�)�JoԎ�j�r�A��F&MЭy\)��Z7�=���p�[�Cxv| ~Q��}dj�
t
z���u������!���1��.�;�(��:����7�"���L)���\���������ȷ�̱�в�ԭ��ب��������������������������������4&����*4�i�Á�J�p�Ä�(PA!�,N
0W�H����I+���}q���}a)�����Z����� �捇p�s��((��r�\V�NF/�Q'�kz�`��� ��͚y]Ũ����������;�~H�p|�fQ���`����Z�Z
�� �� ���g������������*������5����.�������&���û�Ʒ�ɲ���������2���ܢ��ڝ����������Z�������������W�����ؕK���s��QH!�,N0W�H���n���mN�;Ѡ'F`8�ez���b��V�<��vӹ��=�/� ��#1�D���R��L֫0��z��xL.��\�z�n�۳�|�^���~��z�{v�tq�oh���������
�f��c���`�����]�����\�������������Y���/��������Ƨ���7���Х���;���bؾ��a��_�c���������^�����]�����`����#���) !�,<<BB�H���P�I��6���'r`��c�Y�Jl�<��y�����pH,�Ȥr�l:�ШtJX��u�m�خ�G�`�MV3�mw^���W�v��vVz�F�7D���xC��;t���@l����u���A\����O����L����M����K������#���"ƾ�ɽH�(����͜J���G���Ե/�E����������B�)�A���D����.���vLb�J��|v�Q膡� |kb�!�,NW0�H���0�7�8�͉�](��g^d�J����׺qέ�kx���� Hti���,.-M�N5�,�'�
FO�V��z���x\3�IB�:�vwU8ɜ���H{t�~w+L�[�����Q������E����~I������������@����?�����;����5����0�›ʳ�͑���+����)���ܿ*���"��!�����X�"������"�B� �O�okR4���F���l�( /�ȨQǎ5>��!r�j&��K� !�,
NW0�H���I��8�ȵ��ǍRh�!9�lK��+��:�`m�<�ǽ����q��,�M�ڜR���6 x�dv��}�>�LƝϗZ��u��i%�^���qN.|e�xV�\�����V������K����O������������F����B�����A����8����3�›ʳ�͑��у���{�ڷ �c|!�ܿ������&� ��� �������&��o��cW�D=~mP��I`!�� jDmE+ /
ɨ�ǎ8>��!r���&�<�!�,<BB�H���I�����]��Ս\h�d*����@+O�:��x�����pH,�Ȥr�l:�ШtJ=��� �՚��7�/��.� m�:�>���;�����|��w;�Fz���Et?��DmA���x@���WC�� �R�����P����O�!��N����M�����'��K���L�DZJ�º��,���˶I�׫H���Fީ�G�������;�E�7�D�3���@��?�o& H``@�o�Qx�aCt10K!�,0W�H� ,�Ik{��M����a)�����Z������Ѥ}�.��v�E����4
�{�_&��z��xL.�ϡ�z�n�۶�|�v��s~7��z�{v�tq�oh���������h�f��c���`��_��]��Y��V��S�������������\�2��.���6���>��ͱ:��ҷB��b��a��`�������c��������������������������wf��!� ,||�H���0�I��8�ͻ�`(�di�h��l�p,�t
�@��8���^H�}�$�T:��sJ��X+���N�^��N���1�]���t;<�i�ή���3|��!���� �� ��s��������G���C�����&�������$���#�������"���!����ǹ��ˤͽ��·�������������������������������������������L'����*\Ȱ�ÇhHq�ċ/j��pP�F�7* �!ɒO�4��#˖M”�r&Ǘ0�\���I�$+��H#ѣH�*]ʴ�ӧP�J�J��իX�j�ʵ�ׯ`�I;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ExtJS 3.X Demo : Flickr REST Photo Viewer</title>
<link href="css/app.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="js/ext/resources/css/ext-all.css" />
<!--
<script type="text/javascript" src="./js/ext/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="./js/ext/ext-all-debug.js"></script>
!-->
<script type="text/javascript">
as = {
util : {
Loader : {
files : [
'./js/as/base/data/BaseJsonReader.js',
'./js/as/base/data/BaseJsonStore.js',
'./js/as/base/flickr/FlickrProxy.js',
'./js/as/base/flickr/FlickrPhotoReader.js',
'./js/as/base/flickr/FlickrWindow.js',
'./js/as/base/list/BaseListItemTpl.js',
'./js/as/base/list/BaseListView.js',
'./js/as/base/data/BaseJsonStore.js',
'./js/as/base/Controller.js',
'./js/as/base/IconButton.js',
'./js/as/app/controller/FrontController.js',
'./js/as/app/controller/AppController.js',
'./js/as/app/model/AppModel.js',
'./js/as/app/view/AppView.js',
'./js/as/app/view/AppCardPanel.js',
'./js/as/app/view/AppList.js'
// ,'./js/as/app/view/AppLogPanel.js'
,'./js/as/app/view/AppFooterView.js'
,'./js/as/app/view/flickr/FlickrDataView.js'
,'./js/as/app/model/FlickrModel.js'
,'./js/as/app/view/flickr/FlickrPanel.js'
,'./js/as/app/view/flickr/FlickrDataViewTpl.js'
,'./js/as/app/view/topbar/AppTopbarView.js'
],
count : 0,
onExtReady : function(){
// console.warn("%s.go",this,arguments,Ext);
var files, base;
base = "./js/";
files = this.files;
Ext.Loader.load(files,this.onLoadComplete,this,true);
},
onLoadComplete : function(){
// console.info("%s.onLoadComplete",window,arguments);
this.count++;
// if(this.files.length==this.count){
window.App = new as.app.controller.FrontController();
window.App.initialize();
//}
}
}
}
}
</script>
<script type="text/javascript" src="./js/build/ext.js"></script>
<link href="css/base.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="loading">
<div class="loading-indicator">
<img src="images/widgets/loader_main.gif" alt="loader" width="124" height="124" />
<br /><span id="loading-msg">Loading Ext JS Framework...</span></div>
</div>
</body>
</html>
Ext.ns('as.app.controller');
as.app.controller.AppController = function(){};
as.app.controller.AppController = Ext.extend(as.base.Controller,{
constructor : function(cfg){
cfg = cfg || {};
var _model = new as.app.model.AppModel({
front : cfg.front,
ctrl : this
})
var _view = new as.app.view.AppView({
model : _model
})
this.model = _model;
this.view = _view;
_view.on({
scope : this,
action: this.onAction
})
as.app.controller.AppController.superclass.constructor.call(this,cfg);
},
onAction : function(){
// console.warn("%s.function",this,arguments);
}
})
Ext.ns('as.app.controller.FrontController');
as.app.controller.FrontController = function(){
var _controllers = {};
/**
* @namespace as.app.controller.FrontController
* @scope App
* @param {Object} front Front Controller.
* @type Void
*/
var _initControllers = function _initControllers(front) {
_controllers.app = new as.app.controller.AppController({
front:front
});
return _controllers;
}
/**
* @function
* @private
* @return The controller map.
* @type Object
*/
var _getControllers = function _getControllers(){
return _controllers;
};
/**
* @namespace as.app.controller.FrontController
* @scope App
* @param {Object} front Front Controller.
* @type Void
*/
var _destroyControllers = function _destroyControllers(){
Ext.iterate(_controllers,function(key,ctrl){
ctrl.destroy();
},this);
_controllers = null;
}
/**
* @scope as.app.controller.FrontController#
*/
var FrontCtrlAjaxLst = function(scope){
var encodeData = function(data){
Ext.iterate(data,function(key,value,object){
if(Ext.isObject(value)){
value = this.encodeData(value);
}
},this);
};
return {
scope : this,
beforerequest : function(conn, opt){
if(this.shutingDown){
return false;
}
opt.url = opt.url || '../app/bridge.php';
opt.params = opt.params || {};
},
requestcomplete : function(conn, res, opt){
var json;
if(this.shutingDown){
return false;
}
if(this.initialized) this.getAjaxLoadMask().hide();
try {
json = Ext.decode(res.responseText);
res.json = json;
} catch (exception) {
json = false;
}
},
requestexception : function(){
if(console && console.error){
console.error("Server Error",arguments);
}
}
}
}
return {
_lst : {},
_msg : {
loaderTitle :'Initializing Application',
init :'Starting up internals...',
data :'Preloading external data...'
},
initDataTask : {},
initialized : false,
shutingDown : false,
getCtrl :function(name){
return _getControllers()['name']
},
initialize : function() {
this.shutingDown = false;
this.isDataInit = false;
// console.warn("%s.initialize: Init Application",this);
// control garbage
Ext.EventManager.addListener(window,'unload', this.hdlWindowUnload,this);
Ext.BLANK_IMAGE_URL = './js/ext/resources/images/default/s.gif';
Ext.QuickTips.init();
this._initAjax();
this._initControllers();
// Ext.MessageBox.progress(this._msg.init, this._msg.loaderTitle);
},
_initControllers : function(){
var ctrl = _initControllers(this);
Ext.iterate(_getControllers(),function(key,ctrl){
ctrl.initialize();
},this)
},
_initAjax : function(){
// console.info("%s.initAjax: install connection listeners",this);
this._lst.ajax = new FrontCtrlAjaxLst(this);
Ext.Ajax.on(this._lst.ajax);
},
hdlWindowUnload : function(){
// clean up code.
},
destroy :function(){}
}
}
Ext.ns('as.app.model');
(function(){
/**
* Features Ext.extend with private members by clouser passed as
* override object.
*
* @namespace as.app.model
*/
as.app.model.AppModel = function (){};
as.app.model.AppModel = Ext.extend( Ext.util.Observable,{
constructor : function (cfg){
this.front = cfg.front;
this.initialize(cfg);
as.app.model.AppModel.superclass.constructor.call(this,cfg);
},
initialize : function (cfg){
this.addEvents({
mainload : true,
flickrload : true
})
this.models = {};
this.models.flickr = new as.app.model.FlickrModel({
front : this.front
})
this.models.flickr.on({
scope : this,
load : function(ds,recs,opt){
var action = opt.action;
this.fireEvent('flickrload',this,action,recs)
}
})
}
});
})();
Ext.ns("as.app.model");
as.app.model.FlickrModel = function(cfg){
this.initialize();
as.app.model.FlickrModel.superclass.constructor.call(this,cfg);
}
as.app.model.FlickrModel = Ext.extend( Ext.util.Observable,{
constructor : as.app.model.FlickrModel,
initialize : function(){
this.store = new Ext.data.Store({
autoLoad : false,
proxy : new as.base.flickr.FlickrProxy({
url : 'http://api.flickr.com/services/feeds/photos_public.gne',
method : 'GET',
params : {
per_page: 4,
tags :'tree'
}
}),
reader: new as.base.flickr.FlickrPhotoReader()
});
this.addEvents({
load: true
})
this.relayEvents(this.store,['load']);
},
load : function(params,action){
action = action || 'recent';
params = params || {};
this.store.load({
action : action,
params : params
});
}
})
Ext.ns('as.app.view');
(function(){
/**
* @constructor
*/
as.app.view.AppCardPanel = function(cfg){
this.model = cfg.model;
as.app.view.AppCardPanel.superclass.constructor.call(this,cfg);
};
as.app.view.AppCardPanel = Ext.extend (
Ext.Panel, {
/**
* @ignore
*/
constructor : as.app.view.AppCardPanel,
/**
* @private
* @type Void
*/
initComponent : function() {
var defaults = {};
defaults = Ext.apply(defaults, {
layout : 'card',
minWidth :938,
defaults :{
model : this.model,
border : false,
bodyBorder : false
},
items :[{
ref : 'flickr',
xtype : 'app-flick-panel'
},{
xtype :'panel',
items :[{
xtype :'box',
autoEl :{
tag :'div',
cls :'loader'
}
}]
}]
});
Ext.apply(this,Ext.apply(this.initialConfig,defaults));
as.app.view.AppCardPanel.superclass.initComponent.apply(this,arguments);
},
////////////////////////////////////////////////////////////////////////
// custom event
onRender : function(){
as.app.view.AppCardPanel.superclass.onRender.apply(this,arguments);
this.flickr.model.on({
scope : this,
beforeload : function(){
this.layout.setActiveItem(1);
},
loadexception : function(){
this.layout.setActiveItem(0);
}
})
this.flickr.on({
scope : this,
load : function(){
this.layout.setActiveItem(0);
},
target : this.flickr.getComponent(0)
})
}
}
);
})();
Ext.reg('app-cardpanel',as.app.view.AppCardPanel);
Ext.ns('as.app.view');
(function(){
/**
* @constructor
*/
as.app.view.AppFooterView = function(cfg){
as.app.view.AppFooterView.superclass.constructor.call(this,cfg);
};
as.app.view.AppFooterView = Ext.extend (
Ext.BoxComponent, {
/**
* @ignore
*/
constructor : as.app.view.AppFooterView,
/**
* @private
* @type Void
*/
initComponent : function() {
var defaults = {};
defaults = Ext.apply(defaults, {
cls : 'app-footer',
unstyled: true,
data : {
info:"Demo Information",
desc:"The application allows user to search the Flickr Public Photo feeds.",
text:"Key Features: MVC, ExtJS, AJAX, JSONP, Web Service.<br />"
+"Technics Lazy Instantiation, Custom Events,"
+"OOP, CSS3, XTemplate, Ext Theming, Cross-site Script (among others)"
},
tpl: new Ext.XTemplate(
'<div class="footer">',
'<h3>{title}</h3>',
'<p>{text}</p>',
'</div>'
)
});
Ext.apply(this,Ext.apply(this.initialConfig,defaults));
as.app.view.AppFooterView.superclass.initComponent.apply(this,arguments);
}
}
);
})();
Ext.reg('app-infofooter',as.app.view.AppFooterView);
Ext.ns('as.app.view');
(function(){
/**
* @constructor
*/
as.app.view.AppListPanel = function(cfg){
this.model = cfg.model;
as.app.view.AppListPanel.superclass.constructor.call(this,cfg);
};
as.app.view.AppListPanel = Ext.extend (
Ext.grid.GridPanel, {
/**
* @ignore
*/
constructor : as.app.view.AppListPanel,
/**
* @private
* @type Void
*/
initComponent : function() {
var myData = [
['> Tags','noaction',''],
['Recent','recent',''],
['Trees','tag','tree'],
['Custom','custom','']
];
var store = new Ext.data.Store({
autoLoad : true,
proxy : new Ext.data.MemoryProxy(myData),
reader : new Ext.data.ArrayReader({}, [
{name: 'title'},
{name: 'action'},
{name: 'tags'}
])
});
var defaults = {};
defaults = Ext.apply(defaults, {
cls : 'app-list',
store : store,
colModel : new Ext.grid.ColumnModel({
defaults : {
width : 120,
sortable : true
},
columns: [
{
id : 'list-title',
header : false,
width : 200,
sortable : true,
dataIndex : 'title'
},
{header: 'tags',dataIndex:'tags',hidden:true}
]
}),
viewConfig : {
forceFit : false ,
showPreview : true, // custom property
enableRowBody : true, // required to create a second, full-width row to show expanded Record data
getRowClass : function(record, rowIndex, rp, ds){ // rp = rowParams
if(rowIndex==0){
return 'x-grid3-row-nostyle';
}
return 'x-grid3-row-styled';
}
},
bubbleEvents :['loadflickr']
});
Ext.apply(this,Ext.apply(this.initialConfig,defaults));
as.app.view.AppListPanel.superclass.initComponent.apply(this,arguments);
this.addEvents({
/**
* @event
* @param {AppListPanel} view
* @param {string} action
* @param {string} tagas
*/
loadflickr : true
});
this.getSelectionModel().on({
scope : this,
rowselect : function(sm,i,rec){
// console.warn("%s.select",this,arguments);
if(rec.get('action')!='custom'){
this.fireEvent('loadflickr',this,rec.get('action'),rec.get('tags'))
}
},
beforerowselect :function(sm,i,keep,rec){
if(i==0) return false;
}
})
},
////////////////////////////////////////////////////////////////////////
// custom event
onRender : function(){
as.app.view.AppListPanel.superclass.onRender.apply(this,arguments);
this.addListener('viewready',function(){
this.getSelectionModel().selectRow(1);
this.model.on({
scope : this,
flickrload : function(model,action,recs){
// console.warn("%s. handle flickr load in list",this,arguments);
if(action=='custom'){
this.getSelectionModel().selectRow(3);
}
}
})
},this);
}
}
);
Ext.reg('app-listgrid',as.app.view.AppListPanel);
})();
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
Ext.ns('as.app.view');
(function(){
as.app.view.AppView = Ext.extend(Ext.Viewport,{
constructor :function(cfg){
cfg = cfg || {};
this.addEvents({
/**
* @event
* @param {Type} param1 Parameter
*/
action : true,
/**
* @event
* @param {AppView} view
* @param {string} action Type of search
* @param {string} tags Tag list string.
*/
loadflickr : true
});
this.model = cfg.model;
as.app.view.AppView.superclass.constructor.call(this,cfg);
},
initEvents :function(){
var model_lst = (function(model){
return {
scope : model,
loadflickr : function(view,action,tags){
var params = Ext.apply({},{
tags : tags
})
model.models.flickr.load(params,action);
}
}
})(this.model);
this.on(model_lst);
},
initComponent :function(){
var defaults = {};
defaults = Ext.apply(defaults, {
//renderTo: Ext.getBody(),
layout : 'border',
minWidth : 1136,
defaults : {
model : this.model,
border : false,
bodyBorder : false
},
items:[{
region : 'north',
xtype : 'app-topbarview'
},{
model : this.model,
width : 220,
region :'west',
xtype :'app-listgrid'
},{
minSize :938,
activeItem : 0,
xtype : 'app-cardpanel',
region : 'center'
},{
xtype : 'app-infofooter',
region : 'south',
height : 80
}
]
});
Ext.apply(this,Ext.apply(this.initialConfig,defaults));
as.app.view.AppView.superclass.initComponent.apply(this,arguments);
this.initEvents();
},
onRender :function(){
Ext.get('loading').remove();
as.app.view.AppView.superclass.onRender.apply(this,arguments);
this.fireEvent('loadflickr',this,'recent','');
}
});
})();
Ext.ns('as.app.view.flickr.FlickrListView');
(function(){
/**
* @constructor
*/
as.app.view.flickr.FlickrListView = function(cfg){
as.app.view.flickr.FlickrListView.superclass.constructor.call(this,cfg);
};
as.app.view.flickr.FlickrListView = Ext.extend (
as.base.list.BaseListView, {
/**
* @ignore
*/
constructor : as.app.view.flickr.FlickrListView,
/**
* @private
* @type Void
*/
initComponent : function() {
var defaults = {};
defaults = Ext.apply(defaults, {
overClass : 'flickr-item-over',
selectedClass : 'flickr-item-selected',
trackOver:true
});
Ext.apply(this,Ext.apply(this.initialConfig,defaults));
as.app.view.flickr.FlickrListView.superclass.initComponent.apply(this,arguments);
},
////////////////////////////////////////////////////////////////////////
// custom event
onRender : function(ct){
as.app.view.flickr.FlickrListView.superclass.onRender.apply(this,arguments);
this.loadMask = new Ext.LoadMask(ct,{msg:"Loading.."});
this.loadMask._onLoad = this.loadMask.onLoad;
this.loadMask.onLoad = Ext.emptyFn;
this.on({
scope : this,
click : this.handleClick,
mouseenter : this.onMouseEnter,
mouseleave : this.onMouseLeave,
selectionchange : function(){
// console.warn('selection change',arguments);
},
load :function(){
// console.clear();
this.imageCount--;
// console.warn("%s.l",this,this.imageCount);
if(this.imageCount==0) this.loadMask._onLoad()
}
// beforedestroy : this.hdlBeforeDestroy
});
},
refresh : function(){
as.app.view.flickr.FlickrListView.superclass.refresh.call(this);
this.itemOver = new Ext.Element(Ext.getBody().select('div.item-over').elements[0]);
var img = this.el.select('img');
this.imageCount = img.getCount();
img.each(function(el){
this.relayEvents(el,['load']);
},this);
this.loadMask.show();
},
handleClick : function(dv,index,node,e){
this.select(node);
},
onMouseEnter: function(dv, index, node, e){
var el = Ext.fly(node);
var xy = el.getXY();
xy[0] += 10;
xy[1] += 16;
this.itemOver.setXY(xy).show();
},
onMouseLeave: function(dv, index, node, e){
this.itemOver.hide();
}
}
);
})();
Ext.reg('app-flickrlistview',as.app.view.flickr.FlickrListView);
Ext.ns('as.app.view.flickr');
as.app.view.flickr.FlickrDataViewTpl = new Ext.XTemplate(
'<tpl if="this.test(values)">',
'<div class="item" id="item_{#}">',
'<div class="thumb-wrap" alt="project image" >',
'<div class="thumb" style="float:left">',
'<img width="224" height="143" src="{[this.getSrc(values)]}" title="{title}"/>',
'</div>',
'</div>',
'<h3 class="title">{[this.renderTitle(values)]}</h3>',
'<div class="x-clear"></div>',
'</div>',
'</tpl>',{
compiled : true,
renderTitle : function(values){
var frm = Ext.util.Format;
var title = frm.ellipsis(values.title,40,false);
return frm.ellipsis(title, 40, true);
},
getSrc : function(values){
return values.media.m;
},
test :function(){
return true;
}
})
Ext.ns('as.app.view.flickr');
as.app.view.flickr.FlickrPanel = function(cfg){
this.model = cfg.model;
as.app.view.flickr.FlickrPanel.superclass.constructor.call(this,cfg);
};
as.app.view.flickr.FlickrPanel = Ext.extend( Ext.Panel,{
constructor : as.app.view.flickr.FlickrPanel,
initComponent : function(){
var defaults = {};
defaults = Ext.apply(defaults, {
// title :'flick',
// anchor : "-2 -2",
autoScroll: true,
padding : "14px 0px 0px 0px",
defaults: {
model : this.model
},
items:[{
itemTemplate: as.app.view.flickr.FlickrDataViewTpl,
cls : 'flickrlist',
store : this.model.models.flickr.store,
xtype : 'app-flickrlistview'
}]
});
Ext.apply(this, Ext.apply(this.initialConfig,defaults));
as.app.view.flickr.FlickrPanel.superclass.initComponent.apply(this,arguments);
}
})
Ext.reg('app-flick-panel',as.app.view.flickr.FlickrPanel);
Ext.ns('as.app.view.topbar');
(function(){
/**
* @constructor
*/
as.app.view.topbar.AppTopbarView = function(cfg){
this.model = cfg.model;
as.app.view.topbar.AppTopbarView.superclass.constructor.call(this,cfg);
};
as.app.view.topbar.AppTopbarView = Ext.extend (
Ext.Panel, {
/**
* @ignore
*/
constructor : as.app.view.topbar.AppTopbarView,
/**
* @private
* @type Void
*/
initComponent : function() {
var defaults = {};
defaults = Ext.apply(defaults, {
id :'thetop',
cls :'app-topbar',
height : 120,
padding :'0px 40px',
layout :'hbox',
layoutConfig:{
pack : 'end',
align : 'middle',
defaultMargins :'10px'
},
defaults:{
xtype : 'button'
},
items:[{
xtype :'label',
cls : 'app-topbar-searchlabel',
text :'write your tags:'
},{
ref : 'tagField',
cls : 'app-searchfield',
width : 300,
fieldLabel : 'tags',
xtype : 'textfield',
listeners: {
scope : this,
specialkey : function(field, e){
if (e.getKey() == e.ENTER) {
var tags = field.getValue().trim().replace(' ',',');
if(tags.length>0){
this.searchBtn.disable();
this.fireEvent('loadflickr',this,'custom',tags);
}
}
}
}
},{
xtype :'app-iconbutton',
ref :'searchBtn',
disabled: true,
// id : 'SearchBN',
tooltip : 'Click Me',
scope : this,
handler : function() {
var tags = this.tagField.getValue().trim().replace(' ',',');
if(tags.length>0){
this.searchBtn.disable();
this.fireEvent('loadflickr',this,'custom',tags);
}
}
}]
});
Ext.apply(this,Ext.apply(this.initialConfig,defaults));
as.app.view.topbar.AppTopbarView.superclass.initComponent.apply(this,arguments);
this.enableBubble(['loadflickr']);
this.model.on({
scope : this,
flickrload : function(model,action,recs){
this.searchBtn.enable();
}
})
}
}
);
})();
Ext.reg('app-topbarview',as.app.view.topbar.AppTopbarView);
Ext.ns('as.base');
as.base.Controller = function(cfg){
cfg = cfg || {};
if(Ext.isDefined(cfg.front)){
// console.info("%s.front",this,arguments);
this.front = cfg.front;
}
/**
* @type Object
*/
this.listeners = cfg.listeners || {};
as.base.Controller.superclass.constructor.call(this,cfg);
/**
* @type Project.View.ProjectView
*/
this.view = cfg.view || this.view;
/**
* @type Project.Model.ProjectModel
*/
this.model = cfg.model || this.model;
// end fix
},
as.base.Controller = Ext.extend( Ext.util.Observable,{
constructor : as.base.Controller,
_className : '',
toString : function(){
var name = this._className || 'Ctrl';
return String.format('[{0}]',name);
},
initialize : function(){},
destroy : function(){
if(typeof(this.model.destroy)=='function') this.model.destroy();
if(typeof(this.view.destroy)=='function') this.view.destroy();
},
/**
* @method getView
* @return Project View object.
* @type Project.View.ProjectView
*/
getView : function (){
return this.view;
},
/**
* @type Project.Model.ProjectModel
*/
getModel : function (){
return this.model;
}
})
/**
* @namespace as.base.data.
*/
Ext.ns('as.base.data');
as.base.data.BaseJsonReader = Ext.extend(
Ext.data.JsonReader,{
constructor: function(meta,recordType){
// console.warn("base json reader",this);
meta = meta || {};
meta = Ext.apply( meta, {
idProperty : 'id',
successProperty : 'success',
totalProperty : 'total',
messageProperty : 'message',
root : 'data'
});
/*
if((recordType === undefined)&&(!meta.fields)){
meta.fields = [];
}*/
as.base.data.BaseJsonReader.superclass.constructor.call(this, meta,recordType || meta.fields);
}
});
Ext.reg('basejsonreader',as.base.data.BaseJsonReader);
Ext.ns('as.base.data.');
/**
* @constructor
*/
as.base.data.BaseJsonStore = function(cfg){
// this.addEvents({});
cfg = cfg || {};
// fixed
Ext.applyIf(cfg,{
url : '../app/bridge.php'
});
// defaults
Ext.applyIf(cfg,{
autoDestroy : true,
autoLoad : true,
baseParams : {},
fields : [
{name:'id',type:'int'}
]
});
Ext.applyIf(cfg.baseParams,{
action : 'ping',
data : {}
});
// configure reader
cfg = Ext.apply(cfg,{
idProperty : 'id',
root : 'data',
totalProperty : 'total'
});
cfg = Ext.apply(cfg,{
reader : new Ext.data.JsonReader(cfg)
});
cfg.listeners = cfg.listeners || {};
// console.info("%s.constructor: create",this,this.storeId);
as.base.data.BaseJsonStore.superclass.constructor.call(this, cfg);
this.on({
scope : this,
beforeload : function(){
if(App.shutingDown) {
// console.warn("%s. shuting down",this,arguments);
return false;
}
}
})
};
as.base.data.BaseJsonStore = Ext.extend(
Ext.data.Store, {
toString : function(){
return String.format('[{0}]',"as.base.data.BaseJsonStore");
},
constructor: as.base.data.BaseJsonStore
});
Ext.reg('basejsonstore',as.base.data.BaseJsonStore);
Ext.namespace('as.base.flickr');
/*
Creates a reader to grab photo data from as.base.flickr. Note that although
flickr only shows the response as XML, there are several response formats available.
The XML maps to JSON, eg:
<photos>
<photo id="1" />
<photo id="2" />
</photos>
Will be
{
photos:
{
photo: [{id: 1}, {id: 2}]
}
}
*/
as.base.flickr.FlickrPhotoReader = Ext.extend(Ext.data.JsonReader,
{
constructor: function()
{
this.rec = Ext.data.Record.create(
[
'title',
'author',
'author_id',
'owner',
'link',
'media',
'description',
'tags',
{ name: 'date_taken', type: 'date' },
{ name: 'published', type: 'date' },
// 'server',
// { name: 'farm', type: 'int' },
{ name: 'ispublic', type: 'boolean' },
{ name: 'isfriend', type: 'boolean' },
{ name: 'isfamily', type: 'boolean' }
]
);
as.base.flickr.FlickrPhotoReader.superclass.constructor.call(this,
{
totalProperty: false,// 'photos.total',
root: 'items',//'photos.photo',
id: 'title'
}, this.rec);
}
}
);
Ext.namespace('as.base.flickr');
/*
Utility class for connecting to flickr
*/
as.base.flickr.FlickrProxy = Ext.extend(Ext.data.ScriptTagProxy,
{
url : 'http://api.flickr.com/services/rest/',
method : null,
apiKey : null,
callbackParam: 'jsoncallback',
constructor: function(config)
{
as.base.flickr.FlickrProxy.superclass.constructor.call(this, config);
this.on('beforeload', this.onBeforeLoad, this);
},
onBeforeLoad: function(o, params)
{
Ext.apply(params,
{
format : 'json',
api_key: this.apiKey,
method : 'flickr.' + this.method
}
);
return true;
}
}
);
Ext.namespace('as.base.flickr');
as.base.flickr.FlickrWindow = Ext.extend(Ext.Window,
{
store: null,
resizable: false,
imageSize: 'm',
title: 'flickr Window',
initComponent: function()
{
Ext.QuickTips.init();
this.searchBox = new Ext.form.TextField(
{
defaultAutoCreate: { tag: "input", type: "text", size: "10", autocomplete: "off" },
value: 'nature',
enableKeyEvents: true,
listeners:
{
scope: this,
keypress: function(f, e) {
if (e.getKey() == e.RETURN) {
this.doSearch();
}
}
}
}
);
Ext.apply(this,
{
tbar:
[
{
iconCls: 'x-tbar-page-prev',
handler: this.onPreviousClick,
scope: this,
tooltip: { text: 'Go to the previous image' }
},
{
iconCls: 'x-tbar-page-next',
handler: this.onNextClick,
scope: this,
tooltip: { text: 'Go to the next image' }
},
'->',
{
iconCls: 'sizer',
tooltip: { text: 'Set the size of the images' },
menu:
{
items:
[
this.createSizeItem('Small', 's'),
this.createSizeItem('Thumb', 't'),
this.createSizeItem('Medium', 'm'),
this.createSizeItem('Big', 'b')
]
}
},
'-',
{
iconCls: 'view',
handler: this.onViewClick,
scope: this,
tooltip: { text: 'View this photo at the flickr site' }
}
],
bbar:
[
this.searchBox,
{
iconCls: 'find',
handler: this.doSearch,
scope: this,
tooltip: { text: 'Click to search for images' }
}
]
}
);
as.base.flickr.FlickrWindow.superclass.initComponent.call(this);
this.store.on('beforeload', this.onBeforeLoad, this);
this.store.on('load', this.onLoad, this);
this.active = 0;
},
createSizeItem: function(label, code)
{
return {
text: label,
group: 'imageSize',
checked: this.imageSize == code,
handler: this.setImageSize.createDelegate(this, [code], false)
};
},
afterRender: function()
{
as.base.flickr.FlickrWindow.superclass.afterRender.call(this);
//hide the image initially
this.img = Ext.DomHelper.append(this.body, { tag: 'img', alt: '', src: '', cls: 'x-hide-display' }, true);
this.img.on('load', this.onImageLoad, this);
this.doSearch();
},
doSearch: function()
{
var text = this.searchBox.getValue().trim();
if (text.length > 0)
{
text = text.replace(/ /g, ',');
this.store.load(
{
params: { tags: text }
}
);
}
},
onViewClick: function()
{
window.open(this.viewUrl);
},
onPreviousClick: function()
{
if (this.active == 0)
this.active = this.store.getCount() - 1
else
--this.active;
this.setImage();
},
onNextClick: function()
{
if (this.active == this.store.getCount() - 1)
this.active = 0;
else
++this.active;
this.setImage();
},
onBeforeLoad: function()
{
if (!this.masked)
{
this.body.mask('Loading', 'x-mask-loading');
this.getTopToolbar().disable();
this.masked = true;
}
},
onLoad: function()
{
this.active = 0;
this.setImage();
},
onImageLoad: function()
{
this.body.unmask();
this.getTopToolbar().enable();
this.masked = false;
var title = this.img.dom.alt;
if (title == '')
title = 'Untitled';
this.setTitle(Ext.util.Format.ellipsis(this.img.dom.alt, this.getTextSize()));
this.img.removeClass('x-hide-display');
var sz = this.img.getSize();
if (sz.width < 110)
sz.width = 110;
this.body.setSize(sz);
this.syncSize();
this.setWidth(sz.width + 14);
this.img.fadeIn({ duration: 1 });
},
getTextSize: function()
{
switch (this.imageSize)
{
case 's': return 10;
case 't': return 12;
case 'm': return 25;
default: return 40;
}
},
setImage: function()
{
this.onBeforeLoad();
var rec = this.store.getAt(this.active);
this.constructUrl(rec);
this.img.dom.alt = rec.get('title');
this.img.dom.src = this.imageUrl;
},
constructUrl: function(rec)
{
//construct the URL for the photo as per: http://www.flickr.com/services/api/misc.urls.html
this.imageUrl = String.format('http://farm{0}.static.flickr.com/{1}/{2}_{3}_{4}.jpg', rec.get('farm'), rec.get('server'), rec.get('id'), rec.get('secret'), this.imageSize);
this.viewUrl = String.format('http://www.flickr.com/photos/{0}/{1}', rec.get('owner'), rec.get('id'));
},
setImageSize: function(sz)
{
var prev = this.imageSize;
this.imageSize = sz;
if (sz != prev)
this.setImage();
}
}
);
Ext.ns('as.base');
as.base.IconButton = function(cfg){
as.base.IconButton.superclass.constructor.call(this,cfg);
};
as.base.IconButton = Ext.extend(Ext.Button, {
constructor :as.base.IconButton,
buttonSelector : 'button',
template: new Ext.Template(
'<div class="main-nav-button">',
'<div class="main-nav-icon">'
,'</div><div class="main-nav-button-overlay"></div><button></button></div>'),
iconCls:'contacts_large',
scale:'medium',
/*
tooltip:'xxxxxx',
menu:[{
text:'xxx'
},{
text:'xxx'
}],*/
menuAlign:'tr',
onRender: function(ct, position){
as.base.IconButton.superclass.onRender.call(this,ct, position);
this.addListener('afterrender',function(){
},this,{single:true})
},
initButtonEl : function(btn, btnEl){
this.btnEl = btn.child(this.buttonSelector);
this.iconEl = btn.child("div.main-nav-icon");
as.base.IconButton.superclass.initButtonEl.apply(this,arguments);
},
setIconClass : function(cls){
this.iconCls = cls;
if(this.el){
this.iconEl.dom.className = "";
this.iconEl.addClass(['main-nav-icon', cls || '']);
}
return this;
}
})
Ext.reg('app-iconbutton',as.base.IconButton);
Ext.ns('as.base.list');
as.base.list.BaseListItemTpl = new Ext.XTemplate(
'<tpl if="this.test(values)">',
'<div class="item" id="item_{#}">',
'<h3 class="title">{title}</h3>',
'<div class="thumb-wrap" alt="project image" >',
'<div class="thumb" style="float:left">',
'<img width="224" height="143" src="{link}" title="{title}"/>',
'</div>',
'</div>',
'<div class="x-clear"></div>',
'</div>',
'</tpl>',
{
compiled:true,
test : function(){
//console.warn("%s.test values",this,arguments);
return true;
}
})
Ext.ns('as.base.list');
as.base.list.BaseListView = function(cfg){
this.model = cfg.model;
this._components = new Ext.util.MixedCollection();
as.base.list.BaseListView.superclass.constructor.call(this,cfg);
this.initialize();
};
as.base.list.BaseListView = Ext.extend (
Ext.DataView, {
_className : 'BaseListView',
autoDestroy : false,
autoScroll : false,
highlited : undefined,
_hlStartColor : 'ffffff',
_hlEndColor : 'f1f2fa',
hlStartColor : '5e7184',
hlEndColor : '869cb4',
toString : function(){
return String.format("[BaseListView {0}]",this.id);
},
constructor : as.base.list.BaseListView,
initialize : function(cfg){
},
itemTemplate : undefined,
initTemplates : function(){
var emptyTpl = new Ext.XTemplate(
'<div class="project">',
'<div class="noresult">',
'<h3>List Title</h3>',
'<p>No results</p>',
'</div>',
'<div id="cisco"></div>',
'</div>'
,{
compiled:true
});
this.emptyTpl = emptyTpl;
var propertyTpl = new Ext.XTemplate(
'<div class="project-property">',
'<span class="pname">{property}:</span><span>{value}</span>',
'</div>'
);
propertyTpl.compile();
this.itemTemplate = new Ext.XTemplate(
'<div class="item-over" ></div>',
'<div class="dataview-list">',
// '<h2 class="title txt-decorated icon-circle">Results</h2>',
'<div class="items">',
'<tpl for=".">',
'{[this.renderItem(values)]}',
'</tpl>',
'<div class="x-clear"></div>',
'</div>',
'</div>'
,{
compiled : true,
itemTpl : this.itemTemplate,
renderItem:function(values){
// return as.base.list.BaseListItemTpl.apply(values);
return this.itemTpl.apply(values);
},
test : function(){
// console.info(this,arguments);
return true;
}
});
this.itemTemplate.compile();
},
initComponent : function(){
if(!this.model){
throw ('BaseListView: no model');
}
this.initTemplates();
var defaults = {};
defaults = Ext.apply(defaults, {
//bodyStyle :'project-cardpanel',
// id:'projectListPanel',
// autoScroll : true,
anchor : "-2 -2",
store : this.store || this.model,
tpl : this.itemTemplate,
// multiSelect : false,
singleSelect: true,
trackOver : true,
overClass :'x-view-over',
itemSelector:'.item',
emptyText : this.emptyTpl.apply()
// events
//*
,
bubbleEvents:['click','activate']
//,stateEvents :['click']
// */
});
defaults.itemTemplate = defaults.itemTemplate || as.base.list.BaseListItemTpl;
Ext.apply(this, Ext.apply(this.initialConfig,defaults));
as.base.list.BaseListView.superclass.initComponent.apply(this,arguments);
},
onRender : function(ct){
as.base.list.BaseListView.superclass.onRender.apply(this,arguments);
},
onUpdate : function(){
as.base.list.BaseListView.superclass.onUpdate.apply(this,arguments);
this.addDeleteButton();
this.itemOver = $$('.item-over');
this.selectRange(0, 0);
},
refresh :function(){
as.base.list.BaseListView.superclass.refresh.call(this,arguments);
},
handleClick : function(dv,index,node,e){
var selectedEl,selectedProject;
this.select(node);
},
/**
* Abstract method.
* @method
* @param {Ext.DataView} dv
* @param {Number} index The index of the target node
* @param {HTMLElement} node The target node
* @param {Ext.EventObject} e The raw event object
* @return Void
*/
onMouseEnter: function(dv, index, node, e){},
/**
* Abstract method.
* @method onMouseLeave
* @param {Ext.DataView} dv Dataview
* @param {Number} index The index of the target node
* @param {HTMLElement} node The target node
* @param {Ext.EventObject} e The raw event object
* @type Void
*/
onMouseLeave: function(dv, index, node, e){}
});
Ext.reg('app-baselist',as.base.list.BaseListView);
This file has been truncated, but you can view the full file.
/*!
* Ext JS Library 3.4.0
* Copyright(c) 2006-2011 Sencha Inc.
* [email protected]
* http://www.sencha.com/license
*/
// for old browsers
window.undefined = window.undefined;
/**
* @class Ext
* Ext core utilities and functions.
* @singleton
*/
Ext = {
/**
* The version of the framework
* @type String
*/
version : '3.4.0',
versionDetail : {
major : 3,
minor : 4,
patch : 0
}
};
/**
* Copies all the properties of config to obj.
* @param {Object} obj The receiver of the properties
* @param {Object} config The source of the properties
* @param {Object} defaults A different object that will also be applied for default values
* @return {Object} returns obj
* @member Ext apply
*/
Ext.apply = function(o, c, defaults){
// no "this" reference for friendly out of scope calls
if(defaults){
Ext.apply(o, defaults);
}
if(o && c && typeof c == 'object'){
for(var p in c){
o[p] = c[p];
}
}
return o;
};
(function(){
var idSeed = 0,
toString = Object.prototype.toString,
ua = navigator.userAgent.toLowerCase(),
check = function(r){
return r.test(ua);
},
DOC = document,
docMode = DOC.documentMode,
isStrict = DOC.compatMode == "CSS1Compat",
isOpera = check(/opera/),
isChrome = check(/\bchrome\b/),
isWebKit = check(/webkit/),
isSafari = !isChrome && check(/safari/),
isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2
isSafari3 = isSafari && check(/version\/3/),
isSafari4 = isSafari && check(/version\/4/),
isIE = !isOpera && check(/msie/),
isIE7 = isIE && (check(/msie 7/) || docMode == 7),
isIE8 = isIE && (check(/msie 8/) && docMode != 7),
isIE9 = isIE && check(/msie 9/),
isIE6 = isIE && !isIE7 && !isIE8 && !isIE9,
isGecko = !isWebKit && check(/gecko/),
isGecko2 = isGecko && check(/rv:1\.8/),
isGecko3 = isGecko && check(/rv:1\.9/),
isBorderBox = isIE && !isStrict,
isWindows = check(/windows|win32/),
isMac = check(/macintosh|mac os x/),
isAir = check(/adobeair/),
isLinux = check(/linux/),
isSecure = /^https/i.test(window.location.protocol);
// remove css image flicker
if(isIE6){
try{
DOC.execCommand("BackgroundImageCache", false, true);
}catch(e){}
}
Ext.apply(Ext, {
/**
* URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent
* the IE insecure content warning (<tt>'about:blank'</tt>, except for IE in secure mode, which is <tt>'javascript:""'</tt>).
* @type String
*/
SSL_SECURE_URL : isSecure && isIE ? 'javascript:""' : 'about:blank',
/**
* True if the browser is in strict (standards-compliant) mode, as opposed to quirks mode
* @type Boolean
*/
isStrict : isStrict,
/**
* True if the page is running over SSL
* @type Boolean
*/
isSecure : isSecure,
/**
* True when the document is fully initialized and ready for action
* @type Boolean
*/
isReady : false,
/**
* True if the {@link Ext.Fx} Class is available
* @type Boolean
* @property enableFx
*/
/**
* HIGHLY EXPERIMENTAL
* True to force css based border-box model override and turning off javascript based adjustments. This is a
* runtime configuration and must be set before onReady.
* @type Boolean
*/
enableForcedBoxModel : false,
/**
* True to automatically uncache orphaned Ext.Elements periodically (defaults to true)
* @type Boolean
*/
enableGarbageCollector : true,
/**
* True to automatically purge event listeners during garbageCollection (defaults to false).
* @type Boolean
*/
enableListenerCollection : false,
/**
* EXPERIMENTAL - True to cascade listener removal to child elements when an element is removed.
* Currently not optimized for performance.
* @type Boolean
*/
enableNestedListenerRemoval : false,
/**
* Indicates whether to use native browser parsing for JSON methods.
* This option is ignored if the browser does not support native JSON methods.
* <b>Note: Native JSON methods will not work with objects that have functions.
* Also, property names must be quoted, otherwise the data will not parse.</b> (Defaults to false)
* @type Boolean
*/
USE_NATIVE_JSON : false,
/**
* Copies all the properties of config to obj if they don't already exist.
* @param {Object} obj The receiver of the properties
* @param {Object} config The source of the properties
* @return {Object} returns obj
*/
applyIf : function(o, c){
if(o){
for(var p in c){
if(!Ext.isDefined(o[p])){
o[p] = c[p];
}
}
}
return o;
},
/**
* Generates unique ids. If the element already has an id, it is unchanged
* @param {Mixed} el (optional) The element to generate an id for
* @param {String} prefix (optional) Id prefix (defaults "ext-gen")
* @return {String} The generated Id.
*/
id : function(el, prefix){
el = Ext.getDom(el, true) || {};
if (!el.id) {
el.id = (prefix || "ext-gen") + (++idSeed);
}
return el.id;
},
/**
* <p>Extends one class to create a subclass and optionally overrides members with the passed literal. This method
* also adds the function "override()" to the subclass that can be used to override members of the class.</p>
* For example, to create a subclass of Ext GridPanel:
* <pre><code>
MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
constructor: function(config) {
// Create configuration for this Grid.
var store = new Ext.data.Store({...});
var colModel = new Ext.grid.ColumnModel({...});
// Create a new config object containing our computed properties
// *plus* whatever was in the config parameter.
config = Ext.apply({
store: store,
colModel: colModel
}, config);
MyGridPanel.superclass.constructor.call(this, config);
// Your postprocessing here
},
yourMethod: function() {
// etc.
}
});
</code></pre>
*
* <p>This function also supports a 3-argument call in which the subclass's constructor is
* passed as an argument. In this form, the parameters are as follows:</p>
* <div class="mdetail-params"><ul>
* <li><code>subclass</code> : Function <div class="sub-desc">The subclass constructor.</div></li>
* <li><code>superclass</code> : Function <div class="sub-desc">The constructor of class being extended</div></li>
* <li><code>overrides</code> : Object <div class="sub-desc">A literal with members which are copied into the subclass's
* prototype, and are therefore shared among all instances of the new class.</div></li>
* </ul></div>
*
* @param {Function} superclass The constructor of class being extended.
* @param {Object} overrides <p>A literal with members which are copied into the subclass's
* prototype, and are therefore shared between all instances of the new class.</p>
* <p>This may contain a special member named <tt><b>constructor</b></tt>. This is used
* to define the constructor of the new class, and is returned. If this property is
* <i>not</i> specified, a constructor is generated and returned which just calls the
* superclass's constructor passing on its parameters.</p>
* <p><b>It is essential that you call the superclass constructor in any provided constructor. See example code.</b></p>
* @return {Function} The subclass constructor from the <code>overrides</code> parameter, or a generated one if not provided.
*/
extend : function(){
// inline overrides
var io = function(o){
for(var m in o){
this[m] = o[m];
}
};
var oc = Object.prototype.constructor;
return function(sb, sp, overrides){
if(typeof sp == 'object'){
overrides = sp;
sp = sb;
sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
}
var F = function(){},
sbp,
spp = sp.prototype;
F.prototype = spp;
sbp = sb.prototype = new F();
sbp.constructor=sb;
sb.superclass=spp;
if(spp.constructor == oc){
spp.constructor=sp;
}
sb.override = function(o){
Ext.override(sb, o);
};
sbp.superclass = sbp.supr = (function(){
return spp;
});
sbp.override = io;
Ext.override(sb, overrides);
sb.extend = function(o){return Ext.extend(sb, o);};
return sb;
};
}(),
/**
* Adds a list of functions to the prototype of an existing class, overwriting any existing methods with the same name.
* Usage:<pre><code>
Ext.override(MyClass, {
newMethod1: function(){
// etc.
},
newMethod2: function(foo){
// etc.
}
});
</code></pre>
* @param {Object} origclass The class to override
* @param {Object} overrides The list of functions to add to origClass. This should be specified as an object literal
* containing one or more methods.
* @method override
*/
override : function(origclass, overrides){
if(overrides){
var p = origclass.prototype;
Ext.apply(p, overrides);
if(Ext.isIE && overrides.hasOwnProperty('toString')){
p.toString = overrides.toString;
}
}
},
/**
* Creates namespaces to be used for scoping variables and classes so that they are not global.
* Specifying the last node of a namespace implicitly creates all other nodes. Usage:
* <pre><code>
Ext.namespace('Company', 'Company.data');
Ext.namespace('Company.data'); // equivalent and preferable to above syntax
Company.Widget = function() { ... }
Company.data.CustomStore = function(config) { ... }
</code></pre>
* @param {String} namespace1
* @param {String} namespace2
* @param {String} etc
* @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
* @method namespace
*/
namespace : function(){
var len1 = arguments.length,
i = 0,
len2,
j,
main,
ns,
sub,
current;
for(; i < len1; ++i) {
main = arguments[i];
ns = arguments[i].split('.');
current = window[ns[0]];
if (current === undefined) {
current = window[ns[0]] = {};
}
sub = ns.slice(1);
len2 = sub.length;
for(j = 0; j < len2; ++j) {
current = current[sub[j]] = current[sub[j]] || {};
}
}
return current;
},
/**
* Takes an object and converts it to an encoded URL. e.g. Ext.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2". Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value.
* @param {Object} o
* @param {String} pre (optional) A prefix to add to the url encoded string
* @return {String}
*/
urlEncode : function(o, pre){
var empty,
buf = [],
e = encodeURIComponent;
Ext.iterate(o, function(key, item){
empty = Ext.isEmpty(item);
Ext.each(empty ? key : item, function(val){
buf.push('&', e(key), '=', (!Ext.isEmpty(val) && (val != key || !empty)) ? (Ext.isDate(val) ? Ext.encode(val).replace(/"/g, '') : e(val)) : '');
});
});
if(!pre){
buf.shift();
pre = '';
}
return pre + buf.join('');
},
/**
* Takes an encoded URL and and converts it to an object. Example: <pre><code>
Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}
Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false); // returns {foo: "1", bar: ["2", "3", "4"]}
</code></pre>
* @param {String} string
* @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false).
* @return {Object} A literal with members
*/
urlDecode : function(string, overwrite){
if(Ext.isEmpty(string)){
return {};
}
var obj = {},
pairs = string.split('&'),
d = decodeURIComponent,
name,
value;
Ext.each(pairs, function(pair) {
pair = pair.split('=');
name = d(pair[0]);
value = d(pair[1]);
obj[name] = overwrite || !obj[name] ? value :
[].concat(obj[name]).concat(value);
});
return obj;
},
/**
* Appends content to the query string of a URL, handling logic for whether to place
* a question mark or ampersand.
* @param {String} url The URL to append to.
* @param {String} s The content to append to the URL.
* @return (String) The resulting URL
*/
urlAppend : function(url, s){
if(!Ext.isEmpty(s)){
return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
}
return url;
},
/**
* Converts any iterable (numeric indices and a length property) into a true array
* Don't use this on strings. IE doesn't support "abc"[0] which this implementation depends on.
* For strings, use this instead: "abc".match(/./g) => [a,b,c];
* @param {Iterable} the iterable object to be turned into a true Array.
* @return (Array) array
*/
toArray : function(){
return isIE ?
function(a, i, j, res){
res = [];
for(var x = 0, len = a.length; x < len; x++) {
res.push(a[x]);
}
return res.slice(i || 0, j || res.length);
} :
function(a, i, j){
return Array.prototype.slice.call(a, i || 0, j || a.length);
};
}(),
isIterable : function(v){
//check for array or arguments
if(Ext.isArray(v) || v.callee){
return true;
}
//check for node list type
if(/NodeList|HTMLCollection/.test(toString.call(v))){
return true;
}
//NodeList has an item and length property
//IXMLDOMNodeList has nextNode method, needs to be checked first.
return ((typeof v.nextNode != 'undefined' || v.item) && Ext.isNumber(v.length));
},
/**
* Iterates an array calling the supplied function.
* @param {Array/NodeList/Mixed} array The array to be iterated. If this
* argument is not really an array, the supplied function is called once.
* @param {Function} fn The function to be called with each item. If the
* supplied function returns false, iteration stops and this method returns
* the current <code>index</code>. This function is called with
* the following arguments:
* <div class="mdetail-params"><ul>
* <li><code>item</code> : <i>Mixed</i>
* <div class="sub-desc">The item at the current <code>index</code>
* in the passed <code>array</code></div></li>
* <li><code>index</code> : <i>Number</i>
* <div class="sub-desc">The current index within the array</div></li>
* <li><code>allItems</code> : <i>Array</i>
* <div class="sub-desc">The <code>array</code> passed as the first
* argument to <code>Ext.each</code>.</div></li>
* </ul></div>
* @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed.
* Defaults to the <code>item</code> at the current <code>index</code>
* within the passed <code>array</code>.
* @return See description for the fn parameter.
*/
each : function(array, fn, scope){
if(Ext.isEmpty(array, true)){
return;
}
if(!Ext.isIterable(array) || Ext.isPrimitive(array)){
array = [array];
}
for(var i = 0, len = array.length; i < len; i++){
if(fn.call(scope || array[i], array[i], i, array) === false){
return i;
};
}
},
/**
* Iterates either the elements in an array, or each of the properties in an object.
* <b>Note</b>: If you are only iterating arrays, it is better to call {@link #each}.
* @param {Object/Array} object The object or array to be iterated
* @param {Function} fn The function to be called for each iteration.
* The iteration will stop if the supplied function returns false, or
* all array elements / object properties have been covered. The signature
* varies depending on the type of object being interated:
* <div class="mdetail-params"><ul>
* <li>Arrays : <tt>(Object item, Number index, Array allItems)</tt>
* <div class="sub-desc">
* When iterating an array, the supplied function is called with each item.</div></li>
* <li>Objects : <tt>(String key, Object value, Object)</tt>
* <div class="sub-desc">
* When iterating an object, the supplied function is called with each key-value pair in
* the object, and the iterated object</div></li>
* </ul></div>
* @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed. Defaults to
* the <code>object</code> being iterated.
*/
iterate : function(obj, fn, scope){
if(Ext.isEmpty(obj)){
return;
}
if(Ext.isIterable(obj)){
Ext.each(obj, fn, scope);
return;
}else if(typeof obj == 'object'){
for(var prop in obj){
if(obj.hasOwnProperty(prop)){
if(fn.call(scope || obj, prop, obj[prop], obj) === false){
return;
};
}
}
}
},
/**
* Return the dom node for the passed String (id), dom node, or Ext.Element.
* Optional 'strict' flag is needed for IE since it can return 'name' and
* 'id' elements by using getElementById.
* Here are some examples:
* <pre><code>
// gets dom node based on id
var elDom = Ext.getDom('elId');
// gets dom node based on the dom node
var elDom1 = Ext.getDom(elDom);
// If we don&#39;t know if we are working with an
// Ext.Element or a dom node use Ext.getDom
function(el){
var dom = Ext.getDom(el);
// do something with the dom node
}
* </code></pre>
* <b>Note</b>: the dom node to be found actually needs to exist (be rendered, etc)
* when this method is called to be successful.
* @param {Mixed} el
* @return HTMLElement
*/
getDom : function(el, strict){
if(!el || !DOC){
return null;
}
if (el.dom){
return el.dom;
} else {
if (typeof el == 'string') {
var e = DOC.getElementById(el);
// IE returns elements with the 'name' and 'id' attribute.
// we do a strict check to return the element with only the id attribute
if (e && isIE && strict) {
if (el == e.getAttribute('id')) {
return e;
} else {
return null;
}
}
return e;
} else {
return el;
}
}
},
/**
* Returns the current document body as an {@link Ext.Element}.
* @return Ext.Element The document body
*/
getBody : function(){
return Ext.get(DOC.body || DOC.documentElement);
},
/**
* Returns the current document body as an {@link Ext.Element}.
* @return Ext.Element The document body
*/
getHead : function() {
var head;
return function() {
if (head == undefined) {
head = Ext.get(DOC.getElementsByTagName("head")[0]);
}
return head;
};
}(),
/**
* Removes a DOM node from the document.
*/
/**
* <p>Removes this element from the document, removes all DOM event listeners, and deletes the cache reference.
* All DOM event listeners are removed from this element. If {@link Ext#enableNestedListenerRemoval} is
* <code>true</code>, then DOM event listeners are also removed from all child nodes. The body node
* will be ignored if passed in.</p>
* @param {HTMLElement} node The node to remove
*/
removeNode : isIE && !isIE8 ? function(){
var d;
return function(n){
if(n && n.tagName != 'BODY'){
(Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
d = d || DOC.createElement('div');
d.appendChild(n);
d.innerHTML = '';
delete Ext.elCache[n.id];
}
};
}() : function(n){
if(n && n.parentNode && n.tagName != 'BODY'){
(Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
n.parentNode.removeChild(n);
delete Ext.elCache[n.id];
}
},
/**
* <p>Returns true if the passed value is empty.</p>
* <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
* <li>null</li>
* <li>undefined</li>
* <li>an empty array</li>
* <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
* </ul></div>
* @param {Mixed} value The value to test
* @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)
* @return {Boolean}
*/
isEmpty : function(v, allowBlank){
return v === null || v === undefined || ((Ext.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);
},
/**
* Returns true if the passed value is a JavaScript array, otherwise false.
* @param {Mixed} value The value to test
* @return {Boolean}
*/
isArray : function(v){
return toString.apply(v) === '[object Array]';
},
/**
* Returns true if the passed object is a JavaScript date object, otherwise false.
* @param {Object} object The object to test
* @return {Boolean}
*/
isDate : function(v){
return toString.apply(v) === '[object Date]';
},
/**
* Returns true if the passed value is a JavaScript Object, otherwise false.
* @param {Mixed} value The value to test
* @return {Boolean}
*/
isObject : function(v){
return !!v && Object.prototype.toString.call(v) === '[object Object]';
},
/**
* Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.
* @param {Mixed} value The value to test
* @return {Boolean}
*/
isPrimitive : function(v){
return Ext.isString(v) || Ext.isNumber(v) || Ext.isBoolean(v);
},
/**
* Returns true if the passed value is a JavaScript Function, otherwise false.
* @param {Mixed} value The value to test
* @return {Boolean}
*/
isFunction : function(v){
return toString.apply(v) === '[object Function]';
},
/**
* Returns true if the passed value is a number. Returns false for non-finite numbers.
* @param {Mixed} value The value to test
* @return {Boolean}
*/
isNumber : function(v){
return typeof v === 'number' && isFinite(v);
},
/**
* Returns true if the passed value is a string.
* @param {Mixed} value The value to test
* @return {Boolean}
*/
isString : function(v){
return typeof v === 'string';
},
/**
* Returns true if the passed value is a boolean.
* @param {Mixed} value The value to test
* @return {Boolean}
*/
isBoolean : function(v){
return typeof v === 'boolean';
},
/**
* Returns true if the passed value is an HTMLElement
* @param {Mixed} value The value to test
* @return {Boolean}
*/
isElement : function(v) {
return v ? !!v.tagName : false;
},
/**
* Returns true if the passed value is not undefined.
* @param {Mixed} value The value to test
* @return {Boolean}
*/
isDefined : function(v){
return typeof v !== 'undefined';
},
/**
* True if the detected browser is Opera.
* @type Boolean
*/
isOpera : isOpera,
/**
* True if the detected browser uses WebKit.
* @type Boolean
*/
isWebKit : isWebKit,
/**
* True if the detected browser is Chrome.
* @type Boolean
*/
isChrome : isChrome,
/**
* True if the detected browser is Safari.
* @type Boolean
*/
isSafari : isSafari,
/**
* True if the detected browser is Safari 3.x.
* @type Boolean
*/
isSafari3 : isSafari3,
/**
* True if the detected browser is Safari 4.x.
* @type Boolean
*/
isSafari4 : isSafari4,
/**
* True if the detected browser is Safari 2.x.
* @type Boolean
*/
isSafari2 : isSafari2,
/**
* True if the detected browser is Internet Explorer.
* @type Boolean
*/
isIE : isIE,
/**
* True if the detected browser is Internet Explorer 6.x.
* @type Boolean
*/
isIE6 : isIE6,
/**
* True if the detected browser is Internet Explorer 7.x.
* @type Boolean
*/
isIE7 : isIE7,
/**
* True if the detected browser is Internet Explorer 8.x.
* @type Boolean
*/
isIE8 : isIE8,
/**
* True if the detected browser is Internet Explorer 9.x.
* @type Boolean
*/
isIE9 : isIE9,
/**
* True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).
* @type Boolean
*/
isGecko : isGecko,
/**
* True if the detected browser uses a pre-Gecko 1.9 layout engine (e.g. Firefox 2.x).
* @type Boolean
*/
isGecko2 : isGecko2,
/**
* True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).
* @type Boolean
*/
isGecko3 : isGecko3,
/**
* True if the detected browser is Internet Explorer running in non-strict mode.
* @type Boolean
*/
isBorderBox : isBorderBox,
/**
* True if the detected platform is Linux.
* @type Boolean
*/
isLinux : isLinux,
/**
* True if the detected platform is Windows.
* @type Boolean
*/
isWindows : isWindows,
/**
* True if the detected platform is Mac OS.
* @type Boolean
*/
isMac : isMac,
/**
* True if the detected platform is Adobe Air.
* @type Boolean
*/
isAir : isAir
});
/**
* Creates namespaces to be used for scoping variables and classes so that they are not global.
* Specifying the last node of a namespace implicitly creates all other nodes. Usage:
* <pre><code>
Ext.namespace('Company', 'Company.data');
Ext.namespace('Company.data'); // equivalent and preferable to above syntax
Company.Widget = function() { ... }
Company.data.CustomStore = function(config) { ... }
</code></pre>
* @param {String} namespace1
* @param {String} namespace2
* @param {String} etc
* @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
* @method ns
*/
Ext.ns = Ext.namespace;
})();
Ext.ns('Ext.util', 'Ext.lib', 'Ext.data', 'Ext.supports');
Ext.elCache = {};
/**
* @class Function
* These functions are available on every Function object (any JavaScript function).
*/
Ext.apply(Function.prototype, {
/**
* Creates an interceptor function. The passed function is called before the original one. If it returns false,
* the original one is not called. The resulting function returns the results of the original function.
* The passed function is called with the parameters of the original function. Example usage:
* <pre><code>
var sayHi = function(name){
alert('Hi, ' + name);
}
sayHi('Fred'); // alerts "Hi, Fred"
// create a new function that validates input without
// directly modifying the original function:
var sayHiToFriend = sayHi.createInterceptor(function(name){
return name == 'Brian';
});
sayHiToFriend('Fred'); // no alert
sayHiToFriend('Brian'); // alerts "Hi, Brian"
</code></pre>
* @param {Function} fcn The function to call before the original
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
* <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
* @return {Function} The new function
*/
createInterceptor : function(fcn, scope){
var method = this;
return !Ext.isFunction(fcn) ?
this :
function() {
var me = this,
args = arguments;
fcn.target = me;
fcn.method = method;
return (fcn.apply(scope || me || window, args) !== false) ?
method.apply(me || window, args) :
null;
};
},
/**
* Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
* Call directly on any function. Example: <code>myFunction.createCallback(arg1, arg2)</code>
* Will create a function that is bound to those 2 args. <b>If a specific scope is required in the
* callback, use {@link #createDelegate} instead.</b> The function returned by createCallback always
* executes in the window scope.
* <p>This method is required when you want to pass arguments to a callback function. If no arguments
* are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
* However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
* would simply execute immediately when the code is parsed. Example usage:
* <pre><code>
var sayHi = function(name){
alert('Hi, ' + name);
}
// clicking the button alerts "Hi, Fred"
new Ext.Button({
text: 'Say Hi',
renderTo: Ext.getBody(),
handler: sayHi.createCallback('Fred')
});
</code></pre>
* @return {Function} The new function
*/
createCallback : function(/*args...*/){
// make args available, in function below
var args = arguments,
method = this;
return function() {
return method.apply(window, args);
};
},
/**
* Creates a delegate (callback) that sets the scope to obj.
* Call directly on any function. Example: <code>this.myFunction.createDelegate(this, [arg1, arg2])</code>
* Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
* callback points to obj. Example usage:
* <pre><code>
var sayHi = function(name){
// Note this use of "this.text" here. This function expects to
// execute within a scope that contains a text property. In this
// example, the "this" variable is pointing to the btn object that
// was passed in createDelegate below.
alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
}
var btn = new Ext.Button({
text: 'Say Hi',
renderTo: Ext.getBody()
});
// This callback will execute in the scope of the
// button instance. Clicking the button alerts
// "Hi, Fred. You clicked the "Say Hi" button."
btn.on('click', sayHi.createDelegate(btn, ['Fred']));
</code></pre>
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
* <b>If omitted, defaults to the browser window.</b>
* @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
* @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
* if a number the args are inserted at the specified position
* @return {Function} The new function
*/
createDelegate : function(obj, args, appendArgs){
var method = this;
return function() {
var callArgs = args || arguments;
if (appendArgs === true){
callArgs = Array.prototype.slice.call(arguments, 0);
callArgs = callArgs.concat(args);
}else if (Ext.isNumber(appendArgs)){
callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
var applyArgs = [appendArgs, 0].concat(args); // create method call params
Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
}
return method.apply(obj || window, callArgs);
};
},
/**
* Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
* <pre><code>
var sayHi = function(name){
alert('Hi, ' + name);
}
// executes immediately:
sayHi('Fred');
// executes after 2 seconds:
sayHi.defer(2000, this, ['Fred']);
// this syntax is sometimes useful for deferring
// execution of an anonymous function:
(function(){
alert('Anonymous');
}).defer(100);
</code></pre>
* @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
* <b>If omitted, defaults to the browser window.</b>
* @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
* @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
* if a number the args are inserted at the specified position
* @return {Number} The timeout id that can be used with clearTimeout
*/
defer : function(millis, obj, args, appendArgs){
var fn = this.createDelegate(obj, args, appendArgs);
if(millis > 0){
return setTimeout(fn, millis);
}
fn();
return 0;
}
});
/**
* @class String
* These functions are available on every String object.
*/
Ext.applyIf(String, {
/**
* Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
* token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
* <pre><code>
var cls = 'my-class', text = 'Some text';
var s = String.format('&lt;div class="{0}">{1}&lt;/div>', cls, text);
// s now contains the string: '&lt;div class="my-class">Some text&lt;/div>'
* </code></pre>
* @param {String} string The tokenized string to be formatted
* @param {String} value1 The value to replace token {0}
* @param {String} value2 Etc...
* @return {String} The formatted string
* @static
*/
format : function(format){
var args = Ext.toArray(arguments, 1);
return format.replace(/\{(\d+)\}/g, function(m, i){
return args[i];
});
}
});
/**
* @class Array
*/
Ext.applyIf(Array.prototype, {
/**
* Checks whether or not the specified object exists in the array.
* @param {Object} o The object to check for
* @param {Number} from (Optional) The index at which to begin the search
* @return {Number} The index of o in the array (or -1 if it is not found)
*/
indexOf : function(o, from){
var len = this.length;
from = from || 0;
from += (from < 0) ? len : 0;
for (; from < len; ++from){
if(this[from] === o){
return from;
}
}
return -1;
},
/**
* Removes the specified object from the array. If the object is not found nothing happens.
* @param {Object} o The object to remove
* @return {Array} this array
*/
remove : function(o){
var index = this.indexOf(o);
if(index != -1){
this.splice(index, 1);
}
return this;
}
});
/**
* @class Ext.util.TaskRunner
* Provides the ability to execute one or more arbitrary tasks in a multithreaded
* manner. Generally, you can use the singleton {@link Ext.TaskMgr} instead, but
* if needed, you can create separate instances of TaskRunner. Any number of
* separate tasks can be started at any time and will run independently of each
* other. Example usage:
* <pre><code>
// Start a simple clock task that updates a div once per second
var updateClock = function(){
Ext.fly('clock').update(new Date().format('g:i:s A'));
}
var task = {
run: updateClock,
interval: 1000 //1 second
}
var runner = new Ext.util.TaskRunner();
runner.start(task);
// equivalent using TaskMgr
Ext.TaskMgr.start({
run: updateClock,
interval: 1000
});
* </code></pre>
* <p>See the {@link #start} method for details about how to configure a task object.</p>
* Also see {@link Ext.util.DelayedTask}.
*
* @constructor
* @param {Number} interval (optional) The minimum precision in milliseconds supported by this TaskRunner instance
* (defaults to 10)
*/
Ext.util.TaskRunner = function(interval){
interval = interval || 10;
var tasks = [],
removeQueue = [],
id = 0,
running = false,
// private
stopThread = function(){
running = false;
clearInterval(id);
id = 0;
},
// private
startThread = function(){
if(!running){
running = true;
id = setInterval(runTasks, interval);
}
},
// private
removeTask = function(t){
removeQueue.push(t);
if(t.onStop){
t.onStop.apply(t.scope || t);
}
},
// private
runTasks = function(){
var rqLen = removeQueue.length,
now = new Date().getTime();
if(rqLen > 0){
for(var i = 0; i < rqLen; i++){
tasks.remove(removeQueue[i]);
}
removeQueue = [];
if(tasks.length < 1){
stopThread();
return;
}
}
for(var i = 0, t, itime, rt, len = tasks.length; i < len; ++i){
t = tasks[i];
itime = now - t.taskRunTime;
if(t.interval <= itime){
rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]);
t.taskRunTime = now;
if(rt === false || t.taskRunCount === t.repeat){
removeTask(t);
return;
}
}
if(t.duration && t.duration <= (now - t.taskStartTime)){
removeTask(t);
}
}
};
/**
* Starts a new task.
* @method start
* @param {Object} task <p>A config object that supports the following properties:<ul>
* <li><code>run</code> : Function<div class="sub-desc"><p>The function to execute each time the task is invoked. The
* function will be called at each interval and passed the <code>args</code> argument if specified, and the
* current invocation count if not.</p>
* <p>If a particular scope (<code>this</code> reference) is required, be sure to specify it using the <code>scope</code> argument.</p>
* <p>Return <code>false</code> from this function to terminate the task.</p></div></li>
* <li><code>interval</code> : Number<div class="sub-desc">The frequency in milliseconds with which the task
* should be invoked.</div></li>
* <li><code>args</code> : Array<div class="sub-desc">(optional) An array of arguments to be passed to the function
* specified by <code>run</code>. If not specified, the current invocation count is passed.</div></li>
* <li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (<tt>this</tt> reference) in which to execute the
* <code>run</code> function. Defaults to the task config object.</div></li>
* <li><code>duration</code> : Number<div class="sub-desc">(optional) The length of time in milliseconds to invoke
* the task before stopping automatically (defaults to indefinite).</div></li>
* <li><code>repeat</code> : Number<div class="sub-desc">(optional) The number of times to invoke the task before
* stopping automatically (defaults to indefinite).</div></li>
* </ul></p>
* <p>Before each invocation, Ext injects the property <code>taskRunCount</code> into the task object so
* that calculations based on the repeat count can be performed.</p>
* @return {Object} The task
*/
this.start = function(task){
tasks.push(task);
task.taskStartTime = new Date().getTime();
task.taskRunTime = 0;
task.taskRunCount = 0;
startThread();
return task;
};
/**
* Stops an existing running task.
* @method stop
* @param {Object} task The task to stop
* @return {Object} The task
*/
this.stop = function(task){
removeTask(task);
return task;
};
/**
* Stops all tasks that are currently running.
* @method stopAll
*/
this.stopAll = function(){
stopThread();
for(var i = 0, len = tasks.length; i < len; i++){
if(tasks[i].onStop){
tasks[i].onStop();
}
}
tasks = [];
removeQueue = [];
};
};
/**
* @class Ext.TaskMgr
* @extends Ext.util.TaskRunner
* A static {@link Ext.util.TaskRunner} instance that can be used to start and stop arbitrary tasks. See
* {@link Ext.util.TaskRunner} for supported methods and task config properties.
* <pre><code>
// Start a simple clock task that updates a div once per second
var task = {
run: function(){
Ext.fly('clock').update(new Date().format('g:i:s A'));
},
interval: 1000 //1 second
}
Ext.TaskMgr.start(task);
</code></pre>
* <p>See the {@link #start} method for details about how to configure a task object.</p>
* @singleton
*/
Ext.TaskMgr = new Ext.util.TaskRunner();(function(){
var libFlyweight;
function fly(el) {
if (!libFlyweight) {
libFlyweight = new Ext.Element.Flyweight();
}
libFlyweight.dom = el;
return libFlyweight;
}
(function(){
var doc = document,
isCSS1 = doc.compatMode == "CSS1Compat",
MAX = Math.max,
ROUND = Math.round,
PARSEINT = parseInt;
Ext.lib.Dom = {
isAncestor : function(p, c) {
var ret = false;
p = Ext.getDom(p);
c = Ext.getDom(c);
if (p && c) {
if (p.contains) {
return p.contains(c);
} else if (p.compareDocumentPosition) {
return !!(p.compareDocumentPosition(c) & 16);
} else {
while (c = c.parentNode) {
ret = c == p || ret;
}
}
}
return ret;
},
getViewWidth : function(full) {
return full ? this.getDocumentWidth() : this.getViewportWidth();
},
getViewHeight : function(full) {
return full ? this.getDocumentHeight() : this.getViewportHeight();
},
getDocumentHeight: function() {
return MAX(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, this.getViewportHeight());
},
getDocumentWidth: function() {
return MAX(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, this.getViewportWidth());
},
getViewportHeight: function(){
return Ext.isIE ?
(Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) :
self.innerHeight;
},
getViewportWidth : function() {
return !Ext.isStrict && !Ext.isOpera ? doc.body.clientWidth :
Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth;
},
getY : function(el) {
return this.getXY(el)[1];
},
getX : function(el) {
return this.getXY(el)[0];
},
getXY : function(el) {
var p,
pe,
b,
bt,
bl,
dbd,
x = 0,
y = 0,
scroll,
hasAbsolute,
bd = (doc.body || doc.documentElement),
ret = [0,0];
el = Ext.getDom(el);
if(el != bd){
if (el.getBoundingClientRect) {
b = el.getBoundingClientRect();
scroll = fly(document).getScroll();
ret = [ROUND(b.left + scroll.left), ROUND(b.top + scroll.top)];
} else {
p = el;
hasAbsolute = fly(el).isStyle("position", "absolute");
while (p) {
pe = fly(p);
x += p.offsetLeft;
y += p.offsetTop;
hasAbsolute = hasAbsolute || pe.isStyle("position", "absolute");
if (Ext.isGecko) {
y += bt = PARSEINT(pe.getStyle("borderTopWidth"), 10) || 0;
x += bl = PARSEINT(pe.getStyle("borderLeftWidth"), 10) || 0;
if (p != el && !pe.isStyle('overflow','visible')) {
x += bl;
y += bt;
}
}
p = p.offsetParent;
}
if (Ext.isSafari && hasAbsolute) {
x -= bd.offsetLeft;
y -= bd.offsetTop;
}
if (Ext.isGecko && !hasAbsolute) {
dbd = fly(bd);
x += PARSEINT(dbd.getStyle("borderLeftWidth"), 10) || 0;
y += PARSEINT(dbd.getStyle("borderTopWidth"), 10) || 0;
}
p = el.parentNode;
while (p && p != bd) {
if (!Ext.isOpera || (p.tagName != 'TR' && !fly(p).isStyle("display", "inline"))) {
x -= p.scrollLeft;
y -= p.scrollTop;
}
p = p.parentNode;
}
ret = [x,y];
}
}
return ret;
},
setXY : function(el, xy) {
(el = Ext.fly(el, '_setXY')).position();
var pts = el.translatePoints(xy),
style = el.dom.style,
pos;
for (pos in pts) {
if (!isNaN(pts[pos])) {
style[pos] = pts[pos] + "px";
}
}
},
setX : function(el, x) {
this.setXY(el, [x, false]);
},
setY : function(el, y) {
this.setXY(el, [false, y]);
}
};
})();Ext.lib.Event = function() {
var loadComplete = false,
unloadListeners = {},
retryCount = 0,
onAvailStack = [],
_interval,
locked = false,
win = window,
doc = document,
// constants
POLL_RETRYS = 200,
POLL_INTERVAL = 20,
TYPE = 0,
FN = 1,
OBJ = 2,
ADJ_SCOPE = 3,
SCROLLLEFT = 'scrollLeft',
SCROLLTOP = 'scrollTop',
UNLOAD = 'unload',
MOUSEOVER = 'mouseover',
MOUSEOUT = 'mouseout',
// private
doAdd = function() {
var ret;
if (win.addEventListener) {
ret = function(el, eventName, fn, capture) {
if (eventName == 'mouseenter') {
fn = fn.createInterceptor(checkRelatedTarget);
el.addEventListener(MOUSEOVER, fn, (capture));
} else if (eventName == 'mouseleave') {
fn = fn.createInterceptor(checkRelatedTarget);
el.addEventListener(MOUSEOUT, fn, (capture));
} else {
el.addEventListener(eventName, fn, (capture));
}
return fn;
};
} else if (win.attachEvent) {
ret = function(el, eventName, fn, capture) {
el.attachEvent("on" + eventName, fn);
return fn;
};
} else {
ret = function(){};
}
return ret;
}(),
// private
doRemove = function(){
var ret;
if (win.removeEventListener) {
ret = function (el, eventName, fn, capture) {
if (eventName == 'mouseenter') {
eventName = MOUSEOVER;
} else if (eventName == 'mouseleave') {
eventName = MOUSEOUT;
}
el.removeEventListener(eventName, fn, (capture));
};
} else if (win.detachEvent) {
ret = function (el, eventName, fn) {
el.detachEvent("on" + eventName, fn);
};
} else {
ret = function(){};
}
return ret;
}();
function checkRelatedTarget(e) {
return !elContains(e.currentTarget, pub.getRelatedTarget(e));
}
function elContains(parent, child) {
if(parent && parent.firstChild){
while(child) {
if(child === parent) {
return true;
}
child = child.parentNode;
if(child && (child.nodeType != 1)) {
child = null;
}
}
}
return false;
}
// private
function _tryPreloadAttach() {
var ret = false,
notAvail = [],
element, i, v, override,
tryAgain = !loadComplete || (retryCount > 0);
if(!locked){
locked = true;
for(i = 0; i < onAvailStack.length; ++i){
v = onAvailStack[i];
if(v && (element = doc.getElementById(v.id))){
if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) {
override = v.override;
element = override ? (override === true ? v.obj : override) : element;
v.fn.call(element, v.obj);
onAvailStack.remove(v);
--i;
}else{
notAvail.push(v);
}
}
}
retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
if (tryAgain) {
startInterval();
} else {
clearInterval(_interval);
_interval = null;
}
ret = !(locked = false);
}
return ret;
}
// private
function startInterval() {
if(!_interval){
var callback = function() {
_tryPreloadAttach();
};
_interval = setInterval(callback, POLL_INTERVAL);
}
}
// private
function getScroll() {
var dd = doc.documentElement,
db = doc.body;
if(dd && (dd[SCROLLTOP] || dd[SCROLLLEFT])){
return [dd[SCROLLLEFT], dd[SCROLLTOP]];
}else if(db){
return [db[SCROLLLEFT], db[SCROLLTOP]];
}else{
return [0, 0];
}
}
// private
function getPageCoord (ev, xy) {
ev = ev.browserEvent || ev;
var coord = ev['page' + xy];
if (!coord && coord !== 0) {
coord = ev['client' + xy] || 0;
if (Ext.isIE) {
coord += getScroll()[xy == "X" ? 0 : 1];
}
}
return coord;
}
var pub = {
extAdapter: true,
onAvailable : function(p_id, p_fn, p_obj, p_override) {
onAvailStack.push({
id: p_id,
fn: p_fn,
obj: p_obj,
override: p_override,
checkReady: false });
retryCount = POLL_RETRYS;
startInterval();
},
// This function should ALWAYS be called from Ext.EventManager
addListener: function(el, eventName, fn) {
el = Ext.getDom(el);
if (el && fn) {
if (eventName == UNLOAD) {
if (unloadListeners[el.id] === undefined) {
unloadListeners[el.id] = [];
}
unloadListeners[el.id].push([eventName, fn]);
return fn;
}
return doAdd(el, eventName, fn, false);
}
return false;
},
// This function should ALWAYS be called from Ext.EventManager
removeListener: function(el, eventName, fn) {
el = Ext.getDom(el);
var i, len, li, lis;
if (el && fn) {
if(eventName == UNLOAD){
if((lis = unloadListeners[el.id]) !== undefined){
for(i = 0, len = lis.length; i < len; i++){
if((li = lis[i]) && li[TYPE] == eventName && li[FN] == fn){
unloadListeners[el.id].splice(i, 1);
}
}
}
return;
}
doRemove(el, eventName, fn, false);
}
},
getTarget : function(ev) {
ev = ev.browserEvent || ev;
return this.resolveTextNode(ev.target || ev.srcElement);
},
resolveTextNode : Ext.isGecko ? function(node){
if(!node){
return;
}
// work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
var s = HTMLElement.prototype.toString.call(node);
if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
return;
}
return node.nodeType == 3 ? node.parentNode : node;
} : function(node){
return node && node.nodeType == 3 ? node.parentNode : node;
},
getRelatedTarget : function(ev) {
ev = ev.browserEvent || ev;
return this.resolveTextNode(ev.relatedTarget ||
(/(mouseout|mouseleave)/.test(ev.type) ? ev.toElement :
/(mouseover|mouseenter)/.test(ev.type) ? ev.fromElement : null));
},
getPageX : function(ev) {
return getPageCoord(ev, "X");
},
getPageY : function(ev) {
return getPageCoord(ev, "Y");
},
getXY : function(ev) {
return [this.getPageX(ev), this.getPageY(ev)];
},
stopEvent : function(ev) {
this.stopPropagation(ev);
this.preventDefault(ev);
},
stopPropagation : function(ev) {
ev = ev.browserEvent || ev;
if (ev.stopPropagation) {
ev.stopPropagation();
} else {
ev.cancelBubble = true;
}
},
preventDefault : function(ev) {
ev = ev.browserEvent || ev;
if (ev.preventDefault) {
ev.preventDefault();
} else {
if (ev.keyCode) {
ev.keyCode = 0;
}
ev.returnValue = false;
}
},
getEvent : function(e) {
e = e || win.event;
if (!e) {
var c = this.getEvent.caller;
while (c) {
e = c.arguments[0];
if (e && Event == e.constructor) {
break;
}
c = c.caller;
}
}
return e;
},
getCharCode : function(ev) {
ev = ev.browserEvent || ev;
return ev.charCode || ev.keyCode || 0;
},
//clearCache: function() {},
// deprecated, call from EventManager
getListeners : function(el, eventName) {
Ext.EventManager.getListeners(el, eventName);
},
// deprecated, call from EventManager
purgeElement : function(el, recurse, eventName) {
Ext.EventManager.purgeElement(el, recurse, eventName);
},
_load : function(e) {
loadComplete = true;
if (Ext.isIE && e !== true) {
// IE8 complains that _load is null or not an object
// so lets remove self via arguments.callee
doRemove(win, "load", arguments.callee);
}
},
_unload : function(e) {
var EU = Ext.lib.Event,
i, v, ul, id, len, scope;
for (id in unloadListeners) {
ul = unloadListeners[id];
for (i = 0, len = ul.length; i < len; i++) {
v = ul[i];
if (v) {
try{
scope = v[ADJ_SCOPE] ? (v[ADJ_SCOPE] === true ? v[OBJ] : v[ADJ_SCOPE]) : win;
v[FN].call(scope, EU.getEvent(e), v[OBJ]);
}catch(ex){}
}
}
};
Ext.EventManager._unload();
doRemove(win, UNLOAD, EU._unload);
}
};
// Initialize stuff.
pub.on = pub.addListener;
pub.un = pub.removeListener;
if (doc && doc.body) {
pub._load(true);
} else {
doAdd(win, "load", pub._load);
}
doAdd(win, UNLOAD, pub._unload);
_tryPreloadAttach();
return pub;
}();
/*
* Portions of this file are based on pieces of Yahoo User Interface Library
* Copyright (c) 2007, Yahoo! Inc. All rights reserved.
* YUI licensed under the BSD License:
* http://developer.yahoo.net/yui/license.txt
*/
Ext.lib.Ajax = function() {
var activeX = ['Msxml2.XMLHTTP.6.0',
'Msxml2.XMLHTTP.3.0',
'Msxml2.XMLHTTP'],
CONTENTTYPE = 'Content-Type';
// private
function setHeader(o) {
var conn = o.conn,
prop,
headers = {};
function setTheHeaders(conn, headers){
for (prop in headers) {
if (headers.hasOwnProperty(prop)) {
conn.setRequestHeader(prop, headers[prop]);
}
}
}
Ext.apply(headers, pub.headers, pub.defaultHeaders);
setTheHeaders(conn, headers);
delete pub.headers;
}
// private
function createExceptionObject(tId, callbackArg, isAbort, isTimeout) {
return {
tId : tId,
status : isAbort ? -1 : 0,
statusText : isAbort ? 'transaction aborted' : 'communication failure',
isAbort: isAbort,
isTimeout: isTimeout,
argument : callbackArg
};
}
// private
function initHeader(label, value) {
(pub.headers = pub.headers || {})[label] = value;
}
// private
function createResponseObject(o, callbackArg) {
var headerObj = {},
headerStr,
conn = o.conn,
t,
s,
// see: https://prototype.lighthouseapp.com/projects/8886/tickets/129-ie-mangles-http-response-status-code-204-to-1223
isBrokenStatus = conn.status == 1223;
try {
headerStr = o.conn.getAllResponseHeaders();
Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
t = v.indexOf(':');
if(t >= 0){
s = v.substr(0, t).toLowerCase();
if(v.charAt(t + 1) == ' '){
++t;
}
headerObj[s] = v.substr(t + 1);
}
});
} catch(e) {}
return {
tId : o.tId,
// Normalize the status and statusText when IE returns 1223, see the above link.
status : isBrokenStatus ? 204 : conn.status,
statusText : isBrokenStatus ? 'No Content' : conn.statusText,
getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
getAllResponseHeaders : function(){return headerStr;},
responseText : conn.responseText,
responseXML : conn.responseXML,
argument : callbackArg
};
}
// private
function releaseObject(o) {
if (o.tId) {
pub.conn[o.tId] = null;
}
o.conn = null;
o = null;
}
// private
function handleTransactionResponse(o, callback, isAbort, isTimeout) {
if (!callback) {
releaseObject(o);
return;
}
var httpStatus, responseObject;
try {
if (o.conn.status !== undefined && o.conn.status != 0) {
httpStatus = o.conn.status;
}
else {
httpStatus = 13030;
}
}
catch(e) {
httpStatus = 13030;
}
if ((httpStatus >= 200 && httpStatus < 300) || (Ext.isIE && httpStatus == 1223)) {
responseObject = createResponseObject(o, callback.argument);
if (callback.success) {
if (!callback.scope) {
callback.success(responseObject);
}
else {
callback.success.apply(callback.scope, [responseObject]);
}
}
}
else {
switch (httpStatus) {
case 12002:
case 12029:
case 12030:
case 12031:
case 12152:
case 13030:
responseObject = createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false), isTimeout);
if (callback.failure) {
if (!callback.scope) {
callback.failure(responseObject);
}
else {
callback.failure.apply(callback.scope, [responseObject]);
}
}
break;
default:
responseObject = createResponseObject(o, callback.argument);
if (callback.failure) {
if (!callback.scope) {
callback.failure(responseObject);
}
else {
callback.failure.apply(callback.scope, [responseObject]);
}
}
}
}
releaseObject(o);
responseObject = null;
}
function checkResponse(o, callback, conn, tId, poll, cbTimeout){
if (conn && conn.readyState == 4) {
clearInterval(poll[tId]);
poll[tId] = null;
if (cbTimeout) {
clearTimeout(pub.timeout[tId]);
pub.timeout[tId] = null;
}
handleTransactionResponse(o, callback);
}
}
function checkTimeout(o, callback){
pub.abort(o, callback, true);
}
// private
function handleReadyState(o, callback){
callback = callback || {};
var conn = o.conn,
tId = o.tId,
poll = pub.poll,
cbTimeout = callback.timeout || null;
if (cbTimeout) {
pub.conn[tId] = conn;
pub.timeout[tId] = setTimeout(checkTimeout.createCallback(o, callback), cbTimeout);
}
poll[tId] = setInterval(checkResponse.createCallback(o, callback, conn, tId, poll, cbTimeout), pub.pollInterval);
}
// private
function asyncRequest(method, uri, callback, postData) {
var o = getConnectionObject() || null;
if (o) {
o.conn.open(method, uri, true);
if (pub.useDefaultXhrHeader) {
initHeader('X-Requested-With', pub.defaultXhrHeader);
}
if(postData && pub.useDefaultHeader && (!pub.headers || !pub.headers[CONTENTTYPE])){
initHeader(CONTENTTYPE, pub.defaultPostHeader);
}
if (pub.defaultHeaders || pub.headers) {
setHeader(o);
}
handleReadyState(o, callback);
o.conn.send(postData || null);
}
return o;
}
// private
function getConnectionObject() {
var o;
try {
if (o = createXhrObject(pub.transactionId)) {
pub.transactionId++;
}
} catch(e) {
} finally {
return o;
}
}
// private
function createXhrObject(transactionId) {
var http;
try {
http = new XMLHttpRequest();
} catch(e) {
for (var i = Ext.isIE6 ? 1 : 0; i < activeX.length; ++i) {
try {
http = new ActiveXObject(activeX[i]);
break;
} catch(e) {}
}
} finally {
return {conn : http, tId : transactionId};
}
}
var pub = {
request : function(method, uri, cb, data, options) {
if(options){
var me = this,
xmlData = options.xmlData,
jsonData = options.jsonData,
hs;
Ext.applyIf(me, options);
if(xmlData || jsonData){
hs = me.headers;
if(!hs || !hs[CONTENTTYPE]){
initHeader(CONTENTTYPE, xmlData ? 'text/xml' : 'application/json');
}
data = xmlData || (!Ext.isPrimitive(jsonData) ? Ext.encode(jsonData) : jsonData);
}
}
return asyncRequest(method || options.method || "POST", uri, cb, data);
},
serializeForm : function(form) {
var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
hasSubmit = false,
encoder = encodeURIComponent,
name,
data = '',
type,
hasValue;
Ext.each(fElements, function(element){
name = element.name;
type = element.type;
if (!element.disabled && name) {
if (/select-(one|multiple)/i.test(type)) {
Ext.each(element.options, function(opt){
if (opt.selected) {
hasValue = opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttributeNode('value').specified;
data += String.format("{0}={1}&", encoder(name), encoder(hasValue ? opt.value : opt.text));
}
});
} else if (!(/file|undefined|reset|button/i.test(type))) {
if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) {
data += encoder(name) + '=' + encoder(element.value) + '&';
hasSubmit = /submit/i.test(type);
}
}
}
});
return data.substr(0, data.length - 1);
},
useDefaultHeader : true,
defaultPostHeader : 'application/x-www-form-urlencoded; charset=UTF-8',
useDefaultXhrHeader : true,
defaultXhrHeader : 'XMLHttpRequest',
poll : {},
timeout : {},
conn: {},
pollInterval : 50,
transactionId : 0,
// This is never called - Is it worth exposing this?
// setProgId : function(id) {
// activeX.unshift(id);
// },
// This is never called - Is it worth exposing this?
// setDefaultPostHeader : function(b) {
// this.useDefaultHeader = b;
// },
// This is never called - Is it worth exposing this?
// setDefaultXhrHeader : function(b) {
// this.useDefaultXhrHeader = b;
// },
// This is never called - Is it worth exposing this?
// setPollingInterval : function(i) {
// if (typeof i == 'number' && isFinite(i)) {
// this.pollInterval = i;
// }
// },
// This is never called - Is it worth exposing this?
// resetDefaultHeaders : function() {
// this.defaultHeaders = null;
// },
abort : function(o, callback, isTimeout) {
var me = this,
tId = o.tId,
isAbort = false;
if (me.isCallInProgress(o)) {
o.conn.abort();
clearInterval(me.poll[tId]);
me.poll[tId] = null;
clearTimeout(pub.timeout[tId]);
me.timeout[tId] = null;
handleTransactionResponse(o, callback, (isAbort = true), isTimeout);
}
return isAbort;
},
isCallInProgress : function(o) {
// if there is a connection and readyState is not 0 or 4
return o.conn && !{0:true,4:true}[o.conn.readyState];
}
};
return pub;
}();(function(){
var EXTLIB = Ext.lib,
noNegatives = /width|height|opacity|padding/i,
offsetAttribute = /^((width|height)|(top|left))$/,
defaultUnit = /width|height|top$|bottom$|left$|right$/i,
offsetUnit = /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i,
isset = function(v){
return typeof v !== 'undefined';
},
now = function(){
return new Date();
};
EXTLIB.Anim = {
motion : function(el, args, duration, easing, cb, scope) {
return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
},
run : function(el, args, duration, easing, cb, scope, type) {
type = type || Ext.lib.AnimBase;
if (typeof easing == "string") {
easing = Ext.lib.Easing[easing];
}
var anim = new type(el, args, duration, easing);
anim.animateX(function() {
if(Ext.isFunction(cb)){
cb.call(scope);
}
});
return anim;
}
};
EXTLIB.AnimBase = function(el, attributes, duration, method) {
if (el) {
this.init(el, attributes, duration, method);
}
};
EXTLIB.AnimBase.prototype = {
doMethod: function(attr, start, end) {
var me = this;
return me.method(me.curFrame, start, end - start, me.totalFrames);
},
setAttr: function(attr, val, unit) {
if (noNegatives.test(attr) && val < 0) {
val = 0;
}
Ext.fly(this.el, '_anim').setStyle(attr, val + unit);
},
getAttr: function(attr) {
var el = Ext.fly(this.el),
val = el.getStyle(attr),
a = offsetAttribute.exec(attr) || [];
if (val !== 'auto' && !offsetUnit.test(val)) {
return parseFloat(val);
}
return (!!(a[2]) || (el.getStyle('position') == 'absolute' && !!(a[3]))) ? el.dom['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)] : 0;
},
getDefaultUnit: function(attr) {
return defaultUnit.test(attr) ? 'px' : '';
},
animateX : function(callback, scope) {
var me = this,
f = function() {
me.onComplete.removeListener(f);
if (Ext.isFunction(callback)) {
callback.call(scope || me, me);
}
};
me.onComplete.addListener(f, me);
me.animate();
},
setRunAttr: function(attr) {
var me = this,
a = this.attributes[attr],
to = a.to,
by = a.by,
from = a.from,
unit = a.unit,
ra = (this.runAttrs[attr] = {}),
end;
if (!isset(to) && !isset(by)){
return false;
}
var start = isset(from) ? from : me.getAttr(attr);
if (isset(to)) {
end = to;
}else if(isset(by)) {
if (Ext.isArray(start)){
end = [];
for(var i=0,len=start.length; i<len; i++) {
end[i] = start[i] + by[i];
}
}else{
end = start + by;
}
}
Ext.apply(ra, {
start: start,
end: end,
unit: isset(unit) ? unit : me.getDefaultUnit(attr)
});
},
init: function(el, attributes, duration, method) {
var me = this,
actualFrames = 0,
mgr = EXTLIB.AnimMgr;
Ext.apply(me, {
isAnimated: false,
startTime: null,
el: Ext.getDom(el),
attributes: attributes || {},
duration: duration || 1,
method: method || EXTLIB.Easing.easeNone,
useSec: true,
curFrame: 0,
totalFrames: mgr.fps,
runAttrs: {},
animate: function(){
var me = this,
d = me.duration;
if(me.isAnimated){
return false;
}
me.curFrame = 0;
me.totalFrames = me.useSec ? Math.ceil(mgr.fps * d) : d;
mgr.registerElement(me);
},
stop: function(finish){
var me = this;
if(finish){
me.curFrame = me.totalFrames;
me._onTween.fire();
}
mgr.stop(me);
}
});
var onStart = function(){
var me = this,
attr;
me.onStart.fire();
me.runAttrs = {};
for(attr in this.attributes){
this.setRunAttr(attr);
}
me.isAnimated = true;
me.startTime = now();
actualFrames = 0;
};
var onTween = function(){
var me = this;
me.onTween.fire({
duration: now() - me.startTime,
curFrame: me.curFrame
});
var ra = me.runAttrs;
for (var attr in ra) {
this.setAttr(attr, me.doMethod(attr, ra[attr].start, ra[attr].end), ra[attr].unit);
}
++actualFrames;
};
var onComplete = function() {
var me = this,
actual = (now() - me.startTime) / 1000,
data = {
duration: actual,
frames: actualFrames,
fps: actualFrames / actual
};
me.isAnimated = false;
actualFrames = 0;
me.onComplete.fire(data);
};
me.onStart = new Ext.util.Event(me);
me.onTween = new Ext.util.Event(me);
me.onComplete = new Ext.util.Event(me);
(me._onStart = new Ext.util.Event(me)).addListener(onStart);
(me._onTween = new Ext.util.Event(me)).addListener(onTween);
(me._onComplete = new Ext.util.Event(me)).addListener(onComplete);
}
};
Ext.lib.AnimMgr = new function() {
var me = this,
thread = null,
queue = [],
tweenCount = 0;
Ext.apply(me, {
fps: 1000,
delay: 1,
registerElement: function(tween){
queue.push(tween);
++tweenCount;
tween._onStart.fire();
me.start();
},
unRegister: function(tween, index){
tween._onComplete.fire();
index = index || getIndex(tween);
if (index != -1) {
queue.splice(index, 1);
}
if (--tweenCount <= 0) {
me.stop();
}
},
start: function(){
if(thread === null){
thread = setInterval(me.run, me.delay);
}
},
stop: function(tween){
if(!tween){
clearInterval(thread);
for(var i = 0, len = queue.length; i < len; ++i){
if(queue[0].isAnimated){
me.unRegister(queue[0], 0);
}
}
queue = [];
thread = null;
tweenCount = 0;
}else{
me.unRegister(tween);
}
},
run: function(){
var tf, i, len, tween;
for(i = 0, len = queue.length; i<len; i++) {
tween = queue[i];
if(tween && tween.isAnimated){
tf = tween.totalFrames;
if(tween.curFrame < tf || tf === null){
++tween.curFrame;
if(tween.useSec){
correctFrame(tween);
}
tween._onTween.fire();
}else{
me.stop(tween);
}
}
}
}
});
var getIndex = function(anim) {
var i, len;
for(i = 0, len = queue.length; i<len; i++) {
if(queue[i] === anim) {
return i;
}
}
return -1;
};
var correctFrame = function(tween) {
var frames = tween.totalFrames,
frame = tween.curFrame,
duration = tween.duration,
expected = (frame * duration * 1000 / frames),
elapsed = (now() - tween.startTime),
tweak = 0;
if(elapsed < duration * 1000){
tweak = Math.round((elapsed / expected - 1) * frame);
}else{
tweak = frames - (frame + 1);
}
if(tweak > 0 && isFinite(tweak)){
if(tween.curFrame + tweak >= frames){
tweak = frames - (frame + 1);
}
tween.curFrame += tweak;
}
};
};
EXTLIB.Bezier = new function() {
this.getPosition = function(points, t) {
var n = points.length,
tmp = [],
c = 1 - t,
i,
j;
for (i = 0; i < n; ++i) {
tmp[i] = [points[i][0], points[i][1]];
}
for (j = 1; j < n; ++j) {
for (i = 0; i < n - j; ++i) {
tmp[i][0] = c * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
tmp[i][1] = c * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
}
}
return [ tmp[0][0], tmp[0][1] ];
};
};
EXTLIB.Easing = {
easeNone: function (t, b, c, d) {
return c * t / d + b;
},
easeIn: function (t, b, c, d) {
return c * (t /= d) * t + b;
},
easeOut: function (t, b, c, d) {
return -c * (t /= d) * (t - 2) + b;
}
};
(function() {
EXTLIB.Motion = function(el, attributes, duration, method) {
if (el) {
EXTLIB.Motion.superclass.constructor.call(this, el, attributes, duration, method);
}
};
Ext.extend(EXTLIB.Motion, Ext.lib.AnimBase);
var superclass = EXTLIB.Motion.superclass,
pointsRe = /^points$/i;
Ext.apply(EXTLIB.Motion.prototype, {
setAttr: function(attr, val, unit){
var me = this,
setAttr = superclass.setAttr;
if (pointsRe.test(attr)) {
unit = unit || 'px';
setAttr.call(me, 'left', val[0], unit);
setAttr.call(me, 'top', val[1], unit);
} else {
setAttr.call(me, attr, val, unit);
}
},
getAttr: function(attr){
var me = this,
getAttr = superclass.getAttr;
return pointsRe.test(attr) ? [getAttr.call(me, 'left'), getAttr.call(me, 'top')] : getAttr.call(me, attr);
},
doMethod: function(attr, start, end){
var me = this;
return pointsRe.test(attr)
? EXTLIB.Bezier.getPosition(me.runAttrs[attr], me.method(me.curFrame, 0, 100, me.totalFrames) / 100)
: superclass.doMethod.call(me, attr, start, end);
},
setRunAttr: function(attr){
if(pointsRe.test(attr)){
var me = this,
el = this.el,
points = this.attributes.points,
control = points.control || [],
from = points.from,
to = points.to,
by = points.by,
DOM = EXTLIB.Dom,
start,
i,
end,
len,
ra;
if(control.length > 0 && !Ext.isArray(control[0])){
control = [control];
}else{
/*
var tmp = [];
for (i = 0,len = control.length; i < len; ++i) {
tmp[i] = control[i];
}
control = tmp;
*/
}
Ext.fly(el, '_anim').position();
DOM.setXY(el, isset(from) ? from : DOM.getXY(el));
start = me.getAttr('points');
if(isset(to)){
end = translateValues.call(me, to, start);
for (i = 0,len = control.length; i < len; ++i) {
control[i] = translateValues.call(me, control[i], start);
}
} else if (isset(by)) {
end = [start[0] + by[0], start[1] + by[1]];
for (i = 0,len = control.length; i < len; ++i) {
control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
}
}
ra = this.runAttrs[attr] = [start];
if (control.length > 0) {
ra = ra.concat(control);
}
ra[ra.length] = end;
}else{
superclass.setRunAttr.call(this, attr);
}
}
});
var translateValues = function(val, start) {
var pageXY = EXTLIB.Dom.getXY(this.el);
return [val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1]];
};
})();
})();// Easing functions
(function(){
// shortcuts to aid compression
var abs = Math.abs,
pi = Math.PI,
asin = Math.asin,
pow = Math.pow,
sin = Math.sin,
EXTLIB = Ext.lib;
Ext.apply(EXTLIB.Easing, {
easeBoth: function (t, b, c, d) {
return ((t /= d / 2) < 1) ? c / 2 * t * t + b : -c / 2 * ((--t) * (t - 2) - 1) + b;
},
easeInStrong: function (t, b, c, d) {
return c * (t /= d) * t * t * t + b;
},
easeOutStrong: function (t, b, c, d) {
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
},
easeBothStrong: function (t, b, c, d) {
return ((t /= d / 2) < 1) ? c / 2 * t * t * t * t + b : -c / 2 * ((t -= 2) * t * t * t - 2) + b;
},
elasticIn: function (t, b, c, d, a, p) {
if (t == 0 || (t /= d) == 1) {
return t == 0 ? b : b + c;
}
p = p || (d * .3);
var s;
if (a >= abs(c)) {
s = p / (2 * pi) * asin(c / a);
} else {
a = c;
s = p / 4;
}
return -(a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b;
},
elasticOut: function (t, b, c, d, a, p) {
if (t == 0 || (t /= d) == 1) {
return t == 0 ? b : b + c;
}
p = p || (d * .3);
var s;
if (a >= abs(c)) {
s = p / (2 * pi) * asin(c / a);
} else {
a = c;
s = p / 4;
}
return a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b;
},
elasticBoth: function (t, b, c, d, a, p) {
if (t == 0 || (t /= d / 2) == 2) {
return t == 0 ? b : b + c;
}
p = p || (d * (.3 * 1.5));
var s;
if (a >= abs(c)) {
s = p / (2 * pi) * asin(c / a);
} else {
a = c;
s = p / 4;
}
return t < 1 ?
-.5 * (a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b :
a * pow(2, -10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p) * .5 + c + b;
},
backIn: function (t, b, c, d, s) {
s = s || 1.70158;
return c * (t /= d) * t * ((s + 1) * t - s) + b;
},
backOut: function (t, b, c, d, s) {
if (!s) {
s = 1.70158;
}
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
},
backBoth: function (t, b, c, d, s) {
s = s || 1.70158;
return ((t /= d / 2 ) < 1) ?
c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b :
c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
},
bounceIn: function (t, b, c, d) {
return c - EXTLIB.Easing.bounceOut(d - t, 0, c, d) + b;
},
bounceOut: function (t, b, c, d) {
if ((t /= d) < (1 / 2.75)) {
return c * (7.5625 * t * t) + b;
} else if (t < (2 / 2.75)) {
return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
} else if (t < (2.5 / 2.75)) {
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
}
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
},
bounceBoth: function (t, b, c, d) {
return (t < d / 2) ?
EXTLIB.Easing.bounceIn(t * 2, 0, c, d) * .5 + b :
EXTLIB.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
}
});
})();
(function() {
var EXTLIB = Ext.lib;
// Color Animation
EXTLIB.Anim.color = function(el, args, duration, easing, cb, scope) {
return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.ColorAnim);
};
EXTLIB.ColorAnim = function(el, attributes, duration, method) {
EXTLIB.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
};
Ext.extend(EXTLIB.ColorAnim, EXTLIB.AnimBase);
var superclass = EXTLIB.ColorAnim.superclass,
colorRE = /color$/i,
transparentRE = /^transparent|rgba\(0, 0, 0, 0\)$/,
rgbRE = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,
hexRE= /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,
hex3RE = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i,
isset = function(v){
return typeof v !== 'undefined';
};
// private
function parseColor(s) {
var pi = parseInt,
base,
out = null,
c;
if (s.length == 3) {
return s;
}
Ext.each([hexRE, rgbRE, hex3RE], function(re, idx){
base = (idx % 2 == 0) ? 16 : 10;
c = re.exec(s);
if(c && c.length == 4){
out = [pi(c[1], base), pi(c[2], base), pi(c[3], base)];
return false;
}
});
return out;
}
Ext.apply(EXTLIB.ColorAnim.prototype, {
getAttr : function(attr) {
var me = this,
el = me.el,
val;
if(colorRE.test(attr)){
while(el && transparentRE.test(val = Ext.fly(el).getStyle(attr))){
el = el.parentNode;
val = "fff";
}
}else{
val = superclass.getAttr.call(me, attr);
}
return val;
},
doMethod : function(attr, start, end) {
var me = this,
val,
floor = Math.floor,
i,
len,
v;
if(colorRE.test(attr)){
val = [];
end = end || [];
for(i = 0, len = start.length; i < len; i++) {
v = start[i];
val[i] = superclass.doMethod.call(me, attr, v, end[i]);
}
val = 'rgb(' + floor(val[0]) + ',' + floor(val[1]) + ',' + floor(val[2]) + ')';
}else{
val = superclass.doMethod.call(me, attr, start, end);
}
return val;
},
setRunAttr : function(attr) {
var me = this,
a = me.attributes[attr],
to = a.to,
by = a.by,
ra;
superclass.setRunAttr.call(me, attr);
ra = me.runAttrs[attr];
if(colorRE.test(attr)){
var start = parseColor(ra.start),
end = parseColor(ra.end);
if(!isset(to) && isset(by)){
end = parseColor(by);
for(var i=0,len=start.length; i<len; i++) {
end[i] = start[i] + end[i];
}
}
ra.start = start;
ra.end = end;
}
}
});
})();
(function() {
// Scroll Animation
var EXTLIB = Ext.lib;
EXTLIB.Anim.scroll = function(el, args, duration, easing, cb, scope) {
return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.Scroll);
};
EXTLIB.Scroll = function(el, attributes, duration, method) {
if(el){
EXTLIB.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
}
};
Ext.extend(EXTLIB.Scroll, EXTLIB.ColorAnim);
var superclass = EXTLIB.Scroll.superclass,
SCROLL = 'scroll';
Ext.apply(EXTLIB.Scroll.prototype, {
doMethod : function(attr, start, end) {
var val,
me = this,
curFrame = me.curFrame,
totalFrames = me.totalFrames;
if(attr == SCROLL){
val = [me.method(curFrame, start[0], end[0] - start[0], totalFrames),
me.method(curFrame, start[1], end[1] - start[1], totalFrames)];
}else{
val = superclass.doMethod.call(me, attr, start, end);
}
return val;
},
getAttr : function(attr) {
var me = this;
if (attr == SCROLL) {
return [me.el.scrollLeft, me.el.scrollTop];
}else{
return superclass.getAttr.call(me, attr);
}
},
setAttr : function(attr, val, unit) {
var me = this;
if(attr == SCROLL){
me.el.scrollLeft = val[0];
me.el.scrollTop = val[1];
}else{
superclass.setAttr.call(me, attr, val, unit);
}
}
});
})();
if (Ext.isIE) {
function fnCleanUp() {
var p = Function.prototype;
delete p.createSequence;
delete p.defer;
delete p.createDelegate;
delete p.createCallback;
delete p.createInterceptor;
window.detachEvent("onunload", fnCleanUp);
}
window.attachEvent("onunload", fnCleanUp);
}
})();
(function(){
var EXTUTIL = Ext.util,
EACH = Ext.each,
TRUE = true,
FALSE = false;
EXTUTIL.Observable = function(){
var me = this, e = me.events;
if(me.listeners){
me.on(me.listeners);
delete me.listeners;
}
me.events = e || {};
};
EXTUTIL.Observable.prototype = {
filterOptRe : /^(?:scope|delay|buffer|single)$/,
fireEvent : function(){
var a = Array.prototype.slice.call(arguments, 0),
ename = a[0].toLowerCase(),
me = this,
ret = TRUE,
ce = me.events[ename],
cc,
q,
c;
if (me.eventsSuspended === TRUE) {
if (q = me.eventQueue) {
q.push(a);
}
}
else if(typeof ce == 'object') {
if (ce.bubble){
if(ce.fire.apply(ce, a.slice(1)) === FALSE) {
return FALSE;
}
c = me.getBubbleTarget && me.getBubbleTarget();
if(c && c.enableBubble) {
cc = c.events[ename];
if(!cc || typeof cc != 'object' || !cc.bubble) {
c.enableBubble(ename);
}
return c.fireEvent.apply(c, a);
}
}
else {
a.shift();
ret = ce.fire.apply(ce, a);
}
}
return ret;
},
addListener : function(eventName, fn, scope, o){
var me = this,
e,
oe,
ce;
if (typeof eventName == 'object') {
o = eventName;
for (e in o) {
oe = o[e];
if (!me.filterOptRe.test(e)) {
me.addListener(e, oe.fn || oe, oe.scope || o.scope, oe.fn ? oe : o);
}
}
} else {
eventName = eventName.toLowerCase();
ce = me.events[eventName] || TRUE;
if (typeof ce == 'boolean') {
me.events[eventName] = ce = new EXTUTIL.Event(me, eventName);
}
ce.addListener(fn, scope, typeof o == 'object' ? o : {});
}
},
removeListener : function(eventName, fn, scope){
var ce = this.events[eventName.toLowerCase()];
if (typeof ce == 'object') {
ce.removeListener(fn, scope);
}
},
purgeListeners : function(){
var events = this.events,
evt,
key;
for(key in events){
evt = events[key];
if(typeof evt == 'object'){
evt.clearListeners();
}
}
},
addEvents : function(o){
var me = this;
me.events = me.events || {};
if (typeof o == 'string') {
var a = arguments,
i = a.length;
while(i--) {
me.events[a[i]] = me.events[a[i]] || TRUE;
}
} else {
Ext.applyIf(me.events, o);
}
},
hasListener : function(eventName){
var e = this.events[eventName.toLowerCase()];
return typeof e == 'object' && e.listeners.length > 0;
},
suspendEvents : function(queueSuspended){
this.eventsSuspended = TRUE;
if(queueSuspended && !this.eventQueue){
this.eventQueue = [];
}
},
resumeEvents : function(){
var me = this,
queued = me.eventQueue || [];
me.eventsSuspended = FALSE;
delete me.eventQueue;
EACH(queued, function(e) {
me.fireEvent.apply(me, e);
});
}
};
var OBSERVABLE = EXTUTIL.Observable.prototype;
OBSERVABLE.on = OBSERVABLE.addListener;
OBSERVABLE.un = OBSERVABLE.removeListener;
EXTUTIL.Observable.releaseCapture = function(o){
o.fireEvent = OBSERVABLE.fireEvent;
};
function createTargeted(h, o, scope){
return function(){
if(o.target == arguments[0]){
h.apply(scope, Array.prototype.slice.call(arguments, 0));
}
};
};
function createBuffered(h, o, l, scope){
l.task = new EXTUTIL.DelayedTask();
return function(){
l.task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
};
};
function createSingle(h, e, fn, scope){
return function(){
e.removeListener(fn, scope);
return h.apply(scope, arguments);
};
};
function createDelayed(h, o, l, scope){
return function(){
var task = new EXTUTIL.DelayedTask(),
args = Array.prototype.slice.call(arguments, 0);
if(!l.tasks) {
l.tasks = [];
}
l.tasks.push(task);
task.delay(o.delay || 10, function(){
l.tasks.remove(task);
h.apply(scope, args);
}, scope);
};
};
EXTUTIL.Event = function(obj, name){
this.name = name;
this.obj = obj;
this.listeners = [];
};
EXTUTIL.Event.prototype = {
addListener : function(fn, scope, options){
var me = this,
l;
scope = scope || me.obj;
if(!me.isListening(fn, scope)){
l = me.createListener(fn, scope, options);
if(me.firing){
me.listeners = me.listeners.slice(0);
}
me.listeners.push(l);
}
},
createListener: function(fn, scope, o){
o = o || {};
scope = scope || this.obj;
var l = {
fn: fn,
scope: scope,
options: o
}, h = fn;
if(o.target){
h = createTargeted(h, o, scope);
}
if(o.delay){
h = createDelayed(h, o, l, scope);
}
if(o.single){
h = createSingle(h, this, fn, scope);
}
if(o.buffer){
h = createBuffered(h, o, l, scope);
}
l.fireFn = h;
return l;
},
findListener : function(fn, scope){
var list = this.listeners,
i = list.length,
l;
scope = scope || this.obj;
while(i--){
l = list[i];
if(l){
if(l.fn == fn && l.scope == scope){
return i;
}
}
}
return -1;
},
isListening : function(fn, scope){
return this.findListener(fn, scope) != -1;
},
removeListener : function(fn, scope){
var index,
l,
k,
me = this,
ret = FALSE;
if((index = me.findListener(fn, scope)) != -1){
if (me.firing) {
me.listeners = me.listeners.slice(0);
}
l = me.listeners[index];
if(l.task) {
l.task.cancel();
delete l.task;
}
k = l.tasks && l.tasks.length;
if(k) {
while(k--) {
l.tasks[k].cancel();
}
delete l.tasks;
}
me.listeners.splice(index, 1);
ret = TRUE;
}
return ret;
},
clearListeners : function(){
var me = this,
l = me.listeners,
i = l.length;
while(i--) {
me.removeListener(l[i].fn, l[i].scope);
}
},
fire : function(){
var me = this,
listeners = me.listeners,
len = listeners.length,
i = 0,
l;
if(len > 0){
me.firing = TRUE;
var args = Array.prototype.slice.call(arguments, 0);
for (; i < len; i++) {
l = listeners[i];
if(l && l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) {
return (me.firing = FALSE);
}
}
}
me.firing = FALSE;
return TRUE;
}
};
})();
Ext.DomHelper = function(){
var tempTableEl = null,
emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,
tableRe = /^table|tbody|tr|td$/i,
confRe = /tag|children|cn|html$/i,
tableElRe = /td|tr|tbody/i,
cssRe = /([a-z0-9-]+)\s*:\s*([^;\s]+(?:\s*[^;\s]+)*);?/gi,
endRe = /end/i,
pub,
afterbegin = 'afterbegin',
afterend = 'afterend',
beforebegin = 'beforebegin',
beforeend = 'beforeend',
ts = '<table>',
te = '</table>',
tbs = ts+'<tbody>',
tbe = '</tbody>'+te,
trs = tbs + '<tr>',
tre = '</tr>'+tbe;
function doInsert(el, o, returnElement, pos, sibling, append){
var newNode = pub.insertHtml(pos, Ext.getDom(el), createHtml(o));
return returnElement ? Ext.get(newNode, true) : newNode;
}
function createHtml(o){
var b = '',
attr,
val,
key,
cn;
if(typeof o == "string"){
b = o;
} else if (Ext.isArray(o)) {
for (var i=0; i < o.length; i++) {
if(o[i]) {
b += createHtml(o[i]);
}
};
} else {
b += '<' + (o.tag = o.tag || 'div');
for (attr in o) {
val = o[attr];
if(!confRe.test(attr)){
if (typeof val == "object") {
b += ' ' + attr + '="';
for (key in val) {
b += key + ':' + val[key] + ';';
};
b += '"';
}else{
b += ' ' + ({cls : 'class', htmlFor : 'for'}[attr] || attr) + '="' + val + '"';
}
}
};
if (emptyTags.test(o.tag)) {
b += '/>';
} else {
b += '>';
if ((cn = o.children || o.cn)) {
b += createHtml(cn);
} else if(o.html){
b += o.html;
}
b += '</' + o.tag + '>';
}
}
return b;
}
function ieTable(depth, s, h, e){
tempTableEl.innerHTML = [s, h, e].join('');
var i = -1,
el = tempTableEl,
ns;
while(++i < depth){
el = el.firstChild;
}
if(ns = el.nextSibling){
var df = document.createDocumentFragment();
while(el){
ns = el.nextSibling;
df.appendChild(el);
el = ns;
}
el = df;
}
return el;
}
function insertIntoTable(tag, where, el, html) {
var node,
before;
tempTableEl = tempTableEl || document.createElement('div');
if(tag == 'td' && (where == afterbegin || where == beforeend) ||
!tableElRe.test(tag) && (where == beforebegin || where == afterend)) {
return;
}
before = where == beforebegin ? el :
where == afterend ? el.nextSibling :
where == afterbegin ? el.firstChild : null;
if (where == beforebegin || where == afterend) {
el = el.parentNode;
}
if (tag == 'td' || (tag == 'tr' && (where == beforeend || where == afterbegin))) {
node = ieTable(4, trs, html, tre);
} else if ((tag == 'tbody' && (where == beforeend || where == afterbegin)) ||
(tag == 'tr' && (where == beforebegin || where == afterend))) {
node = ieTable(3, tbs, html, tbe);
} else {
node = ieTable(2, ts, html, te);
}
el.insertBefore(node, before);
return node;
}
function createContextualFragment(html){
var div = document.createElement("div"),
fragment = document.createDocumentFragment(),
i = 0,
length, childNodes;
div.innerHTML = html;
childNodes = div.childNodes;
length = childNodes.length;
for (; i < length; i++) {
fragment.appendChild(childNodes[i].cloneNode(true));
}
return fragment;
}
pub = {
markup : function(o){
return createHtml(o);
},
applyStyles : function(el, styles){
if (styles) {
var matches;
el = Ext.fly(el);
if (typeof styles == "function") {
styles = styles.call();
}
if (typeof styles == "string") {
cssRe.lastIndex = 0;
while ((matches = cssRe.exec(styles))) {
el.setStyle(matches[1], matches[2]);
}
} else if (typeof styles == "object") {
el.setStyle(styles);
}
}
},
insertHtml : function(where, el, html){
var hash = {},
hashVal,
range,
rangeEl,
setStart,
frag,
rs;
where = where.toLowerCase();
hash[beforebegin] = ['BeforeBegin', 'previousSibling'];
hash[afterend] = ['AfterEnd', 'nextSibling'];
if (el.insertAdjacentHTML) {
if(tableRe.test(el.tagName) && (rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html))){
return rs;
}
hash[afterbegin] = ['AfterBegin', 'firstChild'];
hash[beforeend] = ['BeforeEnd', 'lastChild'];
if ((hashVal = hash[where])) {
el.insertAdjacentHTML(hashVal[0], html);
return el[hashVal[1]];
}
} else {
range = el.ownerDocument.createRange();
setStart = 'setStart' + (endRe.test(where) ? 'After' : 'Before');
if (hash[where]) {
range[setStart](el);
if (!range.createContextualFragment) {
frag = createContextualFragment(html);
}
else {
frag = range.createContextualFragment(html);
}
el.parentNode.insertBefore(frag, where == beforebegin ? el : el.nextSibling);
return el[(where == beforebegin ? 'previous' : 'next') + 'Sibling'];
} else {
rangeEl = (where == afterbegin ? 'first' : 'last') + 'Child';
if (el.firstChild) {
range[setStart](el[rangeEl]);
if (!range.createContextualFragment) {
frag = createContextualFragment(html);
}
else {
frag = range.createContextualFragment(html);
}
if(where == afterbegin){
el.insertBefore(frag, el.firstChild);
}else{
el.appendChild(frag);
}
} else {
el.innerHTML = html;
}
return el[rangeEl];
}
}
throw 'Illegal insertion point -> "' + where + '"';
},
insertBefore : function(el, o, returnElement){
return doInsert(el, o, returnElement, beforebegin);
},
insertAfter : function(el, o, returnElement){
return doInsert(el, o, returnElement, afterend, 'nextSibling');
},
insertFirst : function(el, o, returnElement){
return doInsert(el, o, returnElement, afterbegin, 'firstChild');
},
append : function(el, o, returnElement){
return doInsert(el, o, returnElement, beforeend, '', true);
},
overwrite : function(el, o, returnElement){
el = Ext.getDom(el);
el.innerHTML = createHtml(o);
return returnElement ? Ext.get(el.firstChild) : el.firstChild;
},
createHtml : createHtml
};
return pub;
}();
Ext.Template = function(html){
var me = this,
a = arguments,
buf = [],
v;
if (Ext.isArray(html)) {
html = html.join("");
} else if (a.length > 1) {
for(var i = 0, len = a.length; i < len; i++){
v = a[i];
if(typeof v == 'object'){
Ext.apply(me, v);
} else {
buf.push(v);
}
};
html = buf.join('');
}
me.html = html;
if (me.compiled) {
me.compile();
}
};
Ext.Template.prototype = {
re : /\{([\w\-]+)\}/g,
applyTemplate : function(values){
var me = this;
return me.compiled ?
me.compiled(values) :
me.html.replace(me.re, function(m, name){
return values[name] !== undefined ? values[name] : "";
});
},
set : function(html, compile){
var me = this;
me.html = html;
me.compiled = null;
return compile ? me.compile() : me;
},
compile : function(){
var me = this,
sep = Ext.isGecko ? "+" : ",";
function fn(m, name){
name = "values['" + name + "']";
return "'"+ sep + '(' + name + " == undefined ? '' : " + name + ')' + sep + "'";
}
eval("this.compiled = function(values){ return " + (Ext.isGecko ? "'" : "['") +
me.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
(Ext.isGecko ? "';};" : "'].join('');};"));
return me;
},
insertFirst: function(el, values, returnElement){
return this.doInsert('afterBegin', el, values, returnElement);
},
insertBefore: function(el, values, returnElement){
return this.doInsert('beforeBegin', el, values, returnElement);
},
insertAfter : function(el, values, returnElement){
return this.doInsert('afterEnd', el, values, returnElement);
},
append : function(el, values, returnElement){
return this.doInsert('beforeEnd', el, values, returnElement);
},
doInsert : function(where, el, values, returnEl){
el = Ext.getDom(el);
var newNode = Ext.DomHelper.insertHtml(where, el, this.applyTemplate(values));
return returnEl ? Ext.get(newNode, true) : newNode;
},
overwrite : function(el, values, returnElement){
el = Ext.getDom(el);
el.innerHTML = this.applyTemplate(values);
return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
}
};
Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
Ext.Template.from = function(el, config){
el = Ext.getDom(el);
return new Ext.Template(el.value || el.innerHTML, config || '');
};
Ext.DomQuery = function(){
var cache = {},
simpleCache = {},
valueCache = {},
nonSpace = /\S/,
trimRe = /^\s+|\s+$/g,
tplRe = /\{(\d+)\}/g,
modeRe = /^(\s?[\/>+~]\s?|\s|$)/,
tagTokenRe = /^(#)?([\w\-\*]+)/,
nthRe = /(\d*)n\+?(\d*)/,
nthRe2 = /\D/,
isIE = window.ActiveXObject ? true : false,
key = 30803;
eval("var batch = 30803;");
function child(parent, index){
var i = 0,
n = parent.firstChild;
while(n){
if(n.nodeType == 1){
if(++i == index){
return n;
}
}
n = n.nextSibling;
}
return null;
}
function next(n){
while((n = n.nextSibling) && n.nodeType != 1);
return n;
}
function prev(n){
while((n = n.previousSibling) && n.nodeType != 1);
return n;
}
function children(parent){
var n = parent.firstChild,
nodeIndex = -1,
nextNode;
while(n){
nextNode = n.nextSibling;
if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
parent.removeChild(n);
}else{
n.nodeIndex = ++nodeIndex;
}
n = nextNode;
}
return this;
}
function byClassName(nodeSet, cls){
if(!cls){
return nodeSet;
}
var result = [], ri = -1;
for(var i = 0, ci; ci = nodeSet[i]; i++){
if((' '+ci.className+' ').indexOf(cls) != -1){
result[++ri] = ci;
}
}
return result;
};
function attrValue(n, attr){
if(!n.tagName && typeof n.length != "undefined"){
n = n[0];
}
if(!n){
return null;
}
if(attr == "for"){
return n.htmlFor;
}
if(attr == "class" || attr == "className"){
return n.className;
}
return n.getAttribute(attr) || n[attr];
};
function getNodes(ns, mode, tagName){
var result = [], ri = -1, cs;
if(!ns){
return result;
}
tagName = tagName || "*";
if(typeof ns.getElementsByTagName != "undefined"){
ns = [ns];
}
if(!mode){
for(var i = 0, ni; ni = ns[i]; i++){
cs = ni.getElementsByTagName(tagName);
for(var j = 0, ci; ci = cs[j]; j++){
result[++ri] = ci;
}
}
} else if(mode == "/" || mode == ">"){
var utag = tagName.toUpperCase();
for(var i = 0, ni, cn; ni = ns[i]; i++){
cn = ni.childNodes;
for(var j = 0, cj; cj = cn[j]; j++){
if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
result[++ri] = cj;
}
}
}
}else if(mode == "+"){
var utag = tagName.toUpperCase();
for(var i = 0, n; n = ns[i]; i++){
while((n = n.nextSibling) && n.nodeType != 1);
if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
result[++ri] = n;
}
}
}else if(mode == "~"){
var utag = tagName.toUpperCase();
for(var i = 0, n; n = ns[i]; i++){
while((n = n.nextSibling)){
if (n.nodeName == utag || n.nodeName == tagName || tagName == '*'){
result[++ri] = n;
}
}
}
}
return result;
}
function concat(a, b){
if(b.slice){
return a.concat(b);
}
for(var i = 0, l = b.length; i < l; i++){
a[a.length] = b[i];
}
return a;
}
function byTag(cs, tagName){
if(cs.tagName || cs == document){
cs = [cs];
}
if(!tagName){
return cs;
}
var result = [], ri = -1;
tagName = tagName.toLowerCase();
for(var i = 0, ci; ci = cs[i]; i++){
if(ci.nodeType == 1 && ci.tagName.toLowerCase() == tagName){
result[++ri] = ci;
}
}
return result;
}
function byId(cs, id){
if(cs.tagName || cs == document){
cs = [cs];
}
if(!id){
return cs;
}
var result = [], ri = -1;
for(var i = 0, ci; ci = cs[i]; i++){
if(ci && ci.id == id){
result[++ri] = ci;
return result;
}
}
return result;
}
function byAttribute(cs, attr, value, op, custom){
var result = [],
ri = -1,
useGetStyle = custom == "{",
fn = Ext.DomQuery.operators[op],
a,
xml,
hasXml;
for(var i = 0, ci; ci = cs[i]; i++){
if(ci.nodeType != 1){
continue;
}
if(!hasXml){
xml = Ext.DomQuery.isXml(ci);
hasXml = true;
}
if(!xml){
if(useGetStyle){
a = Ext.DomQuery.getStyle(ci, attr);
} else if (attr == "class" || attr == "className"){
a = ci.className;
} else if (attr == "for"){
a = ci.htmlFor;
} else if (attr == "href"){
a = ci.getAttribute("href", 2);
} else{
a = ci.getAttribute(attr);
}
}else{
a = ci.getAttribute(attr);
}
if((fn && fn(a, value)) || (!fn && a)){
result[++ri] = ci;
}
}
return result;
}
function byPseudo(cs, name, value){
return Ext.DomQuery.pseudos[name](cs, value);
}
function nodupIEXml(cs){
var d = ++key,
r;
cs[0].setAttribute("_nodup", d);
r = [cs[0]];
for(var i = 1, len = cs.length; i < len; i++){
var c = cs[i];
if(!c.getAttribute("_nodup") != d){
c.setAttribute("_nodup", d);
r[r.length] = c;
}
}
for(var i = 0, len = cs.length; i < len; i++){
cs[i].removeAttribute("_nodup");
}
return r;
}
function nodup(cs){
if(!cs){
return [];
}
var len = cs.length, c, i, r = cs, cj, ri = -1;
if(!len || typeof cs.nodeType != "undefined" || len == 1){
return cs;
}
if(isIE && typeof cs[0].selectSingleNode != "undefined"){
return nodupIEXml(cs);
}
var d = ++key;
cs[0]._nodup = d;
for(i = 1; c = cs[i]; i++){
if(c._nodup != d){
c._nodup = d;
}else{
r = [];
for(var j = 0; j < i; j++){
r[++ri] = cs[j];
}
for(j = i+1; cj = cs[j]; j++){
if(cj._nodup != d){
cj._nodup = d;
r[++ri] = cj;
}
}
return r;
}
}
return r;
}
function quickDiffIEXml(c1, c2){
var d = ++key,
r = [];
for(var i = 0, len = c1.length; i < len; i++){
c1[i].setAttribute("_qdiff", d);
}
for(var i = 0, len = c2.length; i < len; i++){
if(c2[i].getAttribute("_qdiff") != d){
r[r.length] = c2[i];
}
}
for(var i = 0, len = c1.length; i < len; i++){
c1[i].removeAttribute("_qdiff");
}
return r;
}
function quickDiff(c1, c2){
var len1 = c1.length,
d = ++key,
r = [];
if(!len1){
return c2;
}
if(isIE && typeof c1[0].selectSingleNode != "undefined"){
return quickDiffIEXml(c1, c2);
}
for(var i = 0; i < len1; i++){
c1[i]._qdiff = d;
}
for(var i = 0, len = c2.length; i < len; i++){
if(c2[i]._qdiff != d){
r[r.length] = c2[i];
}
}
return r;
}
function quickId(ns, mode, root, id){
if(ns == root){
var d = root.ownerDocument || root;
return d.getElementById(id);
}
ns = getNodes(ns, mode, "*");
return byId(ns, id);
}
return {
getStyle : function(el, name){
return Ext.fly(el).getStyle(name);
},
compile : function(path, type){
type = type || "select";
var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"],
mode,
lastPath,
matchers = Ext.DomQuery.matchers,
matchersLn = matchers.length,
modeMatch,
lmode = path.match(modeRe);
if(lmode && lmode[1]){
fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
path = path.replace(lmode[1], "");
}
while(path.substr(0, 1)=="/"){
path = path.substr(1);
}
while(path && lastPath != path){
lastPath = path;
var tokenMatch = path.match(tagTokenRe);
if(type == "select"){
if(tokenMatch){
if(tokenMatch[1] == "#"){
fn[fn.length] = 'n = quickId(n, mode, root, "'+tokenMatch[2]+'");';
}else{
fn[fn.length] = 'n = getNodes(n, mode, "'+tokenMatch[2]+'");';
}
path = path.replace(tokenMatch[0], "");
}else if(path.substr(0, 1) != '@'){
fn[fn.length] = 'n = getNodes(n, mode, "*");';
}
}else{
if(tokenMatch){
if(tokenMatch[1] == "#"){
fn[fn.length] = 'n = byId(n, "'+tokenMatch[2]+'");';
}else{
fn[fn.length] = 'n = byTag(n, "'+tokenMatch[2]+'");';
}
path = path.replace(tokenMatch[0], "");
}
}
while(!(modeMatch = path.match(modeRe))){
var matched = false;
for(var j = 0; j < matchersLn; j++){
var t = matchers[j];
var m = path.match(t.re);
if(m){
fn[fn.length] = t.select.replace(tplRe, function(x, i){
return m[i];
});
path = path.replace(m[0], "");
matched = true;
break;
}
}
if(!matched){
throw 'Error parsing selector, parsing failed at "' + path + '"';
}
}
if(modeMatch[1]){
fn[fn.length] = 'mode="'+modeMatch[1].replace(trimRe, "")+'";';
path = path.replace(modeMatch[1], "");
}
}
fn[fn.length] = "return nodup(n);\n}";
eval(fn.join(""));
return f;
},
jsSelect: function(path, root, type){
root = root || document;
if(typeof root == "string"){
root = document.getElementById(root);
}
var paths = path.split(","),
results = [];
for(var i = 0, len = paths.length; i < len; i++){
var subPath = paths[i].replace(trimRe, "");
if(!cache[subPath]){
cache[subPath] = Ext.DomQuery.compile(subPath);
if(!cache[subPath]){
throw subPath + " is not a valid selector";
}
}
var result = cache[subPath](root);
if(result && result != document){
results = results.concat(result);
}
}
if(paths.length > 1){
return nodup(results);
}
return results;
},
isXml: function(el) {
var docEl = (el ? el.ownerDocument || el : 0).documentElement;
return docEl ? docEl.nodeName !== "HTML" : false;
},
select : document.querySelectorAll ? function(path, root, type) {
root = root || document;
if (!Ext.DomQuery.isXml(root)) {
try {
var cs = root.querySelectorAll(path);
return Ext.toArray(cs);
}
catch (ex) {}
}
return Ext.DomQuery.jsSelect.call(this, path, root, type);
} : function(path, root, type) {
return Ext.DomQuery.jsSelect.call(this, path, root, type);
},
selectNode : function(path, root){
return Ext.DomQuery.select(path, root)[0];
},
selectValue : function(path, root, defaultValue){
path = path.replace(trimRe, "");
if(!valueCache[path]){
valueCache[path] = Ext.DomQuery.compile(path, "select");
}
var n = valueCache[path](root), v;
n = n[0] ? n[0] : n;
if (typeof n.normalize == 'function') n.normalize();
v = (n && n.firstChild ? n.firstChild.nodeValue : null);
return ((v === null||v === undefined||v==='') ? defaultValue : v);
},
selectNumber : function(path, root, defaultValue){
var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
return parseFloat(v);
},
is : function(el, ss){
if(typeof el == "string"){
el = document.getElementById(el);
}
var isArray = Ext.isArray(el),
result = Ext.DomQuery.filter(isArray ? el : [el], ss);
return isArray ? (result.length == el.length) : (result.length > 0);
},
filter : function(els, ss, nonMatches){
ss = ss.replace(trimRe, "");
if(!simpleCache[ss]){
simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
}
var result = simpleCache[ss](els);
return nonMatches ? quickDiff(result, els) : result;
},
matchers : [{
re: /^\.([\w\-]+)/,
select: 'n = byClassName(n, " {1} ");'
}, {
re: /^\:([\w\-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
select: 'n = byPseudo(n, "{1}", "{2}");'
},{
re: /^(?:([\[\{])(?:@)?([\w\-]+)\s?(?:(=|.=)\s?(["']?)(.*?)\4)?[\]\}])/,
select: 'n = byAttribute(n, "{2}", "{5}", "{3}", "{1}");'
}, {
re: /^#([\w\-]+)/,
select: 'n = byId(n, "{1}");'
},{
re: /^@([\w\-]+)/,
select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
}
],
/**
* Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
* New operators can be added as long as the match the format <i>c</i>= where <i>c</i> is any character other than space, &gt; &lt;.
*/
operators : {
"=" : function(a, v){
return a == v;
},
"!=" : function(a, v){
return a != v;
},
"^=" : function(a, v){
return a && a.substr(0, v.length) == v;
},
"$=" : function(a, v){
return a && a.substr(a.length-v.length) == v;
},
"*=" : function(a, v){
return a && a.indexOf(v) !== -1;
},
"%=" : function(a, v){
return (a % v) == 0;
},
"|=" : function(a, v){
return a && (a == v || a.substr(0, v.length+1) == v+'-');
},
"~=" : function(a, v){
return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
}
},
/**
* <p>Object hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed
* two parameters:</p><div class="mdetail-params"><ul>
* <li><b>c</b> : Array<div class="sub-desc">An Array of DOM elements to filter.</div></li>
* <li><b>v</b> : String<div class="sub-desc">The argument (if any) supplied in the selector.</div></li>
* </ul></div>
* <p>A filter function returns an Array of DOM elements which conform to the pseudo class.</p>
* <p>In addition to the provided pseudo classes listed above such as <code>first-child</code> and <code>nth-child</code>,
* developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.</p>
* <p>For example, to filter <code>&lt;a></code> elements to only return links to <i>external</i> resources:</p>
* <code><pre>
Ext.DomQuery.pseudos.external = function(c, v){
var r = [], ri = -1;
for(var i = 0, ci; ci = c[i]; i++){
// Include in result set only if it's a link to an external resource
if(ci.hostname != location.hostname){
r[++ri] = ci;
}
}
return r;
};</pre></code>
* Then external links could be gathered with the following statement:<code><pre>
var externalLinks = Ext.select("a:external");
</code></pre>
*/
pseudos : {
"first-child" : function(c){
var r = [], ri = -1, n;
for(var i = 0, ci; ci = n = c[i]; i++){
while((n = n.previousSibling) && n.nodeType != 1);
if(!n){
r[++ri] = ci;
}
}
return r;
},
"last-child" : function(c){
var r = [], ri = -1, n;
for(var i = 0, ci; ci = n = c[i]; i++){
while((n = n.nextSibling) && n.nodeType != 1);
if(!n){
r[++ri] = ci;
}
}
return r;
},
"nth-child" : function(c, a) {
var r = [], ri = -1,
m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
f = (m[1] || 1) - 0, l = m[2] - 0;
for(var i = 0, n; n = c[i]; i++){
var pn = n.parentNode;
if (batch != pn._batch) {
var j = 0;
for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
if(cn.nodeType == 1){
cn.nodeIndex = ++j;
}
}
pn._batch = batch;
}
if (f == 1) {
if (l == 0 || n.nodeIndex == l){
r[++ri] = n;
}
} else if ((n.nodeIndex + l) % f == 0){
r[++ri] = n;
}
}
return r;
},
"only-child" : function(c){
var r = [], ri = -1;;
for(var i = 0, ci; ci = c[i]; i++){
if(!prev(ci) && !next(ci)){
r[++ri] = ci;
}
}
return r;
},
"empty" : function(c){
var r = [], ri = -1;
for(var i = 0, ci; ci = c[i]; i++){
var cns = ci.childNodes, j = 0, cn, empty = true;
while(cn = cns[j]){
++j;
if(cn.nodeType == 1 || cn.nodeType == 3){
empty = false;
break;
}
}
if(empty){
r[++ri] = ci;
}
}
return r;
},
"contains" : function(c, v){
var r = [], ri = -1;
for(var i = 0, ci; ci = c[i]; i++){
if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
r[++ri] = ci;
}
}
return r;
},
"nodeValue" : function(c, v){
var r = [], ri = -1;
for(var i = 0, ci; ci = c[i]; i++){
if(ci.firstChild && ci.firstChild.nodeValue == v){
r[++ri] = ci;
}
}
return r;
},
"checked" : function(c){
var r = [], ri = -1;
for(var i = 0, ci; ci = c[i]; i++){
if(ci.checked == true){
r[++ri] = ci;
}
}
return r;
},
"not" : function(c, ss){
return Ext.DomQuery.filter(c, ss, true);
},
"any" : function(c, selectors){
var ss = selectors.split('|'),
r = [], ri = -1, s;
for(var i = 0, ci; ci = c[i]; i++){
for(var j = 0; s = ss[j]; j++){
if(Ext.DomQuery.is(ci, s)){
r[++ri] = ci;
break;
}
}
}
return r;
},
"odd" : function(c){
return this["nth-child"](c, "odd");
},
"even" : function(c){
return this["nth-child"](c, "even");
},
"nth" : function(c, a){
return c[a-1] || [];
},
"first" : function(c){
return c[0] || [];
},
"last" : function(c){
return c[c.length-1] || [];
},
"has" : function(c, ss){
var s = Ext.DomQuery.select,
r = [], ri = -1;
for(var i = 0, ci; ci = c[i]; i++){
if(s(ss, ci).length > 0){
r[++ri] = ci;
}
}
return r;
},
"next" : function(c, ss){
var is = Ext.DomQuery.is,
r = [], ri = -1;
for(var i = 0, ci; ci = c[i]; i++){
var n = next(ci);
if(n && is(n, ss)){
r[++ri] = ci;
}
}
return r;
},
"prev" : function(c, ss){
var is = Ext.DomQuery.is,
r = [], ri = -1;
for(var i = 0, ci; ci = c[i]; i++){
var n = prev(ci);
if(n && is(n, ss)){
r[++ri] = ci;
}
}
return r;
}
}
};
}();
/**
* Selects an array of DOM nodes by CSS/XPath selector. Shorthand of {@link Ext.DomQuery#select}
* @param {String} path The selector/xpath query
* @param {Node} root (optional) The start of the query (defaults to document).
* @return {Array}
* @member Ext
* @method query
*/
Ext.query = Ext.DomQuery.select;
/**
* @class Ext.util.DelayedTask
* <p> The DelayedTask class provides a convenient way to "buffer" the execution of a method,
* performing setTimeout where a new timeout cancels the old timeout. When called, the
* task will wait the specified time period before executing. If durng that time period,
* the task is called again, the original call will be cancelled. This continues so that
* the function is only called a single time for each iteration.</p>
* <p>This method is especially useful for things like detecting whether a user has finished
* typing in a text field. An example would be performing validation on a keypress. You can
* use this class to buffer the keypress events for a certain number of milliseconds, and
* perform only if they stop for that amount of time. Usage:</p><pre><code>
var task = new Ext.util.DelayedTask(function(){
alert(Ext.getDom('myInputField').value.length);
});
// Wait 500ms before calling our function. If the user presses another key
// during that 500ms, it will be cancelled and we'll wait another 500ms.
Ext.get('myInputField').on('keypress', function(){
task.{@link #delay}(500);
});
* </code></pre>
* <p>Note that we are using a DelayedTask here to illustrate a point. The configuration
* option <tt>buffer</tt> for {@link Ext.util.Observable#addListener addListener/on} will
* also setup a delayed task for you to buffer events.</p>
* @constructor The parameters to this constructor serve as defaults and are not required.
* @param {Function} fn (optional) The default function to call.
* @param {Object} scope The default scope (The <code><b>this</b></code> reference) in which the
* function is called. If not specified, <code>this</code> will refer to the browser window.
* @param {Array} args (optional) The default Array of arguments.
*/
Ext.util.DelayedTask = function(fn, scope, args){
var me = this,
id,
call = function(){
clearInterval(id);
id = null;
fn.apply(scope, args || []);
};
/**
* Cancels any pending timeout and queues a new one
* @param {Number} delay The milliseconds to delay
* @param {Function} newFn (optional) Overrides function passed to constructor
* @param {Object} newScope (optional) Overrides scope passed to constructor. Remember that if no scope
* is specified, <code>this</code> will refer to the browser window.
* @param {Array} newArgs (optional) Overrides args passed to constructor
*/
me.delay = function(delay, newFn, newScope, newArgs){
me.cancel();
fn = newFn || fn;
scope = newScope || scope;
args = newArgs || args;
id = setInterval(call, delay);
};
/**
* Cancel the last queued timeout
*/
me.cancel = function(){
if(id){
clearInterval(id);
id = null;
}
};
};/**
* @class Ext.Element
* <p>Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.</p>
* <p>All instances of this class inherit the methods of {@link Ext.Fx} making visual effects easily available to all DOM elements.</p>
* <p>Note that the events documented in this class are not Ext events, they encapsulate browser events. To
* access the underlying browser event, see {@link Ext.EventObject#browserEvent}. Some older
* browsers may not support the full range of events. Which events are supported is beyond the control of ExtJs.</p>
* Usage:<br>
<pre><code>
// by id
var el = Ext.get("my-div");
// by DOM element reference
var el = Ext.get(myDivElement);
</code></pre>
* <b>Animations</b><br />
* <p>When an element is manipulated, by default there is no animation.</p>
* <pre><code>
var el = Ext.get("my-div");
// no animation
el.setWidth(100);
* </code></pre>
* <p>Many of the functions for manipulating an element have an optional "animate" parameter. This
* parameter can be specified as boolean (<tt>true</tt>) for default animation effects.</p>
* <pre><code>
// default animation
el.setWidth(100, true);
* </code></pre>
*
* <p>To configure the effects, an object literal with animation options to use as the Element animation
* configuration object can also be specified. Note that the supported Element animation configuration
* options are a subset of the {@link Ext.Fx} animation options specific to Fx effects. The supported
* Element animation configuration options are:</p>
<pre>
Option Default Description
--------- -------- ---------------------------------------------
{@link Ext.Fx#duration duration} .35 The duration of the animation in seconds
{@link Ext.Fx#easing easing} easeOut The easing method
{@link Ext.Fx#callback callback} none A function to execute when the anim completes
{@link Ext.Fx#scope scope} this The scope (this) of the callback function
</pre>
*
* <pre><code>
// Element animation options object
var opt = {
{@link Ext.Fx#duration duration}: 1,
{@link Ext.Fx#easing easing}: 'elasticIn',
{@link Ext.Fx#callback callback}: this.foo,
{@link Ext.Fx#scope scope}: this
};
// animation with some options set
el.setWidth(100, opt);
* </code></pre>
* <p>The Element animation object being used for the animation will be set on the options
* object as "anim", which allows you to stop or manipulate the animation. Here is an example:</p>
* <pre><code>
// using the "anim" property to get the Anim object
if(opt.anim.isAnimated()){
opt.anim.stop();
}
* </code></pre>
* <p>Also see the <tt>{@link #animate}</tt> method for another animation technique.</p>
* <p><b> Composite (Collections of) Elements</b></p>
* <p>For working with collections of Elements, see {@link Ext.CompositeElement}</p>
* @constructor Create a new Element directly.
* @param {String/HTMLElement} element
* @param {Boolean} forceNew (optional) By default the constructor checks to see if there is already an instance of this element in the cache and if there is it returns the same instance. This will skip that check (useful for extending this class).
*/
(function(){
var DOC = document;
Ext.Element = function(element, forceNew){
var dom = typeof element == "string" ?
DOC.getElementById(element) : element,
id;
if(!dom) return null;
id = dom.id;
if(!forceNew && id && Ext.elCache[id]){ // element object already exists
return Ext.elCache[id].el;
}
/**
* The DOM element
* @type HTMLElement
*/
this.dom = dom;
/**
* The DOM element ID
* @type String
*/
this.id = id || Ext.id(dom);
};
var DH = Ext.DomHelper,
El = Ext.Element,
EC = Ext.elCache;
El.prototype = {
/**
* Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)
* @param {Object} o The object with the attributes
* @param {Boolean} useSet (optional) false to override the default setAttribute to use expandos.
* @return {Ext.Element} this
*/
set : function(o, useSet){
var el = this.dom,
attr,
val,
useSet = (useSet !== false) && !!el.setAttribute;
for (attr in o) {
if (o.hasOwnProperty(attr)) {
val = o[attr];
if (attr == 'style') {
DH.applyStyles(el, val);
} else if (attr == 'cls') {
el.className = val;
} else if (useSet) {
el.setAttribute(attr, val);
} else {
el[attr] = val;
}
}
}
return this;
},
// Mouse events
/**
* @event click
* Fires when a mouse click is detected within the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event contextmenu
* Fires when a right click is detected within the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event dblclick
* Fires when a mouse double click is detected within the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event mousedown
* Fires when a mousedown is detected within the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event mouseup
* Fires when a mouseup is detected within the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event mouseover
* Fires when a mouseover is detected within the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event mousemove
* Fires when a mousemove is detected with the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event mouseout
* Fires when a mouseout is detected with the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event mouseenter
* Fires when the mouse enters the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event mouseleave
* Fires when the mouse leaves the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
// Keyboard events
/**
* @event keypress
* Fires when a keypress is detected within the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event keydown
* Fires when a keydown is detected within the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event keyup
* Fires when a keyup is detected within the element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
// HTML frame/object events
/**
* @event load
* Fires when the user agent finishes loading all content within the element. Only supported by window, frames, objects and images.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event unload
* Fires when the user agent removes all content from a window or frame. For elements, it fires when the target element or any of its content has been removed.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event abort
* Fires when an object/image is stopped from loading before completely loaded.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event error
* Fires when an object/image/frame cannot be loaded properly.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event resize
* Fires when a document view is resized.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event scroll
* Fires when a document view is scrolled.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
// Form events
/**
* @event select
* Fires when a user selects some text in a text field, including input and textarea.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event change
* Fires when a control loses the input focus and its value has been modified since gaining focus.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event submit
* Fires when a form is submitted.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event reset
* Fires when a form is reset.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event focus
* Fires when an element receives focus either via the pointing device or by tab navigation.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event blur
* Fires when an element loses focus either via the pointing device or by tabbing navigation.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
// User Interface events
/**
* @event DOMFocusIn
* Where supported. Similar to HTML focus event, but can be applied to any focusable element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event DOMFocusOut
* Where supported. Similar to HTML blur event, but can be applied to any focusable element.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event DOMActivate
* Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
// DOM Mutation events
/**
* @event DOMSubtreeModified
* Where supported. Fires when the subtree is modified.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event DOMNodeInserted
* Where supported. Fires when a node has been added as a child of another node.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event DOMNodeRemoved
* Where supported. Fires when a descendant node of the element is removed.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event DOMNodeRemovedFromDocument
* Where supported. Fires when a node is being removed from a document.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event DOMNodeInsertedIntoDocument
* Where supported. Fires when a node is being inserted into a document.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event DOMAttrModified
* Where supported. Fires when an attribute has been modified.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* @event DOMCharacterDataModified
* Where supported. Fires when the character data has been modified.
* @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
* @param {HtmlElement} t The target of the event.
* @param {Object} o The options configuration passed to the {@link #addListener} call.
*/
/**
* The default unit to append to CSS values where a unit isn't provided (defaults to px).
* @type String
*/
defaultUnit : "px",
/**
* Returns true if this element matches the passed simple selector (e.g. div.some-class or span:first-child)
* @param {String} selector The simple selector to test
* @return {Boolean} True if this element matches the selector, else false
*/
is : function(simpleSelector){
return Ext.DomQuery.is(this.dom, simpleSelector);
},
/**
* Tries to focus the element. Any exceptions are caught and ignored.
* @param {Number} defer (optional) Milliseconds to defer the focus
* @return {Ext.Element} this
*/
focus : function(defer, /* private */ dom) {
var me = this,
dom = dom || me.dom;
try{
if(Number(defer)){
me.focus.defer(defer, null, [null, dom]);
}else{
dom.focus();
}
}catch(e){}
return me;
},
/**
* Tries to blur the element. Any exceptions are caught and ignored.
* @return {Ext.Element} this
*/
blur : function() {
try{
this.dom.blur();
}catch(e){}
return this;
},
/**
* Returns the value of the "value" attribute
* @param {Boolean} asNumber true to parse the value as a number
* @return {String/Number}
*/
getValue : function(asNumber){
var val = this.dom.value;
return asNumber ? parseInt(val, 10) : val;
},
/**
* Appends an event handler to this element. The shorthand version {@link #on} is equivalent.
* @param {String} eventName The name of event to handle.
* @param {Function} fn The handler function the event invokes. This function is passed
* the following parameters:<ul>
* <li><b>evt</b> : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
* <li><b>el</b> : HtmlElement<div class="sub-desc">The DOM element which was the target of the event.
* Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
* <li><b>o</b> : Object<div class="sub-desc">The options object from the addListener call.</div></li>
* </ul>
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the handler function is executed.
* <b>If omitted, defaults to this Element.</b>.
* @param {Object} options (optional) An object containing handler configuration properties.
* This may contain any of the following properties:<ul>
* <li><b>scope</b> Object : <div class="sub-desc">The scope (<code><b>this</b></code> reference) in which the handler function is executed.
* <b>If omitted, defaults to this Element.</b></div></li>
* <li><b>delegate</b> String: <div class="sub-desc">A simple selector to filter the target or look for a descendant of the target. See below for additional details.</div></li>
* <li><b>stopEvent</b> Boolean: <div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
* <li><b>preventDefault</b> Boolean: <div class="sub-desc">True to prevent the default action</div></li>
* <li><b>stopPropagation</b> Boolean: <div class="sub-desc">True to prevent event propagation</div></li>
* <li><b>normalized</b> Boolean: <div class="sub-desc">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>
* <li><b>target</b> Ext.Element: <div class="sub-desc">Only call the handler if the event was fired on the target Element, <i>not</i> if the event was bubbled up from a child node.</div></li>
* <li><b>delay</b> Number: <div class="sub-desc">The number of milliseconds to delay the invocation of the handler after the event fires.</div></li>
* <li><b>single</b> Boolean: <div class="sub-desc">True to add a handler to handle just the next firing of the event, and then remove itself.</div></li>
* <li><b>buffer</b> Number: <div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
* by the specified number of milliseconds. If the event fires again within that time, the original
* handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
* </ul><br>
* <p>
* <b>Combining Options</b><br>
* In the following examples, the shorthand form {@link #on} is used rather than the more verbose
* addListener. The two are equivalent. Using the options argument, it is possible to combine different
* types of listeners:<br>
* <br>
* A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the
* options object. The options object is available as the third parameter in the handler function.<div style="margin: 5px 20px 20px;">
* Code:<pre><code>
el.on('click', this.onClick, this, {
single: true,
delay: 100,
stopEvent : true,
forumId: 4
});</code></pre></p>
* <p>
* <b>Attaching multiple handlers in 1 call</b><br>
* The method also allows for a single argument to be passed which is a config object containing properties
* which specify multiple handlers.</p>
* <p>
* Code:<pre><code>
el.on({
'click' : {
fn: this.onClick,
scope: this,
delay: 100
},
'mouseover' : {
fn: this.onMouseOver,
scope: this
},
'mouseout' : {
fn: this.onMouseOut,
scope: this
}
});</code></pre>
* <p>
* Or a shorthand syntax:<br>
* Code:<pre><code></p>
el.on({
'click' : this.onClick,
'mouseover' : this.onMouseOver,
'mouseout' : this.onMouseOut,
scope: this
});
* </code></pre></p>
* <p><b>delegate</b></p>
* <p>This is a configuration option that you can pass along when registering a handler for
* an event to assist with event delegation. Event delegation is a technique that is used to
* reduce memory consumption and prevent exposure to memory-leaks. By registering an event
* for a container element as opposed to each element within a container. By setting this
* configuration option to a simple selector, the target element will be filtered to look for
* a descendant of the target.
* For example:<pre><code>
// using this markup:
&lt;div id='elId'>
&lt;p id='p1'>paragraph one&lt;/p>
&lt;p id='p2' class='clickable'>paragraph two&lt;/p>
&lt;p id='p3'>paragraph three&lt;/p>
&lt;/div>
// utilize event delegation to registering just one handler on the container element:
el = Ext.get('elId');
el.on(
'click',
function(e,t) {
// handle click
console.info(t.id); // 'p2'
},
this,
{
// filter the target element to be a descendant with the class 'clickable'
delegate: '.clickable'
}
);
* </code></pre></p>
* @return {Ext.Element} this
*/
addListener : function(eventName, fn, scope, options){
Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
return this;
},
/**
* Removes an event handler from this element. The shorthand version {@link #un} is equivalent.
* <b>Note</b>: if a <i>scope</i> was explicitly specified when {@link #addListener adding} the
* listener, the same scope must be specified here.
* Example:
* <pre><code>
el.removeListener('click', this.handlerFn);
// or
el.un('click', this.handlerFn);
</code></pre>
* @param {String} eventName The name of the event from which to remove the handler.
* @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
* @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
* then this must refer to the same object.
* @return {Ext.Element} this
*/
removeListener : function(eventName, fn, scope){
Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);
return this;
},
/**
* Removes all previous added listeners from this element
* @return {Ext.Element} this
*/
removeAllListeners : function(){
Ext.EventManager.removeAll(this.dom);
return this;
},
/**
* Recursively removes all previous added listeners from this element and its children
* @return {Ext.Element} this
*/
purgeAllListeners : function() {
Ext.EventManager.purgeElement(this, true);
return this;
},
/**
* @private Test if size has a unit, otherwise appends the default
*/
addUnits : function(size){
if(size === "" || size == "auto" || size === undefined){
size = size || '';
} else if(!isNaN(size) || !unitPattern.test(size)){
size = size + (this.defaultUnit || 'px');
}
return size;
},
/**
* <p>Updates the <a href="http:
* from a specified URL. Note that this is subject to the <a href="http://en.wikipedia.org/wiki/Same_origin_policy">Same Origin Policy</a></p>
* <p>Updating innerHTML of an element will <b>not</b> execute embedded <tt>&lt;script></tt> elements. This is a browser restriction.</p>
* @param {Mixed} options. Either a sring containing the URL from which to load the HTML, or an {@link Ext.Ajax#request} options object specifying
* exactly how to request the HTML.
* @return {Ext.Element} this
*/
load : function(url, params, cb){
Ext.Ajax.request(Ext.apply({
params: params,
url: url.url || url,
callback: cb,
el: this.dom,
indicatorText: url.indicatorText || ''
}, Ext.isObject(url) ? url : {}));
return this;
},
isBorderBox : function(){
return Ext.isBorderBox || Ext.isForcedBorderBox || noBoxAdjust[(this.dom.tagName || "").toLowerCase()];
},
remove : function(){
var me = this,
dom = me.dom;
if (dom) {
delete me.dom;
Ext.removeNode(dom);
}
},
hover : function(overFn, outFn, scope, options){
var me = this;
me.on('mouseenter', overFn, scope || me.dom, options);
me.on('mouseleave', outFn, scope || me.dom, options);
return me;
},
contains : function(el){
return !el ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);
},
getAttributeNS : function(ns, name){
return this.getAttribute(name, ns);
},
getAttribute: (function(){
var test = document.createElement('table'),
isBrokenOnTable = false,
hasGetAttribute = 'getAttribute' in test,
unknownRe = /undefined|unknown/;
if (hasGetAttribute) {
try {
test.getAttribute('ext:qtip');
} catch (e) {
isBrokenOnTable = true;
}
return function(name, ns) {
var el = this.dom,
value;
if (el.getAttributeNS) {
value = el.getAttributeNS(ns, name) || null;
}
if (value == null) {
if (ns) {
if (isBrokenOnTable && el.tagName.toUpperCase() == 'TABLE') {
try {
value = el.getAttribute(ns + ':' + name);
} catch (e) {
value = '';
}
} else {
value = el.getAttribute(ns + ':' + name);
}
} else {
value = el.getAttribute(name) || el[name];
}
}
return value || '';
};
} else {
return function(name, ns) {
var el = this.om,
value,
attribute;
if (ns) {
attribute = el[ns + ':' + name];
value = unknownRe.test(typeof attribute) ? undefined : attribute;
} else {
value = el[name];
}
return value || '';
};
}
test = null;
})(),
update : function(html) {
if (this.dom) {
this.dom.innerHTML = html;
}
return this;
}
};
var ep = El.prototype;
El.addMethods = function(o){
Ext.apply(ep, o);
};
ep.on = ep.addListener;
ep.un = ep.removeListener;
ep.autoBoxAdjust = true;
var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
docEl;
El.get = function(el){
var ex,
elm,
id;
if(!el){ return null; }
if (typeof el == "string") {
if (!(elm = DOC.getElementById(el))) {
return null;
}
if (EC[el] && EC[el].el) {
ex = EC[el].el;
ex.dom = elm;
} else {
ex = El.addToCache(new El(elm));
}
return ex;
} else if (el.tagName) {
if(!(id = el.id)){
id = Ext.id(el);
}
if (EC[id] && EC[id].el) {
ex = EC[id].el;
ex.dom = el;
} else {
ex = El.addToCache(new El(el));
}
return ex;
} else if (el instanceof El) {
if(el != docEl){
if (Ext.isIE && (el.id == undefined || el.id == '')) {
el.dom = el.dom;
} else {
el.dom = DOC.getElementById(el.id) || el.dom;
}
}
return el;
} else if(el.isComposite) {
return el;
} else if(Ext.isArray(el)) {
return El.select(el);
} else if(el == DOC) {
if(!docEl){
var f = function(){};
f.prototype = El.prototype;
docEl = new f();
docEl.dom = DOC;
}
return docEl;
}
return null;
};
El.addToCache = function(el, id){
id = id || el.id;
EC[id] = {
el: el,
data: {},
events: {}
};
return el;
};
El.data = function(el, key, value){
el = El.get(el);
if (!el) {
return null;
}
var c = EC[el.id].data;
if(arguments.length == 2){
return c[key];
}else{
return (c[key] = value);
}
};
function garbageCollect(){
if(!Ext.enableGarbageCollector){
clearInterval(El.collectorThreadId);
} else {
var eid,
el,
d,
o;
for(eid in EC){
o = EC[eid];
if(o.skipGC){
continue;
}
el = o.el;
d = el.dom;
if(!d || !d.parentNode || (!d.offsetParent && !DOC.getElementById(eid))){
if(Ext.enableListenerCollection){
Ext.EventManager.removeAll(d);
}
delete EC[eid];
}
}
if (Ext.isIE) {
var t = {};
for (eid in EC) {
t[eid] = EC[eid];
}
EC = Ext.elCache = t;
}
}
}
El.collectorThreadId = setInterval(garbageCollect, 30000);
var flyFn = function(){};
flyFn.prototype = El.prototype;
El.Flyweight = function(dom){
this.dom = dom;
};
El.Flyweight.prototype = new flyFn();
El.Flyweight.prototype.isFlyweight = true;
El._flyweights = {};
El.fly = function(el, named){
var ret = null;
named = named || '_global';
if (el = Ext.getDom(el)) {
(El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;
ret = El._flyweights[named];
}
return ret;
};
Ext.get = El.get;
Ext.fly = El.fly;
var noBoxAdjust = Ext.isStrict ? {
select:1
} : {
input:1, select:1, textarea:1
};
if(Ext.isIE || Ext.isGecko){
noBoxAdjust['button'] = 1;
}
})();
Ext.Element.addMethods(function(){
var PARENTNODE = 'parentNode',
NEXTSIBLING = 'nextSibling',
PREVIOUSSIBLING = 'previousSibling',
DQ = Ext.DomQuery,
GET = Ext.get;
return {
findParent : function(simpleSelector, maxDepth, returnEl){
var p = this.dom,
b = document.body,
depth = 0,
stopEl;
if(Ext.isGecko && Object.prototype.toString.call(p) == '[object XULElement]') {
return null;
}
maxDepth = maxDepth || 50;
if (isNaN(maxDepth)) {
stopEl = Ext.getDom(maxDepth);
maxDepth = Number.MAX_VALUE;
}
while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
if(DQ.is(p, simpleSelector)){
return returnEl ? GET(p) : p;
}
depth++;
p = p.parentNode;
}
return null;
},
findParentNode : function(simpleSelector, maxDepth, returnEl){
var p = Ext.fly(this.dom.parentNode, '_internal');
return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
},
up : function(simpleSelector, maxDepth){
return this.findParentNode(simpleSelector, maxDepth, true);
},
select : function(selector){
return Ext.Element.select(selector, this.dom);
},
query : function(selector){
return DQ.select(selector, this.dom);
},
child : function(selector, returnDom){
var n = DQ.selectNode(selector, this.dom);
return returnDom ? n : GET(n);
},
down : function(selector, returnDom){
var n = DQ.selectNode(" > " + selector, this.dom);
return returnDom ? n : GET(n);
},
parent : function(selector, returnDom){
return this.matchNode(PARENTNODE, PARENTNODE, selector, returnDom);
},
next : function(selector, returnDom){
return this.matchNode(NEXTSIBLING, NEXTSIBLING, selector, returnDom);
},
prev : function(selector, returnDom){
return this.matchNode(PREVIOUSSIBLING, PREVIOUSSIBLING, selector, returnDom);
},
first : function(selector, returnDom){
return this.matchNode(NEXTSIBLING, 'firstChild', selector, returnDom);
},
last : function(selector, returnDom){
return this.matchNode(PREVIOUSSIBLING, 'lastChild', selector, returnDom);
},
matchNode : function(dir, start, selector, returnDom){
var n = this.dom[start];
while(n){
if(n.nodeType == 1 && (!selector || DQ.is(n, selector))){
return !returnDom ? GET(n) : n;
}
n = n[dir];
}
return null;
}
};
}());
Ext.Element.addMethods(
function() {
var GETDOM = Ext.getDom,
GET = Ext.get,
DH = Ext.DomHelper;
return {
appendChild: function(el){
return GET(el).appendTo(this);
},
appendTo: function(el){
GETDOM(el).appendChild(this.dom);
return this;
},
insertBefore: function(el){
(el = GETDOM(el)).parentNode.insertBefore(this.dom, el);
return this;
},
insertAfter: function(el){
(el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);
return this;
},
insertFirst: function(el, returnDom){
el = el || {};
if(el.nodeType || el.dom || typeof el == 'string'){
el = GETDOM(el);
this.dom.insertBefore(el, this.dom.firstChild);
return !returnDom ? GET(el) : el;
}else{
return this.createChild(el, this.dom.firstChild, returnDom);
}
},
replace: function(el){
el = GET(el);
this.insertBefore(el);
el.remove();
return this;
},
replaceWith: function(el){
var me = this;
if(el.nodeType || el.dom || typeof el == 'string'){
el = GETDOM(el);
me.dom.parentNode.insertBefore(el, me.dom);
}else{
el = DH.insertBefore(me.dom, el);
}
delete Ext.elCache[me.id];
Ext.removeNode(me.dom);
me.id = Ext.id(me.dom = el);
Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me);
return me;
},
createChild: function(config, insertBefore, returnDom){
config = config || {tag:'div'};
return insertBefore ?
DH.insertBefore(insertBefore, config, returnDom !== true) :
DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
},
wrap: function(config, returnDom){
var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);
newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
return newEl;
},
insertHtml : function(where, html, returnEl){
var el = DH.insertHtml(where, this.dom, html);
return returnEl ? Ext.get(el) : el;
}
};
}());
Ext.Element.addMethods(function(){
var supports = Ext.supports,
propCache = {},
camelRe = /(-[a-z])/gi,
view = document.defaultView,
opacityRe = /alpha\(opacity=(.*)\)/i,
trimRe = /^\s+|\s+$/g,
EL = Ext.Element,
spacesRe = /\s+/,
wordsRe = /\w/g,
PADDING = "padding",
MARGIN = "margin",
BORDER = "border",
LEFT = "-left",
RIGHT = "-right",
TOP = "-top",
BOTTOM = "-bottom",
WIDTH = "-width",
MATH = Math,
HIDDEN = 'hidden',
ISCLIPPED = 'isClipped',
OVERFLOW = 'overflow',
OVERFLOWX = 'overflow-x',
OVERFLOWY = 'overflow-y',
ORIGINALCLIP = 'originalClip',
borders = {l: BORDER + LEFT + WIDTH, r: BORDER + RIGHT + WIDTH, t: BORDER + TOP + WIDTH, b: BORDER + BOTTOM + WIDTH},
paddings = {l: PADDING + LEFT, r: PADDING + RIGHT, t: PADDING + TOP, b: PADDING + BOTTOM},
margins = {l: MARGIN + LEFT, r: MARGIN + RIGHT, t: MARGIN + TOP, b: MARGIN + BOTTOM},
data = Ext.Element.data;
function camelFn(m, a) {
return a.charAt(1).toUpperCase();
}
function chkCache(prop) {
return propCache[prop] || (propCache[prop] = prop == 'float' ? (supports.cssFloat ? 'cssFloat' : 'styleFloat') : prop.replace(camelRe, camelFn));
}
return {
adjustWidth : function(width) {
var me = this;
var isNum = (typeof width == "number");
if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
width -= (me.getBorderWidth("lr") + me.getPadding("lr"));
}
return (isNum && width < 0) ? 0 : width;
},
adjustHeight : function(height) {
var me = this;
var isNum = (typeof height == "number");
if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
height -= (me.getBorderWidth("tb") + me.getPadding("tb"));
}
return (isNum && height < 0) ? 0 : height;
},
addClass : function(className){
var me = this,
i,
len,
v,
cls = [];
if (!Ext.isArray(className)) {
if (typeof className == 'string' && !this.hasClass(className)) {
me.dom.className += " " + className;
}
}
else {
for (i = 0, len = className.length; i < len; i++) {
v = className[i];
if (typeof v == 'string' && (' ' + me.dom.className + ' ').indexOf(' ' + v + ' ') == -1) {
cls.push(v);
}
}
if (cls.length) {
me.dom.className += " " + cls.join(" ");
}
}
return me;
},
removeClass : function(className){
var me = this,
i,
idx,
len,
cls,
elClasses;
if (!Ext.isArray(className)){
className = [className];
}
if (me.dom && me.dom.className) {
elClasses = me.dom.className.replace(trimRe, '').split(spacesRe);
for (i = 0, len = className.length; i < len; i++) {
cls = className[i];
if (typeof cls == 'string') {
cls = cls.replace(trimRe, '');
idx = elClasses.indexOf(cls);
if (idx != -1) {
elClasses.splice(idx, 1);
}
}
}
me.dom.className = elClasses.join(" ");
}
return me;
},
radioClass : function(className){
var cn = this.dom.parentNode.childNodes,
v,
i,
len;
className = Ext.isArray(className) ? className : [className];
for (i = 0, len = cn.length; i < len; i++) {
v = cn[i];
if (v && v.nodeType == 1) {
Ext.fly(v, '_internal').removeClass(className);
}
};
return this.addClass(className);
},
toggleClass : function(className){
return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
},
hasClass : function(className){
return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1;
},
replaceClass : function(oldClassName, newClassName){
return this.removeClass(oldClassName).addClass(newClassName);
},
isStyle : function(style, val) {
return this.getStyle(style) == val;
},
getStyle : function(){
return view && view.getComputedStyle ?
function(prop){
var el = this.dom,
v,
cs,
out,
display;
if(el == document){
return null;
}
prop = chkCache(prop);
out = (v = el.style[prop]) ? v :
(cs = view.getComputedStyle(el, "")) ? cs[prop] : null;
if(prop == 'marginRight' && out != '0px' && !supports.correctRightMargin){
display = el.style.display;
el.style.display = 'inline-block';
out = view.getComputedStyle(el, '').marginRight;
el.style.display = display;
}
if(prop == 'backgroundColor' && out == 'rgba(0, 0, 0, 0)' && !supports.correctTransparentColor){
out = 'transparent';
}
return out;
} :
function(prop){
var el = this.dom,
m,
cs;
if(el == document) return null;
if (prop == 'opacity') {
if (el.style.filter.match) {
if(m = el.style.filter.match(opacityRe)){
var fv = parseFloat(m[1]);
if(!isNaN(fv)){
return fv ? fv / 100 : 0;
}
}
}
return 1;
}
prop = chkCache(prop);
return el.style[prop] || ((cs = el.currentStyle) ? cs[prop] : null);
};
}(),
getColor : function(attr, defaultValue, prefix){
var v = this.getStyle(attr),
color = (typeof prefix != 'undefined') ? prefix : '#',
h;
if(!v || (/transparent|inherit/.test(v))) {
return defaultValue;
}
if(/^r/.test(v)){
Ext.each(v.slice(4, v.length -1).split(','), function(s){
h = parseInt(s, 10);
color += (h < 16 ? '0' : '') + h.toString(16);
});
}else{
v = v.replace('#', '');
color += v.length == 3 ? v.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3') : v;
}
return(color.length > 5 ? color.toLowerCase() : defaultValue);
},
setStyle : function(prop, value){
var tmp, style;
if (typeof prop != 'object') {
tmp = {};
tmp[prop] = value;
prop = tmp;
}
for (style in prop) {
value = prop[style];
style == 'opacity' ?
this.setOpacity(value) :
this.dom.style[chkCache(style)] = value;
}
return this;
},
setOpacity : function(opacity, animate){
var me = this,
s = me.dom.style;
if(!animate || !me.anim){
if(Ext.isIE){
var opac = opacity < 1 ? 'alpha(opacity=' + opacity * 100 + ')' : '',
val = s.filter.replace(opacityRe, '').replace(trimRe, '');
s.zoom = 1;
s.filter = val + (val.length > 0 ? ' ' : '') + opac;
}else{
s.opacity = opacity;
}
}else{
me.anim({opacity: {to: opacity}}, me.preanim(arguments, 1), null, .35, 'easeIn');
}
return me;
},
clearOpacity : function(){
var style = this.dom.style;
if(Ext.isIE){
if(!Ext.isEmpty(style.filter)){
style.filter = style.filter.replace(opacityRe, '').replace(trimRe, '');
}
}else{
style.opacity = style['-moz-opacity'] = style['-khtml-opacity'] = '';
}
return this;
},
getHeight : function(contentHeight){
var me = this,
dom = me.dom,
hidden = Ext.isIE && me.isStyle('display', 'none'),
h = MATH.max(dom.offsetHeight, hidden ? 0 : dom.clientHeight) || 0;
h = !contentHeight ? h : h - me.getBorderWidth("tb") - me.getPadding("tb");
return h < 0 ? 0 : h;
},
getWidth : function(contentWidth){
var me = this,
dom = me.dom,
hidden = Ext.isIE && me.isStyle('display', 'none'),
w = MATH.max(dom.offsetWidth, hidden ? 0 : dom.clientWidth) || 0;
w = !contentWidth ? w : w - me.getBorderWidth("lr") - me.getPadding("lr");
return w < 0 ? 0 : w;
},
setWidth : function(width, animate){
var me = this;
width = me.adjustWidth(width);
!animate || !me.anim ?
me.dom.style.width = me.addUnits(width) :
me.anim({width : {to : width}}, me.preanim(arguments, 1));
return me;
},
setHeight : function(height, animate){
var me = this;
height = me.adjustHeight(height);
!animate || !me.anim ?
me.dom.style.height = me.addUnits(height) :
me.anim({height : {to : height}}, me.preanim(arguments, 1));
return me;
},
getBorderWidth : function(side){
return this.addStyles(side, borders);
},
getPadding : function(side){
return this.addStyles(side, paddings);
},
clip : function(){
var me = this,
dom = me.dom;
if(!data(dom, ISCLIPPED)){
data(dom, ISCLIPPED, true);
data(dom, ORIGINALCLIP, {
o: me.getStyle(OVERFLOW),
x: me.getStyle(OVERFLOWX),
y: me.getStyle(OVERFLOWY)
});
me.setStyle(OVERFLOW, HIDDEN);
me.setStyle(OVERFLOWX, HIDDEN);
me.setStyle(OVERFLOWY, HIDDEN);
}
return me;
},
unclip : function(){
var me = this,
dom = me.dom;
if(data(dom, ISCLIPPED)){
data(dom, ISCLIPPED, false);
var o = data(dom, ORIGINALCLIP);
if(o.o){
me.setStyle(OVERFLOW, o.o);
}
if(o.x){
me.setStyle(OVERFLOWX, o.x);
}
if(o.y){
me.setStyle(OVERFLOWY, o.y);
}
}
return me;
},
addStyles : function(sides, styles){
var ttlSize = 0,
sidesArr = sides.match(wordsRe),
side,
size,
i,
len = sidesArr.length;
for (i = 0; i < len; i++) {
side = sidesArr[i];
size = side && parseInt(this.getStyle(styles[side]), 10);
if (size) {
ttlSize += MATH.abs(size);
}
}
return ttlSize;
},
margins : margins
};
}()
);
(function(){
var D = Ext.lib.Dom,
LEFT = "left",
RIGHT = "right",
TOP = "top",
BOTTOM = "bottom",
POSITION = "position",
STATIC = "static",
RELATIVE = "relative",
AUTO = "auto",
ZINDEX = "z-index";
Ext.Element.addMethods({
getX : function(){
return D.getX(this.dom);
},
getY : function(){
return D.getY(this.dom);
},
getXY : function(){
return D.getXY(this.dom);
},
getOffsetsTo : function(el){
var o = this.getXY(),
e = Ext.fly(el, '_internal').getXY();
return [o[0]-e[0],o[1]-e[1]];
},
setX : function(x, animate){
return this.setXY([x, this.getY()], this.animTest(arguments, animate, 1));
},
setY : function(y, animate){
return this.setXY([this.getX(), y], this.animTest(arguments, animate, 1));
},
setLeft : function(left){
this.setStyle(LEFT, this.addUnits(left));
return this;
},
setTop : function(top){
this.setStyle(TOP, this.addUnits(top));
return this;
},
setRight : function(right){
this.setStyle(RIGHT, this.addUnits(right));
return this;
},
setBottom : function(bottom){
this.setStyle(BOTTOM, this.addUnits(bottom));
return this;
},
setXY : function(pos, animate){
var me = this;
if(!animate || !me.anim){
D.setXY(me.dom, pos);
}else{
me.anim({points: {to: pos}}, me.preanim(arguments, 1), 'motion');
}
return me;
},
setLocation : function(x, y, animate){
return this.setXY([x, y], this.animTest(arguments, animate, 2));
},
moveTo : function(x, y, animate){
return this.setXY([x, y], this.animTest(arguments, animate, 2));
},
getLeft : function(local){
return !local ? this.getX() : parseInt(this.getStyle(LEFT), 10) || 0;
},
getRight : function(local){
var me = this;
return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0;
},
getTop : function(local) {
return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0;
},
getBottom : function(local){
var me = this;
return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0;
},
position : function(pos, zIndex, x, y){
var me = this;
if(!pos && me.isStyle(POSITION, STATIC)){
me.setStyle(POSITION, RELATIVE);
} else if(pos) {
me.setStyle(POSITION, pos);
}
if(zIndex){
me.setStyle(ZINDEX, zIndex);
}
if(x || y) me.setXY([x || false, y || false]);
},
clearPositioning : function(value){
value = value || '';
this.setStyle({
left : value,
right : value,
top : value,
bottom : value,
"z-index" : "",
position : STATIC
});
return this;
},
getPositioning : function(){
var l = this.getStyle(LEFT);
var t = this.getStyle(TOP);
return {
"position" : this.getStyle(POSITION),
"left" : l,
"right" : l ? "" : this.getStyle(RIGHT),
"top" : t,
"bottom" : t ? "" : this.getStyle(BOTTOM),
"z-index" : this.getStyle(ZINDEX)
};
},
setPositioning : function(pc){
var me = this,
style = me.dom.style;
me.setStyle(pc);
if(pc.right == AUTO){
style.right = "";
}
if(pc.bottom == AUTO){
style.bottom = "";
}
return me;
},
translatePoints : function(x, y){
y = isNaN(x[1]) ? y : x[1];
x = isNaN(x[0]) ? x : x[0];
var me = this,
relative = me.isStyle(POSITION, RELATIVE),
o = me.getXY(),
l = parseInt(me.getStyle(LEFT), 10),
t = parseInt(me.getStyle(TOP), 10);
l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);
t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop);
return {left: (x - o[0] + l), top: (y - o[1] + t)};
},
animTest : function(args, animate, i) {
return !!animate && this.preanim ? this.preanim(args, i) : false;
}
});
})();
Ext.Element.addMethods({
isScrollable : function(){
var dom = this.dom;
return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
},
scrollTo : function(side, value){
this.dom["scroll" + (/top/i.test(side) ? "Top" : "Left")] = value;
return this;
},
getScroll : function(){
var d = this.dom,
doc = document,
body = doc.body,
docElement = doc.documentElement,
l,
t,
ret;
if(d == doc || d == body){
if(Ext.isIE && Ext.isStrict){
l = docElement.scrollLeft;
t = docElement.scrollTop;
}else{
l = window.pageXOffset;
t = window.pageYOffset;
}
ret = {left: l || (body ? body.scrollLeft : 0), top: t || (body ? body.scrollTop : 0)};
}else{
ret = {left: d.scrollLeft, top: d.scrollTop};
}
return ret;
}
});
Ext.Element.VISIBILITY = 1;
Ext.Element.DISPLAY = 2;
Ext.Element.OFFSETS = 3;
Ext.Element.ASCLASS = 4;
Ext.Element.visibilityCls = 'x-hide-nosize';
Ext.Element.addMethods(function(){
var El = Ext.Element,
OPACITY = "opacity",
VISIBILITY = "visibility",
DISPLAY = "display",
HIDDEN = "hidden",
OFFSETS = "offsets",
ASCLASS = "asclass",
NONE = "none",
NOSIZE = 'nosize',
ORIGINALDISPLAY = 'originalDisplay',
VISMODE = 'visibilityMode',
ISVISIBLE = 'isVisible',
data = El.data,
getDisplay = function(dom){
var d = data(dom, ORIGINALDISPLAY);
if(d === undefined){
data(dom, ORIGINALDISPLAY, d = '');
}
return d;
},
getVisMode = function(dom){
var m = data(dom, VISMODE);
if(m === undefined){
data(dom, VISMODE, m = 1);
}
return m;
};
return {
originalDisplay : "",
visibilityMode : 1,
setVisibilityMode : function(visMode){
data(this.dom, VISMODE, visMode);
return this;
},
animate : function(args, duration, onComplete, easing, animType){
this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
return this;
},
anim : function(args, opt, animType, defaultDur, defaultEase, cb){
animType = animType || 'run';
opt = opt || {};
var me = this,
anim = Ext.lib.Anim[animType](
me.dom,
args,
(opt.duration || defaultDur) || .35,
(opt.easing || defaultEase) || 'easeOut',
function(){
if(cb) cb.call(me);
if(opt.callback) opt.callback.call(opt.scope || me, me, opt);
},
me
);
opt.anim = anim;
return anim;
},
preanim : function(a, i){
return !a[i] ? false : (typeof a[i] == 'object' ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
},
isVisible : function() {
var me = this,
dom = me.dom,
visible = data(dom, ISVISIBLE);
if(typeof visible == 'boolean'){
return visible;
}
visible = !me.isStyle(VISIBILITY, HIDDEN) &&
!me.isStyle(DISPLAY, NONE) &&
!((getVisMode(dom) == El.ASCLASS) && me.hasClass(me.visibilityCls || El.visibilityCls));
data(dom, ISVISIBLE, visible);
return visible;
},
setVisible : function(visible, animate){
var me = this, isDisplay, isVisibility, isOffsets, isNosize,
dom = me.dom,
visMode = getVisMode(dom);
if (typeof animate == 'string'){
switch (animate) {
case DISPLAY:
visMode = El.DISPLAY;
break;
case VISIBILITY:
visMode = El.VISIBILITY;
break;
case OFFSETS:
visMode = El.OFFSETS;
break;
case NOSIZE:
case ASCLASS:
visMode = El.ASCLASS;
break;
}
me.setVisibilityMode(visMode);
animate = false;
}
if (!animate || !me.anim) {
if(visMode == El.ASCLASS ){
me[visible?'removeClass':'addClass'](me.visibilityCls || El.visibilityCls);
} else if (visMode == El.DISPLAY){
return me.setDisplayed(visible);
} else if (visMode == El.OFFSETS){
if (!visible){
me.hideModeStyles = {
position: me.getStyle('position'),
top: me.getStyle('top'),
left: me.getStyle('left')
};
me.applyStyles({position: 'absolute', top: '-10000px', left: '-10000px'});
} else {
me.applyStyles(me.hideModeStyles || {position: '', top: '', left: ''});
delete me.hideModeStyles;
}
}else{
me.fixDisplay();
dom.style.visibility = visible ? "visible" : HIDDEN;
}
}else{
if(visible){
me.setOpacity(.01);
me.setVisible(true);
}
me.anim({opacity: { to: (visible?1:0) }},
me.preanim(arguments, 1),
null,
.35,
'easeIn',
function(){
visible || me.setVisible(false).setOpacity(1);
});
}
data(dom, ISVISIBLE, visible);
return me;
},
hasMetrics : function(){
var dom = this.dom;
return this.isVisible() || (getVisMode(dom) == El.VISIBILITY);
},
toggle : function(animate){
var me = this;
me.setVisible(!me.isVisible(), me.preanim(arguments, 0));
return me;
},
setDisplayed : function(value) {
if(typeof value == "boolean"){
value = value ? getDisplay(this.dom) : NONE;
}
this.setStyle(DISPLAY, value);
return this;
},
fixDisplay : function(){
var me = this;
if(me.isStyle(DISPLAY, NONE)){
me.setStyle(VISIBILITY, HIDDEN);
me.setStyle(DISPLAY, getDisplay(this.dom));
if(me.isStyle(DISPLAY, NONE)){
me.setStyle(DISPLAY, "block");
}
}
},
hide : function(animate){
if (typeof animate == 'string'){
this.setVisible(false, animate);
return this;
}
this.setVisible(false, this.preanim(arguments, 0));
return this;
},
show : function(animate){
if (typeof animate == 'string'){
this.setVisible(true, animate);
return this;
}
this.setVisible(true, this.preanim(arguments, 0));
return this;
}
};
}());(function(){
var NULL = null,
UNDEFINED = undefined,
TRUE = true,
FALSE = false,
SETX = "setX",
SETY = "setY",
SETXY = "setXY",
LEFT = "left",
BOTTOM = "bottom",
TOP = "top",
RIGHT = "right",
HEIGHT = "height",
WIDTH = "width",
POINTS = "points",
HIDDEN = "hidden",
ABSOLUTE = "absolute",
VISIBLE = "visible",
MOTION = "motion",
POSITION = "position",
EASEOUT = "easeOut",
flyEl = new Ext.Element.Flyweight(),
queues = {},
getObject = function(o){
return o || {};
},
fly = function(dom){
flyEl.dom = dom;
flyEl.id = Ext.id(dom);
return flyEl;
},
getQueue = function(id){
if(!queues[id]){
queues[id] = [];
}
return queues[id];
},
setQueue = function(id, value){
queues[id] = value;
};
Ext.enableFx = TRUE;
Ext.Fx = {
switchStatements : function(key, fn, argHash){
return fn.apply(this, argHash[key]);
},
slideIn : function(anchor, o){
o = getObject(o);
var me = this,
dom = me.dom,
st = dom.style,
xy,
r,
b,
wrap,
after,
st,
args,
pt,
bw,
bh;
anchor = anchor || "t";
me.queueFx(o, function(){
xy = fly(dom).getXY();
fly(dom).fixDisplay();
r = fly(dom).getFxRestore();
b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
b.right = b.x + b.width;
b.bottom = b.y + b.height;
fly(dom).setWidth(b.width).setHeight(b.height);
wrap = fly(dom).fxWrap(r.pos, o, HIDDEN);
st.visibility = VISIBLE;
st.position = ABSOLUTE;
function after(){
fly(dom).fxUnwrap(wrap, r.pos, o);
st.width = r.width;
st.height = r.height;
fly(dom).afterFx(o);
}
pt = {to: [b.x, b.y]};
bw = {to: b.width};
bh = {to: b.height};
function argCalc(wrap, style, ww, wh, sXY, sXYval, s1, s2, w, h, p){
var ret = {};
fly(wrap).setWidth(ww).setHeight(wh);
if(fly(wrap)[sXY]){
fly(wrap)[sXY](sXYval);
}
style[s1] = style[s2] = "0";
if(w){
ret.width = w;
}
if(h){
ret.height = h;
}
if(p){
ret.points = p;
}
return ret;
};
args = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
t : [wrap, st, b.width, 0, NULL, NULL, LEFT, BOTTOM, NULL, bh, NULL],
l : [wrap, st, 0, b.height, NULL, NULL, RIGHT, TOP, bw, NULL, NULL],
r : [wrap, st, b.width, b.height, SETX, b.right, LEFT, TOP, NULL, NULL, pt],
b : [wrap, st, b.width, b.height, SETY, b.bottom, LEFT, TOP, NULL, bh, pt],
tl : [wrap, st, 0, 0, NULL, NULL, RIGHT, BOTTOM, bw, bh, pt],
bl : [wrap, st, 0, 0, SETY, b.y + b.height, RIGHT, TOP, bw, bh, pt],
br : [wrap, st, 0, 0, SETXY, [b.right, b.bottom], LEFT, TOP, bw, bh, pt],
tr : [wrap, st, 0, 0, SETX, b.x + b.width, LEFT, BOTTOM, bw, bh, pt]
});
st.visibility = VISIBLE;
fly(wrap).show();
arguments.callee.anim = fly(wrap).fxanim(args,
o,
MOTION,
.5,
EASEOUT,
after);
});
return me;
},
slideOut : function(anchor, o){
o = getObject(o);
var me = this,
dom = me.dom,
st = dom.style,
xy = me.getXY(),
wrap,
r,
b,
a,
zero = {to: 0};
anchor = anchor || "t";
me.queueFx(o, function(){
r = fly(dom).getFxRestore();
b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
b.right = b.x + b.width;
b.bottom = b.y + b.height;
fly(dom).setWidth(b.width).setHeight(b.height);
wrap = fly(dom).fxWrap(r.pos, o, VISIBLE);
st.visibility = VISIBLE;
st.position = ABSOLUTE;
fly(wrap).setWidth(b.width).setHeight(b.height);
function after(){
o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
fly(dom).fxUnwrap(wrap, r.pos, o);
st.width = r.width;
st.height = r.height;
fly(dom).afterFx(o);
}
function argCalc(style, s1, s2, p1, v1, p2, v2, p3, v3){
var ret = {};
style[s1] = style[s2] = "0";
ret[p1] = v1;
if(p2){
ret[p2] = v2;
}
if(p3){
ret[p3] = v3;
}
return ret;
};
a = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
t : [st, LEFT, BOTTOM, HEIGHT, zero],
l : [st, RIGHT, TOP, WIDTH, zero],
r : [st, LEFT, TOP, WIDTH, zero, POINTS, {to : [b.right, b.y]}],
b : [st, LEFT, TOP, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
tl : [st, RIGHT, BOTTOM, WIDTH, zero, HEIGHT, zero],
bl : [st, RIGHT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
br : [st, LEFT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x + b.width, b.bottom]}],
tr : [st, LEFT, BOTTOM, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.right, b.y]}]
});
arguments.callee.anim = fly(wrap).fxanim(a,
o,
MOTION,
.5,
EASEOUT,
after);
});
return me;
},
puff : function(o){
o = getObject(o);
var me = this,
dom = me.dom,
st = dom.style,
width,
height,
r;
me.queueFx(o, function(){
width = fly(dom).getWidth();
height = fly(dom).getHeight();
fly(dom).clearOpacity();
fly(dom).show();
r = fly(dom).getFxRestore();
function after(){
o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
fly(dom).clearOpacity();
fly(dom).setPositioning(r.pos);
st.width = r.width;
st.height = r.height;
st.fontSize = '';
fly(dom).afterFx(o);
}
arguments.callee.anim = fly(dom).fxanim({
width : {to : fly(dom).adjustWidth(width * 2)},
height : {to : fly(dom).adjustHeight(height * 2)},
points : {by : [-width * .5, -height * .5]},
opacity : {to : 0},
fontSize: {to : 200, unit: "%"}
},
o,
MOTION,
.5,
EASEOUT,
after);
});
return me;
},
switchOff : function(o){
o = getObject(o);
var me = this,
dom = me.dom,
st = dom.style,
r;
me.queueFx(o, function(){
fly(dom).clearOpacity();
fly(dom).clip();
r = fly(dom).getFxRestore();
function after(){
o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
fly(dom).clearOpacity();
fly(dom).setPositioning(r.pos);
st.width = r.width;
st.height = r.height;
fly(dom).afterFx(o);
};
fly(dom).fxanim({opacity : {to : 0.3}},
NULL,
NULL,
.1,
NULL,
function(){
fly(dom).clearOpacity();
(function(){
fly(dom).fxanim({
height : {to : 1},
points : {by : [0, fly(dom).getHeight() * .5]}
},
o,
MOTION,
0.3,
'easeIn',
after);
}).defer(100);
});
});
return me;
},
highlight : function(color, o){
o = getObject(o);
var me = this,
dom = me.dom,
attr = o.attr || "backgroundColor",
a = {},
restore;
me.queueFx(o, function(){
fly(dom).clearOpacity();
fly(dom).show();
function after(){
dom.style[attr] = restore;
fly(dom).afterFx(o);
}
restore = dom.style[attr];
a[attr] = {from: color || "ffff9c", to: o.endColor || fly(dom).getColor(attr) || "ffffff"};
arguments.callee.anim = fly(dom).fxanim(a,
o,
'color',
1,
'easeIn',
after);
});
return me;
},
frame : function(color, count, o){
o = getObject(o);
var me = this,
dom = me.dom,
proxy,
active;
me.queueFx(o, function(){
color = color || '#C3DAF9';
if(color.length == 6){
color = '#' + color;
}
count = count || 1;
fly(dom).show();
var xy = fly(dom).getXY(),
b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight},
queue = function(){
proxy = fly(document.body || document.documentElement).createChild({
style:{
position : ABSOLUTE,
'z-index': 35000,
border : '0px solid ' + color
}
});
return proxy.queueFx({}, animFn);
};
arguments.callee.anim = {
isAnimated: true,
stop: function() {
count = 0;
proxy.stopFx();
}
};
function animFn(){
var scale = Ext.isBorderBox ? 2 : 1;
active = proxy.anim({
top : {from : b.y, to : b.y - 20},
left : {from : b.x, to : b.x - 20},
borderWidth : {from : 0, to : 10},
opacity : {from : 1, to : 0},
height : {from : b.height, to : b.height + 20 * scale},
width : {from : b.width, to : b.width + 20 * scale}
},{
duration: o.duration || 1,
callback: function() {
proxy.remove();
--count > 0 ? queue() : fly(dom).afterFx(o);
}
});
arguments.callee.anim = {
isAnimated: true,
stop: function(){
active.stop();
}
};
};
queue();
});
return me;
},
pause : function(seconds){
var dom = this.dom,
t;
this.queueFx({}, function(){
t = setTimeout(function(){
fly(dom).afterFx({});
}, seconds * 1000);
arguments.callee.anim = {
isAnimated: true,
stop: function(){
clearTimeout(t);
fly(dom).afterFx({});
}
};
});
return this;
},
fadeIn : function(o){
o = getObject(o);
var me = this,
dom = me.dom,
to = o.endOpacity || 1;
me.queueFx(o, function(){
fly(dom).setOpacity(0);
fly(dom).fixDisplay();
dom.style.visibility = VISIBLE;
arguments.callee.anim = fly(dom).fxanim({opacity:{to:to}},
o, NULL, .5, EASEOUT, function(){
if(to == 1){
fly(dom).clearOpacity();
}
fly(dom).afterFx(o);
});
});
return me;
},
fadeOut : function(o){
o = getObject(o);
var me = this,
dom = me.dom,
style = dom.style,
to = o.endOpacity || 0;
me.queueFx(o, function(){
arguments.callee.anim = fly(dom).fxanim({
opacity : {to : to}},
o,
NULL,
.5,
EASEOUT,
function(){
if(to == 0){
Ext.Element.data(dom, 'visibilityMode') == Ext.Element.DISPLAY || o.useDisplay ?
style.display = "none" :
style.visibility = HIDDEN;
fly(dom).clearOpacity();
}
fly(dom).afterFx(o);
});
});
return me;
},
scale : function(w, h, o){
this.shift(Ext.apply({}, o, {
width: w,
height: h
}));
return this;
},
shift : function(o){
o = getObject(o);
var dom = this.dom,
a = {};
this.queueFx(o, function(){
for (var prop in o) {
if (o[prop] != UNDEFINED) {
a[prop] = {to : o[prop]};
}
}
a.width ? a.width.to = fly(dom).adjustWidth(o.width) : a;
a.height ? a.height.to = fly(dom).adjustWidth(o.height) : a;
if (a.x || a.y || a.xy) {
a.points = a.xy ||
{to : [ a.x ? a.x.to : fly(dom).getX(),
a.y ? a.y.to : fly(dom).getY()]};
}
arguments.callee.anim = fly(dom).fxanim(a,
o,
MOTION,
.35,
EASEOUT,
function(){
fly(dom).afterFx(o);
});
});
return this;
},
ghost : function(anchor, o){
o = getObject(o);
var me = this,
dom = me.dom,
st = dom.style,
a = {opacity: {to: 0}, points: {}},
pt = a.points,
r,
w,
h;
anchor = anchor || "b";
me.queueFx(o, function(){
r = fly(dom).getFxRestore();
w = fly(dom).getWidth();
h = fly(dom).getHeight();
function after(){
o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
fly(dom).clearOpacity();
fly(dom).setPositioning(r.pos);
st.width = r.width;
st.height = r.height;
fly(dom).afterFx(o);
}
pt.by = fly(dom).switchStatements(anchor.toLowerCase(), function(v1,v2){ return [v1, v2];}, {
t : [0, -h],
l : [-w, 0],
r : [w, 0],
b : [0, h],
tl : [-w, -h],
bl : [-w, h],
br : [w, h],
tr : [w, -h]
});
arguments.callee.anim = fly(dom).fxanim(a,
o,
MOTION,
.5,
EASEOUT, after);
});
return me;
},
syncFx : function(){
var me = this;
me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
block : FALSE,
concurrent : TRUE,
stopFx : FALSE
});
return me;
},
sequenceFx : function(){
var me = this;
me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
block : FALSE,
concurrent : FALSE,
stopFx : FALSE
});
return me;
},
nextFx : function(){
var ef = getQueue(this.dom.id)[0];
if(ef){
ef.call(this);
}
},
hasActiveFx : function(){
return getQueue(this.dom.id)[0];
},
stopFx : function(finish){
var me = this,
id = me.dom.id;
if(me.hasActiveFx()){
var cur = getQueue(id)[0];
if(cur && cur.anim){
if(cur.anim.isAnimated){
setQueue(id, [cur]);
cur.anim.stop(finish !== undefined ? finish : TRUE);
}else{
setQueue(id, []);
}
}
}
return me;
},
beforeFx : function(o){
if(this.hasActiveFx() && !o.concurrent){
if(o.stopFx){
this.stopFx();
return TRUE;
}
return FALSE;
}
return TRUE;
},
hasFxBlock : function(){
var q = getQueue(this.dom.id);
return q && q[0] && q[0].block;
},
queueFx : function(o, fn){
var me = fly(this.dom);
if(!me.hasFxBlock()){
Ext.applyIf(o, me.fxDefaults);
if(!o.concurrent){
var run = me.beforeFx(o);
fn.block = o.block;
getQueue(me.dom.id).push(fn);
if(run){
me.nextFx();
}
}else{
fn.call(me);
}
}
return me;
},
fxWrap : function(pos, o, vis){
var dom = this.dom,
wrap,
wrapXY;
if(!o.wrap || !(wrap = Ext.getDom(o.wrap))){
if(o.fixPosition){
wrapXY = fly(dom).getXY();
}
var div = document.createElement("div");
div.style.visibility = vis;
wrap = dom.parentNode.insertBefore(div, dom);
fly(wrap).setPositioning(pos);
if(fly(wrap).isStyle(POSITION, "static")){
fly(wrap).position("relative");
}
fly(dom).clearPositioning('auto');
fly(wrap).clip();
wrap.appendChild(dom);
if(wrapXY){
fly(wrap).setXY(wrapXY);
}
}
return wrap;
},
fxUnwrap : function(wrap, pos, o){
var dom = this.dom;
fly(dom).clearPositioning();
fly(dom).setPositioning(pos);
if(!o.wrap){
var pn = fly(wrap).dom.parentNode;
pn.insertBefore(dom, wrap);
fly(wrap).remove();
}
},
getFxRestore : function(){
var st = this.dom.style;
return {pos: this.getPositioning(), width: st.width, height : st.height};
},
afterFx : function(o){
var dom = this.dom,
id = dom.id;
if(o.afterStyle){
fly(dom).setStyle(o.afterStyle);
}
if(o.afterCls){
fly(dom).addClass(o.afterCls);
}
if(o.remove == TRUE){
fly(dom).remove();
}
if(o.callback){
o.callback.call(o.scope, fly(dom));
}
if(!o.concurrent){
getQueue(id).shift();
fly(dom).nextFx();
}
},
fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
animType = animType || 'run';
opt = opt || {};
var anim = Ext.lib.Anim[animType](
this.dom,
args,
(opt.duration || defaultDur) || .35,
(opt.easing || defaultEase) || EASEOUT,
cb,
this
);
opt.anim = anim;
return anim;
}
};
Ext.Fx.resize = Ext.Fx.scale;
Ext.Element.addMethods(Ext.Fx);
})();
Ext.CompositeElementLite = function(els, root){
this.elements = [];
this.add(els, root);
this.el = new Ext.Element.Flyweight();
};
Ext.CompositeElementLite.prototype = {
isComposite: true,
getElement : function(el){
var e = this.el;
e.dom = el;
e.id = el.id;
return e;
},
transformElement : function(el){
return Ext.getDom(el);
},
getCount : function(){
return this.elements.length;
},
add : function(els, root){
var me = this,
elements = me.elements;
if(!els){
return this;
}
if(typeof els == "string"){
els = Ext.Element.selectorFunction(els, root);
}else if(els.isComposite){
els = els.elements;
}else if(!Ext.isIterable(els)){
els = [els];
}
for(var i = 0, len = els.length; i < len; ++i){
elements.push(me.transformElement(els[i]));
}
return me;
},
invoke : function(fn, args){
var me = this,
els = me.elements,
len = els.length,
e,
i;
for(i = 0; i < len; i++) {
e = els[i];
if(e){
Ext.Element.prototype[fn].apply(me.getElement(e), args);
}
}
return me;
},
item : function(index){
var me = this,
el = me.elements[index],
out = null;
if(el){
out = me.getElement(el);
}
return out;
},
addListener : function(eventName, handler, scope, opt){
var els = this.elements,
len = els.length,
i, e;
for(i = 0; i<len; i++) {
e = els[i];
if(e) {
Ext.EventManager.on(e, eventName, handler, scope || e, opt);
}
}
return this;
},
each : function(fn, scope){
var me = this,
els = me.elements,
len = els.length,
i, e;
for(i = 0; i<len; i++) {
e = els[i];
if(e){
e = this.getElement(e);
if(fn.call(scope || e, e, me, i) === false){
break;
}
}
}
return me;
},
fill : function(els){
var me = this;
me.elements = [];
me.add(els);
return me;
},
filter : function(selector){
var els = [],
me = this,
fn = Ext.isFunction(selector) ? selector
: function(el){
return el.is(selector);
};
me.each(function(el, self, i) {
if (fn(el, i) !== false) {
els[els.length] = me.transformElement(el);
}
});
me.elements = els;
return me;
},
indexOf : function(el){
return this.elements.indexOf(this.transformElement(el));
},
replaceElement : function(el, replacement, domReplace){
var index = !isNaN(el) ? el : this.indexOf(el),
d;
if(index > -1){
replacement = Ext.getDom(replacement);
if(domReplace){
d = this.elements[index];
d.parentNode.insertBefore(replacement, d);
Ext.removeNode(d);
}
this.elements.splice(index, 1, replacement);
}
return this;
},
clear : function(){
this.elements = [];
}
};
Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;
Ext.CompositeElementLite.importElementMethods = function() {
var fnName,
ElProto = Ext.Element.prototype,
CelProto = Ext.CompositeElementLite.prototype;
for (fnName in ElProto) {
if (typeof ElProto[fnName] == 'function'){
(function(fnName) {
CelProto[fnName] = CelProto[fnName] || function() {
return this.invoke(fnName, arguments);
};
}).call(CelProto, fnName);
}
}
};
Ext.CompositeElementLite.importElementMethods();
if(Ext.DomQuery){
Ext.Element.selectorFunction = Ext.DomQuery.select;
}
Ext.Element.select = function(selector, root){
var els;
if(typeof selector == "string"){
els = Ext.Element.selectorFunction(selector, root);
}else if(selector.length !== undefined){
els = selector;
}else{
throw "Invalid selector";
}
return new Ext.CompositeElementLite(els);
};
Ext.select = Ext.Element.select;
(function(){
var BEFOREREQUEST = "beforerequest",
REQUESTCOMPLETE = "requestcomplete",
REQUESTEXCEPTION = "requestexception",
UNDEFINED = undefined,
LOAD = 'load',
POST = 'POST',
GET = 'GET',
WINDOW = window;
Ext.data.Connection = function(config){
Ext.apply(this, config);
this.addEvents(
BEFOREREQUEST,
REQUESTCOMPLETE,
REQUESTEXCEPTION
);
Ext.data.Connection.superclass.constructor.call(this);
};
Ext.extend(Ext.data.Connection, Ext.util.Observable, {
timeout : 30000,
autoAbort:false,
disableCaching: true,
disableCachingParam: '_dc',
request : function(o){
var me = this;
if(me.fireEvent(BEFOREREQUEST, me, o)){
if (o.el) {
if(!Ext.isEmpty(o.indicatorText)){
me.indicatorText = '<div class="loading-indicator">'+o.indicatorText+"</div>";
}
if(me.indicatorText) {
Ext.getDom(o.el).innerHTML = me.indicatorText;
}
o.success = (Ext.isFunction(o.success) ? o.success : function(){}).createInterceptor(function(response) {
Ext.getDom(o.el).innerHTML = response.responseText;
});
}
var p = o.params,
url = o.url || me.url,
method,
cb = {success: me.handleResponse,
failure: me.handleFailure,
scope: me,
argument: {options: o},
timeout : Ext.num(o.timeout, me.timeout)
},
form,
serForm;
if (Ext.isFunction(p)) {
p = p.call(o.scope||WINDOW, o);
}
p = Ext.urlEncode(me.extraParams, Ext.isObject(p) ? Ext.urlEncode(p) : p);
if (Ext.isFunction(url)) {
url = url.call(o.scope || WINDOW, o);
}
if((form = Ext.getDom(o.form))){
url = url || form.action;
if(o.isUpload || (/multipart\/form-data/i.test(form.getAttribute("enctype")))) {
return me.doFormUpload.call(me, o, p, url);
}
serForm = Ext.lib.Ajax.serializeForm(form);
p = p ? (p + '&' + serForm) : serForm;
}
method = o.method || me.method || ((p || o.xmlData || o.jsonData) ? POST : GET);
if(method === GET && (me.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
var dcp = o.disableCachingParam || me.disableCachingParam;
url = Ext.urlAppend(url, dcp + '=' + (new Date().getTime()));
}
o.headers = Ext.applyIf(o.headers || {}, me.defaultHeaders || {});
if(o.autoAbort === true || me.autoAbort) {
me.abort();
}
if((method == GET || o.xmlData || o.jsonData) && p){
url = Ext.urlAppend(url, p);
p = '';
}
return (me.transId = Ext.lib.Ajax.request(method, url, cb, p, o));
}else{
return o.callback ? o.callback.apply(o.scope, [o,UNDEFINED,UNDEFINED]) : null;
}
},
isLoading : function(transId){
return transId ? Ext.lib.Ajax.isCallInProgress(transId) : !! this.transId;
},
abort : function(transId){
if(transId || this.isLoading()){
Ext.lib.Ajax.abort(transId || this.transId);
}
},
handleResponse : function(response){
this.transId = false;
var options = response.argument.options;
response.argument = options ? options.argument : null;
this.fireEvent(REQUESTCOMPLETE, this, response, options);
if(options.success){
options.success.call(options.scope, response, options);
}
if(options.callback){
options.callback.call(options.scope, options, true, response);
}
},
handleFailure : function(response, e){
this.transId = false;
var options = response.argument.options;
response.argument = options ? options.argument : null;
this.fireEvent(REQUESTEXCEPTION, this, response, options, e);
if(options.failure){
options.failure.call(options.scope, response, options);
}
if(options.callback){
options.callback.call(options.scope, options, false, response);
}
},
doFormUpload : function(o, ps, url){
var id = Ext.id(),
doc = document,
frame = doc.createElement('iframe'),
form = Ext.getDom(o.form),
hiddens = [],
hd,
encoding = 'multipart/form-data',
buf = {
target: form.target,
method: form.method,
encoding: form.encoding,
enctype: form.enctype,
action: form.action
};
Ext.fly(frame).set({
id: id,
name: id,
cls: 'x-hidden',
src: Ext.SSL_SECURE_URL
});
doc.body.appendChild(frame);
if(Ext.isIE){
document.frames[id].name = id;
}
Ext.fly(form).set({
target: id,
method: POST,
enctype: encoding,
encoding: encoding,
action: url || buf.action
});
Ext.iterate(Ext.urlDecode(ps, false), function(k, v){
hd = doc.createElement('input');
Ext.fly(hd).set({
type: 'hidden',
value: v,
name: k
});
form.appendChild(hd);
hiddens.push(hd);
});
function cb(){
var me = this,
r = {responseText : '',
responseXML : null,
argument : o.argument},
doc,
firstChild;
try{
doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;
if(doc){
if(doc.body){
if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){
r.responseText = firstChild.value;
}else{
r.responseText = doc.body.innerHTML;
}
}
r.responseXML = doc.XMLDocument || doc;
}
}
catch(e) {}
Ext.EventManager.removeListener(frame, LOAD, cb, me);
me.fireEvent(REQUESTCOMPLETE, me, r, o);
function runCallback(fn, scope, args){
if(Ext.isFunction(fn)){
fn.apply(scope, args);
}
}
runCallback(o.success, o.scope, [r, o]);
runCallback(o.callback, o.scope, [o, true, r]);
if(!me.debugUploads){
setTimeout(function(){Ext.removeNode(frame);}, 100);
}
}
Ext.EventManager.on(frame, LOAD, cb, this);
form.submit();
Ext.fly(form).set(buf);
Ext.each(hiddens, function(h) {
Ext.removeNode(h);
});
}
});
})();
Ext.Ajax = new Ext.data.Connection({
autoAbort : false,
serializeForm : function(form){
return Ext.lib.Ajax.serializeForm(form);
}
});
Ext.util.JSON = new (function(){
var useHasOwn = !!{}.hasOwnProperty,
isNative = function() {
var useNative = null;
return function() {
if (useNative === null) {
useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';
}
return useNative;
};
}(),
pad = function(n) {
return n < 10 ? "0" + n : n;
},
doDecode = function(json){
return json ? eval("(" + json + ")") : "";
},
doEncode = function(o){
if(!Ext.isDefined(o) || o === null){
return "null";
}else if(Ext.isArray(o)){
return encodeArray(o);
}else if(Ext.isDate(o)){
return Ext.util.JSON.encodeDate(o);
}else if(Ext.isString(o)){
return encodeString(o);
}else if(typeof o == "number"){
return isFinite(o) ? String(o) : "null";
}else if(Ext.isBoolean(o)){
return String(o);
}else {
var a = ["{"], b, i, v;
for (i in o) {
if(!o.getElementsByTagName){
if(!useHasOwn || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if(b){
a.push(',');
}
a.push(doEncode(i), ":",
v === null ? "null" : doEncode(v));
b = true;
}
}
}
}
a.push("}");
return a.join("");
}
},
m = {
"\b": '\\b',
"\t": '\\t',
"\n": '\\n',
"\f": '\\f',
"\r": '\\r',
'"' : '\\"',
"\\": '\\\\'
},
encodeString = function(s){
if (/["\\\x00-\x1f]/.test(s)) {
return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
var c = m[b];
if(c){
return c;
}
c = b.charCodeAt();
return "\\u00" +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"';
}
return '"' + s + '"';
},
encodeArray = function(o){
var a = ["["], b, i, l = o.length, v;
for (i = 0; i < l; i += 1) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if (b) {
a.push(',');
}
a.push(v === null ? "null" : Ext.util.JSON.encode(v));
b = true;
}
}
a.push("]");
return a.join("");
};
this.encodeDate = function(o){
return '"' + o.getFullYear() + "-" +
pad(o.getMonth() + 1) + "-" +
pad(o.getDate()) + "T" +
pad(o.getHours()) + ":" +
pad(o.getMinutes()) + ":" +
pad(o.getSeconds()) + '"';
};
this.encode = function() {
var ec;
return function(o) {
if (!ec) {
ec = isNative() ? JSON.stringify : doEncode;
}
return ec(o);
};
}();
this.decode = function() {
var dc;
return function(json) {
if (!dc) {
dc = isNative() ? JSON.parse : doDecode;
}
return dc(json);
};
}();
})();
Ext.encode = Ext.util.JSON.encode;
Ext.decode = Ext.util.JSON.decode;
Ext.EventManager = function(){
var docReadyEvent,
docReadyProcId,
docReadyState = false,
DETECT_NATIVE = Ext.isGecko || Ext.isWebKit || Ext.isSafari,
E = Ext.lib.Event,
D = Ext.lib.Dom,
DOC = document,
WINDOW = window,
DOMCONTENTLOADED = "DOMContentLoaded",
COMPLETE = 'complete',
propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
specialElCache = [];
function getId(el){
var id = false,
i = 0,
len = specialElCache.length,
skip = false,
o;
if (el) {
if (el.getElementById || el.navigator) {
for(; i < len; ++i){
o = specialElCache[i];
if(o.el === el){
id = o.id;
break;
}
}
if(!id){
id = Ext.id(el);
specialElCache.push({
id: id,
el: el
});
skip = true;
}
}else{
id = Ext.id(el);
}
if(!Ext.elCache[id]){
Ext.Element.addToCache(new Ext.Element(el), id);
if(skip){
Ext.elCache[id].skipGC = true;
}
}
}
return id;
}
function addListener(el, ename, fn, task, wrap, scope){
el = Ext.getDom(el);
var id = getId(el),
es = Ext.elCache[id].events,
wfn;
wfn = E.on(el, ename, wrap);
es[ename] = es[ename] || [];
es[ename].push([fn, wrap, scope, wfn, task]);
if(el.addEventListener && ename == "mousewheel"){
var args = ["DOMMouseScroll", wrap, false];
el.addEventListener.apply(el, args);
Ext.EventManager.addListener(WINDOW, 'unload', function(){
el.removeEventListener.apply(el, args);
});
}
if(el == DOC && ename == "mousedown"){
Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
}
}
function doScrollChk(){
if(window != top){
return false;
}
try{
DOC.documentElement.doScroll('left');
}catch(e){
return false;
}
fireDocReady();
return true;
}
function checkReadyState(e){
if(Ext.isIE && doScrollChk()){
return true;
}
if(DOC.readyState == COMPLETE){
fireDocReady();
return true;
}
docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
return false;
}
var styles;
function checkStyleSheets(e){
styles || (styles = Ext.query('style, link[rel=stylesheet]'));
if(styles.length == DOC.styleSheets.length){
fireDocReady();
return true;
}
docReadyState || (docReadyProcId = setTimeout(arguments.callee, 2));
return false;
}
function OperaDOMContentLoaded(e){
DOC.removeEventListener(DOMCONTENTLOADED, arguments.callee, false);
checkStyleSheets();
}
function fireDocReady(e){
if(!docReadyState){
docReadyState = true;
if(docReadyProcId){
clearTimeout(docReadyProcId);
}
if(DETECT_NATIVE) {
DOC.removeEventListener(DOMCONTENTLOADED, fireDocReady, false);
}
if(Ext.isIE && checkReadyState.bindIE){
DOC.detachEvent('onreadystatechange', checkReadyState);
}
E.un(WINDOW, "load", arguments.callee);
}
if(docReadyEvent && !Ext.isReady){
Ext.isReady = true;
docReadyEvent.fire();
docReadyEvent.listeners = [];
}
}
function initDocReady(){
docReadyEvent || (docReadyEvent = new Ext.util.Event());
if (DETECT_NATIVE) {
DOC.addEventListener(DOMCONTENTLOADED, fireDocReady, false);
}
if (Ext.isIE){
if(!checkReadyState()){
checkReadyState.bindIE = true;
DOC.attachEvent('onreadystatechange', checkReadyState);
}
}else if(Ext.isOpera ){
(DOC.readyState == COMPLETE && checkStyleSheets()) ||
DOC.addEventListener(DOMCONTENTLOADED, OperaDOMContentLoaded, false);
}else if (Ext.isWebKit){
checkReadyState();
}
E.on(WINDOW, "load", fireDocReady);
}
function createTargeted(h, o){
return function(){
var args = Ext.toArray(arguments);
if(o.target == Ext.EventObject.setEvent(args[0]).target){
h.apply(this, args);
}
};
}
function createBuffered(h, o, task){
return function(e){
task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
};
}
function createSingle(h, el, ename, fn, scope){
return function(e){
Ext.EventManager.removeListener(el, ename, fn, scope);
h(e);
};
}
function createDelayed(h, o, fn){
return function(e){
var task = new Ext.util.DelayedTask(h);
if(!fn.tasks) {
fn.tasks = [];
}
fn.tasks.push(task);
task.delay(o.delay || 10, h, null, [new Ext.EventObjectImpl(e)]);
};
}
function listen(element, ename, opt, fn, scope){
var o = (!opt || typeof opt == "boolean") ? {} : opt,
el = Ext.getDom(element), task;
fn = fn || o.fn;
scope = scope || o.scope;
if(!el){
throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
}
function h(e){
if(!Ext){
return;
}
e = Ext.EventObject.setEvent(e);
var t;
if (o.delegate) {
if(!(t = e.getTarget(o.delegate, el))){
return;
}
} else {
t = e.target;
}
if (o.stopEvent) {
e.stopEvent();
}
if (o.preventDefault) {
e.preventDefault();
}
if (o.stopPropagation) {
e.stopPropagation();
}
if (o.normalized === false) {
e = e.browserEvent;
}
fn.call(scope || el, e, t, o);
}
if(o.target){
h = createTargeted(h, o);
}
if(o.delay){
h = createDelayed(h, o, fn);
}
if(o.single){
h = createSingle(h, el, ename, fn, scope);
}
if(o.buffer){
task = new Ext.util.DelayedTask(h);
h = createBuffered(h, o, task);
}
addListener(el, ename, fn, task, h, scope);
return h;
}
var pub = {
addListener : function(element, eventName, fn, scope, options){
if(typeof eventName == 'object'){
var o = eventName, e, val;
for(e in o){
val = o[e];
if(!propRe.test(e)){
if(Ext.isFunction(val)){
listen(element, e, o, val, o.scope);
}else{
listen(element, e, val);
}
}
}
} else {
listen(element, eventName, options, fn, scope);
}
},
removeListener : function(el, eventName, fn, scope){
el = Ext.getDom(el);
var id = getId(el),
f = el && (Ext.elCache[id].events)[eventName] || [],
wrap, i, l, k, len, fnc;
for (i = 0, len = f.length; i < len; i++) {
if (Ext.isArray(fnc = f[i]) && fnc[0] == fn && (!scope || fnc[2] == scope)) {
if(fnc[4]) {
fnc[4].cancel();
}
k = fn.tasks && fn.tasks.length;
if(k) {
while(k--) {
fn.tasks[k].cancel();
}
delete fn.tasks;
}
wrap = fnc[1];
E.un(el, eventName, E.extAdapter ? fnc[3] : wrap);
if(wrap && el.addEventListener && eventName == "mousewheel"){
el.removeEventListener("DOMMouseScroll", wrap, false);
}
if(wrap && el == DOC && eventName == "mousedown"){
Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
}
f.splice(i, 1);
if (f.length === 0) {
delete Ext.elCache[id].events[eventName];
}
for (k in Ext.elCache[id].events) {
return false;
}
Ext.elCache[id].events = {};
return false;
}
}
},
removeAll : function(el){
el = Ext.getDom(el);
var id = getId(el),
ec = Ext.elCache[id] || {},
es = ec.events || {},
f, i, len, ename, fn, k, wrap;
for(ename in es){
if(es.hasOwnProperty(ename)){
f = es[ename];
for (i = 0, len = f.length; i < len; i++) {
fn = f[i];
if(fn[4]) {
fn[4].cancel();
}
if(fn[0].tasks && (k = fn[0].tasks.length)) {
while(k--) {
fn[0].tasks[k].cancel();
}
delete fn.tasks;
}
wrap = fn[1];
E.un(el, ename, E.extAdapter ? fn[3] : wrap);
if(el.addEventListener && wrap && ename == "mousewheel"){
el.removeEventListener("DOMMouseScroll", wrap, false);
}
if(wrap && el == DOC && ename == "mousedown"){
Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
}
}
}
}
if (Ext.elCache[id]) {
Ext.elCache[id].events = {};
}
},
getListeners : function(el, eventName) {
el = Ext.getDom(el);
var id = getId(el),
ec = Ext.elCache[id] || {},
es = ec.events || {},
results = [];
if (es && es[eventName]) {
return es[eventName];
} else {
return null;
}
},
purgeElement : function(el, recurse, eventName) {
el = Ext.getDom(el);
var id = getId(el),
ec = Ext.elCache[id] || {},
es = ec.events || {},
i, f, len;
if (eventName) {
if (es && es.hasOwnProperty(eventName)) {
f = es[eventName];
for (i = 0, len = f.length; i < len; i++) {
Ext.EventManager.removeListener(el, eventName, f[i][0]);
}
}
} else {
Ext.EventManager.removeAll(el);
}
if (recurse && el && el.childNodes) {
for (i = 0, len = el.childNodes.length; i < len; i++) {
Ext.EventManager.purgeElement(el.childNodes[i], recurse, eventName);
}
}
},
_unload : function() {
var el;
for (el in Ext.elCache) {
Ext.EventManager.removeAll(el);
}
delete Ext.elCache;
delete Ext.Element._flyweights;
var c,
conn,
tid,
ajax = Ext.lib.Ajax;
(typeof ajax.conn == 'object') ? conn = ajax.conn : conn = {};
for (tid in conn) {
c = conn[tid];
if (c) {
ajax.abort({conn: c, tId: tid});
}
}
},
onDocumentReady : function(fn, scope, options){
if (Ext.isReady) {
docReadyEvent || (docReadyEvent = new Ext.util.Event());
docReadyEvent.addListener(fn, scope, options);
docReadyEvent.fire();
docReadyEvent.listeners = [];
} else {
if (!docReadyEvent) {
initDocReady();
}
options = options || {};
options.delay = options.delay || 1;
docReadyEvent.addListener(fn, scope, options);
}
},
fireDocReady : fireDocReady
};
pub.on = pub.addListener;
pub.un = pub.removeListener;
pub.stoppedMouseDownEvent = new Ext.util.Event();
return pub;
}();
Ext.onReady = Ext.EventManager.onDocumentReady;
(function(){
var initExtCss = function() {
var bd = document.body || document.getElementsByTagName('body')[0];
if (!bd) {
return false;
}
var cls = [' ',
Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : (Ext.isIE8 ? 'ext-ie8' : 'ext-ie9')))
: Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
: Ext.isOpera ? "ext-opera"
: Ext.isWebKit ? "ext-webkit" : ""];
if (Ext.isSafari) {
cls.push("ext-safari " + (Ext.isSafari2 ? 'ext-safari2' : (Ext.isSafari3 ? 'ext-safari3' : 'ext-safari4')));
} else if(Ext.isChrome) {
cls.push("ext-chrome");
}
if (Ext.isMac) {
cls.push("ext-mac");
}
if (Ext.isLinux) {
cls.push("ext-linux");
}
if (Ext.isStrict || Ext.isBorderBox) {
var p = bd.parentNode;
if (p) {
if (!Ext.isStrict) {
Ext.fly(p, '_internal').addClass('x-quirks');
if (Ext.isIE && !Ext.isStrict) {
Ext.isIEQuirks = true;
}
}
Ext.fly(p, '_internal').addClass(((Ext.isStrict && Ext.isIE ) || (!Ext.enableForcedBoxModel && !Ext.isIE)) ? ' ext-strict' : ' ext-border-box');
}
}
if (Ext.enableForcedBoxModel && !Ext.isIE) {
Ext.isForcedBorderBox = true;
cls.push("ext-forced-border-box");
}
Ext.fly(bd, '_internal').addClass(cls);
return true;
};
if (!initExtCss()) {
Ext.onReady(initExtCss);
}
})();
(function(){
var supports = Ext.apply(Ext.supports, {
correctRightMargin: true,
correctTransparentColor: true,
cssFloat: true
});
var supportTests = function(){
var div = document.createElement('div'),
doc = document,
view,
last;
div.innerHTML = '<div style="height:30px;width:50px;"><div style="height:20px;width:20px;"></div></div><div style="float:left;background-color:transparent;">';
doc.body.appendChild(div);
last = div.lastChild;
if((view = doc.defaultView)){
if(view.getComputedStyle(div.firstChild.firstChild, null).marginRight != '0px'){
supports.correctRightMargin = false;
}
if(view.getComputedStyle(last, null).backgroundColor != 'transparent'){
supports.correctTransparentColor = false;
}
}
supports.cssFloat = !!last.style.cssFloat;
doc.body.removeChild(div);
};
if (Ext.isReady) {
supportTests();
} else {
Ext.onReady(supportTests);
}
})();
Ext.EventObject = function(){
var E = Ext.lib.Event,
clickRe = /(dbl)?click/,
safariKeys = {
3 : 13,
63234 : 37,
63235 : 39,
63232 : 38,
63233 : 40,
63276 : 33,
63277 : 34,
63272 : 46,
63273 : 36,
63275 : 35
},
btnMap = Ext.isIE ? {1:0,4:1,2:2} : {0:0,1:1,2:2};
Ext.EventObjectImpl = function(e){
if(e){
this.setEvent(e.browserEvent || e);
}
};
Ext.EventObjectImpl.prototype = {
setEvent : function(e){
var me = this;
if(e == me || (e && e.browserEvent)){
return e;
}
me.browserEvent = e;
if(e){
me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1);
if(clickRe.test(e.type) && me.button == -1){
me.button = 0;
}
me.type = e.type;
me.shiftKey = e.shiftKey;
me.ctrlKey = e.ctrlKey || e.metaKey || false;
me.altKey = e.altKey;
me.keyCode = e.keyCode;
me.charCode = e.charCode;
me.target = E.getTarget(e);
me.xy = E.getXY(e);
}else{
me.button = -1;
me.shiftKey = false;
me.ctrlKey = false;
me.altKey = false;
me.keyCode = 0;
me.charCode = 0;
me.target = null;
me.xy = [0, 0];
}
return me;
},
stopEvent : function(){
var me = this;
if(me.browserEvent){
if(me.browserEvent.type == 'mousedown'){
Ext.EventManager.stoppedMouseDownEvent.fire(me);
}
E.stopEvent(me.browserEvent);
}
},
preventDefault : function(){
if(this.browserEvent){
E.preventDefault(this.browserEvent);
}
},
stopPropagation : function(){
var me = this;
if(me.browserEvent){
if(me.browserEvent.type == 'mousedown'){
Ext.EventManager.stoppedMouseDownEvent.fire(me);
}
E.stopPropagation(me.browserEvent);
}
},
getCharCode : function(){
return this.charCode || this.keyCode;
},
getKey : function(){
return this.normalizeKey(this.keyCode || this.charCode);
},
normalizeKey: function(k){
return Ext.isSafari ? (safariKeys[k] || k) : k;
},
getPageX : function(){
return this.xy[0];
},
getPageY : function(){
return this.xy[1];
},
getXY : function(){
return this.xy;
},
getTarget : function(selector, maxDepth, returnEl){
return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
},
getRelatedTarget : function(){
return this.browserEvent ? E.getRelatedTarget(this.browserEvent) : null;
},
getWheelDelta : function(){
var e = this.browserEvent;
var delta = 0;
if(e.wheelDelta){
delta = e.wheelDelta/120;
}else if(e.detail){
delta = -e.detail/3;
}
return delta;
},
within : function(el, related, allowEl){
if(el){
var t = this[related ? "getRelatedTarget" : "getTarget"]();
return t && ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
}
return false;
}
};
return new Ext.EventObjectImpl();
}();
Ext.Loader = Ext.apply({}, {
load: function(fileList, callback, scope, preserveOrder) {
var scope = scope || this,
head = document.getElementsByTagName("head")[0],
fragment = document.createDocumentFragment(),
numFiles = fileList.length,
loadedFiles = 0,
me = this;
var loadFileIndex = function(index) {
head.appendChild(
me.buildScriptTag(fileList[index], onFileLoaded)
);
};
var onFileLoaded = function() {
loadedFiles ++;
if (numFiles == loadedFiles && typeof callback == 'function') {
callback.call(scope);
} else {
if (preserveOrder === true) {
loadFileIndex(loadedFiles);
}
}
};
if (preserveOrder === true) {
loadFileIndex.call(this, 0);
} else {
Ext.each(fileList, function(file, index) {
fragment.appendChild(
this.buildScriptTag(file, onFileLoaded)
);
}, this);
head.appendChild(fragment);
}
},
buildScriptTag: function(filename, callback) {
var script = document.createElement('script');
script.type = "text/javascript";
script.src = filename;
if (script.readyState) {
script.onreadystatechange = function() {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onreadystatechange = null;
callback();
}
};
} else {
script.onload = callback;
}
return script;
}
});
Ext.ns("Ext.grid", "Ext.list", "Ext.dd", "Ext.tree", "Ext.form", "Ext.menu",
"Ext.state", "Ext.layout.boxOverflow", "Ext.app", "Ext.ux", "Ext.chart", "Ext.direct", "Ext.slider");
Ext.apply(Ext, function(){
var E = Ext,
idSeed = 0,
scrollWidth = null;
return {
emptyFn : function(){},
BLANK_IMAGE_URL : Ext.isIE6 || Ext.isIE7 || Ext.isAir ?
'http:/' + '/www.extjs.com/s.gif' :
'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
extendX : function(supr, fn){
return Ext.extend(supr, fn(supr.prototype));
},
getDoc : function(){
return Ext.get(document);
},
num : function(v, defaultValue){
v = Number(Ext.isEmpty(v) || Ext.isArray(v) || typeof v == 'boolean' || (typeof v == 'string' && v.trim().length == 0) ? NaN : v);
return isNaN(v) ? defaultValue : v;
},
value : function(v, defaultValue, allowBlank){
return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
},
escapeRe : function(s) {
return s.replace(/([-.*+?^${}()|[\]\/\\])/g, "\\$1");
},
sequence : function(o, name, fn, scope){
o[name] = o[name].createSequence(fn, scope);
},
addBehaviors : function(o){
if(!Ext.isReady){
Ext.onReady(function(){
Ext.addBehaviors(o);
});
} else {
var cache = {},
parts,
b,
s;
for (b in o) {
if ((parts = b.split('@'))[1]) {
s = parts[0];
if(!cache[s]){
cache[s] = Ext.select(s);
}
cache[s].on(parts[1], o[b]);
}
}
cache = null;
}
},
getScrollBarWidth: function(force){
if(!Ext.isReady){
return 0;
}
if(force === true || scrollWidth === null){
var div = Ext.getBody().createChild('<div class="x-hide-offsets" style="width:100px;height:50px;overflow:hidden;"><div style="height:200px;"></div></div>'),
child = div.child('div', true);
var w1 = child.offsetWidth;
div.setStyle('overflow', (Ext.isWebKit || Ext.isGecko) ? 'auto' : 'scroll');
var w2 = child.offsetWidth;
div.remove();
scrollWidth = w1 - w2 + 2;
}
return scrollWidth;
},
combine : function(){
var as = arguments, l = as.length, r = [];
for(var i = 0; i < l; i++){
var a = as[i];
if(Ext.isArray(a)){
r = r.concat(a);
}else if(a.length !== undefined && !a.substr){
r = r.concat(Array.prototype.slice.call(a, 0));
}else{
r.push(a);
}
}
return r;
},
copyTo : function(dest, source, names){
if(typeof names == 'string'){
names = names.split(/[,;\s]/);
}
Ext.each(names, function(name){
if(source.hasOwnProperty(name)){
dest[name] = source[name];
}
}, this);
return dest;
},
destroy : function(){
Ext.each(arguments, function(arg){
if(arg){
if(Ext.isArray(arg)){
this.destroy.apply(this, arg);
}else if(typeof arg.destroy == 'function'){
arg.destroy();
}else if(arg.dom){
arg.remove();
}
}
}, this);
},
destroyMembers : function(o, arg1, arg2, etc){
for(var i = 1, a = arguments, len = a.length; i < len; i++) {
Ext.destroy(o[a[i]]);
delete o[a[i]];
}
},
clean : function(arr){
var ret = [];
Ext.each(arr, function(v){
if(!!v){
ret.push(v);
}
});
return ret;
},
unique : function(arr){
var ret = [],
collect = {};
Ext.each(arr, function(v) {
if(!collect[v]){
ret.push(v);
}
collect[v] = true;
});
return ret;
},
flatten : function(arr){
var worker = [];
function rFlatten(a) {
Ext.each(a, function(v) {
if(Ext.isArray(v)){
rFlatten(v);
}else{
worker.push(v);
}
});
return worker;
}
return rFlatten(arr);
},
min : function(arr, comp){
var ret = arr[0];
comp = comp || function(a,b){ return a < b ? -1 : 1; };
Ext.each(arr, function(v) {
ret = comp(ret, v) == -1 ? ret : v;
});
return ret;
},
max : function(arr, comp){
var ret = arr[0];
comp = comp || function(a,b){ return a > b ? 1 : -1; };
Ext.each(arr, function(v) {
ret = comp(ret, v) == 1 ? ret : v;
});
return ret;
},
mean : function(arr){
return arr.length > 0 ? Ext.sum(arr) / arr.length : undefined;
},
sum : function(arr){
var ret = 0;
Ext.each(arr, function(v) {
ret += v;
});
return ret;
},
partition : function(arr, truth){
var ret = [[],[]];
Ext.each(arr, function(v, i, a) {
ret[ (truth && truth(v, i, a)) || (!truth && v) ? 0 : 1].push(v);
});
return ret;
},
invoke : function(arr, methodName){
var ret = [],
args = Array.prototype.slice.call(arguments, 2);
Ext.each(arr, function(v,i) {
if (v && typeof v[methodName] == 'function') {
ret.push(v[methodName].apply(v, args));
} else {
ret.push(undefined);
}
});
return ret;
},
pluck : function(arr, prop){
var ret = [];
Ext.each(arr, function(v) {
ret.push( v[prop] );
});
return ret;
},
zip : function(){
var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }),
arrs = parts[0],
fn = parts[1][0],
len = Ext.max(Ext.pluck(arrs, "length")),
ret = [];
for (var i = 0; i < len; i++) {
ret[i] = [];
if(fn){
ret[i] = fn.apply(fn, Ext.pluck(arrs, i));
}else{
for (var j = 0, aLen = arrs.length; j < aLen; j++){
ret[i].push( arrs[j][i] );
}
}
}
return ret;
},
getCmp : function(id){
return Ext.ComponentMgr.get(id);
},
useShims: E.isIE6 || (E.isMac && E.isGecko2),
type : function(o){
if(o === undefined || o === null){
return false;
}
if(o.htmlElement){
return 'element';
}
var t = typeof o;
if(t == 'object' && o.nodeName) {
switch(o.nodeType) {
case 1: return 'element';
case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
}
}
if(t == 'object' || t == 'function') {
switch(o.constructor) {
case Array: return 'array';
case RegExp: return 'regexp';
case Date: return 'date';
}
if(typeof o.length == 'number' && typeof o.item == 'function') {
return 'nodelist';
}
}
return t;
},
intercept : function(o, name, fn, scope){
o[name] = o[name].createInterceptor(fn, scope);
},
callback : function(cb, scope, args, delay){
if(typeof cb == 'function'){
if(delay){
cb.defer(delay, scope, args || []);
}else{
cb.apply(scope, args || []);
}
}
}
};
}());
Ext.apply(Function.prototype, {
createSequence : function(fcn, scope){
var method = this;
return (typeof fcn != 'function') ?
this :
function(){
var retval = method.apply(this || window, arguments);
fcn.apply(scope || this || window, arguments);
return retval;
};
}
});
Ext.applyIf(String, {
escape : function(string) {
return string.replace(/('|\\)/g, "\\$1");
},
leftPad : function (val, size, ch) {
var result = String(val);
if(!ch) {
ch = " ";
}
while (result.length < size) {
result = ch + result;
}
return result;
}
});
String.prototype.toggle = function(value, other){
return this == value ? other : value;
};
String.prototype.trim = function(){
var re = /^\s+|\s+$/g;
return function(){ return this.replace(re, ""); };
}();
Date.prototype.getElapsed = function(date) {
return Math.abs((date || new Date()).getTime()-this.getTime());
};
Ext.applyIf(Number.prototype, {
constrain : function(min, max){
return Math.min(Math.max(this, min), max);
}
});
Ext.lib.Dom.getRegion = function(el) {
return Ext.lib.Region.getRegion(el);
}; Ext.lib.Region = function(t, r, b, l) {
var me = this;
me.top = t;
me[1] = t;
me.right = r;
me.bottom = b;
me.left = l;
me[0] = l;
};
Ext.lib.Region.prototype = {
contains : function(region) {
var me = this;
return ( region.left >= me.left &&
region.right <= me.right &&
region.top >= me.top &&
region.bottom <= me.bottom );
},
getArea : function() {
var me = this;
return ( (me.bottom - me.top) * (me.right - me.left) );
},
intersect : function(region) {
var me = this,
t = Math.max(me.top, region.top),
r = Math.min(me.right, region.right),
b = Math.min(me.bottom, region.bottom),
l = Math.max(me.left, region.left);
if (b >= t && r >= l) {
return new Ext.lib.Region(t, r, b, l);
}
},
union : function(region) {
var me = this,
t = Math.min(me.top, region.top),
r = Math.max(me.right, region.right),
b = Math.max(me.bottom, region.bottom),
l = Math.min(me.left, region.left);
return new Ext.lib.Region(t, r, b, l);
},
constrainTo : function(r) {
var me = this;
me.top = me.top.constrain(r.top, r.bottom);
me.bottom = me.bottom.constrain(r.top, r.bottom);
me.left = me.left.constrain(r.left, r.right);
me.right = me.right.constrain(r.left, r.right);
return me;
},
adjust : function(t, l, b, r) {
var me = this;
me.top += t;
me.left += l;
me.right += r;
me.bottom += b;
return me;
}
};
Ext.lib.Region.getRegion = function(el) {
var p = Ext.lib.Dom.getXY(el),
t = p[1],
r = p[0] + el.offsetWidth,
b = p[1] + el.offsetHeight,
l = p[0];
return new Ext.lib.Region(t, r, b, l);
}; Ext.lib.Point = function(x, y) {
if (Ext.isArray(x)) {
y = x[1];
x = x[0];
}
var me = this;
me.x = me.right = me.left = me[0] = x;
me.y = me.top = me.bottom = me[1] = y;
};
Ext.lib.Point.prototype = new Ext.lib.Region();
Ext.apply(Ext.DomHelper,
function(){
var pub,
afterbegin = 'afterbegin',
afterend = 'afterend',
beforebegin = 'beforebegin',
beforeend = 'beforeend',
confRe = /tag|children|cn|html$/i;
function doInsert(el, o, returnElement, pos, sibling, append){
el = Ext.getDom(el);
var newNode;
if (pub.useDom) {
newNode = createDom(o, null);
if (append) {
el.appendChild(newNode);
} else {
(sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);
}
} else {
newNode = Ext.DomHelper.insertHtml(pos, el, Ext.DomHelper.createHtml(o));
}
return returnElement ? Ext.get(newNode, true) : newNode;
}
function createDom(o, parentNode){
var el,
doc = document,
useSet,
attr,
val,
cn;
if (Ext.isArray(o)) {
el = doc.createDocumentFragment();
for (var i = 0, l = o.length; i < l; i++) {
createDom(o[i], el);
}
} else if (typeof o == 'string') {
el = doc.createTextNode(o);
} else {
el = doc.createElement( o.tag || 'div' );
useSet = !!el.setAttribute;
for (var attr in o) {
if(!confRe.test(attr)){
val = o[attr];
if(attr == 'cls'){
el.className = val;
}else{
if(useSet){
el.setAttribute(attr, val);
}else{
el[attr] = val;
}
}
}
}
Ext.DomHelper.applyStyles(el, o.style);
if ((cn = o.children || o.cn)) {
createDom(cn, el);
} else if (o.html) {
el.innerHTML = o.html;
}
}
if(parentNode){
parentNode.appendChild(el);
}
return el;
}
pub = {
createTemplate : function(o){
var html = Ext.DomHelper.createHtml(o);
return new Ext.Template(html);
},
useDom : false,
insertBefore : function(el, o, returnElement){
return doInsert(el, o, returnElement, beforebegin);
},
insertAfter : function(el, o, returnElement){
return doInsert(el, o, returnElement, afterend, 'nextSibling');
},
insertFirst : function(el, o, returnElement){
return doInsert(el, o, returnElement, afterbegin, 'firstChild');
},
append: function(el, o, returnElement){
return doInsert(el, o, returnElement, beforeend, '', true);
},
createDom: createDom
};
return pub;
}());
Ext.apply(Ext.Template.prototype, {
disableFormats : false,
re : /\{([\w\-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
argsRe : /^\s*['"](.*)["']\s*$/,
compileARe : /\\/g,
compileBRe : /(\r\n|\n)/g,
compileCRe : /'/g,
/**
* Returns an HTML fragment of this template with the specified values applied.
* @param {Object/Array} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
* @return {String} The HTML fragment
* @hide repeat doc
*/
applyTemplate : function(values){
var me = this,
useF = me.disableFormats !== true,
fm = Ext.util.Format,
tpl = me;
if(me.compiled){
return me.compiled(values);
}
function fn(m, name, format, args){
if (format && useF) {
if (format.substr(0, 5) == "this.") {
return tpl.call(format.substr(5), values[name], values);
} else {
if (args) {
// quoted values are required for strings in compiled templates,
// but for non compiled we need to strip them
// quoted reversed for jsmin
var re = me.argsRe;
args = args.split(',');
for(var i = 0, len = args.length; i < len; i++){
args[i] = args[i].replace(re, "$1");
}
args = [values[name]].concat(args);
} else {
args = [values[name]];
}
return fm[format].apply(fm, args);
}
} else {
return values[name] !== undefined ? values[name] : "";
}
}
return me.html.replace(me.re, fn);
},
/**
* Compiles the template into an internal function, eliminating the RegEx overhead.
* @return {Ext.Template} this
* @hide repeat doc
*/
compile : function(){
var me = this,
fm = Ext.util.Format,
useF = me.disableFormats !== true,
sep = Ext.isGecko ? "+" : ",",
body;
function fn(m, name, format, args){
if(format && useF){
args = args ? ',' + args : "";
if(format.substr(0, 5) != "this."){
format = "fm." + format + '(';
}else{
format = 'this.call("'+ format.substr(5) + '", ';
args = ", values";
}
}else{
args= ''; format = "(values['" + name + "'] == undefined ? '' : ";
}
return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
}
// branched to use + in gecko and [].join() in others
if(Ext.isGecko){
body = "this.compiled = function(values){ return '" +
me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn) +
"';};";
}else{
body = ["this.compiled = function(values){ return ['"];
body.push(me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn));
body.push("'].join('');};");
body = body.join('');
}
eval(body);
return me;
},
// private function used to call members
call : function(fnName, value, allValues){
return this[fnName](value, allValues);
}
});
Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
/**
* @class Ext.util.Functions
* @singleton
*/
Ext.util.Functions = {
/**
* Creates an interceptor function. The passed function is called before the original one. If it returns false,
* the original one is not called. The resulting function returns the results of the original function.
* The passed function is called with the parameters of the original function. Example usage:
* <pre><code>
var sayHi = function(name){
alert('Hi, ' + name);
}
sayHi('Fred'); // alerts "Hi, Fred"
// create a new function that validates input without
// directly modifying the original function:
var sayHiToFriend = Ext.createInterceptor(sayHi, function(name){
return name == 'Brian';
});
sayHiToFriend('Fred'); // no alert
sayHiToFriend('Brian'); // alerts "Hi, Brian"
</code></pre>
* @param {Function} origFn The original function.
* @param {Function} newFn The function to call before the original
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
* <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
* @return {Function} The new function
*/
createInterceptor: function(origFn, newFn, scope) {
var method = origFn;
if (!Ext.isFunction(newFn)) {
return origFn;
}
else {
return function() {
var me = this,
args = arguments;
newFn.target = me;
newFn.method = origFn;
return (newFn.apply(scope || me || window, args) !== false) ?
origFn.apply(me || window, args) :
null;
};
}
},
/**
* Creates a delegate (callback) that sets the scope to obj.
* Call directly on any function. Example: <code>Ext.createDelegate(this.myFunction, this, [arg1, arg2])</code>
* Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
* callback points to obj. Example usage:
* <pre><code>
var sayHi = function(name){
// Note this use of "this.text" here. This function expects to
// execute within a scope that contains a text property. In this
// example, the "this" variable is pointing to the btn object that
// was passed in createDelegate below.
alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
}
var btn = new Ext.Button({
text: 'Say Hi',
renderTo: Ext.getBody()
});
// This callback will execute in the scope of the
// button instance. Clicking the button alerts
// "Hi, Fred. You clicked the "Say Hi" button."
btn.on('click', Ext.createDelegate(sayHi, btn, ['Fred']));
</code></pre>
* @param {Function} fn The function to delegate.
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
* <b>If omitted, defaults to the browser window.</b>
* @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
* @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
* if a number the args are inserted at the specified position
* @return {Function} The new function
*/
createDelegate: function(fn, obj, args, appendArgs) {
if (!Ext.isFunction(fn)) {
return fn;
}
return function() {
var callArgs = args || arguments;
if (appendArgs === true) {
callArgs = Array.prototype.slice.call(arguments, 0);
callArgs = callArgs.concat(args);
}
else if (Ext.isNumber(appendArgs)) {
callArgs = Array.prototype.slice.call(arguments, 0);
// copy arguments first
var applyArgs = [appendArgs, 0].concat(args);
// create method call params
Array.prototype.splice.apply(callArgs, applyArgs);
// splice them in
}
return fn.apply(obj || window, callArgs);
};
},
/**
* Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
* <pre><code>
var sayHi = function(name){
alert('Hi, ' + name);
}
// executes immediately:
sayHi('Fred');
// executes after 2 seconds:
Ext.defer(sayHi, 2000, this, ['Fred']);
// this syntax is sometimes useful for deferring
// execution of an anonymous function:
Ext.defer(function(){
alert('Anonymous');
}, 100);
</code></pre>
* @param {Function} fn The function to defer.
* @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
* <b>If omitted, defaults to the browser window.</b>
* @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
* @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
* if a number the args are inserted at the specified position
* @return {Number} The timeout id that can be used with clearTimeout
*/
defer: function(fn, millis, obj, args, appendArgs) {
fn = Ext.util.Functions.createDelegate(fn, obj, args, appendArgs);
if (millis > 0) {
return setTimeout(fn, millis);
}
fn();
return 0;
},
/**
* Create a combined function call sequence of the original function + the passed function.
* The resulting function returns the results of the original function.
* The passed fcn is called with the parameters of the original function. Example usage:
*
var sayHi = function(name){
alert('Hi, ' + name);
}
sayHi('Fred'); // alerts "Hi, Fred"
var sayGoodbye = Ext.createSequence(sayHi, function(name){
alert('Bye, ' + name);
});
sayGoodbye('Fred'); // both alerts show
* @param {Function} origFn The original function.
* @param {Function} newFn The function to sequence
* @param {Object} scope (optional) The scope (this reference) in which the passed function is executed.
* If omitted, defaults to the scope in which the original function is called or the browser window.
* @return {Function} The new function
*/
createSequence: function(origFn, newFn, scope) {
if (!Ext.isFunction(newFn)) {
return origFn;
}
else {
return function() {
var retval = origFn.apply(this || window, arguments);
newFn.apply(scope || this || window, arguments);
return retval;
};
}
}
};
/**
* Shorthand for {@link Ext.util.Functions#defer}
* @param {Function} fn The function to defer.
* @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
* <b>If omitted, defaults to the browser window.</b>
* @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
* @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
* if a number the args are inserted at the specified position
* @return {Number} The timeout id that can be used with clearTimeout
* @member Ext
* @method defer
*/
Ext.defer = Ext.util.Functions.defer;
/**
* Shorthand for {@link Ext.util.Functions#createInterceptor}
* @param {Function} origFn The original function.
* @param {Function} newFn The function to call before the original
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
* <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
* @return {Function} The new function
* @member Ext
* @method defer
*/
Ext.createInterceptor = Ext.util.Functions.createInterceptor;
/**
* Shorthand for {@link Ext.util.Functions#createSequence}
* @param {Function} origFn The original function.
* @param {Function} newFn The function to sequence
* @param {Object} scope (optional) The scope (this reference) in which the passed function is executed.
* If omitted, defaults to the scope in which the original function is called or the browser window.
* @return {Function} The new function
* @member Ext
* @method defer
*/
Ext.createSequence = Ext.util.Functions.createSequence;
/**
* Shorthand for {@link Ext.util.Functions#createDelegate}
* @param {Function} fn The function to delegate.
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
* <b>If omitted, defaults to the browser window.</b>
* @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
* @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
* if a number the args are inserted at the specified position
* @return {Function} The new function
* @member Ext
* @method defer
*/
Ext.createDelegate = Ext.util.Functions.createDelegate;
/**
* @class Ext.util.Observable
*/
Ext.apply(Ext.util.Observable.prototype, function(){
// this is considered experimental (along with beforeMethod, afterMethod, removeMethodListener?)
// allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call
// private
function getMethodEvent(method){
var e = (this.methodEvents = this.methodEvents ||
{})[method], returnValue, v, cancel, obj = this;
if (!e) {
this.methodEvents[method] = e = {};
e.originalFn = this[method];
e.methodName = method;
e.before = [];
e.after = [];
var makeCall = function(fn, scope, args){
if((v = fn.apply(scope || obj, args)) !== undefined){
if (typeof v == 'object') {
if(v.returnValue !== undefined){
returnValue = v.returnValue;
}else{
returnValue = v;
}
cancel = !!v.cancel;
}
else
if (v === false) {
cancel = true;
}
else {
returnValue = v;
}
}
};
this[method] = function(){
var args = Array.prototype.slice.call(arguments, 0),
b;
returnValue = v = undefined;
cancel = false;
for(var i = 0, len = e.before.length; i < len; i++){
b = e.before[i];
makeCall(b.fn, b.scope, args);
if (cancel) {
return returnValue;
}
}
if((v = e.originalFn.apply(obj, args)) !== undefined){
returnValue = v;
}
for(var i = 0, len = e.after.length; i < len; i++){
b = e.after[i];
makeCall(b.fn, b.scope, args);
if (cancel) {
return returnValue;
}
}
return returnValue;
};
}
return e;
}
return {
// these are considered experimental
// allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call
// adds an 'interceptor' called before the original method
beforeMethod : function(method, fn, scope){
getMethodEvent.call(this, method).before.push({
fn: fn,
scope: scope
});
},
// adds a 'sequence' called after the original method
afterMethod : function(method, fn, scope){
getMethodEvent.call(this, method).after.push({
fn: fn,
scope: scope
});
},
removeMethodListener: function(method, fn, scope){
var e = this.getMethodEvent(method);
for(var i = 0, len = e.before.length; i < len; i++){
if(e.before[i].fn == fn && e.before[i].scope == scope){
e.before.splice(i, 1);
return;
}
}
for(var i = 0, len = e.after.length; i < len; i++){
if(e.after[i].fn == fn && e.after[i].scope == scope){
e.after.splice(i, 1);
return;
}
}
},
/**
* Relays selected events from the specified Observable as if the events were fired by <tt><b>this</b></tt>.
* @param {Object} o The Observable whose events this object is to relay.
* @param {Array} events Array of event names to relay.
*/
relayEvents : function(o, events){
var me = this;
function createHandler(ename){
return function(){
return me.fireEvent.apply(me, [ename].concat(Array.prototype.slice.call(arguments, 0)));
};
}
for(var i = 0, len = events.length; i < len; i++){
var ename = events[i];
me.events[ename] = me.events[ename] || true;
o.on(ename, createHandler(ename), me);
}
},
/**
* <p>Enables events fired by this Observable to bubble up an owner hierarchy by calling
* <code>this.getBubbleTarget()</code> if present. There is no implementation in the Observable base class.</p>
* <p>This is commonly used by Ext.Components to bubble events to owner Containers. See {@link Ext.Component.getBubbleTarget}. The default
* implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to
* access the required target more quickly.</p>
* <p>Example:</p><pre><code>
Ext.override(Ext.form.Field, {
initComponent : Ext.form.Field.prototype.initComponent.createSequence(function() {
this.enableBubble('change');
}),
getBubbleTarget : function() {
if (!this.formPanel) {
this.formPanel = this.findParentByType('form');
}
return this.formPanel;
}
});
var myForm = new Ext.formPanel({
title: 'User Details',
items: [{
...
}],
listeners: {
change: function() {
myForm.header.setStyle('color', 'red');
}
}
});
</code></pre>
* @param {String/Array} events The event name to bubble, or an Array of event names.
*/
enableBubble : function(events){
var me = this;
if(!Ext.isEmpty(events)){
events = Ext.isArray(events) ? events : Array.prototype.slice.call(arguments, 0);
for(var i = 0, len = events.length; i < len; i++){
var ename = events[i];
ename = ename.toLowerCase();
var ce = me.events[ename] || true;
if (typeof ce == 'boolean') {
ce = new Ext.util.Event(me, ename);
me.events[ename] = ce;
}
ce.bubble = true;
}
}
}
};
}());
Ext.util.Observable.capture = function(o, fn, scope){
o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
};
Ext.util.Observable.observeClass = function(c, listeners){
if(c){
if(!c.fireEvent){
Ext.apply(c, new Ext.util.Observable());
Ext.util.Observable.capture(c.prototype, c.fireEvent, c);
}
if(typeof listeners == 'object'){
c.on(listeners);
}
return c;
}
};
Ext.apply(Ext.EventManager, function(){
var resizeEvent,
resizeTask,
textEvent,
textSize,
D = Ext.lib.Dom,
propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
unload = Ext.EventManager._unload,
curWidth = 0,
curHeight = 0,
useKeydown = Ext.isWebKit ?
Ext.num(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1]) >= 525 :
!((Ext.isGecko && !Ext.isWindows) || Ext.isOpera);
return {
_unload: function(){
Ext.EventManager.un(window, "resize", this.fireWindowResize, this);
unload.call(Ext.EventManager);
},
doResizeEvent: function(){
var h = D.getViewHeight(),
w = D.getViewWidth();
if(curHeight != h || curWidth != w){
resizeEvent.fire(curWidth = w, curHeight = h);
}
},
onWindowResize : function(fn, scope, options){
if(!resizeEvent){
resizeEvent = new Ext.util.Event();
resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);
Ext.EventManager.on(window, "resize", this.fireWindowResize, this);
}
resizeEvent.addListener(fn, scope, options);
},
fireWindowResize : function(){
if(resizeEvent){
resizeTask.delay(100);
}
},
onTextResize : function(fn, scope, options){
if(!textEvent){
textEvent = new Ext.util.Event();
var textEl = new Ext.Element(document.createElement('div'));
textEl.dom.className = 'x-text-resize';
textEl.dom.innerHTML = 'X';
textEl.appendTo(document.body);
textSize = textEl.dom.offsetHeight;
setInterval(function(){
if(textEl.dom.offsetHeight != textSize){
textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
}
}, this.textResizeInterval);
}
textEvent.addListener(fn, scope, options);
},
removeResizeListener : function(fn, scope){
if(resizeEvent){
resizeEvent.removeListener(fn, scope);
}
},
fireResize : function(){
if(resizeEvent){
resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
}
},
textResizeInterval : 50,
ieDeferSrc : false,
getKeyEvent : function(){
return useKeydown ? 'keydown' : 'keypress';
},
useKeydown: useKeydown
};
}());
Ext.EventManager.on = Ext.EventManager.addListener;
Ext.apply(Ext.EventObjectImpl.prototype, {
BACKSPACE: 8,
TAB: 9,
NUM_CENTER: 12,
ENTER: 13,
RETURN: 13,
SHIFT: 16,
CTRL: 17,
CONTROL : 17,
ALT: 18,
PAUSE: 19,
CAPS_LOCK: 20,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGEUP : 33,
PAGE_DOWN: 34,
PAGEDOWN : 34,
END: 35,
HOME: 36,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
PRINT_SCREEN: 44,
INSERT: 45,
DELETE: 46,
ZERO: 48,
ONE: 49,
TWO: 50,
THREE: 51,
FOUR: 52,
FIVE: 53,
SIX: 54,
SEVEN: 55,
EIGHT: 56,
NINE: 57,
A: 65,
B: 66,
C: 67,
D: 68,
E: 69,
F: 70,
G: 71,
H: 72,
I: 73,
J: 74,
K: 75,
L: 76,
M: 77,
N: 78,
O: 79,
P: 80,
Q: 81,
R: 82,
S: 83,
T: 84,
U: 85,
V: 86,
W: 87,
X: 88,
Y: 89,
Z: 90,
CONTEXT_MENU: 93,
NUM_ZERO: 96,
NUM_ONE: 97,
NUM_TWO: 98,
NUM_THREE: 99,
NUM_FOUR: 100,
NUM_FIVE: 101,
NUM_SIX: 102,
NUM_SEVEN: 103,
NUM_EIGHT: 104,
NUM_NINE: 105,
NUM_MULTIPLY: 106,
NUM_PLUS: 107,
NUM_MINUS: 109,
NUM_PERIOD: 110,
NUM_DIVISION: 111,
F1: 112,
F2: 113,
F3: 114,
F4: 115,
F5: 116,
F6: 117,
F7: 118,
F8: 119,
F9: 120,
F10: 121,
F11: 122,
F12: 123,
isNavKeyPress : function(){
var me = this,
k = this.normalizeKey(me.keyCode);
return (k >= 33 && k <= 40) ||
k == me.RETURN ||
k == me.TAB ||
k == me.ESC;
},
isSpecialKey : function(){
var k = this.normalizeKey(this.keyCode);
return (this.type == 'keypress' && this.ctrlKey) ||
this.isNavKeyPress() ||
(k == this.BACKSPACE) ||
(k >= 16 && k <= 20) ||
(k >= 44 && k <= 46);
},
getPoint : function(){
return new Ext.lib.Point(this.xy[0], this.xy[1]);
},
hasModifier : function(){
return ((this.ctrlKey || this.altKey) || this.shiftKey);
}
});
Ext.Element.addMethods({
swallowEvent : function(eventName, preventDefault) {
var me = this;
function fn(e) {
e.stopPropagation();
if (preventDefault) {
e.preventDefault();
}
}
if (Ext.isArray(eventName)) {
Ext.each(eventName, function(e) {
me.on(e, fn);
});
return me;
}
me.on(eventName, fn);
return me;
},
relayEvent : function(eventName, observable) {
this.on(eventName, function(e) {
observable.fireEvent(eventName, e);
});
},
clean : function(forceReclean) {
var me = this,
dom = me.dom,
n = dom.firstChild,
ni = -1;
if (Ext.Element.data(dom, 'isCleaned') && forceReclean !== true) {
return me;
}
while (n) {
var nx = n.nextSibling;
if (n.nodeType == 3 && !(/\S/.test(n.nodeValue))) {
dom.removeChild(n);
} else {
n.nodeIndex = ++ni;
}
n = nx;
}
Ext.Element.data(dom, 'isCleaned', true);
return me;
},
load : function() {
var updateManager = this.getUpdater();
updateManager.update.apply(updateManager, arguments);
return this;
},
getUpdater : function() {
return this.updateManager || (this.updateManager = new Ext.Updater(this));
},
update : function(html, loadScripts, callback) {
if (!this.dom) {
return this;
}
html = html || "";
if (loadScripts !== true) {
this.dom.innerHTML = html;
if (typeof callback == 'function') {
callback();
}
return this;
}
var id = Ext.id(),
dom = this.dom;
html += '<span id="' + id + '"></span>';
Ext.lib.Event.onAvailable(id, function() {
var DOC = document,
hd = DOC.getElementsByTagName("head")[0],
re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
srcRe = /\ssrc=([\'\"])(.*?)\1/i,
typeRe = /\stype=([\'\"])(.*?)\1/i,
match,
attrs,
srcMatch,
typeMatch,
el,
s;
while ((match = re.exec(html))) {
attrs = match[1];
srcMatch = attrs ? attrs.match(srcRe) : false;
if (srcMatch && srcMatch[2]) {
s = DOC.createElement("script");
s.src = srcMatch[2];
typeMatch = attrs.match(typeRe);
if (typeMatch && typeMatch[2]) {
s.type = typeMatch[2];
}
hd.appendChild(s);
} else if (match[2] && match[2].length > 0) {
if (window.execScript) {
window.execScript(match[2]);
} else {
window.eval(match[2]);
}
}
}
el = DOC.getElementById(id);
if (el) {
Ext.removeNode(el);
}
if (typeof callback == 'function') {
callback();
}
});
dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
return this;
},
removeAllListeners : function() {
this.removeAnchor();
Ext.EventManager.removeAll(this.dom);
return this;
},
createProxy : function(config, renderTo, matchBox) {
config = (typeof config == 'object') ? config : {tag : "div", cls: config};
var me = this,
proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
Ext.DomHelper.insertBefore(me.dom, config, true);
if (matchBox && me.setBox && me.getBox) {
proxy.setBox(me.getBox());
}
return proxy;
}
});
Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;
Ext.Element.addMethods({
getAnchorXY : function(anchor, local, s){
anchor = (anchor || "tl").toLowerCase();
s = s || {};
var me = this,
vp = me.dom == document.body || me.dom == document,
w = s.width || vp ? Ext.lib.Dom.getViewWidth() : me.getWidth(),
h = s.height || vp ? Ext.lib.Dom.getViewHeight() : me.getHeight(),
xy,
r = Math.round,
o = me.getXY(),
scroll = me.getScroll(),
extraX = vp ? scroll.left : !local ? o[0] : 0,
extraY = vp ? scroll.top : !local ? o[1] : 0,
hash = {
c : [r(w * 0.5), r(h * 0.5)],
t : [r(w * 0.5), 0],
l : [0, r(h * 0.5)],
r : [w, r(h * 0.5)],
b : [r(w * 0.5), h],
tl : [0, 0],
bl : [0, h],
br : [w, h],
tr : [w, 0]
};
xy = hash[anchor];
return [xy[0] + extraX, xy[1] + extraY];
},
anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback){
var me = this,
dom = me.dom,
scroll = !Ext.isEmpty(monitorScroll),
action = function(){
Ext.fly(dom).alignTo(el, alignment, offsets, animate);
Ext.callback(callback, Ext.fly(dom));
},
anchor = this.getAnchor();
this.removeAnchor();
Ext.apply(anchor, {
fn: action,
scroll: scroll
});
Ext.EventManager.onWindowResize(action, null);
if(scroll){
Ext.EventManager.on(window, 'scroll', action, null,
{buffer: !isNaN(monitorScroll) ? monitorScroll : 50});
}
action.call(me);
return me;
},
removeAnchor : function(){
var me = this,
anchor = this.getAnchor();
if(anchor && anchor.fn){
Ext.EventManager.removeResizeListener(anchor.fn);
if(anchor.scroll){
Ext.EventManager.un(window, 'scroll', anchor.fn);
}
delete anchor.fn;
}
return me;
},
getAnchor : function(){
var data = Ext.Element.data,
dom = this.dom;
if (!dom) {
return;
}
var anchor = data(dom, '_anchor');
if(!anchor){
anchor = data(dom, '_anchor', {});
}
return anchor;
},
getAlignToXY : function(el, p, o){
el = Ext.get(el);
if(!el || !el.dom){
throw "Element.alignToXY with an element that doesn't exist";
}
o = o || [0,0];
p = (!p || p == "?" ? "tl-bl?" : (!(/-/).test(p) && p !== "" ? "tl-" + p : p || "tl-bl")).toLowerCase();
var me = this,
d = me.dom,
a1,
a2,
x,
y,
w,
h,
r,
dw = Ext.lib.Dom.getViewWidth() -10,
dh = Ext.lib.Dom.getViewHeight()-10,
p1y,
p1x,
p2y,
p2x,
swapY,
swapX,
doc = document,
docElement = doc.documentElement,
docBody = doc.body,
scrollX = (docElement.scrollLeft || docBody.scrollLeft || 0)+5,
scrollY = (docElement.scrollTop || docBody.scrollTop || 0)+5,
c = false,
p1 = "",
p2 = "",
m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
if(!m){
throw "Element.alignTo with an invalid alignment " + p;
}
p1 = m[1];
p2 = m[2];
c = !!m[3];
a1 = me.getAnchorXY(p1, true);
a2 = el.getAnchorXY(p2, false);
x = a2[0] - a1[0] + o[0];
y = a2[1] - a1[1] + o[1];
if(c){
w = me.getWidth();
h = me.getHeight();
r = el.getRegion();
p1y = p1.charAt(0);
p1x = p1.charAt(p1.length-1);
p2y = p2.charAt(0);
p2x = p2.charAt(p2.length-1);
swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
if (x + w > dw + scrollX) {
x = swapX ? r.left-w : dw+scrollX-w;
}
if (x < scrollX) {
x = swapX ? r.right : scrollX;
}
if (y + h > dh + scrollY) {
y = swapY ? r.top-h : dh+scrollY-h;
}
if (y < scrollY){
y = swapY ? r.bottom : scrollY;
}
}
return [x,y];
},
alignTo : function(element, position, offsets, animate){
var me = this;
return me.setXY(me.getAlignToXY(element, position, offsets),
me.preanim && !!animate ? me.preanim(arguments, 3) : false);
},
adjustForConstraints : function(xy, parent, offsets){
return this.getConstrainToXY(parent || document, false, offsets, xy) || xy;
},
getConstrainToXY : function(el, local, offsets, proposedXY){
var os = {top:0, left:0, bottom:0, right: 0};
return function(el, local, offsets, proposedXY){
el = Ext.get(el);
offsets = offsets ? Ext.applyIf(offsets, os) : os;
var vw, vh, vx = 0, vy = 0;
if(el.dom == document.body || el.dom == document){
vw =Ext.lib.Dom.getViewWidth();
vh = Ext.lib.Dom.getViewHeight();
}else{
vw = el.dom.clientWidth;
vh = el.dom.clientHeight;
if(!local){
var vxy = el.getXY();
vx = vxy[0];
vy = vxy[1];
}
}
var s = el.getScroll();
vx += offsets.left + s.left;
vy += offsets.top + s.top;
vw -= offsets.right;
vh -= offsets.bottom;
var vr = vx + vw,
vb = vy + vh,
xy = proposedXY || (!local ? this.getXY() : [this.getLeft(true), this.getTop(true)]),
x = xy[0], y = xy[1],
offset = this.getConstrainOffset(),
w = this.dom.offsetWidth + offset,
h = this.dom.offsetHeight + offset;
var moved = false;
if((x + w) > vr){
x = vr - w;
moved = true;
}
if((y + h) > vb){
y = vb - h;
moved = true;
}
if(x < vx){
x = vx;
moved = true;
}
if(y < vy){
y = vy;
moved = true;
}
return moved ? [x, y] : false;
};
}(),
getConstrainOffset : function(){
return 0;
},
getCenterXY : function(){
return this.getAlignToXY(document, 'c-c');
},
center : function(centerIn){
return this.alignTo(centerIn || document, 'c-c');
}
});
Ext.Element.addMethods({
select : function(selector, unique){
return Ext.Element.select(selector, unique, this.dom);
}
});
Ext.apply(Ext.Element.prototype, function() {
var GETDOM = Ext.getDom,
GET = Ext.get,
DH = Ext.DomHelper;
return {
insertSibling: function(el, where, returnDom){
var me = this,
rt,
isAfter = (where || 'before').toLowerCase() == 'after',
insertEl;
if(Ext.isArray(el)){
insertEl = me;
Ext.each(el, function(e) {
rt = Ext.fly(insertEl, '_internal').insertSibling(e, where, returnDom);
if(isAfter){
insertEl = rt;
}
});
return rt;
}
el = el || {};
if(el.nodeType || el.dom){
rt = me.dom.parentNode.insertBefore(GETDOM(el), isAfter ? me.dom.nextSibling : me.dom);
if (!returnDom) {
rt = GET(rt);
}
}else{
if (isAfter && !me.dom.nextSibling) {
rt = DH.append(me.dom.parentNode, el, !returnDom);
} else {
rt = DH[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
}
}
return rt;
}
};
}());
Ext.Element.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
Ext.Element.addMethods(function(){
var INTERNAL = "_internal",
pxMatch = /(\d+\.?\d+)px/;
return {
applyStyles : function(style){
Ext.DomHelper.applyStyles(this.dom, style);
return this;
},
getStyles : function(){
var ret = {};
Ext.each(arguments, function(v) {
ret[v] = this.getStyle(v);
},
this);
return ret;
},
setOverflow : function(v){
var dom = this.dom;
if(v=='auto' && Ext.isMac && Ext.isGecko2){
dom.style.overflow = 'hidden';
(function(){dom.style.overflow = 'auto';}).defer(1);
}else{
dom.style.overflow = v;
}
},
boxWrap : function(cls){
cls = cls || 'x-box';
var el = Ext.get(this.insertHtml("beforeBegin", "<div class='" + cls + "'>" + String.format(Ext.Element.boxMarkup, cls) + "</div>"));
Ext.DomQuery.selectNode('.' + cls + '-mc', el.dom).appendChild(this.dom);
return el;
},
setSize : function(width, height, animate){
var me = this;
if(typeof width == 'object'){
height = width.height;
width = width.width;
}
width = me.adjustWidth(width);
height = me.adjustHeight(height);
if(!animate || !me.anim){
me.dom.style.width = me.addUnits(width);
me.dom.style.height = me.addUnits(height);
}else{
me.anim({width: {to: width}, height: {to: height}}, me.preanim(arguments, 2));
}
return me;
},
getComputedHeight : function(){
var me = this,
h = Math.max(me.dom.offsetHeight, me.dom.clientHeight);
if(!h){
h = parseFloat(me.getStyle('height')) || 0;
if(!me.isBorderBox()){
h += me.getFrameWidth('tb');
}
}
return h;
},
getComputedWidth : function(){
var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
if(!w){
w = parseFloat(this.getStyle('width')) || 0;
if(!this.isBorderBox()){
w += this.getFrameWidth('lr');
}
}
return w;
},
getFrameWidth : function(sides, onlyContentBox){
return onlyContentBox && this.isBorderBox() ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));
},
addClassOnOver : function(className){
this.hover(
function(){
Ext.fly(this, INTERNAL).addClass(className);
},
function(){
Ext.fly(this, INTERNAL).removeClass(className);
}
);
return this;
},
addClassOnFocus : function(className){
this.on("focus", function(){
Ext.fly(this, INTERNAL).addClass(className);
}, this.dom);
this.on("blur", function(){
Ext.fly(this, INTERNAL).removeClass(className);
}, this.dom);
return this;
},
addClassOnClick : function(className){
var dom = this.dom;
this.on("mousedown", function(){
Ext.fly(dom, INTERNAL).addClass(className);
var d = Ext.getDoc(),
fn = function(){
Ext.fly(dom, INTERNAL).removeClass(className);
d.removeListener("mouseup", fn);
};
d.on("mouseup", fn);
});
return this;
},
getViewSize : function(){
var doc = document,
d = this.dom,
isDoc = (d == doc || d == doc.body);
if (isDoc) {
var extdom = Ext.lib.Dom;
return {
width : extdom.getViewWidth(),
height : extdom.getViewHeight()
};
} else {
return {
width : d.clientWidth,
height : d.clientHeight
};
}
},
getStyleSize : function(){
var me = this,
w, h,
doc = document,
d = this.dom,
isDoc = (d == doc || d == doc.body),
s = d.style;
if (isDoc) {
var extdom = Ext.lib.Dom;
return {
width : extdom.getViewWidth(),
height : extdom.getViewHeight()
};
}
if(s.width && s.width != 'auto'){
w = parseFloat(s.width);
if(me.isBorderBox()){
w -= me.getFrameWidth('lr');
}
}
if(s.height && s.height != 'auto'){
h = parseFloat(s.height);
if(me.isBorderBox()){
h -= me.getFrameWidth('tb');
}
}
return {width: w || me.getWidth(true), height: h || me.getHeight(true)};
},
getSize : function(contentSize){
return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
},
repaint : function(){
var dom = this.dom;
this.addClass("x-repaint");
setTimeout(function(){
Ext.fly(dom).removeClass("x-repaint");
}, 1);
return this;
},
unselectable : function(){
this.dom.unselectable = "on";
return this.swallowEvent("selectstart", true).
applyStyles("-moz-user-select:none;-khtml-user-select:none;").
addClass("x-unselectable");
},
getMargins : function(side){
var me = this,
key,
hash = {t:"top", l:"left", r:"right", b: "bottom"},
o = {};
if (!side) {
for (key in me.margins){
o[hash[key]] = parseFloat(me.getStyle(me.margins[key])) || 0;
}
return o;
} else {
return me.addStyles.call(me, side, me.margins);
}
}
};
}());
Ext.Element.addMethods({
setBox : function(box, adjust, animate){
var me = this,
w = box.width,
h = box.height;
if((adjust && !me.autoBoxAdjust) && !me.isBorderBox()){
w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
}
me.setBounds(box.x, box.y, w, h, me.animTest.call(me, arguments, animate, 2));
return me;
},
getBox : function(contentBox, local) {
var me = this,
xy,
left,
top,
getBorderWidth = me.getBorderWidth,
getPadding = me.getPadding,
l,
r,
t,
b;
if(!local){
xy = me.getXY();
}else{
left = parseInt(me.getStyle("left"), 10) || 0;
top = parseInt(me.getStyle("top"), 10) || 0;
xy = [left, top];
}
var el = me.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
if(!contentBox){
bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
}else{
l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");
r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");
t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");
b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");
bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};
}
bx.right = bx.x + bx.width;
bx.bottom = bx.y + bx.height;
return bx;
},
move : function(direction, distance, animate){
var me = this,
xy = me.getXY(),
x = xy[0],
y = xy[1],
left = [x - distance, y],
right = [x + distance, y],
top = [x, y - distance],
bottom = [x, y + distance],
hash = {
l : left,
left : left,
r : right,
right : right,
t : top,
top : top,
up : top,
b : bottom,
bottom : bottom,
down : bottom
};
direction = direction.toLowerCase();
me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));
},
setLeftTop : function(left, top){
var me = this,
style = me.dom.style;
style.left = me.addUnits(left);
style.top = me.addUnits(top);
return me;
},
getRegion : function(){
return Ext.lib.Dom.getRegion(this.dom);
},
setBounds : function(x, y, width, height, animate){
var me = this;
if (!animate || !me.anim) {
me.setSize(width, height);
me.setLocation(x, y);
} else {
me.anim({points: {to: [x, y]},
width: {to: me.adjustWidth(width)},
height: {to: me.adjustHeight(height)}},
me.preanim(arguments, 4),
'motion');
}
return me;
},
setRegion : function(region, animate) {
return this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.animTest.call(this, arguments, animate, 1));
}
});
Ext.Element.addMethods({
scrollTo : function(side, value, animate) {
var top = /top/i.test(side),
me = this,
dom = me.dom,
prop;
if (!animate || !me.anim) {
prop = 'scroll' + (top ? 'Top' : 'Left');
dom[prop] = value;
}
else {
prop = 'scroll' + (top ? 'Left' : 'Top');
me.anim({scroll: {to: top ? [dom[prop], value] : [value, dom[prop]]}}, me.preanim(arguments, 2), 'scroll');
}
return me;
},
scrollIntoView : function(container, hscroll) {
var c = Ext.getDom(container) || Ext.getBody().dom,
el = this.dom,
o = this.getOffsetsTo(c),
l = o[0] + c.scrollLeft,
t = o[1] + c.scrollTop,
b = t + el.offsetHeight,
r = l + el.offsetWidth,
ch = c.clientHeight,
ct = parseInt(c.scrollTop, 10),
cl = parseInt(c.scrollLeft, 10),
cb = ct + ch,
cr = cl + c.clientWidth;
if (el.offsetHeight > ch || t < ct) {
c.scrollTop = t;
}
else if (b > cb) {
c.scrollTop = b-ch;
}
c.scrollTop = c.scrollTop;
if (hscroll !== false) {
if (el.offsetWidth > c.clientWidth || l < cl) {
c.scrollLeft = l;
}
else if (r > cr) {
c.scrollLeft = r - c.clientWidth;
}
c.scrollLeft = c.scrollLeft;
}
return this;
},
scrollChildIntoView : function(child, hscroll) {
Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
},
scroll : function(direction, distance, animate) {
if (!this.isScrollable()) {
return false;
}
var el = this.dom,
l = el.scrollLeft, t = el.scrollTop,
w = el.scrollWidth, h = el.scrollHeight,
cw = el.clientWidth, ch = el.clientHeight,
scrolled = false, v,
hash = {
l: Math.min(l + distance, w-cw),
r: v = Math.max(l - distance, 0),
t: Math.max(t - distance, 0),
b: Math.min(t + distance, h-ch)
};
hash.d = hash.b;
hash.u = hash.t;
direction = direction.substr(0, 1);
if ((v = hash[direction]) > -1) {
scrolled = true;
this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.preanim(arguments, 2));
}
return scrolled;
}
});
Ext.Element.addMethods(
function() {
var VISIBILITY = "visibility",
DISPLAY = "display",
HIDDEN = "hidden",
NONE = "none",
XMASKED = "x-masked",
XMASKEDRELATIVE = "x-masked-relative",
data = Ext.Element.data;
return {
isVisible : function(deep) {
var vis = !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE),
p = this.dom.parentNode;
if (deep !== true || !vis) {
return vis;
}
while (p && !(/^body/i.test(p.tagName))) {
if (!Ext.fly(p, '_isVisible').isVisible()) {
return false;
}
p = p.parentNode;
}
return true;
},
isDisplayed : function() {
return !this.isStyle(DISPLAY, NONE);
},
enableDisplayMode : function(display) {
this.setVisibilityMode(Ext.Element.DISPLAY);
if (!Ext.isEmpty(display)) {
data(this.dom, 'originalDisplay', display);
}
return this;
},
mask : function(msg, msgCls) {
var me = this,
dom = me.dom,
dh = Ext.DomHelper,
EXTELMASKMSG = "ext-el-mask-msg",
el,
mask;
if (!/^body/i.test(dom.tagName) && me.getStyle('position') == 'static') {
me.addClass(XMASKEDRELATIVE);
}
if (el = data(dom, 'maskMsg')) {
el.remove();
}
if (el = data(dom, 'mask')) {
el.remove();
}
mask = dh.append(dom, {cls : "ext-el-mask"}, true);
data(dom, 'mask', mask);
me.addClass(XMASKED);
mask.setDisplayed(true);
if (typeof msg == 'string') {
var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
data(dom, 'maskMsg', mm);
mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
mm.dom.firstChild.innerHTML = msg;
mm.setDisplayed(true);
mm.center(me);
}
if (Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto') {
mask.setSize(undefined, me.getHeight());
}
return mask;
},
unmask : function() {
var me = this,
dom = me.dom,
mask = data(dom, 'mask'),
maskMsg = data(dom, 'maskMsg');
if (mask) {
if (maskMsg) {
maskMsg.remove();
data(dom, 'maskMsg', undefined);
}
mask.remove();
data(dom, 'mask', undefined);
me.removeClass([XMASKED, XMASKEDRELATIVE]);
}
},
isMasked : function() {
var m = data(this.dom, 'mask');
return m && m.isVisible();
},
createShim : function() {
var el = document.createElement('iframe'),
shim;
el.frameBorder = '0';
el.className = 'ext-shim';
el.src = Ext.SSL_SECURE_URL;
shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
shim.autoBoxAdjust = false;
return shim;
}
};
}()
);
Ext.Element.addMethods({
addKeyListener : function(key, fn, scope){
var config;
if(typeof key != 'object' || Ext.isArray(key)){
config = {
key: key,
fn: fn,
scope: scope
};
}else{
config = {
key : key.key,
shift : key.shift,
ctrl : key.ctrl,
alt : key.alt,
fn: fn,
scope: scope
};
}
return new Ext.KeyMap(this, config);
},
addKeyMap : function(config){
return new Ext.KeyMap(this, config);
}
});
Ext.CompositeElementLite.importElementMethods();
Ext.apply(Ext.CompositeElementLite.prototype, {
addElements : function(els, root){
if(!els){
return this;
}
if(typeof els == "string"){
els = Ext.Element.selectorFunction(els, root);
}
var yels = this.elements;
Ext.each(els, function(e) {
yels.push(Ext.get(e));
});
return this;
},
first : function(){
return this.item(0);
},
last : function(){
return this.item(this.getCount()-1);
},
contains : function(el){
return this.indexOf(el) != -1;
},
removeElement : function(keys, removeDom){
var me = this,
els = this.elements,
el;
Ext.each(keys, function(val){
if ((el = (els[val] || els[val = me.indexOf(val)]))) {
if(removeDom){
if(el.dom){
el.remove();
}else{
Ext.removeNode(el);
}
}
els.splice(val, 1);
}
});
return this;
}
});
Ext.CompositeElement = Ext.extend(Ext.CompositeElementLite, {
constructor : function(els, root){
this.elements = [];
this.add(els, root);
},
getElement : function(el){
return el;
},
transformElement : function(el){
return Ext.get(el);
}
});
Ext.Element.select = function(selector, unique, root){
var els;
if(typeof selector == "string"){
els = Ext.Element.selectorFunction(selector, root);
}else if(selector.length !== undefined){
els = selector;
}else{
throw "Invalid selector";
}
return (unique === true) ? new Ext.CompositeElement(els) : new Ext.CompositeElementLite(els);
};
Ext.select = Ext.Element.select;
Ext.UpdateManager = Ext.Updater = Ext.extend(Ext.util.Observable,
function() {
var BEFOREUPDATE = "beforeupdate",
UPDATE = "update",
FAILURE = "failure";
function processSuccess(response){
var me = this;
me.transaction = null;
if (response.argument.form && response.argument.reset) {
try {
response.argument.form.reset();
} catch(e){}
}
if (me.loadScripts) {
me.renderer.render(me.el, response, me,
updateComplete.createDelegate(me, [response]));
} else {
me.renderer.render(me.el, response, me);
updateComplete.call(me, response);
}
}
function updateComplete(response, type, success){
this.fireEvent(type || UPDATE, this.el, response);
if(Ext.isFunction(response.argument.callback)){
response.argument.callback.call(response.argument.scope, this.el, Ext.isEmpty(success) ? true : false, response, response.argument.options);
}
}
function processFailure(response){
updateComplete.call(this, response, FAILURE, !!(this.transaction = null));
}
return {
constructor: function(el, forceNew){
var me = this;
el = Ext.get(el);
if(!forceNew && el.updateManager){
return el.updateManager;
}
me.el = el;
me.defaultUrl = null;
me.addEvents(
BEFOREUPDATE,
UPDATE,
FAILURE
);
Ext.apply(me, Ext.Updater.defaults);
me.transaction = null;
me.refreshDelegate = me.refresh.createDelegate(me);
me.updateDelegate = me.update.createDelegate(me);
me.formUpdateDelegate = (me.formUpdate || function(){}).createDelegate(me);
me.renderer = me.renderer || me.getDefaultRenderer();
Ext.Updater.superclass.constructor.call(me);
},
setRenderer : function(renderer){
this.renderer = renderer;
},
getRenderer : function(){
return this.renderer;
},
getDefaultRenderer: function() {
return new Ext.Updater.BasicRenderer();
},
setDefaultUrl : function(defaultUrl){
this.defaultUrl = defaultUrl;
},
getEl : function(){
return this.el;
},
update : function(url, params, callback, discardUrl){
var me = this,
cfg,
callerScope;
if(me.fireEvent(BEFOREUPDATE, me.el, url, params) !== false){
if(Ext.isObject(url)){
cfg = url;
url = cfg.url;
params = params || cfg.params;
callback = callback || cfg.callback;
discardUrl = discardUrl || cfg.discardUrl;
callerScope = cfg.scope;
if(!Ext.isEmpty(cfg.nocache)){me.disableCaching = cfg.nocache;};
if(!Ext.isEmpty(cfg.text)){me.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
if(!Ext.isEmpty(cfg.scripts)){me.loadScripts = cfg.scripts;};
if(!Ext.isEmpty(cfg.timeout)){me.timeout = cfg.timeout;};
}
me.showLoading();
if(!discardUrl){
me.defaultUrl = url;
}
if(Ext.isFunction(url)){
url = url.call(me);
}
var o = Ext.apply({}, {
url : url,
params: (Ext.isFunction(params) && callerScope) ? params.createDelegate(callerScope) : params,
success: processSuccess,
failure: processFailure,
scope: me,
callback: undefined,
timeout: (me.timeout*1000),
disableCaching: me.disableCaching,
argument: {
"options": cfg,
"url": url,
"form": null,
"callback": callback,
"scope": callerScope || window,
"params": params
}
}, cfg);
me.transaction = Ext.Ajax.request(o);
}
},
formUpdate : function(form, url, reset, callback){
var me = this;
if(me.fireEvent(BEFOREUPDATE, me.el, form, url) !== false){
if(Ext.isFunction(url)){
url = url.call(me);
}
form = Ext.getDom(form);
me.transaction = Ext.Ajax.request({
form: form,
url:url,
success: processSuccess,
failure: processFailure,
scope: me,
timeout: (me.timeout*1000),
argument: {
"url": url,
"form": form,
"callback": callback,
"reset": reset
}
});
me.showLoading.defer(1, me);
}
},
startAutoRefresh : function(interval, url, params, callback, refreshNow){
var me = this;
if(refreshNow){
me.update(url || me.defaultUrl, params, callback, true);
}
if(me.autoRefreshProcId){
clearInterval(me.autoRefreshProcId);
}
me.autoRefreshProcId = setInterval(me.update.createDelegate(me, [url || me.defaultUrl, params, callback, true]), interval * 1000);
},
stopAutoRefresh : function(){
if(this.autoRefreshProcId){
clearInterval(this.autoRefreshProcId);
delete this.autoRefreshProcId;
}
},
isAutoRefreshing : function(){
return !!this.autoRefreshProcId;
},
showLoading : function(){
if(this.showLoadIndicator){
this.el.dom.innerHTML = this.indicatorText;
}
},
abort : function(){
if(this.transaction){
Ext.Ajax.abort(this.transaction);
}
},
isUpdating : function(){
return this.transaction ? Ext.Ajax.isLoading(this.transaction) : false;
},
refresh : function(callback){
if(this.defaultUrl){
this.update(this.defaultUrl, null, callback, true);
}
}
};
}());
Ext.Updater.defaults = {
timeout : 30,
disableCaching : false,
showLoadIndicator : true,
indicatorText : '<div class="loading-indicator">Loading...</div>',
loadScripts : false,
sslBlankUrl : Ext.SSL_SECURE_URL
};
Ext.Updater.updateElement = function(el, url, params, options){
var um = Ext.get(el).getUpdater();
Ext.apply(um, options);
um.update(url, params, options ? options.callback : null);
};
Ext.Updater.BasicRenderer = function(){};
Ext.Updater.BasicRenderer.prototype = {
render : function(el, response, updateManager, callback){
el.update(response.responseText, updateManager.loadScripts, callback);
}
};
(function() {
Date.useStrict = false;
function xf(format) {
var args = Array.prototype.slice.call(arguments, 1);
return format.replace(/\{(\d+)\}/g, function(m, i) {
return args[i];
});
}
Date.formatCodeToRegex = function(character, currentGroup) {
var p = Date.parseCodes[character];
if (p) {
p = typeof p == 'function'? p() : p;
Date.parseCodes[character] = p;
}
return p ? Ext.applyIf({
c: p.c ? xf(p.c, currentGroup || "{0}") : p.c
}, p) : {
g:0,
c:null,
s:Ext.escapeRe(character)
};
};
var $f = Date.formatCodeToRegex;
Ext.apply(Date, {
parseFunctions: {
"M$": function(input, strict) {
var re = new RegExp('\\/Date\\(([-+])?(\\d+)(?:[+-]\\d{4})?\\)\\/');
var r = (input || '').match(re);
return r? new Date(((r[1] || '') + r[2]) * 1) : null;
}
},
parseRegexes: [],
formatFunctions: {
"M$": function() {
return '\\/Date(' + this.getTime() + ')\\/';
}
},
y2kYear : 50,
MILLI : "ms",
SECOND : "s",
MINUTE : "mi",
HOUR : "h",
DAY : "d",
MONTH : "mo",
YEAR : "y",
defaults: {},
dayNames : [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
monthNames : [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
monthNumbers : {
Jan:0,
Feb:1,
Mar:2,
Apr:3,
May:4,
Jun:5,
Jul:6,
Aug:7,
Sep:8,
Oct:9,
Nov:10,
Dec:11
},
getShortMonthName : function(month) {
return Date.monthNames[month].substring(0, 3);
},
getShortDayName : function(day) {
return Date.dayNames[day].substring(0, 3);
},
getMonthNumber : function(name) {
return Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
},
formatContainsHourInfo : (function(){
var stripEscapeRe = /(\\.)/g,
hourInfoRe = /([gGhHisucUOPZ]|M\$)/;
return function(format){
return hourInfoRe.test(format.replace(stripEscapeRe, ''));
};
})(),
formatCodes : {
d: "String.leftPad(this.getDate(), 2, '0')",
D: "Date.getShortDayName(this.getDay())",
j: "this.getDate()",
l: "Date.dayNames[this.getDay()]",
N: "(this.getDay() ? this.getDay() : 7)",
S: "this.getSuffix()",
w: "this.getDay()",
z: "this.getDayOfYear()",
W: "String.leftPad(this.getWeekOfYear(), 2, '0')",
F: "Date.monthNames[this.getMonth()]",
m: "String.leftPad(this.getMonth() + 1, 2, '0')",
M: "Date.getShortMonthName(this.getMonth())",
n: "(this.getMonth() + 1)",
t: "this.getDaysInMonth()",
L: "(this.isLeapYear() ? 1 : 0)",
o: "(this.getFullYear() + (this.getWeekOfYear() == 1 && this.getMonth() > 0 ? +1 : (this.getWeekOfYear() >= 52 && this.getMonth() < 11 ? -1 : 0)))",
Y: "String.leftPad(this.getFullYear(), 4, '0')",
y: "('' + this.getFullYear()).substring(2, 4)",
a: "(this.getHours() < 12 ? 'am' : 'pm')",
A: "(this.getHours() < 12 ? 'AM' : 'PM')",
g: "((this.getHours() % 12) ? this.getHours() % 12 : 12)",
G: "this.getHours()",
h: "String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')",
H: "String.leftPad(this.getHours(), 2, '0')",
i: "String.leftPad(this.getMinutes(), 2, '0')",
s: "String.leftPad(this.getSeconds(), 2, '0')",
u: "String.leftPad(this.getMilliseconds(), 3, '0')",
O: "this.getGMTOffset()",
P: "this.getGMTOffset(true)",
T: "this.getTimezone()",
Z: "(this.getTimezoneOffset() * -60)",
c: function() {
for (var c = "Y-m-dTH:i:sP", code = [], i = 0, l = c.length; i < l; ++i) {
var e = c.charAt(i);
code.push(e == "T" ? "'T'" : Date.getFormatCode(e));
}
return code.join(" + ");
},
U: "Math.round(this.getTime() / 1000)"
},
isValid : function(y, m, d, h, i, s, ms) {
h = h || 0;
i = i || 0;
s = s || 0;
ms = ms || 0;
var dt = new Date(y < 100 ? 100 : y, m - 1, d, h, i, s, ms).add(Date.YEAR, y < 100 ? y - 100 : 0);
return y == dt.getFullYear() &&
m == dt.getMonth() + 1 &&
d == dt.getDate() &&
h == dt.getHours() &&
i == dt.getMinutes() &&
s == dt.getSeconds() &&
ms == dt.getMilliseconds();
},
parseDate : function(input, format, strict) {
var p = Date.parseFunctions;
if (p[format] == null) {
Date.createParser(format);
}
return p[format](input, Ext.isDefined(strict) ? strict : Date.useStrict);
},
getFormatCode : function(character) {
var f = Date.formatCodes[character];
if (f) {
f = typeof f == 'function'? f() : f;
Date.formatCodes[character] = f;
}
return f || ("'" + String.escape(character) + "'");
},
createFormat : function(format) {
var code = [],
special = false,
ch = '';
for (var i = 0; i < format.length; ++i) {
ch = format.charAt(i);
if (!special && ch == "\\") {
special = true;
} else if (special) {
special = false;
code.push("'" + String.escape(ch) + "'");
} else {
code.push(Date.getFormatCode(ch));
}
}
Date.formatFunctions[format] = new Function("return " + code.join('+'));
},
createParser : function() {
var code = [
"var dt, y, m, d, h, i, s, ms, o, z, zz, u, v,",
"def = Date.defaults,",
"results = String(input).match(Date.parseRegexes[{0}]);",
"if(results){",
"{1}",
"if(u != null){",
"v = new Date(u * 1000);",
"}else{",
"dt = (new Date()).clearTime();",
"y = Ext.num(y, Ext.num(def.y, dt.getFullYear()));",
"m = Ext.num(m, Ext.num(def.m - 1, dt.getMonth()));",
"d = Ext.num(d, Ext.num(def.d, dt.getDate()));",
"h = Ext.num(h, Ext.num(def.h, dt.getHours()));",
"i = Ext.num(i, Ext.num(def.i, dt.getMinutes()));",
"s = Ext.num(s, Ext.num(def.s, dt.getSeconds()));",
"ms = Ext.num(ms, Ext.num(def.ms, dt.getMilliseconds()));",
"if(z >= 0 && y >= 0){",
"v = new Date(y < 100 ? 100 : y, 0, 1, h, i, s, ms).add(Date.YEAR, y < 100 ? y - 100 : 0);",
"v = !strict? v : (strict === true && (z <= 364 || (v.isLeapYear() && z <= 365))? v.add(Date.DAY, z) : null);",
"}else if(strict === true && !Date.isValid(y, m + 1, d, h, i, s, ms)){",
"v = null;",
"}else{",
"v = new Date(y < 100 ? 100 : y, m, d, h, i, s, ms).add(Date.YEAR, y < 100 ? y - 100 : 0);",
"}",
"}",
"}",
"if(v){",
"if(zz != null){",
"v = v.add(Date.SECOND, -v.getTimezoneOffset() * 60 - zz);",
"}else if(o){",
"v = v.add(Date.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));",
"}",
"}",
"return v;"
].join('\n');
return function(format) {
var regexNum = Date.parseRegexes.length,
currentGroup = 1,
calc = [],
regex = [],
special = false,
ch = "",
i = 0,
obj,
last;
for (; i < format.length; ++i) {
ch = format.charAt(i);
if (!special && ch == "\\") {
special = true;
} else if (special) {
special = false;
regex.push(String.escape(ch));
} else {
obj = $f(ch, currentGroup);
currentGroup += obj.g;
regex.push(obj.s);
if (obj.g && obj.c) {
if (obj.calcLast) {
last = obj.c;
} else {
calc.push(obj.c);
}
}
}
}
if (last) {
calc.push(last);
}
Date.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", 'i');
Date.parseFunctions[format] = new Function("input", "strict", xf(code, regexNum, calc.join('')));
};
}(),
parseCodes : {
d: {
g:1,
c:"d = parseInt(results[{0}], 10);\n",
s:"(\\d{2})"
},
j: {
g:1,
c:"d = parseInt(results[{0}], 10);\n",
s:"(\\d{1,2})"
},
D: function() {
for (var a = [], i = 0; i < 7; a.push(Date.getShortDayName(i)), ++i);
return {
g:0,
c:null,
s:"(?:" + a.join("|") +")"
};
},
l: function() {
return {
g:0,
c:null,
s:"(?:" + Date.dayNames.join("|") + ")"
};
},
N: {
g:0,
c:null,
s:"[1-7]"
},
S: {
g:0,
c:null,
s:"(?:st|nd|rd|th)"
},
w: {
g:0,
c:null,
s:"[0-6]"
},
z: {
g:1,
c:"z = parseInt(results[{0}], 10);\n",
s:"(\\d{1,3})"
},
W: {
g:0,
c:null,
s:"(?:\\d{2})"
},
F: function() {
return {
g:1,
c:"m = parseInt(Date.getMonthNumber(results[{0}]), 10);\n",
s:"(" + Date.monthNames.join("|") + ")"
};
},
M: function() {
for (var a = [], i = 0; i < 12; a.push(Date.getShortMonthName(i)), ++i);
return Ext.applyIf({
s:"(" + a.join("|") + ")"
}, $f("F"));
},
m: {
g:1,
c:"m = parseInt(results[{0}], 10) - 1;\n",
s:"(\\d{2})"
},
n: {
g:1,
c:"m = parseInt(results[{0}], 10) - 1;\n",
s:"(\\d{1,2})"
},
t: {
g:0,
c:null,
s:"(?:\\d{2})"
},
L: {
g:0,
c:null,
s:"(?:1|0)"
},
o: function() {
return $f("Y");
},
Y: {
g:1,
c:"y = parseInt(results[{0}], 10);\n",
s:"(\\d{4})"
},
y: {
g:1,
c:"var ty = parseInt(results[{0}], 10);\n"
+ "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
s:"(\\d{1,2})"
},
a: function(){
return $f("A");
},
A: {
calcLast: true,
g:1,
c:"if (/(am)/i.test(results[{0}])) {\n"
+ "if (!h || h == 12) { h = 0; }\n"
+ "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
s:"(AM|PM|am|pm)"
},
g: function() {
return $f("G");
},
G: {
g:1,
c:"h = parseInt(results[{0}], 10);\n",
s:"(\\d{1,2})"
},
h: function() {
return $f("H");
},
H: {
g:1,
c:"h = parseInt(results[{0}], 10);\n",
s:"(\\d{2})"
},
i: {
g:1,
c:"i = parseInt(results[{0}], 10);\n",
s:"(\\d{2})"
},
s: {
g:1,
c:"s = parseInt(results[{0}], 10);\n",
s:"(\\d{2})"
},
u: {
g:1,
c:"ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n",
s:"(\\d+)"
},
O: {
g:1,
c:[
"o = results[{0}];",
"var sn = o.substring(0,1),",
"hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60),",
"mn = o.substring(3,5) % 60;",
"o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n"
].join("\n"),
s: "([+\-]\\d{4})"
},
P: {
g:1,
c:[
"o = results[{0}];",
"var sn = o.substring(0,1),",
"hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60),",
"mn = o.substring(4,6) % 60;",
"o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n"
].join("\n"),
s: "([+\-]\\d{2}:\\d{2})"
},
T: {
g:0,
c:null,
s:"[A-Z]{1,4}"
},
Z: {
g:1,
c:"zz = results[{0}] * 1;\n"
+ "zz = (-43200 <= zz && zz <= 50400)? zz : null;\n",
s:"([+\-]?\\d{1,5})"
},
c: function() {
var calc = [],
arr = [
$f("Y", 1),
$f("m", 2),
$f("d", 3),
$f("h", 4),
$f("i", 5),
$f("s", 6),
{c:"ms = results[7] || '0'; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n"},
{c:[
"if(results[8]) {",
"if(results[8] == 'Z'){",
"zz = 0;",
"}else if (results[8].indexOf(':') > -1){",
$f("P", 8).c,
"}else{",
$f("O", 8).c,
"}",
"}"
].join('\n')}
];
for (var i = 0, l = arr.length; i < l; ++i) {
calc.push(arr[i].c);
}
return {
g:1,
c:calc.join(""),
s:[
arr[0].s,
"(?:", "-", arr[1].s,
"(?:", "-", arr[2].s,
"(?:",
"(?:T| )?",
arr[3].s, ":", arr[4].s,
"(?::", arr[5].s, ")?",
"(?:(?:\\.|,)(\\d+))?",
"(Z|(?:[-+]\\d{2}(?::)?\\d{2}))?",
")?",
")?",
")?"
].join("")
};
},
U: {
g:1,
c:"u = parseInt(results[{0}], 10);\n",
s:"(-?\\d+)"
}
}
});
}());
Ext.apply(Date.prototype, {
dateFormat : function(format) {
if (Date.formatFunctions[format] == null) {
Date.createFormat(format);
}
return Date.formatFunctions[format].call(this);
},
getTimezone : function() {
return this.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
},
getGMTOffset : function(colon) {
return (this.getTimezoneOffset() > 0 ? "-" : "+")
+ String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset()) / 60), 2, "0")
+ (colon ? ":" : "")
+ String.leftPad(Math.abs(this.getTimezoneOffset() % 60), 2, "0");
},
getDayOfYear: function() {
var num = 0,
d = this.clone(),
m = this.getMonth(),
i;
for (i = 0, d.setDate(1), d.setMonth(0); i < m; d.setMonth(++i)) {
num += d.getDaysInMonth();
}
return num + this.getDate() - 1;
},
getWeekOfYear : function() {
var ms1d = 864e5,
ms7d = 7 * ms1d;
return function() {
var DC3 = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / ms1d,
AWN = Math.floor(DC3 / 7),
Wyr = new Date(AWN * ms7d).getUTCFullYear();
return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
};
}(),
isLeapYear : function() {
var year = this.getFullYear();
return !!((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
},
getFirstDayOfMonth : function() {
var day = (this.getDay() - (this.getDate() - 1)) % 7;
return (day < 0) ? (day + 7) : day;
},
getLastDayOfMonth : function() {
return this.getLastDateOfMonth().getDay();
},
getFirstDateOfMonth : function() {
return new Date(this.getFullYear(), this.getMonth(), 1);
},
getLastDateOfMonth : function() {
return new Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth());
},
getDaysInMonth: function() {
var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
return function() {
var m = this.getMonth();
return m == 1 && this.isLeapYear() ? 29 : daysInMonth[m];
};
}(),
getSuffix : function() {
switch (this.getDate()) {
case 1:
case 21:
case 31:
return "st";
case 2:
case 22:
return "nd";
case 3:
case 23:
return "rd";
default:
return "th";
}
},
clone : function() {
return new Date(this.getTime());
},
isDST : function() {
return new Date(this.getFullYear(), 0, 1).getTimezoneOffset() != this.getTimezoneOffset();
},
clearTime : function(clone) {
if (clone) {
return this.clone().clearTime();
}
var d = this.getDate();
this.setHours(0);
this.setMinutes(0);
this.setSeconds(0);
this.setMilliseconds(0);
if (this.getDate() != d) {
for (var hr = 1, c = this.add(Date.HOUR, hr); c.getDate() != d; hr++, c = this.add(Date.HOUR, hr));
this.setDate(d);
this.setHours(c.getHours());
}
return this;
},
add : function(interval, value) {
var d = this.clone();
if (!interval || value === 0) return d;
switch(interval.toLowerCase()) {
case Date.MILLI:
d.setMilliseconds(this.getMilliseconds() + value);
break;
case Date.SECOND:
d.setSeconds(this.getSeconds() + value);
break;
case Date.MINUTE:
d.setMinutes(this.getMinutes() + value);
break;
case Date.HOUR:
d.setHours(this.getHours() + value);
break;
case Date.DAY:
d.setDate(this.getDate() + value);
break;
case Date.MONTH:
var day = this.getDate();
if (day > 28) {
day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
}
d.setDate(day);
d.setMonth(this.getMonth() + value);
break;
case Date.YEAR:
d.setFullYear(this.getFullYear() + value);
break;
}
return d;
},
between : function(start, end) {
var t = this.getTime();
return start.getTime() <= t && t <= end.getTime();
}
});
Date.prototype.format = Date.prototype.dateFormat;
if (Ext.isSafari && (navigator.userAgent.match(/WebKit\/(\d+)/)[1] || NaN) < 420) {
Ext.apply(Date.prototype, {
_xMonth : Date.prototype.setMonth,
_xDate : Date.prototype.setDate,
setMonth : function(num) {
if (num <= -1) {
var n = Math.ceil(-num),
back_year = Math.ceil(n / 12),
month = (n % 12) ? 12 - n % 12 : 0;
this.setFullYear(this.getFullYear() - back_year);
return this._xMonth(month);
} else {
return this._xMonth(num);
}
},
setDate : function(d) {
return this.setTime(this.getTime() - (this.getDate() - d) * 864e5);
}
});
}
Ext.util.MixedCollection = function(allowFunctions, keyFn){
this.items = [];
this.map = {};
this.keys = [];
this.length = 0;
this.addEvents(
'clear',
'add',
'replace',
'remove',
'sort'
);
this.allowFunctions = allowFunctions === true;
if(keyFn){
this.getKey = keyFn;
}
Ext.util.MixedCollection.superclass.constructor.call(this);
};
Ext.extend(Ext.util.MixedCollection, Ext.util.Observable, {
allowFunctions : false,
add : function(key, o){
if(arguments.length == 1){
o = arguments[0];
key = this.getKey(o);
}
if(typeof key != 'undefined' && key !== null){
var old = this.map[key];
if(typeof old != 'undefined'){
return this.replace(key, o);
}
this.map[key] = o;
}
this.length++;
this.items.push(o);
this.keys.push(key);
this.fireEvent('add', this.length-1, o, key);
return o;
},
getKey : function(o){
return o.id;
},
replace : function(key, o){
if(arguments.length == 1){
o = arguments[0];
key = this.getKey(o);
}
var old = this.map[key];
if(typeof key == 'undefined' || key === null || typeof old == 'undefined'){
return this.add(key, o);
}
var index = this.indexOfKey(key);
this.items[index] = o;
this.map[key] = o;
this.fireEvent('replace', key, old, o);
return o;
},
addAll : function(objs){
if(arguments.length > 1 || Ext.isArray(objs)){
var args = arguments.length > 1 ? arguments : objs;
for(var i = 0, len = args.length; i < len; i++){
this.add(args[i]);
}
}else{
for(var key in objs){
if(this.allowFunctions || typeof objs[key] != 'function'){
this.add(key, objs[key]);
}
}
}
},
each : function(fn, scope){
var items = [].concat(this.items);
for(var i = 0, len = items.length; i < len; i++){
if(fn.call(scope || items[i], items[i], i, len) === false){
break;
}
}
},
eachKey : function(fn, scope){
for(var i = 0, len = this.keys.length; i < len; i++){
fn.call(scope || window, this.keys[i], this.items[i], i, len);
}
},
find : function(fn, scope){
for(var i = 0, len = this.items.length; i < len; i++){
if(fn.call(scope || window, this.items[i], this.keys[i])){
return this.items[i];
}
}
return null;
},
insert : function(index, key, o){
if(arguments.length == 2){
o = arguments[1];
key = this.getKey(o);
}
if(this.containsKey(key)){
this.suspendEvents();
this.removeKey(key);
this.resumeEvents();
}
if(index >= this.length){
return this.add(key, o);
}
this.length++;
this.items.splice(index, 0, o);
if(typeof key != 'undefined' && key !== null){
this.map[key] = o;
}
this.keys.splice(index, 0, key);
this.fireEvent('add', index, o, key);
return o;
},
remove : function(o){
return this.removeAt(this.indexOf(o));
},
removeAt : function(index){
if(index < this.length && index >= 0){
this.length--;
var o = this.items[index];
this.items.splice(index, 1);
var key = this.keys[index];
if(typeof key != 'undefined'){
delete this.map[key];
}
this.keys.splice(index, 1);
this.fireEvent('remove', o, key);
return o;
}
return false;
},
removeKey : function(key){
return this.removeAt(this.indexOfKey(key));
},
getCount : function(){
return this.length;
},
indexOf : function(o){
return this.items.indexOf(o);
},
indexOfKey : function(key){
return this.keys.indexOf(key);
},
item : function(key){
var mk = this.map[key],
item = mk !== undefined ? mk : (typeof key == 'number') ? this.items[key] : undefined;
return typeof item != 'function' || this.allowFunctions ? item : null;
},
itemAt : function(index){
return this.items[index];
},
key : function(key){
return this.map[key];
},
contains : function(o){
return this.indexOf(o) != -1;
},
containsKey : function(key){
return typeof this.map[key] != 'undefined';
},
clear : function(){
this.length = 0;
this.items = [];
this.keys = [];
this.map = {};
this.fireEvent('clear');
},
first : function(){
return this.items[0];
},
last : function(){
return this.items[this.length-1];
},
_sort : function(property, dir, fn){
var i, len,
dsc = String(dir).toUpperCase() == 'DESC' ? -1 : 1,
c = [],
keys = this.keys,
items = this.items;
fn = fn || function(a, b) {
return a - b;
};
for(i = 0, len = items.length; i < len; i++){
c[c.length] = {
key : keys[i],
value: items[i],
index: i
};
}
c.sort(function(a, b){
var v = fn(a[property], b[property]) * dsc;
if(v === 0){
v = (a.index < b.index ? -1 : 1);
}
return v;
});
for(i = 0, len = c.length; i < len; i++){
items[i] = c[i].value;
keys[i] = c[i].key;
}
this.fireEvent('sort', this);
},
sort : function(dir, fn){
this._sort('value', dir, fn);
},
reorder: function(mapping) {
this.suspendEvents();
var items = this.items,
index = 0,
length = items.length,
order = [],
remaining = [],
oldIndex;
for (oldIndex in mapping) {
order[mapping[oldIndex]] = items[oldIndex];
}
for (index = 0; index < length; index++) {
if (mapping[index] == undefined) {
remaining.push(items[index]);
}
}
for (index = 0; index < length; index++) {
if (order[index] == undefined) {
order[index] = remaining.shift();
}
}
this.clear();
this.addAll(order);
this.resumeEvents();
this.fireEvent('sort', this);
},
keySort : function(dir, fn){
this._sort('key', dir, fn || function(a, b){
var v1 = String(a).toUpperCase(), v2 = String(b).toUpperCase();
return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
});
},
getRange : function(start, end){
var items = this.items;
if(items.length < 1){
return [];
}
start = start || 0;
end = Math.min(typeof end == 'undefined' ? this.length-1 : end, this.length-1);
var i, r = [];
if(start <= end){
for(i = start; i <= end; i++) {
r[r.length] = items[i];
}
}else{
for(i = start; i >= end; i--) {
r[r.length] = items[i];
}
}
return r;
},
filter : function(property, value, anyMatch, caseSensitive){
if(Ext.isEmpty(value, false)){
return this.clone();
}
value = this.createValueMatcher(value, anyMatch, caseSensitive);
return this.filterBy(function(o){
return o && value.test(o[property]);
});
},
filterBy : function(fn, scope){
var r = new Ext.util.MixedCollection();
r.getKey = this.getKey;
var k = this.keys, it = this.items;
for(var i = 0, len = it.length; i < len; i++){
if(fn.call(scope||this, it[i], k[i])){
r.add(k[i], it[i]);
}
}
return r;
},
findIndex : function(property, value, start, anyMatch, caseSensitive){
if(Ext.isEmpty(value, false)){
return -1;
}
value = this.createValueMatcher(value, anyMatch, caseSensitive);
return this.findIndexBy(function(o){
return o && value.test(o[property]);
}, null, start);
},
findIndexBy : function(fn, scope, start){
var k = this.keys, it = this.items;
for(var i = (start||0), len = it.length; i < len; i++){
if(fn.call(scope||this, it[i], k[i])){
return i;
}
}
return -1;
},
createValueMatcher : function(value, anyMatch, caseSensitive, exactMatch) {
if (!value.exec) {
var er = Ext.escapeRe;
value = String(value);
if (anyMatch === true) {
value = er(value);
} else {
value = '^' + er(value);
if (exactMatch === true) {
value += '$';
}
}
value = new RegExp(value, caseSensitive ? '' : 'i');
}
return value;
},
clone : function(){
var r = new Ext.util.MixedCollection();
var k = this.keys, it = this.items;
for(var i = 0, len = it.length; i < len; i++){
r.add(k[i], it[i]);
}
r.getKey = this.getKey;
return r;
}
});
Ext.util.MixedCollection.prototype.get = Ext.util.MixedCollection.prototype.item;
Ext.AbstractManager = Ext.extend(Object, {
typeName: 'type',
constructor: function(config) {
Ext.apply(this, config || {});
this.all = new Ext.util.MixedCollection();
this.types = {};
},
get : function(id){
return this.all.get(id);
},
register: function(item) {
this.all.add(item);
},
unregister: function(item) {
this.all.remove(item);
},
registerType : function(type, cls){
this.types[type] = cls;
cls[this.typeName] = type;
},
isRegistered : function(type){
return this.types[type] !== undefined;
},
create: function(config, defaultType) {
var type = config[this.typeName] || config.type || defaultType,
Constructor = this.types[type];
if (Constructor == undefined) {
throw new Error(String.format("The '{0}' type has not been registered with this manager", type));
}
return new Constructor(config);
},
onAvailable : function(id, fn, scope){
var all = this.all;
all.on("add", function(index, o){
if (o.id == id) {
fn.call(scope || o, o);
all.un("add", fn, scope);
}
});
}
});
Ext.util.Format = function() {
var trimRe = /^\s+|\s+$/g,
stripTagsRE = /<\/?[^>]+>/gi,
stripScriptsRe = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,
nl2brRe = /\r?\n/g;
return {
ellipsis : function(value, len, word) {
if (value && value.length > len) {
if (word) {
var vs = value.substr(0, len - 2),
index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));
if (index == -1 || index < (len - 15)) {
return value.substr(0, len - 3) + "...";
} else {
return vs.substr(0, index) + "...";
}
} else {
return value.substr(0, len - 3) + "...";
}
}
return value;
},
undef : function(value) {
return value !== undefined ? value : "";
},
defaultValue : function(value, defaultValue) {
return value !== undefined && value !== '' ? value : defaultValue;
},
htmlEncode : function(value) {
return !value ? value : String(value).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
},
htmlDecode : function(value) {
return !value ? value : String(value).replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
},
trim : function(value) {
return String(value).replace(trimRe, "");
},
substr : function(value, start, length) {
return String(value).substr(start, length);
},
lowercase : function(value) {
return String(value).toLowerCase();
},
uppercase : function(value) {
return String(value).toUpperCase();
},
capitalize : function(value) {
return !value ? value : value.charAt(0).toUpperCase() + value.substr(1).toLowerCase();
},
call : function(value, fn) {
if (arguments.length > 2) {
var args = Array.prototype.slice.call(arguments, 2);
args.unshift(value);
return eval(fn).apply(window, args);
} else {
return eval(fn).call(window, value);
}
},
usMoney : function(v) {
v = (Math.round((v-0)*100))/100;
v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
v = String(v);
var ps = v.split('.'),
whole = ps[0],
sub = ps[1] ? '.'+ ps[1] : '.00',
r = /(\d+)(\d{3})/;
while (r.test(whole)) {
whole = whole.replace(r, '$1' + ',' + '$2');
}
v = whole + sub;
if (v.charAt(0) == '-') {
return '-$' + v.substr(1);
}
return "$" + v;
},
date : function(v, format) {
if (!v) {
return "";
}
if (!Ext.isDate(v)) {
v = new Date(Date.parse(v));
}
return v.dateFormat(format || "m/d/Y");
},
dateRenderer : function(format) {
return function(v) {
return Ext.util.Format.date(v, format);
};
},
stripTags : function(v) {
return !v ? v : String(v).replace(stripTagsRE, "");
},
stripScripts : function(v) {
return !v ? v : String(v).replace(stripScriptsRe, "");
},
fileSize : function(size) {
if (size < 1024) {
return size + " bytes";
} else if (size < 1048576) {
return (Math.round(((size*10) / 1024))/10) + " KB";
} else {
return (Math.round(((size*10) / 1048576))/10) + " MB";
}
},
math : function(){
var fns = {};
return function(v, a){
if (!fns[a]) {
fns[a] = new Function('v', 'return v ' + a + ';');
}
return fns[a](v);
};
}(),
round : function(value, precision) {
var result = Number(value);
if (typeof precision == 'number') {
precision = Math.pow(10, precision);
result = Math.round(value * precision) / precision;
}
return result;
},
number: function(v, format) {
if (!format) {
return v;
}
v = Ext.num(v, NaN);
if (isNaN(v)) {
return '';
}
var comma = ',',
dec = '.',
i18n = false,
neg = v < 0;
v = Math.abs(v);
if (format.substr(format.length - 2) == '/i') {
format = format.substr(0, format.length - 2);
i18n = true;
comma = '.';
dec = ',';
}
var hasComma = format.indexOf(comma) != -1,
psplit = (i18n ? format.replace(/[^\d\,]/g, '') : format.replace(/[^\d\.]/g, '')).split(dec);
if (1 < psplit.length) {
v = v.toFixed(psplit[1].length);
} else if(2 < psplit.length) {
throw ('NumberFormatException: invalid format, formats should have no more than 1 period: ' + format);
} else {
v = v.toFixed(0);
}
var fnum = v.toString();
psplit = fnum.split('.');
if (hasComma) {
var cnum = psplit[0],
parr = [],
j = cnum.length,
m = Math.floor(j / 3),
n = cnum.length % 3 || 3,
i;
for (i = 0; i < j; i += n) {
if (i != 0) {
n = 3;
}
parr[parr.length] = cnum.substr(i, n);
m -= 1;
}
fnum = parr.join(comma);
if (psplit[1]) {
fnum += dec + psplit[1];
}
} else {
if (psplit[1]) {
fnum = psplit[0] + dec + psplit[1];
}
}
return (neg ? '-' : '') + format.replace(/[\d,?\.?]+/, fnum);
},
numberRenderer : function(format) {
return function(v) {
return Ext.util.Format.number(v, format);
};
},
plural : function(v, s, p) {
return v +' ' + (v == 1 ? s : (p ? p : s+'s'));
},
nl2br : function(v) {
return Ext.isEmpty(v) ? '' : v.replace(nl2brRe, '<br/>');
}
};
}();
Ext.XTemplate = function(){
Ext.XTemplate.superclass.constructor.apply(this, arguments);
var me = this,
s = me.html,
re = /<tpl\b[^>]*>((?:(?=([^<]+))\2|<(?!tpl\b[^>]*>))*?)<\/tpl>/,
nameRe = /^<tpl\b[^>]*?for="(.*?)"/,
ifRe = /^<tpl\b[^>]*?if="(.*?)"/,
execRe = /^<tpl\b[^>]*?exec="(.*?)"/,
m,
id = 0,
tpls = [],
VALUES = 'values',
PARENT = 'parent',
XINDEX = 'xindex',
XCOUNT = 'xcount',
RETURN = 'return ',
WITHVALUES = 'with(values){ ';
s = ['<tpl>', s, '</tpl>'].join('');
while((m = s.match(re))){
var m2 = m[0].match(nameRe),
m3 = m[0].match(ifRe),
m4 = m[0].match(execRe),
exp = null,
fn = null,
exec = null,
name = m2 && m2[1] ? m2[1] : '';
if (m3) {
exp = m3 && m3[1] ? m3[1] : null;
if(exp){
fn = new Function(VALUES, PARENT, XINDEX, XCOUNT, WITHVALUES + RETURN +(Ext.util.Format.htmlDecode(exp))+'; }');
}
}
if (m4) {
exp = m4 && m4[1] ? m4[1] : null;
if(exp){
exec = new Function(VALUES, PARENT, XINDEX, XCOUNT, WITHVALUES +(Ext.util.Format.htmlDecode(exp))+'; }');
}
}
if(name){
switch(name){
case '.': name = new Function(VALUES, PARENT, WITHVALUES + RETURN + VALUES + '; }'); break;
case '..': name = new Function(VALUES, PARENT, WITHVALUES + RETURN + PARENT + '; }'); break;
default: name = new Function(VALUES, PARENT, WITHVALUES + RETURN + name + '; }');
}
}
tpls.push({
id: id,
target: name,
exec: exec,
test: fn,
body: m[1]||''
});
s = s.replace(m[0], '{xtpl'+ id + '}');
++id;
}
for(var i = tpls.length-1; i >= 0; --i){
me.compileTpl(tpls[i]);
}
me.master = tpls[tpls.length-1];
me.tpls = tpls;
};
Ext.extend(Ext.XTemplate, Ext.Template, {
re : /\{([\w\-\.\#]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?(\s?[\+\-\*\\]\s?[\d\.\+\-\*\\\(\)]+)?\}/g,
codeRe : /\{\[((?:\\\]|.|\n)*?)\]\}/g,
applySubTemplate : function(id, values, parent, xindex, xcount){
var me = this,
len,
t = me.tpls[id],
vs,
buf = [];
if ((t.test && !t.test.call(me, values, parent, xindex, xcount)) ||
(t.exec && t.exec.call(me, values, parent, xindex, xcount))) {
return '';
}
vs = t.target ? t.target.call(me, values, parent) : values;
len = vs.length;
parent = t.target ? values : parent;
if(t.target && Ext.isArray(vs)){
for(var i = 0, len = vs.length; i < len; i++){
buf[buf.length] = t.compiled.call(me, vs[i], parent, i+1, len);
}
return buf.join('');
}
return t.compiled.call(me, vs, parent, xindex, xcount);
},
compileTpl : function(tpl){
var fm = Ext.util.Format,
useF = this.disableFormats !== true,
sep = Ext.isGecko ? "+" : ",",
body;
function fn(m, name, format, args, math){
if(name.substr(0, 4) == 'xtpl'){
return "'"+ sep +'this.applySubTemplate('+name.substr(4)+', values, parent, xindex, xcount)'+sep+"'";
}
var v;
if(name === '.'){
v = 'values';
}else if(name === '#'){
v = 'xindex';
}else if(name.indexOf('.') != -1){
v = name;
}else{
v = "values['" + name + "']";
}
if(math){
v = '(' + v + math + ')';
}
if (format && useF) {
args = args ? ',' + args : "";
if(format.substr(0, 5) != "this."){
format = "fm." + format + '(';
}else{
format = 'this.call("'+ format.substr(5) + '", ';
args = ", values";
}
} else {
args= ''; format = "("+v+" === undefined ? '' : ";
}
return "'"+ sep + format + v + args + ")"+sep+"'";
}
function codeFn(m, code){
return "'" + sep + '(' + code.replace(/\\'/g, "'") + ')' + sep + "'";
}
if(Ext.isGecko){
body = "tpl.compiled = function(values, parent, xindex, xcount){ return '" +
tpl.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn).replace(this.codeRe, codeFn) +
"';};";
}else{
body = ["tpl.compiled = function(values, parent, xindex, xcount){ return ['"];
body.push(tpl.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn).replace(this.codeRe, codeFn));
body.push("'].join('');};");
body = body.join('');
}
eval(body);
return this;
},
applyTemplate : function(values){
return this.master.compiled.call(this, values, {}, 1, 1);
},
compile : function(){return this;}
});
Ext.XTemplate.prototype.apply = Ext.XTemplate.prototype.applyTemplate;
Ext.XTemplate.from = function(el){
el = Ext.getDom(el);
return new Ext.XTemplate(el.value || el.innerHTML);
};
Ext.util.CSS = function(){
var rules = null;
var doc = document;
var camelRe = /(-[a-z])/gi;
var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
return {
createStyleSheet : function(cssText, id){
var ss;
var head = doc.getElementsByTagName("head")[0];
var rules = doc.createElement("style");
rules.setAttribute("type", "text/css");
if(id){
rules.setAttribute("id", id);
}
if(Ext.isIE){
head.appendChild(rules);
ss = rules.styleSheet;
ss.cssText = cssText;
}else{
try{
rules.appendChild(doc.createTextNode(cssText));
}catch(e){
rules.cssText = cssText;
}
head.appendChild(rules);
ss = rules.styleSheet ? rules.styleSheet : (rules.sheet || doc.styleSheets[doc.styleSheets.length-1]);
}
this.cacheStyleSheet(ss);
return ss;
},
removeStyleSheet : function(id){
var existing = doc.getElementById(id);
if(existing){
existing.parentNode.removeChild(existing);
}
},
swapStyleSheet : function(id, url){
this.removeStyleSheet(id);
var ss = doc.createElement("link");
ss.setAttribute("rel", "stylesheet");
ss.setAttribute("type", "text/css");
ss.setAttribute("id", id);
ss.setAttribute("href", url);
doc.getElementsByTagName("head")[0].appendChild(ss);
},
refreshCache : function(){
return this.getRules(true);
},
cacheStyleSheet : function(ss){
if(!rules){
rules = {};
}
try{
var ssRules = ss.cssRules || ss.rules;
for(var j = ssRules.length-1; j >= 0; --j){
rules[ssRules[j].selectorText.toLowerCase()] = ssRules[j];
}
}catch(e){}
},
getRules : function(refreshCache){
if(rules === null || refreshCache){
rules = {};
var ds = doc.styleSheets;
for(var i =0, len = ds.length; i < len; i++){
try{
this.cacheStyleSheet(ds[i]);
}catch(e){}
}
}
return rules;
},
getRule : function(selector, refreshCache){
var rs = this.getRules(refreshCache);
if(!Ext.isArray(selector)){
return rs[selector.toLowerCase()];
}
for(var i = 0; i < selector.length; i++){
if(rs[selector[i]]){
return rs[selector[i].toLowerCase()];
}
}
return null;
},
updateRule : function(selector, property, value){
if(!Ext.isArray(selector)){
var rule = this.getRule(selector);
if(rule){
rule.style[property.replace(camelRe, camelFn)] = value;
return true;
}
}else{
for(var i = 0; i < selector.length; i++){
if(this.updateRule(selector[i], property, value)){
return true;
}
}
}
return false;
}
};
}();
Ext.util.ClickRepeater = Ext.extend(Ext.util.Observable, {
constructor : function(el, config){
this.el = Ext.get(el);
this.el.unselectable();
Ext.apply(this, config);
this.addEvents(
"mousedown",
"click",
"mouseup"
);
if(!this.disabled){
this.disabled = true;
this.enable();
}
if(this.handler){
this.on("click", this.handler, this.scope || this);
}
Ext.util.ClickRepeater.superclass.constructor.call(this);
},
interval : 20,
delay: 250,
preventDefault : true,
stopDefault : false,
timer : 0,
enable: function(){
if(this.disabled){
this.el.on('mousedown', this.handleMouseDown, this);
if (Ext.isIE){
this.el.on('dblclick', this.handleDblClick, this);
}
if(this.preventDefault || this.stopDefault){
this.el.on('click', this.eventOptions, this);
}
}
this.disabled = false;
},
disable: function( force){
if(force || !this.disabled){
clearTimeout(this.timer);
if(this.pressClass){
this.el.removeClass(this.pressClass);
}
Ext.getDoc().un('mouseup', this.handleMouseUp, this);
this.el.removeAllListeners();
}
this.disabled = true;
},
setDisabled: function(disabled){
this[disabled ? 'disable' : 'enable']();
},
eventOptions: function(e){
if(this.preventDefault){
e.preventDefault();
}
if(this.stopDefault){
e.stopEvent();
}
},
destroy : function() {
this.disable(true);
Ext.destroy(this.el);
this.purgeListeners();
},
handleDblClick : function(e){
clearTimeout(this.timer);
this.el.blur();
this.fireEvent("mousedown", this, e);
this.fireEvent("click", this, e);
},
handleMouseDown : function(e){
clearTimeout(this.timer);
this.el.blur();
if(this.pressClass){
this.el.addClass(this.pressClass);
}
this.mousedownTime = new Date();
Ext.getDoc().on("mouseup", this.handleMouseUp, this);
this.el.on("mouseout", this.handleMouseOut, this);
this.fireEvent("mousedown", this, e);
this.fireEvent("click", this, e);
if (this.accelerate) {
this.delay = 400;
}
this.timer = this.click.defer(this.delay || this.interval, this, [e]);
},
click : function(e){
this.fireEvent("click", this, e);
this.timer = this.click.defer(this.accelerate ?
this.easeOutExpo(this.mousedownTime.getElapsed(),
400,
-390,
12000) :
this.interval, this, [e]);
},
easeOutExpo : function (t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
handleMouseOut : function(){
clearTimeout(this.timer);
if(this.pressClass){
this.el.removeClass(this.pressClass);
}
this.el.on("mouseover", this.handleMouseReturn, this);
},
handleMouseReturn : function(){
this.el.un("mouseover", this.handleMouseReturn, this);
if(this.pressClass){
this.el.addClass(this.pressClass);
}
this.click();
},
handleMouseUp : function(e){
clearTimeout(this.timer);
this.el.un("mouseover", this.handleMouseReturn, this);
this.el.un("mouseout", this.handleMouseOut, this);
Ext.getDoc().un("mouseup", this.handleMouseUp, this);
this.el.removeClass(this.pressClass);
this.fireEvent("mouseup", this, e);
}
});
Ext.KeyNav = function(el, config){
this.el = Ext.get(el);
Ext.apply(this, config);
if(!this.disabled){
this.disabled = true;
this.enable();
}
};
Ext.KeyNav.prototype = {
disabled : false,
defaultEventAction: "stopEvent",
forceKeyDown : false,
relay : function(e){
var k = e.getKey(),
h = this.keyToHandler[k];
if(h && this[h]){
if(this.doRelay(e, this[h], h) !== true){
e[this.defaultEventAction]();
}
}
},
doRelay : function(e, h, hname){
return h.call(this.scope || this, e, hname);
},
enter : false,
left : false,
right : false,
up : false,
down : false,
tab : false,
esc : false,
pageUp : false,
pageDown : false,
del : false,
home : false,
end : false,
space : false,
keyToHandler : {
37 : "left",
39 : "right",
38 : "up",
40 : "down",
33 : "pageUp",
34 : "pageDown",
46 : "del",
36 : "home",
35 : "end",
13 : "enter",
27 : "esc",
9 : "tab",
32 : "space"
},
stopKeyUp: function(e) {
var k = e.getKey();
if (k >= 37 && k <= 40) {
e.stopEvent();
}
},
destroy: function(){
this.disable();
},
enable: function() {
if (this.disabled) {
if (Ext.isSafari2) {
this.el.on('keyup', this.stopKeyUp, this);
}
this.el.on(this.isKeydown()? 'keydown' : 'keypress', this.relay, this);
this.disabled = false;
}
},
disable: function() {
if (!this.disabled) {
if (Ext.isSafari2) {
this.el.un('keyup', this.stopKeyUp, this);
}
this.el.un(this.isKeydown()? 'keydown' : 'keypress', this.relay, this);
this.disabled = true;
}
},
setDisabled : function(disabled){
this[disabled ? "disable" : "enable"]();
},
isKeydown: function(){
return this.forceKeyDown || Ext.EventManager.useKeydown;
}
};
Ext.KeyMap = function(el, config, eventName){
this.el = Ext.get(el);
this.eventName = eventName || "keydown";
this.bindings = [];
if(config){
this.addBinding(config);
}
this.enable();
};
Ext.KeyMap.prototype = {
stopEvent : false,
addBinding : function(config){
if(Ext.isArray(config)){
Ext.each(config, function(c){
this.addBinding(c);
}, this);
return;
}
var keyCode = config.key,
fn = config.fn || config.handler,
scope = config.scope;
if (config.stopEvent) {
this.stopEvent = config.stopEvent;
}
if(typeof keyCode == "string"){
var ks = [];
var keyString = keyCode.toUpperCase();
for(var j = 0, len = keyString.length; j < len; j++){
ks.push(keyString.charCodeAt(j));
}
keyCode = ks;
}
var keyArray = Ext.isArray(keyCode);
var handler = function(e){
if(this.checkModifiers(config, e)){
var k = e.getKey();
if(keyArray){
for(var i = 0, len = keyCode.length; i < len; i++){
if(keyCode[i] == k){
if(this.stopEvent){
e.stopEvent();
}
fn.call(scope || window, k, e);
return;
}
}
}else{
if(k == keyCode){
if(this.stopEvent){
e.stopEvent();
}
fn.call(scope || window, k, e);
}
}
}
};
this.bindings.push(handler);
},
checkModifiers: function(config, e){
var val, key, keys = ['shift', 'ctrl', 'alt'];
for (var i = 0, len = keys.length; i < len; ++i){
key = keys[i];
val = config[key];
if(!(val === undefined || (val === e[key + 'Key']))){
return false;
}
}
return true;
},
on : function(key, fn, scope){
var keyCode, shift, ctrl, alt;
if(typeof key == "object" && !Ext.isArray(key)){
keyCode = key.key;
shift = key.shift;
ctrl = key.ctrl;
alt = key.alt;
}else{
keyCode = key;
}
this.addBinding({
key: keyCode,
shift: shift,
ctrl: ctrl,
alt: alt,
fn: fn,
scope: scope
});
},
handleKeyDown : function(e){
if(this.enabled){
var b = this.bindings;
for(var i = 0, len = b.length; i < len; i++){
b[i].call(this, e);
}
}
},
isEnabled : function(){
return this.enabled;
},
enable: function(){
if(!this.enabled){
this.el.on(this.eventName, this.handleKeyDown, this);
this.enabled = true;
}
},
disable: function(){
if(this.enabled){
this.el.removeListener(this.eventName, this.handleKeyDown, this);
this.enabled = false;
}
},
setDisabled : function(disabled){
this[disabled ? "disable" : "enable"]();
}
};
Ext.util.TextMetrics = function(){
var shared;
return {
measure : function(el, text, fixedWidth){
if(!shared){
shared = Ext.util.TextMetrics.Instance(el, fixedWidth);
}
shared.bind(el);
shared.setFixedWidth(fixedWidth || 'auto');
return shared.getSize(text);
},
createInstance : function(el, fixedWidth){
return Ext.util.TextMetrics.Instance(el, fixedWidth);
}
};
}();
Ext.util.TextMetrics.Instance = function(bindTo, fixedWidth){
var ml = new Ext.Element(document.createElement('div'));
document.body.appendChild(ml.dom);
ml.position('absolute');
ml.setLeftTop(-1000, -1000);
ml.hide();
if(fixedWidth){
ml.setWidth(fixedWidth);
}
var instance = {
getSize : function(text){
ml.update(text);
var s = ml.getSize();
ml.update('');
return s;
},
bind : function(el){
ml.setStyle(
Ext.fly(el).getStyles('font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing')
);
},
setFixedWidth : function(width){
ml.setWidth(width);
},
getWidth : function(text){
ml.dom.style.width = 'auto';
return this.getSize(text).width;
},
getHeight : function(text){
return this.getSize(text).height;
}
};
instance.bind(bindTo);
return instance;
};
Ext.Element.addMethods({
getTextWidth : function(text, min, max){
return (Ext.util.TextMetrics.measure(this.dom, Ext.value(text, this.dom.innerHTML, true)).width).constrain(min || 0, max || 1000000);
}
});
Ext.util.Cookies = {
set : function(name, value){
var argv = arguments;
var argc = arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : '/';
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secure" : "");
},
get : function(name){
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
var j = 0;
while(i < clen){
j = i + alen;
if(document.cookie.substring(i, j) == arg){
return Ext.util.Cookies.getCookieVal(j);
}
i = document.cookie.indexOf(" ", i) + 1;
if(i === 0){
break;
}
}
return null;
},
clear : function(name){
if(Ext.util.Cookies.get(name)){
document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
},
getCookieVal : function(offset){
var endstr = document.cookie.indexOf(";", offset);
if(endstr == -1){
endstr = document.cookie.length;
}
return unescape(document.cookie.substring(offset, endstr));
}
};
Ext.handleError = function(e) {
throw e;
};
Ext.Error = function(message) {
this.message = (this.lang[message]) ? this.lang[message] : message;
};
Ext.Error.prototype = new Error();
Ext.apply(Ext.Error.prototype, {
lang: {},
name: 'Ext.Error',
getName : function() {
return this.name;
},
getMessage : function() {
return this.message;
},
toJson : function() {
return Ext.encode(this);
}
});
Ext.ComponentMgr = function(){
var all = new Ext.util.MixedCollection();
var types = {};
var ptypes = {};
return {
register : function(c){
all.add(c);
},
unregister : function(c){
all.remove(c);
},
get : function(id){
return all.get(id);
},
onAvailable : function(id, fn, scope){
all.on("add", function(index, o){
if(o.id == id){
fn.call(scope || o, o);
all.un("add", fn, scope);
}
});
},
all : all,
types : types,
ptypes: ptypes,
isRegistered : function(xtype){
return types[xtype] !== undefined;
},
isPluginRegistered : function(ptype){
return ptypes[ptype] !== undefined;
},
registerType : function(xtype, cls){
types[xtype] = cls;
cls.xtype = xtype;
},
create : function(config, defaultType){
return config.render ? config : new types[config.xtype || defaultType](config);
},
registerPlugin : function(ptype, cls){
ptypes[ptype] = cls;
cls.ptype = ptype;
},
createPlugin : function(config, defaultType){
var PluginCls = ptypes[config.ptype || defaultType];
if (PluginCls.init) {
return PluginCls;
} else {
return new PluginCls(config);
}
}
};
}();
Ext.reg = Ext.ComponentMgr.registerType;
Ext.preg = Ext.ComponentMgr.registerPlugin;
Ext.create = Ext.ComponentMgr.create;
Ext.Component = function(config){
config = config || {};
if(config.initialConfig){
if(config.isAction){
this.baseAction = config;
}
config = config.initialConfig;
}else if(config.tagName || config.dom || Ext.isString(config)){
config = {applyTo: config, id: config.id || config};
}
this.initialConfig = config;
Ext.apply(this, config);
this.addEvents(
'added',
'disable',
'enable',
'beforeshow',
'show',
'beforehide',
'hide',
'removed',
'beforerender',
'render',
'afterrender',
'beforedestroy',
'destroy',
'beforestaterestore',
'staterestore',
'beforestatesave',
'statesave'
);
this.getId();
Ext.ComponentMgr.register(this);
Ext.Component.superclass.constructor.call(this);
if(this.baseAction){
this.baseAction.addComponent(this);
}
this.initComponent();
if(this.plugins){
if(Ext.isArray(this.plugins)){
for(var i = 0, len = this.plugins.length; i < len; i++){
this.plugins[i] = this.initPlugin(this.plugins[i]);
}
}else{
this.plugins = this.initPlugin(this.plugins);
}
}
if(this.stateful !== false){
this.initState();
}
if(this.applyTo){
this.applyToMarkup(this.applyTo);
delete this.applyTo;
}else if(this.renderTo){
this.render(this.renderTo);
delete this.renderTo;
}
};
Ext.Component.AUTO_ID = 1000;
Ext.extend(Ext.Component, Ext.util.Observable, {
disabled : false,
hidden : false,
autoEl : 'div',
disabledClass : 'x-item-disabled',
allowDomMove : true,
autoShow : false,
hideMode : 'display',
hideParent : false,
rendered : false,
tplWriteMode : 'overwrite',
bubbleEvents: [],
ctype : 'Ext.Component',
actionMode : 'el',
getActionEl : function(){
return this[this.actionMode];
},
initPlugin : function(p){
if(p.ptype && !Ext.isFunction(p.init)){
p = Ext.ComponentMgr.createPlugin(p);
}else if(Ext.isString(p)){
p = Ext.ComponentMgr.createPlugin({
ptype: p
});
}
p.init(this);
return p;
},
initComponent : function(){
if(this.listeners){
this.on(this.listeners);
delete this.listeners;
}
this.enableBubble(this.bubbleEvents);
},
render : function(container, position){
if(!this.rendered && this.fireEvent('beforerender', this) !== false){
if(!container && this.el){
this.el = Ext.get(this.el);
container = this.el.dom.parentNode;
this.allowDomMove = false;
}
this.container = Ext.get(container);
if(this.ctCls){
this.container.addClass(this.ctCls);
}
this.rendered = true;
if(position !== undefined){
if(Ext.isNumber(position)){
position = this.container.dom.childNodes[position];
}else{
position = Ext.getDom(position);
}
}
this.onRender(this.container, position || null);
if(this.autoShow){
this.el.removeClass(['x-hidden','x-hide-' + this.hideMode]);
}
if(this.cls){
this.el.addClass(this.cls);
delete this.cls;
}
if(this.style){
this.el.applyStyles(this.style);
delete this.style;
}
if(this.overCls){
this.el.addClassOnOver(this.overCls);
}
this.fireEvent('render', this);
var contentTarget = this.getContentTarget();
if (this.html){
contentTarget.update(Ext.DomHelper.markup(this.html));
delete this.html;
}
if (this.contentEl){
var ce = Ext.getDom(this.contentEl);
Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
contentTarget.appendChild(ce);
}
if (this.tpl) {
if (!this.tpl.compile) {
this.tpl = new Ext.XTemplate(this.tpl);
}
if (this.data) {
this.tpl[this.tplWriteMode](contentTarget, this.data);
delete this.data;
}
}
this.afterRender(this.container);
if(this.hidden){
this.doHide();
}
if(this.disabled){
this.disable(true);
}
if(this.stateful !== false){
this.initStateEvents();
}
this.fireEvent('afterrender', this);
}
return this;
},
update: function(htmlOrData, loadScripts, cb) {
var contentTarget = this.getContentTarget();
if (this.tpl && typeof htmlOrData !== "string") {
this.tpl[this.tplWriteMode](contentTarget, htmlOrData || {});
} else {
var html = Ext.isObject(htmlOrData) ? Ext.DomHelper.markup(htmlOrData) : htmlOrData;
contentTarget.update(html, loadScripts, cb);
}
},
onAdded : function(container, pos) {
this.ownerCt = container;
this.initRef();
this.fireEvent('added', this, container, pos);
},
onRemoved : function() {
this.removeRef();
this.fireEvent('removed', this, this.ownerCt);
delete this.ownerCt;
},
initRef : function() {
if(this.ref && !this.refOwner){
var levels = this.ref.split('/'),
last = levels.length,
i = 0,
t = this;
while(t && i < last){
t = t.ownerCt;
++i;
}
if(t){
t[this.refName = levels[--i]] = this;
this.refOwner = t;
}
}
},
removeRef : function() {
if (this.refOwner && this.refName) {
delete this.refOwner[this.refName];
delete this.refOwner;
}
},
initState : function(){
if(Ext.state.Manager){
var id = this.getStateId();
if(id){
var state = Ext.state.Manager.get(id);
if(state){
if(this.fireEvent('beforestaterestore', this, state) !== false){
this.applyState(Ext.apply({}, state));
this.fireEvent('staterestore', this, state);
}
}
}
}
},
getStateId : function(){
return this.stateId || ((/^(ext-comp-|ext-gen)/).test(String(this.id)) ? null : this.id);
},
initStateEvents : function(){
if(this.stateEvents){
for(var i = 0, e; e = this.stateEvents[i]; i++){
this.on(e, this.saveState, this, {delay:100});
}
}
},
applyState : function(state){
if(state){
Ext.apply(this, state);
}
},
getState : function(){
return null;
},
saveState : function(){
if(Ext.state.Manager && this.stateful !== false){
var id = this.getStateId();
if(id){
var state = this.getState();
if(this.fireEvent('beforestatesave', this, state) !== false){
Ext.state.Manager.set(id, state);
this.fireEvent('statesave', this, state);
}
}
}
},
applyToMarkup : function(el){
this.allowDomMove = false;
this.el = Ext.get(el);
this.render(this.el.dom.parentNode);
},
addClass : function(cls){
if(this.el){
this.el.addClass(cls);
}else{
this.cls = this.cls ? this.cls + ' ' + cls : cls;
}
return this;
},
removeClass : function(cls){
if(this.el){
this.el.removeClass(cls);
}else if(this.cls){
this.cls = this.cls.split(' ').remove(cls).join(' ');
}
return this;
},
onRender : function(ct, position){
if(!this.el && this.autoEl){
if(Ext.isString(this.autoEl)){
this.el = document.createElement(this.autoEl);
}else{
var div = document.createElement('div');
Ext.DomHelper.overwrite(div, this.autoEl);
this.el = div.firstChild;
}
if (!this.el.id) {
this.el.id = this.getId();
}
}
if(this.el){
this.el = Ext.get(this.el);
if(this.allowDomMove !== false){
ct.dom.insertBefore(this.el.dom, position);
if (div) {
Ext.removeNode(div);
div = null;
}
}
}
},
getAutoCreate : function(){
var cfg = Ext.isObject(this.autoCreate) ?
this.autoCreate : Ext.apply({}, this.defaultAutoCreate);
if(this.id && !cfg.id){
cfg.id = this.id;
}
return cfg;
},
afterRender : Ext.emptyFn,
destroy : function(){
if(!this.isDestroyed){
if(this.fireEvent('beforedestroy', this) !== false){
this.destroying = true;
this.beforeDestroy();
if(this.ownerCt && this.ownerCt.remove){
this.ownerCt.remove(this, false);
}
if(this.rendered){
this.el.remove();
if(this.actionMode == 'container' || this.removeMode == 'container'){
this.container.remove();
}
}
if(this.focusTask && this.focusTask.cancel){
this.focusTask.cancel();
}
this.onDestroy();
Ext.ComponentMgr.unregister(this);
this.fireEvent('destroy', this);
this.purgeListeners();
this.destroying = false;
this.isDestroyed = true;
}
}
},
deleteMembers : function(){
var args = arguments;
for(var i = 0, len = args.length; i < len; ++i){
delete this[args[i]];
}
},
beforeDestroy : Ext.emptyFn,
onDestroy : Ext.emptyFn,
getEl : function(){
return this.el;
},
getContentTarget : function(){
return this.el;
},
getId : function(){
return this.id || (this.id = 'ext-comp-' + (++Ext.Component.AUTO_ID));
},
getItemId : function(){
return this.itemId || this.getId();
},
focus : function(selectText, delay){
if(delay){
this.focusTask = new Ext.util.DelayedTask(this.focus, this, [selectText, false]);
this.focusTask.delay(Ext.isNumber(delay) ? delay : 10);
return this;
}
if(this.rendered && !this.isDestroyed){
this.el.focus();
if(selectText === true){
this.el.dom.select();
}
}
return this;
},
blur : function(){
if(this.rendered){
this.el.blur();
}
return this;
},
disable : function( silent){
if(this.rendered){
this.onDisable();
}
this.disabled = true;
if(silent !== true){
this.fireEvent('disable', this);
}
return this;
},
onDisable : function(){
this.getActionEl().addClass(this.disabledClass);
this.el.dom.disabled = true;
},
enable : function(){
if(this.rendered){
this.onEnable();
}
this.disabled = false;
this.fireEvent('enable', this);
return this;
},
onEnable : function(){
this.getActionEl().removeClass(this.disabledClass);
this.el.dom.disabled = false;
},
setDisabled : function(disabled){
return this[disabled ? 'disable' : 'enable']();
},
show : function(){
if(this.fireEvent('beforeshow', this) !== false){
this.hidden = false;
if(this.autoRender){
this.render(Ext.isBoolean(this.autoRender) ? Ext.getBody() : this.autoRender);
}
if(this.rendered){
this.onShow();
}
this.fireEvent('show', this);
}
return this;
},
onShow : function(){
this.getVisibilityEl().removeClass('x-hide-' + this.hideMode);
},
hide : function(){
if(this.fireEvent('beforehide', this) !== false){
this.doHide();
this.fireEvent('hide', this);
}
return this;
},
doHide: function(){
this.hidden = true;
if(this.rendered){
this.onHide();
}
},
onHide : function(){
this.getVisibilityEl().addClass('x-hide-' + this.hideMode);
},
getVisibilityEl : function(){
return this.hideParent ? this.container : this.getActionEl();
},
setVisible : function(visible){
return this[visible ? 'show' : 'hide']();
},
isVisible : function(){
return this.rendered && this.getVisibilityEl().isVisible();
},
cloneConfig : function(overrides){
overrides = overrides || {};
var id = overrides.id || Ext.id();
var cfg = Ext.applyIf(overrides, this.initialConfig);
cfg.id = id;
return new this.constructor(cfg);
},
getXType : function(){
return this.constructor.xtype;
},
isXType : function(xtype, shallow){
if (Ext.isFunction(xtype)){
xtype = xtype.xtype;
}else if (Ext.isObject(xtype)){
xtype = xtype.constructor.xtype;
}
return !shallow ? ('/' + this.getXTypes() + '/').indexOf('/' + xtype + '/') != -1 : this.constructor.xtype == xtype;
},
getXTypes : function(){
var tc = this.constructor;
if(!tc.xtypes){
var c = [], sc = this;
while(sc && sc.constructor.xtype){
c.unshift(sc.constructor.xtype);
sc = sc.constructor.superclass;
}
tc.xtypeChain = c;
tc.xtypes = c.join('/');
}
return tc.xtypes;
},
findParentBy : function(fn) {
for (var p = this.ownerCt; (p != null) && !fn(p, this); p = p.ownerCt);
return p || null;
},
findParentByType : function(xtype, shallow){
return this.findParentBy(function(c){
return c.isXType(xtype, shallow);
});
},
bubble : function(fn, scope, args){
var p = this;
while(p){
if(fn.apply(scope || p, args || [p]) === false){
break;
}
p = p.ownerCt;
}
return this;
},
getPositionEl : function(){
return this.positionEl || this.el;
},
purgeListeners : function(){
Ext.Component.superclass.purgeListeners.call(this);
if(this.mons){
this.on('beforedestroy', this.clearMons, this, {single: true});
}
},
clearMons : function(){
Ext.each(this.mons, function(m){
m.item.un(m.ename, m.fn, m.scope);
}, this);
this.mons = [];
},
createMons: function(){
if(!this.mons){
this.mons = [];
this.on('beforedestroy', this.clearMons, this, {single: true});
}
},
mon : function(item, ename, fn, scope, opt){
this.createMons();
if(Ext.isObject(ename)){
var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
var o = ename;
for(var e in o){
if(propRe.test(e)){
continue;
}
if(Ext.isFunction(o[e])){
this.mons.push({
item: item, ename: e, fn: o[e], scope: o.scope
});
item.on(e, o[e], o.scope, o);
}else{
this.mons.push({
item: item, ename: e, fn: o[e], scope: o.scope
});
item.on(e, o[e]);
}
}
return;
}
this.mons.push({
item: item, ename: ename, fn: fn, scope: scope
});
item.on(ename, fn, scope, opt);
},
mun : function(item, ename, fn, scope){
var found, mon;
this.createMons();
for(var i = 0, len = this.mons.length; i < len; ++i){
mon = this.mons[i];
if(item === mon.item && ename == mon.ename && fn === mon.fn && scope === mon.scope){
this.mons.splice(i, 1);
item.un(ename, fn, scope);
found = true;
break;
}
}
return found;
},
nextSibling : function(){
if(this.ownerCt){
var index = this.ownerCt.items.indexOf(this);
if(index != -1 && index+1 < this.ownerCt.items.getCount()){
return this.ownerCt.items.itemAt(index+1);
}
}
return null;
},
previousSibling : function(){
if(this.ownerCt){
var index = this.ownerCt.items.indexOf(this);
if(index > 0){
return this.ownerCt.items.itemAt(index-1);
}
}
return null;
},
getBubbleTarget : function(){
return this.ownerCt;
}
});
Ext.reg('component', Ext.Component);
Ext.Action = Ext.extend(Object, {
constructor : function(config){
this.initialConfig = config;
this.itemId = config.itemId = (config.itemId || config.id || Ext.id());
this.items = [];
},
isAction : true,
setText : function(text){
this.initialConfig.text = text;
this.callEach('setText', [text]);
},
getText : function(){
return this.initialConfig.text;
},
setIconClass : function(cls){
this.initialConfig.iconCls = cls;
this.callEach('setIconClass', [cls]);
},
getIconClass : function(){
return this.initialConfig.iconCls;
},
setDisabled : function(v){
this.initialConfig.disabled = v;
this.callEach('setDisabled', [v]);
},
enable : function(){
this.setDisabled(false);
},
disable : function(){
this.setDisabled(true);
},
isDisabled : function(){
return this.initialConfig.disabled;
},
setHidden : function(v){
this.initialConfig.hidden = v;
this.callEach('setVisible', [!v]);
},
show : function(){
this.setHidden(false);
},
hide : function(){
this.setHidden(true);
},
isHidden : function(){
return this.initialConfig.hidden;
},
setHandler : function(fn, scope){
this.initialConfig.handler = fn;
this.initialConfig.scope = scope;
this.callEach('setHandler', [fn, scope]);
},
each : function(fn, scope){
Ext.each(this.items, fn, scope);
},
callEach : function(fnName, args){
var cs = this.items;
for(var i = 0, len = cs.length; i < len; i++){
cs[i][fnName].apply(cs[i], args);
}
},
addComponent : function(comp){
this.items.push(comp);
comp.on('destroy', this.removeComponent, this);
},
removeComponent : function(comp){
this.items.remove(comp);
},
execute : function(){
this.initialConfig.handler.apply(this.initialConfig.scope || window, arguments);
}
});
(function(){
Ext.Layer = function(config, existingEl){
config = config || {};
var dh = Ext.DomHelper,
cp = config.parentEl, pel = cp ? Ext.getDom(cp) : document.body;
if (existingEl) {
this.dom = Ext.getDom(existingEl);
}
if(!this.dom){
var o = config.dh || {tag: 'div', cls: 'x-layer'};
this.dom = dh.append(pel, o);
}
if(config.cls){
this.addClass(config.cls);
}
this.constrain = config.constrain !== false;
this.setVisibilityMode(Ext.Element.VISIBILITY);
if(config.id){
this.id = this.dom.id = config.id;
}else{
this.id = Ext.id(this.dom);
}
this.zindex = config.zindex || this.getZIndex();
this.position('absolute', this.zindex);
if(config.shadow){
this.shadowOffset = config.shadowOffset || 4;
this.shadow = new Ext.Shadow({
offset : this.shadowOffset,
mode : config.shadow
});
}else{
this.shadowOffset = 0;
}
this.useShim = config.shim !== false && Ext.useShims;
this.useDisplay = config.useDisplay;
this.hide();
};
var supr = Ext.Element.prototype;
var shims = [];
Ext.extend(Ext.Layer, Ext.Element, {
getZIndex : function(){
return this.zindex || parseInt((this.getShim() || this).getStyle('z-index'), 10) || 11000;
},
getShim : function(){
if(!this.useShim){
return null;
}
if(this.shim){
return this.shim;
}
var shim = shims.shift();
if(!shim){
shim = this.createShim();
shim.enableDisplayMode('block');
shim.dom.style.display = 'none';
shim.dom.style.visibility = 'visible';
}
var pn = this.dom.parentNode;
if(shim.dom.parentNode != pn){
pn.insertBefore(shim.dom, this.dom);
}
shim.setStyle('z-index', this.getZIndex()-2);
this.shim = shim;
return shim;
},
hideShim : function(){
if(this.shim){
this.shim.setDisplayed(false);
shims.push(this.shim);
delete this.shim;
}
},
disableShadow : function(){
if(this.shadow){
this.shadowDisabled = true;
this.shadow.hide();
this.lastShadowOffset = this.shadowOffset;
this.shadowOffset = 0;
}
},
enableShadow : function(show){
if(this.shadow){
this.shadowDisabled = false;
if(Ext.isDefined(this.lastShadowOffset)) {
this.shadowOffset = this.lastShadowOffset;
delete this.lastShadowOffset;
}
if(show){
this.sync(true);
}
}
},
sync : function(doShow){
var shadow = this.shadow;
if(!this.updating && this.isVisible() && (shadow || this.useShim)){
var shim = this.getShim(),
w = this.getWidth(),
h = this.getHeight(),
l = this.getLeft(true),
t = this.getTop(true);
if(shadow && !this.shadowDisabled){
if(doShow && !shadow.isVisible()){
shadow.show(this);
}else{
shadow.realign(l, t, w, h);
}
if(shim){
if(doShow){
shim.show();
}
var shadowAdj = shadow.el.getXY(), shimStyle = shim.dom.style,
shadowSize = shadow.el.getSize();
shimStyle.left = (shadowAdj[0])+'px';
shimStyle.top = (shadowAdj[1])+'px';
shimStyle.width = (shadowSize.width)+'px';
shimStyle.height = (shadowSize.height)+'px';
}
}else if(shim){
if(doShow){
shim.show();
}
shim.setSize(w, h);
shim.setLeftTop(l, t);
}
}
},
destroy : function(){
this.hideShim();
if(this.shadow){
this.shadow.hide();
}
this.removeAllListeners();
Ext.removeNode(this.dom);
delete this.dom;
},
remove : function(){
this.destroy();
},
beginUpdate : function(){
this.updating = true;
},
endUpdate : function(){
this.updating = false;
this.sync(true);
},
hideUnders : function(negOffset){
if(this.shadow){
this.shadow.hide();
}
this.hideShim();
},
constrainXY : function(){
if(this.constrain){
var vw = Ext.lib.Dom.getViewWidth(),
vh = Ext.lib.Dom.getViewHeight();
var s = Ext.getDoc().getScroll();
var xy = this.getXY();
var x = xy[0], y = xy[1];
var so = this.shadowOffset;
var w = this.dom.offsetWidth+so, h = this.dom.offsetHeight+so;
var moved = false;
if((x + w) > vw+s.left){
x = vw - w - so;
moved = true;
}
if((y + h) > vh+s.top){
y = vh - h - so;
moved = true;
}
if(x < s.left){
x = s.left;
moved = true;
}
if(y < s.top){
y = s.top;
moved = true;
}
if(moved){
if(this.avoidY){
var ay = this.avoidY;
if(y <= ay && (y+h) >= ay){
y = ay-h-5;
}
}
xy = [x, y];
this.storeXY(xy);
supr.setXY.call(this, xy);
this.sync();
}
}
return this;
},
getConstrainOffset : function(){
return this.shadowOffset;
},
isVisible : function(){
return this.visible;
},
showAction : function(){
this.visible = true;
if(this.useDisplay === true){
this.setDisplayed('');
}else if(this.lastXY){
supr.setXY.call(this, this.lastXY);
}else if(this.lastLT){
supr.setLeftTop.call(this, this.lastLT[0], this.lastLT[1]);
}
},
hideAction : function(){
this.visible = false;
if(this.useDisplay === true){
this.setDisplayed(false);
}else{
this.setLeftTop(-10000,-10000);
}
},
setVisible : function(v, a, d, c, e){
if(v){
this.showAction();
}
if(a && v){
var cb = function(){
this.sync(true);
if(c){
c();
}
}.createDelegate(this);
supr.setVisible.call(this, true, true, d, cb, e);
}else{
if(!v){
this.hideUnders(true);
}
var cb = c;
if(a){
cb = function(){
this.hideAction();
if(c){
c();
}
}.createDelegate(this);
}
supr.setVisible.call(this, v, a, d, cb, e);
if(v){
this.sync(true);
}else if(!a){
this.hideAction();
}
}
return this;
},
storeXY : function(xy){
delete this.lastLT;
this.lastXY = xy;
},
storeLeftTop : function(left, top){
delete this.lastXY;
this.lastLT = [left, top];
},
beforeFx : function(){
this.beforeAction();
return Ext.Layer.superclass.beforeFx.apply(this, arguments);
},
afterFx : function(){
Ext.Layer.superclass.afterFx.apply(this, arguments);
this.sync(this.isVisible());
},
beforeAction : function(){
if(!this.updating && this.shadow){
this.shadow.hide();
}
},
setLeft : function(left){
this.storeLeftTop(left, this.getTop(true));
supr.setLeft.apply(this, arguments);
this.sync();
return this;
},
setTop : function(top){
this.storeLeftTop(this.getLeft(true), top);
supr.setTop.apply(this, arguments);
this.sync();
return this;
},
setLeftTop : function(left, top){
this.storeLeftTop(left, top);
supr.setLeftTop.apply(this, arguments);
this.sync();
return this;
},
setXY : function(xy, a, d, c, e){
this.fixDisplay();
this.beforeAction();
this.storeXY(xy);
var cb = this.createCB(c);
supr.setXY.call(this, xy, a, d, cb, e);
if(!a){
cb();
}
return this;
},
createCB : function(c){
var el = this;
return function(){
el.constrainXY();
el.sync(true);
if(c){
c();
}
};
},
setX : function(x, a, d, c, e){
this.setXY([x, this.getY()], a, d, c, e);
return this;
},
setY : function(y, a, d, c, e){
this.setXY([this.getX(), y], a, d, c, e);
return this;
},
setSize : function(w, h, a, d, c, e){
this.beforeAction();
var cb = this.createCB(c);
supr.setSize.call(this, w, h, a, d, cb, e);
if(!a){
cb();
}
return this;
},
setWidth : function(w, a, d, c, e){
this.beforeAction();
var cb = this.createCB(c);
supr.setWidth.call(this, w, a, d, cb, e);
if(!a){
cb();
}
return this;
},
setHeight : function(h, a, d, c, e){
this.beforeAction();
var cb = this.createCB(c);
supr.setHeight.call(this, h, a, d, cb, e);
if(!a){
cb();
}
return this;
},
setBounds : function(x, y, w, h, a, d, c, e){
this.beforeAction();
var cb = this.createCB(c);
if(!a){
this.storeXY([x, y]);
supr.setXY.call(this, [x, y]);
supr.setSize.call(this, w, h, a, d, cb, e);
cb();
}else{
supr.setBounds.call(this, x, y, w, h, a, d, cb, e);
}
return this;
},
setZIndex : function(zindex){
this.zindex = zindex;
this.setStyle('z-index', zindex + 2);
if(this.shadow){
this.shadow.setZIndex(zindex + 1);
}
if(this.shim){
this.shim.setStyle('z-index', zindex);
}
return this;
}
});
})();
Ext.Shadow = function(config) {
Ext.apply(this, config);
if (typeof this.mode != "string") {
this.mode = this.defaultMode;
}
var o = this.offset,
a = {
h: 0
},
rad = Math.floor(this.offset / 2);
switch (this.mode.toLowerCase()) {
case "drop":
a.w = 0;
a.l = a.t = o;
a.t -= 1;
if (Ext.isIE) {
a.l -= this.offset + rad;
a.t -= this.offset + rad;
a.w -= rad;
a.h -= rad;
a.t += 1;
}
break;
case "sides":
a.w = (o * 2);
a.l = -o;
a.t = o - 1;
if (Ext.isIE) {
a.l -= (this.offset - rad);
a.t -= this.offset + rad;
a.l += 1;
a.w -= (this.offset - rad) * 2;
a.w -= rad + 1;
a.h -= 1;
}
break;
case "frame":
a.w = a.h = (o * 2);
a.l = a.t = -o;
a.t += 1;
a.h -= 2;
if (Ext.isIE) {
a.l -= (this.offset - rad);
a.t -= (this.offset - rad);
a.l += 1;
a.w -= (this.offset + rad + 1);
a.h -= (this.offset + rad);
a.h += 1;
}
break;
};
this.adjusts = a;
};
Ext.Shadow.prototype = {
offset: 4,
defaultMode: "drop",
show: function(target) {
target = Ext.get(target);
if (!this.el) {
this.el = Ext.Shadow.Pool.pull();
if (this.el.dom.nextSibling != target.dom) {
this.el.insertBefore(target);
}
}
this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10) - 1);
if (Ext.isIE) {
this.el.dom.style.filter = "progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius=" + (this.offset) + ")";
}
this.realign(
target.getLeft(true),
target.getTop(true),
target.getWidth(),
target.getHeight()
);
this.el.dom.style.display = "block";
},
isVisible: function() {
return this.el ? true: false;
},
realign: function(l, t, w, h) {
if (!this.el) {
return;
}
var a = this.adjusts,
d = this.el.dom,
s = d.style,
iea = 0,
sw = (w + a.w),
sh = (h + a.h),
sws = sw + "px",
shs = sh + "px",
cn,
sww;
s.left = (l + a.l) + "px";
s.top = (t + a.t) + "px";
if (s.width != sws || s.height != shs) {
s.width = sws;
s.height = shs;
if (!Ext.isIE) {
cn = d.childNodes;
sww = Math.max(0, (sw - 12)) + "px";
cn[0].childNodes[1].style.width = sww;
cn[1].childNodes[1].style.width = sww;
cn[2].childNodes[1].style.width = sww;
cn[1].style.height = Math.max(0, (sh - 12)) + "px";
}
}
},
hide: function() {
if (this.el) {
this.el.dom.style.display = "none";
Ext.Shadow.Pool.push(this.el);
delete this.el;
}
},
setZIndex: function(z) {
this.zIndex = z;
if (this.el) {
this.el.setStyle("z-index", z);
}
}
};
Ext.Shadow.Pool = function() {
var p = [],
markup = Ext.isIE ?
'<div class="x-ie-shadow"></div>':
'<div class="x-shadow"><div class="xst"><div class="xstl"></div><div class="xstc"></div><div class="xstr"></div></div><div class="xsc"><div class="xsml"></div><div class="xsmc"></div><div class="xsmr"></div></div><div class="xsb"><div class="xsbl"></div><div class="xsbc"></div><div class="xsbr"></div></div></div>';
return {
pull: function() {
var sh = p.shift();
if (!sh) {
sh = Ext.get(Ext.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
sh.autoBoxAdjust = false;
}
return sh;
},
push: function(sh) {
p.push(sh);
}
};
}();
Ext.BoxComponent = Ext.extend(Ext.Component, {
initComponent : function(){
Ext.BoxComponent.superclass.initComponent.call(this);
this.addEvents(
'resize',
'move'
);
},
boxReady : false,
deferHeight: false,
setSize : function(w, h){
if(typeof w == 'object'){
h = w.height;
w = w.width;
}
if (Ext.isDefined(w) && Ext.isDefined(this.boxMinWidth) && (w < this.boxMinWidth)) {
w = this.boxMinWidth;
}
if (Ext.isDefined(h) && Ext.isDefined(this.boxMinHeight) && (h < this.boxMinHeight)) {
h = this.boxMinHeight;
}
if (Ext.isDefined(w) && Ext.isDefined(this.boxMaxWidth) && (w > this.boxMaxWidth)) {
w = this.boxMaxWidth;
}
if (Ext.isDefined(h) && Ext.isDefined(this.boxMaxHeight) && (h > this.boxMaxHeight)) {
h = this.boxMaxHeight;
}
if(!this.boxReady){
this.width = w;
this.height = h;
return this;
}
if(this.cacheSizes !== false && this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
return this;
}
this.lastSize = {width: w, height: h};
var adj = this.adjustSize(w, h),
aw = adj.width,
ah = adj.height,
rz;
if(aw !== undefined || ah !== undefined){
rz = this.getResizeEl();
if(!this.deferHeight && aw !== undefined && ah !== undefined){
rz.setSize(aw, ah);
}else if(!this.deferHeight && ah !== undefined){
rz.setHeight(ah);
}else if(aw !== undefined){
rz.setWidth(aw);
}
this.onResize(aw, ah, w, h);
this.fireEvent('resize', this, aw, ah, w, h);
}
return this;
},
setWidth : function(width){
return this.setSize(width);
},
setHeight : function(height){
return this.setSize(undefined, height);
},
getSize : function(){
return this.getResizeEl().getSize();
},
getWidth : function(){
return this.getResizeEl().getWidth();
},
getHeight : function(){
return this.getResizeEl().getHeight();
},
getOuterSize : function(){
var el = this.getResizeEl();
return {width: el.getWidth() + el.getMargins('lr'),
height: el.getHeight() + el.getMargins('tb')};
},
getPosition : function(local){
var el = this.getPositionEl();
if(local === true){
return [el.getLeft(true), el.getTop(true)];
}
return this.xy || el.getXY();
},
getBox : function(local){
var pos = this.getPosition(local);
var s = this.getSize();
s.x = pos[0];
s.y = pos[1];
return s;
},
updateBox : function(box){
this.setSize(box.width, box.height);
this.setPagePosition(box.x, box.y);
return this;
},
getResizeEl : function(){
return this.resizeEl || this.el;
},
setAutoScroll : function(scroll){
if(this.rendered){
this.getContentTarget().setOverflow(scroll ? 'auto' : '');
}
this.autoScroll = scroll;
return this;
},
setPosition : function(x, y){
if(x && typeof x[1] == 'number'){
y = x[1];
x = x[0];
}
this.x = x;
this.y = y;
if(!this.boxReady){
return this;
}
var adj = this.adjustPosition(x, y);
var ax = adj.x, ay = adj.y;
var el = this.getPositionEl();
if(ax !== undefined || ay !== undefined){
if(ax !== undefined && ay !== undefined){
el.setLeftTop(ax, ay);
}else if(ax !== undefined){
el.setLeft(ax);
}else if(ay !== undefined){
el.setTop(ay);
}
this.onPosition(ax, ay);
this.fireEvent('move', this, ax, ay);
}
return this;
},
setPagePosition : function(x, y){
if(x && typeof x[1] == 'number'){
y = x[1];
x = x[0];
}
this.pageX = x;
this.pageY = y;
if(!this.boxReady){
return;
}
if(x === undefined || y === undefined){
return;
}
var p = this.getPositionEl().translatePoints(x, y);
this.setPosition(p.left, p.top);
return this;
},
afterRender : function(){
Ext.BoxComponent.superclass.afterRender.call(this);
if(this.resizeEl){
this.resizeEl = Ext.get(this.resizeEl);
}
if(this.positionEl){
this.positionEl = Ext.get(this.positionEl);
}
this.boxReady = true;
Ext.isDefined(this.autoScroll) && this.setAutoScroll(this.autoScroll);
this.setSize(this.width, this.height);
if(this.x || this.y){
this.setPosition(this.x, this.y);
}else if(this.pageX || this.pageY){
this.setPagePosition(this.pageX, this.pageY);
}
},
syncSize : function(){
delete this.lastSize;
this.setSize(this.autoWidth ? undefined : this.getResizeEl().getWidth(), this.autoHeight ? undefined : this.getResizeEl().getHeight());
return this;
},
onResize : function(adjWidth, adjHeight, rawWidth, rawHeight){
},
onPosition : function(x, y){
},
adjustSize : function(w, h){
if(this.autoWidth){
w = 'auto';
}
if(this.autoHeight){
h = 'auto';
}
return {width : w, height: h};
},
adjustPosition : function(x, y){
return {x : x, y: y};
}
});
Ext.reg('box', Ext.BoxComponent);
Ext.Spacer = Ext.extend(Ext.BoxComponent, {
autoEl:'div'
});
Ext.reg('spacer', Ext.Spacer);
Ext.SplitBar = function(dragElement, resizingElement, orientation, placement, existingProxy){
this.el = Ext.get(dragElement, true);
this.el.dom.unselectable = "on";
this.resizingEl = Ext.get(resizingElement, true);
this.orientation = orientation || Ext.SplitBar.HORIZONTAL;
this.minSize = 0;
this.maxSize = 2000;
this.animate = false;
this.useShim = false;
this.shim = null;
if(!existingProxy){
this.proxy = Ext.SplitBar.createProxy(this.orientation);
}else{
this.proxy = Ext.get(existingProxy).dom;
}
this.dd = new Ext.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
this.dragSpecs = {};
this.adapter = new Ext.SplitBar.BasicLayoutAdapter();
this.adapter.init(this);
if(this.orientation == Ext.SplitBar.HORIZONTAL){
this.placement = placement || (this.el.getX() > this.resizingEl.getX() ? Ext.SplitBar.LEFT : Ext.SplitBar.RIGHT);
this.el.addClass("x-splitbar-h");
}else{
this.placement = placement || (this.el.getY() > this.resizingEl.getY() ? Ext.SplitBar.TOP : Ext.SplitBar.BOTTOM);
this.el.addClass("x-splitbar-v");
}
this.addEvents(
"resize",
"moved",
"beforeresize",
"beforeapply"
);
Ext.SplitBar.superclass.constructor.call(this);
};
Ext.extend(Ext.SplitBar, Ext.util.Observable, {
onStartProxyDrag : function(x, y){
this.fireEvent("beforeresize", this);
this.overlay = Ext.DomHelper.append(document.body, {cls: "x-drag-overlay", html: "&#160;"}, true);
this.overlay.unselectable();
this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
this.overlay.show();
Ext.get(this.proxy).setDisplayed("block");
var size = this.adapter.getElementSize(this);
this.activeMinSize = this.getMinimumSize();
this.activeMaxSize = this.getMaximumSize();
var c1 = size - this.activeMinSize;
var c2 = Math.max(this.activeMaxSize - size, 0);
if(this.orientation == Ext.SplitBar.HORIZONTAL){
this.dd.resetConstraints();
this.dd.setXConstraint(
this.placement == Ext.SplitBar.LEFT ? c1 : c2,
this.placement == Ext.SplitBar.LEFT ? c2 : c1,
this.tickSize
);
this.dd.setYConstraint(0, 0);
}else{
this.dd.resetConstraints();
this.dd.setXConstraint(0, 0);
this.dd.setYConstraint(
this.placement == Ext.SplitBar.TOP ? c1 : c2,
this.placement == Ext.SplitBar.TOP ? c2 : c1,
this.tickSize
);
}
this.dragSpecs.startSize = size;
this.dragSpecs.startPoint = [x, y];
Ext.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
},
onEndProxyDrag : function(e){
Ext.get(this.proxy).setDisplayed(false);
var endPoint = Ext.lib.Event.getXY(e);
if(this.overlay){
Ext.destroy(this.overlay);
delete this.overlay;
}
var newSize;
if(this.orientation == Ext.SplitBar.HORIZONTAL){
newSize = this.dragSpecs.startSize +
(this.placement == Ext.SplitBar.LEFT ?
endPoint[0] - this.dragSpecs.startPoint[0] :
this.dragSpecs.startPoint[0] - endPoint[0]
);
}else{
newSize = this.dragSpecs.startSize +
(this.placement == Ext.SplitBar.TOP ?
endPoint[1] - this.dragSpecs.startPoint[1] :
this.dragSpecs.startPoint[1] - endPoint[1]
);
}
newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
if(newSize != this.dragSpecs.startSize){
if(this.fireEvent('beforeapply', this, newSize) !== false){
this.adapter.setElementSize(this, newSize);
this.fireEvent("moved", this, newSize);
this.fireEvent("resize", this, newSize);
}
}
},
getAdapter : function(){
return this.adapter;
},
setAdapter : function(adapter){
this.adapter = adapter;
this.adapter.init(this);
},
getMinimumSize : function(){
return this.minSize;
},
setMinimumSize : function(minSize){
this.minSize = minSize;
},
getMaximumSize : function(){
return this.maxSize;
},
setMaximumSize : function(maxSize){
this.maxSize = maxSize;
},
setCurrentSize : function(size){
var oldAnimate = this.animate;
this.animate = false;
this.adapter.setElementSize(this, size);
this.animate = oldAnimate;
},
destroy : function(removeEl){
Ext.destroy(this.shim, Ext.get(this.proxy));
this.dd.unreg();
if(removeEl){
this.el.remove();
}
this.purgeListeners();
}
});
Ext.SplitBar.createProxy = function(dir){
var proxy = new Ext.Element(document.createElement("div"));
document.body.appendChild(proxy.dom);
proxy.unselectable();
var cls = 'x-splitbar-proxy';
proxy.addClass(cls + ' ' + (dir == Ext.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
return proxy.dom;
};
Ext.SplitBar.BasicLayoutAdapter = function(){
};
Ext.SplitBar.BasicLayoutAdapter.prototype = {
init : function(s){
},
getElementSize : function(s){
if(s.orientation == Ext.SplitBar.HORIZONTAL){
return s.resizingEl.getWidth();
}else{
return s.resizingEl.getHeight();
}
},
setElementSize : function(s, newSize, onComplete){
if(s.orientation == Ext.SplitBar.HORIZONTAL){
if(!s.animate){
s.resizingEl.setWidth(newSize);
if(onComplete){
onComplete(s, newSize);
}
}else{
s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
}
}else{
if(!s.animate){
s.resizingEl.setHeight(newSize);
if(onComplete){
onComplete(s, newSize);
}
}else{
s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
}
}
}
};
Ext.SplitBar.AbsoluteLayoutAdapter = function(container){
this.basic = new Ext.SplitBar.BasicLayoutAdapter();
this.container = Ext.get(container);
};
Ext.SplitBar.AbsoluteLayoutAdapter.prototype = {
init : function(s){
this.basic.init(s);
},
getElementSize : function(s){
return this.basic.getElementSize(s);
},
setElementSize : function(s, newSize, onComplete){
this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
},
moveSplitter : function(s){
var yes = Ext.SplitBar;
switch(s.placement){
case yes.LEFT:
s.el.setX(s.resizingEl.getRight());
break;
case yes.RIGHT:
s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
break;
case yes.TOP:
s.el.setY(s.resizingEl.getBottom());
break;
case yes.BOTTOM:
s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
break;
}
}
};
Ext.SplitBar.VERTICAL = 1;
Ext.SplitBar.HORIZONTAL = 2;
Ext.SplitBar.LEFT = 1;
Ext.SplitBar.RIGHT = 2;
Ext.SplitBar.TOP = 3;
Ext.SplitBar.BOTTOM = 4;
Ext.Container = Ext.extend(Ext.BoxComponent, {
bufferResize: 50,
autoDestroy : true,
forceLayout: false,
defaultType : 'panel',
resizeEvent: 'resize',
bubbleEvents: ['add', 'remove'],
initComponent : function(){
Ext.Container.superclass.initComponent.call(this);
this.addEvents(
'afterlayout',
'beforeadd',
'beforeremove',
'add',
'remove'
);
var items = this.items;
if(items){
delete this.items;
this.add(items);
}
},
initItems : function(){
if(!this.items){
this.items = new Ext.util.MixedCollection(false, this.getComponentId);
this.getLayout();
}
},
setLayout : function(layout){
if(this.layout && this.layout != layout){
this.layout.setContainer(null);
}
this.layout = layout;
this.initItems();
layout.setContainer(this);
},
afterRender: function(){
Ext.Container.superclass.afterRender.call(this);
if(!this.layout){
this.layout = 'auto';
}
if(Ext.isObject(this.layout) && !this.layout.layout){
this.layoutConfig = this.layout;
this.layout = this.layoutConfig.type;
}
if(Ext.isString(this.layout)){
this.layout = new Ext.Container.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig);
}
this.setLayout(this.layout);
if(this.activeItem !== undefined && this.layout.setActiveItem){
var item = this.activeItem;
delete this.activeItem;
this.layout.setActiveItem(item);
}
if(!this.ownerCt){
this.doLayout(false, true);
}
if(this.monitorResize === true){
Ext.EventManager.onWindowResize(this.doLayout, this, [false]);
}
},
getLayoutTarget : function(){
return this.el;
},
getComponentId : function(comp){
return comp.getItemId();
},
add : function(comp){
this.initItems();
var args = arguments.length > 1;
if(args || Ext.isArray(comp)){
var result = [];
Ext.each(args ? arguments : comp, function(c){
result.push(this.add(c));
}, this);
return result;
}
var c = this.lookupComponent(this.applyDefaults(comp));
var index = this.items.length;
if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){
this.items.add(c);
c.onAdded(this, index);
this.onAdd(c);
this.fireEvent('add', this, c, index);
}
return c;
},
onAdd : function(c){
},
onAdded : function(container, pos) {
this.ownerCt = container;
this.initRef();
this.cascade(function(c){
c.initRef();
});
this.fireEvent('added', this, container, pos);
},
insert : function(index, comp) {
var args = arguments,
length = args.length,
result = [],
i, c;
this.initItems();
if (length > 2) {
for (i = length - 1; i >= 1; --i) {
result.push(this.insert(index, args[i]));
}
return result;
}
c = this.lookupComponent(this.applyDefaults(comp));
index = Math.min(index, this.items.length);
if (this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false) {
if (c.ownerCt == this) {
this.items.remove(c);
}
this.items.insert(index, c);
c.onAdded(this, index);
this.onAdd(c);
this.fireEvent('add', this, c, index);
}
return c;
},
applyDefaults : function(c){
var d = this.defaults;
if(d){
if(Ext.isFunction(d)){
d = d.call(this, c);
}
if(Ext.isString(c)){
c = Ext.ComponentMgr.get(c);
Ext.apply(c, d);
}else if(!c.events){
Ext.applyIf(c.isAction ? c.initialConfig : c, d);
}else{
Ext.apply(c, d);
}
}
return c;
},
onBeforeAdd : function(item){
if(item.ownerCt){
item.ownerCt.remove(item, false);
}
if(this.hideBorders === true){
item.border = (item.border === true);
}
},
remove : function(comp, autoDestroy){
this.initItems();
var c = this.getComponent(comp);
if(c && this.fireEvent('beforeremove', this, c) !== false){
this.doRemove(c, autoDestroy);
this.fireEvent('remove', this, c);
}
return c;
},
onRemove: function(c){
},
doRemove: function(c, autoDestroy){
var l = this.layout,
hasLayout = l && this.rendered;
if(hasLayout){
l.onRemove(c);
}
this.items.remove(c);
c.onRemoved();
this.onRemove(c);
if(autoDestroy === true || (autoDestroy !== false && this.autoDestroy)){
c.destroy();
}
if(hasLayout){
l.afterRemove(c);
}
},
removeAll: function(autoDestroy){
this.initItems();
var item, rem = [], items = [];
this.items.each(function(i){
rem.push(i);
});
for (var i = 0, len = rem.length; i < len; ++i){
item = rem[i];
this.remove(item, autoDestroy);
if(item.ownerCt !== this){
items.push(item);
}
}
return items;
},
getComponent : function(comp){
if(Ext.isObject(comp)){
comp = comp.getItemId();
}
return this.items.get(comp);
},
lookupComponent : function(comp){
if(Ext.isString(comp)){
return Ext.ComponentMgr.get(comp);
}else if(!comp.events){
return this.createComponent(comp);
}
return comp;
},
createComponent : function(config, defaultType){
if (config.render) {
return config;
}
var c = Ext.create(Ext.apply({
ownerCt: this
}, config), defaultType || this.defaultType);
delete c.initialConfig.ownerCt;
delete c.ownerCt;
return c;
},
canLayout : function() {
var el = this.getVisibilityEl();
return el && el.dom && !el.isStyle("display", "none");
},
doLayout : function(shallow, force){
var rendered = this.rendered,
forceLayout = force || this.forceLayout;
if(this.collapsed || !this.canLayout()){
this.deferLayout = this.deferLayout || !shallow;
if(!forceLayout){
return;
}
shallow = shallow && !this.deferLayout;
} else {
delete this.deferLayout;
}
if(rendered && this.layout){
this.layout.layout();
}
if(shallow !== true && this.items){
var cs = this.items.items;
for(var i = 0, len = cs.length; i < len; i++){
var c = cs[i];
if(c.doLayout){
c.doLayout(false, forceLayout);
}
}
}
if(rendered){
this.onLayout(shallow, forceLayout);
}
this.hasLayout = true;
delete this.forceLayout;
},
onLayout : Ext.emptyFn,
shouldBufferLayout: function(){
var hl = this.hasLayout;
if(this.ownerCt){
return hl ? !this.hasLayoutPending() : false;
}
return hl;
},
hasLayoutPending: function(){
var pending = false;
this.ownerCt.bubble(function(c){
if(c.layoutPending){
pending = true;
return false;
}
});
return pending;
},
onShow : function(){
Ext.Container.superclass.onShow.call(this);
if(Ext.isDefined(this.deferLayout)){
delete this.deferLayout;
this.doLayout(true);
}
},
getLayout : function(){
if(!this.layout){
var layout = new Ext.layout.AutoLayout(this.layoutConfig);
this.setLayout(layout);
}
return this.layout;
},
beforeDestroy : function(){
var c;
if(this.items){
while(c = this.items.first()){
this.doRemove(c, true);
}
}
if(this.monitorResize){
Ext.EventManager.removeResizeListener(this.doLayout, this);
}
Ext.destroy(this.layout);
Ext.Container.superclass.beforeDestroy.call(this);
},
cascade : function(fn, scope, args){
if(fn.apply(scope || this, args || [this]) !== false){
if(this.items){
var cs = this.items.items;
for(var i = 0, len = cs.length; i < len; i++){
if(cs[i].cascade){
cs[i].cascade(fn, scope, args);
}else{
fn.apply(scope || cs[i], args || [cs[i]]);
}
}
}
}
return this;
},
findById : function(id){
var m = null,
ct = this;
this.cascade(function(c){
if(ct != c && c.id === id){
m = c;
return false;
}
});
return m;
},
findByType : function(xtype, shallow){
return this.findBy(function(c){
return c.isXType(xtype, shallow);
});
},
find : function(prop, value){
return this.findBy(function(c){
return c[prop] === value;
});
},
findBy : function(fn, scope){
var m = [], ct = this;
this.cascade(function(c){
if(ct != c && fn.call(scope || c, c, ct) === true){
m.push(c);
}
});
return m;
},
get : function(key){
return this.getComponent(key);
}
});
Ext.Container.LAYOUTS = {};
Ext.reg('container', Ext.Container);
Ext.layout.ContainerLayout = Ext.extend(Object, {
monitorResize:false,
activeItem : null,
constructor : function(config){
this.id = Ext.id(null, 'ext-layout-');
Ext.apply(this, config);
},
type: 'container',
IEMeasureHack : function(target, viewFlag) {
var tChildren = target.dom.childNodes, tLen = tChildren.length, c, d = [], e, i, ret;
for (i = 0 ; i < tLen ; i++) {
c = tChildren[i];
e = Ext.get(c);
if (e) {
d[i] = e.getStyle('display');
e.setStyle({display: 'none'});
}
}
ret = target ? target.getViewSize(viewFlag) : {};
for (i = 0 ; i < tLen ; i++) {
c = tChildren[i];
e = Ext.get(c);
if (e) {
e.setStyle({display: d[i]});
}
}
return ret;
},
getLayoutTargetSize : Ext.EmptyFn,
layout : function(){
var ct = this.container, target = ct.getLayoutTarget();
if(!(this.hasLayout || Ext.isEmpty(this.targetCls))){
target.addClass(this.targetCls);
}
this.onLayout(ct, target);
ct.fireEvent('afterlayout', ct, this);
},
onLayout : function(ct, target){
this.renderAll(ct, target);
},
isValidParent : function(c, target){
return target && c.getPositionEl().dom.parentNode == (target.dom || target);
},
renderAll : function(ct, target){
var items = ct.items.items, i, c, len = items.length;
for(i = 0; i < len; i++) {
c = items[i];
if(c && (!c.rendered || !this.isValidParent(c, target))){
this.renderItem(c, i, target);
}
}
},
renderItem : function(c, position, target){
if (c) {
if (!c.rendered) {
c.render(target, position);
this.configureItem(c);
} else if (!this.isValidParent(c, target)) {
if (Ext.isNumber(position)) {
position = target.dom.childNodes[position];
}
target.dom.insertBefore(c.getPositionEl().dom, position || null);
c.container = target;
this.configureItem(c);
}
}
},
getRenderedItems: function(ct){
var t = ct.getLayoutTarget(), cti = ct.items.items, len = cti.length, i, c, items = [];
for (i = 0; i < len; i++) {
if((c = cti[i]).rendered && this.isValidParent(c, t) && c.shouldLayout !== false){
items.push(c);
}
};
return items;
},
configureItem: function(c){
if (this.extraCls) {
var t = c.getPositionEl ? c.getPositionEl() : c;
t.addClass(this.extraCls);
}
if (c.doLayout && this.forceLayout) {
c.doLayout();
}
if (this.renderHidden && c != this.activeItem) {
c.hide();
}
},
onRemove: function(c){
if(this.activeItem == c){
delete this.activeItem;
}
if(c.rendered && this.extraCls){
var t = c.getPositionEl ? c.getPositionEl() : c;
t.removeClass(this.extraCls);
}
},
afterRemove: function(c){
if(c.removeRestore){
c.removeMode = 'container';
delete c.removeRestore;
}
},
onResize: function(){
var ct = this.container,
b;
if(ct.collapsed){
return;
}
if(b = ct.bufferResize && ct.shouldBufferLayout()){
if(!this.resizeTask){
this.resizeTask = new Ext.util.DelayedTask(this.runLayout, this);
this.resizeBuffer = Ext.isNumber(b) ? b : 50;
}
ct.layoutPending = true;
this.resizeTask.delay(this.resizeBuffer);
}else{
this.runLayout();
}
},
runLayout: function(){
var ct = this.container;
this.layout();
ct.onLayout();
delete ct.layoutPending;
},
setContainer : function(ct){
if(this.monitorResize && ct != this.container){
var old = this.container;
if(old){
old.un(old.resizeEvent, this.onResize, this);
}
if(ct){
ct.on(ct.resizeEvent, this.onResize, this);
}
}
this.container = ct;
},
parseMargins : function(v){
if (Ext.isNumber(v)) {
v = v.toString();
}
var ms = v.split(' '),
len = ms.length;
if (len == 1) {
ms[1] = ms[2] = ms[3] = ms[0];
} else if(len == 2) {
ms[2] = ms[0];
ms[3] = ms[1];
} else if(len == 3) {
ms[3] = ms[1];
}
return {
top :parseInt(ms[0], 10) || 0,
right :parseInt(ms[1], 10) || 0,
bottom:parseInt(ms[2], 10) || 0,
left :parseInt(ms[3], 10) || 0
};
},
fieldTpl: (function() {
var t = new Ext.Template(
'<div class="x-form-item {itemCls}" tabIndex="-1">',
'<label for="{id}" style="{labelStyle}" class="x-form-item-label">{label}{labelSeparator}</label>',
'<div class="x-form-element" id="x-form-el-{id}" style="{elementStyle}">',
'</div><div class="{clearCls}"></div>',
'</div>'
);
t.disableFormats = true;
return t.compile();
})(),
destroy : function(){
if(this.resizeTask && this.resizeTask.cancel){
this.resizeTask.cancel();
}
if(this.container) {
this.container.un(this.container.resizeEvent, this.onResize, this);
}
if(!Ext.isEmpty(this.targetCls)){
var target = this.container.getLayoutTarget();
if(target){
target.removeClass(this.targetCls);
}
}
}
});
Ext.layout.AutoLayout = Ext.extend(Ext.layout.ContainerLayout, {
type: 'auto',
monitorResize: true,
onLayout : function(ct, target){
Ext.layout.AutoLayout.superclass.onLayout.call(this, ct, target);
var cs = this.getRenderedItems(ct), len = cs.length, i, c;
for(i = 0; i < len; i++){
c = cs[i];
if (c.doLayout){
c.doLayout(true);
}
}
}
});
Ext.Container.LAYOUTS['auto'] = Ext.layout.AutoLayout;
Ext.layout.FitLayout = Ext.extend(Ext.layout.ContainerLayout, {
monitorResize:true,
type: 'fit',
getLayoutTargetSize : function() {
var target = this.container.getLayoutTarget();
if (!target) {
return {};
}
return target.getStyleSize();
},
onLayout : function(ct, target){
Ext.layout.FitLayout.superclass.onLayout.call(this, ct, target);
if(!ct.collapsed){
this.setItemSize(this.activeItem || ct.items.itemAt(0), this.getLayoutTargetSize());
}
},
setItemSize : function(item, size){
if(item && size.height > 0){
item.setSize(size);
}
}
});
Ext.Container.LAYOUTS['fit'] = Ext.layout.FitLayout;
Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
deferredRender : false,
layoutOnCardChange : false,
renderHidden : true,
type: 'card',
setActiveItem : function(item){
var ai = this.activeItem,
ct = this.container;
item = ct.getComponent(item);
if(item && ai != item){
if(ai){
ai.hide();
if (ai.hidden !== true) {
return false;
}
ai.fireEvent('deactivate', ai);
}
var layout = item.doLayout && (this.layoutOnCardChange || !item.rendered);
this.activeItem = item;
delete item.deferLayout;
item.show();
this.layout();
if(layout){
item.doLayout();
}
item.fireEvent('activate', item);
}
},
renderAll : function(ct, target){
if(this.deferredRender){
this.renderItem(this.activeItem, undefined, target);
}else{
Ext.layout.CardLayout.superclass.renderAll.call(this, ct, target);
}
}
});
Ext.Container.LAYOUTS['card'] = Ext.layout.CardLayout;
Ext.layout.AnchorLayout = Ext.extend(Ext.layout.ContainerLayout, {
monitorResize : true,
type : 'anchor',
defaultAnchor : '100%',
parseAnchorRE : /^(r|right|b|bottom)$/i,
getLayoutTargetSize : function() {
var target = this.container.getLayoutTarget(), ret = {};
if (target) {
ret = target.getViewSize();
if (Ext.isIE && Ext.isStrict && ret.width == 0){
ret = target.getStyleSize();
}
ret.width -= target.getPadding('lr');
ret.height -= target.getPadding('tb');
}
return ret;
},
onLayout : function(container, target) {
Ext.layout.AnchorLayout.superclass.onLayout.call(this, container, target);
var size = this.getLayoutTargetSize(),
containerWidth = size.width,
containerHeight = size.height,
overflow = target.getStyle('overflow'),
components = this.getRenderedItems(container),
len = components.length,
boxes = [],
box,
anchorWidth,
anchorHeight,
component,
anchorSpec,
calcWidth,
calcHeight,
anchorsArray,
totalHeight = 0,
i,
el;
if(containerWidth < 20 && containerHeight < 20){
return;
}
if(container.anchorSize) {
if(typeof container.anchorSize == 'number') {
anchorWidth = container.anchorSize;
} else {
anchorWidth = container.anchorSize.width;
anchorHeight = container.anchorSize.height;
}
} else {
anchorWidth = container.initialConfig.width;
anchorHeight = container.initialConfig.height;
}
for(i = 0; i < len; i++) {
component = components[i];
el = component.getPositionEl();
if (!component.anchor && component.items && !Ext.isNumber(component.width) && !(Ext.isIE6 && Ext.isStrict)){
component.anchor = this.defaultAnchor;
}
if(component.anchor) {
anchorSpec = component.anchorSpec;
if(!anchorSpec){
anchorsArray = component.anchor.split(' ');
component.anchorSpec = anchorSpec = {
right: this.parseAnchor(anchorsArray[0], component.initialConfig.width, anchorWidth),
bottom: this.parseAnchor(anchorsArray[1], component.initialConfig.height, anchorHeight)
};
}
calcWidth = anchorSpec.right ? this.adjustWidthAnchor(anchorSpec.right(containerWidth) - el.getMargins('lr'), component) : undefined;
calcHeight = anchorSpec.bottom ? this.adjustHeightAnchor(anchorSpec.bottom(containerHeight) - el.getMargins('tb'), component) : undefined;
if(calcWidth || calcHeight) {
boxes.push({
component: component,
width: calcWidth || undefined,
height: calcHeight || undefined
});
}
}
}
for (i = 0, len = boxes.length; i < len; i++) {
box = boxes[i];
box.component.setSize(box.width, box.height);
}
if (overflow && overflow != 'hidden' && !this.adjustmentPass) {
var newTargetSize = this.getLayoutTargetSize();
if (newTargetSize.width != size.width || newTargetSize.height != size.height){
this.adjustmentPass = true;
this.onLayout(container, target);
}
}
delete this.adjustmentPass;
},
parseAnchor : function(a, start, cstart) {
if (a && a != 'none') {
var last;
if (this.parseAnchorRE.test(a)) {
var diff = cstart - start;
return function(v){
if(v !== last){
last = v;
return v - diff;
}
};
} else if(a.indexOf('%') != -1) {
var ratio = parseFloat(a.replace('%', ''))*.01;
return function(v){
if(v !== last){
last = v;
return Math.floor(v*ratio);
}
};
} else {
a = parseInt(a, 10);
if (!isNaN(a)) {
return function(v) {
if (v !== last) {
last = v;
return v + a;
}
};
}
}
}
return false;
},
adjustWidthAnchor : function(value, comp){
return value;
},
adjustHeightAnchor : function(value, comp){
return value;
}
});
Ext.Container.LAYOUTS['anchor'] = Ext.layout.AnchorLayout;
Ext.layout.ColumnLayout = Ext.extend(Ext.layout.ContainerLayout, {
monitorResize:true,
type: 'column',
extraCls: 'x-column',
scrollOffset : 0,
targetCls: 'x-column-layout-ct',
isValidParent : function(c, target){
return this.innerCt && c.getPositionEl().dom.parentNode == this.innerCt.dom;
},
getLayoutTargetSize : function() {
var target = this.container.getLayoutTarget(), ret;
if (target) {
ret = target.getViewSize();
if (Ext.isIE && Ext.isStrict && ret.width == 0){
ret = target.getStyleSize();
}
ret.width -= target.getPadding('lr');
ret.height -= target.getPadding('tb');
}
return ret;
},
renderAll : function(ct, target) {
if(!this.innerCt){
this.innerCt = target.createChild({cls:'x-column-inner'});
this.innerCt.createChild({cls:'x-clear'});
}
Ext.layout.ColumnLayout.superclass.renderAll.call(this, ct, this.innerCt);
},
onLayout : function(ct, target){
var cs = ct.items.items,
len = cs.length,
c,
i,
m,
margins = [];
this.renderAll(ct, target);
var size = this.getLayoutTargetSize();
if(size.width < 1 && size.height < 1){
return;
}
var w = size.width - this.scrollOffset,
h = size.height,
pw = w;
this.innerCt.setWidth(w);
for(i = 0; i < len; i++){
c = cs[i];
m = c.getPositionEl().getMargins('lr');
margins[i] = m;
if(!c.columnWidth){
pw -= (c.getWidth() + m);
}
}
pw = pw < 0 ? 0 : pw;
for(i = 0; i < len; i++){
c = cs[i];
m = margins[i];
if(c.columnWidth){
c.setSize(Math.floor(c.columnWidth * pw) - m);
}
}
if (Ext.isIE) {
if (i = target.getStyle('overflow') && i != 'hidden' && !this.adjustmentPass) {
var ts = this.getLayoutTargetSize();
if (ts.width != size.width){
this.adjustmentPass = true;
this.onLayout(ct, target);
}
}
}
delete this.adjustmentPass;
}
});
Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout;
Ext.layout.BorderLayout = Ext.extend(Ext.layout.ContainerLayout, {
monitorResize:true,
rendered : false,
type: 'border',
targetCls: 'x-border-layout-ct',
getLayoutTargetSize : function() {
var target = this.container.getLayoutTarget();
return target ? target.getViewSize() : {};
},
onLayout : function(ct, target){
var collapsed, i, c, pos, items = ct.items.items, len = items.length;
if(!this.rendered){
collapsed = [];
for(i = 0; i < len; i++) {
c = items[i];
pos = c.region;
if(c.collapsed){
collapsed.push(c);
}
c.collapsed = false;
if(!c.rendered){
c.render(target, i);
c.getPositionEl().addClass('x-border-panel');
}
this[pos] = pos != 'center' && c.split ?
new Ext.layout.BorderLayout.SplitRegion(this, c.initialConfig, pos) :
new Ext.layout.BorderLayout.Region(this, c.initialConfig, pos);
this[pos].render(target, c);
}
this.rendered = true;
}
var size = this.getLayoutTargetSize();
if(size.width < 20 || size.height < 20){
if(collapsed){
this.restoreCollapsed = collapsed;
}
return;
}else if(this.restoreCollapsed){
collapsed = this.restoreCollapsed;
delete this.restoreCollapsed;
}
var w = size.width, h = size.height,
centerW = w, centerH = h, centerY = 0, centerX = 0,
n = this.north, s = this.south, west = this.west, e = this.east, c = this.center,
b, m, totalWidth, totalHeight;
if(!c && Ext.layout.BorderLayout.WARN !== false){
throw 'No center region defined in BorderLayout ' + ct.id;
}
if(n && n.isVisible()){
b = n.getSize();
m = n.getMargins();
b.width = w - (m.left+m.right);
b.x = m.left;
b.y = m.top;
centerY = b.height + b.y + m.bottom;
centerH -= centerY;
n.applyLayout(b);
}
if(s && s.isVisible()){
b = s.getSize();
m = s.getMargins();
b.width = w - (m.left+m.right);
b.x = m.left;
totalHeight = (b.height + m.top + m.bottom);
b.y = h - totalHeight + m.top;
centerH -= totalHeight;
s.applyLayout(b);
}
if(west && west.isVisible()){
b = west.getSize();
m = west.getMargins();
b.height = centerH - (m.top+m.bottom);
b.x = m.left;
b.y = centerY + m.top;
totalWidth = (b.width + m.left + m.right);
centerX += totalWidth;
centerW -= totalWidth;
west.applyLayout(b);
}
if(e && e.isVisible()){
b = e.getSize();
m = e.getMargins();
b.height = centerH - (m.top+m.bottom);
totalWidth = (b.width + m.left + m.right);
b.x = w - totalWidth + m.left;
b.y = centerY + m.top;
centerW -= totalWidth;
e.applyLayout(b);
}
if(c){
m = c.getMargins();
var centerBox = {
x: centerX + m.left,
y: centerY + m.top,
width: centerW - (m.left+m.right),
height: centerH - (m.top+m.bottom)
};
c.applyLayout(centerBox);
}
if(collapsed){
for(i = 0, len = collapsed.length; i < len; i++){
collapsed[i].collapse(false);
}
}
if(Ext.isIE && Ext.isStrict){
target.repaint();
}
if (i = target.getStyle('overflow') && i != 'hidden' && !this.adjustmentPass) {
var ts = this.getLayoutTargetSize();
if (ts.width != size.width || ts.height != size.height){
this.adjustmentPass = true;
this.onLayout(ct, target);
}
}
delete this.adjustmentPass;
},
destroy: function() {
var r = ['north', 'south', 'east', 'west'], i, region;
for (i = 0; i < r.length; i++) {
region = this[r[i]];
if(region){
if(region.destroy){
region.destroy();
}else if (region.split){
region.split.destroy(true);
}
}
}
Ext.layout.BorderLayout.superclass.destroy.call(this);
}
});
Ext.layout.BorderLayout.Region = function(layout, config, pos){
Ext.apply(this, config);
this.layout = layout;
this.position = pos;
this.state = {};
if(typeof this.margins == 'string'){
this.margins = this.layout.parseMargins(this.margins);
}
this.margins = Ext.applyIf(this.margins || {}, this.defaultMargins);
if(this.collapsible){
if(typeof this.cmargins == 'string'){
this.cmargins = this.layout.parseMargins(this.cmargins);
}
if(this.collapseMode == 'mini' && !this.cmargins){
this.cmargins = {left:0,top:0,right:0,bottom:0};
}else{
this.cmargins = Ext.applyIf(this.cmargins || {},
pos == 'north' || pos == 'south' ? this.defaultNSCMargins : this.defaultEWCMargins);
}
}
};
Ext.layout.BorderLayout.Region.prototype = {
collapsible : false,
split:false,
floatable: true,
minWidth:50,
minHeight:50,
defaultMargins : {left:0,top:0,right:0,bottom:0},
defaultNSCMargins : {left:5,top:5,right:5,bottom:5},
defaultEWCMargins : {left:5,top:0,right:5,bottom:0},
floatingZIndex: 100,
isCollapsed : false,
render : function(ct, p){
this.panel = p;
p.el.enableDisplayMode();
this.targetEl = ct;
this.el = p.el;
var gs = p.getState, ps = this.position;
p.getState = function(){
return Ext.apply(gs.call(p) || {}, this.state);
}.createDelegate(this);
if(ps != 'center'){
p.allowQueuedExpand = false;
p.on({
beforecollapse: this.beforeCollapse,
collapse: this.onCollapse,
beforeexpand: this.beforeExpand,
expand: this.onExpand,
hide: this.onHide,
show: this.onShow,
scope: this
});
if(this.collapsible || this.floatable){
p.collapseEl = 'el';
p.slideAnchor = this.getSlideAnchor();
}
if(p.tools && p.tools.toggle){
p.tools.toggle.addClass('x-tool-collapse-'+ps);
p.tools.toggle.addClassOnOver('x-tool-collapse-'+ps+'-over');
}
}
},
getCollapsedEl : function(){
if(!this.collapsedEl){
if(!this.toolTemplate){
var tt = new Ext.Template(
'<div class="x-tool x-tool-{id}">&#160;</div>'
);
tt.disableFormats = true;
tt.compile();
Ext.layout.BorderLayout.Region.prototype.toolTemplate = tt;
}
this.collapsedEl = this.targetEl.createChild({
cls: "x-layout-collapsed x-layout-collapsed-"+this.position,
id: this.panel.id + '-xcollapsed'
});
this.collapsedEl.enableDisplayMode('block');
if(this.collapseMode == 'mini'){
this.collapsedEl.addClass('x-layout-cmini-'+this.position);
this.miniCollapsedEl = this.collapsedEl.createChild({
cls: "x-layout-mini x-layout-mini-"+this.position, html: "&#160;"
});
this.miniCollapsedEl.addClassOnOver('x-layout-mini-over');
this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
this.collapsedEl.on('click', this.onExpandClick, this, {stopEvent:true});
}else {
if(this.collapsible !== false && !this.hideCollapseTool) {
var t = this.expandToolEl = this.toolTemplate.append(
this.collapsedEl.dom,
{id:'expand-'+this.position}, true);
t.addClassOnOver('x-tool-expand-'+this.position+'-over');
t.on('click', this.onExpandClick, this, {stopEvent:true});
}
if(this.floatable !== false || this.titleCollapse){
this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
this.collapsedEl.on("click", this[this.floatable ? 'collapseClick' : 'onExpandClick'], this);
}
}
}
return this.collapsedEl;
},
onExpandClick : function(e){
if(this.isSlid){
this.panel.expand(false);
}else{
this.panel.expand();
}
},
onCollapseClick : function(e){
this.panel.collapse();
},
beforeCollapse : function(p, animate){
this.lastAnim = animate;
if(this.splitEl){
this.splitEl.hide();
}
this.getCollapsedEl().show();
var el = this.panel.getEl();
this.originalZIndex = el.getStyle('z-index');
el.setStyle('z-index', 100);
this.isCollapsed = true;
this.layout.layout();
},
onCollapse : function(animate){
this.panel.el.setStyle('z-index', 1);
if(this.lastAnim === false || this.panel.animCollapse === false){
this.getCollapsedEl().dom.style.visibility = 'visible';
}else{
this.getCollapsedEl().slideIn(this.panel.slideAnchor, {duration:.2});
}
this.state.collapsed = true;
this.panel.saveState();
},
beforeExpand : function(animate){
if(this.isSlid){
this.afterSlideIn();
}
var c = this.getCollapsedEl();
this.el.show();
if(this.position == 'east' || this.position == 'west'){
this.panel.setSize(undefined, c.getHeight());
}else{
this.panel.setSize(c.getWidth(), undefined);
}
c.hide();
c.dom.style.visibility = 'hidden';
this.panel.el.setStyle('z-index', this.floatingZIndex);
},
onExpand : function(){
this.isCollapsed = false;
if(this.splitEl){
this.splitEl.show();
}
this.layout.layout();
this.panel.el.setStyle('z-index', this.originalZIndex);
this.state.collapsed = false;
this.panel.saveState();
},
collapseClick : function(e){
if(this.isSlid){
e.stopPropagation();
this.slideIn();
}else{
e.stopPropagation();
this.slideOut();
}
},
onHide : function(){
if(this.isCollapsed){
this.getCollapsedEl().hide();
}else if(this.splitEl){
this.splitEl.hide();
}
},
onShow : function(){
if(this.isCollapsed){
this.getCollapsedEl().show();
}else if(this.splitEl){
this.splitEl.show();
}
},
isVisible : function(){
return !this.panel.hidden;
},
getMargins : function(){
return this.isCollapsed && this.cmargins ? this.cmargins : this.margins;
},
getSize : function(){
return this.isCollapsed ? this.getCollapsedEl().getSize() : this.panel.getSize();
},
setPanel : function(panel){
this.panel = panel;
},
getMinWidth: function(){
return this.minWidth;
},
getMinHeight: function(){
return this.minHeight;
},
applyLayoutCollapsed : function(box){
var ce = this.getCollapsedEl();
ce.setLeftTop(box.x, box.y);
ce.setSize(box.width, box.height);
},
applyLayout : function(box){
if(this.isCollapsed){
this.applyLayoutCollapsed(box);
}else{
this.panel.setPosition(box.x, box.y);
this.panel.setSize(box.width, box.height);
}
},
beforeSlide: function(){
this.panel.beforeEffect();
},
afterSlide : function(){
this.panel.afterEffect();
},
initAutoHide : function(){
if(this.autoHide !== false){
if(!this.autoHideHd){
this.autoHideSlideTask = new Ext.util.DelayedTask(this.slideIn, this);
this.autoHideHd = {
"mouseout": function(e){
if(!e.within(this.el, true)){
this.autoHideSlideTask.delay(500);
}
},
"mouseover" : function(e){
this.autoHideSlideTask.cancel();
},
scope : this
};
}
this.el.on(this.autoHideHd);
this.collapsedEl.on(this.autoHideHd);
}
},
clearAutoHide : function(){
if(this.autoHide !== false){
this.el.un("mouseout", this.autoHideHd.mouseout);
this.el.un("mouseover", this.autoHideHd.mouseover);
this.collapsedEl.un("mouseout", this.autoHideHd.mouseout);
this.collapsedEl.un("mouseover", this.autoHideHd.mouseover);
}
},
clearMonitor : function(){
Ext.getDoc().un("click", this.slideInIf, this);
},
slideOut : function(){
if(this.isSlid || this.el.hasActiveFx()){
return;
}
this.isSlid = true;
var ts = this.panel.tools, dh, pc;
if(ts && ts.toggle){
ts.toggle.hide();
}
this.el.show();
pc = this.panel.collapsed;
this.panel.collapsed = false;
if(this.position == 'east' || this.position == 'west'){
dh = this.panel.deferHeight;
this.panel.deferHeight = false;
this.panel.setSize(undefined, this.collapsedEl.getHeight());
this.panel.deferHeight = dh;
}else{
this.panel.setSize(this.collapsedEl.getWidth(), undefined);
}
this.panel.collapsed = pc;
this.restoreLT = [this.el.dom.style.left, this.el.dom.style.top];
this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
this.el.setStyle("z-index", this.floatingZIndex+2);
this.panel.el.replaceClass('x-panel-collapsed', 'x-panel-floating');
if(this.animFloat !== false){
this.beforeSlide();
this.el.slideIn(this.getSlideAnchor(), {
callback: function(){
this.afterSlide();
this.initAutoHide();
Ext.getDoc().on("click", this.slideInIf, this);
},
scope: this,
block: true
});
}else{
this.initAutoHide();
Ext.getDoc().on("click", this.slideInIf, this);
}
},
afterSlideIn : function(){
this.clearAutoHide();
this.isSlid = false;
this.clearMonitor();
this.el.setStyle("z-index", "");
this.panel.el.replaceClass('x-panel-floating', 'x-panel-collapsed');
this.el.dom.style.left = this.restoreLT[0];
this.el.dom.style.top = this.restoreLT[1];
var ts = this.panel.tools;
if(ts && ts.toggle){
ts.toggle.show();
}
},
slideIn : function(cb){
if(!this.isSlid || this.el.hasActiveFx()){
Ext.callback(cb);
return;
}
this.isSlid = false;
if(this.animFloat !== false){
this.beforeSlide();
this.el.slideOut(this.getSlideAnchor(), {
callback: function(){
this.el.hide();
this.afterSlide();
this.afterSlideIn();
Ext.callback(cb);
},
scope: this,
block: true
});
}else{
this.el.hide();
this.afterSlideIn();
}
},
slideInIf : function(e){
if(!e.within(this.el)){
this.slideIn();
}
},
anchors : {
"west" : "left",
"east" : "right",
"north" : "top",
"south" : "bottom"
},
sanchors : {
"west" : "l",
"east" : "r",
"north" : "t",
"south" : "b"
},
canchors : {
"west" : "tl-tr",
"east" : "tr-tl",
"north" : "tl-bl",
"south" : "bl-tl"
},
getAnchor : function(){
return this.anchors[this.position];
},
getCollapseAnchor : function(){
return this.canchors[this.position];
},
getSlideAnchor : function(){
return this.sanchors[this.position];
},
getAlignAdj : function(){
var cm = this.cmargins;
switch(this.position){
case "west":
return [0, 0];
break;
case "east":
return [0, 0];
break;
case "north":
return [0, 0];
break;
case "south":
return [0, 0];
break;
}
},
getExpandAdj : function(){
var c = this.collapsedEl, cm = this.cmargins;
switch(this.position){
case "west":
return [-(cm.right+c.getWidth()+cm.left), 0];
break;
case "east":
return [cm.right+c.getWidth()+cm.left, 0];
break;
case "north":
return [0, -(cm.top+cm.bottom+c.getHeight())];
break;
case "south":
return [0, cm.top+cm.bottom+c.getHeight()];
break;
}
},
destroy : function(){
if (this.autoHideSlideTask && this.autoHideSlideTask.cancel){
this.autoHideSlideTask.cancel();
}
Ext.destroyMembers(this, 'miniCollapsedEl', 'collapsedEl', 'expandToolEl');
}
};
Ext.layout.BorderLayout.SplitRegion = function(layout, config, pos){
Ext.layout.BorderLayout.SplitRegion.superclass.constructor.call(this, layout, config, pos);
this.applyLayout = this.applyFns[pos];
};
Ext.extend(Ext.layout.BorderLayout.SplitRegion, Ext.layout.BorderLayout.Region, {
splitTip : "Drag to resize.",
collapsibleSplitTip : "Drag to resize. Double click to hide.",
useSplitTips : false,
splitSettings : {
north : {
orientation: Ext.SplitBar.VERTICAL,
placement: Ext.SplitBar.TOP,
maxFn : 'getVMaxSize',
minProp: 'minHeight',
maxProp: 'maxHeight'
},
south : {
orientation: Ext.SplitBar.VERTICAL,
placement: Ext.SplitBar.BOTTOM,
maxFn : 'getVMaxSize',
minProp: 'minHeight',
maxProp: 'maxHeight'
},
east : {
orientation: Ext.SplitBar.HORIZONTAL,
placement: Ext.SplitBar.RIGHT,
maxFn : 'getHMaxSize',
minProp: 'minWidth',
maxProp: 'maxWidth'
},
west : {
orientation: Ext.SplitBar.HORIZONTAL,
placement: Ext.SplitBar.LEFT,
maxFn : 'getHMaxSize',
minProp: 'minWidth',
maxProp: 'maxWidth'
}
},
applyFns : {
west : function(box){
if(this.isCollapsed){
return this.applyLayoutCollapsed(box);
}
var sd = this.splitEl.dom, s = sd.style;
this.panel.setPosition(box.x, box.y);
var sw = sd.offsetWidth;
s.left = (box.x+box.width-sw)+'px';
s.top = (box.y)+'px';
s.height = Math.max(0, box.height)+'px';
this.panel.setSize(box.width-sw, box.height);
},
east : function(box){
if(this.isCollapsed){
return this.applyLayoutCollapsed(box);
}
var sd = this.splitEl.dom, s = sd.style;
var sw = sd.offsetWidth;
this.panel.setPosition(box.x+sw, box.y);
s.left = (box.x)+'px';
s.top = (box.y)+'px';
s.height = Math.max(0, box.height)+'px';
this.panel.setSize(box.width-sw, box.height);
},
north : function(box){
if(this.isCollapsed){
return this.applyLayoutCollapsed(box);
}
var sd = this.splitEl.dom, s = sd.style;
var sh = sd.offsetHeight;
this.panel.setPosition(box.x, box.y);
s.left = (box.x)+'px';
s.top = (box.y+box.height-sh)+'px';
s.width = Math.max(0, box.width)+'px';
this.panel.setSize(box.width, box.height-sh);
},
south : function(box){
if(this.isCollapsed){
return this.applyLayoutCollapsed(box);
}
var sd = this.splitEl.dom, s = sd.style;
var sh = sd.offsetHeight;
this.panel.setPosition(box.x, box.y+sh);
s.left = (box.x)+'px';
s.top = (box.y)+'px';
s.width = Math.max(0, box.width)+'px';
this.panel.setSize(box.width, box.height-sh);
}
},
render : function(ct, p){
Ext.layout.BorderLayout.SplitRegion.superclass.render.call(this, ct, p);
var ps = this.position;
this.splitEl = ct.createChild({
cls: "x-layout-split x-layout-split-"+ps, html: "&#160;",
id: this.panel.id + '-xsplit'
});
if(this.collapseMode == 'mini'){
this.miniSplitEl = this.splitEl.createChild({
cls: "x-layout-mini x-layout-mini-"+ps, html: "&#160;"
});
this.miniSplitEl.addClassOnOver('x-layout-mini-over');
this.miniSplitEl.on('click', this.onCollapseClick, this, {stopEvent:true});
}
var s = this.splitSettings[ps];
this.split = new Ext.SplitBar(this.splitEl.dom, p.el, s.orientation);
this.split.tickSize = this.tickSize;
this.split.placement = s.placement;
this.split.getMaximumSize = this[s.maxFn].createDelegate(this);
this.split.minSize = this.minSize || this[s.minProp];
this.split.on("beforeapply", this.onSplitMove, this);
this.split.useShim = this.useShim === true;
this.maxSize = this.maxSize || this[s.maxProp];
if(p.hidden){
this.splitEl.hide();
}
if(this.useSplitTips){
this.splitEl.dom.title = this.collapsible ? this.collapsibleSplitTip : this.splitTip;
}
if(this.collapsible){
this.splitEl.on("dblclick", this.onCollapseClick, this);
}
},
getSize : function(){
if(this.isCollapsed){
return this.collapsedEl.getSize();
}
var s = this.panel.getSize();
if(this.position == 'north' || this.position == 'south'){
s.height += this.splitEl.dom.offsetHeight;
}else{
s.width += this.splitEl.dom.offsetWidth;
}
return s;
},
getHMaxSize : function(){
var cmax = this.maxSize || 10000;
var center = this.layout.center;
return Math.min(cmax, (this.el.getWidth()+center.el.getWidth())-center.getMinWidth());
},
getVMaxSize : function(){
var cmax = this.maxSize || 10000;
var center = this.layout.center;
return Math.min(cmax, (this.el.getHeight()+center.el.getHeight())-center.getMinHeight());
},
onSplitMove : function(split, newSize){
var s = this.panel.getSize();
this.lastSplitSize = newSize;
if(this.position == 'north' || this.position == 'south'){
this.panel.setSize(s.width, newSize);
this.state.height = newSize;
}else{
this.panel.setSize(newSize, s.height);
this.state.width = newSize;
}
this.layout.layout();
this.panel.saveState();
return false;
},
getSplitBar : function(){
return this.split;
},
destroy : function() {
Ext.destroy(this.miniSplitEl, this.split, this.splitEl);
Ext.layout.BorderLayout.SplitRegion.superclass.destroy.call(this);
}
});
Ext.Container.LAYOUTS['border'] = Ext.layout.BorderLayout;
Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, {
labelSeparator : ':',
trackLabels: true,
type: 'form',
onRemove: function(c){
Ext.layout.FormLayout.superclass.onRemove.call(this, c);
if(this.trackLabels){
c.un('show', this.onFieldShow, this);
c.un('hide', this.onFieldHide, this);
}
var el = c.getPositionEl(),
ct = c.getItemCt && c.getItemCt();
if (c.rendered && ct) {
if (el && el.dom) {
el.insertAfter(ct);
}
Ext.destroy(ct);
Ext.destroyMembers(c, 'label', 'itemCt');
if (c.customItemCt) {
Ext.destroyMembers(c, 'getItemCt', 'customItemCt');
}
}
},
setContainer : function(ct){
Ext.layout.FormLayout.superclass.setContainer.call(this, ct);
if(ct.labelAlign){
ct.addClass('x-form-label-'+ct.labelAlign);
}
if(ct.hideLabels){
Ext.apply(this, {
labelStyle: 'display:none',
elementStyle: 'padding-left:0;',
labelAdjust: 0
});
}else{
this.labelSeparator = Ext.isDefined(ct.labelSeparator) ? ct.labelSeparator : this.labelSeparator;
ct.labelWidth = ct.labelWidth || 100;
if(Ext.isNumber(ct.labelWidth)){
var pad = Ext.isNumber(ct.labelPad) ? ct.labelPad : 5;
Ext.apply(this, {
labelAdjust: ct.labelWidth + pad,
labelStyle: 'width:' + ct.labelWidth + 'px;',
elementStyle: 'padding-left:' + (ct.labelWidth + pad) + 'px'
});
}
if(ct.labelAlign == 'top'){
Ext.apply(this, {
labelStyle: 'width:auto;',
labelAdjust: 0,
elementStyle: 'padding-left:0;'
});
}
}
},
isHide: function(c){
return c.hideLabel || this.container.hideLabels;
},
onFieldShow: function(c){
c.getItemCt().removeClass('x-hide-' + c.hideMode);
if (c.isComposite) {
c.doLayout();
}
},
onFieldHide: function(c){
c.getItemCt().addClass('x-hide-' + c.hideMode);
},
getLabelStyle: function(s){
var ls = '', items = [this.labelStyle, s];
for (var i = 0, len = items.length; i < len; ++i){
if (items[i]){
ls += items[i];
if (ls.substr(-1, 1) != ';'){
ls += ';';
}
}
}
return ls;
},
renderItem : function(c, position, target){
if(c && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){
var args = this.getTemplateArgs(c);
if(Ext.isNumber(position)){
position = target.dom.childNodes[position] || null;
}
if(position){
c.itemCt = this.fieldTpl.insertBefore(position, args, true);
}else{
c.itemCt = this.fieldTpl.append(target, args, true);
}
if(!c.getItemCt){
Ext.apply(c, {
getItemCt: function(){
return c.itemCt;
},
customItemCt: true
});
}
c.label = c.getItemCt().child('label.x-form-item-label');
if(!c.rendered){
c.render('x-form-el-' + c.id);
}else if(!this.isValidParent(c, target)){
Ext.fly('x-form-el-' + c.id).appendChild(c.getPositionEl());
}
if(this.trackLabels){
if(c.hidden){
this.onFieldHide(c);
}
c.on({
scope: this,
show: this.onFieldShow,
hide: this.onFieldHide
});
}
this.configureItem(c);
}else {
Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
}
},
getTemplateArgs: function(field) {
var noLabelSep = !field.fieldLabel || field.hideLabel,
itemCls = (field.itemCls || this.container.itemCls || '') + (field.hideLabel ? ' x-hide-label' : '');
if (Ext.isIE9 && Ext.isIEQuirks && field instanceof Ext.form.TextField) {
itemCls += ' x-input-wrapper';
}
return {
id : field.id,
label : field.fieldLabel,
itemCls : itemCls,
clearCls : field.clearCls || 'x-form-clear-left',
labelStyle : this.getLabelStyle(field.labelStyle),
elementStyle : this.elementStyle || '',
labelSeparator: noLabelSep ? '' : (Ext.isDefined(field.labelSeparator) ? field.labelSeparator : this.labelSeparator)
};
},
adjustWidthAnchor: function(value, c){
if(c.label && !this.isHide(c) && (this.container.labelAlign != 'top')){
var adjust = Ext.isIE6 || (Ext.isIE && !Ext.isStrict);
return value - this.labelAdjust + (adjust ? -3 : 0);
}
return value;
},
adjustHeightAnchor : function(value, c){
if(c.label && !this.isHide(c) && (this.container.labelAlign == 'top')){
return value - c.label.getHeight();
}
return value;
},
isValidParent : function(c, target){
return target && this.container.getEl().contains(c.getPositionEl());
}
});
Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout;
Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {
fill : true,
autoWidth : true,
titleCollapse : true,
hideCollapseTool : false,
collapseFirst : false,
animate : false,
sequence : false,
activeOnTop : false,
type: 'accordion',
renderItem : function(c){
if(this.animate === false){
c.animCollapse = false;
}
c.collapsible = true;
if(this.autoWidth){
c.autoWidth = true;
}
if(this.titleCollapse){
c.titleCollapse = true;
}
if(this.hideCollapseTool){
c.hideCollapseTool = true;
}
if(this.collapseFirst !== undefined){
c.collapseFirst = this.collapseFirst;
}
if(!this.activeItem && !c.collapsed){
this.setActiveItem(c, true);
}else if(this.activeItem && this.activeItem != c){
c.collapsed = true;
}
Ext.layout.AccordionLayout.superclass.renderItem.apply(this, arguments);
c.header.addClass('x-accordion-hd');
c.on('beforeexpand', this.beforeExpand, this);
},
onRemove: function(c){
Ext.layout.AccordionLayout.superclass.onRemove.call(this, c);
if(c.rendered){
c.header.removeClass('x-accordion-hd');
}
c.un('beforeexpand', this.beforeExpand, this);
},
beforeExpand : function(p, anim){
var ai = this.activeItem;
if(ai){
if(this.sequence){
delete this.activeItem;
if (!ai.collapsed){
ai.collapse({callback:function(){
p.expand(anim || true);
}, scope: this});
return false;
}
}else{
ai.collapse(this.animate);
}
}
this.setActive(p);
if(this.activeOnTop){
p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);
}
this.layout();
},
setItemSize : function(item, size){
if(this.fill && item){
var hh = 0, i, ct = this.getRenderedItems(this.container), len = ct.length, p;
for (i = 0; i < len; i++) {
if((p = ct[i]) != item && !p.hidden){
hh += p.header.getHeight();
}
};
size.height -= hh;
item.setSize(size);
}
},
setActiveItem : function(item){
this.setActive(item, true);
},
setActive : function(item, expand){
var ai = this.activeItem;
item = this.container.getComponent(item);
if(ai != item){
if(item.rendered && item.collapsed && expand){
item.expand();
}else{
if(ai){
ai.fireEvent('deactivate', ai);
}
this.activeItem = item;
item.fireEvent('activate', item);
}
}
}
});
Ext.Container.LAYOUTS.accordion = Ext.layout.AccordionLayout;
Ext.layout.Accordion = Ext.layout.AccordionLayout;
Ext.layout.TableLayout = Ext.extend(Ext.layout.ContainerLayout, {
monitorResize:false,
type: 'table',
targetCls: 'x-table-layout-ct',
tableAttrs:null,
setContainer : function(ct){
Ext.layout.TableLayout.superclass.setContainer.call(this, ct);
this.currentRow = 0;
this.currentColumn = 0;
this.cells = [];
},
onLayout : function(ct, target){
var cs = ct.items.items, len = cs.length, c, i;
if(!this.table){
target.addClass('x-table-layout-ct');
this.table = target.createChild(
Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), null, true);
}
this.renderAll(ct, target);
},
getRow : function(index){
var row = this.table.tBodies[0].childNodes[index];
if(!row){
row = document.createElement('tr');
this.table.tBodies[0].appendChild(row);
}
return row;
},
getNextCell : function(c){
var cell = this.getNextNonSpan(this.currentColumn, this.currentRow);
var curCol = this.currentColumn = cell[0], curRow = this.currentRow = cell[1];
for(var rowIndex = curRow; rowIndex < curRow + (c.rowspan || 1); rowIndex++){
if(!this.cells[rowIndex]){
this.cells[rowIndex] = [];
}
for(var colIndex = curCol; colIndex < curCol + (c.colspan || 1); colIndex++){
this.cells[rowIndex][colIndex] = true;
}
}
var td = document.createElement('td');
if(c.cellId){
td.id = c.cellId;
}
var cls = 'x-table-layout-cell';
if(c.cellCls){
cls += ' ' + c.cellCls;
}
td.className = cls;
if(c.colspan){
td.colSpan = c.colspan;
}
if(c.rowspan){
td.rowSpan = c.rowspan;
}
this.getRow(curRow).appendChild(td);
return td;
},
getNextNonSpan: function(colIndex, rowIndex){
var cols = this.columns;
while((cols && colIndex >= cols) || (this.cells[rowIndex] && this.cells[rowIndex][colIndex])) {
if(cols && colIndex >= cols){
rowIndex++;
colIndex = 0;
}else{
colIndex++;
}
}
return [colIndex, rowIndex];
},
renderItem : function(c, position, target){
if(!this.table){
this.table = target.createChild(
Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), null, true);
}
if(c && !c.rendered){
c.render(this.getNextCell(c));
this.configureItem(c);
}else if(c && !this.isValidParent(c, target)){
var container = this.getNextCell(c);
container.insertBefore(c.getPositionEl().dom, null);
c.container = Ext.get(container);
this.configureItem(c);
}
},
isValidParent : function(c, target){
return c.getPositionEl().up('table', 5).dom.parentNode === (target.dom || target);
},
destroy: function(){
delete this.table;
Ext.layout.TableLayout.superclass.destroy.call(this);
}
});
Ext.Container.LAYOUTS['table'] = Ext.layout.TableLayout;
Ext.layout.AbsoluteLayout = Ext.extend(Ext.layout.AnchorLayout, {
extraCls: 'x-abs-layout-item',
type: 'absolute',
onLayout : function(ct, target){
target.position();
this.paddingLeft = target.getPadding('l');
this.paddingTop = target.getPadding('t');
Ext.layout.AbsoluteLayout.superclass.onLayout.call(this, ct, target);
},
adjustWidthAnchor : function(value, comp){
return value ? value - comp.getPosition(true)[0] + this.paddingLeft : value;
},
adjustHeightAnchor : function(value, comp){
return value ? value - comp.getPosition(true)[1] + this.paddingTop : value;
}
});
Ext.Container.LAYOUTS['absolute'] = Ext.layout.AbsoluteLayout;
Ext.layout.BoxLayout = Ext.extend(Ext.layout.ContainerLayout, {
defaultMargins : {left:0,top:0,right:0,bottom:0},
padding : '0',
pack : 'start',
monitorResize : true,
type: 'box',
scrollOffset : 0,
extraCls : 'x-box-item',
targetCls : 'x-box-layout-ct',
innerCls : 'x-box-inner',
constructor : function(config){
Ext.layout.BoxLayout.superclass.constructor.call(this, config);
if (Ext.isString(this.defaultMargins)) {
this.defaultMargins = this.parseMargins(this.defaultMargins);
}
var handler = this.overflowHandler;
if (typeof handler == 'string') {
handler = {
type: handler
};
}
var handlerType = 'none';
if (handler && handler.type != undefined) {
handlerType = handler.type;
}
var constructor = Ext.layout.boxOverflow[handlerType];
if (constructor[this.type]) {
constructor = constructor[this.type];
}
this.overflowHandler = new constructor(this, handler);
},
onLayout: function(container, target) {
Ext.layout.BoxLayout.superclass.onLayout.call(this, container, target);
var tSize = this.getLayoutTargetSize(),
items = this.getVisibleItems(container),
calcs = this.calculateChildBoxes(items, tSize),
boxes = calcs.boxes,
meta = calcs.meta;
if (tSize.width > 0) {
var handler = this.overflowHandler,
method = meta.tooNarrow ? 'handleOverflow' : 'clearOverflow';
var results = handler[method](calcs, tSize);
if (results) {
if (results.targetSize) {
tSize = results.targetSize;
}
if (results.recalculate) {
items = this.getVisibleItems(container);
calcs = this.calculateChildBoxes(items, tSize);
boxes = calcs.boxes;
}
}
}
this.layoutTargetLastSize = tSize;
this.childBoxCache = calcs;
this.updateInnerCtSize(tSize, calcs);
this.updateChildBoxes(boxes);
this.handleTargetOverflow(tSize, container, target);
},
updateChildBoxes: function(boxes) {
for (var i = 0, length = boxes.length; i < length; i++) {
var box = boxes[i],
comp = box.component;
if (box.dirtySize) {
comp.setSize(box.width, box.height);
}
if (isNaN(box.left) || isNaN(box.top)) {
continue;
}
comp.setPosition(box.left, box.top);
}
},
updateInnerCtSize: function(tSize, calcs) {
var align = this.align,
padding = this.padding,
width = tSize.width,
height = tSize.height;
if (this.type == 'hbox') {
var innerCtWidth = width,
innerCtHeight = calcs.meta.maxHeight + padding.top + padding.bottom;
if (align == 'stretch') {
innerCtHeight = height;
} else if (align == 'middle') {
innerCtHeight = Math.max(height, innerCtHeight);
}
} else {
var innerCtHeight = height,
innerCtWidth = calcs.meta.maxWidth + padding.left + padding.right;
if (align == 'stretch') {
innerCtWidth = width;
} else if (align == 'center') {
innerCtWidth = Math.max(width, innerCtWidth);
}
}
this.innerCt.setSize(innerCtWidth || undefined, innerCtHeight || undefined);
},
handleTargetOverflow: function(previousTargetSize, container, target) {
var overflow = target.getStyle('overflow');
if (overflow && overflow != 'hidden' &&!this.adjustmentPass) {
var newTargetSize = this.getLayoutTargetSize();
if (newTargetSize.width != previousTargetSize.width || newTargetSize.height != previousTargetSize.height){
this.adjustmentPass = true;
this.onLayout(container, target);
}
}
delete this.adjustmentPass;
},
isValidParent : function(c, target) {
return this.innerCt && c.getPositionEl().dom.parentNode == this.innerCt.dom;
},
getVisibleItems: function(ct) {
var ct = ct || this.container,
t = ct.getLayoutTarget(),
cti = ct.items.items,
len = cti.length,
i, c, items = [];
for (i = 0; i < len; i++) {
if((c = cti[i]).rendered && this.isValidParent(c, t) && c.hidden !== true && c.collapsed !== true && c.shouldLayout !== false){
items.push(c);
}
}
return items;
},
renderAll : function(ct, target) {
if (!this.innerCt) {
this.innerCt = target.createChild({cls:this.innerCls});
this.padding = this.parseMargins(this.padding);
}
Ext.layout.BoxLayout.superclass.renderAll.call(this, ct, this.innerCt);
},
getLayoutTargetSize : function() {
var target = this.container.getLayoutTarget(), ret;
if (target) {
ret = target.getViewSize();
if (Ext.isIE && Ext.isStrict && ret.width == 0){
ret = target.getStyleSize();
}
ret.width -= target.getPadding('lr');
ret.height -= target.getPadding('tb');
}
return ret;
},
renderItem : function(c) {
if(Ext.isString(c.margins)){
c.margins = this.parseMargins(c.margins);
}else if(!c.margins){
c.margins = this.defaultMargins;
}
Ext.layout.BoxLayout.superclass.renderItem.apply(this, arguments);
},
destroy: function() {
Ext.destroy(this.overflowHandler);
Ext.layout.BoxLayout.superclass.destroy.apply(this, arguments);
}
});
Ext.layout.boxOverflow.None = Ext.extend(Object, {
constructor: function(layout, config) {
this.layout = layout;
Ext.apply(this, config || {});
},
handleOverflow: Ext.emptyFn,
clearOverflow: Ext.emptyFn
});
Ext.layout.boxOverflow.none = Ext.layout.boxOverflow.None;
Ext.layout.boxOverflow.Menu = Ext.extend(Ext.layout.boxOverflow.None, {
afterCls: 'x-strip-right',
noItemsMenuText : '<div class="x-toolbar-no-items">(None)</div>',
constructor: function(layout) {
Ext.layout.boxOverflow.Menu.superclass.constructor.apply(this, arguments);
this.menuItems = [];
},
createInnerElements: function() {
if (!this.afterCt) {
this.afterCt = this.layout.innerCt.insertSibling({cls: this.afterCls}, 'before');
}
},
clearOverflow: function(calculations, targetSize) {
var newWidth = targetSize.width + (this.afterCt ? this.afterCt.getWidth() : 0),
items = this.menuItems;
this.hideTrigger();
for (var index = 0, length = items.length; index < length; index++) {
items.pop().component.show();
}
return {
targetSize: {
height: targetSize.height,
width : newWidth
}
};
},
showTrigger: function() {
this.createMenu();
this.menuTrigger.show();
},
hideTrigger: function() {
if (this.menuTrigger != undefined) {
this.menuTrigger.hide();
}
},
beforeMenuShow: function(menu) {
var items = this.menuItems,
len = items.length,
item,
prev;
var needsSep = function(group, item){
return group.isXType('buttongroup') && !(item instanceof Ext.Toolbar.Separator);
};
this.clearMenu();
menu.removeAll();
for (var i = 0; i < len; i++) {
item = items[i].component;
if (prev && (needsSep(item, prev) || needsSep(prev, item))) {
menu.add('-');
}
this.addComponentToMenu(menu, item);
prev = item;
}
if (menu.items.length < 1) {
menu.add(this.noItemsMenuText);
}
},
createMenuConfig : function(component, hideOnClick){
var config = Ext.apply({}, component.initialConfig),
group = component.toggleGroup;
Ext.copyTo(config, component, [
'iconCls', 'icon', 'itemId', 'disabled', 'handler', 'scope', 'menu'
]);
Ext.apply(config, {
text : component.overflowText || component.text,
hideOnClick: hideOnClick
});
if (group || component.enableToggle) {
Ext.apply(config, {
group : group,
checked: component.pressed,
listeners: {
checkchange: function(item, checked){
component.toggle(checked);
}
}
});
}
delete config.ownerCt;
delete config.xtype;
delete config.id;
return config;
},
addComponentToMenu : function(menu, component) {
if (component instanceof Ext.Toolbar.Separator) {
menu.add('-');
} else if (Ext.isFunction(component.isXType)) {
if (component.isXType('splitbutton')) {
menu.add(this.createMenuConfig(component, true));
} else if (component.isXType('button')) {
menu.add(this.createMenuConfig(component, !component.menu));
} else if (component.isXType('buttongroup')) {
component.items.each(function(item){
this.addComponentToMenu(menu, item);
}, this);
}
}
},
clearMenu : function(){
var menu = this.moreMenu;
if (menu && menu.items) {
menu.items.each(function(item){
delete item.menu;
});
}
},
createMenu: function() {
if (!this.menuTrigger) {
this.createInnerElements();
this.menu = new Ext.menu.Menu({
ownerCt : this.layout.container,
listeners: {
scope: this,
beforeshow: this.beforeMenuShow
}
});
this.menuTrigger = new Ext.Button({
iconCls : 'x-toolbar-more-icon',
cls : 'x-toolbar-more',
menu : this.menu,
renderTo: this.afterCt
});
}
},
destroy: function() {
Ext.destroy(this.menu, this.menuTrigger);
}
});
Ext.layout.boxOverflow.menu = Ext.layout.boxOverflow.Menu;
Ext.layout.boxOverflow.HorizontalMenu = Ext.extend(Ext.layout.boxOverflow.Menu, {
constructor: function() {
Ext.layout.boxOverflow.HorizontalMenu.superclass.constructor.apply(this, arguments);
var me = this,
layout = me.layout,
origFunction = layout.calculateChildBoxes;
layout.calculateChildBoxes = function(visibleItems, targetSize) {
var calcs = origFunction.apply(layout, arguments),
meta = calcs.meta,
items = me.menuItems;
var hiddenWidth = 0;
for (var index = 0, length = items.length; index < length; index++) {
hiddenWidth += items[index].width;
}
meta.minimumWidth += hiddenWidth;
meta.tooNarrow = meta.minimumWidth > targetSize.width;
return calcs;
};
},
handleOverflow: function(calculations, targetSize) {
this.showTrigger();
var newWidth = targetSize.width - this.afterCt.getWidth(),
boxes = calculations.boxes,
usedWidth = 0,
recalculate = false;
for (var index = 0, length = boxes.length; index < length; index++) {
usedWidth += boxes[index].width;
}
var spareWidth = newWidth - usedWidth,
showCount = 0;
for (var index = 0, length = this.menuItems.length; index < length; index++) {
var hidden = this.menuItems[index],
comp = hidden.component,
width = hidden.width;
if (width < spareWidth) {
comp.show();
spareWidth -= width;
showCount ++;
recalculate = true;
} else {
break;
}
}
if (recalculate) {
this.menuItems = this.menuItems.slice(showCount);
} else {
for (var i = boxes.length - 1; i >= 0; i--) {
var item = boxes[i].component,
right = boxes[i].left + boxes[i].width;
if (right >= newWidth) {
this.menuItems.unshift({
component: item,
width : boxes[i].width
});
item.hide();
} else {
break;
}
}
}
if (this.menuItems.length == 0) {
this.hideTrigger();
}
return {
targetSize: {
height: targetSize.height,
width : newWidth
},
recalculate: recalculate
};
}
});
Ext.layout.boxOverflow.menu.hbox = Ext.layout.boxOverflow.HorizontalMenu;
Ext.layout.boxOverflow.Scroller = Ext.extend(Ext.layout.boxOverflow.None, {
animateScroll: true,
scrollIncrement: 100,
wheelIncrement: 3,
scrollRepeatInterval: 400,
scrollDuration: 0.4,
beforeCls: 'x-strip-left',
afterCls: 'x-strip-right',
scrollerCls: 'x-strip-scroller',
beforeScrollerCls: 'x-strip-scroller-left',
afterScrollerCls: 'x-strip-scroller-right',
createWheelListener: function() {
this.layout.innerCt.on({
scope : this,
mousewheel: function(e) {
e.stopEvent();
this.scrollBy(e.getWheelDelta() * this.wheelIncrement * -1, false);
}
});
},
handleOverflow: function(calculations, targetSize) {
this.createInnerElements();
this.showScrollers();
},
clearOverflow: function() {
this.hideScrollers();
},
showScrollers: function() {
this.createScrollers();
this.beforeScroller.show();
this.afterScroller.show();
this.updateScrollButtons();
},
hideScrollers: function() {
if (this.beforeScroller != undefined) {
this.beforeScroller.hide();
this.afterScroller.hide();
}
},
createScrollers: function() {
if (!this.beforeScroller && !this.afterScroller) {
var before = this.beforeCt.createChild({
cls: String.format("{0} {1} ", this.scrollerCls, this.beforeScrollerCls)
});
var after = this.afterCt.createChild({
cls: String.format("{0} {1}", this.scrollerCls, this.afterScrollerCls)
});
before.addClassOnOver(this.beforeScrollerCls + '-hover');
after.addClassOnOver(this.afterScrollerCls + '-hover');
before.setVisibilityMode(Ext.Element.DISPLAY);
after.setVisibilityMode(Ext.Element.DISPLAY);
this.beforeRepeater = new Ext.util.ClickRepeater(before, {
interval: this.scrollRepeatInterval,
handler : this.scrollLeft,
scope : this
});
this.afterRepeater = new Ext.util.ClickRepeater(after, {
interval: this.scrollRepeatInterval,
handler : this.scrollRight,
scope : this
});
this.beforeScroller = before;
this.afterScroller = after;
}
},
destroy: function() {
Ext.destroy(this.beforeScroller, this.afterScroller, this.beforeRepeater, this.afterRepeater, this.beforeCt, this.afterCt);
},
scrollBy: function(delta, animate) {
this.scrollTo(this.getScrollPosition() + delta, animate);
},
getItem: function(item) {
if (Ext.isString(item)) {
item = Ext.getCmp(item);
} else if (Ext.isNumber(item)) {
item = this.items[item];
}
return item;
},
getScrollAnim: function() {
return {
duration: this.scrollDuration,
callback: this.updateScrollButtons,
scope : this
};
},
updateScrollButtons: function() {
if (this.beforeScroller == undefined || this.afterScroller == undefined) {
return;
}
var beforeMeth = this.atExtremeBefore() ? 'addClass' : 'removeClass',
afterMeth = this.atExtremeAfter() ? 'addClass' : 'removeClass',
beforeCls = this.beforeScrollerCls + '-disabled',
afterCls = this.afterScrollerCls + '-disabled';
this.beforeScroller[beforeMeth](beforeCls);
this.afterScroller[afterMeth](afterCls);
this.scrolling = false;
},
atExtremeBefore: function() {
return this.getScrollPosition() === 0;
},
scrollLeft: function(animate) {
this.scrollBy(-this.scrollIncrement, animate);
},
scrollRight: function(animate) {
this.scrollBy(this.scrollIncrement, animate);
},
scrollToItem: function(item, animate) {
item = this.getItem(item);
if (item != undefined) {
var visibility = this.getItemVisibility(item);
if (!visibility.fullyVisible) {
var box = item.getBox(true, true),
newX = box.x;
if (visibility.hiddenRight) {
newX -= (this.layout.innerCt.getWidth() - box.width);
}
this.scrollTo(newX, animate);
}
}
},
getItemVisibility: function(item) {
var box = this.getItem(item).getBox(true, true),
itemLeft = box.x,
itemRight = box.x + box.width,
scrollLeft = this.getScrollPosition(),
scrollRight = this.layout.innerCt.getWidth() + scrollLeft;
return {
hiddenLeft : itemLeft < scrollLeft,
hiddenRight : itemRight > scrollRight,
fullyVisible: itemLeft > scrollLeft && itemRight < scrollRight
};
}
});
Ext.layout.boxOverflow.scroller = Ext.layout.boxOverflow.Scroller;
Ext.layout.boxOverflow.VerticalScroller = Ext.extend(Ext.layout.boxOverflow.Scroller, {
scrollIncrement: 75,
wheelIncrement : 2,
handleOverflow: function(calculations, targetSize) {
Ext.layout.boxOverflow.VerticalScroller.superclass.handleOverflow.apply(this, arguments);
return {
targetSize: {
height: targetSize.height - (this.beforeCt.getHeight() + this.afterCt.getHeight()),
width : targetSize.width
}
};
},
createInnerElements: function() {
var target = this.layout.innerCt;
if (!this.beforeCt) {
this.beforeCt = target.insertSibling({cls: this.beforeCls}, 'before');
this.afterCt = target.insertSibling({cls: this.afterCls}, 'after');
this.createWheelListener();
}
},
scrollTo: function(position, animate) {
var oldPosition = this.getScrollPosition(),
newPosition = position.constrain(0, this.getMaxScrollBottom());
if (newPosition != oldPosition && !this.scrolling) {
if (animate == undefined) {
animate = this.animateScroll;
}
this.layout.innerCt.scrollTo('top', newPosition, animate ? this.getScrollAnim() : false);
if (animate) {
this.scrolling = true;
} else {
this.scrolling = false;
this.updateScrollButtons();
}
}
},
getScrollPosition: function(){
return parseInt(this.layout.innerCt.dom.scrollTop, 10) || 0;
},
getMaxScrollBottom: function() {
return this.layout.innerCt.dom.scrollHeight - this.layout.innerCt.getHeight();
},
atExtremeAfter: function() {
return this.getScrollPosition() >= this.getMaxScrollBottom();
}
});
Ext.layout.boxOverflow.scroller.vbox = Ext.layout.boxOverflow.VerticalScroller;
Ext.layout.boxOverflow.HorizontalScroller = Ext.extend(Ext.layout.boxOverflow.Scroller, {
handleOverflow: function(calculations, targetSize) {
Ext.layout.boxOverflow.HorizontalScroller.superclass.handleOverflow.apply(this, arguments);
return {
targetSize: {
height: targetSize.height,
width : targetSize.width - (this.beforeCt.getWidth() + this.afterCt.getWidth())
}
};
},
createInnerElements: function() {
var target = this.layout.innerCt;
if (!this.beforeCt) {
this.afterCt = target.insertSibling({cls: this.afterCls}, 'before');
this.beforeCt = target.insertSibling({cls: this.beforeCls}, 'before');
this.createWheelListener();
}
},
scrollTo: function(position, animate) {
var oldPosition = this.getScrollPosition(),
newPosition = position.constrain(0, this.getMaxScrollRight());
if (newPosition != oldPosition && !this.scrolling) {
if (animate == undefined) {
animate = this.animateScroll;
}
this.layout.innerCt.scrollTo('left', newPosition, animate ? this.getScrollAnim() : false);
if (animate) {
this.scrolling = true;
} else {
this.scrolling = false;
this.updateScrollButtons();
}
}
},
getScrollPosition: function(){
return parseInt(this.layout.innerCt.dom.scrollLeft, 10) || 0;
},
getMaxScrollRight: function() {
return this.layout.innerCt.dom.scrollWidth - this.layout.innerCt.getWidth();
},
atExtremeAfter: function() {
return this.getScrollPosition() >= this.getMaxScrollRight();
}
});
Ext.layout.boxOverflow.scroller.hbox = Ext.layout.boxOverflow.HorizontalScroller;
Ext.layout.HBoxLayout = Ext.extend(Ext.layout.BoxLayout, {
align: 'top',
type : 'hbox',
calculateChildBoxes: function(visibleItems, targetSize) {
var visibleCount = visibleItems.length,
padding = this.padding,
topOffset = padding.top,
leftOffset = padding.left,
paddingVert = topOffset + padding.bottom,
paddingHoriz = leftOffset + padding.right,
width = targetSize.width - this.scrollOffset,
height = targetSize.height,
availHeight = Math.max(0, height - paddingVert),
isStart = this.pack == 'start',
isCenter = this.pack == 'center',
isEnd = this.pack == 'end',
nonFlexWidth = 0,
maxHeight = 0,
totalFlex = 0,
desiredWidth = 0,
minimumWidth = 0,
boxes = [],
child, childWidth, childHeight, childSize, childMargins, canLayout, i, calcs, flexedWidth,
horizMargins, vertMargins, stretchHeight;
for (i = 0; i < visibleCount; i++) {
child = visibleItems[i];
childHeight = child.height;
childWidth = child.width;
canLayout = !child.hasLayout && typeof child.doLayout == 'function';
if (typeof childWidth != 'number') {
if (child.flex && !childWidth) {
totalFlex += child.flex;
} else {
if (!childWidth && canLayout) {
child.doLayout();
}
childSize = child.getSize();
childWidth = childSize.width;
childHeight = childSize.height;
}
}
childMargins = child.margins;
horizMargins = childMargins.left + childMargins.right;
nonFlexWidth += horizMargins + (childWidth || 0);
desiredWidth += horizMargins + (child.flex ? child.minWidth || 0 : childWidth);
minimumWidth += horizMargins + (child.minWidth || childWidth || 0);
if (typeof childHeight != 'number') {
if (canLayout) {
child.doLayout();
}
childHeight = child.getHeight();
}
maxHeight = Math.max(maxHeight, childHeight + childMargins.top + childMargins.bottom);
boxes.push({
component: child,
height : childHeight || undefined,
width : childWidth || undefined
});
}
var shortfall = desiredWidth - width,
tooNarrow = minimumWidth > width;
var availableWidth = Math.max(0, width - nonFlexWidth - paddingHoriz);
if (tooNarrow) {
for (i = 0; i < visibleCount; i++) {
boxes[i].width = visibleItems[i].minWidth || visibleItems[i].width || boxes[i].width;
}
} else {
if (shortfall > 0) {
var minWidths = [];
for (var index = 0, length = visibleCount; index < length; index++) {
var item = visibleItems[index],
minWidth = item.minWidth || 0;
if (item.flex) {
boxes[index].width = minWidth;
} else {
minWidths.push({
minWidth : minWidth,
available: boxes[index].width - minWidth,
index : index
});
}
}
minWidths.sort(function(a, b) {
return a.available > b.available ? 1 : -1;
});
for (var i = 0, length = minWidths.length; i < length; i++) {
var itemIndex = minWidths[i].index;
if (itemIndex == undefined) {
continue;
}
var item = visibleItems[itemIndex],
box = boxes[itemIndex],
oldWidth = box.width,
minWidth = item.minWidth,
newWidth = Math.max(minWidth, oldWidth - Math.ceil(shortfall / (length - i))),
reduction = oldWidth - newWidth;
boxes[itemIndex].width = newWidth;
shortfall -= reduction;
}
} else {
var remainingWidth = availableWidth,
remainingFlex = totalFlex;
for (i = 0; i < visibleCount; i++) {
child = visibleItems[i];
calcs = boxes[i];
childMargins = child.margins;
vertMargins = childMargins.top + childMargins.bottom;
if (isStart && child.flex && !child.width) {
flexedWidth = Math.ceil((child.flex / remainingFlex) * remainingWidth);
remainingWidth -= flexedWidth;
remainingFlex -= child.flex;
calcs.width = flexedWidth;
calcs.dirtySize = true;
}
}
}
}
if (isCenter) {
leftOffset += availableWidth / 2;
} else if (isEnd) {
leftOffset += availableWidth;
}
for (i = 0; i < visibleCount; i++) {
child = visibleItems[i];
calcs = boxes[i];
childMargins = child.margins;
leftOffset += childMargins.left;
vertMargins = childMargins.top + childMargins.bottom;
calcs.left = leftOffset;
calcs.top = topOffset + childMargins.top;
switch (this.align) {
case 'stretch':
stretchHeight = availHeight - vertMargins;
calcs.height = stretchHeight.constrain(child.minHeight || 0, child.maxHeight || 1000000);
calcs.dirtySize = true;
break;
case 'stretchmax':
stretchHeight = maxHeight - vertMargins;
calcs.height = stretchHeight.constrain(child.minHeight || 0, child.maxHeight || 1000000);
calcs.dirtySize = true;
break;
case 'middle':
var diff = availHeight - calcs.height - vertMargins;
if (diff > 0) {
calcs.top = topOffset + vertMargins + (diff / 2);
}
}
leftOffset += calcs.width + childMargins.right;
}
return {
boxes: boxes,
meta : {
maxHeight : maxHeight,
nonFlexWidth: nonFlexWidth,
desiredWidth: desiredWidth,
minimumWidth: minimumWidth,
shortfall : desiredWidth - width,
tooNarrow : tooNarrow
}
};
}
});
Ext.Container.LAYOUTS.hbox = Ext.layout.HBoxLayout;
Ext.layout.VBoxLayout = Ext.extend(Ext.layout.BoxLayout, {
align : 'left',
type: 'vbox',
calculateChildBoxes: function(visibleItems, targetSize) {
var visibleCount = visibleItems.length,
padding = this.padding,
topOffset = padding.top,
leftOffset = padding.left,
paddingVert = topOffset + padding.bottom,
paddingHoriz = leftOffset + padding.right,
width = targetSize.width - this.scrollOffset,
height = targetSize.height,
availWidth = Math.max(0, width - paddingHoriz),
isStart = this.pack == 'start',
isCenter = this.pack == 'center',
isEnd = this.pack == 'end',
nonFlexHeight= 0,
maxWidth = 0,
totalFlex = 0,
desiredHeight= 0,
minimumHeight= 0,
boxes = [],
child, childWidth, childHeight, childSize, childMargins, canLayout, i, calcs, flexedHeight,
horizMargins, vertMargins, stretchWidth, length;
for (i = 0; i < visibleCount; i++) {
child = visibleItems[i];
childHeight = child.height;
childWidth = child.width;
canLayout = !child.hasLayout && typeof child.doLayout == 'function';
if (typeof childHeight != 'number') {
if (child.flex && !childHeight) {
totalFlex += child.flex;
} else {
if (!childHeight && canLayout) {
child.doLayout();
}
childSize = child.getSize();
childWidth = childSize.width;
childHeight = childSize.height;
}
}
childMargins = child.margins;
vertMargins = childMargins.top + childMargins.bottom;
nonFlexHeight += vertMargins + (childHeight || 0);
desiredHeight += vertMargins + (child.flex ? child.minHeight || 0 : childHeight);
minimumHeight += vertMargins + (child.minHeight || childHeight || 0);
if (typeof childWidth != 'number') {
if (canLayout) {
child.doLayout();
}
childWidth = child.getWidth();
}
maxWidth = Math.max(maxWidth, childWidth + childMargins.left + childMargins.right);
boxes.push({
component: child,
height : childHeight || undefined,
width : childWidth || undefined
});
}
var shortfall = desiredHeight - height,
tooNarrow = minimumHeight > height;
var availableHeight = Math.max(0, (height - nonFlexHeight - paddingVert));
if (tooNarrow) {
for (i = 0, length = visibleCount; i < length; i++) {
boxes[i].height = visibleItems[i].minHeight || visibleItems[i].height || boxes[i].height;
}
} else {
if (shortfall > 0) {
var minHeights = [];
for (var index = 0, length = visibleCount; index < length; index++) {
var item = visibleItems[index],
minHeight = item.minHeight || 0;
if (item.flex) {
boxes[index].height = minHeight;
} else {
minHeights.push({
minHeight: minHeight,
available: boxes[index].height - minHeight,
index : index
});
}
}
minHeights.sort(function(a, b) {
return a.available > b.available ? 1 : -1;
});
for (var i = 0, length = minHeights.length; i < length; i++) {
var itemIndex = minHeights[i].index;
if (itemIndex == undefined) {
continue;
}
var item = visibleItems[itemIndex],
box = boxes[itemIndex],
oldHeight = box.height,
minHeight = item.minHeight,
newHeight = Math.max(minHeight, oldHeight - Math.ceil(shortfall / (length - i))),
reduction = oldHeight - newHeight;
boxes[itemIndex].height = newHeight;
shortfall -= reduction;
}
} else {
var remainingHeight = availableHeight,
remainingFlex = totalFlex;
for (i = 0; i < visibleCount; i++) {
child = visibleItems[i];
calcs = boxes[i];
childMargins = child.margins;
horizMargins = childMargins.left + childMargins.right;
if (isStart && child.flex && !child.height) {
flexedHeight = Math.ceil((child.flex / remainingFlex) * remainingHeight);
remainingHeight -= flexedHeight;
remainingFlex -= child.flex;
calcs.height = flexedHeight;
calcs.dirtySize = true;
}
}
}
}
if (isCenter) {
topOffset += availableHeight / 2;
} else if (isEnd) {
topOffset += availableHeight;
}
for (i = 0; i < visibleCount; i++) {
child = visibleItems[i];
calcs = boxes[i];
childMargins = child.margins;
topOffset += childMargins.top;
horizMargins = childMargins.left + childMargins.right;
calcs.left = leftOffset + childMargins.left;
calcs.top = topOffset;
switch (this.align) {
case 'stretch':
stretchWidth = availWidth - horizMargins;
calcs.width = stretchWidth.constrain(child.minWidth || 0, child.maxWidth || 1000000);
calcs.dirtySize = true;
break;
case 'stretchmax':
stretchWidth = maxWidth - horizMargins;
calcs.width = stretchWidth.constrain(child.minWidth || 0, child.maxWidth || 1000000);
calcs.dirtySize = true;
break;
case 'center':
var diff = availWidth - calcs.width - horizMargins;
if (diff > 0) {
calcs.left = leftOffset + horizMargins + (diff / 2);
}
}
topOffset += calcs.height + childMargins.bottom;
}
return {
boxes: boxes,
meta : {
maxWidth : maxWidth,
nonFlexHeight: nonFlexHeight,
desiredHeight: desiredHeight,
minimumHeight: minimumHeight,
shortfall : desiredHeight - height,
tooNarrow : tooNarrow
}
};
}
});
Ext.Container.LAYOUTS.vbox = Ext.layout.VBoxLayout;
Ext.layout.ToolbarLayout = Ext.extend(Ext.layout.ContainerLayout, {
monitorResize : true,
type: 'toolbar',
triggerWidth: 18,
noItemsMenuText : '<div class="x-toolbar-no-items">(None)</div>',
lastOverflow: false,
tableHTML: [
'<table cellspacing="0" class="x-toolbar-ct">',
'<tbody>',
'<tr>',
'<td class="x-toolbar-left" align="{0}">',
'<table cellspacing="0">',
'<tbody>',
'<tr class="x-toolbar-left-row"></tr>',
'</tbody>',
'</table>',
'</td>',
'<td class="x-toolbar-right" align="right">',
'<table cellspacing="0" class="x-toolbar-right-ct">',
'<tbody>',
'<tr>',
'<td>',
'<table cellspacing="0">',
'<tbody>',
'<tr class="x-toolbar-right-row"></tr>',
'</tbody>',
'</table>',
'</td>',
'<td>',
'<table cellspacing="0">',
'<tbody>',
'<tr class="x-toolbar-extras-row"></tr>',
'</tbody>',
'</table>',
'</td>',
'</tr>',
'</tbody>',
'</table>',
'</td>',
'</tr>',
'</tbody>',
'</table>'
].join(""),
onLayout : function(ct, target) {
if (!this.leftTr) {
var align = ct.buttonAlign == 'center' ? 'center' : 'left';
target.addClass('x-toolbar-layout-ct');
target.insertHtml('beforeEnd', String.format(this.tableHTML, align));
this.leftTr = target.child('tr.x-toolbar-left-row', true);
this.rightTr = target.child('tr.x-toolbar-right-row', true);
this.extrasTr = target.child('tr.x-toolbar-extras-row', true);
if (this.hiddenItem == undefined) {
this.hiddenItems = [];
}
}
var side = ct.buttonAlign == 'right' ? this.rightTr : this.leftTr,
items = ct.items.items,
position = 0;
for (var i = 0, len = items.length, c; i < len; i++, position++) {
c = items[i];
if (c.isFill) {
side = this.rightTr;
position = -1;
} else if (!c.rendered) {
c.render(this.insertCell(c, side, position));
this.configureItem(c);
} else {
if (!c.xtbHidden && !this.isValidParent(c, side.childNodes[position])) {
var td = this.insertCell(c, side, position);
td.appendChild(c.getPositionEl().dom);
c.container = Ext.get(td);
}
}
}
this.cleanup(this.leftTr);
this.cleanup(this.rightTr);
this.cleanup(this.extrasTr);
this.fitToSize(target);
},
cleanup : function(el) {
var cn = el.childNodes, i, c;
for (i = cn.length-1; i >= 0 && (c = cn[i]); i--) {
if (!c.firstChild) {
el.removeChild(c);
}
}
},
insertCell : function(c, target, position) {
var td = document.createElement('td');
td.className = 'x-toolbar-cell';
target.insertBefore(td, target.childNodes[position] || null);
return td;
},
hideItem : function(item) {
this.hiddenItems.push(item);
item.xtbHidden = true;
item.xtbWidth = item.getPositionEl().dom.parentNode.offsetWidth;
item.hide();
},
unhideItem : function(item) {
item.show();
item.xtbHidden = false;
this.hiddenItems.remove(item);
},
getItemWidth : function(c) {
return c.hidden ? (c.xtbWidth || 0) : c.getPositionEl().dom.parentNode.offsetWidth;
},
fitToSize : function(target) {
if (this.container.enableOverflow === false) {
return;
}
var width = target.dom.clientWidth,
tableWidth = target.dom.firstChild.offsetWidth,
clipWidth = width - this.triggerWidth,
lastWidth = this.lastWidth || 0,
hiddenItems = this.hiddenItems,
hasHiddens = hiddenItems.length != 0,
isLarger = width >= lastWidth;
this.lastWidth = width;
if (tableWidth > width || (hasHiddens && isLarger)) {
var items = this.container.items.items,
len = items.length,
loopWidth = 0,
item;
for (var i = 0; i < len; i++) {
item = items[i];
if (!item.isFill) {
loopWidth += this.getItemWidth(item);
if (loopWidth > clipWidth) {
if (!(item.hidden || item.xtbHidden)) {
this.hideItem(item);
}
} else if (item.xtbHidden) {
this.unhideItem(item);
}
}
}
}
hasHiddens = hiddenItems.length != 0;
if (hasHiddens) {
this.initMore();
if (!this.lastOverflow) {
this.container.fireEvent('overflowchange', this.container, true);
this.lastOverflow = true;
}
} else if (this.more) {
this.clearMenu();
this.more.destroy();
delete this.more;
if (this.lastOverflow) {
this.container.fireEvent('overflowchange', this.container, false);
this.lastOverflow = false;
}
}
},
createMenuConfig : function(component, hideOnClick){
var config = Ext.apply({}, component.initialConfig),
group = component.toggleGroup;
Ext.copyTo(config, component, [
'iconCls', 'icon', 'itemId', 'disabled', 'handler', 'scope', 'menu'
]);
Ext.apply(config, {
text : component.overflowText || component.text,
hideOnClick: hideOnClick
});
if (group || component.enableToggle) {
Ext.apply(config, {
group : group,
checked: component.pressed,
listeners: {
checkchange: function(item, checked){
component.toggle(checked);
}
}
});
}
delete config.ownerCt;
delete config.xtype;
delete config.id;
return config;
},
addComponentToMenu : function(menu, component) {
if (component instanceof Ext.Toolbar.Separator) {
menu.add('-');
} else if (Ext.isFunction(component.isXType)) {
if (component.isXType('splitbutton')) {
menu.add(this.createMenuConfig(component, true));
} else if (component.isXType('button')) {
menu.add(this.createMenuConfig(component, !component.menu));
} else if (component.isXType('buttongroup')) {
component.items.each(function(item){
this.addComponentToMenu(menu, item);
}, this);
}
}
},
clearMenu : function(){
var menu = this.moreMenu;
if (menu && menu.items) {
menu.items.each(function(item){
delete item.menu;
});
}
},
beforeMoreShow : function(menu) {
var items = this.container.items.items,
len = items.length,
item,
prev;
var needsSep = function(group, item){
return group.isXType('buttongroup') && !(item instanceof Ext.Toolbar.Separator);
};
this.clearMenu();
menu.removeAll();
for (var i = 0; i < len; i++) {
item = items[i];
if (item.xtbHidden) {
if (prev && (needsSep(item, prev) || needsSep(prev, item))) {
menu.add('-');
}
this.addComponentToMenu(menu, item);
prev = item;
}
}
if (menu.items.length < 1) {
menu.add(this.noItemsMenuText);
}
},
initMore : function(){
if (!this.more) {
this.moreMenu = new Ext.menu.Menu({
ownerCt : this.container,
listeners: {
beforeshow: this.beforeMoreShow,
scope: this
}
});
this.more = new Ext.Button({
iconCls: 'x-toolbar-more-icon',
cls : 'x-toolbar-more',
menu : this.moreMenu,
ownerCt: this.container
});
var td = this.insertCell(this.more, this.extrasTr, 100);
this.more.render(td);
}
},
destroy : function(){
Ext.destroy(this.more, this.moreMenu);
delete this.leftTr;
delete this.rightTr;
delete this.extrasTr;
Ext.layout.ToolbarLayout.superclass.destroy.call(this);
}
});
Ext.Container.LAYOUTS.toolbar = Ext.layout.ToolbarLayout;
Ext.layout.MenuLayout = Ext.extend(Ext.layout.ContainerLayout, {
monitorResize : true,
type: 'menu',
setContainer : function(ct){
this.monitorResize = !ct.floating;
ct.on('autosize', this.doAutoSize, this);
Ext.layout.MenuLayout.superclass.setContainer.call(this, ct);
},
renderItem : function(c, position, target){
if (!this.itemTpl) {
this.itemTpl = Ext.layout.MenuLayout.prototype.itemTpl = new Ext.XTemplate(
'<li id="{itemId}" class="{itemCls}">',
'<tpl if="needsIcon">',
'<img alt="{altText}" src="{icon}" class="{iconCls}"/>',
'</tpl>',
'</li>'
);
}
if(c && !c.rendered){
if(Ext.isNumber(position)){
position = target.dom.childNodes[position];
}
var a = this.getItemArgs(c);
c.render(c.positionEl = position ?
this.itemTpl.insertBefore(position, a, true) :
this.itemTpl.append(target, a, true));
c.positionEl.menuItemId = c.getItemId();
if (!a.isMenuItem && a.needsIcon) {
c.positionEl.addClass('x-menu-list-item-indent');
}
this.configureItem(c);
}else if(c && !this.isValidParent(c, target)){
if(Ext.isNumber(position)){
position = target.dom.childNodes[position];
}
target.dom.insertBefore(c.getActionEl().dom, position || null);
}
},
getItemArgs : function(c) {
var isMenuItem = c instanceof Ext.menu.Item,
canHaveIcon = !(isMenuItem || c instanceof Ext.menu.Separator);
return {
isMenuItem: isMenuItem,
needsIcon: canHaveIcon && (c.icon || c.iconCls),
icon: c.icon || Ext.BLANK_IMAGE_URL,
iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),
itemId: 'x-menu-el-' + c.id,
itemCls: 'x-menu-list-item ',
altText: c.altText || ''
};
},
isValidParent : function(c, target) {
return c.el.up('li.x-menu-list-item', 5).dom.parentNode === (target.dom || target);
},
onLayout : function(ct, target){
Ext.layout.MenuLayout.superclass.onLayout.call(this, ct, target);
this.doAutoSize();
},
doAutoSize : function(){
var ct = this.container, w = ct.width;
if(ct.floating){
if(w){
ct.setWidth(w);
}else if(Ext.isIE){
ct.setWidth(Ext.isStrict && (Ext.isIE7 || Ext.isIE8 || Ext.isIE9) ? 'auto' : ct.minWidth);
var el = ct.getEl(), t = el.dom.offsetWidth;
ct.setWidth(ct.getLayoutTarget().getWidth() + el.getFrameWidth('lr'));
}
}
}
});
Ext.Container.LAYOUTS['menu'] = Ext.layout.MenuLayout;
Ext.Viewport = Ext.extend(Ext.Container, {
initComponent : function() {
Ext.Viewport.superclass.initComponent.call(this);
document.getElementsByTagName('html')[0].className += ' x-viewport';
this.el = Ext.getBody();
this.el.setHeight = Ext.emptyFn;
this.el.setWidth = Ext.emptyFn;
this.el.setSize = Ext.emptyFn;
this.el.dom.scroll = 'no';
this.allowDomMove = false;
this.autoWidth = true;
this.autoHeight = true;
Ext.EventManager.onWindowResize(this.fireResize, this);
this.renderTo = this.el;
},
fireResize : function(w, h){
this.fireEvent('resize', this, w, h, w, h);
}
});
Ext.reg('viewport', Ext.Viewport);
Ext.Panel = Ext.extend(Ext.Container, {
baseCls : 'x-panel',
collapsedCls : 'x-panel-collapsed',
maskDisabled : true,
animCollapse : Ext.enableFx,
headerAsText : true,
buttonAlign : 'right',
collapsed : false,
collapseFirst : true,
minButtonWidth : 75,
elements : 'body',
preventBodyReset : false,
padding: undefined,
resizeEvent: 'bodyresize',
toolTarget : 'header',
collapseEl : 'bwrap',
slideAnchor : 't',
disabledClass : '',
deferHeight : true,
expandDefaults: {
duration : 0.25
},
collapseDefaults : {
duration : 0.25
},
initComponent : function(){
Ext.Panel.superclass.initComponent.call(this);
this.addEvents(
'bodyresize',
'titlechange',
'iconchange',
'collapse',
'expand',
'beforecollapse',
'beforeexpand',
'beforeclose',
'close',
'activate',
'deactivate'
);
if(this.unstyled){
this.baseCls = 'x-plain';
}
this.toolbars = [];
if(this.tbar){
this.elements += ',tbar';
this.topToolbar = this.createToolbar(this.tbar);
this.tbar = null;
}
if(this.bbar){
this.elements += ',bbar';
this.bottomToolbar = this.createToolbar(this.bbar);
this.bbar = null;
}
if(this.header === true){
this.elements += ',header';
this.header = null;
}else if(this.headerCfg || (this.title && this.header !== false)){
this.elements += ',header';
}
if(this.footerCfg || this.footer === true){
this.elements += ',footer';
this.footer = null;
}
if(this.buttons){
this.fbar = this.buttons;
this.buttons = null;
}
if(this.fbar){
this.createFbar(this.fbar);
}
if(this.autoLoad){
this.on('render', this.doAutoLoad, this, {delay:10});
}
},
createFbar : function(fbar){
var min = this.minButtonWidth;
this.elements += ',footer';
this.fbar = this.createToolbar(fbar, {
buttonAlign: this.buttonAlign,
toolbarCls: 'x-panel-fbar',
enableOverflow: false,
defaults: function(c){
return {
minWidth: c.minWidth || min
};
}
});
this.fbar.items.each(function(c){
c.minWidth = c.minWidth || this.minButtonWidth;
}, this);
this.buttons = this.fbar.items.items;
},
createToolbar: function(tb, options){
var result;
if(Ext.isArray(tb)){
tb = {
items: tb
};
}
result = tb.events ? Ext.apply(tb, options) : this.createComponent(Ext.apply({}, tb, options), 'toolbar');
this.toolbars.push(result);
return result;
},
createElement : function(name, pnode){
if(this[name]){
pnode.appendChild(this[name].dom);
return;
}
if(name === 'bwrap' || this.elements.indexOf(name) != -1){
if(this[name+'Cfg']){
this[name] = Ext.fly(pnode).createChild(this[name+'Cfg']);
}else{
var el = document.createElement('div');
el.className = this[name+'Cls'];
this[name] = Ext.get(pnode.appendChild(el));
}
if(this[name+'CssClass']){
this[name].addClass(this[name+'CssClass']);
}
if(this[name+'Style']){
this[name].applyStyles(this[name+'Style']);
}
}
},
onRender : function(ct, position){
Ext.Panel.superclass.onRender.call(this, ct, position);
this.createClasses();
var el = this.el,
d = el.dom,
bw,
ts;
if(this.collapsible && !this.hideCollapseTool){
this.tools = this.tools ? this.tools.slice(0) : [];
this.tools[this.collapseFirst?'unshift':'push']({
id: 'toggle',
handler : this.toggleCollapse,
scope: this
});
}
if(this.tools){
ts = this.tools;
this.elements += (this.header !== false) ? ',header' : '';
}
this.tools = {};
el.addClass(this.baseCls);
if(d.firstChild){
this.header = el.down('.'+this.headerCls);
this.bwrap = el.down('.'+this.bwrapCls);
var cp = this.bwrap ? this.bwrap : el;
this.tbar = cp.down('.'+this.tbarCls);
this.body = cp.down('.'+this.bodyCls);
this.bbar = cp.down('.'+this.bbarCls);
this.footer = cp.down('.'+this.footerCls);
this.fromMarkup = true;
}
if (this.preventBodyReset === true) {
el.addClass('x-panel-reset');
}
if(this.cls){
el.addClass(this.cls);
}
if(this.buttons){
this.elements += ',footer';
}
if(this.frame){
el.insertHtml('afterBegin', String.format(Ext.Element.boxMarkup, this.baseCls));
this.createElement('header', d.firstChild.firstChild.firstChild);
this.createElement('bwrap', d);
bw = this.bwrap.dom;
var ml = d.childNodes[1], bl = d.childNodes[2];
bw.appendChild(ml);
bw.appendChild(bl);
var mc = bw.firstChild.firstChild.firstChild;
this.createElement('tbar', mc);
this.createElement('body', mc);
this.createElement('bbar', mc);
this.createElement('footer', bw.lastChild.firstChild.firstChild);
if(!this.footer){
this.bwrap.dom.lastChild.className += ' x-panel-nofooter';
}
this.ft = Ext.get(this.bwrap.dom.lastChild);
this.mc = Ext.get(mc);
}else{
this.createElement('header', d);
this.createElement('bwrap', d);
bw = this.bwrap.dom;
this.createElement('tbar', bw);
this.createElement('body', bw);
this.createElement('bbar', bw);
this.createElement('footer', bw);
if(!this.header){
this.body.addClass(this.bodyCls + '-noheader');
if(this.tbar){
this.tbar.addClass(this.tbarCls + '-noheader');
}
}
}
if(Ext.isDefined(this.padding)){
this.body.setStyle('padding', this.body.addUnits(this.padding));
}
if(this.border === false){
this.el.addClass(this.baseCls + '-noborder');
this.body.addClass(this.bodyCls + '-noborder');
if(this.header){
this.header.addClass(this.headerCls + '-noborder');
}
if(this.footer){
this.footer.addClass(this.footerCls + '-noborder');
}
if(this.tbar){
this.tbar.addClass(this.tbarCls + '-noborder');
}
if(this.bbar){
this.bbar.addClass(this.bbarCls + '-noborder');
}
}
if(this.bodyBorder === false){
this.body.addClass(this.bodyCls + '-noborder');
}
this.bwrap.enableDisplayMode('block');
if(this.header){
this.header.unselectable();
if(this.headerAsText){
this.header.dom.innerHTML =
'<span class="' + this.headerTextCls + '">'+this.header.dom.innerHTML+'</span>';
if(this.iconCls){
this.setIconClass(this.iconCls);
}
}
}
if(this.floating){
this.makeFloating(this.floating);
}
if(this.collapsible && this.titleCollapse && this.header){
this.mon(this.header, 'click', this.toggleCollapse, this);
this.header.setStyle('cursor', 'pointer');
}
if(ts){
this.addTool.apply(this, ts);
}
if(this.fbar){
this.footer.addClass('x-panel-btns');
this.fbar.ownerCt = this;
this.fbar.render(this.footer);
this.footer.createChild({cls:'x-clear'});
}
if(this.tbar && this.topToolbar){
this.topToolbar.ownerCt = this;
this.topToolbar.render(this.tbar);
}
if(this.bbar && this.bottomToolbar){
this.bottomToolbar.ownerCt = this;
this.bottomToolbar.render(this.bbar);
}
},
setIconClass : function(cls){
var old = this.iconCls;
this.iconCls = cls;
if(this.rendered && this.header){
if(this.frame){
this.header.addClass('x-panel-icon');
this.header.replaceClass(old, this.iconCls);
}else{
var hd = this.header,
img = hd.child('img.x-panel-inline-icon');
if(img){
Ext.fly(img).replaceClass(old, this.iconCls);
}else{
var hdspan = hd.child('span.' + this.headerTextCls);
if (hdspan) {
Ext.DomHelper.insertBefore(hdspan.dom, {
tag:'img', alt: '', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
});
}
}
}
}
this.fireEvent('iconchange', this, cls, old);
},
makeFloating : function(cfg){
this.floating = true;
this.el = new Ext.Layer(Ext.apply({}, cfg, {
shadow: Ext.isDefined(this.shadow) ? this.shadow : 'sides',
shadowOffset: this.shadowOffset,
constrain:false,
shim: this.shim === false ? false : undefined
}), this.el);
},
getTopToolbar : function(){
return this.topToolbar;
},
getBottomToolbar : function(){
return this.bottomToolbar;
},
getFooterToolbar : function() {
return this.fbar;
},
addButton : function(config, handler, scope){
if(!this.fbar){
this.createFbar([]);
}
if(handler){
if(Ext.isString(config)){
config = {text: config};
}
config = Ext.apply({
handler: handler,
scope: scope
}, config);
}
return this.fbar.add(config);
},
addTool : function(){
if(!this.rendered){
if(!this.tools){
this.tools = [];
}
Ext.each(arguments, function(arg){
this.tools.push(arg);
}, this);
return;
}
if(!this[this.toolTarget]){
return;
}
if(!this.toolTemplate){
var tt = new Ext.Template(
'<div class="x-tool x-tool-{id}">&#160;</div>'
);
tt.disableFormats = true;
tt.compile();
Ext.Panel.prototype.toolTemplate = tt;
}
for(var i = 0, a = arguments, len = a.length; i < len; i++) {
var tc = a[i];
if(!this.tools[tc.id]){
var overCls = 'x-tool-'+tc.id+'-over';
var t = this.toolTemplate.insertFirst(this[this.toolTarget], tc, true);
this.tools[tc.id] = t;
t.enableDisplayMode('block');
this.mon(t, 'click', this.createToolHandler(t, tc, overCls, this));
if(tc.on){
this.mon(t, tc.on);
}
if(tc.hidden){
t.hide();
}
if(tc.qtip){
if(Ext.isObject(tc.qtip)){
Ext.QuickTips.register(Ext.apply({
target: t.id
}, tc.qtip));
} else {
t.dom.qtip = tc.qtip;
}
}
t.addClassOnOver(overCls);
}
}
},
onLayout : function(shallow, force){
Ext.Panel.superclass.onLayout.apply(this, arguments);
if(this.hasLayout && this.toolbars.length > 0){
Ext.each(this.toolbars, function(tb){
tb.doLayout(undefined, force);
});
this.syncHeight();
}
},
syncHeight : function(){
var h = this.toolbarHeight,
bd = this.body,
lsh = this.lastSize.height,
sz;
if(this.autoHeight || !Ext.isDefined(lsh) || lsh == 'auto'){
return;
}
if(h != this.getToolbarHeight()){
h = Math.max(0, lsh - this.getFrameHeight());
bd.setHeight(h);
sz = bd.getSize();
this.toolbarHeight = this.getToolbarHeight();
this.onBodyResize(sz.width, sz.height);
}
},
onShow : function(){
if(this.floating){
return this.el.show();
}
Ext.Panel.superclass.onShow.call(this);
},
onHide : function(){
if(this.floating){
return this.el.hide();
}
Ext.Panel.superclass.onHide.call(this);
},
createToolHandler : function(t, tc, overCls, panel){
return function(e){
t.removeClass(overCls);
if(tc.stopEvent !== false){
e.stopEvent();
}
if(tc.handler){
tc.handler.call(tc.scope || t, e, t, panel, tc);
}
};
},
afterRender : function(){
if(this.floating && !this.hidden){
this.el.show();
}
if(this.title){
this.setTitle(this.title);
}
Ext.Panel.superclass.afterRender.call(this);
if (this.collapsed) {
this.collapsed = false;
this.collapse(false);
}
this.initEvents();
},
getKeyMap : function(){
if(!this.keyMap){
this.keyMap = new Ext.KeyMap(this.el, this.keys);
}
return this.keyMap;
},
initEvents : function(){
if(this.keys){
this.getKeyMap();
}
if(this.draggable){
this.initDraggable();
}
if(this.toolbars.length > 0){
Ext.each(this.toolbars, function(tb){
tb.doLayout();
tb.on({
scope: this,
afterlayout: this.syncHeight,
remove: this.syncHeight
});
}, this);
this.syncHeight();
}
},
initDraggable : function(){
this.dd = new Ext.Panel.DD(this, Ext.isBoolean(this.draggable) ? null : this.draggable);
},
beforeEffect : function(anim){
if(this.floating){
this.el.beforeAction();
}
if(anim !== false){
this.el.addClass('x-panel-animated');
}
},
afterEffect : function(anim){
this.syncShadow();
this.el.removeClass('x-panel-animated');
},
createEffect : function(a, cb, scope){
var o = {
scope:scope,
block:true
};
if(a === true){
o.callback = cb;
return o;
}else if(!a.callback){
o.callback = cb;
}else {
o.callback = function(){
cb.call(scope);
Ext.callback(a.callback, a.scope);
};
}
return Ext.applyIf(o, a);
},
collapse : function(animate){
if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){
return;
}
var doAnim = animate === true || (animate !== false && this.animCollapse);
this.beforeEffect(doAnim);
this.onCollapse(doAnim, animate);
return this;
},
onCollapse : function(doAnim, animArg){
if(doAnim){
this[this.collapseEl].slideOut(this.slideAnchor,
Ext.apply(this.createEffect(animArg||true, this.afterCollapse, this),
this.collapseDefaults));
}else{
this[this.collapseEl].hide(this.hideMode);
this.afterCollapse(false);
}
},
afterCollapse : function(anim){
this.collapsed = true;
this.el.addClass(this.collapsedCls);
if(anim !== false){
this[this.collapseEl].hide(this.hideMode);
}
this.afterEffect(anim);
this.cascade(function(c) {
if (c.lastSize) {
c.lastSize = { width: undefined, height: undefined };
}
});
this.fireEvent('collapse', this);
},
expand : function(animate){
if(!this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforeexpand', this, animate) === false){
return;
}
var doAnim = animate === true || (animate !== false && this.animCollapse);
this.el.removeClass(this.collapsedCls);
this.beforeEffect(doAnim);
this.onExpand(doAnim, animate);
return this;
},
onExpand : function(doAnim, animArg){
if(doAnim){
this[this.collapseEl].slideIn(this.slideAnchor,
Ext.apply(this.createEffect(animArg||true, this.afterExpand, this),
this.expandDefaults));
}else{
this[this.collapseEl].show(this.hideMode);
this.afterExpand(false);
}
},
afterExpand : function(anim){
this.collapsed = false;
if(anim !== false){
this[this.collapseEl].show(this.hideMode);
}
this.afterEffect(anim);
if (this.deferLayout) {
delete this.deferLayout;
this.doLayout(true);
}
this.fireEvent('expand', this);
},
toggleCollapse : function(animate){
this[this.collapsed ? 'expand' : 'collapse'](animate);
return this;
},
onDisable : function(){
if(this.rendered && this.maskDisabled){
this.el.mask();
}
Ext.Panel.superclass.onDisable.call(this);
},
onEnable : function(){
if(this.rendered && this.maskDisabled){
this.el.unmask();
}
Ext.Panel.superclass.onEnable.call(this);
},
onResize : function(adjWidth, adjHeight, rawWidth, rawHeight){
var w = adjWidth,
h = adjHeight;
if(Ext.isDefined(w) || Ext.isDefined(h)){
if(!this.collapsed){
if(Ext.isNumber(w)){
this.body.setWidth(w = this.adjustBodyWidth(w - this.getFrameWidth()));
} else if (w == 'auto') {
w = this.body.setWidth('auto').dom.offsetWidth;
} else {
w = this.body.dom.offsetWidth;
}
if(this.tbar){
this.tbar.setWidth(w);
if(this.topToolbar){
this.topToolbar.setSize(w);
}
}
if(this.bbar){
this.bbar.setWidth(w);
if(this.bottomToolbar){
this.bottomToolbar.setSize(w);
if (Ext.isIE) {
this.bbar.setStyle('position', 'static');
this.bbar.setStyle('position', '');
}
}
}
if(this.footer){
this.footer.setWidth(w);
if(this.fbar){
this.fbar.setSize(Ext.isIE ? (w - this.footer.getFrameWidth('lr')) : 'auto');
}
}
if(Ext.isNumber(h)){
h = Math.max(0, h - this.getFrameHeight());
this.body.setHeight(h);
}else if(h == 'auto'){
this.body.setHeight(h);
}
if(this.disabled && this.el._mask){
this.el._mask.setSize(this.el.dom.clientWidth, this.el.getHeight());
}
}else{
this.queuedBodySize = {width: w, height: h};
if(!this.queuedExpand && this.allowQueuedExpand !== false){
this.queuedExpand = true;
this.on('expand', function(){
delete this.queuedExpand;
this.onResize(this.queuedBodySize.width, this.queuedBodySize.height);
}, this, {single:true});
}
}
this.onBodyResize(w, h);
}
this.syncShadow();
Ext.Panel.superclass.onResize.call(this, adjWidth, adjHeight, rawWidth, rawHeight);
},
onBodyResize: function(w, h){
this.fireEvent('bodyresize', this, w, h);
},
getToolbarHeight: function(){
var h = 0;
if(this.rendered){
Ext.each(this.toolbars, function(tb){
h += tb.getHeight();
}, this);
}
return h;
},
adjustBodyHeight : function(h){
return h;
},
adjustBodyWidth : function(w){
return w;
},
onPosition : function(){
this.syncShadow();
},
getFrameWidth : function(){
var w = this.el.getFrameWidth('lr') + this.bwrap.getFrameWidth('lr');
if(this.frame){
var l = this.bwrap.dom.firstChild;
w += (Ext.fly(l).getFrameWidth('l') + Ext.fly(l.firstChild).getFrameWidth('r'));
w += this.mc.getFrameWidth('lr');
}
return w;
},
getFrameHeight : function() {
var h = this.el.getFrameWidth('tb') + this.bwrap.getFrameWidth('tb');
h += (this.tbar ? this.tbar.getHeight() : 0) +
(this.bbar ? this.bbar.getHeight() : 0);
if(this.frame){
h += this.el.dom.firstChild.offsetHeight + this.ft.dom.offsetHeight + this.mc.getFrameWidth('tb');
}else{
h += (this.header ? this.header.getHeight() : 0) +
(this.footer ? this.footer.getHeight() : 0);
}
return h;
},
getInnerWidth : function(){
return this.getSize().width - this.getFrameWidth();
},
getInnerHeight : function(){
return this.body.getHeight();
},
syncShadow : function(){
if(this.floating){
this.el.sync(true);
}
},
getLayoutTarget : function(){
return this.body;
},
getContentTarget : function(){
return this.body;
},
setTitle : function(title, iconCls){
this.title = title;
if(this.header && this.headerAsText){
this.header.child('span').update(title);
}
if(iconCls){
this.setIconClass(iconCls);
}
this.fireEvent('titlechange', this, title);
return this;
},
getUpdater : function(){
return this.body.getUpdater();
},
load : function(){
var um = this.body.getUpdater();
um.update.apply(um, arguments);
return this;
},
beforeDestroy : function(){
Ext.Panel.superclass.beforeDestroy.call(this);
if(this.header){
this.header.removeAllListeners();
}
if(this.tools){
for(var k in this.tools){
Ext.destroy(this.tools[k]);
}
}
if(this.toolbars.length > 0){
Ext.each(this.toolbars, function(tb){
tb.un('afterlayout', this.syncHeight, this);
tb.un('remove', this.syncHeight, this);
}, this);
}
if(Ext.isArray(this.buttons)){
while(this.buttons.length) {
Ext.destroy(this.buttons[0]);
}
}
if(this.rendered){
Ext.destroy(
this.ft,
this.header,
this.footer,
this.tbar,
this.bbar,
this.body,
this.mc,
this.bwrap,
this.dd
);
if (this.fbar) {
Ext.destroy(
this.fbar,
this.fbar.el
);
}
}
Ext.destroy(this.toolbars);
},
createClasses : function(){
this.headerCls = this.baseCls + '-header';
this.headerTextCls = this.baseCls + '-header-text';
this.bwrapCls = this.baseCls + '-bwrap';
this.tbarCls = this.baseCls + '-tbar';
this.bodyCls = this.baseCls + '-body';
this.bbarCls = this.baseCls + '-bbar';
this.footerCls = this.baseCls + '-footer';
},
createGhost : function(cls, useShim, appendTo){
var el = document.createElement('div');
el.className = 'x-panel-ghost ' + (cls ? cls : '');
if(this.header){
el.appendChild(this.el.dom.firstChild.cloneNode(true));
}
Ext.fly(el.appendChild(document.createElement('ul'))).setHeight(this.bwrap.getHeight());
el.style.width = this.el.dom.offsetWidth + 'px';;
if(!appendTo){
this.container.dom.appendChild(el);
}else{
Ext.getDom(appendTo).appendChild(el);
}
if(useShim !== false && this.el.useShim !== false){
var layer = new Ext.Layer({shadow:false, useDisplay:true, constrain:false}, el);
layer.show();
return layer;
}else{
return new Ext.Element(el);
}
},
doAutoLoad : function(){
var u = this.body.getUpdater();
if(this.renderer){
u.setRenderer(this.renderer);
}
u.update(Ext.isObject(this.autoLoad) ? this.autoLoad : {url: this.autoLoad});
},
getTool : function(id) {
return this.tools[id];
}
});
Ext.reg('panel', Ext.Panel);
Ext.Editor = function(field, config){
if(field.field){
this.field = Ext.create(field.field, 'textfield');
config = Ext.apply({}, field);
delete config.field;
}else{
this.field = field;
}
Ext.Editor.superclass.constructor.call(this, config);
};
Ext.extend(Ext.Editor, Ext.Component, {
allowBlur: true,
value : "",
alignment: "c-c?",
offsets: [0, 0],
shadow : "frame",
constrain : false,
swallowKeys : true,
completeOnEnter : true,
cancelOnEsc : true,
updateEl : false,
initComponent : function(){
Ext.Editor.superclass.initComponent.call(this);
this.addEvents(
"beforestartedit",
"startedit",
"beforecomplete",
"complete",
"canceledit",
"specialkey"
);
},
onRender : function(ct, position){
this.el = new Ext.Layer({
shadow: this.shadow,
cls: "x-editor",
parentEl : ct,
shim : this.shim,
shadowOffset: this.shadowOffset || 4,
id: this.id,
constrain: this.constrain
});
if(this.zIndex){
this.el.setZIndex(this.zIndex);
}
this.el.setStyle("overflow", Ext.isGecko ? "auto" : "hidden");
if(this.field.msgTarget != 'title'){
this.field.msgTarget = 'qtip';
}
this.field.inEditor = true;
this.mon(this.field, {
scope: this,
blur: this.onBlur,
specialkey: this.onSpecialKey
});
if(this.field.grow){
this.mon(this.field, "autosize", this.el.sync, this.el, {delay:1});
}
this.field.render(this.el).show();
this.field.getEl().dom.name = '';
if(this.swallowKeys){
this.field.el.swallowEvent([
'keypress',
'keydown'
]);
}
},
onSpecialKey : function(field, e){
var key = e.getKey(),
complete = this.completeOnEnter && key == e.ENTER,
cancel = this.cancelOnEsc && key == e.ESC;
if(complete || cancel){
e.stopEvent();
if(complete){
this.completeEdit();
}else{
this.cancelEdit();
}
if(field.triggerBlur){
field.triggerBlur();
}
}
this.fireEvent('specialkey', field, e);
},
startEdit : function(el, value){
if(this.editing){
this.completeEdit();
}
this.boundEl = Ext.get(el);
var v = value !== undefined ? value : this.boundEl.dom.innerHTML;
if(!this.rendered){
this.render(this.parentEl || document.body);
}
if(this.fireEvent("beforestartedit", this, this.boundEl, v) !== false){
this.startValue = v;
this.field.reset();
this.field.setValue(v);
this.realign(true);
this.editing = true;
this.show();
}
},
doAutoSize : function(){
if(this.autoSize){
var sz = this.boundEl.getSize(),
fs = this.field.getSize();
switch(this.autoSize){
case "width":
this.setSize(sz.width, fs.height);
break;
case "height":
this.setSize(fs.width, sz.height);
break;
case "none":
this.setSize(fs.width, fs.height);
break;
default:
this.setSize(sz.width, sz.height);
}
}
},
setSize : function(w, h){
delete this.field.lastSize;
this.field.setSize(w, h);
if(this.el){
if(Ext.isGecko2 || Ext.isOpera || (Ext.isIE7 && Ext.isStrict)){
this.el.setSize(w, h);
}
this.el.sync();
}
},
realign : function(autoSize){
if(autoSize === true){
this.doAutoSize();
}
this.el.alignTo(this.boundEl, this.alignment, this.offsets);
},
completeEdit : function(remainVisible){
if(!this.editing){
return;
}
if (this.field.assertValue) {
this.field.assertValue();
}
var v = this.getValue();
if(!this.field.isValid()){
if(this.revertInvalid !== false){
this.cancelEdit(remainVisible);
}
return;
}
if(String(v) === String(this.startValue) && this.ignoreNoChange){
this.hideEdit(remainVisible);
return;
}
if(this.fireEvent("beforecomplete", this, v, this.startValue) !== false){
v = this.getValue();
if(this.updateEl && this.boundEl){
this.boundEl.update(v);
}
this.hideEdit(remainVisible);
this.fireEvent("complete", this, v, this.startValue);
}
},
onShow : function(){
this.el.show();
if(this.hideEl !== false){
this.boundEl.hide();
}
this.field.show().focus(false, true);
this.fireEvent("startedit", this.boundEl, this.startValue);
},
cancelEdit : function(remainVisible){
if(this.editing){
var v = this.getValue();
this.setValue(this.startValue);
this.hideEdit(remainVisible);
this.fireEvent("canceledit", this, v, this.startValue);
}
},
hideEdit: function(remainVisible){
if(remainVisible !== true){
this.editing = false;
this.hide();
}
},
onBlur : function(){
if(this.allowBlur === true && this.editing && this.selectSameEditor !== true){
this.completeEdit();
}
},
onHide : function(){
if(this.editing){
this.completeEdit();
return;
}
this.field.blur();
if(this.field.collapse){
this.field.collapse();
}
this.el.hide();
if(this.hideEl !== false){
this.boundEl.show();
}
},
setValue : function(v){
this.field.setValue(v);
},
getValue : function(){
return this.field.getValue();
},
beforeDestroy : function(){
Ext.destroyMembers(this, 'field');
delete this.parentEl;
delete this.boundEl;
}
});
Ext.reg('editor', Ext.Editor);
Ext.ColorPalette = Ext.extend(Ext.Component, {
itemCls : 'x-color-palette',
value : null,
clickEvent :'click',
ctype : 'Ext.ColorPalette',
allowReselect : false,
colors : [
'000000', '993300', '333300', '003300', '003366', '000080', '333399', '333333',
'800000', 'FF6600', '808000', '008000', '008080', '0000FF', '666699', '808080',
'FF0000', 'FF9900', '99CC00', '339966', '33CCCC', '3366FF', '800080', '969696',
'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0',
'FF99CC', 'FFCC99', 'FFFF99', 'CCFFCC', 'CCFFFF', '99CCFF', 'CC99FF', 'FFFFFF'
],
initComponent : function(){
Ext.ColorPalette.superclass.initComponent.call(this);
this.addEvents(
'select'
);
if(this.handler){
this.on('select', this.handler, this.scope, true);
}
},
onRender : function(container, position){
this.autoEl = {
tag: 'div',
cls: this.itemCls
};
Ext.ColorPalette.superclass.onRender.call(this, container, position);
var t = this.tpl || new Ext.XTemplate(
'<tpl for="."><a href="#" class="color-{.}" hidefocus="on"><em><span style="background:#{.}" unselectable="on">&#160;</span></em></a></tpl>'
);
t.overwrite(this.el, this.colors);
this.mon(this.el, this.clickEvent, this.handleClick, this, {delegate: 'a'});
if(this.clickEvent != 'click'){
this.mon(this.el, 'click', Ext.emptyFn, this, {delegate: 'a', preventDefault: true});
}
},
afterRender : function(){
Ext.ColorPalette.superclass.afterRender.call(this);
if(this.value){
var s = this.value;
this.value = null;
this.select(s, true);
}
},
handleClick : function(e, t){
e.preventDefault();
if(!this.disabled){
var c = t.className.match(/(?:^|\s)color-(.{6})(?:\s|$)/)[1];
this.select(c.toUpperCase());
}
},
select : function(color, suppressEvent){
color = color.replace('#', '');
if(color != this.value || this.allowReselect){
var el = this.el;
if(this.value){
el.child('a.color-'+this.value).removeClass('x-color-palette-sel');
}
el.child('a.color-'+color).addClass('x-color-palette-sel');
this.value = color;
if(suppressEvent !== true){
this.fireEvent('select', this, color);
}
}
}
});
Ext.reg('colorpalette', Ext.ColorPalette);
Ext.DatePicker = Ext.extend(Ext.BoxComponent, {
todayText : 'Today',
okText : '&#160;OK&#160;',
cancelText : 'Cancel',
todayTip : '{0} (Spacebar)',
minText : 'This date is before the minimum date',
maxText : 'This date is after the maximum date',
format : 'm/d/y',
disabledDaysText : 'Disabled',
disabledDatesText : 'Disabled',
monthNames : Date.monthNames,
dayNames : Date.dayNames,
nextText : 'Next Month (Control+Right)',
prevText : 'Previous Month (Control+Left)',
monthYearText : 'Choose a month (Control+Up/Down to move years)',
startDay : 0,
showToday : true,
focusOnSelect: true,
initHour: 12,
initComponent : function(){
Ext.DatePicker.superclass.initComponent.call(this);
this.value = this.value ?
this.value.clearTime(true) : new Date().clearTime();
this.addEvents(
'select'
);
if(this.handler){
this.on('select', this.handler, this.scope || this);
}
this.initDisabledDays();
},
initDisabledDays : function(){
if(!this.disabledDatesRE && this.disabledDates){
var dd = this.disabledDates,
len = dd.length - 1,
re = '(?:';
Ext.each(dd, function(d, i){
re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
if(i != len){
re += '|';
}
}, this);
this.disabledDatesRE = new RegExp(re + ')');
}
},
setDisabledDates : function(dd){
if(Ext.isArray(dd)){
this.disabledDates = dd;
this.disabledDatesRE = null;
}else{
this.disabledDatesRE = dd;
}
this.initDisabledDays();
this.update(this.value, true);
},
setDisabledDays : function(dd){
this.disabledDays = dd;
this.update(this.value, true);
},
setMinDate : function(dt){
this.minDate = dt;
this.update(this.value, true);
},
setMaxDate : function(dt){
this.maxDate = dt;
this.update(this.value, true);
},
setValue : function(value){
this.value = value.clearTime(true);
this.update(this.value);
},
getValue : function(){
return this.value;
},
focus : function(){
this.update(this.activeDate);
},
onEnable: function(initial){
Ext.DatePicker.superclass.onEnable.call(this);
this.doDisabled(false);
this.update(initial ? this.value : this.activeDate);
if(Ext.isIE){
this.el.repaint();
}
},
onDisable : function(){
Ext.DatePicker.superclass.onDisable.call(this);
this.doDisabled(true);
if(Ext.isIE && !Ext.isIE8){
Ext.each([].concat(this.textNodes, this.el.query('th span')), function(el){
Ext.fly(el).repaint();
});
}
},
doDisabled : function(disabled){
this.keyNav.setDisabled(disabled);
this.prevRepeater.setDisabled(disabled);
this.nextRepeater.setDisabled(disabled);
if(this.showToday){
this.todayKeyListener.setDisabled(disabled);
this.todayBtn.setDisabled(disabled);
}
},
onRender : function(container, position){
var m = [
'<table cellspacing="0">',
'<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'">&#160;</a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'">&#160;</a></td></tr>',
'<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'],
dn = this.dayNames,
i;
for(i = 0; i < 7; i++){
var d = this.startDay+i;
if(d > 6){
d = d-7;
}
m.push('<th><span>', dn[d].substr(0,1), '</span></th>');
}
m[m.length] = '</tr></thead><tbody><tr>';
for(i = 0; i < 42; i++) {
if(i % 7 === 0 && i !== 0){
m[m.length] = '</tr><tr>';
}
m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
}
m.push('</tr></tbody></table></td></tr>',
this.showToday ? '<tr><td colspan="3" class="x-date-bottom" align="center"></td></tr>' : '',
'</table><div class="x-date-mp"></div>');
var el = document.createElement('div');
el.className = 'x-date-picker';
el.innerHTML = m.join('');
container.dom.insertBefore(el, position);
this.el = Ext.get(el);
this.eventEl = Ext.get(el.firstChild);
this.prevRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-left a'), {
handler: this.showPrevMonth,
scope: this,
preventDefault:true,
stopDefault:true
});
this.nextRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-right a'), {
handler: this.showNextMonth,
scope: this,
preventDefault:true,
stopDefault:true
});
this.monthPicker = this.el.down('div.x-date-mp');
this.monthPicker.enableDisplayMode('block');
this.keyNav = new Ext.KeyNav(this.eventEl, {
'left' : function(e){
if(e.ctrlKey){
this.showPrevMonth();
}else{
this.update(this.activeDate.add('d', -1));
}
},
'right' : function(e){
if(e.ctrlKey){
this.showNextMonth();
}else{
this.update(this.activeDate.add('d', 1));
}
},
'up' : function(e){
if(e.ctrlKey){
this.showNextYear();
}else{
this.update(this.activeDate.add('d', -7));
}
},
'down' : function(e){
if(e.ctrlKey){
this.showPrevYear();
}else{
this.update(this.activeDate.add('d', 7));
}
},
'pageUp' : function(e){
this.showNextMonth();
},
'pageDown' : function(e){
this.showPrevMonth();
},
'enter' : function(e){
e.stopPropagation();
return true;
},
scope : this
});
this.el.unselectable();
this.cells = this.el.select('table.x-date-inner tbody td');
this.textNodes = this.el.query('table.x-date-inner tbody span');
this.mbtn = new Ext.Button({
text: '&#160;',
tooltip: this.monthYearText,
renderTo: this.el.child('td.x-date-middle', true)
});
this.mbtn.el.child('em').addClass('x-btn-arrow');
if(this.showToday){
this.todayKeyListener = this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday, this);
var today = (new Date()).dateFormat(this.format);
this.todayBtn = new Ext.Button({
renderTo: this.el.child('td.x-date-bottom', true),
text: String.format(this.todayText, today),
tooltip: String.format(this.todayTip, today),
handler: this.selectToday,
scope: this
});
}
this.mon(this.eventEl, 'mousewheel', this.handleMouseWheel, this);
this.mon(this.eventEl, 'click', this.handleDateClick, this, {delegate: 'a.x-date-date'});
this.mon(this.mbtn, 'click', this.showMonthPicker, this);
this.onEnable(true);
},
createMonthPicker : function(){
if(!this.monthPicker.dom.firstChild){
var buf = ['<table border="0" cellspacing="0">'];
for(var i = 0; i < 6; i++){
buf.push(
'<tr><td class="x-date-mp-month"><a href="#">', Date.getShortMonthName(i), '</a></td>',
'<td class="x-date-mp-month x-date-mp-sep"><a href="#">', Date.getShortMonthName(i + 6), '</a></td>',
i === 0 ?
'<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>' :
'<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
);
}
buf.push(
'<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
this.okText,
'</button><button type="button" class="x-date-mp-cancel">',
this.cancelText,
'</button></td></tr>',
'</table>'
);
this.monthPicker.update(buf.join(''));
this.mon(this.monthPicker, 'click', this.onMonthClick, this);
this.mon(this.monthPicker, 'dblclick', this.onMonthDblClick, this);
this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
this.mpYears = this.monthPicker.select('td.x-date-mp-year');
this.mpMonths.each(function(m, a, i){
i += 1;
if((i%2) === 0){
m.dom.xmonth = 5 + Math.round(i * 0.5);
}else{
m.dom.xmonth = Math.round((i-1) * 0.5);
}
});
}
},
showMonthPicker : function(){
if(!this.disabled){
this.createMonthPicker();
var size = this.el.getSize();
this.monthPicker.setSize(size);
this.monthPicker.child('table').setSize(size);
this.mpSelMonth = (this.activeDate || this.value).getMonth();
this.updateMPMonth(this.mpSelMonth);
this.mpSelYear = (this.activeDate || this.value).getFullYear();
this.updateMPYear(this.mpSelYear);
this.monthPicker.slideIn('t', {duration:0.2});
}
},
updateMPYear : function(y){
this.mpyear = y;
var ys = this.mpYears.elements;
for(var i = 1; i <= 10; i++){
var td = ys[i-1], y2;
if((i%2) === 0){
y2 = y + Math.round(i * 0.5);
td.firstChild.innerHTML = y2;
td.xyear = y2;
}else{
y2 = y - (5-Math.round(i * 0.5));
td.firstChild.innerHTML = y2;
td.xyear = y2;
}
this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
}
},
updateMPMonth : function(sm){
this.mpMonths.each(function(m, a, i){
m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
});
},
selectMPMonth : function(m){
},
onMonthClick : function(e, t){
e.stopEvent();
var el = new Ext.Element(t), pn;
if(el.is('button.x-date-mp-cancel')){
this.hideMonthPicker();
}
else if(el.is('button.x-date-mp-ok')){
var d = new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate());
if(d.getMonth() != this.mpSelMonth){
d = new Date(this.mpSelYear, this.mpSelMonth, 1).getLastDateOfMonth();
}
this.update(d);
this.hideMonthPicker();
}
else if((pn = el.up('td.x-date-mp-month', 2))){
this.mpMonths.removeClass('x-date-mp-sel');
pn.addClass('x-date-mp-sel');
this.mpSelMonth = pn.dom.xmonth;
}
else if((pn = el.up('td.x-date-mp-year', 2))){
this.mpYears.removeClass('x-date-mp-sel');
pn.addClass('x-date-mp-sel');
this.mpSelYear = pn.dom.xyear;
}
else if(el.is('a.x-date-mp-prev')){
this.updateMPYear(this.mpyear-10);
}
else if(el.is('a.x-date-mp-next')){
this.updateMPYear(this.mpyear+10);
}
},
onMonthDblClick : function(e, t){
e.stopEvent();
var el = new Ext.Element(t), pn;
if((pn = el.up('td.x-date-mp-month', 2))){
this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));
this.hideMonthPicker();
}
else if((pn = el.up('td.x-date-mp-year', 2))){
this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
this.hideMonthPicker();
}
},
hideMonthPicker : function(disableAnim){
if(this.monthPicker){
if(disableAnim === true){
this.monthPicker.hide();
}else{
this.monthPicker.slideOut('t', {duration:0.2});
}
}
},
showPrevMonth : function(e){
this.update(this.activeDate.add('mo', -1));
},
showNextMonth : function(e){
this.update(this.activeDate.add('mo', 1));
},
showPrevYear : function(){
this.update(this.activeDate.add('y', -1));
},
showNextYear : function(){
this.update(this.activeDate.add('y', 1));
},
handleMouseWheel : function(e){
e.stopEvent();
if(!this.disabled){
var delta = e.getWheelDelta();
if(delta > 0){
this.showPrevMonth();
} else if(delta < 0){
this.showNextMonth();
}
}
},
handleDateClick : function(e, t){
e.stopEvent();
if(!this.disabled && t.dateValue && !Ext.fly(t.parentNode).hasClass('x-date-disabled')){
this.cancelFocus = this.focusOnSelect === false;
this.setValue(new Date(t.dateValue));
delete this.cancelFocus;
this.fireEvent('select', this, this.value);
}
},
selectToday : function(){
if(this.todayBtn && !this.todayBtn.disabled){
this.setValue(new Date().clearTime());
this.fireEvent('select', this, this.value);
}
},
update : function(date, forceRefresh){
if(this.rendered){
var vd = this.activeDate, vis = this.isVisible();
this.activeDate = date;
if(!forceRefresh && vd && this.el){
var t = date.getTime();
if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
this.cells.removeClass('x-date-selected');
this.cells.each(function(c){
if(c.dom.firstChild.dateValue == t){
c.addClass('x-date-selected');
if(vis && !this.cancelFocus){
Ext.fly(c.dom.firstChild).focus(50);
}
return false;
}
}, this);
return;
}
}
var days = date.getDaysInMonth(),
firstOfMonth = date.getFirstDateOfMonth(),
startingPos = firstOfMonth.getDay()-this.startDay;
if(startingPos < 0){
startingPos += 7;
}
days += startingPos;
var pm = date.add('mo', -1),
prevStart = pm.getDaysInMonth()-startingPos,
cells = this.cells.elements,
textEls = this.textNodes,
d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart, this.initHour)),
today = new Date().clearTime().getTime(),
sel = date.clearTime(true).getTime(),
min = this.minDate ? this.minDate.clearTime(true) : Number.NEGATIVE_INFINITY,
max = this.maxDate ? this.maxDate.clearTime(true) : Number.POSITIVE_INFINITY,
ddMatch = this.disabledDatesRE,
ddText = this.disabledDatesText,
ddays = this.disabledDays ? this.disabledDays.join('') : false,
ddaysText = this.disabledDaysText,
format = this.format;
if(this.showToday){
var td = new Date().clearTime(),
disable = (td < min || td > max ||
(ddMatch && format && ddMatch.test(td.dateFormat(format))) ||
(ddays && ddays.indexOf(td.getDay()) != -1));
if(!this.disabled){
this.todayBtn.setDisabled(disable);
this.todayKeyListener[disable ? 'disable' : 'enable']();
}
}
var setCellClass = function(cal, cell){
cell.title = '';
var t = d.clearTime(true).getTime();
cell.firstChild.dateValue = t;
if(t == today){
cell.className += ' x-date-today';
cell.title = cal.todayText;
}
if(t == sel){
cell.className += ' x-date-selected';
if(vis){
Ext.fly(cell.firstChild).focus(50);
}
}
if(t < min) {
cell.className = ' x-date-disabled';
cell.title = cal.minText;
return;
}
if(t > max) {
cell.className = ' x-date-disabled';
cell.title = cal.maxText;
return;
}
if(ddays){
if(ddays.indexOf(d.getDay()) != -1){
cell.title = ddaysText;
cell.className = ' x-date-disabled';
}
}
if(ddMatch && format){
var fvalue = d.dateFormat(format);
if(ddMatch.test(fvalue)){
cell.title = ddText.replace('%0', fvalue);
cell.className = ' x-date-disabled';
}
}
};
var i = 0;
for(; i < startingPos; i++) {
textEls[i].innerHTML = (++prevStart);
d.setDate(d.getDate()+1);
cells[i].className = 'x-date-prevday';
setCellClass(this, cells[i]);
}
for(; i < days; i++){
var intDay = i - startingPos + 1;
textEls[i].innerHTML = (intDay);
d.setDate(d.getDate()+1);
cells[i].className = 'x-date-active';
setCellClass(this, cells[i]);
}
var extraDays = 0;
for(; i < 42; i++) {
textEls[i].innerHTML = (++extraDays);
d.setDate(d.getDate()+1);
cells[i].className = 'x-date-nextday';
setCellClass(this, cells[i]);
}
this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());
if(!this.internalRender){
var main = this.el.dom.firstChild,
w = main.offsetWidth;
this.el.setWidth(w + this.el.getBorderWidth('lr'));
Ext.fly(main).setWidth(w);
this.internalRender = true;
if(Ext.isOpera && !this.secondPass){
main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';
this.secondPass = true;
this.update.defer(10, this, [date]);
}
}
}
},
beforeDestroy : function() {
if(this.rendered){
Ext.destroy(
this.keyNav,
this.monthPicker,
this.eventEl,
this.mbtn,
this.nextRepeater,
this.prevRepeater,
this.cells.el,
this.todayBtn
);
delete this.textNodes;
delete this.cells.elements;
}
}
});
Ext.reg('datepicker', Ext.DatePicker);
Ext.LoadMask = function(el, config){
this.el = Ext.get(el);
Ext.apply(this, config);
if(this.store){
this.store.on({
scope: this,
beforeload: this.onBeforeLoad,
load: this.onLoad,
exception: this.onLoad
});
this.removeMask = Ext.value(this.removeMask, false);
}else{
var um = this.el.getUpdater();
um.showLoadIndicator = false;
um.on({
scope: this,
beforeupdate: this.onBeforeLoad,
update: this.onLoad,
failure: this.onLoad
});
this.removeMask = Ext.value(this.removeMask, true);
}
};
Ext.LoadMask.prototype = {
msg : 'Loading...',
msgCls : 'x-mask-loading',
disabled: false,
disable : function(){
this.disabled = true;
},
enable : function(){
this.disabled = false;
},
onLoad : function(){
this.el.unmask(this.removeMask);
},
onBeforeLoad : function(){
if(!this.disabled){
this.el.mask(this.msg, this.msgCls);
}
},
show: function(){
this.onBeforeLoad();
},
hide: function(){
this.onLoad();
},
destroy : function(){
if(this.store){
this.store.un('beforeload', this.onBeforeLoad, this);
this.store.un('load', this.onLoad, this);
this.store.un('exception', this.onLoad, this);
}else{
var um = this.el.getUpdater();
um.un('beforeupdate', this.onBeforeLoad, this);
um.un('update', this.onLoad, this);
um.un('failure', this.onLoad, this);
}
}
};
Ext.slider.Thumb = Ext.extend(Object, {
dragging: false,
constructor: function(config) {
Ext.apply(this, config || {}, {
cls: 'x-slider-thumb',
constrain: false
});
Ext.slider.Thumb.superclass.constructor.call(this, config);
if (this.slider.vertical) {
Ext.apply(this, Ext.slider.Thumb.Vertical);
}
},
render: function() {
this.el = this.slider.innerEl.insertFirst({cls: this.cls});
this.initEvents();
},
enable: function() {
this.disabled = false;
this.el.removeClass(this.slider.disabledClass);
},
disable: function() {
this.disabled = true;
this.el.addClass(this.slider.disabledClass);
},
initEvents: function() {
var el = this.el;
el.addClassOnOver('x-slider-thumb-over');
this.tracker = new Ext.dd.DragTracker({
onBeforeStart: this.onBeforeDragStart.createDelegate(this),
onStart : this.onDragStart.createDelegate(this),
onDrag : this.onDrag.createDelegate(this),
onEnd : this.onDragEnd.createDelegate(this),
tolerance : 3,
autoStart : 300
});
this.tracker.initEl(el);
},
onBeforeDragStart : function(e) {
if (this.disabled) {
return false;
} else {
this.slider.promoteThumb(this);
return true;
}
},
onDragStart: function(e){
this.el.addClass('x-slider-thumb-drag');
this.dragging = true;
this.dragStartValue = this.value;
this.slider.fireEvent('dragstart', this.slider, e, this);
},
onDrag: function(e) {
var slider = this.slider,
index = this.index,
newValue = this.getNewValue();
if (this.constrain) {
var above = slider.thumbs[index + 1],
below = slider.thumbs[index - 1];
if (below != undefined && newValue <= below.value) newValue = below.value;
if (above != undefined && newValue >= above.value) newValue = above.value;
}
slider.setValue(index, newValue, false);
slider.fireEvent('drag', slider, e, this);
},
getNewValue: function() {
var slider = this.slider,
pos = slider.innerEl.translatePoints(this.tracker.getXY());
return Ext.util.Format.round(slider.reverseValue(pos.left), slider.decimalPrecision);
},
onDragEnd: function(e) {
var slider = this.slider,
value = this.value;
this.el.removeClass('x-slider-thumb-drag');
this.dragging = false;
slider.fireEvent('dragend', slider, e);
if (this.dragStartValue != value) {
slider.fireEvent('changecomplete', slider, value, this);
}
},
destroy: function(){
Ext.destroyMembers(this, 'tracker', 'el');
}
});
Ext.slider.MultiSlider = Ext.extend(Ext.BoxComponent, {
vertical: false,
minValue: 0,
maxValue: 100,
decimalPrecision: 0,
keyIncrement: 1,
increment: 0,
clickRange: [5,15],
clickToChange : true,
animate: true,
constrainThumbs: true,
topThumbZIndex: 10000,
initComponent : function(){
if(!Ext.isDefined(this.value)){
this.value = this.minValue;
}
this.thumbs = [];
Ext.slider.MultiSlider.superclass.initComponent.call(this);
this.keyIncrement = Math.max(this.increment, this.keyIncrement);
this.addEvents(
'beforechange',
'change',
'changecomplete',
'dragstart',
'drag',
'dragend'
);
if (this.values == undefined || Ext.isEmpty(this.values)) this.values = [0];
var values = this.values;
for (var i=0; i < values.length; i++) {
this.addThumb(values[i]);
}
if(this.vertical){
Ext.apply(this, Ext.slider.Vertical);
}
},
addThumb: function(value) {
var thumb = new Ext.slider.Thumb({
value : value,
slider : this,
index : this.thumbs.length,
constrain: this.constrainThumbs
});
this.thumbs.push(thumb);
if (this.rendered) thumb.render();
},
promoteThumb: function(topThumb) {
var thumbs = this.thumbs,
zIndex, thumb;
for (var i = 0, j = thumbs.length; i < j; i++) {
thumb = thumbs[i];
if (thumb == topThumb) {
zIndex = this.topThumbZIndex;
} else {
zIndex = '';
}
thumb.el.setStyle('zIndex', zIndex);
}
},
onRender : function() {
this.autoEl = {
cls: 'x-slider ' + (this.vertical ? 'x-slider-vert' : 'x-slider-horz'),
cn : {
cls: 'x-slider-end',
cn : {
cls:'x-slider-inner',
cn : [{tag:'a', cls:'x-slider-focus', href:"#", tabIndex: '-1', hidefocus:'on'}]
}
}
};
Ext.slider.MultiSlider.superclass.onRender.apply(this, arguments);
this.endEl = this.el.first();
this.innerEl = this.endEl.first();
this.focusEl = this.innerEl.child('.x-slider-focus');
for (var i=0; i < this.thumbs.length; i++) {
this.thumbs[i].render();
}
var thumb = this.innerEl.child('.x-slider-thumb');
this.halfThumb = (this.vertical ? thumb.getHeight() : thumb.getWidth()) / 2;
this.initEvents();
},
initEvents : function(){
this.mon(this.el, {
scope : this,
mousedown: this.onMouseDown,
keydown : this.onKeyDown
});
this.focusEl.swallowEvent("click", true);
},
onMouseDown : function(e){
if(this.disabled){
return;
}
var thumbClicked = false;
for (var i=0; i < this.thumbs.length; i++) {
thumbClicked = thumbClicked || e.target == this.thumbs[i].el.dom;
}
if (this.clickToChange && !thumbClicked) {
var local = this.innerEl.translatePoints(e.getXY());
this.onClickChange(local);
}
this.focus();
},
onClickChange : function(local) {
if (local.top > this.clickRange[0] && local.top < this.clickRange[1]) {
var thumb = this.getNearest(local, 'left'),
index = thumb.index;
this.setValue(index, Ext.util.Format.round(this.reverseValue(local.left), this.decimalPrecision), undefined, true);
}
},
getNearest: function(local, prop) {
var localValue = prop == 'top' ? this.innerEl.getHeight() - local[prop] : local[prop],
clickValue = this.reverseValue(localValue),
nearestDistance = (this.maxValue - this.minValue) + 5,
index = 0,
nearest = null;
for (var i=0; i < this.thumbs.length; i++) {
var thumb = this.thumbs[i],
value = thumb.value,
dist = Math.abs(value - clickValue);
if (Math.abs(dist <= nearestDistance)) {
nearest = thumb;
index = i;
nearestDistance = dist;
}
}
return nearest;
},
onKeyDown : function(e){
if(this.disabled || this.thumbs.length !== 1){
e.preventDefault();
return;
}
var k = e.getKey(),
val;
switch(k){
case e.UP:
case e.RIGHT:
e.stopEvent();
val = e.ctrlKey ? this.maxValue : this.getValue(0) + this.keyIncrement;
this.setValue(0, val, undefined, true);
break;
case e.DOWN:
case e.LEFT:
e.stopEvent();
val = e.ctrlKey ? this.minValue : this.getValue(0) - this.keyIncrement;
this.setValue(0, val, undefined, true);
break;
default:
e.preventDefault();
}
},
doSnap : function(value){
if (!(this.increment && value)) {
return value;
}
var newValue = value,
inc = this.increment,
m = value % inc;
if (m != 0) {
newValue -= m;
if (m * 2 >= inc) {
newValue += inc;
} else if (m * 2 < -inc) {
newValue -= inc;
}
}
return newValue.constrain(this.minValue, this.maxValue);
},
afterRender : function(){
Ext.slider.MultiSlider.superclass.afterRender.apply(this, arguments);
for (var i=0; i < this.thumbs.length; i++) {
var thumb = this.thumbs[i];
if (thumb.value !== undefined) {
var v = this.normalizeValue(thumb.value);
if (v !== thumb.value) {
this.setValue(i, v, false);
} else {
this.moveThumb(i, this.translateValue(v), false);
}
}
};
},
getRatio : function(){
var w = this.innerEl.getWidth(),
v = this.maxValue - this.minValue;
return v == 0 ? w : (w/v);
},
normalizeValue : function(v){
v = this.doSnap(v);
v = Ext.util.Format.round(v, this.decimalPrecision);
v = v.constrain(this.minValue, this.maxValue);
return v;
},
setMinValue : function(val){
this.minValue = val;
var i = 0,
thumbs = this.thumbs,
len = thumbs.length,
t;
for(; i < len; ++i){
t = thumbs[i];
t.value = t.value < val ? val : t.value;
}
this.syncThumb();
},
setMaxValue : function(val){
this.maxValue = val;
var i = 0,
thumbs = this.thumbs,
len = thumbs.length,
t;
for(; i < len; ++i){
t = thumbs[i];
t.value = t.value > val ? val : t.value;
}
this.syncThumb();
},
setValue : function(index, v, animate, changeComplete) {
var thumb = this.thumbs[index],
el = thumb.el;
v = this.normalizeValue(v);
if (v !== thumb.value && this.fireEvent('beforechange', this, v, thumb.value, thumb) !== false) {
thumb.value = v;
if(this.rendered){
this.moveThumb(index, this.translateValue(v), animate !== false);
this.fireEvent('change', this, v, thumb);
if(changeComplete){
this.fireEvent('changecomplete', this, v, thumb);
}
}
}
},
translateValue : function(v) {
var ratio = this.getRatio();
return (v * ratio) - (this.minValue * ratio) - this.halfThumb;
},
reverseValue : function(pos){
var ratio = this.getRatio();
return (pos + (this.minValue * ratio)) / ratio;
},
moveThumb: function(index, v, animate){
var thumb = this.thumbs[index].el;
if(!animate || this.animate === false){
thumb.setLeft(v);
}else{
thumb.shift({left: v, stopFx: true, duration:.35});
}
},
focus : function(){
this.focusEl.focus(10);
},
onResize : function(w, h){
var thumbs = this.thumbs,
len = thumbs.length,
i = 0;
for(; i < len; ++i){
thumbs[i].el.stopFx();
}
if(Ext.isNumber(w)){
this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r')));
}
this.syncThumb();
Ext.slider.MultiSlider.superclass.onResize.apply(this, arguments);
},
onDisable: function(){
Ext.slider.MultiSlider.superclass.onDisable.call(this);
for (var i=0; i < this.thumbs.length; i++) {
var thumb = this.thumbs[i],
el = thumb.el;
thumb.disable();
if(Ext.isIE){
var xy = el.getXY();
el.hide();
this.innerEl.addClass(this.disabledClass).dom.disabled = true;
if (!this.thumbHolder) {
this.thumbHolder = this.endEl.createChild({cls: 'x-slider-thumb ' + this.disabledClass});
}
this.thumbHolder.show().setXY(xy);
}
}
},
onEnable: function(){
Ext.slider.MultiSlider.superclass.onEnable.call(this);
for (var i=0; i < this.thumbs.length; i++) {
var thumb = this.thumbs[i],
el = thumb.el;
thumb.enable();
if (Ext.isIE) {
this.innerEl.removeClass(this.disabledClass).dom.disabled = false;
if (this.thumbHolder) this.thumbHolder.hide();
el.show();
this.syncThumb();
}
}
},
syncThumb : function() {
if (this.rendered) {
for (var i=0; i < this.thumbs.length; i++) {
this.moveThumb(i, this.translateValue(this.thumbs[i].value));
}
}
},
getValue : function(index) {
return this.thumbs[index].value;
},
getValues: function() {
var values = [];
for (var i=0; i < this.thumbs.length; i++) {
values.push(this.thumbs[i].value);
}
return values;
},
beforeDestroy : function(){
var thumbs = this.thumbs;
for(var i = 0, len = thumbs.length; i < len; ++i){
thumbs[i].destroy();
thumbs[i] = null;
}
Ext.destroyMembers(this, 'endEl', 'innerEl', 'focusEl', 'thumbHolder');
Ext.slider.MultiSlider.superclass.beforeDestroy.call(this);
}
});
Ext.reg('multislider', Ext.slider.MultiSlider);
Ext.slider.SingleSlider = Ext.extend(Ext.slider.MultiSlider, {
constructor: function(config) {
config = config || {};
Ext.applyIf(config, {
values: [config.value || 0]
});
Ext.slider.SingleSlider.superclass.constructor.call(this, config);
},
getValue: function() {
return Ext.slider.SingleSlider.superclass.getValue.call(this, 0);
},
setValue: function(value, animate) {
var args = Ext.toArray(arguments),
len = args.length;
if (len == 1 || (len <= 3 && typeof arguments[1] != 'number')) {
args.unshift(0);
}
return Ext.slider.SingleSlider.superclass.setValue.apply(this, args);
},
syncThumb : function() {
return Ext.slider.SingleSlider.superclass.syncThumb.apply(this, [0].concat(arguments));
},
getNearest : function(){
return this.thumbs[0];
}
});
Ext.Slider = Ext.slider.SingleSlider;
Ext.reg('slider', Ext.slider.SingleSlider);
Ext.slider.Vertical = {
onResize : function(w, h){
this.innerEl.setHeight(h - (this.el.getPadding('t') + this.endEl.getPadding('b')));
this.syncThumb();
},
getRatio : function(){
var h = this.innerEl.getHeight(),
v = this.maxValue - this.minValue;
return h/v;
},
moveThumb: function(index, v, animate) {
var thumb = this.thumbs[index],
el = thumb.el;
if (!animate || this.animate === false) {
el.setBottom(v);
} else {
el.shift({bottom: v, stopFx: true, duration:.35});
}
},
onClickChange : function(local) {
if (local.left > this.clickRange[0] && local.left < this.clickRange[1]) {
var thumb = this.getNearest(local, 'top'),
index = thumb.index,
value = this.minValue + this.reverseValue(this.innerEl.getHeight() - local.top);
this.setValue(index, Ext.util.Format.round(value, this.decimalPrecision), undefined, true);
}
}
};
Ext.slider.Thumb.Vertical = {
getNewValue: function() {
var slider = this.slider,
innerEl = slider.innerEl,
pos = innerEl.translatePoints(this.tracker.getXY()),
bottom = innerEl.getHeight() - pos.top;
return slider.minValue + Ext.util.Format.round(bottom / slider.getRatio(), slider.decimalPrecision);
}
};
Ext.ProgressBar = Ext.extend(Ext.BoxComponent, {
baseCls : 'x-progress',
animate : false,
waitTimer : null,
initComponent : function(){
Ext.ProgressBar.superclass.initComponent.call(this);
this.addEvents(
"update"
);
},
onRender : function(ct, position){
var tpl = new Ext.Template(
'<div class="{cls}-wrap">',
'<div class="{cls}-inner">',
'<div class="{cls}-bar">',
'<div class="{cls}-text">',
'<div>&#160;</div>',
'</div>',
'</div>',
'<div class="{cls}-text {cls}-text-back">',
'<div>&#160;</div>',
'</div>',
'</div>',
'</div>'
);
this.el = position ? tpl.insertBefore(position, {cls: this.baseCls}, true)
: tpl.append(ct, {cls: this.baseCls}, true);
if(this.id){
this.el.dom.id = this.id;
}
var inner = this.el.dom.firstChild;
this.progressBar = Ext.get(inner.firstChild);
if(this.textEl){
this.textEl = Ext.get(this.textEl);
delete this.textTopEl;
}else{
this.textTopEl = Ext.get(this.progressBar.dom.firstChild);
var textBackEl = Ext.get(inner.childNodes[1]);
this.textTopEl.setStyle("z-index", 99).addClass('x-hidden');
this.textEl = new Ext.CompositeElement([this.textTopEl.dom.firstChild, textBackEl.dom.firstChild]);
this.textEl.setWidth(inner.offsetWidth);
}
this.progressBar.setHeight(inner.offsetHeight);
},
afterRender : function(){
Ext.ProgressBar.superclass.afterRender.call(this);
if(this.value){
this.updateProgress(this.value, this.text);
}else{
this.updateText(this.text);
}
},
updateProgress : function(value, text, animate){
this.value = value || 0;
if(text){
this.updateText(text);
}
if(this.rendered && !this.isDestroyed){
var w = Math.floor(value*this.el.dom.firstChild.offsetWidth);
this.progressBar.setWidth(w, animate === true || (animate !== false && this.animate));
if(this.textTopEl){
this.textTopEl.removeClass('x-hidden').setWidth(w);
}
}
this.fireEvent('update', this, value, text);
return this;
},
wait : function(o){
if(!this.waitTimer){
var scope = this;
o = o || {};
this.updateText(o.text);
this.waitTimer = Ext.TaskMgr.start({
run: function(i){
var inc = o.increment || 10;
i -= 1;
this.updateProgress(((((i+inc)%inc)+1)*(100/inc))*0.01, null, o.animate);
},
interval: o.interval || 1000,
duration: o.duration,
onStop: function(){
if(o.fn){
o.fn.apply(o.scope || this);
}
this.reset();
},
scope: scope
});
}
return this;
},
isWaiting : function(){
return this.waitTimer !== null;
},
updateText : function(text){
this.text = text || '&#160;';
if(this.rendered){
this.textEl.update(this.text);
}
return this;
},
syncProgressBar : function(){
if(this.value){
this.updateProgress(this.value, this.text);
}
return this;
},
setSize : function(w, h){
Ext.ProgressBar.superclass.setSize.call(this, w, h);
if(this.textTopEl){
var inner = this.el.dom.firstChild;
this.textEl.setSize(inner.offsetWidth, inner.offsetHeight);
}
this.syncProgressBar();
return this;
},
reset : function(hide){
this.updateProgress(0);
if(this.textTopEl){
this.textTopEl.addClass('x-hidden');
}
this.clearTimer();
if(hide === true){
this.hide();
}
return this;
},
clearTimer : function(){
if(this.waitTimer){
this.waitTimer.onStop = null;
Ext.TaskMgr.stop(this.waitTimer);
this.waitTimer = null;
}
},
onDestroy: function(){
this.clearTimer();
if(this.rendered){
if(this.textEl.isComposite){
this.textEl.clear();
}
Ext.destroyMembers(this, 'textEl', 'progressBar', 'textTopEl');
}
Ext.ProgressBar.superclass.onDestroy.call(this);
}
});
Ext.reg('progress', Ext.ProgressBar);
(function() {
var Event=Ext.EventManager;
var Dom=Ext.lib.Dom;
Ext.dd.DragDrop = function(id, sGroup, config) {
if(id) {
this.init(id, sGroup, config);
}
};
Ext.dd.DragDrop.prototype = {
id: null,
config: null,
dragElId: null,
handleElId: null,
invalidHandleTypes: null,
invalidHandleIds: null,
invalidHandleClasses: null,
startPageX: 0,
startPageY: 0,
groups: null,
locked: false,
lock: function() {
this.locked = true;
},
moveOnly: false,
unlock: function() {
this.locked = false;
},
isTarget: true,
padding: null,
_domRef: null,
__ygDragDrop: true,
constrainX: false,
constrainY: false,
minX: 0,
maxX: 0,
minY: 0,
maxY: 0,
maintainOffset: false,
xTicks: null,
yTicks: null,
primaryButtonOnly: true,
available: false,
hasOuterHandles: false,
b4StartDrag: function(x, y) { },
startDrag: function(x, y) { },
b4Drag: function(e) { },
onDrag: function(e) { },
onDragEnter: function(e, id) { },
b4DragOver: function(e) { },
onDragOver: function(e, id) { },
b4DragOut: function(e) { },
onDragOut: function(e, id) { },
b4DragDrop: function(e) { },
onDragDrop: function(e, id) { },
onInvalidDrop: function(e) { },
b4EndDrag: function(e) { },
endDrag: function(e) { },
b4MouseDown: function(e) { },
onMouseDown: function(e) { },
onMouseUp: function(e) { },
onAvailable: function () {
},
defaultPadding : {left:0, right:0, top:0, bottom:0},
constrainTo : function(constrainTo, pad, inContent){
if(Ext.isNumber(pad)){
pad = {left: pad, right:pad, top:pad, bottom:pad};
}
pad = pad || this.defaultPadding;
var b = Ext.get(this.getEl()).getBox(),
ce = Ext.get(constrainTo),
s = ce.getScroll(),
c,
cd = ce.dom;
if(cd == document.body){
c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
}else{
var xy = ce.getXY();
c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};
}
var topSpace = b.y - c.y,
leftSpace = b.x - c.x;
this.resetConstraints();
this.setXConstraint(leftSpace - (pad.left||0),
c.width - leftSpace - b.width - (pad.right||0),
this.xTickSize
);
this.setYConstraint(topSpace - (pad.top||0),
c.height - topSpace - b.height - (pad.bottom||0),
this.yTickSize
);
},
getEl: function() {
if (!this._domRef) {
this._domRef = Ext.getDom(this.id);
}
return this._domRef;
},
getDragEl: function() {
return Ext.getDom(this.dragElId);
},
init: function(id, sGroup, config) {
this.initTarget(id, sGroup, config);
Event.on(this.id, "mousedown", this.handleMouseDown, this);
},
initTarget: function(id, sGroup, config) {
this.config = config || {};
this.DDM = Ext.dd.DDM;
this.groups = {};
if (typeof id !== "string") {
id = Ext.id(id);
}
this.id = id;
this.addToGroup((sGroup) ? sGroup : "default");
this.handleElId = id;
this.setDragElId(id);
this.invalidHandleTypes = { A: "A" };
this.invalidHandleIds = {};
this.invalidHandleClasses = [];
this.applyConfig();
this.handleOnAvailable();
},
applyConfig: function() {
this.padding = this.config.padding || [0, 0, 0, 0];
this.isTarget = (this.config.isTarget !== false);
this.maintainOffset = (this.config.maintainOffset);
this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
},
handleOnAvailable: function() {
this.available = true;
this.resetConstraints();
this.onAvailable();
},
setPadding: function(iTop, iRight, iBot, iLeft) {
if (!iRight && 0 !== iRight) {
this.padding = [iTop, iTop, iTop, iTop];
} else if (!iBot && 0 !== iBot) {
this.padding = [iTop, iRight, iTop, iRight];
} else {
this.padding = [iTop, iRight, iBot, iLeft];
}
},
setInitPosition: function(diffX, diffY) {
var el = this.getEl();
if (!this.DDM.verifyEl(el)) {
return;
}
var dx = diffX || 0;
var dy = diffY || 0;
var p = Dom.getXY( el );
this.initPageX = p[0] - dx;
this.initPageY = p[1] - dy;
this.lastPageX = p[0];
this.lastPageY = p[1];
this.setStartPosition(p);
},
setStartPosition: function(pos) {
var p = pos || Dom.getXY( this.getEl() );
this.deltaSetXY = null;
this.startPageX = p[0];
this.startPageY = p[1];
},
addToGroup: function(sGroup) {
this.groups[sGroup] = true;
this.DDM.regDragDrop(this, sGroup);
},
removeFromGroup: function(sGroup) {
if (this.groups[sGroup]) {
delete this.groups[sGroup];
}
this.DDM.removeDDFromGroup(this, sGroup);
},
setDragElId: function(id) {
this.dragElId = id;
},
setHandleElId: function(id) {
if (typeof id !== "string") {
id = Ext.id(id);
}
this.handleElId = id;
this.DDM.regHandle(this.id, id);
},
setOuterHandleElId: function(id) {
if (typeof id !== "string") {
id = Ext.id(id);
}
Event.on(id, "mousedown",
this.handleMouseDown, this);
this.setHandleElId(id);
this.hasOuterHandles = true;
},
unreg: function() {
Event.un(this.id, "mousedown",
this.handleMouseDown);
this._domRef = null;
this.DDM._remove(this);
},
destroy : function(){
this.unreg();
},
isLocked: function() {
return (this.DDM.isLocked() || this.locked);
},
handleMouseDown: function(e, oDD){
if (this.primaryButtonOnly && e.button != 0) {
return;
}
if (this.isLocked()) {
return;
}
this.DDM.refreshCache(this.groups);
var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
} else {
if (this.clickValidator(e)) {
this.setStartPosition();
this.b4MouseDown(e);
this.onMouseDown(e);
this.DDM.handleMouseDown(e, this);
this.DDM.stopEvent(e);
} else {
}
}
},
clickValidator: function(e) {
var target = e.getTarget();
return ( this.isValidHandleChild(target) &&
(this.id == this.handleElId ||
this.DDM.handleWasClicked(target, this.id)) );
},
addInvalidHandleType: function(tagName) {
var type = tagName.toUpperCase();
this.invalidHandleTypes[type] = type;
},
addInvalidHandleId: function(id) {
if (typeof id !== "string") {
id = Ext.id(id);
}
this.invalidHandleIds[id] = id;
},
addInvalidHandleClass: function(cssClass) {
this.invalidHandleClasses.push(cssClass);
},
removeInvalidHandleType: function(tagName) {
var type = tagName.toUpperCase();
delete this.invalidHandleTypes[type];
},
removeInvalidHandleId: function(id) {
if (typeof id !== "string") {
id = Ext.id(id);
}
delete this.invalidHandleIds[id];
},
removeInvalidHandleClass: function(cssClass) {
for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
if (this.invalidHandleClasses[i] == cssClass) {
delete this.invalidHandleClasses[i];
}
}
},
isValidHandleChild: function(node) {
var valid = true;
var nodeName;
try {
nodeName = node.nodeName.toUpperCase();
} catch(e) {
nodeName = node.nodeName;
}
valid = valid && !this.invalidHandleTypes[nodeName];
valid = valid && !this.invalidHandleIds[node.id];
for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
}
return valid;
},
setXTicks: function(iStartX, iTickSize) {
this.xTicks = [];
this.xTickSize = iTickSize;
var tickMap = {};
for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
if (!tickMap[i]) {
this.xTicks[this.xTicks.length] = i;
tickMap[i] = true;
}
}
for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
if (!tickMap[i]) {
this.xTicks[this.xTicks.length] = i;
tickMap[i] = true;
}
}
this.xTicks.sort(this.DDM.numericSort) ;
},
setYTicks: function(iStartY, iTickSize) {
this.yTicks = [];
this.yTickSize = iTickSize;
var tickMap = {};
for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
if (!tickMap[i]) {
this.yTicks[this.yTicks.length] = i;
tickMap[i] = true;
}
}
for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
if (!tickMap[i]) {
this.yTicks[this.yTicks.length] = i;
tickMap[i] = true;
}
}
this.yTicks.sort(this.DDM.numericSort) ;
},
setXConstraint: function(iLeft, iRight, iTickSize) {
this.leftConstraint = iLeft;
this.rightConstraint = iRight;
this.minX = this.initPageX - iLeft;
this.maxX = this.initPageX + iRight;
if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
this.constrainX = true;
},
clearConstraints: function() {
this.constrainX = false;
this.constrainY = false;
this.clearTicks();
},
clearTicks: function() {
this.xTicks = null;
this.yTicks = null;
this.xTickSize = 0;
this.yTickSize = 0;
},
setYConstraint: function(iUp, iDown, iTickSize) {
this.topConstraint = iUp;
this.bottomConstraint = iDown;
this.minY = this.initPageY - iUp;
this.maxY = this.initPageY + iDown;
if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
this.constrainY = true;
},
resetConstraints: function() {
if (this.initPageX || this.initPageX === 0) {
var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
this.setInitPosition(dx, dy);
} else {
this.setInitPosition();
}
if (this.constrainX) {
this.setXConstraint( this.leftConstraint,
this.rightConstraint,
this.xTickSize );
}
if (this.constrainY) {
this.setYConstraint( this.topConstraint,
this.bottomConstraint,
this.yTickSize );
}
},
getTick: function(val, tickArray) {
if (!tickArray) {
return val;
} else if (tickArray[0] >= val) {
return tickArray[0];
} else {
for (var i=0, len=tickArray.length; i<len; ++i) {
var next = i + 1;
if (tickArray[next] && tickArray[next] >= val) {
var diff1 = val - tickArray[i];
var diff2 = tickArray[next] - val;
return (diff2 > diff1) ? tickArray[i] : tickArray[next];
}
}
return tickArray[tickArray.length - 1];
}
},
toString: function() {
return ("DragDrop " + this.id);
}
};
})();
if (!Ext.dd.DragDropMgr) {
Ext.dd.DragDropMgr = function() {
var Event = Ext.EventManager;
return {
ids: {},
handleIds: {},
dragCurrent: null,
dragOvers: {},
deltaX: 0,
deltaY: 0,
preventDefault: true,
stopPropagation: true,
initialized: false,
locked: false,
init: function() {
this.initialized = true;
},
POINT: 0,
INTERSECT: 1,
mode: 0,
_execOnAll: function(sMethod, args) {
for (var i in this.ids) {
for (var j in this.ids[i]) {
var oDD = this.ids[i][j];
if (! this.isTypeOfDD(oDD)) {
continue;
}
oDD[sMethod].apply(oDD, args);
}
}
},
_onLoad: function() {
this.init();
Event.on(document, "mouseup", this.handleMouseUp, this, true);
Event.on(document, "mousemove", this.handleMouseMove, this, true);
Event.on(window, "unload", this._onUnload, this, true);
Event.on(window, "resize", this._onResize, this, true);
},
_onResize: function(e) {
this._execOnAll("resetConstraints", []);
},
lock: function() { this.locked = true; },
unlock: function() { this.locked = false; },
isLocked: function() { return this.locked; },
locationCache: {},
useCache: true,
clickPixelThresh: 3,
clickTimeThresh: 350,
dragThreshMet: false,
clickTimeout: null,
startX: 0,
startY: 0,
regDragDrop: function(oDD, sGroup) {
if (!this.initialized) { this.init(); }
if (!this.ids[sGroup]) {
this.ids[sGroup] = {};
}
this.ids[sGroup][oDD.id] = oDD;
},
removeDDFromGroup: function(oDD, sGroup) {
if (!this.ids[sGroup]) {
this.ids[sGroup] = {};
}
var obj = this.ids[sGroup];
if (obj && obj[oDD.id]) {
delete obj[oDD.id];
}
},
_remove: function(oDD) {
for (var g in oDD.groups) {
if (g && this.ids[g] && this.ids[g][oDD.id]) {
delete this.ids[g][oDD.id];
}
}
delete this.handleIds[oDD.id];
},
regHandle: function(sDDId, sHandleId) {
if (!this.handleIds[sDDId]) {
this.handleIds[sDDId] = {};
}
this.handleIds[sDDId][sHandleId] = sHandleId;
},
isDragDrop: function(id) {
return ( this.getDDById(id) ) ? true : false;
},
getRelated: function(p_oDD, bTargetsOnly) {
var oDDs = [];
for (var i in p_oDD.groups) {
for (var j in this.ids[i]) {
var dd = this.ids[i][j];
if (! this.isTypeOfDD(dd)) {
continue;
}
if (!bTargetsOnly || dd.isTarget) {
oDDs[oDDs.length] = dd;
}
}
}
return oDDs;
},
isLegalTarget: function (oDD, oTargetDD) {
var targets = this.getRelated(oDD, true);
for (var i=0, len=targets.length;i<len;++i) {
if (targets[i].id == oTargetDD.id) {
return true;
}
}
return false;
},
isTypeOfDD: function (oDD) {
return (oDD && oDD.__ygDragDrop);
},
isHandle: function(sDDId, sHandleId) {
return ( this.handleIds[sDDId] &&
this.handleIds[sDDId][sHandleId] );
},
getDDById: function(id) {
for (var i in this.ids) {
if (this.ids[i][id]) {
return this.ids[i][id];
}
}
return null;
},
handleMouseDown: function(e, oDD) {
if(Ext.QuickTips){
Ext.QuickTips.ddDisable();
}
if(this.dragCurrent){
this.handleMouseUp(e);
}
this.currentTarget = e.getTarget();
this.dragCurrent = oDD;
var el = oDD.getEl();
this.startX = e.getPageX();
this.startY = e.getPageY();
this.deltaX = this.startX - el.offsetLeft;
this.deltaY = this.startY - el.offsetTop;
this.dragThreshMet = false;
this.clickTimeout = setTimeout(
function() {
var DDM = Ext.dd.DDM;
DDM.startDrag(DDM.startX, DDM.startY);
},
this.clickTimeThresh );
},
startDrag: function(x, y) {
clearTimeout(this.clickTimeout);
if (this.dragCurrent) {
this.dragCurrent.b4StartDrag(x, y);
this.dragCurrent.startDrag(x, y);
}
this.dragThreshMet = true;
},
handleMouseUp: function(e) {
if(Ext.QuickTips){
Ext.QuickTips.ddEnable();
}
if (! this.dragCurrent) {
return;
}
clearTimeout(this.clickTimeout);
if (this.dragThreshMet) {
this.fireEvents(e, true);
} else {
}
this.stopDrag(e);
this.stopEvent(e);
},
stopEvent: function(e){
if(this.stopPropagation) {
e.stopPropagation();
}
if (this.preventDefault) {
e.preventDefault();
}
},
stopDrag: function(e) {
if (this.dragCurrent) {
if (this.dragThreshMet) {
this.dragCurrent.b4EndDrag(e);
this.dragCurrent.endDrag(e);
}
this.dragCurrent.onMouseUp(e);
}
this.dragCurrent = null;
this.dragOvers = {};
},
handleMouseMove: function(e) {
if (! this.dragCurrent) {
return true;
}
if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
this.stopEvent(e);
return this.handleMouseUp(e);
}
if (!this.dragThreshMet) {
var diffX = Math.abs(this.startX - e.getPageX());
var diffY = Math.abs(this.startY - e.getPageY());
if (diffX > this.clickPixelThresh ||
diffY > this.clickPixelThresh) {
this.startDrag(this.startX, this.startY);
}
}
if (this.dragThreshMet) {
this.dragCurrent.b4Drag(e);
this.dragCurrent.onDrag(e);
if(!this.dragCurrent.moveOnly){
this.fireEvents(e, false);
}
}
this.stopEvent(e);
return true;
},
fireEvents: function(e, isDrop) {
var dc = this.dragCurrent;
if (!dc || dc.isLocked()) {
return;
}
var pt = e.getPoint();
var oldOvers = [];
var outEvts = [];
var overEvts = [];
var dropEvts = [];
var enterEvts = [];
for (var i in this.dragOvers) {
var ddo = this.dragOvers[i];
if (! this.isTypeOfDD(ddo)) {
continue;
}
if (! this.isOverTarget(pt, ddo, this.mode)) {
outEvts.push( ddo );
}
oldOvers[i] = true;
delete this.dragOvers[i];
}
for (var sGroup in dc.groups) {
if ("string" != typeof sGroup) {
continue;
}
for (i in this.ids[sGroup]) {
var oDD = this.ids[sGroup][i];
if (! this.isTypeOfDD(oDD)) {
continue;
}
if (oDD.isTarget && !oDD.isLocked() && ((oDD != dc) || (dc.ignoreSelf === false))) {
if (this.isOverTarget(pt, oDD, this.mode)) {
if (isDrop) {
dropEvts.push( oDD );
} else {
if (!oldOvers[oDD.id]) {
enterEvts.push( oDD );
} else {
overEvts.push( oDD );
}
this.dragOvers[oDD.id] = oDD;
}
}
}
}
}
if (this.mode) {
if (outEvts.length) {
dc.b4DragOut(e, outEvts);
dc.onDragOut(e, outEvts);
}
if (enterEvts.length) {
dc.onDragEnter(e, enterEvts);
}
if (overEvts.length) {
dc.b4DragOver(e, overEvts);
dc.onDragOver(e, overEvts);
}
if (dropEvts.length) {
dc.b4DragDrop(e, dropEvts);
dc.onDragDrop(e, dropEvts);
}
} else {
var len = 0;
for (i=0, len=outEvts.length; i<len; ++i) {
dc.b4DragOut(e, outEvts[i].id);
dc.onDragOut(e, outEvts[i].id);
}
for (i=0,len=enterEvts.length; i<len; ++i) {
dc.onDragEnter(e, enterEvts[i].id);
}
for (i=0,len=overEvts.length; i<len; ++i) {
dc.b4DragOver(e, overEvts[i].id);
dc.onDragOver(e, overEvts[i].id);
}
for (i=0, len=dropEvts.length; i<len; ++i) {
dc.b4DragDrop(e, dropEvts[i].id);
dc.onDragDrop(e, dropEvts[i].id);
}
}
if (isDrop && !dropEvts.length) {
dc.onInvalidDrop(e);
}
},
getBestMatch: function(dds) {
var winner = null;
var len = dds.length;
if (len == 1) {
winner = dds[0];
} else {
for (var i=0; i<len; ++i) {
var dd = dds[i];
if (dd.cursorIsOver) {
winner = dd;
break;
} else {
if (!winner ||
winner.overlap.getArea() < dd.overlap.getArea()) {
winner = dd;
}
}
}
}
return winner;
},
refreshCache: function(groups) {
for (var sGroup in groups) {
if ("string" != typeof sGroup) {
continue;
}
for (var i in this.ids[sGroup]) {
var oDD = this.ids[sGroup][i];
if (this.isTypeOfDD(oDD)) {
var loc = this.getLocation(oDD);
if (loc) {
this.locationCache[oDD.id] = loc;
} else {
delete this.locationCache[oDD.id];
}
}
}
}
},
verifyEl: function(el) {
if (el) {
var parent;
if(Ext.isIE){
try{
parent = el.offsetParent;
}catch(e){}
}else{
parent = el.offsetParent;
}
if (parent) {
return true;
}
}
return false;
},
getLocation: function(oDD) {
if (! this.isTypeOfDD(oDD)) {
return null;
}
var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l, region;
try {
pos= Ext.lib.Dom.getXY(el);
} catch (e) { }
if (!pos) {
return null;
}
x1 = pos[0];
x2 = x1 + el.offsetWidth;
y1 = pos[1];
y2 = y1 + el.offsetHeight;
t = y1 - oDD.padding[0];
r = x2 + oDD.padding[1];
b = y2 + oDD.padding[2];
l = x1 - oDD.padding[3];
region = new Ext.lib.Region( t, r, b, l );
el = Ext.get(el.parentNode);
while (el && region) {
if (el.isScrollable()) {
region = region.intersect(el.getRegion());
}
el = el.parent();
}
return region;
},
isOverTarget: function(pt, oTarget, intersect) {
var loc = this.locationCache[oTarget.id];
if (!loc || !this.useCache) {
loc = this.getLocation(oTarget);
this.locationCache[oTarget.id] = loc;
}
if (!loc) {
return false;
}
oTarget.cursorIsOver = loc.contains( pt );
var dc = this.dragCurrent;
if (!dc || !dc.getTargetCoord ||
(!intersect && !dc.constrainX && !dc.constrainY)) {
return oTarget.cursorIsOver;
}
oTarget.overlap = null;
var pos = dc.getTargetCoord(pt.x, pt.y);
var el = dc.getDragEl();
var curRegion = new Ext.lib.Region( pos.y,
pos.x + el.offsetWidth,
pos.y + el.offsetHeight,
pos.x );
var overlap = curRegion.intersect(loc);
if (overlap) {
oTarget.overlap = overlap;
return (intersect) ? true : oTarget.cursorIsOver;
} else {
return false;
}
},
_onUnload: function(e, me) {
Event.removeListener(document, "mouseup", this.handleMouseUp, this);
Event.removeListener(document, "mousemove", this.handleMouseMove, this);
Event.removeListener(window, "resize", this._onResize, this);
Ext.dd.DragDropMgr.unregAll();
},
unregAll: function() {
if (this.dragCurrent) {
this.stopDrag();
this.dragCurrent = null;
}
this._execOnAll("unreg", []);
for (var i in this.elementCache) {
delete this.elementCache[i];
}
this.elementCache = {};
this.ids = {};
},
elementCache: {},
getElWrapper: function(id) {
var oWrapper = this.elementCache[id];
if (!oWrapper || !oWrapper.el) {
oWrapper = this.elementCache[id] =
new this.ElementWrapper(Ext.getDom(id));
}
return oWrapper;
},
getElement: function(id) {
return Ext.getDom(id);
},
getCss: function(id) {
var el = Ext.getDom(id);
return (el) ? el.style : null;
},
ElementWrapper: function(el) {
this.el = el || null;
this.id = this.el && el.id;
this.css = this.el && el.style;
},
getPosX: function(el) {
return Ext.lib.Dom.getX(el);
},
getPosY: function(el) {
return Ext.lib.Dom.getY(el);
},
swapNode: function(n1, n2) {
if (n1.swapNode) {
n1.swapNode(n2);
} else {
var p = n2.parentNode;
var s = n2.nextSibling;
if (s == n1) {
p.insertBefore(n1, n2);
} else if (n2 == n1.nextSibling) {
p.insertBefore(n2, n1);
} else {
n1.parentNode.replaceChild(n2, n1);
p.insertBefore(n1, s);
}
}
},
getScroll: function () {
var t, l, dde=document.documentElement, db=document.body;
if (dde && (dde.scrollTop || dde.scrollLeft)) {
t = dde.scrollTop;
l = dde.scrollLeft;
} else if (db) {
t = db.scrollTop;
l = db.scrollLeft;
} else {
}
return { top: t, left: l };
},
getStyle: function(el, styleProp) {
return Ext.fly(el).getStyle(styleProp);
},
getScrollTop: function () {
return this.getScroll().top;
},
getScrollLeft: function () {
return this.getScroll().left;
},
moveToEl: function (moveEl, targetEl) {
var aCoord = Ext.lib.Dom.getXY(targetEl);
Ext.lib.Dom.setXY(moveEl, aCoord);
},
numericSort: function(a, b) {
return (a - b);
},
_timeoutCount: 0,
_addListeners: function() {
var DDM = Ext.dd.DDM;
if ( Ext.lib.Event && document ) {
DDM._onLoad();
} else {
if (DDM._timeoutCount > 2000) {
} else {
setTimeout(DDM._addListeners, 10);
if (document && document.body) {
DDM._timeoutCount += 1;
}
}
}
},
handleWasClicked: function(node, id) {
if (this.isHandle(id, node.id)) {
return true;
} else {
var p = node.parentNode;
while (p) {
if (this.isHandle(id, p.id)) {
return true;
} else {
p = p.parentNode;
}
}
}
return false;
}
};
}();
Ext.dd.DDM = Ext.dd.DragDropMgr;
Ext.dd.DDM._addListeners();
}
Ext.dd.DD = function(id, sGroup, config) {
if (id) {
this.init(id, sGroup, config);
}
};
Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
scroll: true,
autoOffset: function(iPageX, iPageY) {
var x = iPageX - this.startPageX;
var y = iPageY - this.startPageY;
this.setDelta(x, y);
},
setDelta: function(iDeltaX, iDeltaY) {
this.deltaX = iDeltaX;
this.deltaY = iDeltaY;
},
setDragElPos: function(iPageX, iPageY) {
var el = this.getDragEl();
this.alignElWithMouse(el, iPageX, iPageY);
},
alignElWithMouse: function(el, iPageX, iPageY) {
var oCoord = this.getTargetCoord(iPageX, iPageY);
var fly = el.dom ? el : Ext.fly(el, '_dd');
if (!this.deltaSetXY) {
var aCoord = [oCoord.x, oCoord.y];
fly.setXY(aCoord);
var newLeft = fly.getLeft(true);
var newTop = fly.getTop(true);
this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
} else {
fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
}
this.cachePosition(oCoord.x, oCoord.y);
this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
return oCoord;
},
cachePosition: function(iPageX, iPageY) {
if (iPageX) {
this.lastPageX = iPageX;
this.lastPageY = iPageY;
} else {
var aCoord = Ext.lib.Dom.getXY(this.getEl());
this.lastPageX = aCoord[0];
this.lastPageY = aCoord[1];
}
},
autoScroll: function(x, y, h, w) {
if (this.scroll) {
var clientH = Ext.lib.Dom.getViewHeight();
var clientW = Ext.lib.Dom.getViewWidth();
var st = this.DDM.getScrollTop();
var sl = this.DDM.getScrollLeft();
var bot = h + y;
var right = w + x;
var toBot = (clientH + st - y - this.deltaY);
var toRight = (clientW + sl - x - this.deltaX);
var thresh = 40;
var scrAmt = (document.all) ? 80 : 30;
if ( bot > clientH && toBot < thresh ) {
window.scrollTo(sl, st + scrAmt);
}
if ( y < st && st > 0 && y - st < thresh ) {
window.scrollTo(sl, st - scrAmt);
}
if ( right > clientW && toRight < thresh ) {
window.scrollTo(sl + scrAmt, st);
}
if ( x < sl && sl > 0 && x - sl < thresh ) {
window.scrollTo(sl - scrAmt, st);
}
}
},
getTargetCoord: function(iPageX, iPageY) {
var x = iPageX - this.deltaX;
var y = iPageY - this.deltaY;
if (this.constrainX) {
if (x < this.minX) { x = this.minX; }
if (x > this.maxX) { x = this.maxX; }
}
if (this.constrainY) {
if (y < this.minY) { y = this.minY; }
if (y > this.maxY) { y = this.maxY; }
}
x = this.getTick(x, this.xTicks);
y = this.getTick(y, this.yTicks);
return {x:x, y:y};
},
applyConfig: function() {
Ext.dd.DD.superclass.applyConfig.call(this);
this.scroll = (this.config.scroll !== false);
},
b4MouseDown: function(e) {
this.autoOffset(e.getPageX(),
e.getPageY());
},
b4Drag: function(e) {
this.setDragElPos(e.getPageX(),
e.getPageY());
},
toString: function() {
return ("DD " + this.id);
}
});
Ext.dd.DDProxy = function(id, sGroup, config) {
if (id) {
this.init(id, sGroup, config);
this.initFrame();
}
};
Ext.dd.DDProxy.dragElId = "ygddfdiv";
Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
resizeFrame: true,
centerFrame: false,
createFrame: function() {
var self = this;
var body = document.body;
if (!body || !body.firstChild) {
setTimeout( function() { self.createFrame(); }, 50 );
return;
}
var div = this.getDragEl();
if (!div) {
div = document.createElement("div");
div.id = this.dragElId;
var s = div.style;
s.position = "absolute";
s.visibility = "hidden";
s.cursor = "move";
s.border = "2px solid #aaa";
s.zIndex = 999;
body.insertBefore(div, body.firstChild);
}
},
initFrame: function() {
this.createFrame();
},
applyConfig: function() {
Ext.dd.DDProxy.superclass.applyConfig.call(this);
this.resizeFrame = (this.config.resizeFrame !== false);
this.centerFrame = (this.config.centerFrame);
this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
},
showFrame: function(iPageX, iPageY) {
var el = this.getEl();
var dragEl = this.getDragEl();
var s = dragEl.style;
this._resizeProxy();
if (this.centerFrame) {
this.setDelta( Math.round(parseInt(s.width, 10)/2),
Math.round(parseInt(s.height, 10)/2) );
}
this.setDragElPos(iPageX, iPageY);
Ext.fly(dragEl).show();
},
_resizeProxy: function() {
if (this.resizeFrame) {
var el = this.getEl();
Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
}
},
b4MouseDown: function(e) {
var x = e.getPageX();
var y = e.getPageY();
this.autoOffset(x, y);
this.setDragElPos(x, y);
},
b4StartDrag: function(x, y) {
this.showFrame(x, y);
},
b4EndDrag: function(e) {
Ext.fly(this.getDragEl()).hide();
},
endDrag: function(e) {
var lel = this.getEl();
var del = this.getDragEl();
del.style.visibility = "";
this.beforeMove();
lel.style.visibility = "hidden";
Ext.dd.DDM.moveToEl(lel, del);
del.style.visibility = "hidden";
lel.style.visibility = "";
this.afterDrag();
},
beforeMove : function(){
},
afterDrag : function(){
},
toString: function() {
return ("DDProxy " + this.id);
}
});
Ext.dd.DDTarget = function(id, sGroup, config) {
if (id) {
this.initTarget(id, sGroup, config);
}
};
Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
getDragEl: Ext.emptyFn,
isValidHandleChild: Ext.emptyFn,
startDrag: Ext.emptyFn,
endDrag: Ext.emptyFn,
onDrag: Ext.emptyFn,
onDragDrop: Ext.emptyFn,
onDragEnter: Ext.emptyFn,
onDragOut: Ext.emptyFn,
onDragOver: Ext.emptyFn,
onInvalidDrop: Ext.emptyFn,
onMouseDown: Ext.emptyFn,
onMouseUp: Ext.emptyFn,
setXConstraint: Ext.emptyFn,
setYConstraint: Ext.emptyFn,
resetConstraints: Ext.emptyFn,
clearConstraints: Ext.emptyFn,
clearTicks: Ext.emptyFn,
setInitPosition: Ext.emptyFn,
setDragElId: Ext.emptyFn,
setHandleElId: Ext.emptyFn,
setOuterHandleElId: Ext.emptyFn,
addInvalidHandleClass: Ext.emptyFn,
addInvalidHandleId: Ext.emptyFn,
addInvalidHandleType: Ext.emptyFn,
removeInvalidHandleClass: Ext.emptyFn,
removeInvalidHandleId: Ext.emptyFn,
removeInvalidHandleType: Ext.emptyFn,
toString: function() {
return ("DDTarget " + this.id);
}
});
Ext.dd.DragTracker = Ext.extend(Ext.util.Observable, {
active: false,
tolerance: 5,
autoStart: false,
constructor : function(config){
Ext.apply(this, config);
this.addEvents(
'mousedown',
'mouseup',
'mousemove',
'dragstart',
'dragend',
'drag'
);
this.dragRegion = new Ext.lib.Region(0,0,0,0);
if(this.el){
this.initEl(this.el);
}
Ext.dd.DragTracker.superclass.constructor.call(this, config);
},
initEl: function(el){
this.el = Ext.get(el);
el.on('mousedown', this.onMouseDown, this,
this.delegate ? {delegate: this.delegate} : undefined);
},
destroy : function(){
this.el.un('mousedown', this.onMouseDown, this);
delete this.el;
},
onMouseDown: function(e, target){
if(this.fireEvent('mousedown', this, e) !== false && this.onBeforeStart(e) !== false){
this.startXY = this.lastXY = e.getXY();
this.dragTarget = this.delegate ? target : this.el.dom;
if(this.preventDefault !== false){
e.preventDefault();
}
Ext.getDoc().on({
scope: this,
mouseup: this.onMouseUp,
mousemove: this.onMouseMove,
selectstart: this.stopSelect
});
if(this.autoStart){
this.timer = this.triggerStart.defer(this.autoStart === true ? 1000 : this.autoStart, this, [e]);
}
}
},
onMouseMove: function(e, target){
if(this.active && Ext.isIE && !e.browserEvent.button){
e.preventDefault();
this.onMouseUp(e);
return;
}
e.preventDefault();
var xy = e.getXY(), s = this.startXY;
this.lastXY = xy;
if(!this.active){
if(Math.abs(s[0]-xy[0]) > this.tolerance || Math.abs(s[1]-xy[1]) > this.tolerance){
this.triggerStart(e);
}else{
return;
}
}
this.fireEvent('mousemove', this, e);
this.onDrag(e);
this.fireEvent('drag', this, e);
},
onMouseUp: function(e) {
var doc = Ext.getDoc(),
wasActive = this.active;
doc.un('mousemove', this.onMouseMove, this);
doc.un('mouseup', this.onMouseUp, this);
doc.un('selectstart', this.stopSelect, this);
e.preventDefault();
this.clearStart();
this.active = false;
delete this.elRegion;
this.fireEvent('mouseup', this, e);
if(wasActive){
this.onEnd(e);
this.fireEvent('dragend', this, e);
}
},
triggerStart: function(e) {
this.clearStart();
this.active = true;
this.onStart(e);
this.fireEvent('dragstart', this, e);
},
clearStart : function() {
if(this.timer){
clearTimeout(this.timer);
delete this.timer;
}
},
stopSelect : function(e) {
e.stopEvent();
return false;
},
onBeforeStart : function(e) {
},
onStart : function(xy) {
},
onDrag : function(e) {
},
onEnd : function(e) {
},
getDragTarget : function(){
return this.dragTarget;
},
getDragCt : function(){
return this.el;
},
getXY : function(constrain){
return constrain ?
this.constrainModes[constrain].call(this, this.lastXY) : this.lastXY;
},
getOffset : function(constrain){
var xy = this.getXY(constrain),
s = this.startXY;
return [s[0]-xy[0], s[1]-xy[1]];
},
constrainModes: {
'point' : function(xy){
if(!this.elRegion){
this.elRegion = this.getDragCt().getRegion();
}
var dr = this.dragRegion;
dr.left = xy[0];
dr.top = xy[1];
dr.right = xy[0];
dr.bottom = xy[1];
dr.constrainTo(this.elRegion);
return [dr.left, dr.top];
}
}
});
Ext.dd.ScrollManager = function(){
var ddm = Ext.dd.DragDropMgr;
var els = {};
var dragEl = null;
var proc = {};
var onStop = function(e){
dragEl = null;
clearProc();
};
var triggerRefresh = function(){
if(ddm.dragCurrent){
ddm.refreshCache(ddm.dragCurrent.groups);
}
};
var doScroll = function(){
if(ddm.dragCurrent){
var dds = Ext.dd.ScrollManager;
var inc = proc.el.ddScrollConfig ?
proc.el.ddScrollConfig.increment : dds.increment;
if(!dds.animate){
if(proc.el.scroll(proc.dir, inc)){
triggerRefresh();
}
}else{
proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
}
}
};
var clearProc = function(){
if(proc.id){
clearInterval(proc.id);
}
proc.id = 0;
proc.el = null;
proc.dir = "";
};
var startProc = function(el, dir){
clearProc();
proc.el = el;
proc.dir = dir;
var group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup : undefined,
freq = (el.ddScrollConfig && el.ddScrollConfig.frequency)
? el.ddScrollConfig.frequency
: Ext.dd.ScrollManager.frequency;
if (group === undefined || ddm.dragCurrent.ddGroup == group) {
proc.id = setInterval(doScroll, freq);
}
};
var onFire = function(e, isDrop){
if(isDrop || !ddm.dragCurrent){ return; }
var dds = Ext.dd.ScrollManager;
if(!dragEl || dragEl != ddm.dragCurrent){
dragEl = ddm.dragCurrent;
dds.refreshCache();
}
var xy = Ext.lib.Event.getXY(e);
var pt = new Ext.lib.Point(xy[0], xy[1]);
for(var id in els){
var el = els[id], r = el._region;
var c = el.ddScrollConfig ? el.ddScrollConfig : dds;
if(r && r.contains(pt) && el.isScrollable()){
if(r.bottom - pt.y <= c.vthresh){
if(proc.el != el){
startProc(el, "down");
}
return;
}else if(r.right - pt.x <= c.hthresh){
if(proc.el != el){
startProc(el, "left");
}
return;
}else if(pt.y - r.top <= c.vthresh){
if(proc.el != el){
startProc(el, "up");
}
return;
}else if(pt.x - r.left <= c.hthresh){
if(proc.el != el){
startProc(el, "right");
}
return;
}
}
}
clearProc();
};
ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
return {
register : function(el){
if(Ext.isArray(el)){
for(var i = 0, len = el.length; i < len; i++) {
this.register(el[i]);
}
}else{
el = Ext.get(el);
els[el.id] = el;
}
},
unregister : function(el){
if(Ext.isArray(el)){
for(var i = 0, len = el.length; i < len; i++) {
this.unregister(el[i]);
}
}else{
el = Ext.get(el);
delete els[el.id];
}
},
vthresh : 25,
hthresh : 25,
increment : 100,
frequency : 500,
animate: true,
animDuration: .4,
ddGroup: undefined,
refreshCache : function(){
for(var id in els){
if(typeof els[id] == 'object'){
els[id]._region = els[id].getRegion();
}
}
}
};
}();
Ext.dd.Registry = function(){
var elements = {};
var handles = {};
var autoIdSeed = 0;
var getId = function(el, autogen){
if(typeof el == "string"){
return el;
}
var id = el.id;
if(!id && autogen !== false){
id = "extdd-" + (++autoIdSeed);
el.id = id;
}
return id;
};
return {
register : function(el, data){
data = data || {};
if(typeof el == "string"){
el = document.getElementById(el);
}
data.ddel = el;
elements[getId(el)] = data;
if(data.isHandle !== false){
handles[data.ddel.id] = data;
}
if(data.handles){
var hs = data.handles;
for(var i = 0, len = hs.length; i < len; i++){
handles[getId(hs[i])] = data;
}
}
},
unregister : function(el){
var id = getId(el, false);
var data = elements[id];
if(data){
delete elements[id];
if(data.handles){
var hs = data.handles;
for(var i = 0, len = hs.length; i < len; i++){
delete handles[getId(hs[i], false)];
}
}
}
},
getHandle : function(id){
if(typeof id != "string"){
id = id.id;
}
return handles[id];
},
getHandleFromEvent : function(e){
var t = Ext.lib.Event.getTarget(e);
return t ? handles[t.id] : null;
},
getTarget : function(id){
if(typeof id != "string"){
id = id.id;
}
return elements[id];
},
getTargetFromEvent : function(e){
var t = Ext.lib.Event.getTarget(e);
return t ? elements[t.id] || handles[t.id] : null;
}
};
}();
Ext.dd.StatusProxy = function(config){
Ext.apply(this, config);
this.id = this.id || Ext.id();
this.el = new Ext.Layer({
dh: {
id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
{tag: "div", cls: "x-dd-drop-icon"},
{tag: "div", cls: "x-dd-drag-ghost"}
]
},
shadow: !config || config.shadow !== false
});
this.ghost = Ext.get(this.el.dom.childNodes[1]);
this.dropStatus = this.dropNotAllowed;
};
Ext.dd.StatusProxy.prototype = {
dropAllowed : "x-dd-drop-ok",
dropNotAllowed : "x-dd-drop-nodrop",
setStatus : function(cssClass){
cssClass = cssClass || this.dropNotAllowed;
if(this.dropStatus != cssClass){
this.el.replaceClass(this.dropStatus, cssClass);
this.dropStatus = cssClass;
}
},
reset : function(clearGhost){
this.el.dom.className = "x-dd-drag-proxy " + this.dropNotAllowed;
this.dropStatus = this.dropNotAllowed;
if(clearGhost){
this.ghost.update("");
}
},
update : function(html){
if(typeof html == "string"){
this.ghost.update(html);
}else{
this.ghost.update("");
html.style.margin = "0";
this.ghost.dom.appendChild(html);
}
var el = this.ghost.dom.firstChild;
if(el){
Ext.fly(el).setStyle('float', 'none');
}
},
getEl : function(){
return this.el;
},
getGhost : function(){
return this.ghost;
},
hide : function(clear){
this.el.hide();
if(clear){
this.reset(true);
}
},
stop : function(){
if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
this.anim.stop();
}
},
show : function(){
this.el.show();
},
sync : function(){
this.el.sync();
},
repair : function(xy, callback, scope){
this.callback = callback;
this.scope = scope;
if(xy && this.animRepair !== false){
this.el.addClass("x-dd-drag-repair");
this.el.hideUnders(true);
this.anim = this.el.shift({
duration: this.repairDuration || .5,
easing: 'easeOut',
xy: xy,
stopFx: true,
callback: this.afterRepair,
scope: this
});
}else{
this.afterRepair();
}
},
afterRepair : function(){
this.hide(true);
if(typeof this.callback == "function"){
this.callback.call(this.scope || this);
}
this.callback = null;
this.scope = null;
},
destroy: function(){
Ext.destroy(this.ghost, this.el);
}
};
Ext.dd.DragSource = function(el, config){
this.el = Ext.get(el);
if(!this.dragData){
this.dragData = {};
}
Ext.apply(this, config);
if(!this.proxy){
this.proxy = new Ext.dd.StatusProxy();
}
Ext.dd.DragSource.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
{dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true});
this.dragging = false;
};
Ext.extend(Ext.dd.DragSource, Ext.dd.DDProxy, {
dropAllowed : "x-dd-drop-ok",
dropNotAllowed : "x-dd-drop-nodrop",
getDragData : function(e){
return this.dragData;
},
onDragEnter : function(e, id){
var target = Ext.dd.DragDropMgr.getDDById(id);
this.cachedTarget = target;
if(this.beforeDragEnter(target, e, id) !== false){
if(target.isNotifyTarget){
var status = target.notifyEnter(this, e, this.dragData);
this.proxy.setStatus(status);
}else{
this.proxy.setStatus(this.dropAllowed);
}
if(this.afterDragEnter){
this.afterDragEnter(target, e, id);
}
}
},
beforeDragEnter : function(target, e, id){
return true;
},
alignElWithMouse: function() {
Ext.dd.DragSource.superclass.alignElWithMouse.apply(this, arguments);
this.proxy.sync();
},
onDragOver : function(e, id){
var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
if(this.beforeDragOver(target, e, id) !== false){
if(target.isNotifyTarget){
var status = target.notifyOver(this, e, this.dragData);
this.proxy.setStatus(status);
}
if(this.afterDragOver){
this.afterDragOver(target, e, id);
}
}
},
beforeDragOver : function(target, e, id){
return true;
},
onDragOut : function(e, id){
var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
if(this.beforeDragOut(target, e, id) !== false){
if(target.isNotifyTarget){
target.notifyOut(this, e, this.dragData);
}
this.proxy.reset();
if(this.afterDragOut){
this.afterDragOut(target, e, id);
}
}
this.cachedTarget = null;
},
beforeDragOut : function(target, e, id){
return true;
},
onDragDrop : function(e, id){
var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
if(this.beforeDragDrop(target, e, id) !== false){
if(target.isNotifyTarget){
if(target.notifyDrop(this, e, this.dragData)){
this.onValidDrop(target, e, id);
}else{
this.onInvalidDrop(target, e, id);
}
}else{
this.onValidDrop(target, e, id);
}
if(this.afterDragDrop){
this.afterDragDrop(target, e, id);
}
}
delete this.cachedTarget;
},
beforeDragDrop : function(target, e, id){
return true;
},
onValidDrop : function(target, e, id){
this.hideProxy();
if(this.afterValidDrop){
this.afterValidDrop(target, e, id);
}
},
getRepairXY : function(e, data){
return this.el.getXY();
},
onInvalidDrop : function(target, e, id){
this.beforeInvalidDrop(target, e, id);
if(this.cachedTarget){
if(this.cachedTarget.isNotifyTarget){
this.cachedTarget.notifyOut(this, e, this.dragData);
}
this.cacheTarget = null;
}
this.proxy.repair(this.getRepairXY(e, this.dragData), this.afterRepair, this);
if(this.afterInvalidDrop){
this.afterInvalidDrop(e, id);
}
},
afterRepair : function(){
if(Ext.enableFx){
this.el.highlight(this.hlColor || "c3daf9");
}
this.dragging = false;
},
beforeInvalidDrop : function(target, e, id){
return true;
},
handleMouseDown : function(e){
if(this.dragging) {
return;
}
var data = this.getDragData(e);
if(data && this.onBeforeDrag(data, e) !== false){
this.dragData = data;
this.proxy.stop();
Ext.dd.DragSource.superclass.handleMouseDown.apply(this, arguments);
}
},
onBeforeDrag : function(data, e){
return true;
},
onStartDrag : Ext.emptyFn,
startDrag : function(x, y){
this.proxy.reset();
this.dragging = true;
this.proxy.update("");
this.onInitDrag(x, y);
this.proxy.show();
},
onInitDrag : function(x, y){
var clone = this.el.dom.cloneNode(true);
clone.id = Ext.id();
this.proxy.update(clone);
this.onStartDrag(x, y);
return true;
},
getProxy : function(){
return this.proxy;
},
hideProxy : function(){
this.proxy.hide();
this.proxy.reset(true);
this.dragging = false;
},
triggerCacheRefresh : function(){
Ext.dd.DDM.refreshCache(this.groups);
},
b4EndDrag: function(e) {
},
endDrag : function(e){
this.onEndDrag(this.dragData, e);
},
onEndDrag : function(data, e){
},
autoOffset : function(x, y) {
this.setDelta(-12, -20);
},
destroy: function(){
Ext.dd.DragSource.superclass.destroy.call(this);
Ext.destroy(this.proxy);
}
});
Ext.dd.DropTarget = Ext.extend(Ext.dd.DDTarget, {
constructor : function(el, config){
this.el = Ext.get(el);
Ext.apply(this, config);
if(this.containerScroll){
Ext.dd.ScrollManager.register(this.el);
}
Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
{isTarget: true});
},
dropAllowed : "x-dd-drop-ok",
dropNotAllowed : "x-dd-drop-nodrop",
isTarget : true,
isNotifyTarget : true,
notifyEnter : function(dd, e, data){
if(this.overClass){
this.el.addClass(this.overClass);
}
return this.dropAllowed;
},
notifyOver : function(dd, e, data){
return this.dropAllowed;
},
notifyOut : function(dd, e, data){
if(this.overClass){
this.el.removeClass(this.overClass);
}
},
notifyDrop : function(dd, e, data){
return false;
},
destroy : function(){
Ext.dd.DropTarget.superclass.destroy.call(this);
if(this.containerScroll){
Ext.dd.ScrollManager.unregister(this.el);
}
}
});
Ext.dd.DragZone = Ext.extend(Ext.dd.DragSource, {
constructor : function(el, config){
Ext.dd.DragZone.superclass.constructor.call(this, el, config);
if(this.containerScroll){
Ext.dd.ScrollManager.register(this.el);
}
},
getDragData : function(e){
return Ext.dd.Registry.getHandleFromEvent(e);
},
onInitDrag : function(x, y){
this.proxy.update(this.dragData.ddel.cloneNode(true));
this.onStartDrag(x, y);
return true;
},
afterRepair : function(){
if(Ext.enableFx){
Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
}
this.dragging = false;
},
getRepairXY : function(e){
return Ext.Element.fly(this.dragData.ddel).getXY();
},
destroy : function(){
Ext.dd.DragZone.superclass.destroy.call(this);
if(this.containerScroll){
Ext.dd.ScrollManager.unregister(this.el);
}
}
});
Ext.dd.DropZone = function(el, config){
Ext.dd.DropZone.superclass.constructor.call(this, el, config);
};
Ext.extend(Ext.dd.DropZone, Ext.dd.DropTarget, {
getTargetFromEvent : function(e){
return Ext.dd.Registry.getTargetFromEvent(e);
},
onNodeEnter : function(n, dd, e, data){
},
onNodeOver : function(n, dd, e, data){
return this.dropAllowed;
},
onNodeOut : function(n, dd, e, data){
},
onNodeDrop : function(n, dd, e, data){
return false;
},
onContainerOver : function(dd, e, data){
return this.dropNotAllowed;
},
onContainerDrop : function(dd, e, data){
return false;
},
notifyEnter : function(dd, e, data){
return this.dropNotAllowed;
},
notifyOver : function(dd, e, data){
var n = this.getTargetFromEvent(e);
if(!n){
if(this.lastOverNode){
this.onNodeOut(this.lastOverNode, dd, e, data);
this.lastOverNode = null;
}
return this.onContainerOver(dd, e, data);
}
if(this.lastOverNode != n){
if(this.lastOverNode){
this.onNodeOut(this.lastOverNode, dd, e, data);
}
this.onNodeEnter(n, dd, e, data);
this.lastOverNode = n;
}
return this.onNodeOver(n, dd, e, data);
},
notifyOut : function(dd, e, data){
if(this.lastOverNode){
this.onNodeOut(this.lastOverNode, dd, e, data);
this.lastOverNode = null;
}
},
notifyDrop : function(dd, e, data){
if(this.lastOverNode){
this.onNodeOut(this.lastOverNode, dd, e, data);
this.lastOverNode = null;
}
var n = this.getTargetFromEvent(e);
return n ?
this.onNodeDrop(n, dd, e, data) :
this.onContainerDrop(dd, e, data);
},
triggerCacheRefresh : function(){
Ext.dd.DDM.refreshCache(this.groups);
}
});
Ext.Element.addMethods({
initDD : function(group, config, overrides){
var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);
return Ext.apply(dd, overrides);
},
initDDProxy : function(group, config, overrides){
var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);
return Ext.apply(dd, overrides);
},
initDDTarget : function(group, config, overrides){
var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);
return Ext.apply(dd, overrides);
}
});
Ext.data.Api = (function() {
var validActions = {};
return {
actions : {
create : 'create',
read : 'read',
update : 'update',
destroy : 'destroy'
},
restActions : {
create : 'POST',
read : 'GET',
update : 'PUT',
destroy : 'DELETE'
},
isAction : function(action) {
return (Ext.data.Api.actions[action]) ? true : false;
},
getVerb : function(name) {
if (validActions[name]) {
return validActions[name];
}
for (var verb in this.actions) {
if (this.actions[verb] === name) {
validActions[name] = verb;
break;
}
}
return (validActions[name] !== undefined) ? validActions[name] : null;
},
isValid : function(api){
var invalid = [];
var crud = this.actions;
for (var action in api) {
if (!(action in crud)) {
invalid.push(action);
}
}
return (!invalid.length) ? true : invalid;
},
hasUniqueUrl : function(proxy, verb) {
var url = (proxy.api[verb]) ? proxy.api[verb].url : null;
var unique = true;
for (var action in proxy.api) {
if ((unique = (action === verb) ? true : (proxy.api[action].url != url) ? true : false) === false) {
break;
}
}
return unique;
},
prepare : function(proxy) {
if (!proxy.api) {
proxy.api = {};
}
for (var verb in this.actions) {
var action = this.actions[verb];
proxy.api[action] = proxy.api[action] || proxy.url || proxy.directFn;
if (typeof(proxy.api[action]) == 'string') {
proxy.api[action] = {
url: proxy.api[action],
method: (proxy.restful === true) ? Ext.data.Api.restActions[action] : undefined
};
}
}
},
restify : function(proxy) {
proxy.restful = true;
for (var verb in this.restActions) {
proxy.api[this.actions[verb]].method ||
(proxy.api[this.actions[verb]].method = this.restActions[verb]);
}
proxy.onWrite = proxy.onWrite.createInterceptor(function(action, o, response, rs) {
var reader = o.reader;
var res = new Ext.data.Response({
action: action,
raw: response
});
switch (response.status) {
case 200:
return true;
break;
case 201:
if (Ext.isEmpty(res.raw.responseText)) {
res.success = true;
} else {
return true;
}
break;
case 204:
res.success = true;
res.data = null;
break;
default:
return true;
break;
}
if (res.success === true) {
this.fireEvent("write", this, action, res.data, res, rs, o.request.arg);
} else {
this.fireEvent('exception', this, 'remote', action, o, res, rs);
}
o.request.callback.call(o.request.scope, res.data, res, res.success);
return false;
}, proxy);
}
};
})();
Ext.data.Response = function(params, response) {
Ext.apply(this, params, {
raw: response
});
};
Ext.data.Response.prototype = {
message : null,
success : false,
status : null,
root : null,
raw : null,
getMessage : function() {
return this.message;
},
getSuccess : function() {
return this.success;
},
getStatus : function() {
return this.status;
},
getRoot : function() {
return this.root;
},
getRawResponse : function() {
return this.raw;
}
};
Ext.data.Api.Error = Ext.extend(Ext.Error, {
constructor : function(message, arg) {
this.arg = arg;
Ext.Error.call(this, message);
},
name: 'Ext.data.Api'
});
Ext.apply(Ext.data.Api.Error.prototype, {
lang: {
'action-url-undefined': 'No fallback url defined for this action. When defining a DataProxy api, please be sure to define an url for each CRUD action in Ext.data.Api.actions or define a default url in addition to your api-configuration.',
'invalid': 'received an invalid API-configuration. Please ensure your proxy API-configuration contains only the actions defined in Ext.data.Api.actions',
'invalid-url': 'Invalid url. Please review your proxy configuration.',
'execute': 'Attempted to execute an unknown action. Valid API actions are defined in Ext.data.Api.actions"'
}
});
Ext.data.SortTypes = {
none : function(s){
return s;
},
stripTagsRE : /<\/?[^>]+>/gi,
asText : function(s){
return String(s).replace(this.stripTagsRE, "");
},
asUCText : function(s){
return String(s).toUpperCase().replace(this.stripTagsRE, "");
},
asUCString : function(s) {
return String(s).toUpperCase();
},
asDate : function(s) {
if(!s){
return 0;
}
if(Ext.isDate(s)){
return s.getTime();
}
return Date.parse(String(s));
},
asFloat : function(s) {
var val = parseFloat(String(s).replace(/,/g, ""));
return isNaN(val) ? 0 : val;
},
asInt : function(s) {
var val = parseInt(String(s).replace(/,/g, ""), 10);
return isNaN(val) ? 0 : val;
}
};
Ext.data.Record = function(data, id){
this.id = (id || id === 0) ? id : Ext.data.Record.id(this);
this.data = data || {};
};
Ext.data.Record.create = function(o){
var f = Ext.extend(Ext.data.Record, {});
var p = f.prototype;
p.fields = new Ext.util.MixedCollection(false, function(field){
return field.name;
});
for(var i = 0, len = o.length; i < len; i++){
p.fields.add(new Ext.data.Field(o[i]));
}
f.getField = function(name){
return p.fields.get(name);
};
return f;
};
Ext.data.Record.PREFIX = 'ext-record';
Ext.data.Record.AUTO_ID = 1;
Ext.data.Record.EDIT = 'edit';
Ext.data.Record.REJECT = 'reject';
Ext.data.Record.COMMIT = 'commit';
Ext.data.Record.id = function(rec) {
rec.phantom = true;
return [Ext.data.Record.PREFIX, '-', Ext.data.Record.AUTO_ID++].join('');
};
Ext.data.Record.prototype = {
dirty : false,
editing : false,
error : null,
modified : null,
phantom : false,
join : function(store){
this.store = store;
},
set : function(name, value){
var encode = Ext.isPrimitive(value) ? String : Ext.encode;
if(encode(this.data[name]) == encode(value)) {
return;
}
this.dirty = true;
if(!this.modified){
this.modified = {};
}
if(this.modified[name] === undefined){
this.modified[name] = this.data[name];
}
this.data[name] = value;
if(!this.editing){
this.afterEdit();
}
},
afterEdit : function(){
if (this.store != undefined && typeof this.store.afterEdit == "function") {
this.store.afterEdit(this);
}
},
afterReject : function(){
if(this.store){
this.store.afterReject(this);
}
},
afterCommit : function(){
if(this.store){
this.store.afterCommit(this);
}
},
get : function(name){
return this.data[name];
},
beginEdit : function(){
this.editing = true;
this.modified = this.modified || {};
},
cancelEdit : function(){
this.editing = false;
delete this.modified;
},
endEdit : function(){
this.editing = false;
if(this.dirty){
this.afterEdit();
}
},
reject : function(silent){
var m = this.modified;
for(var n in m){
if(typeof m[n] != "function"){
this.data[n] = m[n];
}
}
this.dirty = false;
delete this.modified;
this.editing = false;
if(silent !== true){
this.afterReject();
}
},
commit : function(silent){
this.dirty = false;
delete this.modified;
this.editing = false;
if(silent !== true){
this.afterCommit();
}
},
getChanges : function(){
var m = this.modified, cs = {};
for(var n in m){
if(m.hasOwnProperty(n)){
cs[n] = this.data[n];
}
}
return cs;
},
hasError : function(){
return this.error !== null;
},
clearError : function(){
this.error = null;
},
copy : function(newId) {
return new this.constructor(Ext.apply({}, this.data), newId || this.id);
},
isModified : function(fieldName){
return !!(this.modified && this.modified.hasOwnProperty(fieldName));
},
isValid : function() {
return this.fields.find(function(f) {
return (f.allowBlank === false && Ext.isEmpty(this.data[f.name])) ? true : false;
},this) ? false : true;
},
markDirty : function(){
this.dirty = true;
if(!this.modified){
this.modified = {};
}
this.fields.each(function(f) {
this.modified[f.name] = this.data[f.name];
},this);
}
};
Ext.StoreMgr = Ext.apply(new Ext.util.MixedCollection(), {
register : function(){
for(var i = 0, s; (s = arguments[i]); i++){
this.add(s);
}
},
unregister : function(){
for(var i = 0, s; (s = arguments[i]); i++){
this.remove(this.lookup(s));
}
},
lookup : function(id){
if(Ext.isArray(id)){
var fields = ['field1'], expand = !Ext.isArray(id[0]);
if(!expand){
for(var i = 2, len = id[0].length; i <= len; ++i){
fields.push('field' + i);
}
}
return new Ext.data.ArrayStore({
fields: fields,
data: id,
expandData: expand,
autoDestroy: true,
autoCreated: true
});
}
return Ext.isObject(id) ? (id.events ? id : Ext.create(id, 'store')) : this.get(id);
},
getKey : function(o){
return o.storeId;
}
});
Ext.data.Store = Ext.extend(Ext.util.Observable, {
writer : undefined,
remoteSort : false,
autoDestroy : false,
pruneModifiedRecords : false,
lastOptions : null,
autoSave : true,
batch : true,
restful: false,
paramNames : undefined,
defaultParamNames : {
start : 'start',
limit : 'limit',
sort : 'sort',
dir : 'dir'
},
isDestroyed: false,
hasMultiSort: false,
batchKey : '_ext_batch_',
constructor : function(config){
this.data = new Ext.util.MixedCollection(false);
this.data.getKey = function(o){
return o.id;
};
this.removed = [];
if(config && config.data){
this.inlineData = config.data;
delete config.data;
}
Ext.apply(this, config);
this.baseParams = Ext.isObject(this.baseParams) ? this.baseParams : {};
this.paramNames = Ext.applyIf(this.paramNames || {}, this.defaultParamNames);
if((this.url || this.api) && !this.proxy){
this.proxy = new Ext.data.HttpProxy({url: this.url, api: this.api});
}
if (this.restful === true && this.proxy) {
this.batch = false;
Ext.data.Api.restify(this.proxy);
}
if(this.reader){
if(!this.recordType){
this.recordType = this.reader.recordType;
}
if(this.reader.onMetaChange){
this.reader.onMetaChange = this.reader.onMetaChange.createSequence(this.onMetaChange, this);
}
if (this.writer) {
if (this.writer instanceof(Ext.data.DataWriter) === false) {
this.writer = this.buildWriter(this.writer);
}
this.writer.meta = this.reader.meta;
this.pruneModifiedRecords = true;
}
}
if(this.recordType){
this.fields = this.recordType.prototype.fields;
}
this.modified = [];
this.addEvents(
'datachanged',
'metachange',
'add',
'remove',
'update',
'clear',
'exception',
'beforeload',
'load',
'loadexception',
'beforewrite',
'write',
'beforesave',
'save'
);
if(this.proxy){
this.relayEvents(this.proxy, ['loadexception', 'exception']);
}
if (this.writer) {
this.on({
scope: this,
add: this.createRecords,
remove: this.destroyRecord,
update: this.updateRecord,
clear: this.onClear
});
}
this.sortToggle = {};
if(this.sortField){
this.setDefaultSort(this.sortField, this.sortDir);
}else if(this.sortInfo){
this.setDefaultSort(this.sortInfo.field, this.sortInfo.direction);
}
Ext.data.Store.superclass.constructor.call(this);
if(this.id){
this.storeId = this.id;
delete this.id;
}
if(this.storeId){
Ext.StoreMgr.register(this);
}
if(this.inlineData){
this.loadData(this.inlineData);
delete this.inlineData;
}else if(this.autoLoad){
this.load.defer(10, this, [
typeof this.autoLoad == 'object' ?
this.autoLoad : undefined]);
}
this.batchCounter = 0;
this.batches = {};
},
buildWriter : function(config) {
var klass = undefined,
type = (config.format || 'json').toLowerCase();
switch (type) {
case 'json':
klass = Ext.data.JsonWriter;
break;
case 'xml':
klass = Ext.data.XmlWriter;
break;
default:
klass = Ext.data.JsonWriter;
}
return new klass(config);
},
destroy : function(){
if(!this.isDestroyed){
if(this.storeId){
Ext.StoreMgr.unregister(this);
}
this.clearData();
this.data = null;
Ext.destroy(this.proxy);
this.reader = this.writer = null;
this.purgeListeners();
this.isDestroyed = true;
}
},
add : function(records) {
var i, len, record, index;
records = [].concat(records);
if (records.length < 1) {
return;
}
for (i = 0, len = records.length; i < len; i++) {
record = records[i];
record.join(this);
if (record.dirty || record.phantom) {
this.modified.push(record);
}
}
index = this.data.length;
this.data.addAll(records);
if (this.snapshot) {
this.snapshot.addAll(records);
}
this.fireEvent('add', this, records, index);
},
addSorted : function(record){
var index = this.findInsertIndex(record);
this.insert(index, record);
},
doUpdate: function(rec){
var id = rec.id;
this.getById(id).join(null);
this.data.replace(id, rec);
if (this.snapshot) {
this.snapshot.replace(id, rec);
}
rec.join(this);
this.fireEvent('update', this, rec, Ext.data.Record.COMMIT);
},
remove : function(record){
if(Ext.isArray(record)){
Ext.each(record, function(r){
this.remove(r);
}, this);
return;
}
var index = this.data.indexOf(record);
if(index > -1){
record.join(null);
this.data.removeAt(index);
}
if(this.pruneModifiedRecords){
this.modified.remove(record);
}
if(this.snapshot){
this.snapshot.remove(record);
}
if(index > -1){
this.fireEvent('remove', this, record, index);
}
},
removeAt : function(index){
this.remove(this.getAt(index));
},
removeAll : function(silent){
var items = [];
this.each(function(rec){
items.push(rec);
});
this.clearData();
if(this.snapshot){
this.snapshot.clear();
}
if(this.pruneModifiedRecords){
this.modified = [];
}
if (silent !== true) {
this.fireEvent('clear', this, items);
}
},
onClear: function(store, records){
Ext.each(records, function(rec, index){
this.destroyRecord(this, rec, index);
}, this);
},
insert : function(index, records) {
var i, len, record;
records = [].concat(records);
for (i = 0, len = records.length; i < len; i++) {
record = records[i];
this.data.insert(index + i, record);
record.join(this);
if (record.dirty || record.phantom) {
this.modified.push(record);
}
}
if (this.snapshot) {
this.snapshot.addAll(records);
}
this.fireEvent('add', this, records, index);
},
indexOf : function(record){
return this.data.indexOf(record);
},
indexOfId : function(id){
return this.data.indexOfKey(id);
},
getById : function(id){
return (this.snapshot || this.data).key(id);
},
getAt : function(index){
return this.data.itemAt(index);
},
getRange : function(start, end){
return this.data.getRange(start, end);
},
storeOptions : function(o){
o = Ext.apply({}, o);
delete o.callback;
delete o.scope;
this.lastOptions = o;
},
clearData: function(){
this.data.each(function(rec) {
rec.join(null);
});
this.data.clear();
},
load : function(options) {
options = Ext.apply({}, options);
this.storeOptions(options);
if(this.sortInfo && this.remoteSort){
var pn = this.paramNames;
options.params = Ext.apply({}, options.params);
options.params[pn.sort] = this.sortInfo.field;
options.params[pn.dir] = this.sortInfo.direction;
}
try {
return this.execute('read', null, options);
} catch(e) {
this.handleException(e);
return false;
}
},
updateRecord : function(store, record, action) {
if (action == Ext.data.Record.EDIT && this.autoSave === true && (!record.phantom || (record.phantom && record.isValid()))) {
this.save();
}
},
createRecords : function(store, records, index) {
var modified = this.modified,
length = records.length,
record, i;
for (i = 0; i < length; i++) {
record = records[i];
if (record.phantom && record.isValid()) {
record.markDirty();
if (modified.indexOf(record) == -1) {
modified.push(record);
}
}
}
if (this.autoSave === true) {
this.save();
}
},
destroyRecord : function(store, record, index) {
if (this.modified.indexOf(record) != -1) {
this.modified.remove(record);
}
if (!record.phantom) {
this.removed.push(record);
record.lastIndex = index;
if (this.autoSave === true) {
this.save();
}
}
},
execute : function(action, rs, options, batch) {
if (!Ext.data.Api.isAction(action)) {
throw new Ext.data.Api.Error('execute', action);
}
options = Ext.applyIf(options||{}, {
params: {}
});
if(batch !== undefined){
this.addToBatch(batch);
}
var doRequest = true;
if (action === 'read') {
doRequest = this.fireEvent('beforeload', this, options);
Ext.applyIf(options.params, this.baseParams);
}
else {
if (this.writer.listful === true && this.restful !== true) {
rs = (Ext.isArray(rs)) ? rs : [rs];
}
else if (Ext.isArray(rs) && rs.length == 1) {
rs = rs.shift();
}
if ((doRequest = this.fireEvent('beforewrite', this, action, rs, options)) !== false) {
this.writer.apply(options.params, this.baseParams, action, rs);
}
}
if (doRequest !== false) {
if (this.writer && this.proxy.url && !this.proxy.restful && !Ext.data.Api.hasUniqueUrl(this.proxy, action)) {
options.params.xaction = action;
}
this.proxy.request(Ext.data.Api.actions[action], rs, options.params, this.reader, this.createCallback(action, rs, batch), this, options);
}
return doRequest;
},
save : function() {
if (!this.writer) {
throw new Ext.data.Store.Error('writer-undefined');
}
var queue = [],
len,
trans,
batch,
data = {},
i;
if(this.removed.length){
queue.push(['destroy', this.removed]);
}
var rs = [].concat(this.getModifiedRecords());
if(rs.length){
var phantoms = [];
for(i = rs.length-1; i >= 0; i--){
if(rs[i].phantom === true){
var rec = rs.splice(i, 1).shift();
if(rec.isValid()){
phantoms.push(rec);
}
}else if(!rs[i].isValid()){
rs.splice(i,1);
}
}
if(phantoms.length){
queue.push(['create', phantoms]);
}
if(rs.length){
queue.push(['update', rs]);
}
}
len = queue.length;
if(len){
batch = ++this.batchCounter;
for(i = 0; i < len; ++i){
trans = queue[i];
data[trans[0]] = trans[1];
}
if(this.fireEvent('beforesave', this, data) !== false){
for(i = 0; i < len; ++i){
trans = queue[i];
this.doTransaction(trans[0], trans[1], batch);
}
return batch;
}
}
return -1;
},
doTransaction : function(action, rs, batch) {
function transaction(records) {
try{
this.execute(action, records, undefined, batch);
}catch (e){
this.handleException(e);
}
}
if(this.batch === false){
for(var i = 0, len = rs.length; i < len; i++){
transaction.call(this, rs[i]);
}
}else{
transaction.call(this, rs);
}
},
addToBatch : function(batch){
var b = this.batches,
key = this.batchKey + batch,
o = b[key];
if(!o){
b[key] = o = {
id: batch,
count: 0,
data: {}
};
}
++o.count;
},
removeFromBatch : function(batch, action, data){
var b = this.batches,
key = this.batchKey + batch,
o = b[key],
arr;
if(o){
arr = o.data[action] || [];
o.data[action] = arr.concat(data);
if(o.count === 1){
data = o.data;
delete b[key];
this.fireEvent('save', this, batch, data);
}else{
--o.count;
}
}
},
createCallback : function(action, rs, batch) {
var actions = Ext.data.Api.actions;
return (action == 'read') ? this.loadRecords : function(data, response, success) {
this['on' + Ext.util.Format.capitalize(action) + 'Records'](success, rs, [].concat(data));
if (success === true) {
this.fireEvent('write', this, action, data, response, rs);
}
this.removeFromBatch(batch, action, data);
};
},
clearModified : function(rs) {
if (Ext.isArray(rs)) {
for (var n=rs.length-1;n>=0;n--) {
this.modified.splice(this.modified.indexOf(rs[n]), 1);
}
} else {
this.modified.splice(this.modified.indexOf(rs), 1);
}
},
reMap : function(record) {
if (Ext.isArray(record)) {
for (var i = 0, len = record.length; i < len; i++) {
this.reMap(record[i]);
}
} else {
delete this.data.map[record._phid];
this.data.map[record.id] = record;
var index = this.data.keys.indexOf(record._phid);
this.data.keys.splice(index, 1, record.id);
delete record._phid;
}
},
onCreateRecords : function(success, rs, data) {
if (success === true) {
try {
this.reader.realize(rs, data);
}
catch (e) {
this.handleException(e);
if (Ext.isArray(rs)) {
this.onCreateRecords(success, rs, data);
}
}
}
},
onUpdateRecords : function(success, rs, data) {
if (success === true) {
try {
this.reader.update(rs, data);
} catch (e) {
this.handleException(e);
if (Ext.isArray(rs)) {
this.onUpdateRecords(success, rs, data);
}
}
}
},
onDestroyRecords : function(success, rs, data) {
rs = (rs instanceof Ext.data.Record) ? [rs] : [].concat(rs);
for (var i=0,len=rs.length;i<len;i++) {
this.removed.splice(this.removed.indexOf(rs[i]), 1);
}
if (success === false) {
for (i=rs.length-1;i>=0;i--) {
this.insert(rs[i].lastIndex, rs[i]);
}
}
},
handleException : function(e) {
Ext.handleError(e);
},
reload : function(options){
this.load(Ext.applyIf(options||{}, this.lastOptions));
},
loadRecords : function(o, options, success){
var i, len;
if (this.isDestroyed === true) {
return;
}
if(!o || success === false){
if(success !== false){
this.fireEvent('load', this, [], options);
}
if(options.callback){
options.callback.call(options.scope || this, [], options, false, o);
}
return;
}
var r = o.records, t = o.totalRecords || r.length;
if(!options || options.add !== true){
if(this.pruneModifiedRecords){
this.modified = [];
}
for(i = 0, len = r.length; i < len; i++){
r[i].join(this);
}
if(this.snapshot){
this.data = this.snapshot;
delete this.snapshot;
}
this.clearData();
this.data.addAll(r);
this.totalLength = t;
this.applySort();
this.fireEvent('datachanged', this);
}else{
var toAdd = [],
rec,
cnt = 0;
for(i = 0, len = r.length; i < len; ++i){
rec = r[i];
if(this.indexOfId(rec.id) > -1){
this.doUpdate(rec);
}else{
toAdd.push(rec);
++cnt;
}
}
this.totalLength = Math.max(t, this.data.length + cnt);
this.add(toAdd);
}
this.fireEvent('load', this, r, options);
if(options.callback){
options.callback.call(options.scope || this, r, options, true);
}
},
loadData : function(o, append){
var r = this.reader.readRecords(o);
this.loadRecords(r, {add: append}, true);
},
getCount : function(){
return this.data.length || 0;
},
getTotalCount : function(){
return this.totalLength || 0;
},
getSortState : function(){
return this.sortInfo;
},
applySort : function(){
if ((this.sortInfo || this.multiSortInfo) && !this.remoteSort) {
this.sortData();
}
},
sortData : function() {
var sortInfo = this.hasMultiSort ? this.multiSortInfo : this.sortInfo,
direction = sortInfo.direction || "ASC",
sorters = sortInfo.sorters,
sortFns = [];
if (!this.hasMultiSort) {
sorters = [{direction: direction, field: sortInfo.field}];
}
for (var i=0, j = sorters.length; i < j; i++) {
sortFns.push(this.createSortFunction(sorters[i].field, sorters[i].direction));
}
if (sortFns.length == 0) {
return;
}
var directionModifier = direction.toUpperCase() == "DESC" ? -1 : 1;
var fn = function(r1, r2) {
var result = sortFns[0].call(this, r1, r2);
if (sortFns.length > 1) {
for (var i=1, j = sortFns.length; i < j; i++) {
result = result || sortFns[i].call(this, r1, r2);
}
}
return directionModifier * result;
};
this.data.sort(direction, fn);
if (this.snapshot && this.snapshot != this.data) {
this.snapshot.sort(direction, fn);
}
},
createSortFunction: function(field, direction) {
direction = direction || "ASC";
var directionModifier = direction.toUpperCase() == "DESC" ? -1 : 1;
var sortType = this.fields.get(field).sortType;
return function(r1, r2) {
var v1 = sortType(r1.data[field]),
v2 = sortType(r2.data[field]);
return directionModifier * (v1 > v2 ? 1 : (v1 < v2 ? -1 : 0));
};
},
setDefaultSort : function(field, dir) {
dir = dir ? dir.toUpperCase() : 'ASC';
this.sortInfo = {field: field, direction: dir};
this.sortToggle[field] = dir;
},
sort : function(fieldName, dir) {
if (Ext.isArray(arguments[0])) {
return this.multiSort.call(this, fieldName, dir);
} else {
return this.singleSort(fieldName, dir);
}
},
singleSort: function(fieldName, dir) {
var field = this.fields.get(fieldName);
if (!field) {
return false;
}
var name = field.name,
sortInfo = this.sortInfo || null,
sortToggle = this.sortToggle ? this.sortToggle[name] : null;
if (!dir) {
if (sortInfo && sortInfo.field == name) {
dir = (this.sortToggle[name] || 'ASC').toggle('ASC', 'DESC');
} else {
dir = field.sortDir;
}
}
this.sortToggle[name] = dir;
this.sortInfo = {field: name, direction: dir};
this.hasMultiSort = false;
if (this.remoteSort) {
if (!this.load(this.lastOptions)) {
if (sortToggle) {
this.sortToggle[name] = sortToggle;
}
if (sortInfo) {
this.sortInfo = sortInfo;
}
}
} else {
this.applySort();
this.fireEvent('datachanged', this);
}
return true;
},
multiSort: function(sorters, direction) {
this.hasMultiSort = true;
direction = direction || "ASC";
if (this.multiSortInfo && direction == this.multiSortInfo.direction) {
direction = direction.toggle("ASC", "DESC");
}
this.multiSortInfo = {
sorters : sorters,
direction: direction
};
if (this.remoteSort) {
this.singleSort(sorters[0].field, sorters[0].direction);
} else {
this.applySort();
this.fireEvent('datachanged', this);
}
},
each : function(fn, scope){
this.data.each(fn, scope);
},
getModifiedRecords : function(){
return this.modified;
},
sum : function(property, start, end){
var rs = this.data.items, v = 0;
start = start || 0;
end = (end || end === 0) ? end : rs.length-1;
for(var i = start; i <= end; i++){
v += (rs[i].data[property] || 0);
}
return v;
},
createFilterFn : function(property, value, anyMatch, caseSensitive, exactMatch){
if(Ext.isEmpty(value, false)){
return false;
}
value = this.data.createValueMatcher(value, anyMatch, caseSensitive, exactMatch);
return function(r) {
return value.test(r.data[property]);
};
},
createMultipleFilterFn: function(filters) {
return function(record) {
var isMatch = true;
for (var i=0, j = filters.length; i < j; i++) {
var filter = filters[i],
fn = filter.fn,
scope = filter.scope;
isMatch = isMatch && fn.call(scope, record);
}
return isMatch;
};
},
filter : function(property, value, anyMatch, caseSensitive, exactMatch){
var fn;
if (Ext.isObject(property)) {
property = [property];
}
if (Ext.isArray(property)) {
var filters = [];
for (var i=0, j = property.length; i < j; i++) {
var filter = property[i],
func = filter.fn,
scope = filter.scope || this;
if (!Ext.isFunction(func)) {
func = this.createFilterFn(filter.property, filter.value, filter.anyMatch, filter.caseSensitive, filter.exactMatch);
}
filters.push({fn: func, scope: scope});
}
fn = this.createMultipleFilterFn(filters);
} else {
fn = this.createFilterFn(property, value, anyMatch, caseSensitive, exactMatch);
}
return fn ? this.filterBy(fn) : this.clearFilter();
},
filterBy : function(fn, scope){
this.snapshot = this.snapshot || this.data;
this.data = this.queryBy(fn, scope || this);
this.fireEvent('datachanged', this);
},
clearFilter : function(suppressEvent){
if(this.isFiltered()){
this.data = this.snapshot;
delete this.snapshot;
if(suppressEvent !== true){
this.fireEvent('datachanged', this);
}
}
},
isFiltered : function(){
return !!this.snapshot && this.snapshot != this.data;
},
query : function(property, value, anyMatch, caseSensitive){
var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
return fn ? this.queryBy(fn) : this.data.clone();
},
queryBy : function(fn, scope){
var data = this.snapshot || this.data;
return data.filterBy(fn, scope||this);
},
find : function(property, value, start, anyMatch, caseSensitive){
var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
return fn ? this.data.findIndexBy(fn, null, start) : -1;
},
findExact: function(property, value, start){
return this.data.findIndexBy(function(rec){
return rec.get(property) === value;
}, this, start);
},
findBy : function(fn, scope, start){
return this.data.findIndexBy(fn, scope, start);
},
collect : function(dataIndex, allowNull, bypassFilter){
var d = (bypassFilter === true && this.snapshot) ?
this.snapshot.items : this.data.items;
var v, sv, r = [], l = {};
for(var i = 0, len = d.length; i < len; i++){
v = d[i].data[dataIndex];
sv = String(v);
if((allowNull || !Ext.isEmpty(v)) && !l[sv]){
l[sv] = true;
r[r.length] = v;
}
}
return r;
},
afterEdit : function(record){
if(this.modified.indexOf(record) == -1){
this.modified.push(record);
}
this.fireEvent('update', this, record, Ext.data.Record.EDIT);
},
afterReject : function(record){
this.modified.remove(record);
this.fireEvent('update', this, record, Ext.data.Record.REJECT);
},
afterCommit : function(record){
this.modified.remove(record);
this.fireEvent('update', this, record, Ext.data.Record.COMMIT);
},
commitChanges : function(){
var modified = this.modified.slice(0),
length = modified.length,
i;
for (i = 0; i < length; i++){
modified[i].commit();
}
this.modified = [];
this.removed = [];
},
rejectChanges : function() {
var modified = this.modified.slice(0),
removed = this.removed.slice(0).reverse(),
mLength = modified.length,
rLength = removed.length,
i;
for (i = 0; i < mLength; i++) {
modified[i].reject();
}
for (i = 0; i < rLength; i++) {
this.insert(removed[i].lastIndex || 0, removed[i]);
removed[i].reject();
}
this.modified = [];
this.removed = [];
},
onMetaChange : function(meta){
this.recordType = this.reader.recordType;
this.fields = this.recordType.prototype.fields;
delete this.snapshot;
if(this.reader.meta.sortInfo){
this.sortInfo = this.reader.meta.sortInfo;
}else if(this.sortInfo && !this.fields.get(this.sortInfo.field)){
delete this.sortInfo;
}
if(this.writer){
this.writer.meta = this.reader.meta;
}
this.modified = [];
this.fireEvent('metachange', this, this.reader.meta);
},
findInsertIndex : function(record){
this.suspendEvents();
var data = this.data.clone();
this.data.add(record);
this.applySort();
var index = this.data.indexOf(record);
this.data = data;
this.resumeEvents();
return index;
},
setBaseParam : function (name, value){
this.baseParams = this.baseParams || {};
this.baseParams[name] = value;
}
});
Ext.reg('store', Ext.data.Store);
Ext.data.Store.Error = Ext.extend(Ext.Error, {
name: 'Ext.data.Store'
});
Ext.apply(Ext.data.Store.Error.prototype, {
lang: {
'writer-undefined' : 'Attempted to execute a write-action without a DataWriter installed.'
}
});
Ext.data.Field = Ext.extend(Object, {
constructor : function(config){
if(Ext.isString(config)){
config = {name: config};
}
Ext.apply(this, config);
var types = Ext.data.Types,
st = this.sortType,
t;
if(this.type){
if(Ext.isString(this.type)){
this.type = Ext.data.Types[this.type.toUpperCase()] || types.AUTO;
}
}else{
this.type = types.AUTO;
}
if(Ext.isString(st)){
this.sortType = Ext.data.SortTypes[st];
}else if(Ext.isEmpty(st)){
this.sortType = this.type.sortType;
}
if(!this.convert){
this.convert = this.type.convert;
}
},
dateFormat: null,
useNull: false,
defaultValue: "",
mapping: null,
sortType : null,
sortDir : "ASC",
allowBlank : true
});
Ext.data.DataReader = function(meta, recordType){
this.meta = meta;
this.recordType = Ext.isArray(recordType) ?
Ext.data.Record.create(recordType) : recordType;
if (this.recordType){
this.buildExtractors();
}
};
Ext.data.DataReader.prototype = {
getTotal: Ext.emptyFn,
getRoot: Ext.emptyFn,
getMessage: Ext.emptyFn,
getSuccess: Ext.emptyFn,
getId: Ext.emptyFn,
buildExtractors : Ext.emptyFn,
extractValues : Ext.emptyFn,
realize: function(rs, data){
if (Ext.isArray(rs)) {
for (var i = rs.length - 1; i >= 0; i--) {
if (Ext.isArray(data)) {
this.realize(rs.splice(i,1).shift(), data.splice(i,1).shift());
}
else {
this.realize(rs.splice(i,1).shift(), data);
}
}
}
else {
if (Ext.isArray(data) && data.length == 1) {
data = data.shift();
}
if (!this.isData(data)) {
throw new Ext.data.DataReader.Error('realize', rs);
}
rs.phantom = false;
rs._phid = rs.id;
rs.id = this.getId(data);
rs.data = data;
rs.commit();
rs.store.reMap(rs);
}
},
update : function(rs, data) {
if (Ext.isArray(rs)) {
for (var i=rs.length-1; i >= 0; i--) {
if (Ext.isArray(data)) {
this.update(rs.splice(i,1).shift(), data.splice(i,1).shift());
}
else {
this.update(rs.splice(i,1).shift(), data);
}
}
}
else {
if (Ext.isArray(data) && data.length == 1) {
data = data.shift();
}
if (this.isData(data)) {
rs.data = Ext.apply(rs.data, data);
}
rs.commit();
}
},
extractData : function(root, returnRecords) {
var rawName = (this instanceof Ext.data.JsonReader) ? 'json' : 'node';
var rs = [];
if (this.isData(root) && !(this instanceof Ext.data.XmlReader)) {
root = [root];
}
var f = this.recordType.prototype.fields,
fi = f.items,
fl = f.length,
rs = [];
if (returnRecords === true) {
var Record = this.recordType;
for (var i = 0; i < root.length; i++) {
var n = root[i];
var record = new Record(this.extractValues(n, fi, fl), this.getId(n));
record[rawName] = n;
rs.push(record);
}
}
else {
for (var i = 0; i < root.length; i++) {
var data = this.extractValues(root[i], fi, fl);
data[this.meta.idProperty] = this.getId(root[i]);
rs.push(data);
}
}
return rs;
},
isData : function(data) {
return (data && Ext.isObject(data) && !Ext.isEmpty(this.getId(data))) ? true : false;
},
onMetaChange : function(meta){
delete this.ef;
this.meta = meta;
this.recordType = Ext.data.Record.create(meta.fields);
this.buildExtractors();
}
};
Ext.data.DataReader.Error = Ext.extend(Ext.Error, {
constructor : function(message, arg) {
this.arg = arg;
Ext.Error.call(this, message);
},
name: 'Ext.data.DataReader'
});
Ext.apply(Ext.data.DataReader.Error.prototype, {
lang : {
'update': "#update received invalid data from server. Please see docs for DataReader#update and review your DataReader configuration.",
'realize': "#realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.",
'invalid-response': "#readResponse received an invalid response from the server."
}
});
Ext.data.DataWriter = function(config){
Ext.apply(this, config);
};
Ext.data.DataWriter.prototype = {
writeAllFields : false,
listful : false,
apply : function(params, baseParams, action, rs) {
var data = [],
renderer = action + 'Record';
if (Ext.isArray(rs)) {
Ext.each(rs, function(rec){
data.push(this[renderer](rec));
}, this);
}
else if (rs instanceof Ext.data.Record) {
data = this[renderer](rs);
}
this.render(params, baseParams, data);
},
render : Ext.emptyFn,
updateRecord : Ext.emptyFn,
createRecord : Ext.emptyFn,
destroyRecord : Ext.emptyFn,
toHash : function(rec, config) {
var map = rec.fields.map,
data = {},
raw = (this.writeAllFields === false && rec.phantom === false) ? rec.getChanges() : rec.data,
m;
Ext.iterate(raw, function(prop, value){
if((m = map[prop])){
data[m.mapping ? m.mapping : m.name] = value;
}
});
if (rec.phantom) {
if (rec.fields.containsKey(this.meta.idProperty) && Ext.isEmpty(rec.data[this.meta.idProperty])) {
delete data[this.meta.idProperty];
}
} else {
data[this.meta.idProperty] = rec.id;
}
return data;
},
toArray : function(data) {
var fields = [];
Ext.iterate(data, function(k, v) {fields.push({name: k, value: v});},this);
return fields;
}
};
Ext.data.DataProxy = function(conn){
conn = conn || {};
this.api = conn.api;
this.url = conn.url;
this.restful = conn.restful;
this.listeners = conn.listeners;
this.prettyUrls = conn.prettyUrls;
this.addEvents(
'exception',
'beforeload',
'load',
'loadexception',
'beforewrite',
'write'
);
Ext.data.DataProxy.superclass.constructor.call(this);
try {
Ext.data.Api.prepare(this);
} catch (e) {
if (e instanceof Ext.data.Api.Error) {
e.toConsole();
}
}
Ext.data.DataProxy.relayEvents(this, ['beforewrite', 'write', 'exception']);
};
Ext.extend(Ext.data.DataProxy, Ext.util.Observable, {
restful: false,
setApi : function() {
if (arguments.length == 1) {
var valid = Ext.data.Api.isValid(arguments[0]);
if (valid === true) {
this.api = arguments[0];
}
else {
throw new Ext.data.Api.Error('invalid', valid);
}
}
else if (arguments.length == 2) {
if (!Ext.data.Api.isAction(arguments[0])) {
throw new Ext.data.Api.Error('invalid', arguments[0]);
}
this.api[arguments[0]] = arguments[1];
}
Ext.data.Api.prepare(this);
},
isApiAction : function(action) {
return (this.api[action]) ? true : false;
},
request : function(action, rs, params, reader, callback, scope, options) {
if (!this.api[action] && !this.load) {
throw new Ext.data.DataProxy.Error('action-undefined', action);
}
params = params || {};
if ((action === Ext.data.Api.actions.read) ? this.fireEvent("beforeload", this, params) : this.fireEvent("beforewrite", this, action, rs, params) !== false) {
this.doRequest.apply(this, arguments);
}
else {
callback.call(scope || this, null, options, false);
}
},
load : null,
doRequest : function(action, rs, params, reader, callback, scope, options) {
this.load(params, reader, callback, scope, options);
},
onRead : Ext.emptyFn,
onWrite : Ext.emptyFn,
buildUrl : function(action, record) {
record = record || null;
var url = (this.conn && this.conn.url) ? this.conn.url : (this.api[action]) ? this.api[action].url : this.url;
if (!url) {
throw new Ext.data.Api.Error('invalid-url', action);
}
var provides = null;
var m = url.match(/(.*)(\.json|\.xml|\.html)$/);
if (m) {
provides = m[2];
url = m[1];
}
if ((this.restful === true || this.prettyUrls === true) && record instanceof Ext.data.Record && !record.phantom) {
url += '/' + record.id;
}
return (provides === null) ? url : url + provides;
},
destroy: function(){
this.purgeListeners();
}
});
Ext.apply(Ext.data.DataProxy, Ext.util.Observable.prototype);
Ext.util.Observable.call(Ext.data.DataProxy);
Ext.data.DataProxy.Error = Ext.extend(Ext.Error, {
constructor : function(message, arg) {
this.arg = arg;
Ext.Error.call(this, message);
},
name: 'Ext.data.DataProxy'
});
Ext.apply(Ext.data.DataProxy.Error.prototype, {
lang: {
'action-undefined': "DataProxy attempted to execute an API-action but found an undefined url / function. Please review your Proxy url/api-configuration.",
'api-invalid': 'Recieved an invalid API-configuration. Please ensure your proxy API-configuration contains only the actions from Ext.data.Api.actions.'
}
});
Ext.data.Request = function(params) {
Ext.apply(this, params);
};
Ext.data.Request.prototype = {
action : undefined,
rs : undefined,
params: undefined,
callback : Ext.emptyFn,
scope : undefined,
reader : undefined
};
Ext.data.Response = function(params) {
Ext.apply(this, params);
};
Ext.data.Response.prototype = {
action: undefined,
success : undefined,
message : undefined,
data: undefined,
raw: undefined,
records: undefined
};
Ext.data.ScriptTagProxy = function(config){
Ext.apply(this, config);
Ext.data.ScriptTagProxy.superclass.constructor.call(this, config);
this.head = document.getElementsByTagName("head")[0];
};
Ext.data.ScriptTagProxy.TRANS_ID = 1000;
Ext.extend(Ext.data.ScriptTagProxy, Ext.data.DataProxy, {
timeout : 30000,
callbackParam : "callback",
nocache : true,
doRequest : function(action, rs, params, reader, callback, scope, arg) {
var p = Ext.urlEncode(Ext.apply(params, this.extraParams));
var url = this.buildUrl(action, rs);
if (!url) {
throw new Ext.data.Api.Error('invalid-url', url);
}
url = Ext.urlAppend(url, p);
if(this.nocache){
url = Ext.urlAppend(url, '_dc=' + (new Date().getTime()));
}
var transId = ++Ext.data.ScriptTagProxy.TRANS_ID;
var trans = {
id : transId,
action: action,
cb : "stcCallback"+transId,
scriptId : "stcScript"+transId,
params : params,
arg : arg,
url : url,
callback : callback,
scope : scope,
reader : reader
};
window[trans.cb] = this.createCallback(action, rs, trans);
url += String.format("&{0}={1}", this.callbackParam, trans.cb);
if(this.autoAbort !== false){
this.abort();
}
trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
var script = document.createElement("script");
script.setAttribute("src", url);
script.setAttribute("type", "text/javascript");
script.setAttribute("id", trans.scriptId);
this.head.appendChild(script);
this.trans = trans;
},
createCallback : function(action, rs, trans) {
var self = this;
return function(res) {
self.trans = false;
self.destroyTrans(trans, true);
if (action === Ext.data.Api.actions.read) {
self.onRead.call(self, action, trans, res);
} else {
self.onWrite.call(self, action, trans, res, rs);
}
};
},
onRead : function(action, trans, res) {
var result;
try {
result = trans.reader.readRecords(res);
}catch(e){
this.fireEvent("loadexception", this, trans, res, e);
this.fireEvent('exception', this, 'response', action, trans, res, e);
trans.callback.call(trans.scope||window, null, trans.arg, false);
return;
}
if (result.success === false) {
this.fireEvent('loadexception', this, trans, res);
this.fireEvent('exception', this, 'remote', action, trans, res, null);
} else {
this.fireEvent("load", this, res, trans.arg);
}
trans.callback.call(trans.scope||window, result, trans.arg, result.success);
},
onWrite : function(action, trans, response, rs) {
var reader = trans.reader;
try {
var res = reader.readResponse(action, response);
} catch (e) {
this.fireEvent('exception', this, 'response', action, trans, res, e);
trans.callback.call(trans.scope||window, null, res, false);
return;
}
if(!res.success === true){
this.fireEvent('exception', this, 'remote', action, trans, res, rs);
trans.callback.call(trans.scope||window, null, res, false);
return;
}
this.fireEvent("write", this, action, res.data, res, rs, trans.arg );
trans.callback.call(trans.scope||window, res.data, res, true);
},
isLoading : function(){
return this.trans ? true : false;
},
abort : function(){
if(this.isLoading()){
this.destroyTrans(this.trans);
}
},
destroyTrans : function(trans, isLoaded){
this.head.removeChild(document.getElementById(trans.scriptId));
clearTimeout(trans.timeoutId);
if(isLoaded){
window[trans.cb] = undefined;
try{
delete window[trans.cb];
}catch(e){}
}else{
window[trans.cb] = function(){
window[trans.cb] = undefined;
try{
delete window[trans.cb];
}catch(e){}
};
}
},
handleFailure : function(trans){
this.trans = false;
this.destroyTrans(trans, false);
if (trans.action === Ext.data.Api.actions.read) {
this.fireEvent("loadexception", this, null, trans.arg);
}
this.fireEvent('exception', this, 'response', trans.action, {
response: null,
options: trans.arg
});
trans.callback.call(trans.scope||window, null, trans.arg, false);
},
destroy: function(){
this.abort();
Ext.data.ScriptTagProxy.superclass.destroy.call(this);
}
});
Ext.data.HttpProxy = function(conn){
Ext.data.HttpProxy.superclass.constructor.call(this, conn);
this.conn = conn;
this.conn.url = null;
this.useAjax = !conn || !conn.events;
var actions = Ext.data.Api.actions;
this.activeRequest = {};
for (var verb in actions) {
this.activeRequest[actions[verb]] = undefined;
}
};
Ext.extend(Ext.data.HttpProxy, Ext.data.DataProxy, {
getConnection : function() {
return this.useAjax ? Ext.Ajax : this.conn;
},
setUrl : function(url, makePermanent) {
this.conn.url = url;
if (makePermanent === true) {
this.url = url;
this.api = null;
Ext.data.Api.prepare(this);
}
},
doRequest : function(action, rs, params, reader, cb, scope, arg) {
var o = {
method: (this.api[action]) ? this.api[action]['method'] : undefined,
request: {
callback : cb,
scope : scope,
arg : arg
},
reader: reader,
callback : this.createCallback(action, rs),
scope: this
};
if (params.jsonData) {
o.jsonData = params.jsonData;
} else if (params.xmlData) {
o.xmlData = params.xmlData;
} else {
o.params = params || {};
}
this.conn.url = this.buildUrl(action, rs);
if(this.useAjax){
Ext.applyIf(o, this.conn);
if (this.activeRequest[action]) {
}
this.activeRequest[action] = Ext.Ajax.request(o);
}else{
this.conn.request(o);
}
this.conn.url = null;
},
createCallback : function(action, rs) {
return function(o, success, response) {
this.activeRequest[action] = undefined;
if (!success) {
if (action === Ext.data.Api.actions.read) {
this.fireEvent('loadexception', this, o, response);
}
this.fireEvent('exception', this, 'response', action, o, response);
o.request.callback.call(o.request.scope, null, o.request.arg, false);
return;
}
if (action === Ext.data.Api.actions.read) {
this.onRead(action, o, response);
} else {
this.onWrite(action, o, response, rs);
}
};
},
onRead : function(action, o, response) {
var result;
try {
result = o.reader.read(response);
}catch(e){
this.fireEvent('loadexception', this, o, response, e);
this.fireEvent('exception', this, 'response', action, o, response, e);
o.request.callback.call(o.request.scope, null, o.request.arg, false);
return;
}
if (result.success === false) {
this.fireEvent('loadexception', this, o, response);
var res = o.reader.readResponse(action, response);
this.fireEvent('exception', this, 'remote', action, o, res, null);
}
else {
this.fireEvent('load', this, o, o.request.arg);
}
o.request.callback.call(o.request.scope, result, o.request.arg, result.success);
},
onWrite : function(action, o, response, rs) {
var reader = o.reader;
var res;
try {
res = reader.readResponse(action, response);
} catch (e) {
this.fireEvent('exception', this, 'response', action, o, response, e);
o.request.callback.call(o.request.scope, null, o.request.arg, false);
return;
}
if (res.success === true) {
this.fireEvent('write', this, action, res.data, res, rs, o.request.arg);
} else {
this.fireEvent('exception', this, 'remote', action, o, res, rs);
}
o.request.callback.call(o.request.scope, res.data, res, res.success);
},
destroy: function(){
if(!this.useAjax){
this.conn.abort();
}else if(this.activeRequest){
var actions = Ext.data.Api.actions;
for (var verb in actions) {
if(this.activeRequest[actions[verb]]){
Ext.Ajax.abort(this.activeRequest[actions[verb]]);
}
}
}
Ext.data.HttpProxy.superclass.destroy.call(this);
}
});
Ext.data.MemoryProxy = function(data){
var api = {};
api[Ext.data.Api.actions.read] = true;
Ext.data.MemoryProxy.superclass.constructor.call(this, {
api: api
});
this.data = data;
};
Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, {
doRequest : function(action, rs, params, reader, callback, scope, arg) {
params = params || {};
var result;
try {
result = reader.readRecords(this.data);
}catch(e){
this.fireEvent("loadexception", this, null, arg, e);
this.fireEvent('exception', this, 'response', action, arg, null, e);
callback.call(scope, null, arg, false);
return;
}
callback.call(scope, result, arg, true);
}
});
Ext.data.Types = new function(){
var st = Ext.data.SortTypes;
Ext.apply(this, {
stripRe: /[\$,%]/g,
AUTO: {
convert: function(v){ return v; },
sortType: st.none,
type: 'auto'
},
STRING: {
convert: function(v){ return (v === undefined || v === null) ? '' : String(v); },
sortType: st.asUCString,
type: 'string'
},
INT: {
convert: function(v){
return v !== undefined && v !== null && v !== '' ?
parseInt(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0);
},
sortType: st.none,
type: 'int'
},
FLOAT: {
convert: function(v){
return v !== undefined && v !== null && v !== '' ?
parseFloat(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0);
},
sortType: st.none,
type: 'float'
},
BOOL: {
convert: function(v){ return v === true || v === 'true' || v == 1; },
sortType: st.none,
type: 'bool'
},
DATE: {
convert: function(v){
var df = this.dateFormat;
if(!v){
return null;
}
if(Ext.isDate(v)){
return v;
}
if(df){
if(df == 'timestamp'){
return new Date(v*1000);
}
if(df == 'time'){
return new Date(parseInt(v, 10));
}
return Date.parseDate(v, df);
}
var parsed = Date.parse(v);
return parsed ? new Date(parsed) : null;
},
sortType: st.asDate,
type: 'date'
}
});
Ext.apply(this, {
BOOLEAN: this.BOOL,
INTEGER: this.INT,
NUMBER: this.FLOAT
});
};
Ext.data.JsonWriter = Ext.extend(Ext.data.DataWriter, {
encode : true,
encodeDelete: false,
constructor : function(config){
Ext.data.JsonWriter.superclass.constructor.call(this, config);
},
render : function(params, baseParams, data) {
if (this.encode === true) {
Ext.apply(params, baseParams);
params[this.meta.root] = Ext.encode(data);
} else {
var jdata = Ext.apply({}, baseParams);
jdata[this.meta.root] = data;
params.jsonData = jdata;
}
},
createRecord : function(rec) {
return this.toHash(rec);
},
updateRecord : function(rec) {
return this.toHash(rec);
},
destroyRecord : function(rec){
if(this.encodeDelete){
var data = {};
data[this.meta.idProperty] = rec.id;
return data;
}else{
return rec.id;
}
}
});
Ext.data.JsonReader = function(meta, recordType){
meta = meta || {};
Ext.applyIf(meta, {
idProperty: 'id',
successProperty: 'success',
totalProperty: 'total'
});
Ext.data.JsonReader.superclass.constructor.call(this, meta, recordType || meta.fields);
};
Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, {
read : function(response){
var json = response.responseText;
var o = Ext.decode(json);
if(!o) {
throw {message: 'JsonReader.read: Json object not found'};
}
return this.readRecords(o);
},
readResponse : function(action, response) {
var o = (response.responseText !== undefined) ? Ext.decode(response.responseText) : response;
if(!o) {
throw new Ext.data.JsonReader.Error('response');
}
var root = this.getRoot(o),
success = this.getSuccess(o);
if (success && action === Ext.data.Api.actions.create) {
var def = Ext.isDefined(root);
if (def && Ext.isEmpty(root)) {
throw new Ext.data.JsonReader.Error('root-empty', this.meta.root);
}
else if (!def) {
throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
}
}
var res = new Ext.data.Response({
action: action,
success: success,
data: (root) ? this.extractData(root, false) : [],
message: this.getMessage(o),
raw: o
});
if (Ext.isEmpty(res.success)) {
throw new Ext.data.JsonReader.Error('successProperty-response', this.meta.successProperty);
}
return res;
},
readRecords : function(o){
this.jsonData = o;
if(o.metaData){
this.onMetaChange(o.metaData);
}
var s = this.meta, Record = this.recordType,
f = Record.prototype.fields, fi = f.items, fl = f.length, v;
var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
if(s.totalProperty){
v = parseInt(this.getTotal(o), 10);
if(!isNaN(v)){
totalRecords = v;
}
}
if(s.successProperty){
v = this.getSuccess(o);
if(v === false || v === 'false'){
success = false;
}
}
return {
success : success,
records : this.extractData(root, true),
totalRecords : totalRecords
};
},
buildExtractors : function() {
if(this.ef){
return;
}
var s = this.meta, Record = this.recordType,
f = Record.prototype.fields, fi = f.items, fl = f.length;
if(s.totalProperty) {
this.getTotal = this.createAccessor(s.totalProperty);
}
if(s.successProperty) {
this.getSuccess = this.createAccessor(s.successProperty);
}
if (s.messageProperty) {
this.getMessage = this.createAccessor(s.messageProperty);
}
this.getRoot = s.root ? this.createAccessor(s.root) : function(p){return p;};
if (s.id || s.idProperty) {
var g = this.createAccessor(s.id || s.idProperty);
this.getId = function(rec) {
var r = g(rec);
return (r === undefined || r === '') ? null : r;
};
} else {
this.getId = function(){return null;};
}
var ef = [];
for(var i = 0; i < fl; i++){
f = fi[i];
var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
ef.push(this.createAccessor(map));
}
this.ef = ef;
},
simpleAccess : function(obj, subsc) {
return obj[subsc];
},
createAccessor : function(){
var re = /[\[\.]/;
return function(expr) {
if(Ext.isEmpty(expr)){
return Ext.emptyFn;
}
if(Ext.isFunction(expr)){
return expr;
}
var i = String(expr).search(re);
if(i >= 0){
return new Function('obj', 'return obj' + (i > 0 ? '.' : '') + expr);
}
return function(obj){
return obj[expr];
};
};
}(),
extractValues : function(data, items, len) {
var f, values = {};
for(var j = 0; j < len; j++){
f = items[j];
var v = this.ef[j](data);
values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, data);
}
return values;
}
});
Ext.data.JsonReader.Error = Ext.extend(Ext.Error, {
constructor : function(message, arg) {
this.arg = arg;
Ext.Error.call(this, message);
},
name : 'Ext.data.JsonReader'
});
Ext.apply(Ext.data.JsonReader.Error.prototype, {
lang: {
'response': 'An error occurred while json-decoding your server response',
'successProperty-response': 'Could not locate your "successProperty" in your server response. Please review your JsonReader config to ensure the config-property "successProperty" matches the property in your server-response. See the JsonReader docs.',
'root-undefined-config': 'Your JsonReader was configured without a "root" property. Please review your JsonReader config and make sure to define the root property. See the JsonReader docs.',
'idProperty-undefined' : 'Your JsonReader was configured without an "idProperty" Please review your JsonReader configuration and ensure the "idProperty" is set (e.g.: "id"). See the JsonReader docs.',
'root-empty': 'Data was expected to be returned by the server in the "root" property of the response. Please review your JsonReader configuration to ensure the "root" property matches that returned in the server-response. See JsonReader docs.'
}
});
Ext.data.ArrayReader = Ext.extend(Ext.data.JsonReader, {
readRecords : function(o){
this.arrayData = o;
var s = this.meta,
sid = s ? Ext.num(s.idIndex, s.id) : null,
recordType = this.recordType,
fields = recordType.prototype.fields,
records = [],
success = true,
v;
var root = this.getRoot(o);
for(var i = 0, len = root.length; i < len; i++) {
var n = root[i],
values = {},
id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
for(var j = 0, jlen = fields.length; j < jlen; j++) {
var f = fields.items[j],
k
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment