further separate addBtn and cloneBtn, fixes

This commit is contained in:
Isaac Connor 2018-02-08 13:15:27 -05:00
parent cfe53c0ffe
commit 95cfdb327d
3 changed files with 33 additions and 24 deletions

View File

@ -80,8 +80,8 @@ echo output_link_if_exists( array(
'css/base/views/'.$basename.'.css',
'css/'.$css.'/views/'.$basename.'.css',
'/js/dateTimePicker/jquery-ui-timepicker-addon.css',
'/js/jquery-ui-structure.css',
'/css/base/jquery-ui-theme.css',
'/js/jquery-ui.structure.css',
'/css/base/jquery-ui.theme.css',
'/css/'.$css.'/jquery-ui-theme.css',
)
);
@ -112,7 +112,7 @@ echo output_link_if_exists( array(
<script type="text/javascript" src="tools/mootools/mootools-more.js"></script>
<script type="text/javascript" src="js/mootools.ext.js"></script>
<script type="text/javascript" src="skins/<?php echo $skin; ?>/js/jquery.js"></script>
<script type="text/javascript" src="skins/<?php echo $skin; ?>/js/jquery-ui.js"></script>
<script type="text/javascript" src="skins/<?php echo $skin; ?>/js/jquery-ui-1.12.1/jquery-ui.js"></script>
<script type="text/javascript" src="skins/<?php echo $skin; ?>/js/bootstrap.min.js"></script>
<script type="text/javascript" src="skins/<?php echo $skin; ?>/js/chosen/chosen.jquery.min.js"></script>
<script type="text/javascript" src="skins/<?php echo $skin; ?>/js/dateTimePicker/jquery-ui-timepicker-addon.js"></script>

View File

@ -296,7 +296,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
>
<?php echo translate('AddNewMonitor') ?>
</button>
<button name="cloneBtn" onclick="addMonitor(this);"
<button name="cloneBtn" onclick="cloneMonitor(this);"
<?php echo (canEdit('Monitors') && !$user['MonitorIds']) ? '' : ' disabled="disabled"' ?>
style="display:none;">
<?php echo translate('CloneMonitor') ?>

View File

@ -33,24 +33,29 @@ function setButtonStates( element ) {
}
function addMonitor(element) {
createPopup( '?view=monitor', 'zmMonitor0', 'monitor' );
}
function cloneMonitor(element) {
var form = element.form;
var dupParam;
var monitorId=-1;
if (form.addBtn.value == jsTranslatedCloneText) {
// get the value of the first checkbox
for ( var i = 0; i < form.elements.length; i++ ) {
if ( form.elements[i].type == "checkbox" ) {
if ( form.elements[i].checked ) {
monitorId = form.elements[i].value;
break;
}
}
// get the value of the first checkbox
for ( var i = 0; i < form.elements.length; i++ ) {
if (
form.elements[i].type == "checkbox"
&&
form.elements[i].name == "markMids[]"
&&
form.elements[i].checked
) {
monitorId = form.elements[i].value;
break;
}
}
} // end foreach element
if ( monitorId != -1 ) {
createPopup( '?view=monitor&dupId='+monitorId, 'zmMonitor0', 'monitor' );
} else {
window.location = '?view=add_monitors';
}
}
@ -59,14 +64,18 @@ function editMonitor( element ) {
var monitorIds = Array();
for ( var i = 0; i < form.elements.length; i++ ) {
if ( form.elements[i].type == "checkbox" ) {
if ( form.elements[i].checked ) {
monitorIds.push( form.elements[i].value );
//form.elements[i].checked = false;
//setButtonStates( form.elements[i] );
//$(form.elements[i]).getParent( 'tr' ).removeClass( 'highlight' );
//break;
}
if (
form.elements[i].type == "checkbox"
&&
form.elements[i].name == "markMids[]"
&&
form.elements[i].checked
) {
monitorIds.push( form.elements[i].value );
//form.elements[i].checked = false;
//setButtonStates( form.elements[i] );
//$(form.elements[i]).getParent( 'tr' ).removeClass( 'highlight' );
//break;
}
} // end foreach checkboxes
if ( monitorIds.length == 1 )