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 | jQuery("body").append("<div style='position:abosolute;left:-200;top:-200'>"); |
---|
57 | if (derivatives.elements.length) { |
---|
58 | //if (derivatives.total - derivatives.done > 0) |
---|
59 | // setTimeout(function () { Set_images(params.src); }, 500 * (derivatives.total - derivatives.done)); |
---|
60 | } |
---|
61 | } //ready |
---|
62 | //=============================================================== |
---|
63 | Set_images = function (dataUrls) { |
---|
64 | if (typeof jQuery.manageAjax != "undefined") { |
---|
65 | for (var i = 0; i < dataUrls.length; i++) { |
---|
66 | fichier = dataUrls[i]; |
---|
67 | if (fichier != "") |
---|
68 | jQuery.manageAjax.add("queued", { |
---|
69 | type: 'GET', |
---|
70 | url: 'i.php?' + fichier + "&ajaxload=true", |
---|
71 | dataType: 'json', |
---|
72 | success: (function (data) { |
---|
73 | derivatives.done++; |
---|
74 | try { |
---|
75 | for (var j = 0; j < params.src.length; j++) { |
---|
76 | if (data.url.match(params.src[j])) { |
---|
77 | params.src[j] = ""; break; |
---|
78 | } |
---|
79 | } |
---|
80 | } catch (e) { |
---|
81 | |
---|
82 | } |
---|
83 | jQuery("#theMainImage").trigger("Success", data); |
---|
84 | }), |
---|
85 | error: (function (data) { |
---|
86 | jQuery("#theMainImage").trigger("Error", data); |
---|
87 | }), |
---|
88 | fail: (function (data) { |
---|
89 | jQuery("#theMainImage").trigger("fail", data); |
---|
90 | }), |
---|
91 | progress: (function (data) { |
---|
92 | jQuery("#theMainImage").trigger("Progress", data); |
---|
93 | }), |
---|
94 | |
---|
95 | complete: (function (data) { |
---|
96 | data.src = jQuery("#theMainImage").attr("src"); |
---|
97 | jQuery("#theMainImage").trigger("Complete", data); |
---|
98 | }), |
---|
99 | isRejected: (function (data) { |
---|
100 | jQuery("#theMainImage").trigger("IsRejected", data); |
---|
101 | }) |
---|
102 | |
---|
103 | }); |
---|
104 | } |
---|
105 | |
---|
106 | } |
---|
107 | }; |
---|