2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-06-16 20:00:10 +00:00
|
|
|
|
2011-09-04 12:43:59 +00:00
|
|
|
pandora.enableDragAndDrop = function($list, canMove) {
|
|
|
|
|
2011-09-05 02:20:38 +00:00
|
|
|
var $tooltip = Ox.Tooltip({
|
2011-09-04 12:43:59 +00:00
|
|
|
animate: false
|
2011-09-05 02:20:38 +00:00
|
|
|
}),
|
|
|
|
drag = {},
|
|
|
|
scrollInterval;
|
2011-09-04 12:43:59 +00:00
|
|
|
|
|
|
|
$list.bindEvent({
|
|
|
|
draganddropstart: function(data) {
|
|
|
|
drag.action = 'copy';
|
|
|
|
drag.ids = $list.options('selected'),
|
|
|
|
drag.item = drag.ids.length == 1
|
|
|
|
? $list.value(drag.ids[0], 'title')
|
|
|
|
: drag.ids.length;
|
|
|
|
drag.source = pandora.getListData(),
|
|
|
|
drag.targets = {};
|
|
|
|
Ox.forEach(pandora.$ui.folderList, function($list) {
|
|
|
|
$list.addClass('OxDroppable').find('.OxItem').each(function() {
|
|
|
|
var $item = $(this),
|
|
|
|
id = $item.data('id'),
|
|
|
|
data = $list.value(id);
|
|
|
|
drag.targets[id] = Ox.extend({
|
|
|
|
editable: data.user == pandora.user.username
|
|
|
|
&& data.type == 'static',
|
|
|
|
selected: $item.is('.OxSelected')
|
|
|
|
}, data);
|
|
|
|
if (!drag.targets[id].selected && drag.targets[id].editable) {
|
|
|
|
$item.addClass('OxDroppable');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$tooltip.options({
|
|
|
|
title: getTitle(data._event)
|
|
|
|
}).show(data._event);
|
|
|
|
canMove && Ox.UI.$window.bind({
|
|
|
|
keydown: keydown,
|
|
|
|
keyup: keyup
|
|
|
|
});
|
|
|
|
},
|
|
|
|
draganddrop: function(data) {
|
2011-09-05 02:20:38 +00:00
|
|
|
var event = data._event;
|
2011-09-04 12:43:59 +00:00
|
|
|
$tooltip.options({
|
2011-09-05 02:20:38 +00:00
|
|
|
title: getTitle(event)
|
|
|
|
}).show(event);
|
|
|
|
if (scrollInterval && !isAtListsTop(event) && !isAtListsBottom(event)) {
|
|
|
|
clearInterval(scrollInterval);
|
|
|
|
scrollInterval = 0;
|
|
|
|
}
|
2011-09-04 12:43:59 +00:00
|
|
|
},
|
2011-09-04 22:06:14 +00:00
|
|
|
draganddroppause: function(data) {
|
2011-09-05 02:20:38 +00:00
|
|
|
var event = data._event, scroll,
|
2011-09-05 01:30:05 +00:00
|
|
|
$parent, $grandparent, $panel, $bar, title;
|
2011-09-05 02:20:38 +00:00
|
|
|
// fixme: should be named showLists in the user ui prefs!
|
|
|
|
if (!pandora.user.ui.showSidebar) {
|
|
|
|
if (event.clientX < 16 && event.clientY >= 44
|
|
|
|
&& event.clientY < window.innerHeight - 16
|
|
|
|
) {
|
|
|
|
pandora.$ui.mainPanel.toggle(0);
|
|
|
|
}
|
2011-09-05 01:30:05 +00:00
|
|
|
} else {
|
2011-09-05 02:20:38 +00:00
|
|
|
$parent = $(event.target).parent();
|
2011-09-05 01:30:05 +00:00
|
|
|
$grandparent = $parent.parent();
|
2011-09-04 22:06:14 +00:00
|
|
|
$panel = $parent.is('.OxCollapsePanel') ? $parent
|
2011-09-05 01:30:05 +00:00
|
|
|
: $grandparent.is('.OxCollapsePanel') ? $grandparent : null;
|
|
|
|
if ($panel) {
|
|
|
|
$bar = $panel.children('.OxBar');
|
|
|
|
title = $bar.children('.OxTitle')
|
|
|
|
.html().split(' ')[0].toLowerCase();
|
|
|
|
!pandora.user.ui.showFolder.items[title] && $bar.trigger('dblclick');
|
|
|
|
}
|
2011-09-05 02:20:38 +00:00
|
|
|
if (!scrollInterval) {
|
|
|
|
scroll = isAtListsTop(event) ? -16
|
|
|
|
: isAtListsBottom(event) ? 16 : 0
|
|
|
|
if (scroll) {
|
|
|
|
scrollInterval = setInterval(function() {
|
|
|
|
pandora.$ui.folders.$element.scrollTop(
|
|
|
|
pandora.$ui.folders.$element.scrollTop() + scroll
|
|
|
|
);
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
}
|
2011-09-04 22:06:14 +00:00
|
|
|
}
|
|
|
|
},
|
2011-09-04 12:43:59 +00:00
|
|
|
draganddropenter: function(data) {
|
|
|
|
var $parent = $(data._event.target).parent(),
|
|
|
|
$item = $parent.is('.OxItem') ? $parent : $parent.parent(),
|
|
|
|
$list = $item.parent().parent().parent().parent();
|
|
|
|
if ($list.is('.OxDroppable')) {
|
|
|
|
$item.addClass('OxDrop');
|
|
|
|
drag.target = drag.targets[$item.data('id')];
|
|
|
|
} else {
|
|
|
|
drag.target = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
draganddropleave: function(data) {
|
|
|
|
var $parent = $(data._event.target).parent(),
|
|
|
|
$item = $parent.is('.OxItem') ? $parent : $parent.parent();
|
|
|
|
if ($item.is('.OxDroppable')) {
|
|
|
|
$item.removeClass('OxDrop');
|
|
|
|
drag.target = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
draganddropend: function(data) {
|
|
|
|
Ox.print(data, drag, '------------');
|
|
|
|
canMove && Ox.UI.$window.unbind({
|
|
|
|
keydown: keydown,
|
|
|
|
keyup: keyup
|
|
|
|
});
|
|
|
|
if (drag.target && drag.target.editable && !drag.target.selected) {
|
|
|
|
if (drag.action == 'copy' || (
|
|
|
|
drag.action == 'move' && drag.source.editable
|
|
|
|
)) {
|
|
|
|
if (drag.action == 'move') {
|
|
|
|
pandora.api.removeListItems({
|
|
|
|
list: pandora.user.ui.list,
|
|
|
|
items: data.ids
|
|
|
|
}, pandora.reloadList);
|
|
|
|
}
|
|
|
|
pandora.api.addListItems({
|
|
|
|
list: drag.target.id,
|
|
|
|
items: data.ids
|
|
|
|
}, function() {
|
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
|
|
|
pandora.api.find({
|
|
|
|
query: {
|
|
|
|
conditions: [{key: 'list', value: drag.target.id, operator: '='}],
|
|
|
|
operator: ''
|
|
|
|
}
|
|
|
|
}, function(result) {
|
|
|
|
var folder = drag.target.status != 'featured' ? 'personal' : 'featured';
|
|
|
|
//Ox.print(drag.source.status, '//////', drag.target.status)
|
|
|
|
pandora.$ui.folderList[folder].value(
|
|
|
|
drag.target.id, 'items',
|
|
|
|
result.data.items
|
|
|
|
);
|
|
|
|
cleanup(250);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cleanup(0);
|
|
|
|
}
|
|
|
|
function cleanup(ms) {
|
|
|
|
drag = {};
|
2011-09-05 02:20:38 +00:00
|
|
|
clearInterval(scrollInterval);
|
|
|
|
scrollInterval = 0;
|
2011-09-04 12:43:59 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
$('.OxDroppable').removeClass('OxDroppable');
|
|
|
|
$('.OxDrop').removeClass('OxDrop');
|
|
|
|
$tooltip.hide();
|
|
|
|
}, ms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function getTitle(e) {
|
|
|
|
var image, text;
|
|
|
|
if (drag.action == 'move' && drag.source.user != pandora.user.username) {
|
|
|
|
image = 'symbolClose'
|
|
|
|
text = 'You can only remove ' + pandora.site.itemName.plural.toLowerCase()
|
|
|
|
+ '<br/>from your own lists.';
|
|
|
|
} else if (drag.action == 'move' && drag.source.type == 'smart') {
|
|
|
|
image = 'symbolClose';
|
|
|
|
text = 'You can\'t remove ' + pandora.site.itemName.plural.toLowerCase()
|
|
|
|
+ '<br/>from smart lists.';
|
|
|
|
} else if (drag.target && drag.target.user != pandora.user.username) {
|
|
|
|
image = 'symbolClose'
|
|
|
|
text = 'You can only ' + drag.action + ' ' + pandora.site.itemName.plural.toLowerCase()
|
|
|
|
+ '<br/>to your own lists';
|
|
|
|
} else if (drag.target && drag.target.type == 'smart') {
|
|
|
|
image = 'symbolClose'
|
|
|
|
text = 'You can\'t ' + drag.action + ' ' + pandora.site.itemName.plural.toLowerCase()
|
|
|
|
+ '<br/>to smart lists';
|
|
|
|
} else {
|
|
|
|
image = drag.action == 'copy' ? 'symbolAdd' : 'symbolRemove';
|
|
|
|
text = Ox.toTitleCase(drag.action) + ' ' + (
|
|
|
|
Ox.isString(drag.item)
|
|
|
|
? '"' + drag.item + '"'
|
|
|
|
: drag.item + ' ' + pandora.site.itemName[
|
|
|
|
drag.item == 1 ? 'singular' : 'plural'
|
|
|
|
].toLowerCase()
|
|
|
|
) + '</br> to ' + (
|
|
|
|
drag.target && !drag.target.selected
|
|
|
|
? 'the list "' + drag.target.name + '"'
|
|
|
|
: 'another list'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return $('<div>')
|
|
|
|
.append(
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: '16px',
|
|
|
|
height: '16px',
|
|
|
|
padding: '2px',
|
|
|
|
border: '2px solid rgb(192, 192, 192)',
|
|
|
|
borderRadius: '12px',
|
|
|
|
margin: '3px 2px 2px 2px'
|
|
|
|
})
|
|
|
|
.append(
|
|
|
|
$('<img>')
|
|
|
|
.attr({src: Ox.UI.getImageURL(image)})
|
|
|
|
.css({width: '16px', height: '16px'})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.append(
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
margin: '1px 2px 2px 2px',
|
|
|
|
fontSize: '11px',
|
|
|
|
whiteSpace: 'nowrap'
|
|
|
|
})
|
|
|
|
.html(text)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2011-09-05 02:20:38 +00:00
|
|
|
function isAtListsTop(e) {
|
|
|
|
return pandora.user.ui.showSidebar
|
|
|
|
&& e.clientX < pandora.user.ui.sidebarSize
|
|
|
|
&& e.clientY >= 44 && e.clientY < 60;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isAtListsBottom(e) {
|
|
|
|
var listsBottom = window.innerHeight - pandora.getInfoHeight();
|
|
|
|
return pandora.user.ui.showSidebar
|
|
|
|
&& e.clientX < pandora.user.ui.sidebarSize
|
|
|
|
&& e.clientY >= listsBottom - 16 && e.clientY < listsBottom;
|
|
|
|
}
|
|
|
|
|
2011-09-04 12:43:59 +00:00
|
|
|
function keydown(e) {
|
|
|
|
if (e.metaKey) {
|
|
|
|
drag.action = 'move';
|
|
|
|
$tooltip.options({title: getTitle()}).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function keyup(e) {
|
|
|
|
if (drag.action == 'move') {
|
|
|
|
drag.action = 'copy';
|
|
|
|
$tooltip.options({title: getTitle()}).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.enterFullscreen = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.appPanel.size(0, 0);
|
|
|
|
pandora.user.ui.showSidebar && pandora.$ui.mainPanel.size(0, 0);
|
|
|
|
pandora.$ui.rightPanel.size(0, 0).size(2, 0);
|
|
|
|
!pandora.user.ui.showMovies && pandora.$ui.contentPanel.css({
|
2011-05-25 19:42:45 +00:00
|
|
|
top: (-112 - Ox.UI.SCROLLBAR_SIZE) + 'px' // fixme: rightPanel.size(0, 0) doesn't preserve negative top of browser
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user.ui.showMovies && pandora.$ui.contentPanel.size(0, 0);
|
|
|
|
pandora.$ui.player.options({
|
|
|
|
height: pandora.$document.height() - 2,
|
|
|
|
width: pandora.$document.width() - 2
|
2011-06-16 20:00:10 +00:00
|
|
|
});
|
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.exitFullscreen = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.appPanel.size(0, 20);
|
|
|
|
pandora.user.ui.showSidebar && pandora.$ui.mainPanel.size(0, pandora.user.ui.sidebarSize);
|
|
|
|
pandora.$ui.rightPanel.size(0, 24).size(2, 16);
|
|
|
|
!pandora.user.ui.showMovies && pandora.$ui.contentPanel.css({
|
2011-05-25 19:42:45 +00:00
|
|
|
top: 24 + (-112 - Ox.UI.SCROLLBAR_SIZE) + 'px' // fixme: rightPanel.size(0, 0) doesn't preserve negative top of browser
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user.ui.showMovies && pandora.$ui.contentPanel.size(0, 112 + Ox.UI.SCROLLBAR_SIZE);
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.getFoldersHeight = function() {
|
2011-09-01 04:46:44 +00:00
|
|
|
var height = 0;
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.site.sectionFolders[pandora.user.ui.section].forEach(function(folder, i) {
|
2011-09-01 04:46:44 +00:00
|
|
|
height += 16 + pandora.user.ui.showFolder[pandora.user.ui.section][folder.id] * (
|
2011-05-25 19:42:45 +00:00
|
|
|
!!folder.showBrowser * 40 + folder.items * 16
|
|
|
|
);
|
2011-09-05 02:20:38 +00:00
|
|
|
// // // Ox.print('h', height);
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
/*
|
2011-06-06 15:48:11 +00:00
|
|
|
$.each(pandora.user.ui.showFolder[pandora.user.ui.section], function(id, show) {
|
|
|
|
var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id);
|
2011-05-25 19:42:45 +00:00
|
|
|
height += show * (
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.site.sectionFolders[pandora.user.ui.section][i].showBrowser * 40 +
|
|
|
|
pandora.site.sectionFolders[pandora.user.ui.section][i].items * 16
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
return height;
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.getFoldersWidth = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
var width = pandora.user.ui.sidebarSize;
|
2011-05-25 19:42:45 +00:00
|
|
|
// fixme: don't use height(), look up in splitpanels
|
2011-09-05 02:20:38 +00:00
|
|
|
// // // Ox.print(pandora.getFoldersHeight(), '>', pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height());
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.getFoldersHeight() > pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height()) {
|
2011-05-25 19:42:45 +00:00
|
|
|
width -= Ox.UI.SCROLLBAR_SIZE;
|
|
|
|
}
|
|
|
|
return width;
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
2011-08-24 06:19:34 +00:00
|
|
|
pandora.getGroupsSizes = function() {
|
|
|
|
return Ox.divideInt(
|
|
|
|
window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1, 5
|
|
|
|
)
|
|
|
|
};
|
|
|
|
|
2011-09-05 02:20:38 +00:00
|
|
|
pandora.getInfoHeight = function() {
|
|
|
|
// fixme: new, check if it can be used more
|
|
|
|
return pandora.user.ui.showInfo * pandora.user.ui.sidebarSize / pandora.user.infoRatio;
|
|
|
|
}
|
|
|
|
|
2011-08-24 06:19:34 +00:00
|
|
|
pandora.getListData = function() {
|
2011-08-28 19:50:38 +00:00
|
|
|
var data = {}, folder;
|
2011-08-24 06:19:34 +00:00
|
|
|
if (pandora.user.ui.list) {
|
2011-08-28 19:50:38 +00:00
|
|
|
Ox.forEach(pandora.$ui.folderList, function(list, key) {
|
|
|
|
if (list.options('selected').length) {
|
|
|
|
folder = key;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2011-09-04 16:08:28 +00:00
|
|
|
// the one case where folder is undefinded is when on page load
|
|
|
|
// the folderLists call getListData to determine which list is selected
|
|
|
|
if (folder) {
|
2011-09-05 02:20:38 +00:00
|
|
|
//Ox.print('gLD f', folder)
|
2011-09-04 16:08:28 +00:00
|
|
|
data = pandora.$ui.folderList[folder].value(pandora.user.ui.list);
|
|
|
|
data.editable = data.user == pandora.user.username && data.type == 'static';
|
|
|
|
data.folder = folder;
|
|
|
|
}
|
2011-08-24 06:19:34 +00:00
|
|
|
}
|
|
|
|
return data;
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.getSortOperator = function(key) { // fixme: make static
|
2011-06-06 15:48:11 +00:00
|
|
|
var type = Ox.getObjectById(pandora.site.itemKeys, key).type;
|
2011-05-25 19:42:45 +00:00
|
|
|
return ['hue', 'string', 'text'].indexOf(
|
|
|
|
Ox.isArray(type) ? type[0] : type
|
|
|
|
) > -1 ? '+' : '-';
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
2011-08-24 06:19:34 +00:00
|
|
|
pandora.getVideoPartsAndPoints = function(durations, points) {
|
|
|
|
var parts = durations.length,
|
|
|
|
offsets = Ox.range(parts).map(function(i) {
|
|
|
|
return Ox.sum(Ox.sub(durations, 0, i));
|
|
|
|
}),
|
|
|
|
ret = {
|
|
|
|
parts: [],
|
|
|
|
points: []
|
|
|
|
};
|
|
|
|
points.forEach(function(point, i) {
|
|
|
|
Ox.loop(parts - 1, -1, -1, function(i) {
|
|
|
|
if (offsets[i] <= point) {
|
|
|
|
ret.parts[i] = i;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
ret.parts = Ox.unique(ret.parts);
|
|
|
|
ret.points = points.map(function(point) {
|
|
|
|
return point - offsets[ret.parts[0]];
|
|
|
|
});
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
2011-08-24 21:04:13 +00:00
|
|
|
pandora.signin = function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user = data.user;
|
2011-08-24 16:42:55 +00:00
|
|
|
pandora.Query.updateGroups();
|
2011-06-06 15:48:11 +00:00
|
|
|
Ox.Theme(pandora.user.ui.theme);
|
|
|
|
pandora.$ui.appPanel.reload();
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
2011-08-24 21:04:13 +00:00
|
|
|
pandora.signout = function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user = data.user;
|
2011-08-24 16:42:55 +00:00
|
|
|
pandora.Query.updateGroups();
|
2011-06-06 15:48:11 +00:00
|
|
|
Ox.Theme(pandora.site.user.ui.theme);
|
|
|
|
pandora.$ui.appPanel.reload();
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.reloadGroups = function(i) {
|
2011-08-24 06:19:34 +00:00
|
|
|
var query = pandora.user.ui.query,
|
2011-06-16 20:00:10 +00:00
|
|
|
view = pandora.user.ui.lists[pandora.user.ui.list].listView;
|
2011-08-24 06:19:34 +00:00
|
|
|
if (view == 'clip') {
|
2011-06-16 20:00:10 +00:00
|
|
|
pandora.$ui.list.options({
|
|
|
|
items: function(data, callback) {
|
2011-08-24 06:19:34 +00:00
|
|
|
return pandora.api.findAnnotations(Ox.extend(data, {
|
2011-06-16 20:00:10 +00:00
|
|
|
itemQuery: query
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (view == 'map') {
|
2011-06-18 18:48:49 +00:00
|
|
|
pandora.$ui.map.options({
|
|
|
|
places: function(data, callback) {
|
2011-08-24 06:19:34 +00:00
|
|
|
return pandora.api.findPlaces(Ox.extend(data, {
|
2011-06-16 20:00:10 +00:00
|
|
|
itemQuery: query
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (view == 'calendar') {
|
|
|
|
pandora.$ui.list.options({
|
|
|
|
items: function(data, callback) {
|
2011-08-24 06:19:34 +00:00
|
|
|
return pandora.api.findEvents(Ox.extend(data, {
|
2011-06-16 20:00:10 +00:00
|
|
|
itemQuery: query
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
pandora.$ui.list.options({
|
|
|
|
items: function(data, callback) {
|
2011-08-24 06:19:34 +00:00
|
|
|
return pandora.api.find(Ox.extend(data, {
|
2011-06-16 20:00:10 +00:00
|
|
|
query: query
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2011-08-24 06:19:34 +00:00
|
|
|
$.each(pandora.user.ui.groups, function(i_, id) {
|
2011-05-25 19:42:45 +00:00
|
|
|
if (i_ != i) {
|
|
|
|
//Ox.print('setting groups request', i, i_)
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.groups[i_].options({
|
2011-05-25 19:42:45 +00:00
|
|
|
items: function(data, callback) {
|
|
|
|
delete data.keys;
|
2011-08-24 06:19:34 +00:00
|
|
|
return pandora.api.find(Ox.extend(data, {
|
|
|
|
group: id,
|
|
|
|
query: pandora.user.ui.groupsData[i_].query
|
2011-05-25 19:42:45 +00:00
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2011-08-19 16:49:09 +00:00
|
|
|
};
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.reloadList = function() {
|
|
|
|
Ox.print('reloadList')
|
|
|
|
var listData = pandora.getListData();
|
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.groups.forEach(function($group) {
|
2011-05-25 19:42:45 +00:00
|
|
|
$group.reloadList();
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.list.bindEvent({
|
2011-05-25 19:42:45 +00:00
|
|
|
init: function(event, data) {
|
2011-09-04 11:31:05 +00:00
|
|
|
// fixme: this will not work for lists in the favorites folder
|
|
|
|
// (but then it's also unlikely they'll have to be reloaded)
|
|
|
|
var folder = listData.status != 'featured' ? 'personal' : 'featured';
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[folder].value(listData.id, 'items', data.items);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.bindEventOnce({
|
|
|
|
load: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.list.gainFocus();
|
|
|
|
if (data) pandora.$ui.list.options({selected: [data.items]});
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.reloadList();
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.resizeGroups = function(width) {
|
2011-08-24 06:19:34 +00:00
|
|
|
pandora.user.ui.groupsSizes = pandora.getGroupsSizes();
|
|
|
|
Ox.print('{}{}{}', window.innerWidth, window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1, pandora.user.ui.groupsSizes)
|
|
|
|
pandora.$ui.browser
|
|
|
|
.size(0, pandora.user.ui.groupsSizes[0])
|
|
|
|
.size(2, pandora.user.ui.groupsSizes[4]);
|
|
|
|
pandora.$ui.groupsInnerPanel
|
|
|
|
.size(0, pandora.user.ui.groupsSizes[1])
|
|
|
|
.size(2, pandora.user.ui.groupsSizes[3]);
|
|
|
|
pandora.$ui.groups.forEach(function(list, i) {
|
|
|
|
list.resizeColumn('name', pandora.user.ui.groupsSizes[i] - 40 - Ox.UI.SCROLLBAR_SIZE);
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.resizeFolders = function() {
|
|
|
|
var width = pandora.getFoldersWidth(),
|
|
|
|
columnWidth = {};
|
2011-09-01 04:46:44 +00:00
|
|
|
if (pandora.user.ui.section == 'items') {
|
|
|
|
columnWidth = {user: parseInt((width - 96) * 0.4)};
|
|
|
|
columnWidth.name = (width - 96) - columnWidth.user;
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
//Ox.print('sectionsWidth', width)
|
2011-09-05 02:20:38 +00:00
|
|
|
Ox.forEach(pandora.$ui.folderList, function($list, id) {
|
2011-06-06 15:48:11 +00:00
|
|
|
var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id);
|
|
|
|
pandora.$ui.folder[i].css({width: width + 'px'});
|
2011-05-25 19:42:45 +00:00
|
|
|
$list.css({width: width + 'px'});
|
2011-09-01 04:46:44 +00:00
|
|
|
if (pandora.user.ui.section == 'items') {
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.site.sectionFolders[pandora.user.ui.section][i].showBrowser) {
|
2011-09-01 07:00:35 +00:00
|
|
|
Ox.print('ID', id)
|
|
|
|
pandora.$ui.findListInput[id].options({
|
|
|
|
width: width - 24
|
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
$list.resizeColumn('user', columnWidth.user)
|
|
|
|
.resizeColumn('name', columnWidth.name);
|
|
|
|
} else {
|
2011-09-01 04:46:44 +00:00
|
|
|
$list.resizeColumn(id == 'favorite' ? 'id' : 'name', width - 96);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2011-06-06 15:48:11 +00:00
|
|
|
if (!pandora.user.ui.showFolder[pandora.user.ui.section][id]) {
|
|
|
|
pandora.$ui.folder[i].update();
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
});
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.saveVideoPosition = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
//alert(JSON.stringify(['videoPosition|' + old.user.ui.item, pandora.$ui[old.user.ui.itemView == 'player' ? 'player' : 'editor'].options('position')]));
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.selectList = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.user.ui.list) {
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.api.findLists({
|
|
|
|
keys: ['status', 'user'],
|
|
|
|
query: {
|
2011-06-06 15:48:11 +00:00
|
|
|
conditions: [{key: 'id', value: pandora.user.ui.list, operator: '='}],
|
2011-05-25 19:42:45 +00:00
|
|
|
operator: ''
|
|
|
|
},
|
|
|
|
range: [0, 1]
|
|
|
|
}, function(result) {
|
|
|
|
var folder, list;
|
|
|
|
if (result.data.items.length) {
|
|
|
|
list = result.data.items[0];
|
|
|
|
folder = list.status == 'featured' ? 'featured' : (
|
2011-06-06 15:48:11 +00:00
|
|
|
list.user == pandora.user.username ? 'personal' : 'favorite'
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[folder]
|
|
|
|
.options('selected', [pandora.user.ui.list])
|
2011-05-25 19:42:45 +00:00
|
|
|
.gainFocus();
|
|
|
|
} else {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user.ui.list = '';
|
|
|
|
//pandora.user.ui.listQuery.conditions = []; // fixme: Query should read from pandora.ui.list, and not need pandora.ui.listQuery to be reset
|
2011-05-25 19:42:45 +00:00
|
|
|
//pandora.URL.set(pandora.Query.toString());
|
|
|
|
}
|
2011-06-16 20:00:10 +00:00
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|