1
YUI().use('node','gallery-carousel','gallery-carousel-anim','substitute', 'gallery-effects','cookie','event-resize','jsonp', 'io', 'dump', 'json-parse', function(Y) {
3
var lp_lookup_callback = {
6
success : function (id, response) {
9
messages = Y.JSON.parse(response.responseText);
11
Y.log("JSON Parse failed!");
14
Y.one('#lp_error').setHTML(messages.message);
16
failure : function (id, response) {
17
Y.log("Async call failed!");
22
core.setupFeatureDisplay = function() {
23
if(Y.one('.list-features-content') != null) {
24
Y.all('.list-features-content li').setStyle('display','none');
25
Y.one('#list-feature-saas').setStyle('display','block');
26
Y.all('.nav-list-features li').each(function (node) {
27
node.delegate('click', function(e){
29
var clicked = this.get('text');
30
Y.all('.nav-list-features li a').removeClass('active');
31
this.addClass('active');
35
toShow = '#list-feature-saas';
37
case 'Service orchestration':
38
toShow = '#list-feature-orchestration';
41
toShow = '#list-feature-paas';
44
toShow = '#list-feature-guest';
47
toShow = '#list-feature-public';
50
toShow = '#list-feature-private';
52
case 'Virtualisation':
53
toShow = '#list-feature-virtualisation';
56
Y.all('.list-features-content li').setStyle('display','none');
57
Y.one(toShow).setStyle('display','block');
64
core.setupAnimations = function(){
65
if(Y.one('body').hasClass('phone-home')) {
70
if(Y.one('body').hasClass('phone-developers') || Y.one('body').hasClass('phone-home') || Y.one('body').hasClass('phone-partners')){
71
var edgeMagic = Y.all('.edge-magic');
72
Y.on('scroll', function(e) {
73
edgeMagic.each(function (node) {
74
if(window.scrollY > node.getXY()[1] - yOffset && window.scrollY < node.getXY()[1] && !node.run){
76
node.one('.slider-animation').addClass('run');
77
if(node.one('.slider-animation').getAttribute('class') == 'slider-animation full-swipe run'){
78
setTimeout(function(){ node.one('.launcher').addClass('return') }, 2000);
84
Y.all('.replay').on('click', function(e){
86
core.rerunAnimation(e.target.get('parentNode').one('.slider-animation').getAttribute('class').replace('slider-animation ','').replace(' run',''));
88
if(Y.one('.content-controls .gallery-screen')){
89
Y.one('.content-controls .gallery-screen').setStyle('display','block');
91
setInterval(function(){
92
Y.all('.infographic .main-image').addClass('hide');
93
Y.one('.infographic .info-pic-'+infoIndex).removeClass('hide');
94
if(++infoIndex > 4){ infoIndex = 0; }
100
if(Y.one('body').hasClass('phone-features')){
101
var videoPanel = Y.all('.row--video');
102
if(Y.one('.show-video')){
103
Y.one('.show-video').on('click',function(e) {
105
videoPanel.addClass('show');
106
Y.one('.the-video div').set('innerHTML','<div class="video-container"><iframe width="984" height="554" src="http://www.youtube.com/embed/-dpfHYpfEXY?showinfo=0&vq=hd1080&rel=0&modestbranding=0&autoplay=1" frameborder="0" allowfullscreen></iframe></div>');
110
Y.one('.row--scopes__nearby .row--scopes__content').append('<a href="#" class="trigger">Explore what’s near you ›</a><a href="#" class="return">Back to NearBy ›</a>');
112
Y.one('.row--scopes__news .row--scopes__content').append('<a href="#" class="trigger">Keep up to date with news ›</a><a href="#" class="return">Back to all news ›</a>');
114
Y.one('.row--scopes__music .row--scopes__content').append('<a href="#" class="trigger">Browse music online ›</a><a href="#" class="return">Back to all music ›</a>');
116
Y.all('a.trigger').each(function() {
117
this.on('click',function(e) {
119
Y.all('.row--scopes').removeClass('branded');
120
Y.one(this).get('parentNode').get('parentNode').get('parentNode').get('parentNode').addClass('branded').removeClass('vanilla');
124
Y.all('a.return').each(function() {
125
this.on('click',function(e) {
127
Y.one(this).get('parentNode').get('parentNode').get('parentNode').get('parentNode').addClass('vanilla').removeClass('branded');
132
var edgeMagic = Y.all('.row--scopes');
133
Y.on('scroll', function(e) {
134
edgeMagic.each(function (node) {
135
if(window.scrollY > node.getXY()[1] + yOffset && window.scrollY < node.getXY()[1] && !node.run){
137
node.removeClass('branded');
141
} // end if(Y.one('body').hasClass('phone-features'))
143
if(Y.one('body').hasClass('tablet-design') || Y.one('body').hasClass('phone-home')) {
144
if(Y.one('body').hasClass('tablet-design')) {
145
var edgeMagic = Y.all('.slider-animation');
147
var videoPanel = Y.all('.the-video');
148
Y.on('scroll', function(e) {
149
edgeMagic.each(function (node) {
150
if(window.scrollY > node.getXY()[1] - yOffset && window.scrollY < node.getXY()[1] && !node.run){
152
node.addClass('run');
157
Y.all('.screen').on('click', function(e){
158
core.rerunAnimation(e.target.get('parentNode').get('parentNode').get('parentNode').one('.slider-animation').getAttribute('class').replace('slider-animation ','').replace(' run',''));
161
Y.all('.replay').on('click', function(e){
163
core.rerunAnimation(e.target.get('parentNode').one('.slider-animation').getAttribute('class').replace('slider-animation ','').replace(' run',''));
165
if(Y.one('.show-video')){
166
Y.one('.show-video').on('click',function(e) {
168
videoPanel.addClass('show');
169
if(Y.one('body').hasClass('tablet-design')){
170
Y.one('.row-hero').setStyle('height','590px');
171
Y.one('.the-video div').set('innerHTML','<iframe width="984" height="554" src="http://www.youtube.com/embed/-dpfHYpfEXY?showinfo=0&vq=hd1080&rel=0&modestbranding=0&autoplay=1" frameborder="0" allowfullscreen></iframe>');
173
Y.one('.row-hero').setStyle('height','588px').append('<div id="topbar"></div>'), 2000;
175
Y.one('.row-hero .row-content').removeClass('show-me').addClass('hide-me');
176
Y.one('.the-video div').set('innerHTML','<iframe width="984" height="554" src="http://www.youtube.com/embed/-dpfHYpfEXY?showinfo=0&vq=hd1080&rel=0&modestbranding=0&autoplay=1" frameborder="0" allowfullscreen></iframe>');
180
if(Y.one('.close-video')){
181
Y.one('.close-video').on('click',function(e) {
183
videoPanel.removeClass('show');
184
if(Y.one('body').hasClass('tablet-design')){
185
Y.one('.row-hero').setStyle('height','460px');
187
Y.one('.row-hero').setStyle('height','678px');
188
Y.one('#topbar').remove()
189
Y.one('.row-hero .row-content').addClass('show-me');
191
Y.one('.the-video div').set('innerHTML','');
197
core.scopesSlideshow = function() {
199
if(Y.one('.row-slideshow')){
200
var carousel = new Y.Carousel({
201
boundingBox: "#carousel-container",
202
contentBox: "#carousel-container > ul",
204
autoPlayInterval: 3500,
209
carousel.plug(Y.CarouselAnimPlugin,{animation:{speed: 0.8,effect: Y.Easing.easeOutStrong }});
211
carousel.startAutoPlay();
215
core.runAnimation = function($anim) {
217
case 'search-screen':
218
Y.one('.search-screen').addClass('run');
219
setTimeout(function(){ Y.one('.search-screen').removeClass('run'); }, 2000);
222
Y.one('.go-back').addClass('run');
227
core.updateSlider = function( $index ) {
228
if($index >= 4){ $index = 0; }
229
if($index <= -1){ $index = 3; }
230
YUI().use('node', function(Y) {
231
Y.one('.slide-container').setStyle('left','-'+(700 * $index)+'px');
232
Y.all('.slider-dots li').removeClass('active');
233
Y.all('.slider-dots li.pip-'+$index).addClass('active');
234
Y.all('.slider-animation').removeClass('run');
235
Y.one('.full-swipe .launcher').removeClass('return');
238
setTimeout(function(){ Y.one('.edge-magic').addClass('run'); }, 1200);
241
setTimeout(function(){ Y.one('.full-swipe').addClass('run');}, 1200);
242
setTimeout(function(){ Y.one('.full-swipe .launcher').addClass('return') }, 2000);
245
setTimeout(function(){ Y.one('.go-back').addClass('run'); }, 1200);
248
setTimeout(function(){ Y.one('.content-controls').addClass('run'); }, 1200);
255
core.rerunAnimation = function($type){
256
Y.one('.'+$type).removeClass('run');
257
if($type == 'full-swipe'){
258
Y.one('.full-swipe .launcher').removeClass('return');
259
setTimeout(function(){ Y.one('.full-swipe').addClass('run'); }, 400);
260
setTimeout(function(){ Y.one('.full-swipe .launcher').addClass('return') }, 1400);
261
}else if($type == 'notification-slider' || $type == 'search-screen'){
262
Y.one('.'+$type).removeClass('run');
263
setTimeout(function(){ Y.one('.'+$type).addClass('run'); }, 1000);
264
}else if($type == 'slider-animation') {
267
Y.one('.'+$type).removeClass('run');
268
setTimeout(function(){ Y.one('.'+$type).addClass('run'); }, 400);
272
core.flipVideo = function(){
273
if(Y.one('body').hasClass('phone-home')) {
274
if(Y.one('.show-video')) {
275
Y.one('.show-video').on('click',function(e) {
277
Y.one('#panel').addClass('flipped');
278
setTimeout(function(){ Y.one('.the-video').set('innerHTML','<iframe width="569" height="320" src="http://www.youtube.com/embed/cpWHJDLsqTU?showinfo=0&hd=1&rel=0&modestbranding=0&autoplay=1" frameborder="0" allowfullscreen></iframe>');Y.one('#panel .back').setStyle('z-index', '50');}, 1000);
281
if(Y.one('.close-video')) {
282
Y.one('.close-video').on('click',function(e) {
284
Y.one('#panel .back').setStyle('z-index', '0');
285
Y.one('.the-video').set('innerHTML','');
286
Y.one('#panel').removeClass('flipped');
292
core.externalLinks = function() {
293
Y.all('a.external-link').each(function() {
294
this.on('click',function(e) {
296
window.open(this.getAttribute('href'), '_blank');
301
core.chineseDownload = function() {
302
if(Y.one('body').hasClass('download-desktop-zh-CN')){
303
var ltsform = Y.one('form.lts');
304
var latestform = Y.one('form.latest');
305
Y.one('form.lts button').on('click',function(e){
307
this.set('text','开始...');
311
Y.one('form.latest button').on('click',function(e){
313
this.set('text','开始...');
317
Y.one('.lts .input-bits').on('change', function() {
318
var bits = Y.one('form.lts .text-bits');
319
var form_cta = ltsform.one('.link-cta-ubuntu');
320
var val = this.get('value');
321
var iso = val == '32' ? 'http://china-images.ubuntu.com/releases/12.04/ubuntu-12.04-desktop-i386.iso' : 'http://china-images.ubuntu.com/releases/12.04/ubuntu-12.04-desktop-amd64.iso';
322
ltsform.setAttribute('action', iso);
323
bits.set('text',val);
325
Y.one('.latest .input-bits').on('change', function() {
326
var bits = Y.one('form.latest .text-bits');
327
var form_cta = latestform.one('.link-cta-ubuntu');
328
var val = this.get('value');
329
var iso = val == '32' ? 'http://cdimage.ubuntu.com/ubuntukylin/releases/13.10/release/ubuntukylin-13.10-desktop-i386.iso' : 'http://cdimage.ubuntu.com/ubuntukylin/releases/13.10/release/ubuntukylin-13.10-desktop-amd64.iso';
330
latestform.setAttribute('action', iso);
331
bits.set('text',val);
336
core.cookiePolicy = function() {
337
if(Y.Cookie.get("_cookies_accepted") != 'true'){
342
YUI().use('node', function(Y) {
343
Y.one('body').prepend('<div class="cookie-policy"><div class="wrapper"><a href="?cp=close" class="link-cta">Close</a><p>We use cookies to improve your experience. By your continued use of this site you accept such use. To change your settings please <a href="http://www.ubuntu.com/legal/terms-and-policies/privacy-policy#cookies">see our policy</a>.</p></div></div>');
344
Y.one('footer.global .legal').addClass('has-cookie');
345
Y.one('.cookie-policy .link-cta').on('click',function(e){
352
YUI().use('node', function(Y) {
353
Y.one('.cookie-policy').setStyle('display','none');
357
function setCookie() {
358
YUI().use('cookie', function (Y) {
359
Y.Cookie.set("_cookies_accepted", "true", { expires: new Date("January 12, 2025") });
364
core.supportsTransitions = function() {
365
var b = document.body || document.documentElement;
367
var p = 'transition';
368
if(typeof s[p] == 'string') {return true; }
369
// Tests for vendor specific prop
370
v = ['Moz', 'webkit', 'Webkit', 'Khtml', 'O', 'ms'],
371
p = p.charAt(0).toUpperCase() + p.substr(1);
372
for(var i=0; i<v.length; i++) {
373
if(typeof s[v[i] + p] == 'string') { return true; }
378
core.setHTMLClasses = function(){
379
if(Y.one('body').hasClass('homepage')){
380
if (!core.supportsTransitions()) {
381
document.getElementsByTagName("html")[0].className += " no-transitions";
383
document.getElementsByTagName("html")[0].className += " run";
388
core.removeNoJS = function(){
389
Y.all('html').removeClass('no-js').addClass('yes-js');
392
core.footerMobileNav = function() {
393
Y.all('.footer-a li h2').on('click', function(e) {
394
e.target.toggleClass('active open');
396
Y.all('.footer-b li h2').on('click', function(e) {
397
e.target.toggleClass('active open');
401
core.resizeListener = function() {
402
Y.on('windowresize', function(e) {
408
core.globalInit= function() {
409
if (document.documentElement.clientWidth < 768) {
410
core.globalPrepend = 'div.legal';
411
core.setupGlobalNav();
412
Y.one('.nav-global-wrapper').insert('<h2>Ubuntu websites</h2>','before');
413
} else if (document.documentElement.clientWidth >= 768) {
414
core.globalPrepend = 'body';
415
core.setupGlobalNav();
416
Y.all('#additional-info h2').setStyle('cursor', 'default');
417
Y.one('footer.global').addClass('no-global');
421
core.redrawGlobal = function() {
422
var globalNav = Y.one("#nav-global");
423
if (document.documentElement.clientWidth < 768 && core.globalPrepend != 'div.legal') {
424
core.globalPrepend = 'div.legal';
427
core.setupGlobalNav();
428
Y.one('.nav-global-wrapper').insert('<h2>Ubuntu websites</h2>','before');
429
Y.one('#nav-global h2').setStyle('cursor', 'pointer').append('<span></span>').on('click',function(e) {
430
this.toggleClass('active');
431
this.next('div').toggleClass('active');
434
} else if (document.documentElement.clientWidth >= 768 && core.globalPrepend != 'body') {
435
Y.one('footer.global').addClass('no-global');
436
core.globalPrepend = 'body';
439
core.setupGlobalNav();
444
core.setupGlobalNavAccordion = function() {
445
if(Y.one('#nav-global h2') !== null) {
446
Y.one('#nav-global h2').setStyle('cursor', 'pointer').append('<span></span>').on('click',function(e) {
447
this.toggleClass('active');
448
this.next('div').toggleClass('active');
453
core.navOnboarding = function() {
455
var nav_secondary = Y.one('.nav-secondary');
456
if(nav_secondary && !nav_secondary.test(':empty')) {
457
if(Y.one('html').hasClass('localstorage')) {
458
if(localStorage.getItem(key) === null) {
459
nav_secondary.addClass('open');
461
ls = JSON.parse(localStorage.getItem( key ));
462
if(ls.navigation !== 'onboard') {
463
nav_secondary.addClass('open');
469
core.setLocalStorage = function($value) {
473
var nav_secondary = Y.one('.nav-secondary');
474
ubuntu.navigation = value;
475
localStorage.setItem(key,JSON.stringify(ubuntu));
478
core.renderJSON = function (response, id) {
479
if (id == undefined) {
480
id = '#dynamic-logos';
483
var numberPartners = JSON.length;
484
var numberToDisplay = numberPartners < 10 ? numberPartners : 10;
486
for (var i = 0; i < numberToDisplay; i++) {
487
Y.one(id).append(Y.Node.create('<li><img onload="this.style.opacity=\'1\';" src="'+JSON[i].logo+'" alt="'+JSON[i].name+'"></li>'));
491
core.loadPartners = function (params, elementID) {
492
var partnersAPI = "http://partners.ubuntu.com/partners.json";
493
var url = partnersAPI + params + "&callback={callback}";
494
var callback = function(response) {
495
return core.renderJSON(response, elementID);
497
Y.jsonp(url, callback);
501
core.setupFeatureDisplay();
502
core.setupAnimations();
504
core.externalLinks();
506
core.setHTMLClasses();
507
core.resizeListener();
508
core.footerMobileNav();
509
core.setupGlobalNavAccordion();
510
core.navOnboarding();
511
core.scopesSlideshow();