topical media & game development
lib-flow-example-files-global-0.js / js
$(function() {
$("#logout").click(function() {
return account.logout();
});
//{{{ messy highlighting stuff
// highlight global nav
var els = location.pathname.split("/");
var f = "/" + els[1];
if (f.indexOf("#") != -1) f = f.substring(0, f.indexOf("#"));
if (f == '/tools') f = '/plugins';
else if (f == '/documentation' || f == '/tutorials') f = '/demos';
else if (f == '/index.html' || f == '/') f = "";
$("#globalnav a").filter("[href=" + f + "/index.html]").addClass("active");
// hightlight subnav
var loc = location.href;
var page = loc.substring(loc.indexOf("/", 10), loc.indexOf("?") > 0 ? loc.indexOf("?") : loc.length);
if (page.indexOf("#") != -1) {
page = page.substring(0, page.indexOf("#"));
}
var el = $("#right ul a[href=" +page+ "]");
if (!el.length && (f == 'documentation' || f == 'account')) el = $("#right ul a:first");
el.addClass("selected").click(function(e) {
e.preventDefault();
});
// remove redundant borders from subnav
$("#right ul").each(function() {
this.find("a:last").css("borderBottom", 0);
});
// setup main title background image
f = f.substring(1);
if (f == 'plugins' && els[2] && els[2] != 'index.html') {
f = els[2];
if (els[1] == 'tools') f = "tools";
}
if (f == 'demos') {
f = "documentation";
}
var title = $("#content h1:first");
if (f && title.length && title.css("backgroundImage") == 'none') {
if (f == 'admin') f = 'flowplayer';
title.css("backgroundImage", "url(http://static.flowplayer.org/img/title/" + f + ".png)");
}
//}}}
//{{{ HOME PAGE
/*
Scripting of the home page. You can freely study it and steal ideas to your site.
*/
if (f == '') {
$("#demo div.item").show();
/*
tabbed navigation uses our jquery.scrollable tool, see:
http://flowplayer.org/tools/scrollable.html
*/
$("#tab_panes").scrollable({
items: '#items',
size: 1,
navi: '#tabs',
onBeforeSeek: function(i) {
f("player1", {src:v.core}, {
// this will enable pseudostreaming support
plugins: {
pseudo: { url: v.pseudostreaming },
controls: {
backgroundColor:'#000000',
backgroundGradient: 'low'
}
},
// clip properties
clip: {
provider: 'pseudo',
url: 'http://pseudo-s3.simplecdn.net/flowplayer-700.flv'
},
onFinish: function() {
this.unload();
}
}).embed();
$("#embedPane textarea").html(player.getEmbedCode());
//}}}
//{{{ plugins
var player = f("player3", {src: v.core, bgcolor: '#112233'}, {
clip: {
provider: flashembed.isSupported([9, 115]) ? 'rtmp' : 'pseudo',
url: flashembed.isSupported([9, 115]) ? null : 'http://pseudo-s3.simplecdn.net/flowplayer-700.flv'
},
onBeforeClick: function() {
var wrap = $(this.getParent());
wrap.next("div.col").hide();
wrap.expose({
opacity:0.9,
color: null,
closeOnClick: false,
onClose: function() {
f(this).load();
$("#exposeMask").html("<p>This MP4 video is streamed globally using a <em>Content Delivery Network</em> (CDN). Look for the amazing video quality. Use our tube- skinned controlbar to jump anywhere on the timeline. <br /><span>Press ESC to close.</span></p>");
});
return false;
},
onUnload: function() {
$(this.getParent()).css({width: null, height: null, marginTop: null});
$("#exposeMask").html("");
$(this.getParent()).next("div.col").fadeIn("slow");
},
plugins: {
rtmp: {
url: v.rtmp,
netConnectionUrl: 'rtmpt://flash-7.simplecdn.net/play'
},
pseudo: { url: v.pseudostreaming},
controls: {
url: v.tube,
autoHide: 'always',
hideDelay: 800
}
},
canvas: {
backgroundGradient: [0.01, 0.03]
}
});
//}}}
//{{{ scripting
// setup player into overlayed content
f("overlay_player").load();
},
// unload player when overlay is closed
onClose: function() {
f().unload();
}
});
//}}}
// preload largest images for future use
window.load(function() {
setTimeout(function() {
var base = "http://static.flowplayer.org/img";
new Image().src = base + "/commerce/products-hero.jpg";
new Image().src = base + "/demos/hero.jpg";
new Image().src = base + "/plugins-hero.jpg";
}, 2000);
});
} // end home }}}
// lazy download of jquery.chili.js
if ($("code[class]").length) {
.post("/account/login?" + form.serialize(), function(res) {
res = eval("(" + res + ")");
if (res.message) {
form.find("div.error").html(res.message).show();
} else {
if (location.href.indexOf("download") != -1) {
location.href = "/account/products.html";
} else {
location.reload();
}
}
});
return false;
},
create: function(form) {
form = form;
.getJSON("/account/requestPassword?" + form.serialize(), function(json) {
if (json.message) {
form.find("div.error").html(json.message).show();
} else {
form.html("Your new password was sent to you by email");
}
});
return false;
},
logout: function() {
.getJSON(form.attr("action") + "?" + form.serialize(), function(json) {
form.fadeTo(400, 1);
if (json.message) {
form.find("div.error").html(json.message).show();
} else {
if (to) {
location.href = to;
} else {
location.reload();
}
}
});
return false;
}
}
$(function() {
// email and embed tab actions
$("#panes + #shareTabs a").click(function(e) {
f().show();
});
/*
email form setup. depends on simple JSON responses of the form
- on error: {message: 'error message'}
- otherwise it's successs
*/
$("#shareForm").submit(function(e) {
var form = this;
form.fadeTo(500, 0.1);
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.