Skip to content

Commit

Permalink
- (Bug Fix) Fixed an issue that would cause Craft to break when editi…
Browse files Browse the repository at this point in the history
…ng entries inline with Google Maps fields
  • Loading branch information
objectivehtml committed Dec 2, 2014
1 parent e17b40b commit 0d42fd7
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 61 deletions.
18 changes: 16 additions & 2 deletions fieldtypes/GoogleMaps_GoogleMapFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,24 @@ public function getInputHtml($name, $value)

craft()->templates->includeJsResource('googlemaps/js/app.compiled.js');
craft()->templates->includeCssResource('googlemaps/css/app.css');
craft()->templates->includeJsFile('//maps.googleapis.com/maps/api/js?key=&sensor=false');
craft()->templates->includeJsResource('googlemaps/js/callback.js');
craft()->templates->includeJsFile('//maps.googleapis.com/maps/api/js?key=&sensor=false&callback=GoogleMaps.init');

$addressFields = $this->getSettings()->addressFields;

craft()->templates->includeJs("
GoogleMaps.data.push(['#$namespacedId-field .oh-google-map-wrapper', {
fieldname: '$name',
savedData: ".(!empty($value) ? $value->toJson() : "false").",
width: '".$this->getSettings()->defaultMapWidth."',
height: '".$this->getSettings()->defaultMapHeight."',
center: '".$this->getSettings()->defaultMapCenter."',
zoom: ".$this->getSettings()->defaultMapZoom.",
showButtons: ".json_encode($this->getSettings()->displayButtons).",
addressFields: ".($addressFields ? json_encode(explode("\r\n", $this->getSettings()->addressFields)) : 'false')."
}]);
/*
new GoogleMaps.Fieldtype('#$namespacedId-field .oh-google-map-wrapper', {
fieldname: '$name',
savedData: ".(!empty($value) ? $value->toJson() : "false").",
Expand All @@ -228,7 +241,8 @@ public function getInputHtml($name, $value)
zoom: ".$this->getSettings()->defaultMapZoom.",
showButtons: ".json_encode($this->getSettings()->displayButtons).",
addressFields: ".($addressFields ? json_encode(explode("\r\n", $this->getSettings()->addressFields)) : 'false')."
});");
});
*/");

return craft()->templates->render('googlemaps/fieldtype', array(
'name' => $name
Expand Down
32 changes: 14 additions & 18 deletions resources/js/app.compiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -11033,7 +11033,16 @@ function program2(depth0,data) {
}());
var GoogleMaps = {
Views: {},
Models: {}
Models: {},
data: [],
instances: [],
init: function() {
var t = this;

_.each(this.data, function(data) {
t.instances.push(new GoogleMaps.Fieldtype(data[0], data[1]));
});
}
};

(function() {
Expand Down Expand Up @@ -11077,6 +11086,8 @@ var GoogleMaps = {

var App = new Backbone.Marionette.Application();

this.App = App;

App.options = options;

App.addRegions({
Expand All @@ -11098,6 +11109,8 @@ var GoogleMaps = {
addressFields: options.addressFields
});

this.map = map;

App.addInitializer(function() {

setTimeout(function() {
Expand Down Expand Up @@ -11125,23 +11138,6 @@ var GoogleMaps = {


}());

/*

(function() {



GoogleMaps.App = new Backbone.Marionette.Application();

GoogleMaps.App.addRegions({
content: ".oh-google-maps-wrapper"
});

GoogleMaps.App.start();

}());
*/
(function() {

"use strict";
Expand Down
32 changes: 14 additions & 18 deletions resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
var GoogleMaps = {
Views: {},
Models: {}
Models: {},
data: [],
instances: [],
init: function() {
var t = this;

_.each(this.data, function(data) {
t.instances.push(new GoogleMaps.Fieldtype(data[0], data[1]));
});
}
};

(function() {
Expand Down Expand Up @@ -44,6 +53,8 @@ var GoogleMaps = {

var App = new Backbone.Marionette.Application();

this.App = App;

App.options = options;

App.addRegions({
Expand All @@ -65,6 +76,8 @@ var GoogleMaps = {
addressFields: options.addressFields
});

this.map = map;

App.addInitializer(function() {

setTimeout(function() {
Expand Down Expand Up @@ -92,23 +105,6 @@ var GoogleMaps = {


}());

/*
(function() {
GoogleMaps.App = new Backbone.Marionette.Application();
GoogleMaps.App.addRegions({
content: ".oh-google-maps-wrapper"
});
GoogleMaps.App.start();
}());
*/
(function() {

"use strict";
Expand Down
8 changes: 4 additions & 4 deletions resources/js/app.min.js

Large diffs are not rendered by default.

34 changes: 15 additions & 19 deletions resources/js/app/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
var GoogleMaps = {
Views: {},
Models: {}
Models: {},
data: [],
instances: [],
init: function() {
var t = this;

_.each(this.data, function(data) {
t.instances.push(new GoogleMaps.Fieldtype(data[0], data[1]));
});
}
};

(function() {
Expand Down Expand Up @@ -44,6 +53,8 @@ var GoogleMaps = {

var App = new Backbone.Marionette.Application();

this.App = App;

App.options = options;

App.addRegions({
Expand All @@ -65,6 +76,8 @@ var GoogleMaps = {
addressFields: options.addressFields
});

this.map = map;

App.addInitializer(function() {

setTimeout(function() {
Expand All @@ -91,21 +104,4 @@ var GoogleMaps = {
});


}());

/*
(function() {
GoogleMaps.App = new Backbone.Marionette.Application();
GoogleMaps.App.addRegions({
content: ".oh-google-maps-wrapper"
});
GoogleMaps.App.start();
}());
*/
}());

0 comments on commit 0d42fd7

Please sign in to comment.