2019-10-22 14:30:17 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
pandora.ui.home = function() {
|
|
|
|
|
2019-10-23 14:11:38 +00:00
|
|
|
var self = {},
|
|
|
|
|
|
|
|
that = $('<div>')
|
2019-10-22 14:30:17 +00:00
|
|
|
.addClass('OxScreen')
|
|
|
|
.css({
|
2019-10-23 14:11:38 +00:00
|
|
|
backgroundColor: 'white',
|
2019-10-22 14:30:17 +00:00
|
|
|
height: '100%',
|
|
|
|
opacity: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
overflowY: 'auto',
|
|
|
|
position: 'absolute',
|
|
|
|
width: '100%',
|
2019-10-22 14:30:17 +00:00
|
|
|
zIndex: 1001
|
|
|
|
}),
|
2019-10-23 14:11:38 +00:00
|
|
|
|
|
|
|
$box = $('<div>')
|
2019-10-22 14:30:17 +00:00
|
|
|
.css({
|
|
|
|
left: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
margin: '0 auto',
|
|
|
|
position: 'absolute',
|
2019-10-22 14:30:17 +00:00
|
|
|
right: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
top: '32px',
|
|
|
|
width: '800px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
|
|
|
.appendTo(that),
|
2019-10-23 14:11:38 +00:00
|
|
|
|
|
|
|
homeMenuCenterCSS = {
|
|
|
|
height: 'auto',
|
|
|
|
left: 0,
|
|
|
|
margin: '0 auto',
|
|
|
|
position: 'absolute',
|
|
|
|
right: 0,
|
|
|
|
top: '300px',
|
|
|
|
width: '320px'
|
|
|
|
},
|
|
|
|
homeMenuLeftCSS = {
|
|
|
|
margin: '',
|
|
|
|
right: '',
|
|
|
|
left: '32px',
|
|
|
|
position: 'absolute',
|
|
|
|
top: '32px',
|
|
|
|
width: '128px'
|
|
|
|
},
|
|
|
|
|
|
|
|
$menu = $('<div>')
|
|
|
|
.attr({
|
|
|
|
id: 'homeMenu'
|
|
|
|
})
|
|
|
|
.css(homeMenuCenterCSS)
|
|
|
|
.appendTo(that),
|
|
|
|
|
|
|
|
$counter = $('<div>')
|
|
|
|
.attr({
|
|
|
|
id: 'homeCounter'
|
|
|
|
})
|
2019-10-22 14:30:17 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
2019-10-23 14:11:38 +00:00
|
|
|
right: '32px',
|
|
|
|
top: '32px',
|
|
|
|
width: '128px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
|
|
|
.appendTo(that),
|
2019-10-23 14:11:38 +00:00
|
|
|
|
|
|
|
$logo = Ox.Element({
|
|
|
|
element: '<img>'
|
|
|
|
})
|
|
|
|
.addClass('selected')
|
2019-10-22 14:30:17 +00:00
|
|
|
.attr({
|
2019-10-23 14:11:38 +00:00
|
|
|
id: 'homeLogo',
|
2019-10-22 14:30:17 +00:00
|
|
|
src: '/static/png/logo.png'
|
|
|
|
})
|
|
|
|
.css({
|
2019-10-23 14:11:38 +00:00
|
|
|
height: 'auto',
|
2019-10-22 14:30:17 +00:00
|
|
|
left: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
margin: '0 auto',
|
|
|
|
position: 'absolute',
|
2019-10-22 14:30:17 +00:00
|
|
|
right: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
top: 0,
|
|
|
|
width: '320px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.bind({
|
2019-10-22 14:30:17 +00:00
|
|
|
click: function() {
|
2019-10-23 14:11:38 +00:00
|
|
|
if (!$logo.hasClass('selected')) {
|
|
|
|
$logo.css({opacity: 1});
|
|
|
|
renderPage('home');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mouseenter: function() {
|
|
|
|
if (!$logo.hasClass('selected')) {
|
|
|
|
$logo.css({opacity: 0.5});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mouseleave: function() {
|
|
|
|
if (!$logo.hasClass('selected')) {
|
|
|
|
$logo.css({opacity: 1});
|
|
|
|
}
|
2019-10-22 14:30:17 +00:00
|
|
|
}
|
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.appendTo($box),
|
|
|
|
|
|
|
|
$title = Ox.Element({
|
|
|
|
element: '<img>'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
|
|
|
.css({
|
2019-10-23 14:11:38 +00:00
|
|
|
display: 'none',
|
|
|
|
height: '40px',
|
2019-10-22 14:30:17 +00:00
|
|
|
left: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
margin: '0 auto',
|
|
|
|
position: 'absolute',
|
|
|
|
right: 0,
|
|
|
|
top: '280px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.appendTo($box),
|
|
|
|
|
|
|
|
$text_es = $('<div>')
|
|
|
|
.css({
|
|
|
|
display: 'none',
|
|
|
|
fontFamily: 'Home Arabic',
|
|
|
|
fontSize: '13px',
|
|
|
|
lineHeight: '18px',
|
|
|
|
marginRight: '8px',
|
|
|
|
position: 'absolute',
|
|
|
|
textAlign: 'right',
|
|
|
|
top: '360px',
|
|
|
|
width: '392px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.appendTo($box),
|
|
|
|
|
|
|
|
$text_en = $('<div>')
|
2019-10-22 14:30:17 +00:00
|
|
|
.css({
|
2019-10-23 14:11:38 +00:00
|
|
|
display: 'none',
|
|
|
|
fontFamily: 'Home English',
|
|
|
|
fontSize: '12px',
|
|
|
|
left: '400px',
|
|
|
|
lineHeight: '17px',
|
|
|
|
marginLeft: '8px',
|
2019-10-22 14:30:17 +00:00
|
|
|
position: 'absolute',
|
2019-10-23 14:11:38 +00:00
|
|
|
top: '360px',
|
|
|
|
width: '392px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.appendTo($box),
|
|
|
|
|
|
|
|
$tutorials = $('<div>')
|
|
|
|
.css({
|
|
|
|
display: 'none',
|
|
|
|
left: '-128px',
|
|
|
|
marginLeft: '8px',
|
|
|
|
marginBottom: '32px',
|
|
|
|
position: 'absolute',
|
|
|
|
top: '392px',
|
|
|
|
width: '1024px',
|
|
|
|
height: '288px'
|
|
|
|
}).appendTo($box),
|
|
|
|
|
|
|
|
$enterButton = Ox.Element({
|
|
|
|
element: '<img>'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.attr({
|
|
|
|
src: '/static/png/enter.png'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
|
|
|
.css({
|
2019-10-23 14:11:38 +00:00
|
|
|
cursor: 'url(/static/png/cursor.png) 4 12, auto',
|
|
|
|
height: '32px',
|
|
|
|
left: 0,
|
|
|
|
margin: '0 auto',
|
2019-10-22 14:30:17 +00:00
|
|
|
position: 'absolute',
|
|
|
|
right: 0,
|
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.bind({
|
2019-10-22 14:30:17 +00:00
|
|
|
click: function() {
|
2019-10-23 14:11:38 +00:00
|
|
|
var page = pandora.user.ui.page == 'home' ? '' : pandora.user.ui.page;
|
|
|
|
/*
|
|
|
|
if (pandora.user.level == 'guest') {
|
|
|
|
page = 'signup'
|
|
|
|
}
|
|
|
|
*/
|
2019-10-22 14:30:17 +00:00
|
|
|
pandora.UI.set({
|
2019-10-23 14:11:38 +00:00
|
|
|
page: page,
|
2019-10-22 14:30:17 +00:00
|
|
|
section: 'items'
|
|
|
|
});
|
|
|
|
that.fadeOutScreen();
|
2019-10-23 14:11:38 +00:00
|
|
|
},
|
|
|
|
mouseenter: function() {
|
|
|
|
$enterButton.css({opacity: 0.5});
|
|
|
|
},
|
|
|
|
mouseleave: function() {
|
|
|
|
$enterButton.css({opacity: 1});
|
2019-10-22 14:30:17 +00:00
|
|
|
}
|
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.appendTo($menu),
|
2019-10-22 14:30:17 +00:00
|
|
|
|
2019-10-23 14:11:38 +00:00
|
|
|
$aboutButton = Ox.Element({
|
|
|
|
element: '<img>'
|
|
|
|
})
|
|
|
|
.attr({
|
|
|
|
src: '/static/png/about.png'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
|
|
|
.css({
|
2019-10-23 14:11:38 +00:00
|
|
|
cursor: 'pointer',
|
|
|
|
height: '32px',
|
2019-10-22 14:30:17 +00:00
|
|
|
left: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
margin: '0 auto',
|
|
|
|
position: 'absolute',
|
|
|
|
right: 0,
|
|
|
|
top: '48px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.bind({
|
2019-10-22 14:30:17 +00:00
|
|
|
click: function() {
|
2019-10-23 14:11:38 +00:00
|
|
|
renderPage('about');
|
|
|
|
},
|
|
|
|
mouseenter: function() {
|
|
|
|
$aboutButton.css({opacity: 0.5});
|
|
|
|
},
|
|
|
|
mouseleave: function() {
|
|
|
|
$aboutButton.css({opacity: 1});
|
2019-10-22 14:30:17 +00:00
|
|
|
}
|
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.appendTo($menu),
|
|
|
|
|
|
|
|
$tutorialButton = Ox.Element({
|
|
|
|
element: '<img>'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.attr({
|
|
|
|
src: '/static/png/tutorial.png'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
|
|
|
.css({
|
2019-10-23 14:11:38 +00:00
|
|
|
cursor: 'pointer',
|
|
|
|
height: '32px',
|
2019-10-22 14:30:17 +00:00
|
|
|
left: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
margin: '0 auto',
|
|
|
|
position: 'absolute',
|
|
|
|
right: 0,
|
|
|
|
top: '84px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.bind({
|
2019-10-22 14:30:17 +00:00
|
|
|
click: function() {
|
2019-10-23 14:11:38 +00:00
|
|
|
renderPage('tutorial');
|
|
|
|
},
|
|
|
|
mouseenter: function() {
|
|
|
|
$tutorialButton.css({opacity: 0.5});
|
|
|
|
},
|
|
|
|
mouseleave: function() {
|
|
|
|
$tutorialButton.css({opacity: 1});
|
2019-10-22 14:30:17 +00:00
|
|
|
}
|
2019-10-23 14:11:38 +00:00
|
|
|
})
|
|
|
|
.appendTo($menu),
|
|
|
|
|
|
|
|
$contactButton = Ox.Element({
|
|
|
|
element: '<img>'
|
|
|
|
})
|
|
|
|
.attr({
|
|
|
|
src: '/static/png/contact.png'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
|
|
|
.css({
|
2019-10-23 14:11:38 +00:00
|
|
|
cursor: 'pointer',
|
|
|
|
height: '32px',
|
|
|
|
left: 0,
|
|
|
|
margin: '0 auto',
|
2019-10-22 14:30:17 +00:00
|
|
|
position: 'absolute',
|
|
|
|
right: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
top: '120px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.bind({
|
2019-10-22 14:30:17 +00:00
|
|
|
click: function() {
|
2019-10-23 14:11:38 +00:00
|
|
|
renderPage('contact');
|
|
|
|
},
|
|
|
|
mouseenter: function() {
|
|
|
|
$contactButton.css({opacity: 0.5});
|
|
|
|
},
|
|
|
|
mouseleave: function() {
|
|
|
|
$contactButton.css({opacity: 1});
|
2019-10-22 14:30:17 +00:00
|
|
|
}
|
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.appendTo($menu),
|
|
|
|
|
|
|
|
$counterImage = Ox.Element({
|
|
|
|
element: '<img>'
|
|
|
|
})
|
|
|
|
.attr({
|
|
|
|
src: '/static/png/counter.png'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
height: '64px',
|
2019-10-22 14:30:17 +00:00
|
|
|
position: 'absolute',
|
|
|
|
right: 0,
|
2019-10-23 14:11:38 +00:00
|
|
|
top: '40px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.appendTo($counter),
|
2019-10-22 14:30:17 +00:00
|
|
|
|
2019-10-23 14:11:38 +00:00
|
|
|
text,
|
|
|
|
loadedCSS = false;
|
2019-10-22 14:30:17 +00:00
|
|
|
|
2019-10-23 14:11:38 +00:00
|
|
|
function getText(callback) {
|
|
|
|
var text = {};
|
|
|
|
Ox.getAsync([
|
|
|
|
'/static/txt/about.ar.txt',
|
|
|
|
'/static/txt/about.en.txt',
|
|
|
|
'/static/txt/tutorial.ar.txt',
|
|
|
|
'/static/txt/tutorial.en.txt',
|
|
|
|
'/static/txt/contact.ar.txt',
|
|
|
|
'/static/txt/contact.en.txt'
|
|
|
|
], Ox.get, function(data) {
|
|
|
|
Object.keys(data).forEach(function(key) {
|
|
|
|
text[key.slice(12, -4)] = data[key].replace(/\n/g, '<br/>')
|
|
|
|
+ '<br/><br/><br/>';
|
|
|
|
})
|
|
|
|
pandora.api.find({}, function(result) {
|
|
|
|
var seconds = result.data.duration | (858 * 3600)
|
|
|
|
text.hours = Math.round(seconds / 3600).toString();
|
|
|
|
callback(text);
|
|
|
|
});
|
|
|
|
});
|
2019-10-22 14:30:17 +00:00
|
|
|
}
|
|
|
|
|
2019-10-23 14:11:38 +00:00
|
|
|
function renderCounter() {
|
|
|
|
Ox.forEach(text.hours, function(value, index) {
|
|
|
|
Ox.Element()
|
|
|
|
.css({
|
|
|
|
border: '2px solid black',
|
|
|
|
fontFamily: 'Home English',
|
|
|
|
fontSize: '32px',
|
|
|
|
fontWeight: 'bold',
|
|
|
|
height: '43px',
|
|
|
|
paddingTop: '5px',
|
|
|
|
position: 'absolute',
|
|
|
|
right: 24 + (text.hours.length - index) * 22 + 'px',
|
|
|
|
width: '20px'
|
2019-10-22 14:30:17 +00:00
|
|
|
})
|
2019-10-23 14:11:38 +00:00
|
|
|
.html(value)
|
|
|
|
.appendTo($counter);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderPage(page) {
|
|
|
|
if (page == 'home') {
|
|
|
|
$logo.addClass('selected').css({cursor: 'default'});
|
|
|
|
$title.css({display: 'none'});
|
|
|
|
$text_es.css({display: 'none'});
|
|
|
|
$text_en.css({display: 'none'});
|
|
|
|
$tutorials.html('').hide();
|
|
|
|
$menu.css(homeMenuCenterCSS);
|
|
|
|
} else {
|
|
|
|
$menu.css(homeMenuLeftCSS);
|
|
|
|
$logo.removeClass('selected').css({cursor: 'pointer'});
|
|
|
|
$title.attr({
|
|
|
|
src: '/static/png/' + page + '.png'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
display: 'block'
|
|
|
|
});
|
|
|
|
$text_es.css({
|
|
|
|
display: 'block'
|
|
|
|
}).html(
|
|
|
|
text[page + '.es']
|
|
|
|
);
|
|
|
|
$text_en.css({
|
|
|
|
display: 'block'
|
|
|
|
}).html(
|
|
|
|
text[page + '.en']
|
|
|
|
);
|
|
|
|
if (page == 'contact') {
|
|
|
|
Ox.forEach(
|
|
|
|
document.querySelectorAll('a[href="/contact"]'),
|
|
|
|
function(link) {
|
|
|
|
link.addEventListener('click', function(e) {
|
|
|
|
pandora.UI.set({page: 'contact'});
|
|
|
|
that.fadeOutScreen();
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
);
|
2019-10-22 14:30:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-23 14:11:38 +00:00
|
|
|
function loadCSS(callback) {
|
|
|
|
if (loadedCSS) {
|
|
|
|
callback()
|
|
|
|
} else {
|
|
|
|
Ox.getFile('/static/css/home.css', function() {
|
|
|
|
loadedCSS = true
|
|
|
|
callback()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-22 14:30:17 +00:00
|
|
|
that.fadeInScreen = function() {
|
2019-10-23 14:11:38 +00:00
|
|
|
loadCSS(function() {
|
|
|
|
that.appendTo(Ox.$body).animate({opacity: 1}, 500, function() {
|
|
|
|
getText(function(data) {
|
|
|
|
text = data;
|
|
|
|
renderCounter();
|
|
|
|
that.find('*').animate({opacity: 1}, 250, function() {
|
|
|
|
// ...
|
|
|
|
});
|
|
|
|
});
|
2019-10-22 14:30:17 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
|
|
|
that.fadeOutScreen = function() {
|
2019-10-23 14:11:38 +00:00
|
|
|
$('.OxTooltip').remove();
|
2019-10-22 14:30:17 +00:00
|
|
|
that.animate({opacity: 0}, 500, function() {
|
|
|
|
that.remove();
|
|
|
|
});
|
|
|
|
pandora.$ui.tv && pandora.$ui.tv.unmute().find('.OxControls.OxVolume').hide();
|
2019-10-23 14:11:38 +00:00
|
|
|
self.keydown && Ox.$document.off({keydown: self.keydown});
|
2019-10-22 14:30:17 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
|
|
|
that.showScreen = function(callback) {
|
2019-10-23 14:11:38 +00:00
|
|
|
var $elements = that.find('*'), count = 0;
|
|
|
|
$box.css({top: '80px'});
|
|
|
|
$menu.css({top: '80px'});
|
|
|
|
$counter.css({top: '80px'});
|
|
|
|
getText(function(data) {
|
|
|
|
text = data;
|
|
|
|
renderCounter();
|
|
|
|
loadCSS(function() {
|
|
|
|
that.css({opacity: 1}).appendTo(Ox.$body);
|
|
|
|
$box.animate({top: '32px'}, 500, function() {
|
|
|
|
$elements.animate({opacity: 1}, 250, function() {
|
|
|
|
if (++count == $elements.length) {
|
|
|
|
// ...
|
|
|
|
// callback && callback();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//$menu.animate({top: '32px'}, 500);
|
|
|
|
$menu.animate({top: homeMenuCenterCSS.top}, 500);
|
|
|
|
$counter.animate({top: '32px'}, 500);
|
|
|
|
callback && callback();
|
|
|
|
});
|
2019-10-22 14:30:17 +00:00
|
|
|
});
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|