Ignore:
Timestamp:
Apr 1, 2012, 3:48:08 PM (12 years ago)
Author:
mistic100
Message:

feature 2588: use jQuery to toggle derivatives and sort boxes + prevent boxes to overflow the page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/themes/default/template/picture.tpl

    r13805 r13844  
    3636}
    3737
    38 function toggleDerivativeSwitchBox()
    39 {
    40         var elt = document.getElementById("derivativeSwitchBox"),
    41                 ePos = document.getElementById("derivativeSwitchLink");
    42         if (elt.style.display==="none")
    43         {
    44                 elt.style.left = (ePos.offsetLeft)+"px";
    45                 elt.style.top = (ePos.offsetTop+ePos.offsetHeight)+"px";
    46                 elt.style.display="";
    47         }
    48         else
    49                 elt.style.display="none";
    50 }
    51 jQuery("#derivativeSwitchBox").on('mouseleave click', function() {
    52         this.style.display="none";
    53 }
    54 );
     38$(document).ready(function() {
     39  $("#derivativeSwitchBox").css({'top':0,'left':0});
     40  var derivativeSwitchBox_width = $("#derivativeSwitchBox").outerWidth(true);
     41  var derivativeSwitchBox_height = $("#derivativeSwitchBox").outerHeight(true);
     42 
     43  $("#derivativeSwitchLink").click(function() {
     44    $("#derivativeSwitchBox").toggle();
     45   
     46    if ($(this).offset().left + derivativeSwitchBox_width > $(window).width()) {
     47      $("#derivativeSwitchBox").css("left", $(window).width() - derivativeSwitchBox_width - 5);
     48    } else {
     49      $("#derivativeSwitchBox").css("left", $(this).offset().left);
     50    }
     51    $("#derivativeSwitchBox").css("top", $(this).offset().top + $(this).outerHeight(true));
     52  });
     53 
     54  $("#derivativeSwitchBox").bind("mouseleave click", function() {
     55    $(this).hide();
     56  });
     57});
    5558{/literal}{/footer_script}
    56 {strip}<a id="derivativeSwitchLink" href="javascript:toggleDerivativeSwitchBox()" title="{'Photo sizes'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
    57 <span class="pwg-icon pwg-icon-sizes">&nbsp;</span><span class="pwg-button-text">{'Photo sizes'|@translate}</span></a>
     59{strip}<a id="derivativeSwitchLink" title="{'Photo sizes'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
     60  <span class="pwg-icon pwg-icon-sizes">&nbsp;</span><span class="pwg-button-text">{'Photo sizes'|@translate}</span>
     61</a>
    5862<div id="derivativeSwitchBox" class="switchBox" style="display:none">
    59 <div class="switchBoxTitle">{'Photo sizes'|@translate}</div>
    60 {foreach from=$current.unique_derivatives item=derivative key=derivative_type}
    61 <span class="switchCheck" id="derivativeChecked{$derivative_type}"{if $derivative->get_type() ne $current.selected_derivative->get_type()} style="visibility:hidden"{/if}>&#x2714; </span>
    62 <a href="javascript:changeImgSrc('{$derivative->get_url()|@escape:javascript}','{$derivative_type}','{$derivative->get_type()}')">
    63         {$derivative->get_type()|@translate}<span class="derivativeSizeDetails"> ({$derivative->get_size_hr()})</span>
    64 </a><br>
    65 {/foreach}
    66 {if isset($U_ORIGINAL)}
    67 <a href="javascript:phpWGOpenWindow('{$U_ORIGINAL}','xxx','scrollbars=yes,toolbar=no,status=no,resizable=yes')" rel="nofollow">{'Original'|@translate}</a>
    68 {/if}
    69 </div>
    70 {/strip}{/if}
    71 
     63  <div class="switchBoxTitle">{'Photo sizes'|@translate}</div>
     64  {foreach from=$current.unique_derivatives item=derivative key=derivative_type}
     65  <span class="switchCheck" id="derivativeChecked{$derivative_type}"{if $derivative->get_type() ne $current.selected_derivative->get_type()} style="visibility:hidden"{/if}>&#x2714; </span>
     66  <a href="javascript:changeImgSrc('{$derivative->get_url()|@escape:javascript}','{$derivative_type}','{$derivative->get_type()}')">
     67    {$derivative->get_type()|@translate}<span class="derivativeSizeDetails"> ({$derivative->get_size_hr()})</span>
     68  </a><br>
     69  {/foreach}
     70  {if isset($U_ORIGINAL)}
     71  <a href="javascript:phpWGOpenWindow('{$U_ORIGINAL}','xxx','scrollbars=yes,toolbar=no,status=no,resizable=yes')" rel="nofollow">{'Original'|@translate}</a>
     72  {/if}
     73</div>
     74{/strip}
     75{/if}
    7276
    7377{strip}{if isset($U_SLIDESHOW_START)}
Note: See TracChangeset for help on using the changeset viewer.