PageSourceSearch

https://www.jhrl.com/sites/all/modules/rescms/rc_riot/js/mixins/RCRiotSolrItem.js?tlse4v

js jhrl.com collected 2026-10-06 13:19:09 UTC 6,208 bytes, 169 lines download raw bytes

1var RCRiotSolrItem = {
2  init: function() {
3    (function($, tag, opts) {
4      var hto
5      var pc = function(pricing) {
6        tag.update()
7      }
8      tag.has_pricing = false
9      tag.pricing_opts = {}
10      tag.pricing = opts.pricing || {}
11      tag.item = opts.item
12      tag.use_slider = Array.isArray(tag.opts.item[tag.opts.image])
13      tag.description = false;
14      if(opts.link) {
15        tag.linkurl = tag.item[opts.link]
16      }
17      else if(opts.nid) {
18        tag.linkurl = '/node/' + tag.item[opts.nid]
19      }
20      if(opts.beds && typeof tag.item[opts.beds] != 'undefined') {
21        tag.beds = tag.item[opts.beds][0] ? tag.item[opts.beds][0] : tag.item[opts.beds]
22      }
23      if(opts.baths && typeof tag.item[opts.baths] != 'undefined') {
24        tag.baths = tag.item[opts.baths][0] ? tag.item[opts.baths][0] : tag.item[opts.baths]
25      }
26      if(opts.sleeps && typeof tag.item[opts.sleeps] != 'undefined') {
27        tag.sleeps = tag.item[opts.sleeps][0] ? tag.item[opts.sleeps][0] : tag.item[opts.sleeps]
28      }
29      if(opts.description && typeof tag.item[opts.description] != 'undefined') {
30        tag.description = Array.isArray(tag.item[opts.description]) ? tag.item[opts.description][0] : tag.item[opts.description]
31      }
32      if(opts.review_count && typeof tag.item[opts.review_count] != 'undefined') {
33        tag.review_count = tag.item[opts.review_count][0] ? tag.item[opts.review_count][0] : tag.item[opts.review_count]
34      }
35      if(opts.rating && typeof tag.item[opts.rating] != 'undefined') {
36        tag.rating = tag.item[opts.rating][0] ? tag.item[opts.rating][0] : tag.item[opts.rating]
37      }
38      if(opts.amenities && typeof tag.item[opts.amenities] != 'undefined') {
39        tag.amenities = tag.item[opts.amenities]
40      }
41      else {
42        tag.amenities = [];
43      }
44      if(opts.type && typeof tag.item[opts.type] != 'undefined') {
45        tag.type = tag.item[opts.type]
46      }
47      if(opts.view && typeof tag.item[opts.view] != 'undefined') {
48        tag.view = tag.item[opts.view]
49      }
50      if(opts.facility && typeof tag.item[opts.facility] != 'undefined') {
51        tag.facility = tag.item[opts.facility]
52      }
53      tag.RCRiotAvailPricing.on('PricingChanged', pc)
54      tag.on('unmount', function() {
55        tag.RCRiotAvailPricing.off('PricingChanged', pc)
56      })
57      tag.on('update', function() {
58        var hash;
59        tag.pricing = tag.getItemPricing(tag.item.item_id)
60        tag.pricing_child = tag.getPricingChild()
61
62        if(typeof tag.pricing != 'undefined') {
63          tag.has_pricing = true;
64          hash = JSON.parse(tag.RCRiotUtils.parseHash().rcav);
65
66          // If we have flexible stay pricing, make sure our link reflects the top-level item.
67          let activePrice = tag.pricing.prices[0];
68          hash.rcav.begin = activePrice.qp.rcav.begin;
69          hash.rcav.end = activePrice.qp.rcav.end;
70
71          if(opts.link) {
72            tag.linkurl = tag.item[opts.link] + "#" + $.param({ rcav: JSON.stringify(hash) })
73          }
74        } else {
75          tag.has_pricing = false
76          if(opts.link) {
77            tag.linkurl = tag.item[opts.link]
78          }
79        }
80      })
81
82      tag.getLinkTarget = function() {
83        return opts.new_window ? "_blank" : "_self"
84      };
85
86      tag.on('RiotSolrIntersectFirstVisible', function(data) {
87        // Integrate with RiotSolrTrackerController.
88        if(typeof RiotSolrTrackerController !== 'undefined' && RiotTagsDispatch && !window.RCRiotIsSearching) {
89          RiotTagsDispatch.trigger('RiotSolrTrackerTrackItem', tag);
90        }
91      });
92
93      if(typeof opts.linkitem == 'undefined' || opts.linkitem) {
94        tag.RiotSolrLinkedItem.on('LinkedItemFocus', function(item) {
95          if(tag.item.id == item.id) {
96            $(tag.root).addClass('focused')
97          } else {
98            $(tag.root).removeClass('focused')
99          }
100        })
101        $(tag.root).hover(function(e) {
102          hto = setTimeout(function() {
103            tag.RiotSolrLinkedItem.trigger('LinkedItemFocus', tag.item)
104          }, 400)
105        }, function() {
106          clearTimeout(hto)
107        })
108      }
109
110      // Override process children
111      var procc = tag.processChildren
112      tag.processChildren = function() {
113        procc.apply(this)
114        var pc = tag.getPricingChild()
115        if(pc != null) {
116          pc.mounted = true
117        }
118      }
119      tag.getPricingChild = function() {
120        for(var c in tag.children) {
121          if(tag.children[c].plugin == "RCRiotAvailPricing") {
122            return tag.children[c]
123          }
124        }
125        return null
126      }
127
128
129      if(tag.use_slider) {
130        tag.on('update', function () {
131          if(tag.opts.link) {
132            $('#rts-' + tag.item.id + ' a.itemlink').attr('href', tag.linkurl)
133          }
134        });
135        tag.one('updated', function () {
136          var slides = '', slider, target = (tag.opts.new_window == 1 ? '_blank' : '_self')
137          for(ind in tag.item[opts.image]) {
138            if (opts.link) {
139              slides += '<a class="itemlink" href="' + tag.linkurl + '" target="' + target + '"> <img class="rsImg" src="' + tag.item[opts.image][ind] +'" /> </a>'
140            }
141            else {
142              slides += '<a class="itemlink" href="' + tag.item[opts.image][ind] + '" class="rsImg" target="' + target + '"> </a>'
143            }
144          }
145          slider = $('#rts-' + tag.item.id).royalSlider({
146            arrowsNav: true,
147            arrowsNavAutoHide: false,
148            arrowsNavHideOnTouch: true,
149            loop: false,
150            keyboardNavEnabled: false,
151            controlNavigation: 'none',
152            usePreloader: true,
153            numImagesToPreload: 0,
154            navigateByClick: false,
155            slides: slides
156          });
157          var rsFunc = function(ev) {
158            if(ev.originalEvent.propertyName == 'width' || ev.originalEvent.propertyName == 'height') {
159              slider.royalSlider('updateSliderSize', true)
160            }
161          }
162          $(tag.root).parent().on('transitionend', rsFunc)
163        })
164      };
165    })(jQuery, this, this.opts);
166  }
167};
168
169riot.mixin('RCRiotSolrItem', RCRiotSolrItem);

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.