Skip to content

Commit

Permalink
Add support for alignRight
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamPS committed Feb 27, 2017
1 parent 8e731f5 commit 43f7207
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions js/rrssb.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
maxRows: {min: 1, max: 99, default: 2},
prefixReserve: {min: 0, max: 0.8, default: 0.3},
prefixHide: {min: 0.1, max: 10, default: 2},
alignRight: {type: 'boolean', default: false},
};

var oldJQuery = function() {
Expand Down Expand Up @@ -40,11 +41,14 @@

var checkedSettings = {};
for (var param in schema) {
if (settings && !isNaN(parseFloat(settings[param]))) {
checkedSettings[param] = Math.min(schema[param].max, Math.max(schema[param].min, settings[param]));
}
else {
checkedSettings[param] = schema[param].default;
checkedSettings[param] = schema[param].default;
if (settings) {
if (schema[param].type == 'boolean') {
checkedSettings[param] = Boolean(settings[param]);
}
else if (!isNaN(parseFloat(settings[param]))) {
checkedSettings[param] = Math.min(schema[param].max, Math.max(schema[param].min, settings[param]));
}
}
}

Expand Down Expand Up @@ -201,12 +205,13 @@
// Use a percentage so a small container doesn't inherit a huge pad after a radical rescale.
// Allow a little extra to ensure rounding error doesn't accidentally spread buttons onto extra lines.
desiredWidth *= scale * 1.02;
var paddingAttr = settings.alignRight ? 'padding-left' : 'padding-right';
if (containerWidth > desiredWidth) {
var padding = Math.floor(10000 * (containerWidth - desiredWidth) / containerWidth) / 100;
$(this).css('padding-right', padding + '%');
$(this).css(paddingAttr, padding + '%');
}
else {
$(this).css('padding-right', '');
$(this).css(paddingAttr, '');
}
};

Expand Down
2 changes: 1 addition & 1 deletion js/rrssb.min.js

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

0 comments on commit 43f7207

Please sign in to comment.