Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Apress
committed
Oct 19, 2016
0 parents
commit faa454f
Showing
300 changed files
with
3,671 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Freeware License, some rights reserved | ||
|
||
Copyright (c) 2015 Stephan Alber and Wilkins Fernandez | ||
|
||
Permission is hereby granted, free of charge, to anyone obtaining a copy | ||
of this software and associated documentation files (the "Software"), | ||
to work with the Software within the limits of freeware distribution and fair use. | ||
This includes the rights to use, copy, and modify the Software for personal use. | ||
Users are also allowed and encouraged to submit corrections and modifications | ||
to the Software for the benefit of other users. | ||
|
||
It is not allowed to reuse, modify, or redistribute the Software for | ||
commercial use in any way, or for a user�s educational materials such as books | ||
or blog articles without prior permission from the copyright holder. | ||
|
||
The above copyright notice and this permission notice need to be included | ||
in all copies or substantial portions of the software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#Apress Source Code | ||
|
||
This repository accompanies [*Beginning App Development with Parse and PhoneGap*](http://www.apress.com/9781484202364) by Stephan Alber and Wilkins Fernandez (Apress, 2015). | ||
|
||
![Cover image](9781484202364.jpg) | ||
|
||
Download the files as a zip using the green button, or clone the repository to your machine using Git. | ||
|
||
##Releases | ||
|
||
Release v1.0 corresponds to the code in the published book, without corrections or updates. | ||
|
||
##Contributions | ||
|
||
See the file Contributing.md for more information on how you can contribute to this repository. |
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Initialize Parse JavaScript SDK | ||
Parse.initialize("APPLICATION ID", "JAVASCRIPT KEY"); | ||
// Define a new Parse class named "Toy" | ||
var Toy = Parse.Object.extend("Toy"); | ||
// Create a new Instance of the Toy Parse Class | ||
var myToy = new Toy(); | ||
|
||
// Set some Example Values | ||
myToy.set("name", "Rocking Horse"); | ||
myToy.set("color", "brown"); | ||
// Save Object to Parse Cloud Database | ||
myToy.save(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var app = { | ||
settings: { | ||
version: "0.0.1" | ||
} | ||
}; | ||
app.user = {}; | ||
app.user.register = function () {}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<script src="framework.js"></script> | ||
<script src="plugin.framework.js"></script> | ||
<script src="myplugin.framework.js"></script> | ||
<script src="init.js"></script> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
$LAB | ||
.script("framework.js").wait() | ||
.script("plugin.framework.js") | ||
.script("myplugin.framework.js").wait() | ||
.script("init.js").wait(); | ||
</script> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$('a.location-text').on('click', app.conversation.addMap); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div id="myMap"></div> | ||
<a href="#" id="closeMyMap" class="btn btn-primary">Close Map</a> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#myMap { | ||
display: none; | ||
position: fixed; | ||
background: red; | ||
top: 60px; | ||
left: 10px; | ||
bottom: 55px; | ||
right: 10px; | ||
} | ||
#closeMyMap { | ||
display: none; | ||
position: fixed; | ||
left: 10px; | ||
bottom: 10px; | ||
right: 10px; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
app.modules.map = (function () { | ||
// Module Variables | ||
var map, Message; | ||
// Initialize Module | ||
var _init = function () { | ||
}; | ||
// Event for "Close Map" Button | ||
var closeEvent = function () { | ||
}; | ||
// Convert a Message Location into a Gmaps Location | ||
var getGLocationFromMessage = function () { | ||
}; | ||
// Get a new Map Instance | ||
var getMap = function () { | ||
}; | ||
// Call when Map is Ready | ||
var onMapReady = function () { | ||
}; | ||
// Hide Conversation and Show Map | ||
var switchView = function () { | ||
}; | ||
// Make _init() function accessible form outside | ||
return { | ||
init: _init | ||
}; | ||
})(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var switchView = function() { | ||
$('.container').hide(); | ||
$('#myMap, #closeMyMap').css('display', 'block'); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var getMap = function() { | ||
map = plugin.google.maps.Map.getMap($('#myMap')[0], { | ||
'controls': { | ||
'compass': true, | ||
'myLocationButton': true, | ||
'zoom': true | ||
} | ||
}); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var getGLocationFromMessage = function(Message) { | ||
return new plugin.google.maps.LatLng( | ||
Message.get('location').latitude, | ||
Message.get('location').longitude); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var onMapReady = function(map) { | ||
map.animateCamera({ | ||
'target': getGLocationFromMessage(Message), | ||
'zoom': 15, | ||
'duration': 3000, | ||
'tilt': 0, | ||
'bearing': 0 | ||
}); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var closeEvent = function() { | ||
$('#closeMyMap').on('tap click', function() { | ||
$('.container').show(); | ||
$('#myMap, #closeMyMap').css('display', 'none'); | ||
map.remove(); | ||
}); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var _init = function(_Message) { | ||
Message = _Message; | ||
switchView(); | ||
getMap(); | ||
closeEvent(); | ||
map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
addMap: function (event) { | ||
event.preventDefault(); | ||
// Add Map Element | ||
var mapClasses = 'alert well-sm alert-info'; | ||
$('<div id="mapbox" class="' + mapClasses + '"></div>').insertBefore(this); | ||
// Set Mapbox Access Token | ||
L.mapbox.accessToken = '{your-mapbox-access-token}'; | ||
// Create Mapbox Instance | ||
var map = L.mapbox.map('mapbox', '{your-mapbox-map-id}', { | ||
zoomControl: false, | ||
attributionControl: false | ||
}); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
addMap: function(event) { | ||
event.preventDefault(); | ||
var Message = app.conversation.Messages[$(this).data('id')]; | ||
app.modules.map.init(Message); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
$('#navigation').on('hide.bs.collapse', function () { | ||
map.setClickable(true); | ||
$('.modal-backdrop').remove(); | ||
}); | ||
$('#navigation').on('show.bs.collapse', function () { | ||
map.setClickable(false); | ||
$('body').append('<div class="modal-backdrop fade in" style="z-index: 999"></div>'); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var addMessageMarker = function(Message) { | ||
map.addMarker({ | ||
'position': getGLocationFromMessage(Message), | ||
'title': Message.get('sender').get('first_name'), | ||
'snippet': Message.get('message_body') | ||
}); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var onMapReady = function(_map) { | ||
addMessageMarker(Message); | ||
// map.animateCamera() ... | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var map, Message, message_ids = [], loading = false; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var onMapReady = function(_map) { | ||
// Keep existing code... | ||
map.animateCamera(options, function() { | ||
map.on(plugin.google.maps.event.CAMERA_CHANGE, getMapCenter); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var getMapCenter = function(position) { | ||
if (loading) { | ||
return; | ||
} | ||
loading = true; | ||
getMessagesNearBy(position).then(addMarkersToMap); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var getMessagesNearBy = function (position) { | ||
var currentPosition = new Parse.GeoPoint({ | ||
latitude: position.target.lat, | ||
longitude: position.target.lng | ||
}); | ||
var query = new Parse.Query(MyParseMessage); | ||
query.near("location", currentPosition); | ||
// Alternatives: | ||
// query.withinMiles("location", currentPosition, 3); | ||
// query.withinKilometers("location", currentPosition, 5); | ||
query.limit(10); | ||
return query.find(); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var addMarkersToMap = function(Messages) { | ||
$.each(Messages, function(index, Message) { | ||
if ($.inArray(Message.id, message_ids) > -1) { | ||
return; | ||
} | ||
message_ids.push(Message.id); | ||
addMessageMarker(Message); | ||
}); | ||
loading = false; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var onMapReady = function(_map) { | ||
// Keep existing code... | ||
// Replace getMapCenter with getVisibleRegion | ||
map.animateCamera(options, function() { | ||
map.on(plugin.google.maps.event.CAMERA_CHANGE, getVisibleRegion); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
renderMessages: function() { | ||
var limit = 5; | ||
MyParseConversation.getMessages(app.conversation.Receiver, | ||
limit).then(function(Messages) { | ||
// Render Messages ... | ||
$(Messages).each(function(index, Message) { | ||
app.conversation.Messages[Message.id] = Message; | ||
}); | ||
}); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var getVisibleRegion = function(position) { | ||
if (loading) { | ||
return; | ||
} | ||
loading = true; | ||
map.getVisibleRegion(function(latLngBounds) { | ||
getMessagesWithinBounds(latLngBounds).then(addMarkersToMap); | ||
}); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var getMessagesWithinBounds = function(latLngBounds) { | ||
var southwest = new Parse.GeoPoint(latLngBounds.southwest.lat, | ||
latLngBounds.southwest.lng); | ||
var northeast = new Parse.GeoPoint(latLngBounds.northeast.lat, | ||
latLngBounds.northeast.lng); | ||
var query = new Parse.Query(MyParseMessage); | ||
query.withinGeoBox("location", southwest, northeast); | ||
query.limit(10); | ||
return query.find(); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var Message = app.conversation.Messages[$(this).data('id')]; | ||
map.setView([Message.get('location').latitude, Message.get('location').longitude], 14); | ||
L.mapbox.featureLayer({ | ||
type: 'Feature', | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [ | ||
Message.get('location').longitude, | ||
Message.get('location').latitude | ||
] | ||
}, | ||
properties: { | ||
title: Message.get('sender').get('first_name'), | ||
description: Message.get('message_body'), | ||
'marker-size': 'large', | ||
'marker-color': '#BE9A6B', | ||
'marker-symbol': 'post' | ||
} | ||
}).addTo(map); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Remove Map on Click | ||
map.on('click', function(e) { | ||
map.remove(); | ||
$('#mapbox').remove(); | ||
}); | ||
// Disable drag and zoom handlers. | ||
map.dragging.disable(); | ||
map.touchZoom.disable(); | ||
map.doubleClickZoom.disable(); | ||
// Disable tap handler, if present. | ||
if (map.tap) map.tap.disable(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
addMap: function(event) { | ||
event.preventDefault(); | ||
if ($('#mapbox').length) { | ||
$('#mapbox').remove(); | ||
} | ||
// ... | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<script src="https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v0.0.3/Leaflet.fullscreen.min.js"></script> | ||
<link href="https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v0.0.3/leaflet.fullscreen.css" rel="stylesheet" /> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
L.control.fullscreen().addTo(map); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
map.on('fullscreenchange', function(e) { | ||
map.setView([Message.get('location').latitude, | ||
Message.get('location').longitude]); | ||
if (map.isFullscreen()) { | ||
$('#mapbox').removeClass(mapClasses); | ||
map.dragging.enable(); | ||
map.touchZoom.enable(); | ||
} else { | ||
$('#mapbox').addClass(mapClasses); | ||
map.dragging.disable(); | ||
map.touchZoom.disable(); | ||
} | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cordova plugin add org.apache.cordova.camera |
Oops, something went wrong.