source: ether_statistics/web/resources/js/classesForJQuery/DragSlide.js @ 596

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

wijmo (linechart, barchart), credits, mentions

File size: 4.1 KB
Line 
1//*************************************************************************
2// Class DragSlide
3// Display a draggable slide
4//
5// use jQuery
6// contentSlide : simple content
7// contentPageSlide : complex content like a full jsp page for example
8//*************************************************************************
9
10var DragSlide = Class.create( {
11
12    initialize: function( objectParameter )
13    {
14        // Param
15        this.parent = objectParameter.parent ? objectParameter.parent : document.body;
16        this.titleId = objectParameter.titleId;
17        this.contentId = objectParameter.contentId;
18        this.width = objectParameter.width;
19        this.height = objectParameter.height;
20        this.top = objectParameter.top;
21        this.left = objectParameter.left;
22        this.specificClass = objectParameter.specificClass;
23        this.specificTitleClass = objectParameter.specificTitleClass ? objectParameter.specificTitleClass : false;
24        this.specificContentClass = objectParameter.specificContentClass ? objectParameter.specificContentClass : false;
25        this.title = objectParameter.title;
26        this.contentSlide = objectParameter.contentSlide ? objectParameter.contentSlide : false;
27        this.contentPageSlide = objectParameter.contentPageSlide ? objectParameter.contentPageSlide : false;
28        this.isIndexToChange = objectParameter.isIndexToChange ? objectParameter.isIndexToChange : false;
29
30        this.divContainer = $( document.createElement( "div" ) );
31        if( this.specificClass )
32            this.divContainer.addClass( this.specificClass );
33        this.divContainer.attr( {id:this.id, style:"width:" + this.width + "px; height:" + this.height + "px; top:" + this.top + "; left:" + this.left} );
34
35        // Title
36        this.divTitle = $( document.createElement( "div" ) );
37        if( this.specificTitleClass )
38            this.divTitle.addClass( this.specificTitleClass );
39        this.divTitle.html( this.title );
40        this.divTitle.attr( {style:"width:" + (this.width - 7) + "px"} );
41        this.divContainer.append( this.divTitle );
42
43        // Content
44        this.divContent = $( document.createElement( "div" ) );
45        if( this.specificContentClass )
46            this.divContent.addClass( this.specificContentClass );
47        this.divContent.html( this.contentSlide );
48        this.divContainer.append( this.divContent );
49
50        this.parent.append( this.divContainer );
51
52        this.divContainer.draggable();
53        this.divContainer.resizable();
54//        this.divContainer.dblclick();
55        this.divTitle.dblclick( jQuery.proxy( this.onDbClickTitle, this ) );
56        this.divContainer.resize( jQuery.proxy( this.onResizeContainer, this ) );
57    },
58
59    getTitle: function()
60    {
61        return this.divTitle.html();
62    },
63
64    setTitle: function( newTitle )
65    {
66        this.divTitle.html( newTitle );
67    },
68
69    getContent: function()
70    {
71        return this.divContent.html();
72    },
73
74    setContent: function( newContent )
75    {
76        this.divContent.html( newContent );
77    },
78
79    getDivContent: function()
80    {
81        return this.divContent;
82    },
83
84    isContentVisible: function()
85    {
86        return (this.divContent.css( "display" ) == "block");
87    },
88
89    // public
90    onDbClickTitle: function()
91    {
92        if( this.width == this.divContainer.width() )
93            this.enlargeContainer();
94        else
95            this.reduceContainer();
96    },
97
98    enlargeContainer: function()
99    {
100        this.divContainer.animate( {
101            height:'500px',
102            width:'500px'
103        }, 1000, function()
104        {
105        } );
106        this.divTitle.animate( {
107            width:'493px'
108        }, 1000, function()
109        {
110        } );
111    },
112
113    reduceContainer: function()
114    {
115        this.divContainer.animate( {
116            height:this.height + 'px',
117            width:this.width + 'px'
118        }, 1000, function()
119        {
120        } );
121        this.divTitle.animate( {
122            width:(this.width - 7) + 'px'
123        }, 1000, function()
124        {
125        } );
126    },
127
128    onResizeContainer: function()
129    {
130        var widthTitle = this.divContainer.width() - 7;
131        this.divTitle.width( widthTitle );
132    }
133} );
Note: See TracBrowser for help on using the repository browser.