diff --git a/library/Icinga/Web/JavaScript.php b/library/Icinga/Web/JavaScript.php index ed39c1b39..dafdee32a 100644 --- a/library/Icinga/Web/JavaScript.php +++ b/library/Icinga/Web/JavaScript.php @@ -27,7 +27,8 @@ class JavaScript 'js/icinga/behavior/tristate.js', 'js/icinga/behavior/navigation.js', 'js/icinga/behavior/form.js', - 'js/icinga/behavior/actiontable.js' + 'js/icinga/behavior/actiontable.js', + 'js/icinga/behavior/dblclickselect.js' ); protected static $vendorFiles = array( diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 75cdf2cb9..b9ad79f00 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -10,17 +10,17 @@ use Icinga\Module\Monitoring\Object\Host; iconImage()->host($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>) render('partials/host/statusicons.phtml'); ?>
host_address6 && $object->host_address6 !== $object->host_name): ?> - escape($object->host_address6); ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> - escape($object->host_address); ?> + escape($object->host_address); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index 5a6fac2ea..67f48e195 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -11,16 +11,16 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->service($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>)
host_address6 && $object->host_address6 !== $object->host_name): ?> - escape($object->host_address6); ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> - escape($object->host_address); ?> + escape($object->host_address); ?> @@ -31,7 +31,7 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->host($object) ?> - translate('Service'); ?>: escape($object->service_display_name); ?> + translate('Service'); ?>: escape($object->service_display_name); ?> service_display_name !== $object->service_description): ?> (escape($object->service_description); ?>) diff --git a/public/js/icinga/behavior/dblclickselect.js b/public/js/icinga/behavior/dblclickselect.js new file mode 100644 index 000000000..142857063 --- /dev/null +++ b/public/js/icinga/behavior/dblclickselect.js @@ -0,0 +1,45 @@ +/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ + +(function(Icinga, $) { + + "use strict"; + + Icinga.Behaviors = Icinga.Behaviors || {}; + + var DblClickSelect = function (icinga) { + Icinga.EventListener.call(this, icinga); + this.on('rendered', this.onRendered, this); + }; + DblClickSelect.prototype = new Icinga.EventListener(); + + DblClickSelect.prototype.onRendered = function(evt) { + $(evt.target).on('dblclick', '.dblclickselect', function() { $(this).selectText(); }); + }; + + /** + * extend jQuery with a selectText function + * + * This function will create a browser selection of the choosen DOM object. + */ + $.fn.selectText = function() { + if (this.length === 0) return; + var e = this[0]; + + var b = document.body, r; + if (b.createTextRange) { + r = b.createTextRange(); + r.moveToElementText(e); + r.select(); + } else if (window.getSelection) { + var s = window.getSelection(); + r = document.createRange(); + r.selectNodeContents(e); + s.removeAllRanges(); + s.addRange(r); + } + }; + + // Export + Icinga.Behaviors.DblClickSelect = DblClickSelect; + +}) (Icinga, jQuery);