source: tapas/web/resources/js/classesForJQuery/VerticalSlide.js @ 382

Last change on this file since 382 was 382, checked in by vmipsl, 12 years ago

clean

File size: 3.0 KB
Line 
1//*************************************************************************
2// Class VerticalSlide
3// Display a vertical slide
4//
5// use jQuery
6// contentSlide : simple content
7// contentPageSlide : complex content like a full jsp page for example
8//*************************************************************************
9
10var VerticalSlide = Class.create( {
11
12    initialize: function( objectParameter )
13    {
14        // Param
15        this.parent = objectParameter.parent ? objectParameter.parent : document.body;
16        this.id = objectParameter.id;
17        this.titleId = objectParameter.titleId;
18        this.contentId = objectParameter.contentId;
19
20        this.title = objectParameter.title ? objectParameter.title : false;
21        this.content = objectParameter.content ? objectParameter.content : false;
22        this.contentPage = objectParameter.contentPage ? objectParameter.contentPage : false;
23        this.timeToSlide = objectParameter.timeToSlide ? objectParameter.timeToSlide : 100;
24        this.onClick = objectParameter.onClick ? objectParameter.onClick : false;
25
26        // Slide div
27        this.divSlide = $( document.createElement( "div" ) );
28        this.divSlide.attr( {id:this.id, class:"containerSlide"} );
29
30        // Title div
31        this.divSlideTitle = $( document.createElement( "div" ) );
32        this.divSlideTitle.attr( {id:this.titleId, class:"containerSlideTitle"} );
33
34        this.divSlideTitleImage = $( document.createElement( "div" ) );
35        this.divSlideTitleImage.addClass( "containerSlideTitle_image" );
36        this.divSlideTitle.append( this.divSlideTitleImage );
37
38        var divSlideTitleText = $( document.createElement( "div" ) );
39        divSlideTitleText.addClass( "containerSlideTitle_text" );
40        if( this.title )
41            divSlideTitleText.html( this.title );
42        this.divSlideTitle.append( divSlideTitleText );
43        this.divSlideTitle.bind( "click", jQuery.proxy( this.onClickTitle, this ) );
44        this.divSlide.append( this.divSlideTitle );
45
46        // Content div
47        this.divSlideContent = $( document.createElement( "div" ) );
48        this.divSlideContent.attr( {id:this.contentId, class:"containerSlideContent", style:"display:none"} );
49        if( this.content )
50            this.divSlideContent.append( this.content );
51        this.divSlide.append( this.divSlideContent );
52
53        this.parent.append( this.divSlide );
54    },
55
56    isContentVisible: function()
57    {
58        return ("block" == this.divSlideContent.css( "display" ));
59    },
60
61    // public
62    onClickTitle: function()
63    {
64        this.divSlideContent.animate( {height:"toggle"}, this.timeToSlide, jQuery.proxy( function()
65        {
66            if( this.isContentVisible() )
67            {
68                this.divSlideTitle.addClass( "activated" );
69            }
70            else
71            {
72                this.divSlideTitle.removeClass( "activated" );
73            }
74        }, this ) );
75
76        if( this.contentPage )
77            this.divSlideContent.load( this.contentPage );
78
79        if( this.onClick )
80            this.onClick();
81    }
82} );
Note: See TracBrowser for help on using the repository browser.