fix event handlers

This commit is contained in:
rolux 2011-09-17 19:40:15 +02:00
parent 9e2f0ad404
commit 6d35c64eb1
23 changed files with 92 additions and 567 deletions

View file

@ -10,7 +10,7 @@ Ox.load('UI', {
var app = new Ox.App({ var app = new Ox.App({
apiURL: '/api/', apiURL: '/api/',
init: 'init', init: 'init',
}).bindEvent('load', function(event, data) { }).bindEvent('load', function(data) {
app.site = data.site; app.site = data.site;
app.user = data.user; app.user = data.user;
app.site.default_info = '<div class="OxSelectable"><h2>Pan.do/ra API Overview</h2>use this api in the browser with <a href="/static/oxjs/demos/doc2/index.html#Ox.App">Ox.app</a> or use <a href="http://code.0x2620.org/pandora_client">pandora_client</a> it in python. Further description of the api can be found <a href="https://wiki.0x2620.org/wiki/pandora/API">on the wiki</a></div>'; app.site.default_info = '<div class="OxSelectable"><h2>Pan.do/ra API Overview</h2>use this api in the browser with <a href="/static/oxjs/demos/doc2/index.html#Ox.App">Ox.app</a> or use <a href="http://code.0x2620.org/pandora_client">pandora_client</a> it in python. Further description of the api can be found <a href="https://wiki.0x2620.org/wiki/pandora/API">on the wiki</a></div>';
@ -116,7 +116,7 @@ function constructList() {
} }
] ]
}).bindEvent({ }).bindEvent({
select: function(event, data) { select: function(data) {
var info = $('<div>').addClass('OxSelectable'), var info = $('<div>').addClass('OxSelectable'),
hash = '#'; hash = '#';
if(data.ids.length) if(data.ids.length)

View file

@ -82,7 +82,7 @@ window.pandora = new Ox.App({url: '/api/'}).bindEvent({
}, },
flipbook: function(item) { flipbook: function(item) {
var that = Ox.Flipbook({ var that = Ox.Flipbook({
}).bindEvent('click', function(event, data) { }).bindEvent('click', function(data) {
var item_url = document.location.origin + '/' + item; var item_url = document.location.origin + '/' + item;
window.top.location.href = item_url + '/timeline#t=' + data.position; window.top.location.href = item_url + '/timeline#t=' + data.position;
}); });

View file

@ -92,6 +92,7 @@ pandora.afterLaunch.push(function() {
}); });
pandora.$ui.sections.push($section); pandora.$ui.sections.push($section);
// fixme: cleanup
pandora.local.volumes(function(data) { pandora.local.volumes(function(data) {
Ox.print("got volumes", data); Ox.print("got volumes", data);
var volumes = 0; var volumes = 0;
@ -123,14 +124,14 @@ pandora.afterLaunch.push(function() {
id: 'add_volume', id: 'add_volume',
title: 'add', title: 'add',
width: 32 width: 32
}).bindEvent('click', function(event, data) { }).bindEvent('click', function(data) {
if(_this.api.setLocation("Volume "+(volumes+1))) _this.loadVolumes(); if(_this.api.setLocation("Volume "+(volumes+1))) _this.loadVolumes();
}); });
var update_button = new Ox.Button({ var update_button = new Ox.Button({
id: 'update_archive', id: 'update_archive',
title: 'update', title: 'update',
width: 48 width: 48
}).bindEvent('click', function(event, data) { }).bindEvent('click', function(data) {
update_button.options({disabled: true}); update_button.options({disabled: true});
_this.api.update(function() { _this.api.update(function() {
update_button.options({disabled: false}); update_button.options({disabled: false});
@ -277,13 +278,13 @@ pandora.afterLaunch.push(function() {
id: 'upload_' + oshash, id: 'upload_' + oshash,
title: 'Upload', title: 'Upload',
width: 48 width: 48
}).bindEvent('click', function(fid) { return function(event, data) { }).bindEvent('click', function(fid) { return function(data) {
Ox.print(videos[fid]); Ox.print(videos[fid]);
$($('#'+fid).find('.OxCell')[1]).html(function(fid) { $($('#'+fid).find('.OxCell')[1]).html(function(fid) {
var button = new Ox.Button({ var button = new Ox.Button({
title: 'Cancel', title: 'Cancel',
width: 48 width: 48
}).bindEvent('click', function(event, data) { }).bindEvent('click', function(data) {
$.each(videos[fid], function(i, oshash) { $.each(videos[fid], function(i, oshash) {
_this.cancel(oshash); _this.cancel(oshash);
}); });

View file

@ -437,7 +437,7 @@ pandora.reloadList = function() {
$group.reloadList(); $group.reloadList();
}); });
pandora.$ui.list.bindEvent({ pandora.$ui.list.bindEvent({
init: function(event, data) { init: function(data) {
// fixme: this will not work for lists in the favorites folder // fixme: this will not work for lists in the favorites folder
// (but then it's also unlikely they'll have to be reloaded) // (but then it's also unlikely they'll have to be reloaded)
var folder = listData.status != 'featured' ? 'personal' : 'featured'; var folder = listData.status != 'featured' ? 'personal' : 'featured';
@ -445,7 +445,7 @@ pandora.reloadList = function() {
} }
}) })
.bindEventOnce({ .bindEventOnce({
load: function(event, data) { load: function(data) {
pandora.$ui.list.gainFocus(); pandora.$ui.list.gainFocus();
if (data) pandora.$ui.list.options({selected: [data.items]}); if (data) pandora.$ui.list.options({selected: [data.items]});
} }

View file

@ -351,7 +351,7 @@ Ox.FilesView = function(options, self) {
orientation: 'horizontal' orientation: 'horizontal'
}); });
function openFiles(event, data) { function openFiles(data) {
Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances'))) Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances')))
} }

View file

@ -8,7 +8,7 @@ pandora.ui.accountDialog = function(action) {
width: 432 width: 432
}, pandora.ui.accountDialogOptions(action))) }, pandora.ui.accountDialogOptions(action)))
.bindEvent({ .bindEvent({
resize: function(event, data) { resize: function(data) {
var width = data.width - 32; var width = data.width - 32;
pandora.$ui.accountForm.items.forEach(function(item) { pandora.$ui.accountForm.items.forEach(function(item) {
item.options({width: width}); item.options({width: width});
@ -171,10 +171,10 @@ pandora.ui.accountForm = function(action, value) {
} }
} }
}).bindEvent({ }).bindEvent({
submit: function(event, data) { submit: function(data) {
}, },
validate: function(event, data) { validate: function(data) {
//Ox.print('FORM VALIDATE', data) //Ox.print('FORM VALIDATE', data)
pandora.$ui.accountDialog[ pandora.$ui.accountDialog[
(data.valid ? 'enable' : 'disable') + 'Button' (data.valid ? 'enable' : 'disable') + 'Button'
@ -278,7 +278,7 @@ pandora.ui.accountForm = function(action, value) {
width: 128 width: 128
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(data) {
var selected = data.selected[0].id; var selected = data.selected[0].id;
pandora.$ui.usernameOrEmailInput.options({ pandora.$ui.usernameOrEmailInput.options({
autovalidate: selected == 'username' ? pandora.autovalidateUsername : autovalidateEmail, autovalidate: selected == 'username' ? pandora.autovalidateUsername : autovalidateEmail,

View file

@ -8,7 +8,7 @@ pandora.ui.backButton = function() {
margin: '4px' margin: '4px'
}) })
.bindEvent({ .bindEvent({
click: function(event, data) { click: function() {
pandora.URL.set(pandora.Query.toString()); pandora.URL.set(pandora.Query.toString());
} }
}); });

View file

@ -22,16 +22,16 @@ pandora.ui.browser = function() {
orientation: 'horizontal' orientation: 'horizontal'
}) })
.bindEvent({ .bindEvent({
resize: function(event, data) { resize: function(data) {
pandora.user.ui.groupsSize = data; pandora.user.ui.groupsSize = data.size;
pandora.$ui.groups.forEach(function(list) { pandora.$ui.groups.forEach(function(list) {
list.size(); list.size();
}); });
}, },
resizeend: function(event, data){ resizeend: function(data) {
pandora.UI.set({groupsSize: data}); pandora.UI.set({groupsSize: data.size});
}, },
toggle: function(event, data) { toggle: function(data) {
pandora.UI.set({showGroups: !data.collapsed}); pandora.UI.set({showGroups: !data.collapsed});
data.collapsed && pandora.$ui.list.gainFocus(); data.collapsed && pandora.$ui.list.gainFocus();
} }
@ -73,14 +73,14 @@ pandora.ui.browser = function() {
unique: 'id' unique: 'id'
}) })
.bindEvent({ .bindEvent({
open: function(event, data) { open: function() {
that.scrollToSelection(); that.scrollToSelection();
}, },
select: function(event, data) { select: function(data) {
pandora.UI.set('lists|' + pandora.user.ui.list + '|selected', data.ids); pandora.UI.set('lists|' + pandora.user.ui.list + '|selected', data.ids);
pandora.URL.set(data.ids[0]); pandora.URL.set(data.ids[0]);
}, },
toggle: function(event, data) { toggle: function(data) {
pandora.UI.set({showMovies: !data.collapsed}); pandora.UI.set({showMovies: !data.collapsed});
if (data.collapsed) { if (data.collapsed) {
if (pandora.user.ui.itemView == 'timeline') { if (pandora.user.ui.itemView == 'timeline') {

View file

@ -8,14 +8,12 @@ pandora.ui.annotations = function() {
}) })
.bindEvent({ .bindEvent({
resize: function(data) { resize: function(data) {
pandora.user.ui.annotationsSize = data; pandora.user.ui.annotationsSize = data.size;
}, },
resizeend: function(data) { resizeend: function(data) {
//alert('resizeend', JSON.stringify(data)) pandora.UI.set({annotationsSize: data.size});
pandora.UI.set({annotationsSize: data});
}, },
toggle: function(data) { toggle: function(data) {
//alert('toggle', JSON.stringify(data))
pandora.UI.set({showAnnotations: !data.collapsed}); pandora.UI.set({showAnnotations: !data.collapsed});
} }
}), }),

View file

@ -4,7 +4,7 @@ pandora.ui.findElement = function() {
findKey = pandora.user.ui.find.key, findKey = pandora.user.ui.find.key,
findValue = pandora.user.ui.find.value; findValue = pandora.user.ui.find.value;
var that = Ox.FormElementGroup({ var that = Ox.FormElementGroup({
elements: $.merge(pandora.user.ui.list ? [ elements: Ox.merge(pandora.user.ui.list ? [
pandora.$ui.findListSelect = Ox.Select({ pandora.$ui.findListSelect = Ox.Select({
items: [ items: [
{id: 'all', title: 'Find: All ' + pandora.site.itemName.plural}, {id: 'all', title: 'Find: All ' + pandora.site.itemName.plural},
@ -14,7 +14,7 @@ pandora.ui.findElement = function() {
type: 'image' type: 'image'
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(data) {
var key = data.selected[0].id; var key = data.selected[0].id;
pandora.$ui.findInput.options({ pandora.$ui.findInput.options({
autocomplete: autocompleteFunction() autocomplete: autocompleteFunction()
@ -42,7 +42,7 @@ pandora.ui.findElement = function() {
width: 112 width: 112
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(data) {
var key = data.selected[0].id; var key = data.selected[0].id;
if (key == 'advanced') { if (key == 'advanced') {
pandora.$ui.filterDialog = pandora.ui.filterDialog().open(); pandora.$ui.filterDialog = pandora.ui.filterDialog().open();

View file

@ -136,7 +136,7 @@ pandora.ui.folderBrowserList = function(id) {
] ]
}) })
.bindEvent({ .bindEvent({
click: function(event, data) { click: function(data) {
if (data.key == 'type') { if (data.key == 'type') {
alert('...'); alert('...');
} else if (data.key == 'subscribed') { } else if (data.key == 'subscribed') {
@ -162,7 +162,7 @@ pandora.ui.folderBrowserList = function(id) {
}); });
} }
}, },
init: function(event, data) { init: function(data) {
pandora.site.sectionFolders[pandora.user.ui.section][i].items = data.items; pandora.site.sectionFolders[pandora.user.ui.section][i].items = data.items;
pandora.$ui.folder[i].$content.css({ pandora.$ui.folder[i].$content.css({
height: 40 + data.items * 16 + 'px' height: 40 + data.items * 16 + 'px'
@ -172,10 +172,10 @@ pandora.ui.folderBrowserList = function(id) {
}); });
pandora.resizeFolders(); pandora.resizeFolders();
}, },
paste: function(event, data) { paste: function(data) {
pandora.$ui.list.triggerEvent('paste', data); pandora.$ui.list.triggerEvent('paste', data);
}, },
select: function(event, data) { select: function(data) {
// fixme: duplicated // fixme: duplicated
if (data.ids.length) { if (data.ids.length) {
$.each(pandora.$ui.folderList, function(id_, $list) { $.each(pandora.$ui.folderList, function(id_, $list) {
@ -190,476 +190,4 @@ pandora.ui.folderBrowserList = function(id) {
} }
}); });
return that; return that;
}; };
/*
pandora.ui.folderList = function(id) {
var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id),
that;
if (pandora.user.ui.section == 'site') {
that = Ox.TextList({
columns: [
{
format: function() {
return $('<img>')
.attr({
src: Ox.UI.PATH + 'png/icon16.png'
})
},
id: 'id',
operator: '+',
unique: true,
visible: true,
width: 16
},
{
id: 'title',
operator: '+',
visible: true,
width: pandora.user.ui.sidebarSize - 16
}
],
items: function(data, callback) {
var result = {data: {}};
if (!data.range) {
result.data.items = Ox.getObjectById(pandora.site.sectionFolders.site, id).items.length;
} else {
result.data.items = Ox.getObjectById(pandora.site.sectionFolders.site, id).items;
}
callback(result);
},
max: 1,
min: 1,
sort: [{key: '', operator: ''}]
})
.bindEvent({
select: function(event, data) {
// fixme: duplicated
$.each(pandora.$ui.folderList, function(id_, $list) {
id != id_ && $list.options('selected', []);
})
pandora.URL.set((id == 'admin' ? 'admin/' : '' ) + data.ids[0]);
},
});
} else if (pandora.user.ui.section == 'items') {
that = Ox.TextList({
columns: [
{
format: function() {
return $('<img>').attr({
src: Ox.UI.PATH + 'png/icon16.png'
});
},
id: 'user',
operator: '+',
visible: true,
width: 16
},
{
format: function(value) {
return value.split('/').join(': ');
},
id: 'id',
operator: '+',
unique: true,
visible: id == 'favorite',
width: pandora.user.ui.sidebarWidth - 88
},
{
editable: function(data) {
return data.user == pandora.user.username;
},
id: 'name',
input: {
autovalidate: pandora.ui.autovalidateListname
},
operator: '+',
visible: id != 'favorite',
width: pandora.user.ui.sidebarWidth - 88
},
{
align: 'right',
id: 'items',
operator: '-',
visible: true,
width: 40
},
{
clickable: function(data) {
return data.type == 'smart';
},
format: function(value) {
return $('<img>')
.attr({
src: Ox.UI.getImageURL('symbolFind')
})
.css({
width: '10px',
height: '10px',
padding: '3px 2px 1px 2px',
opacity: value == 'static' ? 0.1 : 1
});
},
id: 'type',
operator: '+',
visible: true,
width: 16
},
{
clickable: id == 'personal',
format: function(value) {
//var symbols = {private: 'Publish', public: 'Publish', featured: 'Star'};
return $('<img>')
.attr({
src: Ox.UI.getImageURL(
'symbol' + (value == 'featured' ? 'Star' : 'Publish')
)
})
.css({
width: '10px',
height: '10px',
padding: '3px 2px 1px 2px',
opacity: value == 'private' ? 0.1 : 1
})
},
id: 'status',
operator: '+',
visible: true,
width: 16
}
],
items: function(data, callback) {
var query;
if (id == 'personal') {
query = {conditions: [
{key: 'user', value: pandora.user.username, operator: '='},
{key: 'status', value: 'featured', operator: '!'}
], operator: '&'};
} else if (id == 'favorite') {
query = {conditions: [
{key: 'subscribed', value: true, operator: '='},
{key: 'status', value: 'featured', operator: '!'},
], operator: '&'};
} else if (id == 'featured') {
query = {conditions: [{key: 'status', value: 'featured', operator: '='}], operator: '&'};
}
return pandora.api.findLists($.extend(data, {
query: query
}), callback);
},
max: 1,
min: 0,
pageLength: 1000,
sort: [
{key: 'position', operator: '+'}
],
sortable: id == 'personal' || id == 'favorite' || pandora.user.level == 'admin'
})
.css({
left: 0,
top: 0,
width: pandora.user.ui.sidebarWidth + 'px',
})
.bind({
dragenter: function(e) {
//Ox.print('DRAGENTER', e)
}
})
.bindEvent({
click: function(event, data) {
var $list = pandora.$ui.folderList[id];
if (data.key == 'type') {
pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
} else if (data.key == 'status') {
pandora.api.editList({
id: data.id,
status: $list.value(data.id, data.key) == 'private' ? 'public' : 'private'
}, function(result) {
$list.value(result.data.id, 'status', result.data.status);
});
}
},
'delete': function(event, data) {
var $list = pandora.$ui.folderList[id];
pandora.user.ui.listQuery.conditions = [];
pandora.URL.set(pandora.Query.toString());
$list.options({selected: []});
if (id == 'personal') {
pandora.api.removeList({
id: data.ids[0]
}, function(result) {
// fixme: is this the best way to delete a ui preference?
delete pandora.user.ui.lists[data.ids[0]];
pandora.UI.set({lists: pandora.user.ui.lists});
Ox.Request.clearCache(); // fixme: remove
$list.reloadList();
});
} else if (id == 'favorite') {
pandora.api.unsubscribeFromList({
id: data.ids[0]
}, function(result) {
Ox.Request.clearCache(); // fixme: remove
$list.reloadList();
});
} else if (id == 'featured' && pandora.user.level == 'admin') {
pandora.api.editList({
id: data.ids[0],
status: 'public'
}, function(result) {
// fixme: duplicated
if (result.data.user == pandora.user.username || result.data.subscribed) {
Ox.Request.clearCache(); // fixme: remove
pandora.$ui.folderList[
result.data.user == pandora.user.username ? 'personal' : 'favorite'
].reloadList();
}
$list.reloadList();
});
}
},
init: function(event, data) {
pandora.site.sectionFolders[pandora.user.ui.section][i].items = data.items;
pandora.$ui.folder[i].$content.css({
height: data.items * 16 + 'px'
});
pandora.$ui.folderList[id].css({
height: data.items * 16 + 'px'
});
pandora.resizeFolders();
},
move: function(event, data) {
data.ids.forEach(function(id, pos) {
pandora.user.ui.lists[id].position = pos;
});
pandora.api.sortLists({
section: id,
ids: data.ids
});
},
paste: function(event, data) {
pandora.$ui.list.triggerEvent('paste', data);
},
select: function(event, data) {
if (data.ids.length) {
$.each(pandora.$ui.folderList, function(id_, $list) {
id != id_ && $list.options('selected', []);
});
pandora.URL.set('?find=list:' + data.ids[0]);
} else {
pandora.URL.set('?find=');
}
},
submit: function(event, data) {
data_ = {id: data.id};
data_[data.key] = data.value;
pandora.api.editList(data_, function(result) {
if (result.data.id != data.id) {
pandora.$ui.folderList[id].value(data.id, 'name', result.data.name);
pandora.$ui.folderList[id].value(data.id, 'id', result.data.id);
pandora.URL.set('?find=list:' + result.data.id);
}
});
}
});
}
return that;
};
pandora.ui.folders = function() {
var that = Ox.Element()
.css({overflowX: 'hidden', overflowY: 'auto'})
.bindEvent({
resize: function(event, data) {
pandora.resizeFolders();
}
});
var counter = 0;
//var $sections = [];
pandora.$ui.folder = [];
pandora.$ui.folderBrowser = {};
pandora.$ui.folderList = {};
if (pandora.user.ui.section == 'site') {
$.each(pandora.site.sectionFolders.site, function(i, folder) {
var height = (Ox.getObjectById(pandora.site.sectionFolders.site, folder.id).items.length * 16);
pandora.$ui.folder[i] = Ox.CollapsePanel({
id: folder.id,
collapsed: !pandora.user.ui.showFolder.site[folder.id],
size: 16,
title: folder.title
})
.bindEvent({
toggle: function(event, data) {
}
});
//alert(JSON.stringify(Ox.getObjectById(pandora.site.sectionFolders.site, folder.id)))
pandora.$ui.folder[i].$content.css({
height: height + 'px'
})
//.appendTo(that);
pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id)
.css({
height: height + 'px'
})
.appendTo(pandora.$ui.folder[i].$content);
pandora.$ui.folder.forEach(function($folder) {
that.append($folder);
});
});
//pandora.resizeFolders();
} else if (pandora.user.ui.section == 'items') {
$.each(pandora.site.sectionFolders.items, function(i, folder) {
var extras = [];
if (folder.id == 'personal' && pandora.user.level != 'guest') {
extras = [Ox.Select({
items: [
{ id: 'new', title: 'New List...' },
{ id: 'newfromselection', title: 'New List from Current Selection...', disabled: true },
{ id: 'newsmart', title: 'New Smart List...' },
{ id: 'newfromresults', title: 'New Smart List from Current Results...', disabled: true },
{},
{ id: 'addselection', title: 'Add Selection to List...' }
],
max: 0,
min: 0,
selectable: false,
type: 'image'
})
.bindEvent({
click: function(event, data) {
var $list = pandora.$ui.folderList[folder.id],
id;
if (data.id == 'new' || data.id == 'newsmart') {
pandora.api.addList({
name: 'Untitled',
status: 'private',
type: data.id == 'new' ? 'static' : 'smart'
}, function(result) {
id = result.data.id;
pandora.UI.set(['lists', id].join('|'), pandora.site.user.ui.lists['']); // fixme: necessary?
pandora.URL.set('?find=list:' + id)
Ox.Request.clearCache(); // fixme: remove
$list.reloadList().bindEventOnce({
load: function(event, data) {
$list.gainFocus()
.options({selected: [id]})
.editCell(id, 'name');
}
});
});
}
}
})];
} else if (folder.id == 'favorite' && pandora.user.level != 'guest') {
extras = [Ox.Button({
selectable: true,
style: 'symbol',
title: 'Edit',
tooltip: 'Manage Favorite Lists',
type: 'image'
})
.bindEvent({
change: function(event, data) {
Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser;
if (pandora.site.sectionFolders.items[i].showBrowser) {
pandora.$ui.folderList.favorite.replaceWith(
pandora.$ui.folderBrowser.favorite = pandora.ui.folderBrowser('favorite')
);
} else {
pandora.$ui.folderBrowser.favorite.replaceWith(
pandora.$ui.folderList.favorite = pandora.ui.folderList('favorite')
);
}
pandora.resizeFolders();
}
})];
} else if (folder.id == 'featured' && pandora.user.level == 'admin') {
extras = [Ox.Button({
selectable: true,
style: 'symbol',
title: 'Edit',
tooltip: 'Manage Featured Lists',
type: 'image'
})
.bindEvent({
change: function(event, data) {
Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser;
if (pandora.site.sectionFolders.items[i].showBrowser) {
pandora.$ui.folderList.featured.replaceWith(
pandora.$ui.folderBrowser.featured = pandora.ui.folderBrowser('featured'));
} else {
pandora.$ui.folderBrowser.featured.replaceWith(
pandora.$ui.folderList.featured = pandora.ui.folderList('featured')
);
}
pandora.resizeFolders();
}
})];
}
pandora.$ui.folder[i] = Ox.CollapsePanel({
id: folder.id,
collapsed: !pandora.user.ui.showFolder.items[folder.id],
extras: extras,
size: 16,
title: folder.title
})
.bindEvent({
// fixme: duplicated
click: function(event, data) {
var $list = pandora.$ui.folderList[i],
hasFocus, id;
if (data.id == 'new' || data.id == 'newsmart') {
pandora.api.addList({
name: 'Untitled',
status: 'private',
type: data.id == 'new' ? 'static' : 'smart'
}, function(result) {
id = result.data.id;
pandora.URL.set('?find=list:' + id)
Ox.Request.clearCache(); // fixme: remove
$list.reloadList().bindEventOnce({
load: function(event, data) {
$list.gainFocus()
.options({selected: [id]})
.editCell(id, 'name');
}
});
});
} else if (data.id == 'browse') {
alert('??')
//pandora.$ui.sectionList[1].replaceWith(pandora.$ui.publicLists = pandora.ui.publicLists());
//pandora.site.showAllPublicLists = true;
}
},
toggle: function(event, data) {
data.collapsed && pandora.$ui.folderList[folder.id].loseFocus();
pandora.UI.set('showFolder|items|' + folder.id, !data.collapsed);
pandora.resizeFolders();
}
});
//$sections.push(pandora.$ui.section[i]);
pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id)
.bindEventOnce({
init: function(event, data) {
Ox.print('init', i, counter)
if (++counter == 3) {
pandora.$ui.folder.forEach(function($folder) {
that.append($folder);
});
pandora.resizeFolders();
pandora.selectList(); //fixme: doesn't work
}
}
})
.appendTo(pandora.$ui.folder[i].$content);
});
}
that.toggle = function() {
}
return that;
};
*/

View file

@ -3,9 +3,7 @@ pandora.ui.folders = function() {
var that = Ox.Element() var that = Ox.Element()
.css({overflowX: 'hidden', overflowY: 'auto'}) .css({overflowX: 'hidden', overflowY: 'auto'})
.bindEvent({ .bindEvent({
resize: function(event, data) { resize: pandora.resizeFolders
pandora.resizeFolders();
}
}); });
var counter = 0; var counter = 0;
//var $sections = []; //var $sections = [];
@ -41,7 +39,7 @@ pandora.ui.folders = function() {
type: 'image' type: 'image'
}) })
.bindEvent({ .bindEvent({
click: function(event, data) { click: function(data) {
var $list = pandora.$ui.folderList[folder.id]; var $list = pandora.$ui.folderList[folder.id];
// fixme: duplicated // fixme: duplicated
if (data.id == 'new' || data.id == 'newsmart') { if (data.id == 'new' || data.id == 'newsmart') {
@ -55,7 +53,7 @@ pandora.ui.folders = function() {
pandora.URL.set('?find=list:' + id) pandora.URL.set('?find=list:' + id)
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
$list.reloadList().bindEventOnce({ $list.reloadList().bindEventOnce({
load: function(event, data) { load: function(data) {
$list.gainFocus() $list.gainFocus()
.options({selected: [id]}) .options({selected: [id]})
.editCell(id, 'name'); .editCell(id, 'name');
@ -78,7 +76,7 @@ pandora.ui.folders = function() {
type: 'image' type: 'image'
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(data) {
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser; pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser;
if (pandora.site.sectionFolders.items[i].showBrowser) { if (pandora.site.sectionFolders.items[i].showBrowser) {
@ -98,7 +96,7 @@ pandora.ui.folders = function() {
pandora.$ui.folderList.featured.options({selected: [listData.id]}); pandora.$ui.folderList.featured.options({selected: [listData.id]});
} else { } else {
// and nowhere else // and nowhere else
pandora.URL.set('?find='); pandora.URL.set('');
} }
} }
pandora.$ui.folderBrowser.favorite.replaceWith( pandora.$ui.folderBrowser.favorite.replaceWith(
@ -121,7 +119,7 @@ pandora.ui.folders = function() {
type: 'image' type: 'image'
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(data) {
var listData; var listData;
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser; pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser;
@ -149,7 +147,7 @@ pandora.ui.folders = function() {
pandora.$ui.folderList.favorite.options({selected: [listData.id]}); pandora.$ui.folderList.favorite.options({selected: [listData.id]});
} else { } else {
// and nowhere else // and nowhere else
pandora.URL.set('?find='); pandora.URL.set('');
} }
} }
pandora.$ui.folderBrowser.featured.replaceWith( pandora.$ui.folderBrowser.featured.replaceWith(
@ -192,7 +190,7 @@ pandora.ui.folders = function() {
}) })
.bindEvent({ .bindEvent({
// fixme: duplicated // fixme: duplicated
click: function(event, data) { click: function(data) {
var $list = pandora.$ui.folderList[i], var $list = pandora.$ui.folderList[i],
hasFocus, id; hasFocus, id;
if (data.id == 'new' || data.id == 'newsmart') { if (data.id == 'new' || data.id == 'newsmart') {
@ -205,7 +203,7 @@ pandora.ui.folders = function() {
pandora.URL.set('?find=list:' + id) pandora.URL.set('?find=list:' + id)
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
$list.reloadList().bindEventOnce({ $list.reloadList().bindEventOnce({
load: function(event, data) { load: function(data) {
$list.gainFocus() $list.gainFocus()
.options({selected: [id]}) .options({selected: [id]})
.editCell(id, 'name'); .editCell(id, 'name');
@ -220,7 +218,7 @@ pandora.ui.folders = function() {
*/ */
} }
}, },
toggle: function(event, data) { toggle: function(data) {
data.collapsed && pandora.$ui.folderList[folder.id].loseFocus(); data.collapsed && pandora.$ui.folderList[folder.id].loseFocus();
pandora.UI.set('showFolder|items|' + folder.id, !data.collapsed); pandora.UI.set('showFolder|items|' + folder.id, !data.collapsed);
pandora.resizeFolders(); pandora.resizeFolders();
@ -229,7 +227,7 @@ pandora.ui.folders = function() {
//$sections.push(pandora.$ui.section[i]); //$sections.push(pandora.$ui.section[i]);
pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id) pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id)
.bindEventOnce({ .bindEventOnce({
init: function(event, data) { init: function(data) {
Ox.print('init', i, counter) Ox.print('init', i, counter)
if (++counter == 4) { if (++counter == 4) {
pandora.$ui.folder.forEach(function($folder) { pandora.$ui.folder.forEach(function($folder) {

View file

@ -255,7 +255,7 @@ pandora.ui.folderList = function(id) {
pandora.URL.set('?find=list:' + id) pandora.URL.set('?find=list:' + id)
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
that.reloadList().bindEventOnce({ that.reloadList().bindEventOnce({
load: function(event, data) { load: function(data) {
that.gainFocus() that.gainFocus()
.options({selected: [id]}) .options({selected: [id]})
.editCell(id, 'name'); .editCell(id, 'name');
@ -278,7 +278,7 @@ pandora.ui.folderList = function(id) {
*/ */
} }
}, },
click: function(event, data) { click: function(data) {
var $list = pandora.$ui.folderList[id]; var $list = pandora.$ui.folderList[id];
if (data.key == 'type') { if (data.key == 'type') {
pandora.$ui.filterDialog = pandora.ui.filterDialog().open(); pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
@ -295,7 +295,7 @@ pandora.ui.folderList = function(id) {
alert(JSON.stringify(data)); alert(JSON.stringify(data));
} }
}, },
'delete': function(event, data) { 'delete': function(data) {
// fixme: add a confirmation dialog // fixme: add a confirmation dialog
var $list = pandora.$ui.folderList[id]; var $list = pandora.$ui.folderList[id];
pandora.URL.set('?find='); pandora.URL.set('?find=');
@ -331,7 +331,7 @@ pandora.ui.folderList = function(id) {
}); });
} }
}, },
init: function(event, data) { init: function(data) {
pandora.site.sectionFolders[pandora.user.ui.section][i].items = data.items; pandora.site.sectionFolders[pandora.user.ui.section][i].items = data.items;
pandora.$ui.folder[i].$content.css({ pandora.$ui.folder[i].$content.css({
height: data.items * 16 + 'px' height: data.items * 16 + 'px'
@ -341,7 +341,7 @@ pandora.ui.folderList = function(id) {
}); });
pandora.resizeFolders(); pandora.resizeFolders();
}, },
move: function(event, data) { move: function(data) {
/* /*
data.ids.forEach(function(id, pos) { data.ids.forEach(function(id, pos) {
pandora.user.ui.lists[id].position = pos; pandora.user.ui.lists[id].position = pos;
@ -352,10 +352,10 @@ pandora.ui.folderList = function(id) {
ids: data.ids ids: data.ids
}); });
}, },
paste: function(event, data) { paste: function(data) {
pandora.$ui.list.triggerEvent('paste', data); pandora.$ui.list.triggerEvent('paste', data);
}, },
select: function(event, data) { select: function(data) {
if (data.ids.length) { if (data.ids.length) {
Ox.forEach(pandora.$ui.folderList, function($list, id_) { Ox.forEach(pandora.$ui.folderList, function($list, id_) {
id != id_ && $list.options('selected', []); id != id_ && $list.options('selected', []);
@ -366,7 +366,7 @@ pandora.ui.folderList = function(id) {
pandora.URL.set(''); pandora.URL.set('');
} }
}, },
submit: function(event, data) { submit: function(data) {
data_ = {id: data.id}; data_ = {id: data.id};
data_[data.key] = data.value; data_[data.key] = data.value;
pandora.api.editList(data_, function(result) { pandora.api.editList(data_, function(result) {

View file

@ -74,10 +74,10 @@ pandora.ui.group = function(id) {
}] }]
}) })
.bindEvent({ .bindEvent({
paste: function(event, data) { paste: function(data) {
pandora.$ui.list.triggerEvent('paste', data); pandora.$ui.list.triggerEvent('paste', data);
}, },
select: function(event, data) { select: function(data) {
var conditions = data.ids.map(function(value) { var conditions = data.ids.map(function(value) {
return { return {
key: id, key: id,
@ -138,7 +138,7 @@ pandora.ui.group = function(id) {
min: 1, min: 1,
type: 'image' type: 'image'
}) })
.bindEvent('change', function(event, data) { .bindEvent('change', function(data) {
var id_ = data.selected[0].id, var id_ = data.selected[0].id,
i_ = pandora.user.ui.groups.indexOf(id_); i_ = pandora.user.ui.groups.indexOf(id_);
if (i_ == -1) { if (i_ == -1) {

View file

@ -35,8 +35,7 @@ pandora.ui.homePage = function() {
// fixme: duplicated // fixme: duplicated
$select = Ox.Select({ $select = Ox.Select({
id: 'select', id: 'select',
items: $.merge($.map(pandora.site.findKeys, items: Ox.merge(pandora.site.findKeys.map(function(key) {
function(key, i) {
return { return {
id: key.id, id: key.id,
title: 'Find: ' + key.title title: 'Find: ' + key.title

View file

@ -118,7 +118,7 @@ pandora.ui.item = function() {
sort: pandora.user.ui.lists[pandora.user.ui.list].sort, sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
unique: 'id' unique: 'id'
}).bindEvent({ }).bindEvent({
open: function(event, data) { open: function(data) {
var id = data.ids[0], var id = data.ids[0],
item = pandora.user.ui.item, item = pandora.user.ui.item,
points = { points = {
@ -156,7 +156,8 @@ pandora.ui.item = function() {
title: 'Save', title: 'Save',
type: 'text' type: 'text'
}).bindEvent({ }).bindEvent({
click: function(event, data) { click: function(data) {
// fixme: cleanup
var values = $form.value(); var values = $form.value();
var changed = {}; var changed = {};
Ox.map(pandora.site.itemKeys, function(key, i) { Ox.map(pandora.site.itemKeys, function(key, i) {
@ -259,7 +260,7 @@ pandora.ui.item = function() {
sort: pandora.user.ui.lists[pandora.user.ui.list].sort, sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
unique: 'id' unique: 'id'
}).bindEvent({ }).bindEvent({
open: function(event, data) { open: function(data) {
var id = data.ids[0], var id = data.ids[0],
item = pandora.user.ui.item, item = pandora.user.ui.item,
points = { points = {
@ -405,13 +406,13 @@ pandora.ui.item = function() {
position: function(data) { position: function(data) {
pandora.UI.set('videoPoints|' + pandora.user.ui.item + '|position', data.position); pandora.UI.set('videoPoints|' + pandora.user.ui.item + '|position', data.position);
}, },
resize: function(event, data) { resize: function(data) {
pandora.$ui.editor.options({ pandora.$ui.editor.options({
height: data height: data.size
}); });
}, },
resizeend: function(data) { resizeend: function(data) {
pandora.UI.set({annotationsSize: data}); pandora.UI.set({annotationsSize: data.size});
}, },
togglesize: function(data) { togglesize: function(data) {
pandora.UI.set({videoSize: data.size}); pandora.UI.set({videoSize: data.size});
@ -441,14 +442,14 @@ pandora.ui.item = function() {
}); });
} }
})); }));
that.bindEvent('resize', function(event, data) { that.bindEvent('resize', function(data) {
//Ox.print('resize item', data) //Ox.print('resize item', data)
pandora.$ui.editor.options({ pandora.$ui.editor.options({
height: data height: data.size
}); });
}); });
/* /*
pandora.$ui.rightPanel.bindEvent('resize', function(event, data) { pandora.$ui.rightPanel.bindEvent('resize', function(data) {
Ox.print('... rightPanel resize', data, pandora.$ui.timelinePanel.size(1)) Ox.print('... rightPanel resize', data, pandora.$ui.timelinePanel.size(1))
pandora.$ui.editor.options({ pandora.$ui.editor.options({
width: data - pandora.$ui.timelinePanel.size(1) - 1 width: data - pandora.$ui.timelinePanel.size(1) - 1

View file

@ -21,15 +21,15 @@ pandora.ui.leftPanel = function() {
orientation: 'vertical' orientation: 'vertical'
}) })
.bindEvent({ .bindEvent({
resize: function(event, data) { resize: function(data) {
Ox.print('LEFT PANEL RESIZE') Ox.print('LEFT PANEL RESIZE')
var infoSize = Math.round(data / pandora.user.infoRatio); var infoSize = Math.round(data.size / pandora.user.infoRatio);
pandora.UI.set('sidebarSize', data); pandora.UI.set('sidebarSize', data.size);
if (data < pandora.site.sectionButtonsWidth && pandora.$ui.sectionButtons) { if (data.size < pandora.site.sectionButtonsWidth && pandora.$ui.sectionButtons) {
pandora.$ui.sectionButtons.removeElement(); pandora.$ui.sectionButtons.removeElement();
delete pandora.$ui.sectionButtons; delete pandora.$ui.sectionButtons;
pandora.$ui.sectionbar.append(pandora.$ui.sectionSelect = pandora.ui.sectionSelect()); pandora.$ui.sectionbar.append(pandora.$ui.sectionSelect = pandora.ui.sectionSelect());
} else if (data >= pandora.site.sectionButtonsWidth && pandora.$ui.sectionSelect) { } else if (data.size >= pandora.site.sectionButtonsWidth && pandora.$ui.sectionSelect) {
pandora.$ui.sectionSelect.removeElement(); pandora.$ui.sectionSelect.removeElement();
delete pandora.$ui.sectionSelect; delete pandora.$ui.sectionSelect;
pandora.$ui.sectionbar.append(pandora.$ui.sectionButtons = pandora.ui.sectionButtons()); pandora.$ui.sectionbar.append(pandora.$ui.sectionButtons = pandora.ui.sectionButtons());
@ -38,14 +38,14 @@ pandora.ui.leftPanel = function() {
pandora.$ui.leftPanel.size(2, infoSize); pandora.$ui.leftPanel.size(2, infoSize);
pandora.$ui.videoPreview && pandora.$ui.videoPreview.options({ pandora.$ui.videoPreview && pandora.$ui.videoPreview.options({
frameHeight: infoSize - 16, frameHeight: infoSize - 16,
frameWidth: data frameWidth: data.size
}); });
pandora.resizeFolders(); pandora.resizeFolders();
}, },
resizeend: function(event, data) { resizeend: function(data) {
pandora.UI.set({sidebarSize: data}); pandora.UI.set({sidebarSize: data.size});
}, },
toggle: function(event, data) { toggle: function(data) {
pandora.UI.set({showSidebar: !data.collapsed}); pandora.UI.set({showSidebar: !data.collapsed});
if (data.collapsed) { if (data.collapsed) {
$.each(pandora.$ui.folderList, function(k, $list) { $.each(pandora.$ui.folderList, function(k, $list) {

View file

@ -7,7 +7,7 @@ pandora.ui.list = function() { // fixme: remove view argument
//Ox.print('constructList', view); //Ox.print('constructList', view);
if (view == 'list') { if (view == 'list') {
/* /*
keys = Ox.unique($.merge( keys = Ox.unique(Ox.merge(
$.map(pandora.user.ui.lists[pandora.user.ui.list].columns, function(id) { $.map(pandora.user.ui.lists[pandora.user.ui.list].columns, function(id) {
return Ox.getObjectById(pandora.site.sortKeys, id); return Ox.getObjectById(pandora.site.sortKeys, id);
}), }),
@ -514,7 +514,7 @@ pandora.ui.list = function() { // fixme: remove view argument
], ],
orientation: 'horizontal' orientation: 'horizontal'
}) })
.bindEvent('resize', function() { .bindEvent('resize', function(data) {
}); });
} else { } else {
@ -611,10 +611,10 @@ pandora.ui.list = function() { // fixme: remove view argument
that.closePreview(); that.closePreview();
preview = false; preview = false;
}, },
resize: function(event) { resize: function(data) {
pandora.$ui.previewImage.css({ pandora.$ui.previewImage.css({
width: event.width + 'px', width: data.width + 'px',
height: event.height + 'px' height: data.height + 'px'
}); });
} }
}) })

View file

@ -167,7 +167,7 @@ pandora.ui.mainMenu = function() {
] ]
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(data) {
var value = data.checked[0].id; var value = data.checked[0].id;
if (data.id == 'find') { if (data.id == 'find') {
pandora.$ui.findSelect.options({value: value}); pandora.$ui.findSelect.options({value: value});
@ -224,7 +224,7 @@ pandora.ui.mainMenu = function() {
//pandora.URL.set('/' + value + '/' + document.location.search); //pandora.URL.set('/' + value + '/' + document.location.search);
} }
}, },
click: function(event, data) { click: function(data) {
if (data.id == 'home') { if (data.id == 'home') {
pandora.$ui.home = pandora.ui.home().fadeInScreen(); pandora.$ui.home = pandora.ui.home().fadeInScreen();
pandora.URL.push('home'); pandora.URL.push('home');
@ -274,7 +274,7 @@ pandora.ui.mainMenu = function() {
type: 'image' type: 'image'
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(data) {
pandora.$ui.findPlacesSelect.loseFocus(); pandora.$ui.findPlacesSelect.loseFocus();
pandora.$ui.findPlacesInput.options({ pandora.$ui.findPlacesInput.options({
placeholder: data.selected[0].title placeholder: data.selected[0].title
@ -364,7 +364,7 @@ pandora.ui.mainMenu = function() {
margin: '4px' margin: '4px'
}) })
.bindEvent({ .bindEvent({
submit: function(event, data) { submit: function(data) {
pandora.$ui.map.find(data.value, function(location) { pandora.$ui.map.find(data.value, function(location) {
pandora.$ui.placeNameInput.options({ pandora.$ui.placeNameInput.options({

View file

@ -35,13 +35,13 @@ pandora.ui.rightPanel = function() {
orientation: 'vertical' orientation: 'vertical'
}) })
.bindEvent({ .bindEvent({
resize: function(event, data) { resize: function(data) {
if (!pandora.user.ui.item) { if (!pandora.user.ui.item) {
pandora.resizeGroups(); pandora.resizeGroups();
pandora.$ui.list.size(); pandora.$ui.list.size();
if (pandora.user.ui.lists[pandora.user.ui.list].listView == 'timelines') { if (pandora.user.ui.lists[pandora.user.ui.list].listView == 'timelines') {
pandora.$ui.list.options({ pandora.$ui.list.options({
width: data width: data.size
}); });
} else if (pandora.user.ui.lists[pandora.user.ui.list].listView == 'map') { } else if (pandora.user.ui.lists[pandora.user.ui.list].listView == 'map') {
pandora.$ui.map.resizeMap(); pandora.$ui.map.resizeMap();
@ -49,10 +49,10 @@ pandora.ui.rightPanel = function() {
} else { } else {
pandora.$ui.browser.scrollToSelection(); pandora.$ui.browser.scrollToSelection();
pandora.user.ui.itemView == 'player' && pandora.$ui.player.options({ pandora.user.ui.itemView == 'player' && pandora.$ui.player.options({
width: data width: data.size
}); });
pandora.user.ui.itemView == 'timeline' && pandora.$ui.editor.options({ pandora.user.ui.itemView == 'timeline' && pandora.$ui.editor.options({
width: data width: data.size
}); });
} }
} }

View file

@ -13,7 +13,7 @@ pandora.ui.sectionButtons = function() {
margin: '4px' margin: '4px'
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(data) {
var section = data.selected[0]; var section = data.selected[0];
if (section == 'items') { if (section == 'items') {
pandora.URL.set(pandora.Query.toString()); pandora.URL.set(pandora.Query.toString());

View file

@ -16,7 +16,7 @@ pandora.ui.sortSelect = function() {
margin: '4px 0 0 4px' margin: '4px 0 0 4px'
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(data) {
var key = data.selected[0].id, var key = data.selected[0].id,
operator = pandora.getSortOperator(key); operator = pandora.getSortOperator(key);
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + key); pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + key);

View file

@ -27,7 +27,7 @@ pandora.ui.viewSelect = function() {
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list()); pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
pandora.URL.push('/' + view + '/' + document.location.search); pandora.URL.push('/' + view + '/' + document.location.search);
// pandora.URL.set('/' + view + '/' + document.location.search); // pandora.URL.set('/' + view + '/' + document.location.search);
} : function(event, data) { } : function(data) {
var view = data.selected[0].id; var view = data.selected[0].id;
//pandora.UI.set({itemView: id}); //pandora.UI.set({itemView: id});
pandora.URL.set(pandora.user.ui.item + '/' + view); pandora.URL.set(pandora.user.ui.item + '/' + view);