Permalink
Browse files

Bind menu functions to topbar buttons

  • Loading branch information...
1 parent 76a306f commit 67906c68ae6fc481f49a2fcface45504b06d2006 Antoine van Gelder committed May 3, 2012
Showing with 121 additions and 116 deletions.
  1. +55 −54 config.json
  2. +66 −62 photolog.js
View
@@ -1,63 +1,64 @@
{
- "config_version": "2",
+ "config_version": "2",
"platform_version": "avg-topbar",
"name": "Event Stream",
"author": "Trigger",
"uuid": "photolog",
"url" : "http://trigger.io",
"version": "1.1",
"description": "Photo logging app to capture, display and share event photos",
- "modules": {
- "topbar": true,
- "request": {
- "permissions": [ ]
- },
- "background": {
- "files": [ ]
- },
- "activations": [ ],
- "logging": {
- "level": "DEBUG"
- },
- "icons": {
- "16": "img/icons/16x16.png",
- "32": "img/icons/32x32.png",
- "36": "img/icons/36x36.png",
- "48": "img/icons/48x48.png",
- "57": "img/icons/57x57.png",
- "62": "img/icons/62x62.png",
- "64": "img/icons/64x64.png",
- "72": "img/icons/72x72.png",
- "99": "img/icons/99x99.png",
- "114": "img/icons/114x114.png",
- "128": "img/icons/128x128.png",
- "173": "img/icons/173x173.png",
- "512": "img/icons/512x512.png",
- "android": {
- "36": "img/icons/36x36.png",
- "48": "img/icons/48x48.png",
- "72": "img/icons/72x72.png"
- },
- "ios": {
- "57": "img/icons/57x57.png",
- "72": "img/icons/72x72.png",
- "114": "img/icons/114x114.png",
- "512": "img/icons/512x512.png"
- },
- "wp": {
- "62": "img/icons/62x62.png",
- "99": "img/icons/99x99.png",
- "173": "img/icons/173x173.png"
- }
- },
- "package_names": {
- "ios": "io.trigger.forge.eventstream"
- },
- "orientation": {
- "default": "any",
- "iphone": "portrait",
- "android": "portrait",
- "wp": "portrait"
- }
- }
+ "modules": {
+ "is": true,
+ "topbar": true,
+ "request": {
+ "permissions": [ ]
+ },
+ "background": {
+ "files": [ ]
+ },
+ "activations": [ ],
+ "logging": {
+ "level": "DEBUG"
+ },
+ "icons": {
+ "16": "img/icons/16x16.png",
+ "32": "img/icons/32x32.png",
+ "36": "img/icons/36x36.png",
+ "48": "img/icons/48x48.png",
+ "57": "img/icons/57x57.png",
+ "62": "img/icons/62x62.png",
+ "64": "img/icons/64x64.png",
+ "72": "img/icons/72x72.png",
+ "99": "img/icons/99x99.png",
+ "114": "img/icons/114x114.png",
+ "128": "img/icons/128x128.png",
+ "173": "img/icons/173x173.png",
+ "512": "img/icons/512x512.png",
+ "android": {
+ "36": "img/icons/36x36.png",
+ "48": "img/icons/48x48.png",
+ "72": "img/icons/72x72.png"
+ },
+ "ios": {
+ "57": "img/icons/57x57.png",
+ "72": "img/icons/72x72.png",
+ "114": "img/icons/114x114.png",
+ "512": "img/icons/512x512.png"
+ },
+ "wp": {
+ "62": "img/icons/62x62.png",
+ "99": "img/icons/99x99.png",
+ "173": "img/icons/173x173.png"
+ }
+ },
+ "package_names": {
+ "ios": "io.trigger.forge.eventstream"
+ },
+ "orientation": {
+ "default": "any",
+ "iphone": "portrait",
+ "android": "portrait",
+ "wp": "portrait"
+ }
+ }
}
View
@@ -105,38 +105,39 @@ var setupNav = function () {
var setupSearch = function() {
$("#search-streams").bind("input", function() {
var searchString = '#' + this.value.replace('#', '');
- var results = false;
- $(".photoStream").each(function(){
- if($(this).text().toLowerCase().indexOf(searchString.toLowerCase()) == 0) {
- $(this).parent().show();
- results = true;
- } else {
- $(this).parent().hide();
- }
- });
- if(!results) {
- $('#no-results').show();
- } else {
- $('#no-results').hide();
- }
+ var results = false;
+ $(".photoStream").each(function(){
+ if($(this).text().toLowerCase().indexOf(searchString.toLowerCase()) == 0) {
+ $(this).parent().show();
+ results = true;
+ } else {
+ $(this).parent().hide();
+ }
+ });
+ if(!results) {
+ $('#no-results').show();
+ } else {
+ $('#no-results').hide();
+ }
});
};
-var setupPageHeader = function() {
- forge.topbar.setTint([190,57,46,255]);
- forge.topbar.addButton({
- icon: "img/index-button.png",
- position: "left"
- }, function() {
- alert("index-button");
- });
- forge.topbar.setTitleImage("img/logo.png");
- forge.topbar.addButton({
- icon: "img/plus-button.png",
- position: "right"
- }, function() {
- alert("plus-button");
- });
+var setupNativePageHeader = function() {
+ $("#page-header").hide();
+ forge.topbar.setTint([190,57,46,255]);
+ forge.topbar.addButton({
+ icon: "img/index-button.png",
+ position: "left"
+ }, function() {
+ photolog.router.navigate("/", {trigger: true});
+ });
+ forge.topbar.setTitleImage("img/logo.png");
+ forge.topbar.addButton({
+ icon: "img/plus-button.png",
+ position: "right"
+ }, function() {
+ showTopBar('new-bar');
+ });
};
var showTopBar = function(topBarId) {
@@ -325,11 +326,11 @@ photolog.util = {
var photo = photolog.photos.get(photoId);
state.index = photolog.photos.indexOf(photo);
$(document).keydown(function(e){
- if (e.keyCode == 37) {
- photolog.util.showIndividualPhoto(-1);
- } else if (e.keyCode == 39) {
- photolog.util.showIndividualPhoto(1);
- }
+ if (e.keyCode == 37) {
+ photolog.util.showIndividualPhoto(-1);
+ } else if (e.keyCode == 39) {
+ photolog.util.showIndividualPhoto(1);
+ }
});
$('#large-photo').attr('src', photo.get('url'));
$('#scrollbox').show();
@@ -339,40 +340,40 @@ photolog.util = {
return;
}
state.animating = true;
- var nextPhoto = '';
- // A null state.index means show the 'Upsell' box instead of a photo
+ var nextPhoto = '';
+ // A null state.index means show the 'Upsell' box instead of a photo
if (state.index == null) {
state.index = increment == 1 ? 0 : photolog.photos.length - 1;
nextPhoto = photolog.photos.at(state.index).get('url');
} else {
- state.index += increment;
- if (state.index == -1 || state.index == photolog.photos.length) {
- state.index = null;
- }
+ state.index += increment;
+ if (state.index == -1 || state.index == photolog.photos.length) {
+ state.index = null;
+ }
else {
nextPhoto = photolog.photos.at(state.index).get('url');
}
- }
+ }
var xShift = 500;
$('#scrollbox').animate({
- opacity: 0,
- left: '+=' + increment * xShift
+ opacity: 0,
+ left: '+=' + increment * xShift
}, {
duration: 200,
complete: function() {
$('#scrollbox').css('left', -1 * increment * xShift);
if(!nextPhoto) {
- $('#start-stream-header').show();
- $('#large-photo').hide();
+ $('#start-stream-header').show();
+ $('#large-photo').hide();
} else {
- $('#start-stream-header').hide();
- $('#large-photo').show();
+ $('#start-stream-header').hide();
+ $('#large-photo').show();
}
$('#large-photo').attr('src', nextPhoto);
$('#scrollbox').animate({
- opacity: 1,
- left: '+=' + increment * xShift
+ opacity: 1,
+ left: '+=' + increment * xShift
}, {
duration: 200
});
@@ -585,30 +586,33 @@ photolog.views.Photo = Backbone.View.extend({
// Initialise app
$(function () {
- setupPageHeader();
Backbone.history.start()
if (forge.is.web()) {
$('#upload-container').hide();
// Make mobile web experience the same as desktop web
// if (navigator.userAgent.indexOf('Android') != -1) {
- // $('#appstore').hide();
- // photolog.router.navigate('upsell', true);
+ // $('#appstore').hide();
+ // photolog.router.navigate('upsell', true);
// } else if (navigator.userAgent.indexOf('iPhone') != -1 || navigator.userAgent.indexOf('iPad') != -1) {
- // $('#androidmarket').hide();
- // photolog.router.navigate('upsell', true);
+ // $('#androidmarket').hide();
+ // photolog.router.navigate('upsell', true);
// }
} else {
$('#app-download-container').hide();
$('#footer-links').hide();
}
- $('#index-button').bind(clickEvent, function(e) {
- e.preventDefault();
- photolog.router.navigate("/", {trigger: true});
- });
- $('#plus-button').bind(clickEvent, function(e) {
- e.preventDefault();
- showTopBar('new-bar');
- });
+ if (forge.is.mobile()) {
+ setupNativePageHeader();
+ } else {
+ $('#index-button').bind(clickEvent, function(e) {
+ e.preventDefault();
+ photolog.router.navigate("/", {trigger: true});
+ });
+ $('#plus-button').bind(clickEvent, function(e) {
+ e.preventDefault();
+ showTopBar('new-bar');
+ });
+ }
$('#upload-button').bind(clickEvent, function(e) {
e.preventDefault();
photolog.util.upload();

0 comments on commit 67906c6

Please sign in to comment.