pandora/static/js/home.0xdb.js

315 lines
9.2 KiB
JavaScript
Raw Normal View History

2012-04-20 10:36:42 +00:00
'use strict';
pandora.ui.home = function() {
var that = $('<div>')
.addClass('OxScreen')
.css({
position: 'absolute',
width: '100%',
height: '100%',
opacity: 0,
zIndex: 1001
}),
2012-04-20 10:36:42 +00:00
$reflectionImage = $('<img>')
2013-07-09 09:06:00 +00:00
.addClass('logo')
2012-04-20 10:36:42 +00:00
.attr({src: '/static/png/logo.png'})
.css({
position: 'absolute',
left: 0,
top: '160px',
right: 0,
bottom: 0,
width: '320px',
height: 'auto',
2012-04-20 10:36:42 +00:00
margin: 'auto',
opacity: 0,
MozTransform: 'scaleY(-1)',
MsTransform: 'scaleY(-1)',
2012-04-20 10:36:42 +00:00
OTransform: 'scaleY(-1)',
WebkitTransform: 'scaleY(-1)',
transform: 'scaleY(-1)'
2012-04-20 10:36:42 +00:00
})
.appendTo(that),
2012-04-20 10:36:42 +00:00
$reflectionGradient = $('<div>')
2013-07-09 09:06:00 +00:00
.addClass('OxReflection logo')
2012-04-20 10:36:42 +00:00
.css({
position: 'absolute',
left: 0,
top: '160px',
right: 0,
bottom: 0,
// FIXME: should be 320 and 160 - the values below are temporary fixes for Chrome 26
width: '322px',
height: '162px',
2012-05-28 14:10:11 +00:00
margin: 'auto',
2012-04-20 10:36:42 +00:00
})
.appendTo(that),
$logo = $('<img>')
2013-07-09 09:06:00 +00:00
.addClass('logo')
2012-04-20 10:36:42 +00:00
.attr({
id: 'logo',
src: '/static/png/logo.png'
})
.css({
position: 'absolute',
left: 0,
top: 0,
right: 0,
bottom: '160px',
width: window.innerWidth + 'px',
height: 'auto',
2012-04-20 10:36:42 +00:00
margin: 'auto',
cursor: 'pointer'
})
.on({
click: function() {
2012-04-20 10:36:42 +00:00
$browseButton.triggerEvent('click');
}
})
.appendTo(that),
2012-04-20 10:36:42 +00:00
$findInput = Ox.Input({
width: 156
})
.css({
position: 'absolute',
left: 0,
top: '48px',
right: '164px',
bottom: 0,
margin: 'auto',
opacity: 0
})
.on({
click: function(e) {
// fixme: why?
e.stopPropagation();
}
2012-04-20 10:36:42 +00:00
})
.bindEvent({
submit: function(data) {
if (data.value) {
$findButton.triggerEvent('click');
} else {
$browseButton.triggerEvent('click');
}
}
})
.appendTo(that),
2012-04-20 10:36:42 +00:00
$findButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Find'),
2012-04-20 10:36:42 +00:00
width: 74
})
.css({
position: 'absolute',
left: '82px',
top: '48px',
right: 0,
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
var folder = pandora.getListData().folder,
value = $findInput.value();
folder && pandora.$ui.folderList[folder].options({selected: []});
that.fadeOutScreen();
pandora.UI.set({
page: '',
find: {
conditions: value === ''
? []
: [{key: '*', value: value, operator: '='}],
operator: '&'
2013-10-07 19:41:20 +00:00
},
section: 'items'
2012-04-20 10:36:42 +00:00
});
2017-02-15 17:44:59 +00:00
pandora.$ui.findSelect && pandora.$ui.findSelect.value('*');
pandora.$ui.findInput && pandora.$ui.findInput.value(value);
2012-04-20 10:36:42 +00:00
}
})
.appendTo(that),
2012-04-20 10:36:42 +00:00
$browseButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Browse'),
2012-04-20 10:36:42 +00:00
width: 74
})
.css({
position: 'absolute',
left: '246px',
top: '48px',
right: 0,
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
pandora.UI.set({
2013-10-07 19:41:20 +00:00
page: pandora.user.ui.page == 'home' ? '' : pandora.user.ui.page,
section: 'items'
2012-04-20 10:36:42 +00:00
});
that.fadeOutScreen();
}
})
.appendTo(that),
2012-04-20 10:36:42 +00:00
$signupButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Sign Up'),
2012-04-20 10:36:42 +00:00
width: 74
})
.css({
position: 'absolute',
left: 0,
top: '112px',
right: '246px',
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
pandora.UI.set({page: 'signup'});
that.fadeOutScreen();
}
}),
2012-04-20 10:36:42 +00:00
$signinButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Sign In'),
2012-04-20 10:36:42 +00:00
width: 74
})
.css({
position: 'absolute',
left: 0,
top: '112px',
right: '82px',
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
pandora.UI.set({page :'signin'});
that.fadeOutScreen();
}
}),
2012-04-20 10:36:42 +00:00
$preferencesButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Preferences'),
2012-04-20 10:36:42 +00:00
width: 156
})
.css({
position: 'absolute',
left: 0,
top: '112px',
right: '164px',
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
pandora.UI.set({page: 'preferences'});
that.fadeOutScreen();
}
}),
2012-04-20 10:36:42 +00:00
$aboutButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('About {0}', [pandora.site.site.name]),
2012-04-20 10:36:42 +00:00
width: 156
})
.css({
position: 'absolute',
left: '164px',
top: '112px',
right: 0,
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
pandora.UI.set({page: 'about'});
that.fadeOutScreen();
}
})
.appendTo(that),
2012-04-20 10:36:42 +00:00
$text = $('<div>')
.addClass('OxSelectable')
.css({
2012-04-20 10:36:42 +00:00
position: 'absolute',
left: 0,
top: '176px',
right: 0,
bottom: 0,
width: '360px',
height: '16px',
margin: 'auto',
opacity: 0,
textAlign: 'center'
})
.html(Ox._(
'A Movie Database. \u2620 2007-{0} 0x2620. All Open Source.',
[Ox.formatDate(new Date(), '%Y')]
))
2012-04-20 10:36:42 +00:00
.appendTo(that);
if (pandora.user.level == 'guest') {
$signupButton.appendTo(that);
$signinButton.appendTo(that);
} else {
$preferencesButton.appendTo(that);
}
that.fadeInScreen = function() {
that.appendTo(Ox.$body).animate({opacity: 1}, 500, function() {
2012-04-20 10:36:42 +00:00
that.find(':not(#logo)').animate({opacity: 1}, 250, function() {
$findInput.focusInput(true);
});
});
$logo.animate({width: '320px'}, 500);
return that;
};
that.fadeOutScreen = function() {
that.find(':not(#logo)').hide();
$logo.animate({width: window.innerWidth + 'px'}, 500);
that.animate({opacity: 0}, 500, function() {
that.remove();
});
pandora.$ui.tv && pandora.$ui.tv.unmute().find('.OxControls.OxVolume').hide();
2012-04-20 10:36:42 +00:00
return that;
};
that.hideScreen = function() {
that.hide().remove();
that.find(':not(#logo)').css({opacity: 0});
$logo.css({width: window.innerWidth + 'px'});
return that;
};
2013-07-09 09:06:00 +00:00
that.showScreen = function(callback) {
2013-07-09 11:14:00 +00:00
var $elements = that.find(':not(.logo)'), count = 0;
2012-04-20 10:36:42 +00:00
$logo.css({width: '320px'});
that.css({opacity: 1}).appendTo(Ox.$body);
2013-07-09 09:06:00 +00:00
that.find('.logo').css({opacity: 1});
$elements.animate({opacity: 1}, 500, function() {
if (callback && ++count == $elements.length) {
callback();
}
});
2012-04-20 10:36:42 +00:00
$findInput.focusInput(true);
return that;
};
return that;
};