Plugin Directory

Changeset 1859263


Ignore:
Timestamp:
04/16/2018 06:02:48 PM (8 years ago)
Author:
jond
Message:

Added 1.4 release

Location:
shopp/trunk
Files:
3 added
33 edited

Legend:

Unmodified
Added
Removed
  • shopp/trunk/Shopp.php

    r1648469 r1859263  
    44 * Plugin URI: http://shopplugin.com
    55 * Description: An ecommerce framework for WordPress.
    6  * Version: 1.3.13
     6 * Version: 1.4
    77 * Author: Ingenesis Limited
    88 * Author URI: http://ingenesis.net
    9  * Requires at least: 3.5
    10  * Tested up to: 4.7.4
     9 * Requires at least: 4.4
     10 * Tested up to: 4.9.5
    1111 *
    1212 *    Portions created by Ingenesis Limited are Copyright © 2008-2014 by Ingenesis Limited
  • shopp/trunk/core/flow/Ajax.php

    r1473303 r1859263  
    3838        }
    3939
    40         // Flash uploads require unprivileged access
     40        // File uploads require unprivileged access
    4141        add_action('wp_ajax_nopriv_shopp_upload_image', array($this, 'upload_image'));
    4242        add_action('wp_ajax_nopriv_shopp_upload_file', array($this, 'upload_file'));
     
    157157
    158158    public function upload_image () {
    159         $Warehouse = new ShoppAdminWarehouse;
    160         echo $Warehouse->images();
    161         exit();
     159        $file = isset($_FILES['file']) ? $_FILES['file'] : false;
     160        $parent = isset($_GET['parent']) ? (int)$_GET['parent'] : false;
     161        $type = isset($_GET['type']) ? $_GET['type'] : false;
     162        ShoppAdminWarehouse::images($file, $parent, $type);
    162163    }
    163164
    164165    public function upload_file () {
    165         $Warehouse = new ShoppAdminWarehouse;
    166         echo $Warehouse->downloads();
    167         exit();
     166        $file = isset($_FILES['file']) ? $_FILES['file'] : false;
     167        ShoppAdminWarehouse::downloads($file, $_POST);
    168168    }
    169169
     
    413413                        $where[] = "tt.taxonomy = '" . $taxonomy . "'";
    414414                        if ( 'shopp_popular_tags' == strtolower($q) ) {
    415                             $q = ''; 
     415                            $q = '';
    416416                            $orderlimit = "ORDER BY tt.count DESC LIMIT 15";
    417417                        }
     
    574574
    575575        $error    = create_function('$s', 'die(json_encode(array("error" => $s)));');
    576         if (empty($_REQUEST['url'])) $error(Shopp::__('No file import URL was provided.'));
     576        if ( empty($_REQUEST['url']) )
     577            $error(Shopp::__('No file import URL was provided.'));
    577578        $url      = $_REQUEST['url'];
    578579        $request  = parse_url($url);
     
    604605                $_->mime = $mime;
    605606        } else {
    606             if ( ! $importfile = @tempnam(sanitize_path(realpath(SHOPP_TEMP_PATH) ), 'shp')) $error(Shopp::__('A temporary file could not be created for importing the file.', $importfile));
    607             if ( ! $incoming   = @fopen($importfile,'w') ) $error(Shopp::__('A temporary file at %s could not be opened for importing.', $importfile));
    608 
    609             if ( ! $file = @fopen(linkencode($url), 'rb') ) $error(Shopp::__('The file at %s could not be opened for importing.', $url));
     607            if ( ! ($importfile = @tempnam(sanitize_path(realpath(SHOPP_TEMP_PATH) ), 'shp')) ) $error(Shopp::__('A temporary file could not be created for importing the file.', $importfile));
     608            if ( ! ($incoming   = @fopen($importfile, 'w')) ) $error(Shopp::__('A temporary file at %s could not be opened for importing.', $importfile));
     609
     610            if ( ! ($file = @fopen(linkencode($url), 'rb')) ) $error(Shopp::__('The file at %s could not be opened for importing.', $url));
    610611            $data = @stream_get_meta_data($file);
    611612
     
    622623
    623624            $tmp = basename($importfile);
    624             // $Settings =& ShoppSettings();
    625625
    626626            $_->path = $importfile;
     
    639639        if ( ! $_->mime ) $_->mime = "application/octet-stream";
    640640
    641         echo str_repeat(' ', 1024); // Minimum browser data
     641        echo str_repeat(' ', 1024) . "\n"; // Minimum browser data
    642642        echo '<script type="text/javascript">var importFile = ' . json_encode($_) . ';</script>'."\n";
    643643        echo '<script type="text/javascript">var importProgress = 0;</script>' . "\n";
    644         if ( $_->stored ) exit();
     644        if ( $_->stored )
     645            exit();
    645646        @ob_flush();
    646647        @flush();
     
    657658                fwrite($incoming, $buffer);
    658659                $bytesread += strlen($buffer);
    659                 echo '<script type="text/javascript">importProgress = ' . $bytesread/(int)$_->size . ';</script>'."\n";
     660                echo '<script type="text/javascript">importProgress = ' . ( $bytesread / (int)$_->size ) . ';</script>'."\n";
    660661                @ob_flush();
    661662                @flush();
     
    666667        fclose($incoming);
    667668
    668         exit();
     669        wp_die('');
    669670    }
    670671
  • shopp/trunk/core/flow/Categorize.php

    r1648469 r1859263  
    3838
    3939            wp_enqueue_script('postbox');
    40             wp_enqueue_script('swfupload-all');
     40            wp_enqueue_script('dropzone');
    4141
    4242            if ( user_can_richedit() ) {
     
    5151            shopp_enqueue_script('priceline');
    5252            shopp_enqueue_script('ocupload');
    53             //shopp_enqueue_script('swfupload');
    54             //shopp_enqueue_script('shopp-swfupload-queue');
     53            shopp_enqueue_script('dropzone');
     54            shopp_enqueue_script('jquery-tmpl');
    5555
    5656            do_action('shopp_category_editor_scripts');
     
    354354        );
    355355
    356         $uploader = shopp_setting('uploader_pref');
    357         if ( ! $uploader ) $uploader = 'flash';
    358 
    359356        $workflows = array(
    360357            "continue"  => Shopp::__('Continue Editing'),
     
    363360            "next"      => Shopp::__('Edit Next'),
    364361            "previous"  => Shopp::__('Edit Previous')
    365             );
     362        );
    366363
    367364        do_action('add_meta_boxes', ProductCategory::$taxon, $Category);
  • shopp/trunk/core/flow/Install.php

    r1473303 r1859263  
    425425
    426426        // System Settings
    427         $Settings->setup('uploader_pref', 'flash');
    428427        $Settings->setup('script_loading', 'global');
    429428        $Settings->setup('script_server', 'plugin');
  • shopp/trunk/core/flow/Scripts.php

    r1648469 r1859263  
    205205
    206206    $scripts->base_url = $url;
    207     $scripts->default_version = mktime(false,false,false,1,1,2010);
     207    $scripts->default_version = mktime(false,false,false,1,1,2017);
    208208    $scripts->default_dirs = array('/ui/behaviors/','/ui/products');
    209209
     
    242242    $scripts->add_data('ocupload', 'group', 1);
    243243
     244    $scripts->add('dropzone', '/ui/behaviors/dropzone.js', array(), $version);
     245    $scripts->add_data('dropzone', 'group', 1);
     246
    244247    $scripts->add('orders', '/ui/behaviors/orders.js', array('jquery'), $version);
    245248    $scripts->add_data('orders', 'group', 1);
     
    322325    $scripts->add('reports', '/ui/behaviors/reports.js', array(), $version);
    323326    $scripts->add_data('reports', 'group', 1);
    324 
    325327}
    326328
     
    358360    // Address Helper
    359361    shopp_localize_script('address', '$shopp_address', array(
    360         'country_no_postal_codes' => Lookup::country_no_postal_codes() 
     362        'country_no_postal_codes' => Lookup::country_no_postal_codes()
    361363    ));
    362364
  • shopp/trunk/core/flow/Service.php

    r1648469 r1859263  
    224224        $joins = join(' ', $joins);
    225225
    226         $countquery = "SELECT count(*) as total,SUM(IF(txnstatus IN ('authed', 'captured'), total, NULL)) AS sales, AVG(IF(txnstatus IN ('authed', 'captured'), total, NULL)) AS avgsale FROM $Purchase->_table AS o $joins $where ORDER BY o.created DESC LIMIT 1";
     226        $countquery = "SELECT count(*) as total,SUM(IF(txnstatus IN ('authed', 'captured'), o.total, NULL)) AS sales, AVG(IF(txnstatus IN ('authed', 'captured'), o.total, NULL)) AS avgsale FROM $Purchase->_table AS o $joins $where ORDER BY o.created DESC LIMIT 1";
    227227        $this->ordercount = sDB::query($countquery, 'object');
    228228
  • shopp/trunk/core/flow/Warehouse.php

    r1648469 r1859263  
    5151            wp_enqueue_script('postbox');
    5252            wp_enqueue_script('wp-lists');
    53             wp_enqueue_script('swfupload-all');
    5453
    5554            if ( user_can_richedit() ) {
     
    6665            shopp_enqueue_script('priceline');
    6766            shopp_enqueue_script('ocupload');
     67            shopp_enqueue_script('dropzone');
    6868            shopp_enqueue_script('jquery-tmpl');
    6969            shopp_enqueue_script('suggest');
     
    168168            // Gracefully invalidate Shopp object caching
    169169            Shopp::cache_invalidate();
    170            
     170
    171171            $redirect = add_query_arg( $_GET, $adminurl );
    172172            $redirect = remove_query_arg( array('action', 'selected', 'delete_all'), $redirect );
     
    279279            'published'     =>  array('label' => Shopp::__('Published'),          'where' => array("p.post_status='publish'")),
    280280            'drafts'        =>  array('label' => Shopp::__('Drafts'),             'where' => array("p.post_status='draft'")),
    281             'trash'         =>  array('label' => Shopp::__('Trash'),              'where' => array("p.post_status='trash'")),           
     281            'trash'         =>  array('label' => Shopp::__('Trash'),              'where' => array("p.post_status='trash'")),
    282282            'onsale'        =>  array('label' => Shopp::__('On Sale'),            'where' => array("s.sale='on' AND p.post_status != 'trash'")),
    283283            'featured'      =>  array('label' => Shopp::__('Featured'),           'where' => array("s.featured='on' AND p.post_status != 'trash'")),
     
    351351                    $where[] = "(s.inventory='on' AND s.lowstock != 'none')";
    352352                    break;
    353                 case "is": 
     353                case "is":
    354354                    $where[] = "(s.inventory='on' AND s.stock > 0)";
    355355            }
     
    414414            );
    415415        } elseif ( 'sku' == $orderby ) {
    416             $loading['joins'] = array_merge(array($pt => "LEFT JOIN $pt AS pt ON p.ID=pt.product"), $joins);           
     416            $loading['joins'] = array_merge(array($pt => "LEFT JOIN $pt AS pt ON p.ID=pt.product"), $joins);
    417417        }
    418418
     
    693693            ksort($shiprates);
    694694
    695         $uploader = shopp_setting('uploader_pref');
    696         if ( ! $uploader ) $uploader = 'flash';
    697 
    698695        $process = empty($Product->id) ? 'new' : $Product->id;
    699696        $_POST['action'] = add_query_arg(array_merge($_GET, array('page' => $this->Admin->pagename('products'))), admin_url('admin.php'));
     
    834831                    $priceline['stock'] = (int) $priceline['stocked'];
    835832                    if ( ! isset($Price->stocklevel) ) $Price->stocklevel = $priceline['stock'];
    836                     do_action('shopp_stock_product', $priceline['stock'], $Price, $Price->stock, $Price->stocklevel); 
     833                    do_action('shopp_stock_product', $priceline['stock'], $Price, $Price->stock, $Price->stocklevel);
    837834                } else unset($priceline['stocked']);
    838835
     
    991988
    992989    /**
    993      * AJAX behavior to process uploaded files intended as digital downloads
     990     * AJAX behavior to process uploaded files intended as digital product downloads
    994991     *
    995992     * Handles processing a file upload from a temporary file to a
    996993     * the correct storage container (DB, file system, etc)
    997994     *
    998      * @author Jonathan Davis
     995     * @since 1.3
     996     * @param array $file File upload data
     997     * @param array $data Posted data
    999998     * @return string JSON encoded result with DB id, filename, type & size
    1000999     **/
    1001     public static function downloads () {
    1002 
    1003         $error = false;
    1004         if ( isset($_FILES['Filedata']['error']) ) $error = $_FILES['Filedata']['error'];
    1005         if ( $error ) die( json_encode(array('error' => Lookup::errors('uploads', $error))) );
    1006 
    1007         if ( ! @is_uploaded_file($_FILES['Filedata']['tmp_name']) )
    1008             die(json_encode(array('error' => Shopp::__('The file could not be saved because the upload was not found on the server.'))));
    1009 
    1010         if ( 0 == $_FILES['Filedata']['size'] )
    1011             die(json_encode(array('error' => Shopp::__('The file could not be saved because the uploaded file is empty.'))));
     1000    public static function downloads ($file, $data) {
     1001
     1002        set_time_limit(0);        // Try to prevent timeouts
     1003        self::uploaderrs($file);  // Catch any upload errors before proceeding
     1004
     1005        $stagedfile = $file['tmp_name'];
     1006
     1007        // Handle chunked file uploads
     1008        if ( isset($data['dzchunkindex']) && isset($data['dztotalchunkcount']) ) {
     1009            $PartialUpload = new ShoppPartialUpload($file, $data);
     1010            $stagedfile = $PartialUpload->process();
     1011        }
    10121012
    10131013        FileAsset::mimetypes();
    10141014
    10151015        // Save the uploaded file
    1016         $File = new ProductDownload();
    1017         $File->parent = 0;
    1018         $File->context = "price";
    1019         $File->type = "download";
    1020         $File->name = $_FILES['Filedata']['name'];
    1021         $File->filename = $File->name;
    1022 
    1023         list($extension, $mimetype, $properfile) = wp_check_filetype_and_ext($_FILES['Filedata']['tmp_name'], $File->name);
    1024         if ( empty($mimetype) ) $mimetype = 'application/octet-stream';
    1025         $File->mime = $mimetype;
    1026 
    1027         if ( ! empty($properfile) )
    1028             $File->name = $File->filename = $properfile;
    1029 
    1030         $File->size = filesize($_FILES['Filedata']['tmp_name']);
    1031         $File->store($_FILES['Filedata']['tmp_name'], 'upload');
     1016        $DownloadFile = new ProductDownload();
     1017        $DownloadFile->parent = 0;
     1018        $DownloadFile->context = "price";
     1019        $DownloadFile->type = "download";
     1020        $DownloadFile->name = $file['name'];
     1021        $DownloadFile->filename = $DownloadFile->name;
     1022
     1023        $mimedata = wp_check_filetype_and_ext($stagedfile, $DownloadFile->name);
     1024        $DownloadFile->mime = ! empty($mimedata['type']) ? $mimedata['type'] : 'application/octet-stream';
     1025        if ( ! empty($mimedata['proper_filename']) )
     1026            $DownloadFile->name = $DownloadFile->filename = $mimedata['proper_filename'];
     1027
     1028        $DownloadFile->size = filesize($stagedfile);
     1029        $DownloadFile->store($stagedfile, 'file');
    10321030
    10331031        $Error = ShoppErrors()->code('storage_engine_save');
    10341032        if ( ! empty($Error) )
    1035             die( json_encode( array('error' => $Error->message(true)) ) );
    1036 
    1037         $File->save();
    1038 
    1039         do_action('add_product_download', $File,$_FILES['Filedata']);
    1040 
    1041         echo json_encode(array(
    1042             'id'    => $File->id,
    1043             'name'  => stripslashes($File->name),
    1044             'type'  => $File->mime,
    1045             'size'  => $File->size
    1046         ));
    1047     }
     1033            wp_die($Error->message(true), 500);
     1034
     1035        $DownloadFile->save();
     1036
     1037        do_action('add_product_download', $DownloadFile, $file);
     1038
     1039        header('Content-Type: application/json');
     1040        wp_die(json_encode(array(
     1041            'id' => $DownloadFile->id,
     1042            'name' => stripslashes($DownloadFile->name),
     1043            'type' => $DownloadFile->mime,
     1044            'size' => $DownloadFile->size
     1045        )));
     1046    }
     1047
     1048    /**
     1049     * Provide upload errors back to the browser
     1050     *
     1051     * @since 1.4
     1052     * @param array $file The uploaded file data
     1053     * @return boolean False if no errors, exits if there are errors
     1054     **/
     1055    private static function uploaderrs ($file) {
     1056        $error = array();
     1057
     1058        if ( ! empty($file['error']) )
     1059            $error[500] = ShoppLookup::errors('uploads', $file['error']);
     1060
     1061        if ( ! is_uploaded_file($file['tmp_name']) )
     1062            $error[500] = Shopp::__('The file could not be saved because the uploaded file was not found on the server.');
     1063
     1064        if ( ! is_readable($file['tmp_name']) )
     1065            $error[500] = Shopp::__('The file could not be saved because the web server does not have permission to read the upload from the server\'s temporary directory.');
     1066
     1067        if ( 0 == $file['size'] )
     1068            $error[400] = Shopp::__('The file could not be saved because the selected file is empty.');
     1069
     1070        if ( 0 == filesize($file['tmp_name']) )
     1071            $error[500] = Shopp::__('The file could not be saved because the uploaded file is empty.');
     1072
     1073        if ( ! empty($error) )
     1074            wp_die(current($error), key($error));
     1075
     1076        return false;
     1077    }
    10481078
    10491079    /**
    10501080     * AJAX behavior to process uploaded images
    10511081     *
    1052      * @author Jonathan Davis
     1082     * @since 1.3
    10531083     * @return string JSON encoded result with thumbnail id and src
    10541084     **/
    1055     public static function images () {
    1056         $context = false;
    1057         $error = false;
    1058         $valid_contexts = array('product', 'category');
    1059 
    1060         if ( isset($_FILES['Filedata']['error']) )
    1061             $error = $_FILES['Filedata']['error'];
    1062         if ( $error ) die( json_encode(array('error' => Lookup::errors('uploads', $error))) );
    1063 
    1064         if ( isset($_REQUEST['type']) && in_array(strtolower($_REQUEST['type']), $valid_contexts ) ) {
    1065             $parent = $_REQUEST['parent'];
    1066             $context = strtolower($_REQUEST['type']);
    1067         }
    1068 
    1069         if ( ! $context )
    1070             die(json_encode(array('error' => Shopp::__('The file could not be saved because the server cannot tell whether to attach the asset to a product or a category.'))));
    1071 
    1072         if ( ! @is_uploaded_file($_FILES['Filedata']['tmp_name']) )
    1073             die(json_encode(array('error' => Shopp::__('The file could not be saved because the upload was not found on the server.'))));
    1074 
    1075         if ( 0 == $_FILES['Filedata']['size'] )
    1076             die(json_encode(array('error' => Shopp::__('The file could not be saved because the uploaded file is empty.'))));
     1085    public static function images ($file, $parent = false, $context = false) {
     1086
     1087        $ContextClasses = array(
     1088            'category' => 'CategoryImage',
     1089            'product' => 'ProductImage'
     1090        );
     1091
     1092        if ( ! in_array(strtolower($context), array_keys($ContextClasses)) )
     1093            wp_die(Shopp::__('The file could not be saved because the request did not specify whether it is a product or a category image.'), 400);
     1094
     1095        self::uploaderrs($file);
    10771096
    10781097        // Save the source image
    1079         if ( 'category' == $context )
    1080             $Image = new CategoryImage();
    1081         else $Image = new ProductImage();
    1082 
     1098        $Image = new $ContextClasses[ $context ]();
    10831099        $Image->parent = $parent;
    10841100        $Image->type = 'image';
    10851101        $Image->name = 'original';
    1086         $Image->filename = $_FILES['Filedata']['name'];
    1087 
    1088         $context = 'upload';
    1089         $tempfile = $_FILES['Filedata']['tmp_name'];
    1090 
    1091         if ( ! @is_readable($tempfile) ) {
    1092 
    1093             $context = 'file';
    1094             $tempfile = get_temp_dir() . $Image->filename;
    1095 
    1096             if ( ! @move_uploaded_file($_FILES['Filedata']['tmp_name'], $tempfile) )
    1097                 die(json_encode(array('error' => Shopp::__('The file could not be saved because the web server does not have permission to read the upload.'))));
    1098 
    1099         }
    1100 
    1101         list($Image->width, $Image->height, $Image->mime, $Image->attr) = getimagesize($tempfile);
     1102        $Image->filename = $file['name'];
     1103        list($Image->width, $Image->height, $Image->mime, $Image->attr) = getimagesize($file['tmp_name']);
    11021104        $Image->mime = image_type_to_mime_type($Image->mime);
    1103         $Image->size = filesize($tempfile);
    1104 
    1105         if ( ! $Image->unique() ) die(json_encode(array('error' => Shopp::__('The image already exists, but a new filename could not be generated.'))));
    1106 
    1107         $Image->store($tempfile, $context);
    1108 
    1109         if( 'file' == $context )
    1110             unlink($tempfile);
    1111 
     1105        $Image->size = filesize($file['tmp_name']);
     1106
     1107        if ( ! $Image->unique() )
     1108            wp_die(Shopp::__('Server error: the image already exists and a new file could not be generated.'), 500);
     1109
     1110        $Image->store($file['tmp_name'], 'upload');
    11121111        $Error = ShoppErrors()->code('storage_engine_save');
    1113         if ( ! empty($Error) ) die( json_encode( array('error' => $Error->message(true)) ) );
     1112        if ( ! empty($Error) )
     1113            wp_die($Error->message(true), 500);
    11141114
    11151115        $Image->save();
    11161116
    11171117        if ( empty($Image->id) )
    1118             die(json_encode(array('error' => Shopp::__('The image reference was not saved to the database.'))));
    1119 
    1120         echo json_encode(array('id' => $Image->id));
    1121         exit;
     1118            wp_die(Shopp::__('The image reference was not saved to the database.'), 500);
     1119
     1120        header('Content-Type: application/json');
     1121        wp_die(json_encode(array('id' => $Image->id)));
    11221122    }
    11231123
  • shopp/trunk/core/library/Core.php

    r1473303 r1859263  
    974974            case 'json': return 'application/json';
    975975            case 'xml': return 'application/xml';
    976             case 'swf': return 'application/x-shockwave-flash';
    977976
    978977            // images
  • shopp/trunk/core/library/Loader.php

    r1473303 r1859263  
    572572    'shopppage' => '/flow/Pages.php',
    573573    'shopppages' => '/flow/Pages.php',
     574    'shopppartialupload' => '/library/PartialUpload.php',
    574575    'shopppaymentoption' => '/model/Payments.php',
    575576    'shopppayments' => '/model/Payments.php',
  • shopp/trunk/core/library/Version.php

    r1648469 r1859263  
    1919
    2020    /** @type int MINOR The minor version number */
    21     const MINOR = 3;
     21    const MINOR = 4;
    2222
    2323    /** @type int PATCH The maintenance patch version number */
    24     const PATCH = 13;
     24    const PATCH = 0;
    2525
    2626    /** @type string PRERELEASE The prerelease designation (dev, beta, RC1) */
     
    2828
    2929    /** @type string CODENAME The release project code name */
    30     const CODENAME = 'Cymru';
     30    const CODENAME = 'Neptune';
    3131
    3232    /** @type int DB The database schema version */
  • shopp/trunk/core/model/Tax.php

    r1648469 r1859263  
    6363        if ( ! shopp_setting_enabled('taxes') ) return false;
    6464
    65         $eu        = false;    // Track EU tax key
    66         $override  =  array(); // Track taxrate overrides
     65        $eukeys    = array();  // Track EUVAT keys
     66        $override  = array();  // Track EU country VAT overrides
    6767        $taxrates  = shopp_setting('taxrates');
    6868        $fallbacks = array();
     
    103103            $settings[ $key ] = $setting;
    104104
    105             if ( self::EUVAT == $country ) $eu = $key;
     105            if ( self::EUVAT == $country ) $eukeys[] = $key;
    106106            if ( in_array($country, Lookup::country_euvat()) ) $override[ $key ] = $country;
    107107        }
     
    110110            $settings = $fallbacks;
    111111
    112         if ( false !== $eu && ! empty($override) ) unset($settings[ $eu ]) ;
     112        if ( count($eukeys) > 0 && count($override) > 0 ) {
     113            // Overall EUVAT and EUVAT for specific EU country detected, unset overall EUVAT
     114            foreach ( $eukeys as $eukey )
     115                unset($settings[ $eukey ]) ;
     116                }
     117
     118        if ( count($eukeys) > 1 ) {
     119            //Multiple EUVAT detected, unset least specific ones
     120            $arr = array();
     121            foreach ( $eukeys as $eukey ){
     122                $score = 0;
     123                if ( ! empty($settings[ $eukey ]['zone']) ) $score++;
     124                if ( ! empty($settings[ $eukey ]['rules']) ) $score++;
     125                $arr[ $score ] = $eukey;
     126            }
     127
     128            $eukeys = array_slice($arr, 0, count($arr)-1 );
     129
     130            foreach ( $eukeys as $eukey )
     131                unset($settings[ $eukey ]) ;
     132        }
    113133
    114134        $settings = apply_filters('shopp_cart_taxrate_settings', $settings); // @deprecated Use shopp_tax_rate_settings instead
  • shopp/trunk/core/ui/behaviors/calendar.js

    r1020997 r1859263  
    320320    if ( input !== false && input.length > 0 ) {
    321321        pos = input.offset();
    322         pad = $('#wpadminbar').size() > 0 ? $('#wpadminbar').height() * -1 : 0;
     322        pad = $('#wpadminbar').length > 0 ? $('#wpadminbar').height() * -1 : 0;
    323323
    324324        if (pos.left+pos.top == 0) {
  • shopp/trunk/core/ui/behaviors/calendar.min.js

    r1473303 r1859263  
    1 jQuery.fn.PopupCalendar=function(e){var t=jQuery,n=this,a=t(this),s={month:(new Date).getMonth()+1,year:(new Date).getFullYear(),selection:!1,m_input:!1,d_input:!1,y_input:!1,input:!1,startWeek:0,title:"my",scheduling:!0,scheduleAfter:!1,disabled:"disabled",scopeMonth:"month",active:"active",selected:"selected",hover:"hover",autoinit:!1},e=t.extend(s,e),l=new Array(new Array(0,31,28,31,30,31,30,31,31,30,31,30,31),new Array(0,31,29,31,30,31,30,31,31,30,31,30,31)),i=new Array("",$cal.jan,$cal.feb,$cal.mar,$cal.apr,$cal.may,$cal.jun,$cal.jul,$cal.aug,$cal.sep,$cal.oct,$cal.nov,$cal.dec),c=new Array($cal.sun,$cal.mon,$cal.tue,$cal.wed,$cal.thu,$cal.fri,$cal.sat),o=639787,r=11,u=42,d=4,p=6,h=new Array(30,31,1,2,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1)),f=new Date,g=new Array,v=new Array,y=(e.month,e.year,e.m_input),w=e.d_input,m=e.y_input,D=y?y:e.input,T=y?y.add(w).add(m):D,A=e.startWeek,M=e.title,$=e.autoinit,C=e.disabled,Y=e.scopeMonth,k=e.active,b=e.selected,F=e.hover;return f=new Date(f.getFullYear(),f.getMonth(),f.getDate()),n.scope=Y,n.scheduling=e.scheduling,n.selection=e.selection?e.selection:f,n.ui=!1,a.mouseenter(function(){n.ui=!0}).mouseleave(function(){n.ui=!1}),n.change(function(){return D!==!1&&D.val(n.selection.getMonth()+1+"/"+n.selection.getDate()+"/"+n.selection.getFullYear()),y!==!1&&y.val(n.selection.getMonth()+1),w!==!1&&w.val(n.selection.getDate()),m!==!1&&m.val(n.selection.getFullYear()),n.focused&&n.focused.select(),this}),n.bind("updated",function(){var e=!1;y!==!1&&""!=y.val()&&""!=w.val()&&""!=m.val()?n.select(new Date(m.val(),y.val()-1,w.val())):D!==!1&&(e=D.val().match(/^(\d{1,2}).{1}(\d{1,2}).{1}(\d{4})/),e&&n.select(new Date(e[3],e[1]-1,e[2])))}),n.select=function(e){e&&(e instanceof Date?n.selection=e:n.selection=new Date(e)),n.change().render(n.selection.getMonth()+1,n.selection.getFullYear()).autoselect()},n.render=function(s,l){a.empty();var o,r,u,d,p,h,y,w,m=0,D=0,T=0,$=!1,_=new Array,S=new Array;for(s||(s=n.selection.getMonth()+1),l||(l=n.selection.getFullYear()),v=this.getDayMap(s,l,A,!0),e.scheduleAfter.selection&&($=e.scheduleAfter.selection),e.scheduleAfter===!1&&($=f),o=t('<span class="back">&#9664;</span>').appendTo(a),r=new Date(l,s-1,0),(!n.scheduling||n.scheduling&&r.getTime()>=$.getTime())&&o.click(function(){n.scope=Y,n.selection=new Date(l,s-2),n.render(n.selection.getMonth()+1,n.selection.getFullYear()),n.change()}),u=t('<span class="next">&#9654;</span>').click(function(){n.scope=Y,n.selection=new Date(l,s),n.render(n.selection.getMonth()+1,n.selection.getFullYear()),n.change()}).appendTo(a),d=t("<h3></h3>").appendTo(a),m=0;m<M.length;m++)-1!=t.inArray(M[m],["m","n","M","F"])&&t('<span class="month">'+i[s]+"</span>").appendTo(d),-1!=t.inArray(M[m],["y","Y"])&&t('<span class="year">'+l.toString()+"</span>").appendTo(d),t("<span> </span>").appendTo(d);for(S[D]=t('<div class="week"></week>').appendTo(a),T=A,m=0;m<7;m++)p=c[T],_[m]=t('<div class="label">'+p.substr(0,3)+"</span>").appendTo(S[D]),T++,T>=c.length&&(T=0);for(m=0;m<v.length;m++){var h=v[m].getMonth()+1,y=v[m].getFullYear(),w=new Date(y,h-1,v[m].getDate());m%7==0&&(S[++D]=t('<div class="week"></div>').appendTo(a)),v[m]!=-1&&(g[m]=t('<div title="'+m+'">'+w.getDate()+"</div>").appendTo(S[D]),g[m].date=w,h!=s&&g[m].addClass(C),n.scheduling&&w.getTime()<$.getTime()&&g[m].addClass(C),w.getTime()==f.getTime()&&g[m].addClass("today"),g[m].hover(function(){t(this).addClass(F)},function(){t(this).removeClass(F)}),g[m].mousedown(function(){t(this).addClass(k)}),g[m].mouseup(function(){t(this).removeClass(k)}),(!n.scheduling||n.scheduling&&w.getTime()>=$.getTime())&&g[m].click(function(){n.resetCalendar(),t(this).hasClass(C)||t(this).addClass(b),n.select(v[t(this).attr("title")]),n.scope="day",n.selection.getMonth()+1!=s?(n.render(n.selection.getMonth()+1,n.selection.getFullYear()),n.autoselect()):(n.ui=!1,a.hide()),n.change().trigger("calendarSelect")}))}return this},n.autoselect=function(){for(var e=0;e<v.length;e++)if(v[e].getTime()==n.selection.getTime())return g[e].addClass(b)},n.resetCalendar=function(){for(var e=0;e<g.length;e++)g[e].removeClass(b)},n.getDayMap=function(e,t,a,s){var i,c,o,r,d,p,f=1,g=0,v=new Array,y=e-1==0?12:e-1,w=12==y?t-1:t;if(9==e&&1752==t)return h;for(i=0;i<u;i++)v.push(-1);if(c=l[n.is_leapyear(w)?1:0][y],o=l[n.is_leapyear(t)?1:0][e],r=n.dayInWeek(1,e,t,a),d=n.dayInWeek(1,e,t,a),s)for(;d--;)v[d]=new Date(w,y-1,(c--));for(;o--;)v[r++]=new Date(t,e-1,(f++));if(p=v.length-r,s)for(;g<p;)v[r++]=new Date(t,e,(++g));return v},n.dayInYear=function(e,t,a){var s,i=n.is_leapyear(a)?1:0;for(s=1;s<t;s++)e+=l[i][s];return e},n.dayInWeek=function(e,t,a,s){var l=365*(a-1)+n.leapYearsSinceBC(a-1)+n.dayInYear(e,t,a),i=d;return l<o&&(i=(l-1+p)%7),l>=o+r&&(i=(l-1+p-r)%7),i<=s?i+=7-s:i-=s},n.is_leapyear=function(e){return e<=1752?!(e%4):!(e%4)&&e%100>0||!(e%400)},n.centuriesSince1700=function(e){return e>1700?Math.floor(e/100)-17:0},n.quadCenturiesSince1700=function(e){return e>1600?Math.floor((e-1600)/400):0},n.leapYearsSinceBC=function(e){return Math.floor(e/4)-n.centuriesSince1700(e)+n.quadCenturiesSince1700(e)},D!==!1&&D.length>0&&(pos=D.offset(),pad=t("#wpadminbar").size()>0?t("#wpadminbar").height()*-1:0,pos.left+pos.top==0&&(pos=D.parent().parent().css("display","block").offset(),pad=6),a.css({left:pos.left+"px",top:pos.top+D.outerHeight(!0)+"px"}),y!==!1&&m.val()+y.val()+w.val()!=""&&(n.selection=new Date(m.val(),y.val()-1,w.val())),T.focus(function(e){var s=t(this).offset();a.css({left:s.left+"px",top:s.top+"px"}),n.show(),n.focused=t(this)}).click(function(){n.focused&&n.focused.focus().select()}).blur(function(e){n.ui?t(this).focus().select():n.hide()}).bind("change.input",function(){n.trigger("updated")}).trigger("change.input")),e.scheduleAfter.selection&&e.scheduleAfter.change(function(){n.render().autoselect()}),$&&n.change(),n.render().autoselect(),this};
     1jQuery.fn.PopupCalendar=function(e){var t=jQuery,n=this,a=t(this),s={month:(new Date).getMonth()+1,year:(new Date).getFullYear(),selection:!1,m_input:!1,d_input:!1,y_input:!1,input:!1,startWeek:0,title:"my",scheduling:!0,scheduleAfter:!1,disabled:"disabled",scopeMonth:"month",active:"active",selected:"selected",hover:"hover",autoinit:!1},l=(e=t.extend(s,e),new Array(new Array(0,31,28,31,30,31,30,31,31,30,31,30,31),new Array(0,31,29,31,30,31,30,31,31,30,31,30,31))),i=new Array("",$cal.jan,$cal.feb,$cal.mar,$cal.apr,$cal.may,$cal.jun,$cal.jul,$cal.aug,$cal.sep,$cal.oct,$cal.nov,$cal.dec),c=new Array($cal.sun,$cal.mon,$cal.tue,$cal.wed,$cal.thu,$cal.fri,$cal.sat),o=new Array(30,31,1,2,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1),r=new Date,u=new Array,d=new Array,p=(e.month,e.year,e.m_input),h=e.d_input,f=e.y_input,g=p||e.input,v=p?p.add(h).add(f):g,y=e.startWeek,w=e.title,m=e.autoinit,D=e.disabled,T=e.scopeMonth,A=e.active,M=e.selected,$=e.hover;return r=new Date(r.getFullYear(),r.getMonth(),r.getDate()),n.scope=T,n.scheduling=e.scheduling,n.selection=e.selection?e.selection:r,n.ui=!1,a.mouseenter(function(){n.ui=!0}).mouseleave(function(){n.ui=!1}),n.change(function(){return!1!==g&&g.val(n.selection.getMonth()+1+"/"+n.selection.getDate()+"/"+n.selection.getFullYear()),!1!==p&&p.val(n.selection.getMonth()+1),!1!==h&&h.val(n.selection.getDate()),!1!==f&&f.val(n.selection.getFullYear()),n.focused&&n.focused.select(),this}),n.bind("updated",function(){var e=!1;!1!==p&&""!=p.val()&&""!=h.val()&&""!=f.val()?n.select(new Date(f.val(),p.val()-1,h.val())):!1!==g&&(e=g.val().match(/^(\d{1,2}).{1}(\d{1,2}).{1}(\d{4})/))&&n.select(new Date(e[3],e[1]-1,e[2]))}),n.select=function(e){e&&(e instanceof Date?n.selection=e:n.selection=new Date(e)),n.change().render(n.selection.getMonth()+1,n.selection.getFullYear()).autoselect()},n.render=function(s,l){a.empty();var o,p,h,f,g=0,v=0,m=0,C=!1,Y=new Array,k=new Array;for(s||(s=n.selection.getMonth()+1),l||(l=n.selection.getFullYear()),d=this.getDayMap(s,l,y,!0),e.scheduleAfter.selection&&(C=e.scheduleAfter.selection),!1===e.scheduleAfter&&(C=r),o=t('<span class="back">&#9664;</span>').appendTo(a),p=new Date(l,s-1,0),(!n.scheduling||n.scheduling&&p.getTime()>=C.getTime())&&o.click(function(){n.scope=T,n.selection=new Date(l,s-2),n.render(n.selection.getMonth()+1,n.selection.getFullYear()),n.change()}),t('<span class="next">&#9654;</span>').click(function(){n.scope=T,n.selection=new Date(l,s),n.render(n.selection.getMonth()+1,n.selection.getFullYear()),n.change()}).appendTo(a),h=t("<h3></h3>").appendTo(a),g=0;g<w.length;g++)-1!=t.inArray(w[g],["m","n","M","F"])&&t('<span class="month">'+i[s]+"</span>").appendTo(h),-1!=t.inArray(w[g],["y","Y"])&&t('<span class="year">'+l.toString()+"</span>").appendTo(h),t("<span> </span>").appendTo(h);for(k[v]=t('<div class="week"></week>').appendTo(a),m=y,g=0;g<7;g++)f=c[m],Y[g]=t('<div class="label">'+f.substr(0,3)+"</span>").appendTo(k[v]),++m>=c.length&&(m=0);for(g=0;g<d.length;g++){var b=d[g].getMonth()+1,F=d[g].getFullYear(),_=new Date(F,b-1,d[g].getDate());g%7==0&&(k[++v]=t('<div class="week"></div>').appendTo(a)),-1!=d[g]&&(u[g]=t('<div title="'+g+'">'+_.getDate()+"</div>").appendTo(k[v]),u[g].date=_,b!=s&&u[g].addClass(D),n.scheduling&&_.getTime()<C.getTime()&&u[g].addClass(D),_.getTime()==r.getTime()&&u[g].addClass("today"),u[g].hover(function(){t(this).addClass($)},function(){t(this).removeClass($)}),u[g].mousedown(function(){t(this).addClass(A)}),u[g].mouseup(function(){t(this).removeClass(A)}),(!n.scheduling||n.scheduling&&_.getTime()>=C.getTime())&&u[g].click(function(){n.resetCalendar(),t(this).hasClass(D)||t(this).addClass(M),n.select(d[t(this).attr("title")]),n.scope="day",n.selection.getMonth()+1!=s?(n.render(n.selection.getMonth()+1,n.selection.getFullYear()),n.autoselect()):(n.ui=!1,a.hide()),n.change().trigger("calendarSelect")}))}return this},n.autoselect=function(){for(var e=0;e<d.length;e++)if(d[e].getTime()==n.selection.getTime())return u[e].addClass(M)},n.resetCalendar=function(){for(var e=0;e<u.length;e++)u[e].removeClass(M)},n.getDayMap=function(e,t,a,s){var i,c,r,u,d,p,h=1,f=0,g=new Array,v=e-1==0?12:e-1,y=12==v?t-1:t;if(9==e&&1752==t)return o;for(i=0;i<42;i++)g.push(-1);if(c=l[n.is_leapyear(y)?1:0][v],r=l[n.is_leapyear(t)?1:0][e],u=n.dayInWeek(1,e,t,a),d=n.dayInWeek(1,e,t,a),s)for(;d--;)g[d]=new Date(y,v-1,c--);for(;r--;)g[u++]=new Date(t,e-1,h++);if(p=g.length-u,s)for(;f<p;)g[u++]=new Date(t,e,++f);return g},n.dayInYear=function(e,t,a){var s,i=n.is_leapyear(a)?1:0;for(s=1;s<t;s++)e+=l[i][s];return e},n.dayInWeek=function(e,t,a,s){var l=365*(a-1)+n.leapYearsSinceBC(a-1)+n.dayInYear(e,t,a),i=4;return l<639787&&(i=(l-1+6)%7),l>=639798&&(i=(l-1+6-11)%7),i<=s?i+=7-s:i-=s},n.is_leapyear=function(e){return e<=1752?!(e%4):!(e%4)&&e%100>0||!(e%400)},n.centuriesSince1700=function(e){return e>1700?Math.floor(e/100)-17:0},n.quadCenturiesSince1700=function(e){return e>1600?Math.floor((e-1600)/400):0},n.leapYearsSinceBC=function(e){return Math.floor(e/4)-n.centuriesSince1700(e)+n.quadCenturiesSince1700(e)},!1!==g&&g.length>0&&(pos=g.offset(),pad=t("#wpadminbar").size()>0?-1*t("#wpadminbar").height():0,pos.left+pos.top==0&&(pos=g.parent().parent().css("display","block").offset(),pad=6),a.css({left:pos.left+"px",top:pos.top+g.outerHeight(!0)+"px"}),!1!==p&&f.val()+p.val()+h.val()!=""&&(n.selection=new Date(f.val(),p.val()-1,h.val())),v.focus(function(e){var s=t(this).offset();a.css({left:s.left+"px",top:s.top+"px"}),n.show(),n.focused=t(this)}).click(function(){n.focused&&n.focused.focus().select()}).blur(function(e){n.ui?t(this).focus().select():n.hide()}).bind("change.input",function(){n.trigger("updated")}).trigger("change.input")),e.scheduleAfter.selection&&e.scheduleAfter.change(function(){n.render().autoselect()}),m&&n.change(),n.render().autoselect(),this};
  • shopp/trunk/core/ui/behaviors/colorbox.js

    r821385 r1859263  
    11/*!
    2     Colorbox v1.4.27 - 2013-07-16
    3     jQuery lightbox and modal window plugin
    4     (c) 2013 Jack Moore - http://www.jacklmoore.com/colorbox
    5     license: http://www.opensource.org/licenses/mit-license.php
     2    Colorbox 1.6.4
     3    license: MIT
     4    http://www.jacklmoore.com/colorbox
    65*/
    76(function ($, document, window) {
     
    109    // See http://jacklmoore.com/colorbox for details.
    1110    defaults = {
     11        // data sources
     12        html: false,
     13        photo: false,
     14        iframe: false,
     15        inline: false,
     16
     17        // behavior and appearance
    1218        transition: "elastic",
    1319        speed: 300,
     
    2329        scalePhotos: true,
    2430        scrolling: true,
    25         inline: false,
    26         html: false,
    27         iframe: false,
    28         fastIframe: true,
    29         photo: false,
    30         href: false,
    31         title: false,
    32         rel: false,
    33         opacity: 0.7,
     31        opacity: 0.9,
    3432        preloading: true,
    3533        className: false,
    36 
    37         // alternate image paths for high-res displays
    38         retinaImage: false,
    39         retinaUrl: false,
    40         retinaSuffix: '@2x.$1',
    41 
    42         // internationalization
    43         current: "image {current} of {total}",
    44         previous: "previous",
    45         next: "next",
    46         close: "close",
    47         xhrError: "This content failed to load.",
    48         imgError: "This image failed to load.",
    49 
    50         open: false,
    51         returnFocus: true,
    52         trapFocus: true,
    53         reposition: true,
    54         loop: true,
    55         slideshow: false,
    56         slideshowAuto: true,
    57         slideshowSpeed: 2500,
    58         slideshowStart: "start slideshow",
    59         slideshowStop: "stop slideshow",
    60         photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,
    61 
    62         onOpen: false,
    63         onLoad: false,
    64         onComplete: false,
    65         onCleanup: false,
    66         onClosed: false,
    67 
    6834        overlayClose: true,
    6935        escKey: true,
     
    7541        fixed: false,
    7642        data: undefined,
    77         closeButton: true
     43        closeButton: true,
     44        fastIframe: true,
     45        open: false,
     46        reposition: true,
     47        loop: true,
     48        slideshow: false,
     49        slideshowAuto: true,
     50        slideshowSpeed: 2500,
     51        slideshowStart: "start slideshow",
     52        slideshowStop: "stop slideshow",
     53        photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i,
     54
     55        // alternate image paths for high-res displays
     56        retinaImage: false,
     57        retinaUrl: false,
     58        retinaSuffix: '@2x.$1',
     59
     60        // internationalization
     61        current: "image {current} of {total}",
     62        previous: "previous",
     63        next: "next",
     64        close: "close",
     65        xhrError: "This content failed to load.",
     66        imgError: "This image failed to load.",
     67
     68        // accessbility
     69        returnFocus: true,
     70        trapFocus: true,
     71
     72        // callbacks
     73        onOpen: false,
     74        onLoad: false,
     75        onComplete: false,
     76        onCleanup: false,
     77        onClosed: false,
     78
     79        rel: function() {
     80            return this.rel;
     81        },
     82        href: function() {
     83            // using this.href would give the absolute url, when the href may have been inteded as a selector (e.g. '#container')
     84            return $(this).attr('href');
     85        },
     86        title: function() {
     87            return this.title;
     88        },
     89        createImg: function() {
     90            var img = new Image();
     91            var attrs = $(this).data('cbox-img-attrs');
     92
     93            if (typeof attrs === 'object') {
     94                $.each(attrs, function(key, val){
     95                    img[key] = val;
     96                });
     97            }
     98
     99            return img;
     100        },
     101        createIframe: function() {
     102            var iframe = document.createElement('iframe');
     103            var attrs = $(this).data('cbox-iframe-attrs');
     104
     105            if (typeof attrs === 'object') {
     106                $.each(attrs, function(key, val){
     107                    iframe[key] = val;
     108                });
     109            }
     110
     111            if ('frameBorder' in iframe) {
     112                iframe.frameBorder = 0;
     113            }
     114            if ('allowTransparency' in iframe) {
     115                iframe.allowTransparency = "true";
     116            }
     117            iframe.name = (new Date()).getTime(); // give the iframe a unique name to prevent caching
     118            iframe.allowFullscreen = true;
     119
     120            return iframe;
     121        }
    78122    },
    79123
     
    112156    $close,
    113157    $groupControls,
    114     $events = $('<a/>'),
     158    $events = $('<a/>'), // $({}) would be prefered, but there is an issue with jQuery 1.4.2
    115159
    116160    // Variables for cached values or use across multiple functions
     
    120164    loadedHeight,
    121165    loadedWidth,
    122     element,
    123166    index,
    124167    photo,
     
    129172    publicMethod,
    130173    div = "div",
    131     className,
    132174    requests = 0,
    133175    previousCSS = {},
     
    157199    function winheight() {
    158200        return window.innerHeight ? window.innerHeight : $(window).height();
     201    }
     202
     203    function Settings(element, options) {
     204        if (options !== Object(options)) {
     205            options = {};
     206        }
     207
     208        this.cache = {};
     209        this.el = element;
     210
     211        this.value = function(key) {
     212            var dataAttr;
     213
     214            if (this.cache[key] === undefined) {
     215                dataAttr = $(this.el).attr('data-cbox-'+key);
     216
     217                if (dataAttr !== undefined) {
     218                    this.cache[key] = dataAttr;
     219                } else if (options[key] !== undefined) {
     220                    this.cache[key] = options[key];
     221                } else if (defaults[key] !== undefined) {
     222                    this.cache[key] = defaults[key];
     223                }
     224            }
     225
     226            return this.cache[key];
     227        };
     228
     229        this.get = function(key) {
     230            var value = this.value(key);
     231            return $.isFunction(value) ? value.call(this.el, this) : value;
     232        };
    159233    }
    160234
     
    176250    // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex.
    177251    function isImage(settings, url) {
    178         return settings.photo || settings.photoRegex.test(url);
     252        return settings.get('photo') || settings.get('photoRegex').test(url);
    179253    }
    180254
    181255    function retinaUrl(settings, url) {
    182         return settings.retinaUrl && window.devicePixelRatio > 1 ? url.replace(settings.photoRegex, settings.retinaSuffix) : url;
     256        return settings.get('retinaUrl') && window.devicePixelRatio > 1 ? url.replace(settings.get('photoRegex'), settings.get('retinaSuffix')) : url;
    183257    }
    184258
    185259    function trapFocus(e) {
    186         if ('contains' in $box[0] && !$box[0].contains(e.target)) {
     260        if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) {
    187261            e.stopPropagation();
    188262            $box.focus();
     
    190264    }
    191265
    192     // Assigns function results to their respective properties
    193     function makeSettings() {
    194         var i,
    195             data = $.data(element, colorbox);
    196 
    197         if (data == null) {
    198             settings = $.extend({}, defaults);
    199             if (console && console.log) {
    200                 console.log('Error: cboxElement missing settings object');
     266    function setClass(str) {
     267        if (setClass.str !== str) {
     268            $box.add($overlay).removeClass(setClass.str).addClass(str);
     269            setClass.str = str;
     270        }
     271    }
     272
     273    function getRelated(rel) {
     274        index = 0;
     275
     276        if (rel && rel !== false && rel !== 'nofollow') {
     277            $related = $('.' + boxElement).filter(function () {
     278                var options = $.data(this, colorbox);
     279                var settings = new Settings(this, options);
     280                return (settings.get('rel') === rel);
     281            });
     282            index = $related.index(settings.el);
     283
     284            // Check direct calls to Colorbox.
     285            if (index === -1) {
     286                $related = $related.add(settings.el);
     287                index = $related.length - 1;
    201288            }
    202289        } else {
    203             settings = $.extend({}, data);
    204         }
    205 
    206         for (i in settings) {
    207             if ($.isFunction(settings[i]) && i.slice(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
    208                 settings[i] = settings[i].call(element);
    209             }
    210         }
    211 
    212         settings.rel = settings.rel || element.rel || $(element).data('rel') || 'nofollow';
    213         settings.href = settings.href || $(element).attr('href');
    214         settings.title = settings.title || element.title;
    215 
    216         if (typeof settings.href === "string") {
    217             settings.href = $.trim(settings.href);
    218         }
    219     }
    220 
    221     function trigger(event, callback) {
     290            $related = $(settings.el);
     291        }
     292    }
     293
     294    function trigger(event) {
    222295        // for external use
    223296        $(document).trigger(event);
    224 
    225297        // for internal use
    226         $events.trigger(event);
    227 
    228         if ($.isFunction(callback)) {
    229             callback.call(element);
    230         }
    231     }
    232 
    233     // Slideshow functionality
    234     function slideshow() {
    235         var
    236         timeOut,
    237         className = prefix + "Slideshow_",
    238         click = "click." + prefix,
    239         clear,
    240         set,
    241         start,
    242         stop;
    243 
    244         if (settings.slideshow && $related[1]) {
    245             clear = function () {
    246                 clearTimeout(timeOut);
    247             };
    248 
    249             set = function () {
    250                 if (settings.loop || $related[index + 1]) {
    251                     timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
    252                 }
    253             };
    254 
    255             start = function () {
    256                 $slideshow
    257                     .html(settings.slideshowStop)
    258                     .unbind(click)
    259                     .one(click, stop);
    260 
    261                 $events
    262                     .bind(event_complete, set)
    263                     .bind(event_load, clear)
    264                     .bind(event_cleanup, stop);
    265 
    266                 $box.removeClass(className + "off").addClass(className + "on");
    267             };
    268 
    269             stop = function () {
     298        $events.triggerHandler(event);
     299    }
     300
     301    var slideshow = (function(){
     302        var active,
     303            className = prefix + "Slideshow_",
     304            click = "click." + prefix,
     305            timeOut;
     306
     307        function clear () {
     308            clearTimeout(timeOut);
     309        }
     310
     311        function set() {
     312            if (settings.get('loop') || $related[index + 1]) {
    270313                clear();
    271 
    272                 $events
    273                     .unbind(event_complete, set)
    274                     .unbind(event_load, clear)
    275                     .unbind(event_cleanup, stop);
    276 
    277                 $slideshow
    278                     .html(settings.slideshowStart)
    279                     .unbind(click)
    280                     .one(click, function () {
    281                         publicMethod.next();
     314                timeOut = setTimeout(publicMethod.next, settings.get('slideshowSpeed'));
     315            }
     316        }
     317
     318        function start() {
     319            $slideshow
     320                .html(settings.get('slideshowStop'))
     321                .unbind(click)
     322                .one(click, stop);
     323
     324            $events
     325                .bind(event_complete, set)
     326                .bind(event_load, clear);
     327
     328            $box.removeClass(className + "off").addClass(className + "on");
     329        }
     330
     331        function stop() {
     332            clear();
     333
     334            $events
     335                .unbind(event_complete, set)
     336                .unbind(event_load, clear);
     337
     338            $slideshow
     339                .html(settings.get('slideshowStart'))
     340                .unbind(click)
     341                .one(click, function () {
     342                    publicMethod.next();
     343                    start();
     344                });
     345
     346            $box.removeClass(className + "on").addClass(className + "off");
     347        }
     348
     349        function reset() {
     350            active = false;
     351            $slideshow.hide();
     352            clear();
     353            $events
     354                .unbind(event_complete, set)
     355                .unbind(event_load, clear);
     356            $box.removeClass(className + "off " + className + "on");
     357        }
     358
     359        return function(){
     360            if (active) {
     361                if (!settings.get('slideshow')) {
     362                    $events.unbind(event_cleanup, reset);
     363                    reset();
     364                }
     365            } else {
     366                if (settings.get('slideshow') && $related[1]) {
     367                    active = true;
     368                    $events.one(event_cleanup, reset);
     369                    if (settings.get('slideshowAuto')) {
    282370                        start();
    283                     });
    284 
    285                 $box.removeClass(className + "on").addClass(className + "off");
    286             };
    287 
    288             if (settings.slideshowAuto) {
    289                 start();
    290             } else {
    291                 stop();
    292             }
    293         } else {
    294             $box.removeClass(className + "off " + className + "on");
    295         }
    296     }
    297 
    298     function launch(target) {
     371                    } else {
     372                        stop();
     373                    }
     374                    $slideshow.show();
     375                }
     376            }
     377        };
     378
     379    }());
     380
     381
     382    function launch(element) {
     383        var options;
     384
    299385        if (!closing) {
    300386
    301             element = target;
    302 
    303             makeSettings();
    304 
    305             $related = $(element);
    306 
    307             index = 0;
    308 
    309             if (settings.rel !== 'nofollow') {
    310                 $related = $('.' + boxElement).filter(function () {
    311                     var data = $.data(this, colorbox),
    312                         relRelated;
    313 
    314                     if (data) {
    315                         relRelated =  $(this).data('rel') || data.rel || this.rel;
    316                     }
    317 
    318                     return (relRelated === settings.rel);
    319                 });
    320                 index = $related.index(element);
    321 
    322                 // Check direct calls to Colorbox.
    323                 if (index === -1) {
    324                     $related = $related.add(element);
    325                     index = $related.length - 1;
    326                 }
    327             }
    328 
    329             $overlay.css({
    330                 opacity: parseFloat(settings.opacity),
    331                 cursor: settings.overlayClose ? "pointer" : "auto",
    332                 visibility: 'visible'
    333             }).show();
    334 
    335 
    336             if (className) {
    337                 $box.add($overlay).removeClass(className);
    338             }
    339             if (settings.className) {
    340                 $box.add($overlay).addClass(settings.className);
    341             }
    342             className = settings.className;
    343 
    344             if (settings.closeButton) {
    345                 $close.html(settings.close).appendTo($content);
    346             } else {
    347                 $close.appendTo('<div/>');
    348             }
     387            options = $(element).data(colorbox);
     388
     389            settings = new Settings(element, options);
     390
     391            getRelated(settings.get('rel'));
    349392
    350393            if (!open) {
    351394                open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
    352395
     396                setClass(settings.get('className'));
     397
    353398                // Show colorbox so the sizes can be calculated in older versions of jQuery
    354                 $box.css({visibility:'hidden', display:'block'});
    355 
    356                 $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden');
     399                $box.css({visibility:'hidden', display:'block', opacity:''});
     400
     401                $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden; visibility:hidden');
    357402                $content.css({width:'', height:''}).append($loaded);
    358403
     
    364409
    365410                // Opens inital empty Colorbox prior to content being loaded.
    366                 settings.w = setSize(settings.initialWidth, 'x');
    367                 settings.h = setSize(settings.initialHeight, 'y');
     411                var initialWidth = setSize(settings.get('initialWidth'), 'x');
     412                var initialHeight = setSize(settings.get('initialHeight'), 'y');
     413                var maxWidth = settings.get('maxWidth');
     414                var maxHeight = settings.get('maxHeight');
     415
     416                settings.w = Math.max((maxWidth !== false ? Math.min(initialWidth, setSize(maxWidth, 'x')) : initialWidth) - loadedWidth - interfaceWidth, 0);
     417                settings.h = Math.max((maxHeight !== false ? Math.min(initialHeight, setSize(maxHeight, 'y')) : initialHeight) - loadedHeight - interfaceHeight, 0);
     418
     419                $loaded.css({width:'', height:settings.h});
    368420                publicMethod.position();
    369421
    370                 slideshow();
    371 
    372                 trigger(event_open, settings.onOpen);
     422                trigger(event_open);
     423                settings.get('onOpen');
    373424
    374425                $groupControls.add($title).hide();
     
    376427                $box.focus();
    377428
    378 
    379                 if (settings.trapFocus) {
     429                if (settings.get('trapFocus')) {
    380430                    // Confine focus to the modal
    381431                    // Uses event capturing that is not supported in IE8-
     
    391441
    392442                // Return focus on closing
    393                 if (settings.returnFocus) {
     443                if (settings.get('returnFocus')) {
    394444                    $events.one(event_closed, function () {
    395                         $(element).focus();
     445                        $(settings.el).focus();
    396446                    });
    397447                }
     448            }
     449
     450            var opacity = parseFloat(settings.get('opacity'));
     451            $overlay.css({
     452                opacity: opacity === opacity ? opacity : '',
     453                cursor: settings.get('overlayClose') ? 'pointer' : '',
     454                visibility: 'visible'
     455            }).show();
     456
     457            if (settings.get('closeButton')) {
     458                $close.html(settings.get('close')).appendTo($content);
     459            } else {
     460                $close.appendTo('<div/>'); // replace with .detach() when dropping jQuery < 1.4
    398461            }
    399462
     
    405468    // so that the browser will go ahead and load the CSS background images.
    406469    function appendHTML() {
    407         if (!$box && document.body) {
     470        if (!$box) {
    408471            init = false;
    409472            $window = $(window);
     
    422485                $prev = $('<button type="button"/>').attr({id:prefix+'Previous'}),
    423486                $next = $('<button type="button"/>').attr({id:prefix+'Next'}),
    424                 $slideshow = $tag('button', "Slideshow"),
     487                $slideshow = $('<button type="button"/>').attr({id:prefix+'Slideshow'}),
    425488                $loadingOverlay
    426489            );
     
    446509            ).find('div div').css({'float': 'left'});
    447510
    448             $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none');
     511            $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none; max-width:none;');
    449512
    450513            $groupControls = $next.add($prev).add($current).add($slideshow);
    451 
     514        }
     515        if (document.body && !$box.parent().length) {
    452516            $(document.body).append($overlay, $box.append($wrap, $loadingBay));
    453517        }
     
    480544                });
    481545                $overlay.click(function () {
    482                     if (settings.overlayClose) {
     546                    if (settings.get('overlayClose')) {
    483547                        publicMethod.close();
    484548                    }
     
    488552                $(document).bind('keydown.' + prefix, function (e) {
    489553                    var key = e.keyCode;
    490                     if (open && settings.escKey && key === 27) {
     554                    if (open && settings.get('escKey') && key === 27) {
    491555                        e.preventDefault();
    492556                        publicMethod.close();
    493557                    }
    494                     if (open && settings.arrowKey && $related[1] && !e.altKey) {
     558                    if (open && settings.get('arrowKey') && $related[1] && !e.altKey) {
    495559                        if (key === 37) {
    496560                            e.preventDefault();
     
    519583
    520584    // Don't do anything if Colorbox already exists.
    521     if ($.colorbox) {
     585    if ($[colorbox]) {
    522586        return;
    523587    }
     
    534598
    535599    publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
    536         var $this = this;
     600        var settings;
     601        var $obj = this;
    537602
    538603        options = options || {};
    539604
     605        if ($.isFunction($obj)) { // assume a call to $.colorbox
     606            $obj = $('<a/>');
     607            options.open = true;
     608        }
     609
     610        if (!$obj[0]) { // colorbox being applied to empty collection
     611            return $obj;
     612        }
     613
    540614        appendHTML();
    541615
    542616        if (addBindings()) {
    543             if ($.isFunction($this)) { // assume a call to $.colorbox
    544                 $this = $('<a/>');
    545                 options.open = true;
    546             } else if (!$this[0]) { // colorbox being applied to empty collection
    547                 return $this;
    548             }
    549617
    550618            if (callback) {
     
    552620            }
    553621
    554             $this.each(function () {
    555                 $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
     622            $obj.each(function () {
     623                var old = $.data(this, colorbox) || {};
     624                $.data(this, colorbox, $.extend(old, options));
    556625            }).addClass(boxElement);
    557626
    558             if (($.isFunction(options.open) && options.open.call($this)) || options.open) {
    559                 launch($this[0]);
    560             }
    561         }
    562 
    563         return $this;
     627            settings = new Settings($obj[0], options);
     628
     629            if (settings.get('open')) {
     630                launch($obj[0]);
     631            }
     632        }
     633
     634        return $obj;
    564635    };
    565636
     
    581652        scrollLeft = $window.scrollLeft();
    582653
    583         if (settings.fixed) {
     654        if (settings.get('fixed')) {
    584655            offset.top -= scrollTop;
    585656            offset.left -= scrollLeft;
     
    592663
    593664        // keeps the top and left positions within the browser's viewport.
    594         if (settings.right !== false) {
    595             left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
    596         } else if (settings.left !== false) {
    597             left += setSize(settings.left, 'x');
     665        if (settings.get('right') !== false) {
     666            left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.get('right'), 'x'), 0);
     667        } else if (settings.get('left') !== false) {
     668            left += setSize(settings.get('left'), 'x');
    598669        } else {
    599670            left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
    600671        }
    601672
    602         if (settings.bottom !== false) {
    603             top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
    604         } else if (settings.top !== false) {
    605             top += setSize(settings.top, 'y');
     673        if (settings.get('bottom') !== false) {
     674            top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.get('bottom'), 'y'), 0);
     675        } else if (settings.get('top') !== false) {
     676            top += setSize(settings.get('top'), 'y');
    606677        } else {
    607678            top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
     
    651722                $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
    652723
    653                 if (settings.reposition) {
     724                if (settings.get('reposition')) {
    654725                    setTimeout(function () {  // small delay before binding onresize due to an IE8 bug.
    655726                        $window.bind('resize.' + prefix, publicMethod.position);
     
    657728                }
    658729
    659                 if (loadedCallback) {
     730                if ($.isFunction(loadedCallback)) {
    660731                    loadedCallback();
    661732                }
     
    701772            }
    702773
    703             publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
     774            publicMethod.position(settings.get('transition') === "none" ? 0 : settings.get('speed'));
    704775        }
    705776    };
     
    710781        }
    711782
    712         var callback, speed = settings.transition === "none" ? 0 : settings.speed;
    713 
    714         $loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
     783        var callback, speed = settings.get('transition') === "none" ? 0 : settings.get('speed');
     784
     785        $loaded.remove();
    715786
    716787        $loaded = $tag(div, 'LoadedContent').append(object);
     
    729800        $loaded.hide()
    730801        .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
    731         .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
     802        .css({width: getWidth(), overflow: settings.get('scrolling') ? 'auto' : 'hidden'})
    732803        .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
    733804        .prependTo($content);
     
    738809
    739810        $(photo).css({'float': 'none'});
     811
     812        setClass(settings.get('className'));
    740813
    741814        callback = function () {
    742815            var total = $related.length,
    743816                iframe,
    744                 frameBorder = 'frameBorder',
    745                 allowTransparency = 'allowTransparency',
    746817                complete;
    747818
     
    750821            }
    751822
    752             function removeFilter() { // Needed for IE7 & IE8 in versions of jQuery prior to 1.7.2
     823            function removeFilter() { // Needed for IE8 in versions of jQuery prior to 1.7.2
    753824                if ($.support.opacity === false) {
    754825                    $box[0].style.removeAttribute('filter');
     
    759830                clearTimeout(loadingTimer);
    760831                $loadingOverlay.hide();
    761                 trigger(event_complete, settings.onComplete);
     832                trigger(event_complete);
     833                settings.get('onComplete');
    762834            };
    763835
    764             $title.html(settings.title).add($loaded).show();
     836
     837            $title.html(settings.get('title')).show();
     838            $loaded.show();
    765839
    766840            if (total > 1) { // handle grouping
    767                 if (typeof settings.current === "string") {
    768                     $current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show();
    769                 }
    770 
    771                 $next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
    772                 $prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
    773 
    774                 if (settings.slideshow) {
    775                     $slideshow.show();
    776                 }
     841                if (typeof settings.get('current') === "string") {
     842                    $current.html(settings.get('current').replace('{current}', index + 1).replace('{total}', total)).show();
     843                }
     844
     845                $next[(settings.get('loop') || index < total - 1) ? "show" : "hide"]().html(settings.get('next'));
     846                $prev[(settings.get('loop') || index) ? "show" : "hide"]().html(settings.get('previous'));
     847
     848                slideshow();
    777849
    778850                // Preloads images within a rel group
    779                 if (settings.preloading) {
     851                if (settings.get('preloading')) {
    780852                    $.each([getIndex(-1), getIndex(1)], function(){
    781                         var src,
    782                             img,
     853                        var img,
    783854                            i = $related[this],
    784                             data = $.data(i, colorbox);
    785 
    786                         if (data && data.href) {
    787                             src = data.href;
    788                             if ($.isFunction(src)) {
    789                                 src = src.call(i);
    790                             }
    791                         } else {
    792                             src = $(i).attr('href');
    793                         }
    794 
    795                         if (src && isImage(data, src)) {
    796                             src = retinaUrl(data, src);
     855                            settings = new Settings(i, $.data(i, colorbox)),
     856                            src = settings.get('href');
     857
     858                        if (src && isImage(settings, src)) {
     859                            src = retinaUrl(settings, src);
    797860                            img = document.createElement('img');
    798861                            img.src = src;
     
    804867            }
    805868
    806             if (settings.iframe) {
    807                 iframe = $tag('iframe')[0];
    808 
    809                 if (frameBorder in iframe) {
    810                     iframe[frameBorder] = 0;
    811                 }
    812 
    813                 if (allowTransparency in iframe) {
    814                     iframe[allowTransparency] = "true";
    815                 }
    816 
    817                 if (!settings.scrolling) {
     869            if (settings.get('iframe')) {
     870
     871                iframe = settings.get('createIframe');
     872
     873                if (!settings.get('scrolling')) {
    818874                    iframe.scrolling = "no";
    819875                }
     
    821877                $(iframe)
    822878                    .attr({
    823                         src: settings.href,
    824                         name: (new Date()).getTime(), // give the iframe a unique name to prevent caching
    825                         'class': prefix + 'Iframe',
    826                         allowFullScreen : true, // allow HTML5 video to go fullscreen
    827                         webkitAllowFullScreen : true,
    828                         mozallowfullscreen : true
     879                        src: settings.get('href'),
     880                        'class': prefix + 'Iframe'
    829881                    })
    830882                    .one('load', complete)
     
    835887                });
    836888
    837                 if (settings.fastIframe) {
     889                if (settings.get('fastIframe')) {
    838890                    $(iframe).trigger('load');
    839891                }
     
    842894            }
    843895
    844             if (settings.transition === 'fade') {
     896            if (settings.get('transition') === 'fade') {
    845897                $box.fadeTo(speed, 1, removeFilter);
    846898            } else {
     
    849901        };
    850902
    851         if (settings.transition === 'fade') {
     903        if (settings.get('transition') === 'fade') {
    852904            $box.fadeTo(speed, 0, function () {
    853905                publicMethod.position(0, callback);
     
    865917        photo = false;
    866918
    867         element = $related[index];
    868 
    869         makeSettings();
    870 
    871919        trigger(event_purge);
    872 
    873         trigger(event_load, settings.onLoad);
    874 
    875         settings.h = settings.height ?
    876                 setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
    877                 settings.innerHeight && setSize(settings.innerHeight, 'y');
    878 
    879         settings.w = settings.width ?
    880                 setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
    881                 settings.innerWidth && setSize(settings.innerWidth, 'x');
     920        trigger(event_load);
     921        settings.get('onLoad');
     922
     923        settings.h = settings.get('height') ?
     924                setSize(settings.get('height'), 'y') - loadedHeight - interfaceHeight :
     925                settings.get('innerHeight') && setSize(settings.get('innerHeight'), 'y');
     926
     927        settings.w = settings.get('width') ?
     928                setSize(settings.get('width'), 'x') - loadedWidth - interfaceWidth :
     929                settings.get('innerWidth') && setSize(settings.get('innerWidth'), 'x');
    882930
    883931        // Sets the minimum dimensions for use in image scaling
     
    887935        // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
    888936        // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
    889         if (settings.maxWidth) {
    890             settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
     937        if (settings.get('maxWidth')) {
     938            settings.mw = setSize(settings.get('maxWidth'), 'x') - loadedWidth - interfaceWidth;
    891939            settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
    892940        }
    893         if (settings.maxHeight) {
    894             settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
     941        if (settings.get('maxHeight')) {
     942            settings.mh = setSize(settings.get('maxHeight'), 'y') - loadedHeight - interfaceHeight;
    895943            settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
    896944        }
    897945
    898         href = settings.href;
     946        href = settings.get('href');
    899947
    900948        loadingTimer = setTimeout(function () {
     
    902950        }, 100);
    903951
    904         if (settings.inline) {
     952        if (settings.get('inline')) {
     953            var $target = $(href).eq(0);
    905954            // Inserts an empty placeholder where inline content is being pulled from.
    906955            // An event is bound to put inline content back when Colorbox closes or loads new content.
    907             $inline = $tag(div).hide().insertBefore($(href)[0]);
     956            $inline = $('<div>').hide().insertBefore($target);
    908957
    909958            $events.one(event_purge, function () {
    910                 $inline.replaceWith($loaded.children());
     959                $inline.replaceWith($target);
    911960            });
    912961
    913             prep($(href));
    914         } else if (settings.iframe) {
     962            prep($target);
     963        } else if (settings.get('iframe')) {
    915964            // IFrame element won't be added to the DOM until it is ready to be displayed,
    916965            // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
    917966            prep(" ");
    918         } else if (settings.html) {
    919             prep(settings.html);
     967        } else if (settings.get('html')) {
     968            prep(settings.get('html'));
    920969        } else if (isImage(settings, href)) {
    921970
    922971            href = retinaUrl(settings, href);
    923972
    924             photo = document.createElement('img');
     973            photo = settings.get('createImg');
    925974
    926975            $(photo)
    927976            .addClass(prefix + 'Photo')
    928             .bind('error',function () {
    929                 settings.title = false;
    930                 prep($tag(div, 'Error').html(settings.imgError));
     977            .bind('error.'+prefix,function () {
     978                prep($tag(div, 'Error').html(settings.get('imgError')));
    931979            })
    932980            .one('load', function () {
    933                 var percent;
    934 
    935981                if (request !== requests) {
    936982                    return;
    937983                }
    938984
    939                 photo.alt = $(element).attr('alt') || $(element).attr('data-alt') || '';
    940 
    941                 if (settings.retinaImage && window.devicePixelRatio > 1) {
    942                     photo.height = photo.height / window.devicePixelRatio;
    943                     photo.width = photo.width / window.devicePixelRatio;
    944                 }
    945 
    946                 if (settings.scalePhotos) {
    947                     setResize = function () {
    948                         photo.height -= photo.height * percent;
    949                         photo.width -= photo.width * percent;
    950                     };
    951                     if (settings.mw && photo.width > settings.mw) {
    952                         percent = (photo.width - settings.mw) / photo.width;
    953                         setResize();
     985                // A small pause because some browsers will occassionaly report a
     986                // img.width and img.height of zero immediately after the img.onload fires
     987                setTimeout(function(){
     988                    var percent;
     989
     990                    if (settings.get('retinaImage') && window.devicePixelRatio > 1) {
     991                        photo.height = photo.height / window.devicePixelRatio;
     992                        photo.width = photo.width / window.devicePixelRatio;
    954993                    }
    955                     if (settings.mh && photo.height > settings.mh) {
    956                         percent = (photo.height - settings.mh) / photo.height;
    957                         setResize();
     994
     995                    if (settings.get('scalePhotos')) {
     996                        setResize = function () {
     997                            photo.height -= photo.height * percent;
     998                            photo.width -= photo.width * percent;
     999                        };
     1000                        if (settings.mw && photo.width > settings.mw) {
     1001                            percent = (photo.width - settings.mw) / photo.width;
     1002                            setResize();
     1003                        }
     1004                        if (settings.mh && photo.height > settings.mh) {
     1005                            percent = (photo.height - settings.mh) / photo.height;
     1006                            setResize();
     1007                        }
    9581008                    }
    959                 }
    960 
    961                 if (settings.h) {
    962                     photo.style.marginTop = Math.max(settings.mh - photo.height, 0) / 2 + 'px';
    963                 }
    964 
    965                 if ($related[1] && (settings.loop || $related[index + 1])) {
    966                     photo.style.cursor = 'pointer';
    967                     photo.onclick = function () {
    968                         publicMethod.next();
    969                     };
    970                 }
    971 
    972                 photo.style.width = photo.width + 'px';
    973                 photo.style.height = photo.height + 'px';
    974 
    975                 setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
     1009
     1010                    if (settings.h) {
     1011                        photo.style.marginTop = Math.max(settings.mh - photo.height, 0) / 2 + 'px';
     1012                    }
     1013
     1014                    if ($related[1] && (settings.get('loop') || $related[index + 1])) {
     1015                        photo.style.cursor = 'pointer';
     1016
     1017                        $(photo).bind('click.'+prefix, function () {
     1018                            publicMethod.next();
     1019                        });
     1020                    }
     1021
     1022                    photo.style.width = photo.width + 'px';
     1023                    photo.style.height = photo.height + 'px';
    9761024                    prep(photo);
    9771025                }, 1);
    9781026            });
    9791027
    980             setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
    981                 photo.src = href;
    982             }, 1);
     1028            photo.src = href;
     1029
    9831030        } else if (href) {
    984             $loadingBay.load(href, settings.data, function (data, status) {
     1031            $loadingBay.load(href, settings.get('data'), function (data, status) {
    9851032                if (request === requests) {
    986                     prep(status === 'error' ? $tag(div, 'Error').html(settings.xhrError) : $(this).contents());
     1033                    prep(status === 'error' ? $tag(div, 'Error').html(settings.get('xhrError')) : $(this).contents());
    9871034                }
    9881035            });
     
    9921039    // Navigates to the next page/image in a set.
    9931040    publicMethod.next = function () {
    994         if (!active && $related[1] && (settings.loop || $related[index + 1])) {
     1041        if (!active && $related[1] && (settings.get('loop') || $related[index + 1])) {
    9951042            index = getIndex(1);
    9961043            launch($related[index]);
     
    9991046
    10001047    publicMethod.prev = function () {
    1001         if (!active && $related[1] && (settings.loop || index)) {
     1048        if (!active && $related[1] && (settings.get('loop') || index)) {
    10021049            index = getIndex(-1);
    10031050            launch($related[index]);
     
    10101057
    10111058            closing = true;
    1012 
    10131059            open = false;
    1014 
    1015             trigger(event_cleanup, settings.onCleanup);
    1016 
     1060            trigger(event_cleanup);
     1061            settings.get('onCleanup');
    10171062            $window.unbind('.' + prefix);
    1018 
    1019             $overlay.fadeTo(settings.fadeOut || 0, 0);
    1020 
    1021             $box.stop().fadeTo(settings.fadeOut || 0, 0, function () {
    1022 
    1023                 $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
    1024 
     1063            $overlay.fadeTo(settings.get('fadeOut') || 0, 0);
     1064
     1065            $box.stop().fadeTo(settings.get('fadeOut') || 0, 0, function () {
     1066                $box.hide();
     1067                $overlay.hide();
    10251068                trigger(event_purge);
    1026 
    1027                 $loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
     1069                $loaded.remove();
    10281070
    10291071                setTimeout(function () {
    10301072                    closing = false;
    1031                     trigger(event_closed, settings.onClosed);
     1073                    trigger(event_closed);
     1074                    settings.get('onClosed');
    10321075                }, 1);
    10331076            });
    10341077        }
    1035     };
    1036 
    1037     // Added by Jonathan Davis, Ingenesis Limited
    1038     publicMethod.hide = function () {
    1039         $overlay.fadeTo(settings.fadeOut || 0, 0);
    1040         $box.fadeTo(settings.fadeOut || 0, 0, function () {
    1041             $overlay.hide();
    1042             $box.css({'opacity': 1, cursor: 'auto','left':'-9999em'});
    1043             trigger(event_closed, settings.onClosed);
    1044         });
    10451078    };
    10461079
     
    10501083
    10511084        $box.stop();
    1052         $.colorbox.close();
    1053         $box.stop().remove();
     1085        $[colorbox].close();
     1086        $box.stop(false, true).remove();
    10541087        $overlay.remove();
    10551088        closing = false;
     
    10591092            .removeClass(boxElement);
    10601093
    1061         $(document).unbind('click.'+prefix);
     1094        $(document).unbind('click.'+prefix).unbind('keydown.'+prefix);
    10621095    };
    10631096
     
    10651098    // returns a jQuery object.
    10661099    publicMethod.element = function () {
    1067         return $(element);
     1100        return $(settings.el);
    10681101    };
    10691102
  • shopp/trunk/core/ui/behaviors/colorbox.min.js

    r1648469 r1859263  
    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=X+o),n&&(r.style.cssText=n),e(r)}function n(){return i.innerHeight?i.innerHeight:e(i).height()}function r(e){var t=T.length,i=(N+e)%t;return i<0?t+i:i}function l(e,t){return Math.round((/%/.test(e)?("x"===t?C.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 m[0]&&!m[0].contains(e.target)&&(e.stopPropagation(),m.focus())}function d(){var t,i=e.data(D,V);null==i?(K=e.extend({},J),console&&console.log&&console.log("Error: cboxElement missing settings object")):K=e.extend({},i);for(t in K)e.isFunction(K[t])&&"on"!==t.slice(0,2)&&(K[t]=K[t].call(D));K.rel=K.rel||D.rel||e(D).data("rel")||"nofollow",K.href=K.href||e(D).attr("href"),K.title=K.title||D.title,"string"==typeof K.href&&(K.href=e.trim(K.href))}function c(i,o){e(t).trigger(i),re.trigger(i),e.isFunction(o)&&o.call(D)}function u(n){U||(D=n,d(),T=e(D),N=0,"nofollow"!==K.rel&&(T=e("."+Y).filter(function(){var t,i=e.data(this,V);return i&&(t=e(this).data("rel")||i.rel||this.rel),t===K.rel}),-1===(N=T.index(D))&&(T=T.add(D),N=T.length-1)),p.css({opacity:parseFloat(K.opacity),cursor:K.overlayClose?"pointer":"auto",visibility:"visible"}).show(),G&&m.add(p).removeClass(G),K.className&&m.add(p).addClass(K.className),G=K.className,K.closeButton?R.html(K.close).appendTo(g):R.appendTo("<div/>"),A||(A=j=!0,m.css({visibility:"hidden",display:"block"}),k=o(le,"LoadedContent","width:0; height:0; overflow:hidden"),g.css({width:"",height:""}).append(k),O=y.height()+b.height()+g.outerHeight(!0)-g.height(),P=v.width()+x.width()+g.outerWidth(!0)-g.width(),B=k.outerHeight(!0),_=k.outerWidth(!0),K.w=l(K.initialWidth,"x"),K.h=l(K.initialHeight,"y"),q.position(),function(){var e,t,i,o,n,r=X+"Slideshow_",l="click."+X;K.slideshow&&T[1]?(t=function(){clearTimeout(e)},i=function(){(K.loop||T[N+1])&&(e=setTimeout(q.next,K.slideshowSpeed))},o=function(){L.html(K.slideshowStop).unbind(l).one(l,n),re.bind(te,i).bind(ee,t).bind(ie,n),m.removeClass(r+"off").addClass(r+"on")},n=function(){t(),re.unbind(te,i).unbind(ee,t).unbind(ie,n),L.html(K.slideshowStart).unbind(l).one(l,function(){q.next(),o()}),m.removeClass(r+"on").addClass(r+"off")},K.slideshowAuto?o():n()):m.removeClass(r+"off "+r+"on")}(),c(Z,K.onOpen),I.add(W).hide(),m.focus(),K.trapFocus&&t.addEventListener&&(t.addEventListener("focus",s,!0),re.one(oe,function(){t.removeEventListener("focus",s,!0)})),K.returnFocus&&re.one(oe,function(){e(D).focus()})),function(){var n,r,s,u=q.prep,f=++ae;j=!0,z=!1,D=T[N],d(),c(ne),c(ee,K.onLoad),K.h=K.height?l(K.height,"y")-B-O:K.innerHeight&&l(K.innerHeight,"y"),K.w=K.width?l(K.width,"x")-_-P:K.innerWidth&&l(K.innerWidth,"x"),K.mw=K.w,K.mh=K.h,K.maxWidth&&(K.mw=l(K.maxWidth,"x")-_-P,K.mw=K.w&&K.w<K.mw?K.w:K.mw);K.maxHeight&&(K.mh=l(K.maxHeight,"y")-B-O,K.mh=K.h&&K.h<K.mh?K.h:K.mh);n=K.href,$=setTimeout(function(){H.show()},100),K.inline?(s=o(le).hide().insertBefore(e(n)[0]),re.one(ne,function(){s.replaceWith(k.children())}),u(e(n))):K.iframe?u(" "):K.html?u(K.html):a(K,n)?(n=h(K,n),z=t.createElement("img"),e(z).addClass(X+"Photo").bind("error",function(){K.title=!1,u(o(le,"Error").html(K.imgError))}).one("load",function(){var t;f===ae&&(z.alt=e(D).attr("alt")||e(D).attr("data-alt")||"",K.retinaImage&&i.devicePixelRatio>1&&(z.height=z.height/i.devicePixelRatio,z.width=z.width/i.devicePixelRatio),K.scalePhotos&&(r=function(){z.height-=z.height*t,z.width-=z.width*t},K.mw&&z.width>K.mw&&(t=(z.width-K.mw)/z.width,r()),K.mh&&z.height>K.mh&&(t=(z.height-K.mh)/z.height,r())),K.h&&(z.style.marginTop=Math.max(K.mh-z.height,0)/2+"px"),T[1]&&(K.loop||T[N+1])&&(z.style.cursor="pointer",z.onclick=function(){q.next()}),z.style.width=z.width+"px",z.style.height=z.height+"px",setTimeout(function(){u(z)},1))}),setTimeout(function(){z.src=n},1)):n&&E.load(n,K.data,function(t,i){f===ae&&u("error"===i?o(le,"Error").html(K.xhrError):e(this).contents())})}())}function f(){!m&&t.body&&(Q=!1,C=e(i),m=o(le).attr({id:V,class:!1===e.support.opacity?X+"IE":"",role:"dialog",tabindex:"-1"}).hide(),p=o(le,"Overlay").hide(),H=e([o(le,"LoadingOverlay")[0],o(le,"LoadingGraphic")[0]]),w=o(le,"Wrapper"),g=o(le,"Content").append(W=o(le,"Title"),F=o(le,"Current"),M=e('<button type="button"/>').attr({id:X+"Previous"}),S=e('<button type="button"/>').attr({id:X+"Next"}),L=o("button","Slideshow"),H),R=e('<button type="button"/>').attr({id:X+"Close"}),w.append(o(le).append(o(le,"TopLeft"),y=o(le,"TopCenter"),o(le,"TopRight")),o(le,!1,"clear:left").append(v=o(le,"MiddleLeft"),g,x=o(le,"MiddleRight")),o(le,!1,"clear:left").append(o(le,"BottomLeft"),b=o(le,"BottomCenter"),o(le,"BottomRight"))).find("div div").css({float:"left"}),E=o(le,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),I=S.add(M).add(F).add(L),e(t.body).append(p,m.append(w,E)))}var p,m,w,g,y,v,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={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},V="colorbox",X="cbox",Y=X+"Element",Z=X+"_open",ee=X+"_load",te=X+"_complete",ie=X+"_cleanup",oe=X+"_closed",ne=X+"_purge",re=e("<a/>"),le="div",ae=0,he={};e.colorbox||(e(f),(q=e.fn[V]=e[V]=function(i,o){var n=this;if(i=i||{},f(),function(){function i(e){e.which>1||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),u(this))}return!!m&&(Q||(Q=!0,S.click(function(){q.next()}),M.click(function(){q.prev()}),R.click(function(){q.close()}),p.click(function(){K.overlayClose&&q.close()}),e(t).bind("keydown."+X,function(e){var t=e.keyCode;A&&K.escKey&&27===t&&(e.preventDefault(),q.close()),A&&K.arrowKey&&T[1]&&!e.altKey&&(37===t?(e.preventDefault(),M.click()):39===t&&(e.preventDefault(),S.click()))}),e.isFunction(e.fn.on)?e(t).on("click."+X,"."+Y,i):e("."+Y).live("click."+X,i)),!0)}()){if(e.isFunction(n))n=e("<a/>"),i.open=!0;else if(!n[0])return n;o&&(i.onComplete=o),n.each(function(){e.data(this,V,e.extend({},e.data(this,V)||J,i))}).addClass(Y),(e.isFunction(i.open)&&i.open.call(n)||i.open)&&u(n[0])}return n}).position=function(t,i){function o(){y[0].style.width=b[0].style.width=g[0].style.width=parseInt(m[0].style.width,10)-P+"px",g[0].style.height=v[0].style.height=x[0].style.height=parseInt(m[0].style.height,10)-O+"px"}var r,a,h,s=0,d=0,c=m.offset();if(C.unbind("resize."+X),m.css({top:-9e4,left:-9e4}),a=C.scrollTop(),h=C.scrollLeft(),K.fixed?(c.top-=a,c.left-=h,m.css({position:"fixed"})):(s=a,d=h,m.css({position:"absolute"})),!1!==K.right?d+=Math.max(C.width()-K.w-_-P-l(K.right,"x"),0):!1!==K.left?d+=l(K.left,"x"):d+=Math.round(Math.max(C.width()-K.w-_-P,0)/2),!1!==K.bottom?s+=Math.max(n()-K.h-B-O-l(K.bottom,"y"),0):!1!==K.top?s+=l(K.top,"y"):s+=Math.round(Math.max(n()-K.h-B-O,0)/2),m.css({top:c.top,left:c.left,visibility:"visible"}),w[0].style.width=w[0].style.height="9999px",r={width:K.w+_+P,height:K.h+B+O,top:s,left:d},t){var u=0;e.each(r,function(e){r[e]===he[e]||(u=t)}),t=u}he=r,t||m.css(r),m.dequeue().animate(r,{duration:t||0,complete:function(){o(),j=!1,w[0].style.width=K.w+_+P+"px",w[0].style.height=K.h+B+O+"px",K.reposition&&setTimeout(function(){C.bind("resize."+X,q.position)},1),i&&i()},step:o})},q.resize=function(e){var t;A&&((e=e||{}).width&&(K.w=l(e.width,"x")-_-P),e.innerWidth&&(K.w=l(e.innerWidth,"x")),k.css({width:K.w}),e.height&&(K.h=l(e.height,"y")-B-O),e.innerHeight&&(K.h=l(e.innerHeight,"y")),e.innerHeight||e.height||(t=k.scrollTop(),k.css({height:"auto"}),K.h=k.height()),k.css({height:K.h}),t&&k.scrollTop(t),q.position("none"===K.transition?0:K.speed))},q.prep=function(i){if(A){var n,l="none"===K.transition?0:K.speed;k.empty().remove(),(k=o(le,"LoadedContent").append(i)).hide().appendTo(E.show()).css({width:(K.w=K.w||k.width(),K.w=K.mw&&K.mw<K.w?K.mw:K.w,K.w),overflow:K.scrolling?"auto":"hidden"}).css({height:(K.h=K.h||k.height(),K.h=K.mh&&K.mh<K.h?K.mh:K.h,K.h)}).prependTo(g),E.hide(),e(z).css({float:"none"}),n=function(){function i(){!1===e.support.opacity&&m[0].style.removeAttribute("filter")}var n,s,d=T.length,u="allowTransparency";A&&(s=function(){clearTimeout($),H.hide(),c(te,K.onComplete)},W.html(K.title).add(k).show(),d>1?("string"==typeof K.current&&F.html(K.current.replace("{current}",N+1).replace("{total}",d)).show(),S[K.loop||N<d-1?"show":"hide"]().html(K.next),M[K.loop||N?"show":"hide"]().html(K.previous),K.slideshow&&L.show(),K.preloading&&e.each([r(-1),r(1)],function(){var i,o=T[this],n=e.data(o,V);n&&n.href?(i=n.href,e.isFunction(i)&&(i=i.call(o))):i=e(o).attr("href"),i&&a(n,i)&&(i=h(n,i),t.createElement("img").src=i)})):I.hide(),K.iframe?("frameBorder"in(n=o("iframe")[0])&&(n.frameBorder=0),u in n&&(n[u]="true"),K.scrolling||(n.scrolling="no"),e(n).attr({src:K.href,name:(new Date).getTime(),class:X+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",s).appendTo(k),re.one(ne,function(){n.src="//about:blank"}),K.fastIframe&&e(n).trigger("load")):s(),"fade"===K.transition?m.fadeTo(l,1,i):i())},"fade"===K.transition?m.fadeTo(l,0,function(){q.position(0,n)}):q.position(l,n)}},q.next=function(){!j&&T[1]&&(K.loop||T[N+1])&&(N=r(1),u(T[N]))},q.prev=function(){!j&&T[1]&&(K.loop||N)&&(N=r(-1),u(T[N]))},q.close=function(){A&&!U&&(U=!0,A=!1,c(ie,K.onCleanup),C.unbind("."+X),p.fadeTo(K.fadeOut||0,0),m.stop().fadeTo(K.fadeOut||0,0,function(){m.add(p).css({opacity:1,cursor:"auto"}).hide(),c(ne),k.empty().remove(),setTimeout(function(){U=!1,c(oe,K.onClosed)},1)}))},q.hide=function(){p.fadeTo(K.fadeOut||0,0),m.fadeTo(K.fadeOut||0,0,function(){p.hide(),m.css({opacity:1,cursor:"auto",left:"-9999em"}),c(oe,K.onClosed)})},q.remove=function(){m&&(m.stop(),e.colorbox.close(),m.stop().remove(),p.remove(),U=!1,m=null,e("."+Y).removeData(V).removeClass(Y),e(t).unbind("click."+X))},q.element=function(){return e(D)},q.settings=J)}(jQuery,document,window);
  • shopp/trunk/core/ui/behaviors/editors.js

    r1473303 r1859263  
    707707}
    708708
    709 /**
    710  * Image Uploads using SWFUpload or the jQuery plugin One Click Upload
    711  **/
    712 function ImageUploads (id,type) {
    713     var $ = jQuery,
    714     swfu,
    715     settings = {
    716         button_text: ADD_IMAGE_BUTTON_TEXT,
    717         button_text_style: '.buttonText{text-align:center;font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,_sans;font-size:9px;color:#333333;}',
    718         button_text_top_padding: 3,
    719         button_height: "18",
    720         button_width: "100",
    721         button_image_url: uidir+'/icons/buttons.png',
    722         button_placeholder_id: "swf-uploader-button",
    723         upload_url : ajaxurl,
    724         flash_url : uidir+'/behaviors/swfupload.swf',
    725         file_queue_limit : 0,
    726         file_size_limit : filesizeLimit+'b',
    727         file_types : "*.jpg;*.jpeg;*.png;*.gif",
    728         file_types_description : "Web-compatible Image Files",
    729         file_upload_limit : filesizeLimit,
    730         post_params : {
    731             action:'shopp_upload_image',
    732             parent:id,
    733             type:type
    734         },
    735 
    736         swfupload_loaded_handler : swfuLoaded,
    737         file_queue_error_handler : imageFileQueueError,
    738         file_dialog_complete_handler : imageFileDialogComplete,
    739         upload_start_handler : startImageUpload,
    740         upload_progress_handler : imageUploadProgress,
    741         upload_error_handler : imageUploadError,
    742         upload_success_handler : imageUploadSuccess,
    743 
    744         custom_settings : {
    745             loaded: false,
    746             targetHolder : false,
    747             progressBar : false,
    748             sorting : false
    749 
    750         },
    751         prevent_swf_caching: $.ua.msie, // Prevents Flash caching issues in IE
    752         debug: imageupload_debug
    753 
    754     };
    755 
    756     // Initialize image uploader
    757     if (flashuploader)
    758         swfu = new SWFUpload(settings);
    759 
    760     // Browser image uploader
    761     $('#image-upload').upload({
    762         name: 'Filedata',
    763         action: ajaxurl,
    764         params: {
    765             action:'shopp_upload_image',
    766             type:type
    767         },
    768         onSubmit: function() {
    769             this.targetHolder = $('<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');
    770             this.progressBar = this.targetHolder.find('div.bar');
    771             this.sorting = this.targetHolder.find('input');
    772         },
    773         onComplete: function(results) {
    774             var image = false,img,deleteButton,targetHolder = this.targetHolder;
    775 
    776             try {
    777                 image = $.parseJSON(results);
    778             } catch (ex) {
    779                 image.error = results;
    780             }
    781 
    782             if (!image || !image.id) {
    783                 targetHolder.remove();
    784                 if (image.error) alert(image.error);
    785                 else alert(UNKNOWN_UPLOAD_ERROR);
    786                 return false;
    787             }
    788 
    789             targetHolder.attr({'id':'image-'+image.id});
    790             this.sorting.val(image.id);
    791             img = $('<img src="?siid='+image.id+'" width="96" height="96" class="handle" />').appendTo(targetHolder).hide();
    792             deleteButton = $('<button type="button" name="deleteImage" value="'+image.src+'" class="delete"><span class="shoppui-minus"></span></button>').appendTo($(targetHolder)).hide();
    793 
    794             $(this.progressBar).animate({'width':'76px'},250,function () {
    795                 $(this).parent().fadeOut(500,function() {
    796                     $(this).remove();
    797                     $(img).fadeIn('500');
    798                     enableDeleteButton(deleteButton);
     709function ImageUploads(parent, type) {
     710    var $ = jQuery;
     711    Dropzone.autoDiscover = false;
     712
     713    $.template('image-preview-template', $('#lightbox-image-template'));
     714
     715    var myDropzone = new Dropzone('ul.lightbox-dropzone', {
     716        url: imgul_url + "&type=" + type + '&parent=' + parent,
     717        maxFilesize: uploadLimit / 1024 / 1024,
     718        autoDiscover: false,
     719        parallelUploads: 5,
     720        autoProcessQueue: true,
     721        previewTemplate: $.tmpl('image-preview-template').html(),
     722        acceptedFiles: "image/*",
     723        init: function () {
     724            var self = this;
     725            $('.image-upload').on('click', function () {
     726                self.hiddenFileInput.click();
     727            });
     728
     729            self.on('error', function(file, message) {
     730                $('.lightbox-dropzone li.dz-error').on('click', function () {
     731                    $(this).fadeOut(300, function () {
     732                        $(this).remove();
     733                    });
    799734                });
    800735            });
     736
     737            self.on('success', function (file, response) {
     738                $(file.previewElement).find('.imageid').attr('value', response.id);
     739            });
     740
     741            self.on('complete', function (file, response) {
     742                sorting();
     743            });
    801744        }
    802745    });
    803746
    804     $(document).load(function() {
    805         if (!swfu.loaded) $('#product-images .swfupload').remove();
    806     });
    807 
    808747    sorting();
    809     $('#lightbox li').each(function () {
     748    $('.lightbox-dropzone li:not(.dz-upload-control)').each(function () {
    810749        $(this).dblclick(function () {
    811750            var id = $(this).attr('id')+"-details",
     
    879818    });
    880819
    881     function swfuLoaded () {
    882         $('#browser-uploader').hide();
    883         swfu.loaded = true;
    884     }
    885 
    886820    function sorting () {
    887         if ($('#lightbox li').size() > 0) $('#lightbox').sortable({'opacity':0.8});
    888     }
    889 
    890     function imageFileQueueError (file, error, message) {
    891 
    892         if (error == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
    893             alert("You selected too many files to upload at one time. " + (message === 0 ? "You have reached the upload limit." : "You may upload " + (message > 1 ? "up to " + message + " files." : "only one file.")));
    894             return;
    895         } else alert(message);
    896 
    897     }
    898 
    899     function imageFileDialogComplete (selected, queued) {
    900         try {
    901             this.startUpload();
    902         } catch (ex) {
    903             this.debug(ex);
    904         }
    905     }
    906 
    907     function startImageUpload (file) {
    908         this.targetHolder = $('<li class="image uploading"><input type="hidden" name="images[]" /><div class="progress"><div class="bar"></div><div class="gloss"></div></div></li>').appendTo($('#lightbox'));
    909         this.progressBar = this.targetHolder.find('div.bar');
    910         this.sorting = this.targetHolder.find('input');
    911     }
    912 
    913     function imageUploadProgress (file, loaded, total) {
    914         this.progressBar.animate({'width':Math.ceil((loaded/total)*76)+'px'},100);
    915     }
    916 
    917     function imageUploadError (file, error, message) {
    918         //debuglog(error+": "+message);
    919     }
    920 
    921     function imageUploadSuccess (file, results) {
    922         var image = false,img,deleteButton,targetHolder = this.targetHolder;
    923         try {
    924             image = $.parseJSON(results);
    925         } catch (ex) {
    926             targetHolder.remove();
    927             alert(results);
    928             return false;
    929         }
    930 
    931         if (!image.id) {
    932             targetHolder.remove();
    933             if (image.error) alert(image.error);
    934             else alert(UNKNOWN_UPLOAD_ERROR);
    935             return true;
    936         }
    937 
    938         targetHolder.attr({'id':'image-'+image.id});
    939         this.sorting.val(image.id);
    940         img = $('<img src="?siid='+image.id+'" width="96" height="96" class="handle" />').appendTo(targetHolder).hide();
    941         deleteButton = $('<button type="button" name="deleteImage" value="'+image.id+'" class="delete"><span class="shoppui-minus"></span></button>').appendTo(targetHolder).hide();
    942         sorting();
    943 
    944         this.progressBar.animate({'width':'76px'},250,function () {
    945             $(this).parent().fadeOut(500,function() {
    946                 $(this).remove();
    947                 $(img).fadeIn('500');
    948                 enableDeleteButton(deleteButton);
    949             });
    950         });
     821        if ($('.lightbox-dropzone li').length > 0)
     822            $('.lightbox-dropzone').sortable({'opacity':0.8});
    951823    }
    952824
     
    973845        });
    974846    }
    975 
    976847}
    977848
     
    979850    var $ = jQuery,
    980851        _ = this,
    981         chooser = $('#chooser'),
    982         importurl = chooser.find('.fileimport'),
    983         importstatus = chooser.find('.status'),
    984         attach = $('#attach-file'),
    985         dlpath = $('#download_path-'+line),
    986         dlname = $('#download_file-'+line),
     852        uiChooser = $('#filechooser'),
     853        uiImportURL = uiChooser.find('.fileimport'),
     854        uiImportStatus = uiChooser.find('.status'),
     855        uiAttachFile = $('#attach-file'),
     856        uiDownloadPath = $('#download_path-'+line),
     857        uiDownloadFilename = $('#download_file-'+line),
    987858        file = $('#file-'+line),
    988         stored = false,
    989         nostatus = 0,
    990         progressbar = false;
     859        stored = false;
    991860
    992861    _.line = line;
    993862    _.status = status;
    994863
    995     chooser.unbind('change').on('change', '.fileimport', function (e) {
    996         importstatus.attr('class','status').addClass('shoppui-spinner shoppui-spinfx shoppui-spinfx-steps8');
     864    uiChooser.unbind('change').on('change', '.fileimport', function (e) {
     865        uiImportStatus.attr('class','status').addClass('shoppui-spinner shoppui-spinfx shoppui-spinfx-steps8');
    997866        $.ajax({url:fileverify_url+'&action=shopp_verify_file&t=download',
    998867                type:"POST",
    999                 data:'url='+importurl.val(),
     868                data:'url='+uiImportURL.val(),
    1000869                timeout:10000,
    1001870                dataType:'text',
    1002871                success:function (results) {
    1003                     importstatus.attr('class','status');
    1004                     if (results == "OK") return importstatus.addClass('shoppui-ok-sign');
    1005                     if (results == "NULL") importstatus.attr('title',FILE_NOT_FOUND_TEXT);
    1006                     if (results == "ISDIR") importstatus.attr('title',FILE_ISDIR_TEXT);
    1007                     if (results == "READ") importstatus.attr('title',FILE_NOT_READ_TEXT);
    1008                     importstatus.addClass("shoppui-warning-sign");
     872                    uiImportStatus.attr('class','status');
     873                    if (results == "OK") return uiImportStatus.addClass('shoppui-ok-sign');
     874                    if (results == "NULL") uiImportStatus.attr('title',FILE_NOT_FOUND_TEXT);
     875                    if (results == "ISDIR") uiImportStatus.attr('title',FILE_ISDIR_TEXT);
     876                    if (results == "READ") uiImportStatus.attr('title',FILE_NOT_READ_TEXT);
     877                    uiImportStatus.addClass("shoppui-warning-sign");
    1009878                }
    1010879        });
    1011880    });
    1012881
    1013     importurl.unbind('keydown').unbind('keypress').suggest(
    1014         sugg_url+'&action=shopp_storage_suggestions&t=download',
    1015         { delay:500, minchars:3, multiple:false, onSelect:function () { importurl.trigger('change'); } }
     882    uiImportURL.unbind('keydown').unbind('keypress').suggest(
     883        sugg_url + '&action=shopp_storage_suggestions&t=download', {
     884            delay: 500,
     885            minchars: 3,
     886            multiple:false,
     887            onSelect:function () {
     888                uiImportURL.trigger('change');
     889            }
     890        }
    1016891    );
    1017892
    1018893    $(this).click(function () {
    1019         fileUploads.updateLine(line,status);
    1020         importstatus.attr('class','status');
    1021 
    1022         attach.unbind('click').click(function () {
     894        uiImportStatus.attr('class','status');
     895
     896        fileUploads.dropzone.previewsContainer = file[0];
     897        fileUploads.priceline = _.line;
     898
     899        // File import handling
     900        uiAttachFile.unbind('click').click(function () {
    1023901            $.colorbox.hide();
     902
    1024903            if (stored) {
    1025                 dlpath.val(importurl.val());
    1026                 importurl.val('').attr('class','fileimport');
     904                uiDownloadPath.val(uiImportURL.val());
     905                uiImportURL.val('').attr('class','fileimport');
    1027906                return true;
    1028907            }
    1029908
    1030             var importid = false,
    1031                 importdata = false,
    1032                 importfile = importurl.val(),
    1033 
    1034                 completed = function (f) {
    1035                     if (!f.name) return $this.attr('class','');
    1036                     file.attr('class','file').html('<span class="icon shoppui-file '+f.mime.replace('/',' ')+'"></span>'+f.name+'<br /><small>'+readableFileSize(f.size)+'</small>');
    1037                     dlpath.val(f.path); dlname.val(f.name);
    1038                     importurl.val('').attr('class','fileimport');
     909            var importId = false,
     910                uiSetup = false,
     911                noProgressTimeout = 0,
     912                importFile = uiImportURL.val(),
     913
     914                completed = function (filedata) {
     915                    if ( ! filedata.name )
     916                        return $this.attr('class', '');
     917                    uiDownloadPath.val(filedata.path);
     918                    uiDownloadFilename.val(filedata.name);
     919                    uiImportURL.val('').attr('class', 'fileimport');
    1039920                },
    1040921
    1041                 importing = function () {
    1042                     var ui = file.find('div.progress'),
    1043                         progressbar = ui.find('div.bar'),
    1044                         scale = ui.outerWidth(),
    1045                         dataframe = $('#import-file-'+line).get(0).contentWindow,
    1046                         p = dataframe['importProgress'],
    1047                         f = dataframe['importFile'];
    1048 
    1049                     if (f !== undefined) {
    1050                         if (f.error) return file.attr('class','error').html('<small>'+f.error+'</small>');
    1051                         if (!f.path) return file.attr('class','error').html('<small>'+FILE_UNKNOWN_IMPORT_ERROR+'</small>');
    1052 
    1053                         if (f.stored) {
    1054                             return completed(f);
     922                error = function (message) {
     923                    if ( ! message ) message = FILE_UNKNOWN_IMPORT_ERROR;
     924                    file.attr('class', 'error').html('<small>' + message + '</small>');
     925                },
     926
     927                process = function () {
     928                    var progress = dataFrame.importProgress,
     929                        filedata = dataFrame.importFile;
     930
     931                    if ( filedata === undefined )
     932                        return waitForUploadProgress();
     933
     934                    // Handle errors
     935                    if ( ! filedata.path )
     936                        return error();
     937                    if ( filedata.error )
     938                        return error(filedata.error);
     939
     940                    // Allow a passthrough on already imported, stored files
     941                    if ( filedata.stored )
     942                        return completed(filedata);
     943
     944                    if ( progress === undefined )
     945                        progress = 0;
     946
     947                    savepath = filedata.path.split('/');
     948                    importId = savepath[ savepath.length - 1 ];
     949
     950                    // Initialize the UI with file data
     951                    if ( ! uiSetup ) {
     952                        uiIcon.addClass(filedata.mime.replace('/',' '));
     953                        uiFilename.text(filedata.name);
     954                        uiFilesize.text(readableFileSize(filedata.size));
     955                        uiProgressBar.css('opacity',1);
     956                        uiSetup = true;
     957                    }
     958
     959                    if ( progress === 0 && noProgressTimeout++ > 60)
     960                        return error();
     961
     962                    var uploadProgress = Math.floor(progress * 100);
     963
     964                    uiUploadProgress[0].style.width = uploadProgress + "%";
     965
     966                    if ( uploadProgress >= 100 )
     967                        uiProgressBar.fadeOut(500, function() {
     968                            completed(filedata);
     969                        });
     970                    else waitForUploadProgress();
     971
     972                },
     973
     974                waitForUploadProgress = function () {
     975                    setTimeout(process, 100);
     976                };
     977
     978            $.template('filechooser-upload-template', $('#filechooser-upload-template'));
     979
     980            file.attr('class','').html($.tmpl('filechooser-upload-template').html()).append('<iframe id="import-file-'+line+'" width="0" height="0" src="'+fileimport_url+'&action=shopp_import_file&url='+importFile+'"></iframe>');
     981
     982            var dataFrame = $('#import-file-'+line)[0].contentWindow,
     983                uiIcon = file.find('.icon'),
     984                uiFilename = file.find('.dz-filename'),
     985                uiFilesize = file.find('.dz-size'),
     986                uiProgressBar = file.find('.dz-progress'),
     987                uiUploadProgress = file.find('.dz-upload');
     988
     989            waitForUploadProgress();
     990
     991        }); // uiAttachFile click handler
     992
     993    }); // file chooser click handler
     994
     995    $(this).colorbox({'title':'File Selector','innerWidth':'360','innerHeight':'140','inline':true,'href':uiChooser});
     996};
     997
     998function FileUploader(container) {
     999    var $ = jQuery,
     1000        _ = this;
     1001
     1002    this.priceline = false;
     1003
     1004    $.template('filechooser-upload-template', $('#filechooser-upload-template'));
     1005
     1006    this.dropzone = new Dropzone(container, {
     1007        url: fileupload_url,
     1008        autoDiscover: false,
     1009        uploadMultiple: false,
     1010        autoQueue: true,
     1011        autoProcessQueue: true,
     1012        chunking: true,
     1013        forceChunking: true,
     1014        chunkSize: chunkSize,
     1015        maxFilesize: 4096,
     1016        parallelChunkUploads: false,
     1017        retryChunks: true,
     1018        parallelConnectionsLimit: uploadMaxConnections,
     1019        previewTemplate: $.tmpl('filechooser-upload-template').html(),
     1020        init: function () {
     1021            var self = this;
     1022            self.startTime = false;
     1023            self.samples = [];
     1024            self.samplesLimit = 5;
     1025            self.connections = 0;
     1026
     1027            $('.filechooser-upload').on('mousedown', function () {
     1028                self.hiddenFileInput.click();
     1029                $(self.previewsContainer).empty();
     1030            });
     1031
     1032            self.on('addedfile', function (file) {
     1033                $.colorbox.hide();
     1034                self.processQueue();
     1035                $(self.previewsContainer).find('.icon.shoppui-file').addClass(file.type.replace('/',' '));
     1036            });
     1037
     1038            self.on('success', function (file) {
     1039                var response = JSON.parse(file.xhr.response);
     1040                if ( response.id )
     1041                    $('<input>').attr({
     1042                        type: 'hidden',
     1043                        name: 'price[' + _.priceline + '][download]',
     1044                        value: response.id
     1045                    }).appendTo($(self.previewsContainer));
     1046            });
     1047
     1048            self.options.params = function (files, xhr, chunk) {
     1049                if (chunk) {
     1050                    return {
     1051                        dzuuid: chunk.file.upload.uuid,
     1052                        dzchunkindex: chunk.index,
     1053                        dztotalfilesize: chunk.file.size,
     1054                        dzchunksize: chunk.chunkSize,
     1055                        dztotalchunkcount: chunk.file.upload.totalChunkCount,
     1056                        dzchunkbyteoffset: chunk.end
     1057                    };
     1058                }
     1059            };
     1060
     1061            self.uploadFiles = function (files) {
     1062                var _this15 = this;
     1063
     1064                this._transformFiles(files, function (transformedFiles) {
     1065                    if (files[0].upload.chunked) {
     1066                        // This file should be sent in chunks!
     1067
     1068                        // If the chunking option is set, we **know** that there can only be **one** file, since
     1069                        // uploadMultiple is not allowed with this option.
     1070                        var file = files[0];
     1071                        var transformedFile = transformedFiles[0];
     1072                        var startedChunkCount = 0;
     1073
     1074                        file.upload.chunks = [];
     1075
     1076                        var handleNextChunk = function handleNextChunk() {
     1077                            var chunkIndex = 0;
     1078
     1079                            // Find the next item in file.upload.chunks that is not defined yet.
     1080                            while (file.upload.chunks[chunkIndex] !== undefined) {
     1081                                chunkIndex++;
     1082                            }
     1083
     1084                            // This means, that all chunks have already been started.
     1085                            if (chunkIndex >= file.upload.totalChunkCount) return;
     1086
     1087                            startedChunkCount++;
     1088
     1089                            var start = chunkIndex * _this15.options.chunkSize;
     1090                            var end = Math.min(start + _this15.options.chunkSize, file.size);
     1091
     1092                            /** Added for dynamic bandwidth **/
     1093                            if ( self.startTime === false )
     1094                                self.startTime = (new Date()).getTime();
     1095
     1096                            var nowTime = (new Date()).getTime();
     1097
     1098                            if (self.samples.length <= self.samplesLimit && file.upload.bytesSent > 0) {
     1099                                self.samples.push(file.upload.bytesSent / ( (nowTime - self.startTime) / 1000 ));
     1100                            }
     1101
     1102                            if ( self.samples.length == self.samplesLimit ) {
     1103                                var sum = self.samples.reduce(function(a, b) { return a + b; });
     1104                                var avgSpeed = sum / self.samples.length;
     1105
     1106                                self.options.chunkSize = Math.min(Math.floor(avgSpeed), uploadLimit - 1024);
     1107                                file.upload.totalChunkCount = Math.ceil((file.size - file.upload.bytesSent) / self.options.chunkSize) + self.samplesLimit;
     1108
     1109                                // Determine if there is spare bandwidth for parallel chunk uploads and set limits
     1110                                var parallelConnectionsLimit = Math.floor(avgSpeed / self.options.chunkSize);
     1111                                if ( parallelConnectionsLimit > 1 ) {
     1112                                    self.options.parallelChunkUploads = true;
     1113                                    self.options.parallelConnectionsLimit = Math.min(parallelConnectionsLimit, self.options.parallelConnectionsLimit);
     1114                                }
     1115
     1116                            }
     1117
     1118                            if ( chunkIndex > 0 ) {
     1119                                start = file.upload.chunks[chunkIndex - 1].end;
     1120                                end = Math.min(start + self.options.chunkSize, file.size);
     1121                            }
     1122                            /** End dynamic bandwidth handler **/
     1123
     1124                            var dataBlock = {
     1125                                name: _this15._getParamName(0),
     1126                                data: transformedFile.webkitSlice ? transformedFile.webkitSlice(start, end) : transformedFile.slice(start, end),
     1127                                filename: file.upload.filename,
     1128                                chunkIndex: chunkIndex
     1129                            };
     1130
     1131                            file.upload.chunks[chunkIndex] = {
     1132                                file: file,
     1133                                index: chunkIndex,
     1134                                dataBlock: dataBlock, // In case we want to retry.
     1135                                status: Dropzone.UPLOADING,
     1136                                progress: 0,
     1137                                start: start, // Added for dynamic bandiwdth handling
     1138                                end: end, // Added for dynamic bandiwdth handling
     1139                                chunkSize: self.options.chunkSize, // Added for dynamic bandiwdth handling
     1140                                retries: 0 // The number of times this block has been retried.
     1141                            };
     1142
     1143                            _this15._uploadData(files, [dataBlock]);
     1144                        };
     1145
     1146                        var parallelChunkUpload = function() {
     1147                            if ( self.connections > 0 )
     1148                                self.connections--; // Finished an upload
     1149
     1150                            for ( ; self.connections < self.options.parallelConnectionsLimit; self.connections++ )
     1151                                handleNextChunk();
     1152                        };
     1153
     1154                        file.upload.finishedChunkUpload = function (chunk) {
     1155                            var allFinished = true;
     1156                            chunk.status = Dropzone.SUCCESS;
     1157
     1158                            // Clear the data from the chunk
     1159                            chunk.dataBlock = null;
     1160
     1161                            for (var i = 0; i < file.upload.totalChunkCount; i++) {
     1162                                if (file.upload.chunks[i] === undefined) {
     1163                                    // Handle parallel chunk upload connections
     1164                                    if ( self.options.parallelChunkUploads ) {
     1165                                        return parallelChunkUpload();
     1166                                    } else {
     1167                                        return handleNextChunk();
     1168                                    }
     1169                                }
     1170                                if (file.upload.chunks[i].status !== Dropzone.SUCCESS) {
     1171                                    allFinished = false;
     1172                                }
     1173                            }
     1174
     1175                            if (allFinished) {
     1176                                _this15.options.chunksUploaded(file, function () {
     1177                                    _this15._finished(files, '', null);
     1178                                });
     1179                            }
     1180                        };
     1181
     1182                        if (_this15.options.parallelChunkUploads) {
     1183                            for (var i = 0; i < file.upload.totalChunkCount; i++) {
     1184                                handleNextChunk();
     1185                            }
    10551186                        } else {
    1056                             savepath = f.path.split('/');
    1057                             importid = savepath[savepath.length-1];
     1187                            handleNextChunk();
    10581188                        }
     1189                    } else {
     1190                        var dataBlocks = [];
     1191                        for (var _i22 = 0; _i22 < files.length; _i22++) {
     1192                            dataBlocks[_i22] = {
     1193                                name: _this15._getParamName(_i22),
     1194                                data: transformedFiles[_i22],
     1195                                filename: files[_i22].upload.filename
     1196                            };
     1197                        }
     1198                        _this15._uploadData(files, dataBlocks);
    10591199                    }
    1060 
    1061                     if (!p) p = 0;
    1062 
    1063                     // No status timeout failure
    1064                     if (p === 0 && nostatus++ > 60) return file.attr('class','error').html('<small>'+FILE_UNKNOWN_IMPORT_ERROR+'</small>');
    1065 
    1066                     progressbar.animate({'width': Math.ceil(p*scale) +'px'},100);
    1067                     if (p == 1) { // Completed
    1068                         if (progressbar) progressbar.css({'width':'100%'}).fadeOut(500,function () { completed(f); });
    1069                         return;
    1070                     }
    1071                     setTimeout(importing,100);
    1072                 };
    1073 
    1074             setTimeout(importing,100);
    1075             file.attr('class','').html(
    1076                 '<div class="progress"><div class="bar"></div><div class="gloss"></div></div>'+
    1077                 '<iframe id="import-file-'+line+'" width="0" height="0" src="'+fileimport_url+'&action=shopp_import_file&url='+importfile+'"></iframe>'
    1078             );
    1079         });
    1080 
    1081     });
    1082 
    1083     $(this).colorbox({'title':'File Selector','innerWidth':'360','innerHeight':'140','inline':true,'href':chooser});
    1084 };
    1085 
    1086 
    1087 /**
    1088  * File upload handlers for product download files using SWFupload
    1089  **/
    1090 function FileUploader (button, defaultButton) {
    1091     var $ = jQuery, _ = this;
    1092 
    1093     _.swfu = false;
    1094     _.settings = {
    1095         button_text: UPLOAD_FILE_BUTTON_TEXT,
    1096         button_text_style: '.buttonText{text-align:center;font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,_sans;font-size:9px;color:#333333; }',
    1097         button_text_top_padding: 3,
    1098         button_height: "22",
    1099         button_width: "100",
    1100         button_image_url: uidir+'/icons/buttons.png',
    1101         button_placeholder_id: button,
    1102         button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE,
    1103         flash_url : uidir+'/behaviors/swfupload.swf',
    1104         upload_url : ajaxurl,
    1105         file_queue_limit : 1,
    1106         file_size_limit : filesizeLimit+'b',
    1107         file_types : "*.*",
    1108         file_types_description : "All Files",
    1109         file_upload_limit : filesizeLimit,
    1110         post_params : {
    1111             action:'shopp_upload_file'
    1112         },
    1113 
    1114         swfupload_loaded_handler : swfuLoaded,
    1115         file_queue_error_handler : fileQueueError,
    1116         file_dialog_complete_handler : fileDialogComplete,
    1117         upload_start_handler : startUpload,
    1118         upload_progress_handler : uploadProgress,
    1119         upload_success_handler : uploadSuccess,
    1120 
    1121         custom_settings : {
    1122             loaded : false,
    1123             targetCell : false,
    1124             targetLine : false,
    1125             progressBar : false
    1126         },
    1127         prevent_swf_caching: $.ua.msie, // Prevents Flash caching issues in IE
    1128         debug: fileupload_debug
    1129 
    1130     };
    1131 
    1132     // Initialize file uploader
    1133 
    1134     if (flashuploader)
    1135         _.swfu = new SWFUpload(_.settings);
    1136 
    1137     // Browser-based AJAX uploads
    1138     defaultButton.upload({
    1139         name: 'Filedata',
    1140         action: ajaxurl,
    1141         params: { action:'shopp_upload_file' },
    1142         onSubmit: function() {
    1143             $.colorbox.hide();
    1144             _.targetCell.attr('class','').html('');
    1145             $('<div class="progress"><div class="bar"></div><div class="gloss"></div></div>').appendTo(_.targetCell);
    1146             _.progressBar = _.targetCell.find('div.bar');
    1147         },
    1148         onComplete: function(results) {
    1149             $.colorbox.close();
    1150 
    1151             var filedata = false,targetHolder = _.targetCell;
    1152             try {
    1153                 filedata = $.parseJSON(results);
    1154             } catch (ex) {
    1155                 filedata.error = results;
     1200                });
    11561201            }
    11571202
    1158             if (!filedata.id && !filedata.name) {
    1159                 targetHolder.html(NO_DOWNLOAD);
    1160                 if (filedata.error) alert(filedata.error);
    1161                 else alert(UNKNOWN_UPLOAD_ERROR);
    1162                 return false;
    1163             }
    1164             filedata.type = filedata.type.replace(/\//gi," ");
    1165             $(_.progressBar).animate({'width':'76px'},250,function () {
    1166                 $(this).parent().fadeOut(500,function() {
    1167                     targetHolder.attr('class', 'file').html(
    1168                         '<div class="icon shoppui-file ' + filedata.type + '"></div>' +
    1169                         filedata.name + '<br /><small>' + readableFileSize(filedata.size)+'</small>' +
    1170                         '<input type="hidden" name="price[' + _.targetLine + '][download]" value="' + filedata.id + '" />'
    1171                     );
    1172                     $(this).remove();
    1173                 });
    1174             });
    1175         }
    1176     });
    1177 
    1178     $(_).load(function () {
    1179         if (!_.swfu || !_.swfu.loaded) $(defaultButton).parent().parent().find('.swfupload').remove();
    1180     });
    1181 
    1182     function swfuLoaded () {
    1183         $(defaultButton).hide();
    1184         this.loaded = true;
    1185     }
    1186 
    1187     _.updateLine = function (line,status) {
    1188         if (!_.swfu) {
    1189             _.targetLine = line;
    1190             _.targetCell = status;
    1191         } else {
    1192             _.swfu.targetLine = line;
    1193             _.swfu.targetCell = status;
    1194         }
    1195     };
    1196 
    1197     function fileQueueError (file, error, message) {
    1198         if (error == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
    1199             alert("You selected too many files to upload at one time. " + (message === 0 ? "You have reached the upload limit." : "You may upload " + (message > 1 ? "up to " + message + " files." : "only one file.")));
    1200             return;
    1201         } else {
    1202             alert(message);
    1203         }
    1204 
    1205     }
    1206 
    1207     function fileDialogComplete (selected, queued) {
    1208         $.colorbox.hide();
    1209         if (!selected) return;
    1210         try { this.startUpload(); }
    1211         catch (ex) { this.debug(ex); }
    1212 
    1213     }
    1214 
    1215     function startUpload (file) {
    1216         this.targetCell.attr('class','').html('');
    1217         $('<div class="progress"><div class="bar"></div><div class="gloss"></div></div>').appendTo(this.targetCell);
    1218         this.progressBar = this.targetCell.find('div.bar');
    1219     }
    1220 
    1221     function uploadProgress (file, loaded, total) {
    1222         this.progressBar.animate({'width':Math.ceil((loaded/total)*76)+'px'},100);
    1223     }
    1224 
    1225     function uploadSuccess (file, results) {
    1226          var filedata = false,targetCell = this.targetCell,i = this.targetLine;
    1227 
    1228         $.colorbox.close();
    1229         try { filedata = $.parseJSON(results); }
    1230         catch (ex) { filedata.error = results; }
    1231         if (!filedata.id && !filedata.name) {
    1232             targetCell.html(NO_DOWNLOAD);
    1233             if (filedata.error) alert(filedata.error);
    1234             else alert(UNKNOWN_UPLOAD_ERROR);
    1235             return false;
    1236         }
    1237 
    1238         filedata.type = filedata.type.replace(/\//gi," ");
    1239         $(this.progressBar).animate({'width':'76px'},250,function () {
    1240             $(this).parent().fadeOut(500,function() {
    1241                 $(this).remove();
    1242                 $(targetCell).attr('class', 'file').html(
    1243                     '<div class="icon shoppui-file ' + filedata.type + '"></div>' +
    1244                     filedata.name + '<br /><small>' + readableFileSize(filedata.size)+'</small>' +
    1245                     '<input type="hidden" name="price[' + i + '][download]" value="' + filedata.id + '" />'
    1246                 );
    1247             });
    1248         });
    1249     }
    1250 
    1251 }
    1252 
    1253 function SlugEditor (id,type) {
     1203        } //init
     1204    }); // this.dropzone
     1205
     1206} // FileUploader
     1207
     1208function SlugEditor(id,type) {
    12541209    var $ = jQuery, _ = this,
    12551210        editbs = $('#edit-slug-buttons'),
  • shopp/trunk/core/ui/behaviors/editors.min.js

    r1648469 r1859263  
    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="&nbsp;&nbsp;'+IMAGE_DETAILS_DONE+'&nbsp;&nbsp;" /></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(":","&times;")+"</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})};
     1function NestedMenu(e,i,n,t,l,o,a){var s=jQuery,r=this;a||(a={axis:"y"}),r.items=o,r.dataname=n,r.index=e,r.element=s('<li><div class="move"></div><input type="hidden" name="'+n.replace("[","-").replace("]","-")+'-sortorder[]" value="'+e+'" class="sortorder" /><input type="hidden" name="'+n+"["+e+'][id]" class="id" /><input type="text" name="'+n+"["+e+'][name]" class="label" /><button type="button" class="delete"><span class="shoppui-minus"></span></button></li>').appendTo(s(i).children("ul")),r.moveHandle=r.element.find("div.move"),r.sortorder=r.element.find("input.sortorder"),r.id=r.element.find("input.id"),r.label=r.element.find("input.label"),r.deleteButton=r.element.find("button.delete").bind("delete",function(){var e=s(i).find("input.deletes");""!=s(r.id).val()&&e.val(""==e.val()?s(r.id).val():e.val()+","+s(r.id).val()),o&&r.itemsElement.remove(),r.element.remove()}).click(function(){s(this).trigger("delete")}),r.items&&("list"==o.type?r.itemsElement=s("<ul></ul>").appendTo(o.target).hide():r.itemsElement=s("<li></li>").appendTo(o.target).hide()),r.selected=function(){s(i).find("ul li").removeClass("selected"),s(r.element).addClass("selected"),o&&(s(o.target).children().hide(),s(r.itemsElement).show())},r.element.click(this.selected).hover(function(){s(this).addClass("hover")},function(){s(this).removeClass("hover")}),r.label.mouseup(function(e){this.select()}).focus(function(){s(this).keydown(function(e){e.stopPropagation(),13==e.keyCode&&s(this).blur().unbind("keydown")})}),r.id.val(r.index),l&&l.id&&r.id.val(l.id),l&&l.name?r.label.val(htmlentities(l.name)):r.label.val(t+" "+r.index),s(i).children("ul").hasClass("ui-sortable")?s(i).children("ul").sortable("refresh"):s(i).children("ul").sortable(a)}function NestedMenuContent(e,i,n,t){var l=jQuery;this.contents=l('<textarea name="'+n+"["+e+'][value]" cols="40" rows="7"></textarea>').appendTo(i),t&&t.value&&this.contents.val(htmlentities(t.value))}function NestedMenuOption(e,i,n,t,l){var o=jQuery,a=this;a.index=o(i).contents().length,a.element=o('<li class="option"><div class="move"></div><input type="hidden" name="'+n+"["+e+"][options]["+this.index+'][id]" class="id" /><input type="text" name="'+n+"["+e+"][options]["+this.index+'][name]" class="label" /><button type="button" class="delete"><span class="shoppui-minus"></span></button></li>').appendTo(i),a.moveHandle=a.element.find("div.move"),a.id=a.element.find("input.id"),a.label=a.element.find("input.label"),a.deleteButton=a.element.find("button.delete").click(function(){o(a.element).remove()}),a.element.hover(function(){o(this).addClass("hover")},function(){o(this).removeClass("hover")}),a.label.click(function(){this.select()}).focus(function(){o(this).keydown(function(e){e.stopPropagation(),13==e.keyCode&&o(this).blur().unbind("keydown")})}),a.id.val(a.index),l.id&&a.id.val(l.id),l.name&&a.label.val(htmlentities(l.name)),l.name||a.label.val(t+" "+(a.index+1))}function loadVariations(e,i){if(e){var n=jQuery;n.each(e,function(e,i){i&&i.id&&addVariationOptionsMenu(i)}),n.each(i,function(e,i){"variation"==i.context&&Pricelines.add(i.options.split(","),i,"#variations-pricing")}),Pricelines.updateVariationsUI(),n.each(e,function(e,i){i&&i.options&&n.each(i.options,function(e,i){i&&i.id&&"on"==i.linked&&Pricelines.linkVariations(i.id)})})}}function addVariationOptionsMenu(e){var i=jQuery,n=i("#variations-menu"),t=i("#variations-list"),l=(i("#addVariationMenu"),i("#addVariationOption")),o=i("#linkOptionVariations"),a=new NestedMenu(variationsidx,n,"meta[options][v]",OPTION_MENU_DEFAULT,e,{target:t,type:"list"},{axis:"y",update:function(){orderOptions(n,t)}});a.addOption=function(e){var n,s,r=!1;e||(e=new Object),e.id?e.id>optionsidx&&(optionsidx=e.id):(r=!0,e.id=optionsidx),n=new NestedMenuOption(a.index,a.itemsElement,"meta[options][v]",NEW_OPTION_DEFAULT,e),optionsidx++,s=n.id.val(),n.linkIcon=i('<span class="shoppui-link"></span>').appendTo(n.moveHandle),n.linked=i('<input type="hidden" name="meta[options][v]['+a.index+"][options]["+n.index+'][linked]" class="linked" />').val(e.linked?e.linked:"off").appendTo(n.element).change(function(){"on"==i(this).val()?n.linkIcon.removeClass("hidden"):n.linkIcon.addClass("hidden")}).change(),n.selected=function(){n.element.hasClass("selected")?(t.find("ul li").removeClass("selected"),selectedMenuOption=!1):(t.find("ul li").removeClass("selected"),i(n.element).addClass("selected"),selectedMenuOption=n),o.change()},n.element.click(n.selected),productOptions[s]=n.label,n.label.blur(function(){updateVariationLabels()}),n.deleteButton.unbind("click"),n.deleteButton.click(function(){1==a.itemsElement.children().length?deleteVariationPrices([s],!0):deleteVariationPrices([s]),n.element.remove()}),r?addVariationPrices():addVariationPrices(s),t.dequeue().animate({scrollTop:t.prop("scrollHeight")-t.height()},200),n.label.click().focus().select().keydown(function(e){9==(e.keyCode||e.which)&&(e.preventDefault(),n.label.blur(),l.focus())}),a.items.push(n)},a.items=new Array,e&&e.options?i.each(e.options,function(){a.addOption(this)}):(a.addOption(),a.addOption()),a.itemsElement.sortable({axis:"y",update:function(){orderVariationPrices()}}),a.element.unbind("click",a.click).click(function(){a.selected(),i(l).unbind("click").click(a.addOption)}),optionMenus[variationsidx++]=a,a.deleteButton.unbind("click").click(function(){var e=new Array;i(a.itemsElement).find("li").not(".ui-sortable-helper").find("input.id").each(function(n,t){e.push(i(t).val())}),deleteVariationPrices(e,!0),i(this).trigger("delete")}),e||(t.dequeue().animate({scrollTop:t.attr("scrollHeight")-t.height()},200),a.label.click().focus().select().keydown(function(e){9==(e.keyCode||e.which)&&(e.preventDefault(),l.focus())}))}function buildVariations(){var e,i,n,t,l=jQuery,o=new Array,a=l("#variations-list ul"),s=a.length-1,r=new Array(a.length),d=new Array(a.length),c=0;for(a.each(function(e,i){d[e]=l(i).children().length,0==c?c=l(i).children().length:c*=l(i).children().length,r[e]=0}),e=0;e<c;e++){for(i=0;i<a.length;i++)n=l(a[i]).children("li").not(".ui-sortable-helper").children("input.id"),o[e]?o[e].push(l(n[r[i]]).val()):o[e]=[l(n[r[i]]).val()];if(++r[s]>=d[s])for(t=s;t>-1;t--)r[t]<d[t]||(r[t]=0,t-1>-1&&r[t-1]++)}return o}function addVariationPrices(e){if(!e){var i,n,t=jQuery,l=buildVariations(),o=t(t("#variations-pricing")).children(),a=!1;t(l).each(function(e,t){i=xorkey(t),""==(n=xorkey(t.slice(0,t.length-1)))&&(n=-1),Pricelines.row[i]||(Pricelines.row[n]?(Pricelines.row[i]=Pricelines.row[n],delete Pricelines.row[n],Pricelines.row[i].setOptions(t)):(0==o.length?Pricelines.add(t,{context:"variation"},"#variations-pricing"):Pricelines.add(t,{context:"variation"},Pricelines.row[xorkey(l[e-1])].row,"after"),a=!0))}),a&&Pricelines.updateVariationsUI()}}function deleteVariationPrices(e,i){var n,t,l,o,a,s=jQuery,r=buildVariations(),d=!1;s(r).each(function(r,c){for(t=xorkey(c),n=0;n<e.length;n++)-1!=c.indexOf(e[n])&&(l=new Array,s(c).each(function(i,t){t!=e[n]&&l.push(t)}),o=xorkey(l),i&&!Pricelines.row[o]?(0!=o?Pricelines.row[o]=Pricelines.row[t]:Pricelines.row[t].row.remove(),delete Pricelines.row[t],Pricelines.row[o]&&(Pricelines.row[o].setOptions(l),d=!0)):Pricelines.row[t]&&(a=s("#priceid-"+Pricelines.row[t].id).val(),""==s("#deletePrices").val()?s("#deletePrices").val(a):s("#deletePrices").val(s("#deletePrices").val()+","+a),Pricelines.remove(t)))}),d&&Pricelines.updateVariationsUI()}function optionMenuExists(e){if(!e)return!1;var i=jQuery,n=!1;return i.each(optionMenus,function(t,l){if(l&&i(l.label).val()==e)return n=t}),optionMenus[n]?optionMenus[n]:n}function optionMenuItemExists(e,i){if(!e||!e.items||!i)return!1;var n=jQuery,t=!1;return n.each(e.items,function(e,l){if(l&&n(l.label).val()==i)return t=!0}),t}function updateVariationLabels(){jQuery(buildVariations()).each(function(e,i){var n=xorkey(i);Pricelines.row[n]&&Pricelines.row[n].updateLabel()})}function orderOptions(e,i){var n=jQuery;n(e).find("ul li").not(".ui-sortable-helper").find("input.id").each(function(e,t){t&&n(optionMenus[n(t).val()].itemsElement).appendTo(i)}),orderVariationPrices()}function orderVariationPrices(){var e;jQuery(buildVariations()).each(function(i,n){(e=xorkey(n))>0&&Pricelines.row[e]&&Pricelines.reorderVariation(e,n)}),Pricelines.updateVariationsUI("tabs")}function xorkey(e){e instanceof Array||(e=[e]);for(var i=0,n=0;n<e.length;n++)i^=7001*e[n];return i}function variationsToggle(){var e=jQuery,i=e(this),n=e("#variations"),t=e("#product-pricing");i.prop("checked")?(Pricelines.row[0]&&Pricelines.row[0].disable(),t.hide(),n.show()):(n.hide(),t.show(),Pricelines.row[0]&&Pricelines.row[0].enable())}function addonsToggle(){var e=jQuery,i=e(this),n=e("#addons");i.prop("checked")?n.show():n.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 n=jQuery;e&&(n.each(e,function(e,i){newAddonGroup(i)}),n.each(i,function(e,i){if("addon"==i.context){var n=addonOptionsGroup[i.options];Pricelines.add(i.options,this,"#addon-pricegroup-"+n)}}),Pricelines.updateVariationsUI())}function newAddonGroup(e){var i=jQuery,n=i("#addon-menu"),t=i("#addon-list"),l=i("#newAddonGroup"),o=i("#addAddonOption"),a=addon_group_idx,s=new NestedMenu(a,n,"meta[options][a]",ADDON_GROUP_DEFAULT,e,{target:t,type:"list"},{axis:"y",update:function(){orderAddonGroups()}});s.itemsElement.attr("id","addon-group-"+a),s.pricegroup=i('<div id="addon-pricegroup-'+a+'" />').appendTo("#addon-pricing"),s.pricegroupLabel=i("<label />").html("<h4>"+s.label.val()+"</h4>").prependTo(s.pricegroup),s.updatePriceLabel=function(){s.pricegroupLabel.html("<h4>"+s.label.val()+"</h4>")},s.label.blur(s.updatePriceLabel),s.addOption=function(e){var n,l,a=!1;e||(e=new Object),e.id?e.id>addonsidx&&(addonsidx=e.id):(a=!0,e.id=addonsidx),n=new NestedMenuOption(s.index,s.itemsElement,"meta[options][a]",NEW_OPTION_DEFAULT,e),addonsidx++,l=n.id.val(),n.selected=function(){n.element.hasClass("selected")?(t.find("ul li").removeClass("selected"),selectedMenuOption=!1):(t.find("ul li").removeClass("selected"),i(n.element).addClass("selected"),selectedMenuOption=n)},n.element.click(n.selected),productAddons[l]=n.label,n.label.blur(function(){Pricelines.row[l].updateLabel()}),n.deleteButton.unbind("click"),n.deleteButton.click(function(){var e=Pricelines.row[l].data.id,t=i("#deletePrices");e&&(""==t.val()?t.val(e):t.val(t.val()+","+e)),Pricelines.row[l].row.remove(),n.element.remove()}),a&&Pricelines.add(l,{context:"addon"},s.pricegroup),addonOptionsGroup[l]=s.index,s.items.push(n),t.dequeue().animate({scrollTop:t.attr("scrollHeight")-t.height()},200),n.label.click().focus().select().keydown(function(e){9==(e.keyCode||e.which)&&(e.preventDefault(),n.label.blur(),o.focus())})},s.items=new Array,e&&e.options?i.each(e.options,function(){s.addOption(this)}):(s.addOption(),s.addOption()),s.itemsElement.sortable({axis:"y",update:function(){orderAddonPrices(s.index)}}),s.element.unbind("click",s.click),s.element.click(function(){s.selected(),i(o).unbind("click").click(s.addOption)}),addonGroups[addon_group_idx++]=s,s.deleteButton.unbind("click").click(function(){i("#addon-list #addon-group-"+s.index+" li").not(".ui-sortable-helper").find("input.id").each(function(e,n){var t,l=i(n).val(),o=i("#deletePrices");Pricelines.row[l]&&((t=Pricelines.row[l].data.id)&&(""==o.val()?o.val(t):o.val(o.val()+","+t)),Pricelines.row[l].row.remove())}),s.deleteButton.trigger("delete"),s.pricegroup.remove(),s.element.remove()}),e||(n.dequeue().animate({scrollTop:n.attr("scrollHeight")-n.height()},200),s.label.click().focus().select().keydown(function(e){9==(e.keyCode||e.which)&&(e.preventDefault(),s.label.blur(),l.focus())}))}function orderAddonGroups(){var e,i=jQuery;i("#addon-menu ul li").not(".ui-sortable-helper").find("input.id").each(function(n,t){(e=addonGroups[i(t).val()]).pricegroup.appendTo("#addon-pricing")})}function orderAddonPrices(e){var i=jQuery,n=addonGroups[e];i("#addon-list #addon-group-"+n.index+" li").not(".ui-sortable-helper").find("input.id").each(function(e,t){Pricelines.reorderAddon(i(t).val(),n.pricegroup)})}function readableFileSize(e){var i=new Array("bytes","KB","MB","GB"),n=1*e,t=0;if(0==n)return n;for(;n>1e3;)n/=1024,t++;return n.toFixed(2)+" "+i[t]}function addDetail(e){var i,n,t=jQuery,l=t("#details-menu"),o=t("#details-list"),a=new NestedMenu(detailsidx++,l,"details","Detail Name",e,{target:o});if(e&&e.options){n=t('<select name="details['+a.index+'][value]"></select>').appendTo(a.itemsElement),t("<option></option>").appendTo(n);for(i in e.options)t("<option>"+e.options[i].name+"</option>").appendTo(n);e&&e.value&&n.val(htmlentities(e.value))}else a.item=new NestedMenuContent(a.index,a.itemsElement,"details",e);e&&!e.add||(a.add=t('<input type="hidden" name="details['+a.index+'][new]" value="true" />').appendTo(a.element),l.dequeue().animate({scrollTop:l.attr("scrollHeight")-l.height()},200),a.label.click().focus().select(),a.item&&a.item.contents.keydown(function(e){9==(e.keyCode||e.which)&&(e.preventDefault(),t("#addDetail").focus())}))}function ImageUploads(e,i){function n(){t(".lightbox-dropzone li").length>0&&t(".lightbox-dropzone").sortable({opacity:.8})}var t=jQuery;Dropzone.autoDiscover=!1,t.template("image-preview-template",t("#lightbox-image-template"));new Dropzone("ul.lightbox-dropzone",{url:imgul_url+"&type="+i+"&parent="+e,maxFilesize:uploadLimit/1024/1024,autoDiscover:!1,parallelUploads:5,autoProcessQueue:!0,previewTemplate:t.tmpl("image-preview-template").html(),acceptedFiles:"image/*",init:function(){var e=this;t(".image-upload").on("click",function(){e.hiddenFileInput.click()}),e.on("error",function(e,i){t(".lightbox-dropzone li.dz-error").on("click",function(){t(this).fadeOut(300,function(){t(this).remove()})})}),e.on("success",function(e,i){t(e.previewElement).find(".imageid").attr("value",i.id)}),e.on("complete",function(e,i){n()})}});n(),t(".lightbox-dropzone li:not(.dz-upload-control)").each(function(){t(this).dblclick(function(){var e=t(this).attr("id")+"-details",i=t("#"+e),n=i.find("input[type=hidden]").val(),l=i.find("img"),o=i.find("input.imagetitle"),a=i.find("input.imagealt"),s=i.find("input.imagecropped"),r=t('<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="&nbsp;&nbsp;'+IMAGE_DETAILS_DONE+'&nbsp;&nbsp;" /></div>'),d=(r.find("img").attr("src",l.attr("src")),r.find("input[name=title]").val(o.val()).change(function(){o.val(d.val())})),c=r.find("input[name=alt]").val(a.val()).change(function(){a.val(c.val())}),u=(r.find("input[type=button]").click(function(){t.colorbox.close()}),r.find("div.cropping").hide()),p=r.find("div.cropui"),h=r.find("select[name=cropimage]").change(function(){if(""==h.val())return p.empty(),void t.colorbox.resize();var e=h.val().split(":"),i=s.filter("input[alt="+h.val()+"]").val().split(",");p.empty().scaleCrop({imgsrc:"?siid="+n,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(){t.colorbox.resize({innerWidth:parseInt(e[0],10)+125})}).bind("change.scalecrop",function(e,i){i.s||(i.s=1),i&&s.filter("input[alt="+h.val()+"]").val(i.x+","+i.y+","+i.s)})});s.size()>0&&(s.each(function(e,i){var n=t(i).attr("alt");t('<option value="'+n+'">'+(e+1)+": "+n.replace(":","&times;")+"</option>").appendTo(h)}),u.show()),t.colorbox({title:IMAGE_DETAILS_TEXT,html:r})}),function(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(),n=t("#deleteImages"),l=n.val();n.val(""==l?i:l+","+i),t("#confirm-delete-images").show(),e.parent().fadeOut(500,function(){t(this).remove()})}})}(t(this).find("button.delete"))})}function FileUploader(e){var i=jQuery,n=this;this.priceline=!1,i.template("filechooser-upload-template",i("#filechooser-upload-template")),this.dropzone=new Dropzone(e,{url:fileupload_url,autoDiscover:!1,uploadMultiple:!1,autoQueue:!0,autoProcessQueue:!0,chunking:!0,forceChunking:!0,chunkSize:chunkSize,maxFilesize:4096,parallelChunkUploads:!1,retryChunks:!0,parallelConnectionsLimit:uploadMaxConnections,previewTemplate:i.tmpl("filechooser-upload-template").html(),init:function(){var e=this;e.startTime=!1,e.samples=[],e.samplesLimit=5,e.connections=0,i(".filechooser-upload").on("mousedown",function(){e.hiddenFileInput.click(),i(e.previewsContainer).empty()}),e.on("addedfile",function(n){i.colorbox.hide(),e.processQueue(),i(e.previewsContainer).find(".icon.shoppui-file").addClass(n.type.replace("/"," "))}),e.on("success",function(t){var l=JSON.parse(t.xhr.response);l.id&&i("<input>").attr({type:"hidden",name:"price["+n.priceline+"][download]",value:l.id}).appendTo(i(e.previewsContainer))}),e.options.params=function(e,i,n){if(n)return{dzuuid:n.file.upload.uuid,dzchunkindex:n.index,dztotalfilesize:n.file.size,dzchunksize:n.chunkSize,dztotalchunkcount:n.file.upload.totalChunkCount,dzchunkbyteoffset:n.end}},e.uploadFiles=function(i){var n=this;this._transformFiles(i,function(t){if(i[0].upload.chunked){var l=i[0],o=t[0],a=0;l.upload.chunks=[];var s=function(){for(var t=0;void 0!==l.upload.chunks[t];)t++;if(!(t>=l.upload.totalChunkCount)){a++;var s=t*n.options.chunkSize,r=Math.min(s+n.options.chunkSize,l.size);!1===e.startTime&&(e.startTime=(new Date).getTime());var d=(new Date).getTime();if(e.samples.length<=e.samplesLimit&&l.upload.bytesSent>0&&e.samples.push(l.upload.bytesSent/((d-e.startTime)/1e3)),e.samples.length==e.samplesLimit){var c=e.samples.reduce(function(e,i){return e+i})/e.samples.length;e.options.chunkSize=Math.min(Math.floor(c),uploadLimit-1024),l.upload.totalChunkCount=Math.ceil((l.size-l.upload.bytesSent)/e.options.chunkSize)+e.samplesLimit;var u=Math.floor(c/e.options.chunkSize);u>1&&(e.options.parallelChunkUploads=!0,e.options.parallelConnectionsLimit=Math.min(u,e.options.parallelConnectionsLimit))}t>0&&(s=l.upload.chunks[t-1].end,r=Math.min(s+e.options.chunkSize,l.size));var p={name:n._getParamName(0),data:o.webkitSlice?o.webkitSlice(s,r):o.slice(s,r),filename:l.upload.filename,chunkIndex:t};l.upload.chunks[t]={file:l,index:t,dataBlock:p,status:Dropzone.UPLOADING,progress:0,start:s,end:r,chunkSize:e.options.chunkSize,retries:0},n._uploadData(i,[p])}},r=function(){for(e.connections>0&&e.connections--;e.connections<e.options.parallelConnectionsLimit;e.connections++)s()};if(l.upload.finishedChunkUpload=function(t){var o=!0;t.status=Dropzone.SUCCESS,t.dataBlock=null;for(var a=0;a<l.upload.totalChunkCount;a++){if(void 0===l.upload.chunks[a])return e.options.parallelChunkUploads?r():s();l.upload.chunks[a].status!==Dropzone.SUCCESS&&(o=!1)}o&&n.options.chunksUploaded(l,function(){n._finished(i,"",null)})},n.options.parallelChunkUploads)for(var d=0;d<l.upload.totalChunkCount;d++)s();else s()}else{for(var c=[],u=0;u<i.length;u++)c[u]={name:n._getParamName(u),data:t[u],filename:i[u].upload.filename};n._uploadData(i,c)}})}}})}function SlugEditor(e,i){var n=jQuery,t=n("#edit-slug-buttons"),l=t.find(".edit"),o=t.find(".view"),a=n("#editor-slug-buttons"),s=a.find(".save"),r=a.find(".cancel"),d=n("#editable-slug-full");this.permalink=function(){var l,c=0,u=n("#editable-slug"),p=u.html(),h=n("#slug_input"),f=h.html(),m=d.html();for(t.hide(),a.show(),s.unbind("click").click(function(){var l=u.children("input").val(),s=n("#title").val();n.post(editslug_url+"&action=shopp_edit_slug",{id:e,type:i,slug:l,title:s},function(e){u.html(p),-1!=e&&(u.html(e),d.html(e),h.val(e)),o.attr("href",canonurl+d.html()),a.hide(),t.show()},"text")}),r.unbind("click").click(function(){u.html(p),a.hide(),t.show(),h.attr("value",f)}),l=0;l<m.length;++l)"%"==m.charAt(l)&&c++;slug_value=c>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&&r.click(),h.val(this.value)}).focus()},l.click(this.permalink)}jQuery.fn.FileChooser=function(e,i){var n=jQuery,t=this,l=n("#filechooser"),o=l.find(".fileimport"),a=l.find(".status"),s=n("#attach-file"),r=n("#download_path-"+e),d=n("#download_file-"+e),c=n("#file-"+e);t.line=e,t.status=i,l.unbind("change").on("change",".fileimport",function(e){a.attr("class","status").addClass("shoppui-spinner shoppui-spinfx shoppui-spinfx-steps8"),n.ajax({url:fileverify_url+"&action=shopp_verify_file&t=download",type:"POST",data:"url="+o.val(),timeout:1e4,dataType:"text",success:function(e){if(a.attr("class","status"),"OK"==e)return a.addClass("shoppui-ok-sign");"NULL"==e&&a.attr("title",FILE_NOT_FOUND_TEXT),"ISDIR"==e&&a.attr("title",FILE_ISDIR_TEXT),"READ"==e&&a.attr("title",FILE_NOT_READ_TEXT),a.addClass("shoppui-warning-sign")}})}),o.unbind("keydown").unbind("keypress").suggest(sugg_url+"&action=shopp_storage_suggestions&t=download",{delay:500,minchars:3,multiple:!1,onSelect:function(){o.trigger("change")}}),n(this).click(function(){a.attr("class","status"),fileUploads.dropzone.previewsContainer=c[0],fileUploads.priceline=t.line,s.unbind("click").click(function(){n.colorbox.hide();var i=!1,t=!1,l=0,a=o.val(),s=function(e){if(!e.name)return $this.attr("class","");r.val(e.path),d.val(e.name),o.val("").attr("class","fileimport")},u=function(e){e||(e=FILE_UNKNOWN_IMPORT_ERROR),c.attr("class","error").html("<small>"+e+"</small>")},p=function(){var e=f.importProgress,n=f.importFile;if(void 0===n)return h();if(!n.path)return u();if(n.error)return u(n.error);if(n.stored)return s(n);if(void 0===e&&(e=0),savepath=n.path.split("/"),i=savepath[savepath.length-1],t||(m.addClass(n.mime.replace("/"," ")),v.text(n.name),g.text(readableFileSize(n.size)),k.css("opacity",1),t=!0),0===e&&l++>60)return u();var o=Math.floor(100*e);b[0].style.width=o+"%",o>=100?k.fadeOut(500,function(){s(n)}):h()},h=function(){setTimeout(p,100)};n.template("filechooser-upload-template",n("#filechooser-upload-template")),c.attr("class","").html(n.tmpl("filechooser-upload-template").html()).append('<iframe id="import-file-'+e+'" width="0" height="0" src="'+fileimport_url+"&action=shopp_import_file&url="+a+'"></iframe>');var f=n("#import-file-"+e)[0].contentWindow,m=c.find(".icon"),v=c.find(".dz-filename"),g=c.find(".dz-size"),k=c.find(".dz-progress"),b=c.find(".dz-upload");h()})}),n(this).colorbox({title:"File Selector",innerWidth:"360",innerHeight:"140",inline:!0,href:l})};
  • shopp/trunk/core/ui/behaviors/shopp.js

    r1473303 r1859263  
    205205 **/
    206206function quickSelects (e) {
    207     var target = jQuery(e).size() == 0 ? document : e;
     207    var target = jQuery(e).length == 0 ? document : e;
    208208    jQuery(target).on('mouseup.select', 'input.selectall', function () { this.select(); });
    209209}
    210210
    211211function moneyInputs (e) {
    212     var target = jQuery(e).size() == 0 ? document : e;
     212    var target = jQuery(e).length == 0 ? document : e;
    213213    jQuery(document).on('change', 'input.money', function () { this.value = asMoney(this.value); });
    214214}
  • shopp/trunk/core/ui/behaviors/shopp.min.js

    r1473303 r1859263  
    1 function jqnc(){return jQuery.noConflict()}function copyOf(e){var r,n=new Object;for(r in e)n[r]=e[r];return n}function getCurrencyFormat(e){if(e&&e.currency)return e;var r={cpos:!0,currency:"$",precision:2,decimals:".",thousands:",",grouping:[3]},n={cp:"cpos",c:"currency",p:"precision",d:"decimals",t:"thousands",g:"grouping"},t=r;return jQuery.each(n,function(e,r){void 0!==$s[e]&&("p"==e?t[r]=parseInt($s[e],10):"cp"==e?t[r]=Boolean($s[e]):"g"==e?t[r]=$s[e].split(","):t[r]=$s[e])}),t}function asMoney(e,r){return r=getCurrencyFormat(r),e=formatNumber(e,r),r.cpos?r.currency+e:e+r.currency}function asPercent(e,r,n,t){return r=getCurrencyFormat(r),r.precision=n?n:1,formatNumber(e,r,t).replace(/0+$/,"").replace(new RegExp("\\"+r.decimals+"$"),"")+"%"}function formatNumber(e,r,n){r=getCurrencyFormat(r),e=asNumber(e);var t,i=fraction=0,u=!1,c="",o=[],a=e.toFixed(r.precision).toString().split("."),s=r.grouping?r.grouping:[3];for(e="",i=a[0],a[1]&&(fraction=a[1]),s=s.indexOf(",")>-1?s.split(","):[s],t=0,lg=s.length-1;i.length>s[Math.min(t,lg)]&&""!=s[Math.min(t,lg)];)u=i.length-s[Math.min(t++,lg)],c=i,i=c.substr(0,u),o.unshift(c.substr(u));return i&&o.unshift(i),e=o.join(r.thousands),""==e&&(e=0),fraction=n?new Number("0."+fraction).toString().substr(2,r.precision):fraction,fraction=!n||n&&fraction.length>0?r.decimals+fraction:"",r.precision>0&&(e+=fraction),e}function asNumber(e,r){return e?(r=getCurrencyFormat(r),e instanceof Number?new Number(e.toFixed(r.precision)):"number"==typeof e?new Number(e.toFixed(r.precision)):(e=e.toString().replace(r.currency,""),e=e.toString().replace(new RegExp(/(\D\.|[^\d\,\.\-])/g),""),""!=r.thousands&&(e=e.toString().replace(new RegExp("\\"+r.thousands,"g"),"")),r.precision>0&&(e=e.toString().replace(new RegExp("\\"+r.decimals,"g"),".")),isNaN(new Number(e))&&(e=e.replace(new RegExp(/\./g),"").replace(new RegExp(/\,/),".")),new Number(e))):0}function CallbackRegistry(){this.callbacks=new Array,this.register=function(e,r){this.callbacks[e]=r},this.call=function(e,r,n,t){this.callbacks[e](r,n,t)},this.get=function(e){return this.callbacks[e]}}function quickSelects(e){var r=0==jQuery(e).size()?document:e;jQuery(r).on("mouseup.select","input.selectall",function(){this.select()})}function moneyInputs(e){0==jQuery(e).size()?document:e;jQuery(document).on("change","input.money",function(){this.value=asMoney(this.value)})}function htmlentities(e){return e?e=e.replace(new RegExp(/&#(\d+);/g),function(){return String.fromCharCode(RegExp.$1)}):""}jQuery.ua={chrome:!1,mozilla:!1,opera:!1,msie:!1,safari:!1},jQuery.each(jQuery.ua,function(e,r){var n=navigator.userAgent;jQuery.ua[e]=!!new RegExp(e,"i").test(n),jQuery.ua.mozilla&&"mozilla"==e&&(jQuery.ua.mozilla=!!new RegExp("firefox","i").test(n)),jQuery.ua.chrome&&"safari"==e&&(jQuery.ua.safari=!1)}),Array.indexOf||(Array.prototype.indexOf=function(e){for(var r=0;r<this.length;r++)if(this[r]==e)return r;return-1}),Number.prototype.roundFixed||(Number.prototype.roundFixed=function(e){var r=Math.pow(10,e||0);return String(Math.round(this*r)/r)}),jQuery.fn.fadeRemove=function(e,r){var n=jQuery(this);return n.fadeOut(e,function(){n.remove(),r&&r()}),this},jQuery.fn.hoverClass=function(){var e=jQuery(this);return e.hover(function(){e.addClass("hover")},function(){e.removeClass("hover")}),this},jQuery.fn.clickSubmit=function(){var e=jQuery(this);return e.click(function(){jQuery(this).closest("form").submit()}),this},jQuery.fn.setDisabled=function(e){var r=jQuery(this);return r.each(function(){e?r.attr("disabled",!0).addClass("disabled"):r.attr("disabled",!1).removeClass("disabled")}),this},jQuery.parseJSON=function(data){if("undefined"==typeof JSON||"function"!=typeof JSON.parse)return eval("("+data+")");try{return JSON.parse(data)}catch(e){return!1}},jQuery.getQueryVar=function(e,r){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+e+"=([^&#]*)"),t=n.exec(r);return null==t?"":decodeURIComponent(t[1].replace(/\+/g," "))},jQuery(document).ready(function(e){e("input.currency, input.money").change(function(){this.value=asMoney(this.value)}).change(),e(".click-submit").clickSubmit(),quickSelects()});
     1function jqnc(){return jQuery.noConflict()}function copyOf(e){var r,n=new Object;for(r in e)n[r]=e[r];return n}function getCurrencyFormat(e){if(e&&e.currency)return e;var r={cpos:!0,currency:"$",precision:2,decimals:".",thousands:",",grouping:[3]};return jQuery.each({cp:"cpos",c:"currency",p:"precision",d:"decimals",t:"thousands",g:"grouping"},function(e,n){void 0!==$s[e]&&(r[n]="p"==e?parseInt($s[e],10):"cp"==e?Boolean($s[e]):"g"==e?$s[e].split(","):$s[e])}),r}function asMoney(e,r){return r=getCurrencyFormat(r),e=formatNumber(e,r),r.cpos?r.currency+e:e+r.currency}function asPercent(e,r,n,t){return r=getCurrencyFormat(r),r.precision=n||1,formatNumber(e,r,t).replace(/0+$/,"").replace(new RegExp("\\"+r.decimals+"$"),"")+"%"}function formatNumber(e,r,n){r=getCurrencyFormat(r),e=asNumber(e);var t,i=fraction=0,u=!1,c="",o=[],a=e.toFixed(r.precision).toString().split("."),s=r.grouping?r.grouping:[3];for(e="",i=a[0],a[1]&&(fraction=a[1]),s=s.indexOf(",")>-1?s.split(","):[s],t=0,lg=s.length-1;i.length>s[Math.min(t,lg)]&&""!=s[Math.min(t,lg)];)u=i.length-s[Math.min(t++,lg)],i=(c=i).substr(0,u),o.unshift(c.substr(u));return i&&o.unshift(i),""==(e=o.join(r.thousands))&&(e=0),fraction=n?new Number("0."+fraction).toString().substr(2,r.precision):fraction,fraction=!n||n&&fraction.length>0?r.decimals+fraction:"",r.precision>0&&(e+=fraction),e}function asNumber(e,r){return e?(r=getCurrencyFormat(r),e instanceof Number?new Number(e.toFixed(r.precision)):"number"==typeof e?new Number(e.toFixed(r.precision)):(e=e.toString().replace(r.currency,""),e=e.toString().replace(new RegExp(/(\D\.|[^\d\,\.\-])/g),""),""!=r.thousands&&(e=e.toString().replace(new RegExp("\\"+r.thousands,"g"),"")),r.precision>0&&(e=e.toString().replace(new RegExp("\\"+r.decimals,"g"),".")),isNaN(new Number(e))&&(e=e.replace(new RegExp(/\./g),"").replace(new RegExp(/\,/),".")),new Number(e))):0}function CallbackRegistry(){this.callbacks=new Array,this.register=function(e,r){this.callbacks[e]=r},this.call=function(e,r,n,t){this.callbacks[e](r,n,t)},this.get=function(e){return this.callbacks[e]}}function quickSelects(e){var r=0==jQuery(e).length?document:e;jQuery(r).on("mouseup.select","input.selectall",function(){this.select()})}function moneyInputs(e){0==jQuery(e).size()&&document;jQuery(document).on("change","input.money",function(){this.value=asMoney(this.value)})}function htmlentities(e){return e?e=e.replace(new RegExp(/&#(\d+);/g),function(){return String.fromCharCode(RegExp.$1)}):""}jQuery.ua={chrome:!1,mozilla:!1,opera:!1,msie:!1,safari:!1},jQuery.each(jQuery.ua,function(e,r){var n=navigator.userAgent;jQuery.ua[e]=!!new RegExp(e,"i").test(n),jQuery.ua.mozilla&&"mozilla"==e&&(jQuery.ua.mozilla=!!new RegExp("firefox","i").test(n)),jQuery.ua.chrome&&"safari"==e&&(jQuery.ua.safari=!1)}),Array.indexOf||(Array.prototype.indexOf=function(e){for(var r=0;r<this.length;r++)if(this[r]==e)return r;return-1}),Number.prototype.roundFixed||(Number.prototype.roundFixed=function(e){var r=Math.pow(10,e||0);return String(Math.round(this*r)/r)}),jQuery.fn.fadeRemove=function(e,r){var n=jQuery(this);return n.fadeOut(e,function(){n.remove(),r&&r()}),this},jQuery.fn.hoverClass=function(){var e=jQuery(this);return e.hover(function(){e.addClass("hover")},function(){e.removeClass("hover")}),this},jQuery.fn.clickSubmit=function(){return jQuery(this).click(function(){jQuery(this).closest("form").submit()}),this},jQuery.fn.setDisabled=function(e){var r=jQuery(this);return r.each(function(){e?r.attr("disabled",!0).addClass("disabled"):r.attr("disabled",!1).removeClass("disabled")}),this},jQuery.parseJSON=function(data){if("undefined"==typeof JSON||"function"!=typeof JSON.parse)return eval("("+data+")");try{return JSON.parse(data)}catch(e){return!1}},jQuery.getQueryVar=function(e,r){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(r);return null==n?"":decodeURIComponent(n[1].replace(/\+/g," "))},jQuery(document).ready(function(e){e("input.currency, input.money").change(function(){this.value=asMoney(this.value)}).change(),e(".click-submit").clickSubmit(),quickSelects()});
  • shopp/trunk/core/ui/behaviors/suggest.js

    r821385 r1859263  
    3939        resetPosition();
    4040        $(window)
    41             .load(resetPosition)        // just in case user is changing size of page while loading
     41            .on('load', resetPosition)      // just in case user is changing size of page while loading
    4242            .resize(resetPosition);
    4343
  • shopp/trunk/core/ui/behaviors/suggest.min.js

    r1648469 r1859263  
    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);
     1!function(e){e.suggest=function(t,l){function s(){var e=o.offset();h.css({top:e.top+o.outerHeight()+l.yoffset+"px",left:e.left+"px"})}function a(e){if(/27$|38$|40$/.test(e.keyCode)&&h.is(":visible")||/^13$|^9$/.test(e.keyCode)&&u())switch(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,e.keyCode){case 38:!function(){var e=u();e?e.removeClass(l.selectClass).prev().addClass(l.selectClass):h.children("li:last-child").addClass(l.selectClass)}();break;case 40:c();break;case 9:case 13:r();break;case 27:h.hide()}else f.val().length!=m&&(p&&clearTimeout(p),p=setTimeout(i,l.delay),m=f.val().length)}function i(){var t,s,a=e.trim(f.val());0==a.length&&l.autoSuggest&&(a=l.autoSuggest),l.multiple&&-1!=(t=a.lastIndexOf(l.multipleSep))&&(a=e.trim(a.substr(t+l.multipleSep.length))),a.length>=l.minchars?(cached=function(e){var t;for(t=0;t<d.length;t++)if(d[t].q==e)return d.unshift(d.splice(t,1)[0]),d[0];return!1}(a),cached?n(cached.items):e.get(l.source,{q:a},function(t){h.hide(),n(s="json"==l.format?e.parseJSON(t):function(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.replace(new RegExp(s,"ig"),function(e){return'<span class="'+l.matchClass+'">'+e+"</span>"}),n[n.length]=i);return n}(t,a)),function(e,t,s){var a;for(;d.length&&g+s>l.maxCacheSize;)a=d.pop(),g-=a.size;d.push({q:e,size:s,items:t}),g+=s}(a,s,t.length)})):h.hide()}function n(t){var a,i="";if(t)if(t.length){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>";h.html(i).show(),h.children("li").mouseover(function(){h.children("li").removeClass(l.selectClass),e(this).addClass(l.selectClass)}).click(function(e){e.preventDefault(),e.stopPropagation(),r()}),l.autoSelect&&c()}else l.label&&h.html("<li>"+l.label+"</li>").show();else l.label&&h.html("<li>"+l.label+"</li>").show()}function u(){var e;return!!h.is(":visible")&&((e=h.children("li."+l.selectClass)).length||(e=!1),e)}function r(){$currentResult=u(),$currentResult&&(l.multiple?(-1!=f.val().indexOf(l.multipleSep)?$currentVal=f.val().substr(0,f.val().lastIndexOf(l.multipleSep)+l.multipleSep.length):$currentVal="",f.val($currentVal+$currentResult.text()+l.multipleSep),f.focus()):"alt"==l.value?f.val($currentResult.attr("alt")):f.val($currentResult.text()).attr("alt",$currentResult.attr("alt")),h.hide(),l.onSelect&&l.onSelect.apply(f[0]))}function c(){$currentResult=u(),$currentResult?$currentResult.removeClass(l.selectClass).next().addClass(l.selectClass):h.children("li:first-child").addClass(l.selectClass)}var o,f,h,p,m,d,g;if(o=e(t),input=o.is("input")?o:o.find("input"),f=e(input).attr("autocomplete","off"),h=e("<ul/>").appendTo("body"),p=!1,m=0,d=[],g=0,h.addClass(l.resultsClass).appendTo("body"),s(),e(window).load(s).resize(s),f.blur(function(){setTimeout(function(){h.hide()},200)}),l.showOnFocus&&f.focus(function(){s(),n(),l.autoSuggest&&function(){var e=!1;e&&clearTimeout(e),e=setTimeout(i,3e3),f.blur(function(){clearTimeout(e)})}()}),e.ua.msie)try{h.bgiframe()}catch(e){}e.ua.mozilla?f.keypress(a):f.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/categories/category.js

    r1473303 r1859263  
    77    pricingidx = 1,
    88    pricelevelsidx = 1,
    9     fileUploader = false,
    109    changes = false,
    1110    saving = false,
    12     flashUploader = false,
    1311    template = true;
    1412
     
    1614    var $=jQuery,
    1715        editslug = new SlugEditor(category,'category'),
    18         imageUploads = new ImageUploads($('#image-category-id').val(),'category')
     16        imageUploads = new ImageUploads($('#image-category-id').val(), 'category')
    1917        titlePrompt = $('#title-prompt-text'),
    2018
  • shopp/trunk/core/ui/categories/category.min.js

    r1648469 r1859263  
    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()});
     1var Pricelines=new Pricelines,productOptions=new Array,optionMenus=new Array,detailsidx=1,variationsidx=1,optionsidx=1,pricingidx=1,pricelevelsidx=1,changes=!1,saving=!1,template=!0;jQuery(document).ready(function(){function e(e){var t=i("#pricerange-menu"),n=pricelevelsidx++,a=new NestedMenu(n,t,"priceranges","",e,!1,{axis:"y",scroll:!1});i(a.label).change(function(){this.value=asMoney(this.value)}).change()}function t(e){var t=i("#details-menu"),n=i("#details-list"),a=i("#addDetailOption"),s=detailsidx,o=new NestedMenu(s,t,"specs",NEW_DETAIL_DEFAULT,e,{target:n,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=i('<li class="setting"></li>').appendTo(o.itemsElement),l=i('<select name="specs['+o.index+'][facetedmenu]"></select>').appendTo(c);i('<option value="disabled">'+FACETED_DISABLED+"</option>").appendTo(l),i('<option value="auto">'+FACETED_AUTO+"</option>").appendTo(l),i('<option value="ranges">'+FACETED_RANGES+"</option>").appendTo(l),i('<option value="custom">'+FACETED_CUSTOM+"</option>").appendTo(l),e&&e.facetedmenu&&l.val(e.facetedmenu),l.change(function(){"disabled"==i(this).val()||"auto"==i(this).val()?(i(a).hide(),i(o.itemsElement).find("li.option").hide()):(i(a).show(),i(o.itemsElement).find("li.option").show())}).change(),e&&e.options&&i.each(e.options,function(e,t){o.addOption(t)}),i(o.itemsElement).sortable({axis:"y",items:"li.option",scroll:!1}),o.element.unbind("click",o.click),o.element.click(function(){o.selected(),i(a).unbind("click").click(o.addOption),i(l).change()}),detailsidx++}var i=jQuery;new SlugEditor(category,"category"),new ImageUploads(i("#image-category-id").val(),"category");titlePrompt=i("#title-prompt-text"),title=i("#title").bind("focus keydown",function(){titlePrompt.hide()}).blur(function(){""==title.val()?titlePrompt.show():titlePrompt.hide()}),postboxes.add_postbox_toggles("shopp_page_shopp-categories"),i(".if-js-closed").removeClass("if-js-closed").addClass("closed"),i(".postbox a.help").click(function(){return i(this).colorbox({iframe:!0,open:!0,innerWidth:768,innerHeight:480,scrolling:!1}),!1}),i("#workflow").change(function(){setting=i(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&&i.each(worklist,function(e,t){t.id==category&&(worklist[e-1]?request.next=worklist[e-1].id:delete request.id)}),"next"==setting&&i.each(worklist,function(e,t){t.id==category&&(worklist[e+1]?request.next=worklist[e+1].id:delete request.id)})}).change(),i("#category").submit(function(){return""==title.val()?(alert(ENTER_CATEGORY_NAME),!1):(this.action=this.action.substr(0,this.action.indexOf("?"))+"?"+i.param(request),!0)}),i("#templates, #details-template, #details-facetedmenu, #variations-template, #variations-pricing, #price-ranges").hide(),i("#spectemplates-setting").change(function(){this.checked?i("#templates, #details-template").show():i("#details-template").hide(),i("#spectemplates-setting").attr("checked")||i("#variations-setting").attr("checked")||i("#templates").hide()}).change(),i("#faceted-setting").change(function(){this.checked?(i("#details-menu").removeClass("options").addClass("menu"),i("#details-facetedmenu, #price-ranges").show()):(i("#details-menu").removeClass("menu").addClass("options"),i("#details-facetedmenu, #price-ranges").hide())}).change(),details&&i.each(details,function(e,i){t(i)}),i("#addPriceLevel").click(function(){e()}),i("#addDetail").click(function(){t()}),i("#variations-setting").bind("toggleui",function(){this.checked?i("#templates, #variations-template, #variations-pricing").show():i("#variations-template, #variations-pricing").hide(),i("#spectemplates-setting").attr("checked")||i("#variations-setting").attr("checked")||i("#templates").hide()}).click(function(){i(this).trigger("toggleui")}).trigger("toggleui"),options&&loadVariations(options.v?options.v:options,prices),i("#addVariationMenu").click(function(){addVariationOptionsMenu()}),i("#pricerange-facetedmenu").change(function(){"custom"==i(this).val()?i("#pricerange-menu, #addPriceLevel").show():i("#pricerange-menu, #addPriceLevel").hide()}).change(),priceranges&&i.each(priceranges,function(t,i){e(i)}),category||i("#title").focus()});
  • shopp/trunk/core/ui/categories/category.php

    r1473303 r1859263  
    6363<script type="text/javascript">
    6464/* <![CDATA[ */
    65 var flashuploader = <?php echo ($uploader == 'flash' && !(false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac') && apache_mod_loaded('mod_security')))?'true':'false'; ?>,
    66     category = <?php echo (!empty($Category->id))?$Category->id:'false'; ?>,
     65var category = <?php echo (!empty($Category->id))?$Category->id:'false'; ?>,
    6766    product = false,
    6867    details = <?php echo isset($Category->specs) ? json_encode($Category->specs) : json_encode('false'); ?>,
     
    7877    editslug_url = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_edit_slug"); ?>',
    7978    fileverify_url = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "shopp-ajax_verify_file"); ?>',
     79    imgul_url            = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php?action=shopp_upload_image", "wp_ajax_shopp_upload_image"); ?>',
    8080    adminpage = '<?php echo $this->Admin->pagename('categories'); ?>',
    8181    request = <?php echo json_encode(stripslashes_deep($_GET)); ?>,
    8282    worklist = <?php echo json_encode($this->categories(true)); ?>,
    83     filesizeLimit = <?php echo wp_max_upload_size(); ?>,
     83    postsizeLimit        = <?php echo wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ) / MB_IN_BYTES; ?>,
     84    uploadLimit          = <?php echo wp_max_upload_size(); ?>,
     85    uploadMaxConnections = <?php echo ( defined('SHOPP_UPLOAD_MAX_CONNECTIONS') ) ? SHOPP_UPLOAD_MAX_CONNECTIONS : 0; ?>,
    8486    priceTypes = <?php echo json_encode($priceTypes); ?>,
    8587    billPeriods = <?php echo json_encode($billPeriods); ?>,
  • shopp/trunk/core/ui/categories/ui.php

    r1473303 r1859263  
    4343function images_meta_box ($Category) {
    4444?>
    45     <ul id="lightbox">
    46         <?php if (isset($Category->images) && !empty($Category->images)): ?>
    47         <?php foreach ((array)$Category->images as $i => $Image): ?>
    48             <li id="image-<?php echo $Image->id; ?>"><input type="hidden" name="images[]" value="<?php echo $Image->id; ?>" />
    49             <div id="image-<?php echo $Image->id; ?>-details">
    50                 <img src="?siid=<?php echo $Image->id; ?>&amp;<?php echo $Image->resizing(96,0,1); ?>" width="96" height="96" />
    51                 <input type="hidden" name="imagedetails[<?php echo $i; ?>][id]" value="<?php echo $Image->id; ?>" />
    52                 <input type="hidden" name="imagedetails[<?php echo $i; ?>][title]" value="<?php echo $Image->title; ?>" class="imagetitle" />
    53                 <input type="hidden" name="imagedetails[<?php echo $i; ?>][alt]" value="<?php echo $Image->alt; ?>"  class="imagealt" />
    54                 <?php
    55                     if (count($Image->cropped) > 0):
    56                         foreach ($Image->cropped as $cache):
    57                             $cropping = join(',',array($cache->settings['dx'],$cache->settings['dy'],$cache->settings['cropscale']));
    58                             $c = "$cache->width:$cache->height"; ?>
    59                     <input type="hidden" name="imagedetails[<?php echo $i; ?>][cropping][<?php echo $cache->id; ?>]" alt="<?php echo $c; ?>" value="<?php echo $cropping; ?>" class="imagecropped" />
    60                 <?php endforeach; endif;?>
     45    <script id="lightbox-image-template" type="text/x-jquery-tmpl">
     46        <div>
     47        <?php ob_start(); ?>
     48        <li class="dz-preview dz-file-preview">
     49            <div class="dz-details" title="<?php Shopp::_e('Double-click images to edit their details&hellip;'); ?>">
     50                <img data-dz-thumbnail width="120" height="120" class="dz-image" />
    6151            </div>
    62             <?php echo ShoppUI::button('delete', 'deleteImage', array('type' => 'button', 'class' => 'delete deleteButton', 'value' => $Image->id, 'title' => Shopp::__('Remove image&hellip;')) ); ?>
    63             </li>
    64         <?php endforeach; endif; ?>
     52            <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>
     53            <div class="dz-error-mark"><span>&times;</span></div>
     54            <div class="dz-error-message"><span data-dz-errormessage></span></div>
     55            <?php echo ShoppUI::button('delete', 'deleteImage', array('type' => 'button', 'class' => 'delete', 'value' => '${imageid}', 'title' => Shopp::__('Remove image&hellip;'), 'data-dz-remove' => true) ); ?>
     56
     57            <input type="hidden" name="images[]" value="${imageid}" class="imageid"/>
     58            <input type="hidden" name="imagedetails[${index}][id]" value="${imageid}" class="imageid"/>
     59            <input type="hidden" name="imagedetails[${index}][title]" value="${title}" class="imagetitle" />
     60            <input type="hidden" name="imagedetails[${index}][alt]" value="${alt}"  class="imagealt" />
     61        </li>
     62        <?php $preview = ob_get_clean(); echo $preview; ?>
     63        </div>
     64    </script>
     65
     66    <div id="confirm-delete-images" class="notice hidden"><p><?php _e('Save the product to confirm deleted images.','Shopp'); ?></p></div>
     67    <ul class="lightbox-dropzone">
     68    <?php foreach ( (array) $Category->images as $i => $Image ) {
     69            echo ShoppUI::template($preview, array(
     70                '${index}' => $i,
     71                '${imageid}' => $Image->id,
     72                '${title}' => $Image->title,
     73                '${alt}' => $Image->alt,
     74                'data-dz-thumbnail' => sprintf('src="?siid=%d&amp;%s"', $Image->id, $Image->resizing(120, 0, 1)),
     75            ));
     76    } ?>
    6577    </ul>
    6678    <div class="clear"></div>
    67     <input type="hidden" name="category" value="<?php echo $_GET['id']; ?>" id="image-category-id" />
     79
     80    <input type="hidden" name="category" value="<?php echo $Category->id; ?>" id="image-category-id" />
    6881    <input type="hidden" name="deleteImages" id="deleteImages" value="" />
    69     <div id="swf-uploader-button"></div>
    70     <div id="swf-uploader">
    71     <button type="button" class="button-secondary" name="add-image" id="add-image" tabindex="10"><small><?php Shopp::_e('Add New Image'); ?></small></button></div>
    72     <div id="browser-uploader">
    73         <button type="button" name="image_upload" id="image-upload" class="button-secondary"><small><?php Shopp::_e('Add New Image'); ?></small></button><br class="clear"/>
    74     </div>
    7582
    76     <p><?php Shopp::_e('Double-click images to edit their details. Save the product to confirm deleted images.'); ?></p>
     83    <button type="button" name="image_upload" class="button-secondary image-upload"><small><?php Shopp::_e('Add New Image'); ?></small></button>
    7784<?php
    7885}
  • shopp/trunk/core/ui/help/advanced.php

    r821385 r1859263  
    99
    1010This screen provides access to advanced troubleshooting and maintenance tools.
    11 
    12 #### Upload System
    13 
    14 The Adobe Flash upload system shows accurate file upload progress and select multiple files to upload at the same time. If you experience problems, however, disable the setting to use browser-based uploads instead.
    1511
    1612#### Script Loading
  • shopp/trunk/core/ui/products/editor.js

    r1473303 r1859263  
    2121    changes = false,
    2222    saving = false,
    23     flashUploader = false,
    2423    template = false,
    2524    fileUploads = false,
     
    9392
    9493    // Initialize file uploads before the pricelines
    95     fileUploads = new FileUploader('flash-upload-file',$('#ajax-upload-file'));
     94    fileUploads = new FileUploader('#filechooser');
    9695
    9796    // Initalize the base price line
     
    146145
    147146    // We don't need an AYS dialog when saving
    148     $("input[name='save']").click(function() { isSave = true });
     147    $("input[name='save']").click(function() { isSave = true; });
    149148
    150149    // Confirm navigation dialog (avoid people accidentally losing work upon navigation)
     
    153152        if (!isSave && (changesMade || (editor && editor.isDirty() && !editor.isHidden())) )
    154153            return $msg.confirm;
    155     }
     154    };
    156155});
    157156
  • shopp/trunk/core/ui/products/editor.min.js

    r1648469 r1859263  
    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}});
     1function 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");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()});e("#"+t+"-checklist").wpList({alt:"",response:t+"-ajax-response",addBefore:function(i){return!!e("#new-"+t+"-name").val()&&(i.data+="&"+e(":checked","#"+t+"-checklist").serialize(),e("#"+t+"-add-submit").prop("disabled",!0),i)},addAfter: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())}}),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,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("#filechooser"),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("?")[0]+"?"+e.param(request);return e("#product")[0].setAttribute("action",n),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

    r1648469 r1859263  
    5050                    </div>
    5151                </div>
    52                
     52
    5353                <?php do_action( 'edit_form_after_title', $Product ); ?>
    5454
     
    7878/* <![CDATA[ */
    7979jQuery('.hide-if-no-js').removeClass('hide-if-no-js');
    80 var flashuploader       = <?php echo ($uploader == 'flash' && !(false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac') && apache_mod_loaded('mod_security'))) ? 'true' : 'false'; ?>,
    81     product             = <?php echo (!empty($Product->id))?$Product->id:'false'; ?>,
    82     prices              = <?php echo json_encode($Product->prices) ?>,
    83     specs               = <?php $specs = array(); foreach ( $Product->specs as $Spec ) $specs[] = $Spec->json(array('context', 'type', 'numeral', 'sortorder', 'created', 'modified')); echo json_encode($specs); ?>,
    84     options             = <?php echo json_encode($Product->options) ?>,
    85     priceTypes          = <?php echo json_encode($priceTypes) ?>,
    86     billPeriods         = <?php echo json_encode($billPeriods) ?>,
    87     shiprates           = <?php echo json_encode($shiprates); ?>,
    88     uidir               = '<?php echo SHOPP_ADMIN_URI; ?>',
    89     siteurl             = '<?php bloginfo('url'); ?>',
    90     screenid            = '<?php echo get_current_screen()->id; ?>',
    91     canonurl            = '<?php echo trailingslashit(Shopp::url()); ?>',
    92     adminurl            = '<?php echo admin_url(); ?>',
    93     sugg_url            = '<?php echo wp_nonce_url(admin_url('admin-ajax.php'), "wp_ajax_shopp_storage_suggestions"); ?>',
    94     tagsugg_url         = '<?php echo wp_nonce_url(admin_url('admin-ajax.php'), "wp_ajax_shopp_suggestions"); ?>',
    95     spectemp_url        = '<?php echo wp_nonce_url(admin_url('admin-ajax.php'), "wp_ajax_shopp_spec_template"); ?>',
    96     opttemp_url         = '<?php echo wp_nonce_url(admin_url('admin-ajax.php'), "wp_ajax_shopp_options_template"); ?>',
    97     addcategory_url     = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_add_category"); ?>',
    98     editslug_url        = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_edit_slug"); ?>',
    99     fileverify_url      = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_verify_file"); ?>',
    100     fileimport_url      = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_import_file"); ?>',
    101     imageul_url         = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_upload_image"); ?>',
    102     adminpage           = '<?php echo $this->Admin->pagename('products'); ?>',
    103     request             = <?php echo json_encode(stripslashes_deep($_GET)); ?>,
    104     filesizeLimit       = <?php echo wp_max_upload_size(); ?>,
    105     weightUnit          = '<?php echo shopp_setting('weight_unit'); ?>',
    106     dimensionUnit       = '<?php echo shopp_setting('dimension_unit'); ?>',
    107     storage             = '<?php echo shopp_setting('product_storage'); ?>',
    108     productspath        = '<?php /* realpath needed for relative paths */ chdir(WP_CONTENT_DIR); echo addslashes(trailingslashit(sanitize_path(realpath(shopp_setting('products_path'))))); ?>',
    109     imageupload_debug   = <?php echo (defined('SHOPP_IMAGEUPLOAD_DEBUG') && SHOPP_IMAGEUPLOAD_DEBUG)?'true':'false'; ?>,
    110     fileupload_debug    = <?php echo (defined('SHOPP_FILEUPLOAD_DEBUG') && SHOPP_FILEUPLOAD_DEBUG)?'true':'false'; ?>,
    111     dimensionsRequired  = <?php echo $Shopp->Shipping->dimensions?'true':'false'; ?>,
    112     startWeekday        = <?php echo get_option('start_of_week'); ?>,
    113     calendarTitle       = '<?php $df = date_format_order(true); $format = $df["month"]." ".$df["year"]; echo $format; ?>',
     80var product              = <?php echo (!empty($Product->id))?$Product->id:'false'; ?>,
     81    prices               = <?php echo json_encode($Product->prices) ?>,
     82    specs                = <?php $specs = array(); foreach ( $Product->specs as $Spec ) $specs[] = $Spec->json(array('context', 'type', 'numeral', 'sortorder', 'created', 'modified')); echo json_encode($specs); ?>,
     83    options              = <?php echo json_encode($Product->options) ?>,
     84    priceTypes           = <?php echo json_encode($priceTypes) ?>,
     85    billPeriods          = <?php echo json_encode($billPeriods) ?>,
     86    shiprates            = <?php echo json_encode($shiprates); ?>,
     87    uidir                = '<?php echo SHOPP_ADMIN_URI; ?>',
     88    siteurl              = '<?php bloginfo('url'); ?>',
     89    screenid             = '<?php echo get_current_screen()->id; ?>',
     90    canonurl             = '<?php echo trailingslashit(Shopp::url()); ?>',
     91    adminurl             = '<?php echo admin_url(); ?>',
     92    sugg_url             = '<?php echo wp_nonce_url(admin_url('admin-ajax.php'), "wp_ajax_shopp_storage_suggestions"); ?>',
     93    tagsugg_url          = '<?php echo wp_nonce_url(admin_url('admin-ajax.php'), "wp_ajax_shopp_suggestions"); ?>',
     94    spectemp_url         = '<?php echo wp_nonce_url(admin_url('admin-ajax.php'), "wp_ajax_shopp_spec_template"); ?>',
     95    opttemp_url          = '<?php echo wp_nonce_url(admin_url('admin-ajax.php'), "wp_ajax_shopp_options_template"); ?>',
     96    addcategory_url      = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_add_category"); ?>',
     97    editslug_url         = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_edit_slug"); ?>',
     98    fileverify_url       = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_verify_file"); ?>',
     99    fileimport_url       = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php", "wp_ajax_shopp_import_file"); ?>',
     100    fileupload_url       = '<?php echo admin_url()."admin-ajax.php?action=shopp_upload_file"; ?>',
     101    imgul_url            = '<?php echo wp_nonce_url(admin_url()."admin-ajax.php?action=shopp_upload_image", "wp_ajax_shopp_upload_image"); ?>',
     102    adminpage            = '<?php echo $this->Admin->pagename('products'); ?>',
     103    request              = <?php echo json_encode(stripslashes_deep($_GET)); ?>,
     104    postsizeLimit        = <?php echo wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ) / MB_IN_BYTES; ?>,
     105    uploadLimit          = <?php echo wp_max_upload_size(); ?>,
     106    chunkSize            = 524288,
     107    uploadMaxConnections = <?php echo ( defined('SHOPP_UPLOAD_MAX_CONNECTIONS') ) ? SHOPP_UPLOAD_MAX_CONNECTIONS : 5; ?>,
     108    weightUnit           = '<?php echo shopp_setting('weight_unit'); ?>',
     109    dimensionUnit        = '<?php echo shopp_setting('dimension_unit'); ?>',
     110    storage              = '<?php echo shopp_setting('product_storage'); ?>',
     111    productspath         = '<?php /* realpath needed for relative paths */ chdir(WP_CONTENT_DIR); echo addslashes(trailingslashit(sanitize_path(realpath(shopp_setting('products_path'))))); ?>',
     112    imageupload_debug    = <?php echo ( defined('SHOPP_IMAGEUPLOAD_DEBUG') && SHOPP_IMAGEUPLOAD_DEBUG ) ? 'true' : 'false'; ?>,
     113    fileupload_debug     = <?php echo ( defined('SHOPP_FILEUPLOAD_DEBUG') && SHOPP_FILEUPLOAD_DEBUG ) ? 'true' : 'false'; ?>,
     114    dimensionsRequired   = <?php echo $Shopp->Shipping->dimensions?'true':'false'; ?>,
     115    startWeekday         = <?php echo get_option('start_of_week'); ?>,
     116    calendarTitle        = '<?php $df = date_format_order(true); $format = $df["month"]." ".$df["year"]; echo $format; ?>',
    114117
    115118    // Warning/Error Dialogs
  • shopp/trunk/core/ui/products/ui.php

    r1648469 r1859263  
    246246function images_meta_box ($Product) {
    247247?>
    248     <div id="confirm-delete-images" class="notice hidden"><p><?php Shopp::_e('Save the product to confirm deleted images.'); ?></p></div>
    249     <ul id="lightbox">
    250     <?php foreach ( (array) $Product->images as $i => $Image ): ?>
    251         <li id="image-<?php echo (int)$Image->id; ?>"><input type="hidden" name="images[]" value="<?php echo $Image->id; ?>" />
    252             <div id="image-<?php echo (int)$Image->id; ?>-details" title="<?php Shopp::_e('Double-click images to edit their details&hellip;'); ?>">
    253                 <img src="?siid=<?php echo (int)$Image->id; ?>&amp;<?php echo $Image->resizing(96,0,1); ?>" width="96" height="96" />
    254                 <input type="hidden" name="imagedetails[<?php echo (int)$i; ?>][id]" value="<?php echo (int)$Image->id; ?>" />
    255                 <input type="hidden" name="imagedetails[<?php echo (int)$i; ?>][title]" value="<?php echo $Image->title; ?>" class="imagetitle" />
    256                 <input type="hidden" name="imagedetails[<?php echo (int)$i; ?>][alt]" value="<?php echo $Image->alt; ?>"  class="imagealt" />
    257                 <?php
    258                     if ( isset($Product->cropped) && count($Product->cropped) > 0 && isset($Product->cropped[ $Image->id ]) ):
    259 
    260                         $cropped = is_array($Product->cropped[ $Image->id ]) ? $Product->cropped[ $Image->id ] : array($Product->cropped[$Image->id]);
    261 
    262                         foreach ($cropped as $cache):
    263                             $cropimage = unserialize($cache->value);
    264                             $cropdefaults = array('dx' => '','dy' => '','cropscale' => '');
    265                             $cropsettings = array_intersect_key($cropimage->settings, $cropdefaults);
    266                             $cropping = ( array_filter($cropsettings) == array() ) ? '' : join(',', array_merge($cropdefaults, $cropsettings));
    267                             $c = "$cropimage->width:$cropimage->height";
    268                 ?>
    269                     <input type="hidden" name="imagedetails[<?php echo $i; ?>][cropping][<?php echo $cache->id; ?>]" alt="<?php echo $c; ?>" value="<?php echo $cropping; ?>" class="imagecropped" />
    270                 <?php endforeach; endif; ?>
     248    <script id="lightbox-image-template" type="text/x-jquery-tmpl">
     249        <div>
     250        <?php ob_start(); ?>
     251        <li class="dz-preview dz-file-preview">
     252            <div class="dz-details" title="<?php Shopp::_e('Double-click images to edit their details&hellip;'); ?>">
     253                <img data-dz-thumbnail width="120" height="120" class="dz-image" />
    271254            </div>
    272             <?php echo ShoppUI::button('delete', 'deleteImage', array('type' => 'button', 'class' => 'delete', 'value' => $Image->id, 'title' => Shopp::__('Remove image&hellip;')) ); ?>
    273             </li>
    274     <?php endforeach; ?>
     255            <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>
     256            <div class="dz-error-mark"><span>&times;</span></div>
     257            <div class="dz-error-message"><span data-dz-errormessage></span></div>
     258            <?php echo ShoppUI::button('delete', 'deleteImage', array('type' => 'button', 'class' => 'delete', 'value' => '${imageid}', 'title' => Shopp::__('Remove image&hellip;'), 'data-dz-remove' => true) ); ?>
     259
     260            <input type="hidden" name="images[]" value="${imageid}" class="imageid"/>
     261            <input type="hidden" name="imagedetails[${index}][id]" value="${imageid}" class="imageid"/>
     262            <input type="hidden" name="imagedetails[${index}][title]" value="${title}" class="imagetitle" />
     263            <input type="hidden" name="imagedetails[${index}][alt]" value="${alt}"  class="imagealt" />
     264        </li>
     265        <?php $preview = ob_get_clean(); echo $preview; ?>
     266        </div>
     267    </script>
     268
     269    <div id="confirm-delete-images" class="notice hidden"><p><?php _e('Save the product to confirm deleted images.','Shopp'); ?></p></div>
     270    <ul class="lightbox-dropzone">
     271    <?php foreach ( (array) $Product->images as $i => $Image ) {
     272            echo ShoppUI::template($preview, array(
     273                '${index}' => $i,
     274                '${imageid}' => $Image->id,
     275                '${title}' => $Image->title,
     276                '${alt}' => $Image->alt,
     277                'data-dz-thumbnail' => sprintf('src="?siid=%d&amp;%s"', $Image->id, $Image->resizing(120, 0, 1)),
     278            ));
     279    } ?>
    275280    </ul>
    276281    <div class="clear"></div>
    277     <input type="hidden" name="product" value="<?php echo preg_replace('/[^0-9]/', '', $_GET['id']); ?>" id="image-product-id" />
     282
     283    <input type="hidden" name="product" value="<?php echo $_GET['id']; ?>" id="image-product-id" />
    278284    <input type="hidden" name="deleteImages" id="deleteImages" value="" />
    279     <div id="swf-uploader-button"></div>
    280     <div id="browser-uploader">
    281         <button type="button" name="image_upload" id="image-upload" class="button-secondary"><small><?php Shopp::_e('Add New Image'); ?></small></button><br class="clear"/>
    282     </div>
     285
     286    <button type="button" name="image_upload" class="button-secondary image-upload"><small><?php Shopp::_e('Add New Image'); ?></small></button>
    283287<?php
    284288}
     
    356360    <input type="hidden" name="prices" value="" id="prices" /></div>
    357361
    358 <div id="chooser">
     362<div id="filechooser">
    359363    <p><label for="import-url"><?php Shopp::_e('Attach file by URL'); ?>&hellip;</label></p>
    360     <p><span class="fileimporter"><input type="text" name="url" id="import-url" class="fileimport" /><span class="shoppui-spin-align"><span class="status"></span></span></span><button class="button-secondary" id="attach-file"><small><?php Shopp::_e('Attach File'); ?></small></button><br /><span><label for="import-url">file:///path/to/file.zip<?php if ( ! in_array('http', stream_get_wrappers()) ): ?>, http://server.com/file.zip<?php endif; ?></label></span></p>
    361     <label class="alignleft"><?php Shopp::_e('Select a file from your computer'); ?>:</label>
    362     <div class=""><div id="flash-upload-file"></div><button id="ajax-upload-file" class="button-secondary"><small><?php Shopp::_e('Upload File'); ?></small></button></div>
    363 </div>
     364    <p><span class="fileimporter"><input type="text" name="url" id="import-url" class="fileimport" /><span class="shoppui-spin-align"><span class="status"></span></span></span><button class="button-secondary" id="attach-file"><small><?php Shopp::_e('Attach File'); ?></small></button><br /><span><label for="import-url">file:///path/to/file.zip<?php if (!in_array('http',stream_get_wrappers())): ?>, http://server.com/file.zip<?php endif; ?></label></span></p>
     365    <div><button id="filechooser-upload-file" class="button-secondary filechooser-upload"><small><?php Shopp::_e('Upload a file from your device'); ?></small></button></div>
     366</div>
     367
     368<script id="filechooser-upload-template" type="text/x-jquery-tmpl">
     369<div>
     370    <div class="file dz-preview dz-file-preview">
     371        <div class="icon shoppui-file"></div>
     372        <span class="name dz-filename" data-dz-name></span>
     373        <small class="size dz-size" data-dz-size></small>
     374        <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>
     375        <div class="dz-error-message"><span data-dz-errormessage></span></div>
     376    </div>
     377</div>
     378</script>
    364379
    365380<?php
  • shopp/trunk/core/ui/settings/advanced.php

    r1473303 r1859263  
    1515
    1616            <tr>
    17                 <th scope="row" valign="top"><label for="uploader-toggle"><?php Shopp::_e('Upload System'); ?></label></th>
    18                 <td><input type="hidden" name="settings[uploader_pref]" value="browser" /><input type="checkbox" name="settings[uploader_pref]" value="flash" id="uploader-toggle"<?php if (shopp_setting('uploader_pref') == "flash") echo ' checked="checked"'?> /><label for="uploader-toggle"> <?php Shopp::_e('Enable Flash-based uploading'); ?></label><br />
    19                 <?php Shopp::_e('Enable to use Adobe Flash uploads for accurate upload progress. Disable this setting if you are having problems uploading.'); ?></td>
    20             </tr>
    21             <tr>
    2217                <th scope="row" valign="top"><label for="script-server"><?php Shopp::_e('Script Loading'); ?></label></th>
    2318                <td><input type="hidden" name="settings[script_server]" value="script" /><input type="checkbox" name="settings[script_server]" value="plugin" id="script-server"<?php if (shopp_setting('script_server') == "plugin") echo ' checked="checked"'?> /><label for="script-server"> <?php Shopp::_e('Load behavioral scripts through WordPress'); ?></label><br />
     
    3227                <td><input type="hidden" name="settings[image_server]" value="off" /><input type="checkbox" name="settings[image_server]" value="on" id="image-server"<?php if ( "on" == shopp_setting('image_server') ) echo ' checked="checked"'; ?> /><label for="image-server"> <?php Shopp::_e('Toggle this option if images don\'t show on storefront.<br /> <small>(Needs resaving of permalinks.)<small>'); ?></label>
    3328                </td>
    34             </tr>           
     29            </tr>
    3530
    3631            <tr>
  • shopp/trunk/core/ui/styles/admin.css

    r1648469 r1859263  
    8585/** Editors Global **/
    8686.postbox h3 span a.shoppui-question,
     87.postbox .hndle a.shoppui-question,
    8788.postbox label a.shoppui-question,
    8889.subpanel label a.shoppui-question { color: #767676; margin-bottom:-3px;margin-top:-2px;margin-left:5px;top:5px;display:inline-block;width:12px;height:13px;border:none;text-decoration:none; cursor:pointer; text-shadow: 0 1px 1px #fff; }
    8990.postbox h3 span a.shoppui-question:hover,
     91.postbox .hndle a.shoppui-question:hover,
    9092.postbox label a.shoppui-question:hover,
    9193.subpanel label a.shoppui-question:hover { color: #464646; }
     
    107109#schedule-toggling,#schedule-calendar { text-indent: 0; }
    108110#scheduling input { text-align: center; }
     111
     112/** Dropzone **/
     113@-webkit-keyframes passing-through { 0% { opacity:0;-webkit-transform:translateY(40px);-ms-transform:translateY(40px);transform:translateY(40px); }
     11430%,70% { opacity:1;-webkit-transform:translateY(0px);-ms-transform:translateY(0px);transform:translateY(0px); }
     115100% { opacity:0;-webkit-transform:translateY(-40px);-ms-transform:translateY(-40px);transform:translateY(-40px); }
     116 }
     117@keyframes passing-through { 0% { opacity:0;-webkit-transform:translateY(40px);-ms-transform:translateY(40px);transform:translateY(40px); }
     11830%,70% { opacity:1;-webkit-transform:translateY(0px);-ms-transform:translateY(0px);transform:translateY(0px); }
     119100% { opacity:0;-webkit-transform:translateY(-40px);-ms-transform:translateY(-40px);transform:translateY(-40px); }
     120 }
     121@-webkit-keyframes slide-in { 0% { opacity:0;-webkit-transform:translateY(40px);-ms-transform:translateY(40px);transform:translateY(40px); }
     12230% { opacity:1;-webkit-transform:translateY(0px);-ms-transform:translateY(0px);transform:translateY(0px); }
     123 }
     124@keyframes slide-in { 0% { opacity:0;-webkit-transform:translateY(40px);-ms-transform:translateY(40px);transform:translateY(40px); }
     12530% { opacity:1;-webkit-transform:translateY(0px);-ms-transform:translateY(0px);transform:translateY(0px); }
     126 }
     127@-webkit-keyframes pulse { 0% { -webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1); }
     12810% { -webkit-transform:scale(1.1);-ms-transform:scale(1.1);transform:scale(1.1); }
     12920% { -webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1); }
     130 }
     131@keyframes pulse { 0% { -webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1); }
     13210% { -webkit-transform:scale(1.1);-ms-transform:scale(1.1);transform:scale(1.1); }
     13320% { -webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1); }
     134 }
     135.lightbox-dropzone { box-sizing:border-box;min-height:150px;list-style-type:none;margin:0;margin-left:-5px;padding:5px;border:1px solid transparent;margin-bottom:20px; }
     136.lightbox-dropzone.dz-drag-hover { border:1px dashed #dfdfdf; }
     137.lightbox-dropzone .dz-preview { position:relative;display:inline-block;vertical-align:top;background:#ffffff;margin:0 10px 10px 0;padding:5px;width:120px;height:120px;border:1px solid #dfdfdf;z-index:1; }
     138.lightbox-dropzone .dz-error .dz-image { filter:contrast(50%) saturate(0%) brightness(150%);-webkit-transition:filter 0.2s ease-out; }
     139.lightbox-dropzone .dz-preview:hover { z-index:1000; }
     140.lightbox-dropzone .dz-preview:hover .dz-details { opacity:1; }
     141.lightbox-dropzone .dz-preview.dz-file-preview .dz-details { opacity:1; }
     142.lightbox-dropzone .dz-preview.dz-image-preview .dz-details { -webkit-transition:opacity 0.2s linear;transition:opacity 0.2s linear; }
     143.lightbox-dropzone .dz-preview .dz-remove { font-size:14px;text-align:center;display:block;cursor:pointer;border:none; }
     144.lightbox-dropzone .dz-preview .delete { margin:0;width:16px;height:16px;position:absolute;top:-4px;right:-5px;z-index:10;visibility:hidden; }
     145.lightbox-dropzone .dz-preview:not(.dz-error):hover .delete { visibility:visible; }
     146.lightbox-dropzone .dz-preview .dz-remove:hover { text-decoration:underline; }
     147.lightbox-dropzone .dz-preview .dz-details .dz-size { margin-bottom:1em;font-size:16px; }
     148.lightbox-dropzone .dz-preview .dz-details .dz-filename { white-space:nowrap; }
     149.lightbox-dropzone .dz-preview .dz-image img { display:block; }
     150.lightbox-dropzone .dz-preview:hover .dz-image img { -webkit-transform:scale(1.05,1.05);-ms-transform:scale(1.05,1.05);transform:scale(1.05,1.05);-webkit-filter:blur(8px);filter:blur(8px); }
     151.lightbox-dropzone .dz-preview .dz-image { pointer-events:none;overflow:hidden;width:120px;height:120px;position:relative;display:block;z-index:10; }
     152.lightbox-dropzone .dz-preview.dz-success .dz-success-mark { -webkit-animation:passing-through 3s cubic-bezier(0.77,0,0.175,1);animation:passing-through 3s cubic-bezier(0.77,0,0.175,1); }
     153.lightbox-dropzone .dz-preview.dz-error .dz-error-mark { opacity:1;-webkit-animation:slide-in 3s cubic-bezier(0.77,0,0.175,1);animation:slide-in 3s cubic-bezier(0.77,0,0.175,1); }
     154.lightbox-dropzone .dz-preview .dz-success-mark,
     155.lightbox-dropzone .dz-preview .dz-error-mark { pointer-events:none;opacity:0;z-index:500;position:absolute;display:block;top:calc(50% - 30px);left:calc(50% - 15px);color:#ffffff;text-shadow:-2px 0 #be2626,0 2px #be2626,2px 0 #be2626,0 -2px #be2626;font-size:60px;line-height:60px; }
     156.lightbox-dropzone .dz-preview.dz-processing .dz-progress { opacity:1;-webkit-transition:all 0.2s linear;transition:all 0.2s linear; }
     157.lightbox-dropzone .dz-preview.dz-complete .dz-progress { opacity:0;-webkit-transition:opacity 0.4s ease-in;transition:opacity 0.4s ease-in; }
     158.lightbox-dropzone .dz-preview:not(.dz-processing) .dz-progress { -webkit-animation:pulse 6s ease infinite;animation:pulse 6s ease infinite; }
     159.lightbox-dropzone .dz-preview .dz-progress { opacity:0;z-index:1000;pointer-events:none;position:absolute;height:10px;left:50%;top:50%;margin-top:-8px;width:80px;margin-left:-40px;background:rgba(255,255,255,0.7);border:2px solid rgba(255,255,255,0.7);-webkit-transform:scale(1);border-radius:8px;overflow:hidden; }
     160.lightbox-dropzone .dz-preview .dz-progress .dz-upload { background:#333;background:linear-gradient(to bottom,#666666,#444444);position:absolute;top:0;left:0;bottom:0;width:0;-webkit-transition:width 300ms ease-in-out;transition:width 300ms ease-in-out; }
     161.lightbox-dropzone .dz-preview.dz-error:hover .dz-error-message { cursor:pointer;opacity:1;pointer-events:auto; }
     162.lightbox-dropzone .dz-preview .dz-error-message { font-size:12px;letter-spacing:-0.03em;display:block;width:130px;height:130px;box-sizing:border-box;padding:10px;z-index:1000;position:absolute;top:0;left:0;opacity:0;background:linear-gradient(to bottom,#ffffff,#e8e8e8);-webkit-transition:opacity 0.3s ease;transition:opacity 0.3s ease;pointer-events:none; }
     163.lightbox-dropzone .ui-sortable-handle { cursor:move; }
    109164
    110165/** Image details modal **/
     
    288343.form-table.pricing { border-bottom:1px solid #dfdfdf; }
    289344
    290 #chooser { font-size:11px;position:absolute;left:-9999em;width:360px; }
    291 #chooser p { font-size:11px;margin:6px 0 8px;line-height:1; }
    292 #cboxContent #chooser { left:auto; }
    293 #cboxContent #chooser label { margin:0;padding:6px 0;text-align:left;width:auto; }
    294 
    295 div.progress { position:relative;width:76px;height:10px;background:#ffffff;border:1px solid #dddddd; }
    296 div.progress div.bar { position:absolute;height:10px;background:#85ec3d;border:none; }
    297 div.progress div.gloss { position:absolute;width:100%;height:10px;background:url('../icons/gloss.png') repeat-x; }
    298 
     345/** Priceline file chooser **/
     346#filechooser { font-size:11px;position:absolute;left:-9999em;width:360px; }
     347#filechooser p { font-size:11px;margin:6px 0 8px;line-height:1; }
     348#cboxContent #filechooser { left:auto; }
     349#cboxContent #filechooser label { margin:0;padding:6px 0;text-align:left;width:auto; }
     350.filechooser-upload { width:100%; }
     351.pricing-table .dz-filename { display:block; }
     352.pricing-table .dz-size { display:inline-block; }
     353.pricing-table .dz-error { color:#999; }
     354.pricing-table .dz-error-message { color:#900;font-weight:bold; }
     355.pricing-table .dz-preview.dz-processing .dz-progress { opacity:1;-webkit-transition:all 0.2s linear;transition:all 0.2s linear; }
     356.pricing-table .dz-preview.dz-complete .dz-progress { opacity:0;-webkit-transition:opacity 0.4s ease-in;transition:opacity 0.4s ease-in; }
     357.pricing-table .dz-preview:not(.dz-processing) .dz-progress { -webkit-animation:pulse 6s ease infinite;animation:pulse 6s ease infinite; }
     358.pricing-table .dz-preview.dz-error .dz-progress { opacity:0;-webkit-transition:opacity 0.4s ease-out;transition:opacity 0.4s ease-out; }
     359.pricing-table .dz-preview .dz-progress { display:inline-block;opacity:0;z-index:1000;pointer-events:none;position:relative;height:8px;top:2px;width:80px;background:rgba(255,255,255,0.7);border:2px solid rgba(255,255,255,0.7);-webkit-transform:scale(1);border-radius:8px;overflow:hidden; }
     360.pricing-table .dz-preview .dz-progress .dz-upload { background:#333;background:linear-gradient(to bottom,#666666,#444444);position:absolute;top:0;left:0;bottom:0;width:0;-webkit-transition:width 300ms ease-in-out;transition:width 300ms ease-in-out; }
     361
     362/** Slug Editor **/
    299363#editable-slug-full,#editor-slug-buttons { display:none; }
    300364#editable-slug { background-color:#fffbcc;float:none;padding:0; }
  • shopp/trunk/readme.md

    r1648469 r1859263  
    1010
    1111## 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)
     12- [Latest release (1.3.13)](https://github.com/ingenesis/shopp/releases/tag/1.3.13)
     13- [Current dev (1.3.14dev)](https://github.com/ingenesis/shopp/archive/1.3.14dev.zip)
    1414- [Future dev (1.4.dev)](https://github.com/ingenesis/shopp/archive/master.zip)
    1515
Note: See TracChangeset for help on using the changeset viewer.