Move javascript for sliders to functions.js.

This commit is contained in:
Michal Čihař
2011-02-02 16:04:22 +01:00
parent 3cb9916d8b
commit a0d08a3321
2 changed files with 29 additions and 36 deletions

View File

@@ -2410,6 +2410,17 @@ function PMA_getRowNumber(classlist) {
return parseInt(classlist.split(/row_/)[1]); return parseInt(classlist.split(/row_/)[1]);
} }
/**
* Changes status of slider
*/
function PMA_set_status_label(id) {
if ($('#' + id).css('display') == 'none') {
$('#anchor_status_' + id).text('+ ');
} else {
$('#anchor_status_' + id).text('- ');
}
}
/** /**
* Vertical pointer * Vertical pointer
*/ */
@@ -2478,5 +2489,22 @@ $(document).ready(function() {
})(); })();
} }
/**
* Slider effect.
*/
$('.pma_auto_slider').each(function(idx, e) {
$('<span id="anchor_status_' + e.id + '"><span>')
.insertBefore(e);
PMA_set_status_label(e.id);
$('<a href="#' + e.id + '" id="anchor_' + e.id + '">' + e.title + '</a>')
.insertBefore(e)
.click(function() {
$('#' + e.id).toggle('clip');
PMA_set_status_label(e.id);
return false;
});
});
}) // end of $(document).ready() }) // end of $(document).ready()

View File

@@ -2524,42 +2524,7 @@ function PMA_generate_slider_effect($id, $message)
* maybe by using an additional param, the id of the div to append to * maybe by using an additional param, the id of the div to append to
*/ */
?> ?>
<div id="<?php echo $id; ?>" <?php echo $GLOBALS['cfg']['InitialSlidersState'] == 'closed' ? ' style="display: none; overflow:auto;"' : ''; ?>> <div id="<?php echo $id; ?>" <?php echo $GLOBALS['cfg']['InitialSlidersState'] == 'closed' ? ' style="display: none; overflow:auto;"' : ''; ?> class="pma_auto_slider" title="<?php echo htmlspecialchars($message); ?>">
<script type="text/javascript">
// <![CDATA[
function PMA_set_status_label_<?php echo $id; ?>() {
if ($('#<?php echo $id; ?>').css('display') == 'none') {
$('#anchor_status_<?php echo $id; ?>').text('+ ');
} else {
$('#anchor_status_<?php echo $id; ?>').text('- ');
}
}
$(document).ready(function() {
$('<span id="anchor_status_<?php echo $id; ?>"><span>')
.insertBefore('#<?php echo $id; ?>')
PMA_set_status_label_<?php echo $id; ?>();
$('<a href="#<?php echo $id; ?>" id="anchor_<?php echo $id; ?>"><?php echo htmlspecialchars($message); ?></a>')
.insertBefore('#<?php echo $id; ?>')
.click(function() {
// The callback should be the 4th parameter but
// it only works as the second parameter;
// For the possible effects see http://jqueryui.com/demos/show
$('#<?php echo $id; ?>').toggle('clip', function() {
PMA_set_status_label_<?php echo $id; ?>();
});
return false;
});
});
//]]>
</script>
<noscript>
<div id="<?php echo $id; ?>"></div>
</noscript>
<?php <?php
} }