Wisepricer_Syncer - Version 1.1.3.1

Version Notes

Added filters:
enabled,
website,
product type

Download this release

Release Info

Developer Magento Core Team
Extension Wisepricer_Syncer
Version 1.1.3.1
Comparing to
See all releases


Code changes from version 1.1.3.0 to 1.1.3.1

app/code/local/Wisepricer/Syncer/Block/Adminhtml/Mapping.php CHANGED
@@ -104,6 +104,40 @@ class Wisepricer_Syncer_Block_Adminhtml_Mapping extends Mage_Adminhtml_Block_Wid
104
return $html;
105
}
106
107
private function _getCustomSelect($name,$options,$default=0,$class='',$style='',$id=''){
108
109
$select='<select name="'.$name.'" id="'.$id.'" class="'.$class.'" style="'.$style.'">';
104
return $html;
105
}
106
107
+ public function renderWebsitesSelect($selected=0){
108
+
109
+ $switcher=new Mage_Adminhtml_Block_Store_Switcher;
110
+ $websites = $switcher->getWebsites();
111
+
112
+ $options=array();
113
+ $options[]=array('label'=>'All','value'=>0);
114
+ foreach($websites as $website){
115
+ foreach($website->getGroups() as $group){
116
+
117
+ $name=$group->getName();
118
+ $options[]=array('label'=>$name,'value'=>$group->getdefault_store_id());
119
+
120
+ }
121
+ }
122
+
123
+
124
+ $html=$this->_getCustomSelect('register_form[website]',$options,$selected,'chzn-select function-select','width:250px');
125
+ return $html;
126
+ }
127
+
128
+ public function renderTypesSelect($selected='simple'){
129
+
130
+ $options=array();
131
+ $options[]=array('label'=>'Simple','value'=>'simple');
132
+ $options[]=array('label'=>'All','value'=>'all');
133
+ $options[]=array('label'=>'Configurable','value'=>'configurable');
134
+ $options[]=array('label'=>'Bundle','value'=>'bundle');
135
+ $options[]=array('label'=>'Grouped','value'=>'grouped');
136
+
137
+ $html=$this->_getCustomSelect('register_form[product_type]',$options,$selected,'chzn-select function-select','width:250px');
138
+ return $html;
139
+ }
140
+
141
private function _getCustomSelect($name,$options,$default=0,$class='',$style='',$id=''){
142
143
$select='<select name="'.$name.'" id="'.$id.'" class="'.$class.'" style="'.$style.'">';
app/code/local/Wisepricer/Syncer/controllers/Adminhtml/SyncerController.php CHANGED
@@ -39,6 +39,9 @@ class Wisepricer_Syncer_Adminhtml_SyncerController extends Mage_Adminhtml_Contro
39
{
40
$post = $this->getRequest()->getPost('register_form');
41
$lisensekey = $post['licensekey'];
42
try {
43
if (empty($lisensekey)) {
44
Mage::throwException($this->__('Invalid form data. The license key is missing!'));
@@ -46,7 +49,9 @@ class Wisepricer_Syncer_Adminhtml_SyncerController extends Mage_Adminhtml_Contro
46
$model = Mage::getModel('wisepricer_syncer/config');
47
$lisenceData=$model->load(1);
48
if(count($lisenceData->getData())>0){
49
- $lisenceData->setLicensekey($lisensekey);
50
$lisenceData->save();
51
}else{
52
$model->setLicensekey($lisensekey)->save();
39
{
40
$post = $this->getRequest()->getPost('register_form');
41
$lisensekey = $post['licensekey'];
42
+ $website = $post['website'];
43
+ $type = $post['product_type'];
44
+
45
try {
46
if (empty($lisensekey)) {
47
Mage::throwException($this->__('Invalid form data. The license key is missing!'));
49
$model = Mage::getModel('wisepricer_syncer/config');
50
$lisenceData=$model->load(1);
51
if(count($lisenceData->getData())>0){
52
+ $lisenceData->setLicensekey($lisensekey);
53
+ $lisenceData->setWebsite($website);
54
+ $lisenceData->setProduct_type($type);
55
$lisenceData->save();
56
}else{
57
$model->setLicensekey($lisensekey)->save();
app/code/local/Wisepricer/Syncer/controllers/ProductsController.php CHANGED
@@ -70,6 +70,13 @@ class Wisepricer_Syncer_ProductsController extends Mage_Core_Controller_Front_Ac
70
}
71
72
}
73
74
//TODO add user control here - dont bring not saleble products
75
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
70
}
71
72
}
73
+ $collection->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
74
+ $collection->addAttributeToFilter('type_id', array('eq' => 'simple'));
75
+
76
+ if($licenseData->getWebsite()!=0){
77
+ $collection->addStoreFilter($licenseData->getWebsite());
78
+ }
79
+
80
81
//TODO add user control here - dont bring not saleble products
82
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
app/code/local/Wisepricer/Syncer/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
<config>
3
<modules>
4
<Wisepricer_Syncer>
5
- <version>1.1.3.0</version>
6
<url>http://www.wisepricer.com/index.php</url>
7
<modulename>Wisepricer Syncer</modulename>
8
</Wisepricer_Syncer>
2
<config>
3
<modules>
4
<Wisepricer_Syncer>
5
+ <version>1.1.3.1</version>
6
<url>http://www.wisepricer.com/index.php</url>
7
<modulename>Wisepricer Syncer</modulename>
8
</Wisepricer_Syncer>
app/code/local/Wisepricer/Syncer/sql/syncer_setup/mysql4-install-1.1.3.0.php CHANGED
@@ -30,9 +30,7 @@ CREATE TABLE IF NOT EXISTS {$this->getTable('wisepricer_syncer_mapping')} (
30
31
`magento_field` varchar(255) character set utf8 NOT NULL,
32
33
- PRIMARY KEY (`mapping_id`),
34
-
35
- UNIQUE KEY `wsp_field` (`magento_field`)
36
37
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
38
30
31
`magento_field` varchar(255) character set utf8 NOT NULL,
32
33
+ PRIMARY KEY (`mapping_id`)
34
35
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
36
app/code/local/Wisepricer/Syncer/sql/syncer_setup/mysql4-upgrade-1.1.3.0-1.1.3.1.php ADDED
@@ -0,0 +1,14 @@
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ ALTER TABLE {$this->getTable('wisepricer_syncer_config')} ADD `website` INT NOT NULL DEFAULT '0';
10
+ ALTER TABLE {$this->getTable('wisepricer_syncer_config')} ADD `product_type` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'simple';
11
+
12
+ ");
13
+
14
+ $installer->endSetup();
app/design/adminhtml/default/default/template/wisepricer/mapping.phtml CHANGED
@@ -21,6 +21,9 @@
21
<div class="guidelines-block">
22
<p><?php echo $this->__('Enter your WisePricer license key you received from WisePricer. This will link this store with your WisePricer account.')?></p>
23
</div>
24
<div class="guidelines-block mapping-guidelines">
25
<h4><?php echo $this->__('Wisepricer mapping guidelines:')?></h4>
26
<ul>
@@ -40,6 +43,18 @@
40
<input type="text" value="<?php echo $licenseData->getLicensekey()?>" class="input-text required-entry" name="register_form[licensekey]" />
41
</div>
42
</div>
43
<p><?php echo $this->__('Please make sure the following fields are assigned correctly:');?></p>
44
<div class="values-block">
45
<table cellspacing="0" class="form-list">
21
<div class="guidelines-block">
22
<p><?php echo $this->__('Enter your WisePricer license key you received from WisePricer. This will link this store with your WisePricer account.')?></p>
23
</div>
24
+ <div class="guidelines-block import-guidelines">
25
+ <p><?php echo $this->__('Choose which products to import to WisePricer.')?></p>
26
+ </div>
27
<div class="guidelines-block mapping-guidelines">
28
<h4><?php echo $this->__('Wisepricer mapping guidelines:')?></h4>
29
<ul>
43
<input type="text" value="<?php echo $licenseData->getLicensekey()?>" class="input-text required-entry" name="register_form[licensekey]" />
44
</div>
45
</div>
46
+ <div class="values-block">
47
+ <div class="license-block import-settings">
48
+ <div class="values-block-sub b10">
49
+ <div class="label-block"><label><?php echo $this->__('Import:')?></label></div>
50
+ <?php echo $this->renderWebsitesSelect($licenseData->getWebsite())?>
51
+ </div>
52
+ <div class="values-block-sub">
53
+ <div class="label-block"><label><?php echo $this->__('Product types:')?></label></div>
54
+ <?php echo $this->renderTypesSelect($licenseData->getProduct_type())?>
55
+ </div>
56
+ </div>
57
+ </div>
58
<p><?php echo $this->__('Please make sure the following fields are assigned correctly:');?></p>
59
<div class="values-block">
60
<table cellspacing="0" class="form-list">
package.xml CHANGED
@@ -1,18 +1,21 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>Wisepricer_Syncer</name>
4
- <version>1.1.3.0</version>
5
<stability>stable</stability>
6
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
7
<channel>community</channel>
8
<extends/>
9
<summary>WisePricer- Beat your competition</summary>
10
<description>WisePricer is a new tool that allows you to Track &amp; monitor successful online retailers and update your store prices in real-time. With WisePricer you&#x2019;ll never get left behind the competition.</description>
11
- <notes>Added version info function, reindex function, speeded up products import</notes>
12
<authors><author><name>Moshe</name><user>auto-converted</user><email>moshe@wisepricer.com</email></author></authors>
13
- <date>2012-11-06</date>
14
- <time>08:45:21</time>
15
- <contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="wisepricer"><file name="bullet-green.png" hash="78d917a9d9aea11366bada6e0ae53931"/><file name="validation_advice_bg.gif" hash="ffdad80de989e3b04a977be3778c4347"/><file name="wp-alert-icon.png" hash="0dbbadfbbe2329098d03f8351aa2eaf2"/><file name="wp-logo.png" hash="48db98cdfc570336c942271352f31094"/><file name="wp-save-btn.png" hash="6d8e02c7f5e54dcc705e6436f126c66d"/></dir></dir><dir name="wisepricer"><file name="chosen-sprite.png" hash="8e70d120437ffc6a1bf7cebeca292d5c"/><file name="chosen.css" hash="a1b7280ed62dbe210257027dd6bfa073"/><file name="chosen.proto.js" hash="b98b346e60d90e7e3f83106cf860dacd"/><file name="myprototype.js" hash="3b4b13dad33b475e11feb26fd3468ecc"/><file name="prototype17.js" hash="3b4b13dad33b475e11feb26fd3468ecc"/><file name="wisepricer.css" hash="bab3eada0e2a974b1f8f7a87cbf5bb9c"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="syncer.xml" hash="a9d0f0b5af6b7bc28fb3c3b897c1773c"/></dir><dir name="template"><dir name="wisepricer"><file name="mapping.phtml" hash="8c8f177dc6f5097c422c6bc783542b5f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wisepricer_Syncer.xml" hash="838dc229469d27db4c96a49591b12f55"/></dir></target><target name="magelocal"><dir name="Wisepricer"><dir name="Syncer"><dir name="Block"><dir name="Adminhtml"><file name="Mapping.php" hash="ce3249eb8500db5ba9a60eb788437fed"/><file name="Register.php" hash="ed2ffde3237ecba2dbdd6002b5077af3"/></dir></dir><dir name="controllers"><file name="ProductsController.php" hash="7c899d388b55ddc29b74d649d06f9720"/><dir name="Adminhtml"><file name="SyncerController.php" hash="453e3352d35836128a24280471362866"/></dir></dir><dir name="etc"><file name="config.xml" hash="9267615eae6a5d6bbaad556f4566a267"/></dir><dir name="Helper"><file name="Data.php" hash="025b73c04ab0ca01d2e7c75aaad7fea6"/></dir><dir name="lib"><dir name="phpseclib"><dir name="Crypt"><file name="AES.php" hash="dd67dd1dbc7706e6c740e8430054d5e0"/><file name="DES.php" hash="47ac443f1edd2833cdc2f4eb80aa9a71"/><file name="Hash.php" hash="9be22f6426f2176caebb34a6cd2cb579"/><file name="Random.php" hash="5befc55c3423792c0cd50bc6d4f527b1"/><file name="RC4.php" hash="c6ec724c3a5d807d5ea4645518c37d29"/><file name="Rijndael.php" hash="7a92c95c750dd9ec1b8ce92915b4aa35"/><file name="RSA.php" hash="9bd5734f28d149d183c603643f6dbbb4"/><file name="TripleDES.php" hash="07c384b505d52802803313126e9e3836"/></dir><dir name="Math"><file name="BigInteger.php" hash="61aa9373ea606c928187d168159ac3f8"/></dir><dir name="Net"><file name="SFTP.php" hash="029f797c16ddd23b1d65636a72141115"/><file name="SSH1.php" hash="818d83815fe9bb5741594226bbdad975"/><file name="SSH2.php" hash="db5145effae044c7a1f6e7d778b566f5"/></dir><dir name="PHP"><dir name="Compat"><dir name="Function"><file name="array_fill.php" hash="840a674cac272c5588fa59f9421ed9a3"/><file name="bcpowmod.php" hash="4cb8fab0ee419f4b5a626980bbf04938"/><file name="str_split.php" hash="85cb5961afa62dde933190ee851a6d9a"/></dir></dir></dir></dir></dir><dir name="Model"><file name="Config.php" hash="d669c3dc977ddf71a58c90fa8df3180c"/><file name="Mapping.php" hash="d924ae8bcf54a3ca1224e8680d847fee"/><file name="Reprice.php" hash="dd1f6f4b0031940b1c695aefbf8f47e9"/><dir name="Adminhtml"><file name="Attributes.php" hash="2d50a30f0e7df8cf5791aea101f9008a"/></dir><dir name="Mysql4"><file name="Config.php" hash="61b7eb73489844aa0ee041c216bab2db"/><file name="Mapping.php" hash="d97574adda931ce798964c67041f6af5"/><dir name="Config"><file name="Collection.php" hash="c7c7b6844e3ff8893163c392f4132f30"/></dir><dir name="Mapping"><file name="Collection.php" hash="c0f15143db582e070cfb83de92c57d09"/></dir></dir></dir><dir name="sql"><dir name="syncer_setup"><file name="mysql4-install-1.1.3.0.php" hash="25b666bcc330f7aeebc2c9759f82273f"/></dir></dir></dir></dir></target></contents>
16
<compatible/>
17
<dependencies/>
18
</package>
1
<?xml version="1.0"?>
2
<package>
3
<name>Wisepricer_Syncer</name>
4
+ <version>1.1.3.1</version>
5
<stability>stable</stability>
6
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
7
<channel>community</channel>
8
<extends/>
9
<summary>WisePricer- Beat your competition</summary>
10
<description>WisePricer is a new tool that allows you to Track &amp; monitor successful online retailers and update your store prices in real-time. With WisePricer you&#x2019;ll never get left behind the competition.</description>
11
+ <notes>Added filters:
12
+ enabled,
13
+ website,
14
+ product type</notes>
15
<authors><author><name>Moshe</name><user>auto-converted</user><email>moshe@wisepricer.com</email></author></authors>
16
+ <date>2012-11-12</date>
17
+ <time>16:26:48</time>
18
+ <contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="wisepricer"><file name="bullet-green.png" hash="78d917a9d9aea11366bada6e0ae53931"/><file name="validation_advice_bg.gif" hash="ffdad80de989e3b04a977be3778c4347"/><file name="wp-alert-icon.png" hash="0dbbadfbbe2329098d03f8351aa2eaf2"/><file name="wp-logo.png" hash="48db98cdfc570336c942271352f31094"/><file name="wp-save-btn.png" hash="6d8e02c7f5e54dcc705e6436f126c66d"/></dir></dir><dir name="wisepricer"><file name="chosen-sprite.png" hash="8e70d120437ffc6a1bf7cebeca292d5c"/><file name="chosen.css" hash="bcd3f3e697219898e26631ccf29d97ba"/><file name="chosen.proto.js" hash="8259b22f4f337ba9ab63506b5ee4a52f"/><file name="myprototype.js" hash="2325b8b147c5dfaa8531c9d8bafd3648"/><file name="prototype17.js" hash="2325b8b147c5dfaa8531c9d8bafd3648"/><file name="wisepricer.css" hash="9b0e0d64f599cabd38d4b7f767054ac0"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="syncer.xml" hash="a9d0f0b5af6b7bc28fb3c3b897c1773c"/></dir><dir name="template"><dir name="wisepricer"><file name="mapping.phtml" hash="4e5f5968d7834a5933215360d574c3b2"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wisepricer_Syncer.xml" hash="838dc229469d27db4c96a49591b12f55"/></dir></target><target name="magelocal"><dir name="Wisepricer"><dir name="Syncer"><dir name="Block"><dir name="Adminhtml"><file name="Mapping.php" hash="fd13e1440806d6fe54f7f17106951ae0"/><file name="Register.php" hash="ed2ffde3237ecba2dbdd6002b5077af3"/></dir></dir><dir name="controllers"><file name="ProductsController.php" hash="6d367c0d23ce253bb07dd5faedd68628"/><dir name="Adminhtml"><file name="SyncerController.php" hash="6a229900d705b0ee4335e37233c798e3"/></dir></dir><dir name="etc"><file name="config.xml" hash="0d0eeb8d8da8349a94de07ae54d70a15"/></dir><dir name="Helper"><file name="Data.php" hash="025b73c04ab0ca01d2e7c75aaad7fea6"/></dir><dir name="lib"><dir name="phpseclib"><dir name="Crypt"><file name="AES.php" hash="dd67dd1dbc7706e6c740e8430054d5e0"/><file name="DES.php" hash="47ac443f1edd2833cdc2f4eb80aa9a71"/><file name="Hash.php" hash="9be22f6426f2176caebb34a6cd2cb579"/><file name="Random.php" hash="5befc55c3423792c0cd50bc6d4f527b1"/><file name="RC4.php" hash="c6ec724c3a5d807d5ea4645518c37d29"/><file name="Rijndael.php" hash="7a92c95c750dd9ec1b8ce92915b4aa35"/><file name="RSA.php" hash="9bd5734f28d149d183c603643f6dbbb4"/><file name="TripleDES.php" hash="07c384b505d52802803313126e9e3836"/></dir><dir name="Math"><file name="BigInteger.php" hash="61aa9373ea606c928187d168159ac3f8"/></dir><dir name="Net"><file name="SFTP.php" hash="029f797c16ddd23b1d65636a72141115"/><file name="SSH1.php" hash="818d83815fe9bb5741594226bbdad975"/><file name="SSH2.php" hash="db5145effae044c7a1f6e7d778b566f5"/></dir><dir name="PHP"><dir name="Compat"><dir name="Function"><file name="array_fill.php" hash="840a674cac272c5588fa59f9421ed9a3"/><file name="bcpowmod.php" hash="4cb8fab0ee419f4b5a626980bbf04938"/><file name="str_split.php" hash="85cb5961afa62dde933190ee851a6d9a"/></dir></dir></dir></dir></dir><dir name="Model"><file name="Config.php" hash="d669c3dc977ddf71a58c90fa8df3180c"/><file name="Mapping.php" hash="d924ae8bcf54a3ca1224e8680d847fee"/><file name="Reprice.php" hash="dd1f6f4b0031940b1c695aefbf8f47e9"/><dir name="Adminhtml"><file name="Attributes.php" hash="2d50a30f0e7df8cf5791aea101f9008a"/></dir><dir name="Mysql4"><file name="Config.php" hash="61b7eb73489844aa0ee041c216bab2db"/><file name="Mapping.php" hash="d97574adda931ce798964c67041f6af5"/><dir name="Config"><file name="Collection.php" hash="c7c7b6844e3ff8893163c392f4132f30"/></dir><dir name="Mapping"><file name="Collection.php" hash="c0f15143db582e070cfb83de92c57d09"/></dir></dir></dir><dir name="sql"><dir name="syncer_setup"><file name="mysql4-install-1.1.3.0.php" hash="0535a537eadc0592925bd68c567de176"/><file name="mysql4-upgrade-1.1.3.0-1.1.3.1.php" hash="13b13e0bc00bc59e280367cede7ade84"/></dir></dir></dir></dir></target></contents>
19
<compatible/>
20
<dependencies/>
21
</package>
skin/adminhtml/default/default/wisepricer/chosen.css CHANGED
@@ -1,396 +1,396 @@
1
- /* @group Base */
2
- .chzn-container {
3
- font-size: 13px;
4
- position: relative;
5
- display: inline-block;
6
- zoom: 1;
7
- *display: inline;
8
- }
9
- .chzn-container .chzn-drop {
10
- background: #fff;
11
- border: 1px solid #aaa;
12
- border-top: 0;
13
- position: absolute;
14
- top: 29px;
15
- left: 0;
16
- -webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15);
17
- -moz-box-shadow : 0 4px 5px rgba(0,0,0,.15);
18
- -o-box-shadow : 0 4px 5px rgba(0,0,0,.15);
19
- box-shadow : 0 4px 5px rgba(0,0,0,.15);
20
- z-index: 1010;
21
- }
22
- /* @end */
23
-
24
- /* @group Single Chosen */
25
- .chzn-container-single .chzn-single {
26
- background-color: #ffffff;
27
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0 );
28
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4));
29
- background-image: -webkit-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
30
- background-image: -moz-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
31
- background-image: -o-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
32
- background-image: -ms-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
33
- background-image: linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
34
- -webkit-border-radius: 5px;
35
- -moz-border-radius : 5px;
36
- border-radius : 5px;
37
- -moz-background-clip : padding;
38
- -webkit-background-clip: padding-box;
39
- background-clip : padding-box;
40
- border: 1px solid #aaaaaa;
41
- -webkit-box-shadow: 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
42
- -moz-box-shadow : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
43
- box-shadow : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
44
- display: block;
45
- overflow: hidden;
46
- white-space: nowrap;
47
- position: relative;
48
- height: 23px;
49
- line-height: 24px;
50
- padding: 0 0 0 8px;
51
- color: #444444;
52
- text-decoration: none;
53
- }
54
- .chzn-container-single .chzn-default {
55
- color: #999;
56
- }
57
- .chzn-container-single .chzn-single span {
58
- margin-right: 26px;
59
- display: block;
60
- overflow: hidden;
61
- white-space: nowrap;
62
- -o-text-overflow: ellipsis;
63
- -ms-text-overflow: ellipsis;
64
- text-overflow: ellipsis;
65
- }
66
- .chzn-container-single .chzn-single abbr {
67
- display: block;
68
- position: absolute;
69
- right: 26px;
70
- top: 6px;
71
- width: 12px;
72
- height: 13px;
73
- font-size: 1px;
74
- background: url('chosen-sprite.png') right top no-repeat;
75
- }
76
- .chzn-container-single .chzn-single abbr:hover {
77
- background-position: right -11px;
78
- }
79
- .chzn-container-single.chzn-disabled .chzn-single abbr:hover {
80
- background-position: right top;
81
- }
82
- .chzn-container-single .chzn-single div {
83
- position: absolute;
84
- right: 0;
85
- top: 0;
86
- display: block;
87
- height: 100%;
88
- width: 18px;
89
- }
90
- .chzn-container-single .chzn-single div b {
91
- background: url('chosen-sprite.png') no-repeat 0 0;
92
- display: block;
93
- width: 100%;
94
- height: 100%;
95
- }
96
- .chzn-container-single .chzn-search {
97
- padding: 3px 4px;
98
- position: relative;
99
- margin: 0;
100
- white-space: nowrap;
101
- z-index: 1010;
102
- }
103
- .chzn-container-single .chzn-search input {
104
- background: #fff url('chosen-sprite.png') no-repeat 100% -22px;
105
- background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
106
- background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
107
- background: url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
108
- background: url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
109
- background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
110
- background: url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
111
- margin: 1px 0;
112
- padding: 4px 20px 4px 5px;
113
- outline: 0;
114
- border: 1px solid #aaa;
115
- font-family: sans-serif;
116
- font-size: 1em;
117
- }
118
- .chzn-container-single .chzn-drop {
119
- -webkit-border-radius: 0 0 4px 4px;
120
- -moz-border-radius : 0 0 4px 4px;
121
- border-radius : 0 0 4px 4px;
122
- -moz-background-clip : padding;
123
- -webkit-background-clip: padding-box;
124
- background-clip : padding-box;
125
- }
126
- /* @end */
127
-
128
- .chzn-container-single-nosearch .chzn-search input {
129
- position: absolute;
130
- left: -9000px;
131
- }
132
-
133
- /* @group Multi Chosen */
134
- .chzn-container-multi .chzn-choices {
135
- background-color: #fff;
136
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
137
- background-image: -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
138
- background-image: -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
139
- background-image: -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
140
- background-image: -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
141
- background-image: linear-gradient(top, #eeeeee 1%, #ffffff 15%);
142
- border: 1px solid #aaa;
143
- margin: 0;
144
- padding: 0;
145
- cursor: text;
146
- overflow: hidden;
147
- height: auto !important;
148
- height: 1%;
149
- position: relative;
150
- }
151
- .chzn-container-multi .chzn-choices li {
152
- float: left;
153
- list-style: none;
154
- }
155
- .chzn-container-multi .chzn-choices .search-field {
156
- white-space: nowrap;
157
- margin: 0;
158
- padding: 0;
159
- }
160
- .chzn-container-multi .chzn-choices .search-field input {
161
- color: #666;
162
- background: transparent !important;
163
- border: 0 !important;
164
- font-family: sans-serif;
165
- font-size: 100%;
166
- height: 15px;
167
- padding: 5px;
168
- margin: 1px 0;
169
- outline: 0;
170
- -webkit-box-shadow: none;
171
- -moz-box-shadow : none;
172
- -o-box-shadow : none;
173
- box-shadow : none;
174
- }
175
- .chzn-container-multi .chzn-choices .search-field .default {
176
- color: #999;
177
- }
178
- .chzn-container-multi .chzn-choices .search-choice {
179
- -webkit-border-radius: 3px;
180
- -moz-border-radius : 3px;
181
- border-radius : 3px;
182
- -moz-background-clip : padding;
183
- -webkit-background-clip: padding-box;
184
- background-clip : padding-box;
185
- background-color: #e4e4e4;
186
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee', GradientType=0 );
187
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
188
- background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
189
- background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
190
- background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
191
- background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
192
- background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
193
- -webkit-box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
194
- -moz-box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
195
- box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
196
- color: #333;
197
- border: 1px solid #aaaaaa;
198
- line-height: 13px;
199
- padding: 3px 20px 3px 5px;
200
- margin: 3px 0 3px 5px;
201
- position: relative;
202
- cursor: default;
203
- }
204
- .chzn-container-multi .chzn-choices .search-choice-focus {
205
- background: #d4d4d4;
206
- }
207
- .chzn-container-multi .chzn-choices .search-choice .search-choice-close {
208
- display: block;
209
- position: absolute;
210
- right: 3px;
211
- top: 4px;
212
- width: 12px;
213
- height: 13px;
214
- font-size: 1px;
215
- background: url('chosen-sprite.png') right top no-repeat;
216
- }
217
- .chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover {
218
- background-position: right -11px;
219
- }
220
- .chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close {
221
- background-position: right -11px;
222
- }
223
- /* @end */
224
-
225
- /* @group Results */
226
- .chzn-container .chzn-results {
227
- margin: 0 4px 4px 0;
228
- max-height: 240px;
229
- padding: 0 0 0 4px;
230
- position: relative;
231
- overflow-x: hidden;
232
- overflow-y: auto;
233
- -webkit-overflow-scrolling: touch;
234
- }
235
- .chzn-container-multi .chzn-results {
236
- margin: -1px 0 0;
237
- padding: 0;
238
- }
239
- .chzn-container .chzn-results li {
240
- display: none;
241
- line-height: 15px;
242
- padding: 5px 6px;
243
- margin: 0;
244
- list-style: none;
245
- }
246
- .chzn-container .chzn-results .active-result {
247
- cursor: pointer;
248
- display: list-item;
249
- }
250
- .chzn-container .chzn-results .highlighted {
251
- background-color: #3875d7;
252
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3875d7', endColorstr='#2a62bc', GradientType=0 );
253
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
254
- background-image: -webkit-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
255
- background-image: -moz-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
256
- background-image: -o-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
257
- background-image: -ms-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
258
- background-image: linear-gradient(top, #3875d7 20%, #2a62bc 90%);
259
- color: #fff;
260
- }
261
- .chzn-container .chzn-results li em {
262
- background: #feffde;
263
- font-style: normal;
264
- }
265
- .chzn-container .chzn-results .highlighted em {
266
- background: transparent;
267
- }
268
- .chzn-container .chzn-results .no-results {
269
- background: #f4f4f4;
270
- display: list-item;
271
- }
272
- .chzn-container .chzn-results .group-result {
273
- cursor: default;
274
- color: #999;
275
- font-weight: bold;
276
- }
277
- .chzn-container .chzn-results .group-option {
278
- padding-left: 15px;
279
- }
280
- .chzn-container-multi .chzn-drop .result-selected {
281
- display: none;
282
- }
283
- .chzn-container .chzn-results-scroll {
284
- background: white;
285
- margin: 0 4px;
286
- position: absolute;
287
- text-align: center;
288
- width: 321px; /* This should by dynamic with js */
289
- z-index: 1;
290
- }
291
- .chzn-container .chzn-results-scroll span {
292
- display: inline-block;
293
- height: 17px;
294
- text-indent: -5000px;
295
- width: 9px;
296
- }
297
- .chzn-container .chzn-results-scroll-down {
298
- bottom: 0;
299
- }
300
- .chzn-container .chzn-results-scroll-down span {
301
- background: url('chosen-sprite.png') no-repeat -4px -3px;
302
- }
303
- .chzn-container .chzn-results-scroll-up span {
304
- background: url('chosen-sprite.png') no-repeat -22px -3px;
305
- }
306
- /* @end */
307
-
308
- /* @group Active */
309
- .chzn-container-active .chzn-single {
310
- -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
311
- -moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
312
- -o-box-shadow : 0 0 5px rgba(0,0,0,.3);
313
- box-shadow : 0 0 5px rgba(0,0,0,.3);
314
- border: 1px solid #5897fb;
315
- }
316
- .chzn-container-active .chzn-single-with-drop {
317
- border: 1px solid #aaa;
318
- -webkit-box-shadow: 0 1px 0 #fff inset;
319
- -moz-box-shadow : 0 1px 0 #fff inset;
320
- -o-box-shadow : 0 1px 0 #fff inset;
321
- box-shadow : 0 1px 0 #fff inset;
322
- background-color: #eee;
323
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0 );
324
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
325
- background-image: -webkit-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
326
- background-image: -moz-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
327
- background-image: -o-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
328
- background-image: -ms-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
329
- background-image: linear-gradient(top, #eeeeee 20%, #ffffff 80%);
330
- -webkit-border-bottom-left-radius : 0;
331
- -webkit-border-bottom-right-radius: 0;
332
- -moz-border-radius-bottomleft : 0;
333
- -moz-border-radius-bottomright: 0;
334
- border-bottom-left-radius : 0;
335
- border-bottom-right-radius: 0;
336
- }
337
- .chzn-container-active .chzn-single-with-drop div {
338
- background: transparent;
339
- border-left: none;
340
- }
341
- .chzn-container-active .chzn-single-with-drop div b {
342
- background-position: -18px 1px;
343
- }
344
- .chzn-container-active .chzn-choices {
345
- -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
346
- -moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
347
- -o-box-shadow : 0 0 5px rgba(0,0,0,.3);
348
- box-shadow : 0 0 5px rgba(0,0,0,.3);
349
- border: 1px solid #5897fb;
350
- }
351
- .chzn-container-active .chzn-choices .search-field input {
352
- color: #111 !important;
353
- }
354
- /* @end */
355
-
356
- /* @group Disabled Support */
357
- .chzn-disabled {
358
- cursor: default;
359
- opacity:0.5 !important;
360
- }
361
- .chzn-disabled .chzn-single {
362
- cursor: default;
363
- }
364
- .chzn-disabled .chzn-choices .search-choice .search-choice-close {
365
- cursor: default;
366
- }
367
-
368
- /* @group Right to Left */
369
- .chzn-rtl { text-align: right; }
370
- .chzn-rtl .chzn-single { padding: 0 8px 0 0; overflow: visible; }
371
- .chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; direction: rtl; }
372
-
373
- .chzn-rtl .chzn-single div { left: 3px; right: auto; }
374
- .chzn-rtl .chzn-single abbr {
375
- left: 26px;
376
- right: auto;
377
- }
378
- .chzn-rtl .chzn-choices .search-field input { direction: rtl; }
379
- .chzn-rtl .chzn-choices li { float: right; }
380
- .chzn-rtl .chzn-choices .search-choice { padding: 3px 5px 3px 19px; margin: 3px 5px 3px 0; }
381
- .chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 4px; right: auto; background-position: right top;}
382
- .chzn-rtl.chzn-container-single .chzn-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; }
383
- .chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 15px; }
384
- .chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
385
- .chzn-rtl .chzn-search input {
386
- background: #fff url('chosen-sprite.png') no-repeat -38px -22px;
387
- background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
388
- background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
389
- background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
390
- background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
391
- background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
392
- background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
393
- padding: 4px 5px 4px 20px;
394
- direction: rtl;
395
- }
396
- /* @end */
1
+ /* @group Base */
2
+ .chzn-container {
3
+ font-size: 13px;
4
+ position: relative;
5
+ display: inline-block;
6
+ zoom: 1;
7
+ *display: inline;
8
+ }
9
+ .chzn-container .chzn-drop {
10
+ background: #fff;
11
+ border: 1px solid #aaa;
12
+ border-top: 0;
13
+ position: absolute;
14
+ top: 29px;
15
+ left: 0;
16
+ -webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15);
17
+ -moz-box-shadow : 0 4px 5px rgba(0,0,0,.15);
18
+ -o-box-shadow : 0 4px 5px rgba(0,0,0,.15);
19
+ box-shadow : 0 4px 5px rgba(0,0,0,.15);
20
+ z-index: 1010;
21
+ }
22
+ /* @end */
23
+
24
+ /* @group Single Chosen */
25
+ .chzn-container-single .chzn-single {
26
+ background-color: #ffffff;
27
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0 );
28
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4));
29
+ background-image: -webkit-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
30
+ background-image: -moz-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
31
+ background-image: -o-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
32
+ background-image: -ms-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
33
+ background-image: linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
34
+ -webkit-border-radius: 5px;
35
+ -moz-border-radius : 5px;
36
+ border-radius : 5px;
37
+ -moz-background-clip : padding;
38
+ -webkit-background-clip: padding-box;
39
+ background-clip : padding-box;
40
+ border: 1px solid #aaaaaa;
41
+ -webkit-box-shadow: 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
42
+ -moz-box-shadow : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
43
+ box-shadow : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
44
+ display: block;
45
+ overflow: hidden;
46
+ white-space: nowrap;
47
+ position: relative;
48
+ height: 23px;
49
+ line-height: 24px;
50
+ padding: 0 0 0 8px;
51
+ color: #444444;
52
+ text-decoration: none;
53
+ }
54
+ .chzn-container-single .chzn-default {
55
+ color: #999;
56
+ }
57
+ .chzn-container-single .chzn-single span {
58
+ margin-right: 26px;
59
+ display: block;
60
+ overflow: hidden;
61
+ white-space: nowrap;
62
+ -o-text-overflow: ellipsis;
63
+ -ms-text-overflow: ellipsis;
64
+ text-overflow: ellipsis;
65
+ }
66
+ .chzn-container-single .chzn-single abbr {
67
+ display: block;
68
+ position: absolute;
69
+ right: 26px;
70
+ top: 6px;
71
+ width: 12px;
72
+ height: 13px;
73
+ font-size: 1px;
74
+ background: url('chosen-sprite.png') right top no-repeat;
75
+ }
76
+ .chzn-container-single .chzn-single abbr:hover {
77
+ background-position: right -11px;
78
+ }
79
+ .chzn-container-single.chzn-disabled .chzn-single abbr:hover {
80
+ background-position: right top;
81
+ }
82
+ .chzn-container-single .chzn-single div {
83
+ position: absolute;
84
+ right: 0;
85
+ top: 0;
86
+ display: block;
87
+ height: 100%;
88
+ width: 18px;
89
+ }
90
+ .chzn-container-single .chzn-single div b {
91
+ background: url('chosen-sprite.png') no-repeat 0 0;
92
+ display: block;
93
+ width: 100%;
94
+ height: 100%;
95
+ }
96
+ .chzn-container-single .chzn-search {
97
+ padding: 3px 4px;
98
+ position: relative;
99
+ margin: 0;
100
+ white-space: nowrap;
101
+ z-index: 1010;
102
+ }
103
+ .chzn-container-single .chzn-search input {
104
+ background: #fff url('chosen-sprite.png') no-repeat 100% -22px;
105
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
106
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
107
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
108
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
109
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
110
+ background: url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
111
+ margin: 1px 0;
112
+ padding: 4px 20px 4px 5px;
113
+ outline: 0;
114
+ border: 1px solid #aaa;
115
+ font-family: sans-serif;
116
+ font-size: 1em;
117
+ }
118
+ .chzn-container-single .chzn-drop {
119
+ -webkit-border-radius: 0 0 4px 4px;
120
+ -moz-border-radius : 0 0 4px 4px;
121
+ border-radius : 0 0 4px 4px;
122
+ -moz-background-clip : padding;
123
+ -webkit-background-clip: padding-box;
124
+ background-clip : padding-box;
125
+ }
126
+ /* @end */
127
+
128
+ .chzn-container-single-nosearch .chzn-search input {
129
+ position: absolute;
130
+ left: -9000px;
131
+ }
132
+
133
+ /* @group Multi Chosen */
134
+ .chzn-container-multi .chzn-choices {
135
+ background-color: #fff;
136
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
137
+ background-image: -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
138
+ background-image: -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
139
+ background-image: -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
140
+ background-image: -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
141
+ background-image: linear-gradient(top, #eeeeee 1%, #ffffff 15%);
142
+ border: 1px solid #aaa;
143
+ margin: 0;
144
+ padding: 0;
145
+ cursor: text;
146
+ overflow: hidden;
147
+ height: auto !important;
148
+ height: 1%;
149
+ position: relative;
150
+ }
151
+ .chzn-container-multi .chzn-choices li {
152
+ float: left;
153
+ list-style: none;
154
+ }
155
+ .chzn-container-multi .chzn-choices .search-field {
156
+ white-space: nowrap;
157
+ margin: 0;
158
+ padding: 0;
159
+ }
160
+ .chzn-container-multi .chzn-choices .search-field input {
161
+ color: #666;
162
+ background: transparent !important;
163
+ border: 0 !important;
164
+ font-family: sans-serif;
165
+ font-size: 100%;
166
+ height: 15px;
167
+ padding: 5px;
168
+ margin: 1px 0;
169
+ outline: 0;
170
+ -webkit-box-shadow: none;
171
+ -moz-box-shadow : none;
172
+ -o-box-shadow : none;
173
+ box-shadow : none;
174
+ }
175
+ .chzn-container-multi .chzn-choices .search-field .default {
176
+ color: #999;
177
+ }
178
+ .chzn-container-multi .chzn-choices .search-choice {
179
+ -webkit-border-radius: 3px;
180
+ -moz-border-radius : 3px;
181
+ border-radius : 3px;
182
+ -moz-background-clip : padding;
183
+ -webkit-background-clip: padding-box;
184
+ background-clip : padding-box;
185
+ background-color: #e4e4e4;
186
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee', GradientType=0 );
187
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
188
+ background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
189
+ background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
190
+ background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
191
+ background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
192
+ background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
193
+ -webkit-box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
194
+ -moz-box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
195
+ box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
196
+ color: #333;
197
+ border: 1px solid #aaaaaa;
198
+ line-height: 13px;
199
+ padding: 3px 20px 3px 5px;
200
+ margin: 3px 0 3px 5px;
201
+ position: relative;
202
+ cursor: default;
203
+ }
204
+ .chzn-container-multi .chzn-choices .search-choice-focus {
205
+ background: #d4d4d4;
206
+ }
207
+ .chzn-container-multi .chzn-choices .search-choice .search-choice-close {
208
+ display: block;
209
+ position: absolute;
210
+ right: 3px;
211
+ top: 4px;
212
+ width: 12px;
213
+ height: 13px;
214
+ font-size: 1px;
215
+ background: url('chosen-sprite.png') right top no-repeat;
216
+ }
217
+ .chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover {
218
+ background-position: right -11px;
219
+ }
220
+ .chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close {
221
+ background-position: right -11px;
222
+ }
223
+ /* @end */
224
+
225
+ /* @group Results */
226
+ .chzn-container .chzn-results {
227
+ margin: 0 4px 4px 0;
228
+ max-height: 240px;
229
+ padding: 0 0 0 4px;
230
+ position: relative;
231
+ overflow-x: hidden;
232
+ overflow-y: auto;
233
+ -webkit-overflow-scrolling: touch;
234
+ }
235
+ .chzn-container-multi .chzn-results {
236
+ margin: -1px 0 0;
237
+ padding: 0;
238
+ }
239
+ .chzn-container .chzn-results li {
240
+ display: none;
241
+ line-height: 15px;
242
+ padding: 5px 6px;
243
+ margin: 0;
244
+ list-style: none;
245
+ }
246
+ .chzn-container .chzn-results .active-result {
247
+ cursor: pointer;
248
+ display: list-item;
249
+ }
250
+ .chzn-container .chzn-results .highlighted {
251
+ background-color: #3875d7;
252
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3875d7', endColorstr='#2a62bc', GradientType=0 );
253
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
254
+ background-image: -webkit-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
255
+ background-image: -moz-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
256
+ background-image: -o-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
257
+ background-image: -ms-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
258
+ background-image: linear-gradient(top, #3875d7 20%, #2a62bc 90%);
259
+ color: #fff;
260
+ }
261
+ .chzn-container .chzn-results li em {
262
+ background: #feffde;
263
+ font-style: normal;
264
+ }
265
+ .chzn-container .chzn-results .highlighted em {
266
+ background: transparent;
267
+ }
268
+ .chzn-container .chzn-results .no-results {
269
+ background: #f4f4f4;
270
+ display: list-item;
271
+ }
272
+ .chzn-container .chzn-results .group-result {
273
+ cursor: default;
274
+ color: #999;
275
+ font-weight: bold;
276
+ }
277
+ .chzn-container .chzn-results .group-option {
278
+ padding-left: 15px;
279
+ }
280
+ .chzn-container-multi .chzn-drop .result-selected {
281
+ display: none;
282
+ }
283
+ .chzn-container .chzn-results-scroll {
284
+ background: white;
285
+ margin: 0 4px;
286
+ position: absolute;
287
+ text-align: center;
288
+ width: 321px; /* This should by dynamic with js */
289
+ z-index: 1;
290
+ }
291
+ .chzn-container .chzn-results-scroll span {
292
+ display: inline-block;
293
+ height: 17px;
294
+ text-indent: -5000px;
295
+ width: 9px;
296
+ }
297
+ .chzn-container .chzn-results-scroll-down {
298
+ bottom: 0;
299
+ }
300
+ .chzn-container .chzn-results-scroll-down span {
301
+ background: url('chosen-sprite.png') no-repeat -4px -3px;
302
+ }
303
+ .chzn-container .chzn-results-scroll-up span {
304
+ background: url('chosen-sprite.png') no-repeat -22px -3px;
305
+ }
306
+ /* @end */
307
+
308
+ /* @group Active */
309
+ .chzn-container-active .chzn-single {
310
+ -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
311
+ -moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
312
+ -o-box-shadow : 0 0 5px rgba(0,0,0,.3);
313
+ box-shadow : 0 0 5px rgba(0,0,0,.3);
314
+ border: 1px solid #5897fb;
315
+ }
316
+ .chzn-container-active .chzn-single-with-drop {
317
+ border: 1px solid #aaa;
318
+ -webkit-box-shadow: 0 1px 0 #fff inset;
319
+ -moz-box-shadow : 0 1px 0 #fff inset;
320
+ -o-box-shadow : 0 1px 0 #fff inset;
321
+ box-shadow : 0 1px 0 #fff inset;
322
+ background-color: #eee;
323
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0 );
324
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
325
+ background-image: -webkit-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
326
+ background-image: -moz-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
327
+ background-image: -o-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
328
+ background-image: -ms-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
329
+ background-image: linear-gradient(top, #eeeeee 20%, #ffffff 80%);
330
+ -webkit-border-bottom-left-radius : 0;
331
+ -webkit-border-bottom-right-radius: 0;
332
+ -moz-border-radius-bottomleft : 0;
333
+ -moz-border-radius-bottomright: 0;
334
+ border-bottom-left-radius : 0;
335
+ border-bottom-right-radius: 0;
336
+ }
337
+ .chzn-container-active .chzn-single-with-drop div {
338
+ background: transparent;
339
+ border-left: none;
340
+ }
341
+ .chzn-container-active .chzn-single-with-drop div b {
342
+ background-position: -18px 1px;
343
+ }
344
+ .chzn-container-active .chzn-choices {
345
+ -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
346
+ -moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
347
+ -o-box-shadow : 0 0 5px rgba(0,0,0,.3);
348
+ box-shadow : 0 0 5px rgba(0,0,0,.3);
349
+ border: 1px solid #5897fb;
350
+ }
351
+ .chzn-container-active .chzn-choices .search-field input {
352
+ color: #111 !important;
353
+ }
354
+ /* @end */
355
+
356
+ /* @group Disabled Support */
357
+ .chzn-disabled {
358
+ cursor: default;
359
+ opacity:0.5 !important;
360
+ }
361
+ .chzn-disabled .chzn-single {
362
+ cursor: default;
363
+ }
364
+ .chzn-disabled .chzn-choices .search-choice .search-choice-close {
365
+ cursor: default;
366
+ }
367
+
368
+ /* @group Right to Left */
369
+ .chzn-rtl { text-align: right; }
370
+ .chzn-rtl .chzn-single { padding: 0 8px 0 0; overflow: visible; }
371
+ .chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; direction: rtl; }
372
+
373
+ .chzn-rtl .chzn-single div { left: 3px; right: auto; }
374
+ .chzn-rtl .chzn-single abbr {
375
+ left: 26px;
376
+ right: auto;
377
+ }
378
+ .chzn-rtl .chzn-choices .search-field input { direction: rtl; }
379
+ .chzn-rtl .chzn-choices li { float: right; }
380
+ .chzn-rtl .chzn-choices .search-choice { padding: 3px 5px 3px 19px; margin: 3px 5px 3px 0; }
381
+ .chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 4px; right: auto; background-position: right top;}
382
+ .chzn-rtl.chzn-container-single .chzn-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; }
383
+ .chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 15px; }
384
+ .chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
385
+ .chzn-rtl .chzn-search input {
386
+ background: #fff url('chosen-sprite.png') no-repeat -38px -22px;
387
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
388
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
389
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
390
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
391
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
392
+ background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
393
+ padding: 4px 5px 4px 20px;
394
+ direction: rtl;
395
+ }
396
+ /* @end */
skin/adminhtml/default/default/wisepricer/chosen.proto.js CHANGED
@@ -1,1007 +1,1007 @@
1
- // Chosen, a Select Box Enhancer for jQuery and Protoype
2
- // by Patrick Filler for Harvest, http://getharvest.com
3
- //
4
- // Version 0.9.8
5
- // Full source at https://github.com/harvesthq/chosen
6
- // Copyright (c) 2011 Harvest http://getharvest.com
7
-
8
- // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
9
- // This file is generated by `cake build`, do not edit it by hand.
10
- (function() {
11
- var SelectParser;
12
-
13
- SelectParser = (function() {
14
-
15
- function SelectParser() {
16
- this.options_index = 0;
17
- this.parsed = [];
18
- }
19
-
20
- SelectParser.prototype.add_node = function(child) {
21
- if (child.nodeName === "OPTGROUP") {
22
- return this.add_group(child);
23
- } else {
24
- return this.add_option(child);
25
- }
26
- };
27
-
28
- SelectParser.prototype.add_group = function(group) {
29
- var group_position, option, _i, _len, _ref, _results;
30
- group_position = this.parsed.length;
31
- this.parsed.push({
32
- array_index: group_position,
33
- group: true,
34
- label: group.label,
35
- children: 0,
36
- disabled: group.disabled
37
- });
38
- _ref = group.childNodes;
39
- _results = [];
40
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
41
- option = _ref[_i];
42
- _results.push(this.add_option(option, group_position, group.disabled));
43
- }
44
- return _results;
45
- };
46
-
47
- SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
48
- if (option.nodeName === "OPTION") {
49
- if (option.text !== "") {
50
- if (group_position != null) this.parsed[group_position].children += 1;
51
- this.parsed.push({
52
- array_index: this.parsed.length,
53
- options_index: this.options_index,
54
- value: option.value,
55
- text: option.text,
56
- html: option.innerHTML,
57
- selected: option.selected,
58
- disabled: group_disabled === true ? group_disabled : option.disabled,
59
- group_array_index: group_position,
60
- classes: option.className,
61
- style: option.style.cssText
62
- });
63
- } else {
64
- this.parsed.push({
65
- array_index: this.parsed.length,
66
- options_index: this.options_index,
67
- empty: true
68
- });
69
- }
70
- return this.options_index += 1;
71
- }
72
- };
73
-
74
- return SelectParser;
75
-
76
- })();
77
-
78
- SelectParser.select_to_array = function(select) {
79
- var child, parser, _i, _len, _ref;
80
- parser = new SelectParser();
81
- _ref = select.childNodes;
82
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
83
- child = _ref[_i];
84
- parser.add_node(child);
85
- }
86
- return parser.parsed;
87
- };
88
-
89
- this.SelectParser = SelectParser;
90
-
91
- }).call(this);
92
-
93
- /*
94
- Chosen source: generate output using 'cake build'
95
- Copyright (c) 2011 by Harvest
96
- */
97
-
98
- (function() {
99
- var AbstractChosen, root;
100
-
101
- root = this;
102
-
103
- AbstractChosen = (function() {
104
-
105
- function AbstractChosen(form_field, options) {
106
- this.form_field = form_field;
107
- this.options = options != null ? options : {};
108
- this.set_default_values();
109
- this.is_multiple = this.form_field.multiple;
110
- this.set_default_text();
111
- this.setup();
112
- this.set_up_html();
113
- this.register_observers();
114
- this.finish_setup();
115
- }
116
-
117
- AbstractChosen.prototype.set_default_values = function() {
118
- var _this = this;
119
- this.click_test_action = function(evt) {
120
- return _this.test_active_click(evt);
121
- };
122
- this.activate_action = function(evt) {
123
- return _this.activate_field(evt);
124
- };
125
- this.active_field = false;
126
- this.mouse_on_container = false;
127
- this.results_showing = false;
128
- this.result_highlighted = null;
129
- this.result_single_selected = null;
130
- this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
131
- this.disable_search_threshold = this.options.disable_search_threshold || 0;
132
- this.search_contains = this.options.search_contains || false;
133
- this.choices = 0;
134
- this.single_backstroke_delete = this.options.single_backstroke_delete || false;
135
- return this.max_selected_options = this.options.max_selected_options || Infinity;
136
- };
137
-
138
- AbstractChosen.prototype.set_default_text = function() {
139
- if (this.form_field.getAttribute("data-placeholder")) {
140
- this.default_text = this.form_field.getAttribute("data-placeholder");
141
- } else if (this.is_multiple) {
142
- this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || "Select Some Options";
143
- } else {
144
- this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || "Select an Option";
145
- }
146
- return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || "No results match";
147
- };
148
-
149
- AbstractChosen.prototype.mouse_enter = function() {
150
- return this.mouse_on_container = true;
151
- };
152
-
153
- AbstractChosen.prototype.mouse_leave = function() {
154
- return this.mouse_on_container = false;
155
- };
156
-
157
- AbstractChosen.prototype.input_focus = function(evt) {
158
- var _this = this;
159
- if (!this.active_field) {
160
- return setTimeout((function() {
161
- return _this.container_mousedown();
162
- }), 50);
163
- }
164
- };
165
-
166
- AbstractChosen.prototype.input_blur = function(evt) {
167
- var _this = this;
168
- if (!this.mouse_on_container) {
169
- this.active_field = false;
170
- return setTimeout((function() {
171
- return _this.blur_test();
172
- }), 100);
173
- }
174
- };
175
-
176
- AbstractChosen.prototype.result_add_option = function(option) {
177
- var classes, style;
178
- if (!option.disabled) {
179
- option.dom_id = this.container_id + "_o_" + option.array_index;
180
- classes = option.selected && this.is_multiple ? [] : ["active-result"];
181
- if (option.selected) classes.push("result-selected");
182
- if (option.group_array_index != null) classes.push("group-option");
183
- if (option.classes !== "") classes.push(option.classes);
184
- style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
185
- return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
186
- } else {
187
- return "";
188
- }
189
- };
190
-
191
- AbstractChosen.prototype.results_update_field = function() {
192
- if (!this.is_multiple) this.results_reset_cleanup();
193
- this.result_clear_highlight();
194
- this.result_single_selected = null;
195
- return this.results_build();
196
- };
197
-
198
- AbstractChosen.prototype.results_toggle = function() {
199
- if (this.results_showing) {
200
- return this.results_hide();
201
- } else {
202
- return this.results_show();
203
- }
204
- };
205
-
206
- AbstractChosen.prototype.results_search = function(evt) {
207
- if (this.results_showing) {
208
- return this.winnow_results();
209
- } else {
210
- return this.results_show();
211
- }
212
- };
213
-
214
- AbstractChosen.prototype.keyup_checker = function(evt) {
215
- var stroke, _ref;
216
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
217
- this.search_field_scale();
218
- switch (stroke) {
219
- case 8:
220
- if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
221
- return this.keydown_backstroke();
222
- } else if (!this.pending_backstroke) {
223
- this.result_clear_highlight();
224
- return this.results_search();
225
- }
226
- break;
227
- case 13:
228
- evt.preventDefault();
229
- if (this.results_showing) return this.result_select(evt);
230
- break;
231
- case 27:
232
- if (this.results_showing) this.results_hide();
233
- return true;
234
- case 9:
235
- case 38:
236
- case 40:
237
- case 16:
238
- case 91:
239
- case 17:
240
- break;
241
- default:
242
- return this.results_search();
243
- }
244
- };
245
-
246
- AbstractChosen.prototype.generate_field_id = function() {
247
- var new_id;
248
- new_id = this.generate_random_id();
249
- this.form_field.id = new_id;
250
- return new_id;
251
- };
252
-
253
- AbstractChosen.prototype.generate_random_char = function() {
254
- var chars, newchar, rand;
255
- chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
256
- rand = Math.floor(Math.random() * chars.length);
257
- return newchar = chars.substring(rand, rand + 1);
258
- };
259
-
260
- return AbstractChosen;
261
-
262
- })();
263
-
264
- root.AbstractChosen = AbstractChosen;
265
-
266
- }).call(this);
267
-
268
- /*
269
- Chosen source: generate output using 'cake build'
270
- Copyright (c) 2011 by Harvest
271
- */
272
-
273
- (function() {
274
- var Chosen, get_side_border_padding, root,
275
- __hasProp = Object.prototype.hasOwnProperty,
276
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
277
-
278
- root = this;
279
-
280
- Chosen = (function(_super) {
281
-
282
- __extends(Chosen, _super);
283
-
284
- function Chosen() {
285
- Chosen.__super__.constructor.apply(this, arguments);
286
- }
287
-
288
- Chosen.prototype.setup = function() {
289
- this.current_value = this.form_field.value;
290
- return this.is_rtl = this.form_field.hasClassName("chzn-rtl");
291
- };
292
-
293
- Chosen.prototype.finish_setup = function() {
294
- return this.form_field.addClassName("chzn-done");
295
- };
296
-
297
- Chosen.prototype.set_default_values = function() {
298
- Chosen.__super__.set_default_values.call(this);
299
- this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
300
- this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
301
- this.choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>');
302
- return this.no_results_temp = new Template('<li class="no-results">' + this.results_none_found + ' "<span>#{terms}</span>"</li>');
303
- };
304
-
305
- Chosen.prototype.set_up_html = function() {
306
- var base_template, container_props, dd_top, dd_width, sf_width;
307
- this.container_id = this.form_field.identify().replace(/[^\w]/g, '_') + "_chzn";
308
- this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth();
309
- container_props = {
310
- 'id': this.container_id,
311
- 'class': "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
312
- 'style': 'width: ' + this.f_width + 'px'
313
- };
314
- base_template = this.is_multiple ? new Element('div', container_props).update(this.multi_temp.evaluate({
315
- "default": this.default_text
316
- })) : new Element('div', container_props).update(this.single_temp.evaluate({
317
- "default": this.default_text
318
- }));
319
- this.form_field.hide().insert({
320
- after: base_template
321
- });
322
- this.container = $(this.container_id);
323
- this.container.addClassName("chzn-container-" + (this.is_multiple ? "multi" : "single"));
324
- this.dropdown = this.container.down('div.chzn-drop');
325
- dd_top = this.container.getHeight();
326
- dd_width = this.f_width - get_side_border_padding(this.dropdown);
327
- this.dropdown.setStyle({
328
- "width": dd_width + "px",
329
- "top": dd_top + "px"
330
- });
331
- this.search_field = this.container.down('input');
332
- this.search_results = this.container.down('ul.chzn-results');
333
- this.search_field_scale();
334
- this.search_no_results = this.container.down('li.no-results');
335
- if (this.is_multiple) {
336
- this.search_choices = this.container.down('ul.chzn-choices');
337
- this.search_container = this.container.down('li.search-field');
338
- } else {
339
- this.search_container = this.container.down('div.chzn-search');
340
- this.selected_item = this.container.down('.chzn-single');
341
- sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
342
- this.search_field.setStyle({
343
- "width": sf_width + "px"
344
- });
345
- }
346
- this.results_build();
347
- this.set_tab_index();
348
- return this.form_field.fire("liszt:ready", {
349
- chosen: this
350
- });
351
- };
352
-
353
- Chosen.prototype.register_observers = function() {
354
- var _this = this;
355
- this.container.observe("mousedown", function(evt) {
356
- return _this.container_mousedown(evt);
357
- });
358
- this.container.observe("mouseup", function(evt) {
359
- return _this.container_mouseup(evt);
360
- });
361
- this.container.observe("mouseenter", function(evt) {
362
- return _this.mouse_enter(evt);
363
- });
364
- this.container.observe("mouseleave", function(evt) {
365
- return _this.mouse_leave(evt);
366
- });
367
- this.search_results.observe("mouseup", function(evt) {
368
- return _this.search_results_mouseup(evt);
369
- });
370
- this.search_results.observe("mouseover", function(evt) {
371
- return _this.search_results_mouseover(evt);
372
- });
373
- this.search_results.observe("mouseout", function(evt) {
374
- return _this.search_results_mouseout(evt);
375
- });
376
- this.form_field.observe("liszt:updated", function(evt) {
377
- return _this.results_update_field(evt);
378
- });
379
- this.search_field.observe("blur", function(evt) {
380
- return _this.input_blur(evt);
381
- });
382
- this.search_field.observe("keyup", function(evt) {
383
- return _this.keyup_checker(evt);
384
- });
385
- this.search_field.observe("keydown", function(evt) {
386
- return _this.keydown_checker(evt);
387
- });
388
- if (this.is_multiple) {
389
- this.search_choices.observe("click", function(evt) {
390
- return _this.choices_click(evt);
391
- });
392
- return this.search_field.observe("focus", function(evt) {
393
- return _this.input_focus(evt);
394
- });
395
- } else {
396
- return this.container.observe("click", function(evt) {
397
- return evt.preventDefault();
398
- });
399
- }
400
- };
401
-
402
- Chosen.prototype.search_field_disabled = function() {
403
- this.is_disabled = this.form_field.disabled;
404
- if (this.is_disabled) {
405
- this.container.addClassName('chzn-disabled');
406
- this.search_field.disabled = true;
407
- if (!this.is_multiple) {
408
- this.selected_item.stopObserving("focus", this.activate_action);
409
- }
410
- return this.close_field();
411
- } else {
412
- this.container.removeClassName('chzn-disabled');
413
- this.search_field.disabled = false;
414
- if (!this.is_multiple) {
415
- return this.selected_item.observe("focus", this.activate_action);
416
- }
417
- }
418
- };
419
-
420
- Chosen.prototype.container_mousedown = function(evt) {
421
- var target_closelink;
422
- if (!this.is_disabled) {
423
- target_closelink = evt != null ? evt.target.hasClassName("search-choice-close") : false;
424
- if (evt && evt.type === "mousedown" && !this.results_showing) evt.stop();
425
- if (!this.pending_destroy_click && !target_closelink) {
426
- if (!this.active_field) {
427
- if (this.is_multiple) this.search_field.clear();
428
- document.observe("click", this.click_test_action);
429
- this.results_show();
430
- } else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chzn-single"))) {
431
- this.results_toggle();
432
- }
433
- return this.activate_field();
434
- } else {
435
- return this.pending_destroy_click = false;
436
- }
437
- }
438
- };
439
-
440
- Chosen.prototype.container_mouseup = function(evt) {
441
- if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
442
- return this.results_reset(evt);
443
- }
444
- };
445
-
446
- Chosen.prototype.blur_test = function(evt) {
447
- if (!this.active_field && this.container.hasClassName("chzn-container-active")) {
448
- return this.close_field();
449
- }
450
- };
451
-
452
- Chosen.prototype.close_field = function() {
453
- document.stopObserving("click", this.click_test_action);
454
- if (!this.is_multiple) {
455
- this.selected_item.tabIndex = this.search_field.tabIndex;
456
- this.search_field.tabIndex = -1;
457
- }
458
- this.active_field = false;
459
- this.results_hide();
460
- this.container.removeClassName("chzn-container-active");
461
- this.winnow_results_clear();
462
- this.clear_backstroke();
463
- this.show_search_field_default();
464
- return this.search_field_scale();
465
- };
466
-
467
- Chosen.prototype.activate_field = function() {
468
- if (!this.is_multiple && !this.active_field) {
469
- this.search_field.tabIndex = this.selected_item.tabIndex;
470
- this.selected_item.tabIndex = -1;
471
- }
472
- this.container.addClassName("chzn-container-active");
473
- this.active_field = true;
474
- this.search_field.value = this.search_field.value;
475
- return this.search_field.focus();
476
- };
477
-
478
- Chosen.prototype.test_active_click = function(evt) {
479
- if (evt.target.up('#' + this.container_id)) {
480
- return this.active_field = true;
481
- } else {
482
- return this.close_field();
483
- }
484
- };
485
-
486
- Chosen.prototype.results_build = function() {
487
- var content, data, _i, _len, _ref;
488
- this.parsing = true;
489
- this.results_data = root.SelectParser.select_to_array(this.form_field);
490
- if (this.is_multiple && this.choices > 0) {
491
- this.search_choices.select("li.search-choice").invoke("remove");
492
- this.choices = 0;
493
- } else if (!this.is_multiple) {
494
- this.selected_item.addClassName("chzn-default").down("span").update(this.default_text);
495
- if (this.form_field.options.length <= this.disable_search_threshold) {
496
- this.container.addClassName("chzn-container-single-nosearch");
497
- } else {
498
- this.container.removeClassName("chzn-container-single-nosearch");
499
- }
500
- }
501
- content = '';
502
- _ref = this.results_data;
503
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
504
- data = _ref[_i];
505
- if (data.group) {
506
- content += this.result_add_group(data);
507
- } else if (!data.empty) {
508
- content += this.result_add_option(data);
509
- if (data.selected && this.is_multiple) {
510
- this.choice_build(data);
511
- } else if (data.selected && !this.is_multiple) {
512
- this.selected_item.removeClassName("chzn-default").down("span").update(data.html);
513
- if (this.allow_single_deselect) this.single_deselect_control_build();
514
- }
515
- }
516
- }
517
- this.search_field_disabled();
518
- this.show_search_field_default();
519
- this.search_field_scale();
520
- this.search_results.update(content);
521
- return this.parsing = false;
522
- };
523
-
524
- Chosen.prototype.result_add_group = function(group) {
525
- if (!group.disabled) {
526
- group.dom_id = this.container_id + "_g_" + group.array_index;
527
- return '<li id="' + group.dom_id + '" class="group-result">' + group.label.escapeHTML() + '</li>';
528
- } else {
529
- return "";
530
- }
531
- };
532
-
533
- Chosen.prototype.result_do_highlight = function(el) {
534
- var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
535
- this.result_clear_highlight();
536
- this.result_highlight = el;
537
- this.result_highlight.addClassName("highlighted");
538
- maxHeight = parseInt(this.search_results.getStyle('maxHeight'), 10);
539
- visible_top = this.search_results.scrollTop;
540
- visible_bottom = maxHeight + visible_top;
541
- high_top = this.result_highlight.positionedOffset().top;
542
- high_bottom = high_top + this.result_highlight.getHeight();
543
- if (high_bottom >= visible_bottom) {
544
- return this.search_results.scrollTop = (high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0;
545
- } else if (high_top < visible_top) {
546
- return this.search_results.scrollTop = high_top;
547
- }
548
- };
549
-
550
- Chosen.prototype.result_clear_highlight = function() {
551
- if (this.result_highlight) {
552
- this.result_highlight.removeClassName('highlighted');
553
- }
554
- return this.result_highlight = null;
555
- };
556
-
557
- Chosen.prototype.results_show = function() {
558
- var dd_top;
559
- if (!this.is_multiple) {
560
- this.selected_item.addClassName('chzn-single-with-drop');
561
- if (this.result_single_selected) {
562
- this.result_do_highlight(this.result_single_selected);
563
- }
564
- } else if (this.max_selected_options <= this.choices) {
565
- this.form_field.fire("liszt:maxselected", {
566
- chosen: this
567
- });
568
- return false;
569
- }
570
- dd_top = this.is_multiple ? this.container.getHeight() : this.container.getHeight() - 1;
571
- this.form_field.fire("liszt:showing_dropdown", {
572
- chosen: this
573
- });
574
- this.dropdown.setStyle({
575
- "top": dd_top + "px",
576
- "left": 0
577
- });
578
- this.results_showing = true;
579
- this.search_field.focus();
580
- this.search_field.value = this.search_field.value;
581
- return this.winnow_results();
582
- };
583
-
584
- Chosen.prototype.results_hide = function() {
585
- if (!this.is_multiple) {
586
- this.selected_item.removeClassName('chzn-single-with-drop');
587
- }
588
- this.result_clear_highlight();
589
- this.form_field.fire("liszt:hiding_dropdown", {
590
- chosen: this
591
- });
592
- this.dropdown.setStyle({
593
- "left": "-9000px"
594
- });
595
- return this.results_showing = false;
596
- };
597
-
598
- Chosen.prototype.set_tab_index = function(el) {
599
- var ti;
600
- if (this.form_field.tabIndex) {
601
- ti = this.form_field.tabIndex;
602
- this.form_field.tabIndex = -1;
603
- if (this.is_multiple) {
604
- return this.search_field.tabIndex = ti;
605
- } else {
606
- this.selected_item.tabIndex = ti;
607
- return this.search_field.tabIndex = -1;
608
- }
609
- }
610
- };
611
-
612
- Chosen.prototype.show_search_field_default = function() {
613
- if (this.is_multiple && this.choices < 1 && !this.active_field) {
614
- this.search_field.value = this.default_text;
615
- return this.search_field.addClassName("default");
616
- } else {
617
- this.search_field.value = "";
618
- return this.search_field.removeClassName("default");
619
- }
620
- };
621
-
622
- Chosen.prototype.search_results_mouseup = function(evt) {
623
- var target;
624
- target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
625
- if (target) {
626
- this.result_highlight = target;
627
- return this.result_select(evt);
628
- }
629
- };
630
-
631
- Chosen.prototype.search_results_mouseover = function(evt) {
632
- var target;
633
- target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
634
- if (target) return this.result_do_highlight(target);
635
- };
636
-
637
- Chosen.prototype.search_results_mouseout = function(evt) {
638
- if (evt.target.hasClassName('active-result') || evt.target.up('.active-result')) {
639
- return this.result_clear_highlight();
640
- }
641
- };
642
-
643
- Chosen.prototype.choices_click = function(evt) {
644
- evt.preventDefault();
645
- if (this.active_field && !(evt.target.hasClassName('search-choice') || evt.target.up('.search-choice')) && !this.results_showing) {
646
- return this.results_show();
647
- }
648
- };
649
-
650
- Chosen.prototype.choice_build = function(item) {
651
- var choice_id, link,
652
- _this = this;
653
- if (this.is_multiple && this.max_selected_options <= this.choices) {
654
- this.form_field.fire("liszt:maxselected", {
655
- chosen: this
656
- });
657
- return false;
658
- }
659
- choice_id = this.container_id + "_c_" + item.array_index;
660
- this.choices += 1;
661
- this.search_container.insert({
662
- before: this.choice_temp.evaluate({
663
- id: choice_id,
664
- choice: item.html,
665
- position: item.array_index
666
- })
667
- });
668
- link = $(choice_id).down('a');
669
- return link.observe("click", function(evt) {
670
- return _this.choice_destroy_link_click(evt);
671
- });
672
- };
673
-
674
- Chosen.prototype.choice_destroy_link_click = function(evt) {
675
- evt.preventDefault();
676
- if (!this.is_disabled) {
677
- this.pending_destroy_click = true;
678
- return this.choice_destroy(evt.target);
679
- }
680
- };
681
-
682
- Chosen.prototype.choice_destroy = function(link) {
683
- this.choices -= 1;
684
- this.show_search_field_default();
685
- if (this.is_multiple && this.choices > 0 && this.search_field.value.length < 1) {
686
- this.results_hide();
687
- }
688
- this.result_deselect(link.readAttribute("rel"));
689
- return link.up('li').remove();
690
- };
691
-
692
- Chosen.prototype.results_reset = function() {
693
- this.form_field.options[0].selected = true;
694
- this.selected_item.down("span").update(this.default_text);
695
- if (!this.is_multiple) this.selected_item.addClassName("chzn-default");
696
- this.show_search_field_default();
697
- this.results_reset_cleanup();
698
- if (typeof Event.simulate === 'function') this.form_field.simulate("change");
699
- if (this.active_field) return this.results_hide();
700
- };
701
-
702
- Chosen.prototype.results_reset_cleanup = function() {
703
- var deselect_trigger;
704
- deselect_trigger = this.selected_item.down("abbr");
705
- if (deselect_trigger) return deselect_trigger.remove();
706
- };
707
-
708
- Chosen.prototype.result_select = function(evt) {
709
- var high, item, position;
710
- if (this.result_highlight) {
711
- high = this.result_highlight;
712
- this.result_clear_highlight();
713
- if (this.is_multiple) {
714
- this.result_deactivate(high);
715
- } else {
716
- this.search_results.descendants(".result-selected").invoke("removeClassName", "result-selected");
717
- this.selected_item.removeClassName("chzn-default");
718
- this.result_single_selected = high;
719
- }
720
- high.addClassName("result-selected");
721
- position = high.id.substr(high.id.lastIndexOf("_") + 1);
722
- item = this.results_data[position];
723
- item.selected = true;
724
- this.form_field.options[item.options_index].selected = true;
725
- if (this.is_multiple) {
726
- this.choice_build(item);
727
- } else {
728
- this.selected_item.down("span").update(item.html);
729
- if (this.allow_single_deselect) this.single_deselect_control_build();
730
- }
731
- if (!(evt.metaKey && this.is_multiple)) this.results_hide();
732
- this.search_field.value = "";
733
- if (typeof Event.simulate === 'function' && (this.is_multiple || this.form_field.value !== this.current_value)) {
734
- this.form_field.simulate("change");
735
- }
736
- this.current_value = this.form_field.value;
737
- return this.search_field_scale();
738
- }
739
- };
740
-
741
- Chosen.prototype.result_activate = function(el) {
742
- return el.addClassName("active-result");
743
- };
744
-
745
- Chosen.prototype.result_deactivate = function(el) {
746
- return el.removeClassName("active-result");
747
- };
748
-
749
- Chosen.prototype.result_deselect = function(pos) {
750
- var result, result_data;
751
- result_data = this.results_data[pos];
752
- result_data.selected = false;
753
- this.form_field.options[result_data.options_index].selected = false;
754
- result = $(this.container_id + "_o_" + pos);
755
- result.removeClassName("result-selected").addClassName("active-result").show();
756
- this.result_clear_highlight();
757
- this.winnow_results();
758
- if (typeof Event.simulate === 'function') this.form_field.simulate("change");
759
- return this.search_field_scale();
760
- };
761
-
762
- Chosen.prototype.single_deselect_control_build = function() {
763
- if (this.allow_single_deselect && !this.selected_item.down("abbr")) {
764
- return this.selected_item.down("span").insert({
765
- after: "<abbr class=\"search-choice-close\"></abbr>"
766
- });
767
- }
768
- };
769
-
770
- Chosen.prototype.winnow_results = function() {
771
- var found, option, part, parts, regex, regexAnchor, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
772
- this.no_results_clear();
773
- results = 0;
774
- searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip().escapeHTML();
775
- regexAnchor = this.search_contains ? "" : "^";
776
- regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\amp;"), 'i');
777
- zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\amp;"), 'i');
778
- _ref = this.results_data;
779
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
780
- option = _ref[_i];
781
- if (!option.disabled && !option.empty) {
782
- if (option.group) {
783
- $(option.dom_id).hide();
784
- } else if (!(this.is_multiple && option.selected)) {
785
- found = false;
786
- result_id = option.dom_id;
787
- if (regex.test(option.html)) {
788
- found = true;
789
- results += 1;
790
- } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
791
- parts = option.html.replace(/\[|\]/g, "").split(" ");
792
- if (parts.length) {
793
- for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
794
- part = parts[_j];
795
- if (regex.test(part)) {
796
- found = true;
797
- results += 1;
798
- }
799
- }
800
- }
801
- }
802
- if (found) {
803
- if (searchText.length) {
804
- startpos = option.html.search(zregex);
805
- text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
806
- text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
807
- } else {
808
- text = option.html;
809
- }
810
- if ($(result_id).innerHTML !== text) $(result_id).update(text);
811
- this.result_activate($(result_id));
812
- if (option.group_array_index != null) {
813
- $(this.results_data[option.group_array_index].dom_id).setStyle({
814
- display: 'list-item'
815
- });
816
- }
817
- } else {
818
- if ($(result_id) === this.result_highlight) {
819
- this.result_clear_highlight();
820
- }
821
- this.result_deactivate($(result_id));
822
- }
823
- }
824
- }
825
- }
826
- if (results < 1 && searchText.length) {
827
- return this.no_results(searchText);
828
- } else {
829
- return this.winnow_results_set_highlight();
830
- }
831
- };
832
-
833
- Chosen.prototype.winnow_results_clear = function() {
834
- var li, lis, _i, _len, _results;
835
- this.search_field.clear();
836
- lis = this.search_results.select("li");
837
- _results = [];
838
- for (_i = 0, _len = lis.length; _i < _len; _i++) {
839
- li = lis[_i];
840
- if (li.hasClassName("group-result")) {
841
- _results.push(li.show());
842
- } else if (!this.is_multiple || !li.hasClassName("result-selected")) {
843
- _results.push(this.result_activate(li));
844
- } else {
845
- _results.push(void 0);
846
- }
847
- }
848
- return _results;
849
- };
850
-
851
- Chosen.prototype.winnow_results_set_highlight = function() {
852
- var do_high;
853
- if (!this.result_highlight) {
854
- if (!this.is_multiple) {
855
- do_high = this.search_results.down(".result-selected.active-result");
856
- }
857
- if (!(do_high != null)) {
858
- do_high = this.search_results.down(".active-result");
859
- }
860
- if (do_high != null) return this.result_do_highlight(do_high);
861
- }
862
- };
863
-
864
- Chosen.prototype.no_results = function(terms) {
865
- return this.search_results.insert(this.no_results_temp.evaluate({
866
- terms: terms
867
- }));
868
- };
869
-
870
- Chosen.prototype.no_results_clear = function() {
871
- var nr, _results;
872
- nr = null;
873
- _results = [];
874
- while (nr = this.search_results.down(".no-results")) {
875
- _results.push(nr.remove());
876
- }
877
- return _results;
878
- };
879
-
880
- Chosen.prototype.keydown_arrow = function() {
881
- var actives, nexts, sibs;
882
- actives = this.search_results.select("li.active-result");
883
- if (actives.length) {
884
- if (!this.result_highlight) {
885
- this.result_do_highlight(actives.first());
886
- } else if (this.results_showing) {
887
- sibs = this.result_highlight.nextSiblings();
888
- nexts = sibs.intersect(actives);
889
- if (nexts.length) this.result_do_highlight(nexts.first());
890
- }
891
- if (!this.results_showing) return this.results_show();
892
- }
893
- };
894
-
895
- Chosen.prototype.keyup_arrow = function() {
896
- var actives, prevs, sibs;
897
- if (!this.results_showing && !this.is_multiple) {
898
- return this.results_show();
899
- } else if (this.result_highlight) {
900
- sibs = this.result_highlight.previousSiblings();
901
- actives = this.search_results.select("li.active-result");
902
- prevs = sibs.intersect(actives);
903
- if (prevs.length) {
904
- return this.result_do_highlight(prevs.first());
905
- } else {
906
- if (this.choices > 0) this.results_hide();
907
- return this.result_clear_highlight();
908
- }
909
- }
910
- };
911
-
912
- Chosen.prototype.keydown_backstroke = function() {
913
- if (this.pending_backstroke) {
914
- this.choice_destroy(this.pending_backstroke.down("a"));
915
- return this.clear_backstroke();
916
- } else {
917
- this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
918
- if (this.single_backstroke_delete) {
919
- return this.keydown_backstroke();
920
- } else {
921
- return this.pending_backstroke.addClassName("search-choice-focus");
922
- }
923
- }
924
- };
925
-
926
- Chosen.prototype.clear_backstroke = function() {
927
- if (this.pending_backstroke) {
928
- this.pending_backstroke.removeClassName("search-choice-focus");
929
- }
930
- return this.pending_backstroke = null;
931
- };
932
-
933
- Chosen.prototype.keydown_checker = function(evt) {
934
- var stroke, _ref;
935
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
936
- this.search_field_scale();
937
- if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
938
- switch (stroke) {
939
- case 8:
940
- this.backstroke_length = this.search_field.value.length;
941
- break;
942
- case 9:
943
- if (this.results_showing && !this.is_multiple) this.result_select(evt);
944
- this.mouse_on_container = false;
945
- break;
946
- case 13:
947
- evt.preventDefault();
948
- break;
949
- case 38:
950
- evt.preventDefault();
951
- this.keyup_arrow();
952
- break;
953
- case 40:
954
- this.keydown_arrow();
955
- break;
956
- }
957
- };
958
-
959
- Chosen.prototype.search_field_scale = function() {
960
- var dd_top, div, h, style, style_block, styles, w, _i, _len;
961
- if (this.is_multiple) {
962
- h = 0;
963
- w = 0;
964
- style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
965
- styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
966
- for (_i = 0, _len = styles.length; _i < _len; _i++) {
967
- style = styles[_i];
968
- style_block += style + ":" + this.search_field.getStyle(style) + ";";
969
- }
970
- div = new Element('div', {
971
- 'style': style_block
972
- }).update(this.search_field.value.escapeHTML());
973
- document.body.appendChild(div);
974
- w = Element.measure(div, 'width') + 25;
975
- div.remove();
976
- if (w > this.f_width - 10) w = this.f_width - 10;
977
- this.search_field.setStyle({
978
- 'width': w + 'px'
979
- });
980
- dd_top = this.container.getHeight();
981
- return this.dropdown.setStyle({
982
- "top": dd_top + "px"
983
- });
984
- }
985
- };
986
-
987
- return Chosen;
988
-
989
- })(AbstractChosen);
990
-
991
- root.Chosen = Chosen;
992
-
993
- if (Prototype.Browser.IE) {
994
- if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
995
- Prototype.BrowserFeatures['Version'] = new Number(RegExp.$1);
996
- }
997
- }
998
-
999
- get_side_border_padding = function(elmt) {
1000
- var layout, side_border_padding;
1001
- layout = new Element.Layout(elmt);
1002
- return side_border_padding = layout.get("border-left") + layout.get("border-right") + layout.get("padding-left") + layout.get("padding-right");
1003
- };
1004
-
1005
- root.get_side_border_padding = get_side_border_padding;
1006
-
1007
- }).call(this);
1
+ // Chosen, a Select Box Enhancer for jQuery and Protoype
2
+ // by Patrick Filler for Harvest, http://getharvest.com
3
+ //
4
+ // Version 0.9.8
5
+ // Full source at https://github.com/harvesthq/chosen
6
+ // Copyright (c) 2011 Harvest http://getharvest.com
7
+
8
+ // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
9
+ // This file is generated by `cake build`, do not edit it by hand.
10
+ (function() {
11
+ var SelectParser;
12
+
13
+ SelectParser = (function() {
14
+
15
+ function SelectParser() {
16
+ this.options_index = 0;
17
+ this.parsed = [];
18
+ }
19
+
20
+ SelectParser.prototype.add_node = function(child) {
21
+ if (child.nodeName === "OPTGROUP") {
22
+ return this.add_group(child);
23
+ } else {
24
+ return this.add_option(child);
25
+ }
26
+ };
27
+
28
+ SelectParser.prototype.add_group = function(group) {
29
+ var group_position, option, _i, _len, _ref, _results;
30
+ group_position = this.parsed.length;
31
+ this.parsed.push({
32
+ array_index: group_position,
33
+ group: true,
34
+ label: group.label,
35
+ children: 0,
36
+ disabled: group.disabled
37
+ });
38
+ _ref = group.childNodes;
39
+ _results = [];
40
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
41
+ option = _ref[_i];
42
+ _results.push(this.add_option(option, group_position, group.disabled));
43
+ }
44
+ return _results;
45
+ };
46
+
47
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
48
+ if (option.nodeName === "OPTION") {
49
+ if (option.text !== "") {
50
+ if (group_position != null) this.parsed[group_position].children += 1;
51
+ this.parsed.push({
52
+ array_index: this.parsed.length,
53
+ options_index: this.options_index,
54
+ value: option.value,
55
+ text: option.text,
56
+ html: option.innerHTML,
57
+ selected: option.selected,
58
+ disabled: group_disabled === true ? group_disabled : option.disabled,
59
+ group_array_index: group_position,
60
+ classes: option.className,
61
+ style: option.style.cssText
62
+ });
63
+ } else {
64
+ this.parsed.push({
65
+ array_index: this.parsed.length,
66
+ options_index: this.options_index,
67
+ empty: true
68
+ });
69
+ }
70
+ return this.options_index += 1;
71
+ }
72
+ };
73
+
74
+ return SelectParser;
75
+
76
+ })();
77
+
78
+ SelectParser.select_to_array = function(select) {
79
+ var child, parser, _i, _len, _ref;
80
+ parser = new SelectParser();
81
+ _ref = select.childNodes;
82
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
83
+ child = _ref[_i];
84
+ parser.add_node(child);
85
+ }
86
+ return parser.parsed;
87
+ };
88
+
89
+ this.SelectParser = SelectParser;
90
+
91
+ }).call(this);
92
+
93
+ /*
94
+ Chosen source: generate output using 'cake build'
95
+ Copyright (c) 2011 by Harvest
96
+ */
97
+
98
+ (function() {
99
+ var AbstractChosen, root;
100
+
101
+ root = this;
102
+
103
+ AbstractChosen = (function() {
104
+
105
+ function AbstractChosen(form_field, options) {
106
+ this.form_field = form_field;
107
+ this.options = options != null ? options : {};
108
+ this.set_default_values();
109
+ this.is_multiple = this.form_field.multiple;
110
+ this.set_default_text();
111
+ this.setup();
112
+ this.set_up_html();
113
+ this.register_observers();
114
+ this.finish_setup();
115
+ }
116
+
117
+ AbstractChosen.prototype.set_default_values = function() {
118
+ var _this = this;
119
+ this.click_test_action = function(evt) {
120
+ return _this.test_active_click(evt);
121
+ };
122
+ this.activate_action = function(evt) {
123
+ return _this.activate_field(evt);
124
+ };
125
+ this.active_field = false;
126
+ this.mouse_on_container = false;
127
+ this.results_showing = false;
128
+ this.result_highlighted = null;
129
+ this.result_single_selected = null;
130
+ this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
131
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
132
+ this.search_contains = this.options.search_contains || false;
133
+ this.choices = 0;
134
+ this.single_backstroke_delete = this.options.single_backstroke_delete || false;
135
+ return this.max_selected_options = this.options.max_selected_options || Infinity;
136
+ };
137
+
138
+ AbstractChosen.prototype.set_default_text = function() {
139
+ if (this.form_field.getAttribute("data-placeholder")) {
140
+ this.default_text = this.form_field.getAttribute("data-placeholder");
141
+ } else if (this.is_multiple) {
142
+ this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || "Select Some Options";
143
+ } else {
144
+ this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || "Select an Option";
145
+ }
146
+ return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || "No results match";
147
+ };
148
+
149
+ AbstractChosen.prototype.mouse_enter = function() {
150
+ return this.mouse_on_container = true;
151
+ };
152
+
153
+ AbstractChosen.prototype.mouse_leave = function() {
154
+ return this.mouse_on_container = false;
155
+ };
156
+
157
+ AbstractChosen.prototype.input_focus = function(evt) {
158
+ var _this = this;
159
+ if (!this.active_field) {
160
+ return setTimeout((function() {
161
+ return _this.container_mousedown();
162
+ }), 50);
163
+ }
164
+ };
165
+
166
+ AbstractChosen.prototype.input_blur = function(evt) {
167
+ var _this = this;
168
+ if (!this.mouse_on_container) {
169
+ this.active_field = false;
170
+ return setTimeout((function() {
171
+ return _this.blur_test();
172
+ }), 100);
173
+ }
174
+ };
175
+
176
+ AbstractChosen.prototype.result_add_option = function(option) {
177
+ var classes, style;
178
+ if (!option.disabled) {
179
+ option.dom_id = this.container_id + "_o_" + option.array_index;
180
+ classes = option.selected && this.is_multiple ? [] : ["active-result"];
181
+ if (option.selected) classes.push("result-selected");
182
+ if (option.group_array_index != null) classes.push("group-option");
183
+ if (option.classes !== "") classes.push(option.classes);
184
+ style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
185
+ return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
186
+ } else {
187
+ return "";
188
+ }
189
+ };
190
+
191
+ AbstractChosen.prototype.results_update_field = function() {
192
+ if (!this.is_multiple) this.results_reset_cleanup();
193
+ this.result_clear_highlight();
194
+ this.result_single_selected = null;
195
+ return this.results_build();
196
+ };
197
+
198
+ AbstractChosen.prototype.results_toggle = function() {
199
+ if (this.results_showing) {
200
+ return this.results_hide();
201
+ } else {
202
+ return this.results_show();
203
+ }
204
+ };
205
+
206
+ AbstractChosen.prototype.results_search = function(evt) {
207
+ if (this.results_showing) {
208
+ return this.winnow_results();
209
+ } else {
210
+ return this.results_show();
211
+ }
212
+ };
213
+
214
+ AbstractChosen.prototype.keyup_checker = function(evt) {
215
+ var stroke, _ref;
216
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
217
+ this.search_field_scale();
218
+ switch (stroke) {
219
+ case 8:
220
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
221
+ return this.keydown_backstroke();
222
+ } else if (!this.pending_backstroke) {
223
+ this.result_clear_highlight();
224
+ return this.results_search();
225
+ }
226
+ break;
227
+ case 13:
228
+ evt.preventDefault();
229
+ if (this.results_showing) return this.result_select(evt);
230
+ break;
231
+ case 27:
232
+ if (this.results_showing) this.results_hide();
233
+ return true;
234
+ case 9:
235
+ case 38:
236
+ case 40:
237
+ case 16:
238
+ case 91:
239
+ case 17:
240
+ break;
241
+ default:
242
+ return this.results_search();
243
+ }
244
+ };
245
+
246
+ AbstractChosen.prototype.generate_field_id = function() {
247
+ var new_id;
248
+ new_id = this.generate_random_id();
249
+ this.form_field.id = new_id;
250
+ return new_id;
251
+ };
252
+
253
+ AbstractChosen.prototype.generate_random_char = function() {
254
+ var chars, newchar, rand;
255
+ chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
256
+ rand = Math.floor(Math.random() * chars.length);
257
+ return newchar = chars.substring(rand, rand + 1);
258
+ };
259
+
260
+ return AbstractChosen;
261
+
262
+ })();
263
+
264
+ root.AbstractChosen = AbstractChosen;
265
+
266
+ }).call(this);
267
+
268
+ /*
269
+ Chosen source: generate output using 'cake build'
270
+ Copyright (c) 2011 by Harvest
271
+ */
272
+
273
+ (function() {
274
+ var Chosen, get_side_border_padding, root,
275
+ __hasProp = Object.prototype.hasOwnProperty,
276
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
277
+
278
+ root = this;
279
+
280
+ Chosen = (function(_super) {
281
+
282
+ __extends(Chosen, _super);
283
+
284
+ function Chosen() {
285
+ Chosen.__super__.constructor.apply(this, arguments);
286
+ }
287
+
288
+ Chosen.prototype.setup = function() {
289
+ this.current_value = this.form_field.value;
290
+ return this.is_rtl = this.form_field.hasClassName("chzn-rtl");
291
+ };
292
+
293
+ Chosen.prototype.finish_setup = function() {
294
+ return this.form_field.addClassName("chzn-done");
295
+ };
296
+
297
+ Chosen.prototype.set_default_values = function() {
298
+ Chosen.__super__.set_default_values.call(this);
299
+ this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
300
+ this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
301
+ this.choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>');
302
+ return this.no_results_temp = new Template('<li class="no-results">' + this.results_none_found + ' "<span>#{terms}</span>"</li>');
303
+ };
304
+
305
+ Chosen.prototype.set_up_html = function() {
306
+ var base_template, container_props, dd_top, dd_width, sf_width;
307
+ this.container_id = this.form_field.identify().replace(/[^\w]/g, '_') + "_chzn";
308
+ this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth();
309
+ container_props = {
310
+ 'id': this.container_id,
311
+ 'class': "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
312
+ 'style': 'width: ' + this.f_width + 'px'
313
+ };
314
+ base_template = this.is_multiple ? new Element('div', container_props).update(this.multi_temp.evaluate({
315
+ "default": this.default_text
316
+ })) : new Element('div', container_props).update(this.single_temp.evaluate({
317
+ "default": this.default_text
318
+ }));
319
+ this.form_field.hide().insert({
320
+ after: base_template
321
+ });
322
+ this.container = $(this.container_id);
323
+ this.container.addClassName("chzn-container-" + (this.is_multiple ? "multi" : "single"));
324
+ this.dropdown = this.container.down('div.chzn-drop');
325
+ dd_top = this.container.getHeight();
326
+ dd_width = this.f_width - get_side_border_padding(this.dropdown);
327
+ this.dropdown.setStyle({
328
+ "width": dd_width + "px",
329
+ "top": dd_top + "px"
330
+ });
331
+ this.search_field = this.container.down('input');
332
+ this.search_results = this.container.down('ul.chzn-results');
333
+ this.search_field_scale();
334
+ this.search_no_results = this.container.down('li.no-results');
335
+ if (this.is_multiple) {
336
+ this.search_choices = this.container.down('ul.chzn-choices');
337
+ this.search_container = this.container.down('li.search-field');
338
+ } else {
339
+ this.search_container = this.container.down('div.chzn-search');
340
+ this.selected_item = this.container.down('.chzn-single');
341
+ sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
342
+ this.search_field.setStyle({
343
+ "width": sf_width + "px"
344
+ });
345
+ }
346
+ this.results_build();
347
+ this.set_tab_index();
348
+ return this.form_field.fire("liszt:ready", {
349
+ chosen: this
350
+ });
351
+ };
352
+
353
+ Chosen.prototype.register_observers = function() {
354
+ var _this = this;
355
+ this.container.observe("mousedown", function(evt) {
356
+ return _this.container_mousedown(evt);
357
+ });
358
+ this.container.observe("mouseup", function(evt) {
359
+ return _this.container_mouseup(evt);
360
+ });
361
+ this.container.observe("mouseenter", function(evt) {
362
+ return _this.mouse_enter(evt);
363
+ });
364
+ this.container.observe("mouseleave", function(evt) {
365
+ return _this.mouse_leave(evt);
366
+ });
367
+ this.search_results.observe("mouseup", function(evt) {
368
+ return _this.search_results_mouseup(evt);
369
+ });
370
+ this.search_results.observe("mouseover", function(evt) {
371
+ return _this.search_results_mouseover(evt);
372
+ });
373
+ this.search_results.observe("mouseout", function(evt) {
374
+ return _this.search_results_mouseout(evt);
375
+ });
376
+ this.form_field.observe("liszt:updated", function(evt) {
377
+ return _this.results_update_field(evt);
378
+ });
379
+ this.search_field.observe("blur", function(evt) {
380
+ return _this.input_blur(evt);
381
+ });
382
+ this.search_field.observe("keyup", function(evt) {
383
+ return _this.keyup_checker(evt);
384
+ });
385
+ this.search_field.observe("keydown", function(evt) {
386
+ return _this.keydown_checker(evt);
387
+ });
388
+ if (this.is_multiple) {
389
+ this.search_choices.observe("click", function(evt) {
390
+ return _this.choices_click(evt);
391
+ });
392
+ return this.search_field.observe("focus", function(evt) {
393
+ return _this.input_focus(evt);
394
+ });
395
+ } else {
396
+ return this.container.observe("click", function(evt) {
397
+ return evt.preventDefault();
398
+ });
399
+ }
400
+ };
401
+
402
+ Chosen.prototype.search_field_disabled = function() {
403
+ this.is_disabled = this.form_field.disabled;
404
+ if (this.is_disabled) {
405
+ this.container.addClassName('chzn-disabled');
406
+ this.search_field.disabled = true;
407
+ if (!this.is_multiple) {
408
+ this.selected_item.stopObserving("focus", this.activate_action);
409
+ }
410
+ return this.close_field();
411
+ } else {
412
+ this.container.removeClassName('chzn-disabled');
413
+ this.search_field.disabled = false;
414
+ if (!this.is_multiple) {
415
+ return this.selected_item.observe("focus", this.activate_action);
416
+ }
417
+ }
418
+ };
419
+
420
+ Chosen.prototype.container_mousedown = function(evt) {
421
+ var target_closelink;
422
+ if (!this.is_disabled) {
423
+ target_closelink = evt != null ? evt.target.hasClassName("search-choice-close") : false;
424
+ if (evt && evt.type === "mousedown" && !this.results_showing) evt.stop();
425
+ if (!this.pending_destroy_click && !target_closelink) {
426
+ if (!this.active_field) {
427
+ if (this.is_multiple) this.search_field.clear();
428
+ document.observe("click", this.click_test_action);
429
+ this.results_show();
430
+ } else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chzn-single"))) {
431
+ this.results_toggle();
432
+ }
433
+ return this.activate_field();
434
+ } else {
435
+ return this.pending_destroy_click = false;
436
+ }
437
+ }
438
+ };
439
+
440
+ Chosen.prototype.container_mouseup = function(evt) {
441
+ if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
442
+ return this.results_reset(evt);
443
+ }
444
+ };
445
+
446
+ Chosen.prototype.blur_test = function(evt) {
447
+ if (!this.active_field && this.container.hasClassName("chzn-container-active")) {
448
+ return this.close_field();
449
+ }
450
+ };
451
+
452
+ Chosen.prototype.close_field = function() {
453
+ document.stopObserving("click", this.click_test_action);
454
+ if (!this.is_multiple) {
455
+ this.selected_item.tabIndex = this.search_field.tabIndex;
456
+ this.search_field.tabIndex = -1;
457
+ }
458
+ this.active_field = false;
459
+ this.results_hide();
460
+ this.container.removeClassName("chzn-container-active");
461
+ this.winnow_results_clear();
462
+ this.clear_backstroke();
463
+ this.show_search_field_default();
464
+ return this.search_field_scale();
465
+ };
466
+
467
+ Chosen.prototype.activate_field = function() {
468
+ if (!this.is_multiple && !this.active_field) {
469
+ this.search_field.tabIndex = this.selected_item.tabIndex;
470
+ this.selected_item.tabIndex = -1;
471
+ }
472
+ this.container.addClassName("chzn-container-active");
473
+ this.active_field = true;
474
+ this.search_field.value = this.search_field.value;
475
+ return this.search_field.focus();
476
+ };
477
+
478
+ Chosen.prototype.test_active_click = function(evt) {
479
+ if (evt.target.up('#' + this.container_id)) {
480
+ return this.active_field = true;
481
+ } else {
482
+ return this.close_field();
483
+ }
484
+ };
485
+
486
+ Chosen.prototype.results_build = function() {
487
+ var content, data, _i, _len, _ref;
488
+ this.parsing = true;
489
+ this.results_data = root.SelectParser.select_to_array(this.form_field);
490
+ if (this.is_multiple && this.choices > 0) {
491
+ this.search_choices.select("li.search-choice").invoke("remove");
492
+ this.choices = 0;
493
+ } else if (!this.is_multiple) {
494
+ this.selected_item.addClassName("chzn-default").down("span").update(this.default_text);
495
+ if (this.form_field.options.length <= this.disable_search_threshold) {
496
+ this.container.addClassName("chzn-container-single-nosearch");
497
+ } else {
498
+ this.container.removeClassName("chzn-container-single-nosearch");
499
+ }
500
+ }
501
+ content = '';
502
+ _ref = this.results_data;
503
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
504
+ data = _ref[_i];
505
+ if (data.group) {
506
+ content += this.result_add_group(data);
507
+ } else if (!data.empty) {
508
+ content += this.result_add_option(data);
509
+ if (data.selected && this.is_multiple) {
510
+ this.choice_build(data);
511
+ } else if (data.selected && !this.is_multiple) {
512
+ this.selected_item.removeClassName("chzn-default").down("span").update(data.html);
513
+ if (this.allow_single_deselect) this.single_deselect_control_build();
514
+ }
515
+ }
516
+ }
517
+ this.search_field_disabled();
518
+ this.show_search_field_default();
519
+ this.search_field_scale();
520
+ this.search_results.update(content);
521
+ return this.parsing = false;
522
+ };
523
+
524
+ Chosen.prototype.result_add_group = function(group) {
525
+ if (!group.disabled) {
526
+ group.dom_id = this.container_id + "_g_" + group.array_index;
527
+ return '<li id="' + group.dom_id + '" class="group-result">' + group.label.escapeHTML() + '</li>';
528
+ } else {
529
+ return "";
530
+ }
531
+ };
532
+
533
+ Chosen.prototype.result_do_highlight = function(el) {
534
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
535
+ this.result_clear_highlight();
536
+ this.result_highlight = el;
537
+ this.result_highlight.addClassName("highlighted");
538
+ maxHeight = parseInt(this.search_results.getStyle('maxHeight'), 10);
539
+ visible_top = this.search_results.scrollTop;
540
+ visible_bottom = maxHeight + visible_top;
541
+ high_top = this.result_highlight.positionedOffset().top;
542
+ high_bottom = high_top + this.result_highlight.getHeight();
543
+ if (high_bottom >= visible_bottom) {
544
+ return this.search_results.scrollTop = (high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0;
545
+ } else if (high_top < visible_top) {
546
+ return this.search_results.scrollTop = high_top;
547
+ }
548
+ };
549
+
550
+ Chosen.prototype.result_clear_highlight = function() {
551
+ if (this.result_highlight) {
552
+ this.result_highlight.removeClassName('highlighted');
553
+ }
554
+ return this.result_highlight = null;
555
+ };
556
+
557
+ Chosen.prototype.results_show = function() {
558
+ var dd_top;
559
+ if (!this.is_multiple) {
560
+ this.selected_item.addClassName('chzn-single-with-drop');
561
+ if (this.result_single_selected) {
562
+ this.result_do_highlight(this.result_single_selected);
563
+ }
564
+ } else if (this.max_selected_options <= this.choices) {
565
+ this.form_field.fire("liszt:maxselected", {
566
+ chosen: this
567
+ });
568
+ return false;
569
+ }
570
+ dd_top = this.is_multiple ? this.container.getHeight() : this.container.getHeight() - 1;
571
+ this.form_field.fire("liszt:showing_dropdown", {
572
+ chosen: this
573
+ });
574
+ this.dropdown.setStyle({
575
+ "top": dd_top + "px",
576
+ "left": 0
577
+ });
578
+ this.results_showing = true;
579
+ this.search_field.focus();
580
+ this.search_field.value = this.search_field.value;
581
+ return this.winnow_results();
582
+ };
583
+
584
+ Chosen.prototype.results_hide = function() {
585
+ if (!this.is_multiple) {
586
+ this.selected_item.removeClassName('chzn-single-with-drop');
587
+ }
588
+ this.result_clear_highlight();
589
+ this.form_field.fire("liszt:hiding_dropdown", {
590
+ chosen: this
591
+ });
592
+ this.dropdown.setStyle({
593
+ "left": "-9000px"
594
+ });
595
+ return this.results_showing = false;
596
+ };
597
+
598
+ Chosen.prototype.set_tab_index = function(el) {
599
+ var ti;
600
+ if (this.form_field.tabIndex) {
601
+ ti = this.form_field.tabIndex;
602
+ this.form_field.tabIndex = -1;
603
+ if (this.is_multiple) {
604
+ return this.search_field.tabIndex = ti;
605
+ } else {
606
+ this.selected_item.tabIndex = ti;
607
+ return this.search_field.tabIndex = -1;
608
+ }
609
+ }
610
+ };
611
+
612
+ Chosen.prototype.show_search_field_default = function() {
613
+ if (this.is_multiple && this.choices < 1 && !this.active_field) {
614
+ this.search_field.value = this.default_text;
615
+ return this.search_field.addClassName("default");
616
+ } else {
617
+ this.search_field.value = "";
618
+ return this.search_field.removeClassName("default");
619
+ }
620
+ };
621
+
622
+ Chosen.prototype.search_results_mouseup = function(evt) {
623
+ var target;
624
+ target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
625
+ if (target) {
626
+ this.result_highlight = target;
627
+ return this.result_select(evt);
628
+ }
629
+ };
630
+
631
+ Chosen.prototype.search_results_mouseover = function(evt) {
632
+ var target;
633
+ target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
634
+ if (target) return this.result_do_highlight(target);
635
+ };
636
+
637
+ Chosen.prototype.search_results_mouseout = function(evt) {
638
+ if (evt.target.hasClassName('active-result') || evt.target.up('.active-result')) {
639
+ return this.result_clear_highlight();
640
+ }
641
+ };
642
+
643
+ Chosen.prototype.choices_click = function(evt) {
644
+ evt.preventDefault();
645
+ if (this.active_field && !(evt.target.hasClassName('search-choice') || evt.target.up('.search-choice')) && !this.results_showing) {
646
+ return this.results_show();
647
+ }
648
+ };
649
+
650
+ Chosen.prototype.choice_build = function(item) {
651
+ var choice_id, link,
652
+ _this = this;
653
+ if (this.is_multiple && this.max_selected_options <= this.choices) {
654
+ this.form_field.fire("liszt:maxselected", {
655
+ chosen: this
656
+ });
657
+ return false;
658
+ }
659
+ choice_id = this.container_id + "_c_" + item.array_index;
660
+ this.choices += 1;
661
+ this.search_container.insert({
662
+ before: this.choice_temp.evaluate({
663
+ id: choice_id,
664
+ choice: item.html,
665
+ position: item.array_index
666
+ })
667
+ });
668
+ link = $(choice_id).down('a');
669
+ return link.observe("click", function(evt) {
670
+ return _this.choice_destroy_link_click(evt);
671
+ });
672
+ };
673
+
674
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
675
+ evt.preventDefault();
676
+ if (!this.is_disabled) {
677
+ this.pending_destroy_click = true;
678
+ return this.choice_destroy(evt.target);
679
+ }
680
+ };
681
+
682
+ Chosen.prototype.choice_destroy = function(link) {
683
+ this.choices -= 1;
684
+ this.show_search_field_default();
685
+ if (this.is_multiple && this.choices > 0 && this.search_field.value.length < 1) {
686
+ this.results_hide();
687
+ }
688
+ this.result_deselect(link.readAttribute("rel"));
689
+ return link.up('li').remove();
690
+ };
691
+
692
+ Chosen.prototype.results_reset = function() {
693
+ this.form_field.options[0].selected = true;
694
+ this.selected_item.down("span").update(this.default_text);
695
+ if (!this.is_multiple) this.selected_item.addClassName("chzn-default");
696
+ this.show_search_field_default();
697
+ this.results_reset_cleanup();
698
+ if (typeof Event.simulate === 'function') this.form_field.simulate("change");
699
+ if (this.active_field) return this.results_hide();
700
+ };
701
+
702
+ Chosen.prototype.results_reset_cleanup = function() {
703
+ var deselect_trigger;
704
+ deselect_trigger = this.selected_item.down("abbr");
705
+ if (deselect_trigger) return deselect_trigger.remove();
706
+ };
707
+
708
+ Chosen.prototype.result_select = function(evt) {
709
+ var high, item, position;
710
+ if (this.result_highlight) {
711
+ high = this.result_highlight;
712
+ this.result_clear_highlight();
713
+ if (this.is_multiple) {
714
+ this.result_deactivate(high);
715
+ } else {
716
+ this.search_results.descendants(".result-selected").invoke("removeClassName", "result-selected");
717
+ this.selected_item.removeClassName("chzn-default");
718
+ this.result_single_selected = high;
719
+ }
720
+ high.addClassName("result-selected");
721
+ position = high.id.substr(high.id.lastIndexOf("_") + 1);
722
+ item = this.results_data[position];
723
+ item.selected = true;
724
+ this.form_field.options[item.options_index].selected = true;
725
+ if (this.is_multiple) {
726
+ this.choice_build(item);
727
+ } else {
728
+ this.selected_item.down("span").update(item.html);
729
+ if (this.allow_single_deselect) this.single_deselect_control_build();
730
+ }
731
+ if (!(evt.metaKey && this.is_multiple)) this.results_hide();
732
+ this.search_field.value = "";
733
+ if (typeof Event.simulate === 'function' && (this.is_multiple || this.form_field.value !== this.current_value)) {
734
+ this.form_field.simulate("change");
735
+ }
736
+ this.current_value = this.form_field.value;
737
+ return this.search_field_scale();
738
+ }
739
+ };
740
+
741
+ Chosen.prototype.result_activate = function(el) {
742
+ return el.addClassName("active-result");
743
+ };
744
+
745
+ Chosen.prototype.result_deactivate = function(el) {
746
+ return el.removeClassName("active-result");
747
+ };
748
+
749
+ Chosen.prototype.result_deselect = function(pos) {
750
+ var result, result_data;
751
+ result_data = this.results_data[pos];
752
+ result_data.selected = false;
753
+ this.form_field.options[result_data.options_index].selected = false;
754
+ result = $(this.container_id + "_o_" + pos);
755
+ result.removeClassName("result-selected").addClassName("active-result").show();
756
+ this.result_clear_highlight();
757
+ this.winnow_results();
758
+ if (typeof Event.simulate === 'function') this.form_field.simulate("change");
759
+ return this.search_field_scale();
760
+ };
761
+
762
+ Chosen.prototype.single_deselect_control_build = function() {
763
+ if (this.allow_single_deselect && !this.selected_item.down("abbr")) {
764
+ return this.selected_item.down("span").insert({
765
+ after: "<abbr class=\"search-choice-close\"></abbr>"
766
+ });
767
+ }
768
+ };
769
+
770
+ Chosen.prototype.winnow_results = function() {
771
+ var found, option, part, parts, regex, regexAnchor, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
772
+ this.no_results_clear();
773
+ results = 0;
774
+ searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip().escapeHTML();
775
+ regexAnchor = this.search_contains ? "" : "^";
776
+ regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\amp;"), 'i');
777
+ zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\amp;"), 'i');
778
+ _ref = this.results_data;
779
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
780
+ option = _ref[_i];
781
+ if (!option.disabled && !option.empty) {
782
+ if (option.group) {
783
+ $(option.dom_id).hide();
784
+ } else if (!(this.is_multiple && option.selected)) {
785
+ found = false;
786
+ result_id = option.dom_id;
787
+ if (regex.test(option.html)) {
788
+ found = true;
789
+ results += 1;
790
+ } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
791
+ parts = option.html.replace(/\[|\]/g, "").split(" ");
792
+ if (parts.length) {
793
+ for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
794
+ part = parts[_j];
795
+ if (regex.test(part)) {
796
+ found = true;
797
+ results += 1;
798
+ }
799
+ }
800
+ }
801
+ }
802
+ if (found) {
803
+ if (searchText.length) {
804
+ startpos = option.html.search(zregex);
805
+ text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
806
+ text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
807
+ } else {
808
+ text = option.html;
809
+ }
810
+ if ($(result_id).innerHTML !== text) $(result_id).update(text);
811
+ this.result_activate($(result_id));
812
+ if (option.group_array_index != null) {
813
+ $(this.results_data[option.group_array_index].dom_id).setStyle({
814
+ display: 'list-item'
815
+ });
816
+ }
817
+ } else {
818
+ if ($(result_id) === this.result_highlight) {
819
+ this.result_clear_highlight();
820
+ }
821
+ this.result_deactivate($(result_id));
822
+ }
823
+ }
824
+ }
825
+ }
826
+ if (results < 1 && searchText.length) {
827
+ return this.no_results(searchText);
828
+ } else {
829
+ return this.winnow_results_set_highlight();
830
+ }
831
+ };
832
+
833
+ Chosen.prototype.winnow_results_clear = function() {
834
+ var li, lis, _i, _len, _results;
835
+ this.search_field.clear();
836
+ lis = this.search_results.select("li");
837
+ _results = [];
838
+ for (_i = 0, _len = lis.length; _i < _len; _i++) {
839
+ li = lis[_i];
840
+ if (li.hasClassName("group-result")) {
841
+ _results.push(li.show());
842
+ } else if (!this.is_multiple || !li.hasClassName("result-selected")) {
843
+ _results.push(this.result_activate(li));
844
+ } else {
845
+ _results.push(void 0);
846
+ }
847
+ }
848
+ return _results;
849
+ };
850
+
851
+ Chosen.prototype.winnow_results_set_highlight = function() {
852
+ var do_high;
853
+ if (!this.result_highlight) {
854
+ if (!this.is_multiple) {
855
+ do_high = this.search_results.down(".result-selected.active-result");
856
+ }
857
+ if (!(do_high != null)) {
858
+ do_high = this.search_results.down(".active-result");
859
+ }
860
+ if (do_high != null) return this.result_do_highlight(do_high);
861
+ }
862
+ };
863
+
864
+ Chosen.prototype.no_results = function(terms) {
865
+ return this.search_results.insert(this.no_results_temp.evaluate({
866
+ terms: terms
867
+ }));
868
+ };
869
+
870
+ Chosen.prototype.no_results_clear = function() {
871
+ var nr, _results;
872
+ nr = null;
873
+ _results = [];
874
+ while (nr = this.search_results.down(".no-results")) {
875
+ _results.push(nr.remove());
876
+ }
877
+ return _results;
878
+ };
879
+
880
+ Chosen.prototype.keydown_arrow = function() {
881
+ var actives, nexts, sibs;
882
+ actives = this.search_results.select("li.active-result");
883
+ if (actives.length) {
884
+ if (!this.result_highlight) {
885
+ this.result_do_highlight(actives.first());
886
+ } else if (this.results_showing) {
887
+ sibs = this.result_highlight.nextSiblings();
888
+ nexts = sibs.intersect(actives);
889
+ if (nexts.length) this.result_do_highlight(nexts.first());
890
+ }
891
+ if (!this.results_showing) return this.results_show();
892
+ }
893
+ };
894
+
895
+ Chosen.prototype.keyup_arrow = function() {
896
+ var actives, prevs, sibs;
897
+ if (!this.results_showing && !this.is_multiple) {
898
+ return this.results_show();
899
+ } else if (this.result_highlight) {
900
+ sibs = this.result_highlight.previousSiblings();
901
+ actives = this.search_results.select("li.active-result");
902
+ prevs = sibs.intersect(actives);
903
+ if (prevs.length) {
904
+ return this.result_do_highlight(prevs.first());
905
+ } else {
906
+ if (this.choices > 0) this.results_hide();
907
+ return this.result_clear_highlight();
908
+ }
909
+ }
910
+ };
911
+
912
+ Chosen.prototype.keydown_backstroke = function() {
913
+ if (this.pending_backstroke) {
914
+ this.choice_destroy(this.pending_backstroke.down("a"));
915
+ return this.clear_backstroke();
916
+ } else {
917
+ this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
918
+ if (this.single_backstroke_delete) {
919
+ return this.keydown_backstroke();
920
+ } else {
921
+ return this.pending_backstroke.addClassName("search-choice-focus");
922
+ }
923
+ }
924
+ };
925
+
926
+ Chosen.prototype.clear_backstroke = function() {
927
+ if (this.pending_backstroke) {
928
+ this.pending_backstroke.removeClassName("search-choice-focus");
929
+ }
930
+ return this.pending_backstroke = null;
931
+ };
932
+
933
+ Chosen.prototype.keydown_checker = function(evt) {
934
+ var stroke, _ref;
935
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
936
+ this.search_field_scale();
937
+ if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
938
+ switch (stroke) {
939
+ case 8:
940
+ this.backstroke_length = this.search_field.value.length;
941
+ break;
942
+ case 9:
943
+ if (this.results_showing && !this.is_multiple) this.result_select(evt);
944
+ this.mouse_on_container = false;
945
+ break;
946
+ case 13:
947
+ evt.preventDefault();
948
+ break;
949
+ case 38:
950
+ evt.preventDefault();
951
+ this.keyup_arrow();
952
+ break;
953
+ case 40:
954
+ this.keydown_arrow();
955
+ break;
956
+ }
957
+ };
958
+
959
+ Chosen.prototype.search_field_scale = function() {
960
+ var dd_top, div, h, style, style_block, styles, w, _i, _len;
961
+ if (this.is_multiple) {
962
+ h = 0;
963
+ w = 0;
964
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
965
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
966
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
967
+