PageSourceSearch

https://www.jhrl.com/sites/all/modules/bluetent/riot_tags/contrib/riot_tags_modal/js/RiotTagsModal.js?tlse4v

js jhrl.com collected 2026-10-06 13:18:01 UTC 2,952 bytes, 111 lines download raw bytes

1var RiotTagsModal = (function($) {
2  var stack = [],
3    activeModal = null,
4    sizes = {
5      tiny: 'tiny',
6      small: 'small',
7      medium: 'medium',
8      large: 'large',
9      xlarge: 'xlarge'
10    };
11
12  return {
13    getCurrentModal: function() {
14      return activeModal
15    },
16    isTagActive: function(tag) {
17      return (stack.findIndex(function(e) { return e.tag === tag; }) !== -1);
18    },
19    mount: function(tagname, tagopts, size, opts) {
20      var tag = document.createElement(tagname);
21      var retval = this.show(tag, size, opts, tagname);
22      riot.mount(tag, tagname, tagopts);
23      return retval;
24    },
25    closeAll: function() {
26      var conf,
27          ind,
28          p = $.Deferred();
29
30      while (conf = stack.pop()) {
31        if (typeof conf.elem._tag != 'undefined') {
32          conf.elem._tag.unmount();
33        }
34      }
35
36      if (activeModal != null) {
37        $(activeModal).foundation('reveal', 'close').on('closed', function() {
38          p.resolve()
39        })
40      } else {
41        p.resolve()
42      }
43
44      return p
45    },
46    show: function(elem, size, opts, tag) {
47      size = sizes[size] || 'medium';
48      var modal,
49          config = {
50            elem: elem,
51            tag: tag,
52            size: size,
53            opts: opts
54          },
55          modalDefaults = {
56            animationSpeed: 150,
57            animation: 'fadeAndPop'
58          },
59          classes = [size];
60
61      if (opts && opts.class) {
62        classes.push(opts.class);
63      }
64
65      modal = $('<div class="reveal-modal ' + classes.join(' ') + '"><a class="close-reveal-modal" aria-label="Close">&times;</a></div>').prepend(elem);
66      $('body').append(modal);
67      Drupal.attachBehaviors(modal);
68      config.modal = modal;
69      stack.push(config);
70      activeModal = modal;
71
72      var $modal = $(modal).foundation('reveal', 'open', $.extend(modalDefaults, opts)).on('closed', function() {
73        if (modal === activeModal) {
74          var si = stack.findIndex(function(e) { return e === config; }),
75              conf,
76              e;
77
78          if (si !== -1) {
79            e = stack.splice(si, 1)[0];
80
81            if (typeof e.elem._tag !== 'undefined') {
82              e.elem._tag.unmount();
83            }
84
85            if (typeof config.tag !== 'undefined' && typeof config.tag.trigger != 'undefined') {
86              config.tag.trigger('removed');
87            }
88          }
89
90          // Top modal closed, remove from stack.  If there are more in stack pop and show the top again
91          if (stack.length > 0) {
92            conf = stack[stack.length-1];
93            activeModal = conf.modal;
94            $(activeModal).foundation('reveal', 'open');
95          }
96          else {
97            activeModal = null;
98          }
99          $(modal).remove();
100
101        }
102      });
103
104      if (opts && opts.close) {
105        $modal.on('close', window[opts.close]);
106      }
107
108      return $modal;
109    }
110  }
111})(jQuery);

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.