Ignore:
Timestamp:
Jun 2, 2014, 5:26:14 PM (10 years ago)
Author:
mistic100
Message:

fix "missing image_ids" + clean buttons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/template/thumbnails_css_js.tpl

    r27747 r28593  
    66var $cdm = jQuery('#collectionsDropdown');
    77
    8 {if not $IN_PICTURE}
    98$cdm.on('mouseleave', function() {
    109  $cdm.hide();
    1110});
    12 {/if}
    1311
    1412// click on "create collection" button
     
    3937      return;
    4038    }
     39   
     40    var first = $cdm.children('.noCollecMsg').length > 0;
    4141
    4242    jQuery.ajax({
     
    5151      success: function(data) {
    5252        if (data.stat == 'ok') {
    53           var col = data.result;
    54           var html = '<span>&#9733;</span> <a class="add" data-id="'+ col.id +'">'+ col.name +'</a> '
     53          var col = data.result,
     54              html =
     55            '<span>&#9733;</span> <a class="add" data-id="'+ col.id +'">'+ col.name +'</a> '
    5556            +'<span class="menuInfoCat">[<span class="nbImagesCollec-'+ col.id +'">'+ col.nb_images +'</span>]</span> '
    5657            +'<a class="remove" data-id="'+ col.id +'">{'(remove)'|translate|escape:javscript}</a>'
     
    5859
    5960          $cdm.children('.switchBoxFooter').before(html);
    60           $cdm.children('.noCollecMsg').remove();
     61         
     62          if (first) {
     63            $cdm.children('.noCollecMsg').remove();
     64            $cdm.children('.add').trigger('click');
     65          }
    6166        }
    6267        else {
     
    7782// add and remove links (delegate for new collections)
    7883$cdm.on('click', '.add, .remove', function(e) {
    79   var img_id = $cdm.data('img_id');
    80   var col_id = jQuery(this).data('id');
    81   var method = jQuery(this).hasClass('add') ? 'pwg.collections.addImages' : 'pwg.collections.removeImages';
     84  var img_id = $cdm.data('img_id'),
     85      col_id = jQuery(this).data('id'),
     86      method = jQuery(this).hasClass('add') ? 'pwg.collections.addImages' : 'pwg.collections.removeImages';
    8287
    8388  jQuery.ajax({
     
    97102
    98103        // update item datas
    99         var $target = jQuery('.addCollection[data-id="'+ img_id +'"]');
    100         var col_ids = $target.data('cols');
     104        var $target = jQuery('.addCollection[data-id="'+ img_id +'"]'),
     105            col_ids = $target.data('cols');
     106
    101107        if (method == 'pwg.collections.addImages' && col_ids.indexOf(col_id) == -1) {
    102108          col_ids[ col_ids.length ] = col_id;
     
    121127
    122128// main button, open the menu
    123 jQuery('#thumbnails').on('click', '.addCollection', function(e) {
    124   var img_id = jQuery(this).data('id');
    125   var col_ids = jQuery(this).data('cols');
     129jQuery(document).on('click', '.addCollection', function(e) {
     130  var img_id = jQuery(this).data('id'),
     131      col_ids = jQuery(this).data('cols');
    126132
    127133  $cdm.data('img_id', img_id);
    128134
    129135  $cdm.children('.add').each(function() {
    130     if (col_ids.indexOf($(this).data('id')) != -1) {
    131       $(this).css('font-weight', 'bold').next().next().show();
     136    if (col_ids.indexOf(jQuery(this).data('id')) != -1) {
     137      jQuery(this).css('font-weight', 'bold').next().next().show();
    132138    }
    133139    else {
    134       $(this).css('font-weight', 'normal').next().next().hide();
    135     }
    136   });
    137 
    138   {if not $IN_PICTURE}
     140      jQuery(this).css('font-weight', 'normal').next().next().hide();
     141    }
     142  });
     143
     144  {if $IN_PICTURE}
    139145  $cdm.css({
    140     'top': e.pageY-5-$(window).scrollTop(),
    141     'left': Math.min(e.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5)
    142   });
    143   $cdm.show();
     146    'left': Math.min(jQuery(this).offset().left, jQuery(window).width()-$cdm.outerWidth(true)-5),
     147    'top': jQuery(this).offset().top + jQuery(this).outerHeight(true)
     148  });
     149  {else}
     150  $cdm.css({
     151    'left': Math.min(e.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5),
     152    'top': e.pageY-5-$(window).scrollTop()
     153  });
    144154  {/if}
     155  $cdm.toggle();
    145156
    146157  e.preventDefault();
     
    173184{footer_script require='jquery'}
    174185jQuery('#thumbnails').on('click', '.addCollection', function(e) {
    175   var $trigger = jQuery(this);
    176   var img_id = jQuery(this).data('id');
    177   var col_id = {$collection.ID};
     186  var $trigger = jQuery(this),
     187      img_id = jQuery(this).data('id'),
     188      col_id = {$collection.ID};
    178189
    179190  jQuery.ajax({
Note: See TracChangeset for help on using the changeset viewer.