mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 09:05:58 +00:00
Merge branch 'master' of git://github.com/silverstripe/silverstripe-blog
This commit is contained in:
commit
07ede8e550
@ -64,9 +64,9 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getColumnContent($gridField, $record, $columnName) {
|
public function getColumnContent($gridField, $record, $columnName) {
|
||||||
if($columnName === 'MergeAction') {
|
if($columnName === 'MergeAction' && $record->{$this->childMethod}()->Count() > 0) {
|
||||||
$dropdown = new DropdownField('Target', 'Target', $this->records->map());
|
$dropdown = new DropdownField('Target', 'Target', $this->records->exclude('ID', $record->ID)->map());
|
||||||
|
|
||||||
$prefix = strtolower($this->parentMethod . '-' . $this->childMethod);
|
$prefix = strtolower($this->parentMethod . '-' . $this->childMethod);
|
||||||
|
|
||||||
$action = GridFieldFormAction::create(
|
$action = GridFieldFormAction::create(
|
||||||
@ -84,7 +84,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
|||||||
'data-target' => $prefix . '-target-record-' . $record->ID
|
'data-target' => $prefix . '-target-record-' . $record->ID
|
||||||
));
|
));
|
||||||
|
|
||||||
return $dropdown->Field() . $action->Field() . '<a class="MergeActionReveal">move posts to</a>';
|
return $dropdown->Field() . $action->Field() . '<a title="Move posts to" class="MergeActionReveal">move posts to</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -80,8 +80,7 @@ class Blog extends Page implements PermissionProvider {
|
|||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
||||||
Requirements::javascript(BLOGGER_DIR . '/js/expandable-help-text.js');
|
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
||||||
Requirements::javascript(BLOGGER_DIR . '/js/merge-action.js');
|
|
||||||
|
|
||||||
$self =& $this;
|
$self =& $this;
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ class BlogPost extends Page {
|
|||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
||||||
|
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
||||||
|
|
||||||
$self =& $this;
|
$self =& $this;
|
||||||
$this->beforeUpdateCMSFields(function($fields) use ($self) {
|
$this->beforeUpdateCMSFields(function($fields) use ($self) {
|
||||||
|
118
js/cms.js
Normal file
118
js/cms.js
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
(function ($) {
|
||||||
|
|
||||||
|
$.entwine('ss', function ($) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register expandable help text functions with fields.
|
||||||
|
*/
|
||||||
|
$('.toggle-description').entwine({
|
||||||
|
'onadd': function () {
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent multiple events being added.
|
||||||
|
*/
|
||||||
|
if ($this.hasClass('toggle-description-enabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this.addClass('toggle-description-enabled');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle next description when button is clicked.
|
||||||
|
*/
|
||||||
|
var shown = false;
|
||||||
|
|
||||||
|
$this.on('click', function() {
|
||||||
|
$this.parent().next('.description')[shown ? 'hide' : 'show']();
|
||||||
|
|
||||||
|
$this.toggleClass('toggle-description-shown');
|
||||||
|
|
||||||
|
shown = !shown;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide next description by default.
|
||||||
|
*/
|
||||||
|
$this.parent().next('.description').hide();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add classes to correct inherited layout issues in a small context.
|
||||||
|
*/
|
||||||
|
$this.parent().addClass('toggle-description-correct-right');
|
||||||
|
$this.parent().prev('.middleColumn').addClass('toggle-description-correct-middle');
|
||||||
|
$this.parent().next('.description').addClass('toggle-description-correct-description');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom merge actions for tags and categories
|
||||||
|
*/
|
||||||
|
$('.MergeAction').entwine({
|
||||||
|
'onadd': function() {
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
|
$this.on('click', 'select', function() {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$this.children('button').each(function(i, button) {
|
||||||
|
var $button = $(button);
|
||||||
|
var $select = $button.prev('select');
|
||||||
|
|
||||||
|
$button.before('<input type="hidden" name="' + $button.attr('data-target') + '" value="' + $select.val() + '" />');
|
||||||
|
});
|
||||||
|
|
||||||
|
$this.on('change', 'select', function(e) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
|
||||||
|
$target.next('input').val($target.val());
|
||||||
|
});
|
||||||
|
|
||||||
|
$this.children('button, select').hide();
|
||||||
|
|
||||||
|
$this.on('click', '.MergeActionReveal', function(e) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
|
||||||
|
$target.parent().children('button, select').show();
|
||||||
|
$target.hide();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customise the cms-panel behaviour for blog sidebar
|
||||||
|
*
|
||||||
|
* see LeftAndMain.Panel.js for base behaviour
|
||||||
|
*/
|
||||||
|
$('.blog-admin-sidebar.cms-panel').entwine({
|
||||||
|
minInnerWidth: 620,
|
||||||
|
onadd: function() {
|
||||||
|
this._super();
|
||||||
|
this.updateLayout();
|
||||||
|
|
||||||
|
// If this panel is open and the left hand column is smaller than the minimum, contract it instead
|
||||||
|
if(!this.hasClass('collapsed') && ($(".blog-admin-outer").width() < this.getminInnerWidth())) {
|
||||||
|
this.collapsePanel();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
togglePanel: function(bool, silent) {
|
||||||
|
this._super(bool, silent);
|
||||||
|
this.updateLayout();
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Adjust minimum width of content to account for extra panel
|
||||||
|
*
|
||||||
|
* @returns {undefined}
|
||||||
|
*/
|
||||||
|
updateLayout: function() {
|
||||||
|
$('.cms-container').updateLayoutOptions({
|
||||||
|
minContentWidth: 820 + this.width()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
})(jQuery);
|
@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* Register expandable help text functions with fields.
|
|
||||||
*/
|
|
||||||
(function ($) {
|
|
||||||
|
|
||||||
$.entwine('ss', function ($) {
|
|
||||||
|
|
||||||
$('.toggle-description').entwine({
|
|
||||||
'onadd': function () {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prevent multiple events being added.
|
|
||||||
*/
|
|
||||||
if ($this.hasClass('toggle-description-enabled')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this.addClass('toggle-description-enabled');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggle next description when button is clicked.
|
|
||||||
*/
|
|
||||||
var shown = false;
|
|
||||||
|
|
||||||
$this.on('click', function() {
|
|
||||||
$this.parent().next('.description')[shown ? 'hide' : 'show']();
|
|
||||||
|
|
||||||
$this.toggleClass('toggle-description-shown');
|
|
||||||
|
|
||||||
shown = !shown;
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hide next description by default.
|
|
||||||
*/
|
|
||||||
$this.parent().next('.description').hide();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add classes to correct inherited layout issues in a small context.
|
|
||||||
*/
|
|
||||||
$this.parent().addClass('toggle-description-correct-right');
|
|
||||||
$this.parent().prev('.middleColumn').addClass('toggle-description-correct-middle');
|
|
||||||
$this.parent().next('.description').addClass('toggle-description-correct-description');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
})(jQuery);
|
|
@ -1,44 +0,0 @@
|
|||||||
/**
|
|
||||||
* Register expandable help text functions with fields.
|
|
||||||
*/
|
|
||||||
(function ($) {
|
|
||||||
|
|
||||||
$.entwine('ss', function ($) {
|
|
||||||
|
|
||||||
$('.MergeAction').entwine({
|
|
||||||
'onadd': function() {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
$this.on('click', 'select', function() {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$this.children('button').each(function(i, button) {
|
|
||||||
var $button = $(button);
|
|
||||||
var $select = $button.prev('select');
|
|
||||||
|
|
||||||
$button.before('<input type="hidden" name="' + $button.attr('data-target') + '" value="' + $select.val() + '" />');
|
|
||||||
});
|
|
||||||
|
|
||||||
$this.on('change', 'select', function(e) {
|
|
||||||
var $target = $(e.target);
|
|
||||||
|
|
||||||
$target.next('input').val($target.val());
|
|
||||||
});
|
|
||||||
|
|
||||||
$this.children('button, select').hide();
|
|
||||||
|
|
||||||
$this.on('click', '.MergeActionReveal', function(e) {
|
|
||||||
var $target = $(e.target);
|
|
||||||
|
|
||||||
$target.parent().children('button, select').show();
|
|
||||||
$target.hide();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}(jQuery));
|
|
Loading…
x
Reference in New Issue
Block a user