Skip to content

Commit

Permalink
Merge branch 'master' into fix/js-hijack
Browse files Browse the repository at this point in the history
* master:
  Replace deprecated draftModel->delete() call
  Readd Children variable.
  Fix call to getWriteChildrenMethod
  Fix the docblock and default for Gdn_Request->decodePost()
  Recompile CSS.
  Increment version for 2017-Q1-1
  Add btn-group collapsing
  Address avatar image sizes in Vanilla
  Do not set config defaults inline when the setting is in conf-defaults
  Increase default image resolutions
  Support a JSON content type in the request

Conflicts:
	applications/dashboard/design/admin.css.map
	applications/dashboard/styleguide/public/admin.css
	applications/dashboard/styleguide/public/dashboard.js
	applications/dashboard/template/public/admin.css
	applications/dashboard/template/public/dashboard.js
  • Loading branch information
beckyvb committed Jan 20, 2017
2 parents 4ba23c6 + ce6c824 commit 3a983a9
Show file tree
Hide file tree
Showing 25 changed files with 638 additions and 66 deletions.
1 change: 1 addition & 0 deletions applications/dashboard/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ module.exports = function (grunt) {
styleguide: {
src: ([]).concat([
'js/vendors/tether.js',
'js/vendors/jquery.checkall.min.js',
'js/vendors/icheck.min.js',
'js/vendors/clipboard.min.js',
'js/vendors/drop.min.js',
Expand Down
10 changes: 5 additions & 5 deletions applications/dashboard/controllers/class.profilecontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ public function picture($userReference = '', $username = '', $userID = '') {
if ($this->isUploadedAvatar($avatar)) {
// Get the image source so we can manipulate it in the crop module.
$upload = new Gdn_UploadImage();
$thumbnailSize = c('Garden.Thumbnail.Size', 40);
$thumbnailSize = c('Garden.Thumbnail.Size');
$basename = changeBasename($avatar, "p%s");
$source = $upload->copyLocal($basename);

Expand Down Expand Up @@ -791,7 +791,7 @@ public function picture($userReference = '', $username = '', $userID = '') {
}
if ($this->Form->errorCount() == 0) {
if ($newAvatar !== false) {
$thumbnailSize = c('Garden.Thumbnail.Size', 40);
$thumbnailSize = c('Garden.Thumbnail.Size');
// Update crop properties.
$basename = changeBasename($newAvatar, "p%s");
$source = $upload->copyLocal($basename);
Expand Down Expand Up @@ -874,12 +874,12 @@ private function saveAvatars($source, $thumbOptions, $upload = null) {
$parts = Gdn_UploadImage::saveImageAs(
$source,
self::AVATAR_FOLDER."/$subdir/p$imageBaseName",
c('Garden.Profile.MaxHeight', 1000),
c('Garden.Profile.MaxWidth', 250),
c('Garden.Profile.MaxHeight'),
c('Garden.Profile.MaxWidth'),
array('SaveGif' => c('Garden.Thumbnail.SaveGif'))
);

$thumbnailSize = c('Garden.Thumbnail.Size', 40);
$thumbnailSize = c('Garden.Thumbnail.Size');

// Save the thumbnail size image.
Gdn_UploadImage::saveImageAs(
Expand Down
10 changes: 5 additions & 5 deletions applications/dashboard/controllers/class.settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function defaultAvatar() {
if (($avatar = c('Garden.DefaultAvatar')) && $this->isUploadedDefaultAvatar($avatar)) {
//Get the image source so we can manipulate it in the crop module.
$upload = new Gdn_UploadImage();
$thumbnailSize = c('Garden.Thumbnail.Size', 40);
$thumbnailSize = c('Garden.Thumbnail.Size');
$basename = changeBasename($avatar, "p%s");
$source = $upload->copyLocal($basename);

Expand Down Expand Up @@ -310,7 +310,7 @@ public function defaultAvatar() {
if ($newAvatar) {
$this->deleteDefaultAvatars($avatar);
$avatar = c('Garden.DefaultAvatar');
$thumbnailSize = c('Garden.Thumbnail.Size', 40);
$thumbnailSize = c('Garden.Thumbnail.Size');

// Update crop properties.
$basename = changeBasename($avatar, "p%s");
Expand Down Expand Up @@ -360,12 +360,12 @@ private function saveDefaultAvatars($source, $thumbOptions) {
Gdn_UploadImage::saveImageAs(
$source,
self::DEFAULT_AVATAR_FOLDER."/p$imageBaseName",
c('Garden.Profile.MaxHeight', 1000),
c('Garden.Profile.MaxWidth', 250),
c('Garden.Profile.MaxHeight'),
c('Garden.Profile.MaxWidth'),
array('SaveGif' => c('Garden.Thumbnail.SaveGif'))
);

$thumbnailSize = c('Garden.Thumbnail.Size', 40);
$thumbnailSize = c('Garden.Thumbnail.Size');
// Save the thumbnail size image.
Gdn_UploadImage::saveImageAs(
$source,
Expand Down
32 changes: 27 additions & 5 deletions applications/dashboard/design/admin.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion applications/dashboard/design/admin.css.map

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions applications/dashboard/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,110 @@ var DashboardModal = (function() {
});
}

function buttonGroupInit(element) {

/**
* Transforms a button group into a dropdown-filter.
*
* @param $buttonGroup
*/
var transformButtonGroup = function(buttonGroup) {
var elem = document.createElement('div');
$(elem).addClass('dropdown');
$(elem).addClass('dropdown-filter');

var items = $(buttonGroup).html();
var title = gdn.definition('Filter');
var list = document.createElement('div');
var id = Math.random().toString(36).substr(2, 9);


$(list).addClass('dropdown-menu');
$(list).attr('aria-labelledby', id);
$(list).html(items);

$('.btn', list).each(function() {
$(this).removeClass('btn');
$(this).removeClass('btn-secondary');
$(this).addClass('dropdown-item');

if ($(this).hasClass('active')) {
title = $(this).html();
}
});

$(elem).prepend(
'<button ' +
'id="' + id + '" ' +
'type="button" ' +
'class="btn btn-secondary dropdown-toggle" ' +
'data-toggle="dropdown" ' +
'aria-haspopup="true" ' +
'aria-expanded="false"' +
'>' +
title +
'</button>'
);

$(elem).append($(list));

return elem;
};

var showButtonGroup = function(buttonGroup, dropdown) {
$(buttonGroup).show();
$(dropdown).hide();
};

var showDropdown = function(buttonGroup, dropdown) {
$(buttonGroup).hide();
$(dropdown).show();
};

/**
* Generates an equivalent dropdown to the btn-group. Calculates widths to see whether we show the dropdown
* or btn-group, and then shows/hides the appropriate one.
*
* @param element The scope of the function
*/
var checkWidth = function(element) {
$('.btn-group', element).each(function() {
var self = this;
var maxWidth = $(self).data('maxWidth');
var container = $(self).data('containerSelector');

if (!container && !maxWidth) {
maxWidth = $(window).width();
}

if (container) {
maxWidth = $(container).width();
}

if (!self.width) {
self.width = $(self).width();
}

if (!self.dropdown) {
self.dropdown = transformButtonGroup(self);
$(self).after(self.dropdown);
}

if (self.width <= maxWidth) {
showButtonGroup(self, self.dropdown);
} else {
showDropdown(self, self.dropdown);
}
});
};

checkWidth(element);

$(window).resize(function() {
checkWidth(document);
});
}

$(document).on('contentLoad', function(e) {
prettyPrintInit(e.target); // prettifies <pre> blocks
aceInit(e.target); // code editor
Expand All @@ -1004,6 +1108,7 @@ var DashboardModal = (function() {
foggyInit(e.target); // makes settings blurred out
checkallInit(e.target); // handles 'select all' type checkboxes
dropDownInit(e.target); // makes sure our dropdowns open in the right direction
buttonGroupInit(e.target); // changes button groups that get too long into selects
});

/**
Expand Down
105 changes: 105 additions & 0 deletions applications/dashboard/js/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,110 @@
});
}

function buttonGroupInit(element) {

/**
* Transforms a button group into a dropdown-filter.
*
* @param $buttonGroup
*/
var transformButtonGroup = function(buttonGroup) {
var elem = document.createElement('div');
$(elem).addClass('dropdown');
$(elem).addClass('dropdown-filter');

var items = $(buttonGroup).html();
var title = gdn.definition('Filter');
var list = document.createElement('div');
var id = Math.random().toString(36).substr(2, 9);


$(list).addClass('dropdown-menu');
$(list).attr('aria-labelledby', id);
$(list).html(items);

$('.btn', list).each(function() {
$(this).removeClass('btn');
$(this).removeClass('btn-secondary');
$(this).addClass('dropdown-item');

if ($(this).hasClass('active')) {
title = $(this).html();
}
});

$(elem).prepend(
'<button ' +
'id="' + id + '" ' +
'type="button" ' +
'class="btn btn-secondary dropdown-toggle" ' +
'data-toggle="dropdown" ' +
'aria-haspopup="true" ' +
'aria-expanded="false"' +
'>' +
title +
'</button>'
);

$(elem).append($(list));

return elem;
};

var showButtonGroup = function(buttonGroup, dropdown) {
$(buttonGroup).show();
$(dropdown).hide();
};

var showDropdown = function(buttonGroup, dropdown) {
$(buttonGroup).hide();
$(dropdown).show();
};

/**
* Generates an equivalent dropdown to the btn-group. Calculates widths to see whether we show the dropdown
* or btn-group, and then shows/hides the appropriate one.
*
* @param element The scope of the function
*/
var checkWidth = function(element) {
$('.btn-group', element).each(function() {
var self = this;
var maxWidth = $(self).data('maxWidth');
var container = $(self).data('containerSelector');

if (!container && !maxWidth) {
maxWidth = $(window).width();
}

if (container) {
maxWidth = $(container).width();
}

if (!self.width) {
self.width = $(self).width();
}

if (!self.dropdown) {
self.dropdown = transformButtonGroup(self);
$(self).after(self.dropdown);
}

if (self.width <= maxWidth) {
showButtonGroup(self, self.dropdown);
} else {
showDropdown(self, self.dropdown);
}
});
};

checkWidth(element);

$(window).resize(function() {
checkWidth(document);
});
}

$(document).on('contentLoad', function(e) {
prettyPrintInit(e.target); // prettifies <pre> blocks
aceInit(e.target); // code editor
Expand All @@ -342,6 +446,7 @@
foggyInit(e.target); // makes settings blurred out
checkallInit(e.target); // handles 'select all' type checkboxes
dropDownInit(e.target); // makes sure our dropdowns open in the right direction
buttonGroupInit(e.target); // changes button groups that get too long into selects
});

/**
Expand Down
6 changes: 3 additions & 3 deletions applications/dashboard/models/class.smf2importmodel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public function processAvatars() {
$UploadImage->SaveImageAs(
$Image,
PATH_ROOT.'/uploads/userpics/p'.$ImageBaseName,
Gdn::config('Garden.Profile.MaxHeight', 1000),
Gdn::config('Garden.Profile.MaxWidth', 250)
Gdn::config('Garden.Profile.MaxHeight'),
Gdn::config('Garden.Profile.MaxWidth')
);
}

Expand All @@ -68,7 +68,7 @@ public function processAvatars() {
);*/

// Save the uploaded image in thumbnail size
$ThumbSize = Gdn::config('Garden.Thumbnail.Size', 40);
$ThumbSize = Gdn::config('Garden.Thumbnail.Size');
if (!file_exists(PATH_ROOT.'/uploads/userpics/n'.$ImageBaseName)) {
$UploadImage->SaveImageAs(
$Image,
Expand Down
Loading

0 comments on commit 3a983a9

Please sign in to comment.