Infobeans_Switchowner - Version 1.0.2

Version Notes

Release 1.0.2

Download this release

Release Info

Developer InfoBeans
Extension Infobeans_Switchowner
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/community/Infobeans/Switchowner/Block/Adminhtml/Customer/Info.php CHANGED
@@ -70,7 +70,7 @@ class Infobeans_Switchowner_Block_Adminhtml_Customer_Info extends Mage_Adminhtml
70
  $customerBillingAddressId = $customerData->getDefaultBilling();
71
  //getting default shipping address
72
  $customerShippingAddressId = $customerData->getDefaultShipping();
73
- if (($customerBillingAddressId == "" || $customerShippingAddressId == "") && $overwriteAddress == 1 ) {
74
  $users->removeItemByKey($key);
75
  }
76
  }
@@ -114,11 +114,13 @@ class Infobeans_Switchowner_Block_Adminhtml_Customer_Info extends Mage_Adminhtml
114
  if ($group->getWebsiteId() != $website->getId()) {
115
  continue;
116
  }
 
117
  $groupShow = false;
118
  foreach ($storeModel->getStoreCollection() as $store) {
119
  if ($store->getGroupId() != $group->getId()) {
120
  continue;
121
  }
 
122
  if (!$websiteShow) {
123
  $websiteShow = true;
124
  $options['website_' . $website->getCode()] = array(
@@ -127,6 +129,7 @@ class Infobeans_Switchowner_Block_Adminhtml_Customer_Info extends Mage_Adminhtml
127
  'style' => 'padding-left:6px; background:#DDD; font-weight:bold;',
128
  );
129
  }
 
130
  if (!$groupShow) {
131
  $groupShow = true;
132
  $options['group_' . $group->getId() . '_open'] = array(
@@ -137,12 +140,14 @@ class Infobeans_Switchowner_Block_Adminhtml_Customer_Info extends Mage_Adminhtml
137
  'style' => 'padding-left:32px;'
138
  );
139
  }
 
140
  $options['store_' . $store->getCode()] = array(
141
  'label' => $store->getName(),
142
  'id' => 'store_'.$store->getId(),
143
  'style' => '',
144
  );
145
  }
 
146
  if ($groupShow) {
147
  $options['group_' . $group->getId() . '_close'] = array(
148
  'is_group' => true,
@@ -151,6 +156,7 @@ class Infobeans_Switchowner_Block_Adminhtml_Customer_Info extends Mage_Adminhtml
151
  }
152
  }
153
  }
 
154
  return $options;
155
  }
156
  }
70
  $customerBillingAddressId = $customerData->getDefaultBilling();
71
  //getting default shipping address
72
  $customerShippingAddressId = $customerData->getDefaultShipping();
73
+ if (($customerBillingAddressId == "" || $customerShippingAddressId == "") && $overwriteAddress == 1) {
74
  $users->removeItemByKey($key);
75
  }
76
  }
114
  if ($group->getWebsiteId() != $website->getId()) {
115
  continue;
116
  }
117
+
118
  $groupShow = false;
119
  foreach ($storeModel->getStoreCollection() as $store) {
120
  if ($store->getGroupId() != $group->getId()) {
121
  continue;
122
  }
123
+
124
  if (!$websiteShow) {
125
  $websiteShow = true;
126
  $options['website_' . $website->getCode()] = array(
129
  'style' => 'padding-left:6px; background:#DDD; font-weight:bold;',
130
  );
131
  }
132
+
133
  if (!$groupShow) {
134
  $groupShow = true;
135
  $options['group_' . $group->getId() . '_open'] = array(
140
  'style' => 'padding-left:32px;'
141
  );
142
  }
143
+
144
  $options['store_' . $store->getCode()] = array(
145
  'label' => $store->getName(),
146
  'id' => 'store_'.$store->getId(),
147
  'style' => '',
148
  );
149
  }
150
+
151
  if ($groupShow) {
152
  $options['group_' . $group->getId() . '_close'] = array(
153
  'is_group' => true,
156
  }
157
  }
158
  }
159
+
160
  return $options;
161
  }
162
  }
app/code/community/Infobeans/Switchowner/Helper/Notify.php CHANGED
@@ -56,7 +56,6 @@ class Infobeans_Switchowner_Helper_Notify extends Mage_Core_Helper_Abstract
56
  /** @var Mage_Core_Model_Email_Template $mailTemplate */
57
  $mailTemplate = Mage::getModel('core/email_template');
58
  try {
59
-
60
  $mailTemplate
61
  ->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))
62
  ->sendTransactional(
@@ -67,9 +66,7 @@ class Infobeans_Switchowner_Helper_Notify extends Mage_Core_Helper_Abstract
67
  $vars,
68
  $storeId
69
  );
70
-
71
  } catch (Exception $e) {
72
-
73
  Mage::logException($e);
74
  }
75
  }
56
  /** @var Mage_Core_Model_Email_Template $mailTemplate */
57
  $mailTemplate = Mage::getModel('core/email_template');
58
  try {
 
59
  $mailTemplate
60
  ->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))
61
  ->sendTransactional(
66
  $vars,
67
  $storeId
68
  );
 
69
  } catch (Exception $e) {
 
70
  Mage::logException($e);
71
  }
72
  }
app/code/community/Infobeans/Switchowner/Model/History.php CHANGED
@@ -24,14 +24,13 @@ class Infobeans_Switchowner_Model_History extends Mage_Core_Model_Abstract
24
  {
25
  if (!$this->_order) {
26
  if ($orderId = $this->getOrderId()) {
27
-
28
  $order = Mage::getModel('switchowner/order')->load($orderId);
29
  $this->_order = $order;
30
-
31
  } else {
32
  return false;
33
  }
34
  }
 
35
  return $this->_order;
36
  }
37
 
@@ -67,6 +66,7 @@ class Infobeans_Switchowner_Model_History extends Mage_Core_Model_Abstract
67
  $collection->addFieldToFilter('history_id', $this->getId());
68
  $this->_details = $collection;
69
  }
 
70
  return $this->_details;
71
  }
72
 
@@ -105,10 +105,12 @@ class Infobeans_Switchowner_Model_History extends Mage_Core_Model_Abstract
105
  break;
106
  }
107
  }
 
108
  if ($customerId) {
109
  $customer = Mage::getModel('customer/customer')->load($customerId);
110
  return $customer;
111
  }
 
112
  return new Varien_Object();
113
  }
114
 
@@ -126,10 +128,12 @@ class Infobeans_Switchowner_Model_History extends Mage_Core_Model_Abstract
126
  break;
127
  }
128
  }
 
129
  if ($adminId) {
130
  $adminData = Mage::getModel('admin/user')->load($adminId);
131
  return $adminData;
132
  }
 
133
  return new Varien_Object();
134
  }
135
 
24
  {
25
  if (!$this->_order) {
26
  if ($orderId = $this->getOrderId()) {
 
27
  $order = Mage::getModel('switchowner/order')->load($orderId);
28
  $this->_order = $order;
 
29
  } else {
30
  return false;
31
  }
32
  }
33
+
34
  return $this->_order;
35
  }
36
 
66
  $collection->addFieldToFilter('history_id', $this->getId());
67
  $this->_details = $collection;
68
  }
69
+
70
  return $this->_details;
71
  }
72
 
105
  break;
106
  }
107
  }
108
+
109
  if ($customerId) {
110
  $customer = Mage::getModel('customer/customer')->load($customerId);
111
  return $customer;
112
  }
113
+
114
  return new Varien_Object();
115
  }
116
 
128
  break;
129
  }
130
  }
131
+
132
  if ($adminId) {
133
  $adminData = Mage::getModel('admin/user')->load($adminId);
134
  return $adminData;
135
  }
136
+
137
  return new Varien_Object();
138
  }
139
 
app/code/community/Infobeans/Switchowner/Model/Mysql4/History/Collection.php CHANGED
@@ -37,6 +37,7 @@ class Infobeans_Switchowner_Model_Mysql4_History_Collection extends Mage_Core_Mo
37
  if (!$this->isLoaded()) {
38
  $this->load();
39
  }
 
40
  return $this->_last;
41
  }
42
  }
37
  if (!$this->isLoaded()) {
38
  $this->load();
39
  }
40
+
41
  return $this->_last;
42
  }
43
  }
app/code/community/Infobeans/Switchowner/Model/Observer.php CHANGED
@@ -34,19 +34,23 @@ class Infobeans_Switchowner_Model_Observer
34
  $state = explode(",", Mage::getStoreConfig('switchowner/general/orderstate'));
35
  $orderState = $order->getStatus();
36
 
37
- if (!in_array($orderState , $state)) {
38
  if ($order->isGuestOrder() && $this->_helper()->isAllowed()) {
39
- $block->addButton('switchOrder', array(
 
40
  'label' => $this->_helper()->__("Switch Order Owner"),
41
  'onclick' => "javascript: switchownerRowClick()",
42
  'class' => 'switch-order',
43
- ));
 
44
  } else {
45
- $block->addButton('switchOrder', array(
 
46
  'label' => $this->_helper()->__("Switch Order Owner"),
47
  'onclick' => "javascript: switchownerRowClick()",
48
  'class' => 'switch-order',
49
- ));
 
50
  }
51
  }
52
  }
@@ -71,12 +75,14 @@ class Infobeans_Switchowner_Model_Observer
71
  'sales_order',
72
  );
73
 
74
- if ( in_array($block->getRequest()->getControllerName(), $allowedControllerNames) ) {
75
  $backendUrl = Mage::getSingleton('adminhtml/url');
76
- $block->addItem('switch', array(
 
77
  'label' => $this->_helper()->__("Switch Order Owner"),
78
  'url' => "javascript:switchownerRowClick();",
79
- ));
 
80
  }
81
  }
82
  }
34
  $state = explode(",", Mage::getStoreConfig('switchowner/general/orderstate'));
35
  $orderState = $order->getStatus();
36
 
37
+ if (!in_array($orderState, $state)) {
38
  if ($order->isGuestOrder() && $this->_helper()->isAllowed()) {
39
+ $block->addButton(
40
+ 'switchOrder', array(
41
  'label' => $this->_helper()->__("Switch Order Owner"),
42
  'onclick' => "javascript: switchownerRowClick()",
43
  'class' => 'switch-order',
44
+ )
45
+ );
46
  } else {
47
+ $block->addButton(
48
+ 'switchOrder', array(
49
  'label' => $this->_helper()->__("Switch Order Owner"),
50
  'onclick' => "javascript: switchownerRowClick()",
51
  'class' => 'switch-order',
52
+ )
53
+ );
54
  }
55
  }
56
  }
75
  'sales_order',
76
  );
77
 
78
+ if (in_array($block->getRequest()->getControllerName(), $allowedControllerNames)) {
79
  $backendUrl = Mage::getSingleton('adminhtml/url');
80
+ $block->addItem(
81
+ 'switch', array(
82
  'label' => $this->_helper()->__("Switch Order Owner"),
83
  'url' => "javascript:switchownerRowClick();",
84
+ )
85
+ );
86
  }
87
  }
88
  }
app/code/community/Infobeans/Switchowner/Model/Order.php CHANGED
@@ -52,7 +52,6 @@ class Infobeans_Switchowner_Model_Order extends Mage_Sales_Model_Order
52
  /** @var Infobeans_Switchowner_Model_History $lastItem */
53
  $lastItem = $this->getOwnerSwitchHistory()->getLastItem();
54
  if ($lastItem && $lastItem->hasDetails()){
55
-
56
  $from = $lastItem->getFromData();
57
 
58
  foreach ($this->getNameParts() as $key){
@@ -64,6 +63,7 @@ class Infobeans_Switchowner_Model_Order extends Mage_Sales_Model_Order
64
 
65
  return implode(" ", $nameParts);
66
  }
 
67
  return false;
68
  }
69
 
@@ -104,7 +104,6 @@ class Infobeans_Switchowner_Model_Order extends Mage_Sales_Model_Order
104
  ->setCustomerGroupId($newCustomerGroup);
105
 
106
  if ($overwriteName == 1) {
107
-
108
  $nameParts = $this->getNameParts();
109
  foreach ($nameParts as $nameKey) {
110
  $dataKey = 'customer_' . $nameKey;
@@ -119,7 +118,6 @@ class Infobeans_Switchowner_Model_Order extends Mage_Sales_Model_Order
119
 
120
  // Overwrite billing/shipping address of customer
121
  if ($overwriteAddress == 1) {
122
-
123
  //getting default billing address
124
  $customerBillingAddressId = $customer->getDefaultBilling();
125
  $defaultBillingAddress = Mage::getModel('customer/address')->load($customerBillingAddressId)->getData();
@@ -182,11 +180,10 @@ class Infobeans_Switchowner_Model_Order extends Mage_Sales_Model_Order
182
  $shippingAddress->addData($shippingData);
183
  $shippingAddress->implodeStreetAddress()->save();
184
  }
185
-
186
  } catch (Exception $e) {
187
- Mage::log($e,null,"IBswitchowner.log");
188
  Mage::getSingleton('core/session')->addError($e->getMessage());
189
- exit;
190
  }
191
  }
192
 
@@ -230,6 +227,7 @@ class Infobeans_Switchowner_Model_Order extends Mage_Sales_Model_Order
230
 
231
  $this->_ownerswitchHistoryCollection = $collection;
232
  }
 
233
  return $this->_ownerswitchHistoryCollection;
234
  }
235
 
52
  /** @var Infobeans_Switchowner_Model_History $lastItem */
53
  $lastItem = $this->getOwnerSwitchHistory()->getLastItem();
54
  if ($lastItem && $lastItem->hasDetails()){
 
55
  $from = $lastItem->getFromData();
56
 
57
  foreach ($this->getNameParts() as $key){
63
 
64
  return implode(" ", $nameParts);
65
  }
66
+
67
  return false;
68
  }
69
 
104
  ->setCustomerGroupId($newCustomerGroup);
105
 
