aboutsummaryrefslogtreecommitdiffstats
path: root/themes
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-06-18 10:29:55 +0000
committermistic100 <mistic@piwigo.org>2013-06-18 10:29:55 +0000
commit078e4d1bbdc920ff6c7a3ba8777fae2b23d38909 (patch)
treeb16cf52fa2642b8118985173b9723e5d4655907f /themes
parent9602a3a2034ac6a83a90a9fb925065a931a2ff19 (diff)
feature:2928 Factorize JS code for switchBox
switchBox("selector for link", "selector for box"); git-svn-id: http://piwigo.org/svn/trunk@23320 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--themes/default/js/switchbox.js11
-rw-r--r--themes/default/template/index.tpl26
-rw-r--r--themes/default/template/picture.tpl19
3 files changed, 21 insertions, 35 deletions
diff --git a/themes/default/js/switchbox.js b/themes/default/js/switchbox.js
new file mode 100644
index 000000000..9e8167a33
--- /dev/null
+++ b/themes/default/js/switchbox.js
@@ -0,0 +1,11 @@
+function switchBox(link, box) {
+ jQuery(link).click(function() {
+ var elt = jQuery(box);
+ elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
+ .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
+ .toggle();
+ });
+ jQuery(box).on("mouseleave click", function() {
+ jQuery(this).hide();
+ });
+} \ No newline at end of file
diff --git a/themes/default/template/index.tpl b/themes/default/template/index.tpl
index 71e8d8ba4..89ac0f2b4 100644
--- a/themes/default/template/index.tpl
+++ b/themes/default/template/index.tpl
@@ -1,5 +1,7 @@
+{combine_script id='core.switchbox' load='footer' require='jquery' path='themes/default/js/switchbox.js'}
{$MENUBAR}
+
{if isset($errors) or isset($infos)}
<div class="content messages{if isset($MENUBAR)} contentWithMenu{/if}">
{include file='infos_errors.tpl'}
@@ -24,17 +26,7 @@
{/if}
{/foreach}
</div>
- {footer_script require='jquery'}{literal}
-jQuery("#sortOrderLink").click(function() {
- var elt = jQuery("#sortOrderBox");
- elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
- .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
- .toggle();
-});
-jQuery("#sortOrderBox").on("mouseleave", function() {
- jQuery(this).hide();
-});
- {/literal}{/footer_script}
+ {footer_script require='core.switchbox'}switchBox("#sortOrderLink", "#sortOrderBox");{/footer_script}
{/strip}</li>
{/if}
{if !empty($image_derivatives)}
@@ -51,17 +43,7 @@ jQuery("#sortOrderBox").on("mouseleave", function() {
{/if}
{/foreach}
</div>
- {footer_script require='jquery'}{literal}
-jQuery("#derivativeSwitchLink").click(function() {
- var elt = jQuery("#derivativeSwitchBox");
- elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
- .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
- .toggle();
-});
-jQuery("#derivativeSwitchBox").on("mouseleave", function() {
- jQuery(this).hide();
-});
- {/literal}{/footer_script}
+ {footer_script require='core.switchbox'}switchBox("#derivativeSwitchLink", "#derivativeSwitchBox");{/footer_script}
{/strip}</li>
{/if}
diff --git a/themes/default/template/picture.tpl b/themes/default/template/picture.tpl
index d86434c88..419918aca 100644
--- a/themes/default/template/picture.tpl
+++ b/themes/default/template/picture.tpl
@@ -1,11 +1,11 @@
-{* Example of resizeable
-{include file='include/autosize.inc.tpl'}
-*}
+{combine_script id='core.switchbox' load='footer' require='jquery' path='themes/default/js/switchbox.js'}
{if isset($MENUBAR)}{$MENUBAR}{/if}
<div id="content"{if isset($MENUBAR)} class="contentWithMenu"{/if}>
+
{if isset($errors) or not empty($infos)}
{include file='infos_errors.tpl'}
{/if}
+
{if !empty($PLUGIN_PICTURE_BEFORE)}{$PLUGIN_PICTURE_BEFORE}{/if}
<div id="imageHeaderBar">
@@ -17,9 +17,10 @@
<div id="imageToolBar">
<div class="imageNumber">{$PHOTO}</div>
{include file='picture_nav_buttons.tpl'|@get_extent:'picture_nav_buttons'}
+
<div class="actionButtons">
{if isset($current.unique_derivatives) && count($current.unique_derivatives)>1}
-{footer_script require='jquery'}{literal}
+{footer_script require='jquery,core.switchbox'}{literal}
function changeImgSrc(url,typeSave,typeMap)
{
var theImg = document.getElementById("theMainImage");
@@ -33,15 +34,7 @@ function changeImgSrc(url,typeSave,typeMap)
jQuery('#derivativeChecked'+typeSave).css('visibility','visible');
document.cookie = 'picture_deriv='+typeSave+';path={/literal}{$COOKIE_PATH}{literal}';
}
-jQuery("#derivativeSwitchLink").click(function() {
- var elt = jQuery("#derivativeSwitchBox");
- elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
- .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
- .toggle();
-});
-jQuery("#derivativeSwitchBox").on("mouseleave click", function() {
- jQuery(this).hide();
-});
+switchBox("#derivativeSwitchLink", "#derivativeSwitchBox");
{/literal}{/footer_script}
{strip}<a id="derivativeSwitchLink" title="{'Photo sizes'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
<span class="pwg-icon pwg-icon-sizes">&nbsp;</span><span class="pwg-button-text">{'Photo sizes'|@translate}</span>