Ignore:
Timestamp:
Jul 11, 2012, 12:20:27 PM (12 years ago)
Author:
mistic100
Message:

-add complete breadcrumb
-AJAX for add/remove photos (more faster)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/include/events.inc.php

    r16599 r16608  
    1919  {
    2020    $page['section'] = 'collections';
    21     $page['title'] = '<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>';
     21    $page['title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].'<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>';
    2222   
    2323    if (in_array(@$tokens[1], array('edit','view','list')))
     
    116116function user_collections_thumbnails_list_prefilter($content, &$smarty)
    117117{
    118   $search = '<span class="thumbName">';
    119  
    120   $add = '<a href="{$collection_toggle_url}&amp;collection_toggle={$thumbnail.id}" rel="nofollow">
     118  // custom style
     119  $search[0] = '{/html_style}';
     120  $replace[0] = '.thumbnails  .wrap1 {ldelim} position:relative; }
     121.addCollection {ldelim} width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:0.8em; }
     122.wrap1:hover .addCollection {ldelim} display:block; }'
     123.$search[0];
     124
     125  // links
     126  $search[1] = '<span class="wrap1">';
     127  $replace[1] = $search[1].'
     128{strip}<a class="addCollection" href="{$collection_toggle_url}&amp;collection_toggle={$thumbnail.id}" data-id="{$thumbnail.id}" rel="nofollow">
    121129{if $thumbnail.COLLECTION_SELECTED}
    122 <img src="{$USER_COLLEC_PATH}template/image_delete.png" title="{\'Remove from collection\'|@translate}">
     130{\'Remove from collection\'|@translate}&nbsp;<img src="{$USER_COLLEC_PATH}template/image_delete.png" title="{\'Remove from collection\'|@translate}">
    123131{else}
    124 <img src="{$USER_COLLEC_PATH}template/image_add.png" title="{\'Add to collection\'|@translate}">
     132{\'Add to collection\'|@translate}&nbsp;<img src="{$USER_COLLEC_PATH}template/image_add.png" title="{\'Add to collection\'|@translate}">
    125133{/if}
    126 </a>&nbsp;';
    127 
    128   return str_replace($search, $search.$add, $content);
     134</a>{/strip}';
     135
     136  // AJAX request
     137  $search[2] = '{/html_style}';
     138  $replace[2] = $search[2].'
     139{footer_script require=\'jquery\'}
     140jQuery(".addCollection").click(function() {ldelim}
     141  var toggle_id = jQuery(this).data("id");
     142  var $trigger = jQuery(this);
     143 
     144  jQuery.ajax({ldelim}
     145    type: "POST",
     146    url: "{$USER_COLLEC_PATH}toggle_image.php",
     147    data: {ldelim} "toggle_id": toggle_id }
     148  }).done(function(msg) {ldelim}
     149    if (msg == "true") {ldelim}
     150      $trigger.html(\'{\'Remove from collection\'|@translate}&nbsp;<img src="{$USER_COLLEC_PATH}template/image_delete.png" title="{\'Remove from collection\'|@translate}">\');
     151    } else if (msg == "false") {ldelim}
     152      $trigger.html(\'{\'Add to collection\'|@translate}&nbsp;<img src="{$USER_COLLEC_PATH}template/image_add.png" title="{\'Add to collection\'|@translate}">\');
     153    } else {ldelim}
     154      $trigger.html(\'{\'Un unknown error occured\'|@translate}\');
     155    }
     156  });
     157 
     158  return false;
     159});
     160{/footer_script}';
     161
     162  return str_replace($search, $replace, $content);
    129163}
    130164
Note: See TracChangeset for help on using the changeset viewer.