2011-11-06 18:36:40 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
pandora.ui.allItems = function() {
|
|
|
|
|
|
|
|
var that = Ox.Element()
|
2011-12-22 07:24:30 +00:00
|
|
|
.addClass('OxSelectableElement' + (pandora.user.ui._list ? '' : ' OxSelected'))
|
2011-11-06 18:36:40 +00:00
|
|
|
.css({
|
|
|
|
height: '16px',
|
|
|
|
cursor: 'default',
|
|
|
|
overflow: 'hidden'
|
|
|
|
})
|
2012-05-28 14:10:11 +00:00
|
|
|
.on({
|
2011-11-06 18:36:40 +00:00
|
|
|
click: function() {
|
|
|
|
that.gainFocus();
|
2013-02-16 01:20:40 +00:00
|
|
|
if (pandora.user.ui.section == 'items') {
|
|
|
|
pandora.user.ui._list && pandora.UI.set('find', {conditions: [], operator: '&'});
|
|
|
|
} else {
|
|
|
|
pandora.UI.set(pandora.user.ui.section.slice(0, -1), '');
|
|
|
|
}
|
2011-11-06 18:36:40 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
pandora_find: function() {
|
|
|
|
that[pandora.user.ui._list ? 'removeClass' : 'addClass']('OxSelected');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
$icon = $('<img>')
|
2012-04-20 10:22:32 +00:00
|
|
|
.attr({src: '/static/png/icon.png'})
|
2011-11-06 18:36:40 +00:00
|
|
|
.css({float: 'left', width: '14px', height: '14px', margin: '1px'})
|
|
|
|
.appendTo(that),
|
|
|
|
$name = $('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
height: '14px',
|
|
|
|
margin: '1px 4px 1px 3px',
|
|
|
|
textOverflow: 'ellipsis',
|
|
|
|
overflow: 'hidden',
|
|
|
|
whiteSpace: 'nowrap'
|
|
|
|
})
|
2013-02-16 01:20:40 +00:00
|
|
|
.html(pandora.user.ui.section == 'items' ? 'All ' + pandora.site.itemName.plural
|
|
|
|
: pandora.site.site.name + ' ' + Ox.toTitleCase(pandora.user.ui.section))
|
2013-02-19 07:25:14 +00:00
|
|
|
.appendTo(that),
|
|
|
|
$items,
|
|
|
|
$clickButton,
|
|
|
|
$uploadButton;
|
2011-11-06 18:36:40 +00:00
|
|
|
|
2013-02-16 01:20:40 +00:00
|
|
|
if (pandora.user.ui.section == 'items') {
|
2013-02-19 07:25:14 +00:00
|
|
|
$items = $('<div>')
|
2013-02-16 01:20:40 +00:00
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: '42px',
|
|
|
|
margin: '1px 4px 1px 3px',
|
|
|
|
textAlign: 'right'
|
|
|
|
})
|
2013-02-19 07:25:14 +00:00
|
|
|
.appendTo(that);
|
2013-02-16 01:20:40 +00:00
|
|
|
$clickButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'click',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({opacity: 0.25})
|
2013-02-19 07:25:14 +00:00
|
|
|
.appendTo(that);
|
2013-02-16 01:20:40 +00:00
|
|
|
$uploadButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'upload',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.appendTo(that);
|
|
|
|
pandora.api.find({
|
|
|
|
query: {conditions: [], operator: '&'}
|
|
|
|
}, function(result) {
|
|
|
|
that.update(result.data.items);
|
|
|
|
});
|
|
|
|
}
|
2011-11-06 18:36:40 +00:00
|
|
|
|
2013-02-09 05:14:47 +00:00
|
|
|
that.update = function(items) {
|
2013-02-19 07:25:14 +00:00
|
|
|
$items && $items.html(Ox.formatNumber(items));
|
2013-02-09 05:14:47 +00:00
|
|
|
};
|
|
|
|
|
2011-11-06 18:36:40 +00:00
|
|
|
that.resizeElement = function(width) {
|
|
|
|
$name.css({width: width + 'px'});
|
|
|
|
};
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|