source: extensions/Autosize/js/Affiche_script.js @ 6983

Last change on this file since 6983 was 6983, checked in by cljosse, 14 years ago

[Autosize]Improvement rv_maps compatibility.


File size: 9.4 KB
Line 
1
2if (!theme.match(RegExp("gally", "g")))
3    jQuery.noConflict();
4 
5
6jQuery(document).ready(
7function (jQuery) {
8    function Marge_haute(myObj, ajoute_h) {
9        if (ajoute_h) h_p = parseInt(jQuery(myObj).height());
10        else h_p = 0;
11
12        if (jQuery(myObj).css("marginTop"))
13            if (jQuery(myObj).css("marginTop") != "auto") h_p += parseInt(jQuery(myObj).css("marginTop"));
14        if (jQuery(myObj).css("marginBottom"))
15            if (jQuery(myObj).css("marginBottom") != "auto") h_p += parseInt(jQuery(myObj).css("marginBottom"));
16        if (jQuery(myObj).css("paddingTop"))
17            if (jQuery(myObj).css("paddingTop") != "auto") h_p += parseInt(jQuery(myObj).css("paddingTop"));
18        if (parseInt(jQuery(myObj).css("paddingBottom")))
19            if (jQuery(myObj).css("paddingBottom") != "auto") h_p += parseInt(jQuery(myObj).css("paddingBottom"));
20        return h_p;
21    }
22    //===================================================================       
23
24
25
26    jQuery(window).resize(function (event, ui) {
27        if (typeof (event) == 'undefined') return;
28
29        var Type_Img = "";
30        //====== détection du type d'images ======
31        var Image = jQuery("#theImage").find("embed");
32        if (Image.length > 0) {
33            Type_Img = "embed";
34        } else if (jQuery("#map").length) {
35
36            Type_Img = "map";
37
38
39        } else if (jQuery("#pamoorama").length) {
40
41            Type_Img = "pamoorama";
42        } else if (jQuery("#theImage").find("img").length > 0) {
43            Type_Img = "img";
44        } else if (jQuery("img").length > 0) {
45            Type_Img = "img_autre";
46        } else {
47            return;
48        }
49
50
51        //=================================================================
52        switch (Type_Img) {
53            case "map":
54                var Image = jQuery("#map");
55                var TheImg = jQuery("#map").get(0);
56                position = jQuery("#map").position();
57
58                img_height = jQuery(window).height() - position.top;
59                img_width = jQuery(window).width() - position.left;
60                break
61            case "img":
62                var Image = jQuery("#theImage").find("img");
63                var TheImg = jQuery("#theImg").find("img").get(0);
64                if (!TheImg)
65                    TheImg = jQuery(Image).get(0);
66                break
67            case "img_autre":
68                var Image = jQuery("img");
69                var TheImg = jQuery(Image).get(0);
70                break
71            case "embed":
72                var Image = jQuery("#theImage").find("embed");
73                var TheImg = jQuery(Image).get(0);
74                img_height = TheImg.clientHeight;
75                img_width = TheImg.clientWidth;
76                break
77            case "pamoorama":
78                //=========================================================
79                var Images = jQuery("#pamoorama");
80                var Image = jQuery(Images).get(0);
81
82                var TheImg = jQuery("#pamoorama").get(0);
83                if (!TheImg) return;
84                TheImg = jQuery("#pamoorama_inner");
85                if (TheImg.length < 1) return;
86
87                break
88        }
89
90        //==================================================================================
91        var sel0 = jQuery(TheImg).position();
92
93        if (!sel0) return;
94        type_pos = jQuery(TheImg).css("position"); //static
95        if (sel0.top  == 0) {
96            sel0.top = 0;
97            sel0.top += Marge_haute("#theHeader", true);
98            sel0.top += Marge_haute("#imageHeaderBar", true);
99            sel0.top += Marge_haute(TheImg, false);
100            if (jQuery("#theImage").css("marginTop"))
101                if (jQuery("#theImage").css("marginTop") != "auto") sel0.top += parseInt(jQuery("#theImage").css("marginTop"));
102            if (jQuery("#theImage").css("paddingTop"))
103                if (jQuery("#theImage").css("paddingTop") != "auto") sel0.top += parseInt(jQuery("#theImage").css("paddingTop"));
104
105        }
106
107        mini_width = parseInt(mini_width);
108        mini_height = parseInt(mini_height);
109
110        W0 = parseInt(img_width);
111        if (W0 < mini_width) return;
112
113        H0 = parseInt(img_height);
114        if (H0 < parseInt(mini_height)) return;
115        if (Type_Img != "map")
116            var rapport = (W0 / H0);
117        else
118            var rapport = -1;
119
120        //==========================================================================
121        var Licence = jQuery("#theImage").find(".licencetag");
122        if (Licence.length > 0) {
123            var lmt = jQuery(Licence.get(0)).height();
124            h_p = jQuery(Licence.get(0)).height();
125            jQuery(Licence.get(0)).css("position", "relative");
126
127            jQuery(Licence.get(0)).css("top", "0px");
128
129        } else {
130            var lmt = 0;
131
132        }
133        //==== paragraphe supplèmentaire ===
134        if (jQuery("#theImage").find("p")) {
135            h_p = 0;
136            Pars = jQuery("#theImage").find("p");
137
138            for (var i = 0; i < Pars.length; i++) {
139                P0 = Pars.get(i);
140                h_p += Marge_haute(P0, true);
141            }
142
143            //   n_t = (p_p.top - Image_height) + h_p;
144
145            lmt += h_p;
146            jQuery("#theImage").css("paddingBottom", 0 + "px");
147        }
148
149        //==========================================================================
150        var winheight = jQuery(window).height();
151        var Image_height = (winheight - sel0.top) - parseInt(marge_basse) - lmt;
152        var height_user = eval(user_status + "_height");
153
154        //=============================================================
155        var reg1 = new RegExp("%", "g");
156        if (height_user.match(reg1))
157            Image_height = Image_height * parseInt(height_user) / 100;
158        else
159            Image_height = parseInt(height_user);
160
161        //============================================================
162        echelle_max = parseFloat(echelle_max, '3');
163        var echelle = parseFloat(Image_height / H0, 3);
164
165        if (echelle > echelle_max) {
166            echelle = echelle_max;
167            Image_height = parseInt(H0 * echelle);
168        }
169
170        if (rapport > 0)
171            var Image_Width = parseInt(Image_height * rapport);
172        else
173            var Image_Width = parseInt(W0);
174        //===============================================================
175        twidth = jQuery("#imageHeaderBar").width();
176        img_la = jQuery(TheImg).width(); //initiale
177        offset = jQuery(TheImg).position();
178
179        var winwidth = jQuery(window).width();
180        var width_user = eval(user_status + "_width");
181        align_auto = "center";
182        if (check_auto_w == 'checked="checked"') {
183            if (Type_Img != "pamoorama") {
184                widthmin = (winwidth - offset.left);
185
186                if (Image_Width > widthmin) {
187                    //=============================================================
188                    if (width_user.match(reg1))
189                        Image_Width = Image_Width * parseInt(width_user) / 100;
190                    else
191                        Image_Width = parseInt(width_user);
192
193                    var echelle_w = parseFloat(winwidth / W0, 3);
194                    if (echelle_w > echelle_max) {
195                        echelle_w = echelle_max;
196                        Image_Width = parseInt(W0 * echelle_w);
197                    }
198                    Image_Width = parseInt(W0 * echelle_w);
199
200                    align_auto = "left";
201                } else {
202
203                    align_auto = "center";
204                }
205                Image_height = parseInt(Image_Width / rapport);
206
207            }
208
209
210        }
211        //=============================================================
212
213        if (Type_Img == "pamoorama") {
214
215
216            jQuery("#pamoorama").css("height", Image_height + "px");
217            jQuery("#pamoorama").css("width", twidth + "px");
218
219            jQuery("#pamoorama").height(Image_height + "px");
220            jQuery("#pamoorama").width(twidth + "px");
221
222
223
224            jQuery("#pamoorama_outter").height(Image_height + "px");
225            jQuery("#pamoorama_outter").width(twidth + "px");
226
227            jQuery("#pamoorama_outter").css("height", Image_height + "px");
228            jQuery("#pamoorama_outter").css("width", twidth + "px");
229
230            zoom = Image_height / img_height;
231
232            h_frame = jQuery("#pamoorama_frame").height();
233            h_width = jQuery("#pamoorama_frame").width();
234            jQuery(TheImg).css("zoom", zoom);
235
236
237
238        } else {
239            if (jQuery("#theImg").css("textAlign"))
240                jQuery("#theImg").css("textAlign", align_auto);
241
242            jQuery(TheImg).height(Image_height + "px");
243            jQuery(TheImg).width(Image_Width + "px");
244            jQuery(TheImg).css("height", Image_height + "px");
245            jQuery(TheImg).css("width", Image_Width + "px");
246
247        }
248
249
250        try {
251            // pour les themes Gally
252            initializeImageMode('resize');
253        } catch (e) { }
254        return;
255    });
256
257    //===================================================================         
258
259    jQuery(window).resize();
260
261    jQuery(window).resize();
262   
263   
264});   
265
266//=========================================================
267 
Note: See TracBrowser for help on using the repository browser.