PageSourceSearch

https://artschool.vn.ua/modules/glyanec/ajax_forms/js/ajax_forms.js?v=tmbss7

js artschool.vn.ua collected 2026-10-03 18:59:45 UTC 3,340 bytes, 115 lines download raw bytes

1
2(function($, Drupal, drupalSettings) {
3
4  'use strict';
5
6  Drupal.AjaxCommands.prototype.magnificPopup = function(ajax, response, status) {
7    var options = {
8      items: {
9        src: response.html,
10        type: 'inline'
11      },
12      mainClass: 'mfp-zoom-in',
13      removalDelay: 400,
14      fixedContentPos: true,
15      fixedBgPos: ('ontouchstart' in window) ? false : true,
16      autoFocusLast: false,
17    }
18
19    // Add custom options added on server side.
20    for (var option in response.options) {
21      options[option] = response.options[option]
22    }
23
24    $.magnificPopup.open(options);
25    Drupal.attachBehaviors();
26  };
27
28  var ajaxFormPromise = new Promise(function (resolve, reject) {
29    if (typeof $.magnificPopup === 'undefined') {
30      setTimeout(function () {
31        if (typeof $.magnificPopup === 'undefined') {
32          reject();
33        }
34        else {
35          resolve();
36        }
37      }, 1000);
38    }
39    else {
40      resolve();
41    }
42  });
43
44  ajaxFormPromise.then(function(){
45    var mfpOpen = $.magnificPopup.instance.open;
46    var mfp_checkIfClose = $.magnificPopup.instance._checkIfClose;
47
48    $.magnificPopup.instance.open = function (data) {
49      mfpOpen.apply(this, arguments);
50
51      var mfp = $.magnificPopup.instance;
52      if(mfp.bgOverlay) {
53        mfp.wrap.on('mousedown.mfp', function(e) {
54          if(mfp._checkIfClose(e.target, true)) {
55            mfp.close();
56          }
57        });
58      }
59    }
60
61    $.magnificPopup.instance._checkIfClose = function(target, isRun) {
62      var mfp = $.magnificPopup.instance;
63      if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
64        return true;
65      }
66      if(isRun) {
67        return mfp_checkIfClose.apply(this, arguments);
68      }
69    }
70    $.magnificPopup.instance._onFocusIn = function(e) {
71      // Do nothing if target element is select2 input
72      if( $(e.target).hasClass('select2-search__field') ) {
73        return true;
74      }
75      // Else call parent method
76      $.magnificPopup.proto._onFocusIn.call(this,e);
77    };
78
79  }).catch(function(error) {});
80
81  function ajaxForms(element, form_id) {
82    var langPath = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix;
83
84    // get entity id if we need node comment form
85    var currentPath = drupalSettings.path.currentPath.split('/');
86    var entity_id_attribute = element.getAttribute('entity_id');
87    var entity_id = '';
88
89    if (entity_id_attribute) {
90      entity_id = '/' + entity_id_attribute;
91    } else if (currentPath[0] === 'node') {
92      entity_id = '/' + currentPath[1];
93    }
94
95    Drupal.ajax({
96      url: langPath + 'api/ajax_forms/link/' + form_id + entity_id + '?destination=/' + drupalSettings.path.currentPath,
97      element: element,
98      progress: { type: 'fullscreen' }
99    }).execute();
100  }
101
102  $(document).ready(function(){
103    if (typeof drupalSettings.ajax_forms !== 'undefined') {
104      for (var selector in drupalSettings.ajax_forms.links) {
105        (function(form_id, selector){
106          $('body').off('click.ajax_forms', selector).on('click.ajax_forms', selector, function(e){
107            e.preventDefault();
108            ajaxForms(this, form_id);
109          });
110        })(drupalSettings.ajax_forms.links[selector], selector);
111      }
112    }
113  });
114
115})(jQuery, Drupal, drupalSettings);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.