minimal edits with a sortable list interface and 'add selected item/in/out support'

This commit is contained in:
j 2013-05-27 20:06:56 +00:00
commit cfdaaa4464
17 changed files with 1363 additions and 120 deletions

View file

@ -317,6 +317,20 @@ pandora.URL = (function() {
item: {}
};
// Edits
views['edits'] = {
list: [],
item: ['edit']
};
spanType['edits'] = {
list: [],
item: {edit: 'number'}
};
sortKeys['edits'] = {
list: {},
item: {}
};
findKeys = [{id: 'list', type: 'string'}].concat(pandora.site.itemKeys);
self.URL = Ox.URL({

View file

@ -0,0 +1,200 @@
'use strict';
pandora.ui.editPanel = function() {
var that = Ox.SplitPanel({
elements: [
{element: Ox.Element(), size: 24},
{element: Ox.Element()},
{element: Ox.Element(), size: 16}
],
orientation: 'vertical'
});
pandora.user.ui.edit && render();
function render() {
pandora.api.getEdit({id: pandora.user.ui.edit}, function(result) {
var edit = result.data;
var $toolbar = Ox.Bar({size: 24}),
$editMenu,
$statusbar = Ox.Bar({size: 16}),
$panel = Ox.SplitPanel({
elements: [
{
element: pandora.$ui.edit = pandora.ui.editList(edit)
},
{
element: Ox.Element(),
size: 0,
resizable: false
}
],
orientation: 'horizontal'
});
that.replaceElement(0, $toolbar);
that.replaceElement(1, $panel);
that.replaceElement(2, $statusbar);
});
}
that.reload = function() {
render();
}
return that;
};
pandora.ui.editList = function(edit) {
var height = getHeight(),
width = getWidth(),
that = Ox.Element()
.css({
'overflow-y': 'auto'
});
self.$list = Ox.TableList({
columns: [
{
align: 'left',
id: 'index',
operator: '+',
title: Ox._('Index'),
visible: false,
width: 60
},
{
align: 'left',
id: 'id',
operator: '+',
title: Ox._('ID'),
visible: false,
width: 60
},
{
align: 'left',
id: 'item',
operator: '+',
title: Ox._(pandora.site.itemName.singular),
visible: true,
width: 360
},
{
editable: true,
id: 'in',
operator: '+',
title: Ox._('In'),
visible: true,
width: 60
},
{
editable: true,
id: 'out',
operator: '+',
title: Ox._('Out'),
visible: true,
width: 60
},
{
id: 'duration',
operator: '+',
title: Ox._('Duration'),
visible: true,
width: 60
}
],
columnsMovable: true,
columnsRemovable: true,
columnsResizable: true,
columnsVisible: true,
items: edit.clips,
scrollbarVisible: true,
sort: [{key: 'index', operator: '+'}],
sortable: true,
unique: 'id'
})
.appendTo(that)
.bindEvent({
add: function(data) {
if(pandora.user.ui.item) {
pandora.api.addClip({
edit: pandora.user.ui.edit,
item: pandora.user.ui.item,
'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'],
out: pandora.user.ui.videoPoints[pandora.user.ui.item].out,
}, function(result) {
Ox.Request.clearCache();
pandora.$ui.rightPanel.reload()
});
}
},
'delete': function(data) {
if (data.ids.length > 0 && edit.editable) {
pandora.api.removeClip({
ids: data.ids,
edit: pandora.user.ui.edit
}, function(result) {
Ox.Request.clearCache();
pandora.$ui.rightPanel.reload()
});
}
},
move: function(data) {
Ox.Request.clearCache();
pandora.api.sortClips({
edit: pandora.user.ui.edit,
ids: data.ids
})
},
select: function(data) {
},
submit: function(data) {
var value = self.$list.value(data.id, data.key);
if (data.value != value && !(data.value === '' && value === null)) {
self.$list.value(data.id, data.key, data.value || null);
var edit = {
id: data.id,
};
edit[data.key] = parseFloat(data.value);
pandora.api.editClip(edit, function(result) {
self.$list.value(data.id, data.key, result.data[data.key]);
self.$list.value(data.id, 'duration', result.data.duration);
});
}
}
});
function getHeight() {
// 24 menu + 24 toolbar + 16 statusbar + 32 title + 32 margins
// + 1px to ge trid of scrollbar
return window.innerHeight - 128 -1;
}
function getWidth() {
return window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1
- pandora.user.ui.embedSize - 1
- 32;
}
that.update = function() {
$text.options({
maxHeight: getHeight(),
width: getWidth()
});
return that;
};
return that;
};

View file

@ -20,6 +20,9 @@ pandora.ui.mainPanel = function() {
orientation: 'horizontal'
})
.bindEvent({
pandora_edit: function(data) {
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
},
pandora_find: function() {
var previousUI = pandora.UI.getPrevious();
Ox.Log('FIND', 'handled in mainPanel', previousUI.item, previousUI._list)

View file

@ -59,6 +59,8 @@ pandora.ui.rightPanel = function() {
});
} else if (pandora.user.ui.section == 'texts') {
that = pandora.$ui.textPanel = pandora.ui.textPanel();
} else if (pandora.user.ui.section == 'edits') {
that = pandora.$ui.editPanel = pandora.ui.editPanel();
}
return that;
};

View file

@ -3,8 +3,8 @@
pandora.ui.sectionButtons = function() {
var that = Ox.ButtonGroup({
buttons: [
{id: 'items', title: pandora.site.itemName.plural},
{id: 'edits', title: Ox._('Edits'), disabled: true},
{id: 'items', title: Ox._(pandora.site.itemName.plural)},
{id: 'edits', title: Ox._('Edits'), disabled: pandora.user.level != 'admin'},
{id: 'texts', title: Ox._('Texts'), disabled: pandora.user.level != 'admin'}
],
id: 'sectionButtons',

View file

@ -5,9 +5,9 @@ pandora.ui.sectionSelect = function() {
var that = Ox.Select({
id: 'sectionSelect',
items: [
{id: 'items', title: pandora.site.itemName.plural},
{id: 'edits', title: Ox._('Edits'), disabled: true},
{id: 'texts', title: Ox._('Texts'), disabled: true}
{id: 'items', title: Ox._(pandora.site.itemName.plural)},
{id: 'edits', title: Ox._('Edits'), disabled: pandora.user.level != 'admin'}
{id: 'texts', title: Ox._('Texts'), disabled: pandora.user.level != 'admin'}
],
value: pandora.user.ui.section
}).css({

View file

@ -785,6 +785,16 @@ pandora.getItem = function(state, str, callback) {
callback();
}
});
} else if (state.type == 'edits') {
pandora.api.getEdit({id: str}, function(result) {
if (result.status.code == 200) {
state.item = result.data.id;
callback();
} else {
state.item = '';
callback();
}
});
} else {
callback();
}
@ -1444,9 +1454,10 @@ pandora.selectList = function() {
});
}
} else {
var id = pandora.user.ui[pandora.user.ui.section.slice(0,-1)];
var id = pandora.user.ui[pandora.user.ui.section.slice(0,-1)],
section = Ox.toTitleCase(pandora.user.ui.section.slice(0, -1));
if (id) {
pandora.api.getText({id: id}, function(result) {
pandora.api['edit' + section]({id: id}, function(result) {
var folder;
if (result.data.id) {
folder = result.data.status == 'featured' ? 'featured' : (