Sie sind auf Seite 1von 3

/** * @author: ehungampola (Erandika Umal Hungampola (c)2012*) * @App ID: Erandika Sample eBook Viewer * @Comments: Display

summary of the selected ebook */ //Titanium.UI.setBackgroundColor('#066'); var currentWin = Ti.UI.currentWindow; var TeBookName = Ti.UI.currentWindow.TeBookName; //var TeBookName = Ti.UI.currentWindow.title; //alert("this is a message"+ TeBookName); var db = Ti.Database.install('../DB/eBooksDB', 'eBooksTable'); var rows = db.execute('SELECT * FROM eBooksTable WHERE eBookName="' + TeBookName + '"'); var data = []; var tableview = Ti.UI.createTableView({ //data:data }); var TSmallImg = Ti.UI.createImageView({ image : '../images/' + rows.fieldByName('ebookSmallPic') + '.jpg', width : 'auto', height : 'auto', left : 4, top : 2 }); var TeBookName = Ti.UI.createLabel({ text : 'eBook Title: ' + rows.fieldByName('eBookName'), font : { fontSize : 16, fontWeight : 'bold' }, width : 'auto', textAlign : 'left', top : 2, left : 140, height : 'auto' }); var TeBookPrice = Ti.UI.createLabel({ text : 'Price: ' + rows.fieldByName('eBookPrice'), font : { fontSize : 16, fontWeight : 'bold' }, width : 'auto', textAlign : 'left', top : 22, left : 140, height : 'auto' }); var TeBookPromo = Ti.UI.createLabel({ text : 'Promotions :' + rows.fieldByName('eBookPromo'), font : { fontSize : 16,

fontWeight : 'bold' }, width : 'auto', textAlign : 'left', top : 40, left : 140, height : 'auto' }); var TeBookISBN = Ti.UI.createLabel({ text : 'ISBN ID :' + rows.fieldByName('eBookISBN'), font : { fontSize : 16, fontWeight : 'bold' }, width : 'auto', textAlign : 'left', top : 60, left : 140, height : 'auto' }); var TLogo1 = Ti.UI.createImageView({ image : '../images/ebookLogo1.jpg', width : 100, height : 85, left : 1000, top : 2 }); var row = Ti.UI.createTableViewRow(); row.add(TSmallImg); row.add(TeBookName); row.add(TeBookPrice); row.add(TeBookPromo); row.add(TeBookISBN); row.add(TLogo1); row.hasChild = false; row.title =rows.fieldByName('eBookName'); row.className = 'eBook_Summary_row1'; data.push(row); var TeBookDescription = Ti.UI.createLabel({ text : rows.fieldByName('eBookDescription'), font : { fontSize : 16, fontWeight : 'bold' }, width : 900, textAlign : 'left', top : 2, left : 4, height : 'auto' }); var TLrageImg = Ti.UI.createImageView({ image : '../images/' + rows.fieldByName('ebookLargePic') + '.jpg', width : 'auto', height : 'auto', left : 950, top : 2 }); var TeBookAuthor = Ti.UI.createLabel({

text : 'Author :' + rows.fieldByName('eBookAuthor'), font : { fontSize : 16, fontWeight : 'bold' }, width : 'auto', textAlign : 'left', top : 310, left : 950, height : 'auto' }); var TeBookAboutAuthor = Ti.UI.createLabel({ text : 'Authors Profile :' + rows.fieldByName('eBookAboutAuthor'), font : { fontSize : 16, fontWeight : 'bold' }, width : 290, textAlign : 'left', top : 340, left : 950, height : 'auto' }); var TeBookPDFButton = Titanium.UI.createButton({ title: 'View this eBook online', top : 490, left : 950 }); TeBookPDFButton.myfield = rows.fieldByName('eBookName'); var row = Ti.UI.createTableViewRow(); row.add(TeBookDescription); row.add(TLrageImg); row.add(TeBookAuthor) row.add(TeBookAboutAuthor) row.add(TeBookPDFButton) row.hasChild = false; row.title = rows.fieldByName('eBookName'), row.className = 'eBook_Summary_row2'; data.push(row); tableview.setData(data); TeBookPDFButton.addEventListener('click', function(e) { var winPDF = Ti.UI.createWindow({ url : '../eBooks/eBook_PDF_viwer.js', title : e.source.myfield, }) var TeBookPDFName = e.source.myfield; //winPDF.TeBookPDFName = TeBookPDFName; Ti.UI.currentTab.open(winPDF); }); currentWin.add(tableview);

Das könnte Ihnen auch gefallen