1 | jQuery(document).ready( |
---|
2 | function (jQuery) { |
---|
3 | |
---|
4 | |
---|
5 | }); |
---|
6 | |
---|
7 | //============================================================ |
---|
8 | var derivatives = { |
---|
9 | elements: null, |
---|
10 | done: 0, |
---|
11 | total: 0, |
---|
12 | finished: function() { |
---|
13 | derivatives.elements.splice(0, 1); |
---|
14 | return derivatives.done == derivatives.total && derivatives.elements && derivatives.elements.length==0; |
---|
15 | } |
---|
16 | }; |
---|
17 | |
---|
18 | function progress(success,data) { |
---|
19 | if (derivatives.finished()) { |
---|
20 | jQuery("#theMainImage").trigger("Finish", [derivatives]); |
---|
21 | } |
---|
22 | |
---|
23 | } |
---|
24 | |
---|
25 | derivatives.elements = []; |
---|
26 | var ids = derivatives.elements.splice(0, 500); |
---|
27 | var params = { max_urls: 10, ids: ids, types: [], src: [],width:[], height:[] }; |
---|
28 | |
---|
29 | function getDerivativeUrls(nofile) { |
---|
30 | params.max_urls = nofile.length; |
---|
31 | jQuery(nofile).each(function (i, t) { |
---|
32 | if (typeof t.file != "undefined") { |
---|
33 | nbsrc = params.src.length; |
---|
34 | var reg = new RegExp("^\/", "g",1); |
---|
35 | t.file= t.file.replace( reg ,"",1); |
---|
36 | if (nbsrc == 0) { |
---|
37 | params.ids.push(t.id); |
---|
38 | params.types.push(t.type); |
---|
39 | params.src.push(t.file); |
---|
40 | |
---|
41 | |
---|
42 | } else if (~jQuery.inArray(t.file, params.src)) { |
---|
43 | jQuery.noop(); |
---|
44 | } else { |
---|
45 | params.ids.push(t.id); |
---|
46 | params.types.push(t.type); |
---|
47 | params.src.push(t.file); |
---|
48 | |
---|
49 | } |
---|
50 | } |
---|
51 | }); |
---|
52 | |
---|
53 | if(derivatives.elements.length==0) |
---|
54 | derivatives.elements = params.ids; |
---|
55 | derivatives.total += params.src.length; |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | jQuery("body").append("<div style='position:abosolute;left:-200;top:-200'>"); |
---|
61 | if (derivatives.elements.length) { |
---|
62 | if (derivatives.total - derivatives.done > 0) |
---|
63 | setTimeout("Set_images(params.src)", 500 * (derivatives.total - derivatives.done)); |
---|
64 | } |
---|
65 | } //ready |
---|
66 | //=============================================================== |
---|
67 | Set_images = function (dataUrls) { |
---|
68 | if (typeof jQuery.manageAjax != "undefined") { |
---|
69 | for (var i = 0; i < dataUrls.length; i++) { |
---|
70 | fichier = dataUrls[i]; |
---|
71 | if (fichier != "") |
---|
72 | jQuery.manageAjax.add("queued", { |
---|
73 | type: 'GET', |
---|
74 | url: 'i.php?' + fichier + "&ajaxload=true", |
---|
75 | dataType: 'json', |
---|
76 | success: (function (data) { |
---|
77 | derivatives.done++; |
---|
78 | try { |
---|
79 | for (var j = 0; j < params.src.length; j++) { |
---|
80 | if (data.url.match(params.src[j])) { |
---|
81 | params.src[j] = ""; break; |
---|
82 | } |
---|
83 | } |
---|
84 | } catch (e) { |
---|
85 | |
---|
86 | } |
---|
87 | jQuery("#theMainImage").trigger("Success", data); |
---|
88 | }), |
---|
89 | error: (function (data) { |
---|
90 | jQuery("#theMainImage").trigger("Error", data); |
---|
91 | }), |
---|
92 | fail: (function (data) { |
---|
93 | jQuery("#theMainImage").trigger("fail", data); |
---|
94 | }), |
---|
95 | progress: (function (data) { |
---|
96 | jQuery("#theMainImage").trigger("Progress", data); |
---|
97 | }), |
---|
98 | |
---|
99 | complete: (function (data) { |
---|
100 | data.src = jQuery("#theMainImage").attr("src"); |
---|
101 | jQuery("#theMainImage").trigger("Complete", data); |
---|
102 | }), |
---|
103 | isRejected: (function (data) { |
---|
104 | jQuery("#theMainImage").trigger("IsRejected", data); |
---|
105 | }) |
---|
106 | |
---|
107 | }); |
---|
108 | } |
---|
109 | |
---|
110 | } |
---|
111 | } |
---|