106
  if ($overwriteName == 1) {
 
107
  $nameParts = $this->getNameParts();
108
  foreach ($nameParts as $nameKey) {
109
  $dataKey = 'customer_' . $nameKey;
118
 
119
  // Overwrite billing/shipping address of customer
120
  if ($overwriteAddress == 1) {
 
121
  //getting default billing address
122
  $customerBillingAddressId = $customer->getDefaultBilling();
123
  $defaultBillingAddress = Mage::getModel('customer/address')->load($customerBillingAddressId)->getData();
180
  $shippingAddress->addData($shippingData);
181
  $shippingAddress->implodeStreetAddress()->save();
182
  }
 
183
  } catch (Exception $e) {
184
+ Mage::log($e, null, "IBswitchowner.log");
185
  Mage::getSingleton('core/session')->addError($e->getMessage());
186
+ return;
187
  }
188
  }
189
 
227
 
228
  $this->_ownerswitchHistoryCollection = $collection;
229
  }
230
+
231
  return $this->_ownerswitchHistoryCollection;
232
  }
233
 
app/code/community/Infobeans/Switchowner/controllers/Adminhtml/Switchowner/OrderController.php CHANGED
@@ -9,7 +9,7 @@
9
  * @copyright Copyright (c) 2016 InfoBeans Technologies Limited
10
  */
11
 
12
- class Infobeans_Switchowner_Adminhtml_Switchowner_OrderController extends Mage_Adminhtml_Controller_Action
13
  {
14
 
15
  /**
@@ -62,7 +62,6 @@ class Infobeans_Switchowner_Adminhtml_Switchowner_OrderController extends Mage_A
62
  $overwriteAddress = Mage::getStoreConfig('switchowner/address/override_billing_shipping');
63
 
64
  foreach ($users as $key => $value) {
65
-
66
  $customerData = Mage::getModel('customer/customer')->load($value->getId());
67
 
68
  //getting default billing address
@@ -80,9 +79,11 @@ class Infobeans_Switchowner_Adminhtml_Switchowner_OrderController extends Mage_A
80
  foreach ($users as $user) {
81
  $customerOptions = $customerOptions . '<option value="' . $user->getId() . '">' . $user->getEmail() .' ( '.$user->getFirstname().' '.$user->getMiddlename().' '.$user->getLastname().' )</option>';
82
  }
 
83
  $customerOptions = $customerOptions . "</select>";
84
 
85
- echo $customerOptions;
 
86
  }
87
 
88
  public function switchOwnerAction()
@@ -113,13 +114,14 @@ class Infobeans_Switchowner_Adminhtml_Switchowner_OrderController extends Mage_A
113
  if($acountSharingOption == 1 && $newCustomerWebsiteId != $oldCustomerWebsiteId) {
114
  $canOwnerSwitch = 0;
115
  }
116
- if (!in_array($orderState , $state) && $canOwnerSwitch == 1) {
 
117
  $order->switchOwner($customerId, $overwriteName, $sendEmail, $overwriteAddress);
118
  $success++;
119
  } else if ($canOwnerSwitch == 0) {
120
  $websiteError++;
121
  $websiteErrorMsg = $websiteErrorMsg.$order->getIncrementId().", ";
122
- } else if (in_array($orderState , $state)) {
123
  $orderStatusError++;
124
  $orderStatusErrorMsg = $orderStatusErrorMsg.$order->getIncrementId().", ";
125
  } else {
@@ -134,29 +136,35 @@ class Infobeans_Switchowner_Adminhtml_Switchowner_OrderController extends Mage_A
134
  if ($success) {
135
  $this->_getSession()->addSuccess($this->_helper()->__("%s Order owner were successfully switched.", $success));
136
  }
 
137
  if($websiteError) {
138
  $this->_getSession()->addError($this->_helper()->__("Order owner can not be switched for %s as the selected customer belongs to the different website.", rtrim($websiteErrorMsg, ", ")));
139
  }
 
140
  if($orderStatusError) {
141
- $this->_getSession()->addError($this->_helper()->__("Order owner can not be switched for %s as it can not be processed further." ,rtrim($orderStatusErrorMsg, ", ")));
142
  }
 
143
  if ($error) {
144
  $this->_getSession()->addError($this->_helper()->__("%s Order were not be updated due to some error.", $error));
145
  }
146
 
147
  $this->_redirect('adminhtml/sales_order/index');
148
  } else {
149
- $referer = Mage::helper( 'core/http' )->getHttpReferer();
150
 
151
  if ($success) {
152
  $this->_getSession()->addSuccess($this->_helper()->__("Order owner was successfully switched."));
153
  }
 
154
  if($websiteError) {
155
- $this->_getSession()->addError($this->_helper()->__("Order %s owner can not be switched as the selected customer belongs to the different website.",rtrim($websiteErrorMsg, ", ")));
156
  }
 
157
  if($orderStatusError) {
158
- $this->_getSession()->addError($this->_helper()->__("Order %s owner can not be switched as it can not be processed further." ,rtrim($orderStatusErrorMsg, ", ")));
159
  }
 
160
  if ($error) {
161
  $this->_getSession()->addError($this->_helper()->__("Order was not be updated due to some error."));
162
  }
@@ -172,6 +180,7 @@ class Infobeans_Switchowner_Adminhtml_Switchowner_OrderController extends Mage_A
172
  $this->_redirect('adminhtml/sales_order/index');
173
  }
174
  }
 
175
  return;
176
  }
177
  }
9
  * @copyright Copyright (c) 2016 InfoBeans Technologies Limited
10
  */
11
 
12
+ class Infobeans_Switchowner_Adminhtml_Switchowner_OrderController extends Mage_Adminhtml_Controller_Action
13
  {
14
 
15
  /**
62
  $overwriteAddress = Mage::getStoreConfig('switchowner/address/override_billing_shipping');
63
 
64
  foreach ($users as $key => $value) {
 
65
  $customerData = Mage::getModel('customer/customer')->load($value->getId());
66
 
67
  //getting default billing address
79
  foreach ($users as $user) {
80
  $customerOptions = $customerOptions . '<option value="' . $user->getId() . '">' . $user->getEmail() .' ( '.$user->getFirstname().' '.$user->getMiddlename().' '.$user->getLastname().' )</option>';
81
  }
82
+
83
  $customerOptions = $customerOptions . "</select>";
84
 
85
+ $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
86
+ $this->getResponse()->setBody(json_encode($customerOptions));
87
  }
88
 
89
  public function switchOwnerAction()
114
  if($acountSharingOption == 1 && $newCustomerWebsiteId != $oldCustomerWebsiteId) {
115
  $canOwnerSwitch = 0;
116
  }
117
+
118
+ if (!in_array($orderState, $state) && $canOwnerSwitch == 1) {
119
  $order->switchOwner($customerId, $overwriteName, $sendEmail, $overwriteAddress);
120
  $success++;
121
  } else if ($canOwnerSwitch == 0) {
122
  $websiteError++;
123
  $websiteErrorMsg = $websiteErrorMsg.$order->getIncrementId().", ";
124
+ } else if (in_array($orderState, $state)) {
125
  $orderStatusError++;
126
  $orderStatusErrorMsg = $orderStatusErrorMsg.$order->getIncrementId().", ";
127
  } else {
136
  if ($success) {
137
  $this->_getSession()->addSuccess($this->_helper()->__("%s Order owner were successfully switched.", $success));
138
  }
139
+
140
  if($websiteError) {
141
  $this->_getSession()->addError($this->_helper()->__("Order owner can not be switched for %s as the selected customer belongs to the different website.", rtrim($websiteErrorMsg, ", ")));
142
  }
143
+
144
  if($orderStatusError) {
145
+ $this->_getSession()->addError($this->_helper()->__("Order owner can not be switched for %s as it can not be processed further.", rtrim($orderStatusErrorMsg, ", ")));
146
  }
147
+
148
  if ($error) {
149
  $this->_getSession()->addError($this->_helper()->__("%s Order were not be updated due to some error.", $error));
150
  }
151
 
152
  $this->_redirect('adminhtml/sales_order/index');
153
  } else {
154
+ $referer = Mage::helper('core/http')->getHttpReferer();
155
 
156
  if ($success) {
157
  $this->_getSession()->addSuccess($this->_helper()->__("Order owner was successfully switched."));
158
  }
159
+
160
  if($websiteError) {
161
+ $this->_getSession()->addError($this->_helper()->__("Order %s owner can not be switched as the selected customer belongs to the different website.", rtrim($websiteErrorMsg, ", ")));
162
  }
163
+
164
  if($orderStatusError) {
165
+ $this->_getSession()->addError($this->_helper()->__("Order %s owner can not be switched as it can not be processed further.", rtrim($orderStatusErrorMsg, ", ")));
166
  }
167
+
168
  if ($error) {
169
  $this->_getSession()->addError($this->_helper()->__("Order was not be updated due to some error."));
170
  }
180
  $this->_redirect('adminhtml/sales_order/index');
181
  }
182
  }
183
+
184
  return;
185
  }
186
  }
app/code/community/Infobeans/Switchowner/etc/config.xml CHANGED
@@ -6,6 +6,9 @@
6
  * @category Infobeans
7
  * @package Infobeans_Switchowner
8
  * @version 1.0.1
 
 
 
9
  * @author InfoBeans Technologies Limited http://www.infobeans.com/
10
  * @copyright Copyright (c) 2016 InfoBeans Technologies Limited
11
  */
@@ -13,7 +16,7 @@
13
  <config>
14
  <modules>
15
  <Infobeans_Switchowner>
16
- <version>1.0.1</version>
17
  </Infobeans_Switchowner>
18
  </modules>
19
  <admin>
6
  * @category Infobeans
7
  * @package Infobeans_Switchowner
8
  * @version 1.0.1
9
+ *
10
+ * Update release with version 1.0.2
11
+ *
12
  * @author InfoBeans Technologies Limited http://www.infobeans.com/
13
  * @copyright Copyright (c) 2016 InfoBeans Technologies Limited
14
  */
16
  <config>
17
  <modules>
18
  <Infobeans_Switchowner>
19
+ <version>1.0.2</version>
20
  </Infobeans_Switchowner>
21
  </modules>
22
  <admin>
app/code/community/Infobeans/Switchowner/sql/switchowner_setup/mysql4-install-1.0.1.php CHANGED
@@ -12,7 +12,8 @@
12
  $installer = $this;
13
 
14
  $installer->startSetup();
15
- $installer->run("
 
16
 
17
  DROP TABLE IF EXISTS {$this->getTable('ib_switchowner_history_details')};
18
  DROP TABLE IF EXISTS {$this->getTable('ib_switchowner_history')};
@@ -37,6 +38,7 @@ CREATE TABLE IF NOT EXISTS {$this->getTable('ib_switchowner_history_details')} (
37
  CONSTRAINT `FK_IB_AORDER_DETAIL_HISTORY` FOREIGN KEY (`history_id`) REFERENCES `{$this->getTable('ib_switchowner_history')}` (`history_id`) ON DELETE CASCADE ON UPDATE CASCADE
38
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
39
 
40
- ");
 
41
 
42
  $installer->endSetup();
12
  $installer = $this;
13
 
14
  $installer->startSetup();
15
+ $installer->run(
16
+ "
17
 
18
  DROP TABLE IF EXISTS {$this->getTable('ib_switchowner_history_details')};
19
  DROP TABLE IF EXISTS {$this->getTable('ib_switchowner_history')};
38
  CONSTRAINT `FK_IB_AORDER_DETAIL_HISTORY` FOREIGN KEY (`history_id`) REFERENCES `{$this->getTable('ib_switchowner_history')}` (`history_id`) ON DELETE CASCADE ON UPDATE CASCADE
39
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
40
 
41
+ "
42
+ );
43
 
44
  $installer->endSetup();
app/design/adminhtml/default/default/template/infobeans/switchowner/order/info.phtml CHANGED
@@ -91,8 +91,9 @@ foreach ($this->getCustomersData() as $key => $value) {
91
  new Ajax.Request(reloadurl, {
92
  method: 'post',
93
  parameters: paramsStr,
 
94
  onComplete: function(transport) {
95
- jQuery('.customer-select').html(transport.responseText);
96
  jQuery('.chosen-select').chosen();
97
  }
98
  });
91
  new Ajax.Request(reloadurl, {
92
  method: 'post',
93
  parameters: paramsStr,
94
+ dataType: "json",
95
  onComplete: function(transport) {
96
+ jQuery('.customer-select').html(transport.responseText.evalJSON(true));
97
  jQuery('.chosen-select').chosen();
98
  }
99
  });
js/infobeans/switchowner/chosen/chosen.jquery.js CHANGED
@@ -8,18 +8,22 @@
8
  * @copyright Copyright (c) 2016 InfoBeans Technologies Limited
9
  */
10
 
11
- (function() {
12
  var $, AbstractChosen, Chosen, SelectParser, _ref,
13
  __hasProp = {}.hasOwnProperty,
14
- __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; };
15
-
16
- SelectParser = (function() {
17
- function SelectParser() {
 
 
 
 
18
  this.options_index = 0;
19
  this.parsed = [];
20
  }
21
 
22
- SelectParser.prototype.add_node = function(child) {
23
  if (child.nodeName.toUpperCase() === "OPTGROUP") {
24
  return this.add_group(child);
25
  } else {
@@ -27,66 +31,77 @@
27
  }
28
  };
29
 
30
- SelectParser.prototype.add_group = function(group) {
31
  var group_position, option, _i, _len, _ref, _results;
32
  group_position = this.parsed.length;
33
- this.parsed.push({
34
- array_index: group_position,
35
- group: true,
36
- label: this.escapeExpression(group.label),
37
- title: group.title ? group.title : void 0,
38
- children: 0,
39
- disabled: group.disabled,
40
- classes: group.className
41
- });
 
 
42
  _ref = group.childNodes;
43
  _results = [];
44
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
45
  option = _ref[_i];
46
  _results.push(this.add_option(option, group_position, group.disabled));
47
  }
 
48
  return _results;
49
  };
50
 
51
- SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
52
  if (option.nodeName.toUpperCase() === "OPTION") {
53
  if (option.text !== "") {
54
  if (group_position != null) {
55
  this.parsed[group_position].children += 1;
56
  }
57
- this.parsed.push({
58
- array_index: this.parsed.length,
59
- options_index: this.options_index,
60
- value: option.value,
61
- text: option.text,
62
- html: option.innerHTML,
63
- title: option.title ? option.title : void 0,
64
- selected: option.selected,
65
- disabled: group_disabled === true ? group_disabled : option.disabled,
66
- group_array_index: group_position,
67
- group_label: group_position != null ? this.parsed[group_position].label : null,
68
- classes: option.className,
69
- style: option.style.cssText
70
- });
 
 
 
71
  } else {
72
- this.parsed.push({
73
- array_index: this.parsed.length,
74
- options_index: this.options_index,
75
- empty: true
76
- });
 
 
77
  }
 
78
  return this.options_index += 1;
79
  }
80
  };
81
 
82
- SelectParser.prototype.escapeExpression = function(text) {
83
  var map, unsafe_chars;
84
  if ((text == null) || text === false) {
85
  return "";
86
  }
 
87
  if (!/[\&\<\>\"\'\`]/.test(text)) {
88
  return text;
89
  }
 
90
  map = {
91
  "<": "&lt;",
92
  ">": "&gt;",
@@ -95,16 +110,18 @@
95
  "`": "&#x60;"
96
  };
97
  unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
98
- return text.replace(unsafe_chars, function(chr) {
99
- return map[chr] || "&amp;";
100
- });
 
 
101
  };
102
 
103
  return SelectParser;
104
 
105
  })();
106
 
107
- SelectParser.select_to_array = function(select) {
108
  var child, parser, _i, _len, _ref;
109
  parser = new SelectParser();
110
  _ref = select.childNodes;
@@ -112,16 +129,19 @@
112
  child = _ref[_i];
113
  parser.add_node(child);
114
  }
 
115
  return parser.parsed;
116
  };
117
 
118
- AbstractChosen = (function() {
119
- function AbstractChosen(form_field, options) {
 
120
  this.form_field = form_field;
121
  this.options = options != null ? options : {};
122
  if (!AbstractChosen.browser_is_supported()) {
123
  return;
124
  }
 
125
  this.is_multiple = this.form_field.multiple;
126
  this.set_default_text();
127
  this.set_default_values();
@@ -131,12 +151,12 @@
131
  this.on_ready();
132
  }
133
 
134
- AbstractChosen.prototype.set_default_values = function() {
135
  var _this = this;
136
- this.click_test_action = function(evt) {
137
  return _this.test_active_click(evt);
138
  };
139
- this.activate_action = function(evt) {
140
  return _this.activate_field(evt);
141
  };
142
  this.active_field = false;
@@ -159,7 +179,7 @@
159
  return this.case_sensitive_search = this.options.case_sensitive_search || false;
160
  };
161
 
162
- AbstractChosen.prototype.set_default_text = function() {
163
  if (this.form_field.getAttribute("data-placeholder")) {
164
  this.default_text = this.form_field.getAttribute("data-placeholder");
165
  } else if (this.is_multiple) {
@@ -167,10 +187,11 @@
167
  } else {
168
  this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
169
  }
 
170
  return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
171
  };
172
 
173
- AbstractChosen.prototype.choice_label = function(item) {
174
  if (this.include_group_label_in_selected && (item.group_label != null)) {
175
  return "<b class='group-name'>" + item.group_label + "</b>" + item.html;
176
  } else {
@@ -178,21 +199,23 @@
178
  }
179
  };
180
 
181
- AbstractChosen.prototype.mouse_enter = function() {
182
  return this.mouse_on_container = true;
183
  };
184
 
185
- AbstractChosen.prototype.mouse_leave = function() {
186
  return this.mouse_on_container = false;
187
  };
188
 
189
- AbstractChosen.prototype.input_focus = function(evt) {
190
  var _this = this;
191
  if (this.is_multiple) {
192
  if (!this.active_field) {
193
- return setTimeout((function() {
194
- return _this.container_mousedown();
195
- }), 50);
 
 
196
  }
197
  } else {
198
  if (!this.active_field) {
@@ -201,17 +224,19 @@
201
  }
202
  };
203
 
204
- AbstractChosen.prototype.input_blur = function(evt) {
205
  var _this = this;
206
  if (!this.mouse_on_container) {
207
  this.active_field = false;
208
- return setTimeout((function() {
209
- return _this.blur_test();
210
- }), 100);
 
 
211
  }
212
  };
213
 
214
- AbstractChosen.prototype.results_option_build = function(options) {
215
  var content, data, data_content, shown_results, _i, _len, _ref;
216
  content = '';
217
  shown_results = 0;
@@ -224,10 +249,12 @@
224
  } else {
225
  data_content = this.result_add_option(data);
226
  }
 
227
  if (data_content !== '') {
228
  shown_results++;
229
  content += data_content;
230
  }
 
231
  if (options != null ? options.first : void 0) {
232
  if (data.selected && this.is_multiple) {
233
  this.choice_build(data);
@@ -235,37 +262,46 @@
235
  this.single_set_selected_text(this.choice_label(data));
236
  }
237
  }
 
238
  if (shown_results >= this.max_shown_results) {
239
  break;
240
  }
241
  }
 
242
  return content;
243
  };
244
 
245
- AbstractChosen.prototype.result_add_option = function(option) {
246
  var classes, option_el;
247
  if (!option.search_match) {
248
  return '';
249
  }
 
250
  if (!this.include_option_in_results(option)) {
251
  return '';
252
  }
 
253
  classes = [];
254
  if (!option.disabled && !(option.selected && this.is_multiple)) {
255
  classes.push("active-result");
256
  }
 
257
  if (option.disabled && !(option.selected && this.is_multiple)) {
258
  classes.push("disabled-result");
259
  }
 
260
  if (option.selected) {
261
  classes.push("result-selected");
262
  }
 
263
  if (option.group_array_index != null) {
264
  classes.push("group-option");
265
  }
 
266
  if (option.classes !== "") {
267
  classes.push(option.classes);
268
  }
 
269
  option_el = document.createElement("li");
270
  option_el.className = classes.join(" ");
271
  option_el.style.cssText = option.style;
@@ -274,36 +310,42 @@
274
  if (option.title) {
275
  option_el.title = option.title;
276
  }
 
277
  return this.outerHTML(option_el);
278
  };
279
 
280
- AbstractChosen.prototype.result_add_group = function(group) {
281
  var classes, group_el;
282
  if (!(group.search_match || group.group_match)) {
283
  return '';
284
  }
 
285
  if (!(group.active_options > 0)) {
286
  return '';
287
  }
 
288
  classes = [];
289
  classes.push("group-result");
290
  if (group.classes) {
291
  classes.push(group.classes);
292
  }
 
293
  group_el = document.createElement("li");
294
  group_el.className = classes.join(" ");
295
  group_el.innerHTML = group.search_text;
296
  if (group.title) {
297
  group_el.title = group.title;
298
  }
 
299
  return this.outerHTML(group_el);
300
  };
301
 
302
- AbstractChosen.prototype.results_update_field = function() {
303
  this.set_default_text();
304
  if (!this.is_multiple) {
305
  this.results_reset_cleanup();
306
  }
 
307
  this.result_clear_highlight();
308
  this.results_build();
309
  if (this.results_showing) {
@@ -311,7 +353,7 @@
311
  }
312
  };
313
 
314
- AbstractChosen.prototype.reset_single_select_options = function() {
315
  var result, _i, _len, _ref, _results;
316
  _ref = this.results_data;
317
  _results = [];
@@ -323,10 +365,11 @@
323
  _results.push(void 0);
324
  }
325
  }
 
326
  return _results;
327
  };
328
 
329
- AbstractChosen.prototype.results_toggle = function() {
330
  if (this.results_showing) {
331
  return this.results_hide();
332
  } else {
@@ -334,7 +377,7 @@
334
  }
335
  };
336
 
337
- AbstractChosen.prototype.results_search = function(evt) {
338
  if (this.results_showing) {
339
  return this.winnow_results();
340
  } else {
@@ -342,7 +385,7 @@
342
  }
343
  };
344
 
345
- AbstractChosen.prototype.winnow_results = function() {
346
  var escapedSearchText, option, regex, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
347
  this.no_results_clear();
348
  results = 0;
@@ -360,25 +403,30 @@
360
  option.group_match = false;
361
  option.active_options = 0;
362
  }
 
363
  if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
364
  results_group = this.results_data[option.group_array_index];
365
  if (results_group.active_options === 0 && results_group.search_match) {
366
  results += 1;
367
  }
 
368
  results_group.active_options += 1;
369
  }
 
370
  option.search_text = option.group ? option.label : option.html;
371
  if (!(option.group && !this.group_search)) {
372
  option.search_match = this.search_string_match(option.search_text, regex);
373
  if (option.search_match && !option.group) {
374
  results += 1;
375
  }
 
376
  if (option.search_match) {
377
  if (searchText.length) {
378
  startpos = option.search_text.search(zregex);
379
  text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
380
  option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
381
  }
 
382
  if (results_group != null) {
383
  results_group.group_match = true;
384
  }
@@ -388,6 +436,7 @@
388
  }
389
  }
390
  }
 
391
  this.result_clear_highlight();
392
  if (results < 1 && searchText.length) {
393
  this.update_results_content("");
@@ -398,14 +447,14 @@
398
  }
399
  };
