source: extensions/Slide/js/slide.js @ 28503

Last change on this file since 28503 was 28503, checked in by Miklfe, 10 years ago
File size: 24.4 KB
Line 
1/************************************************************************************
2 *                                                                                                                                                                      *                                                               
3 *                                                                                                                                                                      *
4 *                                                      Slide - v2.0 - 2013-10-01                                                               *
5 *                                                       http://piwitheme.fr/                                                                   *
6 *                                                                                                                                                                      *
7 *                                                                                                                                                                      *
8*************************************************************************************/
9 
10(function($) {
11//_________________________________________________________________________________________________________________________________
12//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
13
14        $(document).ready(function(){
15                $('body').prepend($('<div />').attr({'class':'tab','id':'tab-0','data-urltab':window.location}).append($('<div />').attr('class','sld_tab'))).wrapInner($('<div />').attr({'class':'pageslide','id':'layer-0'}));
16                $('.pageslide').first().show();
17                var $w_w                = $(window).width(),
18                        $w_h            = $(window).height(),
19                //      $tab            = 40,
20                        i                       = 0,
21                        $layerShow      = $('#layer-0'),
22                        $slideshow      = [];
23                       
24                $('body').append($('<div />').attr('id','slideLoading').css({top:(($w_h/2)-50),left:(($w_w/2)-50)}));
25                $('body').data('layerShow',$layerShow);
26                _init_page()
27               
28                $(document).on('click','.slide', function(e) {
29                        var $url        = $(this).attr('href');
30                       
31                        $int            = setTimeout(function() {
32                                $('#slideLoading').css('z-index',1000)
33                                }, 500);
34                        i++;
35                       
36                        _load($url);
37                        _pushstate($url);       
38                       
39                        e.preventDefault();
40                });
41
42                $(document).on('click','.sameLayer', function(e) {
43                        var $href               = $(this).attr('href'),
44                                $layerShow      = $('body').data('layerShow'),
45                                $url            = $href + ' #the_page',
46                                $slide_w        = $layerShow.width();
47                               
48                        _pushstate($href);
49                       
50                        if ($('.slshFirst').length){
51                                $urlFirst       = $('.slshFirst').attr('href')
52                        } else {
53                                $urlFirst       = $href 
54                        };
55                       
56                        $('#the_page',$layerShow).addClass('unwrap').load($url, function(){
57                                _init_page($urlFirst,$slide_w)
58                                $('.unwrap').children().unwrap();
59                        });     
60                       
61                        e.preventDefault();
62                });     
63               
64                $(document).on('click','.tab', function(e) {
65                        _close( $(this) );
66                        var $url = $(this).data('urltab');
67                        _pushstate($url);                               
68                });
69               
70//quicksearch           
71                $(document).on('submit','#quicksearch', function(e) {
72                        i++;
73                        var $search             = $(this),
74                                $searchData             = $search.serialize(), 
75                                $searchHref     = $search.attr('action'),
76                                $url                    = $searchHref+'?'+$searchData,
77                                frame                   = $("<iframe />").attr({src: $url,id: 'frame'}).css({display:'none'});
78                               
79                        $('body').append(frame);
80                       
81                        var $obj = $('#frame').contents();
82                        setTimeout(     function(){
83                                var $obj                = $("#frame").contents(),
84                                        $urlframe        = $obj[0].location.href;
85                                _pushstate($urlframe);
86                                $('#frame').remove()
87                        },1000);
88                               
89                        $int = setTimeout(function(){
90                                $('#slideLoading').css('z-index',1000)
91                        }, 500);
92                       
93                        $('#qsearchInput').val(qsearch_prompt);
94                        _load($url);
95                        e.preventDefault();
96                });
97               
98// Picture page rating
99                $(document).on('mouseover','.rateButton',function(){
100                        $('#rateForm input').each(function(){
101                                $(this).removeClass('rateButtonFull').removeClass('rateButtonSelected');
102                                });
103                        $(this).addClass('rateButtonFull');
104                        var rate        = $(this).attr('title'),
105                                nth             = ':nth-child(-n+' + rate + ')';
106                        $('.rateButton' + nth).addClass('rateButtonFull');
107                });
108                               
109                $(document).on('mouseout','#rateForm',function(){
110                        $('#rateForm input').each(function(){
111                                $(this).removeClass('rateButtonFull').addClass('rateButton');
112                        });
113                        $('#rateForm input[type="button"]').addClass('rateButtonSelected');
114                        _rate_star()
115                });
116                               
117                $(document).on('click','.rateButton', function(e){
118                        var form        = $(this).parents('form'),
119                                hrefa   = form.attr('action'),
120                                hrefm   = form.attr('method'),
121                                rate    = $(this).attr('title'),
122                                rate    = 'rate=' + rate;
123                        $.ajax({
124                                url             : hrefa,
125                                type    : hrefm,
126                                data    : rate,
127                                success : function(){
128                                        hrefa = hrefa.substring(0,hrefa.indexOf('&'));
129                                        hrefInf = hrefa + ' #imageInfos';
130                                        $('#imageInfos').addClass('unwrap').load(hrefInf,function(){
131                                                _rate_star();
132                                                _imageInfo();
133                                                $('.unwrap').children().unwrap();
134                                        });
135                                }
136                        });
137                        e.preventDefault();
138                });
139               
140//switchbox derivative
141                $(document).on('click','.derivative', function(){
142                        var url                 = $(this).data('url'),
143                                typeSave        = $(this).data('typesave'),
144                                typeMap         = $(this).data('typemap'),
145                                cookies         = $(this).data('cookie')
146                                theImg          = $('#theMainImage');
147                        theImg.attr({'width':'' ,'height':'', 'src': url , 'useMap': '#map' + typeMap});
148                        $('#derivativeSwitchBox .switchCheck').css('visibility','hidden');
149                        $('#derivativeChecked' + typeSave).css('visibility','visible');
150                        document.cookie = 'picture_deriv='+typeSave+';path=cookies';
151                });             
152               
153                $(document).on('click','.original',function(){
154                        var theURL              = $(this).data('url'),
155                                winName         = $(this).data('winname'),
156                                features        = $(this).data('features');
157                        $.getScript('./themes/default/js/scripts.js', function(){
158                                phpWGOpenWindow(theURL,winName,features)
159                        });
160                });
161               
162                $(document).on('click','.privacy', function(){
163                        var rootUrl             = $(this).data('root'),
164                                id                      = $(this).data('id'),
165                                level           = $(this).data('level');
166                        setPrivacyLevel(rootUrl, id, level);
167                });
168
169//add comment
170                $(document).on('click', '#addComment input[type=submit]', function(e){
171                        $(this).valid_comment();
172                        e.preventDefault();
173                });
174                $(document).on('click', '#editComment input[type=submit]',  function(e){
175                        $(this).valid_comment();
176                        e.preventDefault(); 
177                });
178
179// removal/edit comment
180                $(document).on('click', '.actions a', function(e){
181                        var $a          = $(this);
182                        if($a.hasClass('delet')){
183                                var     $confi  = $a.attr('confirm');
184                                if (confirm($confi)) {
185                                        _rem_ed($a);
186                                };
187                        }
188                        _rem_ed($a);
189                        e.preventDefault();
190                });
191               
192//Change the order of comments
193                $(document).on('click', '.commentsOrder', function(e){
194                        var $a          = $(this);
195                        _rem_ed($a);
196                        e.preventDefault();
197                });
198
199//edit profil           
200                $(document).on('click', '#profile input[name=reset_to_default]', function(e){
201                        var $profil             = $('#profile'),
202                                $profilhref     = $profil.attr('action'),
203                                $profilmet      = $profil.attr('method'),
204                                $profilser      = $profil.serialize(),
205                                $profilval      = $(this).attr('value'),
206                                $profilnam      = $(this).attr('name'),
207                                $data = $profilser + '&' + $profilnam + '=' + $profilval;
208                                $.ajax({           
209                                        url             : $profilhref, 
210                                        type    : $profilmet, 
211                                        data    : $data, 
212                                        success : function(html) {
213                                                var $content = $(html).find('#profile');
214                                                $profil.replaceWith($content)
215                                        }
216                                });                     
217                        e.preventDefault();
218                });
219
220// search page
221                $(document).on('submit', '.theSearchPage .filter', function(e){
222                        var $sch                = $('.filter'),
223                                $schmet         = $sch.attr('method'),
224                                $schser         = $sch.serialize(),
225                                $schhref        = $sch.attr('action');
226                                $schser         = $schser+"&submit=Valide";
227                        $.ajax({           
228                                url             : $schhref, 
229                                type    : $schmet, 
230                                data    : $schser, 
231                                success : function(html){
232                                        var $e = $(html).find('.errors');
233                                        if($e.leng$th){
234                                                var $inf = $e.text();
235                                                _message($inf);
236                                        } else {
237                                                var $href               = $(html).find('.titrePage h2 a:nth-child(2)').attr('href'),
238                                                        $layerShow      = $('body').data('layerShow'),
239                                                        $url            = $href + ' #the_page';
240                                                $('#the_page', $layerShow).addClass('unwrap').load($url,function(){
241                                                        _init_page();
242                                                        $('.unwrap').children().unwrap();
243                                                });
244                                        };     
245                                }
246                        });
247                        e.preventDefault();
248                });
249                               
250//comment page
251                $(document).on('submit', '.theCommentsPage .filter',  function(e){
252                        var $com                = $('.filter'),
253                                $commet         = $com.attr('method'),
254                                $comser         = $com.serialize(), 
255                                $comhref        = $com.attr('action');
256                        $.ajax({           
257                                url             : $comhref, 
258                                type    : $commet, 
259                                data    : $comser, 
260                                success : function(html){
261                                        var $layerShow          = $('body').data('layerShow'),
262                                                $comfilt                = $(html).find('#content');
263                                        $('#content', $layerShow).replaceWith($comfilt);       
264                                }
265                        });
266                        e.preventDefault();
267                });
268               
269//switchBox
270                var $optbox = [ {li : '#sortOrderLink', box : '#sortOrderBox'},
271                                                {li : '#derivativeSwitchLink' , box : '#derivativeSwitchBox'},
272                                                {li : '#privacyLevelLink' , box : '#privacyLevelBox'},
273                                                {li : '#calendarViewSwitchLink' , box : '#calendarViewSwitchBox'}
274                                                ];
275                $.each($optbox, function(i, a){
276                        $(document).on('click', a.li , function(e) {
277                                var $layerShow  = $('body').data('layerShow'),
278                                        $ele            = $( a.box  , $layerShow),
279                                        ePos            = $(this).position(),
280                                        ePos_h          = $(this).height();
281                                if ($ele.is(":hidden")){
282                                        var left        = (ePos.left) + 'px',
283                                                top             = (ePos.top + ePos_h) + 'px';
284                                        $ele.css({left: left , top: top }).show();
285                                }
286                        e.preventDefault();     
287                        });
288                        $(document).on('mouseleave', a.box, function() {
289                                $(this).hide();
290                        });
291                });
292               
293//_____function SLIDE______________________________________________________________________________________________________________________________________________
294                function _init_page($urlFirst,$slide_w) {
295                var $layerShow  = $('body').data('layerShow');
296                        _selectPageSlide();
297                        _display_menu();
298                        _titre_page();
299                        _scrollbar();
300                        _content_size();
301                        _piwitheme_link();
302                        _dragbar_tabs();
303                        if($('#the_page',$layerShow).hasClass('thePicturePage')){
304                                _rate_star();
305                                _imageInfo()
306                        };
307                        if($('#the_page',$layerShow).hasClass('EC_drag')||$('#the_page',$layerShow).hasClass('EC_tictac')){
308                                _ECaptcha();
309                        };
310                        if($('#slideshow').length){
311                                $('#theHeader', $layerShow).remove();
312                                if (!$('#slideshow').hasClass('slideshowReady')) {
313                                        $.getScript('themes/Slide/js/slideshow.js', function(){
314                                                $('#slideshow').addClass('slideshowReady');
315                                                _load_slideshow($urlFirst, $slide_w);
316                                        });
317                                };
318                        };
319                        if($('body').hasClass('lightbox')||$('body').hasClass('lightboxReady')) {
320                                _lightbox()                             
321                        };
322                        if($('body').hasClass('GThumb')||$('body').hasClass('GThumbReady')) {
323                                _SlideGThumb()
324                        };
325                        if($('body').hasClass('MyPiwiShop')||$('body').hasClass('MyPiwiShopReady')) {
326                                _MyPiwiShop()
327                        };
328                        if($('body').hasClass('SmiliesSupport')||$('body').hasClass('SmiliesSupportReady')) {
329                                _SmiliesSupport()
330                        };
331                        if($('body').hasClass('SocialButtons')) {
332                                _SocialButtons()
333                        };
334
335                };             
336               
337                function _load( $url ) {
338                                       
339                        if(i<3){
340                                var $tab        = 40 * i,
341                                        $res    = 40;                   
342                        }else if(i==3){ 
343                                var $tab        = (20 * (i-1))+ 40,
344                                        $res    = 0;                   
345                        } else { 
346                                var     $tab    = (20 * (i-1))+ 40,
347                                        $res    = 20;
348                        }       
349
350                        var     $z                              = (100 / i).toFixed(),
351                                $pageslide_w    = $w_w - $tab,
352                                $href                   = $url + ' #the_page';
353               
354                                       
355                                       
356                        $('body').append($('<div />').attr('class','pageslide').css({ left: 'auto', right: '-' + $w_w + 'px' }));
357                        $('.pageslide').attr('id', function(i){
358                                return "layer-" + i;
359                        });
360                       
361                        var $layerPrev          = $('#layer-' + (i - 1)),
362                                $layerShow              = $('#layer-' + i);
363       
364                        $layerShow.css({'z-index'       : $z,
365                                                        width           : $pageslide_w +'px'
366                        })     
367                        $('body').data('layerShow',$layerShow);
368                        $('body').data('layerPrev',$layerPrev);
369                        $('body').data( 'i',i);
370                       
371                        $layerShow.load( $href, function(){
372                                if(i==3){
373                                                $('.pageslide:lt(-2)').each(function(e){
374                                                var m           = parseInt($(this).css('marginLeft')),
375                                                        newM    = m-(20*(e+1));
376                                                $(this).css({marginLeft: newM});
377                                                $('.tab', this).addClass('tabMin');
378                                        //console.debug(e)
379                                                e++
380                                                });
381
382                                }else if(i>3){
383                                        $('.pageslide:nth-last-child(3)').each(function(){
384                                                var m           = parseInt($(this).css('marginLeft')),
385                                                        newM    = m-20;
386                                                $(this).css({marginLeft: newM});
387                                                $('.tab', this).addClass('tabMin');
388                                        });
389                                }
390                               
391                                $layerPrev      .css({right:'auto'})
392                                                        .animate({marginLeft: - (($pageslide_w-$tab)+$res)}, 1000);
393                                $layerShow      .show()
394                                                        .animate({right: 0}, 1000)
395                                                        .prepend($('<div />')
396                                                        .attr({'class':'tab','id':'tab-0','data-urltab':window.location})
397                                                        .append($('<div />').attr('class','sld_tab')));
398                                $('.tab').attr('id', function(i){
399                                        return "tab-" + i;
400                                });
401                                $('#slideLoading').css('z-index',0);
402                                clearTimeout($int);
403                                _init_page($url, $pageslide_w)
404                        });
405
406                };
407
408
409                function _selectPageSlide(){
410                        var $layerShow  = $('body').data('layerShow'),
411                                $a                      = [     '#menu_start a',
412                                                                '.navigationBar a',
413                                                                '.calendarBar a',
414                                                                '.calendarCalBar a',
415                                                                '.navigationButtons a',
416                                                                '#imageHeaderBar a',
417                                                                '.calImg a',
418                                                                '.date_today',
419                                                                '#sortOrderLink',
420                                                                '#sortOrderBox a',
421                                                                '#derivativeSwitchBox a',
422                                                                '#derivativeSwitchLink',
423                                                                '.actionButtons a',
424                                                                '.actions a',
425                                                                '.navThumb',
426                                                                '.calendarTitle a',
427                                                                '#linkToPiwigo a',
428                                                                '#copyright a',
429                                                                '#languageSwitchLink',
430                                                                '#languageSwitchBox a',
431                                                                '#theHeader a',
432                                                                '#myHomePage a',
433                                                                '#mbAdditionalPages a',
434                                                                '#photosAddContent a',
435                                                                '.amm-MenuBar-links-icons a',
436                                                                '.commentsOrder',
437                                                                '#calendarViewSwitchLink',
438                                                                '#calendarViewSwitchBox a',
439                                                                '#ato_header a',
440                                                                '#ato_header_closed a',
441                                                                'a[rel=colorbox0]',
442                                                                'a[title="Share on tumblr"]',
443                                                                '.IN-widget a',
444                                                                '.twitter-share-button a',
445                                                                ],
446                                $b                      = [     '.pwg-icon-letters',
447                                                                '.pwg-icon-cloud',
448                                                                '.pwg-icon-help',
449                                                                '.pwg-icon-calendar',
450                                                                '.pwg-icon-camera-calendar',
451                                                                '.pwg-icon-favorite-del',
452                                                                '.pwg-icon-caddie-add',
453                                                                '.pwg-icon-category-view-flat',
454                                                                '.pwg-icon-category-view-normal',
455                                                                '#thePicturePage .pwg-icon-slideshow',
456                                                                '#thePicturePage .pwg-icon-camera-info',
457                                                                '#thePicturePage .pwg-icon-save',
458                                                                '#thePicturePage .pwg-icon-favorite-add',
459                                                                '#thePicturePage .pwg-icon-representative',
460                                                                '#thePicturePage .pwg-icon-edit',
461                                                                '.pwg-icon-category-edit'
462                                                                ],
463                                $c                      = [     '.description_stuffs .zero nb-comments',
464                                                                '.description_stuffs .nb-hits',
465                                                                '.description_stuffs .nb-comments'
466                                                                ],
467                                $d                      = [ '.pwg-icon-arrow-n'
468                                                                ],
469                                $e                      = [     '#linkToPiwigo a',
470                                                                '#copyright a'
471                                                                ],
472                                $f                      = [ '.navigationButtons a',
473                                                                '.navThumbs a',
474                                                                '.navigationBar a',
475                                                                '#derivativeSwitchBox a',
476                                                                '#sortOrderBox a',
477                                                                '#theMainImage map area a',
478                                                                '#calendarViewSwitchBox a',
479                                                                '.calImg a',
480                                                                ];
481                                $g                      = [ '.pwg-icon-caddie-add',
482                                                                '.pwg-icon-category-view-normal',
483                                                                '.pwg-icon-calendar',
484                                                                '.pwg-icon-camera-calendar'
485                                                                ];
486                                                               
487                        if($('body').hasClass('withlightbox')) {       
488                                        $a.push('.illustration a');
489                                };
490                                       
491                        $.each($a, function(i,e) {
492                                $(e, $layerShow).addClass('noSlide')
493                        });
494                        $.each($b, function(i,e) {
495                                $(e, $layerShow).parent().addClass('noSlide')
496                        });
497                        $.each($c,function(i,e) {
498                                $(e, $layerShow).remove()
499                        });
500                        $.each($d,function(i,e) {
501                                $(e, $layerShow).parent().remove()
502                        });
503                        $.each($e,function(i,e) {
504                                $(e, $layerShow).attr('target','blank')
505                        });
506                        $.each($f, function(i,e) {
507                                $(e, $layerShow).addClass('sameLayer')
508                        });
509                        $.each($g, function(i,e) {
510                                $(e, $layerShow).parent().addClass('sameLayer')
511                        });
512
513                        $('a:not(.noSlide)', $layerShow).addClass('slide');
514                        $('#layer-0 ').find('.sameLayer').removeClass('sameLayer');
515
516                        $('.stuffs_block .illustration .description', $layerShow).removeClass('description').addClass('description_stuffs');
517                        $('.titrePage + div', $layerShow).addClass('blockConteneur');
518                        $('.myHomePage_links a[href="index.php?/contact"]', $layerShow).addClass('slide');
519                };
520               
521                function _titre_page() {
522                        var $layerShow  = $('body').data('layerShow'),
523                                $titre          = $('#content .titrePage h2',$layerShow).first().text(),
524                                $titre          = $titre.substring($titre.lastIndexOf("/")).replace("/","");
525                        $('#content .titrePage h2',$layerShow).first().replaceWith("<h2>"+ $titre +"</h2>");
526                       
527                        if (($titre.indexOf("[")>=0)) {
528                                var $titreTab   = $titre.substring(0,$titre.indexOf("[",1));
529                        }else{
530                                var $titreTab   = $titre;
531                        };
532                        $('.sld_tab',$layerShow).text($titreTab);
533               
534                        $('.browsePath a',$layerShow).remove();
535                        var $titre              = $('.browsePath',$layerShow).text(),
536                                $titre          = $titre.substring($titre.lastIndexOf("/")).replace("/","").replace("[","").replace("]","");
537                        $('.browsePath',$layerShow).replaceWith("<h2>"+ $titre +"</h2>");
538                };
539               
540                function _scrollbar() {
541                        var $layerShow  = $('body').data('layerShow'),
542                                $settings       = {     verticalDragMinHeight: 100,
543                                                                verticalDragMaxHeight: 100,
544                                                                autoReinitialise: true
545                                                        };
546                        var $pane               = $('.scrollpane', $layerShow).jScrollPane($settings);
547                };
548               
549                function _display_menu() {
550                        var $layerShow  = $('body').data('layerShow');
551                        if($layerShow.attr('id') != ('layer-0')) { 
552                                $layerShow.find('#menubar').remove();
553                                $layerShow.find('#theHeader').addClass('headbord')
554                        };
555                        $('#theIdentificationPage #menu').remove();
556                };
557               
558                function _content_size(){
559                        var $layerShow  = $('body').data('layerShow'),
560                                $headerH        = $('#theHeader', $layerShow).height(),
561                                $headerBar      = $('.imageHeaderBar', $layerShow).height(),   
562                                $copyright      = $('#copyright', $layerShow).height(),
563                                $imageToolBar = $('.imageToolBar', $layerShow).height()
564                                $w_mh           = $(window).height() - ($headerH + $headerBar + $copyright +$imageToolBar + 50 ) + 'px';
565                        $('#content',$layerShow).css({minHeight: $w_mh});
566                };
567
568                function _piwitheme_link(){
569                        var $layerShow  = $('body').data('layerShow');
570                        var $link               = ' - theme by <a href="http://piwitheme.fr" target="_blank">piwitheme</a>';
571                        $('#copyright', $layerShow).append($link);
572                };
573
574                function _rate_star(){
575                        $('.rateButton').attr('value','');
576                        if ($('.rateButton [type="button"]').length){
577                                var rate        = $('.rateButtonSelected').attr('title'),
578                                        nth             = ':nth-child(-n+' + rate + ')';
579                                $('.rateButton' + nth).addClass('rateButtonFull');
580                        }
581                }
582               
583                function _imageInfo() {
584                        $('.imageInfo a').each(function(){
585                                var text = $(this).text();
586                                $(this).wrap($('<span />').html(text)).remove();
587                        })
588                };
589               
590                function _load_slideshow($href,$slideW) {
591                        $('#slideshow').empty().addClass('slideloader');
592                       
593                        $.ajax({
594                                url     : $href,
595                                success : function(html){
596                                        var $next       = $(html).find('.pwg-button-icon-right').attr('href'),
597                                                $title  = $(html).find('#imageHeaderBar h2').text(),
598                                                $img    = $(html).find('#theImage #imgContent').data('src'),
599                                                $img_h  = $(html).find('#theImage #imgContent').data('height'),
600                                                $img_w  = $(html).find('#theImage #imgContent').data('width');
601                                               
602                                        _stock_img($img,$title,$img_h,$img_w);
603                                        if(typeof $next != "undefined"){
604                                                _load_slideshow($next,$slideW)
605                                        }else{
606                                                $('#slideshow').removeClass('slideloader').slideshow({
607                                                        imgs                            : $slideshow,
608                                                        autoPlay                        : true,
609                                                        speed                           : 3000,
610                                                        height                          : $w_h,
611                                                        width                           : $slideW - 40,
612                                                        navType                         : 'thumb',
613                                                        styleSlideshow          : 'Fade',
614                                                        thumb_always            : false,
615                                                        thumb_width                     : 100,
616                                                        thumb_height            : 80,
617                                                })
618                                        };
619                                }       
620                        })
621                };
622
623                function _stock_img($href,$title,$height,$width){
624                        var $img = {src : $href  , title : $title , descr : $title , height : $height , width : $width};
625                        $slideshow.push($img);
626                };
627               
628                function _tabs_dragbar() {
629                        var $layerShow  = $('body').data('layerShow');
630                        $('.tab',$layerShow).fadeOut(1000).css("cursor","default");
631                        $('.jspDrag',$layerShow).css("cursor","pointer");                       
632                        $('.jspVerticalBar',$layerShow).fadeIn(1000)
633                };
634               
635                function _dragbar_tabs() {
636                        var $layerPrev  = $('body').data('layerPrev');
637                        if (typeof ($layerPrev) != 'undefined') {
638                                $('.tab',$layerPrev).fadeIn(1000).css("cursor","pointer");
639                                $('.jspDrag',$layerPrev).css("cursor","default");                       
640                                $('.jspVerticalBar',$layerPrev).fadeOut(1000)
641                        }
642                };
643               
644                function _close($tabClick) {
645                        var $layerBack  = $tabClick.parent(),
646                                $layerShow      = $('body').data('layerShow'),
647                                $newI           = $layerBack.attr('id'),
648                                $newI           = $newI.substring($newI.lastIndexOf("-")).replace("-","");
649
650                        $('body').data('layerShow', $layerBack);
651                        _tabs_dragbar();
652                        $layerShow.animate({left: $w_w}, 1000,function(){
653                        $layerBack.nextAll('.pageslide').remove();
654                                var $layerPrev = $layerBack.prev
655                                if($('#slideshow').length){
656                                        var $inter              = $('#slideshow').data('e').interval;
657                                        $slideshow              = [];
658                                        clearTimeout($inter);
659                                };
660                        });
661                       
662                        if($('.tab', $layerBack).hasClass('tabMin') & $newI > 3){
663                                $layerBack.css({right:'auto'}).animate({marginLeft:(($newI-1) * 20)+40}, 1000);
664                        }else{
665                                $layerBack.css({right:'auto'}).animate({marginLeft:($newI * 40)}, 1000);
666                        };
667                       
668                        i                       = $newI;
669                        var     $layerPrev      = $('#layer-' + (i - 1));
670                       
671                        if($('.tab', $layerPrev).hasClass('tabMin')){
672                                if($newI<3){
673                                        $('.pageslide:lt(-2)').each(function(e){
674                                                var m = parseInt($(this).css('marginLeft')),
675                                                        newM=m+(20*(e+1));
676                                                $(this).css({marginLeft: newM});
677                                                $('.tab', this).removeClass('tabMin');
678                                                e++
679                                        });
680                                }else{
681                                        var m           = parseInt($layerPrev.css('marginLeft')),
682                                                newM    = m+20;
683                                                       
684                                        $layerPrev.css({marginLeft: newM})
685                                        $('.tab', $layerPrev).removeClass('tabMin');
686                                }
687                        }
688                       
689                        var $newlayerShow       = $('body').data('layerShow');
690                        $('.tab', $newlayerShow).removeClass('tabMin');
691
692                        $('body').data( 'i',i);         
693                        $('body').data('layerPrev', $layerPrev)
694                };
695               
696                function _pushstate($url) {
697                        window.top.history.pushState({ key: i }, 'titre', $url)
698                        window.onpopstate = function(e){
699                                if (!e.state || e.state.key < i) {
700                                        $layerPrev = $('body').data('layerPrev');
701                                        _close($('.tab',$layerPrev))
702                                } else {
703                                        i++;
704                                        var $url = window.location;
705                                        _load($url);   
706                                }
707                        }
708                };
709               
710                function setPrivacyLevel(rootUrl, id, level) {
711                        var y = new PwgWS(rootUrl);
712                        y.callService(
713                                "pwg.images.setPrivacyLevel", {image_id: id, level:level} ,
714                        {
715                                method: "POST",
716                                onFailure: function(num, text) { alert(num + " " + text); },
717                                onSuccess: function(result) {
718                                          $('#privacyLevelBox .switchCheck').hide();
719                                          $('#levelCheck'+level).show();
720                                }
721                        });
722                };
723
724                function _rem_ed(e) {
725                        var $href = e.attr('href');
726                        $.ajax({ 
727                                url             : $href, 
728                                success : function(html){
729                                _comment_reload(html)
730                                }
731                        });
732                };     
733                               
734                $.fn.valid_comment = function(){       
735                        var addcom      = $(this).parents('form'),
736                                formp   = addcom.children('p'),
737                                contid  = $('#contentid'),
738                                contval = contid.val(),
739                                contlen = contid.length,
740                                aut             = $('#author'),
741                                autval  = aut.val(),
742                                autlen  = aut.length,
743                                em              = $('#email'),
744                                emval   = em.val(),
745                                emlen   = em.length,
746                                emregl  = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/,
747                                href    = addcom.attr('action'),
748                                framehref= href;
749                        formp.children().each(function(){
750                                $(this).removeClass('requi');
751                        });
752                        $.ajax({           
753                                url             : href, 
754                                type    : addcom.attr('method'), 
755                                data    : addcom.serialize(),
756                                error   : function (xhr, ajaxOptions, thrownError) {
757                                        var e           = (xhr.responseText),
758                                                e               = e.substring(e.indexOf('<div class="errors">')),
759                                                e               = e.substring(e.indexOf('<li>') , e.indexOf('</ul>')),
760                                                reg     = new RegExp("(<li>)","g"),
761                                                rege    = new RegExp("(</li>)","g"),
762                                                inf             = e.substring(e.indexOf('<li>'),e.lastIndexOf('</li>')).replace(reg,'').replace(rege,'');
763                                        _message(inf);
764                                },
765                                success : function(html){
766                                        var inf         = $(html).find('.infos li').text();
767                                        if(href.indexOf('&')>=0){href = href.substring(0,href.indexOf('&'))}
768                                        _message(inf);
769                                        _comment_reload(html);
770                                }                       
771                        });
772                };
773               
774                function _comment_reload(html){
775                        var $com                = $(html).find('#comments'),
776                                $layerShow      = $('body').data('layerShow');
777                        $('#comments', $layerShow).replaceWith($com);
778                        if($('#the_page',$layerShow).hasClass('EC_drag')||$('#the_page',$layerShow).hasClass('EC_tictac')){
779                                _ECaptcha();
780                        };
781
782                };
783
784                function _message(inf) {
785                        if($('#msgBox').length==0){
786                                $('body').append($('<div />').attr('id','msgBox').append($('<div />').attr('id','msgBoxCom'))).fadeIn();
787                        } else {
788                                $('#msgBox').fadeIn()
789                        };
790                        $('#msgBoxCom').text(inf);
791                        $('#msgBox').delay(5000).fadeOut();                     
792                };
793
794        });
795})(jQuery);
Note: See TracBrowser for help on using the repository browser.