Changeset 16608


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)

Location:
extensions/UserCollections
Files:
1 added
5 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
  • 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
  • extensions/UserCollections/template/edit.tpl

    r16597 r16608  
    99    copy:$("#publicURL .url").html(),
    1010    afterCopy: function() {ldelim}
     11      $('.confirm').remove();
    1112      $('<span class="confirm" style="display:none;">{'Copied'|@translate}</span>').appendTo("#publicURL")
    1213        .fadeIn(400).delay(1000).fadeOut(400, function(){ldelim} $(this).remove(); });
  • extensions/UserCollections/template/list.tpl

    r16597 r16608  
    3535    <li {if $col.active}class="active"{/if}>
    3636      <p class="collecTitle">
    37         <a href="{$col.U_VIEW}" rel="nofollow"><b>{$col.name}</b></a>
    38         <i>{'%d images'|@translate|@sprintf:$col.nb_images}</i>
     37        <a href="{$col.U_EDIT}" rel="nofollow"><b>{$col.name}</b></a>
     38        <i>{'%d photos'|@translate|@sprintf:$col.nb_images}</i>
    3939      </p>
    4040      <p class="collecActions">
     
    6161      </p>
    6262      <p class="collecTitle">
    63         <a href="{$col.U_VIEW}" rel="nofollow"><b>{$col.name}</b></a>
    64         <i>{'%d images'|@translate|@sprintf:$col.nb_images}</i>
     63        <a href="{$col.U_EDIT}" rel="nofollow"><b>{$col.name}</b></a>
     64        <i>{'%d photos'|@translate|@sprintf:$col.nb_images}</i>
    6565      </p>
    6666      <p class="collecActions">
  • extensions/UserCollections/template/menublock_user_collec.tpl

    r16599 r16608  
    22<dd>
    33{if $block->data.current}
    4   {'Current collection:'|@translate} <b>{$block->data.current.NAME}</b>, {'%d images'|@translate|@sprintf:$block->data.current.NB_IMAGES}
     4  {'Current collection:'|@translate} <b>{$block->data.current.NAME}</b>, {'%d photos'|@translate|@sprintf:$block->data.current.NB_IMAGES}
    55        <ul>{strip}
    66                {foreach from=$block->data.links item=link}
Note: See TracChangeset for help on using the changeset viewer.