400
 
401
- AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
402
  var regex_anchor, regex_flag;
403
  regex_anchor = this.search_contains ? "" : "^";
404
  regex_flag = this.case_sensitive_search ? "" : "i";
405
  return new RegExp(regex_anchor + escaped_search_string, regex_flag);
406
  };
407
 
408
- AbstractChosen.prototype.search_string_match = function(search_string, regex) {
409
  var part, parts, _i, _len;
410
  if (regex.test(search_string)) {
411
  return true;
@@ -422,11 +471,12 @@
422
  }
423
  };
424
 
425
- AbstractChosen.prototype.choices_count = function() {
426
  var option, _i, _len, _ref;
427
  if (this.selected_option_count != null) {
428
  return this.selected_option_count;
429
  }
 
430
  this.selected_option_count = 0;
431
  _ref = this.form_field.options;
432
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -435,17 +485,18 @@
435
  this.selected_option_count += 1;
436
  }
437
  }
 
438
  return this.selected_option_count;
439
  };
440
 
441
- AbstractChosen.prototype.choices_click = function(evt) {
442
  evt.preventDefault();
443
  if (!(this.results_showing || this.is_disabled)) {
444
  return this.results_show();
445
  }
446
  };
447
 
448
- AbstractChosen.prototype.keyup_checker = function(evt) {
449
  var stroke, _ref;
450
  stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
451
  this.search_field_scale();
@@ -482,14 +533,16 @@
482
  }
483
  };
484
 
485
- AbstractChosen.prototype.clipboard_event_checker = function(evt) {
486
  var _this = this;
487
- return setTimeout((function() {
488
- return _this.results_search();
489
- }), 50);
 
 
490
  };
491
 
492
- AbstractChosen.prototype.container_width = function() {
493
  if (this.options.width != null) {
494
  return this.options.width;
495
  } else {
@@ -497,52 +550,58 @@
497
  }
498
  };
499
 
500
- AbstractChosen.prototype.include_option_in_results = function(option) {
501
  if (this.is_multiple && (!this.display_selected_options && option.selected)) {
502
  return false;
503
  }
 
504
  if (!this.display_disabled_options && option.disabled) {
505
  return false;
506
  }
 
507
  if (option.empty) {
508
  return false;
509
  }
 
510
  return true;
511
  };
512
 
513
- AbstractChosen.prototype.search_results_touchstart = function(evt) {
514
  this.touch_started = true;
515
  return this.search_results_mouseover(evt);
516
  };
517
 
518
- AbstractChosen.prototype.search_results_touchmove = function(evt) {
519
  this.touch_started = false;
520
  return this.search_results_mouseout(evt);
521
  };
522
 
523
- AbstractChosen.prototype.search_results_touchend = function(evt) {
524
  if (this.touch_started) {
525
  return this.search_results_mouseup(evt);
526
  }
527
  };
528
 
529
- AbstractChosen.prototype.outerHTML = function(element) {
530
  var tmp;
531
  if (element.outerHTML) {
532
  return element.outerHTML;
533
  }
 
534
  tmp = document.createElement("div");
535
  tmp.appendChild(element);
536
  return tmp.innerHTML;
537
  };
538
 
539
- AbstractChosen.browser_is_supported = function() {
540
  if ("Microsoft Internet Explorer" === window.navigator.appName) {
541
  return document.documentMode >= 8;
542
  }
 
543
  if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
544
  return false;
545
  }
 
546
  return true;
547
  };
548
 
@@ -558,52 +617,62 @@
558
 
559
  $ = jQuery;
560
 
561
- $.fn.extend({
562
- chosen: function(options) {
 
563
  if (!AbstractChosen.browser_is_supported()) {
564
  return this;
565
  }
566
- return this.each(function(input_field) {
567
- var $this, chosen;
568
- $this = $(this);
569
- chosen = $this.data('chosen');
570
- if (options === 'destroy') {
 
 
571
  if (chosen instanceof Chosen) {
572
  chosen.destroy();
573
  }
 
574
  return;
575
- }
576
- if (!(chosen instanceof Chosen)) {
 
577
  $this.data('chosen', new Chosen(this, options));
578
- }
579
- });
580
- }
581
- });
 
 
582
 
