pandora/static/js/home.indiancinema.js

348 lines
10 KiB
JavaScript
Raw Permalink Normal View History

2013-02-19 12:11:27 +00:00
'use strict';
pandora.ui.home = function() {
var self = {},
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
that = $('<div>')
.addClass('OxScreen')
.css({
position: 'absolute',
width: '100%',
height: '100%',
opacity: 0,
2013-02-19 13:49:27 +00:00
overflowY: 'auto',
2013-02-19 12:11:27 +00:00
zIndex: 1001
}),
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
$box = $('<div>')
.css({
position: 'absolute',
left: 0,
2013-02-19 13:49:27 +00:00
top: '80px',
2013-02-19 12:11:27 +00:00
right: 0,
width: '560px',
2013-02-19 13:49:27 +00:00
margin: '0 auto 0 auto'
2013-02-19 12:11:27 +00:00
})
.appendTo(that),
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
$reflectionImage = $('<img>')
.attr({src: '/static/png/logo.png'})
.css({
position: 'absolute',
left: 0,
2013-02-19 13:49:27 +00:00
top: '40px',
2013-02-19 12:11:27 +00:00
right: 0,
bottom: 0,
width: '320px',
2017-02-15 18:13:04 +00:00
height: 'auto',
2013-02-19 12:11:27 +00:00
margin: '0 auto 0 auto',
MozTransform: 'scaleY(-1)',
2017-02-15 18:13:04 +00:00
MsTransform: 'scaleY(-1)',
2013-02-19 12:11:27 +00:00
OTransform: 'scaleY(-1)',
WebkitTransform: 'scaleY(-1)'
})
.appendTo($box),
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
$reflectionGradient = $('<div>')
.addClass('OxReflection')
.css({
position: 'absolute',
left: 0,
2013-02-19 13:49:27 +00:00
top: '40px',
2013-02-19 12:11:27 +00:00
right: 0,
width: '320px',
2013-02-19 13:49:27 +00:00
height: '40px',
2013-02-19 12:11:27 +00:00
margin: '0 auto 0 auto',
})
.appendTo($box),
2013-02-27 09:38:10 +00:00
2013-02-19 13:49:27 +00:00
$logo = Ox.Element({
element: '<img>',
tooltip: function() {
return Ox._('Enter {0}', [pandora.site.site.name]);
}
2013-02-19 13:49:27 +00:00
})
2013-02-19 12:11:27 +00:00
.attr({
id: 'logo',
src: '/static/png/logo.png'
})
.css({
position: 'absolute',
left: 0,
right: 0,
2013-02-19 13:49:27 +00:00
width: '320px',
2017-02-15 18:13:04 +00:00
height: 'auto',
2013-02-19 12:11:27 +00:00
margin: '0 auto 0 auto',
cursor: 'pointer'
})
.bindEvent({
anyclick: function() {
2013-02-19 12:11:27 +00:00
$browseButton.triggerEvent('click');
}
})
.appendTo($box),
2013-02-27 09:38:10 +00:00
$line = Ox.Element('<img>')
2013-02-19 13:49:27 +00:00
.css({
position: 'absolute',
left: 0,
top: '62px',
2013-02-19 13:49:27 +00:00
right: 0,
width: '160px',
height: '20px',
margin: '0 auto 0 auto',
opacity: 0
})
.one({
load: function() {
$line.animate({opacity: 1}, 250, function() {
$line
.options({
tooltip: function() {
return Ox._('Visit {0}', ['Pad.ma']);
}
})
.bindEvent({
anyclick: function() {
2013-03-11 02:14:58 +00:00
window.open('/url=https://pad.ma', '_blank');
}
});
});
}
2013-02-19 13:49:27 +00:00
})
2013-02-20 04:45:37 +00:00
.attr({src: '/static/png/line.indiancinema.png'})
2013-02-19 13:49:27 +00:00
.appendTo($box),
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
$findInput = Ox.Input({
width: 252
})
.css({
position: 'absolute',
left: 0,
top: '104px',
right: '260px',
bottom: 0,
margin: '0 auto 0 auto',
opacity: 0
})
.on({
click: function(e) {
// fixme: why?
e.stopPropagation();
}
2013-02-19 12:11:27 +00:00
})
.bindEvent({
submit: function(data) {
if (data.value) {
$findButton.triggerEvent('click');
} else {
$browseButton.triggerEvent('click');
}
}
})
.appendTo($box),
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
$findButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Find'),
2013-02-19 12:11:27 +00:00
width: 122
})
.css({
position: 'absolute',
left: '130px',
top: '104px',
right: 0,
bottom: 0,
margin: '0 auto 0 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'
2013-02-19 12:11:27 +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);
2013-02-19 12:11:27 +00:00
}
})
.appendTo($box),
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
$browseButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Browse'),
2013-02-19 12:11:27 +00:00
width: 122
})
.css({
position: 'absolute',
left: '390px',
top: '104px',
right: 0,
bottom: 0,
margin: '0 auto 0 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'
2013-02-19 12:11:27 +00:00
});
that.fadeOutScreen();
}
})
.appendTo($box),
2013-02-27 09:38:10 +00:00
2017-02-15 18:13:04 +00:00
$footer = Ox.Element().css({
clear: 'both',
height: '64px',
paddingTop: '12px'
}),
2013-02-19 12:11:27 +00:00
$signupButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Sign Up'),
2013-02-19 12:11:27 +00:00
width: 122
})
.css({
})
.bindEvent({
click: function() {
pandora.UI.set({page: 'signup'});
that.fadeOutScreen();
}
}),
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
$signinButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Sign In'),
2013-02-19 12:11:27 +00:00
width: 122
})
.css({
2017-02-15 18:13:04 +00:00
marginLeft: '8px',
2013-02-19 12:11:27 +00:00
})
.bindEvent({
click: function() {
pandora.UI.set({page :'signin'});
that.fadeOutScreen();
}
}),
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
$preferencesButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Preferences'),
2013-02-19 12:11:27 +00:00
width: 252
})
.css({
})
.bindEvent({
click: function() {
pandora.UI.set({page: 'preferences'});
that.fadeOutScreen();
}
}),
2013-02-27 09:38:10 +00:00
2013-02-19 12:11:27 +00:00
$aboutButton = Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('About {0}', [pandora.site.site.name]),
2013-02-19 12:11:27 +00:00
width: 252
})
.css({
2017-02-15 18:13:04 +00:00
marginLeft: '8px'
2013-02-19 12:11:27 +00:00
})
.bindEvent({
click: function() {
pandora.UI.set({page: 'about'});
that.fadeOutScreen();
}
2017-02-15 18:13:04 +00:00
}),
2013-02-27 09:38:10 +00:00
$features = $('<div>')
2017-02-15 18:13:04 +00:00
.attr({id: 'lists'})
2013-02-19 12:11:27 +00:00
.css({
position: 'absolute',
left: 0,
2017-02-15 18:13:04 +00:00
top: '152px',
2013-02-19 12:11:27 +00:00
right: 0,
bottom: 0,
2017-02-15 18:13:04 +00:00
width: '512px',
2013-02-19 12:11:27 +00:00
margin: '0 auto 0 auto',
opacity: 0
})
.appendTo($box);
if (pandora.user.level == 'guest') {
2017-02-15 18:13:04 +00:00
$signupButton.appendTo($footer);
$signinButton.appendTo($footer);
2013-02-19 12:11:27 +00:00
} else {
2017-02-15 18:13:04 +00:00
$preferencesButton.appendTo($footer);
2013-02-19 12:11:27 +00:00
}
2017-02-15 18:13:04 +00:00
$aboutButton.appendTo($footer);
2013-02-19 12:11:27 +00:00
2013-02-27 09:38:10 +00:00
function showFeatures() {
2017-01-25 20:51:31 +00:00
pandora.api.getHomeItems({active: true}, function(result) {
2017-02-15 18:13:04 +00:00
var items = result.data.items.filter(pandora.isCompleteHomeItem),
$texts;
$features.empty();
2013-02-27 09:38:10 +00:00
if (items.length) {
2017-02-09 02:55:31 +00:00
$texts = Ox.Element().appendTo($features);
items.forEach(function(item) {
2017-02-15 18:13:04 +00:00
var $item = pandora.renderHomeItem({
data: item
}).appendTo($texts);
});
} else {
$features.css({
top: '132px'
2017-02-09 02:55:31 +00:00
});
2013-02-19 12:11:27 +00:00
}
2017-02-15 18:13:04 +00:00
$features.append($footer);
$features.animate({opacity: 1}, 250);
});
2013-02-19 12:11:27 +00:00
}
that.fadeInScreen = function() {
that.appendTo(Ox.$body).animate({opacity: 1}, 500, function() {
2013-02-19 12:11:27 +00:00
that.find('*').animate({opacity: 1}, 250, function() {
$findInput.focusInput(true);
2013-02-27 09:38:10 +00:00
showFeatures();
2013-02-19 12:11:27 +00:00
});
});
return that;
};
that.fadeOutScreen = function() {
2013-02-19 13:58:20 +00:00
$('.OxTooltip').remove();
2013-02-19 12:11:27 +00:00
that.animate({opacity: 0}, 500, function() {
that.remove();
});
pandora.$ui.tv && pandora.$ui.tv.unmute().find('.OxControls.OxVolume').hide();
2013-02-19 12:11:27 +00:00
self.keydown && Ox.$document.off({keydown: self.keydown});
return that;
};
that.showScreen = function(callback) {
2013-07-09 11:14:00 +00:00
var $elements = that.find('*'), count = 0;
2013-07-09 11:07:46 +00:00
$box.css({top: window.innerHeight / 2 - 40 + 'px'});
that.css({opacity: 1}).appendTo(Ox.$body);
2013-02-19 12:11:27 +00:00
$findInput.focusInput(true);
2013-07-09 11:07:46 +00:00
$box.animate({top: '80px'}, 500, function() {
$elements.animate({opacity: 1}, 250, function() {
if (++count == $elements.length) {
showFeatures();
callback && callback();
}
2013-02-19 12:11:27 +00:00
});
2013-07-09 11:07:46 +00:00
});
2013-02-19 12:11:27 +00:00
return that;
};
return that;
};