Changeset 26741


Ignore:
Timestamp:
Jan 15, 2014, 10:12:10 AM (10 years ago)
Author:
mistic100
Message:

partially revert r26725, not suitable solution

Location:
extensions/SmartAlbums/admin/template
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmartAlbums/admin/template/album.tpl

    r26725 r26741  
    1212{combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/minified/jquery.ui.slider.min.js'}
    1313
    14 {combine_script id='smartalbums.filters' load='footer' template=true path=$SMART_PATH|cat:'admin/template/addFilters.js'}
     14
     15{footer_script require='jquery'}
     16var addFilter = (function($){
     17  var count=0,
     18      limit_count=0,
     19      level_count=0;
     20
     21  // MAIN EVENT HANDLERS
     22  $('#addFilter').change(function() {
     23    if ($(this).val() != -1) {
     24      add_filter($(this).val());
     25      $(this).val(-1);
     26    }
     27  });
     28
     29  $('#removeFilters').click(function() {
     30    $('#filtersList li').each(function() {
     31      $(this).remove();
     32    });
     33
     34    limit_level=0;
     35    level_count=0;
     36    return false;
     37  });
     38
     39  $('input[name="is_smart"]').change(function() {
     40    $('#SmartAlbum_options').toggle();
     41    $('input[name="countImages"]').toggle();
     42    $('.count_images_wrapper').toggle();
     43  });
     44
     45  $('input[name="countImages"]').click(function() {
     46    countImages($("#smart"));
     47    return false;
     48  });
     49
     50
     51  // ADD FILTER FUNCTIONS
     52  function add_filter(type, cond, value) {
     53    count++;
     54
     55    var content = $("#filtersRepo #filter_"+type).html().replace(/iiii/g, count);
     56    $block = $($.parseHTML(content)).appendTo("#filtersList");
     57
     58    if (cond) {
     59      select_cond($block, type, cond);
     60    }
     61
     62    if (value) {
     63      if (type == "tags") {
     64        $block.find(".filter-value .tagSelect").html(value);
     65      }
     66      else if (type == "album") {
     67        select_options($block, value);
     68      }
     69      else if (type == "level") {
     70        select_options($block, value);
     71      }
     72      else if (type != "dimensions") {
     73        $block.find(".filter-value input").val(value);
     74      }
     75    }
     76
     77    init_jquery_handlers($block);
     78
     79    if (type == "dimensions") {
     80      select_dimensions($block, cond, value);
     81    }
     82
     83    if (type == 'limit') {
     84      limit_count=1;
     85      $("#addFilter option[value='limit']").attr('disabled','disabled');
     86    }
     87    else if (type == 'level') {
     88      level_count=1;
     89      $("#addFilter option[value='level']").attr('disabled','disabled');
     90    }
     91  }
     92
     93  function select_cond($block, type, cond) {
     94    $block.find(".filter-cond option").removeAttr('selected');
     95    $block.find(".filter-cond option[value='"+cond+"']").attr('selected', 'selected');
     96  }
     97
     98  function select_dimensions($block, cond, value) {
     99    console.log($block, cond, value);
     100    cond = cond || 'width';
     101
     102    $block.find(">.filter-value>span").hide();
     103    $block.find(".dimension_"+cond).show();
     104
     105    if (value) {
     106      values = value.split(',');
     107    }
     108    else {
     109      values = $block.find(".filter_dimension_"+cond+"_slider").slider("values");
     110    }
     111    $block.find(".filter_dimension_"+cond+"_slider").slider("values", values);
     112  }
     113
     114  function select_options($block, value) {
     115    values = value.split(',');
     116    for (j in values) {
     117      $block.find(".filter-value option[value='"+ values[j] +"']").attr('selected', 'selected');
     118    }
     119  }
     120
     121
     122  // DECLARE JQUERY PLUGINS AND VERSATILE HANDLERS
     123  function init_jquery_handlers($block) {
     124    // remove filter
     125    $block.find(".removeFilter").click(function() {
     126      type = $(this).next("input").val();
     127      if (type == 'limit') {
     128        limit_count=1;
     129        $("#addFilter option[value='limit']").removeAttr('disabled');
     130      }
     131      else if (type == 'level') {
     132        level_count=1;
     133        $("#addFilter option[value='level']").removeAttr('disabled');
     134      }
     135
     136      $(this).parents('li').remove();
     137      return false;
     138    });
     139
     140    // date filter
     141    if ($block.hasClass('filter_date')) {
     142      $block.find("input[type='text']").each(function() {
     143        $(this).datepicker({
     144          dateFormat:'yy-mm-dd',
     145          firstDay:1
     146        });
     147      });
     148    }
     149
     150    // tags filter
     151    if ($block.hasClass('filter_tags')) {
     152      $block.find(".tagSelect").tokenInput(
     153        [{foreach from=$all_tags item=tag name=tags}{ name:"{$tag.name|escape:javascript}", id:"{$tag.id}" }{if !$smarty.foreach.tags.last},{/if}{/foreach}],
     154        {
     155          hintText: '{'Type in a search term'|translate}',
     156          noResultsText: '{'No results'|translate}',
     157          searchingText: '{'Searching...'|translate}',
     158          animateDropdown: false,
     159          preventDuplicates: true,
     160          allowFreeTagging: false
     161        }
     162      );
     163    }
     164
     165    // album filter
     166    if ($block.hasClass('filter_album')) {
     167      $block.find(".albumSelect").chosen();
     168    }
     169
     170    // dimension filter
     171    if ($block.hasClass('filter_dimensions')) {
     172      $block.find(".filter-cond select").change(function() {
     173        select_dimensions($block, $(this).val());
     174      });
     175
     176      $block.find(".filter_dimension_width_slider").slider({
     177        range: true,
     178        min: {$dimensions.bounds.min_width},
     179        max: {$dimensions.bounds.max_width},
     180        values: [{$dimensions.bounds.min_width}, {$dimensions.bounds.max_width}],
     181        slide: function(event, ui) {
     182          change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}");
     183        },
     184        change: function(event, ui) {
     185          change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}");
     186        }
     187      });
     188
     189      $block.find(".filter_dimension_height_slider").slider({
     190        range: true,
     191        min: {$dimensions.bounds.min_height},
     192        max: {$dimensions.bounds.max_height},
     193        values: [{$dimensions.bounds.min_height}, {$dimensions.bounds.max_height}],
     194        slide: function(event, ui) {
     195          change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}");
     196        },
     197        change: function(event, ui) {
     198          change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}");
     199        }
     200      });
     201
     202      $block.find(".filter_dimension_ratio_slider").slider({
     203        range: true,
     204        step: 0.01,
     205        min: {$dimensions.bounds.min_ratio},
     206        max: {$dimensions.bounds.max_ratio},
     207        values: [{$dimensions.bounds.min_ratio}, {$dimensions.bounds.max_ratio}],
     208        slide: function(event, ui) {
     209          change_dimension_info($block, ui.values, "{'between %.2f and %.2f'|translate}");
     210        },
     211        change: function(event, ui) {
     212          change_dimension_info($block, ui.values, "{'between %.2f and %.2f'|translate}");
     213        }
     214      });
     215
     216      $block.find("a.dimensions-choice").click(function() {
     217        $block.find(".filter_dimension_"+ $(this).data("type") +"_slider").slider("values",
     218          [$(this).data("min"), $(this).data("max")]
     219        );
     220      });
     221    }
     222  }
     223
     224
     225  // GENERAL FUNCTIONS
     226  function change_dimension_info($block, values, text) {
     227    $block.find("input[name$='[value][min]']").val(values[0]);
     228    $block.find("input[name$='[value][max]']").val(values[1]);
     229    $block.find(".filter_dimension_info").html(sprintf(text, values[0], values[1]));
     230  }
     231
     232  function countImages(form) {
     233    jQuery.post("{$COUNT_SCRIPT_URL}", 'cat_id={$CAT_ID}&'+form.serialize(),
     234      function success(data) {
     235        jQuery('.count_images_wrapper').html(data);
     236      }
     237    );
     238  }
     239
     240  return add_filter; // expose add_filter method
     241}(jQuery));
    15242
    16243{if isset($new_smart)}
    17 {footer_script require='jquery'}
    18244function doBlink(obj,start,finish) {
    19245  jQuery(obj).fadeOut(400).fadeIn(400);
     
    27253
    28254doBlink('.new_smart', 0, 3);
     255{/if}
    29256{/footer_script}
    30 {/if}
    31257
    32258
Note: See TracChangeset for help on using the changeset viewer.