Permalink
Browse files

Merge branch 'master' of github.com:openplans/fitzgerald

  • Loading branch information...
2 parents f5fe79c + a86fd60 commit 3993cf50f2437f8ac0fb2f0620c6e241f93cb647 @andycochran andycochran committed Aug 3, 2012
Showing with 96 additions and 114 deletions.
  1. +72 −52 src/index.html
  2. +0 −38 src/js/models.js
  3. +20 −11 src/js/test_data.js
  4. +0 −11 src/js/util.js
  5. +4 −2 src/js/views.js
View
@@ -58,67 +58,87 @@ <h3 class="dot-title"></h3>
<script src="js/lib/backbone-0.9.2.min.js"></script>
<script src="js/lib/backbone.localStorage-min.js"></script>
- <script src="js/util.js"></script>
<script src="js/routes.js"></script>
- <script src="js/models.js"></script>
<script src="js/views.js"></script>
<script src="js/test_data.js"></script>
<script>
- $(function(){
- var collection = new Fitzgerald.LocationCollection();
+ (function(F){
+ // Define F.LocationCollection and F.FeedbackModel for your backend here
- // Init the views
- var mapSlider = new Fitzgerald.NavigatorView({
- el: '.dot-slider', collection: collection
- });
- var tooltip = new Fitzgerald.TooltipView({
- el: '.dot-tooltip-comments', collection: collection
- });
- var youarehere = new Fitzgerald.YouarehereTooltipView({
- el: '.dot-tooltip-youarehere', collection: collection
- });
- var feedbackActivity = new Fitzgerald.FeedbackActivityView({
- el: '.dot-feedback-activity', collection: collection
- });
- var feedbackList = new Fitzgerald.FeedbackListView({
- el: '.dot-feedback-container',
- colors: ['yellow', 'blue', 'magenta'],
- collection: collection
- });
- var streetview = new Fitzgerald.StreetviewView({
- el: '#dot-sv',
- collection: collection,
- panoOptions: {
- position: new google.maps.LatLng(0, 0),
- visible:true,
- addressControl: false,
- clickToGo: false,
- scrollwheel: false,
- linksControl: false,
- disableDoubleClickZoom: false,
- zoomControlOptions: {
- style: google.maps.ZoomControlStyle.SMALL
+ // To help out the Wordpress PHP backend
+ // Backbone.emulateHTTP = true;
+
+ // An example for the Wordpress plugin
+ // F.LocationCollection = Backbone.Collection.extend({
+ // url: '/4thave/wp-admin/admin-ajax.php?action=intersections'
+ // });
+
+ // An example for the Wordpress plugin
+ // F.FeedbackModel = Backbone.Model.extend({
+ // url: '/4thave/wp-admin/admin-ajax.php?action=feedback'
+ // });
+
+ $(function(){
+ // Disable caching for all ajax calls
+ jQuery.ajaxSetup ({
+ cache: false
+ });
+
+ var collection = new F.LocationCollection();
+
+ // Init the views
+ var mapSlider = new F.NavigatorView({
+ el: '.dot-slider', collection: collection
+ });
+ var tooltip = new F.TooltipView({
+ el: '.dot-tooltip-comments', collection: collection
+ });
+ var youarehere = new F.YouarehereTooltipView({
+ el: '.dot-tooltip-youarehere', collection: collection
+ });
+ var feedbackActivity = new F.FeedbackActivityView({
+ el: '.dot-feedback-activity', collection: collection
+ });
+ var feedbackList = new F.FeedbackListView({
+ el: '.dot-feedback-container',
+ colors: ['yellow', 'blue', 'magenta'],
+ collection: collection
+ });
+ var streetview = new F.StreetviewView({
+ el: '#dot-sv',
+ collection: collection,
+ panoOptions: {
+ position: new google.maps.LatLng(0, 0),
+ visible:true,
+ addressControl: false,
+ clickToGo: false,
+ scrollwheel: false,
+ linksControl: false,
+ disableDoubleClickZoom: false,
+ zoomControlOptions: {
+ style: google.maps.ZoomControlStyle.SMALL
+ }
}
- }
- });
- var feedbackForm = new Fitzgerald.FeedbackFormView({
- el: '.dot-survey-form',
- showFormEl: '#dot-add-feedback',
- collection: collection,
- maxChars: 200
- });
+ });
+ var feedbackForm = new F.FeedbackFormView({
+ el: '.dot-survey-form',
+ showFormEl: '#dot-add-feedback',
+ collection: collection,
+ maxChars: 200
+ });
- var locationTitle = new Fitzgerald.LocationTitleView({
- el: '.dot-title',
- setTitle: function(title) {
- this.$el.html('Fourth Ave &amp; ' + title);
- }
- })
+ var locationTitle = new F.LocationTitleView({
+ el: '.dot-title',
+ setTitle: function(title) {
+ this.$el.html('Fourth Ave &amp; ' + title);
+ }
+ })
- // Fetch the location records
- collection.fetch();
- });
+ // Fetch the location records
+ collection.fetch();
+ });
+ })(Fitzgerald);
</script>
</body>
View
@@ -1,38 +0,0 @@
-var Fitzgerald = Fitzgerald || {};
-
-(function(F, $) {
- // To help out the Wordpress PHP backend
- Backbone.emulateHTTP = true;
- // Disable caching for all ajax calls
- $.ajaxSetup ({
- cache: false
- });
-
- var collectionOptions, feedbackOptions;
- // Define the Location model
- F.LocationModel = Backbone.Model.extend({});
-
- // Setup the collection to support localStorage when running on localhost
- collectionOptions = F.Util.isLocalhost() ? {
- localStorage: new Backbone.LocalStorage("fitzgerald-intersections"),
- model: F.LocationModel
- } : {
- url: '/4thave/wp-admin/admin-ajax.php?action=intersections',
- model: F.LocationModel
- };
- F.LocationCollection = Backbone.Collection.extend(collectionOptions);
-
-
- // Setup the feedback model to support localStorage when running on localhost
- feedbackOptions = F.Util.isLocalhost() ? {
- localStorage: new Backbone.LocalStorage("fitzgerald-feedback")
- } : {
- urlRoot: '/4thave/wp-admin/admin-ajax.php?action=feedback',
- // Whacky code for non-REST Wordpress support
- url: function() {
- return this.urlRoot || this.collection.url;
- }
- };
- // Define the Feeedback model
- F.FeedbackModel = Backbone.Model.extend(feedbackOptions);
-})(Fitzgerald, jQuery);
View
@@ -316,17 +316,26 @@ Fitzgerald.testData = [
];
(function(F){
- var collection;
- if (F.Util.isLocalhost()) {
- collection = new F.LocationCollection();
- collection.fetch();
+ console.log('=== RUNNING IN TEST MODE ===');
- if (collection.length === 0) {
- F.testData.forEach(function(obj, i) {
- collection.create(obj);
- console.log(obj);
- });
- console.log(collection.toJSON());
- }
+ // Setup the collection to support localStorage when running on localhost
+ F.LocationCollection = Backbone.Collection.extend({
+ localStorage: new Backbone.LocalStorage('fitzgerald-intersections')
+ });
+
+ // Define the Feeedback model
+ F.FeedbackModel = Backbone.Model.extend({
+ localStorage: new Backbone.LocalStorage('fitzgerald-feedback')
+ });
+
+ var collection = new F.LocationCollection();
+ collection.fetch();
+
+ if (collection.length === 0) {
+ F.testData.forEach(function(obj, i) {
+ collection.create(obj);
+ console.log(obj);
+ });
+ console.log(collection.toJSON());
}
})(Fitzgerald);
View
@@ -1,11 +0,0 @@
-var Fitzgerald = Fitzgerald || {};
-
-(function(F, $) {
-
- F.Util = {
- isLocalhost: function(url){
- url = url || location.hostname;
- return (url.indexOf('localhost') >= 0 || url.indexOf('127.0.0.1') >= 0);
- }
- };
-})(Fitzgerald, jQuery);
View
@@ -367,11 +367,13 @@ var Fitzgerald = Fitzgerald || {};
this.render();
},
render: function(){
- var percent = this.collection.indexOf(this.locationModel) / this.collection.length;
+ var percent = this.collection.indexOf(this.locationModel) / this.collection.length,
+ count = this.locationModel.get('feedback').length,
+ label = 'Comment' + ((count !== 1) ? 's' : '');
this.$el
.css('left', (percent*100) + '%')
- .html('<strong>' + this.locationModel.get('feedback').length + '</strong> Comments')
+ .html('<strong>' + count + '</strong> ' + label)
.show();
}
});

0 comments on commit 3993cf5

Please sign in to comment.