WordPress.org

Forums

Comprehensive Google Map Plugin
[resolved] Comprehensive Google Map Plugin Jquery 1.10 (23 posts)

  1. jdunneirl
    Member
    Posted 1 year ago #

    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/

  2. crienoloog
    Member
    Posted 1 year ago #

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

    Thanks

  3. jdunneirl
    Member
    Posted 1 year ago #

    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

  4. jkohlbach
    Member
    Posted 1 year ago #

    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.

  5. pha3z
    Member
    Posted 1 year ago #

    @jdunneirl

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

  6. wallyO
    Member
    Posted 1 year ago #

    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.

  7. wallyO
    Member
    Posted 1 year ago #

    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
  8. voala
    Member
    Posted 1 year ago #

    @wallyO

    Thank you. That worked out great.

  9. hpephoto
    Member
    Posted 1 year ago #

    @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.

  10. derandyk
    Member
    Posted 1 year ago #

    Got the same problem!!!!

    Comprehensive Google Map Plugin Version 7.0.31 is incompatible with WordPress 3.6

  11. moluv00
    Member
    Posted 1 year ago #

    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.

  12. lecoinduguitariste
    Member
    Posted 1 year ago #

    @wallyO

    Merci beaucoup pour cette solution!

    Thanks a lot for your work dude!

  13. mjtblyth
    Member
    Posted 1 year ago #

    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.)

  14. bilevader
    Member
    Posted 1 year ago #

    Thanks wallyO, the solution works.

  15. Remko-Creative
    Member
    Posted 1 year ago #

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

    Works for me :)

    Oh just saw your comment mjtblyth, same solution

  16. from ABI roger
    Member
    Posted 1 year ago #

    @Wally: thanks! perfect fix.

  17. joannamnew
    Member
    Posted 1 year ago #

    Hi, I am having the same problem. I get the replace steps, but don't understand these steps...

    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.

    Can someone please explain them? I'm a quick learned and have no problem editing CSS. JS is new to me though. How do i minify a JS file?

  18. wallyO
    Member
    Posted 1 year ago #

    So now copy the contents of framework.js and replace the contents of framework.min.js with the code you just copied.
    Then save framework.min.js.
    The plugin should work now.

    Did you do this and does that plugin work now?

  19. wallyO
    Member
    Posted 1 year ago #

    Google is your friend.
    https://www.google.com.au/#q=How+do+i+minify+a+JS+file
    The first result is http://jscompress.com/
    The javascript compressor on this site seems to work quite well.
    There are many other ways also. (Yslow for firebug can be convenient if you use it, Tools=> All JS beatified, All JS Minified.)

  20. joannamnew
    Member
    Posted 1 year ago #

    Hey WallyO, Yes your fix works in the framework.js file and when copied to the framework.min.js file - THANK YOU!! The maps loaded. Much appreciated.

    However, I would like to minify to cut down my load time of the plugin...
    I've read a bit on minifying (you're right, an easy google away), and i copy and pasted into http://jscompress.com and replaced the text in my framework.min.js file. It seemed pretty easy and straight forward, but actually my minified file doesn't work when uploaded. I also tried another minify site, http://minifyjs.com, to make sure it wasn't that.

    Anyway, here is my
    normal javascript
    minified javascript.
    Is there anyway you could take a glance at it and let me know what is going wrong when I minify? Greatly appreciated.

  21. wallyO
    Member
    Posted 1 year ago #

    Hello joannamnew,
    Here is my minified version.
    This was minified by YSlow for Firefox. (Tools => All JS Minified)
    Hint: To make it easy on yourself when minifying files with YSlow, only load the unminified js in Firefox, not the whole page.
    Some of the differences between yours and mine are,
    Yours is all on one line. Mine has about 100 lines.
    Yours has the end of line semi-colons stripped. mine are still in place.
    Other than that I think yours and my files are identical, so one or more of the semi-colans or one or more was the line breaks are required for the syntax of this file to still be valid after passing through the minifier.
    This is a common problem when trying to minify js files.
    Some files break for some settings in some minifiers

  22. alexanderzagniotov
    Member
    Plugin Contributor

    Posted 1 year ago #

    Please update to v.8.0.1 and give it a go again. It contains the jQuery fix

  23. wallyO
    Member
    Posted 1 year ago #

    Works well for me.
    Thanks Alexander.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Comprehensive Google Map Plugin
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic