PageSourceSearch

https://muenster-doberan.de/components/com_osgallery/assets/js/osGallery.main.js

js muenster-doberan.de collected 2026-10-02 10:44:39 UTC 127,857 bytes, 2,380 lines download raw bytes

1(function () {
2    
3    var osGallery = function (container, params) {
4        if (!(this instanceof osGallery)) return new osGallery(container, params);
5
6        var defaults = {
7            minImgEnable : 1,
8            spaceBetween: 2.5,
9            minImgSize: 200,
10            numColumns: 3,
11            showImgTitle: '',
12            showImgDescription: '',
13            limEnd: 5,
14            galId: 1,
15            galIdRandom: 1,
16            imgCountCat: '',
17            load_more_background: '',
18            os_fancybox_background: '',
19            showLoadMore: '',
20            juri: '',
21            itemId: '',
22            layout: 'default',
23            albumSublayout: 'defaultTabs',
24            modId: 0,
25            searchText: '',
26            thumbWidth: '600',
27            thumbHeight: '400',
28            //sleduyus4ie 2 svoystva byli dobavleny s cel`u uyti ot globalnyh peremennyh, 
29            //no ostavit vozmognost` dostupa i izmeneniya iz luboy 4asti algoritma
30            curCatId: '',
31            imgBlockW: 0,
32            fancSettings:{
33                wrapCSS: 'os-os_fancybox-window',
34                animationEffect: false,
35                animationDuration: '500',
36                transitionEffect: false,
37                transitionDuration: '800',
38                loop: false,
39                arrows: true,
40                clickContent: 'zoom',
41                wheel : false,
42                slideShow : {
43                    autoStart : false,
44                    speed     : 4000
45                },
46                clickSlide : 'close',
47                thumbs : {
48                    autoStart : true,
49                    axis : 'y'
50                },
51                buttons : [
52                'slideShow',
53                'fullScreen',
54                'thumbs',
55                'share',
56                'download',
57                'zoom',
58                'arrowLeft',
59                'arrowRight',
60                'close'
61                ],
62                share : {
63                    tpl : ''
64                },
65                infobar : true,
66                baseClass : 'thumb_right',
67                idleTime: 60
68            }
69        };
70
71        for (var param in defaults) {
72          if (!params[param] && params[param] != 0){
73            params[param] = defaults[param];
74          }
75        }
76        // gallery settings
77        var osg = this;
78        // Params
79        osg.params = params || defaults;
80        
81        osg.getImgBlockWidth = function (numColumns){
82            
83            if(typeof(numColumns) == 'undefined'){
84                numColumns = osg.params.numColumns
85                osg.params.currentNumColumns = numColumns
86            };
87            var checkSpaceBetween = osg.params.spaceBetween;
88            spaceBetween = osg.params.spaceBetween*2;
89            mainBlockW = jQuerOs(container).width();
90            
91            if(osg.params.layout == 'masonry' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'masonry')){
92                
93                var percentGridSizer = 100/numColumns;
94                var gridSizer = mainBlockW/numColumns;
95                imgBlockWpx = (mainBlockW - (spaceBetween*numColumns))/numColumns;
96                
97                var imgBlockW = percentGridSizer * imgBlockWpx/gridSizer - 0.25;
98
99                if(!checkSpaceBetween) imgBlockW = percentGridSizer;
100
101                jQuerOs(".grid-sizer-"+osg.params.galIdRandom).css('width', percentGridSizer + "%");
102                jQuerOs("#grid-"+osg.params.galIdRandom).css('width', imgBlockW + "%");
103                var sizeAwesome = ((imgBlockW*mainBlockW)/100)/11+"px";
104                jQuerOs(container +" .andrea-effect .andrea-zoom-in").css({'width': sizeAwesome, 'height': sizeAwesome });
105
106                var fontSizetext = ((imgBlockW*mainBlockW)/100)/15+"px";
107                jQuerOs(container +" .grid-item").css({'font-size': fontSizetext, 'line-height': fontSizetext });
108                if(osg.params.minImgEnable && ((imgBlockW*mainBlockW)/100) < osg.params.minImgSize){
109//                    if( ((imgBlockW*mainBlockW)/100) < osg.params.minImgSize ){
110                        numColumns--;
111                        osg.params.currentNumColumns = numColumns;
112                        return osg.getImgBlockWidth(numColumns);
113//                    }
114                }else{
115                    return imgBlockW;
116                }
117            //}else if(osg.params.layout == 'fitRows' || osg.params.layout == 'allInOneRow' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
118            }else if(osg.params.layout == 'fitRows' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
119                
120                imgBlockK = 1 / numColumns;
121                var images = jQuerOs("#grid-item-"+osg.params.galIdRandom);
122                
123                jQuerOs.each(images, function(){
124                    var img = jQuerOs(this).find("img");
125                    var w_ = jQuerOs(img).prop('naturalWidth');
126                    var h_ = jQuerOs(img).prop('naturalHeight');
127
128                    w_ = w_ * imgBlockK;
129                    h_ =  h_ * imgBlockK ;
130                    
131                    img.css('width', w_ + "px");
132//                    jQuerOs(this).css('width', w_ + "px");
133                    img.css('height', h_ + "px");
134//                    jQuerOs(this).css('height', h_ + "px");
135
136                }); 
137                
138                spaceBetween = osg.params.spaceBetween*2;
139                mainBlockW = jQuerOs(container).width();
140                var imgBlockW = ( (((mainBlockW-(spaceBetween*numColumns))/numColumns) )*100)/mainBlockW  ;
141
142                var sizeAwesome = ((imgBlockW*mainBlockW)/100)/11+"px";
143//                jQuerOs(container +" .andrea-effect .andrea-zoom-in").css({'width': sizeAwesome, 'height': sizeAwesome });
144
145                var fontSizetext = ((imgBlockW*mainBlockW)/100)/15+"px";
146                jQuerOs(container +" .img-block").css({'font-size': fontSizetext, 'line-height': fontSizetext });
147
148                jQuerOs("#gutter-sizer-"+osg.params.galIdRandom).css('width', "0%");
149                jQuerOs(".os-gallery-tabs-main-"+osg.params.galIdRandom+" .os-cat-tab-images .grid .img-block").css('height', "");
150                jQuerOs(".os-gallery-tabs-main-"+osg.params.galIdRandom+" .os-cat-tab-images .grid .img-block").css('width', "");
151                
152                var sizeAwesome = ((imgBlockW*mainBlockW)/100)/11+"px";
153//                jQuerOs(container +" .andrea-effect .andrea-zoom-in").css({'width': sizeAwesome, 'height': sizeAwesome });
154
155                var fontSizetext = ((imgBlockW*mainBlockW)/100)/15+"px";
156                jQuerOs(container +" .img-block").css({'font-size': fontSizetext, 'line-height': fontSizetext });
157                return imgBlockW;
158                
159//                return imgBlockW;
160            }else{
161                var imgBlockW = ( (((mainBlockW-(spaceBetween*numColumns))/numColumns) )*100)/mainBlockW  ;
162                
163                if(osg.params.minImgEnable && ((imgBlockW*mainBlockW)/100) < osg.params.minImgSize){
164                    numColumns--;
165                    osg.params.currentNumColumns = numColumns;
166                    return osg.getImgBlockWidth(numColumns);
167                    
168                }else{
169                    var sizeAwesome = ((imgBlockW*mainBlockW)/100)/11+"px";
170                    jQuerOs(container +" .andrea-effect .andrea-zoom-in").css({'width': sizeAwesome, 'height': sizeAwesome });
171                    var fontSizetext = ((imgBlockW*mainBlockW)/100)/15+"px";
172                    jQuerOs(container +" .img-block").css({'font-size': fontSizetext, 'line-height': fontSizetext });
173                    return imgBlockW;
174                }
175            }
176        }
177        osg.setImgBlockHeight = function (reinit){
178            if(jQuerOs(container +" .img-block:first").hasClass('tjava-effect') || 
179                    jQuerOs(container +" .img-block:first").hasClass('vadim-effect') || 
180                    jQuerOs(container +" .img-block:first").hasClass('vlados-effect')){ 
181            }else{
182                return;
183            }
184
185            numColumns = osg.params.currentNumColumns
186            spaceBetween = osg.params.spaceBetween*2;
187            mainBlockW = jQuerOs(container).width();
188            imgBlockWpx = (mainBlockW - (spaceBetween*numColumns))/numColumns;
189
190            var bottom_height = jQuerOs('.os-gallery-caption-bottom:first').height();
191            if(!bottom_height) bottom_height = 0
192            
193            var obj = jQuerOs(container +" .img-block img:first")
194            var selector = obj[0]
195            var src = jQuerOs(container +" .img-block img:first").attr('src')
196//            console.log('222222222222222', Array.isArray(src))
197            if(Array.isArray(src) && src.length > 0){
198                if(jQuerOs(src[0]).attr('src') != undefined){
199                    src = jQuerOs(src[0]).attr('src')    
200                }else{
201                    src = jQuerOs(src[0]).attr('data-src')    
202                }
203                
204
205            }
206            
207            osg.imgSize(src)
208                .then(function(returns) {
209                    
210                    var imgW = returns.width
211                    var imgH = returns.height
212                    var imgBlockH = (imgH * (imgBlockWpx / imgW));
213                    if(!imgBlockH){
214                        imgBlockH = jQuerOs(container +" .img-block:first").height()
215                    }
216
217                    if(osg.params.layout == 'default' || osg.params.layout == 'search'){
218                        jQuerOs(container +" .img-block").css('height', imgBlockH+'px')
219                    }else if(osg.params.layout == 'allInOne'){
220
221                        jQuerOs(container+" .all-in-one-block .img-block:first-child").css('height', imgBlockH+'px')
222        //                jQuerOs(container+" .all-in-one-block .img-block a").css('height', imgBlockH+'px')
223                    }
224                    else if(osg.params.layout == 'album'){
225
226                        if(osg.params.albumSublayout == 'fit_rows'){
227
228                            jQuerOs(container +" .album-main-image").parent().css('height', imgBlockH+'px')
229                        }else if(osg.params.albumSublayout == 'defaultTabs'){
230
231                            jQuerOs(container +" .img-block").css('height', imgBlockH+'px')
232                        }else if(osg.params.albumSublayout == 'masonry'){
233                            jQuerOs(container +" .album-main-image").parent().css('height', imgBlockH+'px')
234                            jQuerOs(container +" .grid .img-block").each(function(){
235                                var src = jQuerOs(this).find("img:first").attr('src')
236                                var img = osg.imgSize(src);
237                                var imgW = img.width
238                                var imgH = img.height
239
240                                var imgBlockH = imgH * (imgBlockWpx / imgW);
241
242                                jQuerOs(this).css('height', imgBlockH+'px');
243                            })
244                        }
245        //                jQuerOs(container+" .all-in-one-block .img-block a").css('height', imgBlockH+'px')
246                    }else if(osg.params.layout == 'masonry'){
247                        
248                        if(reinit) var selector = ".load-more-hidden"
249                        else var selector = '';
250                        jQuerOs(container +" .img-block"+selector).each(function(){
251                            
252                            var src = jQuerOs(this).find("img:first").attr('src')
253                            if(reinit){
254
255                                var img = new Image();
256                                img.src = src;
257                                var self = this;
258                                img.onload = function() {
259                                    var imgW = img.width
260                                    var imgH = img.height
261
262
263                                    var imgBlockH = imgH * (imgBlockWpx / imgW);
264
265                                    jQuerOs(self).css('height', imgBlockH+'px');
266                                }
267                            }else{
268                                var self = this;
269                                osg.imgSize(src)
270                                    .then(function(returns) {
271//                                        console.log('111111111111111', returns)
272                                        var imgW = returns.width
273                                        var imgH = returns.height
274                                        var imgBlockH = imgH * (imgBlockWpx / imgW);
275
276                                        jQuerOs(self).css('height', imgBlockH + 'px');
277                                    })
278                                // var img = osg.imgSize(src);
279
280                            }
281                        })
282                    }
283                })
284            // osg.checkHeight(selector)
285            //     .then(function(returns) {
286            //     //esli izobrageniye zagruzilos i funkciya poschitala visotu - pereopredelyaem taymaut i ustanavlivaem vremya ots4eta obratno n
286a 15 sekund.
287            //         var src = jQuerOs(container +" .img-block img:first").attr('src')
288            //         var img = osg.imgSize(src);
289            //         var imgW = img.width
290            //         var imgH = img.height
291            //
292            // })
293//             var src = jQuerOs(container +" .img-block img:first").attr('src')
294//             var img = osg.imgSize(src);
295//             var imgW = img.width
296//             var imgH = img.height
297//             console.log('111111111111111', selector)
298//             var imgBlockH = (imgH * (imgBlockWpx / imgW));
299//             if(!imgBlockH){
300//                 imgBlockH = jQuerOs(container +" .img-block:first").height()
301//             }
302//
303//             if(osg.params.layout == 'default' || osg.params.layout == 'search'){
304//                 jQuerOs(container +" .img-block").css('height', imgBlockH+'px')
305//             }else if(osg.params.layout == 'allInOne'){
306//
307//                 jQuerOs(container+" .all-in-one-block .img-block:first-child").css('height', imgBlockH+'px')
308// //                jQuerOs(container+" .all-in-one-block .img-block a").css('height', imgBlockH+'px')
309//             }
310//             else if(osg.params.layout == 'album'){
311//
312//                 if(osg.params.albumSublayout == 'fit_rows'){
313//
314//                     jQuerOs(container +" .album-main-image").parent().css('height', imgBlockH+'px')
315//                 }else if(osg.params.albumSublayout == 'defaultTabs'){
316//
317//                     jQuerOs(container +" .img-block").css('height', imgBlockH+'px')
318//                 }else if(osg.params.albumSublayout == 'masonry'){
319//                     jQuerOs(container +" .album-main-image").parent().css('height', imgBlockH+'px')
320//                     jQuerOs(container +" .grid .img-block").each(function(){
321//                         var src = jQuerOs(this).find("img:first").attr('src')
322//                         var img = osg.imgSize(src);
323//                         var imgW = img.width
324//                         var imgH = img.height
325//
326//                         var imgBlockH = imgH * (imgBlockWpx / imgW);
327//
328//                         jQuerOs(this).css('height', imgBlockH+'px');
329//                     })
330//                 }
331// //                jQuerOs(container+" .all-in-one-block .img-block a").css('height', imgBlockH+'px')
332//             }else if(osg.params.layout == 'masonry'){
333//                 if(reinit) var selector = ".load-more-hidden"
334//                 else var selector = '';
335//                 jQuerOs(container +" .img-block"+selector).each(function(){
336//                     var src = jQuerOs(this).find("img:first").attr('src')
337//                     if(reinit){
338//
339//                         var img = new Image();
340//                         img.src = src;
341//                         var self = this;
342//                         img.onload = function() {
343//                             var imgW = img.width
344//                             var imgH = img.height
345//
346//
347//                             var imgBlockH = imgH * (imgBlockWpx / imgW);
348//
349//                             jQuerOs(self).css('height', imgBlockH+'px');
350//                         }
351//                     }else{
352//                         var img = osg.imgSize(src);
353//                         var imgW = img.width
354//                         var imgH = img.height
355//                         var imgBlockH = imgH * (imgBlockWpx / imgW);
356//
357//                         jQuerOs(this).css('height', imgBlockH+'px');
358//                     }
359//                 })
360//             }
361            
362        }
363        var checkingInterval2 = "checkingInterval2"+osg.params.galIdRandom;
364        var os_check_timer2 = {};
365        osg.setImgBlockHeightMassonry = function (reinit){
366            return new Promise(function(resolve, reject) {
367                if(jQuerOs(container +" .img-block:first").hasClass('tjava-effect') ||
368                    jQuerOs(container +" .img-block:first").hasClass('vadim-effect') ||
369                    jQuerOs(container +" .img-block:first").hasClass('vlados-effect')){
370                }else{
371                    resolve(true);
372                }
373                
374                numColumns = osg.params.currentNumColumns
375                
376                spaceBetween = osg.params.spaceBetween*2;
377                mainBlockW = jQuerOs(container).width();
378                imgBlockWpx = (mainBlockW - (spaceBetween*numColumns))/numColumns;
379
380                var bottom_height = jQuerOs('.os-gallery-caption-bottom:first').height();
381                if(!bottom_height) bottom_height = 0
382
383                var obj = jQuerOs(container +" .img-block img:first")
384                var selector = obj[0]
385                var src = jQuerOs(container +" .img-block img:first").attr('src')
386                if(reinit) var selector = ".load-more-hidden"
387                else var selector = '';
388                
389                var end_of_selector = false;
390                jQuerOs(container +" [data-cat-id="+osg.params.curCatId+"] .img-block"+selector).each(function(index){
391                    var src = jQuerOs(this).find("img:first").attr('src')
392                    // if(reinit){
393                    //
394                    //     var img = new Image();
395                    //     img.src = src;
396                    //     var self = this;
397                    //     img.onload = function() {
398                    //         var imgW = img.width
399                    //         var imgH = img.height
400                    //
401                    //
402                    //         var imgBlockH = imgH * (imgBlockWpx / imgW);
403                    //
404                    //         jQuerOs(self).css('height', imgBlockH+'px');
405                    //     }
406                    // }else{
407                        var self = this;
408                        osg.imgSize(src)
409                            .then(function(returns) {
410                                var imgW = returns.width
411                                var imgH = returns.height
412                                var imgBlockH = imgH * (imgBlockWpx / imgW);
413//                                console.log('333333333333333', index, jQuerOs(container +" [data-cat-id="+osg.params.curCatId+"] .img-block"+selector).length)
414                                
415                                jQuerOs(self).css('height', imgBlockH + 'px');
416                                if(jQuerOs(container +" [data-cat-id="+osg.params.curCatId+"] .img-block"+selector).length == index + 1){
417//                                    console.log('222222222222222')
418                                    end_of_selector = true;
419                                }
420                            })
421                        // var img = osg.imgSize(src);
422
423                    // }
424                })
425                os_check_timer2[checkingInterval2] = setInterval(function() {
426                    
427                    if(end_of_selector){
428                        
429                          if(typeof os_check_timer2[checkingInterval2] !== 'undefined') clearInterval(os_check_timer2[checkingInterval2])
430                          resolve(true)
431                    }
432                  }, 500);
433                
434            })
435        }
436
437
438        osg.imgSize = function(href){
439
440            return new Promise(function(resolve, reject) {
441                var img = new Image();
442                img.src = href;
443                img.onload = function() {
444                    resolve(img);
445                };
446            })
447
448
449            // return img;
450        }
451        
452        osg.imageWidthCalculation = function(catId, numColumns){
453            
454            if(typeof(numColumns) == 'undefined'){
455                numColumns = osg.params.numColumns;
456                osg.params.currentNumColumns = numColumns;
457            }
458            
459            var mainBlockW = jQuerOs(container).width();
460            var imgBlockK = 1 / numColumns;
461            //var result = [];
462            var images = jQuerOs.makeArray(jQuerOs("#cat-"+ catId +"-"+osg.params.galIdRandom+" .img-block a img"));
463            var images_a = jQuerOs("#cat-"+ catId +"-"+osg.params.galIdRandom+" .img-block a").find("img:first");
464            
465            images = jQuerOs.makeArray(images_a)
466            
467            var min = jQuerOs(images[0]).prop('naturalHeight') * imgBlockK;
468            
469            //var countImg = mainBlockW/min;
470            //var counter = images.length;
471            spaceBetween = osg.params.spaceBetween*2;
472            var imgBlockWpx = ( (((mainBlockW-(spaceBetween*numColumns))/numColumns) )*100)/mainBlockW  ;
473//            var imgBlockWpx = (mainBlockW - (spaceBetween*numColumns))/numColumns;
474            var copyImages = images.slice();
475            var arr_1 = [];
476            var arr_2 = [];
477            var arr_3 = [];
478            var widthRows = 0;
479            var k_height = 0 ;
480            
481            while(copyImages.length > 0){
482                arr_1 = copyImages.splice(0, numColumns);
483                //суммирование длин картинок в массиве arr_1
484                for(var i = 0; i < arr_1.length; i++){
485                    widthRows += (jQuerOs(arr_1[i]).prop('naturalWi
485dth'));
486                }
487                var k = (mainBlockW - ((numColumns) * spaceBetween) - (numColumns) ) / (widthRows );
488                if (k_height == 0 ) k_height = k ;
489                
490                //set k for last images
491                if(k_height > 0 && arr_1.length < numColumns && k > k_height){
492                    k = k_height;
493                }
494                
495                
496
497                for(var i = 0; i < arr_1.length; i++){
498                    arr_2.push((jQuerOs(arr_1[i]).prop('naturalWidth')) * k);
499                    arr_3.push((jQuerOs(arr_1[i]).prop('naturalHeight')) * k_height);
500                }
501                widthRows = 0;
502                //clear array
503                arr_1 = [];
504            }
505
506            var imag = jQuerOs("#cat-"+ catId +"-"+osg.params.galIdRandom+" .img-block a img");
507            imag = jQuerOs("#cat-"+ catId +"-"+osg.params.galIdRandom+" .img-block a[class^=os_fancybox]");
508            
509            if(jQuerOs(container +" .img-block:first").hasClass('tjava-effect') || 
510                    jQuerOs(container +" .img-block:first").hasClass('vadim-effect') || 
511                    jQuerOs(container +" .img-block:first").hasClass('vlados-effect')){ 
512                
513            }else{
514                var bottom_height = jQuerOs('.os-gallery-caption-bottom:first').height();
515            }
516            
517            if(!bottom_height) bottom_height = 0
518            
519            var j = 0;
520            
521            jQuerOs.each(imag, function(){
522                var img = jQuerOs(this).find("img");
523                
524                var w_ = arr_2[j];
525                var h_ = arr_3[j];
526                
527
528                img.css('width', w_ + "px");
529                jQuerOs(this).css('width', w_ + "px");
530                if(osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows'){
531                    jQuerOs(this).parents('.img-block').css('width', w_ + "px");
532                }
533
534                jQuerOs(this).find(".os-gallery-caption-top").css('width', w_ + "px");
535                jQuerOs(this).find(".os-gallery-caption-bottom").css('width', w_ + "px");
536                img.css('height', h_ + "px");
537                jQuerOs(this).css('height', h_ + "px");
538                jQuerOs(this).parent().css('height', h_ + bottom_height +"px");
539
540                j++;
541            });
542
543            
544            if(osg.params.minImgEnable && numColumns > 1){
545                
546                if(((imgBlockWpx*mainBlockW)/100) < osg.params.minImgSize){
547                    numColumns--;
548                    osg.params.currentNumColumns = numColumns;
549                    osg.imageWidthCalculation(catId, numColumns);
550                }
551            }
552            
553        }
554
555        osg.fitRowsIsotope = function(curCatId){
556            jQuerOs("#cat-"+curCatId+"-"+osg.params.galIdRandom).imagesLoaded(function(){
557                osg.imageWidthCalculation(curCatId);
558                jQuerOs("#cat-"+ curCatId+ "-"+osg.params.galIdRandom+" .fitrow-more-hidden").removeClass("fitrow-more-hidden");
559            });
560        };
561        
562        osg.isotope = function(){
563//            console.log('111111111111111', jQuerOs(container + ' .grid'))
564            jQuerOs(container + ' .grid').isotope({
565                itemSelector: '.grid-item',
566                percentPosition: true,
567                masonry: {
568                    columnWidth: '#grid-sizer-'+osg.params.galIdRandom                                
569                },
570            });
571        };
572
573        osg.reloadIsotope = function(){
574            //VlaDOS 11.01.2021 Commented out due to a jump when LoadMore images.
575//            jQuerOs(container + ' .grid').isotope( 'destroy' );
576            //VlaDOS 11.01.2021//
577            jQuerOs(container + ' .grid').isotope();
578        } 
579
580        osg.reloadAfterLazyLoad = function(){
581            jQuerOs('.grid').isotope('reloadItems');
582            osg.resizeGallery();
583            jQuerOs(container + ' .grid').imagesLoaded(function(){
584                osg.isotope();
585            });
586        }
587        
588        // Функция для установки изображений, предшествующих активному
589            osg.loopPrev = function (el, cssleft) {
590                  if (jQuerOs(el).prev().hasClass("visible-block")) {
591                    var imgprev_id = parseInt(jQuerOs(el).find('img:last').attr("slide_id"));
592
593                    if (jQuerOs(el).prev().find('img').attr("slide_id") != "1") {
594                        jQuerOs(el).prev().animate({
595                            left: cssleft[imgprev_id - 2][1]
596                        }, 300);
597                    }
598                    osg.loopPrev(jQuerOs(el).prev(), cssleft);
599                }
600            }
601
602        //Функция установки изображений, следующих за активным 
603            osg.loopNext = function (el, cssleft) {
604                if (jQuerOs(el).next().hasClass("visible-block")) {
605                    var imgnext_id = parseInt(jQuerOs(el).find('img:last').attr("slide_id"));
606                    
607                    jQuerOs(el).next().animate({
608                        left: cssleft[imgnext_id][2]
609                    }, 300);
610                    osg.loopNext(jQuerOs(el).next(), cssleft);
611                }
612            }
613            osg.initAccordeon = function (curCatId) {
614                
615                var cwidth = parseInt(jQuerOs(container + ".os-gallery-tabs-all-in-one-row .os-cat-tab-images").css("width").replace("px", ""));  // Получаем ширину контейнера с изображениями
616                
617                var img_count = osg.params.numColumns;          // Количество изображений
618
619                var img_width = jQuerOs(container + ".os-gallery-tabs-all-in-one-row .os-cat-tab-images #cat-"+curCatId+"-"+osg.params.galIdRandom+" .visible-block").width();                 // Ширина одного изображения
620                jQuerOs(container + '.os-gallery-tabs-all-in-one-row .os-cat-tab-images #cat-'+curCatId+'-'+osg.params.galIdRandom).css("width", ((img_count * img_width) + 500) + "px")
621                
622                var divider = cwidth / img_count;                       // Ширина полоски, выделяемой для изображения в отсутствии курсора мыши над контейнером
623                var small_space = (cwidth - img_width) / (img_count - 1);       // Ширина полоски, выделяемой для изобржаения при наличии курсора мыши над контейнером
624
625                var timer = null;                                                       // Таймер
626
627                // Устанавливаем позиции изображений
628                var cssleft = Array();                         
629
630
631//                    jQuerOs(".os-gallery-tabs-all-in-one-row .os-cat-tab-images #cat-"+curCatId+"-"+osg.params.galIdRandom+" .visible-block img").each(function(index) {
632                jQuerOs(container + ".os-gallery-tabs-all-in-one-row .os-cat-tab-images #cat-"+curCatId+"-"+osg.params.galIdRandom+" .visible-block").each(function(index) {
633                    // Координаты хранятся в массиве
634                    cssleft[index] = new Array();              
635                    // Вычисляем и устанавливаем позицию изображения при отсутстсвии курсора мыши над контейнером
636                    cssleft[index][0] = (index * divider) - (index * img_width);
637                    jQuerOs(this).css("left", cssleft[index][0] + "px");
638
639                    // Вычисляем позицию изображения при наведенном на него курсоре мыши
640                    cssleft[index][1] = (index * small_space) - (index * img_width);
641
642                    // Вычисляем координату правого угла изобржаения
643                    var index2 = index;
644                    if (index2 == 0) {
645                        index2++;
646                    }
647                    cssleft[index][2] = cssleft[index2 - 1][1];
648                });
649
650                // Курсор мыши над изображением
651                jQuerOs(container + ".os-gallery-tabs-all-in-one-row .os-cat-tab-images #cat-"+curCatId+"-"+osg.params.galIdRandom+" .visible-block").mouseenter(function() {
652                    if (timer) {
653                        clearTimeout(timer);
654                        timer = null;
655                    }
656
657                    var self = this;
658
659                    // Таймер используется для предотвращения "дергания" при быстром перемещении курсора мыши
660                    // над контейнером с изображениями
661                    timer = setTimeout(function() {
662                        
663                        var img_id = parseInt(jQuerOs(self).find('img:last').attr("slide_id").replace("img", "")) - 1;
664                        
665                        if (jQuerOs(self).find('img').attr("slide_id") != "1") {
666                            jQuerOs(self).animate({
667                                left: cssleft[img_id][1]
668                            }, 300);
669                        }               
670                        osg.loopNext(self, cssleft);
671                        osg.loopPrev(self, cssleft);
672                    }, 200)
673
674                });
675
676            // Когда курсор мыши покидает контейнер изображений, возвращаем все в исходное состояние
677                jQuerOs(container + ".os-gallery-tabs-all-in-one-row #cat-"+curCatId+"-"+osg.params.galIdRandom+" .grid").mouseleave(function() {
678                    if (timer){
679                        clearTimeout(timer);
680                        timer = null;
681                    }
682
683                    jQuerOs(container + ".os-gallery-tabs-all-in-one-row .os-cat-tab-images #cat-"+curCatId+"-"+osg.params.galIdRandom+" .visible-block").each(function(index) {
684                        jQuerOs(this).animate({
685                            left: cssleft[index][0]
686                        }, 300);
687                    });
688                });
689            }
690
691        //wE CREATEd UNICAL TIMER_id NAME FROM GALERRY id, i KNOW HOW DO THIS ONLY AS CLASS KEY    
692        var checkingInterval = "checkingInterval"+osg.params.galIdRandom;
693        var timeoutHandle = "timeoutHandle"+osg.params.galIdRandom;
694        var os_check_timer = {} ;
695        
696        //Funkcija zagruzki izobrageniy//selector - dopolnitelniy put' kotoriy peredaetsya dlya nahogdeniya izobrageniy(za4astuyu razniy dlya raznih leyoutov i situaciy takih kak LoadMore)
697        osg.imgLoad = function(selector){
698            //Objavlyaem obeschaniya dlya slushatelya(moment gde obyavlena funkciya)
699            return new Promise(function(resolve, reject) {
700                if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
701                if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
702                //Obyavlyaem taymaut, esli ogydanie zagruzki izobrageniya bolshe 15 sekund - to zacanchivaem 
703                //jdat i stroim galereyu dalshe iz togo 4to est'(4toby izbegat blokirovki zaprosa serverom i ne jdat 5 minut)
704                os_check_timer[timeoutHandle] = setTimeout(function(){
705                    //ubivaem taimaut pered otpravkoy otveta
706	            if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
707	            if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
708                    //otpravlyaem otvet
709                    resolve(true);
710                }, 15000);
711                //opredelyaem koli4estvo izobrajeniy kotorye est' po dannomu selektoru
712                var count = jQuerOs(container + selector + ' img[data-src*=http]').length
713                //ustanavlivaem shetchik dlya koli4estva zagrujenyh izobrageniy
714                var lm = 0;
715                //esly, po dannomu selektoru net izobrajeniy - srazu otpravlyaem otvet
716                if(count == 0){
717                    //ubivaem taymaut pered otpravkoy otveta
718                    if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
719                    if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
720                    //otpravlyaem otvet
721                    resolve(true);
722                }
723                //nachinaem perebor izobrajeniy
724                jQuerOs(container + selector + ' img[data-src*=http]').each(function(index){
725                    //dobavlyaem atribut src k tegu izobrajeniya
726                    jQuerOs(this).attr('src', jQuerOs(this).attr('data-src'))
727                    //udalyaem atribut data-src, 4toby pri dogruzke izobrajeniy ne trogalo uze zagrujennye
728                    jQuerOs(this).removeAttr('data-src')
729                    //jdem polnoy zagruzki izobrajeniya
730                    jQuerOs(this).load(function(){
731                        //esly stranica peregrugena, to na leyaute massonry moget ne uspet poschitat vysotu, vyzyvaem etu funkciyu dlya ispravleniya
732                        osg.checkHeight(this)
733                            .then(function(returns) {
734                            //esli izobrageniye zagruzilos i funkciya poschitala visotu - pereopredelyaem taymaut i ustanavlivaem vremya ots4eta obratno na 15 sekund.
735                            if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
736                            if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
737                            os_check_timer[timeoutHandle] = setTimeout(function(){
738                                if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
739                                if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
740                                resolve(true);
741                            }, 15000);
742                        })
743                        //uvelichivaem schetchik zagrujenyh izobrageniy
744                        lm++
745
746                        //proveryaem, esli vse izobrageniya zagrujeny - ubivaem timout i otpravlyaem otvet
747                        if(lm == count){
748                            if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
749                            if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
750                            resolve(true);
751                        }
752                        this.removeEventListener('load',arguments.callee,false);
753                            
754                    })
755                })
756                
757            })
758        }
759        // v processe sozdaniya funkcii zagruzki izobrageniy stolknulsya s problemoy na tyajeloy stranice
760        // nesmotrya na to, 4to kartinki vse byli zagrujeny, layout massonry ne uspeval pos4itat vysotu
761        // eta funkciya prednazna4ena dlya ispravleniya etoy oshibki
762        osg.checkHeight = function(selector){
763
764            return new Promise(function(resolve, reject) {
765               if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
766               if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
767                os_check_timer[timeoutHandle] = setTimeout(function(){
768                    if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
769                    if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
770                    resolve(true);
771                }, 15000);
772                if(jQuerOs(selector).height()>0){
773               	    if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
774                    if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
775                    resolve(true)
776                }else{
777                    os_check_timer[checkingInterval] = setInterval(function() {
778                      if(jQuerOs(selector).height()>0){
779                	    if(typeof os_check_timer[checkingInterval] !== 'undefined') clearInterval(os_check_timer[checkingInterval])
780                    	    if(typeof os_check_timer[timeoutHandle] !== 'undefined') clearTimeout(os_check_timer[timeoutHandle])
781                            resolve(true)
782                        }
783                    }, 500);
784                }
785
786                
787            })
788        }
789        
790              
791        
792        
793        osg.resizeGallery = function (){
794//            if()
795            osg.params.imgBlockW = osg.getImgBlockWidth();
796//            jQuerOs(container+" .img-block:not(.grid-item)").css("width",osg.params.imgBlockW+"%");
797            jQuerOs(container+" .img-block").css("width",osg.params.imgBlockW+"%");
798        }
799        //function reinit for load more functions
800        osg.reinit = function(catId, limEnd){
801                
802                if(limEnd != 0) jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom+" a.active").attr('data-end', limEnd);
803
804                if(catId){
805
806                    jQuerOs(container+" .os-cat-tab-images div[id^='cat-']").find(".os_fancybox-"+catId ).os_fancybox({
807                        beforeShow: function(){
808                            // resize html block to image width
809                            if (this.os_image_id){
810                                var id = this.os_image_id;
811                            }
812                            else {
813                                var id = this.opts.$orig.attr('id');
814                            }
815                            id = id.split('-')[1];//get scalar id
816                            var naturalWidth = jQuerOs('.htmlWidthAsImage#data-html-'+id+' .imgInHtml img').prop('naturalWidth');
817                            if(naturalWidth){  
818                                jQuerOs('.htmlWidthAsImage#data-html-'+id).css({'padding' : 0, 'width' : naturalWidth});
819                                jQuerOs('.htmlWidthAsImage#data-html-'+id+' .contentInHtml').css({'padding' : 15});
820                            }
821                            jQuerOs('.os_fancybox-bg').css('backgroundColor', osg.params.os_fancybox_background);
822
823                            if (this.os_image_id){
824                                var id = this.os_image_id;
825                            }    
826                            else {
827                                var id = this.opts.$orig.attr('id');
828                            }
829                            var href = window.location.href;
830                            if(!from_history){
831                                if (href.indexOf('&os_image_id') > -1) {
832
833                                    history.pushState (null, null, href.substring(0, href.indexOf('&os_image_id') )+ "&" + id);}
834                                else if (href.indexOf('?os_image_id') > -1) {
835
836                                    history.pushState (href, null, href.substring(0, href.indexOf('?os_image_id')) + "?" + id);}
837                                else if (href.indexOf('?') > -1 && href.indexOf('&') > -1 && href.indexOf('&os_image_id') == -1){
838
839                                    history.pushState(null, null, href + '&' + id);}
840                                else if ( href.indexOf('&') == -1 && href.indexOf('?os_image_id') == -1 && href.indexOf('?') == -1){
841
842                                    history.pushState(null, null, href + '?' + id);}
843                                else if (href.indexOf('?') > -1 && href.indexOf('os_image_id') == -1 ){
844                                    history.pushState(null, null, href + '&' + id);
845                                }
846
847                            }
848//                                        
849
850
851
852                        },
853                        beforeClose: function(){
854                            var href = window.location.href;
855
856                            if (href.indexOf('&os_image_id') > -1){
857                                history.pushState (href, null, href.substring(0, href.indexOf('&os_image_id')));
858                            }else{
859                                history.pushState (href, null, href.substring(0, href.indexOf('?os_image_id')));
860                            }
861                            //return value scroll for load more function
862
863                            if (osg.params.showLoadMore == 'scroll'){
864                                osg.loadMore(osg.params.showLoadMore);
865                            }
866                        },
867                        beforeLoad: function() {
868                            //not use because call many times for one image
869                        },
870                        afterShow: function() {
871                            var href = window.location.href;
872                            var os_fancy_box_getInst = jQuerOs.os_fancybox.getInstance();
873                            //get the length of the array
874                            var os_fb_group_count = os_fancy_box_getInst.group.length;
875                            //get the current position
876                            var os_now = os_fancy_box_getInst.currIndex;
877
878                            var os_show_load_more = osg.params.showLoadMore;
879                            //if there are less than 3 pictures left before the end of the array and if load more is possible, we call the load
880                            var catId = jQuerOs('.os-cat-tab-images .active').attr('data-cat-id');
881                            var data_end = jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end');
882                            if(data_end == undefined){
883                                data_end = 0
884                            }
885
886                            if ((Number(os_now) + 4) > os_fb_group_count && data_end > 0 && os_show_load_more !== null && os_show_load_more != 0){ 
887                                
888
889
890                                if (os_show_load_more == 'auto'){
891                                    osg.loadMore("auto");
892
893                                }
894                                else if (os_show_load_more !== null){
895
896                                    osg.loadMore("button");
897                                    jQuerOs('#load-more-'+osg.params.galIdRandom).trigger('click');
898                                }
899                                jQuerOs(".os_fancybox-button--arrow_right").attr('disabled', 'true');
900                                jQuerOs(".os_fancybox-button--arrow_left").attr('disabled', 'true');
901                                var html = jQuerOs("<div class='os_fancybox-loading'></div>")
902                                jQuerOs(".os_fancybox-slide").append(html)
903                                
904
905                            }
906
907                            if (Number(os_now) == os_fb_group_count && jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end') > -1){
908                                jQuerOs(".os_fancybox-button--arrow_right").attr('disabled', 'true');
909                            }
910
911
912                        },
913                        afterLoad: function(){
914                            //not use because call many times for one image
915
916                        },  
917                        wrapCSS    : osg.params.fancSettings.wrapCSS,
918
919                        animationEffect : osg.params.fancSettings.animationEffect,
920                        animationDuration : osg.params.fancSettings.animationDuration,
921                        transitionEffect : osg.params.fancSettings.transitionEffect,
922                        transitionDuration : osg.params.fancSettings.transitionDuration,
923                        loop: osg.params.fancSettings.loop,
924                        arrows: osg.params.fancSettings.arrows,
925                        clickContent : function( current, event ) {
926                            return current.type === 'image' ? osg.params.fancSettings.clickContent : false;
927                        },
928                        wheel : osg.params.fancSettings.wheel,
929                        slideShow : {
930                            autoStart : osg.params.fancSettings.slideShow.autoStart,
931                            speed     : osg.params.fancSettings.slideShow.speed
932                        },
933
934                        clickSlide : osg.params.fancSettings.clickSlide,
935                        thumbs : {
936                            autoStart : osg.params.fancSettings.thumbs.autoStart,
937                            axis      : osg.params.fancSettings.thumbs.axis
938                        },
939                        buttons : [
940                            osg.params.fancSettings.buttons.slideShow,
941                            osg.params.fancSettings.buttons.fullScreen,
942                            osg.params.fancSettings.buttons.thumbs,
943                            osg.params.fancSettings.buttons.share,
944                            osg.params.fancSettings.buttons.download,
945                            osg.params.fancSettings.buttons.zoom,
946                            osg.params.fancSettings.buttons.arrowLeft,
947                            osg.params.fancSettings.buttons.arrowRight,
948                            osg.params.fancSettings.buttons.close,
949                        ],
950                        share : {
951                            tpl : osg.params.fancSettings.share.tpl
952                        },
953                        infobar: osg.params.fancSettings.infobar, //counter on/off
954                        baseClass : osg.params.fancSettings.baseClass, //add appropriate class to set thumbnails position {thumb_bottom},{thumb_right}
955                        loadmore : osg.params.showLoadMore,
956                        idleTime: 60
957                    });
958                }
959        }
960
961
962        //initialize function
963        osg.init = function(limEnd){ 
964            inProgressAjax = false;
965            if(osg.params.juri.slice(-1) == '/'){
966                osg.params.juri = osg.params.juri.slice(0, -1);
967            }
968            if(limEnd != 0) jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom+" a.active").attr('data-end', limEnd);
969
970            osg.params.imgBlockW = osg.getImgBlockWidth();
971
972            jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween + "px");
973            jQuerOs("#button-"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween + "px");
974            
975            //if(osg.params.layout == 'default' || osg.params.layout == 'allInOneRow' || osg.params.layout == 'search'){
976            
977            jQuerOs(container+" .os-cat-tab-images div[id^='cat-']").each(function(index, el) {
978                
979                catId = jQuerOs(this).data("cat-id");
980                catId1 = jQuerOs(this).data("cat-id");
981                
982                if(catId){
983
984                    var os_fancy_box = jQuerOs(this).find(".os_fancybox-"+catId ).os_fancybox({
985
986
987                        
988                       beforeShow: function(){
989                           
990                            // resize html block to image width
991                            if (this.os_image_id){
992                                var id = this.os_image_id;
993                            }
994                            else {
995                                var id = this.opts.$orig.attr('id');
996                            }
997                            id = id.split('-')[1];//get scalar id
998                            var naturalWidth = jQuerOs('.htmlWidthAsImage#data-html-'+id+' .imgInHtml img').prop('naturalWidth');
999                            if(naturalWidth){  
1000                                jQuerOs('.htmlWidthAsImage#data-html-'+id).css({'padding' : 0, 'width' : naturalWidth});
1001                                jQuerOs('.htmlWidthAsImage#data-html-'+id+' .contentInHtml').css({'padding' : 15});
1002                            }
1003                            jQuerOs('.os_fancybox-bg').css('backgroundColor', osg.params.os_fancybox_background);
1004
1005                            if (this.os_image_id){
1006                                var id = this.os_image_id;
1007                            }    
1008                            else {
1009                                var id = this.opts.$orig.attr('id');
1010                            }
1011
1012                            var href = window.location.href;
1013
1014                            if(!from_history){
1015
1016
1017                                if (href.indexOf('&os_image_id') > -1) {
1018
1019                                    history.pushState (null, null, href.substring(0, href.indexOf('&os_image_id') )+ "&" + id);
1020                                }
1021                                else if (href.indexOf('?os_image_id') > -1) {
1022
1023                                    history.pushState (href, null, href.substring(0, href.indexOf('?os_image_id')) + "?" + id);}
1024                                else if (href.indexOf('?') > -1 && href.indexOf('&') > -1 && href.indexOf('&os_image_id') == -1){
1025
1026                                    history.pushState(null, null, href + '&' + id);}
1027                                else if ( href.indexOf('&') == -1 && href.indexOf('?os_image_id') == -1 && href.indexOf('?') == -1){
1028
1029                                    history.pushState(null, null, href + '?' + id);}
1030                                else if (href.indexOf('?') > -1 && href.indexOf('os_image_id') == -1 ){
1031
1032                                    history.pushState(null, null, href + '&' + id);
1033                                }
1034
1035                            }
1036//                                        
1037//                                       
1038
1039
1040
1041                        },
1042                        beforeClose: function(){
1043
1044                            var href = window.location.href;
1045
1046                            if (href.indexOf('&os_image_id') > -1){
1047                                history.pushState (href, null, href.substring(0, href.indexOf('&os_image_id')));
1048                            }else{
1049                                history.pushState (href, null, href.substring(0, href.indexOf('?os_image_id')));
1050                            } 
1051                            //return value scroll for load more function
1052                            if (osg.params.showLoadMore == 'scroll'){
1053                                osg.loadMore(osg.params.showLoadMore);
1054                            }
1055//                            jQuerOs('.os-cat-tab-images .active').removeClass('active');
1056//                            jQuerOs('.os_fancybox-container').remove()
1057                        },
1058                        beforeLoad: function() {
1059                            //not use because call many times for one image
1060
1061
1062
1063                        },
1064                        afterShow: function() {
1065
1066                            
1067                            var iframe_content = jQuerOs('.os_fancybox-content');
1068                            if(iframe_content.length > 0){
1069
1070                            }
1071                            var href = window.location.href;
1072                            var os_fancy_box_getInst = jQuerOs.os_fancybox.getInstance();
1073                            //get the length of the array
1074                            var os_fb_group_count = os_fancy_box_getInst.group.length;
1075                            //get the current position
1076                            var os_now = os_fancy_box_getInst.currIndex;
1077//                            if(os_now == undefined){
1078//                                var cat_id = jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-cat-id');
1079//                                os_now = jQuerOs("#cat-"+cat_id+"-"+osg.params.galIdRandom + " .img-block").length;
1080//                            } 
1081                            var os_show_load_more = osg.params.showLoadMore;
1082                            //if there are less than 3 pictures left before the end of the array and if load more is possible, we call the load
1083                            
1084                            var catId = jQuerOs('.os-cat-tab-images .active').attr('data-cat-id');
1085                            var data_end = jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end');
1086                            if(data_end == undefined){
1087                                data_end = 0
1088                            }
1089
1090                            if ((Number(os_now) + 4) > os_fb_group_count && data_end > 0  && os_show_load_more !== null && os_show_load_more != 0){ 
1091                                if (os_show_load_more == 'auto'){
1092                                    osg.loadMore("auto");
1093
1094                                }
1095                                else if (os_show_load_more !== null){
1096
1097                                    osg.loadMore("button");
1098                                    jQuerOs('#load-more-'+osg.params.galIdRandom).trigger('click');
1099                                }
1100                                jQuerOs(".os_fancybox-button--arrow_right").attr('disabled', 'true');
1101                                jQuerOs(".os_fancybox-button--arrow_left").attr('disabled', 'true');
1102                                var html = jQuerOs("<div class='os_fancybox-loading'></div>")
1103                                jQuerOs(".os_fancybox-slide").append(html)
1104                                
1105
1106                            }
1107
1108                            if (Number(os_now) == os_fb_group_count && jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end') > -1){
1109                                jQuerOs(".os_fancybox-button--arrow_right").attr('disabled', 'true');
1110                            }
1111
1112
1113                        },
1114                        afterLoad: function(){
1115                            //not use because call many times for one image
1116                        },        
1117
1118
1119                        wrapCSS    : osg.params.fancSettings.wrapCSS,
1120
1121                        animationEffect : osg.params.fancSettings.animationEffect,
1122                        animationDuration : osg.params.fancSettings.animationDuration,
1123                        transitionEffect : osg.params.fancSettings.transitionEffect,
1124                        transitionDuration : osg.params.fancSettings.transitionDuration,
1125                        loop: osg.params.fancSettings.loop,
1126                        arrows: osg.params.fancSettings.arrows,
1127                        //VlaDOS 28.05.2021
1128                        //This function checks if the object is a picture, this option is triggered, if any other element (video, html, etc.), then no. After the client has contacted and verified, the function is not needed, fancybox defines it itself.
1129//                        clickContent : function( current, event ) {
1130
1131//                            return current.type === 'image' ? osg.params.fancSettings.clickContent : false;
1132//                        },
1133                        //VlaDOS 28.05.2021
1134                        clickContent : osg.params.fancSettings.clickContent,
1135                        wheel : osg.params.fancSettings.wheel,
1136                        slideShow : {
1137                            autoStart : osg.params.fancSettings.slideShow.autoStart,
1138                            speed     : osg.params.fancSettings.slideShow.speed
1139                        },
1140
1141                        clickSlide : osg.params.fancSettings.clickSlide,
1142                        thumbs : {
1143                            autoStart : osg.params.fancSettings.thumbs.autoStart,
1144                            axis      : osg.params.fancSettings.thumbs.axis
1145                        },
1146                        buttons : [
1147                            osg.params.fancSettings.buttons.slideShow,
1148                            osg.params.fancSettings.buttons.fullScreen,
1149                            osg.params.fancSettings.buttons.thumbs,
1150                            osg.params.fancSettings.buttons.share,
1151                            osg.params.fancSettings.buttons.download,
1152                            osg.params.fancSettings.buttons.zoom,
1153                            osg.params.fancSettings.buttons.arrowLeft,
1154                            osg.params.fancSettings.buttons.arrowRight,
1155                            osg.params.fancSettings.buttons.close,
1156                        ],
1157                        share : {
1158                            tpl : osg.params.fancSettings.share.tpl
1159                        },
1160                        touch: {
1161                            vertical: false, // Allow to drag content vertically
1162                            momentum: true // Continue movement after releasing mouse/touch when panning
1163                        },
1164                        infobar: osg.params.fancSettings.infobar, //counter on/off
1165                        baseClass : osg.params.fancSettings.baseClass, //add appropriate class to set thumbnails position {thumb_bottom},{thumb_right}
1166                        loadmore : osg.params.showLoadMore,
1167                        idleTime: 60
1168
1169                    });
1170                }
1171            });
1172            
1173            width = jQuerOs(window).width();
1174            if(osg.params.imgCountCat != ''){
1175                var img_count_cat = JSON.parse(osg.params.imgCountCat);
1176            }else{
1177                var img_count_cat = '';
1178            }
1179            
1180            if(osg.params.layout != 'allInOne'){
1181                jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom+" a").click(function(e) {
1182
1183                    e.preventDefault();
1184                    jQuerOs('#os_progres_img-'+osg.params.galIdRandom+':last' ).addClass('img-block1'); 
1185                    jQuerOs('li a').removeClass("active");
1186                    jQuerOs(container+" .os-cat-tab-images>div").hide();
1187                    jQuerOs(this).addClass("active");
1188                    osg.params.curCatId = jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom+" a.active").attr('data-cat-id');
1189                    osg.imgLoad(" div#cat-"+osg.params.curCatId + '-' + osg.params.galIdRandom)
1190                        .then(function(returns) {
1191                        osg.params.imgBlockW = osg.getImgBlockWidth();
1192                        if(osg.params.layout == 'default' || osg.params.layout == 'search'){
1193                            jQuerOs(container+" .img-block").css("width",osg.params.imgBlockW+"%");
1194                            osg.setImgBlockHeight()
1195
1196                        }else if(osg.params.layout == 'allInOne'){
1197
1198                            jQuerOs(container+" .all-in-one-block .img-block:first-child").css("width",osg.params.imgBlockW+"%");
1199                            osg.setImgBlockHeight()
1200                            jQuerOs(container+" .os-cat-tab-images").show();
1201                        }else if(osg.params.layout == 'masonry'){
1202
1203                            jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1204                            jQuerOs("#button-"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1205                            jQuerOs(container+" .grid-"+osg.params.galIdRandom).css("width",osg.params.imgBlockW+"%");
1206                            osg.setImgBlockHeight()
1207            //            }else if(osg.params.layout == 'fitRows'|| osg.params.layout == 'allInOneRow' ){
1208                        }else if(osg.params.layout == 'fitRows'){
1209                            jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1210                            jQuerOs("#button-"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1211                        }else if(osg.params.layout == 'allInOneRow'){
1212            //                jQuerOs(container+" .img-block").css("width","100%");
1213                        }
1214                        
1215                        var href = window.location.href;
1216                        if (!from_history && href.indexOf('os_image_id') == -1){
1217
1218                            if (href.indexOf('?cat-') > -1) {
1219
1220                                history.pushState (null, null, href.substring(0, href.indexOf('?cat-') ) + '?cat-' + osg.params.curCatId);
1221                            }else if (href.indexOf('&cat-') > -1) {
1222
1223                                history.pushState (null, null, href.substring(0, href.indexOf('&cat-') ) + '&cat-' + osg.params.curCatId);
1224                            }else if (href.indexOf('?') > -1){
1225
1226                                history.pushState(null, null, href + '&cat-' + osg.params.curCatId);
1227                            }else {
1228
1229                                history.pushState(null, null, href + '?cat-' + osg.params.curCatId);
1230                            }
1231                        }
1232
1233                        jQuerOs("#cat-"+osg.params.curCatId+"-"+osg.params.galIdRandom).show();
1234                        jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-cat-id', osg.params.curCatId);
1235                        curEnd = jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom+" a.active").attr('data-end');
1236                        
1237                        if(osg.params.layout != 'allInOneRow' && osg.params.layout != 'allInOne' && osg.params.showLoadMore == 'button'){
1238                            
1239                            if(img_count_cat != '' && jQuerOs('#cat-' + osg.params.curCatId +'-'+osg.params.galIdRandom).children().length >= Number(img_count_cat[osg.params.curCatId])){
1240
1241                                jQuerOs("#load-more-"+osg.params.galIdRandom+"[data-cat-id="+osg.params.curCatId+"]").hide();
1242                            }else{
1243
1244                                jQuerOs("#load-more-"+osg.params.galIdRandom+"[data-cat-id="+osg.params.curCatId+"]").show();
1245    //                            jQuerOs("#load-more-"+osg.params.galIdRandom+"[data-cat-id="+osg.params.curCatId+"]").parent().show()
1246                            }
1247                        }
1248                        if(curEnd != -1){
1249                            jQuerOs("#load-more-"+osg.params.galIdRandom).removeAttr("disabled");
1250                            jQuerOs("#load-more-"+osg.params.galIdRandom).css("background", osg.params.load_more_background);
1251                        }
1252                        limEnd = curEnd
1253                        jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end', curEnd);
1254                        
1255                        
1256                        jQuerOs(jQuerOs(this).attr("href")).fadeTo(500, 1);
1257                        var href = window.location.href;
1258                        var img_el_id = '';
1259                        var pos1 = href.indexOf('os_image_id'); 
1260                        var pos2 = href.lastIndexOf('#'); 
1261                        var os_show_load_more = osg.params.showLoadMore;
1262                        if (pos1 > -1 && pos2 > - 1) {
1263                            img_el_id = href.substring(pos1, pos2); 
1264                        }else if(pos1 > -1 && pos2 == -1){
1265                            img_el_id = href.substring(pos1);
1266                        }
1267                        os_fancy_box_getInst = jQuerOs.os_fancybox.getInstance(); 
1268
1269                        if(!os_fancy_box_getInst){
1270                            
1271                            if(img_el_id && img_el_id.indexOf('os_image_id') > -1)  {
1272                                
1273                                if(document.getElementById(img_el_id) == null){
1274                                    if (os_show_load_more == 'auto'){
1275                                        osg.loadMore("auto");
1276
1277                                    }
1278                                    else if (os_show_load_more !== null){
1279                                        
1280                                        osg.loadMore("button");
1281
1282                                        jQuerOs('#load-more-'+osg.params.galIdRandom).trigger('click');
1283
1284                                    }
1285
1286                                }
1287
1288                                else {
1289                                    jQuerOs('#' + img_el_id).trigger('click');
1290                                }
1291                            }
1292                        }
1293                        jQuerOs('#os_progres_img-'+osg.params.galIdRandom+':last' ).removeClass('img-block1'); 
1294                        if (osg.params.showLoadMore != 0){
1295                            
1296                            osg.loadMore(osg.params.showLoadMore);
1297                        }
1298                        
1299                        if(osg.params.layout == 'masonry'){
1300                            osg.setImgBlockHeightMassonry()
1301                                .then(function(returns) {
1302                                    osg.isotope();
1303                                    osg.reloadIsotope();
1304                                })
1305//                        }else if(osg.params.layout == 'fitRows' || osg.params.layout == 'allInOneRow'){
1306                        }else if(osg.params.layout == 'fitRows'){
1307                            osg.fitRowsIsotope(osg.params.curCatId);
1308                        }else if(osg.params.layout == 'allInOneRow'){
1309//                            setTimeout(function(){ 
1310
1311                                osg.initAccordeon(osg.params.curCatId)
1312                                
1313                                
1314//                            }, 3000);
1315                            
1316
1317                        }
1318                    })
1319
1320                });
1321            }else{
1322                jQuerOs('.img-block').on('click', function(){
1323                    //e.preventDefault();
1324                    jQuerOs('li a').removeClass("active");
1325                    jQuerOs(this).parent().addClass('active');
1326                    osg.params.curCatId = jQuerOs(this).parent().attr('data-cat-id');
1327                    var href = window.location.href;
1328                    //???????
1329                    if (!from_history && href.indexOf('os_image_id') == -1){
1330                        if (href.indexOf('?cat-') > -1) {
1331
1332                            history.pushState (null, null, href.substring(0, href.indexOf('?cat-') ) + '?cat-' + osg.params.curCatId);
1333                        }else if (href.indexOf('&cat-') > -1) {
1334
1335                            history.pushState (null, null, href.substring(0, href.indexOf('&cat-') ) + '?cat-' + osg.params.curCatId);
1336                        }else if (href.indexOf('?') > -1){
1337
1338                            history.pushState(null, null, href + '&cat-' + osg.params.curCatId);
1339                        }else {
1340
1341                            history.pushState(null, null, href + '?cat-' + osg.params.curCatId);
1342                        }
1343                    }
1344                    //????????
1345                    jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-cat-id', osg.params.curCatId);
1346                    curEnd = jQuerOs('a#cat-'+osg.params.curCatId+osg.params.galIdRandom).attr('data-end');
1347
1348                    jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end', curEnd);
1349
1350
1351                });
1352                
1353                
1354            }
1355            var href = window.location.href;
1356            var position_gallery = href.indexOf('cat');
1357            var gallery_cat_id = '';
1358            var gallery_cat_id = href.substring(position_gallery);
1359            if(gallery_cat_id.indexOf('&') > -1){
1360                gallery_cat_id = gallery_cat_id.substr(0, gallery_cat_id.indexOf('&'));
1361            }
1362            var cat_id = gallery_cat_id.replace(/cat-/i, '');
1363            
1364            
1365            if(gallery_cat_id && gallery_cat_id.indexOf('cat-') > -1 && gallery_cat_id.indexOf('=') == -1 && osg.params.layout != 'album' && img_count_cat[cat_id] !== undefined){
1366                jQuerOs('#' + gallery_cat_id + osg.params.galIdRandom).trigger('click');
1367            }else{
1368                if(osg.params.layout == 'album'){
1369                    
1370                    //начинаем загрузку изображений
1371                    osg.imgLoad(" .album-main-image")
1372                      .then(function(returns) {
1373                          if(osg.params.layout == 'album'){
1374//                              jQuerOs(container+" .img-block").css("width",osg.params.imgBlockW+"%");
1375//                                osg.setImgBlockHeight()
1376                                if(osg.params.albumSublayout == 'fit_rows'){
1377                                    var numColumns = osg.params.numColumns
1378                                    osg.params.imgBlockW = ( (((mainBlockW-(spaceBetween*numColumns))/numColumns) )*100)/mainBlockW  ;
1379                                    if(osg.params.minImgEnable){
1380                                        if(((osg.params.imgBlockW*mainBlockW)/100) < osg.params.minImgSize){
1381                                            numColumns--;
1382                                            osg.getImgBlockWidth(numColumns);
1383                                        }
1384                                    }
1385                                    var sizeAwesome = ((osg.params.imgBlockW*mainBlockW)/100)/11+"px";
1386                                    jQuerOs(container +" .andrea-effect .andrea-zoom-in").css({'width': sizeAwesome, 'height': sizeAwesome });
1387                                    var fontSizetext = ((osg.params.imgBlockW*mainBlockW)/100)/15+"px";
1388                                    jQuerOs(container +" .img-block").css({'font-size': fontSizetext, 'line-height': fontSizetext });
1389                                }
1390                                jQuerOs("#button-"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+'px');
1391                                jQuerOs(container+" .album-block .img-block").css("width",osg.params.imgBlockW+"%");
1392                                osg.setImgBlockHeight()
1393                                jQuerOs(container+" .os-cat-tab-images").show();
1394                                
1395                                //dobavlyaem resize, potomu 4to u klienta kolonok na 1-nu menshe 4em v nastroikah,
1396                                //pohoze, 4to shirina menyaetsa za s4et poyavleniya polosi prokrutki
1397                                //VlaDOS 04.02.2022
1398                                osg.resizeGallery();
1399
1400                            }
1401
1402    //                " div#cat-"+osg.params.curCatId + '-' + osg.params.galIdRandom
1403                            jQuerOs(container+" .album-main-image").click(function(event) {
1404                                albumId = jQuerOs(this).data("cat-id");
1405                                osg.imgLoad(" div#cat-"+albumId + '-' + osg.params.galIdRandom)
1406                                    .then(function(returns) {
1407                                        var href = window.location.href;
1408                                        if (!from_history && href.indexOf('os_image_id') == -1){
1409                                            if (href.indexOf('?cat-') > -1) {
1410
1411                                                history.pushState (null, null, href.substring(0, href.indexOf('?cat-') ) + '?cat-' + albumId);
1412                                            }else if (href.indexOf('&cat-') > -1) {
1413
1414                                                history.pushState (null, null, href.substring(0, href.
1414indexOf('&cat-') ) + '&cat-' + albumId);
1415                                            }else if (href.indexOf('?') > -1){
1416
1417                                                history.pushState(null, null, href + '&cat-' + albumId);
1418                                            }else {
1419
1420                                                history.pushState(null, null, href + '?cat-' + albumId);
1421                                            }
1422                                        }
1423
1424                                        jQuerOs("#back-"+osg.params.galIdRandom).css("margin", osg.params.spaceBetween +"px");
1425                                        osg.params.curCatId = jQuerOs("#cat-"+albumId+"-"+osg.params.galIdRandom).attr('data-cat-id');
1426                                        jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-cat-id', osg.params.curCatId);
1427
1428                                        var curEnd = jQuerOs("#cat-"+albumId+"-"+osg.params.galIdRandom).attr('data-end');
1429
1430
1431                                        jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end', curEnd);
1432
1433                                        jQuerOs(container+" .back-to-albums").data("cat-id", albumId);
1434                                        //show album
1435                                        jQuerOs(container+" .os-gallery-album-"+albumId).parent().fadeTo( "slow", 1 );
1436                                        jQuerOs(container+" .os-gallery-album-"+albumId+","+container+" .back-to-albums").fadeTo( "slow", 1 );
1437
1438                                        if(osg.params.showLoadMore == 'button'){
1439                                            jQuerOs("#load-more-"+osg.params.galIdRandom).fadeTo( "slow", 1 );
1440
1441                                        }
1442
1443                                        //hide albums main image
1444                                        jQuerOs(container+" .album-main-image").parent().hide();
1445
1446                                        jQuerOs("#cat-"+albumId+"-"+osg.params.galIdRandom+" .grid").show();
1447                                        jQuerOs("#cat-"+albumId+"-"+osg.params.galIdRandom+" .img-block:not(:first)").show();
1448                                        window.stopAlbum = true;
1449                                        osg.loadMore(osg.params.showLoadMore,true);
1450                                        if(osg.params.imgCountCat != ''){
1451                                            var img_count_cat = JSON.parse(osg.params.imgCountCat);
1452                                        }else{
1453                                            var img_count_cat = '';
1454                                        }
1455                                        
1456                                        if(img_count_cat != '' && (jQuerOs('#cat-' + osg.params.curCatId +'-'+osg.params.galIdRandom + ' .grid .album-images-block').children().length) >= Number(img_count_cat[osg.params.curCatId])){
1457                                            
1458                                            jQuerOs("#load-more-"+osg.params.galIdRandom+"[data-cat-id="+osg.params.curCatId+"]").hide();
1459
1460                                        }else{
1461                                            if(osg.params.showLoadMore == 'button'){
1462                                                jQuerOs("#load-more-"+osg.params.galIdRandom+"[data-cat-id="+osg.params.curCatId+"]").show();
1463                                            }
1464                                        }
1465                                        if(curEnd != -1){
1466                                            jQuerOs("#load-more-"+osg.params.galIdRandom).removeAttr("disabled");
1467                                            jQuerOs("#load-more-"+osg.params.galIdRandom).css("background", osg.params.load_more_background);
1468                                        }
1469                                        var href = window.location.href;
1470                                        var img_el_id = '';
1471                                        var pos1 = href.indexOf('os_image_id'); 
1472                                        var pos2 = href.lastIndexOf('#'); 
1473                                        var catId = '';
1474                                        var cat_pos1 = href.indexOf('os_fancybox');
1475                                        var cat_pos = href.substring(cat_pos1, href.lastIndexOf('-'));
1476                                        var cat_pos = cat_pos.substring(cat_pos.lastIndexOf('-'));
1477                                        var os_show_load_more = osg.params.showLoadMore;
1478                                        if (pos1 > -1 && pos2 > - 1) {
1479                                            img_el_id = href.substring(pos1, pos2); 
1480                                        }else if(pos1 > -1 && pos2 == -1){
1481                                            img_el_id = href.substring(pos1);
1482                                        }
1483
1484                                        os_fancy_box_getInst = jQuerOs.os_fancybox.getInstance(); 
1485
1486                                        if(!os_fancy_box_getInst){
1487                                            if(img_el_id && img_el_id.indexOf('os_image_id') > -1)  {
1488
1489                                                if(document.getElementById(img_el_id) == null){
1490                                                    if (os_show_load_more == 'auto'){
1491                                                        osg.loadMore("auto");
1492
1493                                                    }
1494                                                    else if (os_show_load_more !== null){
1495                                                        osg.loadMore("button");
1496
1497                                                        jQuerOs('#load-more-'+osg.params.galIdRandom).trigger('click');
1498
1499                                                    }
1500
1501                                                }
1502
1503                                                else {
1504                                                    jQuerOs('#' + img_el_id).trigger('click');
1505                                                }
1506                                            }
1507                                        }
1508                                        if(osg.params.albumSublayout == 'masonry'){
1509                                            osg.setImgBlockHeightMassonry()
1510                                                .then(function(returns) {
1511                                                    osg.isotope();
1512                                                })
1513//                                            osg.reloadIsotope();
1514                                        }else if(osg.params.albumSublayout == 'fit_rows'){
1515                                            osg.resizeGallery();
1516                                            osg.fitRowsIsotope(osg.params.curCatId);
1517                                        }
1518
1519                                    })
1520
1521                            });
1522
1523                            jQuerOs(container+" .back-to-albums").unbind('click');
1524                            jQuerOs(container+" .back-to-albums").click(function(event) {
1525                                //hide images
1526                                albumId = jQuerOs(this).data("cat-id");
1527                                var href = window.location.href;
1528
1529                                if (href.indexOf('&cat-') > -1){
1530
1531                                    history.pushState (href, null, href.substring(0, href.indexOf('&cat-')));
1532                                }else if (href.indexOf('?cat-') > -1){
1533
1534                                    history.pushState (href, null, href.substring(0, href.indexOf('?cat-')));
1535                                }
1536
1537                                jQuerOs(container+" .os-gallery-album-"+albumId).parent().hide();
1538                                jQuerOs(container+" .os-gallery-album-"+albumId+","+container+" .back-to-albums").hide();
1539                                jQuerOs("#cat-"+albumId+"-"+osg.params.galIdRandom+" .img-block").hide();
1540                                jQuerOs("#cat-"+albumId+"-"+osg.params.galIdRandom+" .grid").hide();
1541                                jQuerOs("#load-more-"+osg.params.galIdRandom).hide();
1542
1543                                //show albums
1544                                window.stopAlbum = false;
1545                                //jQuerOs(container+" .album-main-image").parent().fadeIn( 2000 );
1546                                jQuerOs(container+" .album-main-image").parent().show();
1547                                jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).hide();
1548                                osg.resizeGallery();
1549
1550                            });
1551                            if(gallery_cat_id && gallery_cat_id.indexOf('cat-') > -1 && gallery_cat_id.indexOf('=') == -1){
1552                                jQuerOs('#' + gallery_cat_id +'-'+ osg.params.galIdRandom +' .album-main-image').trigger('click');
1553                            }
1554                            
1555                      })
1556
1557                }else{
1558    //                osg.imgLoad();
1559                    console.log(33333333333333)
1560                    jQuerOs(container+" .os-cat-tab-images div:first-child").show();
1561                    jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom+" li:first-child a").addClass("active");
1562                    if(osg.params.layout == 'allInOne'){
1563                        osg.params.curCatId = jQuerOs(container+" .cat-"+osg.params.galIdRandom).attr('data-cat-id');
1564                    }else{
1565                        osg.params.curCatId = jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom+" a.active").attr('data-cat-id');    
1566                    }
1567                    
1568                    if(osg.params.layout == 'allInOne'){
1569                        var selector = "";
1570                    }else{
1571                        var selector = " div#cat-"+osg.params.curCatId + '-' + osg.params.galIdRandom;
1572                    }
1573
1574                    if(osg.params.curCatId == ''){
1575                        osg.params.curCatId = 1
1576                    }
1577                    var curEnd = jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom+" a.active").attr('data-end');
1578                    if(curEnd === undefined){
1579                        curEnd = osg.params.limEnd;
1580                    }
1581
1582                    jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-cat-id', osg.params.curCatId);
1583                    jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end', curEnd);
1584                    
1585                    if(osg.params.layout == 'default' || osg.params.layout == 'search'){
1586                        jQuerOs(container+" .img-block").css("width",osg.params.imgBlockW+"%");
1587                        // osg.setImgBlockHeight()
1588
1589                    }else if(osg.params.layout == 'allInOne'){
1590
1591                        jQuerOs(container+" .all-in-one-block .img-block:first-child").css("width",osg.params.imgBlockW+"%");
1592                        // osg.setImgBlockHeight()
1593                        jQuerOs(container+" .os-cat-tab-images").show();
1594                    }else if(osg.params.layout == 'masonry'){
1595                        console.log('11111111111111')
1596                        jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1597                        jQuerOs("#button-"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1598                        jQuerOs(container+" .grid-"+osg.params.galIdRandom).css("width",osg.params.imgBlockW+"%");
1599                        // osg.setImgBlockHeight()
1600        //            }else if(osg.params.layout == 'fitRows'|| osg.params.layout == 'allInOneRow' ){
1601                    }else if(osg.params.layout == 'fitRows'){
1602
1603                        jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1604                        jQuerOs("#button-"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1605
1606                    }
1607                    osg.imgLoad(selector)
1608                      .then(function(returns) { // `delay` returns a promise
1609
1610    //                  })
1611
1612    //                if(osg.imgLoad(" div#cat-"+osg.params.curCatId + '-' + osg.params.galIdRandom)){
1613
1614                        if(returns == true){ 
1615                            osg.params.imgBlockW = osg.getImgBlockWidth();
1616                            if(osg.params.layout == 'default' || osg.params.layout == 'search'){
1617                                jQuerOs(container+" .img-block").css("width",osg.params.imgBlockW+"%");
1618                                osg.setImgBlockHeight()
1619
1620                            }else if(osg.params.layout == 'allInOne'){
1621
1622                                jQuerOs(container+" .all-in-one-block .img-block:first-child").css("width",osg.params.imgBlockW+"%");
1623                                osg.setImgBlockHeight()
1624                                jQuerOs(container+" .os-cat-tab-images").show();
1625                            }else if(osg.params.layout == 'masonry'){
1626
1627                                jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1628                                jQuerOs("#button-"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1629                                jQuerOs(container+" #grid-"+osg.params.galIdRandom).css("width",osg.params.imgBlockW+"%");
1630                                osg.setImgBlockHeight()
1631                //            }else if(osg.params.layout == 'fitRows'|| osg.params.layout == 'allInOneRow' ){
1632                            }else if(osg.params.layout == 'fitRows'){
1633                                
1634                                jQuerOs(container+" .osgalery-cat-tabs#"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1635                                jQuerOs("#button-"+osg.params.galIdRandom).css("padding", osg.params.spaceBetween+"px");
1636                                
1637                            }else if(osg.params.layout == 'allInOneRow'){
1638                //                jQuerOs(container+" .img-block").css("width","100%");
1639                            }
1640
1641
1642
1643
1644
1645
1646                            if(img_count_cat != '' && jQuerOs('#cat-' + osg.params.curCatId +'-'+osg.params.galIdRandom).children().length >= img_count_cat[osg.params.curCatId]){
1647                                jQuerOs("#load-more-"+osg.params.galIdRandom+"[data-cat-id="+osg.params.curCatId+"]").hide();
1648                            }else if(img_count_cat != '' && !Array.isArray(img_count_cat) && jQuerOs('#cat-1-'+osg.params.galIdRandom).children().length >= img_count_cat){
1649                                jQuerOs("#load-more-"+osg.params.galIdRandom).hide();
1650                            }
1651
1652                            if(osg.params.layout == 'masonry'){
1653                                //fix animate CSS and images appear error for old browsers
1654                                osg.setImgBlockHeightMassonry()
1655                                .then(function(returns) {
1656                                    osg.isotope();
1657                                    
1658                                })
1659                                
1660                                jQuerOs('.tab-click-loadMore').click(function() {
1661
1662                                   setTimeout(function(){ 
1663                                       osg.reloadIsotope();
1664                                    }, 2000);
1665                                });  
1666                            }
1667                            
1668                            if(osg.params.layout == 'allInOne'){
1669                                var href = window.location.href;
1670                                var img_el_id = '';
1671                                var pos1 = href.indexOf('os_image_id'); 
1672                                var pos2 = href.lastIndexOf('#'); 
1673                                var os_show_load_more = osg.params.showLoadMore;
1674                                if (pos1 > -1 && pos2 > - 1) {
1675                                    img_el_id = href.substring(pos1, pos2); 
1676                                }else if(pos1 > -1 && pos2 == -1){
1677                                    img_el_id = href.substring(pos1);
1678                                }
1679                                os_fancy_box_getInst = jQuerOs.os_fancybox.getInstance(); 
1680
1681                                if(!os_fancy_box_getInst){
1682
1683                                    if(img_el_id && img_el_id.indexOf('os_image_id') > -1)  {
1684
1685                                        if(document.getElementById(img_el_id) == null){
1686                                            if (os_show_load_more == 'auto'){
1687                                                osg.loadMore("auto");
1688
1689                                            }
1690                                            else if (os_show_load_more !== null){
1691
1692                                                osg.loadMore("button");
1693
1694                                                jQuerOs('#load-more-'+osg.params.galIdRandom).trigger('click');
1695
1696                                            }
1697
1698                                        }
1699
1700                                        else {
1701                                            jQuerOs('#' + img_el_id).trigger('click');
1702                                        }
1703                                    }
1704                                }
1705                            }
1706                            
1707                            
1708                            
1709                        }
1710                    }).finally(() => {
1711                        // if(osg.params.layout != 'allInOneRow'){
1712                        //     osg.setImgBlockHeight();
1713                        // }
1714                        if(osg.params.layout == 'masonry' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'masonry')){
1715                            
1716                            osg.setImgBlockHeightMassonry()
1717                                .then(function(returns) {
1718                                    
1719                                    osg.isotope();
1720                                    osg.resizeGallery();
1721                                    
1722                                })
1723//                               osg.reloadIsotope(); 
1724                //            }else if(osg.params.layout == 'fitRows' || osg.params.layout == 'allInOneRow'){
1725                //            }else if(osg.params.layout == 'fitRows' || osg.params.layout == 'allInOneRow'){
1726                            }else if(osg.params.layout == 'fitRows'){   
1727                                
1728//                                osg.resizeGallery();
1729                                osg.fitRowsIsotope(osg.params.curCatId);
1730                                
1731                            }else if(osg.params.layout == 'allInOneRow'){
1732
1733                                var href = window.location.href;
1734                                var position_gallery = href.indexOf('cat');
1735                                var gallery_cat_id = '';
1736                                var gallery_cat_id = href.substring(position_gallery);
1737                                if(gallery_cat_id.indexOf('&') > -1){
1738                                    gallery_cat_id = gallery_cat_id.substr(0, gallery_cat_id.indexOf('&'));
1739                                }
1740                                var cat_id = gallery_cat_id.replace(/cat-/i, '');
1741            
1742                                
1743                                if(gallery_cat_id && gallery_cat_id.indexOf('cat-') > -1 && gallery_cat_id.indexOf('=') == -1 && img_count_cat[cat_id] !== undefined){
1744//                                if(gallery_cat_id && gallery_cat_id.indexOf('cat-') > -1 && gallery_cat_id.indexOf('=') == -1){
1745    //                                jQuerOs(container + ' #' + gallery_cat_id + osg.params.galIdRandom).trigger('click');
1746                                }else{
1747                                    osg.initAccordeon(osg.params.curCatId)
1748                                }
1749
1750                            }
1751                            if (osg.params.showLoadMore != 0){
1752                            
1753                                osg.loadMore(osg.params.showLoadMore);
1754                            }
1755                            //VlaDOS 2021/09/14 Added for fixes in version 6.0. A possible problem is the preloader.
1756                            if(osg.params.layout == 'default'){
1757                                osg.resizeGallery();
1758                            }
1759                            
1760                            //VlaDOS end
1761                    })
1762                }
1763            }
1764            
1765            
1766            jQuerOs(window).resize(function(event) {
1767                if(osg.params.layout == 'masonry' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'masonry')){
1768                    osg.resizeGallery();
1769                    if(jQuerOs(window).width() != width){
1770                        width = jQuerOs(window).width();
1771                        osg.reloadIsotope();
1772                    }
1773//                }else if(osg.params.layout == 'fitRows' || osg.params.layout == 'allInOneRow' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fitRows')){
1774                }else if(osg.params.layout == 'fitRows' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
1775//                    osg.resizeGallery();
1776                    osg.fitRowsIsotope(osg.params.curCatId);
1777                }else{
1778                    
1779                    osg.resizeGallery();
1780                }
1781//                if(osg.params.layout != 'fitRows' && osg.params.layout != 'masonry'){
1782//                    osg.resizeGallery();
1783//                }else if(osg.params.layout == 'masonry'){
1784//                    osg.resizeGallery();
1785//                    osg.reloadIsotope();
1786//                }else{
1787//                    osg.fitRowsIsotope(osg.params.curCatId);
1788//                }
1789            });
1790            
1791            
1792            
1793        }
1794        osg.init();
1795        //VlaDOS 25.09.2020
1796        //This line was added in 2018 or 2019 to fix the Masonry Layout error on iPhone 4. 
1797        //Commented on 09/25/2020 to fix the error of framing the first image in the Fitrow Layout
1798//        setTimeout(osg.resizeGallery, 200);
1799        //VlaDOS end
1800
1801        //function for load more Thumbnail
1802        osg.LoadMoreThumbs = function(data){
1803            
1804        var showImgTitle = osg.params.showImgTitle;
1805        var showImgDescription = osg.params.showImgDescription;
1806        
1807        for(index = 0; index < data.os_loadMore_result.length; ++index){
1808
1809            var imgParams = JSON.parse(decodeURIComponent(data.os_loadMore_result[index].params));
1810
1811            var os_caption = "";
1812            if (data.os_loadMore_result[index].params){
1813                if(showImgTitle == 1 && imgParams['imgTitle'] != undefined){
1814                    var os_imgTitle = imgParams['imgTitle'] + '<br>';
1815                }else{
1816                    var os_imgTitle = '';
1817                }
1818                if(showImgDescription == 1 && imgParams['imgShortDescription'] != undefined){
1819                    var os_imgShortDescription = imgParams['imgShortDescription'];
1820                }else{
1821                    var os_imgShortDescription = '';
1822                }
1823                var os_imgHtml = imgParams['imgHtml'];
1824
1825                os_caption = os_imgTitle + os_imgShortDescription;
1826
1827            }
1828            //get youtube link
1829            var videoLink = imgParams['videoLink'];
1830            if(videoLink != undefined && videoLink.indexOf('youtu') > -1){
1831                var os_youtube_link = videoLink.substr(videoLink.indexOf('=')+1)
1832            }
1833            //get vimeo link
1834            if (videoLink != undefined && videoLink.indexOf('vimeo') > -1){
1835                var os_vimeo_link = videoLink.substr(videoLink.lastIndexOf('/')+1);
1836            }
1837
1838            //create a new object <li>
1839
1840            var img_index = jQuerOs(".os_fancybox-thumbs div a:last").attr("data-index");
1841
1842            li_cloned = jQuerOs(".os_fancybox-thumbs div a:first").clone();
1843            
1844
1845            if(document.getElementsByClassName('os_fancybox-thumbs-x').length > 0){
1846
1847                ul_stile = jQuerOs(".os_fancybox-thumbs div");
1848                ul_stile = ul_stile.attr('style');
1849                ul_new_style = Number(ul_stile.substring(7, ul_stile.lastIndexOf('px'))) + 108;
1850                jQuerOs(".os_fancybox-thumbs div").attr('style', 'width: ' + ul_new_style + 'px;');
1851            }
1852
1853//                        var img_index = li_cloned.attr("data-index");
1854            
1855            li_cloned.attr("data-index", ++img_index);
1856            li_cloned.attr("class", "");
1857            var thmb_arr = data.os_loadMore_result[index].file_name.split('.');
1858            var thmb_ext = thmb_arr[thmb_arr.length -1];
1859            thmb_arr.pop();
1860            var thmb_name = thmb_arr.join('.');
1861            var thmb = jQuerOs(container + ' a[href*='+thmb_name+'] img').attr('src');
1862
1863//            if(jQuerOs(container + ' img[src*='+thmb_name+'_'+osg.params.thumbWidth+'_'+osg.params.thumbHeight+']').length > 0){
1864//                thmb_name = thmb_name+'_'+osg.params.thumbWidth+'_'+osg.params.thumbHeight+'.'+thmb_ext;
1865//            }else{
1866//                thmb_name = thmb_name+'.'+thmb_ext;
1867//            }
1868            
1869//            li_cloned.attr("style", "background-image:url("+osg.params.juri + "/images/com_osgallery/gal-" + osg.params.galId + "/thumbnail/"+thmb_name+")")
1870            li_cloned.attr("style", "background-image:url("+thmb+")")
1871//            li_cloned.find('img').attr("src", osg.params.juri + "/images/com_osgallery/gal-" + osg.params.galId + "/thumbnail/"+data.os_loadMore_result[index].file_name);
1872//            li_cloned.find('img').attr("data-src", osg.params.juri + "/images/com_osgallery/gal-" + osg.params.galId + "/thumbnail/"+data.os_loadMore_result[index].file_name);
1873
1874            li_cloned.appendTo(".os_fancybox-thumbs div.os_fancybox-thumbs__list");
1875            os_fancy_box_getInst = jQuerOs.os_fancybox.getInstance();
1876            os_fb_group_count = os_fancy_box_getInst.group.length;
1877
1878            //create a new object slide
1879
1880            os_fancy_box_group_item_tmp = Object.assign({}, os_fancy_box_getInst.group[os_fb_group_count-1]);
1881
1882            os_fancy_box_group_item_tmp.index = os_fb_group_count;
1883            os_fancy_box_group_item_tmp.os_image_id = 'os_image_id-'+data.os_loadMore_result[index].id;
1884            if (videoLink != undefined && videoLink.indexOf('youtu') > -1){
1885                os_fancy_box_group_item_tmp.src = '//www.youtube.com/embed/'+ os_youtube_link + '?autoplay=1&autohide=1&fs=1&rel=0&hd=1&wmode=transparent&enablejsapi=1&html5=1';
1886                os_fancy_box_group_item_tmp.type = 'iframe';
1887            }
1888            else if (videoLink != undefined && videoLink.indexOf('vimeo') > -1){
1889                os_fancy_box_group_item_tmp.src = '//player.vimeo.com/video/'+ os_vimeo_link + '?autoplay=1&hd=1&show_title=1&show_byline=1&show_portrait=0&fullscreen=1&api=1';
1890                os_fancy_box_group_item_tmp.type = 'iframe';
1891            }
1892            else if (os_imgHtml != undefined && os_imgHtml['html'].length > 0){
1893                os_fancy_box_group_item_tmp.src = '#data-html-'+data.os_loadMore_result[index].id;
1894                os_fancy_box_group_item_tmp.type = 'inline';
1895            }    
1896
1897            else {
1898                var images = jQuerOs('.img-block a');
1899                var ind = 0
1900                while(images.length > ind){
1901                    var src = jQuerOs(images[ind]).attr('href');
1902                    
1903                    if(src != undefined && src.indexOf(data.os_loadMore_result[index].file_name) > -1){
1904                        os_fancy_box_group_item_tmp.src = src;
1905                    }
1906                    ind++;
1907                }
1908                
1909                //os_fancy_box_group_item_tmp.src = osg.params.juri + '/images/com_osgallery/gal-' + osg.params.galId + '/original/'+data.os_loadMore_result[index].file_name;
1910                os_fancy_box_group_item_tmp.type = 'image';
1911            }
1912
1913            if (os_caption){
1914
1915                os_fancy_box_group_item_tmp.caption = os_caption;
1916            }
1917            else {
1918                os_fancy_box_group_item_tmp.caption = '';
1919            }
1920            os_fancy_box_getInst.group.push( os_fancy_box_group_item_tmp );
1921                
1922
1923        }
1924
1925
1926        jQuerOs(".os_fancybox-button--arrow_right").removeAttr('disabled');
1927        jQuerOs(".os_fancybox-button--arrow_left").removeAttr('disabled');
1928        jQuerOs(".os_fancybox-loading").remove();
1929
1930    }
1931
1932        osg.loadMore = function(loadMoreType){
1933
1934
1935
1936            limEnd = osg.params.limEnd;
1937
1938
1939            if(loadMoreType == '0'){
1940                return;
1941            }
1942
1943            if(loadMoreType == 'button'){
1944                osg.loadMoreButton();
1945            }
1946
1947            if(loadMoreType == 'scroll'){
1948                osg.loadMoreScroll(false);
1949                jQuerOs(window).scroll(osg.loadMoreScroll)
1950            }
1951
1952            if(loadMoreType == 'auto'){
1953                osg.loadMoreAuto();
1954            }
1955        }
1956
1957
1958        // add load more script
1959        osg.loadMoreButton = function(){
1960            
1961            if(osg.params.layout == 'search'){
1962                var task = 'loadMoreButtonSearch';
1963            }else{
1964                var task = 'loadMoreButton';
1965            }
1966            jQuerOs("#load-more-"+osg.params.galIdRandom).unbind('click');
1967            
1968            if(!inProgressAjax ){
1969                
1970            jQuerOs("#load-more-"+osg.params.galIdRandom).on("click", function() {
1971                inProgressAjax  = true;
1972                //hide load more/show progress image
1973                jQuerOs("#load-more-"+osg.params.galIdRandom).css('display', 'none');
1974                jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).css('display', 'block');
1975
1976
1977                jQuerOs("#load-more-"+osg.params.galIdRandom).attr('disabled','disabled');
1978                var href = window.location.href;
1979                //load more the image in a direct link
1980                var os_one_img = "";
1981                
1982                //jQuerOs.os_fancybox.getInstance() Determines whether the modal window is running
1983
1984                if (jQuerOs.os_fancybox.getInstance() == false && href.indexOf('os_image_id') > -1){
1985                    //get the id of the required picture
1986                    var leight1 = href.indexOf('os_image_id');
1987                    var leight2 = href.lastIndexOf('#');
1988                    if (leight1 > -1 && leight2 > - 1) {
1989                        var os_one_img = href.substring(leight1, leight2); 
1990                    }else if(leight1 > -1 && leight2 == -1){
1991                        var os_one_img = href.substring(leight1);
1992                    }
1993                    var os_one_img = os_one_img.substring(12);
1994
1995                }
1996                
1997                jQuerOs.ajax({
1998                    dataType: "json",
1999                    type: 'POST',
2000                    url: osg.params.juri+'/index.php?option=com_osgallery&format=raw',
2001                    data: {
2002                        task: task,
2003                        Itemid: osg.params.itemId,
2004                        end: jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end'),
2005                        catId: jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-cat-id'),
2006                        galId: osg.params.galId,
2007                        oneimg: os_one_img,
2008                        moduleId: osg.params.modId,
2009                        searchText: osg.params.searchText,
2010                    },
2011                    beforeSend: function() {
2012                        inProgressAjax  = true;
2013                    },
2014                    success: function(data){
2015
2016                            if(data.success){
2017                                //append hidden data
2018//                                if(osg.params.layout == 'album' || osg.params.layout == 'allInOneRow'){
2019                                if(osg.params.layout == 'album'){
2020                                    jQuerOs("#cat-"+data.catId+"-"+osg.params.galIdRandom+" .grid .album-images-block").append(data.html);
2021                                }else{
2022                                    jQuerOs("#cat-"+data.catId+"-"+osg.params.galIdRandom).append(data.html);
2023                                }
2024                                osg.imgLoad(" div#cat-"+osg.params.curCatId + '-' + osg.params.galIdRandom)
2025                                    .then(function(returns) {
2026                                        if(osg.params.layout != 'allInOne'){
2027                                            jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+", #load-more-"+osg.params.galIdRandom).attr('data-end', data.limEnd);
2028                                        }else{
2029                                            jQuerOs("#cat-"+ data.catId+osg.params.galIdRandom+", #load-more-"+osg.params.galIdRandom).attr('data-end', data.limEnd);
2030                                        }
2031                                        if(osg.params.layout != 'allInOneRow' && osg.params.layout != 'fitRows'){
2032                                            osg.setImgBlockHeight(true)
2033                                        }
2034
2035                                        jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+" .load-more-hidden").removeClass("load-more-hidden");
2036
2037
2038                                        limEnd = data.limEnd;
2039
2040//                                        if(osg.params.layout == 'masonry' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'masonry')){
2041//                                            osg.reloadAfterLazyLoad();
2042//                                            osg.reloadIsotope();
2043////                                            }else if(osg.params.layout == 'fitRows' || osg.params.layout == 'allInOneRow' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
2044//                                        }else if(osg.params.layout == 'fitRows' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
2045//                                            osg.fitRowsIsotope(data.catId);
2046//                                        }else{
2047//                                            osg.resizeGallery();
2048//                                        }
2049//
2050//                                        osg.reinit(data.catId, limEnd);
2051
2052                                        if (jQuerOs.os_fancybox.getInstance() !== false){
2053                                            osg.LoadMoreThumbs(data);
2054                                        }
2055
2056                                        if(data.limEnd == -1){
2057//                                                jQuerOs("#load-more-"+osg.params.galIdRandom).attr("disabled","disabled");
2058//                                                jQuerOs("#load-more-"+osg.params.galIdRandom).css("background", "#808080");
2059                                              jQuerOs("#load-more-"+osg.params.galIdRandom).hide();
2060//                                                  jQuerOs("#load-more-"+osg.params.galIdRandom).attr('style', 'display: none;');
2061
2062                                        }else{
2063                                            jQuerOs("#load-more-"+osg.params.galIdRandom).removeAttr('disabled');
2064                                        }
2065
2066                                        //go to the picture by a direct link
2067                                        
2068
2069                                        //show load more/hide progress image
2070                                        if(osg.params.layout != 'allInOne' && data.limEnd > -1){
2071                                            jQuerOs("#load-more-"+osg.params.galIdRandom).css('display', 'block');
2072                                        }
2073
2074                                        jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).css('display', 'none');
2075                                        inProgressAjax  = false;
2076                                    }).finally(() => {
2077                                        // if(osg.params.layout != 'allInOneRow'){
2078                                        //     osg.setImgBlockHeight();
2079                                        // }
2080                                        if(osg.params.layout == 'masonry' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'masonry')){
2081                                            osg.reloadAfterLazyLoad();
2082                                            osg.reloadIsotope();
2083//                                            }else if(osg.params.layout == 'fitRows' || osg.params.layout == 'allInOneRow' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
2084                                        }else if(osg.params.layout == 'fitRows' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
2085                                            osg.fitRowsIsotope(data.catId);
2086                                        }else if(osg.params.layout == 'allInOneRow'){
2087                                            osg.initAccordeon(jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-cat-id'))
2088                                        }else{
2089                                            osg.resizeGallery();
2090                                        }
2091                                        osg.reinit(data.catId, limEnd);
2092                                        if (data.os_oneImgId){
2093                                            
2094                                            var img_el_id = '';
2095                                            var pos1 = href.indexOf('os_image_id'); 
2096                                            var pos2 = href.lastIndexOf('#'); 
2097
2098                                            if (pos1 > -1 && pos2 > - 1) {
2099                                                img_el_id = href.substring(pos1, pos2); 
2100                                            }else if(pos1 > -1 && pos2 == -1){
2101                                                img_el_id = href.substring(pos1);
2102                                            }
2103                                            
2104                                            if(document.getElementById(img_el_id) !== null){
2105                                                jQuerOs('#' + img_el_id).trigger('click');
2106                                            }
2107                                        }
2108                                    })
2109
2110
2111
2112
2113                            }
2114                        //}
2115                    },
2116                    error:function(){
2117                        inProgressAjax = false;
2118                    }
2119                })
2120            });
2121            }
2122        }
2123
2124        //load more by scroll
2125        osg.loadMoreScroll = function(){
2126            
2127            if(osg.params.layout == 'search'){
2128                var task = 'loadMoreScrollSearch';
2129            }else{
2130                var task = 'loadMoreScroll';
2131            }
2132            jQuerOs("#load-more-"+osg.params.galIdRandom).hide();
2133            var href = window.location.href;
2134
2135            if(osg.params.layout == 'album'){
2136                if(href.indexOf('cat-') > -1){
2137                    var scrollPoint = jQuerOs('.scrollPoint_'+osg.params.galIdRandom).offset();
2138                }else{
2139                    var scrollPoint = '';
2140                }
2141            }else{
2142                var scrollPoint = jQuerOs('.scrollPoint_'+osg.params.galIdRandom).offset();
2143            }
2144            
2145            
2146            if(limEnd != -1 && !inProgressAjax && (jQuerOs(window).scrollTop() + jQuerOs(window).height()) > (scrollPoint.top)){
2147                inProgressAjax = true;
2148                jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).css('display', 'block');
2149                
2150                jQuerOs.ajax({
2151                    dataType: "json",
2152                    type: 'POST',
2153                    url: osg.params.juri+'/index.php?option=com_osgallery&format=raw',
2154                    data: {
2155                        task: task,
2156                        Itemid: osg.params.itemId,
2157                        end: jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end'),
2158                        catId: jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-cat-id'),
2159                        galId: osg.params.galId,
2160                        moduleId: osg.params.modId,
2161                        searchText: osg.params.searchText,
2162                    },
2163                    beforeSend: function() {
2164                        inProgressAjax = true;
2165                    },
2166                    success: function(data){
2167
2168                        if(data.success){
2169                                //append hidden data
2170                                if(osg.params.layout == 'album'){
2171                                    jQuerOs("#cat-"+data.catId+"-"+osg.params.galIdRandom + " .grid .album-images-block").append(data.html);
2172                                }else{
2173                                    jQuerOs("#cat-"+data.catId+"-"+osg.params.galIdRandom).append(data.html);
2174                                }
2175                                if(jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+" .load-more-hidden img").length <= 0){
2176                                    jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).css('display', 'none');
2177                                    inProgressAjax = false;
2178                                }
2179//                                var lm = 0;
2180                                osg.imgLoad(" div#cat-"+osg.params.curCatId + '-' + osg.params.galIdRandom)
2181                                    .then(function(returns) {
2182                                        
2183
2184                                        if(osg.params.layout == 'masonry'){
2185                                            jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+" .load-more-hidden").css('position', 'absolute');
2186                                            jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+" .load-more-hidden").css('bottom', '0px');
2187                                        }
2188                                        if(osg.params.layout != 'allInOneRow' && osg.params.layout != 'fitRows'){
2189                                            osg.setImgBlockHeight(true)
2190                                        }
2191
2192                                        jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+" .load-more-hidden").removeClass("load-more-hidden");
2193                                        if(osg.params.layout != 'allInOne'){
2194                                            jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+", #load-more-"+osg.params.galIdRandom).attr('data-end', data.limEnd);
2195                                        }else{
2196                                            jQuerOs("#cat-"+ data.catId+osg.params.galIdRandom+", #load-more-"+osg.params.galIdRandom).attr('data-end', data.limEnd);
2197                                        }
2198
2199                                        //jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+", #load-more-"+osg.params.galIdRandom).attr('data-end', data.limEnd);
2200                                        if(data.limEnd == -1)
2201                                            jQuerOs("#load-more-"+osg.params.galIdRandom).attr("disabled","disabled");
2202                                        limEnd = data.limEnd;
2203
2204                                        jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).css('display', 'none');
2205                                        inProgressAjax = false;
2206
2207                                        osg.loadMoreScroll();
2208//                                    }
2209                                }).finally(() => {
2210                                    // if(osg.params.layout != 'allInOneRow'){
2211                                    //     osg.setImgBlockHeight();
2212                                    // }
2213                                    if(osg.params.layout == 'masonry' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'masonry')){
2214                                        osg.reloadAfterLazyLoad();
2215                                        osg.reloadIsotope();
2216//                                            }else if(osg.params.layout == 'fitRows' || osg.params.layout == 'allInOneRow' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
2217                                    }else if(osg.params.layout == 'fitRows' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
2218                                        osg.fitRowsIsotope(data.catId);
2219                                    }else{
2220                                        osg.resizeGallery();
2221                                    }
2222                                    osg.reinit(data.catId, limEnd);
2223                                })
2224                        }
2225                    },
2226                    error:function(){
2227                        inProgressAjax = false;
2228                        jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).css('display', 'none');
2229                        limEnd = -1;
2230                    }
2231                })
2232            }
2233                
2234        };
2235
2236        //load more by auto
2237        osg.loadMoreAuto = function(){
2238            
2239            if(osg.params.layout == 'search'){
2240                var task = 'loadMoreAutoSearch';
2241            }else{
2242                var task = 'loadMoreAuto';
2243            }
2244            
2245            jQuerOs("#load-more-"+osg.params.galIdRandom).hide();
2246            
2247            if(jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end') != -1 && !inProgressAjax){
2248                inProgressAjax = true;
2249                
2250                jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).css('display', 'block');
2251                jQuerOs.ajax({
2252                    dataType: "json",
2253                    type: 'POST',
2254                    url: osg.params.juri+'/index.php?option=com_osgallery&format=raw',
2255                    data: {
2256                        task: task,
2257                        Itemid: osg.params.itemId,
2258                        end: jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-end'),
2259                        catId: jQuerOs("#load-more-"+osg.params.galIdRandom).attr('data-cat-id'),
2260                        galId: osg.params.galId,
2261                        moduleId: osg.params.modId,
2262                        searchText: osg.params.searchText,
2263                    },
2264                    beforeSend: function() {
2265                        inProgressAjax = true;
2266                    },
2267                    success: function(data){ 
2268                        if(data.success){ 
2269                                //append hidden data
2270
2271                                if(osg.params.layout == 'album'){
2272                                    jQuerOs("#cat-"+data.catId+"-"+osg.params.galIdRandom + " .grid .album-images-block").append(data.html);
2273                                }else{
2274                                    jQuerOs("#cat-"+data.catId+"-"+osg.params.galIdRandom).append(data.html);
2275                                }
2276                                
2277                                if(jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+" .load-more-hidden img").length <= 0){
2278                                    jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).css('display', 'none');
2279                                    inProgressAjax = false;
2280                                }
2281//                                var lm = 0;
2282                                osg.imgLoad(" div#cat-"+osg.params.curCatId + '-' + osg.params.galIdRandom)
2283                                    .then(function(returns) {
2284                                        if(osg.params.layout == 'masonry'){
2285                                            jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+" .load-more-hidden").css('position', 'absolute');
2286                                            jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+" .load-more-hidden").css('bottom', '0px');
2287                                        }
2288                                        if(osg.params.layout != 'allInOneRow' && osg.params.layout != 'fitRows'){
2289                                            osg.setImgBlockHeight(true)
2290                                        }
2291                                        jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+" .load-more-hidden").removeClass("load-more-hidden");
2292                                        jQuerOs("#cat-"+ data.catId+"-"+osg.params.galIdRandom+", #load-more-"+osg.params.galIdRandom).attr('data-end', data.limEnd);
2293                                        if(data.limEnd == -1)
2294                                            jQuerOs("#load-more-"+osg.params.galIdRandom).attr("disabled","disabled");
2295                                        limEnd = data.limEnd;
2296
2297
2298                                        if (jQuerOs.os_fancybox.getInstance() !== false){
2299                                            osg.LoadMoreThumbs(data);
2300                                        }
2301
2302                                        
2303                                        
2304
2305                                        jQuerOs('#os_lm_progres_img-'+osg.params.galIdRandom+':last' ).css('display', 'none');
2306                                        inProgressAjax = false;
2307//                                        setTimeout(function(){ 
2308                                            osg.loadMoreAuto();
2309//                                        }, 2000);
2310
2311//                                            }
2312//                                        });
2313                                    }).finally(() => {
2314                                        // if(osg.params.layout != 'allInOneRow'){
2315                                        //     osg.setImgBlockHeight();
2316                                        // }
2317                                        if(osg.params.layout == 'masonry' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'masonry')){
2318                                            osg.reloadAfterLazyLoad();
2319                                            osg.reloadIsotope();
2320    //                                            }else if(osg.params.layout == 'fitRows' || osg.params.layout == 'allInOneRow' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
2321                                        }else if(osg.params.layout == 'fitRows' || (osg.params.layout == 'album' && osg.params.albumSublayout == 'fit_rows')){
2322                                            osg.fitRowsIsotope(data.catId);
2323                                        }else{
2324                                            osg.resizeGallery();
2325                                        }
2326                                        osg.reinit(data.catId, limEnd);
2327                                        var href = window.location.href;
2328                                        if (jQuerOs.os_fancybox.getInstance() == false && href.indexOf('os_image_id') > -1){
2329                                            var img_el_id = '';
2330                                            var pos1 = href.indexOf('os_image_id'); 
2331                                            var pos2 = href.lastIndexOf('#'); 
2332
2333                                            if (pos1 > -1 && pos2 > - 1) {
2334                                                img_el_id = href.substring(pos1, pos2); 
2335                                            }else if(pos1 > -1 && pos2 == -1){
2336                                                img_el_id = href.substring(pos1);
2337                                            }
2338                                            if(document.getElementById(img_el_id) !== null){
2339                                                jQuerOs('#' + img_el_id).trigger('click');
2340                                            }
2341                                        }
2342                                    })
2343
2344                        }
2345                    },
2346                    error:function(){
2347                        inProgressAjax = false;
2348                        // osg.loadMoreAuto();
2349                    }
2350                })  
2351            }
2352        }
2353        
2354        osg.fileExists = function(url) {
2355            if(url){
2356                var client = new XMLHttpRequest();
2357                client.onload = function() {
2358                    // in case of network errors this might not give reliable results
2359//                    return this.status==200
2360                    
2361                  if ( this.status === 200 ) {
2362                    return true;
2363                  }
2364                  else {
2365                    return false;
2366                  }
2367                }
2368                client.open( "HEAD", url, true );
2369                client.send();
2370
2371            } else {
2372                return false;
2373            }
2374        }
2375        
2376        
2377
2378    }
2379    window.osGallery = osGallery;
2380})();

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.