/* * Licensed Materials - Property of IBM * 5725-G92 (C) Copyright IBM Corp. 2011, 2012. All Rights Reserved. * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ var itemList = new Array(); // This method is invoked after loading the main HTML and successful initialization of the Worklight runtime. function wlEnvInit(){ wlCommonInit(); // Environment initialization code goes here WL.OptionsMenu.init({opacity: "0.9"}); WL.OptionsMenu.addItem('homePage', function() {changePage("#homePage");}, 'Go to Home', {image:'', enabled : true}); itemList.push('homePage'); WL.OptionsMenu.addItem('createMem', function() {changePage("#cameraPage");}, 'Add Memory', {image:'', enabled : true}); itemList.push('createMem'); WL.OptionsMenu.addItem('listMem', function() {changePage("#listPage");}, 'My Memories', {image:'', enabled : true}); itemList.push('listMem'); WL.OptionsMenu.addItem('closeApp', function() {WL.App.close();}, 'Exit', {image:'', enabled : true}); itemList.push('closeApp'); WL.OptionsMenu.setEnabled(true); WL.OptionsMenu.setVisible(true); $(document).on('pagechange', handlePageChange); } function changePage(targetPage) { console.log('Changing page to ' + targetPage); $.mobile.changePage(targetPage); } function handlePageChange(arg, obj) { enableAll(); var pageId = $.mobile.activePage.attr('id'); var disableItem = null; if(pageId == 'homePage') { disableItem = WL.OptionsMenu.getItem('homePage'); } else if(pageId == 'cameraPage') { disableItem = WL.OptionsMenu.getItem('createMem'); } else if(pageId == 'listPage') { disableItem = WL.OptionsMenu.getItem('listMem'); } if(disableItem != null) { disableItem.setEnabled(false); } } function enableAll() { itemList.forEach(function(item) {WL.OptionsMenu.getItem(item).setEnabled(true);}); }