583
- Chosen = (function(_super) {
584
  __extends(Chosen, _super);
585
 
586
- function Chosen() {
 
587
  _ref = Chosen.__super__.constructor.apply(this, arguments);
588
  return _ref;
589
  }
590
 
591
- Chosen.prototype.setup = function() {
592
  this.form_field_jq = $(this.form_field);
593
  this.current_selectedIndex = this.form_field.selectedIndex;
594
  return this.is_rtl = this.form_field_jq.hasClass("chosen-rtl");
595
  };
596
 
597
- Chosen.prototype.set_up_html = function() {
598
  var container_classes, container_props;
599
  container_classes = ["chosen-container"];
600
  container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
601
  if (this.inherit_select_classes && this.form_field.className) {
602
  container_classes.push(this.form_field.className);
603
  }
 
604
  if (this.is_rtl) {
605
  container_classes.push("chosen-rtl");
606
  }
 
607
  container_props = {
608
  'class': container_classes.join(' '),
609
  'style': "width: " + (this.container_width()) + ";",
@@ -612,12 +681,14 @@
612
  if (this.form_field.id.length) {
613
  container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
614
  }
 
615
  this.container = $("<div />", container_props);
616
  if (this.is_multiple) {
617
  this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>');
618
  } else {
619
  this.container.html('<a class="chosen-single chosen-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>');
620
  }
 
621
  this.form_field_jq.hide().after(this.container);
622
  this.dropdown = this.container.find('div.chosen-drop').first();
623
  this.search_field = this.container.find('input').first();
@@ -631,112 +702,166 @@
631
  this.search_container = this.container.find('div.chosen-search').first();
632
  this.selected_item = this.container.find('.chosen-single').first();
633
  }
 
634
  this.results_build();
635
  this.set_tab_index();
636
  return this.set_label_behavior();
637
  };
638
 
639
- Chosen.prototype.on_ready = function() {
640
- return this.form_field_jq.trigger("chosen:ready", {
641
- chosen: this
642
- });
 
 
643
  };
644
 
645
- Chosen.prototype.register_observers = function() {
646
  var _this = this;
647
- this.container.bind('touchstart.chosen', function(evt) {
648
- _this.container_mousedown(evt);
649
- return evt.preventDefault();
650
- });
651
- this.container.bind('touchend.chosen', function(evt) {
652
- _this.container_mouseup(evt);
653
- return evt.preventDefault();
654
- });
655
- this.container.bind('mousedown.chosen', function(evt) {
656
- _this.container_mousedown(evt);
657
- });
658
- this.container.bind('mouseup.chosen', function(evt) {
659
- _this.container_mouseup(evt);
660
- });
661
- this.container.bind('mouseenter.chosen', function(evt) {
662
- _this.mouse_enter(evt);
663
- });
664
- this.container.bind('mouseleave.chosen', function(evt) {
665
- _this.mouse_leave(evt);
666
- });
667
- this.search_results.bind('mouseup.chosen', function(evt) {
668
- _this.search_results_mouseup(evt);
669
- });
670
- this.search_results.bind('mouseover.chosen', function(evt) {
671
- _this.search_results_mouseover(evt);
672
- });
673
- this.search_results.bind('mouseout.chosen', function(evt) {
674
- _this.search_results_mouseout(evt);
675
- });
676
- this.search_results.bind('mousewheel.chosen DOMMouseScroll.chosen', function(evt) {
677
- _this.search_results_mousewheel(evt);
678
- });
679
- this.search_results.bind('touchstart.chosen', function(evt) {
680
- _this.search_results_touchstart(evt);
681
- });
682
- this.search_results.bind('touchmove.chosen', function(evt) {
683
- _this.search_results_touchmove(evt);
684
- });
685
- this.search_results.bind('touchend.chosen', function(evt) {
686
- _this.search_results_touchend(evt);
687
- });
688
- this.form_field_jq.bind("chosen:updated.chosen", function(evt) {
689
- _this.results_update_field(evt);
690
- });
691
- this.form_field_jq.bind("chosen:activate.chosen", function(evt) {
692
- _this.activate_field(evt);
693
- });
694
- this.form_field_jq.bind("chosen:open.chosen", function(evt) {
695
- _this.container_mousedown(evt);
696
- });
697
- this.form_field_jq.bind("chosen:close.chosen", function(evt) {
698
- _this.input_blur(evt);
699
- });
700
- this.search_field.bind('blur.chosen', function(evt) {
701
- _this.input_blur(evt);
702
- });
703
- this.search_field.bind('keyup.chosen', function(evt) {
704
- _this.keyup_checker(evt);
705
- });
706
- this.search_field.bind('keydown.chosen', function(evt) {
707
- _this.keydown_checker(evt);
708
- });
709
- this.search_field.bind('focus.chosen', function(evt) {
710
- _this.input_focus(evt);
711
- });
712
- this.search_field.bind('cut.chosen', function(evt) {
713
- _this.clipboard_event_checker(evt);
714
- });
715
- this.search_field.bind('paste.chosen', function(evt) {
716
- _this.clipboard_event_checker(evt);
717
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
718
  if (this.is_multiple) {
719
- return this.search_choices.bind('click.chosen', function(evt) {
720
- _this.choices_click(evt);
721
- });
 
 
722
  } else {
723
- return this.container.bind('click.chosen', function(evt) {
724
- evt.preventDefault();
725
- });
 
 
726
  }
727
  };
728
 
729
- Chosen.prototype.destroy = function() {
730
  $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
731
  if (this.search_field[0].tabIndex) {
732
  this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
733
  }
 
734
  this.container.remove();
735
  this.form_field_jq.removeData('chosen');
736
  return this.form_field_jq.show();
737
  };
738
 
739
- Chosen.prototype.search_field_disabled = function() {
740
  this.is_disabled = this.form_field_jq[0].disabled;
741
  if (this.is_disabled) {
742
  this.container.addClass('chosen-disabled');
@@ -744,6 +869,7 @@
744
  if (!this.is_multiple) {
745
  this.selected_item.unbind("focus.chosen", this.activate_action);
746
  }
 
747
  return this.close_field();
748
  } else {
749
  this.container.removeClass('chosen-disabled');
@@ -754,54 +880,59 @@
754
  }
755
  };
756
 
757
- Chosen.prototype.container_mousedown = function(evt) {
758
  if (!this.is_disabled) {
759
  if (evt && evt.type === "mousedown" && !this.results_showing) {
760
  evt.preventDefault();
761
  }
 
762
  if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
763
  if (!this.active_field) {
764
  if (this.is_multiple) {
765
  this.search_field.val("");
766
  }
 
767
  $(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
768
  this.results_show();
769
  } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
770
  evt.preventDefault();
771
  this.results_toggle();
772
  }
 
773
  return this.activate_field();
774
  }
775
  }
776
  };
777
 
778
- Chosen.prototype.container_mouseup = function(evt) {
779
  if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
780
  return this.results_reset(evt);
781
  }
782
  };
783
 
784
- Chosen.prototype.search_results_mousewheel = function(evt) {
785
  var delta;
786
  if (evt.originalEvent) {
787
  delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
788
  }
 
789
  if (delta != null) {
790
  evt.preventDefault();
791
  if (evt.type === 'DOMMouseScroll') {
792
  delta = delta * 40;
793
  }
 
794
  return this.search_results.scrollTop(delta + this.search_results.scrollTop());
795
  }
796
  };
797
 
798
- Chosen.prototype.blur_test = function(evt) {
799
  if (!this.active_field && this.container.hasClass("chosen-container-active")) {
800
  return this.close_field();
801
  }
802
  };
803
 
804
- Chosen.prototype.close_field = function() {
805
  $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
806
  this.active_field = false;
807
  this.results_hide();
@@ -811,14 +942,14 @@
811
  return this.search_field_scale();
812
  };
813
 
814
- Chosen.prototype.activate_field = function() {
815
  this.container.addClass("chosen-container-active");
816
  this.active_field = true;
817
  this.search_field.val(this.search_field.val());
818
  return this.search_field.focus();
819
  };
820
 
821
- Chosen.prototype.test_active_click = function(evt) {
822
  var active_container;
823
  active_container = $(evt.target).closest('.chosen-container');
824
  if (active_container.length && this.container[0] === active_container[0]) {
@@ -828,7 +959,7 @@
828
  }
829
  };
830
 
831
- Chosen.prototype.results_build = function() {
832
  this.parsing = true;
833
  this.selected_option_count = null;
834
  this.results_data = SelectParser.select_to_array(this.form_field);
@@ -844,16 +975,21 @@
844
  this.container.removeClass("chosen-container-single-nosearch");
845
  }
846
  }
847
- this.update_results_content(this.results_option_build({
848
- first: true
849
- }));
 
 
 
 
 
850
  this.search_field_disabled();
851
  this.show_search_field_default();
852
  this.search_field_scale();
853
  return this.parsing = false;
854
  };
855
 
856
- Chosen.prototype.result_do_highlight = function(el) {
857
  var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
858
  if (el.length) {
859
  this.result_clear_highlight();
@@ -872,46 +1008,55 @@
872
  }
873
  };
874
 
875
- Chosen.prototype.result_clear_highlight = function() {
876
  if (this.result_highlight) {
877
  this.result_highlight.removeClass("highlighted");
878
  }
 
879
  return this.result_highlight = null;
880
  };
881
 
882
- Chosen.prototype.results_show = function() {
883
  if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
884
- this.form_field_jq.trigger("chosen:maxselected", {
885
- chosen: this
886
- });
 
 
887
  return false;
888
  }
 
889
  this.container.addClass("chosen-with-drop");
890
  this.results_showing = true;
891
  this.search_field.focus();
892
  this.search_field.val(this.search_field.val());
893
  this.winnow_results();
894
- return this.form_field_jq.trigger("chosen:showing_dropdown", {
895
- chosen: this
896
- });
 
 
897
  };
898
 
899
- Chosen.prototype.update_results_content = function(content) {
900
  return this.search_results.html(content);
901
  };
902
 
903
- Chosen.prototype.results_hide = function() {
904
  if (this.results_showing) {
905
  this.result_clear_highlight();
906
  this.container.removeClass("chosen-with-drop");
907
- this.form_field_jq.trigger("chosen:hiding_dropdown", {
908
- chosen: this
909
- });
 
 
910
  }
 
911
  return this.results_showing = false;
912
  };
913
 
914
- Chosen.prototype.set_tab_index = function(el) {
915
  var ti;
916
  if (this.form_field.tabIndex) {
917
  ti = this.form_field.tabIndex;
@@ -920,24 +1065,27 @@
920
  }
921
  };
922
 
923
- Chosen.prototype.set_label_behavior = function() {
924
  var _this = this;
925
  this.form_field_label = this.form_field_jq.parents("label");
926
  if (!this.form_field_label.length && this.form_field.id.length) {
927
  this.form_field_label = $("label[for='" + this.form_field.id + "']");
928
  }
 
929
  if (this.form_field_label.length > 0) {
930
- return this.form_field_label.bind('click.chosen', function(evt) {
931
- if (_this.is_multiple) {
 
932
  return _this.container_mousedown(evt);
933
- } else {
934
  return _this.activate_field();
935
- }
936
- });
 
937
  }
938
  };
939
 
940
- Chosen.prototype.show_search_field_default = function() {
941
  if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
942
  this.search_field.val(this.default_text);
943
  return this.search_field.addClass("default");
@@ -947,7 +1095,7 @@
947
  }
948
  };
949
 
950
- Chosen.prototype.search_results_mouseup = function(evt) {
951
  var target;
952
  target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
953
  if (target.length) {
@@ -957,7 +1105,7 @@
957
  }
958
  };
959
 
960
- Chosen.prototype.search_results_mouseover = function(evt) {
961
  var target;
962
  target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
963
  if (target) {
@@ -965,34 +1113,41 @@
965
  }
966
  };
967
 
968
- Chosen.prototype.search_results_mouseout = function(evt) {
969
  if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
970
  return this.result_clear_highlight();
971
  }
972
  };
973
 
974
- Chosen.prototype.choice_build = function(item) {
975
  var choice, close_link,
976
  _this = this;
977
- choice = $('<li />', {
978
- "class": "search-choice"
979
- }).html("<span>" + (this.choice_label(item)) + "</span>");
 
 
980
  if (item.disabled) {
981
  choice.addClass('search-choice-disabled');
982
  } else {
983
- close_link = $('<a />', {
984
- "class": 'search-choice-close',
985
- 'data-option-array-index': item.array_index
986
- });
987
- close_link.bind('click.chosen', function(evt) {
988
- return _this.choice_destroy_link_click(evt);
989
- });
 
 
 
 
990
  choice.append(close_link);
991
  }
 
992
  return this.search_container.before(choice);
993
  };
994
 
995
- Chosen.prototype.choice_destroy_link_click = function(evt) {
996
  evt.preventDefault();
997
  evt.stopPropagation();
998
  if (!this.is_disabled) {
@@ -1000,18 +1155,19 @@
1000
  }
1001
  };
1002
 
1003
- Chosen.prototype.choice_destroy = function(link) {
1004
  if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
1005
  this.show_search_field_default();
1006
  if (this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1) {
1007
  this.results_hide();
1008
  }
 
1009
  link.parents('li').first().remove();
1010
  return this.search_field_scale();
1011
  }
1012
  };
1013
 
1014
- Chosen.prototype.results_reset = function() {
1015
  this.reset_single_select_options();
1016
  this.form_field.options[0].selected = true;
1017
  this.single_set_selected_text();
@@ -1023,27 +1179,31 @@
1023
  }
1024
  };
1025
 
1026
- Chosen.prototype.results_reset_cleanup = function() {
1027
  this.current_selectedIndex = this.form_field.selectedIndex;
1028
  return this.selected_item.find("abbr").remove();
1029
  };
1030
 
1031
- Chosen.prototype.result_select = function(evt) {
1032
  var high, item;
1033
  if (this.result_highlight) {
1034
  high = this.result_highlight;
1035
  this.result_clear_highlight();
1036
  if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
1037
- this.form_field_jq.trigger("chosen:maxselected", {
1038
- chosen: this
1039
- });
 
 
1040
  return false;
1041
  }
 
1042
  if (this.is_multiple) {
1043
  high.removeClass("active-result");
1044
  } else {
1045
  this.reset_single_select_options();
1046
  }
 
1047
  high.addClass("result-selected");
1048
  item = this.results_data[high[0].getAttribute("data-option-array-index")];
1049
  item.selected = true;
@@ -1054,35 +1214,42 @@
1054
  } else {
1055
  this.single_set_selected_text(this.choice_label(item));
1056
  }
 
1057
  if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
1058
  this.results_hide();
1059
  }
 
1060
  this.show_search_field_default();
1061
  if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
1062
- this.form_field_jq.trigger("change", {
1063
- 'selected': this.form_field.options[item.options_index].value
1064
- });
 
 
1065
  }
 
1066
  this.current_selectedIndex = this.form_field.selectedIndex;
1067
  evt.preventDefault();
1068
  return this.search_field_scale();
1069
  }
1070
  };
1071
 
