Move page style related JS code to separate files

This commit is contained in:
Dmitriy Simushev 2013-12-25 13:56:24 +00:00
parent 086c163db1
commit 5714193eeb
4 changed files with 74 additions and 57 deletions

View File

@ -0,0 +1,48 @@
/**
* @preserve Copyright 2005-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*/
(function($) {
function updateSurvey() {
if ($("#enablepresurvey").is(":checked")) {
$(".undersurvey").show();
} else {
$(".undersurvey").hide();
}
}
function updateSSL() {
if ($("#enablessl").is(":checked")) {
$(".underssl").show();
} else {
$(".underssl").hide();
}
}
function updateGroups() {
if ($("#enablegroups").is(":checked")) {
$(".undergroups").show();
} else {
$(".undergroups").hide();
}
}
$(function() {
$("#enablepresurvey").change(function() {
updateSurvey();
});
$("#enablessl").change(function() {
updateSSL();
});
$("#enablegroups").change(function() {
updateGroups();
});
updateSurvey();
updateSSL();
updateGroups();
});
})(jQuery);

View File

@ -0,0 +1,24 @@
/**
* @preserve Copyright 2005-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*/
(function($) {
function updateParentGroup() {
if ($("#parentgroup").val() == '') {
$("#extrafields").show();
} else {
$("#extrafields").hide();
}
}
$(function() {
$("#parentgroup").change(function() {
updateParentGroup();
});
updateParentGroup();
});
})(jQuery);

View File

@ -21,46 +21,7 @@ require_once(dirname(__FILE__).'/inc_tabbar.php');
function tpl_header() { global $page, $mibewroot; function tpl_header() { global $page, $mibewroot;
?> ?>
<script type="text/javascript" language="javascript" src="<?php echo $mibewroot ?>/js/libs/jquery.min.js"></script> <script type="text/javascript" language="javascript" src="<?php echo $mibewroot ?>/js/libs/jquery.min.js"></script>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript" src="<?php echo $mibewroot ?>/styles/pages/default/js/features.js"></script>
function updateSurvey() {
if($("#enablepresurvey").is(":checked")) {
$(".undersurvey").show();
} else {
$(".undersurvey").hide();
}
}
function updateSSL() {
if($("#enablessl").is(":checked")) {
$(".underssl").show();
} else {
$(".underssl").hide();
}
}
function updateGroups(){
if($("#enablegroups").is(":checked")) {
$(".undergroups").show();
} else {
$(".undergroups").hide();
}
}
$(function(){
$("#enablepresurvey").change(function() {
updateSurvey();
});
$("#enablessl").change(function() {
updateSSL();
});
$("#enablegroups").change(function() {
updateGroups();
});
updateSurvey();
updateSSL();
updateGroups();
});
</script>
<?php <?php
} }

View File

@ -21,23 +21,7 @@ require_once(dirname(__FILE__).'/inc_tabbar.php');
function tpl_header() { global $page, $mibewroot; function tpl_header() { global $page, $mibewroot;
?> ?>
<script type="text/javascript" language="javascript" src="<?php echo $mibewroot ?>/js/libs/jquery.min.js"></script> <script type="text/javascript" language="javascript" src="<?php echo $mibewroot ?>/js/libs/jquery.min.js"></script>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript" src="<?php echo $mibewroot ?>/styles/pages/default/js/group.js"></script>
function updateParentGroup() {
if($("#parentgroup").val() == '') {
$("#extrafields").show();
}else{
$("#extrafields").hide();
}
}
$(function(){
$("#parentgroup").change(function() {
updateParentGroup();
});
updateParentGroup();
});
</script>
<?php <?php
} }