source: extensions/GThumb/template/admin.tpl @ 13653

Last change on this file since 13653 was 13653, checked in by patdenice, 12 years ago
File size: 6.0 KB
Line 
1<div class="titrePage">
2<h2>GThumb+</h2>
3</div>
4
5<form action="" method="post">
6
7<fieldset id="GThumb">
8<legend>{'Configuration'|@translate}</legend>
9<table>
10  <tr>
11    <td align="right">{'Thumbnails max height'|@translate} : &nbsp;&nbsp;</td>
12    <td><input type="text" size="2" maxlength="3" name="height" value="{$HEIGHT}">&nbsp;px</td></td>
13  </tr>
14
15  <tr>
16    <td align="right">{'Margin between thumbnails'|@translate} : &nbsp;&nbsp;</td>
17    <td><input type="text" size="2" maxlength="3" name="margin" value="{$MARGIN}">&nbsp;px</td>
18  </tr>
19
20  <tr>
21    <td align="right">{'Number of photos per page'|@translate} : &nbsp;&nbsp;</td>
22    <td><input type="text" size="2" maxlength="3" name="nb_image_page" value="{$NB_IMAGE_PAGE}"></td>
23  </tr>
24
25  <tr>
26    <td align="right">{'Double the size of the first thumbnail'|@translate} : &nbsp;&nbsp;</td>
27    <td><input type="radio" name="big_thumb" value="1" {if $BIG_THUMB}checked="checked"{/if}> {'Yes'|@translate} &nbsp;
28        <input type="radio" name="big_thumb" value="0" {if !$BIG_THUMB}checked="checked"{/if}> {'No'|@translate}
29    </td>
30  </tr>
31
32  <tr>
33    <td align="right">{'Cache the big thumbnails (recommended)'|@translate} : &nbsp;&nbsp;</td>
34    <td><input type="radio" name="cache_big_thumb" value="1" {if $CACHE_BIG_THUMB}checked="checked"{/if}> {'Yes'|@translate} &nbsp;
35        <input type="radio" name="cache_big_thumb" value="0" {if !$CACHE_BIG_THUMB}checked="checked"{/if}> {'No'|@translate}
36    </td>
37  </tr>
38
39  <tr>
40    <td align="right">{'Scale thumbnails'|@translate} : &nbsp;&nbsp;</td>
41    <td><input type="radio" name="method" value="crop" {if $METHOD == 'crop'}checked="checked"{/if}> {'Crop'|@translate} &nbsp;
42        <input type="radio" name="method" value="resize" {if $METHOD == 'resize'}checked="checked"{/if}> {'Resize'|@translate}
43    </td>
44  </tr>
45
46</table>
47</fieldset>
48
49<p>
50  <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
51  <input type="submit" name="submit" value="{'Submit'|@translate}">
52  <input type="submit" name="cachedelete" value="{'Purge thumbnails cache'|@translate}" title="{'Delete images in GThumb+ cache.'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');">
53  <input type="button" name="cachebuild" value="{'Pre-cache thumbnails'|@translate}" title="{'Finds images that have not been cached and creates the cached version.'|@translate}" onclick="start()">
54</p>
55</form>
56
57<fieldset id="generate_cache">
58<legend>{'Pre-cache thumbnails'|@translate}</legend>
59<p>
60        <input id="startLink" value="{'Start'|@translate}" onclick="start()" type="button">
61        <input id="pauseLink" value="{'Pause'|@translate}" onclick="pause()" type="button" disabled="disbled">
62        <input id="stopLink" value="{'Stop'|@translate}" onclick="stop()" type="button" disabled="disbled">
63</p>
64<p>
65<table>
66        <tr>
67                <td>Errors</td>
68                <td id="errors">0</td>
69        </tr>
70        <tr>
71                <td>Loaded</td>
72                <td id="loaded">0</td>
73        </tr>
74        <tr>
75                <td>Remaining</td>
76                <td id="remaining">0</td>
77        </tr>
78</table>
79</p>
80<div id="feedbackWrap" style="height:{$HEIGHT}px; min-height:{$HEIGHT}px;">
81<img id="feedbackImg">
82</div>
83
84<div id="errorList">
85</div>
86</fieldset>
87
88{html_head}{literal}
89<style type="text/css">
90#GThumb td { padding-bottom: 12px; }
91#cacheinfo p, #GThumbProgressbar { text-align:left; line-height:20px; margin:20px }
92.ui-progressbar-value { background-image: url(plugins/GThumb/template/pbar-ani.gif); }
93#generate_cache { display: none; }
94</style>
95{/literal}{/html_head}
96
97{combine_script id='iloader' load='footer' path='themes/default/js/image.loader.js'}
98
99{footer_script require='jquery.effects.slide'}{literal}
100jQuery('input[name^="cache"]').tipTip({'delay' : 0, 'fadeIn' : 200, 'fadeOut' : 200});
101
102var loader = new ImageLoader( {onChanged: loaderChanged, maxRequests:1 } )
103        , pending_next_page = null
104        , last_image_show_time = 0
105        , allDoneDfd, urlDfd;
106
107function start() {
108        allDoneDfd = jQuery.Deferred();
109        urlDfd = jQuery.Deferred();
110
111        allDoneDfd.always( function() {
112                        jQuery("#startLink").attr('disabled', false).css("opacity", 1);
113                        jQuery("#pauseLink,#stopLink").attr('disabled', true).css("opacity", 0.5);
114                } );
115
116        urlDfd.always( function() {
117                if (loader.remaining()==0)
118                        allDoneDfd.resolve();
119                } );
120
121  jQuery('#generate_cache').show();
122        jQuery("#startLink").attr('disabled', true).css("opacity", 0.5);
123        jQuery("#pauseLink,#stopLink").attr('disabled', false).css("opacity", 1);
124
125        loader.pause(false);
126        updateStats();
127        getUrls(0);
128}
129
130function pause() {
131        loader.pause( !loader.pause() );
132}
133
134function stop() {
135        loader.clear();
136        urlDfd.resolve();
137}
138
139function getUrls(page_token) {
140        data = {prev_page: page_token, max_urls: 500, types: []};
141        jQuery.post( '{/literal}{$ROOT_URL}{literal}admin.php?page=plugin-GThumb&getMissingDerivative=',
142                data, wsData, "json").fail( wsError );
143}
144
145function wsData(data) {
146        loader.add( data.urls );
147        if (data.next_page) {
148                if (loader.pause() || loader.remaining() > 100) {
149                        pending_next_page = data.next_page;
150                }
151                else {
152                        getUrls(data.next_page);
153                }
154        }
155}
156
157function wsError() {
158        urlDfd.reject();
159}
160
161function updateStats() {
162        jQuery("#loaded").text( loader.loaded );
163        jQuery("#errors").text( loader.errors );
164        jQuery("#remaining").text( loader.remaining() );
165}
166
167function loaderChanged(type, img) {
168        updateStats();
169        if (img) {
170                if (type==="load") {
171                        var now = jQuery.now();
172                        if (now - last_image_show_time > 3000) {
173                                last_image_show_time = now;
174                                var h=img.height, url=img.src;
175                                jQuery("#feedbackWrap").hide("slide", {direction:'down'}, function() {
176                                        last_image_show_time = jQuery.now();
177                                        if (h > 300 )
178                                                jQuery("#feedbackImg").attr("height", 300);
179                                        else
180                                                jQuery("#feedbackImg").removeAttr("height");
181                                        jQuery("#feedbackImg").attr("src", url);
182                                        jQuery("#feedbackWrap").show("slide", {direction:'up'} );
183                                        } );
184                        }
185                }
186                else {
187                        jQuery("#errorList").prepend( '<a href="'+img.src+'">'+img.src+'</a>' + "<br>");
188                }
189        }
190        if (pending_next_page && 100 > loader.remaining() )     {
191                getUrls(pending_next_page);
192                pending_next_page = null;
193        }
194        else if (loader.remaining() == 0 && (urlDfd.isResolved() || urlDfd.isRejected()))       {
195                allDoneDfd.resolve();
196        }
197}
198{/literal}{/footer_script}
Note: See TracBrowser for help on using the repository browser.