1072
- Chosen.prototype.single_set_selected_text = function(text) {
1073
  if (text == null) {
1074
  text = this.default_text;
1075
  }
 
1076
  if (text === this.default_text) {
1077
  this.selected_item.addClass("chosen-default");
1078
  } else {
1079
  this.single_deselect_control_build();
1080
  this.selected_item.removeClass("chosen-default");
1081
  }
 
1082
  return this.selected_item.find("span").html(text);
1083
  };
1084
 
1085
- Chosen.prototype.result_deselect = function(pos) {
1086
  var result_data;
1087
  result_data = this.results_data[pos];
1088
  if (!this.form_field.options[result_data.options_index].disabled) {
@@ -1093,9 +1260,12 @@
1093
  if (this.results_showing) {
1094
  this.winnow_results();
1095
  }
1096
- this.form_field_jq.trigger("change", {
1097
- deselected: this.form_field.options[result_data.options_index].value
1098
- });
 
 
 
1099
  this.search_field_scale();
1100
  return true;
1101
  } else {
@@ -1103,21 +1273,23 @@
1103
  }
1104
  };
1105
 
1106
- Chosen.prototype.single_deselect_control_build = function() {
1107
  if (!this.allow_single_deselect) {
1108
  return;
1109
  }
 
1110
  if (!this.selected_item.find("abbr").length) {
1111
  this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
1112
  }
 
1113
  return this.selected_item.addClass("chosen-single-with-deselect");
1114
  };
1115
 
1116
- Chosen.prototype.get_search_text = function() {
1117
  return $('<div/>').text($.trim(this.search_field.val())).html();
1118
  };
1119
 
1120
- Chosen.prototype.winnow_results_set_highlight = function() {
1121
  var do_high, selected_results;
1122
  selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
1123
  do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
@@ -1126,21 +1298,23 @@
1126
  }
1127
  };
1128
 
1129
- Chosen.prototype.no_results = function(terms) {
1130
  var no_results_html;
1131
  no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
1132
  no_results_html.find("span").first().html(terms);
1133
  this.search_results.append(no_results_html);
1134
- return this.form_field_jq.trigger("chosen:no_results", {
1135
- chosen: this
1136
- });
 
 
1137
  };
1138
 
1139
- Chosen.prototype.no_results_clear = function() {
1140
  return this.search_results.find(".no-results").remove();
1141
  };
1142
 
1143
- Chosen.prototype.keydown_arrow = function() {
1144
  var next_sib;
1145
  if (this.results_showing && this.result_highlight) {
1146
  next_sib = this.result_highlight.nextAll("li.active-result").first();
@@ -1152,7 +1326,7 @@
1152
  }
1153
  };
1154
 
1155
- Chosen.prototype.keyup_arrow = function() {
1156
  var prev_sibs;
1157
  if (!this.results_showing && !this.is_multiple) {
1158
  return this.results_show();
@@ -1164,12 +1338,13 @@
1164
  if (this.choices_count() > 0) {
1165
  this.results_hide();
1166
  }
 
1167
  return this.result_clear_highlight();
1168
  }
1169
  }
1170
  };
1171
 
1172
- Chosen.prototype.keydown_backstroke = function() {
1173
  var next_available_destroy;
1174
  if (this.pending_backstroke) {
1175
  this.choice_destroy(this.pending_backstroke.find("a").first());
@@ -1187,20 +1362,22 @@
1187
  }
1188
  };
1189
 
1190
- Chosen.prototype.clear_backstroke = function() {
1191
  if (this.pending_backstroke) {
1192
  this.pending_backstroke.removeClass("search-choice-focus");
1193
  }
 
1194
  return this.pending_backstroke = null;
1195
  };
1196
 
1197
- Chosen.prototype.keydown_checker = function(evt) {
1198
  var stroke, _ref1;
1199
  stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1200
  this.search_field_scale();
1201
  if (stroke !== 8 && this.pending_backstroke) {
1202
  this.clear_backstroke();
1203
  }
 
1204
  switch (stroke) {
1205
  case 8:
1206
  this.backstroke_length = this.search_field.val().length;
@@ -1209,6 +1386,7 @@
1209
  if (this.results_showing && !this.is_multiple) {
1210
  this.result_select(evt);
1211
  }
 
1212
  this.mouse_on_container = false;
1213
  break;
1214
  case 13:
@@ -1232,7 +1410,7 @@
1232
  }
1233
  };
1234
 
1235
- Chosen.prototype.search_field_scale = function() {
1236
  var div, f_width, h, style, style_block, styles, w, _i, _len;
1237
  if (this.is_multiple) {
1238
  h = 0;
@@ -1243,9 +1421,12 @@
1243
  style = styles[_i];
1244
  style_block += style + ":" + this.search_field.css(style) + ";";
1245
  }
1246
- div = $('<div />', {
1247
- 'style': style_block
1248
- });
 
 
 
1249
  div.text(this.search_field.val());
1250
  $('body').append(div);
1251
  w = div.width() + 25;
@@ -1254,9 +1435,12 @@
1254
  if (w > f_width - 10) {
1255
  w = f_width - 10;
1256
  }
1257
- return this.search_field.css({
1258
- 'width': w + 'px'
1259
- });
 
 
 
1260
  }
1261
  };
1262
 
8
  * @copyright Copyright (c) 2016 InfoBeans Technologies Limited
9
  */
10
 
11
+ (function () {
12
  var $, AbstractChosen, Chosen, SelectParser, _ref,
13
  __hasProp = {}.hasOwnProperty,
14
+ __extends = function (child, parent) {
15
+ for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor()
16
+ {
17
+ this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
18
+
19
+ SelectParser = (function () {
20
+ function SelectParser()
21
+ {
22
  this.options_index = 0;
23
  this.parsed = [];
24
  }
25
 
26
+ SelectParser.prototype.add_node = function (child) {
27
  if (child.nodeName.toUpperCase() === "OPTGROUP") {
28
  return this.add_group(child);
29
  } else {
31
  }
32
  };
33
 
34
+ SelectParser.prototype.add_group = function (group) {
35
  var group_position, option, _i, _len, _ref, _results;
36
  group_position = this.parsed.length;
37
+ this.parsed.push(
38
+ {
39
+ array_index: group_position,
40
+ group: true,
41
+ label: this.escapeExpression(group.label),
42
+ title: group.title ? group.title : void 0,
43
+ children: 0,
44
+ disabled: group.disabled,
45
+ classes: group.className
46
+ }
47
+ );
48
  _ref = group.childNodes;
49
  _results = [];
50
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
51
  option = _ref[_i];
52
  _results.push(this.add_option(option, group_position, group.disabled));
53
  }
54
+
55
  return _results;
56
  };
57
 
58
+ SelectParser.prototype.add_option = function (option, group_position, group_disabled) {
59
  if (option.nodeName.toUpperCase() === "OPTION") {
60
  if (option.text !== "") {
61
  if (group_position != null) {
62
  this.parsed[group_position].children += 1;
63
  }
64
+
65
+ this.parsed.push(
66
+ {
67
+ array_index: this.parsed.length,
68
+ options_index: this.options_index,
69
+ value: option.value,
70
+ text: option.text,
71
+ html: option.innerHTML,
72
+ title: option.title ? option.title : void 0,
73
+ selected: option.selected,
74
+ disabled: group_disabled === true ? group_disabled : option.disabled,
75
+ group_array_index: group_position,
76
+ group_label: group_position != null ? this.parsed[group_position].label : null,
77
+ classes: option.className,
78
+ style: option.style.cssText
79
+ }
80
+ );
81
  } else {
82
+ this.parsed.push(
83
+ {
84
+ array_index: this.parsed.length,
85
+ options_index: this.options_index,
86
+ empty: true
87
+ }
88
+ );
89
  }
90
+
91
  return this.options_index += 1;
92
  }
93
  };
94
 
95
+ SelectParser.prototype.escapeExpression = function (text) {
96
  var map, unsafe_chars;
97
  if ((text == null) || text === false) {
98
  return "";
99
  }
100
+
101
  if (!/[\&\<\>\"\'\`]/.test(text)) {
102
  return text;
103
  }
104
+
105
  map = {
106
  "<": "&lt;",
107
  ">": "&gt;",
110
  "`": "&#x60;"
111
  };
112
  unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
113
+ return text.replace(
114
+ unsafe_chars, function (chr) {
115
+ return map[chr] || "&amp;";
116
+ }
117
+ );
118
  };
119
 
120
  return SelectParser;
121
 
122
  })();
123
 
124
+ SelectParser.select_to_array = function (select) {
125
  var child, parser, _i, _len, _ref;
126
  parser = new SelectParser();
127
  _ref = select.childNodes;
129
  child = _ref[_i];
130
  parser.add_node(child);
131
  }
132
+
133
  return parser.parsed;
134
  };
135
 
136
+ AbstractChosen = (function () {
137
+ function AbstractChosen(form_field, options)
138
+ {
139
  this.form_field = form_field;
140
  this.options = options != null ? options : {};
141
  if (!AbstractChosen.browser_is_supported()) {
142
  return;
143
  }
144
+
145
  this.is_multiple = this.form_field.multiple;
146
  this.set_default_text();
147
  this.set_default_values();
151
  this.on_ready();
152
  }
153
 
154
+ AbstractChosen.prototype.set_default_values = function () {
155
  var _this = this;
156
+ this.click_test_action = function (evt) {
157
  return _this.test_active_click(evt);
158
  };
159
+ this.activate_action = function (evt) {
160
  return _this.activate_field(evt);
161
  };
162
  this.active_field = false;
179
  return this.case_sensitive_search = this.options.case_sensitive_search || false;
180
  };
181
 
182
+ AbstractChosen.prototype.set_default_text = function () {
183
  if (this.form_field.getAttribute("data-placeholder")) {
184
  this.default_text = this.form_field.getAttribute("data-placeholder");
185
  } else if (this.is_multiple) {
187
  } else {
188
  this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
189
  }
190
+
191
  return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
192
  };
193
 
194
+ AbstractChosen.prototype.choice_label = function (item) {
195
  if (this.include_group_label_in_selected && (item.group_label != null)) {
196
  return "<b class='group-name'>" + item.group_label + "</b>" + item.html;
197
  } else {
199
  }
200
  };
201
 
202
+ AbstractChosen.prototype.mouse_enter = function () {
203
  return this.mouse_on_container = true;
204
  };
205
 
206
+ AbstractChosen.prototype.mouse_leave = function () {
207
  return this.mouse_on_container = false;
208
  };
209
 
210
+ AbstractChosen.prototype.input_focus = function (evt) {
211
  var _this = this;
212
  if (this.is_multiple) {
213
  if (!this.active_field) {
214
+ return setTimeout(
215
+ (function () {
216
+ return _this.container_mousedown();
217
+ }), 50
218
+ );
219
  }
220
  } else {
221
  if (!this.active_field) {
224
  }
225
  };
226
 
227
+ AbstractChosen.prototype.input_blur = function (evt) {
228
  var _this = this;
229
  if (!this.mouse_on_container) {
230
  this.active_field = false;
231
+ return setTimeout(
232
+ (function () {
233
+ return _this.blur_test();
234
+ }), 100
235
+ );
236
  }
237
  };
238
 
239
+ AbstractChosen.prototype.results_option_build = function (options) {
240
  var content, data, data_content, shown_results, _i, _len, _ref;
241
  content = '';
242
  shown_results = 0;
249
  } else {
250
  data_content = this.result_add_option(data);
251
  }
252
+
253
  if (data_content !== '') {
254
  shown_results++;
255
  content += data_content;
256
  }
257
+
258
  if (options != null ? options.first : void 0) {
259
  if (data.selected && this.is_multiple) {
260
  this.choice_build(data);
262
  this.single_set_selected_text(this.choice_label(data));
263
  }
264
  }
265
+
266
  if (shown_results >= this.max_shown_results) {
267
  break;
268
  }
269
  }
270
+
271
  return content;
272
  };
273
 
274
+ AbstractChosen.prototype.result_add_option = function (option) {
275
  var classes, option_el;
276
  if (!option.search_match) {
277
  return '';
278
  }
279
+
280
  if (!this.include_option_in_results(option)) {
281
  return '';
282
  }
283
+
284
  classes = [];
285
  if (!option.disabled && !(option.selected && this.is_multiple)) {
286
  classes.push("active-result");
287
  }
288
+
289
  if (option.disabled && !(option.selected && this.is_multiple)) {
290
  classes.push("disabled-result");
291
  }
292
+
293
  if (option.selected) {
294
  classes.push("result-selected");
295
  }
296
+
297
  if (option.group_array_index != null) {
298
  classes.push("group-option");
299
  }
300
+
301
  if (option.classes !== "") {
302
  classes.push(option.classes);
303
  }
304
+
305
  option_el = document.createElement("li");
306
  option_el.className = classes.join(" ");
307
  option_el.style.cssText = option.style;
310
  if (option.title) {
311
  option_el.title = option.title;
312
  }
313
+
314
  return this.outerHTML(option_el);
315
  };
316
 
317
+ AbstractChosen.prototype.result_add_group = function (group) {
318
  var classes, group_el;
319
  if (!(group.search_match || group.group_match)) {
320
  return '';
321
  }
322
+
323
  if (!(group.active_options > 0)) {
324
  return '';
325
  }
326
+
327
  classes = [];
328
  classes.push("group-result");
329
  if (group.classes) {
330
  classes.push(group.classes);
331
  }
332
+
333
  group_el = document.createElement("li");
334
  group_el.className = classes.join(" ");
335
  group_el.innerHTML = group.search_text;
336
  if (group.title) {
337
  group_el.title = group.title;
338
  }
339
+
340
  return this.outerHTML(group_el);
341
  };
342
 
343
+ AbstractChosen.prototype.results_update_field = function () {
344
  this.set_default_text();
345
  if (!this.is_multiple) {
346
  this.results_reset_cleanup();
347
  }
348
+
349
  this.result_clear_highlight();
350
  this.results_build();
351
  if (this.results_showing) {
353
  }
354
  };
355
 
356
+ AbstractChosen.prototype.reset_single_select_options = function () {
357
  var result, _i, _len, _ref, _results;
358
  _ref = this.results_data;
359
  _results = [];
365
  _results.push(void 0);
366
  }
367
  }
368
+
369
  return _results;
370
  };
371
 
372
+ AbstractChosen.prototype.results_toggle = function () {
373
  if (this.results_showing) {
374
  return this.results_hide();
375
  } else {
377
  }
378
  };
379
 
380
+ AbstractChosen.prototype.results_search = function (evt) {
381
  if (this.results_showing) {
382
  return this.winnow_results();
383
  } else {
385
  }
386
  };
387
 
388
+ AbstractChosen.prototype.winnow_results = function () {
389
  var escapedSearchText, option, regex, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
390
  this.no_results_clear();
391
  results = 0;
403
  option.group_match = false;
404
  option.active_options = 0;
405
  }
406
+
407
  if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
408
  results_group = this.results_data[option.group_array_index];
409
  if (results_group.active_options === 0 && results_group.search_match) {
410
  results += 1;
411
  }
412
+
413
  results_group.active_options += 1;
414
  }
415
+
416
  option.search_text = option.group ? option.label : option.html;
417
  if (!(option.group && !this.group_search)) {
418
  option.search_match = this.search_string_match(option.search_text, regex);
419
  if (option.search_match && !option.group) {
420
  results += 1;
421
  }
422
+
423
  if (option.search_match) {
424
  if (searchText.length) {
425
  startpos = option.search_text.search(zregex);
426
  text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
427
  option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
428
  }
429
+
430
  if (results_group != null) {
431
  results_group.group_match = true;
432
  }
436
  }
437
  }
438
  }
