Plugin Directory

Changeset 1824958


Ignore:
Timestamp:
02/20/2018 03:26:13 AM (8 years ago)
Author:
adeel.athar
Message:

shows the "add filter" button when editing in the Galleries view
made id attributes unique in the Galleries view (and eliminated ids when unnecessary)

Location:
image-snippet/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • image-snippet/trunk

    • Property svn:ignore set to
      nbproject
  • image-snippet/trunk/assets/js/isnippet.js

    r1330652 r1824958  
    2323
    2424    // create new gallery
    25     $(document).on("submit", "#snippet-settings, #update-snippet-settings", function (e) {
     25    $(document).on("submit", "#snippet-settings, .update-snippet-settings", function (e) {
    2626
    2727        e.preventDefault();
    28 
    29         var directory = $("#directory").val(),
    30             username = $("#username").val(),
    31             property = $("#property").val(),
    32             object = $("#object").val(),
     28        var formId = $(this).attr("id");
     29        var directory = $("#" + formId + "-directory").val(),
     30            username = $("#" + formId + "-username").val(),
     31            property = $("#" + formId + "-property1").val(),
     32            object = $("#" + formId + "-object1").val(),
    3333            button_id = $(this).attr("id");
    3434
  • image-snippet/trunk/image-snippet.php

    r1824902 r1824958  
    187187    }
    188188    wp_enqueue_script('timepicker-js', IS_URL.'/assets/js/jquery.timepicker.min.js', array('jquery'), '1.0', true);
    189     wp_enqueue_script('functions-js', IS_URL.'/assets/js/isnippet.js', array('jquery'), '1.0', true);
     189    wp_enqueue_script('functions-js', IS_URL.'/assets/js/isnippet.js', array('jquery'), '', true);
    190190    wp_localize_script( 'functions-js', 'snippetrequest', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    191191}
     
    243243        $objValue = $postdata['object'.$matches[1]];
    244244        error_log("object value: ".$objValue);
    245         $propertyArray = ['property' => $value, 'object' => $objValue];
    246         array_push($properties, $propertyArray);
    247         $sPropertyArray = ['property' => fix_url_for_sparql($value), 'object' => fix_url_for_sparql($objValue)];
    248         array_push($sparql_props, $sPropertyArray);
     245                if (!empty($value) && !empty($objValue)) {
     246                    $propertyArray = ['property' => $value, 'object' => $objValue];
     247                    array_push($properties, $propertyArray);
     248                    $sPropertyArray = ['property' => fix_url_for_sparql($value), 'object' => fix_url_for_sparql($objValue)];
     249                    array_push($sparql_props, $sPropertyArray);
     250                }
    249251      }
    250252      else {
     
    758760                                    <tr>
    759761                                        <td colspan="7">
    760                                             <div id="toggle-form-container-<?php echo $row->is_id; ?>" class="toggle-form-container" style="display:<?php echo $display ;?>">
    761                                                 <form method="POST" id="update-snippet-settings">
     762                                            <div id="toggle-form-container-<?php echo $row->is_id; ?>" class="toggle-form-container" style="display:<?php echo $display ;?>">                   
     763                                                <form method="POST" class="update-snippet-settings" id="<?php $formId = "form-".$row->is_id; echo $formId; ?>">
    762764                                                    <div class="meta-box-sortables">
    763765                                                        <div class="postbox">
     
    765767                                                                <p>
    766768                                                                    <label for="anps_subtitle">Gallery Name :</label>
    767                                                                     <input type="text" name="directory" id="directory" value="<?php echo $row->is_directory; ?>" style="width: 100%">
     769                                                                    <input type="text" name="directory" id="<?php echo $formId; ?>-directory" value="<?php echo $row->is_directory; ?>" style="width: 100%">
    768770                                                                </p>
    769771                                                            </div>
     
    772774                                                                <p>
    773775                                                                    <label for="anps_subtitle">ImageSnippets Username:</label>
    774                                                                     <input type="text" name="username" id="username" value="<?php echo $row->is_username; ?>" style="width: 100%">
     776                                                                    <input type="text" name="username" id="<?php echo $formId; ?>-username" value="<?php echo $row->is_username; ?>" style="width: 100%">
    775777                                                                </p>
    776778                                                            </div>
    777                                             <?php $filterCount = ''; foreach ($properties as $property): ?>
    778                             <fieldset class="galleryProperty">
    779                             <legend>Filter <?php echo $filterCount; ?></legend>
    780                                                             <div class="inside">
    781                                                                 <p>
    782                                                                     <label for="anps_subtitle">Property (URI or CURI):</label>
    783                                                                     <input type="text" name="property<?php echo $filterCount; ?>" id="property<?php echo $filterCount; ?>" autocomplete="whatever" list="propertyList" value="<?php echo $property['property']; ?>" style="width: 100%">
     779                                                            <div class="galleryProperties">
    784780                <datalist id="propertyList">
    785781                  <option label="depicts" value="lio:depicts">
     
    798794                  <option label="technique" value="lio:technique">
    799795                </datalist>
     796                                            <?php $filterCount = 1; foreach ($properties as $property): ?>
     797                                                <div class="inside">
     798                            <fieldset class="galleryProperty">
     799                            <legend>Filter <?php echo $filterCount; ?></legend>
     800                                                            <div class="inside">
     801                                                                <p>
     802                                                                    <label for="anps_subtitle">Property (URI or CURI):</label>
     803                                                                    <input type="text" name="property<?php echo $filterCount; ?>" id="<?php echo $formId."-property".$filterCount; ?>" autocomplete="whatever" list="propertyList" value="<?php echo $property['property']; ?>" style="width: 100%">
    800804
    801805                                                                </p>
     
    805809                                                                <p>
    806810                                                                    <label>Object (URI or CURI):</label>
    807                                                                     <input type="text" name="object<?php echo $filterCount; ?>" id="object<?php echo $filterCount; ?>" value="<?php echo preg_replace($patterns, $replacements, $property['object']); ?>" style="width: 100%">
     811                                                                    <input type="text" name="object<?php echo $filterCount; ?>" id="<?php echo $formId."-object".$filterCount; ?>" value="<?php echo preg_replace($patterns, $replacements, $property['object']); ?>" style="width: 100%">
    808812                                                                </p>
    809813                                                            </div>
    810814                            </fieldset>
    811                         <?php if ($filterCount == '') $filterCount = 1; else $filterCount++; endforeach; ?>
     815                                                        </div>
     816                        <?php $filterCount++; endforeach; ?>
     817                                                            </div>
     818                                                            <div class="inside" style="text-align:right">
     819                                                                    <button type="button" class="button button-primary button-large btn-disabled addPropertyBtn">Add Filter</button>
     820                                                            </div>
     821
    812822                                                            <div class="inside">
    813823                                                                <p>
     
    826836                                                            <div class="inside" style="text-align:right">
    827837                                                                <p>
    828                                                                     <input type="submit" value="Update" class="button button-primary button-large btn-disabled" id="update">
     838                                                                    <input type="submit" value="Update" class="button button-primary button-large btn-disabled updateSettingsBtn">
    829839                                                                    <input type="hidden" name="graph_action" value="Update">
    830840                                                                    <input type="hidden" name="cronservice" value="off">
     
    851861
    852862        </div>
     863<script type="text/javascript" defer="defer">
     864jQuery(document).ready(function($){
     865  var propUniqueIdx = <?php $filterCount++; echo $filterCount; ?>;
     866  $(".addPropertyBtn").click(function() {
     867    console.log("click!");
     868    var html = '<div class="inside"><fieldset class="galleryProperty"><legend>Filter ' + propUniqueIdx + '</legend><div class="inside"><p><label>Property (URI or CURI):</label><input type="text" name="property' + propUniqueIdx + '" style="width: 100%" autocomplete="whatever" list="propertyList"></p></div>';
     869    html += '<div class="inside"><p><label>Object (URI or CURI):</label><input type="text" name="object' + propUniqueIdx + '" style="width: 100%"></p></div></fieldset></div>';
     870    propUniqueIdx++;
     871
     872    var siblings = $(this).parent().siblings(".galleryProperties");
     873    $(html).appendTo(siblings.eq(0));
     874  });
     875});
     876</script>
     877       
    853878        <?php }
    854879
Note: See TracChangeset for help on using the changeset viewer.