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/collections.inc.php

    r16597 r16608  
    135135      {
    136136        $col['name'] = 'temp #'.$col['id'];
    137         $col['U_VIEW'] = $col['U_EDIT'];
    138137        $col['U_SAVE'] = USER_COLLEC_PUBLIC.'&action=save&col_id='.$col['id'];
    139138        $template->append('temp_col', $col);
     
    141140      else
    142141      {
    143         $col['U_VIEW'] = USER_COLLEC_PUBLIC.'view/'.$col['id'];
    144142        $template->append('collections', $col);
    145143      }
     
    166164      'U_VIEW' => $self_url,
    167165      'U_LIST' => USER_COLLEC_PUBLIC,
     166      'COL_ID' => $page['col_id'],
    168167      ));
    169168   
     
    191190      $template->assign('collection', $UserCollection->getCollectionInfo());
    192191     
    193       $template->set_prefilter('index_thumbnails', 'user_collection_thumbnails_list_prefilter');
     192      $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_special_prefilter');
    194193     
    195194      $page['start'] = isset($_GET['start']) ? $_GET['start'] : 0;
     
    282281$template->assign('USER_COLLEC_PATH', USER_COLLEC_PATH);
    283282
    284 function user_collection_thumbnails_list_prefilter($content, &$smarty)
     283
     284function user_collections_thumbnails_list_special_prefilter($content, &$smarty)
    285285{
    286   $search = '<span class="thumbName">';
     286  // custom style
     287  $search[0] = '{/html_style}';
     288  $replace[0] = '.thumbnails  .wrap1 {ldelim} position:relative; }
     289.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; }
     290.wrap1:hover .addCollection {ldelim} display:block; }'
     291.$search[0];
     292
     293  // links
     294  $search[1] = '<span class="wrap1">';
     295  $replace[1] = $search[1].'
     296{strip}<a class="addCollection" href="{$U_VIEW}&amp;remove={$thumbnail.id}" data-id="{$thumbnail.id}" rel="nofollow">
     297{\'Remove from collection\'|@translate}&nbsp;<img src="{$USER_COLLEC_PATH}template/image_delete.png" title="{\'Remove from collection\'|@translate}">
     298</a>{/strip}';
     299
     300  // AJAX request
     301  $search[2] = '{/html_style}';
     302  $replace[2] = $search[2].'
     303{footer_script require=\'jquery\'}
     304jQuery(".addCollection").click(function() {ldelim}
     305  var toggle_id = jQuery(this).data("id");
     306  var $trigger = jQuery(this);
    287307 
    288   $add = '<a href="{$U_VIEW}&amp;remove={$thumbnail.id}" rel="nofollow">
    289 <img src="{$USER_COLLEC_PATH}template/image_delete.png" title="{\'Remove from collection\'|@translate}">
    290 </a>&nbsp;';
    291 
    292   return str_replace($search, $search.$add, $content);
     308  jQuery.ajax({ldelim}
     309    type: "POST",
     310    url: "{$USER_COLLEC_PATH}toggle_image.php",
     311    data: {ldelim} "col_id": "{$COL_ID}", "toggle_id": toggle_id }
     312  }).done(function(msg) {ldelim}
     313    if (msg == "false") {ldelim}
     314      $trigger.parent(".wrap1").hide("fast", function() {ldelim} $trigger.remove() });
     315    } else {ldelim}
     316      $trigger.html(\'{\'Un unknown error occured\'|@translate}\');
     317    }
     318  });
     319 
     320  return false;
     321});
     322{/footer_script}';
     323
     324  return str_replace($search, $replace, $content);
    293325}
    294326
Note: See TracChangeset for help on using the changeset viewer.