439
+
440
  this.result_clear_highlight();
441
  if (results < 1 && searchText.length) {
442
  this.update_results_content("");
447
  }
448
  };
449
 
450
+ AbstractChosen.prototype.get_search_regex = function (escaped_search_string) {
451
  var regex_anchor, regex_flag;
452
  regex_anchor = this.search_contains ? "" : "^";
453
  regex_flag = this.case_sensitive_search ? "" : "i";
454
  return new RegExp(regex_anchor + escaped_search_string, regex_flag);
455
  };
456
 
457
+ AbstractChosen.prototype.search_string_match = function (search_string, regex) {
458
  var part, parts, _i, _len;
459
  if (regex.test(search_string)) {
460
  return true;
471
  }
472
  };
473
 
474
+ AbstractChosen.prototype.choices_count = function () {
475
  var option, _i, _len, _ref;
476
  if (this.selected_option_count != null) {
477
  return this.selected_option_count;
478
  }
479
+
480
  this.selected_option_count = 0;
481
  _ref = this.form_field.options;
482
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
485
  this.selected_option_count += 1;
486
  }
487
  }
488
+
489
  return this.selected_option_count;
490
  };
491
 
492
+ AbstractChosen.prototype.choices_click = function (evt) {
493
  evt.preventDefault();
494
  if (!(this.results_showing || this.is_disabled)) {
495
  return this.results_show();
496
  }
497
  };
498
 
499
+ AbstractChosen.prototype.keyup_checker = function (evt) {
500
  var stroke, _ref;
501
  stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
502
  this.search_field_scale();
533
  }
534
  };
535
 
536
+ AbstractChosen.prototype.clipboard_event_checker = function (evt) {
537
  var _this = this;
538
+ return setTimeout(
539
+ (function () {
540
+ return _this.results_search();
541
+ }), 50
542
+ );
543
  };
544
 
545
+ AbstractChosen.prototype.container_width = function () {
546
  if (this.options.width != null) {
547
  return this.options.width;
548
  } else {
550
  }
551
  };
552
 
553
+ AbstractChosen.prototype.include_option_in_results = function (option) {
554
  if (this.is_multiple && (!this.display_selected_options && option.selected)) {
555
  return false;
556
  }
557
+
558
  if (!this.display_disabled_options && option.disabled) {
559
  return false;
560
  }
561
+
562
  if (option.empty) {
563
  return false;
564
  }
565
+
566
  return true;
567
  };
568
 
569
+ AbstractChosen.prototype.search_results_touchstart = function (evt) {
570
  this.touch_started = true;
571
  return this.search_results_mouseover(evt);
572
  };
573
 
574
+ AbstractChosen.prototype.search_results_touchmove = function (evt) {
575
  this.touch_started = false;
576
  return this.search_results_mouseout(evt);
577
  };
578
 
579
+ AbstractChosen.prototype.search_results_touchend = function (evt) {
580
  if (this.touch_started) {
581
  return this.search_results_mouseup(evt);
582
  }
583
  };
584
 
585
+ AbstractChosen.prototype.outerHTML = function (element) {
586
  var tmp;
587
  if (element.outerHTML) {
588
  return element.outerHTML;
589
  }
590
+
591
  tmp = document.createElement("div");
592
  tmp.appendChild(element);
593
  return tmp.innerHTML;
594
  };
595
 
596
+ AbstractChosen.browser_is_supported = function () {
597
  if ("Microsoft Internet Explorer" === window.navigator.appName) {
598
  return document.documentMode >= 8;
599
  }
600
+
601
  if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
602
  return false;
603
  }
604
+
605
  return true;
606
  };
607
 
617
 
618
  $ = jQuery;
619
 
620
+ $.fn.extend(
621
+ {
622
+ chosen: function (options) {
623
  if (!AbstractChosen.browser_is_supported()) {
624
  return this;
625
  }
626
+
627
+ return this.each(
628
+ function (input_field) {
629
+ var $this, chosen;
630
+ $this = $(this);
631
+ chosen = $this.data('chosen');
632
+ if (options === 'destroy') {
633
  if (chosen instanceof Chosen) {
634
  chosen.destroy();
635
  }
636
+
637
  return;
638
+ }
639
+
640
+ if (!(chosen instanceof Chosen)) {
641
  $this.data('chosen', new Chosen(this, options));
642
+ }
643
+ }
644
+ );
645
+ }
646
+ }
647
+ );
648
 
649
+ Chosen = (function (_super) {
650
  __extends(Chosen, _super);
651
 
652
+ function Chosen()
653
+ {
654
  _ref = Chosen.__super__.constructor.apply(this, arguments);
655
  return _ref;
656
  }
657
 
658
+ Chosen.prototype.setup = function () {
659
  this.form_field_jq = $(this.form_field);
660
  this.current_selectedIndex = this.form_field.selectedIndex;
661
  return this.is_rtl = this.form_field_jq.hasClass("chosen-rtl");
662
  };
663
 
664
+ Chosen.prototype.set_up_html = function () {
665
  var container_classes, container_props;
666
  container_classes = ["chosen-container"];
667
  container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
668
  if (this.inherit_select_classes && this.form_field.className) {
669
  container_classes.push(this.form_field.className);
670
  }
671
+
672
  if (this.is_rtl) {
673
  container_classes.push("chosen-rtl");
674
  }
675
+
676
  container_props = {
677
  'class': container_classes.join(' '),
678
  'style': "width: " + (this.container_width()) + ";",
681
  if (this.form_field.id.length) {
682
  container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
683
  }
684
+
685
  this.container = $("<div />", container_props);
686
  if (this.is_multiple) {
687
  this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>');
688
  } else {
689
  this.container.html('<a class="chosen-single chosen-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>');
690
  }
691
+
692
  this.form_field_jq.hide().after(this.container);
693
  this.dropdown = this.container.find('div.chosen-drop').first();
694
  this.search_field = this.container.find('input').first();
702
  this.search_container = this.container.find('div.chosen-search').first();
703
  this.selected_item = this.container.find('.chosen-single').first();
704
  }
705
+
706
  this.results_build();
707
  this.set_tab_index();
708
  return this.set_label_behavior();
709
  };
710
 
711
+ Chosen.prototype.on_ready = function () {
712
+ return this.form_field_jq.trigger(
713
+ "chosen:ready", {
714
+ chosen: this
715
+ }
716
+ );
717
  };
718
 
719
+ Chosen.prototype.register_observers = function () {
720
  var _this = this;
721
+ this.container.bind(
722
+ 'touchstart.chosen', function (evt) {
723
+ _this.container_mousedown(evt);
724
+ return evt.preventDefault();
725
+ }
726
+ );
727
+ this.container.bind(
728
+ 'touchend.chosen', function (evt) {
729
+ _this.container_mouseup(evt);
730
+ return evt.preventDefault();
731
+ }
732
+ );
733
+ this.container.bind(
734
+ 'mousedown.chosen', function (evt) {
735
+ _this.container_mousedown(evt);
736
+ }
737
+ );
738
+ this.container.bind(
739
+ 'mouseup.chosen', function (evt) {
740
+ _this.container_mouseup(evt);
741
+ }
742
+ );
743
+ this.container.bind(
744
+ 'mouseenter.chosen', function (evt) {
745
+ _this.mouse_enter(evt);
746
+ }
747
+ );
748
+ this.container.bind(
749
+ 'mouseleave.chosen', function (evt) {
750
+ _this.mouse_leave(evt);
751
+ }
752
+ );
753
+ this.search_results.bind(
754
+ 'mouseup.chosen', function (evt) {
755
+ _this.search_results_mouseup(evt);
756
+ }
757
+ );
758
+ this.search_results.bind(
759
+ 'mouseover.chosen', function (evt) {
760
+ _this.search_results_mouseover(evt);
761
+ }
762
+ );
763
+ this.search_results.bind(
764
+ 'mouseout.chosen', function (evt) {
765
+ _this.search_results_mouseout(evt);
766
+ }
767
+ );
768
+ this.search_results.bind(
769
+ 'mousewheel.chosen DOMMouseScroll.chosen', function (evt) {
770
+ _this.search_results_mousewheel(evt);
771
+ }
772
+ );
773
+ this.search_results.bind(
774
+ 'touchstart.chosen', function (evt) {
775
+ _this.search_results_touchstart(evt);
776
+ }
777
+ );
778
+ this.search_results.bind(
779
+ 'touchmove.chosen', function (evt) {
780
+ _this.search_results_touchmove(evt);
781
+ }
782
+ );
783
+ this.search_results.bind(
784
+ 'touchend.chosen', function (evt) {
785
+ _this.search_results_touchend(evt);
786
+ }
787
+ );
788
+ this.form_field_jq.bind(
789
+ "chosen:updated.chosen", function (evt) {
790
+ _this.results_update_field(evt);
791
+ }
792
+ );
793
+ this.form_field_jq.bind(
794
+ "chosen:activate.chosen", function (evt) {
795
+ _this.activate_field(evt);
796
+ }
797
+ );
798
+ this.form_field_jq.bind(
799
+ "chosen:open.chosen", function (evt) {
800
+ _this.container_mousedown(evt);
801
+ }
802
+ );
803
+ this.form_field_jq.bind(
804
+ "chosen:close.chosen", function (evt) {
805
+ _this.input_blur(evt);
806
+ }
807
+ );
808
+ this.search_field.bind(
809
+ 'blur.chosen', function (evt) {
810
+ _this.input_blur(evt);
811
+ }
812
+ );
813
+ this.search_field.bind(
814
+ 'keyup.chosen', function (evt) {
815
+ _this.keyup_checker(evt);
816
+ }
817
+ );
818
+ this.search_field.bind(
819
+ 'keydown.chosen', function (evt) {
820
+ _this.keydown_checker(evt);
821
+ }
822
+ );
823
+ this.search_field.bind(
824
+ 'focus.chosen', function (evt) {
825
+ _this.input_focus(evt);
826
+ }
827
+ );
828
+ this.search_field.bind(
829
+ 'cut.chosen', function (evt) {
830
+ _this.clipboard_event_checker(evt);
831
+ }
832
+ );
833
+ this.search_field.bind(
834
+ 'paste.chosen', function (evt) {
835
+ _this.clipboard_event_checker(evt);
836
+ }
837
+ );
838
  if (this.is_multiple) {
839
+ return this.search_choices.bind(
840
+ 'click.chosen', function (evt) {
841
+ _this.choices_click(evt);
842
+ }
843
+ );
844
  } else {
845
+ return this.container.bind(
846
+ 'click.chosen', function (evt) {
847
+ evt.preventDefault();
848
+ }
849
+ );
850
  }
851
  };
852
 
853
+ Chosen.prototype.destroy = function () {
854
  $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
855
  if (this.search_field[0].tabIndex) {
856
  this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
857
  }
858
+
859
  this.container.remove();
860
  this.form_field_jq.removeData('chosen');
861
  return this.form_field_jq.show();
862
  };
863
 
864
+ Chosen.prototype.search_field_disabled = function () {
865
  this.is_disabled = this.form_field_jq[0].disabled;
866
  if (this.is_disabled) {
867
  this.container.addClass('chosen-disabled');
869
  if (!this.is_multiple) {
870
  this.selected_item.unbind("focus.chosen", this.activate_action);
871
  }
872
+
873
  return this.close_field();
874
  } else {
875
  this.container.removeClass('chosen-disabled');
880
  }
881
  };
882
 
883
+ Chosen.prototype.container_mousedown = function (evt) {
884
  if (!this.is_disabled) {
885
  if (evt && evt.type === "mousedown" && !this.results_showing) {
886
  evt.preventDefault();
887
  }
888
+
889
  if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
890
  if (!this.active_field) {
891
  if (this.is_multiple) {
892
  this.search_field.val("");
893
  }
894
+
895
  $(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
896
  this.results_show();
897
  } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
898
  evt.preventDefault();
899
  this.results_toggle();
900
  }
901
+
902
  return this.activate_field();
903
  }
904
  }
905
  };
906
 
907
+ Chosen.prototype.container_mouseup = function (evt) {
908
  if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
909
  return this.results_reset(evt);
910
  }
911
  };
912
 
913
+ Chosen.prototype.search_results_mousewheel = function (evt) {
914
  var delta;
915
  if (evt.originalEvent) {
916
  delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
917
  }
918
+
919
  if (delta != null) {
920
  evt.preventDefault();
921
  if (evt.type === 'DOMMouseScroll') {
922
  delta = delta * 40;
923
  }
924
+
925
  return this.search_results.scrollTop(delta + this.search_results.scrollTop());
926
  }
927
  };
928
 
