MNT ESLint issues
This commit is contained in:
parent
3f4b87489c
commit
57def71094
|
@ -2,141 +2,141 @@
|
||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
jQuery.entwine('ss', ($) => {
|
jQuery.entwine('ss', ($) => {
|
||||||
/**
|
/**
|
||||||
* The page success/error message sits outside of the html block
|
* The page success/error message sits outside of the html block
|
||||||
* containing the sidebar and cms fields. This means it overflows
|
* containing the sidebar and cms fields. This means it overflows
|
||||||
* underneath the sidebar.
|
* underneath the sidebar.
|
||||||
*
|
*
|
||||||
* @see https://github.com/silverstripe/silverstripe-blog/issues/210
|
* @see https://github.com/silverstripe/silverstripe-blog/issues/210
|
||||||
*/
|
*/
|
||||||
$('.cms-content-fields > #Form_EditForm_error').entwine({
|
$('.cms-content-fields > #Form_EditForm_error').entwine({
|
||||||
onadd() {
|
onadd() {
|
||||||
const $target = $('.blog-admin-outer');
|
const $target = $('.blog-admin-outer');
|
||||||
if ($target.length === 1) {
|
if ($target.length === 1) {
|
||||||
$target.prepend(this);
|
$target.prepend(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register expandable help text functions with fields.
|
* Register expandable help text functions with fields.
|
||||||
*/
|
*/
|
||||||
$('.toggle-description').entwine({
|
$('.toggle-description').entwine({
|
||||||
onadd() {
|
onadd() {
|
||||||
const $this = $(this);
|
const $this = $(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent multiple events being added.
|
* Prevent multiple events being added.
|
||||||
*/
|
*/
|
||||||
if ($this.hasClass('toggle-description-enabled')) {
|
if ($this.hasClass('toggle-description-enabled')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.addClass('toggle-description-enabled');
|
$this.addClass('toggle-description-enabled');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle next description when button is clicked.
|
* Toggle next description when button is clicked.
|
||||||
*/
|
*/
|
||||||
let shown = false;
|
let shown = false;
|
||||||
const $helpInfo = $this.closest('.field').find('.form-text');
|
const $helpInfo = $this.closest('.field').find('.form-text');
|
||||||
|
|
||||||
$this.on('click', () => {
|
$this.on('click', () => {
|
||||||
$helpInfo[shown ? 'hide' : 'show']();
|
$helpInfo[shown ? 'hide' : 'show']();
|
||||||
$this.toggleClass('toggle-description-shown');
|
$this.toggleClass('toggle-description-shown');
|
||||||
shown = !shown;
|
shown = !shown;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide next description by default.
|
* Hide next description by default.
|
||||||
*/
|
*/
|
||||||
$helpInfo.hide();
|
$helpInfo.hide();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add classes to correct inherited layout issues in a small context.
|
* Add classes to correct inherited layout issues in a small context.
|
||||||
*/
|
*/
|
||||||
$this.parent().addClass('toggle-description-correct-right');
|
$this.parent().addClass('toggle-description-correct-right');
|
||||||
$this.parent().prev('.middleColumn').addClass('toggle-description-correct-middle');
|
$this.parent().prev('.middleColumn').addClass('toggle-description-correct-middle');
|
||||||
$this.parent().next('.description').addClass('toggle-description-correct-description');
|
$this.parent().next('.description').addClass('toggle-description-correct-description');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom merge actions for tags and categories
|
* Custom merge actions for tags and categories
|
||||||
*/
|
*/
|
||||||
$('.MergeAction').entwine({
|
$('.MergeAction').entwine({
|
||||||
onadd() {
|
onadd() {
|
||||||
const $this = $(this);
|
const $this = $(this);
|
||||||
|
|
||||||
$this.on('click', 'select', () => false);
|
$this.on('click', 'select', () => false);
|
||||||
|
|
||||||
$this.children('button').each((i, button) => {
|
$this.children('button').each((i, button) => {
|
||||||
const $button = $(button);
|
const $button = $(button);
|
||||||
const $select = $button.prev('select');
|
const $select = $button.prev('select');
|
||||||
|
|
||||||
$button.before(`<input type="hidden" name="${$button.attr('data-target')}" value="${$select.val()}" />`);
|
$button.before(`<input type="hidden" name="${$button.attr('data-target')}" value="${$select.val()}" />`);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this.on('change', 'select', (e) => {
|
$this.on('change', 'select', (e) => {
|
||||||
const $target = $(e.target);
|
const $target = $(e.target);
|
||||||
|
|
||||||
$target.next('input').val($target.val());
|
$target.next('input').val($target.val());
|
||||||
});
|
});
|
||||||
|
|
||||||
$this.children('button, select').hide();
|
$this.children('button, select').hide();
|
||||||
|
|
||||||
$this.on('click', '.MergeActionReveal', (e) => {
|
$this.on('click', '.MergeActionReveal', (e) => {
|
||||||
const $target = $(e.target);
|
const $target = $(e.target);
|
||||||
|
|
||||||
$target.parent().children('button, select').show();
|
$target.parent().children('button, select').show();
|
||||||
$target.hide();
|
$target.hide();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customise the cms-panel behaviour for blog sidebar
|
* Customise the cms-panel behaviour for blog sidebar
|
||||||
*
|
*
|
||||||
* see LeftAndMain.Panel.js for base behaviour
|
* see LeftAndMain.Panel.js for base behaviour
|
||||||
*/
|
*/
|
||||||
$('.blog-admin-sidebar.cms-panel').entwine({
|
$('.blog-admin-sidebar.cms-panel').entwine({
|
||||||
MinInnerWidth: 620,
|
MinInnerWidth: 620,
|
||||||
onadd() {
|
onadd() {
|
||||||
this._super();
|
this._super();
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
|
|
||||||
// Contract panel if it's open and the left hand column is smaller than the minimum
|
// Contract panel if it's open and the left hand column is smaller than the minimum
|
||||||
if (!this.hasClass('collapsed') && ($('.blog-admin-outer').width() < this.getMinInnerWidth())) {
|
if (!this.hasClass('collapsed') && ($('.blog-admin-outer').width() < this.getMinInnerWidth())) {
|
||||||
this.collapsePanel();
|
this.collapsePanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
const onresize = () => {
|
const onresize = () => {
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
};
|
};
|
||||||
onresize.bind(this);
|
onresize.bind(this);
|
||||||
|
|
||||||
window.onresize = onresize;
|
window.onresize = onresize;
|
||||||
},
|
},
|
||||||
togglePanel(bool, silent) {
|
togglePanel(bool, silent) {
|
||||||
this._super(bool, silent);
|
this._super(bool, silent);
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Adjust minimum width of content to account for extra panel
|
* Adjust minimum width of content to account for extra panel
|
||||||
*
|
*
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
updateLayout() {
|
updateLayout() {
|
||||||
$(this).css('height', '100%');
|
$(this).css('height', '100%');
|
||||||
const currentHeight = $(this).outerHeight();
|
const currentHeight = $(this).outerHeight();
|
||||||
const bottomHeight = $('.cms-content-actions').eq(0).outerHeight();
|
const bottomHeight = $('.cms-content-actions').eq(0).outerHeight();
|
||||||
$(this).css('height', `${currentHeight - bottomHeight}px`);
|
$(this).css('height', `${currentHeight - bottomHeight}px`);
|
||||||
$(this).css('bottom', `${bottomHeight}px`);
|
$(this).css('bottom', `${bottomHeight}px`);
|
||||||
|
|
||||||
$('.cms-container').updateLayoutOptions({
|
$('.cms-container').updateLayoutOptions({
|
||||||
minContentWidth: 820 + this.width()
|
minContentWidth: 820 + this.width()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
jQuery.entwine('ss', ($) => {
|
jQuery.entwine('ss', ($) => {
|
||||||
/**
|
/**
|
||||||
* Prevent the CMS hijacking the return key
|
* Prevent the CMS hijacking the return key
|
||||||
*/
|
*/
|
||||||
$('.add-existing-autocompleter input.text').entwine({
|
$('.add-existing-autocompleter input.text').entwine({
|
||||||
onkeydown(e) {
|
onkeydown(e) {
|
||||||
if (e.which === 13) {
|
if (e.which === 13) {
|
||||||
const $parent = $(this).parents('.add-existing-autocompleter');
|
const $parent = $(this).parents('.add-existing-autocompleter');
|
||||||
$parent.find('button[type="submit"]').click();
|
$parent.find('button[type="submit"]').click();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue