Skip to content
Browse files

made small changes to multiple UI pages

  • Loading branch information...
1 parent b3f3b34 commit f4148e8dec02e4e7919a217d483854213a380bde @n8fr8 n8fr8 committed Mar 18, 2011
View
45 Resources/app.js
@@ -14,8 +14,8 @@ var winHome;
winHome = Titanium.UI.createWindow({
title:'New York State Senate',
- url:'views/homemenu.js',
- //url:'views/window/newsroom.js',
+ //url:'views/homemenu.js',
+url:'views/newsroom.js',
barColor:DEFAULT_BAR_COLOR,
backgroundImage:"img/bg/black.png",
// orientationModes:[Titanium.UI.PORTRAIT]
@@ -107,49 +107,10 @@ var tabMore = Titanium.UI.createTab({
tabGroup.addTab(tabMore);
-var hadWelcome = Titanium.App.Properties.getString("welcome");
-
// open tab group with a transition animation
tabGroup.open({
transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
});
-if (!hadWelcome)
-{
-
-
- //
- // BASIC OPTIONS DIALOG
- //
- var dialog = Titanium.UI.createOptionDialog({
- options:['Lookup My Senator', 'No thanks'],
- title:'Would you like to find your Senator?'
- });
-
- // add event listener
- dialog.addEventListener('click',function(e)
- {
- if (e.index == 0)
- {
- // tabGroup.setActiveTab(2);
- var winSearch = Titanium.UI.createWindow({
- url:'views/findsenator.js',
- title:'Senator Search',
- barColor:DEFAULT_BAR_COLOR,
- backgroundImage:'img/bg/Default.png'
-
- });
- tabHome.open(winSearch,{animated:true});
-
- }
-
- Titanium.App.Properties.setString("welcome","done");
-
- });
-
- dialog.show();
-
-
-
-}
+
View
BIN Resources/img/bg/chamber.jpg
Deleted file not rendered
View
29 Resources/views/homemenu.js
@@ -1,8 +1,9 @@
Ti.include("../globals.js");
+
// create table view data object
var data = [
- {title:'SENATORS', summary:'', hasDetail:true, tag:2, icon:'../img/tabs/man.png'},
+ {title:'SENATORS', summary:'', hasDetail:true, tab:2, icon:'../img/tabs/man.png'},
{title:'NEWSROOM', summary:'', hasDetail:true, ilink:'newsroom.js', icon:'../img/tabs/newspaper.png'},
{title:'LEGISLATION', summary:'', hasDetail:true, ilink:'legislation.js', icon:'../img/tabs/database.png'},
{title:'LATEST VIDEOS', summary:'', hasDetail:true, ilink:'videos.js', icon:'../img/tabs/star.png'},
@@ -15,8 +16,6 @@ var tableview = Titanium.UI.createTableView(
backgroundColor:"#ffffff"
});
-
-
for (var c = 0; c < data.length; c++)
{
@@ -47,20 +46,20 @@ tableview.addEventListener('click', function(e)
{
if (e.rowData.tab)
{
- Titanium.UI.currentTab.setActiveTab(e.rowData.tab);
+ //Titanium.UI.currentTab.setActiveTab(e.rowData.tab);
}
else if (e.rowData.ilink)
{
- subWin = Titanium.UI.createWindow({
- url:e.rowData.ilink,
- title:e.rowData.pageTitle
-
- });
+ subWin = Titanium.UI.createWindow({
+ url:e.rowData.ilink,
+ title:e.rowData.pageTitle
+
+ });
- subWin.channel = e.rowData.channel;
-
- subWin.barColor = DEFAULT_BAR_COLOR;
- Titanium.UI.currentTab.open(subWin,{animated:true});
+ subWin.channel = e.rowData.channel;
+
+ subWin.barColor = DEFAULT_BAR_COLOR;
+ Ti.UI.currentTab.open(subWin,{animated:true});
}
if (e.rowData.elink)
{
@@ -80,9 +79,9 @@ tableview.addEventListener('click', function(e)
subWin.barColor = DEFAULT_BAR_COLOR;
subWin.rss = e.rowData.rss;
- Titanium.UI.currentTab.open(subWin,{animated:true});
+ Ti.UI.currentTab.open(subWin,{animated:true});
}
});
// add table view to the window
-Titanium.UI.currentWindow.add(tableview);
+Ti.UI.currentTab.add(tableview);
View
5 Resources/views/more.js
@@ -5,8 +5,6 @@ var data = [
{title:'Video Search', summary:'Access to the YouTube Video Archive', hasDetail:true, color:"#000000", ilink:'../inc/youtube.js', channel:'NYSenate'},
{title:'About the Senate', summary:'From the NYSenate.gov Website', hasDetail:true, color:"#000000",link:'http://www.nysenate.gov/about-us'},
{title:'Knowledge Base', summary:'Frequently Asked Questions and more', hasDetail:true, color:"#000000",link:'http://www.nysenate.gov/frequently-asked-questions'},
-// {title:'FOIL Request', summary:'Request Senate Data', hasDetail:true, color:"#000000", link:'http://www.nysenate.gov/foil_request'},
-// {title:'Senate Reports', hasDetail:true, color:"#000000",link:'http://www.nysenate.gov/reports'},
{title:'Visiting the Capitol', summary:'Directions and Maps', hasDetail:true, color:"#000000", link:'http://www.nysenate.gov/node/76'},
{title:'Senate Rules', summary:'The Rules of Order for the NY State Senate', hasDetail:true, color:"#000000", link:'http://www.nysenate.gov/rules'},
{title:'Constitution', summary:'New York State Constitution',hasDetail:true, color:"#000000",link:'http://www.nysenate.gov/constitution'},
@@ -17,8 +15,7 @@ var data = [
var tableview = Titanium.UI.createTableView(
{
-backgroundColor:"#ffffff",
-opacity:.8
+backgroundColor:"#ffffff"
});
View
95 Resources/views/newsroom.js
@@ -2,9 +2,13 @@ Ti.include("../globals.js");
Ti.include("../inc/jssha256.js");
Ti.include("../inc/drupal_services.js");
-
+var urlRegex = new RegExp("http:\\/\\/\\S+\\.[jJ][pP][eE]?[gG]", "g");
+//var urlRegex = new RegExp("((?:(?:https?|ftp|file)://|www.|ftp.)[-A-Z0-9+&@#/%=~|$?!:,.][A-Z0-9+&@#/%=~_|$]+.(jpg|png|gif|jpeg|bmp))(?!([^<]+)?>)");
var win = Ti.UI.currentWindow;
-var newsTable = Titanium.UI.createTableView({});
+var newsTable = Titanium.UI.createTableView({
+
+backgroundColor:"#ffffff"
+});
var newsItems = [];
// click listener - when image is clicked
@@ -16,8 +20,6 @@ newsTable.addEventListener('click',function(e)
win.add(newsTable);
-
-
function loadTheNews()
{
@@ -35,14 +37,54 @@ function parseNewsroomResponse (responseText)
newsItems = [];
var data = JSON.parse('{"data":' + responseText + '}').data;
+
-
+ Ti.API.info(responseText);
+
for (i = 0; i < data["#data"].length; i++)
{
+ var item = data["#data"][i];
newsItems[i] = new Object();
- newsItems[i].title = data["#data"][i].title;
- newsItems[i].body = data["#data"][i].body;
+ newsItems[i].title = item.title;
+ newsItems[i].body = item.body;
+
+
+
+ if (item.field_video && item.field_video.length > 0 && item.field_video[0].data.thumbnail)
+ {
+ newsItems[i].thumbnail = item.field_video[0].data.thumbnail.url;
+
+ //link = item.field_video[0].embed;
+ link = item.field_video[0].value;
+
+ }
+ else
+ {
+
+ try
+ {
+ //Ti.API.info("checking for images in desc text");
+
+ var descImages = newsItems[i].body.match(urlRegex);
+ if (descImages)
+ {
+ for (dIdx = 0; dIdx < descImages.length; dIdx++)
+ {
+ Ti.API.debug("found match: " + descImages[dIdx]);
+ newsItems[i].thumbnail = descImages[dIdx];
+ }
+ }
+
+
+ }
+ catch (err)
+ {
+
+ Titanium.API.error(err);
+ }
+ }
+
var row = addRow (newsItems[i]);
newsTable.appendRow(row);
@@ -63,11 +105,13 @@ function addRow (newsItem)
var labelTitle = Ti.UI.createLabel({
text:newsItem.title,
left:60,
- top:10,
+ top:1,
height:rowHeight,
- font:{fontSize:18}
+ font:{fontSize:18},
+ color:'#333333'
});
row.add(labelTitle);
+
/*
if (newsItem.body.length > 0)
{
@@ -80,24 +124,25 @@ function addRow (newsItem)
row.add(labelSummary);
}*/
- /*
- var cachedImage = getCachedFile(thumbnail);
-
- if (!cachedImage)
+ if (newsItem.thumbnail)
{
- cacheFile(thumbnail);
- cachedImage = thumbnail;
+ var cachedImage = getCachedFile(newsItem.thumbnail);
+
+ if (!cachedImage)
+ {
+ cacheFile(newsItem.thumbnail);
+ cachedImage = newsItem.thumbnail;
+ }
+
+ var img = Ti.UI.createImageView({
+ image:cachedImage,
+ left:0,
+ width:55,
+ height:rowHeight
+ });
+ row.add(img);
}
-
- var img = Ti.UI.createImageView({
- image:cachedImage,
- left:0,
- width:55,
- height:rowHeight
- });
- row.add(img);
- */
-
+
row.hasDetail = true;
return row;
View
1 Resources/views/olsearch.js
@@ -147,7 +147,6 @@ xhr.onload = function()
if (summary)
{
- Ti.API.info("summary: " + summary.length + ": " + summary);
if (summary.length == 0)
labelTitleHeight = 70;
View
2 Resources/views/senator.js
@@ -227,4 +227,4 @@ tableview.addEventListener('click', function(e)
});
// add table view to the window
-Titanium.UI.currentWindow.add(tableview);
+Titanium.UI.currentWindow.add(tableview);
View
10 Resources/views/senators.js
@@ -175,8 +175,7 @@ function parseSenatorResponse (responseText)
var imageUrl = senatorItems[i].senator.imageUrl;
- //senatorItems[i].senator.imageUrl = imageUrl;
- //senatorItems[i].senator.imageUrlLarge = imageUrl;
+
var idx = imageUrl.lastIndexOf("/");
imageUrl = imageUrl.substring(idx+1);
@@ -189,6 +188,13 @@ function parseSenatorResponse (responseText)
{
senatorItems[i].senator.imageUrl = "../img/senators/" + senatorItems[i].senator.key + "-" + escape(senatorItems[i].senator.imageFileName);
}
+
+ var file = Titanium.Filesystem.getFile(senatorItems[i].senator.imageUrl);
+
+ if(!file.exists()) {
+ senatorItems[i].senator.imageUrl = imageUrl
+ }
+
senatorItems[i].senator.imageUrlLarge = imageUrl;

0 comments on commit f4148e8

Please sign in to comment.
Something went wrong with that request. Please try again.