929
+ Chosen.prototype.blur_test = function (evt) {
930
  if (!this.active_field && this.container.hasClass("chosen-container-active")) {
931
  return this.close_field();
932
  }
933
  };
934
 
935
+ Chosen.prototype.close_field = function () {
936
  $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
937
  this.active_field = false;
938
  this.results_hide();
942
  return this.search_field_scale();
943
  };
944
 
945
+ Chosen.prototype.activate_field = function () {
946
  this.container.addClass("chosen-container-active");
947
  this.active_field = true;
948
  this.search_field.val(this.search_field.val());
949
  return this.search_field.focus();
950
  };
951
 
952
+ Chosen.prototype.test_active_click = function (evt) {
953
  var active_container;
954
  active_container = $(evt.target).closest('.chosen-container');
955
  if (active_container.length && this.container[0] === active_container[0]) {
959
  }
960
  };
961
 
962
+ Chosen.prototype.results_build = function () {
963
  this.parsing = true;
964
  this.selected_option_count = null;
965
  this.results_data = SelectParser.select_to_array(this.form_field);
975
  this.container.removeClass("chosen-container-single-nosearch");
976
  }
977
  }
978
+
979
+ this.update_results_content(
980
+ this.results_option_build(
981
+ {
982
+ first: true
983
+ }
984
+ )
985
+ );
986
  this.search_field_disabled();
987
  this.show_search_field_default();
988
  this.search_field_scale();
989
  return this.parsing = false;
990
  };
991
 
992
+ Chosen.prototype.result_do_highlight = function (el) {
993
  var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
994
  if (el.length) {
995
  this.result_clear_highlight();
1008
  }
1009
  };
1010
 
1011
+ Chosen.prototype.result_clear_highlight = function () {
1012
  if (this.result_highlight) {
1013
  this.result_highlight.removeClass("highlighted");
1014
  }
1015
+
1016
  return this.result_highlight = null;
1017
  };
1018
 
1019
+ Chosen.prototype.results_show = function () {
1020
  if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
1021
+ this.form_field_jq.trigger(
1022
+ "chosen:maxselected", {
1023
+ chosen: this
1024
+ }
1025
+ );
1026
  return false;
1027
  }
1028
+
1029
  this.container.addClass("chosen-with-drop");
1030
  this.results_showing = true;
1031
  this.search_field.focus();
1032
  this.search_field.val(this.search_field.val());
1033
  this.winnow_results();
1034
+ return this.form_field_jq.trigger(
1035
+ "chosen:showing_dropdown", {
1036
+ chosen: this
1037
+ }
1038
+ );
1039
  };
1040
 
1041
+ Chosen.prototype.update_results_content = function (content) {
1042
  return this.search_results.html(content);
1043
  };
1044
 
1045
+ Chosen.prototype.results_hide = function () {
1046
  if (this.results_showing) {
1047
  this.result_clear_highlight();
1048
  this.container.removeClass("chosen-with-drop");
1049
+ this.form_field_jq.trigger(
1050
+ "chosen:hiding_dropdown", {
1051
+ chosen: this
1052
+ }
1053
+ );
1054
  }
1055
+
1056
  return this.results_showing = false;
1057
  };
1058
 
1059
+ Chosen.prototype.set_tab_index = function (el) {
1060
  var ti;
1061
  if (this.form_field.tabIndex) {
1062
  ti = this.form_field.tabIndex;
1065
  }
1066
  };
1067
 
1068
+ Chosen.prototype.set_label_behavior = function () {
1069
  var _this = this;
1070
  this.form_field_label = this.form_field_jq.parents("label");
1071
  if (!this.form_field_label.length && this.form_field.id.length) {
1072
  this.form_field_label = $("label[for='" + this.form_field.id + "']");
1073
  }
1074
+
1075
  if (this.form_field_label.length > 0) {
1076
+ return this.form_field_label.bind(
1077
+ 'click.chosen', function (evt) {
1078
+ if (_this.is_multiple) {
1079
  return _this.container_mousedown(evt);
1080
+ } else {
1081
  return _this.activate_field();
1082
+ }
1083
+ }
1084
+ );
1085
  }
1086
  };
1087
 
1088
+ Chosen.prototype.show_search_field_default = function () {
1089
  if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
1090
  this.search_field.val(this.default_text);
1091
  return this.search_field.addClass("default");
1095
  }
1096
  };
1097
 
1098
+ Chosen.prototype.search_results_mouseup = function (evt) {
1099
  var target;
1100
  target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
1101
  if (target.length) {
1105
  }
1106
  };
1107
 
1108
+ Chosen.prototype.search_results_mouseover = function (evt) {
1109
  var target;
1110
  target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
1111
  if (target) {
1113
  }
1114
  };
1115
 
1116
+ Chosen.prototype.search_results_mouseout = function (evt) {
1117
  if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
1118
  return this.result_clear_highlight();
1119
  }
1120
  };
1121
 
1122
+ Chosen.prototype.choice_build = function (item) {
1123
  var choice, close_link,
1124
  _this = this;
1125
+ choice = $(
1126
+ '<li />', {
1127
+ "class": "search-choice"
1128
+ }
1129
+ ).html("<span>" + (this.choice_label(item)) + "</span>");
1130
  if (item.disabled) {
1131
  choice.addClass('search-choice-disabled');
1132
  } else {
1133
+ close_link = $(
1134
+ '<a />', {
1135
+ "class": 'search-choice-close',
1136
+ 'data-option-array-index': item.array_index
1137
+ }
1138
+ );
1139
+ close_link.bind(
1140
+ 'click.chosen', function (evt) {
1141
+ return _this.choice_destroy_link_click(evt);
1142
+ }
1143
+ );
1144
  choice.append(close_link);
1145
  }
1146
+
1147
  return this.search_container.before(choice);
1148
  };
1149
 
1150
+ Chosen.prototype.choice_destroy_link_click = function (evt) {
1151
  evt.preventDefault();
1152
  evt.stopPropagation();
1153
  if (!this.is_disabled) {
1155
  }
1156
  };
1157
 
1158
+ Chosen.prototype.choice_destroy = function (link) {
1159
  if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
1160
  this.show_search_field_default();
1161
  if (this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1) {
1162
  this.results_hide();
1163
  }
1164
+
1165
  link.parents('li').first().remove();
1166
  return this.search_field_scale();
1167
  }
1168
  };
1169
 
1170
+ Chosen.prototype.results_reset = function () {
1171
  this.reset_single_select_options();
1172
  this.form_field.options[0].selected = true;
1173
  this.single_set_selected_text();
1179
  }
1180
  };
1181
 
1182
+ Chosen.prototype.results_reset_cleanup = function () {
1183
  this.current_selectedIndex = this.form_field.selectedIndex;
1184
  return this.selected_item.find("abbr").remove();
1185
  };
1186
 
1187
+ Chosen.prototype.result_select = function (evt) {
1188
  var high, item;
1189
  if (this.result_highlight) {
1190
  high = this.result_highlight;
1191
  this.result_clear_highlight();
1192
  if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
1193
+ this.form_field_jq.trigger(
1194
+ "chosen:maxselected", {
1195
+ chosen: this
1196
+ }
1197
+ );
1198
  return false;
1199
  }
1200
+
1201
  if (this.is_multiple) {
1202
  high.removeClass("active-result");
1203
  } else {
1204
  this.reset_single_select_options();
1205
  }
1206
+
1207
  high.addClass("result-selected");
1208
  item = this.results_data[high[0].getAttribute("data-option-array-index")];
1209
  item.selected = true;
1214
  } else {
1215
  this.single_set_selected_text(this.choice_label(item));
1216
  }
1217
+
1218
  if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
1219
  this.results_hide();
1220
  }
1221
+
1222
  this.show_search_field_default();
1223
  if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
1224
+ this.form_field_jq.trigger(
1225
+ "change", {
1226
+ 'selected': this.form_field.options[item.options_index].value
1227
+ }
1228
+ );
1229
  }
1230
+
1231
  this.current_selectedIndex = this.form_field.selectedIndex;
1232
  evt.preventDefault();
1233
  return this.search_field_scale();
1234
  }
1235
  };
1236
 
1237
+ Chosen.prototype.single_set_selected_text = function (text) {
1238
  if (text == null) {
1239
  text = this.default_text;
1240
  }
1241
+
1242
  if (text === this.default_text) {
1243
  this.selected_item.addClass("chosen-default");
1244
  } else {
1245
  this.single_deselect_control_build();
1246
  this.selected_item.removeClass("chosen-default");
1247
  }
1248
+
1249
  return this.selected_item.find("span").html(text);
1250
  };
1251
 
1252
+ Chosen.prototype.result_deselect = function (pos) {
1253
  var result_data;
1254
  result_data = this.results_data[pos];
1255
  if (!this.form_field.options[result_data.options_index].disabled) {
1260
  if (this.results_showing) {
1261
  this.winnow_results();
1262
  }
1263
+
1264
+ this.form_field_jq.trigger(
1265
+ "change", {
1266
+ deselected: this.form_field.options[result_data.options_index].value
1267
+ }
1268
+ );
1269
  this.search_field_scale();
1270
  return true;
1271
  } else {
1273
  }
1274
  };
1275
 
1276
+ Chosen.prototype.single_deselect_control_build = function () {
1277
  if (!this.allow_single_deselect) {
1278
  return;
1279
  }
1280
+
1281
  if (!this.selected_item.find("abbr").length) {
1282
  this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
1283
  }
1284
+
1285
  return this.selected_item.addClass("chosen-single-with-deselect");
1286
  };
1287
 
1288
+ Chosen.prototype.get_search_text = function () {
1289
  return $('<div/>').text($.trim(this.search_field.val())).html();
1290
  };
1291
 
1292
+ Chosen.prototype.winnow_results_set_highlight = function () {
1293
  var do_high, selected_results;
1294
  selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
1295
  do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
1298
  }
1299
  };
1300
 
1301
+ Chosen.prototype.no_results = function (terms) {
1302
  var no_results_html;
1303
  no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
1304
  no_results_html.find("span").first().html(terms);
1305
  this.search_results.append(no_results_html);
1306
+ return this.form_field_jq.trigger(
1307
+ "chosen:no_results", {
1308
+ chosen: this
1309
+ }
1310
+ );
1311
  };
1312
 
1313
+ Chosen.prototype.no_results_clear = function () {
1314
  return this.search_results.find(".no-results").remove();
1315
  };
1316
 
1317
+ Chosen.prototype.keydown_arrow = function () {
1318
  var next_sib;
1319
  if (this.results_showing && this.result_highlight) {
1320
  next_sib = this.result_highlight.nextAll("li.active-result").first();
1326
  }
1327
  };
1328
 
1329
+ Chosen.prototype.keyup_arrow = function () {
1330
  var prev_sibs;
1331
  if (!this.results_showing && !this.is_multiple) {
1332
  return this.results_show();
1338
  if (this.choices_count() > 0) {
1339
  this.results_hide();
1340
  }
1341
+
1342
  return this.result_clear_highlight();
1343
  }
1344
  }
1345
  };
1346
 
1347
+ Chosen.prototype.keydown_backstroke = function () {
1348
  var next_available_destroy;
1349
  if (this.pending_backstroke) {
1350
  this.choice_destroy(this.pending_backstroke.find("a").first());
1362
  }
1363
  };
1364
 
1365
+ Chosen.prototype.clear_backstroke = function () {
1366
  if (this.pending_backstroke) {
1367
  this.pending_backstroke.removeClass("search-choice-focus");
1368
  }
1369
+
1370
  return this.pending_backstroke = null;
1371
  };
1372
 
1373
+ Chosen.prototype.keydown_checker = function (evt) {
1374
  var stroke, _ref1;
1375
  stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1376
  this.search_field_scale();
1377
  if (stroke !== 8 && this.pending_backstroke) {
1378
  this.clear_backstroke();
1379
  }
1380
+
1381
  switch (stroke) {
1382
  case 8:
1383
  this.backstroke_length = this.search_field.val().length;
1386
  if (this.results_showing && !this.is_multiple) {
1387
  this.result_select(evt);
1388
  }
1389
+
1390
  this.mouse_on_container = false;
1391
  break;
1392
  case 13:
1410
  }
1411
  };
1412
 
1413
+ Chosen.prototype.search_field_scale = function () {
1414
  var div, f_width, h, style, style_block, styles, w, _i, _len;
1415
  if (this.is_multiple) {
1416
  h = 0;
1421
  style = styles[_i];
1422
  style_block += style + ":" + this.search_field.css(style) + ";";
1423
  }
1424
+
1425
+ div = $(
1426
+ '<div />', {
1427
+ 'style': style_block
1428
+ }
1429
+ );
1430
  div.text(this.search_field.val());
1431
  $('body').append(div);
1432
  w = div.width() + 25;
1435
  if (w > f_width - 10) {
1436
  w = f_width - 10;
1437
  }
1438
+
1439
+ return this.search_field.css(
1440
+ {
1441
+ 'width': w + 'px'
1442
+ }
1443
+ );
1444
  }
1445
  };
1446
 
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Infobeans_Switchowner</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Infobeans Switch Order Owner Release 1.0.1</summary>
10
  <description>Allow admin to switch order owner.</description>
11
- <notes>Release 1.0.1</notes>
12
  <authors><author><name>InfoBeans</name><user>InfoBeans</user><email>magentosupport@infobeans.com</email></author></authors>
