var $ = require('jQuery');
var onReady = require('kwf/on-ready');
var gmapLoader = require('kwf/google-map/loader');
var gmapMap = require('kwf/google-map/map');

var renderedMaps = [];

var renderMap = function(el) {
    if ($.inArray(el, renderedMaps) != -1) return;
    renderedMaps.push(el);

    var cfg = el.find(".options", true);
    if (!cfg.length) return;
    cfg = $.parseJSON(cfg.val());

    var text = el.find("div.text");
    cfg.mapContainer = el;
    if (!cfg.markers) {
        cfg.markers = {
            longitude : cfg.longitude,
            latitude  : cfg.latitude,
            autoOpenInfoWindow: cfg.autoOpenInfoWindow
        };
        if (text.length) cfg.markers.infoHtml = text.html();
    }

    var cls = eval(cfg.mapClass) || gmapMap;
    var myMap = new cls(cfg);
    el.map = myMap;

    gmapLoader(function() {
        this.show();
    }, myMap);

    return myMap;
};

onReady.onRender('.kwcClass', function(el) {
    if (!el.get('gmapObject') && !el.is(':hidden')) {
        el.data('gmapObject', renderMap(el));
    }
}, { checkVisibility: true });

onReady.onRender('.kwcClass', function (el) {
    var mobileOverlayOpen = el.find('.mobileOverlayOpen');
    var mobileOverlayClose = el.find('.mobileOverlayClose');

    mobileOverlayOpen.click(function (ev) {
        if ($(this).is(':visible')) {
            var newEl = $(this).parent();
            newEl.addClass('navigate');
            $('html, body').animate({
                scrollTop: newEl.offset().top
            }, 400, function() {
                google.maps.event.trigger(newEl.data('gmapObject').gmap, 'resize');
            });
        }
    });

    mobileOverlayClose.on('touchstart click', function (ev) {
        if ($(this).is(':visible')) {
            var newEl = $(this).parent();
            newEl.removeClass('navigate');
            $('html, body').animate({
                scrollTop: newEl.offset().top - (($(window).innerHeight() - newEl.height()) / 2)
            });
        }
    });
});

@@ -170,130 +170,28 @@
 nder
-edMaps = %5B%5D;%0A%0Avar renderMap = function(el) %7B%0A    if ($.inArray(el, renderedMaps) != -1) return;%0A    renderedMaps.push(el);
+Map = function(el) %7B
 %0A%0A  
@@ -693,28 +693,8 @@
 fg);
-%0A    el.map = myMap;
 %0A%0A  
@@ -827,66 +827,8 @@
 ) %7B%0A
-    if (!el.get('gmapObject') && !el.is(':hidden')) %7B%0A    
     
@@ -865,22 +865,16 @@
 p(el));%0A
-    %7D%0A
 %7D, %7B che

remove renderdMaps and check for is:hidden