WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Comprehensive Google Map Plugin Jquery 1.10

[Resolved] Comprehensive Google Map Plugin Jquery 1.10

  • jdunneirl
    Member

    @jdunneirl

    Plugin has stopped working as
    if (version < 1.3) {

    evaluates to be true as 1.10 is seen as 1.1

    This needs to be used instead

    function compVersions(strV1, strV2) {
    var nRes = 0
    , parts1 = strV1.split(‘.’)
    , parts2 = strV2.split(‘.’)
    , nLen = Math.max(parts1.length, parts2.length);

    for (var i = 0; i < nLen; i++) {
    var nP1 = (i < parts1.length) ? parseInt(parts1[i], 10) : 0
    , nP2 = (i < parts2.length) ? parseInt(parts2[i], 10) : 0;

    if (isNaN(nP1)) { nP1 = 0; }
    if (isNaN(nP2)) { nP2 = 0; }

    if (nP1 != nP2) {
    nRes = (nP1 > nP2) ? 1 : -1;
    break;
    }
    }

    return nRes;
    };

    compVersions(’10’, ‘10.0’); // 0
    compVersions(‘10.1’, ‘10.01.0’); // 0
    compVersions(‘10.0.1’, ‘10.0’); // 1
    compVersions(‘10.0.1’, ‘10.1’); // -1

    http://wordpress.org/plugins/comprehensive-google-map-plugin/

Viewing 15 replies - 1 through 15 (of 22 total)
  • crienoloog
    Member

    @crienoloog

    Can you please be a little bit more clearer on this fix please?
    Like which file, line, which lines to change into what?

    Thanks

    jdunneirl
    Member

    @jdunneirl

    Hi,

    The problem is jquery that is shipping with WordPress 3.6 is using 1.10.x

    You are checking the jquery version in the plugin to see if it’s less then 1.3

    The check you are using is reading

    If jquery version is less then 1.3 show message…

    Jquery 1.10 is been seen as 1.1 in you if statement

    I have done a search and found a number of instances of this check. Sorry I am not in the office now to tell you where it is exactly but search for 1.3 in your code swap the parseInt(jquery version) < 1.3 with the function above

    J

    Josh Kohlbach
    Participant

    @jkohlbach

    Bump.. Is this going to be fixed soon? I’m seeing a nasty message box popup on a client’s website. Not such a great front end experience IMHO, these messages would be more appropriate to be displayed as an admin interface message.

    @jdunneirl

    Thanks for posting the cause of this. Helps out some of the rest of us. 🙂

    In the file
    wp-content\plugins\comprehensive-google-map-plugin\assets\js\cgmp.framework.js
    find the code

    var version = parseFloat($.fn.jquery);
    if (version < 1.0) {
    	alert(CGMPGlobal.errors.oldJquery);
    	//Logger.fatal("Client uses jQuery older than the version 1.3.0. Aborting map generation ..");
    	return false;
    }

    and replace it with

    function compVersions(strV1, strV2) {
    var nRes = 0
    , parts1 = strV1.split('.')
    , parts2 = strV2.split('.')
    , nLen = Math.max(parts1.length, parts2.length);
    
    for (var i = 0; i < nLen; i++) {
    var nP1 = (i < parts1.length) ? parseInt(parts1[i], 10) : 0
    , nP2 = (i < parts2.length) ? parseInt(parts2[i], 10) : 0;
    
    if (isNaN(nP1)) { nP1 = 0; }
    if (isNaN(nP2)) { nP2 = 0; }
    
    if (nP1 != nP2) {
    nRes = (nP1 > nP2) ? 1 : -1;
    break;
    }
    }
    
    return nRes;
    
    };
    
    var strV1 = "1.3";
    var strV2 = $.fn.jquery;
    //alert(compVersions(strV1, strV2));
    
    if (compVersions(strV1, strV2) > 0) {
    	alert(CGMPGlobal.errors.oldJquery);
    	//Logger.fatal("Client uses jQuery older than the version 1.3.0. Aborting map generation ..");
    	return false;
    }

    Save this file.
    That file is not actually used by the plugin, it is the formatted version for humans to read and edit.
    The file that is used is
    wp-content\plugins\comprehensive-google-map-plugin\assets\js\cgmp.framework.min.js
    So now copy the contents of framework.js to framework.min.js then save again.
    The plugin should work now.
    If you know how to minify a js file then minify framework.min.js and save again.

    I really like your plugin by the way.
    It is the most feature rich Google maps plugin out of the 4 I have tried.

    1. Geo-coordinate locations with labels
    2. Custom marker pins
    3. kml overlays
    4. Available in any content type I want
    5. Awesome

    @wallyo

    Thank you. That worked out great.

    hpephoto
    Member

    @hpephoto

    @wallo and @jdunneirl; thanks for the solution.

    Keep in mind that the point of the .min.js is to strip down all unnecessary code to keep it fast.

    Another point is that show an alert like this in a production environment is not cool.

    My suggestion, until the original developer fix this, is to remove the following line in cgmp.framework.min.js: if(1.3>m)return alert(i.oldJquery),!1;

    That worked for me. BUT I have not tested it more than to see that it loads the map.

    derandyk
    Member

    @derandyk

    Got the same problem!!!!

    Comprehensive Google Map Plugin Version 7.0.31 is incompatible with WordPress 3.6

    moluv00
    Member

    @moluv00

    The problem is that the jQuery “live” command has been removed in jQuery versions 1.9x and up. It has been replaced with “on”. The “on” command can replace the “live” command directly”.

    I did a search and replace to change the string “.live(” to “.on(” in the wp-content\plugins\comprehensive-google-map-plugin\assets\js\cgmp.framework.js file, then saved that file as cgmp.framework.min.js in the same directory.

    It worked like a charm.

    lecoinduguitariste
    Member

    @lecoinduguitariste

    @wallyo

    Merci beaucoup pour cette solution!

    Thanks a lot for your work dude!

    I changed the version number from 1.1 to 0.1 and it’s working again. This is after adopting a previous solution (changing it from 1.3 to 1.1) that worked but then stopped working after the most recent WP update.

    I don’t know if this is wild and reckless, but hey.

    The files that I changed are:

    cgmp.framework.js
    cgmp.framework.min.js

    (Both are inside the “assets” folder.)

    Thanks wallyO, the solution works.

    Remko-Creative
    Member

    @remko-creative

    Or you can adjust the version in the file to 1.0!

    Works for me 🙂

    Oh just saw your comment mjtblyth, same solution

    from ABI roger
    Member

    @rogerabihostingcom

    @wally: thanks! perfect fix.

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘[Resolved] Comprehensive Google Map Plugin Jquery 1.10’ is closed to new replies.