Created
December 4, 2015 09:02
-
-
Save AppWerft/5295a50715fcde7425ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) 2015 by satzmedia. All Rights Reserved. | |
* Author: Rainer Schleevoigt | |
* Please see the LICENSE included with this distribution for details. | |
*/ | |
var АктйонБар = require('com.alcoapps.actionbarextras'); | |
var Model = new (require('adapter/model'))(); | |
const MODELCACHE =1, TARGETPRINT=2, MENU=3; | |
module.exports = function(_event) { | |
АктйонБар.setTitle('Eppendorf'); | |
АктйонБар.setBackgroundColor('#f8f8f8'); | |
АктйонБар.setSubtitle(_event.source.subtitle || _event.source.title || ''); | |
АктйонБар.subtitleColor = "#63809c"; | |
АктйонБар.titleFont ='Compatil Fact for Epp W02 Bold'; | |
АктйонБар.subtitleFont ='Compatil Fact for Epp W02 Reg'; | |
mainmenu = Model.getMainmenu(); | |
function opennextwindow(_item) { | |
var item = mainmenu[_item.source.itemId]; | |
switch (item.app) { | |
case 'home': | |
Ti.App.fireEvent('app:gohome'); | |
break; | |
default: | |
var newwin = require('apps/'+item.app+'/index')({ | |
menu : true, | |
back : true, | |
title : item.title, | |
url : item.url, // optional for webview | |
withflipview : true, | |
data : item.data, | |
canClose : true | |
}, Model).open(); | |
} | |
} | |
var activity = _event.source.getActivity(); | |
if (activity) { | |
activity.actionBar.displayHomeAsUp = (_event.source.displayHomeAsUp==true) ? false :true; | |
activity.onCreateOptionsMenu = function(_menuevent) { | |
_menuevent.menu.clear(); | |
/* Link to Admin for Labortimer */ | |
_event.source.openadminFunc && _menuevent.menu.add({ | |
title : 'Admin', | |
itemId : MENU, | |
icon:Ti.App.Android.R.drawable.ic_action_pencil, | |
showAsAction : Ti.Android.SHOW_AS_ACTION_IF_ROOM, | |
}).addEventListener("click", function() { | |
var dialog = Ti.UI.createOptionDialog({ | |
options: [L('TIMER_EDIT'), L('TIMER_KILL')], | |
}); | |
dialog.show(); | |
dialog.addEventListener('click',function(_e){ | |
switch (_e.index) { | |
case 0: | |
_event.source.openadminFunc(); | |
break; | |
case 1: | |
_event.source.deleteEventFunc(); | |
break; | |
} | |
}); | |
}); | |
/* END*/ | |
/* Button for printmail and togo*/ | |
if (_event.source.printmail == true) { | |
var ar = mainmenu.filter(function(item){ | |
return item.app=='ar' ? true:false; | |
}); | |
var AR2Go = new (require('adapter/ar2go.adapter'))(ar[0].subcategories.map(function(m){ | |
return m.data.wt3 | |
})); | |
_menuevent.menu.add({ | |
title : '2Go', | |
itemId : MODELCACHE, | |
icon: AR2Go.areCached() ?Ti.App.Android.R.drawable.ic_action_offline:Ti.App.Android.R.drawable.ic_action_online, | |
showAsAction : Ti.Android.SHOW_AS_ACTION_IF_ROOM, | |
}).addEventListener("click", function() { | |
AR2Go.toggleAllModelsCache(); | |
AR2Go.addEventListener('onload',function(){ | |
_menuevent.menu.findItem(MODELCACHE).setIcon(AR2Go.areCached() ?Ti.App.Android.R.drawable.ic_action_offline:Ti.App.Android.R.drawable.ic_action_online); | |
}); | |
}); | |
_menuevent.menu.add({ | |
title : 'Admin', | |
itemId :TARGETPRINT, | |
icon:Ti.App.Android.R.drawable.ic_action_target, | |
showAsAction : Ti.Android.SHOW_AS_ACTION_IF_ROOM, | |
}).addEventListener("click", function() { | |
require('ui/maildialog.widget')(); | |
}); | |
} | |
mainmenu.unshift({ | |
app : 'home', | |
title : L('TITLE_OVERVIEW') | |
}); | |
mainmenu.push({ | |
app : 'legalnotes', | |
title : 'Legal Notes' | |
}); | |
mainmenu.push({ | |
app : 'imprint', | |
title : L('TITLE_IMPRINT') | |
}); | |
mainmenu.forEach(function(item,ndx) { | |
_menuevent.menu.add({ | |
title : item.title, | |
itemId : ndx, | |
payload: JSON.stringify(item), | |
showAsAction : Ti.Android.SHOW_AS_ACTION_NEVER, | |
}).addEventListener("click", opennextwindow); | |
}); | |
_event.source.addEventListener('hideMenuItem',function(){ | |
var item = _menuevent.menu.findItem('999') | |
item && item.setVisible(false); | |
}); | |
_event.source.addEventListener('showMenuItem',function(){ | |
var item = _menuevent.menu.findItem('999') | |
item && item.setVisible(true); | |
}); | |
}; | |
activity.invalidateOptionsMenu(); | |
activity.actionBar.onHomeIconItemSelected = function() { | |
!_event.source.displayHomeAsUp && _event.source.close(); | |
}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment