pandora/static/js/pandora/home.js

285 lines
8.3 KiB
JavaScript
Raw Normal View History

// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-11-05 17:04:10 +00:00
'use strict';
pandora.ui.home = function() {
var that = $('<div>')
2011-09-18 02:22:50 +00:00
.addClass('OxScreen')
.css({
position: 'absolute',
width: '100%',
height: '100%',
opacity: 0,
2012-02-19 12:58:49 +00:00
zIndex: 1001
}),
$reflectionImage = $('<img>')
.attr({src: '/static/png/logo.png'})
.css({
position: 'absolute',
left: 0,
top: '160px',
right: 0,
bottom: 0,
width: '320px',
margin: 'auto',
opacity: 0,
MozTransform: 'scaleY(-1)',
2011-10-23 14:25:23 +00:00
OTransform: 'scaleY(-1)',
WebkitTransform: 'scaleY(-1)'
})
.appendTo(that),
$reflectionGradient = $('<div>')
2011-09-18 02:22:50 +00:00
.addClass('OxReflection')
.css({
position: 'absolute',
left: 0,
top: '160px',
right: 0,
bottom: 0,
width: '320px',
height: '160px',
margin: 'auto',
})
.appendTo(that),
$logo = $('<img>')
.attr({
id: 'logo',
src: '/static/png/logo.png'
})
.css({
position: 'absolute',
left: 0,
top: 0,
right: 0,
bottom: '160px',
width: window.innerWidth + 'px',
margin: 'auto',
cursor: 'pointer'
})
2012-05-28 14:10:11 +00:00
.on({
click: function() {
2011-10-08 13:09:16 +00:00
$browseButton.triggerEvent('click');
}
})
.appendTo(that),
$findInput = Ox.Input({
width: 156
})
.css({
position: 'absolute',
left: 0,
top: '48px',
right: '164px',
bottom: 0,
margin: 'auto',
opacity: 0
})
.click(function(e) {
// fixme: why?
e.stopPropagation();
})
.bindEvent({
submit: function(data) {
2011-09-17 13:04:10 +00:00
if (data.value) {
$findButton.triggerEvent('click');
} else {
$browseButton.triggerEvent('click');
}
}
})
.appendTo(that),
$findButton = Ox.Button({
title: 'Find',
width: 74
})
.css({
position: 'absolute',
left: '82px',
top: '48px',
right: 0,
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
2011-10-08 13:09:16 +00:00
var folder = pandora.getListData().folder,
value = $findInput.value();
2011-09-17 13:30:46 +00:00
folder && pandora.$ui.folderList[folder].options({selected: []});
2011-12-21 15:34:28 +00:00
pandora.$ui.findSelect.value('*');
pandora.$ui.findInput.value(value);
2011-10-08 13:09:16 +00:00
that.fadeOutScreen();
pandora.UI.set({
page: '',
find: {
conditions: value === ''
? []
: [{key: '*', value: value, operator: '='}],
operator: '&'
}
2011-10-08 11:24:09 +00:00
});
}
})
.appendTo(that),
$browseButton = Ox.Button({
title: 'Browse',
width: 74
})
.css({
position: 'absolute',
left: '246px',
top: '48px',
right: 0,
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
pandora.UI.set({
page: pandora.user.ui.page == 'home' ? '' : pandora.user.ui.page
});
that.fadeOutScreen();
}
})
.appendTo(that),
$signupButton = Ox.Button({
title: 'Sign Up',
width: 74
})
.css({
position: 'absolute',
left: 0,
top: '112px',
right: '246px',
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
2011-11-09 22:32:54 +00:00
pandora.UI.set({page: 'signup'});
that.fadeOutScreen();
}
2011-10-29 17:46:46 +00:00
}),
$signinButton = Ox.Button({
title: 'Sign In',
width: 74
})
.css({
position: 'absolute',
left: 0,
top: '112px',
right: '82px',
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
2011-11-09 22:32:54 +00:00
pandora.UI.set({page :'signin'});
that.fadeOutScreen();
}
2011-10-29 17:46:46 +00:00
}),
$preferencesButton = Ox.Button({
title: 'Preferences',
width: 156
})
.css({
position: 'absolute',
left: 0,
top: '112px',
right: '164px',
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
2011-11-09 22:32:54 +00:00
pandora.UI.set({page: 'preferences'});
that.fadeOutScreen();
}
2011-10-29 17:46:46 +00:00
}),
$aboutButton = Ox.Button({
title: 'About ' + pandora.site.site.name,
width: 156
})
.css({
position: 'absolute',
left: '164px',
top: '112px',
right: 0,
bottom: 0,
margin: 'auto',
opacity: 0
})
.bindEvent({
click: function() {
2011-11-09 22:32:54 +00:00
pandora.UI.set({page: 'about'});
that.fadeOutScreen();
}
})
.appendTo(that),
$text = $('<div>')
2012-04-20 10:36:42 +00:00
.html('pan.do/ra. \u2620 2007-2012 0x2620. All Open Source.')
.css({
position: 'absolute',
left: 0,
top: '176px',
right: 0,
bottom: 0,
width: '360px',
height: '16px',
margin: 'auto',
opacity: 0,
2011-10-29 17:46:46 +00:00
textAlign: 'center'
})
.appendTo(that);
if (pandora.user.level == 'guest') {
$signupButton.appendTo(that);
$signinButton.appendTo(that);
} else {
$preferencesButton.appendTo(that);
}
that.fadeInScreen = function() {
that.appendTo(Ox.UI.$body).animate({opacity: 1}, 500, function() {
that.find(':not(#logo)').animate({opacity: 1}, 250, function() {
2011-12-18 09:44:31 +00:00
$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();
});
2012-02-19 12:58:49 +00:00
pandora.$ui.tv && pandora.$ui.tv.unmute();
return that;
};
that.hideScreen = function() {
that.hide().remove();
that.find(':not(#logo)').css({opacity: 0});
$logo.css({width: window.innerWidth + 'px'});
return that;
};
that.showScreen = function() {
$logo.css({width: '320px'});
that.find(':not(#logo)').css({opacity: 1});
that.css({opacity: 1}).appendTo(Ox.UI.$body);
2011-12-18 09:44:31 +00:00
$findInput.focusInput(true);
return that;
};
return that;
2011-10-29 17:46:46 +00:00
};