PageSourceSearch

https://darwinproject.ac.uk/sites/all/modules/learning_resources/js/learning_resources.js?sh7yfi

js darwinproject.ac.uk collected 2026-09-24 09:13:54 UTC 7,867 bytes, 238 lines download raw bytes

1(function ($) {
2  // $.fn.trans3d = function (o) {
3  //   var o = $.extend({x: 0, y: 0, z: 0}, o);
4  //   return this.each(function () {
5  //     $(this).css({transform: 'translate3d(' + o.x + 'px, ' + o.y + 'px, ' + o.z + 'px)'});
6  //   });
7  // }
8
9  Drupal.behaviors.learningResources = {
10    attach: function (context, settings) {
11      // // wrap and remodal - as long as not editing...
12      // var outcomes = $('div.field-name-field-outcomes', context);
13      // if (outcomes.length && !$('body').hasClass('page-node-edit')) {
14      //   $('.node-learning-resources .field-name-body .field-item:last').prepend('<h3 class="button"><a data-remodal-target="outmocomes">Learning Outcomes...</a></h3>');
15      //   outcomes.attr('data-remodal-id', 'outmocomes').remodal();
16      // }
17
18      // // wrap and remodal - as long as not editing...
19      // var overlay = $('div.lr-overlay-wrap', context);
20      // if (overlay.length && !$('body').hasClass('page-node-edit')) {
21      //   overlay.remodal();
22      // }
23
24      // video content
25      var iframeCount = 0;
26      $("iframe.lr-video", context).once('processed').each(function () {
27//        console.log($(this).parent());
28        var p = $(this).parent().remodal();
29        $(this).show();
30      });
31
32      // admin
33      $('div.lr-admin-top select', context).once('processed').each(function (i, e) {
34        var me = $(e);
35        if (!me.attr('name').match(/\[type\]/)) {
36          return;
37        }
38        // multiple admin items in a table
39        var container = me.closest('td');
40        me.change(function () {
41          switch (me.val()) {
42            case 'presentation':
43            case 'activity':
44              container.find('div.lr-admin-video').hide();
45              container.find('div.lr-admin-overlay').hide();
46              container.find('div.lr-admin-attach').show();
47              break;
48            case 'video':
49              container.find('div.lr-admin-video').show();
50              container.find('div.lr-admin-overlay').hide();
51              container.find('div.lr-admin-attach').hide();
52              break;
53            case 'discuss':
54              container.find('div.lr-admin-video').hide();
55              container.find('div.lr-admin-attach').hide();
56              container.find('div.lr-admin-overlay').show();
57              break;
58          }
59        }).change();
60      });
61
62      // collapse
63      $("div.field-name-field-discussion .collapse p").hide();
64      $("div.field-name-field-discussion .collapse .suggested p").show();
65      $("div.field-name-field-discussion .collapse h4, div.field-name-field-discussion .collapse .suggested").on("click",function(){
66        $(this).parent().find("p, ul").slideDown();
67      }).css({cursor:'pointer'});
68
69    }
70
71  };
72
73  // Level items - make all specified items the same height as the tallest
74
75  Drupal.behaviors.levelItems = {
76    // if less than min width, then don't apply
77    _minWidth: 900,
78    levelItems: function (el, selector) {
79      var maxSize = 0;
80      var winWidth = $(window).width();
81
82      if ($(el).find(selector).length > 0) {
83        $(el).find(selector).each(function (p, q) {
84          // Set height to auto so that heights can be recalculated if needed
85          $(this).css('height', 'auto');
86          // force reflow
87          this.offsetHeight;
88
89          // Find the max height
90          if (maxSize < $(q).height()) {
91            maxSize = $(q).height();
92          }
93        });
94
95        // only if min width satisfied
96        if (winWidth > Drupal.behaviors.levelItems._minWidth) {
97          // Don't add the height attribute if attribute has no height
98          if (maxSize !== 0) {
99            $(el).find(selector).height(maxSize);
100          }
101        }
102        return true;
103      } else {
104        return false;
105      }
106    },
107
108    attach: function (context, settings) {
109      setTimeout(function () {
110        var items = $('div.field-type-learning-resources-item', context);
111        if (!items.hasClass('leveling')) {
112          items.addClass('leveling');
113          Drupal.behaviors.levelItems.levelItems(items, '.lr-inner');
114          var timerID = 0;
115          $(window).resize(function () {
116            if (timerID) {
117              clearTimeout(timerID);
118              timerID = 0;
119            }
120            timerID = setTimeout(function () {
121              timerID = 0;
122              Drupal.behaviors.levelItems.levelItems(items, '.lr-inner');
123            }, 250);
124          })
125        }
126      }, 0);
127
128
129    }
130  };
131
132  // Level pairs of items - even -> odd
133
134  Drupal.behaviors.levelPair = {
135    // if less than min width, then don't apply
136    _minWidth: 900,
137    levelPair: function (a) {
138      var maxSize = 0;
139      var winWidth = $(window).width();
140
141      for (var i = 0; i < a.length; ++i) {
142        // Set height to auto so that heights can be recalculated if needed
143        a[i].css('height', 'auto');
144        // force reflow
145        a[i][0].offsetHeight;
146
147        // Find the max height
148        if (maxSize < a[i].height()) {
149          maxSize = a[i].height();
150        }
151      }
152
153      // only if min width satisfied
154      if (winWidth > Drupal.behaviors.levelPair._minWidth) {
155        // Don't add the height attribute if attribute has no height
156        if (maxSize !== 0) {
157          for (var i = 0; i < a.length; ++i) {
158            a[i].height(maxSize);
159          }
160        }
161      }
162      return true;
163    },
164
165    attach: function (context, settings) {
166      setTimeout(function () {
167        var items = $('div.lr-nodes', context);
168        if (!items.hasClass('pairing')) {
169          items.addClass('pairing');
170          items.find('.even').each(function(i,e){
171            var even = $(e);
172            var odd = even.next('.odd');
173            if (odd.length) {
174              var a = [even.find('.lr-inner'), odd.find('.lr-inner')];
175
176              Drupal.behaviors.levelPair.levelPair(a);
177              var timerID = 0;
178              $(window).resize(function () {
179                if (timerID) {
180                  clearTimeout(timerID);
181                  timerID = 0;
182                }
183                timerID = setTimeout(function () {
184                  timerID = 0;
185                  Drupal.behaviors.levelPair.levelPair(a);
186                }, 250);
187              })
188            }
189          });
190        }
191      }, 0);
192
193
194    }
195  };
196
197  Drupal.behaviors.revealText = {
198    attach: function (context, settings) {
199      $("div.lr-reveal-button a", context).each(function (i, e) {
200        var me = $(this);
201        if (me.hasClass('processed')) {
202          return;
203        }
204        me.addClass('processed');
205        me.click(function () {
206          var p = $(this).closest('.lr-reveal');
207          var content = p.find('.lr-reveal-content');
208          if (content.hasClass('revealed')) {
209            content.removeClass('revealed');
210            $(this).removeClass('revealed');
211            $(this).text($(this).data('original'));
212            // // IE button width hack
213            // me.width(me.data('bwidth')+32);
214          }
215          else {
216            content.addClass('revealed');
217            $(this).addClass('revealed');
218            if (!$(this).data('original')) {
219              $(this).data('original', $(this).text());
220            }
221            $(this).text('Hide');
222            // // IE button width hack
223            // me.width(50);
224          }
225          return false;
226        });
227
228        // // IE issues - start off as inline block
229        // // get width, then become display:block
230        // var w = me.width();
231        // me.data('bwidth', w);
232        // me.css({display:'block', width:w+'px'});
233      });
234    }
235  };
236
237})
238(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.