source: extensions/DynamicResize/scripts/xhrpic.js @ 12181

Last change on this file since 12181 was 12181, checked in by arno, 13 years ago

feature : dynamicResize 1er commit, suite et fin

File size: 2.3 KB
Line 
1if (!window.console) console = {};
2console.log = console.log || function(){};
3console.warn = console.warn || function(){};
4console.error = console.error || function(){};
5console.info = console.info || function(){};
6var fire_count=0;
7//http://4loc.wordpress.com/2009/04/28/documentready-vs-windowload/
8//jQuery(document).ready(function (jQuery) {
9//jQuery(window).load(function () {
10        jQuery("#ret_autosize").live("ON", function (e, a) {   
11                /*
12                a.width= largeur de l'image
13                a.height= hauteur de l'image
14                a.theImage=  l'objet image
15                a.src_img=  url de l'image
16                */
17        fire_count = fire_count+1;
18        if(dyn_mode=='FLOW' || dyn_mode=='FLOW0'){
19                console.log('info : returned by autosize are these a.width x a.height :'+a.width+'x'+a.height);
20                console.log('info : returned by autosize are these a.window_width x a.window_height :'+a.window_width+'x'+a.window_height);
21               
22                console.log('saving in cookie the actual size ('+a.window_width+'x'+a.window_height+') for next pic'); 
23                jQuery.cookie("dynamic_width",  a.window_width);
24                jQuery.cookie("dynamic_height", a.window_height);
25        }else if(dyn_mode =='XHR'){
26                //trying to download actual picture
27       
28                if (typeof dyn_src_img == "undefined") {
29                        console.error('var dyn_src_img is not defined !! please check template');
30                }else if(fire_count>1){
31                        console.log('source not downloaded again');
32                }else{
33                        console.log(dyn_src_img);
34                        console.log("fire_count:"+fire_count);
35                        //@todo: deal with alternative methods
36                        dyn_src='/slir/w'+a.width+'-h'+a.height+'/'+dyn_src_img;
37                        //dyn_src_img=dyn_src_img+'&dyn_width='+a.width+'&dyn_height='+a.height;
38                        console.log('dyn_src_img:'+dyn_src_img);
39                        a.theImage.src = dyn_src_img; 
40                }
41        }
42    })
43  //})
44//})
45function fire_ret_autosize(){
46        jQuery("#ret_autosize").trigger("ON");
47}
48
49jQuery(document).ready(function (jQuery) {
50        jQuery(window).load(function () {
51        $("<div />").attr({
52                id: "prefetchContainer",
53        }).appendTo("#tabZone").css({ display: "none" });
54       
55        simpleLoad(next_dyn_url);
56
57        })
58})
59
60
61
62
63
64
65
66
67       
68  //simple image load
69function simpleLoad(fileName) {
70        $("<img />").attr({ 
71                id: "next_pic", 
72                src: fileName,
73                title: fileName
74        }).appendTo("#prefetchContainer").css({ display: "none" });                     
75};
76
77       
78
79
80
Note: See TracBrowser for help on using the repository browser.