forked from 0x2620/pandora
all items element: only show right-aligned buttons once width is known (fixes #887)
This commit is contained in:
parent
ad0645c87c
commit
f4d6cd33c9
1 changed files with 15 additions and 5 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
pandora.ui.allItems = function(section) {
|
pandora.ui.allItems = function(section) {
|
||||||
|
|
||||||
|
// FIXME: Why is this not a list?
|
||||||
|
|
||||||
section = section || pandora.user.ui.section;
|
section = section || pandora.user.ui.section;
|
||||||
|
|
||||||
var canAddItems = !pandora.site.itemRequiresVideo && pandora.site.capabilities.canAddItems[pandora.user.level],
|
var canAddItems = !pandora.site.itemRequiresVideo && pandora.site.capabilities.canAddItems[pandora.user.level],
|
||||||
|
@ -44,7 +46,8 @@ pandora.ui.allItems = function(section) {
|
||||||
})
|
})
|
||||||
.html(pandora.getAllItemsTitle(section))
|
.html(pandora.getAllItemsTitle(section))
|
||||||
.appendTo(that),
|
.appendTo(that),
|
||||||
$items;
|
$items,
|
||||||
|
$buttons = [];
|
||||||
|
|
||||||
if (section == 'items') {
|
if (section == 'items') {
|
||||||
$items = $('<div>')
|
$items = $('<div>')
|
||||||
|
@ -55,24 +58,26 @@ pandora.ui.allItems = function(section) {
|
||||||
textAlign: 'right'
|
textAlign: 'right'
|
||||||
})
|
})
|
||||||
.appendTo(that);
|
.appendTo(that);
|
||||||
Ox.Button({
|
$buttons[0] = Ox.Button({
|
||||||
style: 'symbol',
|
style: 'symbol',
|
||||||
title: 'add',
|
title: 'add',
|
||||||
tooltip: canAddItems ? Ox._('Add {0}', [Ox._(pandora.site.itemName.singular)]) : '',
|
tooltip: canAddItems ? Ox._('Add {0}', [Ox._(pandora.site.itemName.singular)]) : '',
|
||||||
type: 'image'
|
type: 'image'
|
||||||
})
|
})
|
||||||
.css({opacity: canAddItems ? 1 : 0.25})
|
.css({opacity: canAddItems ? 1 : 0.25})
|
||||||
|
.hide()
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: pandora.addItem
|
click: pandora.addItem
|
||||||
})
|
})
|
||||||
.appendTo(that);
|
.appendTo(that);
|
||||||
Ox.Button({
|
$buttons[1] = Ox.Button({
|
||||||
style: 'symbol',
|
style: 'symbol',
|
||||||
title: 'upload',
|
title: 'upload',
|
||||||
tooltip: canUploadVideo ? Ox._('Upload Video...') : '',
|
tooltip: canUploadVideo ? Ox._('Upload Video...') : '',
|
||||||
type: 'image'
|
type: 'image'
|
||||||
})
|
})
|
||||||
.css({opacity: canUploadVideo ? 1 : 0.25})
|
.css({opacity: canUploadVideo ? 1 : 0.25})
|
||||||
|
.hide()
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function() {
|
click: function() {
|
||||||
pandora.$ui.uploadDialog = pandora.ui.uploadDialog().open();
|
pandora.$ui.uploadDialog = pandora.ui.uploadDialog().open();
|
||||||
|
@ -86,19 +91,21 @@ pandora.ui.allItems = function(section) {
|
||||||
});
|
});
|
||||||
} else if (section == 'edits') {
|
} else if (section == 'edits') {
|
||||||
} else if (section == 'texts') {
|
} else if (section == 'texts') {
|
||||||
Ox.Button({
|
$buttons[0] = Ox.Button({
|
||||||
style: 'symbol',
|
style: 'symbol',
|
||||||
title: 'file',
|
title: 'file',
|
||||||
tooltip: Ox._('HTML'),
|
tooltip: Ox._('HTML'),
|
||||||
type: 'image'
|
type: 'image'
|
||||||
})
|
})
|
||||||
|
.hide()
|
||||||
.appendTo(that);
|
.appendTo(that);
|
||||||
Ox.Button({
|
$buttons[1] = Ox.Button({
|
||||||
style: 'symbol',
|
style: 'symbol',
|
||||||
title: 'help',
|
title: 'help',
|
||||||
tooltip: Ox._('Help'),
|
tooltip: Ox._('Help'),
|
||||||
type: 'image'
|
type: 'image'
|
||||||
})
|
})
|
||||||
|
.hide()
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function() {
|
click: function() {
|
||||||
pandora.UI.set({page: 'help'});
|
pandora.UI.set({page: 'help'});
|
||||||
|
@ -124,6 +131,9 @@ pandora.ui.allItems = function(section) {
|
||||||
|
|
||||||
that.resizeElement = function(width) {
|
that.resizeElement = function(width) {
|
||||||
$name.css({width: width + 'px'});
|
$name.css({width: width + 'px'});
|
||||||
|
$buttons.forEach(function($button) {
|
||||||
|
$button.show();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
Loading…
Reference in a new issue