update indiancinema home screen

This commit is contained in:
rolux 2013-02-27 09:38:10 +00:00
parent b38d218a90
commit 2707a5f77d

View file

@ -5,6 +5,7 @@
pandora.ui.home = function() { pandora.ui.home = function() {
var self = {}, var self = {},
that = $('<div>') that = $('<div>')
.addClass('OxScreen') .addClass('OxScreen')
.css({ .css({
@ -15,6 +16,7 @@ pandora.ui.home = function() {
overflowY: 'auto', overflowY: 'auto',
zIndex: 1001 zIndex: 1001
}), }),
$box = $('<div>') $box = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
@ -25,6 +27,7 @@ pandora.ui.home = function() {
margin: '0 auto 0 auto' margin: '0 auto 0 auto'
}) })
.appendTo(that), .appendTo(that),
$reflectionImage = $('<img>') $reflectionImage = $('<img>')
.attr({src: '/static/png/logo.png'}) .attr({src: '/static/png/logo.png'})
.css({ .css({
@ -40,6 +43,7 @@ pandora.ui.home = function() {
WebkitTransform: 'scaleY(-1)' WebkitTransform: 'scaleY(-1)'
}) })
.appendTo($box), .appendTo($box),
$reflectionGradient = $('<div>') $reflectionGradient = $('<div>')
.addClass('OxReflection') .addClass('OxReflection')
.css({ .css({
@ -52,6 +56,7 @@ pandora.ui.home = function() {
margin: '0 auto 0 auto', margin: '0 auto 0 auto',
}) })
.appendTo($box), .appendTo($box),
$logo = Ox.Element({ $logo = Ox.Element({
element: '<img>', element: '<img>',
tooltip: 'Enter ' + pandora.site.site.name tooltip: 'Enter ' + pandora.site.site.name
@ -74,6 +79,7 @@ pandora.ui.home = function() {
} }
}) })
.appendTo($box), .appendTo($box),
$line = Ox.Element('<img>') $line = Ox.Element('<img>')
.css({ .css({
position: 'absolute', position: 'absolute',
@ -100,6 +106,7 @@ pandora.ui.home = function() {
}) })
.attr({src: '/static/png/line.indiancinema.png'}) .attr({src: '/static/png/line.indiancinema.png'})
.appendTo($box), .appendTo($box),
$findInput = Ox.Input({ $findInput = Ox.Input({
width: 252 width: 252
}) })
@ -126,6 +133,7 @@ pandora.ui.home = function() {
} }
}) })
.appendTo($box), .appendTo($box),
$findButton = Ox.Button({ $findButton = Ox.Button({
title: 'Find', title: 'Find',
width: 122 width: 122
@ -159,6 +167,7 @@ pandora.ui.home = function() {
} }
}) })
.appendTo($box), .appendTo($box),
$browseButton = Ox.Button({ $browseButton = Ox.Button({
title: 'Browse', title: 'Browse',
width: 122 width: 122
@ -181,6 +190,7 @@ pandora.ui.home = function() {
} }
}) })
.appendTo($box), .appendTo($box),
$signupButton = Ox.Button({ $signupButton = Ox.Button({
title: 'Sign Up', title: 'Sign Up',
width: 122 width: 122
@ -200,6 +210,7 @@ pandora.ui.home = function() {
that.fadeOutScreen(); that.fadeOutScreen();
} }
}), }),
$signinButton = Ox.Button({ $signinButton = Ox.Button({
title: 'Sign In', title: 'Sign In',
width: 122 width: 122
@ -219,6 +230,7 @@ pandora.ui.home = function() {
that.fadeOutScreen(); that.fadeOutScreen();
} }
}), }),
$preferencesButton = Ox.Button({ $preferencesButton = Ox.Button({
title: 'Preferences', title: 'Preferences',
width: 252 width: 252
@ -238,6 +250,7 @@ pandora.ui.home = function() {
that.fadeOutScreen(); that.fadeOutScreen();
} }
}), }),
$aboutButton = Ox.Button({ $aboutButton = Ox.Button({
title: 'About ' + pandora.site.site.name, title: 'About ' + pandora.site.site.name,
width: 252 width: 252
@ -258,8 +271,9 @@ pandora.ui.home = function() {
} }
}) })
.appendTo($box), .appendTo($box),
$lists = $('<div>')
.attr({id: 'lists'}) $features = $('<div>')
.attr({id: 'features'})
.css({ .css({
position: 'absolute', position: 'absolute',
left: 0, left: 0,
@ -279,30 +293,56 @@ pandora.ui.home = function() {
$preferencesButton.appendTo($box); $preferencesButton.appendTo($box);
} }
function showLists() { function showFeatures() {
pandora.api.findLists({ var $space,
featured = {},
find = {
query: { query: {
conditions: [{key: 'status', value: 'featured', operator: '=='}], conditions: [{key: 'status', value: 'featured', operator: '=='}],
operator: '&' operator: '&'
}, },
keys: ['user', 'name', 'description'], keys: ['user', 'name', 'description'],
sort: [{key: 'position', operator: '+'}] sort: [{key: 'position', operator: '+'}]
}, function(result) { },
var lists = result.data.items, items, lists, texts;
counter = 0, items = 8, mouse = false, position = 0, selected = 0, pandora.api.findLists(find, function(result) {
lists = result.data.items.length;
items = result.data.items.map(function(item) {
return Ox.extend(item, {type: 'list'});
});
pandora.api.findTexts(find, function(result) {
texts = result.data.items.length
items = items.concat(result.data.items.map(function(item) {
return Ox.extend(item, {type: 'text'});
}));
$features.empty();
show();
return;
if (featured.lists.length) {
top += 24;
}
show('texts');
});
});
function show() {
var counter = 0, max = 8, mouse = false, position = 0, selected = 0,
color = Ox.Theme() == 'oxlight' ? 'rgb(32, 32, 32)' color = Ox.Theme() == 'oxlight' ? 'rgb(32, 32, 32)'
: Ox.Theme() == 'oxmedium' ? 'rgb(144, 144, 144)' : Ox.Theme() == 'oxmedium' ? 'rgb(144, 144, 144)'
: 'rgb(224, 224, 224)', : 'rgb(224, 224, 224)',
$label, $icon, $text, $label, $icon, $text,
$listsBox, $listsContainer, $listsContent, $featuresBox, $featuresContainer, $featuresContent,
$listBox = [], $listIcon = [], $featureBox = [], $featureIcon = [],
$previousButton, $nextButton, $previousButton, $nextButton;
$space; if (items.length) {
$lists.empty();
if (lists.length) {
$label = Ox.Label({ $label = Ox.Label({
textAlign: 'center', textAlign: 'center',
title: '<b>Featured List' + (lists.length > 1 ? 's' : '') + '</b>', title: '<b>Featured ' + (
lists == 1 && texts == 0 ? 'List'
: lists == 0 && texts == 1 ? 'Text'
: texts == 0 ? 'Lists'
: lists == 0 ? 'Texts'
: 'Lists and Texts'
) + '</b>',
width: 512 width: 512
}) })
.css({ .css({
@ -313,7 +353,7 @@ pandora.ui.home = function() {
bottom: 0, bottom: 0,
margin: '0 auto 0 auto' margin: '0 auto 0 auto'
}) })
.appendTo($lists); .appendTo($features);
$text = Ox.Label({ $text = Ox.Label({
width: 386 width: 386
}) })
@ -332,18 +372,16 @@ pandora.ui.home = function() {
whiteSpace: 'normal' whiteSpace: 'normal'
}) })
.html( .html(
'<b>' + Ox.encodeHTMLEntities(lists[selected].name) + '</b><br><br>' getHTML(items[selected])
+ lists[selected].description
) )
.appendTo($lists); .appendTo($features);
pandora.createLinks($text); pandora.createLinks($text);
$icon = Ox.Element({ $icon = Ox.Element({
element: '<img>', element: '<img>',
tooltip: 'View List' tooltip: getTooltip(items[selected])
}) })
.attr({ .attr({
src: '/list/' + lists[selected].user + ':' src: getImageURL(items[selected])
+ lists[selected].name + '/icon256.jpg'
}) })
.css({ .css({
position: 'absolute', position: 'absolute',
@ -358,12 +396,12 @@ pandora.ui.home = function() {
}) })
.bindEvent({ .bindEvent({
anyclick: function() { anyclick: function() {
openList(selected); openItem(selected);
} }
}) })
.appendTo($lists); .appendTo($features);
if (lists.length > 1) { if (items.length > 1) {
$listsBox = $('<div>') $featuresBox = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
left: 0, left: 0,
@ -373,8 +411,8 @@ pandora.ui.home = function() {
width: '560px', // 16+8+512+8+16 width: '560px', // 16+8+512+8+16
margin: '0 auto 0 auto' margin: '0 auto 0 auto'
}) })
.appendTo($lists); .appendTo($features);
$listsContainer = $('<div>') $featuresContainer = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
left: '20px', left: '20px',
@ -383,18 +421,18 @@ pandora.ui.home = function() {
width: '520px', width: '520px',
overflow: 'hidden' overflow: 'hidden'
}) })
.appendTo($listsBox); .appendTo($featuresBox);
$listsContent = $('<div>') $featuresContent = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
width: lists.length * 65 + 'px', width: items.length * 65 + 'px',
height: '65px', height: '65px',
marginLeft: lists.length < items marginLeft: items.length < max
? (items - lists.length) * 65 / 2 + 'px' ? (max - items.length) * 65 / 2 + 'px'
: 0 : 0
}) })
.appendTo($listsContainer); .appendTo($featuresContainer);
if (lists.length > items) { if (items.length > max) {
$previousButton = Ox.Button({ $previousButton = Ox.Button({
title: 'left', title: 'left',
type: 'image' type: 'image'
@ -419,12 +457,12 @@ pandora.ui.home = function() {
} }
} }
}) })
.appendTo($listsBox); .appendTo($featuresBox);
$nextButton = Ox.Button({ $nextButton = Ox.Button({
title: 'right', title: 'right',
type: 'image' type: 'image'
}) })
.addClass(position < lists.length - 1 ? 'visible' : '') .addClass(position < items.length - 1 ? 'visible' : '')
.css({ .css({
position: 'absolute', position: 'absolute',
right: 0, right: 0,
@ -444,8 +482,8 @@ pandora.ui.home = function() {
} }
} }
}) })
.appendTo($listsBox); .appendTo($featuresBox);
$listsBox.on({ $featuresBox.on({
mouseenter: function() { mouseenter: function() {
mouse = true; mouse = true;
$('.visible').show().stop().animate({ $('.visible').show().stop().animate({
@ -467,27 +505,8 @@ pandora.ui.home = function() {
} }
}); });
} }
self.keydown = function(e) { items.forEach(function(item, i) {
var focused = Ox.Focus.focused(), $featureBox[i] = $('<div>')
key = Ox.KEYS[e.keyCode];
if (
focused === null
|| !Ox.UI.elements[focused].hasClass('OxInput')
) {
if (key == 'left' && selected > 0) {
selectList(selected - 1);
} else if (key == 'up' && selected > 0) {
selectList(0);
} else if (key == 'right' && selected < lists.length - 1) {
selectList(selected + 1);
} else if (key == 'down' && selected < lists.length - 1) {
selectList(lists.length - 1);
}
}
};
Ox.$document.on({keydown: self.keydown});
lists.forEach(function(list, i) {
$listBox[i] = $('<div>')
.css({ .css({
float: 'left', float: 'left',
width: '57px', width: '57px',
@ -497,14 +516,14 @@ pandora.ui.home = function() {
borderRadius: '16px', borderRadius: '16px',
boxShadow: '0 0 2px ' + (i == selected ? color : 'transparent') boxShadow: '0 0 2px ' + (i == selected ? color : 'transparent')
}) })
.appendTo($listsContent); .appendTo($featuresContent);
$listIcon[i] = Ox.Element({ $featureIcon[i] = Ox.Element({
element: '<img>', element: '<img>',
tooltip: Ox.encodeHTMLEntities(list.name) tooltip: (lists && texts ? Ox.toTitleCase(item.type) + ': ' : '')
+ Ox.encodeHTMLEntities(item.name)
}) })
.attr({ .attr({
src: '/list/' + list.user + ':' src: getImageURL(item)
+ list.name + '/icon256.jpg'
}) })
.css({ .css({
width: '57px', width: '57px',
@ -514,47 +533,87 @@ pandora.ui.home = function() {
}) })
.bindEvent({ .bindEvent({
doubleclick: function() { doubleclick: function() {
openList(i); openItem(i);
}, },
singleclick: function() { singleclick: function() {
selectList(i); selectItem(i);
} }
}) })
.appendTo($listBox[i]); .appendTo($featureBox[i]);
}); });
self.keydown = function(e) {
var focused = Ox.Focus.focused(),
key = Ox.KEYS[e.keyCode];
if (
focused === null
|| !Ox.UI.elements[focused].hasClass('OxInput')
) {
if (key == 'left' && selected > 0) {
selectItem(selected - 1);
} else if (key == 'up' && selected > 0) {
selectItem(0);
} else if (key == 'right' && selected < items.length - 1) {
selectItem(selected + 1);
} else if (key == 'down' && selected < items.length - 1) {
selectItem(itmes.length - 1);
}
}
};
Ox.$document.on({keydown: self.keydown});
} }
$space = $('<div>') $space = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
top: lists.length == 0 ? '0px' top: items.length == 0 ? '0px'
: lists.length == 1 ? '150px' : items.length == 1 ? '150px'
: '215px', : '215px',
width: '560px', width: '560px',
height: '80px' height: '80px'
}) })
.appendTo($lists); .appendTo($features);
$lists.animate({opacity: 1}, 250); $features.animate({opacity: 1}, 250);
} }
function openList(i) {
function getHTML(item) {
return '<b>'
+ (lists && texts ? Ox.toTitleCase(item.type) + ': ' : '')
+ Ox.encodeHTMLEntities(item.name) + '</b><br><br>'
+ item.description;
}
function getImageURL(item) {
return '/' + item.type + '/' + item.user
+ ':' + item.name + '/icon256.jpg';
}
function getTooltip(item) {
return 'View ' + Ox.toTitleCase(item.type)
}
function openItem(i) {
that.fadeOutScreen(); that.fadeOutScreen();
pandora.UI.set({ pandora.UI.set(Ox.extend({
page: '', section: items[i].type == 'list' ? 'items' : 'texts',
item: '', page: ''
}, items[i].type == 'list' ? {
find: { find: {
conditions: [{ conditions: [{
key: 'list', key: 'list',
value: lists[i].user + ':' value: items[i].user + ':'
+ lists[i].name, + items[i].name,
operator: '==' operator: '=='
}], }],
operator: '&' operator: '&'
} }
}); } : {
text: items[i].user + ':' + items[i].name
}));
} }
function scrollToPosition(i, animate) { function scrollToPosition(i, animate) {
if (i >= 0 && i <= lists.length - items && i != position) { if (i >= 0 && i <= items.length - max && i != position) {
position = i; position = i;
$listsContent.stop().animate({ $featuresContent.stop().animate({
left: (position * -65) + 'px' left: (position * -65) + 'px'
}, animate ? 250 : 0, function() { }, animate ? 250 : 0, function() {
if (position == 0) { if (position == 0) {
@ -566,7 +625,7 @@ pandora.ui.home = function() {
} else { } else {
$previousButton.addClass('visible'); $previousButton.addClass('visible');
} }
if (position == lists.length - items) { if (position == items.length - max) {
$nextButton.removeClass('visible').stop().animate({ $nextButton.removeClass('visible').stop().animate({
opacity: 0 opacity: 0
}, 250, function() { }, 250, function() {
@ -576,45 +635,46 @@ pandora.ui.home = function() {
$nextButton.addClass('visible'); $nextButton.addClass('visible');
} }
if (mouse) { if (mouse) {
$listsBox.trigger('mouseenter'); $featuresBox.trigger('mouseenter');
} }
}); });
} }
} }
function selectList(i) {
if (i >= 0 && i <= lists.length - 1 && i != selected) { function selectItem(i) {
$listBox[selected].css({ if (i >= 0 && i <= items.length - 1 && i != selected) {
$featureBox[selected].css({
boxShadow: 'none' boxShadow: 'none'
}); });
selected = i; selected = i;
$listBox[selected].css({ $featureBox[selected].css({
boxShadow: '0 0 2px ' + color boxShadow: '0 0 2px ' + color
}); });
if (selected < position) { if (selected < position) {
scrollToPosition(selected, true); scrollToPosition(selected, true);
} else if (selected > position + items - 1) { } else if (selected > position + max - 1) {
scrollToPosition(selected - items + 1, true); scrollToPosition(selected - max + 1, true);
} }
$icon.attr({ $icon.attr({
src: '/list/' + lists[selected].user + ':' src: getImageURL(items[selected])
+ lists[selected].name + '/icon256.jpg' }).options({
tooltip: getTooltip(items[selected])
}); });
$text.html( $text.html(
'<b>' + Ox.encodeHTMLEntities(lists[selected].name) + '</b><br><br>' getHTML(items[selected])
+ lists[selected].description
); );
} }
} }
});
} }
}
that.fadeInScreen = function() { that.fadeInScreen = function() {
// $box.css({marginTop: '80px'}); // $box.css({marginTop: '80px'});
that.appendTo(Ox.UI.$body).animate({opacity: 1}, 500, function() { that.appendTo(Ox.UI.$body).animate({opacity: 1}, 500, function() {
that.find('*').animate({opacity: 1}, 250, function() { that.find('*').animate({opacity: 1}, 250, function() {
$findInput.focusInput(true); $findInput.focusInput(true);
showLists(); showFeatures();
}); });
}); });
return that; return that;
@ -635,13 +695,13 @@ pandora.ui.home = function() {
// $box.css({marginTop: '80px'}); // $box.css({marginTop: '80px'});
that.find('*').css({opacity: 1}); that.find('*').css({opacity: 1});
$findInput.focusInput(true); $findInput.focusInput(true);
showLists(); showFeatures();
/* /*
$box.animate({marginTop: '80px'}, 500); $box.animate({marginTop: '80px'}, 500);
setTimeout(function() { setTimeout(function() {
that.find('*').animate({opacity: 1}, 250, function() { that.find('*').animate({opacity: 1}, 250, function() {
$findInput.focusInput(true); $findInput.focusInput(true);
showLists(); showFeatures();
}); });
}, 250); }, 250);
*/ */