Created
October 24, 2014 16:20
-
-
Save mikefogg/c3d75c5ce6c3d32b4727 to your computer and use it in GitHub Desktop.
Titanium TiDraggable BubbleParent Issue: app.js
This file contains hidden or 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
// this sets the background color of the master UIView (when there are no windows/tab groups on it) | |
Titanium.UI.setBackgroundColor('#000'); | |
// create tab group | |
var tabGroup = Titanium.UI.createTabGroup(); | |
// Load Draggable | |
var Draggable = require('ti.draggable'); | |
// | |
// create the table view setup | |
// | |
var win = Titanium.UI.createWindow({ | |
title:"Test" | |
}); | |
// create a view container | |
var DraggableView = Draggable.createView({ | |
top: 0, | |
left: 0, | |
right: 0, | |
bottom: 0, | |
draggableConfig: { | |
minLeft: 0, | |
maxLeft: 0, | |
minTop: 0, | |
maxTop: 0, | |
ensureBottom: true, | |
enabled: false | |
} | |
}); | |
var container = Ti.UI.createView({ | |
top: 0, | |
left: 0, | |
right: 0, | |
bottom: 0, | |
bubbleParent: false | |
}); | |
// | |
// add some events so we can listen | |
// | |
var events = ["start", "move", "end", "cancel"]; | |
for(var i=0;i<events.length;i++){ | |
DraggableView.addEventListener(events[i], function(e){ | |
console.log( | |
'Event: ' + e.type, | |
'Left: ' + e.left, | |
'Top: ' + e.top | |
); | |
}); | |
}; | |
// create table view data object | |
var data = [ | |
{title:'Row 1', hasChild:true}, | |
{title:'Row 2', hasDetail:true}, | |
{title:'Row 3'}, | |
{title:'Row 4'}, | |
{title:'Row 5'}, | |
{title:'Row 6'}, | |
{title:'Row 7'} | |
]; | |
// create table view | |
var tableview = Titanium.UI.createTableView({ | |
data:data, | |
bubbleParent: false | |
}); | |
// create table view event listener | |
tableview.addEventListener('click', function(e) | |
{ | |
// event data | |
var index = e.index; | |
var section = e.section; | |
var row = e.row; | |
var rowdata = e.rowData; | |
Titanium.API.info("row - row index = "+row+", row section = "+row); | |
Titanium.UI.createAlertDialog({title:'Table View',message:'row ' + row + ' index ' + index + ' section ' + section + ' row data ' + rowdata}).show(); | |
}); | |
// add move event listener | |
tableview.addEventListener('move',function(e) | |
{ | |
Titanium.API.info("move - row="+e.row+", index="+e.index+", section="+e.section+", from = "+e.fromIndex); | |
}); | |
// add table view to container | |
container.add(tableview); | |
DraggableView.add(container); | |
// add container to the window | |
win.add(DraggableView); | |
// | |
// create edit/cancel buttons for nav bar | |
// | |
var edit = Titanium.UI.createButton({ | |
title:'Move' | |
}); | |
edit.addEventListener('click', function() | |
{ | |
win.setRightNavButton(cancel); | |
tableview.moving = true; | |
}); | |
var cancel = Titanium.UI.createButton({ | |
title:'Cancel', | |
style:Titanium.UI.iPhone.SystemButtonStyle.DONE | |
}); | |
cancel.addEventListener('click', function() | |
{ | |
win.setRightNavButton(edit); | |
tableview.moving = false; | |
}); | |
win.setRightNavButton(edit); | |
var tab1 = Titanium.UI.createTab({ | |
icon:'KS_nav_views.png', | |
title:'Tab 1', | |
window:win | |
}); | |
// | |
// add tabs | |
// | |
tabGroup.addTab(tab1); | |
// open tab group | |
tabGroup.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment