Changeset 1648469
- Timestamp:
- 04/30/2017 04:50:26 PM (9 years ago)
- Location:
- shopp/trunk
- Files:
-
- 64 edited
-
Shopp.php (modified) (1 diff)
-
api/core.php (modified) (3 diffs)
-
api/customer.php (modified) (1 diff)
-
api/theme.php (modified) (1 diff)
-
api/theme/cart.php (modified) (1 diff)
-
api/theme/cartitem.php (modified) (4 diffs)
-
api/theme/checkout.php (modified) (1 diff)
-
api/theme/collection.php (modified) (1 diff)
-
api/theme/customer.php (modified) (1 diff)
-
api/theme/error.php (modified) (1 diff)
-
api/theme/product.php (modified) (15 diffs)
-
api/theme/purchase.php (modified) (3 diffs)
-
api/theme/shipping.php (modified) (1 diff)
-
api/theme/storefront.php (modified) (2 diffs)
-
core/flow/Account.php (modified) (1 diff)
-
core/flow/Admin.php (modified) (3 diffs)
-
core/flow/Categorize.php (modified) (1 diff)
-
core/flow/Dashboard.php (modified) (1 diff)
-
core/flow/Order.php (modified) (1 diff)
-
core/flow/Pages.php (modified) (1 diff)
-
core/flow/Registration.php (modified) (4 diffs)
-
core/flow/Report.php (modified) (1 diff)
-
core/flow/Scripts.php (modified) (1 diff)
-
core/flow/Service.php (modified) (1 diff)
-
core/flow/System.php (modified) (5 diffs)
-
core/flow/Warehouse.php (modified) (1 diff)
-
core/library/DB.php (modified) (6 diffs)
-
core/library/Lookup.php (modified) (1 diff)
-
core/library/Session.php (modified) (13 diffs)
-
core/library/Version.php (modified) (2 diffs)
-
core/model/Asset.php (modified) (1 diff)
-
core/model/Cart.php (modified) (2 diffs)
-
core/model/Collection.php (modified) (2 diffs)
-
core/model/Customer.php (modified) (3 diffs)
-
core/model/Discounts.php (modified) (1 diff)
-
core/model/Events.php (modified) (1 diff)
-
core/model/Item.php (modified) (3 diffs)
-
core/model/Product.php (modified) (4 diffs)
-
core/model/Purchase.php (modified) (5 diffs)
-
core/model/Purchased.php (modified) (1 diff)
-
core/model/Shopping.php (modified) (1 diff)
-
core/model/Tax.php (modified) (6 diffs)
-
core/ui/behaviors/cart.js (modified) (1 diff)
-
core/ui/behaviors/cart.min.js (modified) (1 diff)
-
core/ui/behaviors/colorbox.min.js (modified) (1 diff)
-
core/ui/behaviors/editors.min.js (modified) (1 diff)
-
core/ui/behaviors/priceline.min.js (modified) (1 diff)
-
core/ui/behaviors/spin.min.js (modified) (1 diff)
-
core/ui/behaviors/suggest.min.js (modified) (1 diff)
-
core/ui/behaviors/taxrates.min.js (modified) (1 diff)
-
core/ui/categories/category.min.js (modified) (1 diff)
-
core/ui/orders/order.php (modified) (1 diff)
-
core/ui/orders/orders.php (modified) (10 diffs)
-
core/ui/products/editor.min.js (modified) (1 diff)
-
core/ui/products/editor.php (modified) (1 diff)
-
core/ui/products/ui.php (modified) (1 diff)
-
core/ui/styles/admin.css (modified) (1 diff)
-
core/ui/widgets/cart.php (modified) (1 diff)
-
gateways/PayPal/PayPalStandard.php (modified) (15 diffs)
-
package.json (modified) (1 diff)
-
readme.md (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
shipping/core/OrderWeight.php (modified) (1 diff)
-
storage/core/DBStorage.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
shopp/trunk/Shopp.php
r1548347 r1648469 4 4 * Plugin URI: http://shopplugin.com 5 5 * Description: An ecommerce framework for WordPress. 6 * Version: 1.3.1 26 * Version: 1.3.13 7 7 * Author: Ingenesis Limited 8 8 * Author URI: http://ingenesis.net 9 9 * Requires at least: 3.5 10 * Tested up to: 4. 6.110 * Tested up to: 4.7.4 11 11 * 12 12 * Portions created by Ingenesis Limited are Copyright © 2008-2014 by Ingenesis Limited -
shopp/trunk/api/core.php
r1473303 r1648469 264 264 function is_shopp_catalog_frontpage () { 265 265 $Page = ShoppPages()->requested(); 266 267 return $Page !== false && $Page->name() == 'catalog'; 266 return $Page !== false && $Page->name() == 'catalog' && ! is_shopp_smart_collection(); 268 267 } 269 268 … … 626 625 $index_table = ShoppDatabaseObject::tablename(ContentIndex::$table); 627 626 628 $total = sDB::query("SELECT count(*) AS products,now() as start FROM $wpdb->posts WHERE post_ type='" . ShoppProduct::$posttype . "'");629 if ( empty($total->products) ) false;627 $total = sDB::query("SELECT count(*) AS products,now() as start FROM $wpdb->posts WHERE post_status='publish' AND post_type='" . ShoppProduct::$posttype . "'"); 628 if ( empty($total->products) ) return false; 630 629 631 630 set_time_limit(0); // Prevent timeouts … … 634 633 do_action_ref_array('shopp_rebuild_search_index_init', array($indexed, $total->products, $total->start)); 635 634 for ( $i = 0; $i * $set < $total->products; $i++ ) { // Outer loop to support buffering 636 $products = sDB::query("SELECT ID FROM $wpdb->posts WHERE post_ type='" . ShoppProduct::$posttype . "' LIMIT " . ($i * $set) . ",$set", 'array', 'col', 'ID');635 $products = sDB::query("SELECT ID FROM $wpdb->posts WHERE post_status='publish' AND post_type='" . ShoppProduct::$posttype . "' LIMIT " . ($i * $set) . ",$set", 'array', 'col', 'ID'); 637 636 foreach ( $products as $id ) { 638 637 $Indexer = new IndexProduct($id); -
shopp/trunk/api/customer.php
r1473303 r1648469 27 27 $Customer = false; 28 28 if ( ! $customer ) { 29 $Customer = &ShoppCustomer();29 $Customer = ShoppCustomer(); 30 30 return $Customer; 31 31 } -
shopp/trunk/api/theme.php
r1473303 r1648469 74 74 if ( 'hascontext' == $tag ) return ($Object); 75 75 76 if ( ! $Object ) shopp_add_error(Shopp::__("The shopp('%s.%s') tag cannot be used in this context because the object responsible for handling it doesn't exist.", $context, isset($se scond) ? $second : $tag), SHOPP_PHP_ERR);76 if ( ! $Object ) shopp_add_error(Shopp::__("The shopp('%s.%s') tag cannot be used in this context because the object responsible for handling it doesn't exist.", $context, isset($second) ? $second : $tag), SHOPP_PHP_ERR); 77 77 78 78 $themeapi = apply_filters('shopp_themeapi_context_name', $context); -
shopp/trunk/api/theme/cart.php
r1473303 r1648469 95 95 * 96 96 * @param ShoppCart $Object The ShoppCart object to set as the working context 97 * @param string $ object The context being worked on by the Theme API97 * @param string $context The context being worked on by the Theme API 98 98 * @return ShoppCart The active ShoppCart context 99 99 **/ 100 public static function _setobject ( $Object, $ object ) {101 if ( is_object($Object) && is_a($Object, 'ShoppOrder') && isset($Object->Cart) && 'cart' == strtolower($ object) )100 public static function _setobject ( $Object, $context ) { 101 if ( is_object($Object) && is_a($Object, 'ShoppOrder') && isset($Object->Cart) && 'cart' == strtolower($context) ) 102 102 return $Object->Cart; 103 else if ( strtolower($ object) != 'cart' ) return $Object; // not mine, do nothing103 else if ( strtolower($context) != 'cart' ) return $Object; // not mine, do nothing 104 104 105 105 $Order = ShoppOrder(); -
shopp/trunk/api/theme/cartitem.php
r1473303 r1648469 85 85 * @return ShoppCartItem|bool The working ShoppCartItem context 86 86 **/ 87 public static function _setobject ( $Object, $ object ) {87 public static function _setobject ( $Object, $context ) { 88 88 if ( is_object($Object) && is_a($Object, 'Item') ) return $Object; 89 89 90 if ( strtolower($ object) != 'cartitem' ) return $Object; // not mine, do nothing90 if ( strtolower($context) != 'cartitem' ) return $Object; // not mine, do nothing 91 91 else { 92 92 $Cart = ShoppOrder()->Cart; … … 412 412 **/ 413 413 public static function taxrate ( $result, $options, $O ) { 414 414 // remove unused rates (EU) 415 if ( count($O->taxes) > 1 ) { 416 $taxrates = array(); 417 foreach ( $O->taxes as $label => $rate ) 418 if ( ! is_null($rate->amount) ) $taxrates[$label] = $rate; 419 420 $O->taxes = $taxrates; 421 } 415 422 if ( count($O->taxes) == 1 ) { 416 423 $Tax = reset($O->taxes); … … 721 728 extract($options); 722 729 723 $classes = ! empty($class) ? ' class="' . esc_attr($class) . '"' : ''; 724 $excludes = explode(',', $exclude); 725 $prices = Shopp::str_true($prices); 726 $taxes = Shopp::str_true($taxes); 730 $classes = ! empty($class) ? ' class="' . esc_attr($class) . '"' : ''; 731 $excludes = explode(',', $exclude); 732 $prices = Shopp::str_true($prices); 733 $taxoption = Shopp::str_true($taxes); 734 $inclusivetax = self::_inclusive_taxes($O); 727 735 728 736 // Get the menu labels list and addon options to menus map … … 736 744 737 745 $price = ( Shopp::str_true($addon->sale) ? $addon->promoprice : $addon->price ); 738 if ( $taxes && $O->taxrate > 0 ) 746 747 if ( isset($O->taxprice) ) 748 $adjustment = $O->taxprice/$O->unitprice; 749 else 750 $adjustment = $O->taxrate; 751 752 if ( $adjustment < 0 ) 753 $adjustment = 1 + $adjustment; 754 755 if ( 0 != $adjustment ) 756 $price = $price / $adjustment; 757 758 if ( isset($taxoption) && ( $inclusivetax ^ $taxoption ) ) 739 759 $price = $price + ( $price * $O->taxrate ); 740 760 741 if ( $prices ) $pricing = " (" . ( $addon->price < 0 ? '-' : '+' ) . money($price) . ')';742 $result .= '<li>' . $menu . $addon->label . $pricing . '</li>';761 if ( $prices ) $pricing = " (" . ( $addon->price < 0 ? '-' : '+' ) . money($price) . ')'; 762 $result .= '<li>' . $menu . $addon->label . $pricing . '</li>'; 743 763 } 744 764 $result .= '</ul>' . $after; -
shopp/trunk/api/theme/checkout.php
r1473303 r1648469 134 134 * 135 135 * @param ShoppOrder $Object The ShoppOrder object to set as the working context 136 * @param string $ object The context being worked on by the Theme API136 * @param string $context The context being worked on by the Theme API 137 137 * @return ShoppOrder|ShoppCustomer The active object context 138 138 **/ 139 public static function _setobject ( $Object, $ object, $tag ) {140 141 if ( is_object($Object) && is_a($Object, 'ShoppOrder') && 'checkout' == strtolower($ object) ) return $Object;142 else if ( strtolower($ object) != 'checkout' ) return $Object; // not mine, do nothing139 public static function _setobject ( $Object, $context, $tag ) { 140 141 if ( is_object($Object) && is_a($Object, 'ShoppOrder') && 'checkout' == strtolower($context) ) return $Object; 142 else if ( strtolower($context) != 'checkout' ) return $Object; // not mine, do nothing 143 143 144 144 if ( isset(self::$register[ $tag ]) ) { -
shopp/trunk/api/theme/collection.php
r1473303 r1648469 930 930 // end previous button 931 931 932 if ( $O->page <= floor( $show / 2) ) { 932 $center = floor( $show / 2); 933 if ( $O->page <= $center ) { 933 934 $i = 1; 934 935 } else { 935 $i = $O->page - floor( $show / 2 );936 $visible_pages = $O->page + floor( $show / 2 )+ 1;936 $i = $O->page - $center; 937 $visible_pages = $O->page + $center + 1; 937 938 if ( $visible_pages > $O->pages ) { 938 939 $visible_pages = $O->pages + 1; 939 $i = $O->pages - $show; 940 // to prevent negative pagenumbers 941 $i = max( 1, $O->pages - $show); 940 942 } 941 943 -
shopp/trunk/api/theme/customer.php
r1473303 r1648469 133 133 * @return ShoppCustomer The active object context 134 134 **/ 135 public static function _setobject ($Object, $ object) {135 public static function _setobject ($Object, $context) { 136 136 137 137 if ( is_object($Object) && is_a($Object, 'ShoppCustomer') ) return $Object; 138 138 139 if ( strtolower($ object) != 'customer' ) return $Object; // not mine, do nothing139 if ( strtolower($context) != 'customer' ) return $Object; // not mine, do nothing 140 140 else { 141 141 return ShoppCustomer(); -
shopp/trunk/api/theme/error.php
r1473303 r1648469 61 61 * @return ShoppErrors The active object context 62 62 **/ 63 public static function _setobject ( $Object, $ object ) {63 public static function _setobject ( $Object, $context ) { 64 64 if ( is_object($Object) && is_a($Object, 'ShoppErrors') ) return $Object; 65 65 66 if ( strtolower($ object) != 'error' ) return $Object; // not mine66 if ( strtolower($context) != 'error' ) return $Object; // not mine 67 67 return ShoppErrors(); 68 68 } -
shopp/trunk/api/theme/product.php
r1473303 r1648469 85 85 'outofstock' => 'out_of_stock', 86 86 'price' => 'price', 87 'processing' => 'processing', 88 'relevance' => 'relevance', 87 89 'saleprice' => 'saleprice', 88 'relevance' => 'relevance',89 90 'savings' => 'savings', 90 91 'schema' => 'schema', … … 150 151 * @return ShoppProduct The active object context 151 152 **/ 152 public static function _setobject ($Object, $ object) {153 public static function _setobject ($Object, $context) { 153 154 if ( is_object($Object) && is_a($Object, 'ShoppProduct') ) return $Object; 154 155 155 if ( 'product' != strtolower($ object) ) return $Object; // not mine, do nothing156 if ( 'product' != strtolower($context) ) return $Object; // not mine, do nothing 156 157 else { 157 158 return ShoppProduct(); … … 300 301 } 301 302 302 if ( shopp_setting_enabled('inventory') && $O->outofstock) return false; // Completely out of stock, hide menus303 if ( ! self::availability($result, $options, $O) ) return false; // Completely out of stock, hide menus 303 304 if ( ! isset($O->options['a']) ) return false; // There are no addons, don't render menus 304 305 … … 379 380 if ( Shopp::str_true($label) ) $markup[] = '<label for="' . esc_attr($menuid) . '">' . esc_html($menu['name']) . '</label> '; 380 381 381 $category_class = shopp('collection.get-slug'); 382 $category_slug = array_column($O->categories, 'slug'); 383 $category_class = implode(' ', $category_slug); 382 384 $classes = array($class, $category_class, 'addons'); 383 385 … … 458 460 459 461 $string = ''; 460 if ( shopp_setting_enabled('inventory') && $O->outofstock)462 if ( ! self::availability($result, $options, $O) ) 461 463 return apply_filters('shopp_product_outofstock_text', '<span class="outofstock">' . esc_html(shopp_setting('outofstock_text')) . '</span>'); 462 464 … … 510 512 **/ 511 513 public static function availability ( $result, $options, $O ) { 512 return ! ( shopp_setting_enabled('inventory') && $O->outofstock );514 return ! ( shopp_setting_enabled('inventory') && $O->outofstock && ! shopp_setting_enabled('backorders') ); 513 515 } 514 516 … … 1155 1157 $Cart = ShoppOrder()->Cart; 1156 1158 1157 if ( ! isset($Cart->count) || $Cart->count== 0 ) return false; // Cart is empty1159 if ( $Cart->count() == 0 ) return false; // Cart is empty 1158 1160 1159 1161 foreach ( $Cart as $Item ) … … 1336 1338 * @param array $options The options 1337 1339 * - **label**: Show a label if the product is out of stock 1340 * - **mode**: `text` (text|value) Return 'Out of stock' text or boolean true or false 1338 1341 * @param ShoppProduct $O The working object 1339 1342 * @return bool|string True if out-of-stock, false otherwise, or the given label 1340 1343 **/ 1341 1344 public static function out_of_stock ( $result, $options, $O ) { 1342 1343 1345 if ( ! shopp_setting_enabled('inventory') ) return false; 1344 1346 if ( ! $O->outofstock ) return false; 1345 1346 if ( isset($options['label']) ) { // If label option is set at all, show the label instead 1347 $classes = array('outofstock'); 1348 if ( isset($options['class']) ) 1349 $classes = array_merge($classes, explode(' ', $options['class'])); 1350 1351 $label = shopp_setting('outofstock_text'); // @deprecated Removing label setting 1352 if ( empty($label) ) $label = Shopp::__('Out of stock'); 1353 if ( ! Shopp::str_true($options['label']) ) $label = $options['label']; 1354 return '<span class="' . esc_attr(join(' ', $classes)). '">' . esc_html($label) . '</span>'; 1355 1356 } else return true; 1357 1347 1348 $defaults = array( 1349 'label' => shopp_setting('outofstock_text'),// @deprecated Removing label setting 1350 'mode' => 'text', 1351 ); 1352 1353 $options = array_merge($defaults, $options); 1354 extract($options); 1355 1356 if ( 'value' == $mode ) return true; 1357 1358 $classes = array('outofstock'); 1359 if ( isset($class) ) 1360 $classes = array_merge($classes, explode(' ', $class)); 1361 1362 if ( empty($label) ) $label = Shopp::__('Out of stock'); 1363 1364 return '<span class="' . esc_attr(join(' ', $classes)). '">' . esc_html($label) . '</span>'; 1358 1365 } 1359 1366 … … 1420 1427 1421 1428 /** 1422 * Provide the sale price or sale price range of the product 1423 * 1424 * @api `shopp('product.saleprice')` 1425 * @since 1.0 1426 * 1427 * @param string $result The output 1428 * @param array $options The options 1429 * - **disabled**: `Currently unavailable` The label to show when the product is disabled (no valid, active prices) 1430 * - **high**: `off` (on,off) Show only the highest price of the variant price range 1431 * - **low**: `off` (on,off) Show only the lowest price of the variant price range 1432 * - **money**: `on` (on,off) Format the number with the current currency format for the store 1433 * - **number**: `off` (on,off) Provide the pure numeric value without currency formatting 1434 * - **separator**: `— ` The separator used for the price range 1435 * - **starting**: Provides a label and displays the lowest price with the label as a prefix (@example "Starting at $9.99") 1436 * - **taxes**: (on,off) Include taxes in the price or exclude taxes from the price 1437 * @param ShoppProduct $O The working object 1438 * @return string The sale price markup 1439 **/ 1440 public static function saleprice ( $result, $options, $O ) { 1441 $options['property'] = 'saleprice'; 1442 return self::price( $result, $options, $O ); 1429 * Provides the processing time of the product 1430 * 1431 * @api `shopp('product.processing')` 1432 * @since 1.3 1433 * 1434 * @param string $result The output 1435 * @param array $options The options 1436 * @param ShoppProduct $O The working object 1437 * @return string|boolean The product processing time markup | False when turned off 1438 **/ 1439 public static function processing ( $result, $options, $O ) { 1440 if ( 'off' == $O->processing ) return false; 1441 1442 $period = array( 'd' => Shopp::__('day'), 'w' => Shopp::__('week'), 'm' => Shopp::__('month')); 1443 $periods = array( 'd' => Shopp::__('days'), 'w' => Shopp::__('weeks'), 'm' => Shopp::__('months')); 1444 1445 $minprocess = 0; 1446 $maxprocess = 0; 1447 $processes = array('minprocess', 'maxprocess'); 1448 1449 foreach ($processes as $process) { 1450 $timespan = preg_split('/(?<=[0-9])(?=[a-z]+)/i', $O->$process); 1451 if ( $timespan[0] == 1 ) 1452 $$process = $timespan[0] . ' ' . $period[ $timespan[1] ]; 1453 else 1454 $$process = $timespan[0] . ' ' . $periods[ $timespan[1] ]; 1455 } 1456 1457 return $minprocess . ' - ' . $maxprocess; 1443 1458 } 1444 1459 … … 1480 1495 public static function quantity ( $result, $options, $O ) { 1481 1496 if ( ! shopp_setting_enabled('shopping_cart') ) return ''; 1482 if ( shopp_setting_enabled('inventory') && $O->outofstock) return '';1497 if ( ! self::availability($result, $options, $O) ) return ''; 1483 1498 1484 1499 $inputs = array('text','menu'); … … 1489 1504 'label' => '', 1490 1505 'options' => '1-15,20,25,30,40,50,75,100', 1491 'size' => false1506 'size' => '1' 1492 1507 ); 1493 1508 $options = array_merge($defaults, $options); … … 1573 1588 return (string) $O->score; 1574 1589 } 1590 1591 /** 1592 * Provide the sale price or sale price range of the product 1593 * 1594 * @api `shopp('product.saleprice')` 1595 * @since 1.0 1596 * 1597 * @param string $result The output 1598 * @param array $options The options 1599 * - **disabled**: `Currently unavailable` The label to show when the product is disabled (no valid, active prices) 1600 * - **high**: `off` (on,off) Show only the highest price of the variant price range 1601 * - **low**: `off` (on,off) Show only the lowest price of the variant price range 1602 * - **money**: `on` (on,off) Format the number with the current currency format for the store 1603 * - **number**: `off` (on,off) Provide the pure numeric value without currency formatting 1604 * - **separator**: `— ` The separator used for the price range 1605 * - **starting**: Provides a label and displays the lowest price with the label as a prefix (@example "Starting at $9.99") 1606 * - **taxes**: (on,off) Include taxes in the price or exclude taxes from the price 1607 * @param ShoppProduct $O The working object 1608 * @return string The sale price markup 1609 **/ 1610 public static function saleprice ( $result, $options, $O ) { 1611 $options['property'] = 'saleprice'; 1612 return self::price( $result, $options, $O ); 1613 } 1575 1614 1576 1615 /** … … 2120 2159 } 2121 2160 2122 if ( shopp_setting_enabled('inventory') && $O->outofstock) return false; // Completely out of stock, hide menus2161 if ( ! self::availability($result, $options, $O) ) return false; // Completely out of stock, hide menus 2123 2162 if ( ! isset($options['taxes']) ) $options['taxes'] = null; 2124 2163 … … 2377 2416 if ( empty($taxrates) ) $taxrates = Shopp::taxrates($O); 2378 2417 2418 $inclusivetax = self::_inclusive_taxes($O); 2419 2379 2420 if ( isset($taxoption) ) 2380 2421 $taxoption = Shopp::str_true( $taxoption ); 2381 2382 $inclusivetax = self::_inclusive_taxes($O);2383 if ( $inclusivetax ) { 2384 $adjustment = ShoppTax::adjustment($taxrates);2385 if ( 1 != $adjustment && false !== $taxoption ) // Only adjust when taxes are not excluded @see #30412386 return (float) ($amount / $adjustment); 2387 }2422 else 2423 $taxoption = $inclusivetax; 2424 2425 $adjustment = ShoppTax::adjustment($taxrates, $O); 2426 extract($adjustment); 2427 2428 if ( $baserate == $appliedrate && 0 == $baserate ) return $amount; 2388 2429 2389 2430 // Handle inclusive/exclusive tax presentation options (product editor setting or api option) … … 2391 2432 // or the 'taxes' option is forced on (but not both) then handle taxes by either adding or excluding taxes 2392 2433 // This is an exclusive or known as XOR, the lesser known brother of Thor that gets left out of the family get togethers 2393 if ( isset($taxoption) && ( $inclusivetax ^ $taxoption ) ) { 2394 2434 if ( $inclusivetax ) { 2435 if ( $taxoption ) { 2436 if ( $baserate == $appliedrate ) return $amount; 2437 //return (float)($amount * ( 1 / ( 1 + $baserate ) ) ) * ( 1 + $appliedrate ); 2438 return (float)($amount / ( 1 + $baserate ) ) * ( 1 + $appliedrate ); 2439 } else { 2440 //return (float)$amount * ( 1 / ( 1 + $baserate ) ); 2441 return (float)$amount / ( 1 + $baserate ); 2442 } 2443 } else { 2395 2444 if ( $taxoption ) 2396 return ShoppTax::calculate($taxrates, (float)$amount); 2397 else return ShoppTax::exclusive($taxrates, (float)$amount); 2398 2399 } 2445 return (float)$amount * ( 1 + $appliedrate ); 2446 } 2400 2447 2401 2448 return $amount; -
shopp/trunk/api/theme/purchase.php
r1473303 r1648469 151 151 * @return ShoppPurchase The active object context 152 152 **/ 153 public static function _setobject ( $Object, $ object ) {153 public static function _setobject ( $Object, $context ) { 154 154 if ( is_object($Object) && is_a($Object, 'Purchase') ) return $Object; 155 155 156 if ( strtolower($ object) != 'purchase' ) return $Object; // not mine, do nothing156 if ( strtolower($context) != 'purchase' ) return $Object; // not mine, do nothing 157 157 else { 158 158 return ShoppPurchase(); … … 633 633 * Iterates over the addons from the current item in the items loop 634 634 * 635 * @api `shopp('purc ahse.item-addons')`635 * @api `shopp('purchase.item-addons')` 636 636 * @since 1.1 637 637 * … … 1427 1427 public static function ship_state ( $result, $options, $O ) { 1428 1428 $state = esc_html($O->shipstate); 1429 if ( strlen( $O->s tate > 2 ) ) return $state;1429 if ( strlen( $O->shipstate > 2 ) ) return $state; 1430 1430 $regions = Lookup::country_zones(); 1431 1431 -
shopp/trunk/api/theme/shipping.php
r1473303 r1648469 74 74 * @return ShoppShiprates The active object context 75 75 **/ 76 public static function _setobject ( $Object, $ object ) {77 if ( is_object($Object) && is_a($Object, 'ShoppOrder') && isset($Object->Shiprates) && 'shipping' == strtolower($ object) )76 public static function _setobject ( $Object, $context ) { 77 if ( is_object($Object) && is_a($Object, 'ShoppOrder') && isset($Object->Shiprates) && 'shipping' == strtolower($context) ) 78 78 return $Object->Shiprates; 79 else if ( 'shipping' != strtolower($ object) ) return $Object; // not mine, do nothing79 else if ( 'shipping' != strtolower($context) ) return $Object; // not mine, do nothing 80 80 81 81 return ShoppOrder()->Shiprates; -
shopp/trunk/api/theme/storefront.php
r1473303 r1648469 109 109 * @return ShoppStorefront The active object context 110 110 **/ 111 public static function _setobject ( $Object, $ object ) {111 public static function _setobject ( $Object, $context ) { 112 112 if ( is_object($Object) && is_a($Object, 'ShoppCatalog') ) return $Object; 113 113 114 switch ( strtolower($ object) ) {114 switch ( strtolower($context) ) { 115 115 case 'storefront': 116 116 case 'catalog': … … 1658 1658 $Storefront = ShoppStorefront(); 1659 1659 $page = current($Storefront->menus); 1660 if ( array_key_exists('url', $options) ) return add_query_arg($page->request, '', Shopp::url(false, 'account' ));1660 if ( array_key_exists('url', $options) ) return add_query_arg($page->request, '', Shopp::url(false, 'account', is_ssl())); 1661 1661 if ( array_key_exists('action', $options) ) return $page->request; 1662 1662 if ( array_key_exists('classes', $options) ) { -
shopp/trunk/core/flow/Account.php
r1473303 r1648469 393 393 if ( empty($Customer->info->meta) ) remove_meta_box('customer-info', 'shopp_page_shopp-customers', 'normal'); 394 394 395 //JM if ($Customer->id > 0) {396 395 if ( ! $new_customer ) { 397 396 $purchase_table = ShoppDatabaseObject::tablename(ShoppPurchase::$table); -
shopp/trunk/core/flow/Admin.php
r1473303 r1648469 92 92 93 93 add_filter('wp_dropdown_pages', array($this, 'storefront_pages')); 94 add_filter('pre_update_option_page_on_front', array($this, 'frontpage') );94 add_filter('pre_update_option_page_on_front', array($this, 'frontpage'), 10, 2); 95 95 96 96 $this->pages(); … … 1104 1104 if ( !empty( $columns ) ) { 1105 1105 $this->_columns = $columns; 1106 add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0);1106 add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 1 ); 1107 1107 } 1108 1108 … … 1115 1115 $primary = method_exists($this, "get_primary_column_name") ? $this->get_primary_column_name() : null; 1116 1116 1117 $_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );1117 $_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns(), 1 ); 1118 1118 1119 1119 $sortable = array(); -
shopp/trunk/core/flow/Categorize.php
r1473303 r1648469 51 51 shopp_enqueue_script('priceline'); 52 52 shopp_enqueue_script('ocupload'); 53 // JMshopp_enqueue_script('swfupload');54 // JMshopp_enqueue_script('shopp-swfupload-queue');53 //shopp_enqueue_script('swfupload'); 54 //shopp_enqueue_script('shopp-swfupload-queue'); 55 55 56 56 do_action('shopp_category_editor_scripts'); -
shopp/trunk/core/flow/Dashboard.php
r1473303 r1648469 381 381 ?> 382 382 <table><tbody> 383 <?php foreach ( $Collection->products as $product ): $product->lowstock($product->stock, $product->stocked); ?> 384 <tr> 385 <td class="amount"><?php echo abs($product->stock); ?></td> 386 <td><span class="stock lowstock <?php echo $product->lowstock; ?>"><?php echo $warnings[ $product->lowstock ]; ?></span></td> 387 <td><a href="<?php echo esc_url(add_query_arg('id',$product->id,$productscreen)); ?>"><?php echo $product->name; ?></a></td> 388 <td><a href="<?php echo esc_url(add_query_arg('view','inventory',$productscreen)); ?>"><?php echo $product->sku; ?></a></td> 389 </tr> 390 <?php endforeach; ?> 383 <?php if ( empty($Collection->products) ) : ?> 384 <tr><td colspan="4"><?php Shopp::_e('No low stock products found.'); ?></td></tr> 385 <?php else: ?> 386 <?php foreach ( $Collection->products as $product ): $product->lowstock($product->stock, $product->stocked); ?> 387 <tr> 388 <td class="amount"><?php echo abs($product->stock); ?></td> 389 <td><span class="stock lowstock <?php echo $product->lowstock; ?>"><?php echo $warnings[ $product->lowstock ]; ?></span></td> 390 <td><a href="<?php echo esc_url(add_query_arg('id',$product->id,$productscreen)); ?>"><?php echo $product->name; ?></a></td> 391 <td><a href="<?php echo esc_url(add_query_arg('view','inventory',$productscreen)); ?>"><?php echo $product->sku; ?></a></td> 392 </tr> 393 <?php endforeach; ?> 394 <?php endif; ?> 391 395 </tbody></table> 392 396 -
shopp/trunk/core/flow/Order.php
r1548347 r1648469 273 273 shopp_debug("Lock $lockid process appears to have completed, redirecting..."); 274 274 275 // Otherwise an error must have occur ed, bounce back to checkout275 // Otherwise an error must have occurred, bounce back to checkout 276 276 Shopp::redirect(Shopp::url(array('inprogress' => '1'), 'checkout', $this->security())); 277 277 return; -
shopp/trunk/core/flow/Pages.php
r1473303 r1648469 331 331 global $wp_query; 332 332 // Test that this is the main query and it is a catalog page 333 if ( ! $wp_query->is_main_query() || ! is_ catalog_frontpage() ) return $content;333 if ( ! $wp_query->is_main_query() || ! is_shopp_catalog_frontpage() ) return $content; 334 334 335 335 shopp_debug('Displaying catalog page request: ' . $_SERVER['REQUEST_URI']); -
shopp/trunk/core/flow/Registration.php
r1473303 r1648469 166 166 $Customer = ShoppOrder()->Customer; 167 167 do_action('shopp_customer_registration', $Customer); 168 $registration = false; 168 169 169 170 if ( $Customer->session(ShoppCustomer::GUEST) ) { … … 179 180 } 180 181 181 if ( ! $Customer->exists(true) ) { 182 $registration = ! $Customer->exists(true); 183 184 if ( $registration ) { 182 185 $Customer->id = false; 183 186 shopp_debug('Creating new Shopp customer record'); 187 184 188 if ( empty($Customer->password) ) 185 189 $Customer->password = wp_generate_password(12, true); … … 192 196 } 193 197 194 // New customer, save hashed password 198 // New customer, save hashed password 195 199 $Customer->save(); 196 200 $Customer->password = ''; … … 205 209 } 206 210 207 do_action('shopp_customer_registered', $Customer); 211 if ( $registration ) 212 do_action('shopp_customer_registered', $Customer); 213 else do_action('shopp_customer_registration_updated', $Customer); 208 214 209 215 // Auto-login -
shopp/trunk/core/flow/Report.php
r1473303 r1648469 285 285 286 286 add_action('shopp_report_filter_controls', array($this, 'filters')); 287 add_action("manage_{$this->screen}_columns", array($this, 'screencolumns') );288 add_action("manage_{$this->screen}_sortable_columns", array($this, 'sortcolumns') );287 add_action("manage_{$this->screen}_columns", array($this, 'screencolumns'), 0); 288 add_action("manage_{$this->screen}_sortable_columns", array($this, 'sortcolumns'), 0); 289 289 } 290 290 -
shopp/trunk/core/flow/Scripts.php
r1473303 r1648469 25 25 /** From BackPress */ 26 26 if ( ! class_exists('WP_Scripts') ) { 27 if ( file_exists( ABSPATH . WPINC . '/class-wp-dependency.php' ) ) 28 require( ABSPATH . WPINC . '/class-wp-dependency.php' ); // Fix for Wordpress 4.7 27 29 require( ABSPATH . WPINC . '/class.wp-dependencies.php' ); 28 30 require( ABSPATH . WPINC . '/class.wp-scripts.php' ); -
shopp/trunk/core/flow/Service.php
r1473303 r1648469 559 559 $Purchase->copydata($Customer); 560 560 $Purchase->save(); 561 } else $this->notice(Shopp::__('An unknown error occur ed. The customer could not be created.'), 'error');561 } else $this->notice(Shopp::__('An unknown error occurred. The customer could not be created.'), 'error'); 562 562 } 563 563 -
shopp/trunk/core/flow/System.php
r1473303 r1648469 531 531 $countries = array_merge($specials, (array)shopp_setting('target_markets')); 532 532 533 534 533 $zones = Lookup::country_zones(); 535 534 … … 567 566 if ( '*' != $rate['country'] ) $score++; 568 567 569 $score += $rate['rate'] / 100;568 $score += (float)$rate['rate'] / 100; 570 569 } 571 570 … … 984 983 985 984 public static function reindex_init ( $indexed, $total, $start ) { 986 echo str_pad( '<html><body><script type="text/javascript">var indexProgress = 0;</script>' . "\n", 2048, ' ');985 echo str_pad(header("X-Accel-Buffering: no").header("Content-Encoding: none").'<html><body><script type="text/javascript">var indexProgress = 0;</script>' . "\n", 4096, ' '); 987 986 @ob_flush(); 988 987 @flush(); … … 991 990 public static function reindex_progress ( $indexed, $total, $start ) { 992 991 if ( $total == 0 ) return; 993 echo str_pad('<script type="text/javascript">indexProgress = ' . $indexed/(int)$total . ';</script>' . "\n", 2048, ' ');992 echo str_pad('<script type="text/javascript">indexProgress = ' . $indexed/(int)$total . ';</script>' . "\n", 4096, ' '); 994 993 if ( ob_get_length() ) { 995 994 @ob_flush(); … … 999 998 1000 999 public static function reindex_completed ( $indexed, $total, $start ) { 1001 echo str_pad('</body><html>'."\n", 2048, ' ');1000 echo str_pad('</body><html>'."\n", 4096, ' '); 1002 1001 if ( ob_get_length() ) 1003 1002 @ob_end_flush(); -
shopp/trunk/core/flow/Warehouse.php
r1473303 r1648469 413 413 // 'debug' => true 414 414 ); 415 } elseif ( 'sku' == $orderby ) { 416 $loading['joins'] = array_merge(array($pt => "LEFT JOIN $pt AS pt ON p.ID=pt.product"), $joins); 415 417 } 416 418 -
shopp/trunk/core/library/DB.php
r1548347 r1648469 247 247 * 248 248 * @param string|array|object $data Data to be escaped 249 * @param boolean $unescape Whether or not to unescape() before escape() 249 250 * @return string Database-safe data 250 251 **/ 251 public static function escape ( $data ) {252 public static function escape ( $data, $unescape = true ) { 252 253 // Prevent double escaping by stripping any existing escapes out 253 254 if ( is_array($data) ) array_map(array(__CLASS__, 'escape'), $data); … … 257 258 } else { 258 259 $db = sDB::get(); 259 $data = self::unescape($data); // Prevent double-escapes 260 if ( $unescape === true ) 261 $data = self::unescape($data); // Prevent double-escapes 262 260 263 $data = $db->api->escape($data); 261 264 } … … 438 441 439 442 // Free the results immediately to save memory 440 // JMAdded check for empty result to prevent warning 'Could not fetch mysqli_result'443 // Added check for empty result to prevent warning 'Could not fetch mysqli_result' 441 444 if ( isset($db->found) && $db->found > 0 ) $db->api->free(); 442 445 … … 978 981 979 982 if ( $Settings->available() ) { 980 983 if ( empty($Tables) ) $Tables = array(); 981 984 $Tables[ $this->_table ] = new StdClass(); 982 985 $Tables[ $this->_table ]->_datatypes =& $this->_datatypes; … … 1323 1326 **/ 1324 1327 public function copydata ( $data, $prefix = '', $ignores = false ) { 1325 if ( ! is_array($ignores) || ! $ignores) $ignores = array('_datatypes', '_table', '_key', '_lists', '_map', 'id', 'created', 'modified');1328 if ( ! is_array($ignores) || $ignores === false ) $ignores = array('_datatypes', '_table', '_key', '_lists', '_map', 'id', 'created', 'modified'); 1326 1329 1327 1330 $properties = is_object($data) ? get_object_vars($data) : $data; … … 1492 1495 function save () { 1493 1496 parent::save(); 1494 do_action('save_post', $this->id,get_post($this->id));1497 do_action('save_post', $this->id, get_post($this->id), $update = true); 1495 1498 } 1496 1499 -
shopp/trunk/core/library/Lookup.php
r1548347 r1648469 597 597 598 598 public static function country_euvat () { 599 $_ = array( // Includes 28 core member states plus dependent territories 600 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'ES', 'ET', 'EE', 601 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IM', 'IT', 'LB', 602 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 603 'SK'); 599 $_ = array( // Includes 28 core member countries plus dependent territories 600 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'ES', 'EE', 'FI', 601 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IM', 'IT', 'LB', 'LT', 602 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK'); 604 603 return (array)apply_filters('shopp_country_euvat', $_); 605 604 } -
shopp/trunk/core/library/Session.php
r1548347 r1648469 99 99 } 100 100 101 $this->session = $session;101 $this->session = $session; 102 102 } 103 103 … … 127 127 128 128 if ( ! empty( $_COOKIE[ SHOPP_SESSION_COOKIE ] ) ) 129 return ( $this->session = $_COOKIE[ SHOPP_SESSION_COOKIE ] );129 return (bool)( $this->session = $_COOKIE[ SHOPP_SESSION_COOKIE ] ); 130 130 131 131 } … … 187 187 **/ 188 188 protected function cook () { 189 if ( ! $this->can_cook() ) return false; 190 191 if ( headers_sent() ) { 189 if ( ! $this->cookable() ) 190 return false; 191 192 if ( headers_sent() && PHP_SAPI !== 'cli' ) { 192 193 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) 193 194 trigger_error('Shopp session cookie cannot be set after output headers have been sent.', E_USER_NOTICE ); … … 198 199 $this->modified = time(); 199 200 200 return setcookie(201 return $this->setcookie( 201 202 SHOPP_SESSION_COOKIE, // Shopp session cookie name 202 $this->session(), // Generated session id203 $this->session(), // Generated session id 203 204 false, // Expiration (false makes it expire with the session) 204 205 COOKIEPATH, // Path … … 208 209 ); 209 210 } 211 212 /** 213 * Determine whether Shopp should cook a new session. 214 * 215 * @since 1.3.10 216 * 217 * @return void 218 **/ 219 public function cookable () { 220 /** 221 * 222 * Allow plugins to prevent Shopp from generating a new session. Example: for performance, 223 * a site could prevent creating a session on non-Shopp pages. 224 * 225 * @since 1.3.10 226 * 227 * @param boolean $session Allow Shopp to create a session. true or false 228 */ 229 return apply_filters('shopp_session_cook', true); 230 } 210 231 211 232 /** … … 221 242 **/ 222 243 public function save () { 223 224 // Don't update the session for prefetch requests (via <link rel="next" /> or <link rel="prefetch" /> tags) 225 if ( isset($_SERVER['HTTP_X_MOZ']) && 'prefetch' == $_SERVER['HTTP_X_MOZ'] // Firefox 226 || isset($_SERVER['HTTP_X_PURPOSE']) // Chrome/Safari 227 && in_array($_SERVER['HTTP_X_PURPOSE'], array('preview', 'instant')) ) 228 return false; 244 if ( ! $this->cookable() ) 245 return true; 229 246 230 247 if ( empty($this->session) ) return false; // Do not save if there is no session id … … 339 356 **/ 340 357 protected function create ( $session ) { 358 if ( ! $this->cookable() ) 359 return true; 360 341 361 $now = current_time('mysql'); 342 362 $query = "INSERT $this->_table SET session='$session',data='',ip='$this->ip',created='$now',modified='$now'"; … … 353 373 **/ 354 374 private function securekey () { 355 if ( ! $this->c an_cook() ) return false;375 if ( ! $this->cookable() ) return false; 356 376 if ( ! is_ssl() ) return false; 357 377 … … 361 381 $entropy = $this->entropy(); 362 382 $key = hash('sha256', $this->session . microtime(true) . $this->ip . $entropy); 363 $success = setcookie(SHOPP_SECURE_KEY, $key, 0, COOKIEPATH, COOKIE_DOMAIN, true, true);383 $success = $this->setcookie(SHOPP_SECURE_KEY, $key, 0, COOKIEPATH, COOKIE_DOMAIN, true, true); 364 384 365 385 if ( $success ) return $key; … … 390 410 391 411 $db = sDB::object(); 392 $data = $db->api->escape($secure);412 $data = sDB::escape($secure, false); 393 413 394 414 } … … 411 431 private function decrypt ( &$data ) { 412 432 413 $BOF = strlen(self::ENCRYPTION);414 415 433 // Set the secured flag if the data is encrypted 416 $this->secured = ( self::ENCRYPTION == substr($data, 0, $BOF) );434 $this->secured = ( 0 === strpos($data, self::ENCRYPTION) ); 417 435 if ( ! $this->secured ) return; 418 436 … … 423 441 424 442 $db = sDB::object(); 425 $data = sDB::query("SELECT AES_DECRYPT('" . $db->api->escape(substr($data, $BOF)) . "','$key') AS data", 'auto', 'col', 'data');443 $data = sDB::query("SELECT AES_DECRYPT('" . sDB::escape(ltrim($data, self::ENCRYPTION), false) . "','$key') AS data", 'auto', 'col', 'data'); 426 444 427 445 } … … 477 495 return $entropy; 478 496 } 479 480 /** 481 * Determine whether Shopp can cook a new session. 482 * 483 * @since 1.4.0 484 * 485 * @return void 486 **/ 487 public function can_cook() { 488 /** 489 * 490 * Allow plugins to prevent Shopp from sessioning. Example: for performance, 491 * a site could prevent sessioning on non-Shopp pages. 492 * 493 * @since 1.3.10.x 494 * 495 * @param boolean $session Allow Shopp to create a session. true or false 496 */ 497 return apply_filters('shopp_session_cook', true); 497 498 private function setcookie($name, $value, $expires, $path, $domain, $secure, $httponly) { 499 if ( PHP_SAPI === 'cli' ) { 500 $_COOKIE[ $name ] = $value; 501 return true; 502 } 503 return setcookie($name, $value, $expires, $path, $domain, $secure, $httponly); 498 504 } 499 505 -
shopp/trunk/core/library/Version.php
r1548347 r1648469 22 22 23 23 /** @type int PATCH The maintenance patch version number */ 24 const PATCH = 1 2;24 const PATCH = 13; 25 25 26 26 /** @type string PRERELEASE The prerelease designation (dev, beta, RC1) */ … … 28 28 29 29 /** @type string CODENAME The release project code name */ 30 const CODENAME = ' Juno';30 const CODENAME = 'Cymru'; 31 31 32 32 /** @type int DB The database schema version */ -
shopp/trunk/core/model/Asset.php
r1020997 r1648469 336 336 337 337 public function scaled ( $width, $height, $fit = 'all' ) { 338 $width = intval($width); 339 $height = intval($height); 338 340 if ( preg_match('/^\d+$/', $fit) ) 339 341 $fit = self::$defaults['scaling'][$fit]; -
shopp/trunk/core/model/Cart.php
r1473303 r1648469 507 507 $this->rmvitem($item); 508 508 // add new product/variant 509 $this->additem($quantity, new ShoppProduct($product), $pricing, $category, $data, $addons); 509 $product = new ShoppProduct($product); 510 $this->additem($quantity, $product, $pricing, $category, $data, $addons); 510 511 511 512 return true; … … 633 634 $Totals->register( new OrderAmountShipping( array('id' => 'cart', 'amount' => $Shipping->calculate() ) ) ); 634 635 635 if ( apply_filters( 'shopp_tax_shipping', shopp_setting_enabled('tax_shipping') ) ) 636 if ( apply_filters( 'shopp_tax_shipping', shopp_setting_enabled('tax_shipping') ) ) { 636 637 $Totals->register( new OrderAmountShippingTax( $Totals->total('shipping') ) ); 638 } else { 639 $Totals->takeoff( OrderAmountShippingTax::$register, 'shipping' ); // if not applicable, make sure we scrub 640 } 637 641 638 642 // Calculate discounts -
shopp/trunk/core/model/Collection.php
r1473303 r1648469 115 115 116 116 // Sort Order 117 if ( ! $orderby ) { 118 119 $titlesort = "p.post_title ASC"; 120 $defaultsort = empty($order) ? $titlesort : $order; 121 122 // Define filterable built-in sort methods (you're welcome) 123 $sortmethods = apply_filters('shopp_collection_sort_methods', array( 124 'bestselling' => "s.sold DESC,$titlesort", 125 'highprice' => "maxprice DESC,$titlesort", 126 'lowprice' => "minprice ASC,$titlesort", 127 'newest' => "p.post_date DESC,$titlesort", 128 'oldest' => "p.post_date ASC,$titlesort", 129 'random' => "RAND(".crc32($Shopping->session).")", 130 'chaos' => "RAND(".time().")", 131 'reverse' => "p.post_title DESC", 132 'title' => $titlesort, 133 'custom' => is_subclass_of($this,'ProductTaxonomy') ? "tr.term_order ASC,$titlesort" : $defaultsort, 134 'recommended' => is_subclass_of($this,'ProductTaxonomy') ? "tr.term_order ASC,$titlesort" : $defaultsort, 135 'default' => $defaultsort 136 )); 137 138 // Handle valid user browsing sort change requests 139 if ( isset($_REQUEST['sort']) && !empty($_REQUEST['sort']) && array_key_exists(strtolower($_REQUEST['sort']), $sortmethods) ) 140 $Storefront->browsing['sortorder'] = strtolower($_REQUEST['sort']); 141 142 // Collect sort setting sources (Shopp admin setting, User browsing setting, programmer specified setting) 143 $sortsettings = array( 144 shopp_setting('default_product_order'), 145 isset($Storefront->browsing['sortorder']) ? $Storefront->browsing['sortorder'] : false, 146 !empty($order) ? $order : false 147 ); 148 149 // Go through setting sources to determine most applicable setting 150 $sorting = 'title'; 151 foreach ($sortsettings as $setting) 152 if ( ! empty($setting) && isset($sortmethods[ strtolower($setting) ]) ) 153 $sorting = strtolower($setting); 154 117 $titlesort = "p.post_title ASC"; 118 $defaultsort = empty($order) ? $titlesort : $order; 119 120 // Define filterable built-in sort methods (you're welcome) 121 $sortmethods = apply_filters('shopp_collection_sort_methods', array( 122 'bestselling' => "s.sold DESC,$titlesort", 123 'highprice' => "maxprice DESC,$titlesort", 124 'lowprice' => "minprice ASC,$titlesort", 125 'newest' => "p.post_date DESC,$titlesort", 126 'oldest' => "p.post_date ASC,$titlesort", 127 'random' => "RAND(".crc32($Shopping->session).")", 128 'chaos' => "RAND(".time().")", 129 'reverse' => "p.post_title DESC", 130 'title' => $titlesort, 131 'custom' => is_subclass_of($this,'ProductTaxonomy') ? "tr.term_order ASC,$titlesort" : $defaultsort, 132 'recommended' => is_subclass_of($this,'ProductTaxonomy') ? "tr.term_order ASC,$titlesort" : $defaultsort, 133 'default' => $defaultsort 134 )); 135 136 // Handle valid user browsing sort change requests 137 if ( isset($_REQUEST['sort']) && !empty($_REQUEST['sort']) && array_key_exists(strtolower($_REQUEST['sort']), $sortmethods) ) 138 $Storefront->browsing['sortorder'] = strtolower($_REQUEST['sort']); 139 140 // Collect sort setting sources (Shopp admin setting, User browsing setting, programmer specified setting) 141 $sortsettings = array( 142 shopp_setting('default_product_order'), 143 isset($Storefront->browsing['sortorder']) ? $Storefront->browsing['sortorder'] : false, 144 !empty($order) ? $order : false 145 ); 146 147 // Go through setting sources to determine most applicable setting 148 $sorting = 'title'; 149 foreach ($sortsettings as $setting) 150 if ( ! empty($setting) && isset($sortmethods[ strtolower($setting) ]) ) 151 $sorting = strtolower($setting); 152 153 if ( ! $orderby ) 155 154 $orderby = $sortmethods[ $sorting ]; 156 } 157 158 if ( empty($orderby) ) $orderby = 'p.post_title ASC'; 155 else 156 $orderby = $orderby . ',' . $sortmethods[ $sorting ]; 159 157 160 158 // Pagination … … 278 276 279 277 // Handle catalog landing page category pagination 280 if ( is_ catalog_frontpage() ) $prettyurl = ($page > 1 || $alpha ? "page/$page" : "");278 if ( is_shopp_catalog_frontpage() ) $prettyurl = ($page > 1 || $alpha ? "page/$page" : ""); 281 279 282 280 $queryvars = array($this->taxonomy => $this->uri); -
shopp/trunk/core/model/Customer.php
r1473303 r1648469 249 249 $_ = apply_filters('shopp_merchant_new_customer_notification', $_); 250 250 251 if ( ! Shopp::email(join( '\n', $_)) )251 if ( ! Shopp::email(join("\n", $_)) ) 252 252 shopp_add_error('The new account notification e-mail could not be sent.', SHOPP_ADMIN_ERR); 253 253 else shopp_debug('A new account notification e-mail was sent to the merchant.'); … … 744 744 // Implement for exporting a single value 745 745 public function export ( $value ) { 746 echo ($this->recordstart ? '' : '\t') . $this->escape($value);746 echo ($this->recordstart ? '' : "\t") . $this->escape($value); 747 747 $this->recordstart = false; 748 748 } 749 749 750 750 public function record () { 751 echo '\n';751 echo "\n"; 752 752 $this->recordstart = true; 753 753 } … … 767 767 768 768 public function escape ($value) { 769 $value = str_replace(array( '\n', '\r'), ' ', $value); // No newlines770 771 if ( false !== strpos($value, '\t') && false === strpos($value,'"') ) // Quote tabs769 $value = str_replace(array("\n", "\r"), ' ', $value); // No newlines 770 771 if ( false !== strpos($value, "\t") && false === strpos($value,'"') ) // Quote tabs 772 772 $value = '"' . $value . '"'; 773 773 -
shopp/trunk/core/model/Discounts.php
r1473303 r1648469 737 737 $value = $this->value; 738 738 739 // To make evaluate work correctly when 740 // $subject includes htmlencoded characters like & 741 if ( is_array($subject) ) { 742 foreach ( $subject as $key => $sub ) 743 $subject[ $key ] = htmlspecialchars_decode($sub); 744 } elseif ( is_string($subject) ) { 745 $subject = htmlspecialchars_decode($subject); 746 } 747 739 748 switch( $op ) { 740 749 // String or Numeric operations -
shopp/trunk/core/model/Events.php
r1473303 r1648469 127 127 128 128 if ( empty($this->id) ) { 129 shopp_debug(sprintf('An error occur ed while saving a new %s', get_class($this)));129 shopp_debug(sprintf('An error occurred while saving a new %s', get_class($this))); 130 130 return $this->_exception = true; 131 131 } -
shopp/trunk/core/model/Item.php
r1473303 r1648469 393 393 * @return string 394 394 **/ 395 public function options ( $selection = '') {395 public function options ( $selection = '' ) { 396 396 if ( empty($this->variants) ) return ''; 397 397 398 398 $string = ''; 399 $priceline = $this->priceline; 400 if ( isset($this->taxprice) ) 401 $adjustment = $this->taxprice/$this->unitprice; 402 else 403 $adjustment = $this->taxrate; 404 399 405 foreach( $this->variants as $option ) { 400 406 if ( $option->type == 'N/A' ) continue; 401 $currently = (Shopp::str_true($option->sale)?$option->promoprice:$option->price)+$this->addonsum; 402 $difference = (float)($currently+$this->unittax)-($this->unitprice+$this->unittax); 407 408 if ( $priceline != $option->id ) { 409 $currently = ( ( Shopp::str_true($option->sale) ) ? $option->promoprice : $option->price ) + $this->addonsum; 410 if ( $adjustment < 0 ) 411 $adjustment = 1 + $adjustment; 412 413 if ( 0 == $adjustment ) 414 $difference = (float)($currently-$this->unitprice); 415 else 416 $difference = (float)(($currently / $adjustment) - $this->unitprice); 417 418 if ( isset($taxoption) && ( $inclusivetax ^ $taxoption ) ) 419 $difference = $difference + ( $difference * $this->taxrate ); 420 } else { 421 $difference = 0; 422 } 403 423 404 424 $price = ''; … … 409 429 if ( $selection == $option->id ) $selected = ' selected="selected"'; 410 430 $disabled = ''; 411 if ( Shopp::str_true($option->inventory) && $option->stock < $this->quantity )431 if ( Shopp::str_true($option->inventory) && $option->stock < $this->quantity && ! shopp_setting_enabled('backorders') ) 412 432 $disabled = ' disabled="disabled"'; 413 433 414 $string .= '<option value="' . $option->id . '"' . $selected .$disabled . '>' . $option->label . $price . '</option>';434 $string .= '<option value="' . $option->id . '"' . $selected . $disabled . '>' . $option->label . $price . '</option>'; 415 435 } 416 436 return $string; … … 935 955 936 956 $Tax->rates($this->taxes, $Tax->item($this)); 937 938 $this->unittax = ShoppTax::calculate($this->taxes, $taxable); 957 $this->unittax = ShoppTax::calculate($this->taxes, $taxable, $this); 939 958 $this->tax = $Tax->total($this->taxes, (int) $taxableqty); 940 959 941 960 // Handle inclusive tax price adjustments for non-EU markets or alternate tax rate markets 942 $adjustment = ShoppTax::adjustment($this->taxes); 943 if ( 1 != $adjustment ) { 944 961 $inclusivetax = Shopp::str_true(shopp_setting_enabled('tax_inclusive')); 962 $adjustment = ShoppTax::adjustment($this->taxes, $this); 963 extract($adjustment); 964 965 if ( $baserate != $appliedrate ) { 945 966 if ( ! isset($this->taxprice) ) 946 967 $this->taxprice = $this->unitprice; 947 948 // Modify the unitprice from the original tax inclusive price and update the discounted price 949 $this->unitprice = ( $this->taxprice / $adjustment ); 950 $this->priced = ( $this->unitprice - $this->discount ); 951 968 969 if ( $inclusivetax ) { 970 // Modify the unitprice from the original tax inclusive price and update the discounted price 971 $this->unitprice = ( $this->taxprice / ( 1 + $baserate ) ) * ( 1 + $appliedrate ); 972 $this->priced = ( $this->unitprice - $this->discount ); 973 } 952 974 } elseif ( isset($this->taxprice) ) { // Undo tax price adjustments 953 975 $this->unitprice = $this->taxprice; -
shopp/trunk/core/model/Product.php
r1473303 r1648469 115 115 public function savepost () { 116 116 if ( empty($this->id) ) return; 117 do_action('save_post', $this->id, get_post($this->id) );117 do_action('save_post', $this->id, get_post($this->id), $update = true); 118 118 if ( function_exists('clean_post_cache') ) 119 119 clean_post_cache($this->id); … … 322 322 $purchase = ShoppDatabaseObject::tablename(ShoppPurchase::$table); 323 323 $purchased = ShoppDatabaseObject::tablename(Purchased::$table); 324 $query = "SELECT p.product as id, sum(p.quantity) AS sold,sum(p.total) AS grossed FROM $purchased as p INNER JOIN $purchase AS o ON p.purchase=o.id WHERE p.product IN ($ids) AND o.txnstatus IN ('authorized','captured') GROUP BY p.product";324 $query = "SELECT p.product as id, sum(p.quantity) AS sold,sum(p.total) AS grossed FROM $purchased as p INNER JOIN $purchase AS o ON p.purchase=o.id WHERE p.product IN ($ids) AND o.txnstatus IN ('authed','captured') GROUP BY p.product"; 325 325 sDB::query($query, 'array', array($this, 'sold')); 326 326 } … … 589 589 // Build secondary lookup table using the price id as the key 590 590 $target->priceid[ $price->id ] = $price; 591 if( isset($this->products) && !empty($this->products) ) 592 $this->priceid[$price->id] = $price; 591 593 592 594 // Set promoprice before data aggregation … … 1289 1291 break; 1290 1292 default: 1291 do_action('save_post', $id, $Post );1293 do_action('save_post', $id, $Post, $update = true); 1292 1294 break; 1293 1295 } -
shopp/trunk/core/model/Purchase.php
r1548347 r1648469 630 630 * @return void 631 631 **/ 632 public function copydata ( $Object, $prefix = '', array $ignores = array() ) { 633 634 $ignores = array_merge(array('_datatypes', '_table', '_key', '_lists', 'id', 'created', 'modified'), $ignores); 632 public function copydata ( $Object, $prefix = '', $ignores = false ) { 633 if ( ! is_array($ignores) || $ignores === false ) 634 $ignores = array('_datatypes', '_table', '_key', '_lists', 'id', 'created', 'modified'); 635 else 636 $ignores = array_merge(array('_datatypes', '_table', '_key', '_lists', 'id', 'created', 'modified'), $ignores); 635 637 636 638 foreach( get_object_vars($Object) as $property => $value ) { … … 669 671 $prefix.'shippostcode' => Shopp::__('Shipping Postal Code'), 670 672 $prefix.'shipmethod' => Shopp::__('Shipping Method'), 673 $prefix.'shipoption' => Shopp::__('Shipping Option'), 671 674 'discounts.value' => Shopp::__('Discounts Applied'), 672 675 $prefix.'subtotal' => Shopp::__('Order Subtotal'), … … 679 682 $prefix.'txnstatus' => Shopp::__('Transaction Status'), 680 683 $prefix.'gateway' => Shopp::__('Payment Gateway'), 684 $prefix.'paymethod' => Shopp::__('Payment Method'), 681 685 $prefix.'status' => Shopp::__('Order Status'), 682 686 $prefix.'data' => Shopp::__('Order Data'), … … 973 977 public function escape ($value) { 974 978 $value = str_replace(array("\n", "\r"), ' ', $value); // No newlines 975 if ( false !== strpos($value, "\t") && false === strpos($value, '"') ) // Quote tabs979 if ( false !== strpos($value, "\t") && false === strpos($value, '"') ) // Quote tabs 976 980 $value = '"' . $value . '"'; 977 981 return $value; … … 990 994 991 995 public function export ($value) { 992 echo ( $this->recordstart?"":",").$value;996 echo ( $this->recordstart ? "" : "," ) . $value; 993 997 $this->recordstart = false; 994 998 } 995 999 996 1000 public function escape ($value) { 997 $value = str_replace('"', '""',$value);1001 $value = str_replace('"', '""', $value); 998 1002 if ( preg_match('/^\s|[,"\n\r]|\s$/',$value) ) 999 1003 $value = '"'.$value.'"'; -
shopp/trunk/core/model/Purchased.php
r1548347 r1648469 26 26 27 27 public function copydata ( $Item, $prefix = '', $ignores = false ) { 28 parent::copydata($Item, $ ignores);28 parent::copydata($Item, $prefix, $ignores); 29 29 if ( isset($Item->option->label) ) 30 30 $this->optionlabel = $Item->option->label; -
shopp/trunk/core/model/Shopping.php
r1020997 r1648469 258 258 259 259 } 260 261 /** 262 * Override to ensure we don't create sessions for special types of browser requests. 263 * 264 * @since 1.3.13 265 * 266 * @return bool True if the session should be created/updated, false otherwise 267 */ 268 public function cookable () { 269 $cookable = parent::cookable(); 270 271 // Don't update the session for prefetch requests (via <link rel="next" /> or <link rel="prefetch" /> tags) 272 if ( isset($_SERVER['HTTP_X_MOZ']) && 'prefetch' == $_SERVER['HTTP_X_MOZ'] // Firefox 273 || isset($_SERVER['HTTP_X_PURPOSE']) // Chrome/Safari 274 && in_array($_SERVER['HTTP_X_PURPOSE'], array('preview', 'instant')) ) 275 return false; 276 277 return $cookable; 278 } 260 279 261 280 /** -
shopp/trunk/core/model/Tax.php
r1053635 r1648469 38 38 private $Customer = false; // The current ShoppCustomer to calculate taxes for 39 39 40 40 41 /** 41 42 * Converts a provided item to a ShoppTaxableItem … … 62 63 if ( ! shopp_setting_enabled('taxes') ) return false; 63 64 64 $taxrates = shopp_setting('taxrates'); 65 65 $eu = false; // Track EU tax key 66 $override = array(); // Track taxrate overrides 67 $taxrates = shopp_setting('taxrates'); 66 68 $fallbacks = array(); 67 $settings = array();69 $settings = array(); 68 70 foreach ( (array) $taxrates as $setting ) { 69 71 70 72 $defaults = array( 71 'rate' => 0,72 'country' => '',73 'zone' => '',73 'rate' => 0, 74 'country' => '', 75 'zone' => '', 74 76 'haslocals' => false, 75 'logic' => 'any',76 'rules' => array(),77 'logic' => 'any', 78 'rules' => array(), 77 79 'localrate' => 0, 78 'compound' => false,79 'label' => Shopp::__('Tax')80 'compound' => false, 81 'label' => Shopp::__('Tax') 80 82 81 83 ); … … 100 102 101 103 $settings[ $key ] = $setting; 104 105 if ( self::EUVAT == $country ) $eu = $key; 106 if ( in_array($country, Lookup::country_euvat()) ) $override[ $key ] = $country; 102 107 } 103 108 104 109 if ( empty($settings) && ! empty($fallbacks) ) 105 110 $settings = $fallbacks; 111 112 if ( false !== $eu && ! empty($override) ) unset($settings[ $eu ]) ; 106 113 107 114 $settings = apply_filters('shopp_cart_taxrate_settings', $settings); // @deprecated Use shopp_tax_rate_settings instead … … 298 305 } 299 306 300 public static function adjustment ( $rates ) { 301 302 if ( ! shopp_setting_enabled('tax_inclusive') ) return 1; 303 304 $baserates = ShoppTax::baserates(); 307 public static function adjustment ( $rates, $Item = null ) { 308 $adjustment = array(); 309 $adjustment['baserate'] = $adjustment['appliedrate'] = 1; 310 311 // remove unused rates (EU) 312 if ( count($rates) > 1 ) { 313 $taxrates = array(); 314 foreach ( $rates as $label => $rate ) 315 if ( ! is_null($rate->amount) ) $taxrates[ $label ] = $rate; 316 317 $rates = $taxrates; 318 } 319 320 $baserates = ShoppTax::baserates($Item); 305 321 $baserate = reset($baserates); 306 322 $appliedrate = reset($rates); 307 323 308 $baserate = isset($baserate->rate) ? $baserate->rate : 0; 309 $appliedrate = isset($appliedrate->rate) ? $appliedrate->rate : 0; 310 311 return 1 + ($baserate - $appliedrate); 312 324 $adjustment['baserate'] = isset($baserate->rate) ? $baserate->rate : 0; 325 $adjustment['appliedrate'] = isset($appliedrate->rate) ? $appliedrate->rate : 0; 326 327 return $adjustment; 313 328 } 314 329 … … 337 352 * @param array $rates A list of ShoppItemTax objects 338 353 * @param float $taxable The amount to calculate taxes on 354 * @param Object $Item A taxable item object 339 355 * @return float The total tax amount 340 356 **/ 341 public static function calculate ( array &$rates, $taxable ) {357 public static function calculate ( array &$rates, $taxable, $Item = null ) { 342 358 343 359 $compound = 0; 344 360 $total = 0; 345 361 $inclusive = shopp_setting_enabled('tax_inclusive'); 362 346 363 foreach ( $rates as $label => $taxrate ) { 347 364 … … 351 368 352 369 // Calculate tax amount 353 if ( $inclusive ) $tax = $taxable - ( $taxable / (1 + $taxrate->rate) ); 370 if ( $inclusive ) { 371 $baserates = ShoppTax::baserates($Item); 372 $baserate = reset($baserates); 373 $baserate = isset($baserate->rate) ? $baserate->rate : 0; 374 $tax = ( $taxable / (1 + $baserate) ) * $taxrate->rate; 375 } 354 376 else $tax = $taxable * $taxrate->rate; 355 377 -
shopp/trunk/core/ui/behaviors/cart.js
r1473303 r1648469 117 117 }); 118 118 119 $('#cart input[name*="[quantity]"]').change(function() { 120 $('#cart input.update-button[type="submit"]').click(); 121 }); 122 123 $('#cart select[name*="[price]"]').change(function() { 124 $('#cart input.update-button[type="submit"]').click(); 125 }); 126 119 127 $('#cart input[type=image]').click(function () { $(this.form).submit(); }); 120 128 -
shopp/trunk/core/ui/behaviors/cart.min.js
r1473303 r1648469 1 function addtocart(t){var a=jQuery,e=a(t).find("select.options"),i=!0;return e&&(e.each(function(t,e){if(""==a(e).val())return i=!1}),!i)?($s.opreq||($s.opreq="You must select the options for this item before you can add it to your shopping cart."),alert($s.opreq),!1):(a(t).find("input.addtocart").hasClass("ajax-html")?ShoppCartAjaxRequest(t,"html"):a(t).find("input.addtocart").hasClass("ajax")?ShoppCartAjaxRequest(t):t.submit(),!1)}function ShoppCartAjaxRequest(t,a){a||(a="json");var e=jQuery,i=t.action, o=e(t),r=o.serialize(),n="json"==a?"json":"html";o.trigger("shopp_cart_ajax_request",r),e.ajax({type:"POST",url:i,data:r+"&response="+a,timeout:1e4,dataType:n,success:function(t){o.trigger("shopp_cart_ajax_success",t,a),ShoppCartAjaxHandler(t,a),o.trigger("shopp_cart_ajax_successful",t,a)},error:function(){}})}function ShoppCartAjaxHandler(t,a){var e=jQuery,i="",o=!1,r=!1,n=e(".widget_shoppcartwidget div.widget-all"),s=e("#shopp-cart-ajax"),p=n.length>0?n:s,u=p.find("ul"),d=p.find("p.status"),c=p.find("div.added").empty().hide(),l=e('<div class="added"></div>');return"html"==a?(e(s).trigger("shopp_cart_ajax_html",p,t),p.html(t)):(t.Item&&(o=t.Item),t.Totals&&(r=t.Totals),1==c.length?l=c:l.prependTo(p).hide(),o.option&&o.option.label&&""!=o.option.label&&(i=" ("+o.option.label+")"),o.image&&e('<p><img src="'+t.imguri+'" alt="" width="96" height="96" /></p>').appendTo(l),e("<p />").html("<strong>"+o.name+"</strong>"+i).appendTo(l),e("<p />").html(asMoney(new Number(o.unitprice))).appendTo(l),d.html('<a href="'+t.url+'"><span id="shopp-sidecart-items">'+r.quantity+"</span> <strong>"+$ct.items+"</strong> — <strong>"+$ct.total+'</strong> <span id="shopp-sidecart-total">'+asMoney(new Number(r.total))+"</span></a>"),1!=u.size()&&(u=e("<ul />").appendTo(p)),u.html('<li><a href="'+t.url+'">'+t.label+'</a></li><li><a href="'+t.checkouturl+'">'+t.checkoutLabel+"</a></li>"),e(s).trigger("shopp_cart_ajax_item",l,t),void l.slideDown())}jQuery(document).ready(function(t){t("#cart #shipping-country").change(function(){this.form.submit()}),t("#cart input[type=image]").click(function(){t(this.form).submit()}),t("input.addtocart").each(function(){var a=t(this),e=a.closest("form");return!!e&&(e.unbind("submit.validate").bind("submit.addtocart",function(t){return t.preventDefault(),!(e.hasClass("validate")&&!validate(this))&&void addtocart(this)}),void("button"==a.attr("type")&&a.click(function(){e.submit()})))})});1 function addtocart(t){var a=jQuery,e=a(t).find("select.options"),i=!0;return e&&(e.each(function(t,e){if(""==a(e).val())return i=!1}),!i)?($s.opreq||($s.opreq="You must select the options for this item before you can add it to your shopping cart."),alert($s.opreq),!1):(a(t).find("input.addtocart").hasClass("ajax-html")?ShoppCartAjaxRequest(t,"html"):a(t).find("input.addtocart").hasClass("ajax")?ShoppCartAjaxRequest(t):t.submit(),!1)}function ShoppCartAjaxRequest(t,a){a||(a="json");var e=jQuery,i=t.action,n=e(t),o=n.serialize(),r="json"==a?"json":"html";n.trigger("shopp_cart_ajax_request",o),e.ajax({type:"POST",url:i,data:o+"&response="+a,timeout:1e4,dataType:r,success:function(t){n.trigger("shopp_cart_ajax_success",t,a),ShoppCartAjaxHandler(t,a),n.trigger("shopp_cart_ajax_successful",t,a)},error:function(){}})}function ShoppCartAjaxHandler(t,a){var e=jQuery,i="",n=!1,o=!1,r=e(".widget_shoppcartwidget div.widget-all"),s=e("#shopp-cart-ajax"),p=r.length>0?r:s,u=p.find("ul"),c=p.find("p.status"),d=p.find("div.added").empty().hide(),l=e('<div class="added"></div>');return"html"==a?(e(s).trigger("shopp_cart_ajax_html",p,t),p.html(t)):(t.Item&&(n=t.Item),t.Totals&&(o=t.Totals),1==d.length?l=d:l.prependTo(p).hide(),n.option&&n.option.label&&""!=n.option.label&&(i=" ("+n.option.label+")"),n.image&&e('<p><img src="'+t.imguri+'" alt="" width="96" height="96" /></p>').appendTo(l),e("<p />").html("<strong>"+n.name+"</strong>"+i).appendTo(l),e("<p />").html(asMoney(new Number(n.unitprice))).appendTo(l),c.html('<a href="'+t.url+'"><span id="shopp-sidecart-items">'+o.quantity+"</span> <strong>"+$ct.items+"</strong> — <strong>"+$ct.total+'</strong> <span id="shopp-sidecart-total">'+asMoney(new Number(o.total))+"</span></a>"),1!=u.size()&&(u=e("<ul />").appendTo(p)),u.html('<li><a href="'+t.url+'">'+t.label+'</a></li><li><a href="'+t.checkouturl+'">'+t.checkoutLabel+"</a></li>"),e(s).trigger("shopp_cart_ajax_item",l,t),void l.slideDown())}jQuery(document).ready(function(t){t("#cart #shipping-country").change(function(){this.form.submit()}),t('#cart input[name*="[quantity]"]').change(function(){t('#cart input.update-button[type="submit"]').click()}),t('#cart select[name*="[price]"]').change(function(){t('#cart input.update-button[type="submit"]').click()}),t("#cart input[type=image]").click(function(){t(this.form).submit()}),t("input.addtocart").each(function(){var a=t(this),e=a.closest("form");return!!e&&(e.unbind("submit.validate").bind("submit.addtocart",function(t){return t.preventDefault(),!(e.hasClass("validate")&&!validate(this))&&void addtocart(this)}),void("button"==a.attr("type")&&a.click(function(){e.submit()})))})}); -
shopp/trunk/core/ui/behaviors/colorbox.min.js
r1473303 r1648469 1 !function(e,t,i){function o(i,o,n){var r=t.createElement(i);return o&&(r.id=ee+o),n&&(r.style.cssText=n),e(r)}function n(){return i.innerHeight?i.innerHeight:e(i).height()}function r(e){var t=E.length,i=(j+e)%t;return i<0?t+i:i}function l(e,t){return Math.round((/%/.test(e)?("x"===t?H.width():n())/100:1)*parseInt(e,10))}function a(e,t){return e.photo||e.photoRegex.test(t)}function h(e,t){return e.retinaUrl&&i.devicePixelRatio>1?t.replace(e.photoRegex,e.retinaSuffix):t}function s(e){"contains"in v[0]&&!v[0].contains(e.target)&&(e.stopPropagation(),v.focus())}function d(){var t,i=e.data(A,Z);null==i?(B=e.extend({},Y),console&&console.log&&console.log("Error: cboxElement missing settings object")):B=e.extend({},i);for(t in B)e.isFunction(B[t])&&"on"!==t.slice(0,2)&&(B[t]=B[t].call(A));B.rel=B.rel||A.rel||e(A).data("rel")||"nofollow",B.href=B.href||e(A).attr("href"),B.title=B.title||A.title,"string"==typeof B.href&&(B.href=e.trim(B.href))}function c(i,o){e(t).trigger(i),he.trigger(i),e.isFunction(o)&&o.call(A)}function u(){var e,t,i,o,n,r=ee+"Slideshow_",l="click."+ee;B.slideshow&&E[1]?(t=function(){clearTimeout(e)},i=function(){(B.loop||E[j+1])&&(e=setTimeout(J.next,B.slideshowSpeed))},o=function(){R.html(B.slideshowStop).unbind(l).one(l,n),he.bind(ne,i).bind(oe,t).bind(re,n),v.removeClass(r+"off").addClass(r+"on")},n=function(){t(),he.unbind(ne,i).unbind(oe,t).unbind(re,n),R.html(B.slideshowStart).unbind(l).one(l,function(){J.next(),o()}),v.removeClass(r+"on").addClass(r+"off")},B.slideshowAuto?o():n()):v.removeClass(r+"off "+r+"on")}function f(i){G||(A=i,d(),E=e(A),j=0,"nofollow"!==B.rel&&(E=e("."+te).filter(function(){var t,i=e.data(this,Z);return i&&(t=e(this).data("rel")||i.rel||this.rel),t===B.rel}),j=E.index(A),j===-1&&(E=E.add(A),j=E.length-1)),g.css({opacity:parseFloat(B.opacity),cursor:B.overlayClose?"pointer":"auto",visibility:"visible"}).show(),V&&v.add(g).removeClass(V),B.className&&v.add(g).addClass(B.className),V=B.className,B.closeButton?O.html(B.close).appendTo(x):O.appendTo("<div/>"),$||($=q=!0,v.css({visibility:"hidden",display:"block"}),W=o(se,"LoadedContent","width:0; height:0; overflow:hidden"),x.css({width:"",height:""}).append(W),_=b.height()+k.height()+x.outerHeight(!0)-x.height(),D=T.width()+C.width()+x.outerWidth(!0)-x.width(),N=W.outerHeight(!0),z=W.outerWidth(!0),B.w=l(B.initialWidth,"x"),B.h=l(B.initialHeight,"y"),J.position(),u(),c(ie,B.onOpen),P.add(S).hide(),v.focus(),B.trapFocus&&t.addEventListener&&(t.addEventListener("focus",s,!0),he.one(le,function(){t.removeEventListener("focus",s,!0)})),B.returnFocus&&he.one(le,function(){e(A).focus()})),w())}function p(){!v&&t.body&&(X=!1,H=e(i),v=o(se).attr({id:Z, "class":e.support.opacity===!1?ee+"IE":"",role:"dialog",tabindex:"-1"}).hide(),g=o(se,"Overlay").hide(),L=e([o(se,"LoadingOverlay")[0],o(se,"LoadingGraphic")[0]]),y=o(se,"Wrapper"),x=o(se,"Content").append(S=o(se,"Title"),M=o(se,"Current"),K=e('<button type="button"/>').attr({id:ee+"Previous"}),I=e('<button type="button"/>').attr({id:ee+"Next"}),R=o("button","Slideshow"),L),O=e('<button type="button"/>').attr({id:ee+"Close"}),y.append(o(se).append(o(se,"TopLeft"),b=o(se,"TopCenter"),o(se,"TopRight")),o(se,!1,"clear:left").append(T=o(se,"MiddleLeft"),x,C=o(se,"MiddleRight")),o(se,!1,"clear:left").append(o(se,"BottomLeft"),k=o(se,"BottomCenter"),o(se,"BottomRight"))).find("div div").css({"float":"left"}),F=o(se,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),P=I.add(K).add(M).add(R),e(t.body).append(g,v.append(y,F)))}function m(){function i(e){e.which>1||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),f(this))}return!!v&&(X||(X=!0,I.click(function(){J.next()}),K.click(function(){J.prev()}),O.click(function(){J.close()}),g.click(function(){B.overlayClose&&J.close()}),e(t).bind("keydown."+ee,function(e){var t=e.keyCode;$&&B.escKey&&27===t&&(e.preventDefault(),J.close()),$&&B.arrowKey&&E[1]&&!e.altKey&&(37===t?(e.preventDefault(),K.click()):39===t&&(e.preventDefault(),I.click()))}),e.isFunction(e.fn.on)?e(t).on("click."+ee,"."+te,i):e("."+te).live("click."+ee,i)),!0)}function w(){var n,r,s,u=J.prep,f=++de;q=!0,U=!1,A=E[j],d(),c(ae),c(oe,B.onLoad),B.h=B.height?l(B.height,"y")-N-_:B.innerHeight&&l(B.innerHeight,"y"),B.w=B.width?l(B.width,"x")-z-D:B.innerWidth&&l(B.innerWidth,"x"),B.mw=B.w,B.mh=B.h,B.maxWidth&&(B.mw=l(B.maxWidth,"x")-z-D,B.mw=B.w&&B.w<B.mw?B.w:B.mw),B.maxHeight&&(B.mh=l(B.maxHeight,"y")-N-_,B.mh=B.h&&B.h<B.mh?B.h:B.mh),n=B.href,Q=setTimeout(function(){L.show()},100),B.inline?(s=o(se).hide().insertBefore(e(n)[0]),he.one(ae,function(){s.replaceWith(W.children())}),u(e(n))):B.iframe?u(" "):B.html?u(B.html):a(B,n)?(n=h(B,n),U=t.createElement("img"),e(U).addClass(ee+"Photo").bind("error",function(){B.title=!1,u(o(se,"Error").html(B.imgError))}).one("load",function(){var t;f===de&&(U.alt=e(A).attr("alt")||e(A).attr("data-alt")||"",B.retinaImage&&i.devicePixelRatio>1&&(U.height=U.height/i.devicePixelRatio,U.width=U.width/i.devicePixelRatio),B.scalePhotos&&(r=function(){U.height-=U.height*t,U.width-=U.width*t},B.mw&&U.width>B.mw&&(t=(U.width-B.mw)/U.width,r()),B.mh&&U.height>B.mh&&(t=(U.height-B.mh)/U.height,r())),B.h&&(U.style.marginTop=Math.max(B.mh-U.height,0)/2+"px"),E[1]&&(B.loop||E[j+1])&&(U.style.cursor="pointer",U.onclick=function(){J.next()}),U.style.width=U.width+"px",U.style.height=U.height+"px",setTimeout(function(){u(U)},1))}),setTimeout(function(){U.src=n},1)):n&&F.load(n,B.data,function(t,i){f===de&&u("error"===i?o(se,"Error").html(B.xhrError):e(this).contents())})}var g,v,y,x,b,T,C,k,E,H,W,F,L,S,M,R,I,K,O,P,B,_,D,N,z,A,j,U,$,q,G,Q,J,V,X,Y={transition:"elastic",speed:300,fadeOut:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.7,preloading:!0,className:!1,retinaImage:!1,retinaUrl:!1,retinaSuffix:"@2x.$1",current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",open:!1,returnFocus:!0,trapFocus:!0,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:void 0,closeButton:!0},Z="colorbox",ee="cbox",te=ee+"Element",ie=ee+"_open",oe=ee+"_load",ne=ee+"_complete",re=ee+"_cleanup",le=ee+"_closed",ae=ee+"_purge",he=e("<a/>"),se="div",de=0,ce={};e.colorbox||(e(p),J=e.fn[Z]=e[Z]=function(t,i){var o=this;if(t=t||{},p(),m()){if(e.isFunction(o))o=e("<a/>"),t.open=!0;else if(!o[0])return o;i&&(t.onComplete=i),o.each(function(){e.data(this,Z,e.extend({},e.data(this,Z)||Y,t))}).addClass(te),(e.isFunction(t.open)&&t.open.call(o)||t.open)&&f(o[0])}return o},J.position=function(t,i){function o(){b[0].style.width=k[0].style.width=x[0].style.width=parseInt(v[0].style.width,10)-D+"px",x[0].style.height=T[0].style.height=C[0].style.height=parseInt(v[0].style.height,10)-_+"px"}var r,a,h,s=0,d=0,c=v.offset();if(H.unbind("resize."+ee),v.css({top:-9e4,left:-9e4}),a=H.scrollTop(),h=H.scrollLeft(),B.fixed?(c.top-=a,c.left-=h,v.css({position:"fixed"})):(s=a,d=h,v.css({position:"absolute"})),d+=B.right!==!1?Math.max(H.width()-B.w-z-D-l(B.right,"x"),0):B.left!==!1?l(B.left,"x"):Math.round(Math.max(H.width()-B.w-z-D,0)/2),s+=B.bottom!==!1?Math.max(n()-B.h-N-_-l(B.bottom,"y"),0):B.top!==!1?l(B.top,"y"):Math.round(Math.max(n()-B.h-N-_,0)/2),v.css({top:c.top,left:c.left,visibility:"visible"}),y[0].style.width=y[0].style.height="9999px",r={width:B.w+z+D,height:B.h+N+_,top:s,left:d},t){var u=0;e.each(r,function(e){if(r[e]!==ce[e])return void(u=t)}),t=u}ce=r,t||v.css(r),v.dequeue().animate(r,{duration:t||0,complete:function(){o(),q=!1,y[0].style.width=B.w+z+D+"px",y[0].style.height=B.h+N+_+"px",B.reposition&&setTimeout(function(){H.bind("resize."+ee,J.position)},1),i&&i()},step:o})},J.resize=function(e){var t;$&&(e=e||{},e.width&&(B.w=l(e.width,"x")-z-D),e.innerWidth&&(B.w=l(e.innerWidth,"x")),W.css({width:B.w}),e.height&&(B.h=l(e.height,"y")-N-_),e.innerHeight&&(B.h=l(e.innerHeight,"y")),e.innerHeight||e.height||(t=W.scrollTop(),W.css({height:"auto"}),B.h=W.height()),W.css({height:B.h}),t&&W.scrollTop(t),J.position("none"===B.transition?0:B.speed))},J.prep=function(i){function n(){return B.w=B.w||W.width(),B.w=B.mw&&B.mw<B.w?B.mw:B.w,B.w}function l(){return B.h=B.h||W.height(),B.h=B.mh&&B.mh<B.h?B.mh:B.h,B.h}if($){var s,d="none"===B.transition?0:B.speed;W.empty().remove(),W=o(se,"LoadedContent").append(i),W.hide().appendTo(F.show()).css({width:n(),overflow:B.scrolling?"auto":"hidden"}).css({height:l()}).prependTo(x),F.hide(),e(U).css({"float":"none"}),s=function(){function i(){e.support.opacity===!1&&v[0].style.removeAttribute("filter")}var n,l,s=E.length,u="frameBorder",f="allowTransparency";$&&(l=function(){clearTimeout(Q),L.hide(),c(ne,B.onComplete)},S.html(B.title).add(W).show(),s>1?("string"==typeof B.current&&M.html(B.current.replace("{current}",j+1).replace("{total}",s)).show(),I[B.loop||j<s-1?"show":"hide"]().html(B.next),K[B.loop||j?"show":"hide"]().html(B.previous),B.slideshow&&R.show(),B.preloading&&e.each([r(-1),r(1)],function(){var i,o,n=E[this],r=e.data(n,Z);r&&r.href?(i=r.href,e.isFunction(i)&&(i=i.call(n))):i=e(n).attr("href"),i&&a(r,i)&&(i=h(r,i),o=t.createElement("img"),o.src=i)})):P.hide(),B.iframe?(n=o("iframe")[0],u in n&&(n[u]=0),f in n&&(n[f]="true"),B.scrolling||(n.scrolling="no"),e(n).attr({src:B.href,name:(new Date).getTime(),"class":ee+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",l).appendTo(W),he.one(ae,function(){n.src="//about:blank"}),B.fastIframe&&e(n).trigger("load")):l(),"fade"===B.transition?v.fadeTo(d,1,i):i())},"fade"===B.transition?v.fadeTo(d,0,function(){J.position(0,s)}):J.position(d,s)}},J.next=function(){!q&&E[1]&&(B.loop||E[j+1])&&(j=r(1),f(E[j]))},J.prev=function(){!q&&E[1]&&(B.loop||j)&&(j=r(-1),f(E[j]))},J.close=function(){$&&!G&&(G=!0,$=!1,c(re,B.onCleanup),H.unbind("."+ee),g.fadeTo(B.fadeOut||0,0),v.stop().fadeTo(B.fadeOut||0,0,function(){v.add(g).css({opacity:1,cursor:"auto"}).hide(),c(ae),W.empty().remove(),setTimeout(function(){G=!1,c(le,B.onClosed)},1)}))},J.hide=function(){g.fadeTo(B.fadeOut||0,0),v.fadeTo(B.fadeOut||0,0,function(){g.hide(),v.css({opacity:1,cursor:"auto",left:"-9999em"}),c(le,B.onClosed)})},J.remove=function(){v&&(v.stop(),e.colorbox.close(),v.stop().remove(),g.remove(),G=!1,v=null,e("."+te).removeData(Z).removeClass(te),e(t).unbind("click."+ee))},J.element=function(){return e(A)},J.settings=Y)}(jQuery,document,window);1 !function(e,t,i){function o(i,o,n){var r=t.createElement(i);return o&&(r.id=ee+o),n&&(r.style.cssText=n),e(r)}function n(){return i.innerHeight?i.innerHeight:e(i).height()}function r(e){var t=E.length,i=(j+e)%t;return i<0?t+i:i}function l(e,t){return Math.round((/%/.test(e)?("x"===t?H.width():n())/100:1)*parseInt(e,10))}function a(e,t){return e.photo||e.photoRegex.test(t)}function h(e,t){return e.retinaUrl&&i.devicePixelRatio>1?t.replace(e.photoRegex,e.retinaSuffix):t}function s(e){"contains"in v[0]&&!v[0].contains(e.target)&&(e.stopPropagation(),v.focus())}function d(){var t,i=e.data(A,Z);null==i?(B=e.extend({},Y),console&&console.log&&console.log("Error: cboxElement missing settings object")):B=e.extend({},i);for(t in B)e.isFunction(B[t])&&"on"!==t.slice(0,2)&&(B[t]=B[t].call(A));B.rel=B.rel||A.rel||e(A).data("rel")||"nofollow",B.href=B.href||e(A).attr("href"),B.title=B.title||A.title,"string"==typeof B.href&&(B.href=e.trim(B.href))}function c(i,o){e(t).trigger(i),he.trigger(i),e.isFunction(o)&&o.call(A)}function u(){var e,t,i,o,n,r=ee+"Slideshow_",l="click."+ee;B.slideshow&&E[1]?(t=function(){clearTimeout(e)},i=function(){(B.loop||E[j+1])&&(e=setTimeout(J.next,B.slideshowSpeed))},o=function(){R.html(B.slideshowStop).unbind(l).one(l,n),he.bind(ne,i).bind(oe,t).bind(re,n),v.removeClass(r+"off").addClass(r+"on")},n=function(){t(),he.unbind(ne,i).unbind(oe,t).unbind(re,n),R.html(B.slideshowStart).unbind(l).one(l,function(){J.next(),o()}),v.removeClass(r+"on").addClass(r+"off")},B.slideshowAuto?o():n()):v.removeClass(r+"off "+r+"on")}function f(i){G||(A=i,d(),E=e(A),j=0,"nofollow"!==B.rel&&(E=e("."+te).filter(function(){var t,i=e.data(this,Z);return i&&(t=e(this).data("rel")||i.rel||this.rel),t===B.rel}),j=E.index(A),j===-1&&(E=E.add(A),j=E.length-1)),g.css({opacity:parseFloat(B.opacity),cursor:B.overlayClose?"pointer":"auto",visibility:"visible"}).show(),V&&v.add(g).removeClass(V),B.className&&v.add(g).addClass(B.className),V=B.className,B.closeButton?O.html(B.close).appendTo(x):O.appendTo("<div/>"),$||($=q=!0,v.css({visibility:"hidden",display:"block"}),W=o(se,"LoadedContent","width:0; height:0; overflow:hidden"),x.css({width:"",height:""}).append(W),_=b.height()+k.height()+x.outerHeight(!0)-x.height(),D=T.width()+C.width()+x.outerWidth(!0)-x.width(),N=W.outerHeight(!0),z=W.outerWidth(!0),B.w=l(B.initialWidth,"x"),B.h=l(B.initialHeight,"y"),J.position(),u(),c(ie,B.onOpen),P.add(S).hide(),v.focus(),B.trapFocus&&t.addEventListener&&(t.addEventListener("focus",s,!0),he.one(le,function(){t.removeEventListener("focus",s,!0)})),B.returnFocus&&he.one(le,function(){e(A).focus()})),w())}function p(){!v&&t.body&&(X=!1,H=e(i),v=o(se).attr({id:Z,class:e.support.opacity===!1?ee+"IE":"",role:"dialog",tabindex:"-1"}).hide(),g=o(se,"Overlay").hide(),L=e([o(se,"LoadingOverlay")[0],o(se,"LoadingGraphic")[0]]),y=o(se,"Wrapper"),x=o(se,"Content").append(S=o(se,"Title"),M=o(se,"Current"),K=e('<button type="button"/>').attr({id:ee+"Previous"}),I=e('<button type="button"/>').attr({id:ee+"Next"}),R=o("button","Slideshow"),L),O=e('<button type="button"/>').attr({id:ee+"Close"}),y.append(o(se).append(o(se,"TopLeft"),b=o(se,"TopCenter"),o(se,"TopRight")),o(se,!1,"clear:left").append(T=o(se,"MiddleLeft"),x,C=o(se,"MiddleRight")),o(se,!1,"clear:left").append(o(se,"BottomLeft"),k=o(se,"BottomCenter"),o(se,"BottomRight"))).find("div div").css({float:"left"}),F=o(se,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),P=I.add(K).add(M).add(R),e(t.body).append(g,v.append(y,F)))}function m(){function i(e){e.which>1||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),f(this))}return!!v&&(X||(X=!0,I.click(function(){J.next()}),K.click(function(){J.prev()}),O.click(function(){J.close()}),g.click(function(){B.overlayClose&&J.close()}),e(t).bind("keydown."+ee,function(e){var t=e.keyCode;$&&B.escKey&&27===t&&(e.preventDefault(),J.close()),$&&B.arrowKey&&E[1]&&!e.altKey&&(37===t?(e.preventDefault(),K.click()):39===t&&(e.preventDefault(),I.click()))}),e.isFunction(e.fn.on)?e(t).on("click."+ee,"."+te,i):e("."+te).live("click."+ee,i)),!0)}function w(){var n,r,s,u=J.prep,f=++de;q=!0,U=!1,A=E[j],d(),c(ae),c(oe,B.onLoad),B.h=B.height?l(B.height,"y")-N-_:B.innerHeight&&l(B.innerHeight,"y"),B.w=B.width?l(B.width,"x")-z-D:B.innerWidth&&l(B.innerWidth,"x"),B.mw=B.w,B.mh=B.h,B.maxWidth&&(B.mw=l(B.maxWidth,"x")-z-D,B.mw=B.w&&B.w<B.mw?B.w:B.mw),B.maxHeight&&(B.mh=l(B.maxHeight,"y")-N-_,B.mh=B.h&&B.h<B.mh?B.h:B.mh),n=B.href,Q=setTimeout(function(){L.show()},100),B.inline?(s=o(se).hide().insertBefore(e(n)[0]),he.one(ae,function(){s.replaceWith(W.children())}),u(e(n))):B.iframe?u(" "):B.html?u(B.html):a(B,n)?(n=h(B,n),U=t.createElement("img"),e(U).addClass(ee+"Photo").bind("error",function(){B.title=!1,u(o(se,"Error").html(B.imgError))}).one("load",function(){var t;f===de&&(U.alt=e(A).attr("alt")||e(A).attr("data-alt")||"",B.retinaImage&&i.devicePixelRatio>1&&(U.height=U.height/i.devicePixelRatio,U.width=U.width/i.devicePixelRatio),B.scalePhotos&&(r=function(){U.height-=U.height*t,U.width-=U.width*t},B.mw&&U.width>B.mw&&(t=(U.width-B.mw)/U.width,r()),B.mh&&U.height>B.mh&&(t=(U.height-B.mh)/U.height,r())),B.h&&(U.style.marginTop=Math.max(B.mh-U.height,0)/2+"px"),E[1]&&(B.loop||E[j+1])&&(U.style.cursor="pointer",U.onclick=function(){J.next()}),U.style.width=U.width+"px",U.style.height=U.height+"px",setTimeout(function(){u(U)},1))}),setTimeout(function(){U.src=n},1)):n&&F.load(n,B.data,function(t,i){f===de&&u("error"===i?o(se,"Error").html(B.xhrError):e(this).contents())})}var g,v,y,x,b,T,C,k,E,H,W,F,L,S,M,R,I,K,O,P,B,_,D,N,z,A,j,U,$,q,G,Q,J,V,X,Y={transition:"elastic",speed:300,fadeOut:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.7,preloading:!0,className:!1,retinaImage:!1,retinaUrl:!1,retinaSuffix:"@2x.$1",current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",open:!1,returnFocus:!0,trapFocus:!0,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:void 0,closeButton:!0},Z="colorbox",ee="cbox",te=ee+"Element",ie=ee+"_open",oe=ee+"_load",ne=ee+"_complete",re=ee+"_cleanup",le=ee+"_closed",ae=ee+"_purge",he=e("<a/>"),se="div",de=0,ce={};e.colorbox||(e(p),J=e.fn[Z]=e[Z]=function(t,i){var o=this;if(t=t||{},p(),m()){if(e.isFunction(o))o=e("<a/>"),t.open=!0;else if(!o[0])return o;i&&(t.onComplete=i),o.each(function(){e.data(this,Z,e.extend({},e.data(this,Z)||Y,t))}).addClass(te),(e.isFunction(t.open)&&t.open.call(o)||t.open)&&f(o[0])}return o},J.position=function(t,i){function o(){b[0].style.width=k[0].style.width=x[0].style.width=parseInt(v[0].style.width,10)-D+"px",x[0].style.height=T[0].style.height=C[0].style.height=parseInt(v[0].style.height,10)-_+"px"}var r,a,h,s=0,d=0,c=v.offset();if(H.unbind("resize."+ee),v.css({top:-9e4,left:-9e4}),a=H.scrollTop(),h=H.scrollLeft(),B.fixed?(c.top-=a,c.left-=h,v.css({position:"fixed"})):(s=a,d=h,v.css({position:"absolute"})),d+=B.right!==!1?Math.max(H.width()-B.w-z-D-l(B.right,"x"),0):B.left!==!1?l(B.left,"x"):Math.round(Math.max(H.width()-B.w-z-D,0)/2),s+=B.bottom!==!1?Math.max(n()-B.h-N-_-l(B.bottom,"y"),0):B.top!==!1?l(B.top,"y"):Math.round(Math.max(n()-B.h-N-_,0)/2),v.css({top:c.top,left:c.left,visibility:"visible"}),y[0].style.width=y[0].style.height="9999px",r={width:B.w+z+D,height:B.h+N+_,top:s,left:d},t){var u=0;e.each(r,function(e){if(r[e]!==ce[e])return void(u=t)}),t=u}ce=r,t||v.css(r),v.dequeue().animate(r,{duration:t||0,complete:function(){o(),q=!1,y[0].style.width=B.w+z+D+"px",y[0].style.height=B.h+N+_+"px",B.reposition&&setTimeout(function(){H.bind("resize."+ee,J.position)},1),i&&i()},step:o})},J.resize=function(e){var t;$&&(e=e||{},e.width&&(B.w=l(e.width,"x")-z-D),e.innerWidth&&(B.w=l(e.innerWidth,"x")),W.css({width:B.w}),e.height&&(B.h=l(e.height,"y")-N-_),e.innerHeight&&(B.h=l(e.innerHeight,"y")),e.innerHeight||e.height||(t=W.scrollTop(),W.css({height:"auto"}),B.h=W.height()),W.css({height:B.h}),t&&W.scrollTop(t),J.position("none"===B.transition?0:B.speed))},J.prep=function(i){function n(){return B.w=B.w||W.width(),B.w=B.mw&&B.mw<B.w?B.mw:B.w,B.w}function l(){return B.h=B.h||W.height(),B.h=B.mh&&B.mh<B.h?B.mh:B.h,B.h}if($){var s,d="none"===B.transition?0:B.speed;W.empty().remove(),W=o(se,"LoadedContent").append(i),W.hide().appendTo(F.show()).css({width:n(),overflow:B.scrolling?"auto":"hidden"}).css({height:l()}).prependTo(x),F.hide(),e(U).css({float:"none"}),s=function(){function i(){e.support.opacity===!1&&v[0].style.removeAttribute("filter")}var n,l,s=E.length,u="frameBorder",f="allowTransparency";$&&(l=function(){clearTimeout(Q),L.hide(),c(ne,B.onComplete)},S.html(B.title).add(W).show(),s>1?("string"==typeof B.current&&M.html(B.current.replace("{current}",j+1).replace("{total}",s)).show(),I[B.loop||j<s-1?"show":"hide"]().html(B.next),K[B.loop||j?"show":"hide"]().html(B.previous),B.slideshow&&R.show(),B.preloading&&e.each([r(-1),r(1)],function(){var i,o,n=E[this],r=e.data(n,Z);r&&r.href?(i=r.href,e.isFunction(i)&&(i=i.call(n))):i=e(n).attr("href"),i&&a(r,i)&&(i=h(r,i),o=t.createElement("img"),o.src=i)})):P.hide(),B.iframe?(n=o("iframe")[0],u in n&&(n[u]=0),f in n&&(n[f]="true"),B.scrolling||(n.scrolling="no"),e(n).attr({src:B.href,name:(new Date).getTime(),class:ee+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",l).appendTo(W),he.one(ae,function(){n.src="//about:blank"}),B.fastIframe&&e(n).trigger("load")):l(),"fade"===B.transition?v.fadeTo(d,1,i):i())},"fade"===B.transition?v.fadeTo(d,0,function(){J.position(0,s)}):J.position(d,s)}},J.next=function(){!q&&E[1]&&(B.loop||E[j+1])&&(j=r(1),f(E[j]))},J.prev=function(){!q&&E[1]&&(B.loop||j)&&(j=r(-1),f(E[j]))},J.close=function(){$&&!G&&(G=!0,$=!1,c(re,B.onCleanup),H.unbind("."+ee),g.fadeTo(B.fadeOut||0,0),v.stop().fadeTo(B.fadeOut||0,0,function(){v.add(g).css({opacity:1,cursor:"auto"}).hide(),c(ae),W.empty().remove(),setTimeout(function(){G=!1,c(le,B.onClosed)},1)}))},J.hide=function(){g.fadeTo(B.fadeOut||0,0),v.fadeTo(B.fadeOut||0,0,function(){g.hide(),v.css({opacity:1,cursor:"auto",left:"-9999em"}),c(le,B.onClosed)})},J.remove=function(){v&&(v.stop(),e.colorbox.close(),v.stop().remove(),g.remove(),G=!1,v=null,e("."+te).removeData(Z).removeClass(te),e(t).unbind("click."+ee))},J.element=function(){return e(A)},J.settings=Y)}(jQuery,document,window); -
shopp/trunk/core/ui/behaviors/editors.min.js
r1473303 r1648469 1 function NestedMenu(e,i,t,n,a,l,o){var r=jQuery,s=this;o||(o={axis:"y"}),s.items=l,s.dataname=t,s.index=e,s.element=r('<li><div class="move"></div><input type="hidden" name="'+t.replace("[","-").replace("]","-")+'-sortorder[]" value="'+e+'" class="sortorder" /><input type="hidden" name="'+t+"["+e+'][id]" class="id" /><input type="text" name="'+t+"["+e+'][name]" class="label" /><button type="button" class="delete"><span class="shoppui-minus"></span></button></li>').appendTo(r(i).children("ul")),s.moveHandle=s.element.find("div.move"),s.sortorder=s.element.find("input.sortorder"),s.id=s.element.find("input.id"),s.label=s.element.find("input.label"),s.deleteButton=s.element.find("button.delete").bind("delete",function(){var e=r(i).find("input.deletes");""!=r(s.id).val()&&e.val(""==e.val()?r(s.id).val():e.val()+","+r(s.id).val()),l&&s.itemsElement.remove(),s.element.remove()}).click(function(){r(this).trigger("delete")}),s.items&&("list"==l.type?s.itemsElement=r("<ul></ul>").appendTo(l.target).hide():s.itemsElement=r("<li></li>").appendTo(l.target).hide()),s.selected=function(){r(i).find("ul li").removeClass("selected"),r(s.element).addClass("selected"),l&&(r(l.target).children().hide(),r(s.itemsElement).show())},s.element.click(this.selected).hover(function(){r(this).addClass("hover")},function(){r(this).removeClass("hover")}),s.label.mouseup(function(e){this.select()}).focus(function(){r(this).keydown(function(e){e.stopPropagation(),13==e.keyCode&&r(this).blur().unbind("keydown")})}),s.id.val(s.index),a&&a.id&&s.id.val(a.id),a&&a.name?s.label.val(htmlentities(a.name)):s.label.val(n+" "+s.index),r(i).children("ul").hasClass("ui-sortable")?r(i).children("ul").sortable("refresh"):r(i).children("ul").sortable(o)}function NestedMenuContent(e,i,t,n){var a=jQuery;this.contents=a('<textarea name="'+t+"["+e+'][value]" cols="40" rows="7"></textarea>').appendTo(i),n&&n.value&&this.contents.val(htmlentities(n.value))}function NestedMenuOption(e,i,t,n,a){var l=jQuery,o=this;o.index=l(i).contents().length,o.element=l('<li class="option"><div class="move"></div><input type="hidden" name="'+t+"["+e+"][options]["+this.index+'][id]" class="id" /><input type="text" name="'+t+"["+e+"][options]["+this.index+'][name]" class="label" /><button type="button" class="delete"><span class="shoppui-minus"></span></button></li>').appendTo(i),o.moveHandle=o.element.find("div.move"),o.id=o.element.find("input.id"),o.label=o.element.find("input.label"),o.deleteButton=o.element.find("button.delete").click(function(){l(o.element).remove()}),o.element.hover(function(){l(this).addClass("hover")},function(){l(this).removeClass("hover")}),o.label.click(function(){this.select()}).focus(function(){l(this).keydown(function(e){e.stopPropagation(),13==e.keyCode&&l(this).blur().unbind("keydown")})}),o.id.val(o.index),a.id&&o.id.val(a.id),a.name&&o.label.val(htmlentities(a.name)),a.name||o.label.val(n+" "+(o.index+1))}function loadVariations(e,i){if(e){var t=jQuery;t.each(e,function(e,i){i&&i.id&&addVariationOptionsMenu(i)}),t.each(i,function(e,i){"variation"==i.context&&Pricelines.add(i.options.split(","),i,"#variations-pricing")}),Pricelines.updateVariationsUI(),t.each(e,function(e,i){i&&i.options&&t.each(i.options,function(e,i){i&&i.id&&"on"==i.linked&&Pricelines.linkVariations(i.id)})})}}function addVariationOptionsMenu(e){var i=jQuery,t=i("#variations-menu"),n=i("#variations-list"),a=(i("#addVariationMenu"),i("#addVariationOption")),l=i("#linkOptionVariations"),o=variationsidx,r=new NestedMenu(o,t,"meta[options][v]",OPTION_MENU_DEFAULT,e,{target:n,type:"list"},{axis:"y",update:function(){orderOptions(t,n)}});r.addOption=function(e){var t,o,s=!1;e||(e=new Object),e.id?e.id>optionsidx&&(optionsidx=e.id):(s=!0,e.id=optionsidx),t=new NestedMenuOption(r.index,r.itemsElement,"meta[options][v]",NEW_OPTION_DEFAULT,e),optionsidx++,o=t.id.val(),t.linkIcon=i('<span class="shoppui-link"></span>').appendTo(t.moveHandle),t.linked=i('<input type="hidden" name="meta[options][v]['+r.index+"][options]["+t.index+'][linked]" class="linked" />').val(e.linked?e.linked:"off").appendTo(t.element).change(function(){"on"==i(this).val()?t.linkIcon.removeClass("hidden"):t.linkIcon.addClass("hidden")}).change(),t.selected=function(){t.element.hasClass("selected")?(n.find("ul li").removeClass("selected"),selectedMenuOption=!1):(n.find("ul li").removeClass("selected"),i(t.element).addClass("selected"),selectedMenuOption=t),l.change()},t.element.click(t.selected),productOptions[o]=t.label,t.label.blur(function(){updateVariationLabels()}),t.deleteButton.unbind("click"),t.deleteButton.click(function(){1==r.itemsElement.children().length?deleteVariationPrices([o],!0):deleteVariationPrices([o]),t.element.remove()}),s?addVariationPrices():addVariationPrices(o),n.dequeue().animate({scrollTop:n.prop("scrollHeight")-n.height()},200),t.label.click().focus().select().keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),t.label.blur(),a.focus())}),r.items.push(t)},r.items=new Array,e&&e.options?i.each(e.options,function(){r.addOption(this)}):(r.addOption(),r.addOption()),r.itemsElement.sortable({axis:"y",update:function(){orderVariationPrices()}}),r.element.unbind("click",r.click).click(function(){r.selected(),i(a).unbind("click").click(r.addOption)}),optionMenus[variationsidx++]=r,r.deleteButton.unbind("click").click(function(){var e=new Array;i(r.itemsElement).find("li").not(".ui-sortable-helper").find("input.id").each(function(t,n){e.push(i(n).val())}),deleteVariationPrices(e,!0),i(this).trigger("delete")}),e||(n.dequeue().animate({scrollTop:n.attr("scrollHeight")-n.height()},200),r.label.click().focus().select().keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),a.focus())}))}function buildVariations(){var e,i,t,n,a=jQuery,l=new Array,o=a("#variations-list ul"),r=o.length,s=r-1,d=new Array(o.length),c=new Array(o.length),u=0;for(o.each(function(e,i){c[e]=a(i).children().length,0==u?u=a(i).children().length:u*=a(i).children().length,d[e]=0}),e=0;e<u;e++){for(i=0;i<o.length;i++)t=a(o[i]).children("li").not(".ui-sortable-helper").children("input.id"),l[e]?l[e].push(a(t[d[i]]).val()):l[e]=[a(t[d[i]]).val()];if(++d[s]>=c[s])for(n=s;n>-1;n--)d[n]<c[n]||(d[n]=0,n-1>-1&&d[n-1]++)}return l}function addVariationPrices(e){if(!e){var i,t,n=jQuery,a=buildVariations(),l=n("#variations-pricing"),o=n(l).children(),r=!1;n(a).each(function(e,n){i=xorkey(n),t=xorkey(n.slice(0,n.length-1)),""==t&&(t=-1),Pricelines.row[i]||(Pricelines.row[t]?(Pricelines.row[i]=Pricelines.row[t],delete Pricelines.row[t],Pricelines.row[i].setOptions(n)):(0==o.length?Pricelines.add(n,{context:"variation"},"#variations-pricing"):Pricelines.add(n,{context:"variation"},Pricelines.row[xorkey(a[e-1])].row,"after"),r=!0))}),r&&Pricelines.updateVariationsUI()}}function deleteVariationPrices(e,i){var t,n,a,l,o,r=jQuery,s=buildVariations(),d=!1;r(s).each(function(s,c){for(n=xorkey(c),t=0;t<e.length;t++)c.indexOf(e[t])!=-1&&(a=new Array,r(c).each(function(i,n){n!=e[t]&&a.push(n)}),l=xorkey(a),i&&!Pricelines.row[l]?(0!=l?Pricelines.row[l]=Pricelines.row[n]:Pricelines.row[n].row.remove(),delete Pricelines.row[n],Pricelines.row[l]&&(Pricelines.row[l].setOptions(a),d=!0)):Pricelines.row[n]&&(o=r("#priceid-"+Pricelines.row[n].id).val(),""==r("#deletePrices").val()?r("#deletePrices").val(o):r("#deletePrices").val(r("#deletePrices").val()+","+o),Pricelines.remove(n)))}),d&&Pricelines.updateVariationsUI()}function optionMenuExists(e){if(!e)return!1;var i=jQuery,t=!1;return i.each(optionMenus,function(n,a){if(a&&i(a.label).val()==e)return t=n}),optionMenus[t]?optionMenus[t]:t}function optionMenuItemExists(e,i){if(!e||!e.items||!i)return!1;var t=jQuery,n=!1;return t.each(e.items,function(e,a){if(a&&t(a.label).val()==i)return n=!0}),n}function updateVariationLabels(){var e=jQuery,i=buildVariations();e(i).each(function(e,i){var t=xorkey(i);Pricelines.row[t]&&Pricelines.row[t].updateLabel()})}function orderOptions(e,i){var t=jQuery;t(e).find("ul li").not(".ui-sortable-helper").find("input.id").each(function(e,n){n&&t(optionMenus[t(n).val()].itemsElement).appendTo(i)}),orderVariationPrices()}function orderVariationPrices(){var e,i=jQuery,t=buildVariations();i(t).each(function(i,t){e=xorkey(t),e>0&&Pricelines.row[e]&&Pricelines.reorderVariation(e,t)}),Pricelines.updateVariationsUI("tabs")}function xorkey(e){e instanceof Array||(e=[e]);for(var i=0,t=0;t<e.length;t++)i^=7001*e[t];return i}function variationsToggle(){var e=jQuery,i=e(this),t=e("#variations"),n=e("#product-pricing");i.prop("checked")?(Pricelines.row[0]&&Pricelines.row[0].disable(),n.hide(),t.show()):(t.hide(),n.show(),Pricelines.row[0]&&Pricelines.row[0].enable())}function addonsToggle(){var e=jQuery,i=e(this),t=e("#addons");i.prop("checked")?t.show():t.hide()}function clearLinkedIcons(){jQuery("#variations-list input.linked").val("off").change()}function linkVariationsButton(){var e=jQuery;selectedMenuOption?"off"==selectedMenuOption.linked.val()?(Pricelines.allLinked()&&(clearLinkedIcons(),Pricelines.unlinkAll()),selectedMenuOption.linked.val("on").change(),Pricelines.linkVariations(selectedMenuOption.id.val())):(selectedMenuOption.linked.val("off").change(),Pricelines.unlinkVariations(selectedMenuOption.id.val())):(clearLinkedIcons(),Pricelines.allLinked()?Pricelines.unlinkAll():Pricelines.linkAll()),e(this).change()}function linkVariationsButtonLabel(){var e=jQuery;selectedMenuOption?"on"==selectedMenuOption.linked.val()?e(this).find("small").html(" "+UNLINK_VARIATIONS):e(this).find("small").html(" "+LINK_VARIATIONS):Pricelines.allLinked()?e(this).find("small").html(" "+UNLINK_ALL_VARIATIONS):e(this).find("small").html(" "+LINK_ALL_VARIATIONS)}function loadAddons(e,i){var t=jQuery;e&&(t.each(e,function(e,i){newAddonGroup(i)}),t.each(i,function(e,i){if("addon"==i.context){var t=addonOptionsGroup[i.options];Pricelines.add(i.options,this,"#addon-pricegroup-"+t)}}),Pricelines.updateVariationsUI())}function newAddonGroup(e){var i=jQuery,t=i("#addon-menu"),n=i("#addon-list"),a=i("#newAddonGroup"),l=i("#addAddonOption"),o=addon_group_idx,r=new NestedMenu(o,t,"meta[options][a]",ADDON_GROUP_DEFAULT,e,{target:n,type:"list"},{axis:"y",update:function(){orderAddonGroups()}});r.itemsElement.attr("id","addon-group-"+o),r.pricegroup=i('<div id="addon-pricegroup-'+o+'" />').appendTo("#addon-pricing"),r.pricegroupLabel=i("<label />").html("<h4>"+r.label.val()+"</h4>").prependTo(r.pricegroup),r.updatePriceLabel=function(){r.pricegroupLabel.html("<h4>"+r.label.val()+"</h4>")},r.label.blur(r.updatePriceLabel),r.addOption=function(e){var t,a,o=!1;e||(e=new Object),e.id?e.id>addonsidx&&(addonsidx=e.id):(o=!0,e.id=addonsidx),t=new NestedMenuOption(r.index,r.itemsElement,"meta[options][a]",NEW_OPTION_DEFAULT,e),addonsidx++,a=t.id.val(),t.selected=function(){t.element.hasClass("selected")?(n.find("ul li").removeClass("selected"),selectedMenuOption=!1):(n.find("ul li").removeClass("selected"),i(t.element).addClass("selected"),selectedMenuOption=t)},t.element.click(t.selected),productAddons[a]=t.label,t.label.blur(function(){Pricelines.row[a].updateLabel()}),t.deleteButton.unbind("click"),t.deleteButton.click(function(){var e=Pricelines.row[a].data.id,n=i("#deletePrices");e&&(""==n.val()?n.val(e):n.val(n.val()+","+e)),Pricelines.row[a].row.remove(),t.element.remove()}),o&&Pricelines.add(a,{context:"addon"},r.pricegroup),addonOptionsGroup[a]=r.index,r.items.push(t),n.dequeue().animate({scrollTop:n.attr("scrollHeight")-n.height()},200),t.label.click().focus().select().keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),t.label.blur(),l.focus())})},r.items=new Array,e&&e.options?i.each(e.options,function(){r.addOption(this)}):(r.addOption(),r.addOption()),r.itemsElement.sortable({axis:"y",update:function(){orderAddonPrices(r.index)}}),r.element.unbind("click",r.click),r.element.click(function(){r.selected(),i(l).unbind("click").click(r.addOption)}),addonGroups[addon_group_idx++]=r,r.deleteButton.unbind("click").click(function(){i("#addon-list #addon-group-"+r.index+" li").not(".ui-sortable-helper").find("input.id").each(function(e,t){var n,a=i(t).val(),l=i("#deletePrices");Pricelines.row[a]&&(n=Pricelines.row[a].data.id,n&&(""==l.val()?l.val(n):l.val(l.val()+","+n)),Pricelines.row[a].row.remove())}),r.deleteButton.trigger("delete"),r.pricegroup.remove(),r.element.remove()}),e||(t.dequeue().animate({scrollTop:t.attr("scrollHeight")-t.height()},200),r.label.click().focus().select().keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),r.label.blur(),a.focus())}))}function orderAddonGroups(){var e,i=jQuery;i("#addon-menu ul li").not(".ui-sortable-helper").find("input.id").each(function(t,n){e=addonGroups[i(n).val()],e.pricegroup.appendTo("#addon-pricing")})}function orderAddonPrices(e){var i=jQuery,t=addonGroups[e];i("#addon-list #addon-group-"+t.index+" li").not(".ui-sortable-helper").find("input.id").each(function(e,n){Pricelines.reorderAddon(i(n).val(),t.pricegroup)})}function readableFileSize(e){var i=new Array("bytes","KB","MB","GB"),t=1*e,n=0;if(0==t)return t;for(;t>1e3;)t/=1024,n++;return t.toFixed(2)+" "+i[n]}function addDetail(e){var i,t,n=jQuery,a=n("#details-menu"),l=n("#details-list"),o=detailsidx++,r=new NestedMenu(o,a,"details","Detail Name",e,{target:l});if(e&&e.options){t=n('<select name="details['+r.index+'][value]"></select>').appendTo(r.itemsElement),n("<option></option>").appendTo(t);for(i in e.options)n("<option>"+e.options[i].name+"</option>").appendTo(t);e&&e.value&&t.val(htmlentities(e.value))}else r.item=new NestedMenuContent(r.index,r.itemsElement,"details",e);e&&!e.add||(r.add=n('<input type="hidden" name="details['+r.index+'][new]" value="true" />').appendTo(r.element),a.dequeue().animate({scrollTop:a.attr("scrollHeight")-a.height()},200),r.label.click().focus().select(),r.item&&r.item.contents.keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),n("#addDetail").focus())}))}function ImageUploads(e,i){function t(){p("#browser-uploader").hide(),u.loaded=!0}function n(){p("#lightbox li").size()>0&&p("#lightbox").sortable({opacity:.8})}function a(e,i,t){return i==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED?void alert("You selected too many files to upload at one time. "+(0===t?"You have reached the upload limit.":"You may upload "+(t>1?"up to "+t+" files.":"only one file."))):void alert(t)}function l(e,i){try{this.startUpload()}catch( t){this.debug(t)}}function o(e){this.targetHolder=p('<li class="image uploading"><input type="hidden" name="images[]" /><div class="progress"><div class="bar"></div><div class="gloss"></div></div></li>').appendTo(p("#lightbox")),this.progressBar=this.targetHolder.find("div.bar"),this.sorting=this.targetHolder.find("input")}function r(e,i,t){this.progressBar.animate({width:Math.ceil(i/t*76)+"px"},100)}function s(e,i,t){}function d(e,i){var t,a,l=!1,o=this.targetHolder;try{l=p.parseJSON(i)}catch(r){return o.remove(),alert(i),!1}return l.id?(o.attr({id:"image-"+l.id}),this.sorting.val(l.id),t=p('<img src="?siid='+l.id+'" width="96" height="96" class="handle" />').appendTo(o).hide(),a=p('<button type="button" name="deleteImage" value="'+l.id+'" class="delete"><span class="shoppui-minus"></span></button>').appendTo(o).hide(),n(),void this.progressBar.animate({width:"76px"},250,function(){p(this).parent().fadeOut(500,function(){p(this).remove(),p(t).fadeIn("500"),c(a)})})):(o.remove(),l.error?alert(l.error):alert(UNKNOWN_UPLOAD_ERROR),!0)}function c(e){e.hide(),e.parent().hover(function(){e.show()},function(){e.hide()}),e.click(function(){if(confirm(DELETE_IMAGE_WARNING)){var i="<"==e.val().substr(0,1)?e.find("input[name=ieisstupid]").val():e.val(),t=p("#deleteImages"),n=t.val();t.val(""==n?i:n+","+i),p("#confirm-delete-images").show(),e.parent().fadeOut(500,function(){p(this).remove()})}})}var u,p=jQuery,h={button_text:ADD_IMAGE_BUTTON_TEXT,button_text_style:'.buttonText{text-align:center;font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,_sans;font-size:9px;color:#333333;}',button_text_top_padding:3,button_height:"18",button_width:"100",button_image_url:uidir+"/icons/buttons.png",button_placeholder_id:"swf-uploader-button",upload_url:ajaxurl,flash_url:uidir+"/behaviors/swfupload.swf",file_queue_limit:0,file_size_limit:filesizeLimit+"b",file_types:"*.jpg;*.jpeg;*.png;*.gif",file_types_description:"Web-compatible Image Files",file_upload_limit:filesizeLimit,post_params:{action:"shopp_upload_image",parent:e,type:i},swfupload_loaded_handler:t,file_queue_error_handler:a,file_dialog_complete_handler:l,upload_start_handler:o,upload_progress_handler:r,upload_error_handler:s,upload_success_handler:d,custom_settings:{loaded:!1,targetHolder:!1,progressBar:!1,sorting:!1},prevent_swf_caching:p.ua.msie,debug:imageupload_debug};flashuploader&&(u=new SWFUpload(h)),p("#image-upload").upload({name:"Filedata",action:ajaxurl,params:{action:"shopp_upload_image",type:i},onSubmit:function(){this.targetHolder=p('<li id="image-uploading"><input type="hidden" name="images[]" value="" /><div class="progress"><div class="bar"></div><div class="gloss"></div></div></li>').appendTo("#lightbox"),this.progressBar=this.targetHolder.find("div.bar"),this.sorting=this.targetHolder.find("input")},onComplete:function(e){var i,t,n=!1,a=this.targetHolder;try{n=p.parseJSON(e)}catch(l){n.error=e}return n&&n.id?(a.attr({id:"image-"+n.id}),this.sorting.val(n.id),i=p('<img src="?siid='+n.id+'" width="96" height="96" class="handle" />').appendTo(a).hide(),t=p('<button type="button" name="deleteImage" value="'+n.src+'" class="delete"><span class="shoppui-minus"></span></button>').appendTo(p(a)).hide(),void p(this.progressBar).animate({width:"76px"},250,function(){p(this).parent().fadeOut(500,function(){p(this).remove(),p(i).fadeIn("500"),c(t)})})):(a.remove(),n.error?alert(n.error):alert(UNKNOWN_UPLOAD_ERROR),!1)}}),p(document).load(function(){u.loaded||p("#product-images .swfupload").remove()}),n(),p("#lightbox li").each(function(){p(this).dblclick(function(){var e=p(this).attr("id")+"-details",i=p("#"+e),t=i.find("input[type=hidden]").val(),n=i.find("img"),a=i.find("input.imagetitle"),l=i.find("input.imagealt"),o=i.find("input.imagecropped"),r=p('<div class="image-details-editor"><div class="details-editor"><img class="thumb" width="96" height="96" /><div class="details"><p><label>'+IMAGE_DETAILS_TITLE_LABEL+': </label><input type="text" name="title" /></p><p><label>'+IMAGE_DETAILS_ALT_LABEL+': </label><input type="text" name="alt" /></p></div></div><div class="cropping"><p class="clear">'+IMAGE_DETAILS_CROP_LABEL+': <select name="cropimage"><option></option></select></p><div class="cropui"></div><br class="clear"/></div><input type="button" class="button-primary alignright" value=" '+IMAGE_DETAILS_DONE+' " /></div>'),s=(r.find("img").attr("src",n.attr("src")),r.find("input[name=title]").val(a.val()).change(function(){a.val(s.val())})),d=r.find("input[name=alt]").val(l.val()).change(function(){l.val(d.val())}),c=(r.find("input[type=button]").click(function(){p.colorbox.close()}),r.find("div.cropping").hide()),u=r.find("div.cropui"),h=r.find("select[name=cropimage]").change(function(){if(""==h.val())return u.empty(),void p.colorbox.resize();var e=h.val().split(":"),i=o.filter("input[alt="+h.val()+"]").val().split(",");u.empty().scaleCrop({imgsrc:"?siid="+t,target:{width:parseInt(e[0],10),height:parseInt(e[1],10)},init:{x:parseInt(i[0],10),y:parseInt(i[1],10),s:new Number(i[2])}}).ready(function(){var i=125;p.colorbox.resize({innerWidth:parseInt(e[0],10)+i})}).bind("change.scalecrop",function(e,i){i.s||(i.s=1),i&&o.filter("input[alt="+h.val()+"]").val(i.x+","+i.y+","+i.s)})});o.size()>0&&(o.each(function(e,i){var t=p(i).attr("alt");p('<option value="'+t+'">'+(e+1)+": "+t.replace(":","×")+"</option>").appendTo(h)}),c.show()),p.colorbox({title:IMAGE_DETAILS_TEXT,html:r})}),c(p(this).find("button.delete"))})}function FileUploader(e,i){function t(){s(i).hide(),this.loaded=!0}function n(e,i,t){return i==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED?void alert("You selected too many files to upload at one time. "+(0===t?"You have reached the upload limit.":"You may upload "+(t>1?"up to "+t+" files.":"only one file."))):void alert(t)}function a(e,i){if(s.colorbox.hide(),e)try{this.startUpload()}catch(t){this.debug(t)}}function l(e){this.targetCell.attr("class","").html(""),s('<div class="progress"><div class="bar"></div><div class="gloss"></div></div>').appendTo(this.targetCell),this.progressBar=this.targetCell.find("div.bar")}function o(e,i,t){this.progressBar.animate({width:Math.ceil(i/t*76)+"px"},100)}function r(e,i){var t=!1,n=this.targetCell,a=this.targetLine;s.colorbox.close();try{t=s.parseJSON(i)}catch(l){t.error=i}return t.id||t.name?(t.type=t.type.replace(/\//gi," "),void s(this.progressBar).animate({width:"76px"},250,function(){s(this).parent().fadeOut(500,function(){s(this).remove(),s(n).attr("class","file").html('<div class="icon shoppui-file '+t.type+'"></div>'+t.name+"<br /><small>"+readableFileSize(t.size)+'</small><input type="hidden" name="price['+a+'][download]" value="'+t.id+'" />')})})):(n.html(NO_DOWNLOAD),t.error?alert(t.error):alert(UNKNOWN_UPLOAD_ERROR),!1)}var s=jQuery,d=this;d.swfu=!1,d.settings={button_text:UPLOAD_FILE_BUTTON_TEXT,button_text_style:'.buttonText{text-align:center;font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,_sans;font-size:9px;color:#333333; }',button_text_top_padding:3,button_height:"22",button_width:"100",button_image_url:uidir+"/icons/buttons.png",button_placeholder_id:e,button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,flash_url:uidir+"/behaviors/swfupload.swf",upload_url:ajaxurl,file_queue_limit:1,file_size_limit:filesizeLimit+"b",file_types:"*.*",file_types_description:"All Files",file_upload_limit:filesizeLimit,post_params:{action:"shopp_upload_file"},swfupload_loaded_handler:t,file_queue_error_handler:n,file_dialog_complete_handler:a,upload_start_handler:l,upload_progress_handler:o,upload_success_handler:r,custom_settings:{loaded:!1,targetCell:!1,targetLine:!1,progressBar:!1},prevent_swf_caching:s.ua.msie,debug:fileupload_debug},flashuploader&&(d.swfu=new SWFUpload(d.settings)),i.upload({name:"Filedata",action:ajaxurl,params:{action:"shopp_upload_file"},onSubmit:function(){s.colorbox.hide(),d.targetCell.attr("class","").html(""),s('<div class="progress"><div class="bar"></div><div class="gloss"></div></div>').appendTo(d.targetCell),d.progressBar=d.targetCell.find("div.bar")},onComplete:function(e){s.colorbox.close();var i=!1,t=d.targetCell;try{i=s.parseJSON(e)}catch(n){i.error=e}return i.id||i.name?(i.type=i.type.replace(/\//gi," "),void s(d.progressBar).animate({width:"76px"},250,function(){s(this).parent().fadeOut(500,function(){t.attr("class","file").html('<div class="icon shoppui-file '+i.type+'"></div>'+i.name+"<br /><small>"+readableFileSize(i.size)+'</small><input type="hidden" name="price['+d.targetLine+'][download]" value="'+i.id+'" />'),s(this).remove()})})):(t.html(NO_DOWNLOAD),i.error?alert(i.error):alert(UNKNOWN_UPLOAD_ERROR),!1)}}),s(d).load(function(){d.swfu&&d.swfu.loaded||s(i).parent().parent().find(".swfupload").remove()}),d.updateLine=function(e,i){d.swfu?(d.swfu.targetLine=e,d.swfu.targetCell=i):(d.targetLine=e,d.targetCell=i)}}function SlugEditor(e,i){var t=jQuery,n=this,a=t("#edit-slug-buttons"),l=a.find(".edit"),o=a.find(".view"),r=t("#editor-slug-buttons"),s=r.find(".save"),d=r.find(".cancel"),c=t("#editable-slug-full");n.permalink=function(){var n,l=0,u=t("#editable-slug"),p=u.html(),h=t("#slug_input"),f=h.html(),m=c.html();for(a.hide(),r.show(),s.unbind("click").click(function(){var n=u.children("input").val(),l=t("#title").val();t.post(editslug_url+"&action=shopp_edit_slug",{id:e,type:i,slug:n,title:l},function(e){u.html(p),e!=-1&&(u.html(e),c.html(e),h.val(e)),o.attr("href",canonurl+c.html()),r.hide(),a.show()},"text")}),d.unbind("click").click(function(){u.html(p),r.hide(),a.show(),h.attr("value",f)}),n=0;n<m.length;++n)"%"==m.charAt(n)&&l++;slug_value=l>m.length/4?"":m,u.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(e){var i=e.which;13!=i&&27!=i||e.preventDefault(),13==i&&s.click(),27==i&&d.click(),h.val(this.value)}).focus()},l.click(n.permalink)}jQuery.fn.FileChooser=function(e,i){var t=jQuery,n=this,a=t("#chooser"),l=a.find(".fileimport"),o=a.find(".status"),r=t("#attach-file"),s=t("#download_path-"+e),d=t("#download_file-"+e),c=t("#file-"+e),u=!1,p=0;n.line=e,n.status=i,a.unbind("change").on("change",".fileimport",function(e){o.attr("class","status").addClass("shoppui-spinner shoppui-spinfx shoppui-spinfx-steps8"),t.ajax({url:fileverify_url+"&action=shopp_verify_file&t=download",type:"POST",data:"url="+l.val(),timeout:1e4,dataType:"text",success:function(e){return o.attr("class","status"),"OK"==e?o.addClass("shoppui-ok-sign"):("NULL"==e&&o.attr("title",FILE_NOT_FOUND_TEXT),"ISDIR"==e&&o.attr("title",FILE_ISDIR_TEXT),"READ"==e&&o.attr("title",FILE_NOT_READ_TEXT),void o.addClass("shoppui-warning-sign"))}})}),l.unbind("keydown").unbind("keypress").suggest(sugg_url+"&action=shopp_storage_suggestions&t=download",{delay:500,minchars:3,multiple:!1,onSelect:function(){l.trigger("change")}}),t(this).click(function(){fileUploads.updateLine(e,i),o.attr("class","status"),r.unbind("click").click(function(){if(t.colorbox.hide(),u)return s.val(l.val()),l.val("").attr("class","fileimport"),!0;var i=!1,n=l.val(),a=function(e){return e.name?(c.attr("class","file").html('<span class="icon shoppui-file '+e.mime.replace("/"," ")+'"></span>'+e.name+"<br /><small>"+readableFileSize(e.size)+"</small>"),s.val(e.path),d.val(e.name),void l.val("").attr("class","fileimport")):$this.attr("class","")},o=function(){var n=c.find("div.progress"),l=n.find("div.bar"),r=n.outerWidth(),s=t("#import-file-"+e).get(0).contentWindow,d=s.importProgress,u=s.importFile;if(void 0!==u){if(u.error)return c.attr("class","error").html("<small>"+u.error+"</small>");if(!u.path)return c.attr("class","error").html("<small>"+FILE_UNKNOWN_IMPORT_ERROR+"</small>");if(u.stored)return a(u);savepath=u.path.split("/"),i=savepath[savepath.length-1]}return d||(d=0),0===d&&p++>60?c.attr("class","error").html("<small>"+FILE_UNKNOWN_IMPORT_ERROR+"</small>"):(l.animate({width:Math.ceil(d*r)+"px"},100),1==d?void(l&&l.css({width:"100%"}).fadeOut(500,function(){a(u)})):void setTimeout(o,100))};setTimeout(o,100),c.attr("class","").html('<div class="progress"><div class="bar"></div><div class="gloss"></div></div><iframe id="import-file-'+e+'" width="0" height="0" src="'+fileimport_url+"&action=shopp_import_file&url="+n+'"></iframe>')})}),t(this).colorbox({title:"File Selector",innerWidth:"360",innerHeight:"140",inline:!0,href:a})};1 function NestedMenu(e,i,t,n,a,l,o){var r=jQuery,s=this;o||(o={axis:"y"}),s.items=l,s.dataname=t,s.index=e,s.element=r('<li><div class="move"></div><input type="hidden" name="'+t.replace("[","-").replace("]","-")+'-sortorder[]" value="'+e+'" class="sortorder" /><input type="hidden" name="'+t+"["+e+'][id]" class="id" /><input type="text" name="'+t+"["+e+'][name]" class="label" /><button type="button" class="delete"><span class="shoppui-minus"></span></button></li>').appendTo(r(i).children("ul")),s.moveHandle=s.element.find("div.move"),s.sortorder=s.element.find("input.sortorder"),s.id=s.element.find("input.id"),s.label=s.element.find("input.label"),s.deleteButton=s.element.find("button.delete").bind("delete",function(){var e=r(i).find("input.deletes");""!=r(s.id).val()&&e.val(""==e.val()?r(s.id).val():e.val()+","+r(s.id).val()),l&&s.itemsElement.remove(),s.element.remove()}).click(function(){r(this).trigger("delete")}),s.items&&("list"==l.type?s.itemsElement=r("<ul></ul>").appendTo(l.target).hide():s.itemsElement=r("<li></li>").appendTo(l.target).hide()),s.selected=function(){r(i).find("ul li").removeClass("selected"),r(s.element).addClass("selected"),l&&(r(l.target).children().hide(),r(s.itemsElement).show())},s.element.click(this.selected).hover(function(){r(this).addClass("hover")},function(){r(this).removeClass("hover")}),s.label.mouseup(function(e){this.select()}).focus(function(){r(this).keydown(function(e){e.stopPropagation(),13==e.keyCode&&r(this).blur().unbind("keydown")})}),s.id.val(s.index),a&&a.id&&s.id.val(a.id),a&&a.name?s.label.val(htmlentities(a.name)):s.label.val(n+" "+s.index),r(i).children("ul").hasClass("ui-sortable")?r(i).children("ul").sortable("refresh"):r(i).children("ul").sortable(o)}function NestedMenuContent(e,i,t,n){var a=jQuery;this.contents=a('<textarea name="'+t+"["+e+'][value]" cols="40" rows="7"></textarea>').appendTo(i),n&&n.value&&this.contents.val(htmlentities(n.value))}function NestedMenuOption(e,i,t,n,a){var l=jQuery,o=this;o.index=l(i).contents().length,o.element=l('<li class="option"><div class="move"></div><input type="hidden" name="'+t+"["+e+"][options]["+this.index+'][id]" class="id" /><input type="text" name="'+t+"["+e+"][options]["+this.index+'][name]" class="label" /><button type="button" class="delete"><span class="shoppui-minus"></span></button></li>').appendTo(i),o.moveHandle=o.element.find("div.move"),o.id=o.element.find("input.id"),o.label=o.element.find("input.label"),o.deleteButton=o.element.find("button.delete").click(function(){l(o.element).remove()}),o.element.hover(function(){l(this).addClass("hover")},function(){l(this).removeClass("hover")}),o.label.click(function(){this.select()}).focus(function(){l(this).keydown(function(e){e.stopPropagation(),13==e.keyCode&&l(this).blur().unbind("keydown")})}),o.id.val(o.index),a.id&&o.id.val(a.id),a.name&&o.label.val(htmlentities(a.name)),a.name||o.label.val(n+" "+(o.index+1))}function loadVariations(e,i){if(e){var t=jQuery;t.each(e,function(e,i){i&&i.id&&addVariationOptionsMenu(i)}),t.each(i,function(e,i){"variation"==i.context&&Pricelines.add(i.options.split(","),i,"#variations-pricing")}),Pricelines.updateVariationsUI(),t.each(e,function(e,i){i&&i.options&&t.each(i.options,function(e,i){i&&i.id&&"on"==i.linked&&Pricelines.linkVariations(i.id)})})}}function addVariationOptionsMenu(e){var i=jQuery,t=i("#variations-menu"),n=i("#variations-list"),a=(i("#addVariationMenu"),i("#addVariationOption")),l=i("#linkOptionVariations"),o=variationsidx,r=new NestedMenu(o,t,"meta[options][v]",OPTION_MENU_DEFAULT,e,{target:n,type:"list"},{axis:"y",update:function(){orderOptions(t,n)}});r.addOption=function(e){var t,o,s=!1;e||(e=new Object),e.id?e.id>optionsidx&&(optionsidx=e.id):(s=!0,e.id=optionsidx),t=new NestedMenuOption(r.index,r.itemsElement,"meta[options][v]",NEW_OPTION_DEFAULT,e),optionsidx++,o=t.id.val(),t.linkIcon=i('<span class="shoppui-link"></span>').appendTo(t.moveHandle),t.linked=i('<input type="hidden" name="meta[options][v]['+r.index+"][options]["+t.index+'][linked]" class="linked" />').val(e.linked?e.linked:"off").appendTo(t.element).change(function(){"on"==i(this).val()?t.linkIcon.removeClass("hidden"):t.linkIcon.addClass("hidden")}).change(),t.selected=function(){t.element.hasClass("selected")?(n.find("ul li").removeClass("selected"),selectedMenuOption=!1):(n.find("ul li").removeClass("selected"),i(t.element).addClass("selected"),selectedMenuOption=t),l.change()},t.element.click(t.selected),productOptions[o]=t.label,t.label.blur(function(){updateVariationLabels()}),t.deleteButton.unbind("click"),t.deleteButton.click(function(){1==r.itemsElement.children().length?deleteVariationPrices([o],!0):deleteVariationPrices([o]),t.element.remove()}),s?addVariationPrices():addVariationPrices(o),n.dequeue().animate({scrollTop:n.prop("scrollHeight")-n.height()},200),t.label.click().focus().select().keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),t.label.blur(),a.focus())}),r.items.push(t)},r.items=new Array,e&&e.options?i.each(e.options,function(){r.addOption(this)}):(r.addOption(),r.addOption()),r.itemsElement.sortable({axis:"y",update:function(){orderVariationPrices()}}),r.element.unbind("click",r.click).click(function(){r.selected(),i(a).unbind("click").click(r.addOption)}),optionMenus[variationsidx++]=r,r.deleteButton.unbind("click").click(function(){var e=new Array;i(r.itemsElement).find("li").not(".ui-sortable-helper").find("input.id").each(function(t,n){e.push(i(n).val())}),deleteVariationPrices(e,!0),i(this).trigger("delete")}),e||(n.dequeue().animate({scrollTop:n.attr("scrollHeight")-n.height()},200),r.label.click().focus().select().keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),a.focus())}))}function buildVariations(){var e,i,t,n,a=jQuery,l=new Array,o=a("#variations-list ul"),r=o.length,s=r-1,d=new Array(o.length),c=new Array(o.length),u=0;for(o.each(function(e,i){c[e]=a(i).children().length,0==u?u=a(i).children().length:u*=a(i).children().length,d[e]=0}),e=0;e<u;e++){for(i=0;i<o.length;i++)t=a(o[i]).children("li").not(".ui-sortable-helper").children("input.id"),l[e]?l[e].push(a(t[d[i]]).val()):l[e]=[a(t[d[i]]).val()];if(++d[s]>=c[s])for(n=s;n>-1;n--)d[n]<c[n]||(d[n]=0,n-1>-1&&d[n-1]++)}return l}function addVariationPrices(e){if(!e){var i,t,n=jQuery,a=buildVariations(),l=n("#variations-pricing"),o=n(l).children(),r=!1;n(a).each(function(e,n){i=xorkey(n),t=xorkey(n.slice(0,n.length-1)),""==t&&(t=-1),Pricelines.row[i]||(Pricelines.row[t]?(Pricelines.row[i]=Pricelines.row[t],delete Pricelines.row[t],Pricelines.row[i].setOptions(n)):(0==o.length?Pricelines.add(n,{context:"variation"},"#variations-pricing"):Pricelines.add(n,{context:"variation"},Pricelines.row[xorkey(a[e-1])].row,"after"),r=!0))}),r&&Pricelines.updateVariationsUI()}}function deleteVariationPrices(e,i){var t,n,a,l,o,r=jQuery,s=buildVariations(),d=!1;r(s).each(function(s,c){for(n=xorkey(c),t=0;t<e.length;t++)c.indexOf(e[t])!=-1&&(a=new Array,r(c).each(function(i,n){n!=e[t]&&a.push(n)}),l=xorkey(a),i&&!Pricelines.row[l]?(0!=l?Pricelines.row[l]=Pricelines.row[n]:Pricelines.row[n].row.remove(),delete Pricelines.row[n],Pricelines.row[l]&&(Pricelines.row[l].setOptions(a),d=!0)):Pricelines.row[n]&&(o=r("#priceid-"+Pricelines.row[n].id).val(),""==r("#deletePrices").val()?r("#deletePrices").val(o):r("#deletePrices").val(r("#deletePrices").val()+","+o),Pricelines.remove(n)))}),d&&Pricelines.updateVariationsUI()}function optionMenuExists(e){if(!e)return!1;var i=jQuery,t=!1;return i.each(optionMenus,function(n,a){if(a&&i(a.label).val()==e)return t=n}),optionMenus[t]?optionMenus[t]:t}function optionMenuItemExists(e,i){if(!e||!e.items||!i)return!1;var t=jQuery,n=!1;return t.each(e.items,function(e,a){if(a&&t(a.label).val()==i)return n=!0}),n}function updateVariationLabels(){var e=jQuery,i=buildVariations();e(i).each(function(e,i){var t=xorkey(i);Pricelines.row[t]&&Pricelines.row[t].updateLabel()})}function orderOptions(e,i){var t=jQuery;t(e).find("ul li").not(".ui-sortable-helper").find("input.id").each(function(e,n){n&&t(optionMenus[t(n).val()].itemsElement).appendTo(i)}),orderVariationPrices()}function orderVariationPrices(){var e,i=jQuery,t=buildVariations();i(t).each(function(i,t){e=xorkey(t),e>0&&Pricelines.row[e]&&Pricelines.reorderVariation(e,t)}),Pricelines.updateVariationsUI("tabs")}function xorkey(e){e instanceof Array||(e=[e]);for(var i=0,t=0;t<e.length;t++)i^=7001*e[t];return i}function variationsToggle(){var e=jQuery,i=e(this),t=e("#variations"),n=e("#product-pricing");i.prop("checked")?(Pricelines.row[0]&&Pricelines.row[0].disable(),n.hide(),t.show()):(t.hide(),n.show(),Pricelines.row[0]&&Pricelines.row[0].enable())}function addonsToggle(){var e=jQuery,i=e(this),t=e("#addons");i.prop("checked")?t.show():t.hide()}function clearLinkedIcons(){jQuery("#variations-list input.linked").val("off").change()}function linkVariationsButton(){var e=jQuery;selectedMenuOption?"off"==selectedMenuOption.linked.val()?(Pricelines.allLinked()&&(clearLinkedIcons(),Pricelines.unlinkAll()),selectedMenuOption.linked.val("on").change(),Pricelines.linkVariations(selectedMenuOption.id.val())):(selectedMenuOption.linked.val("off").change(),Pricelines.unlinkVariations(selectedMenuOption.id.val())):(clearLinkedIcons(),Pricelines.allLinked()?Pricelines.unlinkAll():Pricelines.linkAll()),e(this).change()}function linkVariationsButtonLabel(){var e=jQuery;selectedMenuOption?"on"==selectedMenuOption.linked.val()?e(this).find("small").html(" "+UNLINK_VARIATIONS):e(this).find("small").html(" "+LINK_VARIATIONS):Pricelines.allLinked()?e(this).find("small").html(" "+UNLINK_ALL_VARIATIONS):e(this).find("small").html(" "+LINK_ALL_VARIATIONS)}function loadAddons(e,i){var t=jQuery;e&&(t.each(e,function(e,i){newAddonGroup(i)}),t.each(i,function(e,i){if("addon"==i.context){var t=addonOptionsGroup[i.options];Pricelines.add(i.options,this,"#addon-pricegroup-"+t)}}),Pricelines.updateVariationsUI())}function newAddonGroup(e){var i=jQuery,t=i("#addon-menu"),n=i("#addon-list"),a=i("#newAddonGroup"),l=i("#addAddonOption"),o=addon_group_idx,r=new NestedMenu(o,t,"meta[options][a]",ADDON_GROUP_DEFAULT,e,{target:n,type:"list"},{axis:"y",update:function(){orderAddonGroups()}});r.itemsElement.attr("id","addon-group-"+o),r.pricegroup=i('<div id="addon-pricegroup-'+o+'" />').appendTo("#addon-pricing"),r.pricegroupLabel=i("<label />").html("<h4>"+r.label.val()+"</h4>").prependTo(r.pricegroup),r.updatePriceLabel=function(){r.pricegroupLabel.html("<h4>"+r.label.val()+"</h4>")},r.label.blur(r.updatePriceLabel),r.addOption=function(e){var t,a,o=!1;e||(e=new Object),e.id?e.id>addonsidx&&(addonsidx=e.id):(o=!0,e.id=addonsidx),t=new NestedMenuOption(r.index,r.itemsElement,"meta[options][a]",NEW_OPTION_DEFAULT,e),addonsidx++,a=t.id.val(),t.selected=function(){t.element.hasClass("selected")?(n.find("ul li").removeClass("selected"),selectedMenuOption=!1):(n.find("ul li").removeClass("selected"),i(t.element).addClass("selected"),selectedMenuOption=t)},t.element.click(t.selected),productAddons[a]=t.label,t.label.blur(function(){Pricelines.row[a].updateLabel()}),t.deleteButton.unbind("click"),t.deleteButton.click(function(){var e=Pricelines.row[a].data.id,n=i("#deletePrices");e&&(""==n.val()?n.val(e):n.val(n.val()+","+e)),Pricelines.row[a].row.remove(),t.element.remove()}),o&&Pricelines.add(a,{context:"addon"},r.pricegroup),addonOptionsGroup[a]=r.index,r.items.push(t),n.dequeue().animate({scrollTop:n.attr("scrollHeight")-n.height()},200),t.label.click().focus().select().keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),t.label.blur(),l.focus())})},r.items=new Array,e&&e.options?i.each(e.options,function(){r.addOption(this)}):(r.addOption(),r.addOption()),r.itemsElement.sortable({axis:"y",update:function(){orderAddonPrices(r.index)}}),r.element.unbind("click",r.click),r.element.click(function(){r.selected(),i(l).unbind("click").click(r.addOption)}),addonGroups[addon_group_idx++]=r,r.deleteButton.unbind("click").click(function(){i("#addon-list #addon-group-"+r.index+" li").not(".ui-sortable-helper").find("input.id").each(function(e,t){var n,a=i(t).val(),l=i("#deletePrices");Pricelines.row[a]&&(n=Pricelines.row[a].data.id,n&&(""==l.val()?l.val(n):l.val(l.val()+","+n)),Pricelines.row[a].row.remove())}),r.deleteButton.trigger("delete"),r.pricegroup.remove(),r.element.remove()}),e||(t.dequeue().animate({scrollTop:t.attr("scrollHeight")-t.height()},200),r.label.click().focus().select().keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),r.label.blur(),a.focus())}))}function orderAddonGroups(){var e,i=jQuery;i("#addon-menu ul li").not(".ui-sortable-helper").find("input.id").each(function(t,n){e=addonGroups[i(n).val()],e.pricegroup.appendTo("#addon-pricing")})}function orderAddonPrices(e){var i=jQuery,t=addonGroups[e];i("#addon-list #addon-group-"+t.index+" li").not(".ui-sortable-helper").find("input.id").each(function(e,n){Pricelines.reorderAddon(i(n).val(),t.pricegroup)})}function readableFileSize(e){var i=new Array("bytes","KB","MB","GB"),t=1*e,n=0;if(0==t)return t;for(;t>1e3;)t/=1024,n++;return t.toFixed(2)+" "+i[n]}function addDetail(e){var i,t,n=jQuery,a=n("#details-menu"),l=n("#details-list"),o=detailsidx++,r=new NestedMenu(o,a,"details","Detail Name",e,{target:l});if(e&&e.options){t=n('<select name="details['+r.index+'][value]"></select>').appendTo(r.itemsElement),n("<option></option>").appendTo(t);for(i in e.options)n("<option>"+e.options[i].name+"</option>").appendTo(t);e&&e.value&&t.val(htmlentities(e.value))}else r.item=new NestedMenuContent(r.index,r.itemsElement,"details",e);e&&!e.add||(r.add=n('<input type="hidden" name="details['+r.index+'][new]" value="true" />').appendTo(r.element),a.dequeue().animate({scrollTop:a.attr("scrollHeight")-a.height()},200),r.label.click().focus().select(),r.item&&r.item.contents.keydown(function(e){var i=e.keyCode||e.which;9==i&&(e.preventDefault(),n("#addDetail").focus())}))}function ImageUploads(e,i){function t(){p("#browser-uploader").hide(),u.loaded=!0}function n(){p("#lightbox li").size()>0&&p("#lightbox").sortable({opacity:.8})}function a(e,i,t){return i==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED?void alert("You selected too many files to upload at one time. "+(0===t?"You have reached the upload limit.":"You may upload "+(t>1?"up to "+t+" files.":"only one file."))):void alert(t)}function l(e,i){try{this.startUpload()}catch(e){this.debug(e)}}function o(e){this.targetHolder=p('<li class="image uploading"><input type="hidden" name="images[]" /><div class="progress"><div class="bar"></div><div class="gloss"></div></div></li>').appendTo(p("#lightbox")),this.progressBar=this.targetHolder.find("div.bar"),this.sorting=this.targetHolder.find("input")}function r(e,i,t){this.progressBar.animate({width:Math.ceil(i/t*76)+"px"},100)}function s(e,i,t){}function d(e,i){var t,a,l=!1,o=this.targetHolder;try{l=p.parseJSON(i)}catch(e){return o.remove(),alert(i),!1}return l.id?(o.attr({id:"image-"+l.id}),this.sorting.val(l.id),t=p('<img src="?siid='+l.id+'" width="96" height="96" class="handle" />').appendTo(o).hide(),a=p('<button type="button" name="deleteImage" value="'+l.id+'" class="delete"><span class="shoppui-minus"></span></button>').appendTo(o).hide(),n(),void this.progressBar.animate({width:"76px"},250,function(){p(this).parent().fadeOut(500,function(){p(this).remove(),p(t).fadeIn("500"),c(a)})})):(o.remove(),l.error?alert(l.error):alert(UNKNOWN_UPLOAD_ERROR),!0)}function c(e){e.hide(),e.parent().hover(function(){e.show()},function(){e.hide()}),e.click(function(){if(confirm(DELETE_IMAGE_WARNING)){var i="<"==e.val().substr(0,1)?e.find("input[name=ieisstupid]").val():e.val(),t=p("#deleteImages"),n=t.val();t.val(""==n?i:n+","+i),p("#confirm-delete-images").show(),e.parent().fadeOut(500,function(){p(this).remove()})}})}var u,p=jQuery,h={button_text:ADD_IMAGE_BUTTON_TEXT,button_text_style:'.buttonText{text-align:center;font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,_sans;font-size:9px;color:#333333;}',button_text_top_padding:3,button_height:"18",button_width:"100",button_image_url:uidir+"/icons/buttons.png",button_placeholder_id:"swf-uploader-button",upload_url:ajaxurl,flash_url:uidir+"/behaviors/swfupload.swf",file_queue_limit:0,file_size_limit:filesizeLimit+"b",file_types:"*.jpg;*.jpeg;*.png;*.gif",file_types_description:"Web-compatible Image Files",file_upload_limit:filesizeLimit,post_params:{action:"shopp_upload_image",parent:e,type:i},swfupload_loaded_handler:t,file_queue_error_handler:a,file_dialog_complete_handler:l,upload_start_handler:o,upload_progress_handler:r,upload_error_handler:s,upload_success_handler:d,custom_settings:{loaded:!1,targetHolder:!1,progressBar:!1,sorting:!1},prevent_swf_caching:p.ua.msie,debug:imageupload_debug};flashuploader&&(u=new SWFUpload(h)),p("#image-upload").upload({name:"Filedata",action:ajaxurl,params:{action:"shopp_upload_image",type:i},onSubmit:function(){this.targetHolder=p('<li id="image-uploading"><input type="hidden" name="images[]" value="" /><div class="progress"><div class="bar"></div><div class="gloss"></div></div></li>').appendTo("#lightbox"),this.progressBar=this.targetHolder.find("div.bar"),this.sorting=this.targetHolder.find("input")},onComplete:function(e){var i,t,n=!1,a=this.targetHolder;try{n=p.parseJSON(e)}catch(i){n.error=e}return n&&n.id?(a.attr({id:"image-"+n.id}),this.sorting.val(n.id),i=p('<img src="?siid='+n.id+'" width="96" height="96" class="handle" />').appendTo(a).hide(),t=p('<button type="button" name="deleteImage" value="'+n.src+'" class="delete"><span class="shoppui-minus"></span></button>').appendTo(p(a)).hide(),void p(this.progressBar).animate({width:"76px"},250,function(){p(this).parent().fadeOut(500,function(){p(this).remove(),p(i).fadeIn("500"),c(t)})})):(a.remove(),n.error?alert(n.error):alert(UNKNOWN_UPLOAD_ERROR),!1)}}),p(document).load(function(){u.loaded||p("#product-images .swfupload").remove()}),n(),p("#lightbox li").each(function(){p(this).dblclick(function(){var e=p(this).attr("id")+"-details",i=p("#"+e),t=i.find("input[type=hidden]").val(),n=i.find("img"),a=i.find("input.imagetitle"),l=i.find("input.imagealt"),o=i.find("input.imagecropped"),r=p('<div class="image-details-editor"><div class="details-editor"><img class="thumb" width="96" height="96" /><div class="details"><p><label>'+IMAGE_DETAILS_TITLE_LABEL+': </label><input type="text" name="title" /></p><p><label>'+IMAGE_DETAILS_ALT_LABEL+': </label><input type="text" name="alt" /></p></div></div><div class="cropping"><p class="clear">'+IMAGE_DETAILS_CROP_LABEL+': <select name="cropimage"><option></option></select></p><div class="cropui"></div><br class="clear"/></div><input type="button" class="button-primary alignright" value=" '+IMAGE_DETAILS_DONE+' " /></div>'),s=(r.find("img").attr("src",n.attr("src")),r.find("input[name=title]").val(a.val()).change(function(){a.val(s.val())})),d=r.find("input[name=alt]").val(l.val()).change(function(){l.val(d.val())}),c=(r.find("input[type=button]").click(function(){p.colorbox.close()}),r.find("div.cropping").hide()),u=r.find("div.cropui"),h=r.find("select[name=cropimage]").change(function(){if(""==h.val())return u.empty(),void p.colorbox.resize();var e=h.val().split(":"),i=o.filter("input[alt="+h.val()+"]").val().split(",");u.empty().scaleCrop({imgsrc:"?siid="+t,target:{width:parseInt(e[0],10),height:parseInt(e[1],10)},init:{x:parseInt(i[0],10),y:parseInt(i[1],10),s:new Number(i[2])}}).ready(function(){var i=125;p.colorbox.resize({innerWidth:parseInt(e[0],10)+i})}).bind("change.scalecrop",function(e,i){i.s||(i.s=1),i&&o.filter("input[alt="+h.val()+"]").val(i.x+","+i.y+","+i.s)})});o.size()>0&&(o.each(function(e,i){var t=p(i).attr("alt");p('<option value="'+t+'">'+(e+1)+": "+t.replace(":","×")+"</option>").appendTo(h)}),c.show()),p.colorbox({title:IMAGE_DETAILS_TEXT,html:r})}),c(p(this).find("button.delete"))})}function FileUploader(e,i){function t(){s(i).hide(),this.loaded=!0}function n(e,i,t){return i==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED?void alert("You selected too many files to upload at one time. "+(0===t?"You have reached the upload limit.":"You may upload "+(t>1?"up to "+t+" files.":"only one file."))):void alert(t)}function a(e,i){if(s.colorbox.hide(),e)try{this.startUpload()}catch(e){this.debug(e)}}function l(e){this.targetCell.attr("class","").html(""),s('<div class="progress"><div class="bar"></div><div class="gloss"></div></div>').appendTo(this.targetCell),this.progressBar=this.targetCell.find("div.bar")}function o(e,i,t){this.progressBar.animate({width:Math.ceil(i/t*76)+"px"},100)}function r(e,i){var t=!1,n=this.targetCell,a=this.targetLine;s.colorbox.close();try{t=s.parseJSON(i)}catch(e){t.error=i}return t.id||t.name?(t.type=t.type.replace(/\//gi," "),void s(this.progressBar).animate({width:"76px"},250,function(){s(this).parent().fadeOut(500,function(){s(this).remove(),s(n).attr("class","file").html('<div class="icon shoppui-file '+t.type+'"></div>'+t.name+"<br /><small>"+readableFileSize(t.size)+'</small><input type="hidden" name="price['+a+'][download]" value="'+t.id+'" />')})})):(n.html(NO_DOWNLOAD),t.error?alert(t.error):alert(UNKNOWN_UPLOAD_ERROR),!1)}var s=jQuery,d=this;d.swfu=!1,d.settings={button_text:UPLOAD_FILE_BUTTON_TEXT,button_text_style:'.buttonText{text-align:center;font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,_sans;font-size:9px;color:#333333; }',button_text_top_padding:3,button_height:"22",button_width:"100",button_image_url:uidir+"/icons/buttons.png",button_placeholder_id:e,button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,flash_url:uidir+"/behaviors/swfupload.swf",upload_url:ajaxurl,file_queue_limit:1,file_size_limit:filesizeLimit+"b",file_types:"*.*",file_types_description:"All Files",file_upload_limit:filesizeLimit,post_params:{action:"shopp_upload_file"},swfupload_loaded_handler:t,file_queue_error_handler:n,file_dialog_complete_handler:a,upload_start_handler:l,upload_progress_handler:o,upload_success_handler:r,custom_settings:{loaded:!1,targetCell:!1,targetLine:!1,progressBar:!1},prevent_swf_caching:s.ua.msie,debug:fileupload_debug},flashuploader&&(d.swfu=new SWFUpload(d.settings)),i.upload({name:"Filedata",action:ajaxurl,params:{action:"shopp_upload_file"},onSubmit:function(){s.colorbox.hide(),d.targetCell.attr("class","").html(""),s('<div class="progress"><div class="bar"></div><div class="gloss"></div></div>').appendTo(d.targetCell),d.progressBar=d.targetCell.find("div.bar")},onComplete:function(e){s.colorbox.close();var i=!1,t=d.targetCell;try{i=s.parseJSON(e)}catch(t){i.error=e}return i.id||i.name?(i.type=i.type.replace(/\//gi," "),void s(d.progressBar).animate({width:"76px"},250,function(){s(this).parent().fadeOut(500,function(){t.attr("class","file").html('<div class="icon shoppui-file '+i.type+'"></div>'+i.name+"<br /><small>"+readableFileSize(i.size)+'</small><input type="hidden" name="price['+d.targetLine+'][download]" value="'+i.id+'" />'),s(this).remove()})})):(t.html(NO_DOWNLOAD),i.error?alert(i.error):alert(UNKNOWN_UPLOAD_ERROR),!1)}}),s(d).load(function(){d.swfu&&d.swfu.loaded||s(i).parent().parent().find(".swfupload").remove()}),d.updateLine=function(e,i){d.swfu?(d.swfu.targetLine=e,d.swfu.targetCell=i):(d.targetLine=e,d.targetCell=i)}}function SlugEditor(e,i){var t=jQuery,n=this,a=t("#edit-slug-buttons"),l=a.find(".edit"),o=a.find(".view"),r=t("#editor-slug-buttons"),s=r.find(".save"),d=r.find(".cancel"),c=t("#editable-slug-full");n.permalink=function(){var n,l=0,u=t("#editable-slug"),p=u.html(),h=t("#slug_input"),f=h.html(),m=c.html();for(a.hide(),r.show(),s.unbind("click").click(function(){var n=u.children("input").val(),l=t("#title").val();t.post(editslug_url+"&action=shopp_edit_slug",{id:e,type:i,slug:n,title:l},function(e){u.html(p),e!=-1&&(u.html(e),c.html(e),h.val(e)),o.attr("href",canonurl+c.html()),r.hide(),a.show()},"text")}),d.unbind("click").click(function(){u.html(p),r.hide(),a.show(),h.attr("value",f)}),n=0;n<m.length;++n)"%"==m.charAt(n)&&l++;slug_value=l>m.length/4?"":m,u.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(e){var i=e.which;13!=i&&27!=i||e.preventDefault(),13==i&&s.click(),27==i&&d.click(),h.val(this.value)}).focus()},l.click(n.permalink)}jQuery.fn.FileChooser=function(e,i){var t=jQuery,n=this,a=t("#chooser"),l=a.find(".fileimport"),o=a.find(".status"),r=t("#attach-file"),s=t("#download_path-"+e),d=t("#download_file-"+e),c=t("#file-"+e),u=!1,p=0;n.line=e,n.status=i,a.unbind("change").on("change",".fileimport",function(e){o.attr("class","status").addClass("shoppui-spinner shoppui-spinfx shoppui-spinfx-steps8"),t.ajax({url:fileverify_url+"&action=shopp_verify_file&t=download",type:"POST",data:"url="+l.val(),timeout:1e4,dataType:"text",success:function(e){return o.attr("class","status"),"OK"==e?o.addClass("shoppui-ok-sign"):("NULL"==e&&o.attr("title",FILE_NOT_FOUND_TEXT),"ISDIR"==e&&o.attr("title",FILE_ISDIR_TEXT),"READ"==e&&o.attr("title",FILE_NOT_READ_TEXT),void o.addClass("shoppui-warning-sign"))}})}),l.unbind("keydown").unbind("keypress").suggest(sugg_url+"&action=shopp_storage_suggestions&t=download",{delay:500,minchars:3,multiple:!1,onSelect:function(){l.trigger("change")}}),t(this).click(function(){fileUploads.updateLine(e,i),o.attr("class","status"),r.unbind("click").click(function(){if(t.colorbox.hide(),u)return s.val(l.val()),l.val("").attr("class","fileimport"),!0;var i=!1,n=l.val(),a=function(e){return e.name?(c.attr("class","file").html('<span class="icon shoppui-file '+e.mime.replace("/"," ")+'"></span>'+e.name+"<br /><small>"+readableFileSize(e.size)+"</small>"),s.val(e.path),d.val(e.name),void l.val("").attr("class","fileimport")):$this.attr("class","")},o=function(){var n=c.find("div.progress"),l=n.find("div.bar"),r=n.outerWidth(),s=t("#import-file-"+e).get(0).contentWindow,d=s.importProgress,u=s.importFile;if(void 0!==u){if(u.error)return c.attr("class","error").html("<small>"+u.error+"</small>");if(!u.path)return c.attr("class","error").html("<small>"+FILE_UNKNOWN_IMPORT_ERROR+"</small>");if(u.stored)return a(u);savepath=u.path.split("/"),i=savepath[savepath.length-1]}return d||(d=0),0===d&&p++>60?c.attr("class","error").html("<small>"+FILE_UNKNOWN_IMPORT_ERROR+"</small>"):(l.animate({width:Math.ceil(d*r)+"px"},100),1==d?void(l&&l.css({width:"100%"}).fadeOut(500,function(){a(u)})):void setTimeout(o,100))};setTimeout(o,100),c.attr("class","").html('<div class="progress"><div class="bar"></div><div class="gloss"></div></div><iframe id="import-file-'+e+'" width="0" height="0" src="'+fileimport_url+"&action=shopp_import_file&url="+n+'"></iframe>')})}),t(this).colorbox({title:"File Selector",innerWidth:"360",innerHeight:"140",inline:!0,href:a})}; -
shopp/trunk/core/ui/behaviors/priceline.min.js
r1473303 r1648469 1 function Pricelines(){var e=jQuery,i=this;i.idx=0,i.row=new Object,i.variations=new Array,i.addons=new Array,i.linked=new Array,i.add=function(n,t,a,l){t||(t={context:"product"});var o,r,s,p;"variation"==t.context?(o=xorkey(n),r=new Priceline(i.idx,n,t,a,l),i.row[o]=r,l?(s=parseInt(a.optionkey.val(),10),p=e.inArray(s,i.variations),p!=-1&&("before"==l?i.variations.splice(p,0,xorkey(r.options)):i.variations.splice(p+1,0,xorkey(r.options)))):i.variations.push(xorkey(r.options))):"addon"==t.context?(r=new Priceline(i.idx,n,t,a,l),i.row[n]=r):"product"==t.context&&(r=new Priceline(0,n,t,a,l),i.row[0]=r),e("#prices").val(i.idx++)},i.exists=function(e){return!!i.row[e]},i.remove=function(n){var t=e.inArray(n,i.variations);t!=-1&&i.variations.splice(t,1),i.row[n].row.remove(),delete i.row[n]},i.reorderVariation=function(n,t){var a=i.row[n],l=e.inArray(n,i.variations);a.row.appendTo("#variations-pricing"),a.setOptions(t),l!=-1&&(i.variations.splice(l,1),i.variations.push(xorkey(a.options)))},i.reorderAddon=function(e,n){var t=i.row[e];t.row.appendTo(n)},i.updateVariationsUI=function(n){var t,a,l,o;for(t in i.variations)if(a=i.variations[t],Pricelines.row[a]){if(l=Pricelines.row[a],l.updateTabIndex(t),!n||"tabs"!=n){l.unlinkInputs();for(o in i.linked)e.inArray(o,i.row[a].options)!=-1&&(i.linked[o][a]||i.linked[o].push(a),i.row[a].linkInputs(o))}}else delete i.variations[t]},i.linkVariations=function(n){if(n)for(var t in i.row)e.inArray(n.toString(),i.row[t].options)!=-1&&(i.linked[n]||(i.linked[n]=new Array),i.linked[n].push(t),i.row[t].linkInputs(n))},i.unlinkVariations=function(e){if(e&&i.linked[e]){for(var n in i.linked[e])i.row[i.linked[e][n]]&&i.row[i.linked[e][n]].unlinkInputs(e);i.linked.splice(e,1)}},i.unlinkAll=function(){for(var e in i.row)i.row[e].unlinkInputs();i.linked.splice(0,1)},i.updateVariationLinks=function(){if(i.linked){var e,n;for(e in i.row)i.row[e].unlinkInputs();for(n in i.linked)i.linked[n]=!1,i.linkVariations(n)}},i.allLinked=function(){return!!i.linked[0]},i.linkAll=function(){i.unlinkAll(),i.linked=new Array,i.linked[0]=new Array;for(var e in i.row)0!=e&&(i.linked[0].push(e),i.row[e].linkInputs(0))}}function Priceline(e,i,n,t,a){var l,o,r,s,p,d,c,u,h,v,f,b,m,g,w=jQuery,y=this,k=template,L=Pricelines,T="";y.id=e,y.options=i,y.data=n,y.label=!1,y.links=new Array,y.inputs=new Array,y.lasttype=!1,l=y.id,o="price["+l+"]",y.row=w('<div id="row-'+l+'" class="priceline" />'),"after"==a?y.row.insertAfter(t):"before"==a?y.row.insertBefore(t):y.row.appendTo(t),r=w('<div class="pricing-label" />').appendTo(y.row),s=w('<label for="label-'+l+'" />').appendTo(r),y.label=w('<input type="hidden" name="price['+l+'][label]" id="label-'+l+'" />').appendTo(r),w(y.row).on("change.label","#label-"+l,function(){s.text(w(this).val())}),n.id||(n.id=""),n.product||(n.product=product),n.donation||(n.donation={ "var":!1,min:!1}),n.dimensions||(n.dimensions={weight:0,height:0,width:0,length:0}),w('<input type="hidden" name="'+o+'[id]" id="priceid-'+l+'" value="'+n.id+'" /><input type="hidden" name="'+o+'[product]" id="product-'+l+'" value="'+n.product+'" /><input type="hidden" name="'+o+'[context]" id="context-'+l+'"/><input type="hidden" name="'+o+'[optionkey]" id="optionkey-'+l+'" class="optionkey" /><input type="hidden" name="'+o+'[options]" id="options-'+l+'" value="" /><input type="hidden" name="sortorder[]" id="sortorder-'+l+'" value="'+l+'" />').appendTo(r),p=w("#priceid-"+l),d=w("#context-"+l),c=w("#options-"+l),u=w("#sortorder-"+l),h=w("#optionkey-"+l),y.row.optionkey=h,w(priceTypes).each(function(e,i){"addon"==n.context&&"Subscription"==i.label||(T+='<option value="'+i.value+'">'+i.label+"</option>")}),v=w('<select name="price['+l+'][type]" id="type-'+l+'"></select>').html(T).appendTo(r),n&&n.label&&(y.label.val(htmlentities(n.label)).change(),v.val(n.type)),f=w('<div class="pricing-ui clear" />').appendTo(y.row),b=w("<table/>").addClass("pricing-table").appendTo(f),m=w("<tr/>").appendTo(b),g=w("<tr/>").appendTo(b),y.price=function(e,i){var n,t;n=w('<th><label for="price-'+l+'">'+PRICE_LABEL+"</label></th>").appendTo(m),t=w('<td><input type="text" name="'+o+'[price]" id="price-'+l+'" value="0" size="10" class="selectall money right" /><br /><input type="hidden" name="'+o+'[tax]" value="on" /><input type="checkbox" name="'+o+'[tax]" id="tax-'+l+'" value="off" /><label for="tax-'+l+'"> '+NOTAX_LABEL+"</label><br /></td>").appendTo(g),y.p=w("#price-"+l).val(asMoney(new Number(e||0))),y.t=w("#tax-"+l).prop("checked","off"==i)},y.saleprice=function(e,i){var n,t,a;n=w('<th><input type="hidden" name="'+o+'[sale]" value="off" /><input type="checkbox" name="'+o+'[sale]" id="sale-'+l+'" value="on" /><label for="sale-'+l+'"> '+SALE_PRICE_LABEL+"</label></th>").appendTo(m),t=w('<td><span class="status">'+NOT_ON_SALE_TEXT+'</span><span class="ui"><input type="text" name="'+o+'[saleprice]" id="saleprice-'+l+'" size="10" class="selectall money right" /></span></td>').appendTo(g),a=t.find("span.status"),t=t.find("span.ui").hide(),y.sp=w("#saleprice-"+l).val(asMoney(new Number(i||0))),y.spt=w("#sale-"+l).prop("checked","on"==e),y.toggler(y.spt,a,t,y.sp)},y.donation=function(e,i,n,t){var a,r,s,p;a=w('<th><label for="price-'+l+'"> '+AMOUNT_LABEL+"</label></th>").appendTo(m),r=w('<td><input type="text" name="'+o+'[price]" id="price-'+l+'" value="0" size="10" class="selectall money right" /><br /><input type="hidden" name="'+o+'[tax]" value="on" /><input type="checkbox" name="'+o+'[tax]" id="tax-'+l+'" value="off" /><label for="tax-'+l+'"> '+NOTAX_LABEL+"</label><br /></td>").appendTo(g),y.p=w("#price-"+l).val(asMoney(new Number(e||0))),y.t=w("#tax-"+l).prop("checked","on"!=i),s=w("<th />").appendTo(m),p=w('<td width="80%"><input type="hidden" name="'+o+'[donation][var]" value="off" /><input type="checkbox" name="'+o+'[donation][var]" id="donation-var-'+l+'" value="on" /><label for="donation-var-'+l+'"> '+DONATIONS_VAR_LABEL+'</label><br /><input type="hidden" name="'+o+'[donation][min]" value="off" /><input type="checkbox" name="'+o+'[donation][min]" id="donation-min-'+l+'" value="on" /><label for="donation-min-'+l+'"> '+DONATIONS_MIN_LABEL+"</label><br /></td>").appendTo(g),y.dv=w("#donation-var-"+l).prop("checked","on"==n),y.dm=w("#donation-min-"+l).prop("checked","on"==t)},y.shipping=function(e,i,n){function t(){var e=0,i=0;c.find("input").each(function(n,t){w(t).hasClass("weight")?i=asNumber(t.value):0==e?e=asNumber(t.value):e*=asNumber(t.value)}),isNaN(e/i)||y.w.val(e/i).trigger("change.value")}function a(){y.w.toggleClass("extoggle"),c.toggle(),y.dw.focus(),t()}var r,s,p,d,c,u,h=getCurrencyFormat();h.precision="2",r=w('<th><input type="hidden" name="'+o+'[shipping]" value="off" /><input type="checkbox" name="'+o+'[shipping]" id="shipping-'+l+'" value="on" /><label for="shipping-'+l+'"> '+SHIPPING_LABEL+"</label></th>").appendTo(m),s=w('<td><span class="status">'+FREE_SHIPPING_TEXT+'</span><span class="ui"><input type="text" name="'+o+'[dimensions][weight]" id="weight-'+l+'" size="8" class="selectall right" /><label for="weight-'+l+'" id="weight-label-'+l+'" title="'+WEIGHT_LABEL+'"> '+WEIGHT_LABEL+(weightUnit?" ("+weightUnit+")":"")+'</label><br /><span class="dimui"></span><input type="text" name="'+o+'[shipfee]" id="shipfee-'+l+'" size="8" class="selectall money right" /><label for="shipfee-'+l+'" title="'+SHIPFEE_XTRA+'"> '+SHIPFEE_LABEL+"</label><br /></span></td>").appendTo(g),p=s.find("span.status"),d=s.find("span.ui").hide(),dui=s.find(".dimui"),y.w=w("#weight-"+l).val(formatNumber(new Number(i.weight||0),h,!0)),d.on("change.value","#weight-"+l,function(){this.value=formatNumber(isNaN(this.value)?0:this.value,h,!0)}),y.fee=w("#shipfee-"+l),y.fee.val(asMoney(new Number(n||0))),y.st=r.find("#shipping-"+l).prop("checked","off"!=e),y.toggler(y.st,p,d,y.w),dimensionsRequired&&(u=function(){$this.val(formatNumber($this.val(),h,!0))},w("#weight-label-"+l).html(" "+dimensionUnit+"<sup>3</sup>/"+weightUnit),c=w('<div class="dimensions"><div class="inline"><input type="text" name="'+o+'[dimensions][weight]" id="dimensions-weight-'+l+'" size="4" class="selectall right weight" />'+(weightUnit?"<label>"+weightUnit+" </label>":"")+'<br /><label for="dimensions-weight-'+l+'" title="'+WEIGHT_LABEL+'"> '+WEIGHT_LABEL+'</label></div><div class="inline"><input type="text" name="'+o+'[dimensions][length]" id="dimensions-length-'+l+'" size="4" class="selectall right" /><label> x </label><br /><label for="dimensions-length-'+l+'" title="'+LENGTH_LABEL+'"> '+LENGTH_LABEL+'</label></div><div class="inline"><input type="text" name="'+o+'[dimensions][width]" id="dimensions-width-'+l+'" size="4" class="selectall right" /><label> x </label><br /><label for="dimensions-width-'+l+'" title="'+WIDTH_LABEL+'"> '+WIDTH_LABEL+'</label></div><div class="inline"><input type="text" name="'+o+'[dimensions][height]" id="dimensions-height-'+l+'" size="4" class="selectall right" /><label>'+dimensionUnit+'</label><br /><label for="dimensions-height-'+l+'" title="'+HEIGHT_LABEL+'"> '+HEIGHT_LABEL+"</label></div></div>").hide().appendTo(dui),i instanceof Object||(i={weight:0,length:0,width:0,height:0}),c.on("change.value","input",u).trigger("change.value"),y.dw=w("#dimensions-weight-"+l).val(new Number(i.weight||0)),y.dl=w("#dimensions-length-"+l).val(new Number(i.length||0)),y.dwd=w("#dimensions-width-"+l).val(new Number(i.width||0)),y.dh=w("#dimensions-height-"+l).val(new Number(i.height||0)),y.st.change(function(){w(this).prop("checked")||c.hide()}),y.dh.blur(a),y.w.click(a).attr("readonly",!0),t())},y.inventory=function(e,i,n){var t,a,r;t=w('<th><input type="hidden" name="'+o+'[inventory]" value="off" /><input type="checkbox" name="'+o+'[inventory]" id="inventory-'+l+'" value="on" /><label for="inventory-'+l+'"> '+INVENTORY_LABEL+"</label></th>").appendTo(m),a=w('<td><span class="status"></span><input type="text" name="'+o+'[sku]" id="sku-'+l+'" size="8" title="'+SKU_XTRA+'" class="selectall" /><label for="sku-'+l+'" title="'+SKU_LABEL_HELP+'"> '+SKU_LABEL+'</label><br /><span class="ui"><input type="text" name="'+o+'[stocked]" id="stock-'+l+'" size="8" class="selectall right" /><label for="stock-'+l+'"> '+IN_STOCK_LABEL+"</label></span></td>").appendTo(g),r=a.find("span.status"),a=a.find("span.ui").hide(),y.stock=w("#stock-"+l).val(new Number(i||0)),a.on("change.value","#stock-"+l,function(){this.value=isNaN(this.value)?0:new Number(this.value).roundFixed(0)}),y.sku=w("#sku-"+l).val(n),y.it=t.find("#inventory-"+l).prop("checked","on"==e),y.toggler(y.it,r,a,y.stock)},y.download=function(e){var i,n,t,a;i=w('<th><label for="download-'+l+'">'+PRODUCT_DOWNLOAD_LABEL+"</label></th>").appendTo(m),n=w('<td width="31%"><input type="hidden" name="'+o+'[downloadpath]" id="download_path-'+l+'"/><input type="hidden" name="'+o+'[downloadfile]" id="download_file-'+l+'"/><div id="file-'+l+'" class="status">'+NO_DOWNLOAD+"</div></td>").appendTo(g),t=w('<td rowspan="2" class="controls" width="75"><button type="button" class="button-secondary" style="white-space: nowrap;" id="file-selector-'+l+'"><small>'+SELECT_FILE_BUTTON_TEXT+"…</small></button></td>").appendTo(m),y.file=w("#file-"+l),y.selector=w("#file-selector-"+l).FileChooser(l,y.file),e&&e.id&&(a=e.mime.replace("/"," "),y.file.attr("class","file").html('<div class="icon shoppui-file '+a+'"></div>'+e.name+"<br /><small>"+readableFileSize(e.size)+"</small>").click(function(){window.location.href=adminurl+"admin.php?src=download&shopp_download="+e.id}))},y.recurring=function(e){var i,n,t,a,r,s,p,d,c='<option value="0">∞</option>';for(s=1;s<31;s++)r+='<option value="'+s+'">'+s+"</option>",s>1&&(c+='<option value="'+s+'">'+s+"</option>");w(billPeriods[0]).each(function(e,i){p+='<option value="'+i.value+'">'+i.label+"</option>"}),w(billPeriods[1]).each(function(e,i){d+='<option value="'+i.value+'">'+i.label+"</option>"}),t=w('<th><input type="hidden" name="'+o+'[recurring][trial]" value="off" /><input type="checkbox" name="'+o+'[recurring][trial]" id="trial-'+l+'" /><label for="trial-'+l+'"> '+TRIAL_LABEL+"</label></th>").appendTo(m),a=w('<td><span class="status">'+NOTRIAL_TEXT+'</span><span class="ui"><select name="'+o+'[recurring][trialint]" id="trialint-'+l+'">'+r+'</select><select name="'+o+'[recurring][trialperiod]" id="trialperiod-'+l+'" class="period">'+p+'</select><br /><input type="text" name="'+o+'[recurring][trialprice]" id="trialprice-'+l+'" value="0" size="10" class="selectall money right" /><label for="trialprice-'+l+'"> '+PRICE_LABEL+"</label></span></td>").appendTo(g),i=w('<th><label for="billcycle-'+l+'"> '+BILLCYCLE_LABEL+"</label></th>").appendTo(m),n=w('<td><select name="'+o+'[recurring][interval]" id="interval-'+l+'">'+r+'</select><select name="'+o+'[recurring][period]" id="period-'+l+'" class="period">'+p+'</select><br /><select name="'+o+'[recurring][cycles]" id="cycles-'+l+'">'+c+'</select><label for="cycles'+l+'"> '+TIMES_LABEL+"</label></td>").appendTo(g),dis=a.find("span.status"),n=a.find("span.ui").hide(),e||(e={period:1,interval:"d",cycles:0,trialperiod:1,trialint:1,trialprice:0}),y.period=w("#period-"+l).val(e.period),y.interval=w("#interval-"+l).val(e.interval).change(function(){var e=w(this),i=y.period.val();1==e.val()?y.period.html(d):y.period.html(p),y.period.val(i)}).change(),y.cycles=w("#cycles-"+l).val(e.cycles),y.trialperiod=w("#trialperiod-"+l).val(e.trialperiod),y.trialint=w("#trialint-"+l).val(e.trialint).change(function(){var e=w(this),i=y.trialperiod.val();1==e.val()?y.trialperiod.html(d):y.trialperiod.html(p),y.trialperiod.val(i)}).change(),y.trialprice=w("#trialprice-"+l).val(asMoney(new Number(e.trialprice))),y.trial=t.find("#trial-"+l).prop("checked","on"==e.trial).toggler(dis,n,y.trialint)},y.toggler=function(e,i,n,t){e.parent().on("change.toggler",{toggle:e,off:i,ui:n,focal:t},function(e){var i=e.data.toggle,n=e.data.off,t=e.data.ui,a=e.data.focal;i.prop("checked")?(n.hide(),t.show(),a.select()):(n.show(),t.hide())}).trigger("change.toggler")},y.memberlevel=function(){var e,i,n,t;n=["Basic","Silver","Gold","Platinum"],w(n).each(function(e,i){t+='<option value="'+i+'">'+i+"</option>"}),e=w('<th><label for="membership-'+l+'"> '+MEMBERSHIP_LABEL+"</label></th>").appendTo(m),i=w('<td><select name="'+o+'[membership]" id="membership-'+l+'" class="membership">'+t+"</select></td>").appendTo(g)},y.Shipped=function(e){y.price(e.price,e.tax),y.saleprice(e._sale,e.saleprice),y.shipping(e.shipping,e.dimensions,e.shipfee),k||y.inventory(e.inventory,e.stock,e.sku)},y.Virtual=function(e){y.price(e.price,e.tax),y.saleprice(e.sale,e.saleprice),k||y.inventory(e.inventory,e.stock,e.sku)},y.Download=function(e){y.price(e.price,e.tax),y.saleprice(e.sale,e.saleprice),k||y.download(e.download)},y.Donation=function(e){y.donation(e.price,e.tax,e.donation["var"],e.donation.min)},y.Subscription=function(e){y.price(e.price,e.tax),y.saleprice(e.sale,e.saleprice),y.recurring(e.recurring)},y.Membership=function(e){y.price(e.price,e.tax),y.saleprice(e.sale,e.saleprice),y.recurring(),k||y.memberlevel()},v.on("change.value",function(){m.empty(),g.empty();var e=v.val();"Shipped"==e&&y.Shipped(n),"Virtual"==e&&y.Virtual(n),"Download"==e&&y.Download(n),"Donation"==e&&y.Donation(n),"Subscription"==e&&y.Subscription(n),"Membership"==e&&y.Membership(n),moneyInputs(g),quickSelects(g)}).trigger("change.value"),y.disable=function(){y.lasttype=!!v.val()&&v.val(),v.val("N/A").trigger("change.value")},y.enable=function(){y.lasttype&&v.val(y.lasttype).trigger("change.value")},n&&n.context?d.val(n.context):d.val("product"),y.setOptions=function(e){var i=!1;e&&(e!=y.options&&(i=!0),y.options=e),"variation"==d.val()&&h.val(xorkey(y.options)),i&&y.updateLabel()},y.updateKey=function(){h.val(xorkey(y.options))},y.updateLabel=function(){var e=d.val(),i="",n="";y.options&&("variation"==e&&w(y.options).each(function(e,t){""==i?i=w(productOptions[t]).val():i+=", "+w(productOptions[t]).val(),""==n?n=t:n+=","+t}),"addon"==e&&(i=w(productAddons[y.options]).val(),n=y.options)),""==i&&(i=DEFAULT_PRICELINE_LABEL),y.label.val(htmlentities(i)).trigger("change.label"),c.val(n)},y.updateTabIndex=function(e){e=new Number(e),w.each(y.inputs,function(i,n){w(n).attr("tabindex",100*(e+1)+i)})},y.linkInputs=function(e){y.links.push(e),w.each(y.inputs,function(e,i){if(i){var n="change.linkedinputs",t=w(i);"checkbox"==t.attr("type")&&(n="click.linkedinputs"),w(i).bind(n,function(){var i=w(this).val(),n=w(this).attr("checked");w.each(y.links,function(a,l){w.each(L.linked[l],function(a,l){l!=xorkey(y.options)&&L.row[l]&&("checkbox"==t.attr("type")?w(L.row[l].inputs[e]).attr("checked",n):w(L.row[l].inputs[e]).val(i),w(L.row[l].inputs[e]).trigger("change.value"))})})})}})},y.unlinkInputs=function(e){e!==!1&&(index=w.inArray(e,y.links),y.links.splice(index,1)),w.each(y.inputs,function(e,i){if(i){var n="blur.linkedinputs";"checkbox"==w(i).attr("type")&&(n="click.linkedinputs"),w(i).unbind(n)}})},"N/A"!=v.val()&&(y.inputs=new Array(v,y.p,y.t,y.spt,y.sp,y.dv,y.dm,y.st,y.w,y.dw,y.dl,y.dwd,y.dh,y.fee,y.it,y.stock,y.sku,y.period,y.interval,y.cycles,y.trialperiod,y.trialint,y.trialprice,y.trial)),y.updateKey(),y.updateLabel()}jQuery.fn.toggler=function(e,i,n){var t=jQuery,a=t(this);return a.closest("tr").on("change.toggle",a,function(){a.prop("checked")?(e.hide(),i.show()):(e.show(),i.hide())}).trigger("change.toggle"),this};1 function Pricelines(){var e=jQuery,i=this;i.idx=0,i.row=new Object,i.variations=new Array,i.addons=new Array,i.linked=new Array,i.add=function(n,t,a,l){t||(t={context:"product"});var o,r,s,p;"variation"==t.context?(o=xorkey(n),r=new Priceline(i.idx,n,t,a,l),i.row[o]=r,l?(s=parseInt(a.optionkey.val(),10),p=e.inArray(s,i.variations),p!=-1&&("before"==l?i.variations.splice(p,0,xorkey(r.options)):i.variations.splice(p+1,0,xorkey(r.options)))):i.variations.push(xorkey(r.options))):"addon"==t.context?(r=new Priceline(i.idx,n,t,a,l),i.row[n]=r):"product"==t.context&&(r=new Priceline(0,n,t,a,l),i.row[0]=r),e("#prices").val(i.idx++)},i.exists=function(e){return!!i.row[e]},i.remove=function(n){var t=e.inArray(n,i.variations);t!=-1&&i.variations.splice(t,1),i.row[n].row.remove(),delete i.row[n]},i.reorderVariation=function(n,t){var a=i.row[n],l=e.inArray(n,i.variations);a.row.appendTo("#variations-pricing"),a.setOptions(t),l!=-1&&(i.variations.splice(l,1),i.variations.push(xorkey(a.options)))},i.reorderAddon=function(e,n){var t=i.row[e];t.row.appendTo(n)},i.updateVariationsUI=function(n){var t,a,l,o;for(t in i.variations)if(a=i.variations[t],Pricelines.row[a]){if(l=Pricelines.row[a],l.updateTabIndex(t),!n||"tabs"!=n){l.unlinkInputs();for(o in i.linked)e.inArray(o,i.row[a].options)!=-1&&(i.linked[o][a]||i.linked[o].push(a),i.row[a].linkInputs(o))}}else delete i.variations[t]},i.linkVariations=function(n){if(n)for(var t in i.row)e.inArray(n.toString(),i.row[t].options)!=-1&&(i.linked[n]||(i.linked[n]=new Array),i.linked[n].push(t),i.row[t].linkInputs(n))},i.unlinkVariations=function(e){if(e&&i.linked[e]){for(var n in i.linked[e])i.row[i.linked[e][n]]&&i.row[i.linked[e][n]].unlinkInputs(e);i.linked.splice(e,1)}},i.unlinkAll=function(){for(var e in i.row)i.row[e].unlinkInputs();i.linked.splice(0,1)},i.updateVariationLinks=function(){if(i.linked){var e,n;for(e in i.row)i.row[e].unlinkInputs();for(n in i.linked)i.linked[n]=!1,i.linkVariations(n)}},i.allLinked=function(){return!!i.linked[0]},i.linkAll=function(){i.unlinkAll(),i.linked=new Array,i.linked[0]=new Array;for(var e in i.row)0!=e&&(i.linked[0].push(e),i.row[e].linkInputs(0))}}function Priceline(e,i,n,t,a){var l,o,r,s,p,d,c,u,h,v,f,b,m,g,w=jQuery,y=this,k=template,L=Pricelines,T="";y.id=e,y.options=i,y.data=n,y.label=!1,y.links=new Array,y.inputs=new Array,y.lasttype=!1,l=y.id,o="price["+l+"]",y.row=w('<div id="row-'+l+'" class="priceline" />'),"after"==a?y.row.insertAfter(t):"before"==a?y.row.insertBefore(t):y.row.appendTo(t),r=w('<div class="pricing-label" />').appendTo(y.row),s=w('<label for="label-'+l+'" />').appendTo(r),y.label=w('<input type="hidden" name="price['+l+'][label]" id="label-'+l+'" />').appendTo(r),w(y.row).on("change.label","#label-"+l,function(){s.text(w(this).val())}),n.id||(n.id=""),n.product||(n.product=product),n.donation||(n.donation={var:!1,min:!1}),n.dimensions||(n.dimensions={weight:0,height:0,width:0,length:0}),w('<input type="hidden" name="'+o+'[id]" id="priceid-'+l+'" value="'+n.id+'" /><input type="hidden" name="'+o+'[product]" id="product-'+l+'" value="'+n.product+'" /><input type="hidden" name="'+o+'[context]" id="context-'+l+'"/><input type="hidden" name="'+o+'[optionkey]" id="optionkey-'+l+'" class="optionkey" /><input type="hidden" name="'+o+'[options]" id="options-'+l+'" value="" /><input type="hidden" name="sortorder[]" id="sortorder-'+l+'" value="'+l+'" />').appendTo(r),p=w("#priceid-"+l),d=w("#context-"+l),c=w("#options-"+l),u=w("#sortorder-"+l),h=w("#optionkey-"+l),y.row.optionkey=h,w(priceTypes).each(function(e,i){"addon"==n.context&&"Subscription"==i.label||(T+='<option value="'+i.value+'">'+i.label+"</option>")}),v=w('<select name="price['+l+'][type]" id="type-'+l+'"></select>').html(T).appendTo(r),n&&n.label&&(y.label.val(htmlentities(n.label)).change(),v.val(n.type)),f=w('<div class="pricing-ui clear" />').appendTo(y.row),b=w("<table/>").addClass("pricing-table").appendTo(f),m=w("<tr/>").appendTo(b),g=w("<tr/>").appendTo(b),y.price=function(e,i){var n,t;n=w('<th><label for="price-'+l+'">'+PRICE_LABEL+"</label></th>").appendTo(m),t=w('<td><input type="text" name="'+o+'[price]" id="price-'+l+'" value="0" size="10" class="selectall money right" /><br /><input type="hidden" name="'+o+'[tax]" value="on" /><input type="checkbox" name="'+o+'[tax]" id="tax-'+l+'" value="off" /><label for="tax-'+l+'"> '+NOTAX_LABEL+"</label><br /></td>").appendTo(g),y.p=w("#price-"+l).val(asMoney(new Number(e||0))),y.t=w("#tax-"+l).prop("checked","off"==i)},y.saleprice=function(e,i){var n,t,a;n=w('<th><input type="hidden" name="'+o+'[sale]" value="off" /><input type="checkbox" name="'+o+'[sale]" id="sale-'+l+'" value="on" /><label for="sale-'+l+'"> '+SALE_PRICE_LABEL+"</label></th>").appendTo(m),t=w('<td><span class="status">'+NOT_ON_SALE_TEXT+'</span><span class="ui"><input type="text" name="'+o+'[saleprice]" id="saleprice-'+l+'" size="10" class="selectall money right" /></span></td>').appendTo(g),a=t.find("span.status"),t=t.find("span.ui").hide(),y.sp=w("#saleprice-"+l).val(asMoney(new Number(i||0))),y.spt=w("#sale-"+l).prop("checked","on"==e),y.toggler(y.spt,a,t,y.sp)},y.donation=function(e,i,n,t){var a,r,s,p;a=w('<th><label for="price-'+l+'"> '+AMOUNT_LABEL+"</label></th>").appendTo(m),r=w('<td><input type="text" name="'+o+'[price]" id="price-'+l+'" value="0" size="10" class="selectall money right" /><br /><input type="hidden" name="'+o+'[tax]" value="on" /><input type="checkbox" name="'+o+'[tax]" id="tax-'+l+'" value="off" /><label for="tax-'+l+'"> '+NOTAX_LABEL+"</label><br /></td>").appendTo(g),y.p=w("#price-"+l).val(asMoney(new Number(e||0))),y.t=w("#tax-"+l).prop("checked","on"!=i),s=w("<th />").appendTo(m),p=w('<td width="80%"><input type="hidden" name="'+o+'[donation][var]" value="off" /><input type="checkbox" name="'+o+'[donation][var]" id="donation-var-'+l+'" value="on" /><label for="donation-var-'+l+'"> '+DONATIONS_VAR_LABEL+'</label><br /><input type="hidden" name="'+o+'[donation][min]" value="off" /><input type="checkbox" name="'+o+'[donation][min]" id="donation-min-'+l+'" value="on" /><label for="donation-min-'+l+'"> '+DONATIONS_MIN_LABEL+"</label><br /></td>").appendTo(g),y.dv=w("#donation-var-"+l).prop("checked","on"==n),y.dm=w("#donation-min-"+l).prop("checked","on"==t)},y.shipping=function(e,i,n){function t(){var e=0,i=0;c.find("input").each(function(n,t){w(t).hasClass("weight")?i=asNumber(t.value):0==e?e=asNumber(t.value):e*=asNumber(t.value)}),isNaN(e/i)||y.w.val(e/i).trigger("change.value")}function a(){y.w.toggleClass("extoggle"),c.toggle(),y.dw.focus(),t()}var r,s,p,d,c,u,h=getCurrencyFormat();h.precision="2",r=w('<th><input type="hidden" name="'+o+'[shipping]" value="off" /><input type="checkbox" name="'+o+'[shipping]" id="shipping-'+l+'" value="on" /><label for="shipping-'+l+'"> '+SHIPPING_LABEL+"</label></th>").appendTo(m),s=w('<td><span class="status">'+FREE_SHIPPING_TEXT+'</span><span class="ui"><input type="text" name="'+o+'[dimensions][weight]" id="weight-'+l+'" size="8" class="selectall right" /><label for="weight-'+l+'" id="weight-label-'+l+'" title="'+WEIGHT_LABEL+'"> '+WEIGHT_LABEL+(weightUnit?" ("+weightUnit+")":"")+'</label><br /><span class="dimui"></span><input type="text" name="'+o+'[shipfee]" id="shipfee-'+l+'" size="8" class="selectall money right" /><label for="shipfee-'+l+'" title="'+SHIPFEE_XTRA+'"> '+SHIPFEE_LABEL+"</label><br /></span></td>").appendTo(g),p=s.find("span.status"),d=s.find("span.ui").hide(),dui=s.find(".dimui"),y.w=w("#weight-"+l).val(formatNumber(new Number(i.weight||0),h,!0)),d.on("change.value","#weight-"+l,function(){this.value=formatNumber(isNaN(this.value)?0:this.value,h,!0)}),y.fee=w("#shipfee-"+l),y.fee.val(asMoney(new Number(n||0))),y.st=r.find("#shipping-"+l).prop("checked","off"!=e),y.toggler(y.st,p,d,y.w),dimensionsRequired&&(u=function(){$this.val(formatNumber($this.val(),h,!0))},w("#weight-label-"+l).html(" "+dimensionUnit+"<sup>3</sup>/"+weightUnit),c=w('<div class="dimensions"><div class="inline"><input type="text" name="'+o+'[dimensions][weight]" id="dimensions-weight-'+l+'" size="4" class="selectall right weight" />'+(weightUnit?"<label>"+weightUnit+" </label>":"")+'<br /><label for="dimensions-weight-'+l+'" title="'+WEIGHT_LABEL+'"> '+WEIGHT_LABEL+'</label></div><div class="inline"><input type="text" name="'+o+'[dimensions][length]" id="dimensions-length-'+l+'" size="4" class="selectall right" /><label> x </label><br /><label for="dimensions-length-'+l+'" title="'+LENGTH_LABEL+'"> '+LENGTH_LABEL+'</label></div><div class="inline"><input type="text" name="'+o+'[dimensions][width]" id="dimensions-width-'+l+'" size="4" class="selectall right" /><label> x </label><br /><label for="dimensions-width-'+l+'" title="'+WIDTH_LABEL+'"> '+WIDTH_LABEL+'</label></div><div class="inline"><input type="text" name="'+o+'[dimensions][height]" id="dimensions-height-'+l+'" size="4" class="selectall right" /><label>'+dimensionUnit+'</label><br /><label for="dimensions-height-'+l+'" title="'+HEIGHT_LABEL+'"> '+HEIGHT_LABEL+"</label></div></div>").hide().appendTo(dui),i instanceof Object||(i={weight:0,length:0,width:0,height:0}),c.on("change.value","input",u).trigger("change.value"),y.dw=w("#dimensions-weight-"+l).val(new Number(i.weight||0)),y.dl=w("#dimensions-length-"+l).val(new Number(i.length||0)),y.dwd=w("#dimensions-width-"+l).val(new Number(i.width||0)),y.dh=w("#dimensions-height-"+l).val(new Number(i.height||0)),y.st.change(function(){w(this).prop("checked")||c.hide()}),y.dh.blur(a),y.w.click(a).attr("readonly",!0),t())},y.inventory=function(e,i,n){var t,a,r;t=w('<th><input type="hidden" name="'+o+'[inventory]" value="off" /><input type="checkbox" name="'+o+'[inventory]" id="inventory-'+l+'" value="on" /><label for="inventory-'+l+'"> '+INVENTORY_LABEL+"</label></th>").appendTo(m),a=w('<td><span class="status"></span><input type="text" name="'+o+'[sku]" id="sku-'+l+'" size="8" title="'+SKU_XTRA+'" class="selectall" /><label for="sku-'+l+'" title="'+SKU_LABEL_HELP+'"> '+SKU_LABEL+'</label><br /><span class="ui"><input type="text" name="'+o+'[stocked]" id="stock-'+l+'" size="8" class="selectall right" /><label for="stock-'+l+'"> '+IN_STOCK_LABEL+"</label></span></td>").appendTo(g),r=a.find("span.status"),a=a.find("span.ui").hide(),y.stock=w("#stock-"+l).val(new Number(i||0)),a.on("change.value","#stock-"+l,function(){this.value=isNaN(this.value)?0:new Number(this.value).roundFixed(0)}),y.sku=w("#sku-"+l).val(n),y.it=t.find("#inventory-"+l).prop("checked","on"==e),y.toggler(y.it,r,a,y.stock)},y.download=function(e){var i,n,t,a;i=w('<th><label for="download-'+l+'">'+PRODUCT_DOWNLOAD_LABEL+"</label></th>").appendTo(m),n=w('<td width="31%"><input type="hidden" name="'+o+'[downloadpath]" id="download_path-'+l+'"/><input type="hidden" name="'+o+'[downloadfile]" id="download_file-'+l+'"/><div id="file-'+l+'" class="status">'+NO_DOWNLOAD+"</div></td>").appendTo(g),t=w('<td rowspan="2" class="controls" width="75"><button type="button" class="button-secondary" style="white-space: nowrap;" id="file-selector-'+l+'"><small>'+SELECT_FILE_BUTTON_TEXT+"…</small></button></td>").appendTo(m),y.file=w("#file-"+l),y.selector=w("#file-selector-"+l).FileChooser(l,y.file),e&&e.id&&(a=e.mime.replace("/"," "),y.file.attr("class","file").html('<div class="icon shoppui-file '+a+'"></div>'+e.name+"<br /><small>"+readableFileSize(e.size)+"</small>").click(function(){window.location.href=adminurl+"admin.php?src=download&shopp_download="+e.id}))},y.recurring=function(e){var i,n,t,a,r,s,p,d,c='<option value="0">∞</option>';for(s=1;s<31;s++)r+='<option value="'+s+'">'+s+"</option>",s>1&&(c+='<option value="'+s+'">'+s+"</option>");w(billPeriods[0]).each(function(e,i){p+='<option value="'+i.value+'">'+i.label+"</option>"}),w(billPeriods[1]).each(function(e,i){d+='<option value="'+i.value+'">'+i.label+"</option>"}),t=w('<th><input type="hidden" name="'+o+'[recurring][trial]" value="off" /><input type="checkbox" name="'+o+'[recurring][trial]" id="trial-'+l+'" /><label for="trial-'+l+'"> '+TRIAL_LABEL+"</label></th>").appendTo(m),a=w('<td><span class="status">'+NOTRIAL_TEXT+'</span><span class="ui"><select name="'+o+'[recurring][trialint]" id="trialint-'+l+'">'+r+'</select><select name="'+o+'[recurring][trialperiod]" id="trialperiod-'+l+'" class="period">'+p+'</select><br /><input type="text" name="'+o+'[recurring][trialprice]" id="trialprice-'+l+'" value="0" size="10" class="selectall money right" /><label for="trialprice-'+l+'"> '+PRICE_LABEL+"</label></span></td>").appendTo(g),i=w('<th><label for="billcycle-'+l+'"> '+BILLCYCLE_LABEL+"</label></th>").appendTo(m),n=w('<td><select name="'+o+'[recurring][interval]" id="interval-'+l+'">'+r+'</select><select name="'+o+'[recurring][period]" id="period-'+l+'" class="period">'+p+'</select><br /><select name="'+o+'[recurring][cycles]" id="cycles-'+l+'">'+c+'</select><label for="cycles'+l+'"> '+TIMES_LABEL+"</label></td>").appendTo(g),dis=a.find("span.status"),n=a.find("span.ui").hide(),e||(e={period:1,interval:"d",cycles:0,trialperiod:1,trialint:1,trialprice:0}),y.period=w("#period-"+l).val(e.period),y.interval=w("#interval-"+l).val(e.interval).change(function(){var e=w(this),i=y.period.val();1==e.val()?y.period.html(d):y.period.html(p),y.period.val(i)}).change(),y.cycles=w("#cycles-"+l).val(e.cycles),y.trialperiod=w("#trialperiod-"+l).val(e.trialperiod),y.trialint=w("#trialint-"+l).val(e.trialint).change(function(){var e=w(this),i=y.trialperiod.val();1==e.val()?y.trialperiod.html(d):y.trialperiod.html(p),y.trialperiod.val(i)}).change(),y.trialprice=w("#trialprice-"+l).val(asMoney(new Number(e.trialprice))),y.trial=t.find("#trial-"+l).prop("checked","on"==e.trial).toggler(dis,n,y.trialint)},y.toggler=function(e,i,n,t){e.parent().on("change.toggler",{toggle:e,off:i,ui:n,focal:t},function(e){var i=e.data.toggle,n=e.data.off,t=e.data.ui,a=e.data.focal;i.prop("checked")?(n.hide(),t.show(),a.select()):(n.show(),t.hide())}).trigger("change.toggler")},y.memberlevel=function(){var e,i,n,t;n=["Basic","Silver","Gold","Platinum"],w(n).each(function(e,i){t+='<option value="'+i+'">'+i+"</option>"}),e=w('<th><label for="membership-'+l+'"> '+MEMBERSHIP_LABEL+"</label></th>").appendTo(m),i=w('<td><select name="'+o+'[membership]" id="membership-'+l+'" class="membership">'+t+"</select></td>").appendTo(g)},y.Shipped=function(e){y.price(e.price,e.tax),y.saleprice(e._sale,e.saleprice),y.shipping(e.shipping,e.dimensions,e.shipfee),k||y.inventory(e.inventory,e.stock,e.sku)},y.Virtual=function(e){y.price(e.price,e.tax),y.saleprice(e.sale,e.saleprice),k||y.inventory(e.inventory,e.stock,e.sku)},y.Download=function(e){y.price(e.price,e.tax),y.saleprice(e.sale,e.saleprice),k||y.download(e.download)},y.Donation=function(e){y.donation(e.price,e.tax,e.donation.var,e.donation.min)},y.Subscription=function(e){y.price(e.price,e.tax),y.saleprice(e.sale,e.saleprice),y.recurring(e.recurring)},y.Membership=function(e){y.price(e.price,e.tax),y.saleprice(e.sale,e.saleprice),y.recurring(),k||y.memberlevel()},v.on("change.value",function(){m.empty(),g.empty();var e=v.val();"Shipped"==e&&y.Shipped(n),"Virtual"==e&&y.Virtual(n),"Download"==e&&y.Download(n),"Donation"==e&&y.Donation(n),"Subscription"==e&&y.Subscription(n),"Membership"==e&&y.Membership(n),moneyInputs(g),quickSelects(g)}).trigger("change.value"),y.disable=function(){y.lasttype=!!v.val()&&v.val(),v.val("N/A").trigger("change.value")},y.enable=function(){y.lasttype&&v.val(y.lasttype).trigger("change.value")},n&&n.context?d.val(n.context):d.val("product"),y.setOptions=function(e){var i=!1;e&&(e!=y.options&&(i=!0),y.options=e),"variation"==d.val()&&h.val(xorkey(y.options)),i&&y.updateLabel()},y.updateKey=function(){h.val(xorkey(y.options))},y.updateLabel=function(){var e=d.val(),i="",n="";y.options&&("variation"==e&&w(y.options).each(function(e,t){""==i?i=w(productOptions[t]).val():i+=", "+w(productOptions[t]).val(),""==n?n=t:n+=","+t}),"addon"==e&&(i=w(productAddons[y.options]).val(),n=y.options)),""==i&&(i=DEFAULT_PRICELINE_LABEL),y.label.val(htmlentities(i)).trigger("change.label"),c.val(n)},y.updateTabIndex=function(e){e=new Number(e),w.each(y.inputs,function(i,n){w(n).attr("tabindex",100*(e+1)+i)})},y.linkInputs=function(e){y.links.push(e),w.each(y.inputs,function(e,i){if(i){var n="change.linkedinputs",t=w(i);"checkbox"==t.attr("type")&&(n="click.linkedinputs"),w(i).bind(n,function(){var i=w(this).val(),n=w(this).attr("checked");w.each(y.links,function(a,l){w.each(L.linked[l],function(a,l){l!=xorkey(y.options)&&L.row[l]&&("checkbox"==t.attr("type")?w(L.row[l].inputs[e]).attr("checked",n):w(L.row[l].inputs[e]).val(i),w(L.row[l].inputs[e]).trigger("change.value"))})})})}})},y.unlinkInputs=function(e){e!==!1&&(index=w.inArray(e,y.links),y.links.splice(index,1)),w.each(y.inputs,function(e,i){if(i){var n="blur.linkedinputs";"checkbox"==w(i).attr("type")&&(n="click.linkedinputs"),w(i).unbind(n)}})},"N/A"!=v.val()&&(y.inputs=new Array(v,y.p,y.t,y.spt,y.sp,y.dv,y.dm,y.st,y.w,y.dw,y.dl,y.dwd,y.dh,y.fee,y.it,y.stock,y.sku,y.period,y.interval,y.cycles,y.trialperiod,y.trialint,y.trialprice,y.trial)),y.updateKey(),y.updateLabel()}jQuery.fn.toggler=function(e,i,n){var t=jQuery,a=t(this);return a.closest("tr").on("change.toggle",a,function(){a.prop("checked")?(e.hide(),i.show()):(e.show(),i.hide())}).trigger("change.toggle"),this}; -
shopp/trunk/core/ui/behaviors/spin.min.js
r1473303 r1648469 1 !function(t,e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Spinner=e()}(this,function(){"use strict";function t(t,e){var i,n=document.createElement(t||"div");for(i in e)n[i]=e[i];return n}function e(t){for(var e=1,i=arguments.length;e<i;e++)t.appendChild(arguments[e]);return t}function i(t,e,i,n){var o=["opacity",e,~~(100*t),i,n].join("-"),r=.01+i/n*100,s=Math.max(1-(1-t)/e*(100-r),t),a=p.substring(0,p.indexOf("Animation")).toLowerCase(),l=a&&"-"+a+"-"||"";return d[o]||(c.insertRule("@"+l+"keyframes "+o+"{0%{opacity:"+s+"}"+r+"%{opacity:"+t+"}"+(r+.01)+"%{opacity:1}"+(r+e)%100+"%{opacity:"+t+"}100%{opacity:"+s+"}}",c.cssRules.length),d[o]=1),o}function n(t,e){var i,n,o=t.style;if(void 0!==o[e])return e;for(e=e.charAt(0).toUpperCase()+e.slice(1),n=0;n<f.length;n++)if(i=f[n]+e,void 0!==o[i])return i}function o(t,e){for(var i in e)t.style[n(t,i)||i]=e[i];return t}function r(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)void 0===t[n]&&(t[n]=i[n])}return t}function s(t){for(var e={x:t.offsetLeft,y:t.offsetTop};t=t.offsetParent;)e.x+=t.offsetLeft,e.y+=t.offsetTop;return e}function a(t){return"undefined"==typeof this?new a(t):void(this.opts=r(t||{},a.defaults,u))}function l(){function i(e,i){return t("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',i)}c.addRule(".spin-vml","behavior:url(#default#VML)"),a.prototype.lines=function(t,n){function r(){return o(i("group",{coordsize:p+" "+p,coordorigin:-l+" "+-l}),{width:p,height:p})}function s(t,s,a){e(d,e(o(r(),{rotation:360/n.lines*t+"deg",left:~~s}),e(o(i("roundrect",{arcsize:n.corners}),{width:l,height:n.width,left:n.radius,top:-n.width>>1,filter:a}),i("fill",{color:n.color,opacity:n.opacity}),i("stroke",{opacity:0}))))}var a,l=n.length+n.width,p=2*l,f=2*-(n.width+n.length)+"px",d=o(r(),{position:"absolute",top:f,left:f});if(n.shadow)for(a=1;a<=n.lines;a++)s(a,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(a=1;a<=n.lines;a++)s(a);return e(t,d)},a.prototype.opacity=function(t,e,i,n){var o=t.firstChild;n=n.shadow&&n.lines||0,o&&e+n<o.childNodes.length&&(o=o.childNodes[e+n],o=o&&o.firstChild,o=o&&o.firstChild,o&&(o.opacity=i))}}var p,f=["webkit","Moz","ms","O"],d={},c=function(){var i=t("style",{type:"text/css"});return e(document.getElementsByTagName("head")[0],i),i.sheet||i.styleSheet}(),u={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"auto",left:"auto",position:"relative"};a.defaults={},r(a.prototype,{spin:function(e){this.stop();var i,n,r=this,a=r.opts,l=r.el=o(t(0,{className:a.className}),{position:a.position,width:0,zIndex:a.zIndex}),f=a.radius+a.length+a.width;if(e&&(e.insertBefore(l,e.firstChild||null),n=s(e),i=s(l),o(l,{left:("auto"==a.left?n.x-i.x+(e.offsetWidth>>1):parseInt(a.left,10)+f)+"px",top:("auto"==a.top?n.y-i.y+(e.offsetHeight>>1):parseInt(a.top,10)+f)+"px"})),l.setAttribute("role","progressbar"),r.lines(l,r.opts),!p){var d,c=0,u=(a.lines-1)*(1-a.direction)/2,h=a.fps,y=h/a.speed,m=(1-a.opacity)/(y*a.trail/100),w=y/a.lines;!function g(){c++;for(var t=0;t<a.lines;t++)d=Math.max(1-(c+(a.lines-t)*w)%y*m,a.opacity),r.opacity(l,t*a.direction+u,d,a);r.timeout=r.el&&setTimeout(g,~~(1e3/h))}()}return r},stop:function(){var t=this.el;return t&&(clearTimeout(this.timeout),t.parentNode&&t.parentNode.removeChild(t),this.el=void 0),this},lines:function(n,r){function s(e,i){return o(t(),{position:"absolute",width:r.length+r.width+"px",height:r.width+"px",background:e,boxShadow:i,transformOrigin:"left",transform:"rotate("+~~(360/r.lines*l+r.rotate)+"deg) translate("+r.radius+"px,0)",borderRadius:(r.corners*r.width>>1)+"px"})}for(var a,l=0,f=(r.lines-1)*(1-r.direction)/2;l<r.lines;l++)a=o(t(),{position:"absolute",top:1+~(r.width/2)+"px",transform:r.hwaccel?"translate3d(0,0,0)":"",opacity:r.opacity,animation:p&&i(r.opacity,r.trail,f+l*r.direction,r.lines)+" "+1/r.speed+"s linear infinite"}),r.shadow&&e(a,o(s("#000","0 0 4px #000"),{top:"2px"})),e(n,e(a,s(r.color,"0 0 1px rgba(0,0,0,.1)")));return n},opacity:function(t,e,i){e<t.childNodes.length&&(t.childNodes[e].style.opacity=i)}});var h=o(t("group"),{behavior:"url(#default#VML)"});return!n(h,"transform")&&h.adj?l():p=n(h,"animation"),a}),function(t){if("object"==typeof exports)t(require("jquery"),require("spin"));else if("function"==typeof define&&define.amd)define(["jquery","spin"],t);else{if(!window.Spinner)throw new Error("Spin.js not present");t(window.jQuery,window.Spinner)}}(function(t,e){t.fn.spin=function(i,n){return this.each(function(){var o=t(this),r=o.data();r.spinner&&(r.spinner.stop(),delete r.spinner),i!==!1&&(i=t.extend({color:n||o.css("color")},t.fn.spin.presets[i]||i),r.spinner=new e(i).spin(this))})},t.fn.spin.presets={tiny:{lines:8,length:2,width:2,radius:3,className:"spin"},small:{lines:8,length:4,width:3,radius:5,className:"spin"},large:{lines:10,length:8,width:4,radius:8,className:"spin"}}});1 !function(t,e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Spinner=e()}(this,function(){"use strict";function t(t,e){var i,n=document.createElement(t||"div");for(i in e)n[i]=e[i];return n}function e(t){for(var e=1,i=arguments.length;e<i;e++)t.appendChild(arguments[e]);return t}function i(t,e,i,n){var o=["opacity",e,~~(100*t),i,n].join("-"),r=.01+i/n*100,s=Math.max(1-(1-t)/e*(100-r),t),a=p.substring(0,p.indexOf("Animation")).toLowerCase(),l=a&&"-"+a+"-"||"";return d[o]||(c.insertRule("@"+l+"keyframes "+o+"{0%{opacity:"+s+"}"+r+"%{opacity:"+t+"}"+(r+.01)+"%{opacity:1}"+(r+e)%100+"%{opacity:"+t+"}100%{opacity:"+s+"}}",c.cssRules.length),d[o]=1),o}function n(t,e){var i,n,o=t.style;if(void 0!==o[e])return e;for(e=e.charAt(0).toUpperCase()+e.slice(1),n=0;n<f.length;n++)if(i=f[n]+e,void 0!==o[i])return i}function o(t,e){for(var i in e)t.style[n(t,i)||i]=e[i];return t}function r(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)void 0===t[n]&&(t[n]=i[n])}return t}function s(t){for(var e={x:t.offsetLeft,y:t.offsetTop};t=t.offsetParent;)e.x+=t.offsetLeft,e.y+=t.offsetTop;return e}function a(t){return"undefined"==typeof this?new a(t):void(this.opts=r(t||{},a.defaults,u))}function l(){function i(e,i){return t("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',i)}c.addRule(".spin-vml","behavior:url(#default#VML)"),a.prototype.lines=function(t,n){function r(){return o(i("group",{coordsize:p+" "+p,coordorigin:-l+" "+-l}),{width:p,height:p})}function s(t,s,a){e(d,e(o(r(),{rotation:360/n.lines*t+"deg",left:~~s}),e(o(i("roundrect",{arcsize:n.corners}),{width:l,height:n.width,left:n.radius,top:-n.width>>1,filter:a}),i("fill",{color:n.color,opacity:n.opacity}),i("stroke",{opacity:0}))))}var a,l=n.length+n.width,p=2*l,f=2*-(n.width+n.length)+"px",d=o(r(),{position:"absolute",top:f,left:f});if(n.shadow)for(a=1;a<=n.lines;a++)s(a,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(a=1;a<=n.lines;a++)s(a);return e(t,d)},a.prototype.opacity=function(t,e,i,n){var o=t.firstChild;n=n.shadow&&n.lines||0,o&&e+n<o.childNodes.length&&(o=o.childNodes[e+n],o=o&&o.firstChild,o=o&&o.firstChild,o&&(o.opacity=i))}}var p,f=["webkit","Moz","ms","O"],d={},c=function(){var i=t("style",{type:"text/css"});return e(document.getElementsByTagName("head")[0],i),i.sheet||i.styleSheet}(),u={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"auto",left:"auto",position:"relative"};a.defaults={},r(a.prototype,{spin:function(e){this.stop();var i,n,r=this,a=r.opts,l=r.el=o(t(0,{className:a.className}),{position:a.position,width:0,zIndex:a.zIndex}),f=a.radius+a.length+a.width;if(e&&(e.insertBefore(l,e.firstChild||null),n=s(e),i=s(l),o(l,{left:("auto"==a.left?n.x-i.x+(e.offsetWidth>>1):parseInt(a.left,10)+f)+"px",top:("auto"==a.top?n.y-i.y+(e.offsetHeight>>1):parseInt(a.top,10)+f)+"px"})),l.setAttribute("role","progressbar"),r.lines(l,r.opts),!p){var d,c=0,u=(a.lines-1)*(1-a.direction)/2,h=a.fps,y=h/a.speed,m=(1-a.opacity)/(y*a.trail/100),w=y/a.lines;!function t(){c++;for(var e=0;e<a.lines;e++)d=Math.max(1-(c+(a.lines-e)*w)%y*m,a.opacity),r.opacity(l,e*a.direction+u,d,a);r.timeout=r.el&&setTimeout(t,~~(1e3/h))}()}return r},stop:function(){var t=this.el;return t&&(clearTimeout(this.timeout),t.parentNode&&t.parentNode.removeChild(t),this.el=void 0),this},lines:function(n,r){function s(e,i){return o(t(),{position:"absolute",width:r.length+r.width+"px",height:r.width+"px",background:e,boxShadow:i,transformOrigin:"left",transform:"rotate("+~~(360/r.lines*l+r.rotate)+"deg) translate("+r.radius+"px,0)",borderRadius:(r.corners*r.width>>1)+"px"})}for(var a,l=0,f=(r.lines-1)*(1-r.direction)/2;l<r.lines;l++)a=o(t(),{position:"absolute",top:1+~(r.width/2)+"px",transform:r.hwaccel?"translate3d(0,0,0)":"",opacity:r.opacity,animation:p&&i(r.opacity,r.trail,f+l*r.direction,r.lines)+" "+1/r.speed+"s linear infinite"}),r.shadow&&e(a,o(s("#000","0 0 4px #000"),{top:"2px"})),e(n,e(a,s(r.color,"0 0 1px rgba(0,0,0,.1)")));return n},opacity:function(t,e,i){e<t.childNodes.length&&(t.childNodes[e].style.opacity=i)}});var h=o(t("group"),{behavior:"url(#default#VML)"});return!n(h,"transform")&&h.adj?l():p=n(h,"animation"),a}),function(t){if("object"==typeof exports)t(require("jquery"),require("spin"));else if("function"==typeof define&&define.amd)define(["jquery","spin"],t);else{if(!window.Spinner)throw new Error("Spin.js not present");t(window.jQuery,window.Spinner)}}(function(t,e){t.fn.spin=function(i,n){return this.each(function(){var o=t(this),r=o.data();r.spinner&&(r.spinner.stop(),delete r.spinner),i!==!1&&(i=t.extend({color:n||o.css("color")},t.fn.spin.presets[i]||i),r.spinner=new e(i).spin(this))})},t.fn.spin.presets={tiny:{lines:8,length:2,width:2,radius:3,className:"spin"},small:{lines:8,length:4,width:3,radius:5,className:"spin"},large:{lines:10,length:8,width:4,radius:8,className:"spin"}}}); -
shopp/trunk/core/ui/behaviors/suggest.min.js
r1473303 r1648469 1 !function(e){e.suggest=function(t,l){function s(){var e=d.offset();v.css({top:e.top+d.outerHeight()+l.yoffset+"px",left:e.left+"px"})}function a(e){if(/27$|38$|40$/.test(e.keyCode)&&v.is(":visible")||/^13$|^9$/.test(e.keyCode)&&f())switch(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,e.keyCode){case 38:m();break;case 40:p();break;case 9:case 13:h();break;case 27:v.hide()}else g.val().length!=S&&(C&&clearTimeout(C),C=setTimeout(i,l.delay),S=g.val().length)}function i(){var t,s,a=e.trim(g.val());0==a.length&&l.autoSuggest&&(a=l.autoSuggest),l.multiple&&(t=a.lastIndexOf(l.multipleSep),t!=-1&&(a=e.trim(a.substr(t+l.multipleSep.length)))),a.length>=l.minchars?(cached=u(a),cached?c(cached.items):e.get(l.source,{q:a},function(t){v.hide(),s="json"==l.format?e.parseJSON(t):o(t,a),c(s),r(a,s,t.length)})):v.hide()}function n(){var e=!1;e&&clearTimeout(e),e=setTimeout(i,3e3),g.blur(function(){clearTimeout(e)})}function u(e){var t;for(t=0;t<b.length;t++)if(b[t].q==e)return b.unshift(b.splice(t,1)[0]),b[0];return!1}function r(e,t,s){for(var a;b.length&&y+s>l.maxCacheSize;)a=b.pop(),y-=a.size;b.push({q:e,size:s,items:t}),y+=s}function c(t){var a,i="";if(!t)return void(l.label&&v.html("<li>"+l.label+"</li>").show());if(!t.length)return void(l.label&&v.html("<li>"+l.label+"</li>").show());if(s(),"json"==l.format)for(a=0;a<t.length;a++)i+='<li alt="'+t[a].id+'">'+t[a].name+"</li>";else for(a=0;a<t.length;a++)i+="<li>"+t[a]+"</li>";v.html(i).show(),v.children("li").mouseover(function(){v.children("li").removeClass(l.selectClass),e(this).addClass(l.selectClass)}).click(function(e){e.preventDefault(),e.stopPropagation(),h()}),l.autoSelect&&p()}function o(t,s){var a,i,n=[],u=t.split(l.delimiter);for(a=0;a<u.length;a++)i=e.trim(u[a]),i&&(i=i.replace(new RegExp(s,"ig"),function(e){return'<span class="'+l.matchClass+'">'+e+"</span>"}),n[n.length]=i);return n}function f(){var e;return!!v.is(":visible")&&(e=v.children("li."+l.selectClass),e.length||(e=!1),e)}function h(){$currentResult=f(),$currentResult&&(l.multiple?(g.val().indexOf(l.multipleSep)!=-1?$currentVal=g.val().substr(0,g.val().lastIndexOf(l.multipleSep)+l.multipleSep.length):$currentVal="",g.val($currentVal+$currentResult.text()+l.multipleSep),g.focus()):"alt"==l.value?g.val($currentResult.attr("alt")):g.val($currentResult.text()).attr("alt",$currentResult.attr("alt")),v.hide(),l.onSelect&&l.onSelect.apply(g[0]))}function p(){$currentResult=f(),$currentResult?$currentResult.removeClass(l.selectClass).next().addClass(l.selectClass):v.children("li:first-child").addClass(l.selectClass)}function m(){var e=f();e?e.removeClass(l.selectClass).prev().addClass(l.selectClass):v.children("li:last-child").addClass(l.selectClass)}var d,g,v,C,S,b,y;if(d=e(t),input=d.is("input")?d:d.find("input"),g=e(input).attr("autocomplete","off"),v=e("<ul/>").appendTo("body"),C=!1,S=0,b=[],y=0,v.addClass(l.resultsClass).appendTo("body"),s(),e(window).load(s).resize(s),g.blur(function(){setTimeout(function(){v.hide()},200)}),l.showOnFocus&&g.focus(function(){s(),c(),l.autoSuggest&&n()}),e.ua.msie)try{v.bgiframe()}catch( $){}e.ua.mozilla?g.keypress(a):g.keydown(a)},e.fn.suggest=function(t,l){if(t)return l=l||{},l.multiple=l.multiple||!1,l.multipleSep=l.multipleSep||", ",l.showOnFocus=l.showOnFocus||!1,l.source=t,l.yoffset=l.yoffset||0,l.delay=l.delay||100,l.autoDelay=l.autoDelay||3e3,l.autoQuery=l.autoQuery||!1,l.resultsClass=l.resultsClass||"suggest-results",l.selectClass=l.selectClass||"suggest-select",l.matchClass=l.matchClass||"suggest-match",l.minchars=l.minchars||2,l.delimiter=l.delimiter||"\n",l.format=l.format||"string",l.label=l.label||!1,l.value=l.value||"text",l.onSelect=l.onSelect||!1,l.autoSelect=l.autoSelect||!1,l.maxCacheSize=l.maxCacheSize||65536,this.each(function(){new e.suggest(this,l)}),this}}(jQuery);1 !function(e){e.suggest=function(t,l){function s(){var e=d.offset();v.css({top:e.top+d.outerHeight()+l.yoffset+"px",left:e.left+"px"})}function a(e){if(/27$|38$|40$/.test(e.keyCode)&&v.is(":visible")||/^13$|^9$/.test(e.keyCode)&&f())switch(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,e.keyCode){case 38:m();break;case 40:p();break;case 9:case 13:h();break;case 27:v.hide()}else g.val().length!=S&&(C&&clearTimeout(C),C=setTimeout(i,l.delay),S=g.val().length)}function i(){var t,s,a=e.trim(g.val());0==a.length&&l.autoSuggest&&(a=l.autoSuggest),l.multiple&&(t=a.lastIndexOf(l.multipleSep),t!=-1&&(a=e.trim(a.substr(t+l.multipleSep.length)))),a.length>=l.minchars?(cached=u(a),cached?c(cached.items):e.get(l.source,{q:a},function(t){v.hide(),s="json"==l.format?e.parseJSON(t):o(t,a),c(s),r(a,s,t.length)})):v.hide()}function n(){var e=!1;e&&clearTimeout(e),e=setTimeout(i,3e3),g.blur(function(){clearTimeout(e)})}function u(e){var t;for(t=0;t<b.length;t++)if(b[t].q==e)return b.unshift(b.splice(t,1)[0]),b[0];return!1}function r(e,t,s){for(var a;b.length&&y+s>l.maxCacheSize;)a=b.pop(),y-=a.size;b.push({q:e,size:s,items:t}),y+=s}function c(t){var a,i="";if(!t)return void(l.label&&v.html("<li>"+l.label+"</li>").show());if(!t.length)return void(l.label&&v.html("<li>"+l.label+"</li>").show());if(s(),"json"==l.format)for(a=0;a<t.length;a++)i+='<li alt="'+t[a].id+'">'+t[a].name+"</li>";else for(a=0;a<t.length;a++)i+="<li>"+t[a]+"</li>";v.html(i).show(),v.children("li").mouseover(function(){v.children("li").removeClass(l.selectClass),e(this).addClass(l.selectClass)}).click(function(e){e.preventDefault(),e.stopPropagation(),h()}),l.autoSelect&&p()}function o(t,s){var a,i,n=[],u=t.split(l.delimiter);for(a=0;a<u.length;a++)i=e.trim(u[a]),i&&(i=i.replace(new RegExp(s,"ig"),function(e){return'<span class="'+l.matchClass+'">'+e+"</span>"}),n[n.length]=i);return n}function f(){var e;return!!v.is(":visible")&&(e=v.children("li."+l.selectClass),e.length||(e=!1),e)}function h(){$currentResult=f(),$currentResult&&(l.multiple?(g.val().indexOf(l.multipleSep)!=-1?$currentVal=g.val().substr(0,g.val().lastIndexOf(l.multipleSep)+l.multipleSep.length):$currentVal="",g.val($currentVal+$currentResult.text()+l.multipleSep),g.focus()):"alt"==l.value?g.val($currentResult.attr("alt")):g.val($currentResult.text()).attr("alt",$currentResult.attr("alt")),v.hide(),l.onSelect&&l.onSelect.apply(g[0]))}function p(){$currentResult=f(),$currentResult?$currentResult.removeClass(l.selectClass).next().addClass(l.selectClass):v.children("li:first-child").addClass(l.selectClass)}function m(){var e=f();e?e.removeClass(l.selectClass).prev().addClass(l.selectClass):v.children("li:last-child").addClass(l.selectClass)}var d,g,v,C,S,b,y;if(d=e(t),input=d.is("input")?d:d.find("input"),g=e(input).attr("autocomplete","off"),v=e("<ul/>").appendTo("body"),C=!1,S=0,b=[],y=0,v.addClass(l.resultsClass).appendTo("body"),s(),e(window).load(s).resize(s),g.blur(function(){setTimeout(function(){v.hide()},200)}),l.showOnFocus&&g.focus(function(){s(),c(),l.autoSuggest&&n()}),e.ua.msie)try{v.bgiframe()}catch(e){}e.ua.mozilla?g.keypress(a):g.keydown(a)},e.fn.suggest=function(t,l){if(t)return l=l||{},l.multiple=l.multiple||!1,l.multipleSep=l.multipleSep||", ",l.showOnFocus=l.showOnFocus||!1,l.source=t,l.yoffset=l.yoffset||0,l.delay=l.delay||100,l.autoDelay=l.autoDelay||3e3,l.autoQuery=l.autoQuery||!1,l.resultsClass=l.resultsClass||"suggest-results",l.selectClass=l.selectClass||"suggest-select",l.matchClass=l.matchClass||"suggest-match",l.minchars=l.minchars||2,l.delimiter=l.delimiter||"\n",l.format=l.format||"string",l.label=l.label||!1,l.value=l.value||"text",l.onSelect=l.onSelect||!1,l.autoSelect=l.autoSelect||!1,l.maxCacheSize=l.maxCacheSize||65536,this.each(function(){new e.suggest(this,l)}),this}}(jQuery); -
shopp/trunk/core/ui/behaviors/taxrates.min.js
r1473303 r1648469 1 jQuery(document).ready(function(e){e.template("editor",e("#editor")),e.template("conditional",e("#conditional")),e.template("localrate",e("#localrate")),e.template("property-menu",e("#property-menu")),e.template("countries-menu",e("#countries-menu"));var a=!1,t=e("#no-taxrates");e("#taxrates a.edit, #addrate").click(function(n){n&&n.preventDefault(),t.hide();var l=e(this),o=rates.length,i=0,d=l.parents("tr").hide(),s=e.getQueryVar("id",l.attr("href")),c=rates[s]?rates[s]:{},u=e.extend({id:s?s:o++,rate:0,compound:"off",country:!1,zone:!1,logic:"any",rules:[]},c),p=e.tmpl("editor",u),f=p.find("div.conditionals").hide().removeClass("no-conditions"),h=f.find("ul"),m=(p.find("select.logic").val(u.logic),p.find("select.country")),v=p.find("select.zone").hide().removeClass("no-zones"),g=p.find(".local-rates").hide().removeClass("no-local-rates"),y=g.find("ul"),w=p.find(".has-locals"),b=p.find(".add-locals").hide().removeClass("has-local-rates"),x=p.find(".rm-locals").hide().removeClass("no-local-rates"),C=p.find("button.upload"),k=(C.parent(),p.find("p.instructions")),z=p.find("a.cancel"),_=(p.find("#tax-rate").change(function(){this.value=asPercent(this.value,!1,4)}).change(),p.find("#tax-compound").attr("checked","on"==u.compound),p.find("button.add"));l.rules=[],m.html(e.tmpl("countries-menu")).val(u.country).change(function(a){var t=e(this),n="",l=!!zones[t.val()]&&zones[t.val()];0!=l?(n+='<option value=""></option>',e.each(l,function(e,a){n+='<option value="'+e+'">'+a+"</option>"}),v.html(n).val(u.zone).show()):v.empty().hide()}).change(),l.cancel=function(e){e&&e.preventDefault(),a=!1,p.remove(),d.fadeIn("fast"),t.size()>0&&t.show()},z.click(l.cancel),l.addlocals=function(e){e&&e.preventDefault(),b.hide(),x.show(),w.val("true"),g.hide().removeClass("no-local-rates").show()},b.click(l.addlocals),l.rmlocals=function(e){e&&e.preventDefault(),x.hide(),b.show(),w.val("false"),g.fadeOut("fast")},x.click(l.rmlocals),C.upload({name:"ratefile",action:ajaxurl,params:{action:"shopp_upload_local_taxes",_wpnonce:e("#_wpnonce").val()},accept:"text/plain,text/xml",maxfilesize:"1048576",onSubmit:function(){y.empty(),k.empty().removeClass("error"),C.attr("disabled",!0).addClass("updating").parent().css("width","100%")},onComplete:function(a){C.removeAttr("disabled").removeClass("updating");try{r=e.parseJSON(a),r.error?k.addClass("error").html(r.error):l.addlocals(r)}catch( t){alert("LOCAL_RATES_UPLOADERR")}}}),l.addlocalrate=function(a,t){var n={id:u.id,localename:a,localerate:asNumber(t)};e.tmpl("localrate",n).appendTo(y)},l.addlocals=function(a){e.each(a,function(e,a){l.addlocalrate(e,a)}),k.empty()},u.haslocals?(void 0!=u.locals&&l.addlocals(u.locals),g.show(),x.show()):b.show(),l.addrule=function(a,t,n){a&&a.preventDefault(),t||(t=i),n||(n={}),n.id=u.id,n.ruleid=t,n.rulevalue=n.v;var o=e.tmpl("conditional",n).appendTo(h),r=o.find("input.value"),d=(o.find("select.property").html(e.tmpl("property-menu")).val(n.p).change(function(){r.unbind("keydown").unbind("keypress").suggest(suggurl+"&action=shopp_suggestions&t="+e(this).val(),{delay:500,minchars:2,format:"json"})}).change(),o.find("button.delete").click(function(e){e&&e.preventDefault(),o.remove(),l.rules.pop(),0==l.rules.length&&f.hide()}).hide());addrulebtn=o.find("button.add").click(l.addrule),o.hover(function(){d.show()},function(){d.fadeOut("fast")}),f.show(),i++,l.rules.push(i)},_.click(l.addrule),u.rules.length>0&&e.each(u.rules,function(e,a){l.addrule(!1,e,a)}),d.size()>0?p.insertAfter(d):p.prependTo("#taxrates-table"),quickSelects(),a=l})});1 jQuery(document).ready(function(e){e.template("editor",e("#editor")),e.template("conditional",e("#conditional")),e.template("localrate",e("#localrate")),e.template("property-menu",e("#property-menu")),e.template("countries-menu",e("#countries-menu"));var a=!1,t=e("#no-taxrates");e("#taxrates a.edit, #addrate").click(function(n){n&&n.preventDefault(),t.hide();var l=e(this),o=rates.length,i=0,d=l.parents("tr").hide(),s=e.getQueryVar("id",l.attr("href")),c=rates[s]?rates[s]:{},u=e.extend({id:s?s:o++,rate:0,compound:"off",country:!1,zone:!1,logic:"any",rules:[]},c),p=e.tmpl("editor",u),f=p.find("div.conditionals").hide().removeClass("no-conditions"),h=f.find("ul"),m=(p.find("select.logic").val(u.logic),p.find("select.country")),v=p.find("select.zone").hide().removeClass("no-zones"),g=p.find(".local-rates").hide().removeClass("no-local-rates"),y=g.find("ul"),w=p.find(".has-locals"),b=p.find(".add-locals").hide().removeClass("has-local-rates"),x=p.find(".rm-locals").hide().removeClass("no-local-rates"),C=p.find("button.upload"),k=(C.parent(),p.find("p.instructions")),z=p.find("a.cancel"),_=(p.find("#tax-rate").change(function(){this.value=asPercent(this.value,!1,4)}).change(),p.find("#tax-compound").attr("checked","on"==u.compound),p.find("button.add"));l.rules=[],m.html(e.tmpl("countries-menu")).val(u.country).change(function(a){var t=e(this),n="",l=!!zones[t.val()]&&zones[t.val()];0!=l?(n+='<option value=""></option>',e.each(l,function(e,a){n+='<option value="'+e+'">'+a+"</option>"}),v.html(n).val(u.zone).show()):v.empty().hide()}).change(),l.cancel=function(e){e&&e.preventDefault(),a=!1,p.remove(),d.fadeIn("fast"),t.size()>0&&t.show()},z.click(l.cancel),l.addlocals=function(e){e&&e.preventDefault(),b.hide(),x.show(),w.val("true"),g.hide().removeClass("no-local-rates").show()},b.click(l.addlocals),l.rmlocals=function(e){e&&e.preventDefault(),x.hide(),b.show(),w.val("false"),g.fadeOut("fast")},x.click(l.rmlocals),C.upload({name:"ratefile",action:ajaxurl,params:{action:"shopp_upload_local_taxes",_wpnonce:e("#_wpnonce").val()},accept:"text/plain,text/xml",maxfilesize:"1048576",onSubmit:function(){y.empty(),k.empty().removeClass("error"),C.attr("disabled",!0).addClass("updating").parent().css("width","100%")},onComplete:function(a){C.removeAttr("disabled").removeClass("updating");try{r=e.parseJSON(a),r.error?k.addClass("error").html(r.error):l.addlocals(r)}catch(e){alert("LOCAL_RATES_UPLOADERR")}}}),l.addlocalrate=function(a,t){var n={id:u.id,localename:a,localerate:asNumber(t)};e.tmpl("localrate",n).appendTo(y)},l.addlocals=function(a){e.each(a,function(e,a){l.addlocalrate(e,a)}),k.empty()},u.haslocals?(void 0!=u.locals&&l.addlocals(u.locals),g.show(),x.show()):b.show(),l.addrule=function(a,t,n){a&&a.preventDefault(),t||(t=i),n||(n={}),n.id=u.id,n.ruleid=t,n.rulevalue=n.v;var o=e.tmpl("conditional",n).appendTo(h),r=o.find("input.value"),d=(o.find("select.property").html(e.tmpl("property-menu")).val(n.p).change(function(){r.unbind("keydown").unbind("keypress").suggest(suggurl+"&action=shopp_suggestions&t="+e(this).val(),{delay:500,minchars:2,format:"json"})}).change(),o.find("button.delete").click(function(e){e&&e.preventDefault(),o.remove(),l.rules.pop(),0==l.rules.length&&f.hide()}).hide());addrulebtn=o.find("button.add").click(l.addrule),o.hover(function(){d.show()},function(){d.fadeOut("fast")}),f.show(),i++,l.rules.push(i)},_.click(l.addrule),u.rules.length>0&&e.each(u.rules,function(e,a){l.addrule(!1,e,a)}),d.size()>0?p.insertAfter(d):p.prependTo("#taxrates-table"),quickSelects(),a=l})}); -
shopp/trunk/core/ui/categories/category.min.js
r1473303 r1648469 1 var Pricelines=new Pricelines,productOptions=new Array,optionMenus=new Array,detailsidx=1,variationsidx=1,optionsidx=1,pricingidx=1,pricelevelsidx=1,fileUploader=!1,changes=!1,saving=!1,flashUploader=!1,template=!0;jQuery(document).ready(function(){function e(e){var t=n("#pricerange-menu"),i=pricelevelsidx++,a=new NestedMenu(i,t,"priceranges","",e, !1,{axis:"y",scroll:!1});n(a.label).change(function(){this.value=asMoney(this.value)}).change()}function t(e){var t=n("#details-menu"),i=n("#details-list"),a=n("#addDetailOption"),s=detailsidx,o=new NestedMenu(s,t,"specs",NEW_DETAIL_DEFAULT,e,{target:i,type:"list"});o.items=new Array,o.addOption=function(e){var t=new NestedMenuOption(o.index,o.itemsElement,o.dataname,NEW_OPTION_DEFAULT,e,!0);o.items.push(t)};var c=n('<li class="setting"></li>').appendTo(o.itemsElement),l=n('<select name="specs['+o.index+'][facetedmenu]"></select>').appendTo(c);n('<option value="disabled">'+FACETED_DISABLED+"</option>").appendTo(l),n('<option value="auto">'+FACETED_AUTO+"</option>").appendTo(l),n('<option value="ranges">'+FACETED_RANGES+"</option>").appendTo(l),n('<option value="custom">'+FACETED_CUSTOM+"</option>").appendTo(l),e&&e.facetedmenu&&l.val(e.facetedmenu),l.change(function(){"disabled"==n(this).val()||"auto"==n(this).val()?(n(a).hide(),n(o.itemsElement).find("li.option").hide()):(n(a).show(),n(o.itemsElement).find("li.option").show())}).change(),e&&e.options&&n.each(e.options,function(e,t){o.addOption(t)}),n(o.itemsElement).sortable({axis:"y",items:"li.option",scroll:!1}),o.element.unbind("click",o.click),o.element.click(function(){o.selected(),n(a).unbind("click").click(o.addOption),n(l).change()}),detailsidx++}function i(){n("#workflow").change(function(){setting=n(this).val(),request.page=adminpage,request.id=category,request.id||(request.id="new"),"new"==setting&&(request.id="new",request.next=setting),"close"==setting&&delete request.id,"previous"==setting&&n.each(worklist,function(e,t){t.id==category&&(worklist[e-1]?request.next=worklist[e-1].id:delete request.id)}),"next"==setting&&n.each(worklist,function(e,t){t.id==category&&(worklist[e+1]?request.next=worklist[e+1].id:delete request.id)})}).change()}var n=jQuery;new SlugEditor(category,"category"),new ImageUploads(n("#image-category-id").val(),"category");titlePrompt=n("#title-prompt-text"),title=n("#title").bind("focus keydown",function(){titlePrompt.hide()}).blur(function(){""==title.val()?titlePrompt.show():titlePrompt.hide()}),postboxes.add_postbox_toggles("shopp_page_shopp-categories"),n(".if-js-closed").removeClass("if-js-closed").addClass("closed"),n(".postbox a.help").click(function(){return n(this).colorbox({iframe:!0,open:!0,innerWidth:768,innerHeight:480,scrolling:!1}),!1}),i(),n("#category").submit(function(){return""==title.val()?(alert(ENTER_CATEGORY_NAME),!1):(this.action=this.action.substr(0,this.action.indexOf("?"))+"?"+n.param(request),!0)}),n("#templates, #details-template, #details-facetedmenu, #variations-template, #variations-pricing, #price-ranges").hide(),n("#spectemplates-setting").change(function(){this.checked?n("#templates, #details-template").show():n("#details-template").hide(),n("#spectemplates-setting").attr("checked")||n("#variations-setting").attr("checked")||n("#templates").hide()}).change(),n("#faceted-setting").change(function(){this.checked?(n("#details-menu").removeClass("options").addClass("menu"),n("#details-facetedmenu, #price-ranges").show()):(n("#details-menu").removeClass("menu").addClass("options"),n("#details-facetedmenu, #price-ranges").hide())}).change(),details&&n.each(details,function(e,i){t(i)}),n("#addPriceLevel").click(function(){e()}),n("#addDetail").click(function(){t()}),n("#variations-setting").bind("toggleui",function(){this.checked?n("#templates, #variations-template, #variations-pricing").show():n("#variations-template, #variations-pricing").hide(),n("#spectemplates-setting").attr("checked")||n("#variations-setting").attr("checked")||n("#templates").hide()}).click(function(){n(this).trigger("toggleui")}).trigger("toggleui"),options&&loadVariations(options.v?options.v:options,prices),n("#addVariationMenu").click(function(){addVariationOptionsMenu()}),n("#pricerange-facetedmenu").change(function(){"custom"==n(this).val()?n("#pricerange-menu, #addPriceLevel").show():n("#pricerange-menu, #addPriceLevel").hide()}).change(),priceranges&&n.each(priceranges,function(t,i){e(i)}),category||n("#title").focus()});1 var Pricelines=new Pricelines,productOptions=new Array,optionMenus=new Array,detailsidx=1,variationsidx=1,optionsidx=1,pricingidx=1,pricelevelsidx=1,fileUploader=!1,changes=!1,saving=!1,flashUploader=!1,template=!0;jQuery(document).ready(function(){function e(e){var t=n("#pricerange-menu"),i=pricelevelsidx++,a=new NestedMenu(i,t,"priceranges","",e,(!1),{axis:"y",scroll:!1});n(a.label).change(function(){this.value=asMoney(this.value)}).change()}function t(e){var t=n("#details-menu"),i=n("#details-list"),a=n("#addDetailOption"),s=detailsidx,o=new NestedMenu(s,t,"specs",NEW_DETAIL_DEFAULT,e,{target:i,type:"list"});o.items=new Array,o.addOption=function(e){var t=new NestedMenuOption(o.index,o.itemsElement,o.dataname,NEW_OPTION_DEFAULT,e,(!0));o.items.push(t)};var c=n('<li class="setting"></li>').appendTo(o.itemsElement),l=n('<select name="specs['+o.index+'][facetedmenu]"></select>').appendTo(c);n('<option value="disabled">'+FACETED_DISABLED+"</option>").appendTo(l),n('<option value="auto">'+FACETED_AUTO+"</option>").appendTo(l),n('<option value="ranges">'+FACETED_RANGES+"</option>").appendTo(l),n('<option value="custom">'+FACETED_CUSTOM+"</option>").appendTo(l),e&&e.facetedmenu&&l.val(e.facetedmenu),l.change(function(){"disabled"==n(this).val()||"auto"==n(this).val()?(n(a).hide(),n(o.itemsElement).find("li.option").hide()):(n(a).show(),n(o.itemsElement).find("li.option").show())}).change(),e&&e.options&&n.each(e.options,function(e,t){o.addOption(t)}),n(o.itemsElement).sortable({axis:"y",items:"li.option",scroll:!1}),o.element.unbind("click",o.click),o.element.click(function(){o.selected(),n(a).unbind("click").click(o.addOption),n(l).change()}),detailsidx++}function i(){n("#workflow").change(function(){setting=n(this).val(),request.page=adminpage,request.id=category,request.id||(request.id="new"),"new"==setting&&(request.id="new",request.next=setting),"close"==setting&&delete request.id,"previous"==setting&&n.each(worklist,function(e,t){t.id==category&&(worklist[e-1]?request.next=worklist[e-1].id:delete request.id)}),"next"==setting&&n.each(worklist,function(e,t){t.id==category&&(worklist[e+1]?request.next=worklist[e+1].id:delete request.id)})}).change()}var n=jQuery;new SlugEditor(category,"category"),new ImageUploads(n("#image-category-id").val(),"category");titlePrompt=n("#title-prompt-text"),title=n("#title").bind("focus keydown",function(){titlePrompt.hide()}).blur(function(){""==title.val()?titlePrompt.show():titlePrompt.hide()}),postboxes.add_postbox_toggles("shopp_page_shopp-categories"),n(".if-js-closed").removeClass("if-js-closed").addClass("closed"),n(".postbox a.help").click(function(){return n(this).colorbox({iframe:!0,open:!0,innerWidth:768,innerHeight:480,scrolling:!1}),!1}),i(),n("#category").submit(function(){return""==title.val()?(alert(ENTER_CATEGORY_NAME),!1):(this.action=this.action.substr(0,this.action.indexOf("?"))+"?"+n.param(request),!0)}),n("#templates, #details-template, #details-facetedmenu, #variations-template, #variations-pricing, #price-ranges").hide(),n("#spectemplates-setting").change(function(){this.checked?n("#templates, #details-template").show():n("#details-template").hide(),n("#spectemplates-setting").attr("checked")||n("#variations-setting").attr("checked")||n("#templates").hide()}).change(),n("#faceted-setting").change(function(){this.checked?(n("#details-menu").removeClass("options").addClass("menu"),n("#details-facetedmenu, #price-ranges").show()):(n("#details-menu").removeClass("menu").addClass("options"),n("#details-facetedmenu, #price-ranges").hide())}).change(),details&&n.each(details,function(e,i){t(i)}),n("#addPriceLevel").click(function(){e()}),n("#addDetail").click(function(){t()}),n("#variations-setting").bind("toggleui",function(){this.checked?n("#templates, #variations-template, #variations-pricing").show():n("#variations-template, #variations-pricing").hide(),n("#spectemplates-setting").attr("checked")||n("#variations-setting").attr("checked")||n("#templates").hide()}).click(function(){n(this).trigger("toggleui")}).trigger("toggleui"),options&&loadVariations(options.v?options.v:options,prices),n("#addVariationMenu").click(function(){addVariationOptionsMenu()}),n("#pricerange-facetedmenu").change(function(){"custom"==n(this).val()?n("#pricerange-menu, #addPriceLevel").show():n("#pricerange-menu, #addPriceLevel").hide()}).change(),priceranges&&n.each(priceranges,function(t,i){e(i)}),category||n("#title").focus()}); -
shopp/trunk/core/ui/orders/order.php
r1473303 r1648469 259 259 $output = ob_get_contents(); 260 260 ob_end_clean(); 261 echo apply_filters('shopp_manage_order_' . $column . '_column', $output );261 echo apply_filters('shopp_manage_order_' . $column . '_column', $output, $Product, $Item, $Purchase); 262 262 } 263 263 } -
shopp/trunk/core/ui/orders/orders.php
r1473303 r1648469 27 27 28 28 <div class="tablenav"> 29 <div class="alignleft actions"> 29 <?php do_action('shopp_manage_orders_before_actions'); ?> 30 31 <div class="alignleft actions"> 30 32 <?php if (current_user_can('shopp_delete_orders')): ?><button type="submit" id="delete-button" name="deleting" value="order" class="button-secondary"><?php _e('Delete'); ?></button><?php endif; ?> 31 33 </div> … … 46 48 <button type="submit" id="filter-button" name="filter" value="order" class="button-secondary"><?php Shopp::_e('Filter'); ?></button> 47 49 </div> 50 51 <?php do_action('shopp_manage_orders_after_actions'); ?> 48 52 49 53 <?php $ListTable->page_navigation('top'); ?> … … 103 107 if ( in_array($column, $hidden) ) $classes[] = 'hidden'; 104 108 109 $wrap_open = $column == "cb" ? "<th scope='row' class='check-column'>" : '<td class="' . esc_attr(join(' ', $classes)) .'">'; 110 echo apply_filters('shopp_manage_orders_column_wrap_close', $wrap_open, $column, $Order ); 111 112 do_action("shopp_manage_orders_column_{$column}_before"); 113 105 114 switch ( $column ) { 106 115 case 'cb': 107 116 ?> 108 < th scope='row' class='check-column'><input type='checkbox' name='selected[]' value='<?php echo esc_attr($Order->id); ?>' /></th>117 <input type='checkbox' name='selected[]' value='<?php echo esc_attr($Order->id); ?>' /> 109 118 <?php 110 119 break; … … 112 121 case 'order': 113 122 ?> 114 <td class="<?php echo esc_attr(join(' ', $classes)); ?>"> 115 <a class='row-title' href='<?php echo esc_url($viewurl); ?>' title='<?php Shopp::_e('View Order #%d', $Order->id); ?>'><?php Shopp::_e('Order #%d', $Order->id); ?></a> 116 </td> 123 <a class='row-title' href='<?php echo esc_url($viewurl); ?>' title='<?php Shopp::_e('View Order #%d', $Order->id); ?>'><?php Shopp::_e('Order #%d', $Order->id); ?></a> 117 124 <?php 118 125 break; … … 120 127 case 'name': 121 128 ?> 122 <td class="<?php echo esc_attr(join(' ', $classes)); ?>"> 123 <a href="<?php echo esc_url($customerurl); ?>"><?php echo esc_html($customer); ?></a><?php echo !empty($Order->company)?"<br />".esc_html($Order->company):""; ?> 124 </td> 129 <a href="<?php echo esc_url($customerurl); ?>"><?php echo esc_html($customer); ?></a><?php echo !empty($Order->company)?"<br />".esc_html($Order->company):""; ?> 125 130 <?php 126 131 break; … … 128 133 case 'destination': 129 134 ?> 130 <td class="<?php echo esc_attr(join(' ', $classes)); ?>"> 131 <?php echo esc_html($location); ?> 132 </td> 135 <?php echo esc_html($location); ?> 133 136 <?php 134 137 break; … … 136 139 case 'txn': 137 140 ?> 138 <td class="<?php echo esc_attr(join(' ', $classes)); ?>"> 139 <?php echo $Order->txnid; ?><br /><?php echo esc_html($gateway); ?> 140 </td> 141 <?php echo $Order->txnid; ?><br /><?php echo esc_html($gateway); ?> 141 142 <?php 142 143 break; … … 144 145 case 'date': 145 146 ?> 146 <td class="<?php echo esc_attr(join(' ', $classes)); ?>"> 147 <?php echo date("Y/m/d", mktimestamp($Order->created)); ?><br /> 148 <strong><?php echo $statusLabels[$Order->status]; ?></strong> 149 </td> 147 <?php echo date("Y/m/d", mktimestamp($Order->created)); ?><br /> 148 <strong><?php echo $statusLabels[$Order->status]; ?></strong> 150 149 <?php 151 150 break; … … 153 152 case 'total': 154 153 ?> 155 <td class="<?php echo esc_attr(join(' ', $classes)); ?>"> 156 <?php echo money($Order->total); ?><br /><span class="status"><?php echo $txnstatus; ?></span> 157 </td> 154 <?php echo money($Order->total); ?><br /><span class="status"><?php echo $txnstatus; ?></span> 158 155 <?php 159 156 break; … … 161 158 default: 162 159 ?> 163 <td class="<?php echo esc_attr(join(' ', $classes)); ?>"> 164 <?php do_action( 'shopp_manage_orders_custom_column', $column, $Order ); ?> 165 <?php do_action( 'shopp_manage_orders_' . sanitize_key($column) . '_column', $column, $Order ); ?> 166 </td> 167 <?php 168 break; 169 160 <?php do_action( 'shopp_manage_orders_custom_column', $column, $Order ); ?> 161 <?php do_action( 'shopp_manage_orders_' . sanitize_key($column) . '_column', $column, $Order ); ?> 162 <?php 163 break; 170 164 171 165 } // end switch ( $column ) 166 167 do_action("shopp_manage_orders_column_after", $column, $Order); 168 do_action("shopp_manage_orders_column_{$column}_after", $Order); 169 170 $wrap_close = $column == "cb" ? "</th>" : "</td>"; 171 echo apply_filters('shopp_manage_orders_column_wrap_close', $wrap_close, $column, $Order ); 172 172 173 173 } // end foreach ( $columns…) -
shopp/trunk/core/ui/products/editor.min.js
r1473303 r1648469 1 function categories(){var e=jQuery;e("#product .category-metabox").each(function(){var i=e(this),t=e(this).attr("id").split("-").slice(1).join("-"),n=i.find("div.new-category").hide(),a=i.find("ul.category-tabs"),o=(a.find("li a").click(function(i){i.preventDefault();var t=e(this),a=t.attr("href");t.parent().addClass("tabs").siblings("li").removeClass("tabs"),e(a).show().siblings("div.tabs-panel").hide(),t.parent().hasClass("new-category")?n.slideDown("fast",function(){n.find("input").focus()}):n.hide()}),function(i){return e("#new-"+t+"-name").val()?(i.data+="&"+e(":checked","#"+t+"-checklist").serialize(),e("#"+t+"-add-submit").prop("disabled",!0),i):!1}),s=function(i,n){var a,o=e("#new"+t+"_parent");e("#"+t+"-add-submit").prop("disabled",!1),"undefined"!=n.parsed.responses[0]&&(a=n.parsed.responses[0].supplemental.newcat_parent)&&(o.before(a),o.remove())};e("#"+t+"-checklist").wpList({alt:"",response:t+"-ajax-response",addBefore:o,addAfter:s}),a.find("li.tabs a").click(),e("#"+t+"-checklist li.popular-category :checkbox, #"+t+"-checklist-pop :checkbox").on("click",function(){var i=e(this),n=i.is(":checked"),a=i.val();a&&i.parents("#taxonomy-"+t).length&&e("#in-"+t+"-"+a+", #in-popular-"+t+"-"+a).attr("checked",n)})}),e(".category-metabox input[type=checkbox]").change(function(){if(!this.checked)return!0;var i,t=new Array;e("#details-menu").children().children().find("input.label").each(function(i,n){t.push(e(n).val())}),i=e(this).val(),e.getJSON(spectemp_url+"&action=shopp_spec_template&category="+i,function(e){if(!e)return!0;for(i in e)e[i].add=!0,-1==t.toString().search(e[i].name)&&addDetail(e[i])}),e.getJSON(opttemp_url+"&action=shopp_options_template&category="+i,function(i){if(!(i&&i.options&&i.prices&&(Object.keys(i.options).length>0||Object.keys(i.prices).length>0)))return!0;var t=e("#variations-setting"),n=i.options.v?i.options.v:i.options,a=!1;t.attr("checked")||t.attr("checked",!0).trigger("toggleui"),optionMenus.length>0?e.each(n,function(i,t){t&&t.name&&t.options&&((menu=optionMenuExists(t.name))?(a=!1,e.each(t.options,function(e,i){i&&i.name&&(optionMenuItemExists(menu,i.name)||(menu.addOption(i),a=!0))}),a&&addVariationPrices()):(delete t.id,e.each(t.options,function(e,i){i&&i.name&&delete i.id}),addVariationOptionsMenu(t)))}):loadVariations(n,i.prices)})})}function tags(){var e=jQuery;e("#product .tags-metabox").each(function(){var i=e(this),t=e(this).attr("id").split("-").slice(1).join("-"),n=i.find(".tags"),a=n.val().split(","),o=new SearchSelector({source:t,parent:i,url:tagsugg_url,fieldname:"tax_input["+t+"]",label:TAG_SEARCHSELECT_LABEL,classname:"tags",freeform:!0,autosuggest:"shopp_popular_tags"});n.val(""),e.each(a,function(e,i){0!=i.length&&o.ui.prepend(o.newItem("",i))})})}var Pricelines=new Pricelines,productOptions=new Array,productAddons=new Array,optionMenus=new Array,addonGroups=new Array,addonOptionsGroup=new Array,selectedMenuOption=!1,detailsidx=1,variationsidx=1,addon_group_idx=1,addonsidx=1,optionsidx=1,pricingidx=1,fileUploader=!1,changes=!1,saving=!1,flashUploader=!1,template=!1,fileUploads=!1,changesMade=!1,isSave=!1;jQuery(document).ready(function(e){var i=e("#title"),t=e("#title-prompt-text"),n=e(".publishdate");i.bind("focus keydown",function(){t.hide()}).blur(function(){""==i.val()?t.show():t.hide()}),product||(i.focus(),t.show()),postboxes.add_postbox_toggles(screenid),e(".if-js-closed").removeClass("if-js-closed").addClass("closed"),e(".postbox a.help").click(function(){return e(this).colorbox({iframe:!0,open:!0,innerWidth:768,innerHeight:480,scrolling:!1}),!1}),e('<div id="publish-calendar" class="calendar"></div>').appendTo("#wpwrap").PopupCalendar({m_input:e("#publish-month"),d_input:e("#publish-date"),y_input:e("#publish-year"),autoinit:!0,title:calendarTitle,startWeek:startWeekday}),e("#schedule-toggle").click(function(){e("#scheduling").slideToggle("fast",function(){e(this).is(":visible")?n.removeAttr("disabled"):n.attr("disabled",!0)})}),e("#scheduling").hide(),n.attr("disabled",!0),e("#published").change(function(){e(this).prop("checked")?e("#publish-status,#schedule-toggling").show():e("#publish-status,#schedule-toggling,#scheduling").hide()}).change(),e("#process-time").change(function(){var i=e("#processing");e(this).prop("checked")?i.slideDown("fast"):i.hide()}).change(),editslug=new SlugEditor(product,"product"),specs&&e.each(specs,function(){addDetail(this)}),e("#addDetail").click(function(){addDetail()}),fileUploads=new FileUploader("flash-upload-file",e("#ajax-upload-file")),basePrice=e(prices).get(0),basePrice&&"product"==basePrice.context?Pricelines.add(!1,basePrice,"#product-pricing"):Pricelines.add(!1,!1,"#product-pricing"),e("#variations-setting").bind("toggleui",variationsToggle).click(function(){e(this).trigger("toggleui")}).trigger("toggleui"),loadVariations(options&&(options.v||options.a)?options.v:options,prices),e("#addVariationMenu").click(function(){addVariationOptionsMenu()}),e("#linkOptionVariations").click(linkVariationsButton).change(linkVariationsButtonLabel),e("#addons-setting").bind("toggleui",addonsToggle).click(function(){e(this).trigger("toggleui")}).trigger("toggleui"),e("#newAddonGroup").click(function(){newAddonGroup()}),options&&options.a&&loadAddons(options.a,prices),imageUploads=new ImageUploads(e("#image-product-id").val(),"product"),categories(),tags(),quickSelects(),e("#product").change(function(){changes=!0}).unbind("submit").submit(function(t){if(t.stopPropagation(),""==i.val())return alert(ENTER_PRODUCT_NAME),!1;var n=e("#product").attr("action").split("?"),a=n[0]+"?"+e.param(request);return e("#product")[0].setAttribute("action",a),saving=!0,!0}),e("#prices-loading").remove(),e("input").on("change",function(){changesMade=!0,e(this).off("change")}),e("input[name='save']").click(function(){isSave=!0}),window.onbeforeunload=function(){var e="undefined"!=typeof tinymce?tinymce.activeEditor:!1;return!isSave&&(changesMade||e&&e.isDirty()&&!e.isHidden())?$msg.confirm:void 0}});1 function categories(){var e=jQuery;e("#product .category-metabox").each(function(){var i=e(this),t=e(this).attr("id").split("-").slice(1).join("-"),n=i.find("div.new-category").hide(),a=i.find("ul.category-tabs"),o=(a.find("li a").click(function(i){i.preventDefault();var t=e(this),a=t.attr("href");t.parent().addClass("tabs").siblings("li").removeClass("tabs"),e(a).show().siblings("div.tabs-panel").hide(),t.parent().hasClass("new-category")?n.slideDown("fast",function(){n.find("input").focus()}):n.hide()}),function(i){return!!e("#new-"+t+"-name").val()&&(i.data+="&"+e(":checked","#"+t+"-checklist").serialize(),e("#"+t+"-add-submit").prop("disabled",!0),i)}),s=function(i,n){var a,o=e("#new"+t+"_parent");e("#"+t+"-add-submit").prop("disabled",!1),"undefined"!=n.parsed.responses[0]&&(a=n.parsed.responses[0].supplemental.newcat_parent)&&(o.before(a),o.remove())};e("#"+t+"-checklist").wpList({alt:"",response:t+"-ajax-response",addBefore:o,addAfter:s}),a.find("li.tabs a").click(),e("#"+t+"-checklist li.popular-category :checkbox, #"+t+"-checklist-pop :checkbox").on("click",function(){var i=e(this),n=i.is(":checked"),a=i.val();a&&i.parents("#taxonomy-"+t).length&&e("#in-"+t+"-"+a+", #in-popular-"+t+"-"+a).attr("checked",n)})}),e(".category-metabox input[type=checkbox]").change(function(){if(!this.checked)return!0;var i,t=new Array;e("#details-menu").children().children().find("input.label").each(function(i,n){t.push(e(n).val())}),i=e(this).val(),e.getJSON(spectemp_url+"&action=shopp_spec_template&category="+i,function(e){if(!e)return!0;for(i in e)e[i].add=!0,t.toString().search(e[i].name)==-1&&addDetail(e[i])}),e.getJSON(opttemp_url+"&action=shopp_options_template&category="+i,function(i){if(!(i&&i.options&&i.prices&&(Object.keys(i.options).length>0||Object.keys(i.prices).length>0)))return!0;var t=e("#variations-setting"),n=i.options.v?i.options.v:i.options,a=!1;t.attr("checked")||t.attr("checked",!0).trigger("toggleui"),optionMenus.length>0?e.each(n,function(i,t){t&&t.name&&t.options&&((menu=optionMenuExists(t.name))?(a=!1,e.each(t.options,function(e,i){i&&i.name&&(optionMenuItemExists(menu,i.name)||(menu.addOption(i),a=!0))}),a&&addVariationPrices()):(delete t.id,e.each(t.options,function(e,i){i&&i.name&&delete i.id}),addVariationOptionsMenu(t)))}):loadVariations(n,i.prices)})})}function tags(){var e=jQuery;e("#product .tags-metabox").each(function(){var i=e(this),t=e(this).attr("id").split("-").slice(1).join("-"),n=i.find(".tags"),a=n.val().split(","),o=new SearchSelector({source:t,parent:i,url:tagsugg_url,fieldname:"tax_input["+t+"]",label:TAG_SEARCHSELECT_LABEL,classname:"tags",freeform:!0,autosuggest:"shopp_popular_tags"});n.val(""),e.each(a,function(e,i){0!=i.length&&o.ui.prepend(o.newItem("",i))})})}var Pricelines=new Pricelines,productOptions=new Array,productAddons=new Array,optionMenus=new Array,addonGroups=new Array,addonOptionsGroup=new Array,selectedMenuOption=!1,detailsidx=1,variationsidx=1,addon_group_idx=1,addonsidx=1,optionsidx=1,pricingidx=1,fileUploader=!1,changes=!1,saving=!1,flashUploader=!1,template=!1,fileUploads=!1,changesMade=!1,isSave=!1;jQuery(document).ready(function(e){var i=e("#title"),t=e("#title-prompt-text"),n=e(".publishdate");i.bind("focus keydown",function(){t.hide()}).blur(function(){""==i.val()?t.show():t.hide()}),product||(i.focus(),t.show()),postboxes.add_postbox_toggles(screenid),e(".if-js-closed").removeClass("if-js-closed").addClass("closed"),e(".postbox a.help").click(function(){return e(this).colorbox({iframe:!0,open:!0,innerWidth:768,innerHeight:480,scrolling:!1}),!1}),e('<div id="publish-calendar" class="calendar"></div>').appendTo("#wpwrap").PopupCalendar({m_input:e("#publish-month"),d_input:e("#publish-date"),y_input:e("#publish-year"),autoinit:!0,title:calendarTitle,startWeek:startWeekday}),e("#schedule-toggle").click(function(){e("#scheduling").slideToggle("fast",function(){e(this).is(":visible")?n.removeAttr("disabled"):n.attr("disabled",!0)})}),e("#scheduling").hide(),n.attr("disabled",!0),e("#published").change(function(){e(this).prop("checked")?e("#publish-status,#schedule-toggling").show():e("#publish-status,#schedule-toggling,#scheduling").hide()}).change(),e("#process-time").change(function(){var i=e("#processing");e(this).prop("checked")?i.slideDown("fast"):i.hide()}).change(),editslug=new SlugEditor(product,"product"),specs&&e.each(specs,function(){addDetail(this)}),e("#addDetail").click(function(){addDetail()}),fileUploads=new FileUploader("flash-upload-file",e("#ajax-upload-file")),basePrice=e(prices).get(0),basePrice&&"product"==basePrice.context?Pricelines.add(!1,basePrice,"#product-pricing"):Pricelines.add(!1,!1,"#product-pricing"),e("#variations-setting").bind("toggleui",variationsToggle).click(function(){e(this).trigger("toggleui")}).trigger("toggleui"),loadVariations(options&&(options.v||options.a)?options.v:options,prices),e("#addVariationMenu").click(function(){addVariationOptionsMenu()}),e("#linkOptionVariations").click(linkVariationsButton).change(linkVariationsButtonLabel),e("#addons-setting").bind("toggleui",addonsToggle).click(function(){e(this).trigger("toggleui")}).trigger("toggleui"),e("#newAddonGroup").click(function(){newAddonGroup()}),options&&options.a&&loadAddons(options.a,prices),imageUploads=new ImageUploads(e("#image-product-id").val(),"product"),categories(),tags(),quickSelects(),e("#product").change(function(){changes=!0}).unbind("submit").submit(function(t){if(t.stopPropagation(),""==i.val())return alert(ENTER_PRODUCT_NAME),!1;var n=e("#product").attr("action").split("?"),a=n[0]+"?"+e.param(request);return e("#product")[0].setAttribute("action",a),saving=!0,!0}),e("#prices-loading").remove(),e("input").on("change",function(){changesMade=!0,e(this).off("change")}),e("input[name='save']").click(function(){isSave=!0}),window.onbeforeunload=function(){var e="undefined"!=typeof tinymce&&tinymce.activeEditor;if(!isSave&&(changesMade||e&&e.isDirty()&&!e.isHidden()))return $msg.confirm}}); -
shopp/trunk/core/ui/products/editor.php
r1473303 r1648469 167 167 FILE_NOT_READ_TEXT = <?php Shopp::_jse('The file you specified is not readable and cannot be used.'); ?>, 168 168 FILE_ISDIR_TEXT = <?php Shopp::_jse('The file you specified is a directory and cannot be used.'); ?>, 169 FILE_UNKNOWN_IMPORT_ERROR = <?php Shopp::_jse('An unknown error occur ed while attempting to attach the file.'); ?>,169 FILE_UNKNOWN_IMPORT_ERROR = <?php Shopp::_jse('An unknown error occurred while attempting to attach the file.'); ?>, 170 170 IMAGE_DETAILS_TEXT = <?php Shopp::_jse('Image Details'); ?>, 171 171 IMAGE_DETAILS_TITLE_LABEL = <?php Shopp::_jse('Title'); ?>, -
shopp/trunk/core/ui/products/ui.php
r1473303 r1648469 275 275 </ul> 276 276 <div class="clear"></div> 277 <input type="hidden" name="product" value="<?php echo $_GET['id']; ?>" id="image-product-id" />277 <input type="hidden" name="product" value="<?php echo preg_replace('/[^0-9]/', '', $_GET['id']); ?>" id="image-product-id" /> 278 278 <input type="hidden" name="deleteImages" id="deleteImages" value="" /> 279 279 <div id="swf-uploader-button"></div> -
shopp/trunk/core/ui/styles/admin.css
r1473303 r1648469 523 523 #order fieldset { float:left;width:auto;width:23%;padding:10px;border:1px solid #dadada;margin-bottom:30px; } 524 524 #order table.transaction { float:right;margin-bottom:10px; } 525 #order table td { padding:7px 7px 8px; }526 525 #order table.transaction th { text-align:right;padding-right:7px;vertical-align:top; } 527 526 #order table.transaction a { text-decoration:none; } -
shopp/trunk/core/ui/widgets/cart.php
r1473303 r1648469 23 23 } 24 24 25 function widget ($args, $options) {26 if ( !empty($args)) extract($args);25 function widget ($args, $options) { 26 if ( ! empty($args) ) extract($args); 27 27 28 if ( empty($options['title'])) $options['title'] = Shopp::__('Your Cart');29 $title = $before_title .$options['title'].$after_title;28 if ( empty($options['title']) ) $options['title'] = Shopp::__('Your Cart'); 29 $title = $before_title . $options['title'] . $after_title; 30 30 31 if ('on' == $options['hide-empty'] && shopp_cart_items_count() == 0) return; 31 if ( isset($options['hide-empty']) ) 32 if ('on' == $options['hide-empty'] && shopp_cart_items_count() == 0) return; 32 33 33 $sidecart = shopp('cart ','get-sidecart',$options);34 if ( empty($sidecart)) return;35 echo $before_widget .$title.$sidecart.$after_widget;34 $sidecart = shopp('cart.get-sidecart', $options); 35 if ( empty($sidecart) ) return; 36 echo $before_widget . $title . $sidecart . $after_widget; 36 37 } 37 38 38 function update ($new_instance, $old_instance) {39 function update ($new_instance, $old_instance) { 39 40 return $new_instance; 40 41 } 41 42 42 function form ($options) {43 function form ($options) { 43 44 $defaults = array( 44 45 'title' => '', -
shopp/trunk/gateways/PayPal/PayPalStandard.php
r1473303 r1648469 36 36 ); 37 37 38 const APIURL = 'https://www.paypal.com/cgi-bin/webscr';39 const DEVURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';40 const BUTTON = 'http://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif';38 const APIURL = 'https://www.paypal.com/cgi-bin/webscr'; 39 const DEVURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; 40 const BUTTON = 'https://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif'; 41 41 42 42 public function __construct () { … … 130 130 if ( ! $Message ) return; // Requires an IPN/PDT message 131 131 132 shopp_debug(__METHOD__ . ': ' . _object_r($Message));132 shopp_debug(__METHOD__ . ': ' . Shopp::object_r($Message)); 133 133 134 134 if ( $payer_status = $Message->payer() ) { // Note the payer status … … 155 155 156 156 $authed = array( 157 'txnid' => $Message->txnid(),// Transaction ID158 'amount' => $Message->amount(), // Gross amount authorized159 'gateway' => $this->module, // Gateway handler name (module name from @subpackage)157 'txnid' => $Message->txnid(), // Transaction ID 158 'amount' => $Message->amount(), // Gross amount authorized 159 'gateway' => $this->module, // Gateway handler name (module name from @subpackage) 160 160 'paymethod' => $this->settings['label'], // Payment method (payment method label from payment settings) 161 'paytype' => $Message->paytype(), // Type of payment (eCheck, or instant payment)162 'payid' => $Message->email(),// PayPal account email address163 'capture' => ( $captured = $Message->captured() ) // Capture flag161 'paytype' => $Message->paytype(), // Type of payment (eCheck, or instant payment) 162 'payid' => $Message->email(), // PayPal account email address 163 'capture' => ( $captured = $Message->captured() ) // Capture flag 164 164 ); 165 165 … … 193 193 194 194 shopp_add_order_event($Event->order, 'captured', array( 195 'txnid' => $Message->txnid(),// Transaction ID of the CAPTURE event195 'txnid' => $Message->txnid(), // Transaction ID of the CAPTURE event 196 196 'amount' => $Event->amount, // Amount captured 197 'fees' => $Event->fees, // Transaction fees taken by the gateway net revenue = amount-fees197 'fees' => $Event->fees, // Transaction fees taken by the gateway net revenue = amount-fees 198 198 'gateway' => $this->module // Gateway handler name (module name from @subpackage) 199 199 )); … … 244 244 245 245 shopp_add_order_event($Event->order, 'voided', array( 246 'txnid' => $Message->txnid(), // Transaction ID246 'txnid' => $Message->txnid(), // Transaction ID 247 247 'txnorigin' => $Message->txnorigin(), // Original Transaction ID 248 'gateway' => $this->module // Gateway handler name (module name from @subpackage)248 'gateway' => $this->module // Gateway handler name (module name from @subpackage) 249 249 )); 250 250 } … … 379 379 $_ = array(); 380 380 381 $_['cmd'] = '_cart';381 $_['cmd'] = '_cart'; 382 382 $_['upload'] = 1; 383 383 $_['business'] = $this->settings['account']; … … 392 392 $_['cancel_return'] = Shopp::url(false, 'cart'); 393 393 $_['notify_url'] = $this->ipnurl(); 394 $_['rm'] = 1; // Return with no transaction data394 $_['rm'] = 1; // Return with no transaction data 395 395 396 396 // Pre-populate PayPal Checkout 397 $_['lc'] = $this->baseop['country'];397 $_['lc'] = $this->baseop['country']; 398 398 $_['charset'] = 'utf-8'; 399 $_['bn'] = 'shopplugin.net[WPS]';399 $_['bn'] = 'shopplugin.net[WPS]'; 400 400 401 401 $_['first_name'] = $Customer->firstname; … … 416 416 } 417 417 418 $_['address_override']= apply_filters( 'shopp_paypalstandard_addressoverride', 1 );418 $_['address_override'] = apply_filters( 'shopp_paypalstandard_addressoverride', 1 ); 419 419 $_['address1'] = $Address->address; 420 420 … … 422 422 $_['address2'] = $Address->xaddress; 423 423 424 $_['city'] = $Address->city;425 $_['state'] = $Address->state;426 $_['zip'] = $Address->postcode;424 $_['city'] = $Address->city; 425 $_['state'] = $Address->state; 426 $_['zip'] = $Address->postcode; 427 427 $_['country'] = $Address->country; 428 $_['email'] = $Customer->email;428 $_['email'] = $Customer->email; 429 429 430 430 $phone = parse_phone($Order->Customer->phone); … … 433 433 $_['night_phone_b'] = $phone['prefix']; 434 434 $_['night_phone_c'] = $phone['exchange']; 435 } else $_['night_phone_b'] = $phone['raw'];435 } else $_['night_phone_b'] = $phone['raw']; 436 436 437 437 // Include page style option, if provided … … 439 439 440 440 // Transaction 441 $_['currency_code'] = $this->currency();441 $_['currency_code'] = $this->currency(); 442 442 443 443 // Recurring Non-Free Item … … 519 519 // When the issue occurs the product will be set to be one set with one price 520 520 if ( $Item->quantity > 1 ) { 521 $pp_price = $this->amount($_[ 'amount_' . $id ] * $_[ 'quantity_' . $id ]) ;522 $shopp_price = $this->amount($Item->totald);521 $pp_price = $this->amount($_[ 'amount_' . $id ] * $_[ 'quantity_' . $id ]) ; 522 $shopp_price = $this->amount($Item->totald); 523 523 524 524 if ( $pp_price != $shopp_price ) { … … 539 539 $id++; 540 540 $_['item_number_'.$id] = $id; 541 $_['item_name_'.$id] = apply_filters('paypal_freeorder_handling_label', 542 Shopp::__('Shipping & Handling')); 543 $_['amount_'.$id] = $this->amount( max((float)$this->amount('shipping'), 0.01) ); 544 $_['quantity_'.$id] = 1; 541 $_['item_name_'.$id] = apply_filters('paypal_freeorder_handling_label', Shopp::__('Shipping & Handling')); 542 $_['amount_'.$id] = $this->amount( max((float)$this->amount('shipping'), 0.01) ); 543 $_['quantity_'.$id] = 1; 545 544 } else 546 $_['handling_cart'] = $this->amount('shipping');545 $_['handling_cart'] = $this->amount('shipping'); 547 546 548 547 $_['discount_amount_cart'] = $this->amount('discount'); 549 $_['tax_cart'] = $this->amount('tax');550 $_['amount'] = $this->amount('total');548 $_['tax_cart'] = $this->amount('tax'); 549 $_['amount'] = $this->amount('total'); 551 550 552 551 } … … 802 801 803 802 $this->Message = new ShoppPayPalStandardMessage($response); 804 shopp_debug('PayPal PDT response protocol: ' . _object_r($this->Message));803 shopp_debug('PayPal PDT response protocol: ' . Shopp::object_r($this->Message)); 805 804 806 805 // Everything looks good, return true and let the order PDT order processing handle it from here … … 977 976 978 977 self::$reasons = array( 979 'address' => Shopp::__('The customer did not include a confirmed shipping address.'),978 'address' => Shopp::__('The customer did not include a confirmed shipping address.'), 980 979 'echeck' => Shopp::__('The eCheck has not yet cleared.'), 981 980 'intl' => Shopp::__('You must manually accept or deny transactions for your non-US account.'), -
shopp/trunk/package.json
r1473303 r1648469 17 17 "gulp-notify": "^2.2.0", 18 18 "gulp-rename": "^1.2.2", 19 "gulp-uglify": "^ 1.5.3",19 "gulp-uglify": "^2.0.0", 20 20 "gulp-util": "^3.0.7" 21 21 } -
shopp/trunk/readme.md
r1308754 r1648469 8 8 - [License](license.txt) 9 9 - [Contributors](https://github.com/ingenesis/shopp/contributors) 10 11 ## Downloads 12 - [Latest release (1.3.12)](https://github.com/ingenesis/shopp/releases/tag/1.3.12) 13 - [Current dev (1.3.13.dev)](https://github.com/ingenesis/shopp/archive/1.3.x.zip) 14 - [Future dev (1.4.dev)](https://github.com/ingenesis/shopp/archive/master.zip) 10 15 11 16 ## Looking for Help? -
shopp/trunk/readme.txt
r1473303 r1648469 4 4 Tags: ecommerce, e-commerce, wordpress ecommerce, shopp, shop, shopping, cart, store, storefront, sales, sell, catalog, checkout, accounts, secure, variations, variants, reports, downloads, digital, downloadable, inventory, stock, shipping, taxes, shipped, addons, widgets, shortcodes 5 5 Requires at least: 3.5 6 Tested up to: 4. 5.36 Tested up to: 4.7.4 7 7 Stable tag: trunk 8 8 License: GPLv3 or later … … 23 23 E-commerce software shouldn’t tell you how to manage your business. You should be able tell your e-commerce software how you manage your business. Shopp lets you do just that. Create your own order processing labels and easily move orders through each step of the order fulfillment workflow either automatically or take control of it yourself. 24 24 25 Export orders to accounting systems like Intuit® QuickBooks®, or to spreadsheets like Microsoft® Excel®. Shopp remembers your last export date so its easy to do ongoing exports on a regular basis.25 Export orders to accounting systems like Intuit® QuickBooks®, or to CSV files. Shopp remembers your last export date so its easy to do ongoing exports on a regular basis. 26 26 27 27 = Safe & Sound = -
shopp/trunk/shipping/core/OrderWeight.php
r1473303 r1648469 3 3 * Order Weight Tiers 4 4 * 5 * Provides shipping calculations based on order amount tiers5 * Provides shipping calculations based on order weight 6 6 * 7 7 * @author Jonathan Davis -
shopp/trunk/storage/core/DBStorage.php
r1473303 r1648469 55 55 } 56 56 57 $data = sDB::escape($data );57 $data = sDB::escape($data, false); //Prevent unescape() before escape() 58 58 59 59 if ( ! $asset->id ) $uri = sDB::query("INSERT $this->_table SET data='$data'");
Note: See TracChangeset
for help on using the changeset viewer.