Version Notes
Added support for new Callback API features aimed at improving multi-store install integration.
Download this release
Release Info
Developer | PriceWaiter |
Extension | nypwidget |
Version | 1.2.2 |
Comparing to | |
See all releases |
Version 1.2.2
- app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Widget.php +24 -0
- app/code/community/PriceWaiter/NYPWidget/Block/Category.php +54 -0
- app/code/community/PriceWaiter/NYPWidget/Block/Widget.php +30 -0
- app/code/community/PriceWaiter/NYPWidget/Helper/Data.php +228 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Callback.php +318 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Carrier/ShippingMethod.php +34 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Category.php +91 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Display/Phrase.php +27 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Display/Size.php +27 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category.php +24 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category/Collection.php +24 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order.php +24 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order/Collection.php +24 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Observer.php +46 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Order.php +42 -0
- app/code/community/PriceWaiter/NYPWidget/Model/PaymentMethod.php +53 -0
- app/code/community/PriceWaiter/NYPWidget/Model/Resource/Eav/Mysql4/Setup.php +21 -0
- app/code/community/PriceWaiter/NYPWidget/controllers/CallbackController.php +51 -0
- app/code/community/PriceWaiter/NYPWidget/etc/adminhtml.xml +40 -0
- app/code/community/PriceWaiter/NYPWidget/etc/config.xml +174 -0
- app/code/community/PriceWaiter/NYPWidget/etc/system.xml +188 -0
- app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-install-1.0.0.php +67 -0
- app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.2-1.1.3.php +51 -0
- app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.7-1.1.8.php +32 -0
- app/design/adminhtml/default/default/layout/pricewaiter.xml +28 -0
- app/design/adminhtml/default/default/template/pricewaiter/admin_widget.phtml +32 -0
- app/design/adminhtml/default/default/template/pricewaiter/categorytab.phtml +48 -0
- app/design/frontend/base/default/layout/pricewaiter.xml +26 -0
- app/design/frontend/base/default/template/pricewaiter/widget.phtml +36 -0
- app/etc/modules/PriceWaiter_NYPWidget.xml +24 -0
- js/jscolor-pw/arrow.gif +0 -0
- js/jscolor-pw/cross.gif +0 -0
- js/jscolor-pw/hs.png +0 -0
- js/jscolor-pw/hv.png +0 -0
- js/jscolor-pw/jscolor.js +935 -0
- js/pricewaiter/product-pages.js +276 -0
- package.xml +19 -0
- skin/adminhtml/default/default/images/pricewaiter_logo.png +0 -0
- skin/adminhtml/default/default/images/pricewaiter_tab.png +0 -0
- skin/adminhtml/default/default/pricewaiter.css +49 -0
app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Widget.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Block_Adminhtml_Widget extends Mage_Adminhtml_Block_Abstract
|
19 |
+
{
|
20 |
+
public function _getHelper() {
|
21 |
+
$helper = Mage::helper('nypwidget');
|
22 |
+
return $helper;
|
23 |
+
}
|
24 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Block/Category.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Block_Category extends Mage_Adminhtml_Block_Template
|
19 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
20 |
+
{
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
$this->setTemplate('pricewaiter/categorytab.phtml');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getIsEnabled()
|
27 |
+
{
|
28 |
+
$category = Mage::registry('category');
|
29 |
+
$nypcategory = Mage::getModel('nypwidget/category')->loadByCategory($category, $category->getStore()->getId());
|
30 |
+
|
31 |
+
return $nypcategory->isActive(true);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getTabLabel()
|
35 |
+
{
|
36 |
+
return $this->__('PriceWaiter Widget');
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getTabTitle()
|
40 |
+
{
|
41 |
+
return $this->__('PriceWaiter');
|
42 |
+
}
|
43 |
+
|
44 |
+
public function canShowTab()
|
45 |
+
{
|
46 |
+
return true;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function isHidden()
|
50 |
+
{
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Block/Widget.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Block_Widget extends Mage_Core_Block_Template
|
19 |
+
{
|
20 |
+
public function _getHelper()
|
21 |
+
{
|
22 |
+
$helper = Mage::helper('nypwidget');
|
23 |
+
return $helper;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getPriceWaiterOptions()
|
27 |
+
{
|
28 |
+
$product = Mage::registry('current_product');
|
29 |
+
}
|
30 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Helper/Data.php
ADDED
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
|
19 |
+
{
|
20 |
+
private $_product = false;
|
21 |
+
private $_testing = false;
|
22 |
+
|
23 |
+
public function isTesting()
|
24 |
+
{
|
25 |
+
return $this->_testing;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function isEnabled()
|
29 |
+
{
|
30 |
+
// Is the pricewaiter widget enabled for this store
|
31 |
+
if (Mage::getStoreConfig('pricewaiter/configuration/enabled')) {
|
32 |
+
|
33 |
+
// Is the pricewaiter widget enabled for this product
|
34 |
+
$product = $this->_getProduct();
|
35 |
+
if (!is_object($product) or ($product->getId() and $product->getData('nypwidget_disabled'))) {
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
|
39 |
+
// Is the PriceWaiter widget enabled for this category
|
40 |
+
$category = Mage::registry('current_category');
|
41 |
+
if (is_object($category)) {
|
42 |
+
$nypcategory = Mage::getModel('nypwidget/category')->loadByCategory($category);
|
43 |
+
if (!$nypcategory->isActive()) {
|
44 |
+
return false;
|
45 |
+
}
|
46 |
+
} else {
|
47 |
+
// We end up here if we are visiting the product page without being
|
48 |
+
// "in a category". Basically, we arrived via a search page.
|
49 |
+
// The logic here checks to see if there are any categories that this
|
50 |
+
// product belongs to that enable the PriceWaiter widget. If not, return false.
|
51 |
+
$categories = $product->getCategoryIds();
|
52 |
+
$categoryActive = false;
|
53 |
+
foreach ($categories as $categoryId) {
|
54 |
+
unset($currentCategory);
|
55 |
+
unset($nypcategory);
|
56 |
+
$currentCategory = Mage::getModel('catalog/category')->load($categoryId);
|
57 |
+
$nypcategory = Mage::getModel('nypwidget/category')->loadByCategory($currentCategory);
|
58 |
+
if ($nypcategory->isActive()) {
|
59 |
+
$categoryActive = true;
|
60 |
+
break;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
if (!$categoryActive) {
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
} else {
|
69 |
+
// We end up here if PriceWaiter is disabled for this store
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
|
73 |
+
return true;
|
74 |
+
}
|
75 |
+
|
76 |
+
public function getPriceWaiterOptions()
|
77 |
+
{
|
78 |
+
$apiKey = Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
79 |
+
|
80 |
+
$displayPhrase = Mage::getStoreConfig('pricewaiter/appearance/display_phrase') ? 'button_mo' : 'button_nyp';
|
81 |
+
$displaySize = Mage::getStoreConfig('pricewaiter/appearance/display_size') ? 'sm' : 'lg';
|
82 |
+
$displayColor = Mage::getStoreConfig('pricewaiter/appearance/display_color');
|
83 |
+
$displayHoverColor = Mage::getStoreConfig('pricewaiter/appearance/display_hover_color');
|
84 |
+
|
85 |
+
$pwOptions = "
|
86 |
+
var PriceWaiterOptions = {
|
87 |
+
apiKey: '" . $apiKey . "',
|
88 |
+
button: {
|
89 |
+
type: " . json_encode($displayPhrase) . ",
|
90 |
+
size: " . json_encode($displaySize) . ",";
|
91 |
+
|
92 |
+
if ($displayColor) {
|
93 |
+
$pwOptions .= "
|
94 |
+
color: " . json_encode($displayColor) . ",";
|
95 |
+
}
|
96 |
+
|
97 |
+
if ($displayHoverColor) {
|
98 |
+
$pwOptions .= "
|
99 |
+
hoverColor: " . json_encode($displayHoverColor) . ",";
|
100 |
+
}
|
101 |
+
|
102 |
+
$pwOptions .= "
|
103 |
+
},
|
104 |
+
};\n";
|
105 |
+
|
106 |
+
return $pwOptions;
|
107 |
+
}
|
108 |
+
|
109 |
+
public function getProductOptions($admin = false)
|
110 |
+
{
|
111 |
+
if ($admin) {
|
112 |
+
return "PriceWaiterOptions.product = {
|
113 |
+
sku: 'TEST-SKU',
|
114 |
+
name: 'Test Name',
|
115 |
+
price: 19.99,
|
116 |
+
image: 'http://placekitten.com/220/220'
|
117 |
+
};
|
118 |
+
var PriceWaiterProductType = 'simple';
|
119 |
+
var PriceWaiterRegularPrice = 19.99";
|
120 |
+
}
|
121 |
+
|
122 |
+
$product = $this->_getProduct();
|
123 |
+
|
124 |
+
if ($product->getId()) {
|
125 |
+
|
126 |
+
switch ($product->getTypeId()) {
|
127 |
+
case "simple":
|
128 |
+
return $this->_pwBoilerPlate($product) . "
|
129 |
+
var PriceWaiterProductType = 'simple';
|
130 |
+
";
|
131 |
+
break;
|
132 |
+
case "configurable":
|
133 |
+
return $this->_pwBoilerPlate($product) . "
|
134 |
+
var PriceWaiterProductType = 'configurable';
|
135 |
+
";
|
136 |
+
break;
|
137 |
+
case "grouped":
|
138 |
+
return $this->_pwBoilerPlate($product) . "
|
139 |
+
var PriceWaiterProductType = 'grouped';
|
140 |
+
";
|
141 |
+
return false;
|
142 |
+
break;
|
143 |
+
case "virtual":
|
144 |
+
// Virtual products are not yet supported
|
145 |
+
return false;
|
146 |
+
break;
|
147 |
+
case "bundle":
|
148 |
+
return $this->_pwBoilerPlate($product) . "
|
149 |
+
var PriceWaiterProductType = 'bundle';
|
150 |
+
";
|
151 |
+
break;
|
152 |
+
case "downloadable":
|
153 |
+
// Downloadable products are not yet supported
|
154 |
+
return false;
|
155 |
+
break;
|
156 |
+
default:
|
157 |
+
return false;
|
158 |
+
break;
|
159 |
+
}
|
160 |
+
} else {
|
161 |
+
return false;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
public function getWidgetUrl()
|
166 |
+
{
|
167 |
+
if ($this->_testing) {
|
168 |
+
return "https://testing.pricewaiter.com/nyp/script/widget.js";
|
169 |
+
} else {
|
170 |
+
return "https://widget.pricewaiter.com/nyp/script/widget.js";
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
public function getApiUrl()
|
175 |
+
{
|
176 |
+
if ($this->_testing) {
|
177 |
+
return "https://api-testing.pricewaiter.com/1/order/verify?"
|
178 |
+
. "api_key="
|
179 |
+
. Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
180 |
+
} else {
|
181 |
+
return "https://api.pricewaiter.com/1/order/verify?api_key="
|
182 |
+
. Mage::getStoreConfig('pricewaiter/configuration/api_key');
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
private function _pwBoilerPlate($product)
|
187 |
+
{
|
188 |
+
if ($product->getTypeId() == 'grouped') {
|
189 |
+
$productPrice = 0;
|
190 |
+
} else {
|
191 |
+
$productPrice = $product->getFinalPrice();
|
192 |
+
}
|
193 |
+
|
194 |
+
return "
|
195 |
+
PriceWaiterOptions.product = {
|
196 |
+
sku: " . json_encode($product->getSku()) . ",
|
197 |
+
name: " . json_encode($product->getName()) . ",
|
198 |
+
price: " . json_encode($productPrice) . ",
|
199 |
+
image: " . json_encode($product->getImageUrl()) . "
|
200 |
+
};
|
201 |
+
var PriceWaiterRegularPrice = '" . (float) $product->getPrice() . "';
|
202 |
+
";
|
203 |
+
}
|
204 |
+
|
205 |
+
private function _getProduct()
|
206 |
+
{
|
207 |
+
if (!$this->_product) {
|
208 |
+
$this->_product = Mage::registry('current_product');
|
209 |
+
}
|
210 |
+
|
211 |
+
return $this->_product;
|
212 |
+
}
|
213 |
+
|
214 |
+
public function getStoreByApiKey($apiKey) {
|
215 |
+
$stores = Mage::app()->getStores();
|
216 |
+
|
217 |
+
// Find the store with the matching API key by checking the key for each store
|
218 |
+
// in Magento
|
219 |
+
foreach ($stores as $store) {
|
220 |
+
if ($apiKey == Mage::getStoreConfig('pricewaiter/configuration/api_key', $store->getId())) {
|
221 |
+
return $store;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
return Mage::app()->getStore();
|
226 |
+
}
|
227 |
+
|
228 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Callback.php
ADDED
@@ -0,0 +1,318 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Callback
|
19 |
+
{
|
20 |
+
|
21 |
+
private $_store;
|
22 |
+
private $_groupId = '1';
|
23 |
+
private $_sendConfirmation = '0';
|
24 |
+
|
25 |
+
private $orderData = array();
|
26 |
+
private $_product;
|
27 |
+
|
28 |
+
private $_sourceCustomer;
|
29 |
+
private $_sourceOrder;
|
30 |
+
|
31 |
+
public function processRequest($request)
|
32 |
+
{
|
33 |
+
// If the PriceWaiter extension is in testing mode, skip request validation
|
34 |
+
if (!Mage::helper('nypwidget')->isTesting()) {
|
35 |
+
// Build URL to check validity of order notification.
|
36 |
+
$url = Mage::helper('nypwidget')->getApiUrl();
|
37 |
+
|
38 |
+
$ch = curl_init($url);
|
39 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
40 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
41 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
|
42 |
+
|
43 |
+
// If PriceWaiter returns an invalid response
|
44 |
+
if (curl_exec($ch) == "1") {
|
45 |
+
$message = "The Name Your Price Widget has received a valid order notification.";
|
46 |
+
Mage::log($message);
|
47 |
+
$this->_log($message);
|
48 |
+
} else {
|
49 |
+
$message = "An invalid PriceWaiter order notification has been received.";
|
50 |
+
Mage::log($message);
|
51 |
+
$this->_log($message);
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
// Verify that we have not already received this callback based on the `pricewaiter_id` field
|
57 |
+
$pricewaiterOrder = Mage::getModel('nypwidget/order');
|
58 |
+
$pricewaiterOrder->loadByPriceWaiterId($request['pricewaiter_id']);
|
59 |
+
if ($pricewaiterOrder->getId()) {
|
60 |
+
$message = "Received a duplicate order from the PriceWaiter Callback API. Ignoring.";
|
61 |
+
$this->_log($message);
|
62 |
+
return;
|
63 |
+
}
|
64 |
+
|
65 |
+
try {
|
66 |
+
|
67 |
+
// First, determine the store that this order corresponds to.
|
68 |
+
// This is a new feature as of 1.2.2, so we need to make sure the API
|
69 |
+
// is compatible first.
|
70 |
+
if (array_key_exists('api_key', $request)
|
71 |
+
&& $request['api_key'] != '') {
|
72 |
+
$store = Mage::helper('nypwidget')->getStoreByApiKey($request['api_key']);
|
73 |
+
$this->_store = $store;
|
74 |
+
} else {
|
75 |
+
// Fallback for when the API key isn't found
|
76 |
+
$this->_store = Mage::app()->getStore();
|
77 |
+
}
|
78 |
+
|
79 |
+
// Is this an existing customer?
|
80 |
+
$customer = Mage::getModel('customer/customer')
|
81 |
+
->setWebsiteId($this->_store->getWebsiteId());
|
82 |
+
$customer->loadByEmail($request['buyer_email']);
|
83 |
+
preg_match('#^(\w+\.)?\s*([\'\’\w]+)\s+([\'\’\w]+)\s*(\w+\.?)?$#',$request['buyer_name'] , $name);
|
84 |
+
$request['buyer_first_name'] = $name[2];
|
85 |
+
$request['buyer_last_name'] = $name[3];
|
86 |
+
|
87 |
+
if (!$customer->getId()) {
|
88 |
+
// Create a new customer with this email
|
89 |
+
$customer->reset();
|
90 |
+
$passwordLength = 10;
|
91 |
+
$passwordCharacters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
92 |
+
$password = '';
|
93 |
+
for ($p = 0; $p < $passwordLength; $p++) {
|
94 |
+
$password .= $passwordCharacters[mt_rand(0, strlen($passwordCharacters))];
|
95 |
+
}
|
96 |
+
|
97 |
+
$customer->setEmail($request['buyer_email']);
|
98 |
+
$customer->setFirstname($name[2]);
|
99 |
+
$customer->setLastname($name[3]);
|
100 |
+
$customer->setPassword($password);
|
101 |
+
$customer->setConfirmation(null);
|
102 |
+
$customer->setWebsiteId($this->_store->getWebsiteId());
|
103 |
+
$customer->save();
|
104 |
+
$customer->load($customer->getId());
|
105 |
+
}
|
106 |
+
|
107 |
+
$transaction = Mage::getModel('core/resource_transaction');
|
108 |
+
$reservedOrderId = Mage::getSingleton('eav/config')->getEntityType('order')->fetchNewIncrementId($this->_store->getId());
|
109 |
+
|
110 |
+
$order = Mage::getModel('sales/order')
|
111 |
+
->setIncrementId($reservedOrderId)
|
112 |
+
->setStoreId($this->_store->getId())
|
113 |
+
->setQuoteId(0)
|
114 |
+
->setGlobal_currency_code('USD')
|
115 |
+
->setBase_currency_code('USD')
|
116 |
+
->setStore_currency_code('USD')
|
117 |
+
->setOrder_currency_code('USD');
|
118 |
+
|
119 |
+
// set Customer data
|
120 |
+
$order->setCustomer_email($customer->getEmail())
|
121 |
+
->setCustomerFirstname($customer->getFirstname())
|
122 |
+
->setCustomerLastname($customer->getLastname())
|
123 |
+
->setCustomerGroupId($customer->getGroupId())
|
124 |
+
->setCustomer_is_guest(0)
|
125 |
+
->setCustomer($customer);
|
126 |
+
|
127 |
+
//Get a phone number, or make a dummy one
|
128 |
+
if ($request['buyer_shipping_phone']) {
|
129 |
+
$telephone = $request['buyer_shipping_phone'];
|
130 |
+
} else {
|
131 |
+
$telephone = "000-000-0000";
|
132 |
+
}
|
133 |
+
|
134 |
+
// set Billing Address
|
135 |
+
$billing = $customer->getDefaultBillingAddress();
|
136 |
+
$billingAddress = Mage::getModel('sales/order_address')
|
137 |
+
->setStoreId($this->_store->getId())
|
138 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING)
|
139 |
+
->setCustomerId($customer->getId())
|
140 |
+
->setPrefix('')
|
141 |
+
->setFirstname($request['buyer_first_name'])
|
142 |
+
->setMiddlename('')
|
143 |
+
->setLastname($request['buyer_last_name'])
|
144 |
+
->setSuffix('')
|
145 |
+
->setCompany('')
|
146 |
+
->setStreet(array($request['buyer_shipping_address'],$request['buyer_shipping_address2']))
|
147 |
+
->setCity($request['buyer_shipping_city'])
|
148 |
+
->setCountry_id($request['buyer_shipping_country'])
|
149 |
+
->setRegion('')
|
150 |
+
->setRegion_id($request['buyer_shipping_state'])
|
151 |
+
->setPostcode($request['buyer_shipping_zip'])
|
152 |
+
->setTelephone($telephone)
|
153 |
+
->setFax('');
|
154 |
+
$order->setBillingAddress($billingAddress);
|
155 |
+
|
156 |
+
// set Shipping Address
|
157 |
+
$shipping = $customer->getDefaultShippingAddress();
|
158 |
+
$shippingAddress = Mage::getModel('sales/order_address')
|
159 |
+
->setStoreId($this->_store->getId())
|
160 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING)
|
161 |
+
->setCustomerId($customer->getId())
|
162 |
+
->setPrefix('')
|
163 |
+
->setFirstname($request['buyer_first_name'])
|
164 |
+
->setMiddlename('')
|
165 |
+
->setLastname($request['buyer_last_name'])
|
166 |
+
->setSuffix('')
|
167 |
+
->setCompany('')
|
168 |
+
->setStreet(array($request['buyer_shipping_address'],$request['buyer_shipping_address2']))
|
169 |
+
->setCity($request['buyer_shipping_city'])
|
170 |
+
->setCountry_id($request['buyer_shipping_country'])
|
171 |
+
->setRegion('')
|
172 |
+
->setRegion_id($request['buyer_shipping_state'])
|
173 |
+
->setPostcode($request['buyer_shipping_zip'])
|
174 |
+
->setTelephone($telephone)
|
175 |
+
->setFax('');
|
176 |
+
|
177 |
+
// Apply shipping address to order, add PriceWaiter shipping method
|
178 |
+
$order->setShippingAddress($shippingAddress)
|
179 |
+
->setShipping_method('nypwidget_nypwidget')
|
180 |
+
->setShipping_amount($request['shipping'])
|
181 |
+
->setShippingDescription('PriceWaiter');
|
182 |
+
|
183 |
+
// Add PriceWaiter payment method
|
184 |
+
$orderPayment = Mage::getModel('sales/order_payment')
|
185 |
+
->setStoreId($this->_store->getId())
|
186 |
+
->setCustomerPaymentId(0)
|
187 |
+
->setMethod('nypwidget');
|
188 |
+
$order->setPayment($orderPayment);
|
189 |
+
|
190 |
+
// Find the Product from the request
|
191 |
+
$this->_product = Mage::getModel('catalog/product')->getCollection()
|
192 |
+
->addAttributeToFilter('sku', $request['product_sku'])
|
193 |
+
->addAttributeToSelect('*')
|
194 |
+
->getFirstItem();
|
195 |
+
|
196 |
+
// If we have product options, split them out of the request
|
197 |
+
$requestOptions = array();
|
198 |
+
|
199 |
+
for ($i = $request['product_option_count']; $i > 0; $i--) {
|
200 |
+
$requestOptions[$request['product_option_name' . $i]] = $request['product_option_value' . $i];
|
201 |
+
}
|
202 |
+
|
203 |
+
if ($this->_product->getTypeId() == 'configurable') {
|
204 |
+
// Do configurable product specific stuff
|
205 |
+
$attrs = $this->_product->getTypeInstance(true)->getConfigurableAttributesAsArray($this->_product);
|
206 |
+
|
207 |
+
// Find our product based on attributes
|
208 |
+
foreach ($attrs as $attr) {
|
209 |
+
if (array_key_exists($attr['label'], $requestOptions)) {
|
210 |
+
foreach ($attr['values'] as $value) {
|
211 |
+
if ($value['label'] == $requestOptions[$attr['label']]) {
|
212 |
+
$valueIndex = $value['value_index'];
|
213 |
+
break;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
unset($requestOptions[$attr['label']]);
|
217 |
+
$requestOptions[$attr['attribute_id']] = $valueIndex;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
$parentProduct = $this->_product;
|
222 |
+
$this->_product = $this->_product->getTypeInstance()->getProductByAttributes($requestOptions, $this->_product);
|
223 |
+
$this->_product->load($this->_product->getId());
|
224 |
+
}
|
225 |
+
|
226 |
+
// Build the pricing information of the product
|
227 |
+
$subTotal = 0;
|
228 |
+
$rowTotal = ($request['unit_price'] * $request['quantity']) + $request['tax'];
|
229 |
+
$itemDiscount = ($this->_product->getPrice() - $request['unit_price']);
|
230 |
+
|
231 |
+
$orderItem = Mage::getModel('sales/order_item')
|
232 |
+
->setStoreId($this->_store->getId())
|
233 |
+
->setQuoteItemId(0)
|
234 |
+
->setQuoteParentItemId(NULL)
|
235 |
+
->setProductId($this->_product->getId())
|
236 |
+
->setProductType($this->_product->getTypeId())
|
237 |
+
->setQtyBackordered(NULL)
|
238 |
+
->setTotalQtyOrdered($request['quantity'])
|
239 |
+
->setQtyOrdered($request['quantity'])
|
240 |
+
->setName($this->_product->getName())
|
241 |
+
->setSku($this->_product->getSku())
|
242 |
+
->setPrice($request['unit_price'])
|
243 |
+
->setBasePrice($request['unit_price'])
|
244 |
+
->setOriginalPrice($this->_product->getPrice())
|
245 |
+
// ->setDiscountAmount($itemDiscount)
|
246 |
+
->setTaxAmount($request['tax'])
|
247 |
+
->setRowTotal($rowTotal)
|
248 |
+
->setBaseRowTotal($rowTotal);
|
249 |
+
|
250 |
+
// Do we have a simple product with custom options, a bundle product, or a grouped product?
|
251 |
+
if (($this->_product->getTypeId() == 'simple'
|
252 |
+
|| $this->_product->getTypeId() == 'bundle'
|
253 |
+
|| $this->_product->getTypeId() == 'grouped')
|
254 |
+
&& $request['product_option_count'] > 0) {
|
255 |
+
// Grab the options from the request, build $additionalOptions array
|
256 |
+
$additionalOptions = array();
|
257 |
+
for ($i = $request['product_option_count']; $i > 0; $i--) {
|
258 |
+
$additionalOptions[] = array(
|
259 |
+
'label' => $request['product_option_name' . $i],
|
260 |
+
'value' => $request['product_option_value' . $i]
|
261 |
+
);
|
262 |
+
}
|
263 |
+
|
264 |
+
// Apply the $additionalOptions array to the simple product
|
265 |
+
$orderItem->setProductOptions(array('additional_options' => $additionalOptions));
|
266 |
+
}
|
267 |
+
|
268 |
+
// Build and apply the order totals
|
269 |
+
$subTotal += $rowTotal;
|
270 |
+
$order->addItem($orderItem);
|
271 |
+
|
272 |
+
$order->setSubtotal($subTotal)
|
273 |
+
->setBaseSubtotal($subTotal)
|
274 |
+
->setGrandTotal($subTotal + $request['shipping'])
|
275 |
+
->setBaseGrandTotal($subTotal + $request['shipping']);
|
276 |
+
|
277 |
+
$order->addStatusHistoryComment("This order has been programmatically created by the PriceWaiter Name Your Price Widget.");
|
278 |
+
|
279 |
+
// Ok, done with the order.
|
280 |
+
$transaction->addObject($order);
|
281 |
+
$transaction->addCommitCallback(array($order, 'place'));
|
282 |
+
$transaction->addCommitCallback(array($order, 'save'));
|
283 |
+
$transaction->save();
|
284 |
+
|
285 |
+
// Capture the invoice
|
286 |
+
$invoiceId = Mage::getModel('sales/order_invoice_api')
|
287 |
+
->create($order->getIncrementId(), array());
|
288 |
+
$invoice = Mage::getModel('sales/order_invoice')
|
289 |
+
->loadByIncrementId($invoiceId);
|
290 |
+
$invoice->capture()->save();
|
291 |
+
|
292 |
+
// Add this order to the list of received callback orders
|
293 |
+
$pricewaiterOrder->setData(array(
|
294 |
+
'store_id' => $order->getStoreId(),
|
295 |
+
'pricewaiter_id' => $request['pricewaiter_id'],
|
296 |
+
'order_id' => $order->getId()
|
297 |
+
));
|
298 |
+
$pricewaiterOrder->save();
|
299 |
+
|
300 |
+
Mage::log("The Name Your Price Widget has created order #"
|
301 |
+
. $order->getIncrementId() . " with order ID " . $order->getId());
|
302 |
+
$this->_log("The Name Your Price Widget has created order #"
|
303 |
+
. $order->getIncrementId() . " with order ID " . $order->getId());
|
304 |
+
}
|
305 |
+
catch (Exception $e){
|
306 |
+
$this->_log("PriceWaiter Name Your Price Widget was unable to create order. Check log for details.");
|
307 |
+
$this->_log($e->getMessage());
|
308 |
+
}
|
309 |
+
|
310 |
+
}
|
311 |
+
|
312 |
+
private function _log($message)
|
313 |
+
{
|
314 |
+
if (Mage::getStoreConfig('pricewaiter/configuration/log')) {
|
315 |
+
Mage::log($message, null, "PriceWaiter_Callback.log");
|
316 |
+
}
|
317 |
+
}
|
318 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Carrier/ShippingMethod.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Carrier_ShippingMethod
|
19 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
20 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
21 |
+
{
|
22 |
+
protected $_code = 'nypwidget';
|
23 |
+
protected $_isFixed = true;
|
24 |
+
|
25 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
26 |
+
{
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getAllowedMethods()
|
31 |
+
{
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Category.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Category extends Mage_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
public function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('nypwidget/category', 'entity_id');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function loadByCategory($category, $storeId = null)
|
26 |
+
{
|
27 |
+
if (is_object($category)) {
|
28 |
+
$categoryID = $category->getId();
|
29 |
+
} else {
|
30 |
+
$categoryID = $category;
|
31 |
+
}
|
32 |
+
|
33 |
+
if (is_null($storeId)) {
|
34 |
+
$storeId = Mage::app()->getStore()->getId();
|
35 |
+
}
|
36 |
+
|
37 |
+
$collection = Mage::getModel('nypwidget/category')
|
38 |
+
->getCollection()
|
39 |
+
->addFieldToFilter('category_id', $categoryID)
|
40 |
+
->addFieldToFilter('store_id', $storeId);
|
41 |
+
|
42 |
+
if (count($collection)) {
|
43 |
+
$this->load($collection->getFirstItem()->getEntityId());
|
44 |
+
} else {
|
45 |
+
$this->setData('category_id', $categoryID);
|
46 |
+
$this->setData('store_id', $storeId);
|
47 |
+
$this->save();
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function isActive($admin = false)
|
54 |
+
{
|
55 |
+
// If we are in the admin, we want to skip all this, so that we return
|
56 |
+
// the info on this specific category, not parents
|
57 |
+
if (!$admin) {
|
58 |
+
// First, check the "All Store Views" store (0)
|
59 |
+
if ($this->getStoreId() != 0) {
|
60 |
+
$allStoresCategory = Mage::getModel('nypwidget/category')
|
61 |
+
->loadByCategory($this->getCategoryId(), 0);
|
62 |
+
if (!$allStoresCategory->isActive()) {
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
// Check the parent category if we already have a category_id and have a parent
|
68 |
+
if (!is_null($this->getData('category_id'))) {
|
69 |
+
$category = Mage::getModel('catalog/category')->load($this->getData('category_id'));
|
70 |
+
if ($category->getParentId() != 0) {
|
71 |
+
$parentCategory = Mage::getModel('nypwidget/category')->loadByCategory($category->getParentId());
|
72 |
+
if (!$parentCategory->isActive()) {
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
// If the category isn't yet set in the table, default to true.
|
80 |
+
// Otherwise, check the nypwidget_enabled field.
|
81 |
+
if (is_null($this->getData('category_id')) or $this->getData('nypwidget_enabled') == 1) {
|
82 |
+
return true;
|
83 |
+
}
|
84 |
+
|
85 |
+
if (is_null($this->getData('nypwidget_enabled'))) {
|
86 |
+
return true;
|
87 |
+
}
|
88 |
+
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Display/Phrase.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Display_Phrase
|
19 |
+
{
|
20 |
+
public function toOptionArray()
|
21 |
+
{
|
22 |
+
return array(
|
23 |
+
array('value' => 0, 'label' => Mage::helper('nypwidget/data')->__('Name Your Price')),
|
24 |
+
array('value' => 1, 'label' => Mage::helper('nypwidget/data')->__('Make an Offer')),
|
25 |
+
);
|
26 |
+
}
|
27 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Display/Size.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Display_Size
|
19 |
+
{
|
20 |
+
public function toOptionArray()
|
21 |
+
{
|
22 |
+
return array(
|
23 |
+
array('value' => 0, 'label' => Mage::helper('nypwidget/data')->__('Large')),
|
24 |
+
array('value' => 1, 'label' => Mage::helper('nypwidget/data')->__('Small')),
|
25 |
+
);
|
26 |
+
}
|
27 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract
|
19 |
+
{
|
20 |
+
public function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('nypwidget/category', 'entity_id');
|
23 |
+
}
|
24 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category/Collection.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
19 |
+
{
|
20 |
+
public function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('nypwidget/category', 'entity_id');
|
23 |
+
}
|
24 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Mysql4_Order extends Mage_Core_Model_Mysql4_Abstract
|
19 |
+
{
|
20 |
+
public function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('nypwidget/order', 'entity_id');
|
23 |
+
}
|
24 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order/Collection.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Mysql4_Order_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
19 |
+
{
|
20 |
+
public function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('nypwidget/order', 'entity_id');
|
23 |
+
}
|
24 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Observer.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Observer
|
19 |
+
{
|
20 |
+
// Adds the "PriceWaiter" tab to the "Manage Categories" page
|
21 |
+
public function addTab(Varien_Event_Observer $observer)
|
22 |
+
{
|
23 |
+
$tabs = $observer->getEvent()->getTabs();
|
24 |
+
$tabs->addTab('pricewaiter', array(
|
25 |
+
'label' => Mage::helper('catalog')->__('PriceWaiter'),
|
26 |
+
'content' => $tabs->getLayout()->createBlock(
|
27 |
+
'nypwidget/category')->toHtml(),
|
28 |
+
));
|
29 |
+
return true;
|
30 |
+
}
|
31 |
+
|
32 |
+
// Saves "PriceWaiter" options from Category page
|
33 |
+
public function saveCategory(Varien_Event_Observer $observer)
|
34 |
+
{
|
35 |
+
$category = $observer->getEvent()->getCategory();
|
36 |
+
$enabled = $observer->getEvent()->getRequest()->getPost();
|
37 |
+
$enabled = $enabled['pricewaiter']['enabled'];
|
38 |
+
|
39 |
+
// Save the current setting, by category, and store
|
40 |
+
$nypcategory = Mage::getModel('nypwidget/category')->loadByCategory($category, $category->getStore()->getId());
|
41 |
+
$nypcategory->setData('nypwidget_enabled', $enabled);
|
42 |
+
$nypcategory->save();
|
43 |
+
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Order.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Order extends Mage_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
public function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('nypwidget/order', 'entity_id');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function loadByPriceWaiterId($pricewaiterId)
|
26 |
+
{
|
27 |
+
if (is_null($pricewaiterId)) {
|
28 |
+
return false;
|
29 |
+
}
|
30 |
+
|
31 |
+
$collection = Mage::getModel('nypwidget/order')
|
32 |
+
->getCollection()
|
33 |
+
->addFieldToFilter('pricewaiter_id', $pricewaiterId);
|
34 |
+
|
35 |
+
if (count($collection)) {
|
36 |
+
$this->load($collection->getFirstItem()->getEntityId());
|
37 |
+
}
|
38 |
+
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/PaymentMethod.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
|
19 |
+
class PriceWaiter_NYPWidget_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
|
20 |
+
{
|
21 |
+
protected $_code = 'nypwidget';
|
22 |
+
|
23 |
+
protected $_isGateway = false;
|
24 |
+
protected $_canOrder = true;
|
25 |
+
protected $_canAuthorize = false;
|
26 |
+
protected $_canCapture = false;
|
27 |
+
protected $_canCapturePartial = false;
|
28 |
+
protected $_canRefund = false;
|
29 |
+
protected $_canVoid = true;
|
30 |
+
protected $_canUseInternal = true;
|
31 |
+
protected $_canUseCheckout = false;
|
32 |
+
protected $_canUseForMultishipping = false;
|
33 |
+
|
34 |
+
public function authorize(Varien_Object $payment, $amount)
|
35 |
+
{
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function capture(Varien_Object $payment, $amount)
|
40 |
+
{
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function void(Varien_Object $payment)
|
45 |
+
{
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function isAvailable($quote = null)
|
50 |
+
{
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/Model/Resource/Eav/Mysql4/Setup.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
|
19 |
+
{
|
20 |
+
|
21 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/controllers/CallbackController.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
class PriceWaiter_NYPWidget_CallbackController extends Mage_Core_Controller_Front_Action
|
19 |
+
{
|
20 |
+
|
21 |
+
public function indexAction()
|
22 |
+
{
|
23 |
+
if (!$this->getRequest()->isPost()) {
|
24 |
+
$this->_log("HTTP Request is invalid.");
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
try {
|
29 |
+
$request = $this->getRequest()->getPost();
|
30 |
+
if (!array_key_exists('pricewaiter_id', $request)) {
|
31 |
+
$this->_log($request);
|
32 |
+
$this->_log("PriceWaiter Notification is missing required fields.");
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
$this->_log("Incoming PriceWaiter order notification.");
|
36 |
+
$this->_log($request);
|
37 |
+
Mage::getModel('nypwidget/callback')->processRequest($request);
|
38 |
+
} catch (Exception $e) {
|
39 |
+
Mage::logException($e);
|
40 |
+
$this->_log($e);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
private function _log($message)
|
45 |
+
{
|
46 |
+
if (Mage::getStoreConfig('pricewaiter/configuration/log')) {
|
47 |
+
Mage::log($message, null, "PriceWaiter_Callback.log");
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
app/code/community/PriceWaiter/NYPWidget/etc/adminhtml.xml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!--
|
3 |
+
Copyright 2013 Price Waiter, LLC
|
4 |
+
|
5 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
you may not use this file except in compliance with the License.
|
7 |
+
You may obtain a copy of the License at
|
8 |
+
|
9 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
|
11 |
+
Unless required by applicable law or agreed to in writing, software
|
12 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
See the License for the specific language governing permissions and
|
15 |
+
limitations under the License.
|
16 |
+
-->
|
17 |
+
<config>
|
18 |
+
<acl>
|
19 |
+
<resources>
|
20 |
+
<all>
|
21 |
+
<title>Allow Everything</title>
|
22 |
+
</all>
|
23 |
+
<admin>
|
24 |
+
<children>
|
25 |
+
<system>
|
26 |
+
<children>
|
27 |
+
<config>
|
28 |
+
<children>
|
29 |
+
<pricewaiter translate="title">
|
30 |
+
<title>PriceWaiter</title>
|
31 |
+
</pricewaiter>
|
32 |
+
</children>
|
33 |
+
</config>
|
34 |
+
</children>
|
35 |
+
</system>
|
36 |
+
</children>
|
37 |
+
</admin>
|
38 |
+
</resources>
|
39 |
+
</acl>
|
40 |
+
</config>
|
app/code/community/PriceWaiter/NYPWidget/etc/config.xml
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!--
|
3 |
+
Copyright 2013 Price Waiter, LLC
|
4 |
+
|
5 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
you may not use this file except in compliance with the License.
|
7 |
+
You may obtain a copy of the License at
|
8 |
+
|
9 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
|
11 |
+
Unless required by applicable law or agreed to in writing, software
|
12 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
See the License for the specific language governing permissions and
|
15 |
+
limitations under the License.
|
16 |
+
-->
|
17 |
+
<config>
|
18 |
+
|
19 |
+
<modules>
|
20 |
+
<PriceWaiter_NYPWidget>
|
21 |
+
<version>1.2.2</version>
|
22 |
+
</PriceWaiter_NYPWidget>
|
23 |
+
</modules>
|
24 |
+
|
25 |
+
<global>
|
26 |
+
<models>
|
27 |
+
<nypwidget>
|
28 |
+
<class>PriceWaiter_NYPWidget_Model</class>
|
29 |
+
<resourceModel>nypwidget_mysql4</resourceModel>
|
30 |
+
</nypwidget>
|
31 |
+
<nypwidget_mysql4>
|
32 |
+
<class>PriceWaiter_NYPWidget_Model_Mysql4</class>
|
33 |
+
<entities>
|
34 |
+
<category>
|
35 |
+
<table>nypwidget_category</table>
|
36 |
+
</category>
|
37 |
+
<order>
|
38 |
+
<table>nypwidget_orders</table>
|
39 |
+
</order>
|
40 |
+
</entities>
|
41 |
+
</nypwidget_mysql4>
|
42 |
+
<nypwidget_category>
|
43 |
+
<class>PriceWaiter_NYPWidget_Model_Category</class>
|
44 |
+
<resourceModel>nypwidget_mysql4_category</resourceModel>
|
45 |
+
</nypwidget_category>
|
46 |
+
<nypwidget_mysql4_category>
|
47 |
+
<class>PriceWaiter_NYPWidget_Model_Mysql4_Category</class>
|
48 |
+
</nypwidget_mysql4_category>
|
49 |
+
</models>
|
50 |
+
<helpers>
|
51 |
+
<nypwidget>
|
52 |
+
<class>PriceWaiter_NYPWidget_Helper</class>
|
53 |
+
</nypwidget>
|
54 |
+
</helpers>
|
55 |
+
<blocks>
|
56 |
+
<nypwidget>
|
57 |
+
<class>PriceWaiter_NYPWidget_Block</class>
|
58 |
+
</nypwidget>
|
59 |
+
</blocks>
|
60 |
+
<resources>
|
61 |
+
<nypwidget_setup>
|
62 |
+
<setup>
|
63 |
+
<module>PriceWaiter_NYPWidget</module>
|
64 |
+
<class>PriceWaiter_NYPWidget_Model_Resource_Eav_Mysql4_Setup</class>
|
65 |
+
</setup>
|
66 |
+
<connection>
|
67 |
+
<use>core_setup</use>
|
68 |
+
</connection>
|
69 |
+
</nypwidget_setup>
|
70 |
+
<nypwidget_write>
|
71 |
+
<connection>
|
72 |
+
<use>core_write</use>
|
73 |
+
</connection>
|
74 |
+
</nypwidget_write>
|
75 |
+
<nypwidget_read>
|
76 |
+
<connection>
|
77 |
+
<use>core_read</use>
|
78 |
+
</connection>
|
79 |
+
</nypwidget_read>
|
80 |
+
</resources>
|
81 |
+
<events>
|
82 |
+
<adminhtml_catalog_category_tabs>
|
83 |
+
<observers>
|
84 |
+
<adminhtml_catalog_category_tabs_pricewaiter>
|
85 |
+
<type>model</type>
|
86 |
+
<class>nypwidget/observer</class>
|
87 |
+
<method>addTab</method>
|
88 |
+
<args></args>
|
89 |
+
</adminhtml_catalog_category_tabs_pricewaiter>
|
90 |
+
</observers>
|
91 |
+
</adminhtml_catalog_category_tabs>
|
92 |
+
<catalog_category_prepare_save>
|
93 |
+
<observers>
|
94 |
+
<catalog_category_prepare_save_pricewaiter>
|
95 |
+
<type>model</type>
|
96 |
+
<class>nypwidget/observer</class>
|
97 |
+
<method>saveCategory</method>
|
98 |
+
<args></args>
|
99 |
+
</catalog_category_prepare_save_pricewaiter>
|
100 |
+
</observers>
|
101 |
+
</catalog_category_prepare_save>
|
102 |
+
</events>
|
103 |
+
</global>
|
104 |
+
|
105 |
+
<frontend>
|
106 |
+
<layout>
|
107 |
+
<updates>
|
108 |
+
<nypwidget>
|
109 |
+
<file>pricewaiter.xml</file>
|
110 |
+
</nypwidget>
|
111 |
+
</updates>
|
112 |
+
</layout>
|
113 |
+
<routers>
|
114 |
+
<nypwidget>
|
115 |
+
<use>standard</use>
|
116 |
+
<args>
|
117 |
+
<module>PriceWaiter_NYPWidget</module>
|
118 |
+
<frontName>pricewaiter</frontName>
|
119 |
+
</args>
|
120 |
+
</nypwidget>
|
121 |
+
</routers>
|
122 |
+
</frontend>
|
123 |
+
|
124 |
+
<adminhtml>
|
125 |
+
<layout>
|
126 |
+
<updates>
|
127 |
+
<nypwidget>
|
128 |
+
<file>pricewaiter.xml</file>
|
129 |
+
</nypwidget>
|
130 |
+
</updates>
|
131 |
+
</layout>
|
132 |
+
</adminhtml>
|
133 |
+
|
134 |
+
<default>
|
135 |
+
<pricewaiter>
|
136 |
+
<configuration>
|
137 |
+
<enabled>0</enabled>
|
138 |
+
<log>1</log>
|
139 |
+
</configuration>
|
140 |
+
<appearance>
|
141 |
+
<display_size>1</display_size>
|
142 |
+
<display_color>5F82D4</display_color>
|
143 |
+
<display_hover_color>739DFF</display_hover_color>
|
144 |
+
</appearance>
|
145 |
+
<categories>
|
146 |
+
<disable_by_category>1</disable_by_category>
|
147 |
+
</categories>
|
148 |
+
</pricewaiter>
|
149 |
+
<payment>
|
150 |
+
<nypwidget>
|
151 |
+
<active>1</active>
|
152 |
+
<model>nypwidget/paymentMethod</model>
|
153 |
+
<order_status>pricewaiter_pending</order_status>
|
154 |
+
<title>PriceWaiter Payment</title>
|
155 |
+
<payment_action>authorize</payment_action>
|
156 |
+
<allowspecific>0</allowspecific>
|
157 |
+
</nypwidget>
|
158 |
+
</payment>
|
159 |
+
<carriers>
|
160 |
+
<nypwidget>
|
161 |
+
<active>1</active>
|
162 |
+
<allowed_methods>delivery</allowed_methods>
|
163 |
+
<methods>delivery</methods>
|
164 |
+
<allowspecific>0</allowspecific>
|
165 |
+
<model>PriceWaiter_NYPWidget_Model_Carrier_ShippingMethod</model>
|
166 |
+
<name>PriceWaiter Shipping Method</name>
|
167 |
+
<title>PriceWaiter Shipping Method</title>
|
168 |
+
<type>O</type>
|
169 |
+
<handling_type>F</handling_type>
|
170 |
+
</nypwidget>
|
171 |
+
</carriers>
|
172 |
+
</default>
|
173 |
+
|
174 |
+
</config>
|
app/code/community/PriceWaiter/NYPWidget/etc/system.xml
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!--
|
3 |
+
Copyright 2013 Price Waiter, LLC
|
4 |
+
|
5 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
you may not use this file except in compliance with the License.
|
7 |
+
You may obtain a copy of the License at
|
8 |
+
|
9 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
|
11 |
+
Unless required by applicable law or agreed to in writing, software
|
12 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
See the License for the specific language governing permissions and
|
15 |
+
limitations under the License.
|
16 |
+
-->
|
17 |
+
<config>
|
18 |
+
<sections>
|
19 |
+
<pricewaiter>
|
20 |
+
<label>PriceWaiter</label>
|
21 |
+
<tab>sales</tab>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>100</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
+
<class>pricewaiter-tab</class>
|
28 |
+
<header_css>pricewaiter-header</header_css>
|
29 |
+
<groups>
|
30 |
+
<configuration translate="label">
|
31 |
+
<label>Configuration</label>
|
32 |
+
<frontend_type>text</frontend_type>
|
33 |
+
<sort_order>1</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>1</show_in_store>
|
37 |
+
<expanded>1</expanded>
|
38 |
+
<fields>
|
39 |
+
<enabled translate="label comment">
|
40 |
+
<label>Enabled</label>
|
41 |
+
<comment>
|
42 |
+
<![CDATA[Disabling the widget will hide it on
|
43 |
+
all product pages.]]>
|
44 |
+
</comment>
|
45 |
+
<frontend_type>select</frontend_type>
|
46 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
47 |
+
<sort_order>10</sort_order>
|
48 |
+
<show_in_default>1</show_in_default>
|
49 |
+
<show_in_website>1</show_in_website>
|
50 |
+
<show_in_store>1</show_in_store>
|
51 |
+
</enabled>
|
52 |
+
<api_key translate="label comment">
|
53 |
+
<label>API Key</label>
|
54 |
+
<comment>
|
55 |
+
<![CDATA[The API Key you were given when signing
|
56 |
+
up for PriceWaiter. If you do not have one,
|
57 |
+
sign up <a href="http://www.pricewaiter.com/">here</a>.]]>
|
58 |
+
</comment>
|
59 |
+
<frontend_type>text</frontend_type>
|
60 |
+
<sort_order>20</sort_order>
|
61 |
+
<show_in_default>1</show_in_default>
|
62 |
+
<show_in_website>1</show_in_website>
|
63 |
+
<show_in_store>1</show_in_store>
|
64 |
+
</api_key>
|
65 |
+
<log translate="label comment">
|
66 |
+
<label>Log Callback Information</label>
|
67 |
+
<comment>
|
68 |
+
<![CDATA[Log information about order
|
69 |
+
notifications from PriceWaiter. For
|
70 |
+
information about setting up the
|
71 |
+
callback function, go <a
|
72 |
+
href="http://www.pricewaiter.com/">here</a>.]]>
|
73 |
+
</comment>
|
74 |
+
<frontend_type>select</frontend_type>
|
75 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
76 |
+
<sort_order>10</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>1</show_in_website>
|
79 |
+
<show_in_store>1</show_in_store>
|
80 |
+
</log>
|
81 |
+
</fields>
|
82 |
+
</configuration>
|
83 |
+
<appearance translate="label">
|
84 |
+
<label>Appearance</label>
|
85 |
+
<frontend_type>text</frontend_type>
|
86 |
+
<sort_order>10</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>1</show_in_store>
|
90 |
+
<expanded>1</expanded>
|
91 |
+
<fields>
|
92 |
+
<preview translate="label comment"><!--#pricewaiter_appearance_preview-->
|
93 |
+
<label>Preview</label>
|
94 |
+
<comment>
|
95 |
+
<![CDATA[What the "Name Your Price" widget will
|
96 |
+
look like on your product pages.]]>
|
97 |
+
</comment>
|
98 |
+
<frontend_type>hidden</frontend_type>
|
99 |
+
<sort_order>10</sort_order>
|
100 |
+
<show_in_default>1</show_in_default>
|
101 |
+
<show_in_website>1</show_in_website>
|
102 |
+
<show_in_store>1</show_in_store>
|
103 |
+
</preview>
|
104 |
+
</fields>
|
105 |
+
<fields>
|
106 |
+
<display_phrase translate="label comment"><!--#pricewaiter_appearance_button_phrase-->
|
107 |
+
<label>Button Phrase</label>
|
108 |
+
<comment>
|
109 |
+
<![CDATA[Should the PriceWaiter Button read "Name Your Price"
|
110 |
+
or "Make an Offer"?]]>
|
111 |
+
</comment>
|
112 |
+
<frontend_type>select</frontend_type>
|
113 |
+
<source_model>nypwidget/display_phrase</source_model>
|
114 |
+
<sort_order>10</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>1</show_in_website>
|
117 |
+
<show_in_store>1</show_in_store>
|
118 |
+
</display_phrase>
|
119 |
+
</fields>
|
120 |
+
<fields>
|
121 |
+
<display_size translate="label comment"><!--#pricewaiter_appearance_display_size-->
|
122 |
+
<label>Display Size</label>
|
123 |
+
<comment></comment>
|
124 |
+
<frontend_type>select</frontend_type>
|
125 |
+
<source_model>nypwidget/display_size</source_model>
|
126 |
+
<sort_order>20</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>1</show_in_website>
|
129 |
+
<show_in_store>1</show_in_store>
|
130 |
+
</display_size>
|
131 |
+
</fields>
|
132 |
+
<fields>
|
133 |
+
<display_color translate="label comment"><!--#pricewaiter_appearance_button_color-->
|
134 |
+
<label>Color</label>
|
135 |
+
<comment>
|
136 |
+
<![CDATA[The button background color in hexadecimal notation.]]>
|
137 |
+
</comment>
|
138 |
+
<frontend_type>text</frontend_type>
|
139 |
+
<validate>color</validate>
|
140 |
+
<sort_order>30</sort_order>
|
141 |
+
<show_in_default>1</show_in_default>
|
142 |
+
<show_in_website>1</show_in_website>
|
143 |
+
<show_in_store>1</show_in_store>
|
144 |
+
</display_color>
|
145 |
+
<display_hover_color translate="label comment"><!--#pricewaiter_appearance_button_hover_color-->
|
146 |
+
<label>Hover Color</label>
|
147 |
+
<comment>
|
148 |
+
<![CDATA[The button background color, in hexadecimal notation, when it
|
149 |
+
is being hovered over.]]>
|
150 |
+
</comment>
|
151 |
+
<frontend_type>text</frontend_type>
|
152 |
+
<validate>color</validate>
|
153 |
+
<sort_order>40</sort_order>
|
154 |
+
<show_in_default>1</show_in_default>
|
155 |
+
<show_in_website>1</show_in_website>
|
156 |
+
<show_in_store>1</show_in_store>
|
157 |
+
</display_hover_color>
|
158 |
+
</fields>
|
159 |
+
</appearance>
|
160 |
+
<categories>
|
161 |
+
<label>Categories</label>
|
162 |
+
<frontend_type>text</frontend_type>
|
163 |
+
<sort_order>15</sort_order>
|
164 |
+
<show_in_default>1</show_in_default>
|
165 |
+
<show_in_website>1</show_in_website>
|
166 |
+
<show_in_store>1</show_in_store>
|
167 |
+
<expanded>1</expanded>
|
168 |
+
<fields>
|
169 |
+
<disable_by_category>
|
170 |
+
<label>Disable the PriceWaiter Widget by Category?</label>
|
171 |
+
<comment>
|
172 |
+
<![CDATA[With this enabled, you can disable the PriceWaiter Name Your Price Widget by Category.
|
173 |
+
Visit the "PriceWaiter" tab for the category you want to adjust by going to
|
174 |
+
"Catalog"->"Manage Categories".]]>
|
175 |
+
</comment>
|
176 |
+
<frontend_type>select</frontend_type>
|
177 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
178 |
+
<sort_order>10</sort_order>
|
179 |
+
<show_in_default>1</show_in_default>
|
180 |
+
<show_in_website>1</show_in_website>
|
181 |
+
<show_in_store>1</show_in_store>
|
182 |
+
</disable_by_category>
|
183 |
+
</fields>
|
184 |
+
</categories>
|
185 |
+
</groups>
|
186 |
+
</pricewaiter>
|
187 |
+
</sections>
|
188 |
+
</config>
|
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
|
19 |
+
// Product types supported by the Name Your Price Widget
|
20 |
+
// $supportTypeIds = array('simple', 'configurable');
|
21 |
+
$installer = $this;
|
22 |
+
$installer->startSetup();
|
23 |
+
|
24 |
+
// Create a table to store category information --
|
25 |
+
// Magento's Category attributes are not stable enough to bolt onto,
|
26 |
+
// especially in bigger stores.
|
27 |
+
$installer->run("
|
28 |
+
DROP TABLE IF EXISTS {$this->getTable('nypwidget_category')};
|
29 |
+
CREATE TABLE {$this->getTable('nypwidget_category')} (
|
30 |
+
PRIMARY KEY (`entity_id`),
|
31 |
+
`entity_id` int(11) unsigned NOT NULL auto_increment,
|
32 |
+
`category_id` int(11) unsigned NOT NULL,
|
33 |
+
`store_id` int(11) unsigned NOT NULL,
|
34 |
+
`nypwidget_enabled` tinyint(1) NOT NULL default '1'
|
35 |
+
);
|
36 |
+
");
|
37 |
+
|
38 |
+
// Create a new "Pending - PriceWaiter" status for orders
|
39 |
+
// that have been pulled from PriceWaiter back into Magento
|
40 |
+
$installer->run("
|
41 |
+
INSERT INTO `{$this->getTable('sales/order_status')}` (
|
42 |
+
`status`, `label`
|
43 |
+
) VALUES (
|
44 |
+
'pricewaiter_pending', 'Pending - PriceWaiter'
|
45 |
+
);
|
46 |
+
INSERT INTO `{$this->getTable('sales/order_status_state')}` (
|
47 |
+
`status`, `state`, `is_default`
|
48 |
+
) VALUES (
|
49 |
+
'pricewaiter_pending', 'pending', '0'
|
50 |
+
);
|
51 |
+
");
|
52 |
+
|
53 |
+
// The default value above only applies to new products.
|
54 |
+
// Build a collection of products, and set 'nypwidget_enabled' to the default value
|
55 |
+
// This part can take a bit of time.
|
56 |
+
// Mage::app()->setUpdateMode(false);
|
57 |
+
// Mage::app()->setCurrentStore(0);
|
58 |
+
|
59 |
+
// $products = Mage::getModel('catalog/product')->getCollection()
|
60 |
+
// ->addAttributeToFilter('type_id', array('in' => $supportTypeIds));
|
61 |
+
|
62 |
+
// foreach ($products as $product) {
|
63 |
+
// Mage::getSingleton('catalog/product_action')
|
64 |
+
// ->updateAttributes(array($product->getId()), array('nypwidget_enabled' => 1), 0);
|
65 |
+
// }
|
66 |
+
|
67 |
+
?>
|
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.2-1.1.3.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
|
19 |
+
// Product types supported by the Name Your Price Widget
|
20 |
+
$supportTypeIds = array('simple', 'configurable', 'grouped', 'bundle');
|
21 |
+
$installer = $this;
|
22 |
+
$installer->startSetup();
|
23 |
+
|
24 |
+
// Remove the old attribute
|
25 |
+
$installer->removeAttribute('catalog_product', 'nypwidget_enabled');
|
26 |
+
|
27 |
+
// Add a new attribute to all prodcuts to toggle the Widget on/off
|
28 |
+
$installer->addAttribute('catalog_product', 'nypwidget_disabled',
|
29 |
+
array(
|
30 |
+
'group' => 'General',
|
31 |
+
'label' => 'Disable PriceWaiter Widget?',
|
32 |
+
'type' => 'int',
|
33 |
+
'input' => 'boolean',
|
34 |
+
'default' => '0',
|
35 |
+
'class' => '',
|
36 |
+
'backend' => '',
|
37 |
+
'frontend' => '',
|
38 |
+
'source' => '',
|
39 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
40 |
+
'visible' => true,
|
41 |
+
'required' => true,
|
42 |
+
'user_defined' => false,
|
43 |
+
'searchable' => true,
|
44 |
+
'filterable' => true,
|
45 |
+
'comparable' => true,
|
46 |
+
'visible_on_front' => true,
|
47 |
+
'visible_in_advanced_search' => false,
|
48 |
+
'unique' => false,
|
49 |
+
'apply_to' => $supportTypeIds,
|
50 |
+
)
|
51 |
+
);
|
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.7-1.1.8.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
|
19 |
+
// Add table to keep track of order IDs associated with `pricewaiter_id`s
|
20 |
+
// Will prevent duplicate orders from the order callback API
|
21 |
+
$installer = $this;
|
22 |
+
$installer->startSetup();
|
23 |
+
$installer->run("
|
24 |
+
DROP TABLE IF EXISTS {$this->getTable('nypwidget_orders')};
|
25 |
+
CREATE TABLE {$this->getTable('nypwidget_orders')} (
|
26 |
+
PRIMARY KEY (`entity_id`),
|
27 |
+
`entity_id` int(11) unsigned NOT NULL auto_increment,
|
28 |
+
`store_id` int(11) unsigned NOT NULL,
|
29 |
+
`pricewaiter_id` varchar(100) NOT NULL,
|
30 |
+
`order_id` int(11) unsigned NOT NULL
|
31 |
+
);
|
32 |
+
");
|
app/design/adminhtml/default/default/layout/pricewaiter.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!--
|
3 |
+
Copyright 2013 Price Waiter, LLC
|
4 |
+
|
5 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
you may not use this file except in compliance with the License.
|
7 |
+
You may obtain a copy of the License at
|
8 |
+
|
9 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
|
11 |
+
Unless required by applicable law or agreed to in writing, software
|
12 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
See the License for the specific language governing permissions and
|
15 |
+
limitations under the License.
|
16 |
+
-->
|
17 |
+
<layout>
|
18 |
+
<adminhtml_system_config_edit>
|
19 |
+
<reference name="head">
|
20 |
+
<action method="addCss"><name>pricewaiter.css</name></action>
|
21 |
+
<action method="addJs"><name>jscolor-pw/jscolor.js</name></action>
|
22 |
+
<action method="addJs"><name>pricewaiter/product-pages.js</name></action>
|
23 |
+
</reference>
|
24 |
+
<reference name="content">
|
25 |
+
<block type="nypwidget/adminhtml_widget" name="widget_preview" as="widget_preview" template="pricewaiter/admin_widget.phtml"></block>
|
26 |
+
</reference>
|
27 |
+
</adminhtml_system_config_edit>
|
28 |
+
</layout>
|
app/design/adminhtml/default/default/template/pricewaiter/admin_widget.phtml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
?>
|
19 |
+
<?php $helper = $this->_getHelper(); ?>
|
20 |
+
<script type="text/javascript">
|
21 |
+
//<![CDATA[
|
22 |
+
<?php echo $helper->getPriceWaiterOptions(); ?>
|
23 |
+
<?php echo $helper->getProductOptions(true); ?>
|
24 |
+
|
25 |
+
var PriceWaiterWidgetUrl = "<?php echo $helper->getWidgetUrl(); ?>";
|
26 |
+
|
27 |
+
function adminPW() {
|
28 |
+
$('pricewaiter_appearance_preview').up().innerHTML = '<span id="pricewaiter"></span><p class="note"><span> What the "Name Your Price" widget will look like on your product pages. </span></p>';
|
29 |
+
}
|
30 |
+
|
31 |
+
//]]>
|
32 |
+
</script>
|
app/design/adminhtml/default/default/template/pricewaiter/categorytab.phtml
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
?>
|
19 |
+
<?php
|
20 |
+
$enabled = $this->getIsEnabled();
|
21 |
+
?>
|
22 |
+
<div class="entry-edit">
|
23 |
+
<div class="entry-edit-head">
|
24 |
+
<h4 class="icon-head head-edit-form fieldset-legend">PriceWaiter Widget</h4>
|
25 |
+
</div>
|
26 |
+
<div class="fieldset fieldset-wide" id="group_pricewaiter">
|
27 |
+
<div class="hor-scroll">
|
28 |
+
<table cellspacing="0" class="form-list">
|
29 |
+
<tbody>
|
30 |
+
|
31 |
+
<tr>
|
32 |
+
<td class="label"><label for="group_pricewaiter_enabled">Enabled</label></td>
|
33 |
+
<td class="value">
|
34 |
+
<select id="group_pricewaiter_enabled" name="pricewaiter[enabled]" class=" select">
|
35 |
+
<option value="1" <?php if ($enabled):?>selected="selected"<?php endif;?>>Yes</option>
|
36 |
+
<option value="0" <?php if (!$enabled):?>selected="selected"<?php endif;?>>No</option>
|
37 |
+
</select>
|
38 |
+
</td>
|
39 |
+
<td class="scope-label">
|
40 |
+
<span class="nobr">[STORE VIEW]</span>
|
41 |
+
</td>
|
42 |
+
</tr>
|
43 |
+
|
44 |
+
</tbody>
|
45 |
+
</table>
|
46 |
+
</div>
|
47 |
+
</div>
|
48 |
+
</div>
|
app/design/frontend/base/default/layout/pricewaiter.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!--
|
3 |
+
Copyright 2013 Price Waiter, LLC
|
4 |
+
|
5 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
you may not use this file except in compliance with the License.
|
7 |
+
You may obtain a copy of the License at
|
8 |
+
|
9 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
|
11 |
+
Unless required by applicable law or agreed to in writing, software
|
12 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
See the License for the specific language governing permissions and
|
15 |
+
limitations under the License.
|
16 |
+
-->
|
17 |
+
<layout>
|
18 |
+
<catalog_product_view>
|
19 |
+
<reference name="head">
|
20 |
+
<action method="addJs"><name>pricewaiter/product-pages.js</name></action>
|
21 |
+
</reference>
|
22 |
+
<reference name="product.info.addtocart">
|
23 |
+
<block type="nypwidget/widget" name="pricewaiter_widget" template="pricewaiter/widget.phtml" as="pricewaiter.widget" />
|
24 |
+
</reference>
|
25 |
+
</catalog_product_view>
|
26 |
+
</layout>
|
app/design/frontend/base/default/template/pricewaiter/widget.phtml
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright 2013 Price Waiter, LLC
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
* you may not use this file except in compliance with the License.
|
7 |
+
* You may obtain a copy of the License at
|
8 |
+
*
|
9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
*
|
11 |
+
* Unless required by applicable law or agreed to in writing, software
|
12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
* See the License for the specific language governing permissions and
|
15 |
+
* limitations under the License.
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
?>
|
19 |
+
<?php $_product = Mage::registry('current_product'); ?>
|
20 |
+
<?php if($_product->isSaleable()): ?>
|
21 |
+
<?php
|
22 |
+
$helper = $this->_getHelper();
|
23 |
+
if ($helper->isEnabled()):
|
24 |
+
?>
|
25 |
+
<script type="text/javascript">
|
26 |
+
//<![CDATA[
|
27 |
+
<?php echo $helper->getPriceWaiterOptions(); ?>
|
28 |
+
<?php echo $helper->getProductOptions(); ?>
|
29 |
+
var PriceWaiterWidgetUrl = "<?php echo $helper->getWidgetUrl(); ?>";
|
30 |
+
//]]>
|
31 |
+
</script>
|
32 |
+
<div class="name-your-price-widget" style='display: block; clear: both; padding-top: 10px;'>
|
33 |
+
<span id="pricewaiter"></span>
|
34 |
+
</div>
|
35 |
+
<?php endif; ?>
|
36 |
+
<?php endif; ?>
|
app/etc/modules/PriceWaiter_NYPWidget.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!--
|
3 |
+
Copyright 2013 Price Waiter, LLC
|
4 |
+
|
5 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
you may not use this file except in compliance with the License.
|
7 |
+
You may obtain a copy of the License at
|
8 |
+
|
9 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
|
11 |
+
Unless required by applicable law or agreed to in writing, software
|
12 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
See the License for the specific language governing permissions and
|
15 |
+
limitations under the License.
|
16 |
+
-->
|
17 |
+
<config>
|
18 |
+
<modules>
|
19 |
+
<PriceWaiter_NYPWidget>
|
20 |
+
<active>true</active>
|
21 |
+
<codePool>community</codePool>
|
22 |
+
</PriceWaiter_NYPWidget>
|
23 |
+
</modules>
|
24 |
+
</config>
|
js/jscolor-pw/arrow.gif
ADDED
Binary file
|
js/jscolor-pw/cross.gif
ADDED
Binary file
|
js/jscolor-pw/hs.png
ADDED
Binary file
|
js/jscolor-pw/hv.png
ADDED
Binary file
|
js/jscolor-pw/jscolor.js
ADDED
@@ -0,0 +1,935 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* jscolor, JavaScript Color Picker
|
3 |
+
*
|
4 |
+
* @version 1.3.13
|
5 |
+
* @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
|
6 |
+
* @author Jan Odvarko, http://odvarko.cz
|
7 |
+
* @created 2008-06-15
|
8 |
+
* @updated 2012-01-19
|
9 |
+
* @link http://jscolor.com
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
var jscolor = {
|
14 |
+
|
15 |
+
|
16 |
+
dir : '', // location of jscolor directory (leave empty to autodetect)
|
17 |
+
bindClass : 'color', // class name
|
18 |
+
binding : true, // automatic binding via <input class="...">
|
19 |
+
preloading : true, // use image preloading?
|
20 |
+
|
21 |
+
|
22 |
+
install : function() {
|
23 |
+
jscolor.addEvent(window, 'load', jscolor.init);
|
24 |
+
},
|
25 |
+
|
26 |
+
|
27 |
+
init : function() {
|
28 |
+
if(jscolor.binding) {
|
29 |
+
jscolor.bind();
|
30 |
+
}
|
31 |
+
if(jscolor.preloading) {
|
32 |
+
jscolor.preload();
|
33 |
+
}
|
34 |
+
},
|
35 |
+
|
36 |
+
|
37 |
+
getDir : function() {
|
38 |
+
if(!jscolor.dir) {
|
39 |
+
var detected = jscolor.detectDir();
|
40 |
+
jscolor.dir = detected!==false ? detected : 'jscolor/';
|
41 |
+
}
|
42 |
+
return jscolor.dir;
|
43 |
+
},
|
44 |
+
|
45 |
+
|
46 |
+
detectDir : function() {
|
47 |
+
var base = location.href;
|
48 |
+
|
49 |
+
var e = document.getElementsByTagName('base');
|
50 |
+
for(var i=0; i<e.length; i+=1) {
|
51 |
+
if(e[i].href) { base = e[i].href; }
|
52 |
+
}
|
53 |
+
|
54 |
+
var e = document.getElementsByTagName('script');
|
55 |
+
for(var i=0; i<e.length; i+=1) {
|
56 |
+
if(e[i].src && /(^|\/)jscolor\.js([?#].*)?$/i.test(e[i].src)) {
|
57 |
+
var src = new jscolor.URI(e[i].src);
|
58 |
+
var srcAbs = src.toAbsolute(base);
|
59 |
+
srcAbs.path = srcAbs.path.replace(/[^\/]+$/, ''); // remove filename
|
60 |
+
srcAbs.query = null;
|
61 |
+
srcAbs.fragment = null;
|
62 |
+
return srcAbs.toString();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return false;
|
66 |
+
},
|
67 |
+
|
68 |
+
|
69 |
+
bind : function() {
|
70 |
+
var matchClass = new RegExp('(^|\\s)('+jscolor.bindClass+')\\s*(\\{[^}]*\\})?', 'i');
|
71 |
+
var e = document.getElementsByTagName('input');
|
72 |
+
for(var i=0; i<e.length; i+=1) {
|
73 |
+
var m;
|
74 |
+
if(!e[i].color && e[i].className && (m = e[i].className.match(matchClass))) {
|
75 |
+
var prop = {};
|
76 |
+
if(m[3]) {
|
77 |
+
try {
|
78 |
+
eval('prop='+m[3]);
|
79 |
+
} catch(eInvalidProp) {}
|
80 |
+
}
|
81 |
+
e[i].color = new jscolor.color(e[i], prop);
|
82 |
+
}
|
83 |
+
}
|
84 |
+
},
|
85 |
+
|
86 |
+
|
87 |
+
preload : function() {
|
88 |
+
for(var fn in jscolor.imgRequire) {
|
89 |
+
if(jscolor.imgRequire.hasOwnProperty(fn)) {
|
90 |
+
jscolor.loadImage(fn);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
},
|
94 |
+
|
95 |
+
|
96 |
+
images : {
|
97 |
+
pad : [ 181, 101 ],
|
98 |
+
sld : [ 16, 101 ],
|
99 |
+
cross : [ 15, 15 ],
|
100 |
+
arrow : [ 7, 11 ]
|
101 |
+
},
|
102 |
+
|
103 |
+
|
104 |
+
imgRequire : {},
|
105 |
+
imgLoaded : {},
|
106 |
+
|
107 |
+
|
108 |
+
requireImage : function(filename) {
|
109 |
+
jscolor.imgRequire[filename] = true;
|
110 |
+
},
|
111 |
+
|
112 |
+
|
113 |
+
loadImage : function(filename) {
|
114 |
+
if(!jscolor.imgLoaded[filename]) {
|
115 |
+
jscolor.imgLoaded[filename] = new Image();
|
116 |
+
jscolor.imgLoaded[filename].src = jscolor.getDir()+filename;
|
117 |
+
}
|
118 |
+
},
|
119 |
+
|
120 |
+
|
121 |
+
fetchElement : function(mixed) {
|
122 |
+
return typeof mixed === 'string' ? document.getElementById(mixed) : mixed;
|
123 |
+
},
|
124 |
+
|
125 |
+
|
126 |
+
addEvent : function(el, evnt, func) {
|
127 |
+
if(el.addEventListener) {
|
128 |
+
el.addEventListener(evnt, func, false);
|
129 |
+
} else if(el.attachEvent) {
|
130 |
+
el.attachEvent('on'+evnt, func);
|
131 |
+
}
|
132 |
+
},
|
133 |
+
|
134 |
+
|
135 |
+
fireEvent : function(el, evnt) {
|
136 |
+
if(!el) {
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
if(document.createEvent) {
|
140 |
+
var ev = document.createEvent('HTMLEvents');
|
141 |
+
ev.initEvent(evnt, true, true);
|
142 |
+
el.dispatchEvent(ev);
|
143 |
+
} else if(document.createEventObject) {
|
144 |
+
var ev = document.createEventObject();
|
145 |
+
el.fireEvent('on'+evnt, ev);
|
146 |
+
} else if(el['on'+evnt]) { // alternatively use the traditional event model (IE5)
|
147 |
+
el['on'+evnt]();
|
148 |
+
}
|
149 |
+
},
|
150 |
+
|
151 |
+
|
152 |
+
getElementPos : function(e) {
|
153 |
+
var e1=e, e2=e;
|
154 |
+
var x=0, y=0;
|
155 |
+
if(e1.offsetParent) {
|
156 |
+
do {
|
157 |
+
x += e1.offsetLeft;
|
158 |
+
y += e1.offsetTop;
|
159 |
+
} while(e1 = e1.offsetParent);
|
160 |
+
}
|
161 |
+
while((e2 = e2.parentNode) && e2.nodeName.toUpperCase() !== 'BODY') {
|
162 |
+
x -= e2.scrollLeft;
|
163 |
+
y -= e2.scrollTop;
|
164 |
+
}
|
165 |
+
return [x, y];
|
166 |
+
},
|
167 |
+
|
168 |
+
|
169 |
+
getElementSize : function(e) {
|
170 |
+
return [e.offsetWidth, e.offsetHeight];
|
171 |
+
},
|
172 |
+
|
173 |
+
|
174 |
+
getRelMousePos : function(e) {
|
175 |
+
var x = 0, y = 0;
|
176 |
+
if (!e) { e = window.event; }
|
177 |
+
if (typeof e.offsetX === 'number') {
|
178 |
+
x = e.offsetX;
|
179 |
+
y = e.offsetY;
|
180 |
+
} else if (typeof e.layerX === 'number') {
|
181 |
+
x = e.layerX;
|
182 |
+
y = e.layerY;
|
183 |
+
}
|
184 |
+
return { x: x, y: y };
|
185 |
+
},
|
186 |
+
|
187 |
+
|
188 |
+
getViewPos : function() {
|
189 |
+
if(typeof window.pageYOffset === 'number') {
|
190 |
+
return [window.pageXOffset, window.pageYOffset];
|
191 |
+
} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
|
192 |
+
return [document.body.scrollLeft, document.body.scrollTop];
|
193 |
+
} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
|
194 |
+
return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
|
195 |
+
} else {
|
196 |
+
return [0, 0];
|
197 |
+
}
|
198 |
+
},
|
199 |
+
|
200 |
+
|
201 |
+
getViewSize : function() {
|
202 |
+
if(typeof window.innerWidth === 'number') {
|
203 |
+
return [window.innerWidth, window.innerHeight];
|
204 |
+
} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
|
205 |
+
return [document.body.clientWidth, document.body.clientHeight];
|
206 |
+
} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
|
207 |
+
return [document.documentElement.clientWidth, document.documentElement.clientHeight];
|
208 |
+
} else {
|
209 |
+
return [0, 0];
|
210 |
+
}
|
211 |
+
},
|
212 |
+
|
213 |
+
|
214 |
+
URI : function(uri) { // See RFC3986
|
215 |
+
|
216 |
+
this.scheme = null;
|
217 |
+
this.authority = null;
|
218 |
+
this.path = '';
|
219 |
+
this.query = null;
|
220 |
+
this.fragment = null;
|
221 |
+
|
222 |
+
this.parse = function(uri) {
|
223 |
+
var m = uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);
|
224 |
+
this.scheme = m[3] ? m[2] : null;
|
225 |
+
this.authority = m[5] ? m[6] : null;
|
226 |
+
this.path = m[7];
|
227 |
+
this.query = m[9] ? m[10] : null;
|
228 |
+
this.fragment = m[12] ? m[13] : null;
|
229 |
+
return this;
|
230 |
+
};
|
231 |
+
|
232 |
+
this.toString = function() {
|
233 |
+
var result = '';
|
234 |
+
if(this.scheme !== null) { result = result + this.scheme + ':'; }
|
235 |
+
if(this.authority !== null) { result = result + '//' + this.authority; }
|
236 |
+
if(this.path !== null) { result = result + this.path; }
|
237 |
+
if(this.query !== null) { result = result + '?' + this.query; }
|
238 |
+
if(this.fragment !== null) { result = result + '#' + this.fragment; }
|
239 |
+
return result;
|
240 |
+
};
|
241 |
+
|
242 |
+
this.toAbsolute = function(base) {
|
243 |
+
var base = new jscolor.URI(base);
|
244 |
+
var r = this;
|
245 |
+
var t = new jscolor.URI;
|
246 |
+
|
247 |
+
if(base.scheme === null) { return false; }
|
248 |
+
|
249 |
+
if(r.scheme !== null && r.scheme.toLowerCase() === base.scheme.toLowerCase()) {
|
250 |
+
r.scheme = null;
|
251 |
+
}
|
252 |
+
|
253 |
+
if(r.scheme !== null) {
|
254 |
+
t.scheme = r.scheme;
|
255 |
+
t.authority = r.authority;
|
256 |
+
t.path = removeDotSegments(r.path);
|
257 |
+
t.query = r.query;
|
258 |
+
} else {
|
259 |
+
if(r.authority !== null) {
|
260 |
+
t.authority = r.authority;
|
261 |
+
t.path = removeDotSegments(r.path);
|
262 |
+
t.query = r.query;
|
263 |
+
} else {
|
264 |
+
if(r.path === '') { // TODO: == or === ?
|
265 |
+
t.path = base.path;
|
266 |
+
if(r.query !== null) {
|
267 |
+
t.query = r.query;
|
268 |
+
} else {
|
269 |
+
t.query = base.query;
|
270 |
+
}
|
271 |
+
} else {
|
272 |
+
if(r.path.substr(0,1) === '/') {
|
273 |
+
t.path = removeDotSegments(r.path);
|
274 |
+
} else {
|
275 |
+
if(base.authority !== null && base.path === '') { // TODO: == or === ?
|
276 |
+
t.path = '/'+r.path;
|
277 |
+
} else {
|
278 |
+
t.path = base.path.replace(/[^\/]+$/,'')+r.path;
|
279 |
+
}
|
280 |
+
t.path = removeDotSegments(t.path);
|
281 |
+
}
|
282 |
+
t.query = r.query;
|
283 |
+
}
|
284 |
+
t.authority = base.authority;
|
285 |
+
}
|
286 |
+
t.scheme = base.scheme;
|
287 |
+
}
|
288 |
+
t.fragment = r.fragment;
|
289 |
+
|
290 |
+
return t;
|
291 |
+
};
|
292 |
+
|
293 |
+
function removeDotSegments(path) {
|
294 |
+
var out = '';
|
295 |
+
while(path) {
|
296 |
+
if(path.substr(0,3)==='../' || path.substr(0,2)==='./') {
|
297 |
+
path = path.replace(/^\.+/,'').substr(1);
|
298 |
+
} else if(path.substr(0,3)==='/./' || path==='/.') {
|
299 |
+
path = '/'+path.substr(3);
|
300 |
+
} else if(path.substr(0,4)==='/../' || path==='/..') {
|
301 |
+
path = '/'+path.substr(4);
|
302 |
+
out = out.replace(/\/?[^\/]*$/, '');
|
303 |
+
} else if(path==='.' || path==='..') {
|
304 |
+
path = '';
|
305 |
+
} else {
|
306 |
+
var rm = path.match(/^\/?[^\/]*/)[0];
|
307 |
+
path = path.substr(rm.length);
|
308 |
+
out = out + rm;
|
309 |
+
}
|
310 |
+
}
|
311 |
+
return out;
|
312 |
+
}
|
313 |
+
|
314 |
+
if(uri) {
|
315 |
+
this.parse(uri);
|
316 |
+
}
|
317 |
+
|
318 |
+
},
|
319 |
+
|
320 |
+
|
321 |
+
/*
|
322 |
+
* Usage example:
|
323 |
+
* var myColor = new jscolor.color(myInputElement)
|
324 |
+
*/
|
325 |
+
|
326 |
+
color : function(target, prop) {
|
327 |
+
|
328 |
+
|
329 |
+
this.required = true; // refuse empty values?
|
330 |
+
this.adjust = true; // adjust value to uniform notation?
|
331 |
+
this.hash = false; // prefix color with # symbol?
|
332 |
+
this.caps = true; // uppercase?
|
333 |
+
this.slider = true; // show the value/saturation slider?
|
334 |
+
this.valueElement = target; // value holder
|
335 |
+
this.styleElement = target; // where to reflect current color
|
336 |
+
this.onImmediateChange = null; // onchange callback (can be either string or function)
|
337 |
+
this.hsv = [0, 0, 1]; // read-only 0-6, 0-1, 0-1
|
338 |
+
this.rgb = [1, 1, 1]; // read-only 0-1, 0-1, 0-1
|
339 |
+
|
340 |
+
this.pickerOnfocus = true; // display picker on focus?
|
341 |
+
this.pickerMode = 'HSV'; // HSV | HVS
|
342 |
+
this.pickerPosition = 'bottom'; // left | right | top | bottom
|
343 |
+
this.pickerSmartPosition = true; // automatically adjust picker position when necessary
|
344 |
+
this.pickerButtonHeight = 20; // px
|
345 |
+
this.pickerClosable = false;
|
346 |
+
this.pickerCloseText = 'Close';
|
347 |
+
this.pickerButtonColor = 'ButtonText'; // px
|
348 |
+
this.pickerFace = 10; // px
|
349 |
+
this.pickerFaceColor = 'ThreeDFace'; // CSS color
|
350 |
+
this.pickerBorder = 1; // px
|
351 |
+
this.pickerBorderColor = 'ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight'; // CSS color
|
352 |
+
this.pickerInset = 1; // px
|
353 |
+
this.pickerInsetColor = 'ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow'; // CSS color
|
354 |
+
this.pickerZIndex = 10000;
|
355 |
+
|
356 |
+
|
357 |
+
for(var p in prop) {
|
358 |
+
if(prop.hasOwnProperty(p)) {
|
359 |
+
this[p] = prop[p];
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
|
364 |
+
this.hidePicker = function() {
|
365 |
+
if(isPickerOwner()) {
|
366 |
+
removePicker();
|
367 |
+
}
|
368 |
+
};
|
369 |
+
|
370 |
+
|
371 |
+
this.showPicker = function() {
|
372 |
+
if(!isPickerOwner()) {
|
373 |
+
var tp = jscolor.getElementPos(target); // target pos
|
374 |
+
var ts = jscolor.getElementSize(target); // target size
|
375 |
+
var vp = jscolor.getViewPos(); // view pos
|
376 |
+
var vs = jscolor.getViewSize(); // view size
|
377 |
+
var ps = getPickerDims(this); // picker size
|
378 |
+
var a, b, c;
|
379 |
+
switch(this.pickerPosition.toLowerCase()) {
|
380 |
+
case 'left': a=1; b=0; c=-1; break;
|
381 |
+
case 'right':a=1; b=0; c=1; break;
|
382 |
+
case 'top': a=0; b=1; c=-1; break;
|
383 |
+
default: a=0; b=1; c=1; break;
|
384 |
+
}
|
385 |
+
var l = (ts[b]+ps[b])/2;
|
386 |
+
|
387 |
+
// picker pos
|
388 |
+
if (!this.pickerSmartPosition) {
|
389 |
+
var pp = [
|
390 |
+
tp[a],
|
391 |
+
tp[b]+ts[b]-l+l*c
|
392 |
+
];
|
393 |
+
} else {
|
394 |
+
var pp = [
|
395 |
+
-vp[a]+tp[a]+ps[a] > vs[a] ?
|
396 |
+
(-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) :
|
397 |
+
tp[a],
|
398 |
+
-vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ?
|
399 |
+
(-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) :
|
400 |
+
(tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c)
|
401 |
+
];
|
402 |
+
}
|
403 |
+
drawPicker(pp[a], pp[b]);
|
404 |
+
}
|
405 |
+
};
|
406 |
+
|
407 |
+
|
408 |
+
this.importColor = function() {
|
409 |
+
if(!valueElement) {
|
410 |
+
this.exportColor();
|
411 |
+
} else {
|
412 |
+
if(!this.adjust) {
|
413 |
+
if(!this.fromString(valueElement.value, leaveValue)) {
|
414 |
+
styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
|
415 |
+
styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
|
416 |
+
styleElement.style.color = styleElement.jscStyle.color;
|
417 |
+
this.exportColor(leaveValue | leaveStyle);
|
418 |
+
}
|
419 |
+
} else if(!this.required && /^\s*$/.test(valueElement.value)) {
|
420 |
+
valueElement.value = '';
|
421 |
+
styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
|
422 |
+
styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
|
423 |
+
styleElement.style.color = styleElement.jscStyle.color;
|
424 |
+
this.exportColor(leaveValue | leaveStyle);
|
425 |
+
|
426 |
+
} else if(this.fromString(valueElement.value)) {
|
427 |
+
// OK
|
428 |
+
} else {
|
429 |
+
this.exportColor();
|
430 |
+
}
|
431 |
+
}
|
432 |
+
};
|
433 |
+
|
434 |
+
|
435 |
+
this.exportColor = function(flags) {
|
436 |
+
if(!(flags & leaveValue) && valueElement) {
|
437 |
+
var value = this.toString();
|
438 |
+
if(this.caps) { value = value.toUpperCase(); }
|
439 |
+
if(this.hash) { value = '#'+value; }
|
440 |
+
valueElement.value = value;
|
441 |
+
}
|
442 |
+
if(!(flags & leaveStyle) && styleElement) {
|
443 |
+
styleElement.style.backgroundImage = "none";
|
444 |
+
styleElement.style.backgroundColor =
|
445 |
+
'#'+this.toString();
|
446 |
+
styleElement.style.color =
|
447 |
+
0.213 * this.rgb[0] +
|
448 |
+
0.715 * this.rgb[1] +
|
449 |
+
0.072 * this.rgb[2]
|
450 |
+
< 0.5 ? '#FFF' : '#000';
|
451 |
+
}
|
452 |
+
if(!(flags & leavePad) && isPickerOwner()) {
|
453 |
+
redrawPad();
|
454 |
+
}
|
455 |
+
if(!(flags & leaveSld) && isPickerOwner()) {
|
456 |
+
redrawSld();
|
457 |
+
}
|
458 |
+
};
|
459 |
+
|
460 |
+
|
461 |
+
this.fromHSV = function(h, s, v, flags) { // null = don't change
|
462 |
+
h<0 && (h=0) || h>6 && (h=6);
|
463 |
+
s<0 && (s=0) || s>1 && (s=1);
|
464 |
+
v<0 && (v=0) || v>1 && (v=1);
|
465 |
+
this.rgb = HSV_RGB(
|
466 |
+
h===null ? this.hsv[0] : (this.hsv[0]=h),
|
467 |
+
s===null ? this.hsv[1] : (this.hsv[1]=s),
|
468 |
+
v===null ? this.hsv[2] : (this.hsv[2]=v)
|
469 |
+
);
|
470 |
+
this.exportColor(flags);
|
471 |
+
};
|
472 |
+
|
473 |
+
|
474 |
+
this.fromRGB = function(r, g, b, flags) { // null = don't change
|
475 |
+
r<0 && (r=0) || r>1 && (r=1);
|
476 |
+
g<0 && (g=0) || g>1 && (g=1);
|
477 |
+
b<0 && (b=0) || b>1 && (b=1);
|
478 |
+
var hsv = RGB_HSV(
|
479 |
+
r===null ? this.rgb[0] : (this.rgb[0]=r),
|
480 |
+
g===null ? this.rgb[1] : (this.rgb[1]=g),
|
481 |
+
b===null ? this.rgb[2] : (this.rgb[2]=b)
|
482 |
+
);
|
483 |
+
if(hsv[0] !== null) {
|
484 |
+
this.hsv[0] = hsv[0];
|
485 |
+
}
|
486 |
+
if(hsv[2] !== 0) {
|
487 |
+
this.hsv[1] = hsv[1];
|
488 |
+
}
|
489 |
+
this.hsv[2] = hsv[2];
|
490 |
+
this.exportColor(flags);
|
491 |
+
};
|
492 |
+
|
493 |
+
|
494 |
+
this.fromString = function(hex, flags) {
|
495 |
+
var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);
|
496 |
+
if(!m) {
|
497 |
+
return false;
|
498 |
+
} else {
|
499 |
+
if(m[1].length === 6) { // 6-char notation
|
500 |
+
this.fromRGB(
|
501 |
+
parseInt(m[1].substr(0,2),16) / 255,
|
502 |
+
parseInt(m[1].substr(2,2),16) / 255,
|
503 |
+
parseInt(m[1].substr(4,2),16) / 255,
|
504 |
+
flags
|
505 |
+
);
|
506 |
+
} else { // 3-char notation
|
507 |
+
this.fromRGB(
|
508 |
+
parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255,
|
509 |
+
parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255,
|
510 |
+
parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255,
|
511 |
+
flags
|
512 |
+
);
|
513 |
+
}
|
514 |
+
return true;
|
515 |
+
}
|
516 |
+
};
|
517 |
+
|
518 |
+
|
519 |
+
this.toString = function() {
|
520 |
+
return (
|
521 |
+
(0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) +
|
522 |
+
(0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) +
|
523 |
+
(0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1)
|
524 |
+
);
|
525 |
+
};
|
526 |
+
|
527 |
+
|
528 |
+
function RGB_HSV(r, g, b) {
|
529 |
+
var n = Math.min(Math.min(r,g),b);
|
530 |
+
var v = Math.max(Math.max(r,g),b);
|
531 |
+
var m = v - n;
|
532 |
+
if(m === 0) { return [ null, 0, v ]; }
|
533 |
+
var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m);
|
534 |
+
return [ h===6?0:h, m/v, v ];
|
535 |
+
}
|
536 |
+
|
537 |
+
|
538 |
+
function HSV_RGB(h, s, v) {
|
539 |
+
if(h === null) { return [ v, v, v ]; }
|
540 |
+
var i = Math.floor(h);
|
541 |
+
var f = i%2 ? h-i : 1-(h-i);
|
542 |
+
var m = v * (1 - s);
|
543 |
+
var n = v * (1 - s*f);
|
544 |
+
switch(i) {
|
545 |
+
case 6:
|
546 |
+
case 0: return [v,n,m];
|
547 |
+
case 1: return [n,v,m];
|
548 |
+
case 2: return [m,v,n];
|
549 |
+
case 3: return [m,n,v];
|
550 |
+
case 4: return [n,m,v];
|
551 |
+
case 5: return [v,m,n];
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
|
556 |
+
function removePicker() {
|
557 |
+
delete jscolor.picker.owner;
|
558 |
+
document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB);
|
559 |
+
}
|
560 |
+
|
561 |
+
|
562 |
+
function drawPicker(x, y) {
|
563 |
+
if(!jscolor.picker) {
|
564 |
+
jscolor.picker = {
|
565 |
+
box : document.createElement('div'),
|
566 |
+
boxB : document.createElement('div'),
|
567 |
+
pad : document.createElement('div'),
|
568 |
+
padB : document.createElement('div'),
|
569 |
+
padM : document.createElement('div'),
|
570 |
+
sld : document.createElement('div'),
|
571 |
+
sldB : document.createElement('div'),
|
572 |
+
sldM : document.createElement('div'),
|
573 |
+
btn : document.createElement('div'),
|
574 |
+
btnS : document.createElement('span'),
|
575 |
+
btnT : document.createTextNode(THIS.pickerCloseText)
|
576 |
+
};
|
577 |
+
for(var i=0,segSize=4; i<jscolor.images.sld[1]; i+=segSize) {
|
578 |
+
var seg = document.createElement('div');
|
579 |
+
seg.style.height = segSize+'px';
|
580 |
+
seg.style.fontSize = '1px';
|
581 |
+
seg.style.lineHeight = '0';
|
582 |
+
jscolor.picker.sld.appendChild(seg);
|
583 |
+
}
|
584 |
+
jscolor.picker.sldB.appendChild(jscolor.picker.sld);
|
585 |
+
jscolor.picker.box.appendChild(jscolor.picker.sldB);
|
586 |
+
jscolor.picker.box.appendChild(jscolor.picker.sldM);
|
587 |
+
jscolor.picker.padB.appendChild(jscolor.picker.pad);
|
588 |
+
jscolor.picker.box.appendChild(jscolor.picker.padB);
|
589 |
+
jscolor.picker.box.appendChild(jscolor.picker.padM);
|
590 |
+
jscolor.picker.btnS.appendChild(jscolor.picker.btnT);
|
591 |
+
jscolor.picker.btn.appendChild(jscolor.picker.btnS);
|
592 |
+
jscolor.picker.box.appendChild(jscolor.picker.btn);
|
593 |
+
jscolor.picker.boxB.appendChild(jscolor.picker.box);
|
594 |
+
}
|
595 |
+
|
596 |
+
var p = jscolor.picker;
|
597 |
+
|
598 |
+
// controls interaction
|
599 |
+
p.box.onmouseup =
|
600 |
+
p.box.onmouseout = function() { target.focus(); };
|
601 |
+
p.box.onmousedown = function() { abortBlur=true; };
|
602 |
+
p.box.onmousemove = function(e) {
|
603 |
+
if (holdPad || holdSld) {
|
604 |
+
holdPad && setPad(e);
|
605 |
+
holdSld && setSld(e);
|
606 |
+
if (document.selection) {
|
607 |
+
document.selection.empty();
|
608 |
+
} else if (window.getSelection) {
|
609 |
+
window.getSelection().removeAllRanges();
|
610 |
+
}
|
611 |
+
dispatchImmediateChange();
|
612 |
+
}
|
613 |
+
};
|
614 |
+
p.padM.onmouseup =
|
615 |
+
p.padM.onmouseout = function() { if(holdPad) { holdPad=false; jscolor.fireEvent(valueElement,'change'); } };
|
616 |
+
p.padM.onmousedown = function(e) {
|
617 |
+
// if the slider is at the bottom, move it up
|
618 |
+
switch(modeID) {
|
619 |
+
case 0: if (THIS.hsv[2] === 0) { THIS.fromHSV(null, null, 1.0); }; break;
|
620 |
+
case 1: if (THIS.hsv[1] === 0) { THIS.fromHSV(null, 1.0, null); }; break;
|
621 |
+
}
|
622 |
+
holdPad=true;
|
623 |
+
setPad(e);
|
624 |
+
dispatchImmediateChange();
|
625 |
+
};
|
626 |
+
p.sldM.onmouseup =
|
627 |
+
p.sldM.onmouseout = function() { if(holdSld) { holdSld=false; jscolor.fireEvent(valueElement,'change'); } };
|
628 |
+
p.sldM.onmousedown = function(e) {
|
629 |
+
holdSld=true;
|
630 |
+
setSld(e);
|
631 |
+
dispatchImmediateChange();
|
632 |
+
};
|
633 |
+
|
634 |
+
// picker
|
635 |
+
var dims = getPickerDims(THIS);
|
636 |
+
p.box.style.width = dims[0] + 'px';
|
637 |
+
p.box.style.height = dims[1] + 'px';
|
638 |
+
|
639 |
+
// picker border
|
640 |
+
p.boxB.style.position = 'absolute';
|
641 |
+
p.boxB.style.clear = 'both';
|
642 |
+
p.boxB.style.left = x+'px';
|
643 |
+
p.boxB.style.top = y+'px';
|
644 |
+
p.boxB.style.zIndex = THIS.pickerZIndex;
|
645 |
+
p.boxB.style.border = THIS.pickerBorder+'px solid';
|
646 |
+
p.boxB.style.borderColor = THIS.pickerBorderColor;
|
647 |
+
p.boxB.style.background = THIS.pickerFaceColor;
|
648 |
+
|
649 |
+
// pad image
|
650 |
+
p.pad.style.width = jscolor.images.pad[0]+'px';
|
651 |
+
p.pad.style.height = jscolor.images.pad[1]+'px';
|
652 |
+
|
653 |
+
// pad border
|
654 |
+
p.padB.style.position = 'absolute';
|
655 |
+
p.padB.style.left = THIS.pickerFace+'px';
|
656 |
+
p.padB.style.top = THIS.pickerFace+'px';
|
657 |
+
p.padB.style.border = THIS.pickerInset+'px solid';
|
658 |
+
p.padB.style.borderColor = THIS.pickerInsetColor;
|
659 |
+
|
660 |
+
// pad mouse area
|
661 |
+
p.padM.style.position = 'absolute';
|
662 |
+
p.padM.style.left = '0';
|
663 |
+
p.padM.style.top = '0';
|
664 |
+
p.padM.style.width = THIS.pickerFace + 2*THIS.pickerInset + jscolor.images.pad[0] + jscolor.images.arrow[0] + 'px';
|
665 |
+
p.padM.style.height = p.box.style.height;
|
666 |
+
p.padM.style.cursor = 'crosshair';
|
667 |
+
|
668 |
+
// slider image
|
669 |
+
p.sld.style.overflow = 'hidden';
|
670 |
+
p.sld.style.width = jscolor.images.sld[0]+'px';
|
671 |
+
p.sld.style.height = jscolor.images.sld[1]+'px';
|
672 |
+
|
673 |
+
// slider border
|
674 |
+
p.sldB.style.display = THIS.slider ? 'block' : 'none';
|
675 |
+
p.sldB.style.position = 'absolute';
|
676 |
+
p.sldB.style.right = THIS.pickerFace+'px';
|
677 |
+
p.sldB.style.top = THIS.pickerFace+'px';
|
678 |
+
p.sldB.style.border = THIS.pickerInset+'px solid';
|
679 |
+
p.sldB.style.borderColor = THIS.pickerInsetColor;
|
680 |
+
|
681 |
+
// slider mouse area
|
682 |
+
p.sldM.style.display = THIS.slider ? 'block' : 'none';
|
683 |
+
p.sldM.style.position = 'absolute';
|
684 |
+
p.sldM.style.right = '0';
|
685 |
+
p.sldM.style.top = '0';
|
686 |
+
p.sldM.style.width = jscolor.images.sld[0] + jscolor.images.arrow[0] + THIS.pickerFace + 2*THIS.pickerInset + 'px';
|
687 |
+
p.sldM.style.height = p.box.style.height;
|
688 |
+
try {
|
689 |
+
p.sldM.style.cursor = 'pointer';
|
690 |
+
} catch(eOldIE) {
|
691 |
+
p.sldM.style.cursor = 'hand';
|
692 |
+
}
|
693 |
+
|
694 |
+
// "close" button
|
695 |
+
function setBtnBorder() {
|
696 |
+
var insetColors = THIS.pickerInsetColor.split(/\s+/);
|
697 |
+
var pickerOutsetColor = insetColors.length < 2 ? insetColors[0] : insetColors[1] + ' ' + insetColors[0] + ' ' + insetColors[0] + ' ' + insetColors[1];
|
698 |
+
p.btn.style.borderColor = pickerOutsetColor;
|
699 |
+
}
|
700 |
+
p.btn.style.display = THIS.pickerClosable ? 'block' : 'none';
|
701 |
+
p.btn.style.position = 'absolute';
|
702 |
+
p.btn.style.left = THIS.pickerFace + 'px';
|
703 |
+
p.btn.style.bottom = THIS.pickerFace + 'px';
|
704 |
+
p.btn.style.padding = '0 15px';
|
705 |
+
p.btn.style.height = '18px';
|
706 |
+
p.btn.style.border = THIS.pickerInset + 'px solid';
|
707 |
+
setBtnBorder();
|
708 |
+
p.btn.style.color = THIS.pickerButtonColor;
|
709 |
+
p.btn.style.font = '12px sans-serif';
|
710 |
+
p.btn.style.textAlign = 'center';
|
711 |
+
try {
|
712 |
+
p.btn.style.cursor = 'pointer';
|
713 |
+
} catch(eOldIE) {
|
714 |
+
p.btn.style.cursor = 'hand';
|
715 |
+
}
|
716 |
+
p.btn.onmousedown = function () {
|
717 |
+
THIS.hidePicker();
|
718 |
+
};
|
719 |
+
p.btnS.style.lineHeight = p.btn.style.height;
|
720 |
+
|
721 |
+
// load images in optimal order
|
722 |
+
switch(modeID) {
|
723 |
+
case 0: var padImg = 'hs.png'; break;
|
724 |
+
case 1: var padImg = 'hv.png'; break;
|
725 |
+
}
|
726 |
+
p.padM.style.backgroundImage = "url('"+jscolor.getDir()+"cross.gif')";
|
727 |
+
p.padM.style.backgroundRepeat = "no-repeat";
|
728 |
+
p.sldM.style.backgroundImage = "url('"+jscolor.getDir()+"arrow.gif')";
|
729 |
+
p.sldM.style.backgroundRepeat = "no-repeat";
|
730 |
+
p.pad.style.backgroundImage = "url('"+jscolor.getDir()+padImg+"')";
|
731 |
+
p.pad.style.backgroundRepeat = "no-repeat";
|
732 |
+
p.pad.style.backgroundPosition = "0 0";
|
733 |
+
|
734 |
+
// place pointers
|
735 |
+
redrawPad();
|
736 |
+
redrawSld();
|
737 |
+
|
738 |
+
jscolor.picker.owner = THIS;
|
739 |
+
document.getElementsByTagName('body')[0].appendChild(p.boxB);
|
740 |
+
}
|
741 |
+
|
742 |
+
|
743 |
+
function getPickerDims(o) {
|
744 |
+
var dims = [
|
745 |
+
2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[0] +
|
746 |
+
(o.slider ? 2*o.pickerInset + 2*jscolor.images.arrow[0] + jscolor.images.sld[0] : 0),
|
747 |
+
o.pickerClosable ?
|
748 |
+
4*o.pickerInset + 3*o.pickerFace + jscolor.images.pad[1] + o.pickerButtonHeight :
|
749 |
+
2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[1]
|
750 |
+
];
|
751 |
+
return dims;
|
752 |
+
}
|
753 |
+
|
754 |
+
|
755 |
+
function redrawPad() {
|
756 |
+
// redraw the pad pointer
|
757 |
+
switch(modeID) {
|
758 |
+
case 0: var yComponent = 1; break;
|
759 |
+
case 1: var yComponent = 2; break;
|
760 |
+
}
|
761 |
+
var x = Math.round((THIS.hsv[0]/6) * (jscolor.images.pad[0]-1));
|
762 |
+
var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.pad[1]-1));
|
763 |
+
jscolor.picker.padM.style.backgroundPosition =
|
764 |
+
(THIS.pickerFace+THIS.pickerInset+x - Math.floor(jscolor.images.cross[0]/2)) + 'px ' +
|
765 |
+
(THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.cross[1]/2)) + 'px';
|
766 |
+
|
767 |
+
// redraw the slider image
|
768 |
+
var seg = jscolor.picker.sld.childNodes;
|
769 |
+
|
770 |
+
switch(modeID) {
|
771 |
+
case 0:
|
772 |
+
var rgb = HSV_RGB(THIS.hsv[0], THIS.hsv[1], 1);
|
773 |
+
for(var i=0; i<seg.length; i+=1) {
|
774 |
+
seg[i].style.backgroundColor = 'rgb('+
|
775 |
+
(rgb[0]*(1-i/seg.length)*100)+'%,'+
|
776 |
+
(rgb[1]*(1-i/seg.length)*100)+'%,'+
|
777 |
+
(rgb[2]*(1-i/seg.length)*100)+'%)';
|
778 |
+
}
|
779 |
+
break;
|
780 |
+
case 1:
|
781 |
+
var rgb, s, c = [ THIS.hsv[2], 0, 0 ];
|
782 |
+
var i = Math.floor(THIS.hsv[0]);
|
783 |
+
var f = i%2 ? THIS.hsv[0]-i : 1-(THIS.hsv[0]-i);
|
784 |
+
switch(i) {
|
785 |
+
case 6:
|
786 |
+
case 0: rgb=[0,1,2]; break;
|
787 |
+
case 1: rgb=[1,0,2]; break;
|
788 |
+
case 2: rgb=[2,0,1]; break;
|
789 |
+
case 3: rgb=[2,1,0]; break;
|
790 |
+
case 4: rgb=[1,2,0]; break;
|
791 |
+
case 5: rgb=[0,2,1]; break;
|
792 |
+
}
|
793 |
+
for(var i=0; i<seg.length; i+=1) {
|
794 |
+
s = 1 - 1/(seg.length-1)*i;
|
795 |
+
c[1] = c[0] * (1 - s*f);
|
796 |
+
c[2] = c[0] * (1 - s);
|
797 |
+
seg[i].style.backgroundColor = 'rgb('+
|
798 |
+
(c[rgb[0]]*100)+'%,'+
|
799 |
+
(c[rgb[1]]*100)+'%,'+
|
800 |
+
(c[rgb[2]]*100)+'%)';
|
801 |
+
}
|
802 |
+
break;
|
803 |
+
}
|
804 |
+
}
|
805 |
+
|
806 |
+
|
807 |
+
function redrawSld() {
|
808 |
+
// redraw the slider pointer
|
809 |
+
switch(modeID) {
|
810 |
+
case 0: var yComponent = 2; break;
|
811 |
+
case 1: var yComponent = 1; break;
|
812 |
+
}
|
813 |
+
var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.sld[1]-1));
|
814 |
+
jscolor.picker.sldM.style.backgroundPosition =
|
815 |
+
'0 ' + (THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.arrow[1]/2)) + 'px';
|
816 |
+
}
|
817 |
+
|
818 |
+
|
819 |
+
function isPickerOwner() {
|
820 |
+
return jscolor.picker && jscolor.picker.owner === THIS;
|
821 |
+
}
|
822 |
+
|
823 |
+
|
824 |
+
function blurTarget() {
|
825 |
+
if(valueElement === target) {
|
826 |
+
THIS.importColor();
|
827 |
+
}
|
828 |
+
if(THIS.pickerOnfocus) {
|
829 |
+
THIS.hidePicker();
|
830 |
+
}
|
831 |
+
}
|
832 |
+
|
833 |
+
|
834 |
+
function blurValue() {
|
835 |
+
if(valueElement !== target) {
|
836 |
+
THIS.importColor();
|
837 |
+
}
|
838 |
+
}
|
839 |
+
|
840 |
+
|
841 |
+
function setPad(e) {
|
842 |
+
var mpos = jscolor.getRelMousePos(e);
|
843 |
+
var x = mpos.x - THIS.pickerFace - THIS.pickerInset;
|
844 |
+
var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
|
845 |
+
switch(modeID) {
|
846 |
+
case 0: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), 1 - y/(jscolor.images.pad[1]-1), null, leaveSld); break;
|
847 |
+
case 1: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), null, 1 - y/(jscolor.images.pad[1]-1), leaveSld); break;
|
848 |
+
}
|
849 |
+
}
|
850 |
+
|
851 |
+
|
852 |
+
function setSld(e) {
|
853 |
+
var mpos = jscolor.getRelMousePos(e);
|
854 |
+
var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
|
855 |
+
switch(modeID) {
|
856 |
+
case 0: THIS.fromHSV(null, null, 1 - y/(jscolor.images.sld[1]-1), leavePad); break;
|
857 |
+
case 1: THIS.fromHSV(null, 1 - y/(jscolor.images.sld[1]-1), null, leavePad); break;
|
858 |
+
}
|
859 |
+
}
|
860 |
+
|
861 |
+
|
862 |
+
function dispatchImmediateChange() {
|
863 |
+
if (THIS.onImmediateChange) {
|
864 |
+
if (typeof THIS.onImmediateChange === 'string') {
|
865 |
+
eval(THIS.onImmediateChange);
|
866 |
+
} else {
|
867 |
+
THIS.onImmediateChange(THIS);
|
868 |
+
}
|
869 |
+
}
|
870 |
+
}
|
871 |
+
|
872 |
+
|
873 |
+
var THIS = this;
|
874 |
+
var modeID = this.pickerMode.toLowerCase()==='hvs' ? 1 : 0;
|
875 |
+
var abortBlur = false;
|
876 |
+
var
|
877 |
+
valueElement = jscolor.fetchElement(this.valueElement),
|
878 |
+
styleElement = jscolor.fetchElement(this.styleElement);
|
879 |
+
var
|
880 |
+
holdPad = false,
|
881 |
+
holdSld = false;
|
882 |
+
var
|
883 |
+
leaveValue = 1<<0,
|
884 |
+
leaveStyle = 1<<1,
|
885 |
+
leavePad = 1<<2,
|
886 |
+
leaveSld = 1<<3;
|
887 |
+
|
888 |
+
// target
|
889 |
+
jscolor.addEvent(target, 'focus', function() {
|
890 |
+
if(THIS.pickerOnfocus) { THIS.showPicker(); }
|
891 |
+
});
|
892 |
+
jscolor.addEvent(target, 'blur', function() {
|
893 |
+
if(!abortBlur) {
|
894 |
+
window.setTimeout(function(){ abortBlur || blurTarget(); abortBlur=false; }, 0);
|
895 |
+
} else {
|
896 |
+
abortBlur = false;
|
897 |
+
}
|
898 |
+
});
|
899 |
+
|
900 |
+
// valueElement
|
901 |
+
if(valueElement) {
|
902 |
+
var updateField = function() {
|
903 |
+
THIS.fromString(valueElement.value, leaveValue);
|
904 |
+
dispatchImmediateChange();
|
905 |
+
};
|
906 |
+
jscolor.addEvent(valueElement, 'keyup', updateField);
|
907 |
+
jscolor.addEvent(valueElement, 'input', updateField);
|
908 |
+
jscolor.addEvent(valueElement, 'blur', blurValue);
|
909 |
+
valueElement.setAttribute('autocomplete', 'off');
|
910 |
+
}
|
911 |
+
|
912 |
+
// styleElement
|
913 |
+
if(styleElement) {
|
914 |
+
styleElement.jscStyle = {
|
915 |
+
backgroundImage : styleElement.style.backgroundImage,
|
916 |
+
backgroundColor : styleElement.style.backgroundColor,
|
917 |
+
color : styleElement.style.color
|
918 |
+
};
|
919 |
+
}
|
920 |
+
|
921 |
+
// require images
|
922 |
+
switch(modeID) {
|
923 |
+
case 0: jscolor.requireImage('hs.png'); break;
|
924 |
+
case 1: jscolor.requireImage('hv.png'); break;
|
925 |
+
}
|
926 |
+
jscolor.requireImage('cross.gif');
|
927 |
+
jscolor.requireImage('arrow.gif');
|
928 |
+
|
929 |
+
this.importColor();
|
930 |
+
}
|
931 |
+
|
932 |
+
};
|
933 |
+
|
934 |
+
|
935 |
+
jscolor.install();
|
js/pricewaiter/product-pages.js
ADDED
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* Copyright 2013 Price Waiter, LLC
|
3 |
+
*
|
4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
* you may not use this file except in compliance with the License.
|
6 |
+
* You may obtain a copy of the License at
|
7 |
+
*
|
8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
*
|
10 |
+
* Unless required by applicable law or agreed to in writing, software
|
11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
* See the License for the specific language governing permissions and
|
14 |
+
* limitations under the License.
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
$(document).observe('dom:loaded', function() {
|
18 |
+
if (typeof adminPW == 'function') {
|
19 |
+
adminPW();
|
20 |
+
}
|
21 |
+
PriceWaiterOptions.onload =
|
22 |
+
function(PriceWaiter) {
|
23 |
+
PriceWaiter.setRegularPrice(PriceWaiterRegularPrice);
|
24 |
+
|
25 |
+
// define indexof, needed for older versions of IE
|
26 |
+
if(!Array.prototype.indexof) {
|
27 |
+
Array.prototype.indexof = function(needle) {
|
28 |
+
for(var i = 0; i < this.length; i++) {
|
29 |
+
if(this[i] === needle) {
|
30 |
+
return i;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
return -1;
|
34 |
+
};
|
35 |
+
}
|
36 |
+
|
37 |
+
// define getElementsByRegex to find required bundle options
|
38 |
+
document['getElementsByRegex'] = function(pattern) {
|
39 |
+
var arrElements = []; // to accumulate matching elements
|
40 |
+
var re = new RegExp(pattern); // the regex to match with
|
41 |
+
|
42 |
+
function findRecursively(aNode) { // recursive function to traverse dom
|
43 |
+
if (!aNode)
|
44 |
+
return;
|
45 |
+
if (aNode.id !== undefined && aNode.id.search(re) != -1)
|
46 |
+
arrElements.push(aNode); // found one!
|
47 |
+
for (var idx in aNode.childNodes) // search children...
|
48 |
+
findRecursively(aNode.childNodes[idx]);
|
49 |
+
}
|
50 |
+
|
51 |
+
findRecursively(document); // initiate recursive matching
|
52 |
+
return arrElements; // return matching elements
|
53 |
+
};
|
54 |
+
|
55 |
+
// Bind to Qty: input
|
56 |
+
if ($('qty') !== null) {
|
57 |
+
$('qty').observe('change', function(){
|
58 |
+
PriceWaiter.setQuantity($('qty').value);
|
59 |
+
});
|
60 |
+
}
|
61 |
+
|
62 |
+
switch(PriceWaiterProductType) {
|
63 |
+
case 'simple':
|
64 |
+
handleSimples();
|
65 |
+
break;
|
66 |
+
case 'configurable':
|
67 |
+
handleConfigurables();
|
68 |
+
break;
|
69 |
+
case 'bundle':
|
70 |
+
handleBundles();
|
71 |
+
break;
|
72 |
+
case 'grouped':
|
73 |
+
handleGrouped();
|
74 |
+
break;
|
75 |
+
}
|
76 |
+
|
77 |
+
function simplesSelect(select, name) {
|
78 |
+
select.observe('change', function(){
|
79 |
+
PriceWaiter.setProductOption(name, select.options[select.selectedIndex].text);
|
80 |
+
});
|
81 |
+
}
|
82 |
+
|
83 |
+
function simplesInput(select, name) {
|
84 |
+
if (select.type == "text" || select.tagName == 'TEXTAREA') {
|
85 |
+
select.observe('change', function(){
|
86 |
+
PriceWaiter.setProductOption(name, select.value);
|
87 |
+
});
|
88 |
+
} else {
|
89 |
+
select.observe('change', function(){
|
90 |
+
var optionValue = select.next('span').select('label')[0].innerHTML;
|
91 |
+
optionValue = optionValue.replace(/\s*<span.*\/span>/, '');
|
92 |
+
PriceWaiter.setProductOption(name, optionValue);
|
93 |
+
});
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
function handleSimples() {
|
99 |
+
// if there are no custom options, we don't have anything to do
|
100 |
+
if (typeof(opConfig) == 'undefined') {
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
|
104 |
+
// If this product has an upload file option, we can't use the NYP widget
|
105 |
+
var productForm = $('product_addtocart_form');
|
106 |
+
if (productForm.getInputs('file').length !== 0) {
|
107 |
+
console.log("The PriceWaiter Name Your Price Widget does not support upload file options.");
|
108 |
+
$$('div.name-your-price-widget').each(function(pww){
|
109 |
+
pww.setStyle({display: 'none'});
|
110 |
+
});
|
111 |
+
}
|
112 |
+
|
113 |
+
// Grab the updated price before opening the PriceWaiter window
|
114 |
+
PriceWaiter.originalOpen = PriceWaiter.open;
|
115 |
+
PriceWaiter.open = function() {
|
116 |
+
var productPrice = 0;
|
117 |
+
var priceElement = document.getElementsByRegex('^product-price-');
|
118 |
+
var innerSpan = priceElement[0].select('span');
|
119 |
+
if (typeof(innerSpan[0]) == 'undefined') {
|
120 |
+
productPrice = priceElement[0].innerHTML;
|
121 |
+
} else {
|
122 |
+
productPrice = innerSpan[0].innerHTML;
|
123 |
+
}
|
124 |
+
PriceWaiter.setPrice(productPrice);
|
125 |
+
PriceWaiter.originalOpen();
|
126 |
+
};
|
127 |
+
|
128 |
+
// Find the available options, and bind to them
|
129 |
+
var productCustomOptions = $$('.product-custom-option');
|
130 |
+
for (var current in productCustomOptions) {
|
131 |
+
if (!isNaN(parseInt(current, 10))) {
|
132 |
+
// Find the option label
|
133 |
+
var optionLabel = productCustomOptions[current].up('dd').previous('dt').select('label')[0];
|
134 |
+
var optionName = optionLabel.innerHTML.replace(/^<em.*\/em>/, '');
|
135 |
+
// Check if this is a required option
|
136 |
+
if (optionLabel.hasClassName('required')) {
|
137 |
+
PriceWaiter.setProductOptionRequired(optionName);
|
138 |
+
}
|
139 |
+
// we have to handle different inputs a bit differently.
|
140 |
+
switch (productCustomOptions[current].tagName) {
|
141 |
+
case 'SELECT':
|
142 |
+
simplesSelect(productCustomOptions[current], optionName);
|
143 |
+
break;
|
144 |
+
case 'INPUT':
|
145 |
+
case 'TEXTAREA':
|
146 |
+
simplesInput(productCustomOptions[current], optionName);
|
147 |
+
break;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
function handleConfigurables() {
|
154 |
+
// Bind to each configurable options 'change' event
|
155 |
+
spConfig.settings.each(function(setting){
|
156 |
+
var attributeId = $(setting).id;
|
157 |
+
attributeId = attributeId.replace(/attribute/,'');
|
158 |
+
var optionName = spConfig.config.attributes[attributeId].label;
|
159 |
+
// If this option is required, tell the PriceWaiter widget about the requirement
|
160 |
+
if ($(setting).hasClassName('required-entry') && (typeof PriceWaiter.setProductOptionRequired == 'function')) {
|
161 |
+
PriceWaiter.setProductOptionRequired(optionName, true);
|
162 |
+
}
|
163 |
+
Event.observe(setting, 'change', function(event){
|
164 |
+
// Update PriceWaiter's price and options when changes are made
|
165 |
+
PriceWaiter.setPrice(Number(spConfig.config.basePrice) + Number(spConfig.reloadPrice()));
|
166 |
+
var optionValue = setting.value !== "" ? setting.options[setting.selectedIndex].innerHTML : undefined;
|
167 |
+
// if the option value is undefined, clear the option. Otherwise, set the newly selected option.
|
168 |
+
if (optionValue === undefined) {
|
169 |
+
PriceWaiter.clearProductOption(optionName);
|
170 |
+
} else {
|
171 |
+
PriceWaiter.setProductOption(optionName, optionValue);
|
172 |
+
}
|
173 |
+
});
|
174 |
+
});
|
175 |
+
}
|
176 |
+
|
177 |
+
function handleBundles() {
|
178 |
+
// Find options that are marked as required
|
179 |
+
var requiredOptions = [];
|
180 |
+
var bundleElements = document.getElementsByRegex('^bundle-option-');
|
181 |
+
var rePattern = /\[(\d*)\]/;
|
182 |
+
for (var bundleOption in bundleElements) {
|
183 |
+
if (!isNaN(parseInt(bundleOption, 10))) {
|
184 |
+
var obj = bundleElements[bundleOption];
|
185 |
+
if (obj.hasClassName('required-entry') || obj.hasClassName('validate-one-required-by-name')) {
|
186 |
+
var matched = rePattern.exec(obj.name);
|
187 |
+
requiredOptions.push(parseInt(matched[1], 10));
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
+
requiredOptions = requiredOptions.uniq();
|
192 |
+
|
193 |
+
// Add required Options to PriceWaiter
|
194 |
+
for (var key in bundle.config.options) {
|
195 |
+
if (requiredOptions.indexOf(parseInt(key, 10)) > -1) {
|
196 |
+
var opt = bundle.config.options[key];
|
197 |
+
PriceWaiter.setProductOptionRequired(opt.title, true);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
// Bind to event fired when price is changed on bundle
|
202 |
+
document.observe("bundle:reload-price", function(event) {
|
203 |
+
PriceWaiter.setPrice(event.memo.priceInclTax);
|
204 |
+
var bSelected = event.memo.bundle.config.selected;
|
205 |
+
var bOptions = event.memo.bundle.config.options;
|
206 |
+
for (var current in bSelected) {
|
207 |
+
// Find which value is selected
|
208 |
+
var currentSelected = bSelected[current];
|
209 |
+
if (currentSelected.length === 0) {
|
210 |
+
// If none, unset the Product option
|
211 |
+
PriceWaiter.clearProductOption(bOptions[current].title);
|
212 |
+
} else {
|
213 |
+
// Otherwise, find the quantity of the selection
|
214 |
+
var qty = bOptions[current].selections[currentSelected].qty;
|
215 |
+
// Now find the value of the selected option, and set priceInclTax
|
216 |
+
var selectedValue = bOptions[current].selections[currentSelected].name;
|
217 |
+
if (qty > 1) {
|
218 |
+
selectedValue += " - Quantity: " + qty;
|
219 |
+
}
|
220 |
+
PriceWaiter.setProductOption(bOptions[current].title, selectedValue);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
});
|
224 |
+
|
225 |
+
// Reload the bundle's price, to pull the initial options into PriceWaiter
|
226 |
+
if (typeof(bundle) != 'undefined') {
|
227 |
+
bundle.reloadPrice();
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
function handleGrouped() {
|
232 |
+
// Get the Grouped product table rows
|
233 |
+
var productTable = $$('table.grouped-items-table')[0];
|
234 |
+
var productRows = productTable.select('tbody')[0];
|
235 |
+
productRows = productRows.childElements();
|
236 |
+
|
237 |
+
for (var row in productRows) {
|
238 |
+
if (!isNaN(parseInt(row, 10))) {
|
239 |
+
// Bind to the Quantity change
|
240 |
+
productRows[row].select('input.qty')[0].observe('change', function(event){
|
241 |
+
var qty = this.value;
|
242 |
+
// Get the Product's name
|
243 |
+
var productName = this.up('tr').firstDescendant().innerHTML;
|
244 |
+
// Get the Product's price
|
245 |
+
var productPrice = this.up('tr').select('span.price')[0].innerHTML;
|
246 |
+
// The user changed the quantity field. We need to find the previous quantity and price
|
247 |
+
var previousQuantity = PriceWaiter.getProductOptions()[productName + " (" + productPrice + ")"];
|
248 |
+
var amountToRemove = Number(previousQuantity * productPrice.substring(1));
|
249 |
+
if (qty > 0) {
|
250 |
+
// Entered a quantity, set product name as option name, add quantity as value
|
251 |
+
PriceWaiter.setProductOption(productName + " (" + productPrice + ")", qty);
|
252 |
+
// Add the price to the product's total
|
253 |
+
PriceWaiter.setPrice(Number(PriceWaiter.getPrice()) + Number(productPrice.substring(1) * qty));
|
254 |
+
} else {
|
255 |
+
PriceWaiter.clearProductOption(productName + " (" + productPrice + ")");
|
256 |
+
}
|
257 |
+
// If they previously had a quantity for this option, remove it from the total
|
258 |
+
if (previousQuantity > 0) {
|
259 |
+
PriceWaiter.setPrice(Number(PriceWaiter.getPrice() - amountToRemove));
|
260 |
+
}
|
261 |
+
});
|
262 |
+
}
|
263 |
+
}
|
264 |
+
}
|
265 |
+
};
|
266 |
+
|
267 |
+
(function() {
|
268 |
+
var pw = document.createElement('script');
|
269 |
+
pw.type = 'text/javascript';
|
270 |
+
pw.src = window.PriceWaiterWidgetUrl;
|
271 |
+
pw.async = true;
|
272 |
+
|
273 |
+
var s = document.getElementsByTagName('script')[0];
|
274 |
+
s.parentNode.insertBefore(pw, s);
|
275 |
+
})();
|
276 |
+
});
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>nypwidget</name>
|
4 |
+
<version>1.2.2</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>PriceWaiter® let's buyers make offers on your products that you can easily accept, counter offer or reject.</summary>
|
10 |
+
<description>Sell more, immediately, with the PriceWaiter® widget. Convert comparison shoppers you might have lost, increase sales and conversions, and stop "minimum advertised price" from preventing sales before they even start.
|
11 |
+
PriceWaiter® lets customers make offers on products you sell-- offers you can accept, reject or counter. The widget embeds a simple Name Your Price button on any product page or category that you choose. Simply install the extension and you'll have full control over PriceWaiter® in your Magento admin control panel.</description>
|
12 |
+
<notes>Added support for new Callback API features aimed at improving multi-store install integration.</notes>
|
13 |
+
<authors><author><name>PriceWaiter</name><user>pricewaiter</user><email>bobby.b@pricewaiter.com</email></author></authors>
|
14 |
+
<date>2013-09-16</date>
|
15 |
+
<time>20:46:22</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="PriceWaiter"><dir name="NYPWidget"><dir name="Block"><dir name="Adminhtml"><file name="Widget.php" hash="cffdba25dabdb8f9b6a2eac21c0e82e0"/></dir><file name="Category.php" hash="ba5bcfb87399356266eb2874bf691d6e"/><file name="Widget.php" hash="25489ee6ae666d91db98b70dd6adbf40"/></dir><dir name="Helper"><file name="Data.php" hash="e2d7bf749fa77e436b4166411c807487"/></dir><dir name="Model"><file name="Callback.php" hash="17239da4d569b101ef99bc621d3eff1b"/><dir name="Carrier"><file name="ShippingMethod.php" hash="1df7b75009a6e6e8e41b554fecb813db"/></dir><file name="Category.php" hash="55588e458cacb778b92fdacd8edeb22a"/><dir name="Display"><file name="Phrase.php" hash="ad605b93302ec648c5a7d3e3401f47b5"/><file name="Size.php" hash="42c2917e730811b78fd12e7591cb9159"/></dir><dir name="Mysql4"><dir name="Category"><file name="Collection.php" hash="adbbb19ccafb1498bb0d4c5d20abddd1"/></dir><file name="Category.php" hash="ba6b693541711d91edc5b7edae799a97"/><dir name="Order"><file name="Collection.php" hash="de7e92559722c9735b32a6d30862087e"/></dir><file name="Order.php" hash="237302190fa65833b5ff187dd0bbe71a"/></dir><file name="Observer.php" hash="a5b643d09e366068028dc1df1abee154"/><file name="Order.php" hash="c44f2d228a38e991843cee197abd397c"/><file name="PaymentMethod.php" hash="0106a5c193079d4cf07005fc9d22dd29"/><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="da87eaa37fc5a09a5d5c38f9bbecabb1"/></dir></dir></dir></dir><dir name="controllers"><file name="CallbackController.php" hash="8b95003b06ebc0e1a05430655f2caacd"/></dir><dir name="etc"><file name="adminhtml.xml" hash="022f1761ba091c7e1f3e4901d40d5ce0"/><file name="config.xml" hash="760169be53a59f3edaaa1c9eff5796bf"/><file name="system.xml" hash="4fde6c9c7ff1fe5db458cc49a60dc891"/></dir><dir name="sql"><dir name="nypwidget_setup"><file name="mysql4-install-1.0.0.php" hash="18bd8c535b0fe03be0cd2a6f4da7cc9c"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="8d4bd167694c277a0e8ab8034d87cb1b"/><file name="mysql4-upgrade-1.1.7-1.1.8.php" hash="2a8de13744724f647e23e612ecf1d196"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="pricewaiter.xml" hash="cc51462b56118a611be1a329b308d528"/></dir><dir name="template"><dir name="pricewaiter"><file name="admin_widget.phtml" hash="daae86cfa34fbe5e786715c0c579e398"/><file name="categorytab.phtml" hash="43f8af9feca6775e4a1e8a149a86268e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="pricewaiter.xml" hash="0da284d426574c7ae1f154b096f8b413"/></dir><dir name="template"><dir name="pricewaiter"><file name="widget.phtml" hash="e88d809e72dec522e9eb27f1df74f5c8"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PriceWaiter_NYPWidget.xml" hash="d3b86fa976b99e64df65f9e98d689257"/></dir></target><target name="mageweb"><dir name="js"><dir name="jscolor-pw"><file name="arrow.gif" hash="5034704a76cd55c1cbcbc58ea6bf523f"/><file name="cross.gif" hash="ba9a274b9323753cd95bc3b1eb2f4e5f"/><file name="hs.png" hash="fefa1a03d92ebad25c88dca94a0b63db"/><file name="hv.png" hash="990d71cada17da100653636cf8490884"/><file name="jscolor.js" hash="668050b57cb3ad59d0a56a16fddf1a91"/></dir><dir name="pricewaiter"><file name="product-pages.js" hash="e45d0be938b5fcc67371c634ff3e623a"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="pricewaiter_logo.png" hash="becb9713a561131ff69eabb7503d3e74"/><file name="pricewaiter_tab.png" hash="1bab71be6b1a93aee2ae7aeae3807484"/></dir><file name="pricewaiter.css" hash="6a58cdaa35d8f61cbb305a6a1a206816"/></dir></dir></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|
skin/adminhtml/default/default/images/pricewaiter_logo.png
ADDED
Binary file
|
skin/adminhtml/default/default/images/pricewaiter_tab.png
ADDED
Binary file
|
skin/adminhtml/default/default/pricewaiter.css
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* Copyright 2013 Price Waiter, LLC
|
3 |
+
*
|
4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
* you may not use this file except in compliance with the License.
|
6 |
+
* You may obtain a copy of the License at
|
7 |
+
*
|
8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
*
|
10 |
+
* Unless required by applicable law or agreed to in writing, software
|
11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
* See the License for the specific language governing permissions and
|
14 |
+
* limitations under the License.
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
h3.pricewaiter-header {
|
18 |
+
background:url(images/pricewaiter_logo.png) no-repeat 0 0;
|
19 |
+
height:0px;
|
20 |
+
overflow:hidden;
|
21 |
+
padding:50px 0 0 0;
|
22 |
+
margin: 0px;
|
23 |
+
width:145px;
|
24 |
+
}
|
25 |
+
|
26 |
+
ul.tabs a.pricewaiter-tab,
|
27 |
+
ul.tabs a.pricewaiter-tab:hover {
|
28 |
+
background:url(images/tabs_span_bg.gif) repeat-x 0 100%;
|
29 |
+
border-bottom:none;
|
30 |
+
padding:0.5em 0.5em 0.28em 1.5em;
|
31 |
+
}
|
32 |
+
|
33 |
+
ul.tabs a.pricewaiter-tab:hover {
|
34 |
+
background-color:#d8e6e6;
|
35 |
+
}
|
36 |
+
|
37 |
+
ul.tabs a.pricewaiter-tab.active,
|
38 |
+
ul.tabs a.pricewaiter-tab.active:hover {
|
39 |
+
background-color:#fff;
|
40 |
+
}
|
41 |
+
|
42 |
+
ul.tabs a.pricewaiter-tab span,
|
43 |
+
ul.tabs a.pricewaiter-tab:hover span {
|
44 |
+
background:url(images/pricewaiter_tab.png) no-repeat 0 0;
|
45 |
+
height:0;
|
46 |
+
overflow:hidden;
|
47 |
+
padding:14px 0 0;
|
48 |
+
width:300x;
|
49 |
+
}
|