mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
19de22f427
admin/javascript => admin/client admin/javascript/src => admin/client/src/legacy (mostly) admin/scss/_variables.scss => admin/client/styles/_variables.scss admin/scss => admin/client/styles/legacy/ admin/css/editor.css => admin/client/dist/css/editor.css admin/css/screen.css => admin/client/dist/css/bundle.css admin/images => admin/client/dist/images admin/images/sprites/src => admin/client/src/sprites admin/images/sprites/dist => admin/client/dist/sprites admin/font => admin/client/dist/font
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
/**
|
|
* Enable toggling (show/hide) of the field's description.
|
|
*/
|
|
|
|
import $ from 'jQuery';
|
|
|
|
$.entwine('ss', function ($) {
|
|
|
|
$('.cms-description-toggle').entwine({
|
|
onadd: function () {
|
|
var shown = false, // Current state of the description.
|
|
fieldId = this.prop('id').substr(0, this.prop('id').indexOf('_Holder')),
|
|
$trigger = this.find('.cms-description-trigger'), // Click target for toggling the description.
|
|
$description = this.find('.description');
|
|
|
|
// Prevent multiple events being added.
|
|
if (this.hasClass('description-toggle-enabled')) {
|
|
return;
|
|
}
|
|
|
|
// If a custom trigger han't been supplied use a sensible default.
|
|
if ($trigger.length === 0) {
|
|
$trigger = this
|
|
.find('.middleColumn')
|
|
.first() // Get the first middleColumn so we don't add multiple triggers on composite field types.
|
|
.after('<label class="right" for="' + fieldId + '"><a class="cms-description-trigger" href="javascript:void(0)"><span class="btn-icon-information"></span></a></label>')
|
|
.next();
|
|
}
|
|
|
|
this.addClass('description-toggle-enabled');
|
|
|
|
// Toggle next description when button is clicked.
|
|
$trigger.on('click', function() {
|
|
$description[shown ? 'hide' : 'show']();
|
|
shown = !shown;
|
|
});
|
|
|
|
// Hide next description by default.
|
|
$description.hide();
|
|
}
|
|
});
|
|
|
|
});
|