Changeset 23320


Ignore:
Timestamp:
Jun 18, 2013, 12:29:55 PM (7 years ago)
Author:
mistic100
Message:

feature:2928 Factorize JS code for switchBox
switchBox("selector for link", "selector for box");

Location:
trunk/themes/default
Files:
1 added
2 edited

Legend:

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

    r23263 r23320  
     1{combine_script id='core.switchbox' load='footer' require='jquery' path='themes/default/js/switchbox.js'}
    12{$MENUBAR}
     3
    24
    35{if isset($errors) or isset($infos)}
     
    2527                        {/foreach}
    2628                </div>
    27                 {footer_script require='jquery'}{literal}
    28 jQuery("#sortOrderLink").click(function() {
    29         var elt = jQuery("#sortOrderBox");
    30         elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
    31                 .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
    32                 .toggle();
    33 });
    34 jQuery("#sortOrderBox").on("mouseleave", function() {
    35         jQuery(this).hide();
    36 });
    37                 {/literal}{/footer_script}
     29                {footer_script require='core.switchbox'}switchBox("#sortOrderLink", "#sortOrderBox");{/footer_script}
    3830                {/strip}</li>
    3931{/if}
     
    5244                        {/foreach}
    5345                </div>
    54                 {footer_script require='jquery'}{literal}
    55 jQuery("#derivativeSwitchLink").click(function() {
    56         var elt = jQuery("#derivativeSwitchBox");
    57         elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
    58                 .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
    59                 .toggle();
    60 });
    61 jQuery("#derivativeSwitchBox").on("mouseleave", function() {
    62         jQuery(this).hide();
    63 });
    64                 {/literal}{/footer_script}
     46                {footer_script require='core.switchbox'}switchBox("#derivativeSwitchLink", "#derivativeSwitchBox");{/footer_script}
    6547                {/strip}</li>
    6648{/if}
  • trunk/themes/default/template/picture.tpl

    r23263 r23320  
    1 {* Example of resizeable
    2 {include file='include/autosize.inc.tpl'}
    3 *}
     1{combine_script id='core.switchbox' load='footer' require='jquery' path='themes/default/js/switchbox.js'}
    42{if isset($MENUBAR)}{$MENUBAR}{/if}
    53<div id="content"{if isset($MENUBAR)} class="contentWithMenu"{/if}>
     4
    65{if isset($errors) or not empty($infos)}
    76{include file='infos_errors.tpl'}
    87{/if}
     8
    99{if !empty($PLUGIN_PICTURE_BEFORE)}{$PLUGIN_PICTURE_BEFORE}{/if}
    1010
     
    1818<div class="imageNumber">{$PHOTO}</div>
    1919{include file='picture_nav_buttons.tpl'|@get_extent:'picture_nav_buttons'}
     20
    2021<div class="actionButtons">
    2122{if isset($current.unique_derivatives) && count($current.unique_derivatives)>1}
    22 {footer_script require='jquery'}{literal}
     23{footer_script require='jquery,core.switchbox'}{literal}
    2324function changeImgSrc(url,typeSave,typeMap)
    2425{
     
    3435        document.cookie = 'picture_deriv='+typeSave+';path={/literal}{$COOKIE_PATH}{literal}';
    3536}
    36 jQuery("#derivativeSwitchLink").click(function() {
    37         var elt = jQuery("#derivativeSwitchBox");
    38         elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
    39                 .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
    40                 .toggle();
    41 });
    42 jQuery("#derivativeSwitchBox").on("mouseleave click", function() {
    43         jQuery(this).hide();
    44 });
     37switchBox("#derivativeSwitchLink", "#derivativeSwitchBox");
    4538{/literal}{/footer_script}
    4639{strip}<a id="derivativeSwitchLink" title="{'Photo sizes'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
Note: See TracChangeset for help on using the changeset viewer.