filefield_sources_jsonapi-8.x-1.0-beta9/js/modal.js

js/modal.js
(function ($, Drupal, once) {

  'use strict';
  Drupal.behaviors.mediaBox = {
    attach: function (context, settings) {
      var $insert_button = $("#filefield_filesources_jsonapi_action input[name='insert_selected']");

      $('.js-form-type-checkbox + label').each(function () {
        $(once('image-form-wrapper', 'img', this)).wrapAll('<div class="form-image" />');
        $(once('image-wrapper', 'img', this)).wrapAll('<div class="image" />');
      });
      $('input.form-checkbox').on('click', function () {
        var $parent = $(this).closest('.js-form-type-checkbox');
        $insert_button.mousedown();
        if ($(this).is(':checked')) {
          $parent.addClass('checked');
        }
        else {
          $parent.removeClass('checked');
        }
      });

      // Auto trigger search after entering 3 character.
      $("#filefield_filesources_jsonapi_filter input[name='name']").on('keyup', function (e) {
        if (e.which !== 32) {
          var value = $(this).val();
          var noWhitespaceValue = value.replace(/\s+/g, "");
          var noWhitespaceCount = noWhitespaceValue.length;
          if (noWhitespaceCount >= 3 || noWhitespaceCount === 0) {
            $("#filefield_filesources_jsonapi_filter input[name='op']").mousedown();
          }
        }
      });
    }
  };

})(jQuery, Drupal, once);

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc