- popover effect in IE/Chrome not as annoying anymore
- only the active select will have a popover, clicking away destroys it

- Added popovers to the add attachments instead of the old info fields
pull/195/head
iglocska 2013-10-15 10:28:43 +02:00
parent 7e8600e250
commit 1f6024f27d
5 changed files with 60 additions and 66 deletions

View File

@ -134,6 +134,7 @@ $(document).ready(function() {
$('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover('destroy');
}); });
$("#AttributeType, #AttributeCategory, #Attribute, #AttributeDistribution").on('mouseover', function(e) { $("#AttributeType, #AttributeCategory, #Attribute, #AttributeDistribution").on('mouseover', function(e) {
var $e = $(e.target); var $e = $(e.target);
if ($e.is('option')) { if ($e.is('option')) {
@ -154,9 +155,12 @@ $(document).ready(function() {
var $e = $(e.target); var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({ $('#'+e.currentTarget.id).popover({
trigger: 'manual', trigger: 'focus',
placement: 'right', placement: 'right',
}).popover('show'); }).popover('show');
// $('#'+e.currentTarget.id).on('mouseleave', $('#'+e.currentTarget.id).popover('destroy');
//$('#'+e.currentTarget.id).on('mouseout', $('#'+e.currentTarget.id).popover('destroy'));
}); });
// workaround for browsers like IE and Chrome that do now have an onmouseover on the 'options' of a select. // workaround for browsers like IE and Chrome that do now have an onmouseover on the 'options' of a select.
@ -166,7 +170,7 @@ $(document).ready(function() {
var $e = $(e.target); var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({ $('#'+e.currentTarget.id).popover({
trigger: 'manual', trigger: 'focus',
placement: 'right', placement: 'right',
content: formInfoValues[$e.val()], content: formInfoValues[$e.val()],
}).popover('show'); }).popover('show');

View File

@ -4,9 +4,10 @@
<legend><?php echo __('Add Attachment'); ?></legend> <legend><?php echo __('Add Attachment'); ?></legend>
<?php <?php
echo $this->Form->hidden('event_id'); echo $this->Form->hidden('event_id');
echo $this->Form->input('category', array( echo $this->Form->input('category');
'after' => $this->Html->div('forminfo', '', array('id' => 'AttributeCategoryDiv')), ?>
)); <div class="input clear"></div>
<?php
if ('true' == Configure::read('CyDefSIG.sync')) { if ('true' == Configure::read('CyDefSIG.sync')) {
$initialDistribution = 3; $initialDistribution = 3;
if (Configure::read('MISP.default_attribute_distribution') != null) { if (Configure::read('MISP.default_attribute_distribution') != null) {
@ -20,7 +21,6 @@
'options' => $distributionLevels, 'options' => $distributionLevels,
'label' => 'Distribution', 'label' => 'Distribution',
'selected' => $initialDistribution, 'selected' => $initialDistribution,
'after' => $this->Html->div('forminfo', '', array('id' => 'AttributeDistributionDiv')),
)); ));
//'before' => $this->Html->div('forminfo', isset($attrDescriptions['distribution']['formdesc']) ? $attrDescriptions['distribution']['formdesc'] : $attrDescriptions['distribution']['desc']),)); //'before' => $this->Html->div('forminfo', isset($attrDescriptions['distribution']['formdesc']) ? $attrDescriptions['distribution']['formdesc'] : $attrDescriptions['distribution']['desc']),));
} }
@ -122,60 +122,50 @@ foreach ($categoryDefinitions as $category => $def) {
} }
} }
?> ?>
$(document).ready(function() {
function showFormType(id) { $("#AttributeCategory, #AttributeDistribution").on('mouseleave', function(e) {
idDiv = id+'Div'; $('#'+e.currentTarget.id).popover('destroy');
// LATER use nice animations });
//$(idDiv).hide('fast');
// change the content
var value = $(id).val(); // get the selected value
//$(idDiv).html(formInfoValues[value]); // search in a lookup table
// do checkbox un/ticked when the document is changed $("#AttributeCategory, #AttributeDistribution").on('mouseover', function(e) {
if (formZipTypeValues[value] == "true") { var $e = $(e.target);
document.getElementById("AttributeMalware").setAttribute("checked", "checked"); if ($e.is('option')) {
if (formAttTypeValues[value] == "false") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled"); $('#'+e.currentTarget.id).popover('destroy');
else document.getElementById("AttributeMalware").removeAttribute("disabled"); $('#'+e.currentTarget.id).popover({
} else { trigger: 'manual',
document.getElementById("AttributeMalware").removeAttribute("checked"); placement: 'right',
if (formAttTypeValues[value] == "true") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled"); content: formInfoValues[$e.val()],
else document.getElementById("AttributeMalware").removeAttribute("disabled"); }).popover('show');
} }
} });
function showFormInfo(id) { $("input, label").on('mouseleave', function(e) {
idDiv = id+'Div'; $('#'+e.currentTarget.id).popover('destroy');
// LATER use nice animations });
//$(idDiv).hide('fast');
// change the content
var value = $(id).val(); // get the selected value
$(idDiv).html(formInfoValues[value]); // search in a lookup table
// show it again $("input, label").on('mouseover', function(e) {
$(idDiv).fadeIn('slow'); var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({
trigger: 'focus',
placement: 'right',
}).popover('show');
});
// do checkbox un/ticked when the document is changed // workaround for browsers like IE and Chrome that do now have an onmouseover on the 'options' of a select.
if (formZipTypeValues[value] == "true") { // disadvangate is that user needs to click on the item to see the tooltip.
document.getElementById("AttributeMalware").setAttribute("checked", "checked"); // no solutions exist, except to generate the select completely using html.
if (formAttTypeValues[value] == "false") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled"); $("#AttributeCategory, #AttributeDistribution").on('change', function(e) {
else document.getElementById("AttributeMalware").removeAttribute("disabled"); var $e = $(e.target);
} else { $('#'+e.currentTarget.id).popover('destroy');
document.getElementById("AttributeMalware").removeAttribute("checked"); $('#'+e.currentTarget.id).popover({
if (formAttTypeValues[value] == "true") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled"); trigger: 'focus',
else document.getElementById("AttributeMalware").removeAttribute("disabled"); placement: 'right',
} content: formInfoValues[$e.val()],
} }).popover('show');
});
// hide the formInfo things });
$('#AttributeTypeDiv').hide();
$('#AttributeCategoryDiv').hide();
$(function(){
// do checkbox un/ticked when the document is ready
showFormType("#AttributeCategory");
}
);
//hide the formInfo things
$('#AttributeDistributionDiv').hide();
</script> </script>
<?php echo $this->Js->writeBuffer(); // Write cached scripts <?php echo $this->Js->writeBuffer(); // Write cached scripts

View File

@ -139,7 +139,7 @@ $(document).ready(function() {
var $e = $(e.target); var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({ $('#'+e.currentTarget.id).popover({
trigger: 'manual', trigger: 'focus',
placement: 'right', placement: 'right',
}).popover('show'); }).popover('show');
}); });
@ -151,7 +151,7 @@ $(document).ready(function() {
var $e = $(e.target); var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({ $('#'+e.currentTarget.id).popover({
trigger: 'manual', trigger: 'focus',
placement: 'right', placement: 'right',
content: formInfoValues[$e.val()], content: formInfoValues[$e.val()],
}).popover('show'); }).popover('show');

View File

@ -94,7 +94,7 @@ $(document).ready(function() {
if ($e.is('option')) { if ($e.is('option')) {
$('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({ $('#'+e.currentTarget.id).popover({
trigger: 'manual', trigger: 'focus',
placement: 'right', placement: 'right',
content: formInfoValues[e.currentTarget.id][$e.val()], content: formInfoValues[e.currentTarget.id][$e.val()],
}).popover('show'); }).popover('show');
@ -108,7 +108,7 @@ $(document).ready(function() {
var $e = $(e.target); var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({ $('#'+e.currentTarget.id).popover({
trigger: 'manual', trigger: 'focus',
placement: 'right', placement: 'right',
content: formInfoValues[e.currentTarget.id][$e.val()], content: formInfoValues[e.currentTarget.id][$e.val()],
}).popover('show'); }).popover('show');

View File

@ -82,7 +82,7 @@ $(document).ready(function() {
if ($e.is('option')) { if ($e.is('option')) {
$('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({ $('#'+e.currentTarget.id).popover({
trigger: 'manual', trigger: 'focus',
placement: 'right', placement: 'right',
content: formInfoValues[e.currentTarget.id][$e.val()], content: formInfoValues[e.currentTarget.id][$e.val()],
}).popover('show'); }).popover('show');
@ -96,7 +96,7 @@ $(document).ready(function() {
var $e = $(e.target); var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({ $('#'+e.currentTarget.id).popover({
trigger: 'manual', trigger: 'focus',
placement: 'right', placement: 'right',
content: formInfoValues[e.currentTarget.id][$e.val()], content: formInfoValues[e.currentTarget.id][$e.val()],
}).popover('show'); }).popover('show');