Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
Removed _initialized function, as methods are anyway not being called unless
a INIT_DONE has been fired before. Commented out related test.
  • Loading branch information
mmarcon committed Aug 6, 2012
1 parent 000ca3c commit ccb5563
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
Binary file modified dist/jOVI.tar.gz
Binary file not shown.
25 changes: 1 addition & 24 deletions src/jquery.jovi.js
Expand Up @@ -50,11 +50,6 @@
};
_mapsAPI.util.ApplicationContext.set(_cachedCredentials);
},
_initialized = function() {
if (this.data(JOVI) !== true) {
$.error('jOVI map was never initialized on this container');
}
},
_initMap = function(target, settings) {
var components = [],
mapID;
Expand Down Expand Up @@ -263,9 +258,6 @@
"dragend": [_eventProxy || $.noop, false, null]
};

//Check if a map was initialized here
_initialized.call($(this));

settings = $.extend({}, defaultOptions, options);

settings.textPen = {
Expand Down Expand Up @@ -295,9 +287,6 @@
},
settings, bubbles;

//Check if a map was initialized here
_initialized.call($(this));

settings = $.extend({}, defaultOptions, options);
if (settings.content) {
if (settings.content.jquery) {
Expand All @@ -315,27 +304,18 @@
var $this = $(this),
animationType = withAnimation ? 'default' : 'none';

//Check if a map was initialized here
_initialized.call($this);

_maps[$this.attr('id')].setCenter(where, animationType);
},
setZoom: function(level) {
var $this = $(this);

//Check if a map was initialized here
_initialized.call($this);

_maps[$this.attr('id')].set('zoomLevel', level);
},
setType: function(type) {
var $this = $(this),
map = _maps[$this.attr('id')],
mType;

//Check if a map was initialized here
_initialized.call($this);

switch (type) {
case 'map':
mType = map.NORMAL;
Expand All @@ -358,9 +338,6 @@
map = _maps[mapID],
kml = new _mapsAPI.kml.Manager();

//Check if a map was initialized here
_initialized.call($this);

kml.addObserver("state", function kmlLoadStateChange(kmlManager) {
// KML file was successfully loaded
if (kmlManager.state == "finished") {
Expand Down Expand Up @@ -408,7 +385,7 @@
}
return this.each(function() {
var that = this;
// Use apply to sent arguments when calling our selected method
// Use apply to send arguments when calling our selected method
if ((_loader && _loader.done) || init) {
method.apply(that, a);
} else {
Expand Down
18 changes: 10 additions & 8 deletions src/test/js/script.js
Expand Up @@ -71,14 +71,16 @@ $(window).load(function() {
})
.jOVI ('setType', 'satellite')
.jOVI ('showInfoBubble', [40.716667, -74], {content: content});
//8- Attempt to invoke methods on a map never initialized
var error = getTestTemplate ('Invoke methods on a map never initialized (jOVI throws exception)', 'test-map-' + counter++).appendTo (container);
try {
error.children('.map').jOVI('setCenter', [40.69, -74.045278]);
}
catch (e) {
error.children('.map').text(e.toString());
}

//8- Attempt to invoke methods on a map never initialized (OLD BEHAVIOR, no longer valid)
// var error = getTestTemplate ('Invoke methods on a map never initialized (jOVI throws exception)', 'test-map-' + counter++).appendTo (container);
// try {
// error.children('.map').jOVI('setCenter', [40.69, -74.045278]);
// }
// catch (e) {
// error.children('.map').text(e.toString());
// }

//9- Map events
var me = getTestTemplate ('Map Events', 'test-map-' + counter++).appendTo (container);
me.children('.map').jOVI ({center: [40.716667, -74], mapLoaded: function(e) {console.log ('mapLoaded callback was called')}})
Expand Down

0 comments on commit ccb5563

Please sign in to comment.