Commit 24eca359 authored by Shimshock Group's avatar Shimshock Group Committed by Joseph Olstad
Browse files

Issue #3007950 by ron_s: Improper version checking causes CKEditor 4.10.1 to break inserting images

parent 6bf6f341
Loading
Loading
Loading
Loading
+32 −1
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@
      ckeditorInstance.insertElement(editorElement);

      // Initialize widget on our html if possible.
      if (parseFloat(CKEDITOR.version) >= 4.3 && hasWidgetSupport) {
      if (Drupal.settings.ckeditor.plugins['media'].compareVersions(CKEDITOR.version, '4.3') >= 0 && hasWidgetSupport) {
        ckeditorInstance.widgets.initOn( editorElement, 'mediabox' );

        // Also support the image2 plugin.
@@ -191,6 +191,37 @@
      }
    },

    /**
     * Compare versions of CKEditor to determine if one version
     * is less than, greater than, or equal to another.
     *
     * @param a
     *   A first instance of CKEditor.
     * @param b
     *   A second instance of CKEditor.
     * @return
     *   A number less than, greater than, or equal to zero.
     *   - If a < b, a number less than zero is returned.
     *   - If a > b, a number greater than zero is return.
     *   - If a = b, the value of 0 is returned.
     */
    compareVersions: function (a, b) {
      var i, diff;
      var regExStrip0 = /(\.0+)+$/;
      var segmentsA = a.replace(regExStrip0, '').split('.');
      var segmentsB = b.replace(regExStrip0, '').split('.');
      var l = Math.min(segmentsA.length, segmentsB.length);

      for (i = 0; i < l; i++) {
        diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
        if (diff) {
          return diff;
        }
      }

      return segmentsA.length - segmentsB.length;
    },

    /**
     * Forces custom attributes into the class field of the specified image.
     *