diff --git a/lab/static/js/lab.js b/lab/static/js/lab.js index 187f1c4a..70010584 100644 --- a/lab/static/js/lab.js +++ b/lab/static/js/lab.js @@ -2,14 +2,14 @@ var $ = document.querySelector.bind(document); var API_ROOT = '/ionic-lab/api/v1'; -var APP_CONFIG = {} +var APP_CONFIG = {}; function loadAppConfig() { var req = new XMLHttpRequest(); req.addEventListener('load', function(e) { setAppConfig(JSON.parse(req.response)); - }) - req.open('GET', API_ROOT + '/app-config', true) + }); + req.open('GET', API_ROOT + '/app-config', true); req.send(null); } @@ -17,21 +17,20 @@ function setAppConfig(data) { APP_CONFIG = data; } - function buildMenu() { buildComponentsMenu(); - const sidebar = $('#sidebar'); - const topLevels = sidebar.querySelectorAll('#menu > li > a'); + var sidebar = $('#sidebar'); + var topLevels = sidebar.querySelectorAll('#menu > li > a'); - const lastMenuConfig = window.localStorage.getItem('ionic_labmenu'); - if(lastMenuConfig === 'true' || lastMenuConfig === null) { + var lastMenuConfig = window.localStorage.getItem('ionic_labmenu'); + if (lastMenuConfig === 'true' || lastMenuConfig === null) { sidebar.classList.remove('hidden'); } - Array.prototype.map.call(topLevels, a => { - if(!a.href) { - a.addEventListener('click', e => { - if(a.parentNode.classList.contains('expanded')) { + Array.prototype.map.call(topLevels, function(a) { + if (!a.href) { + a.addEventListener('click', function(e) { + if (a.parentNode.classList.contains('expanded')) { a.parentNode.classList.remove('expanded'); } else { a.parentNode.classList.add('expanded'); @@ -39,22 +38,22 @@ function buildMenu() { e.preventDefault(); }); } - }) + }); - $('#view-ad').addEventListener('click', (e) => { + $('#view-ad').addEventListener('click', function(e) { var win = window.open('http://view.ionic.io/', '_blank'); win.focus(); - }) + }); - const toggleMenu = e => { - if(sidebar.classList.contains('hidden')) { + var toggleMenu = function(e) { + if (sidebar.classList.contains('hidden')) { sidebar.classList.remove('hidden'); window.localStorage.setItem('ionic_labmenu', 'true'); } else { sidebar.classList.add('hidden'); window.localStorage.setItem('ionic_labmenu', 'false'); } - } + }; $('#menu-toggle').addEventListener('click', toggleMenu); $('#sidebar .close').addEventListener('click', toggleMenu); @@ -63,22 +62,22 @@ function buildMenu() { function buildComponentsMenu() { var items = [{"href":"http://ionicframework.com/docs/components/#overview","title":"Overview"},{"href":"http://ionicframework.com/docs/components/#action-sheets","title":"Action Sheets"},{"href":"http://ionicframework.com/docs/components/#alert","title":"Alerts"},{"href":"http://ionicframework.com/docs/components/#badges","title":"Badges"},{"href":"http://ionicframework.com/docs/components/#buttons","title":"Buttons"},{"href":"http://ionicframework.com/docs/components/#cards","title":"Cards"},{"href":"http://ionicframework.com/docs/components/#checkbox","title":"Checkbox"},{"href":"http://ionicframework.com/docs/components/#datetime","title":"DateTime"},{"href":"http://ionicframework.com/docs/components/#fabs","title":"FABs"},{"href":"http://ionicframework.com/docs/components/#gestures","title":"Gestures"},{"href":"http://ionicframework.com/docs/components/#grid","title":"Grid"},{"href":"http://ionicframework.com/docs/components/#icons","title":"Icons"},{"href":"http://ionicframework.com/docs/components/#inputs","title":"Inputs"},{"href":"http://ionicframework.com/docs/components/#lists","title":"Lists"},{"href":"http://ionicframework.com/docs/components/#loading","title":"Loading"},{"href":"http://ionicframework.com/docs/components/#menus","title":"Menus"},{"href":"http://ionicframework.com/docs/components/#modals","title":"Modals"},{"href":"http://ionicframework.com/docs/components/#navigation","title":"Navigation"},{"href":"http://ionicframework.com/docs/components/#popovers","title":"Popover"},{"href":"http://ionicframework.com/docs/components/#radio","title":"Radio"},{"href":"http://ionicframework.com/docs/components/#range","title":"Range"},{"href":"http://ionicframework.com/docs/components/#searchbar","title":"Searchbar"},{"href":"http://ionicframework.com/docs/components/#segment","title":"Segment"},{"href":"http://ionicframework.com/docs/components/#select","title":"Select"},{"href":"http://ionicframework.com/docs/components/#slides","title":"Slides"},{"href":"http://ionicframework.com/docs/components/#tabs","title":"Tabs"},{"href":"http://ionicframework.com/docs/components/#toast","title":"Toast"},{"href":"http://ionicframework.com/docs/components/#toggle","title":"Toggle"},{"href":"http://ionicframework.com/docs/components/#toolbar","title":"Toolbar"}]; - const componentsMenu = $('#components-menu'); - items.map(i => { - const l = document.createElement('li') - const a = document.createElement('a') - a.href = i.href + var componentsMenu = $('#components-menu'); + items.map(function (i) { + var l = document.createElement('li'); + var a = document.createElement('a'); + a.href = i.href; a.target = "_blank"; - a.innerText = i.title - l.appendChild(a) - componentsMenu.appendChild(l) - }) + a.innerText = i.title; + l.appendChild(a); + componentsMenu.appendChild(l); + }); } function tryShowViewPopup() { var view = window.localStorage.getItem('ionic_viewpop'); - if(!view) { + if (!view) { $('#view-popup').style.display = 'block'; $('#view-popup .close').addEventListener('click', function(e) { window.localStorage.setItem('ionic_viewpop', true); @@ -101,14 +100,14 @@ function bindToggles() { var windows = $('#device-windows'); var devices = [iphone, android, windows]; - for(i in devices) { + for(var i in devices) { devices[i].addEventListener('change', function(e) { var device = this.name; console.log('Device changed', device, this.checked); showDevice(device, this.checked); saveLastDevices(device, this.checked); - }) + }); } } @@ -122,11 +121,11 @@ function showDevice(device, isShowing) { var clone = document.importNode(template, true); $('preview').appendChild(clone.content); //check for extra params in location.url to pass on to iframes - var params = document.location.href.split('?') + var params = document.location.href.split('?'); if (params) { - var newparams = params[params.length - 1] - var oldsrc = $('preview .frame').getAttribute('src') - $('preview .frame').setAttribute('src', oldsrc + '&' + newparams) + var newparams = params[params.length - 1]; + var oldsrc = $('preview .frame').getAttribute('src'); + $('preview .frame').setAttribute('src', oldsrc + '&' + newparams); } } else { rendered.style.display = isShowing ? '' : 'none'; @@ -163,7 +162,7 @@ function showLastDevices() { } function setCordovaInfo(data) { - let el = $('#app-info'); + var el = $('#app-info'); el.innerHTML = data.name + ' - v' + data.version; if(data.name) { document.title = data.name + ' - Ionic Lab'; @@ -174,8 +173,8 @@ function loadCordova() { var req = new XMLHttpRequest(); req.addEventListener('load', function(e) { setCordovaInfo(JSON.parse(req.response)); - }) - req.open('GET', API_ROOT + '/cordova', true) + }); + req.open('GET', API_ROOT + '/cordova', true); req.send(null); }