Changeset 13545


Ignore:
Timestamp:
03/14/12 09:19:25 (8 years ago)
Author:
patdenice
Message:

Automaticaly set better derivative params for mobile theme according to screen size.

Location:
trunk/themes/smartpocket
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/themes/smartpocket/template/footer.tpl

    r13243 r13545  
    1515</div> 
    1616{/if} 
     17{footer_script require='jquery'} 
     18document.cookie = 'screen_size='+jQuery(document).width()+'x'+jQuery(document).height()+';path={$COOKIE_PATH}'; 
     19{/footer_script} 
    1720{get_combined_scripts load='footer'} 
    1821</div><!-- /page --> 
  • trunk/themes/smartpocket/template/mainpage_categories.tpl

    r13472 r13545  
    1 {define_derivative name='derivative_params_square' type='square'} 
    2  
    31<ul data-role="listview" data-inset="true"> 
    42{foreach from=$category_thumbnails item=cat} 
    53        <li> 
    64                <a href="{$cat.URL}"> 
    7                 <img src="{$pwg->derivative_url($derivative_params_square, $cat.representative.src_image)}"> 
     5                <img src="{$pwg->derivative_url($thumbnail_derivative_params, $cat.representative.src_image)}"> 
    86    <h3>{$cat.NAME}</h3> 
    97                <p class="Nb_images">{$cat.CAPTION_NB_IMAGES}</p> 
  • trunk/themes/smartpocket/template/thumbnails.tpl

    r13472 r13545  
    66{combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'} 
    77 
    8 {define_derivative name='derivative_params_square' type='square'} 
    9 {define_derivative name='derivative_params_large' type='large'} 
    10  
    118<ul class="thumbnails"> 
    129{foreach from=$thumbnails item=thumbnail}{strip} 
    13 {assign var=derivative value=$pwg->derivative($derivative_params_square, $thumbnail.src_image)} 
     10{assign var=derivative value=$pwg->derivative($thumbnail_derivative_params, $thumbnail.src_image)} 
    1411{if isset($page_selection[$thumbnail.id])} 
    1512  <li> 
    16     <a href="{$pwg->derivative_url($derivative_params_large, $thumbnail.src_image)}" rel="external"> 
     13    <a href="{$pwg->derivative_url($picture_derivative_params, $thumbnail.src_image)}" rel="external"> 
    1714     <img {if !$derivative->is_cached()}data-{/if}src="{$derivative->get_url()}" alt="{$thumbnail.TN_ALT}"> 
    1815    </a> 
     
    2017{else} 
    2118  <li style="display:none;"> 
    22     <a href="{$pwg->derivative_url($derivative_params_large, $thumbnail.src_image)}" rel="external"></a> 
     19    <a href="{$pwg->derivative_url($picture_derivative_params, $thumbnail.src_image)}" rel="external"></a> 
    2320  </li> 
    2421{/if} 
  • trunk/themes/smartpocket/themeconf.inc.php

    r13234 r13545  
    1313); 
    1414 
     15// Redirect if page is not compatible with mobile theme 
     16if (!in_array(script_basename(), array('index', 'register', 'profile', 'identification'))) 
     17  redirect(duplicate_index_url()); 
     18 
    1519//Retrive all pictures on thumbnails page 
    1620add_event_handler('loc_index_thumbnails_selection', 'sp_select_all_thumbnails'); 
     
    2529} 
    2630 
     31// Get better derive parameters for screen size 
     32if (!empty($_COOKIE['screen_size'])) 
     33{ 
     34  $screen_size = explode('x', $_COOKIE['screen_size']); 
     35  $derivative_params = new ImageStdParams; 
     36  $derivative_params->load_from_db(); 
     37  $type = IMG_LARGE; 
     38 
     39  foreach ($derivative_params->get_all_type_map() as $type => $map) 
     40  { 
     41    if (max($map->sizing->ideal_size) >= max($screen_size) and min($map->sizing->ideal_size) >= min($screen_size)) 
     42      break; 
     43  } 
     44  pwg_set_session_var('sp_picture_deriv', $type); 
     45} 
     46 
     47$this->assign('picture_derivative_params', ImageStdParams::get_by_type(pwg_get_session_var('sp_picture_deriv', IMG_LARGE))); 
     48$this->assign('thumbnail_derivative_params', ImageStdParams::get_by_type(IMG_SQUARE)); 
     49 
    2750?> 
Note: See TracChangeset for help on using the changeset viewer.