Plugin Directory

Changeset 1608393

Timestamp:
03/06/2017 05:30:30 AM (7 years ago)
Author:
goldsounds
Message:

Small bugfixes

Location:
gltf-media-type/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • gltf-media-type/trunk/README.txt

    r1608389 r1608393  
    11=== Plugin Name ===
    22Contributors: goldsounds
    3 Tags: comments, spam
     3Tags:
    44Requires at least: 4.7
    55Tested up to: 4.7
  • gltf-media-type/trunk/admin/js/gltf-admin-select-model-metabox.js

    r1563556 r1608393  
    99      delModelLink = metaBox.find( '.delete-main-model'),
    1010      modelContainer = metaBox.find( '.gltf-main-model-container'),
    11       modelIdInput = metaBox.find( '.main-model-id' );
     11      modelIdInput = metaBox.find( '.main-model-id' ),
     12        modelScaleInput = metaBox.find( '.main-model-scale' );
    1213 
    1314  // ADD IMAGE LINK
    1415  addModelLink.on( 'click', function( event ){
    15    
    16     event.preventDefault();
    17    
    18     // If the media frame already exists, reopen it.
    19     if ( frame ) {
    20       frame.open();
    21       return;
    22     }
    23    
    24     // Create a new media frame
    25     frame = wp.media({
    26       title: 'Select a GLTF model file',
    27       button: {
    28         text: 'Use this model'
    29       },
    30       multiple: false,  // Set to true to allow multiple files to be selected
    31       library : { type: 'model/gltf+json' }
    32     });
    3316
    34    
    35     // When an image is selected in the media frame...
    36     frame.on( 'select', function() {
    37         // Get media attachment details from the frame state
    38         var attachment = frame.state().get('selection').first().toJSON();
     17        event.preventDefault();
    3918
    40         // Send the attachment URL to our custom image input field.
    41         modelContainer.append( '<div class="gltf-model" data-model="'+attachment.url+'" data-scale="1.0" style="width: 300px; height: 300px;"></div>' );
     19        // If the media frame already exists, reopen it.
     20        if ( frame ) {
     21            frame.open();
     22            return;
     23        }
    4224
    43         // Send the attachment id to our hidden input
    44         modelIdInput.val( attachment.id );
     25        // Create a new media frame
     26        frame = wp.media({
     27            title: 'Select a GLTF model file',
     28            button: {
     29            text: 'Use this model'
     30            },
     31            multiple: false,  // Set to true to allow multiple files to be selected
     32            library : { type: 'model/gltf+json' }
     33        });
    4534
    46         // Hide the add image link
    47         addModelLink.addClass( 'hidden' );
     35        // When an image is selected in the media frame...
     36        frame.on( 'select', function() {
     37            // Get media attachment details from the frame state
     38            var attachment = frame.state().get('selection').first().toJSON();
    4839
    49         // Unhide the remove image link
    50         delModelLink.removeClass( 'hidden' );
     40            var scale = modelScaleInput.val();
    5141
    52         jQuery( '.gltf-model' ).each( initializeGltfElement );
    53     });
     42            if ( '' == scale ) {
     43                scale = '1.0';
     44            }
    5445
    55     // Finally, open the modal on click
    56     frame.open();
     46            // Send the attachment URL to our custom image input field.
     47            modelContainer.append( '<div class="gltf-model" data-model="'+attachment.url+'" data-scale="'+scale+'" style="width: 300px; height: 300px;"></div>' );
     48
     49            // Send the attachment id to our hidden input
     50            modelIdInput.val( attachment.id );
     51
     52            // Hide the add image link
     53            addModelLink.addClass( 'hidden' );
     54
     55            // Unhide the remove image link
     56            delModelLink.removeClass( 'hidden' );
     57
     58            jQuery( '.gltf-model' ).each( initializeGltfElement );
     59        });
     60
     61        // Finally, open the modal on click
     62        frame.open();
    5763  });
    5864 
     
    6066  // DELETE IMAGE LINK
    6167  delModelLink.on( 'click', function( event ){
     68
    6269
    63     event.preventDefault();
     70        // Clear out the preview image
     71        modelContainer.html( '' );
    6472
    65     // Clear out the preview image
    66     modelContainer.html( '' );
     73   
     74    ' );
    6775
    68     // Un-hide the add image link
    69     addModelLink.removeClass( 'hidden' );
     76    image link
     77    Class( 'hidden' );
    7078
    71     // Hide the delete image link
    72     delModelLink.addClass( 'hidden' );
    73 
    74     // Delete the image id from the hidden input
    75     modelIdInput.val( '' );
    76 
     79        // Delete the image id from the hidden input
     80        modelIdInput.val( '' );
    7781  });
    7882
  • gltf-media-type/trunk/includes/class-gltf.php

    r1608389 r1608393  
    208208        wp_nonce_field( basename( __FILE__ ), 'gltf_nonce' );
    209209
    210         // global $post;
    211210        // Get WordPress' media upload URL
    212211        $upload_link = esc_url( get_upload_iframe_src( 'image', $post->ID ) );
     
    215214        $main_model_id = get_post_meta( $post->ID, '_gltf_main_model', true );
    216215        $main_model_scale = get_post_meta( $post->ID, '_gltf_main_model_scale', true );
     216
    217217
    218218        // Get the image src
     
    223223        ?>
    224224
    225         <!-- Your image container, which can be manipulated with js -->
     225        <!-- -->
    226226        <div class="gltf-main-model-container">
    227227            <?php if ( $main_model_is_set ) : ?>
    228                 <div class="gltf-model" data-model="<?php echo $main_model_url ?>" data-scale="1.0" style="width: 300px; height: 300px;"></div>
     228                <div class="gltf-model" data-model="<?php echo $main_model_url" style="width: 300px; height: 300px;"></div>
    229229            <?php endif; ?>
    230230        </div>
    231231
    232         <!-- Your add & remove image links -->
     232        <!-- e links -->
    233233        <p class="hide-if-no-js">
    234234            <a class="upload-main-model <?php if ( $main_model_is_set  ) { echo 'hidden'; } ?>"
     
    242242        </p>
    243243
    244         <!-- A hidden input to set and post the chosen image id -->
     244        <!-- A hidden input to set and post the chosen id -->
    245245        <input class="main-model-id" name="main-model-id" type="hidden" value="<?php echo esc_attr( $main_model_id ); ?>" />
    246246
     
    248248            <label for="main-model-scale">
    249249                <?php _e( 'Model Scale', 'gltf-media-type '); ?>
    250                 <input class="main-model-scale" name="main-model-scale" value="<?php echo esc_attr( $main_model_scale ? $main_model_scale : 1.0 ); ?>" />
     250                <input class="main-model-scale" name="main-model-scale" value="<?php echo esc_attr( $main_model_scale ); ?>" />
    251251            </label>
    252252        </p>
    253253        <?php
    254         /*
    255        
    256         $gltf_stored_meta = get_post_meta( $post->ID );
    257         ?>
    258         <p>
    259             <span class="gltf-row-title"><?php _e( 'Example Radio Buttons', 'gltf-media-type' )?></span>
    260             <div class="gltf-row-content">
    261                 <label for="meta-radio-one">
    262                     <input type="radio" name="meta-radio" id="meta-radio-one" value="radio-one" <?php if ( isset ( $gltf_stored_meta['meta-radio'] ) ) checked( $gltf_stored_meta['meta-radio'][0], 'radio-one' ); ?>>
    263                     <?php _e( 'Radio Option #1', 'gltf-media-type' )?>
    264                 </label>
    265                 <label for="meta-radio-two">
    266                     <input type="radio" name="meta-radio" id="meta-radio-two" value="radio-two" <?php if ( isset ( $gltf_stored_meta['meta-radio'] ) ) checked( $gltf_stored_meta['meta-radio'][0], 'radio-two' ); ?>>
    267                     <?php _e( 'Radio Option #2', 'gltf-media-type' )?>
    268                 </label>
    269             </div>
    270         </p><?php
    271         */
    272254    }
    273255
     
    281263            return;
    282264        }
    283      
    284         // Checks for input and sanitizes/saves if needed
    285         // if( isset( $_POST[ 'meta-text' ] ) ) {
    286         //  update_post_meta( $post_id, 'meta-text', sanitize_text_field( $_POST[ 'meta-text' ] ) );
    287         // }
     265
    288266        if( isset( $_POST[ 'main-model-id' ] ) ) {
    289267            update_post_meta( $post_id, '_gltf_main_model', $_POST[ 'main-model-id' ] );
  • gltf-media-type/trunk/js/public.js

    r1608389 r1608393  
    4892548925
    4892648926    // necessary for the enter VR button to appear in the right position
    48927     $el.css({'position':'relative'});;
     48927    $el.css(;
    4892848928
    4892948929    scene = new __WEBPACK_IMPORTED_MODULE_0_three__["g" /* Scene */]();
  • gltf-media-type/trunk/jssrc/public.js

    r1608389 r1608393  
    137137
    138138    // necessary for the enter VR button to appear in the right position
    139     $el.css({'position':'relative'});;
     139    $el.css(;
    140140
    141141    scene = new THREE.Scene();
Note: See TracChangeset for help on using the changeset viewer.