remove inline js from main.php

This commit is contained in:
Marc Delisle
2010-03-27 15:01:13 -04:00
parent bbad02a5a1
commit 6ff307b546
4 changed files with 50 additions and 38 deletions

28
js/main_custom_color.js Normal file
View File

@@ -0,0 +1,28 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* for main custom color
*
*/
$(document).ready(function() {
$('#li_custom_color').show();
// Choosing another id does not work!
$('#colorSelector').ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function(hsb, hex, rgb) {
top.frame_content.document.body.style.backgroundColor = '#' + hex;
top.frame_navigation.document.body.style.backgroundColor = '#' + hex;
},
onSubmit: function(hsb, hex, rgb) {
$('#custom_color').val('#' + hex);
$('#colorform').submit();
}
});
});

View File

@@ -14,6 +14,7 @@ require_once './libraries/common.inc.php';
$GLOBALS['js_include'][] = 'jquery/jquery-1.4.2-min.js'; $GLOBALS['js_include'][] = 'jquery/jquery-1.4.2-min.js';
$GLOBALS['js_include'][] = 'colorpicker/js/colorpicker.js'; $GLOBALS['js_include'][] = 'colorpicker/js/colorpicker.js';
$GLOBALS['js_include'][] = 'main_custom_color.js';
// Handles some variables that may have been sent by the calling script // Handles some variables that may have been sent by the calling script
$GLOBALS['db'] = ''; $GLOBALS['db'] = '';
@@ -153,45 +154,18 @@ if ($GLOBALS['cfg']['ThemeManager']) {
echo '<li id="li_select_theme">'; echo '<li id="li_select_theme">';
echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox(); echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
echo '</li>'; echo '</li>';
?>
<script type="text/javascript">
//<![CDATA[
document.write('<li id="li_custom_color">');
document.write('<?php echo PMA_escapeJsString($strCustomColor) . ': '; ?>');
document.write('<form name="colorform" id="colorform" method="post" action="index.php" target="_parent">');
document.write('<?php echo PMA_generate_common_hidden_inputs(); ?>');
document.write('<input type="hidden" id="custom_color" name="custom_color" value="" />');
document.write('<input type="submit" name="custom_color_reset" value="<?php echo $strReset; ?>" />');
document.write('</form>');
document.write('<div id="colorSelector">');
document.write('</div>');
document.write('</li>');
$(document).ready(function() { // see js/main_custom_color.js
// Choosing another id does not work! echo '<li id="li_custom_color" class="hide">';
$('#colorSelector').ColorPicker({ echo PMA_escapeJsString($strCustomColor) . ': ';
color: '#0000ff', echo '<form name="colorform" id="colorform" method="post" action="index.php" target="_parent">';
onShow: function (colpkr) { echo PMA_generate_common_hidden_inputs();
$(colpkr).fadeIn(500); echo '<input type="hidden" id="custom_color" name="custom_color" value="" />';
return false; echo '<input type="submit" name="custom_color_reset" value="' . $strReset . '" />';
}, echo '</form>';
onHide: function (colpkr) { echo '<div id="colorSelector">';
$(colpkr).fadeOut(500); echo '</div>';
return false; echo '</li>';
},
onChange: function(hsb, hex, rgb) {
top.frame_content.document.body.style.backgroundColor = '#' + hex;
top.frame_navigation.document.body.style.backgroundColor = '#' + hex;
},
onSubmit: function(hsb, hex, rgb) {
$('#custom_color').val('#' + hex);
$('#colorform').submit();
}
});
});
//]]>
</script>
<?php
} }
echo '<li id="li_select_fontsize">'; echo '<li id="li_select_fontsize">';
echo PMA_Config::getFontsizeForm(); echo PMA_Config::getFontsizeForm();

View File

@@ -1227,6 +1227,11 @@ code.sql {
margin-top: 0; margin-top: 0;
} }
/* for elements that should be revealed only via js */
.hide {
display: none;
}
#li_select_server { #li_select_server {
padding-bottom: 0.3em; padding-bottom: 0.3em;
border-bottom: 0.3em solid <?php echo $GLOBALS['cfg']['ThBackground']; ?>; border-bottom: 0.3em solid <?php echo $GLOBALS['cfg']['ThBackground']; ?>;

View File

@@ -1178,6 +1178,11 @@ code.sql {
margin-top: 0; margin-top: 0;
} }
/* for elements that should be revealed only via js */
.hide {
display: none;
}
#li_select_server { #li_select_server {
padding-bottom: 0.3em; padding-bottom: 0.3em;
border-bottom: 0.3em solid <?php echo $GLOBALS['cfg']['ThBackground']; ?>; border-bottom: 0.3em solid <?php echo $GLOBALS['cfg']['ThBackground']; ?>;