2012-09-26 23:34:00 +02:00
|
|
|
(function($) {
|
|
|
|
$.entwine('ss', function($) {
|
|
|
|
/**
|
2012-12-13 16:33:58 +01:00
|
|
|
* Converts an inline field description into a tooltip
|
|
|
|
* which is shown on hover over any part of the field container,
|
|
|
|
* as well as when focusing into an input element within the field container.
|
|
|
|
*
|
|
|
|
* Note that some fields don't have distinct focusable
|
|
|
|
* input fields (e.g. GridField), and aren't compatible
|
|
|
|
* with showing tooltips.
|
2012-09-26 23:34:00 +02:00
|
|
|
*/
|
2012-12-13 16:33:58 +01:00
|
|
|
$(".cms .field.cms-description-tooltip").entwine({
|
2012-09-26 23:34:00 +02:00
|
|
|
onmatch: function() {
|
2014-07-14 01:15:38 +02:00
|
|
|
this._super();
|
|
|
|
|
2012-12-13 16:33:58 +01:00
|
|
|
var descriptionEl = this.find('.description'), inputEl, tooltipEl;
|
|
|
|
if(descriptionEl.length) {
|
|
|
|
this
|
|
|
|
// TODO Remove title setting, shouldn't be necessary
|
|
|
|
.attr('title', descriptionEl.text())
|
|
|
|
.tooltip({content: descriptionEl.html()});
|
|
|
|
descriptionEl.remove();
|
2012-09-26 23:34:00 +02:00
|
|
|
}
|
2014-07-14 01:15:38 +02:00
|
|
|
},
|
|
|
|
});
|
2012-09-26 23:34:00 +02:00
|
|
|
|
2012-12-13 16:33:58 +01:00
|
|
|
$(".cms .field.cms-description-tooltip :input").entwine({
|
|
|
|
onfocusin: function(e) {
|
|
|
|
this.closest('.field').tooltip('open');
|
|
|
|
},
|
|
|
|
onfocusout: function(e) {
|
|
|
|
this.closest('.field').tooltip('close');
|
2012-09-26 23:34:00 +02:00
|
|
|
}
|
|
|
|
});
|
2012-12-13 16:33:58 +01:00
|
|
|
|
2012-09-26 23:34:00 +02:00
|
|
|
});
|
|
|
|
}(jQuery));
|