13
- <date>2016-07-26</date>
14
- <time>09:16:25</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Infobeans_Switchowner.xml" hash="a97ea129e5e597f4654015841da09586"/></dir></target><target name="magecommunity"><dir name="Infobeans"><dir name="Switchowner"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><file name="Info.php" hash="9becb56c3ac2c9241de8da73a21d2e4c"/></dir><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tabs"><file name="History.php" hash="b596afefbc5dd56a8ed21cc92a0c19c1"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0effe2874bff282b74d57c81226620d0"/><file name="Notify.php" hash="fdd884fc678c7ebe7962278e816f18f8"/><file name="Order.php" hash="b613fe8f0a1303fd5e4b4b1cb6f899a6"/></dir><dir name="Model"><file name="Detail.php" hash="ee0e22fa7c79bc3b302b80d46ef88e99"/><file name="History.php" hash="7d5c71c194e6a78dc858a31abac8d92e"/><dir name="Mysql4"><dir name="Detail"><file name="Collection.php" hash="d5c68b12101d44957de1b9704466d0ba"/></dir><file name="Detail.php" hash="b66e2f31960c72be1689ee2b0cb8ecf6"/><dir name="History"><file name="Collection.php" hash="201864dc1ceb9a590c675135ebaa382f"/></dir><file name="History.php" hash="50a2dc71ec5f55ecf862c2154f9a44d3"/></dir><file name="Observer.php" hash="34bff4a2a504f5059621639c24bd21c1"/><file name="Order.php" hash="6ae157f23c751980be7fc1a8cba0f17f"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Orderstate.php" hash="df01c2eaa0d629f3b0f20bf8f8cc3ba5"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Switchowner"><file name="OrderController.php" hash="a7fba7c5dcfef5281281e9604d795828"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2af49620958126bef66a869454fdc9c0"/><file name="config.xml" hash="a05cfc452c00b64e8231390f4dd3d5f5"/><file name="system.xml" hash="15edec7be14000ec2a8dbdd6dac77017"/></dir><dir name="sql"><dir name="switchowner_setup"><file name="mysql4-install-1.0.1.php" hash="1c6619739308b2f116a9625c09d367c4"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="infobeans"><file name="switchowner.xml" hash="f9ac53d4f45e03110a264ad5b8791420"/></dir></dir><dir name="template"><dir name="infobeans"><dir name="switchowner"><dir name="order"><file name="info.phtml" hash="085c3d08e4c26911aa9023a0f2bde047"/><dir name="view"><dir name="tab"><file name="history.phtml" hash="584bb8b7846d981d1a9c84421865021a"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="infobeans"><dir name="switchowner"><dir name="css"><dir name="chosen"><file name="chosen-sprite.png" hash="8b55a822e72b8fd5e2ee069236f2d797"/><file name="chosen-sprite@2x.png" hash="614fad616d014daf5367e068505cad35"/><file name="chosen.css" hash="53aa964b1c6ea0a0e3bab02113fcb95f"/></dir><file name="default.css" hash="d37c27b1b0a35222bcc874248b400684"/><dir name="ibmagento"><file name="btn_bg.gif" hash="37c51a4d48a92da9648dcd3ca011039f"/><file name="content_bg.gif" hash="21278ea0da2d4256f4ced96b6080ba2e"/><file name="filter_row_bg.gif" hash="013a0929a7b2ddc6823bdda17d08acc0"/><file name="icon_note_list.gif" hash="8d25ba225ca09b687a78bff510df5d10"/><file name="massaction_bg.gif" hash="8b5f4db3ab3ea09cd5bd0164d67c4f0d"/><file name="top_bg.gif" hash="26f28090de87d64f9b01bf624f89bfe2"/><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir><file name="ibmagento.css" hash="083ae82d9ef4dadc3d3f2cbd3f7d6365"/></dir><dir name="images"><file name="cover-left.png" hash="95475d343a19a5be4b386b346d8e1b93"/><file name="cover-right.png" hash="69a03ac1caba31c4c1aaf451fc233291"/><file name="notified_not.png" hash="1828784f31b37fc5d56d0ede62477f47"/><file name="notified_success.gif" hash="0afb20898a704a106cb4c598868abf32"/><file name="user.png" hash="1880e1c36b3d463d2ed5085a3ee826b6"/><file name="validation_advice_bg.gif" hash="b85432906de8985a8b14eeb2dc652d3c"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="infobeans"><dir name="switchowner"><dir name="chosen"><file name="chosen.jquery.js" hash="e703b3630eaf6837f3c52b6bc61eb82a"/></dir><file name="jquery.min.js" hash="bdce12c949e78d570c8d44e9c2b23508"/><file name="jquery.noconflict.js" hash="3179f2255b046d5f2e9a71e365287bef"/><file name="jquery.validate.min.js" hash="c4499184878d17d8af6f4181c0d03102"/></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Infobeans_Switchowner.csv" hash="478b8f0b78ffa22958e7dd60227797e5"/><dir name="template"><dir name="email"><dir name="infobeans_switchowner"><file name="notify_customer.html" hash="f596f7ea55801a56892e454242bde695"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Infobeans_Switchowner</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Infobeans Switch Order Owner Release 1.0.2</summary>
10
  <description>Allow admin to switch order owner.</description>
11
+ <notes>Release 1.0.2</notes>
12
  <authors><author><name>InfoBeans</name><user>InfoBeans</user><email>magentosupport@infobeans.com</email></author></authors>
13
+ <date>2017-01-18</date>
14
+ <time>10:44:32</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Infobeans_Switchowner.xml" hash="a97ea129e5e597f4654015841da09586"/></dir></target><target name="magecommunity"><dir name="Infobeans"><dir name="Switchowner"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><file name="Info.php" hash="4825eb6bac6b14faf1b7d8fab89eec66"/></dir><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tabs"><file name="History.php" hash="b596afefbc5dd56a8ed21cc92a0c19c1"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0effe2874bff282b74d57c81226620d0"/><file name="Notify.php" hash="363e875a92df87788c05cc30913b9121"/><file name="Order.php" hash="b613fe8f0a1303fd5e4b4b1cb6f899a6"/></dir><dir name="Model"><file name="Detail.php" hash="ee0e22fa7c79bc3b302b80d46ef88e99"/><file name="History.php" hash="436ec7303a161abcf82a20bee58283f9"/><dir name="Mysql4"><dir name="Detail"><file name="Collection.php" hash="d5c68b12101d44957de1b9704466d0ba"/></dir><file name="Detail.php" hash="b66e2f31960c72be1689ee2b0cb8ecf6"/><dir name="History"><file name="Collection.php" hash="0f1dd1bf9de721d2095cd52f0e008873"/></dir><file name="History.php" hash="50a2dc71ec5f55ecf862c2154f9a44d3"/></dir><file name="Observer.php" hash="76a71c4fdef7608120f3db809cdf0556"/><file name="Order.php" hash="ae376356bf48358f2f98b907a5bf0596"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Orderstate.php" hash="df01c2eaa0d629f3b0f20bf8f8cc3ba5"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Switchowner"><file name="OrderController.php" hash="9f479cdffc7ba9d3176aac95fea38e90"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2af49620958126bef66a869454fdc9c0"/><file name="config.xml" hash="beb332808ecbc4af9ce322ea811c1fb3"/><file name="system.xml" hash="15edec7be14000ec2a8dbdd6dac77017"/></dir><dir name="sql"><dir name="switchowner_setup"><file name="mysql4-install-1.0.1.php" hash="76679a0dd03f57cb34d0e94c01be437a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="infobeans"><file name="switchowner.xml" hash="f9ac53d4f45e03110a264ad5b8791420"/></dir></dir><dir name="template"><dir name="infobeans"><dir name="switchowner"><dir name="order"><file name="info.phtml" hash="fbf90f7dc92a0d9875ce40c8ecba6a1a"/><dir name="view"><dir name="tab"><file name="history.phtml" hash="584bb8b7846d981d1a9c84421865021a"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="infobeans"><dir name="switchowner"><dir name="css"><dir name="chosen"><file name="chosen-sprite.png" hash="8b55a822e72b8fd5e2ee069236f2d797"/><file name="chosen-sprite@2x.png" hash="614fad616d014daf5367e068505cad35"/><file name="chosen.css" hash="53aa964b1c6ea0a0e3bab02113fcb95f"/></dir><file name="default.css" hash="c4e58b6bcc4f94299680946d4ad9a40a"/><dir name="ibmagento"><file name="btn_bg.gif" hash="37c51a4d48a92da9648dcd3ca011039f"/><file name="content_bg.gif" hash="21278ea0da2d4256f4ced96b6080ba2e"/><file name="filter_row_bg.gif" hash="013a0929a7b2ddc6823bdda17d08acc0"/><file name="icon_note_list.gif" hash="8d25ba225ca09b687a78bff510df5d10"/><file name="massaction_bg.gif" hash="8b5f4db3ab3ea09cd5bd0164d67c4f0d"/><file name="top_bg.gif" hash="26f28090de87d64f9b01bf624f89bfe2"/><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir><file name="ibmagento.css" hash="083ae82d9ef4dadc3d3f2cbd3f7d6365"/></dir><dir name="images"><file name="cover-left.png" hash="95475d343a19a5be4b386b346d8e1b93"/><file name="cover-right.png" hash="69a03ac1caba31c4c1aaf451fc233291"/><file name="notified_not.png" hash="1828784f31b37fc5d56d0ede62477f47"/><file name="notified_success.gif" hash="0afb20898a704a106cb4c598868abf32"/><file name="user.png" hash="1880e1c36b3d463d2ed5085a3ee826b6"/><file name="validation_advice_bg.gif" hash="b85432906de8985a8b14eeb2dc652d3c"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="infobeans"><dir name="switchowner"><dir name="chosen"><file name="chosen.jquery.js" hash="268b4db847b5f366538eaad52a46b2f3"/></dir><file name="jquery.min.js" hash="bdce12c949e78d570c8d44e9c2b23508"/><file name="jquery.noconflict.js" hash="3179f2255b046d5f2e9a71e365287bef"/><file name="jquery.validate.min.js" hash="c4499184878d17d8af6f4181c0d03102"/></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Infobeans_Switchowner.csv" hash="478b8f0b78ffa22958e7dd60227797e5"/><dir name="template"><dir name="email"><dir name="infobeans_switchowner"><file name="notify_customer.html" hash="f596f7ea55801a56892e454242bde695"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
skin/adminhtml/default/default/infobeans/switchowner/css/default.css CHANGED
@@ -25,58 +25,58 @@
25
  .dialog_nw {
26
  width: 9px;
27
  height: 23px;
28
- background: transparent url(default/top_left.gif) no-repeat 0 0;
29
  }
30
 
31
  .dialog_n {
32
- background: transparent url(default/top_mid.gif) repeat-x 0 0;
33
  height: 23px;
34
  }
35
 
36
  .dialog_ne {
37
  width: 9px;
38
  height: 23px;
39
- background: transparent url(default/top_right.gif) no-repeat 0 0;
40
  }
41
 
42
  .dialog_e {
43
  width: 2px;
44
- background: transparent url(default/center_right.gif) repeat-y 0 0;
45
  }
46
 
47
  .dialog_w {
48
  width: 2px;
49
- background: transparent url(default/center_left.gif) repeat-y 0 0;
50
  }
51
 
52
  .dialog_sw {
53
  width: 9px;
54
  height: 19px;
55
- background: transparent url(default/bottom_left.gif) no-repeat 0 0;
56
  }
57
 
58
  .dialog_s {
59
- background: transparent url(default/bottom_mid.gif) repeat-x 0 0;
60
  height: 19px;
61
  }
62
 
63
  .dialog_se {
64
  width: 9px;
65
  height: 19px;
66
- background: transparent url(default/bottom_right.gif) no-repeat 0 0;
67
  }
68
 
69
  .dialog_sizer {
70
  width: 9px;
71
  height: 19px;
72
- background: transparent url(default/sizer.gif) no-repeat 0 0;
73
- cursor:se-resize;
74
  }
75
 
76
  .dialog_close {
77
  width: 14px;
78
  height: 14px;
79
- background: transparent url(default/close.gif) no-repeat 0 0;
80
  position:absolute;
81
  top:5px;
82
  left:8px;
@@ -87,7 +87,7 @@
87
  .dialog_minimize {
88
  width: 14px;
89
  height: 15px;
90
- background: transparent url(default/minimize.gif) no-repeat 0 0;
91
  position:absolute;
92
  top:5px;
93
  left:28px;
@@ -98,7 +98,7 @@
98
  .dialog_maximize {
99
  width: 14px;
100
  height: 15px;
101
- background: transparent url(default/maximize.gif) no-repeat 0 0;
102
  position:absolute;
103
  top:5px;
104
  left:49px;
25
  .dialog_nw {
26
  width: 9px;
27
  height: 23px;
28
+ background: transparent url(default/top_left.gif) no-repeat 0 0;
29
  }
30
 
31
  .dialog_n {
32
+ background: transparent url(default/top_mid.gif) repeat-x 0 0;
33
  height: 23px;
34
  }
35
 
36
  .dialog_ne {
37
  width: 9px;
38
  height: 23px;
39
+ background: transparent url(default/top_right.gif) no-repeat 0 0;
40
  }
41
 
42
  .dialog_e {
43
  width: 2px;
44
+ background: transparent url(default/center_right.gif) repeat-y 0 0;
45
  }
46
 
47
  .dialog_w {
48
  width: 2px;
49
+ background: transparent url(default/center_left.gif) repeat-y 0 0;
50
  }
51
 
52
  .dialog_sw {
53
  width: 9px;
54
  height: 19px;
55
+ background: transparent url(default/bottom_left.gif) no-repeat 0 0;
56
  }
57
 
58
  .dialog_s {
59
+ background: transparent url(default/bottom_mid.gif) repeat-x 0 0;
60
  height: 19px;
61
  }
62
 
63
  .dialog_se {
64
  width: 9px;
65
  height: 19px;
66
+ background: transparent url(default/bottom_right.gif) no-repeat 0 0;
67
  }
68
 
69
  .dialog_sizer {
70
  width: 9px;
71
  height: 19px;
72
+ background: transparent url(default/sizer.gif) no-repeat 0 0;
73
+ cursor:se-resize;
74
  }
75
 
76
  .dialog_close {
77
  width: 14px;
78
  height: 14px;
79
+ background: transparent url(default/close.gif) no-repeat 0 0;
80
  position:absolute;
81
  top:5px;
82
  left:8px;
87
  .dialog_minimize {
88
  width: 14px;
89
  height: 15px;
90
+ background: transparent url(default/minimize.gif) no-repeat 0 0;
91
  position:absolute;
92
  top:5px;
93
  left:28px;
98
  .dialog_maximize {
99
  width: 14px;
100
  height: 15px;
101
+ background: transparent url(default/maximize.gif) no-repeat 0 0;
102
  position:absolute;
103
  top:5px;
104
  left:49px;