Skip to content

Commit

Permalink
Merge pull request #469 from creative-commoners/pulls/3/further-ss4-c…
Browse files Browse the repository at this point in the history
…ompat

ENHANCEMENT -  SS4 compatibility
  • Loading branch information
robbieaverill committed Sep 14, 2017
2 parents b444db1 + 2417863 commit de0e8e0
Show file tree
Hide file tree
Showing 33 changed files with 427 additions and 454 deletions.
7 changes: 0 additions & 7 deletions _config.php
@@ -1,8 +1 @@
<?php

/**
* Fetches the name of the current module folder name.
*
* @return string
**/
define('BLOGGER_DIR', basename(dirname(__FILE__)));
4 changes: 2 additions & 2 deletions docs/en/configuring-large-websites.md
Expand Up @@ -54,8 +54,8 @@ For example in BlogPost:

```php
protected function getCandidateAuthors() {
if($this->config()->restrict_authors_to_group) {
return Group::get()->filter('Code', $this->config()->restrict_authors_to_group)->first()->Members();
if($this->config()->get('restrict_authors_to_group')) {
return Group::get()->filter('Code', $this->config()->get('restrict_authors_to_group'))->first()->Members();
} else {
$list = Member::get();
$this->extend('updateCandidateAuthors', $list);
Expand Down
4 changes: 2 additions & 2 deletions gulpfile.js
Expand Up @@ -8,10 +8,10 @@ gulp.task("scss", function () {
.pipe(gulp.dest("./css"));
});

gulp.task('watch', ['scss'], function() {
gulp.task('watch', ['scss'], function () {
gulp.watch('./scss/*.scss', ['scss']);
});

gulp.task('default', ['scss'], function() {
gulp.task('default', ['scss'], function () {
// noop
});
234 changes: 117 additions & 117 deletions js/cms.js
@@ -1,6 +1,6 @@
(function ($) {

$.entwine('ss', function ($) {
$.entwine('ss', function ($) {

/**
* The page success/error message sits outside of the html block
Expand All @@ -10,136 +10,136 @@
* @see https://github.com/silverstripe/silverstripe-blog/issues/210
*/
$('.cms-content-fields > #Form_EditForm_error').entwine({
'onadd': function() {
'onadd': function () {
var $target = $('.blog-admin-outer');
if($target.length == 1) {
if ($target.length == 1) {
$target.prepend(this);
}
}
});

/**
* 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();
}

window.onresize = 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();
}

window.onresize = function () {
this.updateLayout();
}.bind(this);
},
togglePanel: function(bool, silent) {
this._super(bool, silent);
this.updateLayout();
},
/**
* Adjust minimum width of content to account for extra panel
*
* @returns {undefined}
*/
updateLayout: function() {
},
togglePanel: function (bool, silent) {
this._super(bool, silent);
this.updateLayout();
},
/**
* Adjust minimum width of content to account for extra panel
*
* @returns {undefined}
*/
updateLayout: function () {
$(this).css('height', '100%');
var currentHeight = $(this).outerHeight();
var bottomHeight = $('.cms-content-actions').eq(0).outerHeight();
$(this).css('height', (currentHeight - bottomHeight) + "px");
$(this).css('bottom', bottomHeight + "px");

$('.cms-container').updateLayoutOptions({
minContentWidth: 820 + this.width()
});
$('.cms-container').updateLayoutOptions({
minContentWidth: 820 + this.width()
});

}
});
}
});

});
});
})(jQuery);
12 changes: 6 additions & 6 deletions src/Admin/GridFieldCategorisationConfig.php
Expand Up @@ -23,11 +23,11 @@ public function __construct($itemsPerPage = 15, $mergeRecords, $parentType, $par
$this->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldAddNewButton');

$this->addComponent(
new GridFieldAddByDBField('buttons-before-left')
GridFieldAddByDBField::create('buttons-before-left')
);

$this->addComponent(
new GridFieldMergeAction($mergeRecords, $parentType, $parentMethod, $childMethod)
GridFieldMergeAction::create($mergeRecords, $parentType, $parentMethod, $childMethod)
);

/**
Expand All @@ -36,11 +36,11 @@ public function __construct($itemsPerPage = 15, $mergeRecords, $parentType, $par
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');

$columns->setFieldFormatting(
array(
[
'BlogPostsCount' => function ($value, CategorisationObject $item) {
return $item->BlogPosts()->Count();
}
)
]
);

$this->changeColumnOrder();
Expand All @@ -57,12 +57,12 @@ protected function changeColumnOrder()
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');

$columns->setDisplayFields(
array(
[
'Title' => 'Title',
'BlogPostsCount' => 'Posts',
'MergeAction' => 'MergeAction',
'Actions' => 'Actions'
)
]
);
}
}
2 changes: 1 addition & 1 deletion src/Admin/GridFieldFormAction.php
Expand Up @@ -9,7 +9,7 @@ class GridFieldFormAction extends GridField_FormAction
/**
* @var array
*/
protected $extraAttributes = array();
protected $extraAttributes = [];

/**
* @param array $attributes
Expand Down

0 comments on commit de0e8e0

Please sign in to comment.