PageSourceSearch

https://078.com.ua/templates/ktpl/js/photos.js?1587304018

js 078.com.ua collected 2026-10-02 17:33:07 UTC 10,106 bytes, 314 lines download raw bytes

1var icms = icms || {};
2
3icms.photos = (function ($) {
4
5    this.page = 1;
6    this.initial_page = 1;
7    this.has_next = false;
8    this.init = false;
9    this.is_init_album = {};
10    this.mode = '';
11    this.big_img = '';
12    this.page_img = '';
13    this.page_url = '';
14    this.row_height = 255;
15
16    this.onDocumentReady = function(){
17
18        if (this.init === false) { return; }
19
20        if (this.mode === 'album'){
21            this.initAlbum();
22        }
23
24        if (this.mode === 'photo'){
25            this.initPhoto();
26        }
27
28    };
29
30    this.initPhoto = function(){
31
32        $('#download-button').on('click', function (){
33            var next = $(this).next().css({left: 0});
34            var hide_func = function (){
35                $(document).one('click', function(event) {
36                    if ($(event.target).closest(next).length) { hide_func(); return; }
37                    $(next).hide();
38                });
39            };
40            $(next).fadeIn('fast', hide_func);
41        });
42
43        $('#bubble input').on('click', function (){
44            $('a.process_download').attr('href', $(this).val());
45        }).each(function (){
46            if($(this).is(':checked')){
47                $(this).triggerHandler('click');
48            }
49        });
50
51        this.big_img = $('#photo_container').data('full-size-img');
52        this.page_url = $('#photo_container img').data('page-url');
53
54        if (screenfull.enabled) {
55            $('#fullscreen_photo').removeClass('disabled-act');
56            this.bindFullScreen();
57            $(document).on(screenfull.raw.fullscreenchange, function (){
58                if(!screenfull.isFullscreen){
59                    $('#photo_container img').attr('src', icms.photos.page_img);
60                    $('#fullscreen_photo').removeClass('close');
61                    $('#fullscreen_cont').removeClass('fullscreen_now');
62                    $('.photo_navigation').off('click', icms.photos.bindFullScreenNav);
63                    var current_page_url = $('#photo_container img').data('page-url');
64                    if(current_page_url != icms.photos.page_url){
65                        window.location.href = current_page_url;
66                    }
67                } else {
68                    icms.photos.page_img = $('#photo_container img').attr('src');
69                    $('#photo_container img').attr('src', icms.photos.big_img);
70                    $('#fullscreen_photo').addClass('close');
71                    $('#fullscreen_cont').addClass('fullscreen_now');
72                    $('#photo_container').on('click', '.photo_navigation', icms.photos.bindFullScreenNav);
73                }
74            });
75        } else {
76            $('#photo_container').addClass('full_in_modal').find('.fullscreen_click').show().on('click', function (){
77                if(icms.photos.big_img){
78                    icms.modal.openAjax(icms.photos.big_img);
79                }
80            });
81        }
82
83    };
84
85    this.bindFullScreen = function (){
86        $(document).on('click', '#fullscreen_photo', function (){
87            screenfull.toggle($('#fullscreen_cont')[0]);
88            return false;
89        });
90        $(document).keyup(function(event){
91            if(event.keyCode === 39){
92                try{ $('#photo_container .photo_navigation.next_item').trigger('click');}catch(e){}
93            }
94            if(event.keyCode === 37){
95                try{ $('#photo_container .photo_navigation.prev_item').trigger('click'); }catch(e){}
96            }
97        });
98    };
99
100    this.bindFullScreenNav = function (link) {
101
102        link = link || this;
103
104        $.get($(this).attr('href'), function(data){
105            $('#photo_container').html(data);
106        }, 'html');
107
108        return false;
109
110    };
111
112    this.initAlbum = function(selector){
113
114        selector = selector || '#album-photos-list';
115
116        if (this.is_init_album[selector] === true) { return; }
117
118        $(selector).on('click', 'a.delete', function(){
119            return icms.photos.deletePhoto($(this).data('id'), this);
120        });
121
122        $('.photo_filter .box_menu').on('click', function (){
123            var next = $(this).next().css({left: (+$(this).position().left - 20)});
124            var hide_func = function (){
125                $(document).one('click', function(event) {
126                    if ($(event.target).closest(next).length) { hide_func(); return; }
127                    $(next).hide();
128                });
129            };
130            $(next).fadeIn('fast', hide_func);
131        });
132
133        this.is_init_album[selector] = true;
134
135    };
136
137    this.initCarousel = function (selector, init_callback){
138        var def = $.when(
139            $('.photo', selector).each(function (){
140                $('img', this).width($(this).data('w')).height($(this).data('h'));
141            })
142        );
143        init_callback = init_callback || function(){};
144        def.done(function(){
145            $(selector).owlCarousel({
146                items:3,
147                loop:false,
148                margin:10,
149                autoWidth:true,
150                dots:false,
151                nav:true,
152                autoplay: true,
153                autoplayTimeout:5000,
154                autoplayHoverPause:true,
155                navText: ['',''],
156                onInitialized: init_callback,
157                responsive:{
158                    0:{items:1, nav:false },
159                    640:{items:2},
160                    980:{items:3}
161                }
162            });
163        });
164    };
165
166    this.createUploader = function(upload_url, onSubmit){
167
168        onSubmit = onSubmit || function(){ return true; };
169
170        uploader = new qq.FileUploader({
171            element: document.getElementById('album-photos-uploader'),
172            action: upload_url,
173            debug: false,
174            onSubmit: onSubmit,
175            onComplete: function(id, file_name, result){
176
177                if(!result.success) { return; }
178
179                var widget = $('#album-photos-widget');
180                var preview_block = $('.preview_template', widget).clone().
181                        removeClass('preview_template').addClass('preview').attr('rel', result.id).show();
182
183                $('img', preview_block).attr('src', result.url);
184                icms.modal.bind($('.hover_image', preview_block).attr('href', result.big_url));
185
186                $('.photo_privacy select', preview_block).attr('name', 'is_private['+result.id+']');
187                $('.photo_type select', preview_block).attr('name', 'type['+result.id+']');
188
189                $('.title input', preview_block).attr('name', 'photos['+result.id+']');
190                if(result.name){
191                    var pos, p = result.name.indexOf('.');
192                    while (pos != -1) { pos = result.name.indexOf('.',pos+1); if(pos != -1){ p = pos; } }
193                    $('.title input', preview_block).val(result.name.substring(0, p));
194                }
195
196                $('.photo_content textarea', preview_block).
197                        attr('name', 'content['+result.id+']').
198                        attr('id', 'mcontent_'+result.id);
199
200                $('.actions a.delete', preview_block).click(function() { return icms.photos.remove(result.id); });
201
202                $('.previews_list', widget).append(preview_block);
203
204                $('#mcontent_'+result.id).markItUp(mySettings);
205
206            }
207
208        });
209
210    };
211
212    this.remove = function(id){
213
214        var widget = $('#album-photos-widget');
215
216        var url = widget.data('delete-url') + '/' + id;
217
218        $.post(url, {}, function(result){
219
220            if (!result.success) { return; }
221
222            $('.preview[rel='+id+']', widget).fadeOut('fast', function() { $(this).remove(); });
223
224        }, 'json');
225
226        return false;
227
228    };
229
230    this.deletePhoto = function(id, link){
231
232        if(!confirm(LANG_PHOTOS_DELETE_PHOTO_CONFIRM)){
233            return false;
234        }
235
236        var block = $(link).closest('.photo');
237        var photo_wrap = $(link).closest('.album-photos-wrap');
238
239        $.post($(photo_wrap).data('delete-url') + '/' + id, {}, function(result){
240            block.fadeOut('fast', function (){
241                $(this).remove();
242                icms.photos.flexImagesInit('#'+$(photo_wrap).attr('id'));
243            });
244        }, 'json');
245
246        return false;
247
248    };
249
250    this.delete = function(){
251
252        $.post($('#album-photo-item').data('item-delete-url'), {id: $('#album-photo-item').data('id')}, function(result){
253			if (result.success){
254				window.location.href=result.album_url;
255			}
256		}, 'json');
257
258    };
259
260	this.flexImagesInit = function(selector){
261        selector = selector || '#album-photos-list';
262        $(selector).flexImages({rowHeight: this.row_height, container: '.photo', truncate: this.has_next});
263	};
264
265    this.showMore = function(link){
266
267        var photo_wrap = $(link).prev('.album-photos-wrap');
268
269        if(!icms.photos.has_next){
270            if(icms.photos.initial_page > 1){
271                return true;
272            }
273            $('body,html').animate({
274                scrollTop: $(photo_wrap).offset().top
275                }, 500
276            );
277            return false;
278        }
279
280        $(link).addClass('show_spinner');
281
282        icms.photos.page += 1;
283
284        var post_params = $(link).data('url-params');
285        post_params.photo_page = icms.photos.page;
286
287        $.post($(link).data('url'), post_params, function(html){
288
289            var first_page_url = $(link).data('first-page-url');
290
291            $(link).removeClass('show_spinner');
292
293            if (!html) { return; }
294
295            $(photo_wrap).append(html);
296
297            if(!icms.photos.has_next){
298                $('span', link).html($('span', link).data('to-first'));
299                $(link).attr('href', first_page_url);
300            }
301
302            var _sep = first_page_url.indexOf('?') !== -1 ? '&' : '?';
303
304            window.history.pushState({link: first_page_url+_sep+'photo_page='+icms.photos.page}, '', first_page_url+_sep+'photo_page='+icms.photos.page);
305
306        }, 'html');
307
308        return false;
309
310    };
311
312	return this;
313
314}).call(icms.photos || {},jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.