PageSourceSearch

https://ooagallery.com/lib/g/2.0/scripts/artlogic_modules/_ver_c74…/galleries_js/artworks.js

js ooagallery.com collected 2026-09-30 03:46:48 UTC 23,965 bytes, 459 lines download raw bytes

1import artwork_filters from './artwork_filters.js'
2
3var artworks = {
4
5    init: function() {
6        // If using the version of the template where the filter panel is loaded
7        // in via AJAX (it's slow to render so this method can take advantage of
8        // caching), load in the panel and make it visible.
9        if ($('#artworks_filter_panel').length) {
10            
11            var queryString = $('#artworks_filter_panel').data('query_string');
12            queryString = queryString ? '?' + queryString : '';
13            var proxy_dir_prefix = '';
14            if (window.archimedes.proxy_dir && typeof window.archimedes.proxy_dir !='undefined') {
15                proxy_dir_prefix = window.archimedes.proxy_dir;
16                var lang_code = window.archimedes.proxy_dir.replace('/', '');
17                queryString = queryString ? queryString + '&lang=' + lang_code : '?lang=' + lang_code;
18            }
19            if ($('#artworks_filter_panel').html().trim() === '' && $('#artworks_filter_panel').hasClass('hidden')) {
20                $.get(proxy_dir_prefix + '/artwork_filters/' + queryString, function(html) {
21                    $('#artworks_filter_panel').html(html).removeClass('hidden');
22                    window.galleries.artwork_filters.init();
23                    if ($('#artworks_grid_ajax').html().trim() === '') {
24                        window.galleries.artwork_filters.load_works_api();
25                    }
26                    $('#artworks_filter_panel').css('min-height', '');
27                });
28            } else {
29                window.galleries.artwork_filters.init();
30            }
31            
32            // Load hash permalinks
33            var filterPermalink = '';
34            if (window.location.hash && typeof window.location.hash != 'undefined') {
35                if (window.location.hash.indexOf('#filters=') == 0) {
36                    filterPermalink = window.location.hash.replace('#filters=', '');
37                    var queryString = filterPermalink ? '?' + filterPermalink : '';
38                    if (queryString && queryString != '') { 
39                        var proxy_dir_prefix = '';
40                        if (window.archimedes.proxy_dir && typeof window.archimedes.proxy_dir !='undefined') {
41                            proxy_dir_prefix = window.archimedes.proxy_dir;
42                            var lang_code = window.archimedes.proxy_dir.replace('/', '');
43                            queryString = queryString ? queryString + '&lang=' + lang_code : '?lang=' + lang_code;
44                        }
45                        window.galleries.artwork_filters.load_works_api('/modules/get_artworks/' + queryString);
46                        $.get(proxy_dir_prefix + '/artwork_filters/' + queryString, function(html) {
47                            $('#artworks_filter_panel').html(html);
48                            window.galleries.artwork_filters.init();
49                        });
50                        $('body').addClass('artwork-filters-active');
51                    }
52                }
53            }
54            
55            if (typeof window.onpopstate != 'undefined') {
56                window.onpopstate = function(event) {
57                    if (!$('#filterpanel_form').hasClass('forced-hash-change') && !$('body').hasClass('page-popup-active') && window.location.hash && typeof window.location.hash != 'undefined') {
58                        if (window.location.hash.indexOf('#filters=') == 0) {
59                            filterPermalink = window.location.hash.replace('#filters=', '');
60                            var queryString = filterPermalink ? '?' + filterPermalink : '';
61                            if (queryString && queryString != '') { 
62                                var proxy_dir_prefix = '';
63                                if (window.archimedes.proxy_dir && typeof window.archimedes.proxy_dir !='undefined') {
64                                    proxy_dir_prefix = window.archimedes.proxy_dir;
65                                    var lang_code = window.archimedes.proxy_dir.replace('/', '');
66                                    queryString = queryString ? queryString + '&lang=' + lang_code : '?lang=' + lang_code;
67                                }
68                                window.galleries.artwork_filters.load_works_api('/modules/get_artworks/' + queryString);
69                                $.get(proxy_dir_prefix + '/artwork_filters/' + queryString, function(html) {
70                                    $('#artworks_filter_panel').html(html);
71                                    window.galleries.artwork_filters.init();
72                                });
73                            }
74                        }
75                    }
76                    $('#filterpanel_form').removeClass('forced-hash-change');
77                };
78            }
79        }
80
81        if ($('#artwork_description2_reveal_button').length > 0) {
82            window.galleries.artworks.artwork_description2_reveal_button();
83        }
84        if ($('#artwork_description2_hide_button').length > 0) {
85            window.galleries.artworks.artwork_description2_hide_button();
86        }
87        if ($('#artist_list.artist_image_on_hover').length > 0 || $('.artist_list.artist_image_on_hover').length > 0) {
88            window.galleries.artworks.artist_list_artist_image_on_hover();
89        }
90        if ($('#artwork_descriptive_read_more_button').length > 0) {
91            window.galleries.artworks.artwork_descriptive_read_more_button();
92        }
93        
94        if ($(".roomview-image").length) {
95            setTimeout(() => {
96                
97                $(".roomview-image").each(function(){
98                    
99                    if ($(this).hasClass('roomview-photo-image')) {
100            
101                        var rv_options = {
102                            zoom_enabled: typeof $(this).attr('data-roomview-zoom-disabled') != 'undefined' ? false : true,
103                            zoom_scrollwheel_enabled: typeof $(this).attr('data-roomview-scrollwheel-disabled') != 'undefined' ? false : true
104                        }
105                        var $that = $(this);
106                        // $(this).roomViewPhoto(rv_options);
107                        if (typeof roomViewPhoto == 'undefined') {
108                            Artlogic.import('plugins/roomview-photo.1.0.js')
109                                .then(function(roomview){
110                                    $that.roomViewPhoto(rv_options);
111                                });
112                        } else {
113                            $(this).roomViewPhoto(rv_options);
114                        }
115                        
116                    } else {
117                        
118                        var rv_options = {
119                            furniture_type: 'chair',
120                            wall_type: 'standard', // Options: 'standard', 'concrete', 'brick'
121                            verbose_mode: false
122                        }
123                        // Supply a json config in the html:  data-roomview-custom-config='{"furniture_type":"my_chair","furniture_items": {"rs_chair":{"classname_suffix":"my_chair","furniture_width_cm":148}}}'
124                        var custom_config = $(this).data('roomview-custom-config');
125    
126                        if (custom_config && typeof custom_config != 'undefined') {
127                            if (custom_config.furniture_type && typeof custom_config.furniture_type != 'undefined') {
128                                rv_options["furniture_type"] = custom_config.furniture_type;
129                            }
130                            if (custom_config.furniture_items && typeof custom_config.furniture_items != 'undefined') {
131                                rv_options.furniture_items = custom_config.furniture_items;
132                            }
133                            if (custom_config.wall_type && typeof custom_config.wall_type != 'undefined') {
134                                rv_options["wall_type"] = custom_config.wall_type;
135                            }
136                            if (custom_config.floor_type && typeof custom_config.floor_type != 'undefined') {
137                                rv_options["floor_type"] = custom_config.floor_type;
138                            }
139                        }
140                        var $that = $(this); 
141                        Artlogic.import('plugins/roomview.js')
142                        .then(function(roomview){
143                            $that.roomView(rv_options);
144                        });
145                    }
146                    
147                });
148            }, 250);
149
150            $('.roomview-button-custom').off().click(function(e) {
151                
152                e.preventDefault();
153                
154                // For accessibility - tracks which element to refocus on
155                try {
156                    h.accessibility.global_variables.element_to_refocus_to = $(this).children('a');
157                } catch(error) {
158                    console.error(error);
159                }
160
161                if($(this).parent().parent().hasClass('thumbnails')){
162                    $(".roomview-buttons-wrapper > ul").addClass("active");
163                    $(".roomview-photo-close").addClass("active");
164                     $(".detail_view_module_roomview .roomview-buttons-wrapper > .link , .detail_view_module_ar > button").addClass('hidden');
165
166
167                     if( $(".roomview-buttons-wrapper > ul").height() > 80 ){
168
169                        $(".visualisation-tools").addClass("expand-one-row");
170                     }
171                     if( $(".roomview-buttons-wrapper > ul").height() > 160 ){
172
173                        $(".visualisation-tools").addClass("expand-two-row");
174                     }
175                }
176        
177                var roomview_id = $(this).attr('data-roomview-id');
178                if (roomview_id && typeof roomview_id != 'undefined') {
179                    if ($('#image_gallery').find('.image_gallery_multiple').length) {
180                        var roomview_instance = $('#image_gallery .item:not(.cycle-sentinel) .roomview-image[data-roomview-id="' + roomview_id + '"]');
181                    } else {
182                        var roomview_instance = $('#image_gallery .roomview-image[data-roomview-id="' + roomview_id + '"]');
183                    }
184                    if ($('#image_gallery').find('.image_gallery_multiple').length && !$('.image_gallery_multiple .item:not(.cycle-sentinel) .roomview-image[data-roomview-id="' + roomview_id + '"]').closest('.item').hasClass('cycle-slide-active')) {
185                        
186                        // Change slide before view in a room starts
187                        var this_slide_index = roomview_instance.closest('.cycle-slide').index($('#image_gallery .image_gallery_multiple .cycle-slide').not('.cycle-sentinel'));
188                        if (this_slide_index > -1) {
189                            $('.image_gallery_multiple').cycle(this_slide_index);
190                            setTimeout(function() {
191                                if (typeof roomview_instance.roomView === 'function') {
192                                    roomview_instance.roomView('open');
193                                }
194                            }, 600, roomview_instance);
195                        }
196                    } else {
197                        if (typeof roomview_instance.roomView === 'function') {
198                            roomview_instance.roomView('open');
199                        }
200                    }
201                }
202
203                if (window.gtag) {
204                    gtag('event', 'view_on_a_wall_clicked', {});
205                }
206                
207                window.galleries.artworks.roomview_callback();
208                
209                if (window.ga && typeof window.ga != 'undefined') {
210                    var analytics_params = {
211                        'hitType': 'event',
212                        'eventCategory': 'View on a wall clicked',
213                        'eventAction': window.location.pathname,
214                        'eventLabel': ''
215                    };
216                    ga('send', analytics_params);
217                    ga('tracker2.send', analytics_params);
218                    ga('artlogic_tracker.send', analytics_params);
219                }
220            });
221
222
223            $('.roomview-photo-close').off().click(function(e) {
224                 $(".roomview-buttons-wrapper > ul").removeClass("active");
225                 $(".roomview-photo-close").removeClass("active");
226                 $(".visualisation-tools").removeClass("expand-one-row");
227                 $(".visualisation-tools").removeClass("expand-two-row");
228                 $(".detail_view_module_roomview .roomview-buttons-wrapper > .link , .detail_view_module_ar > button").removeClass('hidden');
229            });
230
231        }
232
233        $(window).off('resize.image_gallery_images').on('resize.image_gallery_images', function() {
234            $('#image_gallery .image[data-width]').each(function() {
235                var image_width = $(this).attr('data-width') && typeof $(this).attr('data-width') != 'undefined' ? $(this).attr('data-width') : false;
236                var image_height = $(this).attr('data-height') && typeof $(this).attr('data-height') != 'undefined' ? $(this).attr('data-height') : false;
237                if (image_width && image_height) {
238                    var item_width = $(this).find('.image').width();
239                    var image_width_proportional = 0;
240                    var image_height_proportional = 0;
241                    if (image_width && image_height) {
242                        var image_width_proportional = item_width / image_width;
243                        var image_height_proportional = image_height * image_width_proportional;
244                        if (image_height_proportional) {
245                                $(this).css('min-height', image_height_proportional);
246                        }
247                    }
248                }
249            });
250        }).trigger('resize.image_gallery_images');
251        
252        if ($('.image_hover_zoom').length) {
253            if (!window.galleries.device.handheld()) {
254                $('.image_hover_zoom').each(function() {
255                    // Disabled on handheld as this stops users from swiping through the works.
256                    var zoom_image = $(this).attr('data-zoom-url');
257                    var zoom_type = window.galleries.device.handheld() ? 'click' : 'mouseover';
258                    if (zoom_image && typeof zoom_image != 'undefined') {
259                        var that = this;
260                        Artlogic.import('plugins/zoom.js').then(function(m) {
261                            $(that).zoom({
262                                url: zoom_image,
263                                duration: 400,
264                                on: zoom_type,
265                                onZoomIn: function(){
266                                    $('body').addClass('zoom-active');
267                                },
268                                onZoomOut: function(){
269                                    $('body').removeClass('zoom-active');
270                                }}
271                            );
272                        })
273                    }
274                });
275            }
276        }
277        
278        if (window.galleries.device.handheld()) {
279            var prevous_drag_percentage = 0;
280            var x;
281
282            var freezeVp = function(e) {
283                e.preventDefault();
284            };
285            function stopBodyScrolling (bool) {
286                if (bool === true) {
287                    document.body.addEventListener("touchmove", function(e) {
288                        e.preventDefault();
289                    }, {passive: false});
290                } else {
291                    document.body.removeEventListener("touchmove", function(e) {
292                        e.preventDefault();
293                    }, {passive: false});
294                }
295            }
296            
297            var debounce_flag = false;
298            var debounce_timeout = false;
299            $('#popup_content').off('scroll').on('scroll', function() {
300                var scrolling_element = $(this);
301                if (!debounce_flag) {
302                    debounce_flag = true;
303                    $(scrolling_element).addClass('scrolling').removeClass('not-scrolling');
304                }
305                clearTimeout(debounce_timeout);
306                debounce_timeout = setTimeout(function() {
307                    $(scrolling_element).removeClass('scrolling').addClass('not-scrolling');
308                    debounce_flag = false;
309                }, 800, scrolling_element);
310            });
311            
312            $('#image_gallery')
313                .on('touchstart', function(e) {
314                    x = e.originalEvent.targetTouches[0].pageX // anchor point
315                })
316                .on('touchmove', function(e) {
317                    $('#image_gallery').addClass('dragging');
318                    var change = e.originalEvent.targetTouches[0].pageX - x;
319                    var percentage = 100 * change / window.innerWidth;
320                    var drag_element = $('#image_gallery .draginner');
321                    if (change < -10 || change > 10) {
322                        var condition_context = $('#image_gallery').closest('#popup_content').length ? '#popup_content' : '#container_outer';
323                        var condition = !$(condition_context).hasClass('scrolling') && !$('body').hasClass('roomview-active');
324                        if (condition) {
325                            // not yet working ios: stopBodyScrolling(true);
326                            $('body').addClass('content-swipe');
327                            drag_element.css({'transform': 'translate3d(' + percentage + '%, 0, 0)'});
328                            $('#image_gallery .draginner').attr('data-left', percentage);
329                            prevous_drag_percentage = percentage;
330                        } else {
331
332                        }
333                    }
334                })
335                .on('touchend', function(e) {
336                    $('#image_gallery').removeClass('dragging');
337                    var percentage = $('#image_gallery .draginner').attr('data-left');
338                    var drag_element = $('#image_gallery .draginner');
339                    $('#image_gallery').removeClass('dragging');
340                    window.setTimeout(function() {
341                        $('body').removeClass('content-swipe');
342                    }, 200);
343                    if (percentage > 30) {
344                        // Previous
345                        if ($('body').hasClass('page-popup-active')) {
346                            var link = $('#popup_box > .inner > .pagination_controls .previous').not('.disabled');
347                        } else {
348                            var link = $('#image_gallery .pagination_controls .previous a').not('.disabled');
349                        }
350                        if (link.length) {
351                            $('.draginner_loader').addClass('loading');
352                            drag_element.css({'transform': 'translate3d(201%, 0, 0)'});
353                            link.trigger('click');
354                        } else {
355                            prevous_drag_percentage = 0;
356                            drag_element.css({'transform': 'translate3d(0, 0, 0)'});
357                            $('#image_gallery.draginner').attr('data-left', '0');
358                        }
359                    } else if (percentage < -30) {
360                        // Next
361                        if ($('body').hasClass('page-popup-active')) {
362                            var link = $('#popup_box > .inner > .pagination_controls .next').not('.disabled');
363                        } else {
364                            var link = $('#image_gallery .pagination_controls .next a').not('.disabled');
365                        }
366                        if (link.length) {
367                            $('.draginner_loader').addClass('loading');
368                            drag_element.css({'transform': 'translate3d(-201%, 0, 0)'});
369                            link.trigger('click');
370                        } else {
371                            varprevous_drag_percentage = 0;
372                            drag_element.css({'transform': 'translate3d(0, 0, 0)'});
373                            $('#image_gallery .draginner').attr('data-left', '0');
374                        }
375                    } else {
376                        var prevous_drag_percentage = 0;
377                        drag_element.css({'transform': 'translate3d(0, 0, 0)'});
378                        $('#image_gallery .draginner').attr('data-left', '0');
379                    }
380                })
381            ;
382        }
383    },
384    
385    roomview_callback: function() {
386                
387    },
388
389    artwork_description2_reveal_button: function() {
390        $('#artwork_description2_reveal_button').click(function() {
391            //$('#artwork_description').slideUp();
392            $(' #artwork_description2_reveal_button, #artwork_description_container').slideUp();
393            $(' #artwork_description2_hide_button').slideDown();
394            $('#artwork_description_2').slideDown();
395            $('#image_gallery').addClass('artwork_full_details_open');
396            $('#artwork_description_2').get(0).focus();
397            return false;
398        });
399    },
400
401    artwork_description2_hide_button: function() {
402        $('#artwork_description2_hide_button').click(function() {
403            //$('#artwork_description').slideUp();
404            $(' #artwork_description2_hide_button').slideUp();
405            $(' #artwork_description2_reveal_button, #artwork_description_container').slideDown();
406            $('#artwork_description_2').slideUp(function() {
407                $('#artwork_description2_reveal_button a').get(0).focus();
408            });
409            $('#image_gallery').removeClass('artwork_full_details_open');
410            return false;
411        });
412    },
413
414    artist_list_artist_image_on_hover: function() {
415        $('#artist_list:not(.artist_list).artist_image_on_hover ul li a img, .artist_list.artist_image_on_hover ul li a img')
416            .each(function() {
417                if (!$(this).closest('a').hasClass('no-hover')) {
418                    $(this).mouseover(function() {
419                        $(this).stop().clearQueue().fadeTo(300, 0.0001);
420                    });
421                    $(this).mouseout(function() {
422                        $(this).fadeTo(500, 1);
423                    });
424                }
425            })
426        ;
427    },
428    
429    artwork_descriptive_read_more_button: function() {
430        
431        $('#artwork_descriptive_read_more_button').off().on('click', function() {
432            
433            if ($('#popup_content #image_gallery').length) {
434                $('#popup_content').animate({
435                    scrollTop: ($("#secondary_content_module").offset().top + $('#popup_content').scrollTop() - $('html,body').scrollTop())
436                }, 600, function() {
437                    if ($('#popup_content #secondary_content_module').length) {
438                        $("#popup_content #secondary_content_module").get(0).focus({preventScroll:true});
439                    }
440                });
441                return false;
442            } else {
443                $('html, body').animate({
444                    scrollTop: $("#secondary_content_module").offset().top
445                }, 600, function() {
446                    if ($('#secondary_content_module').length) {
447                        $("#secondary_content_module").get(0).focus({preventScroll:true});
448                    }
449                });
450            }
451            
452        });
453    }
454
455}
456
457window.galleries = window.galleries || {};
458window.galleries.artworks = artworks;
459export default artworks;

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.