2017-07-08 02:28:18 +02:00
const ELECTRON _APP _VERSION = "1.2.0-beta" ;
2017-07-26 20:02:08 +02:00
const ELECTRON _APP _URL _LINUX = "https://github.com/zulip/zulip-electron/releases/download/v" + ELECTRON _APP _VERSION + "/Zulip-" + ELECTRON _APP _VERSION + "-x86_64.AppImage" ;
const ELECTRON _APP _URL _MAC = "https://github.com/zulip/zulip-electron/releases/download/v" + ELECTRON _APP _VERSION + "/Zulip-" + ELECTRON _APP _VERSION + ".dmg" ;
const ELECTRON _APP _URL _WINDOWS = "https://github.com/zulip/zulip-electron/releases/download/v" + ELECTRON _APP _VERSION + "/Zulip-Web-Setup-" + ELECTRON _APP _VERSION + ".exe" ;
2017-07-08 02:28:18 +02:00
2017-02-28 01:45:25 +01:00
// this will either smooth scroll to an anchor where the `name`
// is the same as the `scroll-to` reference, or to a px height
// (as specified like `scroll-to='0px'`).
var ScrollTo = function ( ) {
$ ( "[scroll-to]" ) . click ( function ( ) {
var sel = $ ( this ) . attr ( "scroll-to" ) ;
// if the `scroll-to` is a parse-able pixel value like `50px`,
// then use that as the scrollTop, else assume it is a selector name
// and find the `offsetTop`.
var top = /\dpx/ . test ( sel ) ?
parseInt ( sel , 10 ) :
$ ( "[name='" + sel + "']" ) . offset ( ) . top ;
$ ( "body" ) . animate ( { scrollTop : top + "px" } , 300 ) ;
} ) ;
} ;
2017-08-01 07:21:44 +02:00
export function path _parts ( ) {
2017-07-18 04:40:31 +02:00
return window . location . pathname . split ( '/' ) . filter ( function ( chunk ) {
return chunk !== '' ;
} ) ;
}
2017-07-01 01:29:15 +02:00
2017-04-20 20:44:49 +02:00
var hello _events = function ( ) {
var counter = 0 ;
$ ( window ) . scroll ( function ( ) {
if ( counter % 2 === 0 ) {
$ ( ".screen.hero-screen .message-feed" ) . css ( "transform" , "translateY(-" + $ ( this ) . scrollTop ( ) / 5 + "px)" ) ;
}
counter += 1 ;
} ) ;
$ ( ".footer" ) . addClass ( "hello" ) ;
} ;
2017-07-08 02:28:18 +02:00
var apps _events = function ( ) {
var info = {
windows : {
image : "/static/images/landing-page/microsoft.png" ,
alt : "Windows" ,
description : "Zulip for Windows is even better than Zulip on the web, with a cleaner look, tray integration, native notifications, and support for multiple Zulip accounts." ,
link : ELECTRON _APP _URL _WINDOWS ,
} ,
mac : {
image : "/static/images/landing-page/macbook.png" ,
alt : "MacOS" ,
description : "Zulip on MacOS is even better than Zulip on the web, with a cleaner look, tray integration, native notifications, and support for multiple Zulip accounts." ,
link : ELECTRON _APP _URL _MAC ,
} ,
android : {
image : "/static/images/app-screenshots/zulip-android.png" ,
alt : "Android" ,
description : "Zulip's native Android app makes it easy to keep up while on the go." ,
link : "https://play.google.com/store/apps/details?id=com.zulip.android" ,
} ,
ios : {
image : "/static/images/app-screenshots/zulip-iphone-rough.png" ,
alt : "iOS" ,
description : "Zulip's native iOS app makes it easy to keep up while on the go." ,
link : "https://itunes.apple.com/us/app/zulip/id1203036395" ,
} ,
linux : {
image : "/static/images/landing-page/ubuntu.png" ,
alt : "Linux" ,
description : "Zulip on the Linux desktop is even better than Zulip on the web, with a cleaner look, tray integration, native notifications, and support for multiple Zulip accounts." ,
link : ELECTRON _APP _URL _LINUX ,
} ,
} ;
2017-07-28 04:29:37 +02:00
var version ;
2017-07-08 02:28:18 +02:00
2017-07-28 04:29:37 +02:00
function get _version _from _path ( ) {
var result ;
var parts = path _parts ( ) ;
2017-07-08 02:28:18 +02:00
2017-07-28 04:29:37 +02:00
Object . keys ( info ) . forEach ( function ( version ) {
if ( parts . includes ( version ) ) {
result = version ;
2017-07-08 02:28:18 +02:00
}
2017-07-28 04:29:37 +02:00
} ) ;
2017-07-08 02:28:18 +02:00
2017-07-28 04:29:37 +02:00
// display Mac app by default
result = result || 'mac' ;
return result ;
}
function get _path _from _version ( ) {
return '/apps/' + version ;
}
2017-07-08 02:28:18 +02:00
2017-07-28 04:29:37 +02:00
function update _path ( ) {
var next _path = get _path _from _version ( ) ;
history . pushState ( version , '' , next _path ) ;
2017-07-08 02:28:18 +02:00
}
2017-07-28 04:29:37 +02:00
var update _page = function ( ) {
2017-07-08 02:28:18 +02:00
var version _info = info [ version ] ;
$ ( ".info .platform" ) . text ( version _info . alt ) ;
$ ( ".info .description" ) . text ( version _info . description ) ;
$ ( ".info .link" ) . attr ( "href" , version _info . link ) ;
$ ( ".image img" ) . attr ( "src" , version _info . image ) ;
} ;
2017-07-28 04:29:37 +02:00
$ ( window ) . on ( 'popstate' , function ( ) {
version = get _version _from _path ( ) ;
update _page ( ) ;
$ ( "body" ) . animate ( { scrollTop : 0 } , 200 ) ;
} ) ;
2017-07-08 02:28:18 +02:00
2017-07-28 04:29:37 +02:00
$ ( ".apps a .icon" ) . click ( function ( e ) {
var next _version = $ ( e . target ) . closest ( 'a' )
. attr ( 'href' )
. replace ( '/apps/' , '' ) ;
version = next _version ;
2017-07-08 02:28:18 +02:00
2017-07-28 04:29:37 +02:00
update _path ( ) ;
update _page ( ) ;
2017-07-08 02:28:18 +02:00
$ ( "body" ) . animate ( { scrollTop : 0 } , 200 ) ;
2017-07-28 04:29:37 +02:00
return false ;
2017-07-08 02:28:18 +02:00
} ) ;
2017-07-28 04:29:37 +02:00
// init
version = get _version _from _path ( ) ;
history . replaceState ( version , '' , get _path _from _version ( ) ) ;
update _page ( ) ;
2017-07-08 02:28:18 +02:00
} ;
2017-02-28 01:45:25 +01:00
var events = function ( ) {
ScrollTo ( ) ;
$ ( "a" ) . click ( function ( e ) {
// if the pathname is different than what we are already on, run the
// custom transition function.
2017-07-08 02:28:18 +02:00
if ( window . location . pathname !== this . pathname && ! this . hasAttribute ( "download" ) &&
! /no-action/ . test ( this . className ) ) {
2017-02-28 01:45:25 +01:00
e . preventDefault ( ) ;
$ ( ".portico-landing" ) . removeClass ( "show" ) ;
setTimeout ( function ( ) {
window . location . href = $ ( this ) . attr ( "href" ) ;
2017-07-27 02:23:43 +02:00
} . bind ( this ) , 500 ) ;
2017-02-28 01:45:25 +01:00
}
} ) ;
// get the location url like `zulipchat.com/features/`, cut off the trailing
// `/` and then split by `/` to get ["zulipchat.com", "features"], then
// pop the last element to get the current section (eg. `features`).
2017-03-21 01:41:50 +01:00
var location = window . location . pathname . replace ( /\/#*$/ , "" ) . split ( /\// ) . pop ( ) ;
2017-02-28 01:45:25 +01:00
$ ( "[on-page='" + location + "']" ) . addClass ( "active" ) ;
$ ( "body" ) . click ( function ( e ) {
var $e = $ ( e . target ) ;
2017-06-12 22:05:29 +02:00
if ( $e . is ( "nav ul .exit" ) ) {
2017-02-28 01:45:25 +01:00
$ ( "nav ul" ) . removeClass ( "show" ) ;
}
} ) ;
2017-05-10 19:55:40 +02:00
$ ( ".hamburger" ) . click ( function ( ) {
2017-02-28 01:45:25 +01:00
$ ( "nav ul" ) . addClass ( "show" ) ;
} ) ;
2017-05-10 19:55:40 +02:00
2017-07-18 04:40:31 +02:00
if ( path _parts ( ) . includes ( "apps" ) ) {
2017-07-08 02:28:18 +02:00
apps _events ( ) ;
}
2017-02-28 01:45:25 +01:00
2017-07-18 04:40:31 +02:00
if ( path _parts ( ) . includes ( 'hello' ) ) {
2017-04-20 20:44:49 +02:00
hello _events ( ) ;
}
2017-02-28 01:45:25 +01:00
} ;
2017-06-21 03:14:26 +02:00
2017-02-28 01:45:25 +01:00
// run this callback when the page is determined to have loaded.
var load = function ( ) {
// show the .portico-landing when the document is loaded.
setTimeout ( function ( ) {
$ ( ".portico-landing" ) . addClass ( "show" ) ;
} , 200 ) ;
// display the `x-grad` element a second after load so that the slide up
// transition on the .portico-landing is nice and smooth.
setTimeout ( function ( ) {
$ ( "x-grad" ) . addClass ( "show" ) ;
} , 1000 ) ;
2017-06-21 03:14:26 +02:00
// Set up events / categories / search
2017-02-28 01:45:25 +01:00
events ( ) ;
} ;
if ( document . readyState === "complete" ) {
load ( ) ;
} else {
$ ( document ) . ready ( load ) ;
}