2014-06-23 10:15:53 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict' ;
pandora . ui . home = function ( ) {
var self = { } ,
that = $ ( '<div>' )
. addClass ( 'OxScreen' )
. css ( {
position : 'absolute' ,
width : '100%' ,
height : '100%' ,
opacity : 0 ,
overflowY : 'auto' ,
zIndex : 1001
} ) ,
$box = $ ( '<div>' )
. css ( {
position : 'absolute' ,
left : 0 ,
top : '80px' ,
right : 0 ,
width : '560px' ,
margin : '0 auto 0 auto'
} )
2023-08-04 17:03:44 +00:00
. appendTo ( that ) ;
/ *
2014-06-23 10:15:53 +00:00
$reflectionImage = $ ( '<img>' )
. attr ( { src : '/static/png/logo.png' } )
. css ( {
position : 'absolute' ,
left : 0 ,
top : '80px' ,
right : 0 ,
bottom : 0 ,
width : '320px' ,
height : 'auto' ,
margin : '0 auto 0 auto' ,
MozTransform : 'scaleY(-1)' ,
MsTransform : 'scaleY(-1)' ,
OTransform : 'scaleY(-1)' ,
WebkitTransform : 'scaleY(-1)'
} )
. appendTo ( $box ) ,
$reflectionGradient = $ ( '<div>' )
. addClass ( 'OxReflection' )
. css ( {
position : 'absolute' ,
left : 0 ,
top : '80px' ,
right : 0 ,
width : '320px' ,
height : '160px' ,
margin : '0 auto 0 auto' ,
} )
. appendTo ( $box ) ,
2023-08-04 17:03:44 +00:00
* /
2014-06-23 10:15:53 +00:00
2023-08-04 17:03:44 +00:00
var $logo = Ox . Element ( {
2014-06-23 10:15:53 +00:00
element : '<img>' ,
tooltip : function ( ) {
return Ox . _ ( 'Enter {0}' , [ pandora . site . site . name ] ) ;
}
} )
. attr ( {
id : 'logo' ,
src : '/static/png/logo.png'
} )
. css ( {
position : 'absolute' ,
left : 0 ,
right : 0 ,
width : '320px' ,
height : 'auto' ,
margin : '0 auto 0 auto' ,
cursor : 'pointer'
} )
. bindEvent ( {
anyclick : function ( ) {
$browseButton . triggerEvent ( 'click' ) ;
}
} )
. appendTo ( $box ) ,
$findInput = Ox . Input ( {
width : 252
} )
. css ( {
position : 'absolute' ,
left : 0 ,
top : '104px' ,
right : '260px' ,
bottom : 0 ,
margin : '0 auto 0 auto' ,
opacity : 0
} )
2014-10-23 11:50:41 +00:00
. on ( {
click : function ( e ) {
// fixme: why?
e . stopPropagation ( ) ;
}
2014-06-23 10:15:53 +00:00
} )
. bindEvent ( {
submit : function ( data ) {
if ( data . value ) {
$findButton . triggerEvent ( 'click' ) ;
} else {
$browseButton . triggerEvent ( 'click' ) ;
}
}
} )
. appendTo ( $box ) ,
$findButton = Ox . Button ( {
title : Ox . _ ( 'Find' ) ,
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 : '&'
} ,
section : 'items'
} ) ;
2017-07-14 08:39:51 +00:00
pandora . $ui . findSelect && pandora . $ui . findSelect . value ( '*' ) ;
pandora . $ui . findInput && pandora . $ui . findInput . value ( value ) ;
2014-06-23 10:15:53 +00:00
}
} )
. appendTo ( $box ) ,
$browseButton = Ox . Button ( {
title : Ox . _ ( 'Browse' ) ,
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 ( {
page : pandora . user . ui . page == 'home' ? '' : pandora . user . ui . page ,
section : 'items'
} ) ;
that . fadeOutScreen ( ) ;
}
} )
. appendTo ( $box ) ,
2017-07-14 08:39:51 +00:00
$footer = Ox . Element ( ) . css ( {
clear : 'both' ,
height : '64px' ,
paddingTop : '12px'
} ) ,
2014-06-23 10:15:53 +00:00
$signupButton = Ox . Button ( {
title : Ox . _ ( 'Sign Up' ) ,
width : 122
} )
. css ( {
} )
. bindEvent ( {
click : function ( ) {
pandora . UI . set ( { page : 'signup' } ) ;
that . fadeOutScreen ( ) ;
}
} ) ,
$signinButton = Ox . Button ( {
title : Ox . _ ( 'Sign In' ) ,
width : 122
} )
. css ( {
2017-07-14 08:39:51 +00:00
marginLeft : '8px' ,
2014-06-23 10:15:53 +00:00
} )
. bindEvent ( {
click : function ( ) {
pandora . UI . set ( { page : 'signin' } ) ;
that . fadeOutScreen ( ) ;
}
} ) ,
$preferencesButton = Ox . Button ( {
title : Ox . _ ( 'Preferences' ) ,
width : 252
} )
. css ( {
} )
. bindEvent ( {
click : function ( ) {
pandora . UI . set ( { page : 'preferences' } ) ;
that . fadeOutScreen ( ) ;
}
} ) ,
$aboutButton = Ox . Button ( {
title : Ox . _ ( 'About {0}' , [ pandora . site . site . name ] ) ,
width : 252
} )
. css ( {
2017-07-14 08:39:51 +00:00
marginLeft : '8px'
2014-06-23 10:15:53 +00:00
} )
. bindEvent ( {
click : function ( ) {
pandora . UI . set ( { page : 'about' } ) ;
that . fadeOutScreen ( ) ;
}
2017-07-14 08:39:51 +00:00
} ) ,
2014-06-23 10:15:53 +00:00
$features = $ ( '<div>' )
. attr ( { id : 'lists' } )
. css ( {
position : 'absolute' ,
left : 0 ,
2017-07-14 08:39:51 +00:00
top : '152px' ,
2014-06-23 10:15:53 +00:00
right : 0 ,
bottom : 0 ,
2017-07-14 08:39:51 +00:00
width : '512px' ,
2014-06-23 10:15:53 +00:00
margin : '0 auto 0 auto' ,
opacity : 0
} )
2017-07-14 08:31:54 +00:00
. appendTo ( $box ) ,
$support = $ ( '<div>' ) . css ( {
2017-07-14 08:39:51 +00:00
clear : 'both' ,
2017-07-14 08:31:54 +00:00
} ) . append (
$ ( '<img>' ) . attr ( { src : '/static/png/sd.logo.png' } ) . css ( { width : '64px' , height : '64px' , float : 'left' } )
) . append (
$ ( '<div>' ) . html ( '“Bu websitesi Sivil Düşün AB Programı Aktivist Desteği kapsamı nda Avrupa Birliği desteği ile hazı rlanmı ştı r.” “Bu websitesi içeriğinin sorumluluğu tamamı yla Koza Görsel Kültür ve Sanat Derneği\'ne aittir ve AB\'nin görüşlerini yansı tmamaktadı r.”' )
2017-07-14 08:39:51 +00:00
) ;
2014-06-23 10:15:53 +00:00
if ( pandora . user . level == 'guest' ) {
2017-07-14 08:39:51 +00:00
$signupButton . appendTo ( $footer ) ;
$signinButton . appendTo ( $footer ) ;
2014-06-23 10:15:53 +00:00
} else {
2017-07-14 08:39:51 +00:00
$preferencesButton . appendTo ( $footer ) ;
2014-06-23 10:15:53 +00:00
}
2017-07-14 08:39:51 +00:00
$aboutButton . appendTo ( $footer ) ;
2014-06-23 10:15:53 +00:00
2023-08-04 17:03:44 +00:00
function getVideos ( clips , resolution ) {
var videos = [ ] ;
clips . filter ( function ( clip ) {
return clip . duration ;
} ) . map ( function ( clip ) {
videos = videos . concat ( pandora . getClipVideos ( clip , resolution ) ) ;
} ) ;
console . log ( videos )
return videos ;
}
function loadEdit ( ) {
pandora . api . getEdit ( {
id : "mamafih:homepage" ,
} , response => {
var edit = response . data
pandora . api . sortClips ( {
edit : edit . id ,
sort : [ {
key : 'random' ,
operator : '+'
} ]
} , result => {
console . log ( '!!' , result )
edit . clips . forEach ( function ( clip ) {
clip . sort = result . data . clips . indexOf ( clip . id ) ;
} ) ;
edit . clips = Ox . sortBy ( edit . clips , 'sort' ) ;
var player = window . player = Ox . VideoElement ( {
items : getVideos ( Ox . clone ( edit . clips ) , pandora . user . ui . videoResolution ) ,
autoplay : true ,
muted : true ,
loop : true ,
} ) . css ( {
position : 'fixed' ,
top : 0 ,
bottom : 0 ,
left : 0 ,
right : 0 ,
width : '100%' ,
height : '100%'
} )
player . find ( 'video' ) . css ( {
width : '100%' ,
height : '100%' ,
'object-fit' : 'cover' ,
} )
player . prependTo ( pandora . $ui . home )
player . bindEvent ( 'loadedmetadata' , ( ) => {
console . log ( 'now play' )
player . play ( )
setTimeout ( ( ) => {
player . play ( )
} , 1000 )
} )
} )
} )
}
loadEdit ( )
2014-06-23 10:15:53 +00:00
function showFeatures ( ) {
2017-07-14 08:39:51 +00:00
pandora . api . getHomeItems ( { active : true } , function ( result ) {
var items = result . data . items . filter ( pandora . isCompleteHomeItem ) ,
$texts ;
$features . empty ( ) ;
2014-06-23 10:15:53 +00:00
if ( items . length ) {
2017-07-14 08:39:51 +00:00
$texts = Ox . Element ( ) . appendTo ( $features ) ;
items . forEach ( function ( item ) {
var $item = pandora . renderHomeItem ( {
data : item
} ) . appendTo ( $texts ) ;
} ) ;
} else {
$features . css ( {
top : '132px'
} ) ;
2014-06-23 10:15:53 +00:00
}
2017-07-14 08:39:51 +00:00
$features . append ( $footer ) ;
2018-03-08 08:19:27 +00:00
//$features.append($support);
2017-07-14 08:39:51 +00:00
$features . animate ( { opacity : 1 } , 250 ) ;
} ) ;
2014-06-23 10:15:53 +00:00
}
that . fadeInScreen = function ( ) {
2014-10-23 11:50:41 +00:00
that . appendTo ( Ox . $body ) . animate ( { opacity : 1 } , 500 , function ( ) {
2014-06-23 10:15:53 +00:00
that . find ( '*' ) . animate ( { opacity : 1 } , 250 , function ( ) {
$findInput . focusInput ( true ) ;
showFeatures ( ) ;
} ) ;
} ) ;
return that ;
} ;
that . fadeOutScreen = function ( ) {
$ ( '.OxTooltip' ) . remove ( ) ;
that . animate ( { opacity : 0 } , 500 , function ( ) {
that . remove ( ) ;
} ) ;
pandora . $ui . tv && pandora . $ui . tv . unmute ( ) . find ( '.OxControls.OxVolume' ) . hide ( ) ;
self . keydown && Ox . $document . off ( { keydown : self . keydown } ) ;
return that ;
} ;
that . showScreen = function ( callback ) {
var $elements = that . find ( '*' ) , count = 0 ;
$box . css ( { top : window . innerHeight / 2 - 80 + 'px' } ) ;
2014-10-23 11:50:41 +00:00
that . css ( { opacity : 1 } ) . appendTo ( Ox . $body ) ;
2014-06-23 10:15:53 +00:00
$findInput . focusInput ( true ) ;
$box . animate ( { top : '80px' } , 500 , function ( ) {
$elements . animate ( { opacity : 1 } , 250 , function ( ) {
if ( ++ count == $elements . length ) {
showFeatures ( ) ;
callback && callback ( ) ;
}
} ) ;
} ) ;
return that ;
} ;
return that ;
} ;