Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ModalPicker() {
- var self = this;
- this.cover = Titanium.UI.createWindow({
- backgroundColor: "#fff",
- opacity: 0.3,
- fullscreen: true,
- height: Titanium.Platform.displayCaps.platformHeight,
- bottom: 0,
- zIndex: 1000
- });
- this.picker_view = Titanium.UI.createView({
- height: 251,
- bottom: -251,
- zIndex: 1010
- });
- this.cancel = Titanium.UI.createButton({
- title: 'Cancel',
- /* TODO: Fix this */
- style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED,
- zIndex: 1020
- });
- this.done = Titanium.UI.createButton({
- title: 'Done',
- /* TODO: Fix this */
- style: Titanium.UI.iPhone.SystemButtonStyle.DONE,
- zIndex: 1020
- });
- this.spacer = Titanium.UI.createButton({
- /* TODO: Fix this */
- systemButton: Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE,
- zIndex: 1020
- });
- this.picker = Ti.UI.createPicker({
- top: 43
- });
- this.slide_in = Titanium.UI.createAnimation({
- bottom: 0
- });
- this.slide_out = Titanium.UI.createAnimation({
- bottom: -251
- });
- this.init = function () {
- tt.ui.View.add(self.cover);
- self.cover.hide();
- self.picker.selectionIndicator = true;
- self.picker_view.add(self.picker);
- self.toolbar = Titanium.UI.createToolbar({
- top: 0,
- items: [self.cancel, self.spacer, self.done]
- });
- self.picker_view.add(self.toolbar);
- self.cancel.addEventListener('click', function (e) {
- self.cover.hide();
- self.picker_view.animate(self.slide_out);
- });
- tt.ui.View.add(self.picker_view);
- }
- this.show = function (params) {
- self.picker.columns = [];
- self.picker.add(params.data);
- if (self.done.lastEventListener) {
- self.done.removeEventListener('click', self.done.lastEventListener);
- }
- self.done.lastEventListener = params.on_select;
- self.done.addEventListener('click', params.on_select);
- self.cover.show();
- self.picker_view.animate(self.slide_in);
- }
- this.hide = function () {
- self.cover.hide();
- self.picker_view.animate(self.slide_out);
- }
- }
Add Comment
Please, Sign In to add comment