Ignore:
Timestamp:
Jan 19, 2014, 11:22:11 PM (10 years ago)
Author:
Miklfe
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Slide/js/slide.js

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