Post Thumbnail Editor - Version 1.0.1

Version Description

  • Fixed compatibility with other thickbox enabled plugins that called the wordpress media scripts.
  • Added Options screen (Settings -> Post Thumbnail Editor) to configure thickbox dimensions and enable/disable debugging.
  • Added Translation support & French translation (thanks to Li-An)
Download this release

Release Info

Developer sewpafly
Plugin Icon Post Thumbnail Editor
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.0.1

Makefile DELETED
@@ -1,74 +0,0 @@
1
-
2
- JSOUTPUT_DEV = js/pte.full.js
3
- JSOUTPUT_MIN = js/pte.full.min.js
4
- COFFEE = coffee
5
- COFFEE_FLAGS = -s -p
6
- COFFEE_FILES = js/header.coffee \
7
- js/log.coffee \
8
- js/pte_admin.coffee \
9
- js/pte.coffee
10
- JS_FILES = apps/jquery-tmpl/jquery.tmpl.js
11
-
12
-
13
- CSSOUTPUT_DEV = css/pte.css
14
- CSSOUTPUT_MIN = css/pte.min.css
15
- SCSSFILE = css/pte.scss
16
- SASS = sass
17
- CSSFILES = css/reset.css
18
-
19
- # create/overwrite the JSMINIFIER command for local
20
- # local.mk is not tracked in git project
21
- include $(wildcard local.mk)
22
-
23
- # The GOOGLE macro is defined in local.mk to point to compiler.jar
24
- ifdef GOOGLE
25
- JSMINIFIER = java -jar "$(GOOGLE)" --js $(JSOUTPUT_DEV) --js_output_file $(JSOUTPUT_MIN)
26
- else
27
- JSMINIFIER = cp $(JSOUTPUT_DEV) $(JSOUTPUT_MIN)
28
- endif
29
-
30
- # The YUI macro is defined in local.mk to point to yuicompressor.jar
31
- ifdef YUI
32
- CSSMINIFIER = java -jar "$(YUI)" --type css -o $(CSSOUTPUT_MIN) $(CSSOUTPUT_DEV)
33
- else
34
- CSSMINIFIER = cp $(CSSOUTPUT_DEV) $(CSSOUTPUT_MIN)
35
- endif
36
-
37
-
38
- # A simple make will compile the js/css and minify them
39
- all: minify-js minify-css
40
-
41
- # Build javascript
42
- $(JSOUTPUT_MIN): $(JSOUTPUT_DEV)
43
- @echo "Minifying javascript"
44
- $(JSMINIFIER)
45
-
46
- $(JSOUTPUT_DEV): $(COFFEE_FILES) $(JS_FILES)
47
- @echo "Building javascript"
48
- cat $(JS_FILES) > $(JSOUTPUT_DEV)
49
- cat $(COFFEE_FILES) | $(COFFEE) $(COFFEE_FLAGS) >> $(JSOUTPUT_DEV)
50
-
51
-
52
- # BUILD CSS
53
- $(CSSOUTPUT_DEV): $(SCSSFILE) $(CSSFILES)
54
- @echo "Building CSS"
55
- cat $(CSSFILES) > $(CSSOUTPUT_DEV)
56
- $(SASS) $(SCSSFILE) >> $(CSSOUTPUT_DEV)
57
-
58
- $(CSSOUTPUT_MIN): $(CSSOUTPUT_DEV)
59
- @echo "Minifying CSS"
60
- $(CSSMINIFIER)
61
-
62
- # Shortcuts
63
- js: $(JSOUTPUT_DEV)
64
- minify-js: $(JSOUTPUT_MIN)
65
- css: $(CSSOUTPUT_DEV)
66
- minify-css: $(CSSOUTPUT_MIN)
67
-
68
- # Clean
69
- OUTPUTFILES = $(wildcard $(CSSOUTPUT_MIN) $(CSSOUTPUT_DEV) $(JSOUTPUT_MIN) $(JSOUTPUT_DEV))
70
- clean:
71
- @echo "Cleaning up"
72
- $(if $(OUTPUTFILES), rm $(OUTPUTFILES))
73
-
74
- # vi: ts=3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Post Thumbnail Editor ===
2
  Contributors: sewpafly
3
- Donate link: http://github.com/sewpafly/post-thumbnail-editor
4
  Tags: post-thumbnail, post thumbnail, featured image, featured, editor, image, awesome
5
- Requires at least: 3.1
6
  Tested up to: 3.2.1
7
  Stable tag: trunk
8
 
@@ -59,9 +59,15 @@ Using a version with [json_encode](http://www.php.net/manual/en/function.json-en
59
  3. In the Edit subpage for media locate the box titled "Thumbnail Settings", and click the link to "Post Thumbnail Editor".
60
  4. Crop the image as you see fit and click "Create Thumbnails".
61
  5. Verify you want to keep the resized/recropped images by clicking "Okay, these look good..."
 
62
 
63
  == Changelog ==
64
 
 
 
 
 
 
65
  = 1.0.0 =
66
  * Total redesign of PHP/HTML interface
67
  * Allows editing multiple images
@@ -79,6 +85,9 @@ Using a version with [json_encode](http://www.php.net/manual/en/function.json-en
79
 
80
  == Upgrade Notice ==
81
 
 
 
 
82
  = 1.0.0 =
83
  Now with more awesome. Redesigned interface will challenge your perceptions of the universe.
84
 
1
  === Post Thumbnail Editor ===
2
  Contributors: sewpafly
3
+ Donate link: https://www.wepay.com/donate/34543
4
  Tags: post-thumbnail, post thumbnail, featured image, featured, editor, image, awesome
5
+ Requires at least: 3.2.1
6
  Tested up to: 3.2.1
7
  Stable tag: trunk
8
 
59
  3. In the Edit subpage for media locate the box titled "Thumbnail Settings", and click the link to "Post Thumbnail Editor".
60
  4. Crop the image as you see fit and click "Create Thumbnails".
61
  5. Verify you want to keep the resized/recropped images by clicking "Okay, these look good..."
62
+ 6. Shortcut to edit the thumbnails from the picture metadata screen.
63
 
64
  == Changelog ==
65
 
66
+ = 1.0.1 =
67
+ * Fixed compatibility with other thickbox enabled plugins that called the wordpress media scripts.
68
+ * Added Options screen (Settings -> Post Thumbnail Editor) to configure thickbox dimensions and enable/disable debugging.
69
+ * Added Translation support & French translation (thanks to Li-An)
70
+
71
  = 1.0.0 =
72
  * Total redesign of PHP/HTML interface
73
  * Allows editing multiple images
85
 
86
  == Upgrade Notice ==
87
 
88
+ = 1.0.1 =
89
+ Added translation support, french language, options menu and fixed incompatibility with other thickbox enabled plugins.
90
+
91
  = 1.0.0 =
92
  Now with more awesome. Redesigned interface will challenge your perceptions of the universe.
93
 
apps/jquery.json-2.2.min.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ (function($){$.toJSON=function(o)
3
+ {if(typeof(JSON)=='object'&&JSON.stringify)
4
+ return JSON.stringify(o);var type=typeof(o);if(o===null)
5
+ return"null";if(type=="undefined")
6
+ return undefined;if(type=="number"||type=="boolean")
7
+ return o+"";if(type=="string")
8
+ return $.quoteString(o);if(type=='object')
9
+ {if(typeof o.toJSON=="function")
10
+ return $.toJSON(o.toJSON());if(o.constructor===Date)
11
+ {var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+
12
+ hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
13
+ if(o.constructor===Array)
14
+ {var ret=[];for(var i=0;i<o.length;i++)
15
+ ret.push($.toJSON(o[i])||"null");return"["+ret.join(",")+"]";}
16
+ var pairs=[];for(var k in o){var name;var type=typeof k;if(type=="number")
17
+ name='"'+k+'"';else if(type=="string")
18
+ name=$.quoteString(k);else
19
+ continue;if(typeof o[k]=="function")
20
+ continue;var val=$.toJSON(o[k]);pairs.push(name+":"+val);}
21
+ return"{"+pairs.join(", ")+"}";}};$.evalJSON=function(src)
22
+ {if(typeof(JSON)=='object'&&JSON.parse)
23
+ return JSON.parse(src);return eval("("+src+")");};$.secureEvalJSON=function(src)
24
+ {if(typeof(JSON)=='object'&&JSON.parse)
25
+ return JSON.parse(src);var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,'@');filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']');filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered))
26
+ return eval("("+src+")");else
27
+ throw new SyntaxError("Error parsing JSON, source is not valid.");};$.quoteString=function(string)
28
+ {if(string.match(_escapeable))
29
+ {return'"'+string.replace(_escapeable,function(a)
30
+ {var c=_meta[a];if(typeof c==='string')return c;c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
31
+ return'"'+string+'"';};var _escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var _meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};})(jQuery);
checklist.md DELETED
@@ -1,26 +0,0 @@
1
- # Checklist
2
-
3
- 1. Update jquery-tmpl and any other apps
4
- * `cd apps/jquery-tmpl`
5
- * `git fetch upstream`
6
- * `git merge upstream/master`
7
- * `git push origin master`
8
- 2. Run build script: `make`
9
- * compiles & minifies css/js
10
- * concatenates into one file
11
- 3. Update post-thumbnail-editor.php
12
- * Change the version information in 2 places
13
- * Set `PTE_DEBUG` to false (switch from dev files to minified ones)
14
- 4. Modify README.txt
15
- * Update the requires/tested version information
16
- * Update the Upgrade Notice
17
- * Update the Changelog
18
- * Update screenshots (max-width: 532px)
19
- * [Test README](http://wordpress.org/extend/plugins/about/validator/)
20
- 5. Test on Firefox, Chrome, Safari, IE7/8/9 & Linux/Windows/Mac
21
- * Do the rows change color on selection?
22
- * Does the height get set correctly?
23
- 6. Tag the git release
24
- * `git tag [-a -m 'annotated tag'] version`
25
- * `git push --tags`
26
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/pte.css CHANGED
@@ -140,9 +140,13 @@ table td {
140
  vertical-align: middle;
141
  padding: 15px 0; }
142
 
143
- /*.col1 { */
144
- /*width: 50px; */
145
- /*}*/
 
 
 
 
146
  /*.col2 { */
147
  /* padding-right: 20px; */
148
  /*}*/
@@ -161,28 +165,110 @@ table td {
161
  .pte-edit-label {
162
  display: block; }
163
 
164
- #pte-loading {
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  height: 100%;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  position: absolute;
 
 
 
 
 
167
  top: 0;
168
  left: 0;
169
  width: 100%; }
170
- #pte-loading #pte-loading-opaque {
171
- background-color: #000;
172
- height: 100%;
173
- position: absolute;
174
- top: 0;
175
- left: 0;
176
- width: 100%;
177
- opacity: 0.8;
178
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
179
- filter: alpha(opacity=80); }
180
  #pte-loading #pte-loading-spinner {
181
  position: relative;
182
- top: 50%;
183
- width: 200px;
184
  margin: 0 auto;
185
- text-align: center; }
 
 
186
 
187
  .stage {
188
  float: left;
@@ -194,7 +280,7 @@ table td {
194
 
195
  #stage2, #stage3 {
196
  display: none;
197
- left: 1500px;
198
  width: 750px; }
199
 
200
  table {
140
  vertical-align: middle;
141
  padding: 15px 0; }
142
 
143
+ .col1 {
144
+ max-width: 30px;
145
+ text-align: center;
146
+ width: 30px; }
147
+ .col1 input {
148
+ margin: 0 auto; }
149
+
150
  /*.col2 { */
151
  /* padding-right: 20px; */
152
  /*}*/
165
  .pte-edit-label {
166
  display: block; }
167
 
168
+ /* Used by #pte-log and #pte-loading */
169
+ .pte-opaque {
170
+ background-color: #000;
171
+ height: 100%;
172
+ position: fixed;
173
+ top: 0;
174
+ left: 0;
175
+ width: 100%;
176
+ opacity: 0.8;
177
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
178
+ filter: alpha(opacity=80);
179
+ z-index: 0; }
180
+
181
+ #pte-log {
182
  height: 100%;
183
+ position: fixed;
184
+ top: 0;
185
+ left: 0;
186
+ width: 100%;
187
+ display: none;
188
+ z-index: 1300;
189
+ color: #ddd; }
190
+ #pte-log a {
191
+ color: white; }
192
+ #pte-log #pte-log-container {
193
+ position: relative;
194
+ margin: 0 auto;
195
+ text-align: center;
196
+ top: 5%;
197
+ height: 80%; }
198
+ #pte-log a.button {
199
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#303080), to(#00007f));
200
+ background-image: -webkit-linear-gradient(top, #303080, #00007f);
201
+ background-image: -moz-linear-gradient(top, #303080, #00007f);
202
+ background-image: -ms-linear-gradient(top, #303080, #00007f);
203
+ background-image: -o-linear-gradient(top, #303080, #00007f);
204
+ /*border: 2px solid white;*/
205
+ border-radius: 0 0 7px 7px;
206
+ -moz-border-radius: 0 0 7px 7px;
207
+ -webkit-border-radius: 0 0 7px 7px;
208
+ padding: 0 10px 3px 10px;
209
+ text-decoration: none; }
210
+ #pte-log a.button:hover {
211
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#00007f), to(#303080));
212
+ background-image: -webkit-linear-gradient(top, #00007f, #303080);
213
+ background-image: -moz-linear-gradient(top, #00007f, #303080);
214
+ background-image: -ms-linear-gradient(top, #00007f, #303080);
215
+ background-image: -o-linear-gradient(top, #00007f, #303080); }
216
+ #pte-log p {
217
+ line-height: 1.2em;
218
+ margin: 0 auto 20px;
219
+ text-align: left;
220
+ width: 90%; }
221
+ #pte-log textarea {
222
+ height: 400px;
223
+ width: 90%; }
224
+
225
+ a#pte-log-button.show-log-messages {
226
+ background-color: #cd0000;
227
+ border-radius: 0 0 7px 7px;
228
+ -moz-border-radius: 0 0 7px 7px;
229
+ -webkit-border-radius: 0 0 7px 7px;
230
+ top: 0;
231
+ right: 20px;
232
+ display: block;
233
+ /*left: 282px;*/
234
+ padding: 3px 5px 5px 5px;
235
+ position: fixed;
236
+ text-align: center;
237
+ color: white;
238
+ font-size: 0.9em;
239
+ font-style: italic;
240
+ text-decoration: none;
241
+ text-shadow: none;
242
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(red), to(#cd0000));
243
+ background-image: -webkit-linear-gradient(top, red, #cd0000);
244
+ background-image: -moz-linear-gradient(top, red, #cd0000);
245
+ background-image: -ms-linear-gradient(top, red, #cd0000);
246
+ background-image: -o-linear-gradient(top, red, #cd0000); }
247
+
248
+ a#pte-log-button.show-log-messages:hover {
249
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#cd0000), to(red));
250
+ background-image: -webkit-linear-gradient(top, #cd0000, red);
251
+ background-image: -moz-linear-gradient(top, #cd0000, red);
252
+ background-image: -ms-linear-gradient(top, #cd0000, red);
253
+ background-image: -o-linear-gradient(top, #cd0000, red); }
254
+
255
+ /* FIXES IE to bottom of screen */
256
+ * html #pte-log-button.show-log-messages {
257
  position: absolute;
258
+ top: expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px'); }
259
+
260
+ #pte-loading {
261
+ height: 100%;
262
+ position: fixed;
263
  top: 0;
264
  left: 0;
265
  width: 100%; }
 
 
 
 
 
 
 
 
 
 
266
  #pte-loading #pte-loading-spinner {
267
  position: relative;
 
 
268
  margin: 0 auto;
269
+ text-align: center;
270
+ top: 50%;
271
+ width: 200px; }
272
 
273
  .stage {
274
  float: left;
280
 
281
  #stage2, #stage3 {
282
  display: none;
283
+ /*left: $width * 2;*/
284
  width: 750px; }
285
 
286
  table {
css/pte.min.css CHANGED
@@ -1 +1 @@
1
- html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}a.stage-navigation,a.stage-navigation:visited{color:#38ab36;font-family:'Amaranth',serif;font-size:.8em;font-style:italic;text-decoration:none;text-shadow:none}a.stage-navigation img,a.stage-navigation:visited img{border:0;vertical-align:bottom}a{color:#444;font-family:'Amaranth',serif;font-style:italic;text-shadow:none}a:visited{color:#black}a img{vertical-align:bottom}h1{color:#2386e2;font-family:'Amaranth',serif;font-style:italic;font-size:1.6em;text-shadow:white 1px 1px 5px,2px 2px 10px #999}body{font-family:'PT Serif',serif;overflow-x:hidden;margin:auto;max-width:750px;background-color:#efefef}#pte-image{float:left;margin-top:5px;width:402px}#pte-image img{display:block;margin:auto}#pte-buttons button{font-family:"Amaranth",Tahoma,sans-serif;font-size:larger;line-height:130%;margin:10px auto;padding:10px;width:100%}#pte-confirm{font-family:"Amaranth",Tahoma,sans-serif;font-size:larger;line-height:130%;margin:10px auto;padding:10px;width:75%}#pte-sizes-container{overflow:auto;padding-left:15px;float:left;width:331px}#pte-selectors,#pte-stage2-selectors{margin-bottom:10px}#pte-sizes{overflow-x:hidden;overflow-y:scroll;position:relative;border:1px solid #ddd}#pte-sizes img{max-width:296px}table tr{border-bottom:1px solid #ddd}table tr.selected{background-color:#fff}table td{position:relative;vertical-align:middle;padding:15px 0}.pte-size-label{background:#cdcdcd;bottom:0;font-family:'Amaranth',serif;font-weight:bolder;padding:5px 0 7px 5px}.pte-size-label .actual{font-size:.8em;font-weight:normal}.pte-edit-label{display:block}#pte-loading{height:100%;position:absolute;top:0;left:0;width:100%}#pte-loading #pte-loading-opaque{background-color:#000;height:100%;position:absolute;top:0;left:0;width:100%;opacity:.8;-ms-filter:"alpha(opacity=80)";filter:alpha(opacity=80)}#pte-loading #pte-loading-spinner{position:relative;top:50%;width:200px;margin:0 auto;text-align:center}.stage{float:left;left:0;position:relative;top:0}#stage2,#stage3{display:none;left:1500px;width:750px}table{width:100%}#stage2 img{max-width:710px}#error{color:#a00}#error ul{list-style:disc;margin:10px 0 10px 20px}#success{color:#38ab36;font-size:1.5em}
1
+ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}a.stage-navigation,a.stage-navigation:visited{color:#38ab36;font-family:'Amaranth',serif;font-size:.8em;font-style:italic;text-decoration:none;text-shadow:none}a.stage-navigation img,a.stage-navigation:visited img{border:0;vertical-align:bottom}a{color:#444;font-family:'Amaranth',serif;font-style:italic;text-shadow:none}a:visited{color:#black}a img{vertical-align:bottom}h1{color:#2386e2;font-family:'Amaranth',serif;font-style:italic;font-size:1.6em;text-shadow:white 1px 1px 5px,2px 2px 10px #999}body{font-family:'PT Serif',serif;overflow-x:hidden;margin:auto;max-width:750px;background-color:#efefef}#pte-image{float:left;margin-top:5px;width:402px}#pte-image img{display:block;margin:auto}#pte-buttons button{font-family:"Amaranth",Tahoma,sans-serif;font-size:larger;line-height:130%;margin:10px auto;padding:10px;width:100%}#pte-confirm{font-family:"Amaranth",Tahoma,sans-serif;font-size:larger;line-height:130%;margin:10px auto;padding:10px;width:75%}#pte-sizes-container{overflow:auto;padding-left:15px;float:left;width:331px}#pte-selectors,#pte-stage2-selectors{margin-bottom:10px}#pte-sizes{overflow-x:hidden;overflow-y:scroll;position:relative;border:1px solid #ddd}#pte-sizes img{max-width:296px}table tr{border-bottom:1px solid #ddd}table tr.selected{background-color:#fff}table td{position:relative;vertical-align:middle;padding:15px 0}.col1{max-width:30px;text-align:center;width:30px}.col1 input{margin:0 auto}.pte-size-label{background:#cdcdcd;bottom:0;font-family:'Amaranth',serif;font-weight:bolder;padding:5px 0 7px 5px}.pte-size-label .actual{font-size:.8em;font-weight:normal}.pte-edit-label{display:block}.pte-opaque{background-color:#000;height:100%;position:fixed;top:0;left:0;width:100%;opacity:.8;-ms-filter:"alpha(opacity=80)";filter:alpha(opacity=80);z-index:0}#pte-log{height:100%;position:fixed;top:0;left:0;width:100%;display:none;z-index:1300;color:#ddd}#pte-log a{color:white}#pte-log #pte-log-container{position:relative;margin:0 auto;text-align:center;top:5%;height:80%}#pte-log a.button{background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#303080),to(#00007f));background-image:-webkit-linear-gradient(top,#303080,#00007f);background-image:-moz-linear-gradient(top,#303080,#00007f);background-image:-ms-linear-gradient(top,#303080,#00007f);background-image:-o-linear-gradient(top,#303080,#00007f);border-radius:0 0 7px 7px;-moz-border-radius:0 0 7px 7px;-webkit-border-radius:0 0 7px 7px;padding:0 10px 3px 10px;text-decoration:none}#pte-log a.button:hover{background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#00007f),to(#303080));background-image:-webkit-linear-gradient(top,#00007f,#303080);background-image:-moz-linear-gradient(top,#00007f,#303080);background-image:-ms-linear-gradient(top,#00007f,#303080);background-image:-o-linear-gradient(top,#00007f,#303080)}#pte-log p{line-height:1.2em;margin:0 auto 20px;text-align:left;width:90%}#pte-log textarea{height:400px;width:90%}a#pte-log-button.show-log-messages{background-color:#cd0000;border-radius:0 0 7px 7px;-moz-border-radius:0 0 7px 7px;-webkit-border-radius:0 0 7px 7px;top:0;right:20px;display:block;padding:3px 5px 5px 5px;position:fixed;text-align:center;color:white;font-size:.9em;font-style:italic;text-decoration:none;text-shadow:none;background-image:-webkit-gradient(linear,0% 0,0% 100%,from(red),to(#cd0000));background-image:-webkit-linear-gradient(top,red,#cd0000);background-image:-moz-linear-gradient(top,red,#cd0000);background-image:-ms-linear-gradient(top,red,#cd0000);background-image:-o-linear-gradient(top,red,#cd0000)}a#pte-log-button.show-log-messages:hover{background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#cd0000),to(red));background-image:-webkit-linear-gradient(top,#cd0000,red);background-image:-moz-linear-gradient(top,#cd0000,red);background-image:-ms-linear-gradient(top,#cd0000,red);background-image:-o-linear-gradient(top,#cd0000,red)}* html #pte-log-button.show-log-messages{position:absolute;top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop:document.body.scrollTop))+'px')}#pte-loading{height:100%;position:fixed;top:0;left:0;width:100%}#pte-loading #pte-loading-spinner{position:relative;margin:0 auto;text-align:center;top:50%;width:200px}.stage{float:left;left:0;position:relative;top:0}#stage2,#stage3{display:none;width:750px}table{width:100%}#stage2 img{max-width:710px}#error{color:#a00}#error ul{list-style:disc;margin:10px 0 10px 20px}#success{color:#38ab36;font-size:1.5em}
css/pte.scss CHANGED
@@ -35,7 +35,7 @@ a {
35
  }
36
  }
37
 
38
- h1, {
39
  color: #2386e2;
40
  font-family: 'Amaranth', serif;
41
  font-style: italic;
@@ -116,9 +116,15 @@ table td {
116
  vertical-align: middle;
117
  padding: 15px 0;
118
  }
119
- /*.col1 { */
120
- /*width: 50px; */
121
- /*}*/
 
 
 
 
 
 
122
  /*.col2 { */
123
  /* padding-right: 20px; */
124
  /*}*/
@@ -143,29 +149,109 @@ table td {
143
 
144
  @mixin full-screen {
145
  height: 100%;
146
- position: absolute;
147
  top: 0;
148
  left: 0;
149
  width: 100%;
150
  }
 
 
 
 
 
151
 
152
- #pte-loading {
153
- $opacity: 80;
154
- $opacity_percent: $opacity/100;
 
 
155
  @include full-screen;
156
- #pte-loading-opaque {
157
- background-color: #000;
158
- @include full-screen;
159
- opacity: $opacity_percent;
160
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + $opacity + ")";
161
- filter: alpha(opacity=$opacity);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  #pte-loading-spinner {
164
- position: relative;
165
  top: 50%;
166
  width: 200px;
167
- margin: 0 auto;
168
- text-align: center;
169
  }
170
  }
171
 
@@ -180,7 +266,7 @@ table td {
180
 
181
  #stage2, #stage3 {
182
  display: none;
183
- left: $width * 2;
184
  width: $width;
185
  }
186
 
35
  }
36
  }
37
 
38
+ h1 {
39
  color: #2386e2;
40
  font-family: 'Amaranth', serif;
41
  font-style: italic;
116
  vertical-align: middle;
117
  padding: 15px 0;
118
  }
119
+ .col1 {
120
+ $c1width: 30px;
121
+ max-width: $c1width;
122
+ text-align: center;
123
+ width: $c1width;
124
+ input {
125
+ margin: 0 auto;
126
+ }
127
+ }
128
  /*.col2 { */
129
  /* padding-right: 20px; */
130
  /*}*/
149
 
150
  @mixin full-screen {
151
  height: 100%;
152
+ position: fixed;
153
  top: 0;
154
  left: 0;
155
  width: 100%;
156
  }
157
+ @mixin full-screen-embedded {
158
+ position: relative;
159
+ margin: 0 auto;
160
+ text-align: center;
161
+ }
162
 
163
+ /* Used by #pte-log and #pte-loading */
164
+ $opacity: 80;
165
+ $opacity_percent: $opacity/100;
166
+ .pte-opaque {
167
+ background-color: #000;
168
  @include full-screen;
169
+ opacity: $opacity_percent;
170
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + $opacity + ")";
171
+ filter: alpha(opacity=$opacity);
172
+ z-index: 0;
173
+ }
174
+
175
+ @mixin gradient($start, $end){
176
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($start), to($end));
177
+ background-image: -webkit-linear-gradient(top, $start, $end);
178
+ background-image: -moz-linear-gradient(top, $start, $end);
179
+ background-image: -ms-linear-gradient(top, $start, $end);
180
+ background-image: -o-linear-gradient(top, $start, $end);
181
+ }
182
+
183
+ #pte-log {
184
+ @include full-screen;
185
+ display: none;
186
+ z-index: 1300;
187
+ color: #ddd;
188
+ a { color: white; }
189
+ #pte-log-container {
190
+ @include full-screen-embedded;
191
+ top: 5%;
192
+ height: 80%;
193
+ }
194
+ $link-gradient-start: #303080;
195
+ $link-gradient-end: #00007F;
196
+ a.button {
197
+ @include gradient($link-gradient-start, $link-gradient-end);
198
+ /*border: 2px solid white;*/
199
+ border-radius: 0 0 7px 7px;
200
+ -moz-border-radius: 0 0 7px 7px;
201
+ -webkit-border-radius: 0 0 7px 7px;
202
+ padding: 0 10px 3px 10px;
203
+ text-decoration: none;
204
+ }
205
+ a.button:hover { @include gradient($link-gradient-end, $link-gradient-start); }
206
+ p {
207
+ line-height: 1.2em;
208
+ margin: 0 auto 20px;
209
+ text-align: left;
210
+ width: 90%;
211
+ }
212
+ textarea {
213
+ height: 400px;
214
+ width: 90%;
215
  }
216
+ }
217
+
218
+ $log-gradient-start: #FF0000;
219
+ $log-gradient-end: #CD0000;
220
+
221
+ a#pte-log-button.show-log-messages {
222
+ background-color: $log-gradient-end;
223
+ border-radius: 0 0 7px 7px;
224
+ -moz-border-radius: 0 0 7px 7px;
225
+ -webkit-border-radius: 0 0 7px 7px;
226
+ top: 0;
227
+ right: 20px;
228
+ display: block;
229
+ /*left: 282px;*/
230
+ padding: 3px 5px 5px 5px;
231
+ position: fixed;
232
+ text-align: center;
233
+ color: white;
234
+ font-size: 0.9em;
235
+ font-style: italic;
236
+ text-decoration: none;
237
+ text-shadow: none;
238
+ @include gradient($log-gradient-start, $log-gradient-end);
239
+ }
240
+ a#pte-log-button.show-log-messages:hover {
241
+ @include gradient($log-gradient-end, $log-gradient-start);
242
+ }
243
+ /* FIXES IE to bottom of screen */
244
+ * html #pte-log-button.show-log-messages {
245
+ position:absolute;
246
+ top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
247
+ }
248
+
249
+ #pte-loading {
250
+ @include full-screen;
251
  #pte-loading-spinner {
252
+ @include full-screen-embedded;
253
  top: 50%;
254
  width: 200px;
 
 
255
  }
256
  }
257
 
266
 
267
  #stage2, #stage3 {
268
  display: none;
269
+ /*left: $width * 2;*/
270
  width: $width;
271
  }
272
 
html/pte.html DELETED
@@ -1,141 +0,0 @@
1
- <!DOCTYPE HTML>
2
- <html>
3
- <head>
4
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
5
- <title>PTE</title>
6
- <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Amaranth:regular,italic,bold|Puritan|PT+Serif">
7
- <style type="text/css" media="screen">
8
- </style>
9
- <?php wp_print_styles(); ?>
10
- <?php wp_print_scripts(); ?>
11
- <script type="text/javascript" charset="utf-8">
12
- ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
13
- thumbnail_info = <?php print(json_encode($size_information)); ?>;
14
- jQuery(function(){ pte.editor(); });<?php
15
- if ( PTE_DEBUG ) {
16
- print( "debug_enabled = true;" );
17
- } ?>
18
- </script>
19
- </head>
20
- <body>
21
- <div id="stage1" class="stage">
22
- <h1 class="stage-header">Post Thumbnail Editor - Step 1</h1>
23
- <?php global $pte_errors;
24
- if ( isset( $pte_errors ) && count( $pte_errors ) > 0 ): ?>
25
- <script type="text/javascript" charset="utf-8">
26
- var pte_errors = <?php print( json_encode( $pte_errors ) ); ?>
27
- log(pte_errors);
28
- </script>
29
- <!-- <div id="error"><ul><?php
30
- //print_r($pte_errors);
31
- foreach ( $pte_errors as $error_message ){
32
- print( "<li>${error_message}</li>\r\n" );
33
- }
34
- ?></ul></div> -->
35
- <?php endif; ?>
36
- <div id="pte-image">
37
- <input type="hidden" id="pte-sizer" value="<?php echo $sizer; ?>" />
38
- <input type="hidden" id="pte-post-id" value="<?php echo $id; ?>" />
39
- <img id="pte-preview" src="<?php echo admin_url('admin-ajax.php'); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" />
40
- <div id="pte-buttons" class="buttons">
41
- <button disabled id="pte-submit">Create Thumbnails</button>
42
- </div>
43
-
44
- </div>
45
- <div id="pte-sizes-container">
46
- <div style="font-size:smaller;">
47
- Choose the images/thumbnails that you want to edit:<br>
48
- </div>
49
- <div id="pte-selectors">
50
- Select: <a class="all" href="all">All</a> | <a class="none" href="none">None</a>
51
- </div>
52
- <div id="pte-sizes">
53
- <table>
54
- <?php foreach ( $size_information as $size_label => $size_array ): ?>
55
- <tr>
56
- <td class="col1">
57
- <input class="pte-size" id="pte-size-<?php print $size_label; ?>" type="checkbox" name="pte-size[]" value="<?php print $size_label; ?>">
58
- </td>
59
- <td class="col2">
60
- <div class="pte-size-label"><?php print $size_label; ?> <?php
61
- print("(${size_array['width']}x${size_array['height']})");
62
- print("<br><span class='actual'>Current image: "
63
- . $size_array['current']['width'] . "x"
64
- . $size_array['current']['height'] . "</span>");
65
- ?></div>
66
- <img src="<?php print( $size_array['current']['url'] . "?" . mt_rand() ); ?>"/><br/>
67
- </td>
68
- </tr>
69
- <?php endforeach; ?>
70
- </table>
71
- </div>
72
- </div>
73
-
74
- </div>
75
- <div id="stage2" class="stage">
76
- </div>
77
- <script id="stage2template" type="text/x-jquery-tmpl">
78
- <a onclick="goBack(); return false;" href="#back" class="stage-navigation"
79
- alt="Return to Step 1" title="Return to Step 1">
80
- <img src="<?php print( PTE_PLUGINURL . "images/back.gif" ); ?>"/> Back</a>
81
- <h1 class="stage-header"> Post Thumbnail Editor - Step 2</h1>
82
- {{if $data['error']}}
83
- <div id="error">We noticed some potential issues:
84
- <ul>
85
- {{each $data['error']}}<li>${$value}</li>{{/each}}
86
- </ul>
87
- </div>
88
- {{/if}}
89
- <div id="pte-stage2-selectors">
90
- Select the images you want to keep: <a class="all" href="all">All</a> | <a class="none" href="none">None</a>
91
- </div>
92
- <input type="hidden" name="pte-nonce" value="${$data['pte-nonce']}" id="pte-nonce" />
93
- <input type="hidden" name="pte-delete-nonce" value="${$data['pte-delete-nonce']}" id="pte-delete-nonce" />
94
- <table>
95
- {{each $data.thumbnails}}
96
- <tr class="selected">
97
- <td><input checked class="pte-confirm" type="checkbox" name="pte_confirm[]" value="${$index}"/></td>
98
- <td class="col2">
99
- <div class="pte-size-label">${$index}</div>
100
- <img src="${$value.url}?${randomness()}"/>
101
- <input id="pte-${$index}-file" type="hidden" value="${$value.file}"/>
102
- </td>
103
- </tr>
104
- {{/each}}
105
- </table>
106
- <div id="stage2-buttons">
107
- <button id="pte-confirm">
108
- Okay, these look good...
109
- </button>&nbsp;
110
- <a href="#back" id="pte-cancel"
111
- onclick="goBack(); return false;">
112
- I'd rather start over...
113
- </a>
114
- </a>
115
- </script>
116
- <div id="stage3" class="stage">
117
- </div>
118
- <script id="stage3template" type="text/x-jquery-tmpl">
119
- <h1 class="stage-header"> Post Thumbnail Editor</h1>
120
- {{if $data['success']}}
121
- <div id="success">
122
- <p>Images were created successfully.</p>
123
- <p>Click <a href="" onclick="window.location.reload();">here</a> to modify another thumbnail.</p>
124
- </div>
125
- {{if $data['error']}}
126
- <div id="error">We noticed some potential issues however:
127
- <ul>
128
- {{each $data['error']}}<li>${$value}</li>{{/each}}
129
- </ul>
130
- </div>
131
- {{/if}}
132
- {{/if}}
133
- </script>
134
- <div id="pte-loading">
135
- <div id="pte-loading-opaque"></div>
136
- <div id="pte-loading-spinner">
137
- <img src="<?php print PTE_PLUGINURL; ?>images/loading.gif" alt="Please wait" />
138
- </div></div>
139
- <div style='clear:both'></div>
140
- </body>
141
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
html/pte.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
5
+ <title>PTE</title>
6
+ <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Amaranth:regular,italic,bold|Puritan|PT+Serif">
7
+ <style type="text/css" media="screen">
8
+ </style>
9
+ <?php wp_print_styles(); ?>
10
+ <?php wp_print_scripts(); ?>
11
+ <script type="text/javascript" charset="utf-8">
12
+ var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
13
+ var thumbnail_info = <?php print( json_encode( $size_information ) ); ?>;
14
+ var options = <?php print( json_encode( $options ) ); ?>;
15
+ jQuery(function(){ pte.editor(); });
16
+ </script>
17
+ </head>
18
+ <body>
19
+ <div id="stage1" class="stage">
20
+ <h1 class="stage-header"><?php echo( __( 'Post Thumbnail Editor - Step 1', PTE_DOMAIN ) ); ?></h1>
21
+ <?php if ( $options['pte_debug'] ): ?>
22
+ <script type="text/javascript" charset="utf-8">
23
+ var pte_errors = <?php print( json_encode( array( 'log' => $logger->get_logs() ) ) ); ?>;
24
+ log( "===== STARTUP PHP MESSAGES =====");
25
+ pte.parseServerLog(pte_errors.log);
26
+ </script>
27
+ <?php endif; ?>
28
+ <div id="pte-image">
29
+ <input type="hidden" id="pte-sizer" value="<?php echo $sizer; ?>" />
30
+ <input type="hidden" id="pte-post-id" value="<?php echo $id; ?>" />
31
+ <img id="pte-preview" src="<?php echo admin_url('admin-ajax.php'); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" />
32
+ <div id="pte-buttons" class="buttons">
33
+ <button disabled id="pte-submit"><?php _e( 'Create Thumbnails', PTE_DOMAIN ); ?></button>
34
+ </div>
35
+
36
+ </div>
37
+ <div id="pte-sizes-container">
38
+ <div style="font-size:smaller;">
39
+ <?php _e( 'Choose the images/thumbnails that you want to edit:', PTE_DOMAIN ); ?><br>
40
+ </div>
41
+ <div id="pte-selectors">
42
+ <?php printf( __( 'Select: %1$sAll%2$s | %3$sNone%4$s', PTE_DOMAIN )
43
+ , '<a class="all" href="all">'
44
+ , '</a>'
45
+ , '<a class="none" href="none">'
46
+ , '</a>'
47
+ ); ?>
48
+ </div>
49
+ <div id="pte-sizes">
50
+ <table>
51
+ <?php foreach ( $size_information as $size_label => $size_array ): ?>
52
+ <tr>
53
+ <td class="col1">
54
+ <input class="pte-size" id="pte-size-<?php print $size_label; ?>" type="checkbox" name="pte-size[]" value="<?php print $size_label; ?>">
55
+ </td>
56
+ <td class="col2">
57
+ <div class="pte-size-label"><?php print $size_label; ?> <?php
58
+ print("(${size_array['width']}x${size_array['height']})");
59
+ print("<br><span class='actual'>" . __( 'Current image:', PTE_DOMAIN )
60
+ . $size_array['current']['width'] . "x"
61
+ . $size_array['current']['height'] . "</span>");
62
+ ?></div>
63
+ <img src="<?php print( $size_array['current']['url'] . "?" . mt_rand() ); ?>"/><br/>
64
+ </td>
65
+ </tr>
66
+ <?php endforeach; ?>
67
+ </table>
68
+ </div>
69
+ </div>
70
+
71
+ </div>
72
+ <div id="stage2" class="stage">
73
+ </div>
74
+ <script id="stage2template" type="text/x-jquery-tmpl">
75
+ <a onclick="goBack(); return false;" href="#back" class="stage-navigation"
76
+ alt="Return to Step 1" title="Return to Step 1">
77
+ <img src="<?php print( PTE_PLUGINURL . "images/back.gif" ); ?>"/> <?php
78
+ _e( 'Back', PTE_DOMAIN );
79
+ ?></a>
80
+ <h1 class="stage-header"><?php echo( __( 'Post Thumbnail Editor - Step 2', PTE_DOMAIN ) ); ?></h1>
81
+ {{if $data['error']}}
82
+ <div id="error"><?php
83
+ _e( 'We noticed some potential issues:', PTE_DOMAIN );
84
+ echo( "&nbsp;" );
85
+ if ( $options['pte_debug'] ){
86
+ printf( __( 'View %1$slogs%2$s for further information', PTE_DOMAIN )
87
+ , '<a href="" class="show-log-messages">'
88
+ , '</a>');
89
+ }
90
+ else {
91
+ printf( __( '%1$sEnable debugging%2$s for additional information', PTE_DOMAIN )
92
+ , '<a href="options-general.php?page=pte">'
93
+ , '</a>');
94
+ } ?>
95
+ <ul>
96
+ {{each $data['error']}}<li>${$value}</li>{{/each}}
97
+ </ul>
98
+ </div>
99
+ {{/if}}
100
+ <div id="pte-stage2-selectors">
101
+ <?php printf( __( 'Select the images you want to keep: %1$sAll%2$s | %3$sNone%4$s', PTE_DOMAIN )
102
+ , '<a class="all" href="all">'
103
+ , '</a>'
104
+ , '<a class="none" href="none">'
105
+ , '</a>'
106
+ ); ?>
107
+ </div>
108
+ <input type="hidden" name="pte-nonce" value="${$data['pte-nonce']}" id="pte-nonce" />
109
+ <input type="hidden" name="pte-delete-nonce" value="${$data['pte-delete-nonce']}" id="pte-delete-nonce" />
110
+ <table>
111
+ {{each $data.thumbnails}}
112
+ <tr class="selected">
113
+ <td class="col1"><input checked class="pte-confirm" type="checkbox" name="pte_confirm[]" value="${$index}"/></td>
114
+ <td class="col2">
115
+ <div class="pte-size-label">${$index}</div>
116
+ <img src="${$value.url}?${randomness()}"/>
117
+ <input id="pte-${$index}-file" type="hidden" value="${$value.file}"/>
118
+ </td>
119
+ </tr>
120
+ {{/each}}
121
+ </table>
122
+ <div id="stage2-buttons">
123
+ <button id="pte-confirm">
124
+ <?php _e( 'Okay, these look good...', PTE_DOMAIN ); ?>
125
+ </button>&nbsp;
126
+ <a href="#back" id="pte-cancel"
127
+ onclick="goBack(); return false;">
128
+ <?php _e( 'I\'d rather start over...', PTE_DOMAIN ); ?>
129
+ </a>
130
+ </a>
131
+ </script>
132
+ <div id="stage3" class="stage">
133
+ </div>
134
+ <script id="stage3template" type="text/x-jquery-tmpl">
135
+ <h1 class="stage-header"><?php _e( 'Post Thumbnail Editor', PTE_DOMAIN ); ?></h1>
136
+ {{if $data['success']}}
137
+ <div id="success">
138
+ <p><?php _e( 'Images were created successfully.', PTE_DOMAIN ); ?></p>
139
+ <p><?php
140
+ printf( __( 'Click %1$shere%2$s to modify another thumbnail.' , PTE_DOMAIN ), '<a href="" onclick="window.location.reload();">', '</a>' );
141
+ ?></p>
142
+ </div>
143
+ {{if $data['error']}}
144
+ <div id="error"><?php _e( 'We noticed some potential issues:', PTE_DOMAIN ); ?>
145
+ <ul>
146
+ {{each $data['error']}}<li>${$value}</li>{{/each}}
147
+ </ul>
148
+ </div>
149
+ {{/if}}
150
+ {{/if}}
151
+ </script>
152
+ <div id="pte-loading">
153
+ <div class="pte-opaque"></div>
154
+ <div id="pte-loading-spinner">
155
+ <img src="<?php print PTE_PLUGINURL; ?>images/loading.gif" alt="<?php
156
+ _e( 'Please wait', PTE_DOMAIN ); ?>" />
157
+ </div></div>
158
+ <?php if ( $options['pte_debug'] ): ?>
159
+ <a id="pte-log-button" class="show-log-messages" href="" alt="<?php
160
+ _e( 'Click here to show application logs', PTE_DOMAIN );
161
+ ?>" title="Click here to show application logs"><?php
162
+ _e( 'Debug', PTE_DOMAIN ); ?></a>
163
+ <div id="pte-log">
164
+ <div class="pte-opaque"></div>
165
+ <div id="pte-log-container">
166
+ <div id="pte-log-messages">
167
+ <p><?php printf( __( 'If you are having any issues with this plugin, create a problem report on %1$sgithub%2$s or %3$swordpress.org%4$s so that I can look into it. Copy these log statements and include some information about what you were trying to do, the expected output, and the output you got (the more information the better). Thanks and good luck!', PTE_DOMAIN )
168
+ , '<a href="https://github.com/sewpafly/post-thumbnail-editor/issues/new">'
169
+ , '</a>'
170
+ , '<a href="http://wordpress.org/tags/post-thumbnail-editor?forum_id=10#postform">'
171
+ , '</a>'
172
+ ); ?></p>
173
+ <textarea name="logs"></textarea>
174
+ <!--<textarea name="logs" rows="8" cols="40"></textarea>-->
175
+ </div>
176
+ <div id="pte-log-tools">
177
+ <?php
178
+ $testurl = admin_url('admin-ajax.php') . "?action=pte_ajax&pte-action=test&id=${id}";
179
+ ?>
180
+ <!--<a id="clipboard" href="">Copy to Clipboard</a>&nbsp;-->
181
+ <a class="button" id="pastebin" href=""><?php _e( 'Send to Pastebin', PTE_DOMAIN ); ?></a>&nbsp;
182
+ <a class="button" id="clear-log" href=""><?php _e( 'Clear Messages', PTE_DOMAIN ); ?></a>&nbsp;
183
+ <a class="button" id="test" target="ptetest" href="<?php
184
+ echo( $testurl ); ?>"><?php
185
+ _e( 'Run Tests', PTE_DOMAIN ); ?></a>&nbsp;
186
+ <a class="button" id="close-log" href=""><?php _e( 'Close', PTE_DOMAIN ); ?></a>
187
+ </div>
188
+ </div>
189
+ </div>
190
+ <?php endif; ?>
191
+ <div style='clear:both'></div>
192
+ </body>
193
+ </html>
html/test.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <html>
4
+ <head>
5
+ <title>QUnit Tests</title>
6
+ <script src="http://code.jquery.com/jquery-latest.js"></script>
7
+ <link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" />
8
+ <script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
9
+
10
+ <script type="text/javascript">
11
+ //set jquery to no conflict, so we do not have a problem with the version from in the page
12
+ var $$ = jQuery.noConflict(true);
13
+ var $ = jQuery = null; //we will be using the normal jquery vars soon enough
14
+
15
+ </script>
16
+
17
+ <script type="text/javascript" src="<?php echo( PTE_PLUGINURL . "js/stage2.js" ); ?>"></script>
18
+ <script type="text/javascript" src="<?php echo( PTE_PLUGINURL . "js/stage1.js" ); ?>"></script>
19
+
20
+
21
+ </head>
22
+ <body>
23
+ <h1 id="qunit-header">QUnit Tests</h1>
24
+
25
+ <div style="width: 100%; height: 550px; float: left">
26
+ <iframe style="width: 100%; height: 100%;" id="pteFrame"></iframe>
27
+ </div>
28
+
29
+ <h2 id="qunit-banner"></h2>
30
+ <div id="qunit-testrunner-toolbar"></div>
31
+ <h2 id="qunit-userAgent"></h2>
32
+ <ol id="qunit-tests"></ol>
33
+ <div id="qunit-fixture"></div>
34
+ </body>
35
+ <script>
36
+ $$('#pteFrame').load(function(){
37
+ udf = function(a){ return a; }();
38
+ //grab jQuery from inside the document
39
+ $ = jQuery = window.frames[0].jQuery;
40
+
41
+ //turn off async so tests will wait for ajax results
42
+ //$.ajaxSetup({ async: false });
43
+
44
+ //turn off animations so they do not bork tests
45
+ //$.fx.off = true;
46
+
47
+ //test("a basic test example", function() {
48
+ // ok( true, "this test is fine" );
49
+ // var value = "hello";
50
+ // equal( value, "hello", "We expect value to be hello" );
51
+ //});
52
+ var pte = window.frames[0].pte;
53
+ stageOne(pte);
54
+ /* TODO: Regression Going back and forth between stages 1 & 2 */
55
+ // Call stage2
56
+ // Redo tests for stage1 and 2
57
+ });
58
+
59
+ $$('#pteFrame').attr('src', '<?php echo( $testurl ); ?>');
60
+
61
+ </script>
62
+
63
+ </html>
i18n/post-thumbnail-editor-fr_FR.mo ADDED
Binary file
i18n/post-thumbnail-editor-fr_FR.po ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2010 Post Thumbnail Editor
2
+ # This file is distributed under the same license as the Post Thumbnail Editor package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Post Thumbnail Editor 1.0.1-alpha2\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/post-thumbnail-editor\n"
7
+ "POT-Creation-Date: 2011-09-06 15:57:59+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2011-08-29 15:53+0100\n"
12
+ "Last-Translator: Li-An <lian00@gmail.com>\n"
13
+ "Language-Team: Li-An <lian00@gmail.com>\n"
14
+ "X-Poedit-Language: French\n"
15
+ "X-Poedit-Country: FRANCE\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+
18
+ #: html/pte.php:20
19
+ msgid "Post Thumbnail Editor - Step 1"
20
+ msgstr "Post Thumbnail Editor - Étape 1"
21
+
22
+ #: html/pte.php:33
23
+ msgid "Create Thumbnails"
24
+ msgstr "Créer les miniatures"
25
+
26
+ #: html/pte.php:39
27
+ msgid "Choose the images/thumbnails that you want to edit:"
28
+ msgstr "Choisissez les images/miniatures que vous désirez éditer:"
29
+
30
+ #: html/pte.php:42
31
+ msgid "Select: %1$sAll%2$s | %3$sNone%4$s"
32
+ msgstr "Sélectionner: %1$sToutes%2$s | %3$sAucune%4$s"
33
+
34
+ #: html/pte.php:59
35
+ msgid "Current image:"
36
+ msgstr "Image actuelle:"
37
+
38
+ #: html/pte.php:78
39
+ msgid "Back"
40
+ msgstr "Revenir en arrière"
41
+
42
+ #: html/pte.php:80
43
+ msgid "Post Thumbnail Editor - Step 2"
44
+ msgstr "Post Thumbnail Editor - Étape 2"
45
+
46
+ #: html/pte.php:83 html/pte.php:144
47
+ msgid "We noticed some potential issues:"
48
+ msgstr "Nous avons noté d'éventuels problèmes:"
49
+
50
+ #: html/pte.php:86
51
+ msgid "View %1$slogs%2$s for further information"
52
+ msgstr ""
53
+
54
+ #: html/pte.php:91
55
+ msgid "%1$sEnable debugging%2$s for additional information"
56
+ msgstr ""
57
+
58
+ #: html/pte.php:101
59
+ msgid "Select the images you want to keep: %1$sAll%2$s | %3$sNone%4$s"
60
+ msgstr "Sélectionner les images que vous désirez conserver: %1$sToutes%2$s | %3$sAucune%4$s"
61
+
62
+ #: html/pte.php:124
63
+ msgid "Okay, these look good..."
64
+ msgstr "Très bien, cela semble correct..."
65
+
66
+ #: html/pte.php:128
67
+ msgid "I'd rather start over..."
68
+ msgstr "Je ferai mieux de recommencer..."
69
+
70
+ #. #-#-#-#-# post-thumbnail-editor.pot (Post Thumbnail Editor 1.0.1-alpha2) #-#-#-#-#
71
+ #. Plugin Name of the plugin/theme
72
+ #: html/pte.php:135 post-thumbnail-editor.php:113
73
+ #: post-thumbnail-editor.php:178 post-thumbnail-editor.php:179
74
+ #: php/options.php:64
75
+ msgid "Post Thumbnail Editor"
76
+ msgstr "Post Thumbnail Editor"
77
+
78
+ #: html/pte.php:138
79
+ msgid "Images were created successfully."
80
+ msgstr "Les images ont été créées avec succès."
81
+
82
+ #: html/pte.php:140
83
+ msgid "Click %1$shere%2$s to modify another thumbnail."
84
+ msgstr "Cliquez %1$sici%2$s pour modifier une autre miniature."
85
+
86
+ #: html/pte.php:156
87
+ msgid "Please wait"
88
+ msgstr "Veuillez attendre"
89
+
90
+ #: html/pte.php:160
91
+ msgid "Click here to show application logs"
92
+ msgstr "Cliquez ici pour montrer les logs de l'application"
93
+
94
+ #: html/pte.php:162 php/options.php:30
95
+ msgid "Debug"
96
+ msgstr "Debugger"
97
+
98
+ #: html/pte.php:167
99
+ msgid ""
100
+ "If you are having any issues with this plugin, create a problem report on "
101
+ "%1$sgithub%2$s or %3$swordpress.org%4$s so that I can look into it. Copy "
102
+ "these log statements and include some information about what you were trying "
103
+ msgstr "Si vous rencontrer des problèmes avec ce plugin, veuillez créer un rapport de problème à %1$sgithub%2$s ou %3$swordpress.org%4$s afin que je puisse le consulter. Veuillez copier ces états de log et inclure les informations sur ce que vous étiez en train de faire, ce que vous espériez obtenir, et ce qui en est résulté (plus il y aura d'informations, mieux ce sera). Merci et bonne chance !"
104
+
105
+ #: html/pte.php:181
106
+ msgid "Send to Pastebin"
107
+ msgstr "Envoyer à Pastebin"
108
+
109
+ #: html/pte.php:182
110
+ msgid "Clear Messages"
111
+ msgstr "Effacer les messages"
112
+
113
+ #: html/pte.php:185
114
+ msgid "Run Tests"
115
+ msgstr ""
116
+
117
+ #: html/pte.php:186
118
+ msgid "Close"
119
+ msgstr "Fermer"
120
+
121
+ #: post-thumbnail-editor.php:167
122
+ msgid "Edit Thumbnails"
123
+ msgstr "Éditer les miniatures"
124
+
125
+ #: post-thumbnail-editor.php:168 php/options.php:51
126
+ msgid "Thumbnails"
127
+ msgstr "Miniatures"
128
+
129
+ #: php/log.php:15
130
+ msgid "ERROR"
131
+ msgstr "ERREUR"
132
+
133
+ #: php/log.php:18
134
+ msgid "WARNING"
135
+ msgstr "AVERTISSEMENT"
136
+
137
+ #: php/log.php:21
138
+ msgid "DEBUG"
139
+ msgstr "DEBUGGER"
140
+
141
+ #: php/log.php:99
142
+ msgid "ERROR Logging Message: %s"
143
+ msgstr "Message d'ERREUR de logging: %s"
144
+
145
+ #: php/options.php:8
146
+ msgid "These site-wide settings can only be changed by an administrator"
147
+ msgstr "Ces réglages communs au site ne peuvent être changés que par un administrateur"
148
+
149
+ #: php/options.php:19
150
+ msgid "User Options"
151
+ msgstr "Options de l'utilisateur"
152
+
153
+ #: php/options.php:24
154
+ msgid "Thickbox dimensions"
155
+ msgstr "Dimensions de la Thickbox"
156
+
157
+ #: php/options.php:36
158
+ msgid "Reset to defaults"
159
+ msgstr "Remettre aux réglages par défaut"
160
+
161
+ #: php/options.php:47
162
+ msgid "Site Options"
163
+ msgstr "Options de site"
164
+
165
+ #: php/options.php:72
166
+ msgid "Save Changes"
167
+ msgstr "Sauvegarder les modifications"
168
+
169
+ #: php/options.php:86
170
+ msgid "Only users with the 'manage_options' capability may make changes to these settings."
171
+ msgstr "Seuls les utilisateurs avec la capacité 'manage_options' (gestion d'options) peuvent modifier ces réglages."
172
+
173
+ #: php/options.php:118
174
+ msgid "Thickbox width must be at least 750 pixels."
175
+ msgstr "La largeur de la fenêtre Thickbox doit mesurer au moins de 750 pixels."
176
+
177
+ #: php/options.php:128
178
+ msgid "Thickbox height must be greater than 550 pixels."
179
+ msgstr "La hauteur de la fenêtre Thickbox doit mesurer plus de 550 pixels."
180
+
181
+ #: php/options.php:142
182
+ msgid "Width:"
183
+ msgstr "Largeur:"
184
+
185
+ #: php/options.php:146
186
+ msgid "Set this to a value greater than 750."
187
+ msgstr "Définissez une valeur plus grande que 750."
188
+
189
+ #: php/options.php:153
190
+ msgid "Height:"
191
+ msgstr "Hauteur:"
192
+
193
+ #: php/options.php:157
194
+ msgid "Set this to a value greater than 550."
195
+ msgstr "Définissez une valeur supérieure à 550."
196
+
197
+ #: php/options.php:169
198
+ msgid "Enable debugging"
199
+ msgstr "Activer le debuggage"
200
+
201
+ #: php/options.php:178
202
+ msgid "Reset User Options"
203
+ msgstr "Réinitialiser les options d'utilisateur"
204
+
205
+ #: php/options.php:204
206
+ msgid "Post Thumbnail"
207
+ msgstr "Miniature de billet"
208
+
209
+ #: php/options.php:205
210
+ msgid "Hidden"
211
+ msgstr "Caché"
212
+
213
+ #: php/functions.php:257
214
+ msgid "Sorry, there was a problem trying to send to pastebin"
215
+ msgstr "Désolé, il y a eu un problème lors de l'envoi à Pastebin"
216
+
217
+ #: php/functions.php:258
218
+ msgid "PASTEBIN URL:"
219
+ msgstr "URL de Pastebin:"
220
+
221
+ #: php/functions.php:259
222
+ msgid "Disabling aspect ratio"
223
+ msgstr "Trop de différents ratios de taille. Désactivation."
224
+
225
+ #. Plugin URI of the plugin/theme
226
+ msgid "http://wordpress.org/extend/plugins/post-thumbnail-editor/"
227
+ msgstr "http://wordpress.org/extend/plugins/post-thumbnail-editor/"
228
+
229
+ #. Description of the plugin/theme
230
+ msgid "Individually manage your post thumbnails"
231
+ msgstr "Gérez individuellement vos miniatures de billet"
232
+
233
+ #. Author of the plugin/theme
234
+ msgid "sewpafly"
235
+ msgstr "sewpafly"
236
+
237
+ #. Author URI of the plugin/theme
238
+ msgid "http://sewpafly.github.com/post-thumbnail-editor"
239
+ msgstr "http://sewpafly.github.com/post-thumbnail-editor"
240
+
i18n/post-thumbnail-editor.pot ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2010 Post Thumbnail Editor
2
+ # This file is distributed under the same license as the Post Thumbnail Editor package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Post Thumbnail Editor 1.0.1-alpha2\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/post-thumbnail-editor\n"
7
+ "POT-Creation-Date: 2011-09-06 15:57:59+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+
15
+ #: html/pte.php:20
16
+ msgid "Post Thumbnail Editor - Step 1"
17
+ msgstr ""
18
+
19
+ #: html/pte.php:33
20
+ msgid "Create Thumbnails"
21
+ msgstr ""
22
+
23
+ #: html/pte.php:39
24
+ msgid "Choose the images/thumbnails that you want to edit:"
25
+ msgstr ""
26
+
27
+ #: html/pte.php:42
28
+ msgid "Select: %1$sAll%2$s | %3$sNone%4$s"
29
+ msgstr ""
30
+
31
+ #: html/pte.php:59
32
+ msgid "Current image:"
33
+ msgstr ""
34
+
35
+ #: html/pte.php:78
36
+ msgid "Back"
37
+ msgstr ""
38
+
39
+ #: html/pte.php:80
40
+ msgid "Post Thumbnail Editor - Step 2"
41
+ msgstr ""
42
+
43
+ #: html/pte.php:83 html/pte.php:144
44
+ msgid "We noticed some potential issues:"
45
+ msgstr ""
46
+
47
+ #: html/pte.php:86
48
+ msgid "View %1$slogs%2$s for further information"
49
+ msgstr ""
50
+
51
+ #: html/pte.php:91
52
+ msgid "%1$sEnable debugging%2$s for additional information"
53
+ msgstr ""
54
+
55
+ #: html/pte.php:101
56
+ msgid "Select the images you want to keep: %1$sAll%2$s | %3$sNone%4$s"
57
+ msgstr ""
58
+
59
+ #: html/pte.php:124
60
+ msgid "Okay, these look good..."
61
+ msgstr ""
62
+
63
+ #: html/pte.php:128
64
+ msgid "I'd rather start over..."
65
+ msgstr ""
66
+
67
+ #. #-#-#-#-# post-thumbnail-editor.pot (Post Thumbnail Editor 1.0.1-alpha2) #-#-#-#-#
68
+ #. Plugin Name of the plugin/theme
69
+ #: html/pte.php:135 post-thumbnail-editor.php:113
70
+ #: post-thumbnail-editor.php:178 post-thumbnail-editor.php:179
71
+ #: php/options.php:64
72
+ msgid "Post Thumbnail Editor"
73
+ msgstr ""
74
+
75
+ #: html/pte.php:138
76
+ msgid "Images were created successfully."
77
+ msgstr ""
78
+
79
+ #: html/pte.php:140
80
+ msgid "Click %1$shere%2$s to modify another thumbnail."
81
+ msgstr ""
82
+
83
+ #: html/pte.php:156
84
+ msgid "Please wait"
85
+ msgstr ""
86
+
87
+ #: html/pte.php:160
88
+ msgid "Click here to show application logs"
89
+ msgstr ""
90
+
91
+ #: html/pte.php:162 php/options.php:30
92
+ msgid "Debug"
93
+ msgstr ""
94
+
95
+ #: html/pte.php:167
96
+ msgid ""
97
+ "If you are having any issues with this plugin, create a problem report on "
98
+ "%1$sgithub%2$s or %3$swordpress.org%4$s so that I can look into it. Copy "
99
+ "these log statements and include some information about what you were trying "
100
+ "to do, the expected output, and the output you got (the more information the "
101
+ "better). Thanks and good luck!"
102
+ msgstr ""
103
+
104
+ #: html/pte.php:181
105
+ msgid "Send to Pastebin"
106
+ msgstr ""
107
+
108
+ #: html/pte.php:182
109
+ msgid "Clear Messages"
110
+ msgstr ""
111
+
112
+ #: html/pte.php:185
113
+ msgid "Run Tests"
114
+ msgstr ""
115
+
116
+ #: html/pte.php:186
117
+ msgid "Close"
118
+ msgstr ""
119
+
120
+ #: post-thumbnail-editor.php:167
121
+ msgid "Edit Thumbnails"
122
+ msgstr ""
123
+
124
+ #: post-thumbnail-editor.php:168 php/options.php:51
125
+ msgid "Thumbnails"
126
+ msgstr ""
127
+
128
+ #: php/log.php:15
129
+ msgid "ERROR"
130
+ msgstr ""
131
+
132
+ #: php/log.php:18
133
+ msgid "WARNING"
134
+ msgstr ""
135
+
136
+ #: php/log.php:21
137
+ msgid "DEBUG"
138
+ msgstr ""
139
+
140
+ #: php/log.php:99
141
+ msgid "ERROR Logging Message: %s"
142
+ msgstr ""
143
+
144
+ #: php/options.php:8
145
+ msgid "These site-wide settings can only be changed by an administrator"
146
+ msgstr ""
147
+
148
+ #: php/options.php:19
149
+ msgid "User Options"
150
+ msgstr ""
151
+
152
+ #: php/options.php:24
153
+ msgid "Thickbox dimensions"
154
+ msgstr ""
155
+
156
+ #: php/options.php:36
157
+ msgid "Reset to defaults"
158
+ msgstr ""
159
+
160
+ #: php/options.php:47
161
+ msgid "Site Options"
162
+ msgstr ""
163
+
164
+ #: php/options.php:72
165
+ msgid "Save Changes"
166
+ msgstr ""
167
+
168
+ #: php/options.php:86
169
+ msgid ""
170
+ "Only users with the 'manage_options' capability may make changes to these "
171
+ "settings."
172
+ msgstr ""
173
+
174
+ #: php/options.php:118
175
+ msgid "Thickbox width must be at least 750 pixels."
176
+ msgstr ""
177
+
178
+ #: php/options.php:128
179
+ msgid "Thickbox height must be greater than 550 pixels."
180
+ msgstr ""
181
+
182
+ #: php/options.php:142
183
+ msgid "Width:"
184
+ msgstr ""
185
+
186
+ #: php/options.php:146
187
+ msgid "Set this to a value greater than 750."
188
+ msgstr ""
189
+
190
+ #: php/options.php:153
191
+ msgid "Height:"
192
+ msgstr ""
193
+
194
+ #: php/options.php:157
195
+ msgid "Set this to a value greater than 550."
196
+ msgstr ""
197
+
198
+ #: php/options.php:169
199
+ msgid "Enable debugging"
200
+ msgstr ""
201
+
202
+ #: php/options.php:178
203
+ msgid "Reset User Options"
204
+ msgstr ""
205
+
206
+ #: php/options.php:204
207
+ msgid "Post Thumbnail"
208
+ msgstr ""
209
+
210
+ #: php/options.php:205
211
+ msgid "Hidden"
212
+ msgstr ""
213
+
214
+ #: php/functions.php:257
215
+ msgid "Sorry, there was a problem trying to send to pastebin"
216
+ msgstr ""
217
+
218
+ #: php/functions.php:258
219
+ msgid "PASTEBIN URL:"
220
+ msgstr ""
221
+
222
+ #: php/functions.php:259
223
+ msgid "Disabling aspect ratio"
224
+ msgstr ""
225
+
226
+ #. Plugin URI of the plugin/theme
227
+ msgid "http://wordpress.org/extend/plugins/post-thumbnail-editor/"
228
+ msgstr ""
229
+
230
+ #. Description of the plugin/theme
231
+ msgid "Individually manage your post thumbnails"
232
+ msgstr ""
233
+
234
+ #. Author of the plugin/theme
235
+ msgid "sewpafly"
236
+ msgstr ""
237
+
238
+ #. Author URI of the plugin/theme
239
+ msgid "http://sewpafly.github.com/post-thumbnail-editor"
240
+ msgstr ""
js/header.coffee CHANGED
@@ -1,8 +1,39 @@
1
  window = @
2
  $ = window.jQuery
3
 
4
- # Call this as
5
- # <script>
6
- # $(function(){ pte.admin() });
7
- # </script>
8
  window.pte = pte = pte || {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  window = @
2
  $ = window.jQuery
3
 
 
 
 
 
4
  window.pte = pte = pte || {}
5
+
6
+ do(pte) ->
7
+ # Let's add some thickbox fixes
8
+ pte.fixThickbox = (parent) ->
9
+ $p = parent.jQuery
10
+ if $p == null or parent.frames.length < 1 then return
11
+ log "===== FIXING THICKBOX ====="
12
+
13
+ # How big should the window be
14
+ width = window.options.pte_tb_width + 30
15
+ height = window.options.pte_tb_height + 38
16
+
17
+ $thickbox = $p("#TB_window")
18
+ if $thickbox.width() >= width and $thickbox.height() >= height
19
+ return
20
+ log """THICKBOX: #{ $thickbox.width() } x #{ $thickbox.height() }"""
21
+
22
+ # set the correct dimensions
23
+ $thickbox.css
24
+ 'margin-left': 0 - (width / 2)
25
+ 'width': width
26
+ 'height': height
27
+ .children("iframe").css
28
+ 'width': width
29
+
30
+ # for some reason setting the height needs this hack
31
+ parent.setTimeout ->
32
+ if $p("iframe", $thickbox).height() > height then return
33
+ $p("iframe", $thickbox).css
34
+ 'height': height
35
+ #.resize()
36
+ log """THICKBOX: #{ $thickbox.width() } x #{ $thickbox.height() }"""
37
+ true
38
+ , 1000
39
+
js/log.coffee CHANGED
@@ -1,7 +1,102 @@
1
- window.log = (obj) ->
2
- return true if not window.debug_enabled
3
- try
4
- console.log obj
5
- catch error
6
- alert obj
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
2
+ toType = (obj) ->
3
+ ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()
4
+
5
+ class Message
6
+ constructor: (@message) ->
7
+ @date = new Date()
8
+ toString: ->
9
+ pad = (num, pad) ->
10
+ while (""+num).length < pad
11
+ num = "0" + num
12
+ num
13
+
14
+ d = @date
15
+ y = pad d.getUTCFullYear(), 4
16
+ M = pad d.getUTCMonth() + 1, 2
17
+ D = pad d.getUTCDate(), 2
18
+ h = pad d.getUTCHours(), 2
19
+ m = pad d.getUTCMinutes(), 2
20
+ s = pad d.getUTCSeconds(), 2
21
+
22
+ switch toType @message
23
+ when "string" then message = @message
24
+ else message = $.toJSON @message
25
+
26
+ """#{ y }#{ M }#{ D } #{ h }:#{ m }:#{ s } - [#{toType @message}] #{ message }"""
27
+
28
+ do(pte) ->
29
+ pte.messages = []
30
+ pte.log = (obj) ->
31
+ # Track date, time, and where the code was called from?
32
+ return true if not window.options.pte_debug
33
+ try
34
+ pte.messages.push(new Message obj)
35
+ console.log obj
36
+ $('#pte-log-messages textarea').filter(':visible').val pte.formatLog()
37
+ catch error
38
+ #alert obj
39
+ return
40
+ pte.formatLog = ->
41
+ log = ""
42
+ log += """#{message}\n""" for message in pte.messages
43
+ log
44
+ pte.parseServerLog = (json) ->
45
+ log "===== SERVER LOG ====="
46
+ if json?.length? and json.length > 0
47
+ for message in json
48
+ log message
49
+ true
50
+
51
+ pte.sendToPastebin = (text) ->
52
+ pastebin_url = "http://dpastey.appspot.com/"
53
+ post_data =
54
+ title: "PostThumbnailEditor Log"
55
+ content: text
56
+ lexer: "text"
57
+ format: "json"
58
+ #expire_options: "3600" # 1 hour
59
+ expire_options: "2592000" # 1 month
60
+ $.ajax
61
+ url: pastebin_url
62
+ data: post_data
63
+ dataType: "json"
64
+ global: false
65
+ type: "POST"
66
+ error: (xhr, status, errorThrown) ->
67
+ $('#pte-log').fadeOut '900'
68
+ alert objectL10n.pastebin_create_error
69
+ log xhr
70
+ log status
71
+ log errorThrown
72
+ success: (data, status, xhr) ->
73
+ $('#pte-log').fadeOut '900'
74
+ prompt objectL10n.pastebin_url, data.url
75
+
76
+
77
+ # End PTE Log Section
78
  true
79
+
80
+ window.log = pte.log
81
+
82
+ $(document).ready ($) ->
83
+ #$('#clipboard').click (e) ->
84
+ # text = pte.formatLog()
85
+ # prompt "Ctrl+C, Enter", text
86
+ $('#test').click (e) ->
87
+ e.stopImmediatePropagation()
88
+ true
89
+ $('#pastebin').click (e) ->
90
+ pte.sendToPastebin pte.formatLog()
91
+ $('#clear-log').click (e) ->
92
+ pte.messages = []
93
+ $('#pte-log-messages textarea').val pte.formatLog()
94
+ $('#close-log').click (e) ->
95
+ $('#pte-log').fadeOut '900'
96
+
97
+ $('#pte-log-tools a').click (e) ->
98
+ e.preventDefault()
99
+ $('body').delegate '.show-log-messages', 'click', (e) ->
100
+ e.preventDefault()
101
+ $('#pte-log-messages textarea').val pte.formatLog()
102
+ $('#pte-log').fadeIn '900'
js/pte.coffee CHANGED
@@ -12,49 +12,106 @@ window.randomness = ->
12
  Math.floor(Math.random()*1000001).toString(16)
13
 
14
  window.debugTmpl = (data) ->
 
15
  log data
16
  true
17
 
18
  # ===========================================================
19
  # Change stages
20
  # ===========================================================
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  window.goBack = (e) ->
22
  e?.preventDefault()
23
- $('#stage2').animate
24
- left: 1200
25
- , 500, 'swing', ->
26
- # COMMENT: this = stage2
27
- $(this).hide()
28
- $('#stage1').show 0, ->
29
- # this = stage1
30
- $(this).animate
31
- left: 0
32
- , 500, 'swing', ->
33
- log "okay cleanup"
34
- # send cleanup request
35
- delete_options =
36
- "id": $('#pte-post-id').val()
37
- 'action': 'pte_ajax'
38
- 'pte-action': 'delete-images'
39
- 'pte-nonce': $('#pte-delete-nonce').val()
40
- # use ajax:global - false
41
- $.ajax
42
- url: ajaxurl,
43
- data: delete_options
44
- global: false
45
- dataType: "json"
46
- success: (data, status, xhr) ->
47
- if data.error?
48
- log data.error
49
- else
50
- log "Deleted tmp files"
51
 
52
 
53
 
54
  gcd = (a, b) ->
55
  return b if a is 0
56
  while b > 0
57
- if a > b
58
  a = a - b
59
  else
60
  b = b - a
@@ -65,64 +122,77 @@ gcd = (a, b) ->
65
  # convert to crop/width/height
66
  # determine current ar and test against other ar's
67
  # throw exception if more than 1?
68
- # _(list).reduce( determineAspectRatio , ar)
69
- determineAspectRatio = (current_ar, size) ->
70
- {crop, width, height} = thumbnail_info[size]
71
  crop = +crop
72
  width = +width
73
  height = +height
74
  gc = gcd width, height
75
  if crop? and crop > 0
76
  tmp_ar = null
77
- if (width? > 0 and height? > 0)
78
  if gc?
79
  tmp_ar = "#{ width / gc }:#{ height / gc }"
80
  else
81
  tmp_ar = "#{ width }:#{ height }"
82
  if current_ar? and tmp_ar? and tmp_ar isnt current_ar
83
- #alert "2 images are trying to set different aspect ratios, disabling..."
84
- throw "Too many Aspect Ratios. Disabling"
85
  current_ar = tmp_ar
 
 
 
 
86
 
87
  do (pte) ->
88
  # Call this on page instantiation
 
89
  editor = pte.editor = ->
90
- setPageHeight()
91
  addRowListeners()
92
  initImgAreaSelect()
93
  addRowListener()
94
  addSubmitListener()
95
  addVerifyListener()
96
  addCheckAllNoneListener()
 
 
 
 
 
97
 
98
- # ===========================================================
99
- # This is our loading div
100
- # ===========================================================
 
101
  $loading_screen = $('#pte-loading')
102
  closeLoadingScreen = ->
103
- log "Closing load screen"
104
  $loading_screen.hide()
105
  true
 
 
106
  $('#pte-preview').load closeLoadingScreen
 
 
107
  $loading_screen
108
  .ajaxStart( ->
109
  $(this).fadeIn 200
110
  ).ajaxStop( ->
111
  $(this).fadeOut 200
112
  )
 
113
  window.setTimeout closeLoadingScreen, 2000
114
  true
115
 
116
 
117
-
118
-
119
  # ===========================================================
120
  # Set the height of the options
121
  # ===========================================================
122
  # Sets a timeout to be a little bit more responsive
123
- setPageHeight = ->
 
124
  reflow = new TimerFunc ->
125
- log "reflow called..."
 
126
  offset = $("#pte-sizes").offset()
127
  window_height = $(window).height() - offset.top - 2
128
  $("#pte-sizes").height window_height
@@ -130,18 +200,23 @@ do (pte) ->
130
  # Add to the resize and load events
131
  $(window).resize(reflow.doFunc).load(reflow.doFunc)
132
 
 
 
 
 
 
133
 
134
  # ===========================================================
135
  # Code to highlight selected rows
136
  # ===========================================================
137
  addRowListeners = ->
138
  enableRowFeatures = ($elem) ->
139
- #$('#stage2').delegate 'tr', 'click', (e) ->
140
  $elem.delegate 'tr', 'click', (e) ->
141
  if e.target.type isnt 'checkbox'
142
  $('input:checkbox', this).click()
143
  true
144
- #$('#stage2').delegate ':checkbox', 'click', (e) ->
145
  $elem.delegate 'input:checkbox', 'click', (e) ->
146
  if this.checked or $(this).is('input:checked')
147
  $(this).parents('tr').first().removeClass 'selected'
@@ -169,17 +244,15 @@ do (pte) ->
169
  instance: true
170
  onSelectEnd: (img, s) ->
171
  if s.width && s.width > 0 and s.height && s.height > 0 and $('.pte-size').filter(':checked').size() > 0
172
- log "Enabling button"
173
  $('#pte-submit').removeAttr('disabled')
174
  else
175
- log "Disabling button"
176
  $('#pte-submit').attr('disabled', true)
177
 
178
 
179
  initImgAreaSelect = ->
180
- ias_instance = $('#pte-image img').imgAreaSelect ias_defaults
181
  iasSetAR = (ar) ->
182
- log "setting aspectRatio: #{ ar }"
183
  ias_instance.setOptions
184
  aspectRatio: ar
185
  ias_instance.update()
@@ -191,17 +264,24 @@ do (pte) ->
191
  # Setting aspectRatio
192
  # This is what happens when a box is checked
193
  # Functional call to reduce would work well here (underscore.js)
194
- #
195
- # TODO: Fix when ar is disabled, don't tell the user until you renable it
196
- # and disable it again
197
  # ===========================================================
198
  addRowListener = ->
 
 
 
 
 
 
 
 
 
 
 
199
  pteCheckHandler = new TimerFunc ->
200
- #log "# checked: #{ $('.pte-size:checked').size() }"
201
  ar = null
202
  selected_elements = $('input.pte-size').filter(':checked').each (i,elem) ->
203
  try
204
- ar = determineAspectRatio ar, $(elem).val()
205
  catch error
206
  ar = null
207
  if ar isnt ias_instance.getOptions().aspectRatio
@@ -214,19 +294,22 @@ do (pte) ->
214
  ias_defaults.onSelectEnd null, ias_instance.getSelection()
215
  true
216
  , 50
 
 
217
  $('input.pte-size').click pteCheckHandler.doFunc
 
 
218
 
219
 
220
  # ===========================================================
221
- ### Callback for resizing images (Stage 1 to 2) ###
222
  # ===========================================================
223
  # What do you do when you click submit --> onResizeImages
224
  addSubmitListener = ->
225
  $('#pte-submit').click (e) ->
226
- log "Clicked Submit..."
227
  selection = ias_instance.getSelection()
228
  scale_factor = $('#pte-sizer').val()
229
- submit_data =
230
  'id': $('#pte-post-id').val()
231
  'action': 'pte_ajax'
232
  'pte-action': 'resize-images'
@@ -237,8 +320,9 @@ do (pte) ->
237
  'y': Math.floor(selection.y1/scale_factor)
238
  'w': Math.floor(selection.width/scale_factor)
239
  'h': Math.floor(selection.height/scale_factor)
 
240
  log submit_data
241
- ias_instance.setOptions
242
  hide: true
243
  x1: 0
244
  y1: 0
@@ -253,23 +337,16 @@ do (pte) ->
253
 
254
  onResizeImages = (data, status, xhr) ->
255
  ### Evaluate data ###
 
256
  log data
 
257
  if data.error? and not data.thumbnails?
258
  alert(data.error)
259
  return
260
 
261
- $('#stage1').animate
262
- left: -$(window).width()
263
- , 500, 'swing', ->
264
- $(this).hide()
265
- $('#stage2').html($('#stage2template').tmpl(data)).show(0, ->
266
- $(this).animate(
267
- left: 0
268
- , 500)
269
- true
270
- )
271
- #$('#stage2').animate({left: 0}, 500)
272
- true
273
  false
274
  # ===========================================================
275
 
@@ -278,7 +355,6 @@ do (pte) ->
278
  # ===========================================================
279
  addVerifyListener = ->
280
  $('#pte-confirm').live 'click', (e) ->
281
- log "Confirming"
282
  thumbnail_data = {}
283
  $('input.pte-confirm').filter(':checked').each (i, elem) ->
284
  size = $(elem).val()
@@ -289,22 +365,16 @@ do (pte) ->
289
  'pte-action': 'confirm-images'
290
  'pte-nonce': $('#pte-nonce').val()
291
  'pte-confirm': thumbnail_data
 
292
  log submit_data
293
  $.getJSON(ajaxurl, submit_data, onConfirmImages)
294
 
295
  onConfirmImages = (data, status, xhr) ->
 
296
  log data
297
- $('#stage2').animate
298
- left: -$(window).width()
299
- , 500, 'swing', ->
300
- $(this).hide()
301
- $('#stage3').html($('#stage3template').tmpl(data)).show(0, ->
302
- $(this).animate(
303
- left: 0
304
- , 500)
305
- true
306
- )
307
- true
308
  false
309
  # ===========================================================
310
 
@@ -317,13 +387,11 @@ do (pte) ->
317
  e?.preventDefault()
318
  elements = e.data?.selector ? '.pte-size'
319
  #$('.pte-size').filter(':checked').click()
320
- #log elements
321
  $(elements).filter(':checked').click()
322
 
323
  checkAllSizes = (e) ->
324
  e?.preventDefault()
325
  elements = e?.data?.selector ? '.pte-size'
326
- #log elements
327
  #$('.pte-size').not(':checked').click()
328
  $(elements).not(':checked').click()
329
 
@@ -334,4 +402,7 @@ do (pte) ->
334
 
335
  # Finished
336
  true
 
 
 
337
 
12
  Math.floor(Math.random()*1000001).toString(16)
13
 
14
  window.debugTmpl = (data) ->
15
+ log "===== TEMPLATE DEBUG DATA FOLLOWS ====="
16
  log data
17
  true
18
 
19
  # ===========================================================
20
  # Change stages
21
  # ===========================================================
22
+ # send cleanup request
23
+ deleteThumbs = (id) ->
24
+ delete_options =
25
+ "id": id
26
+ 'action': 'pte_ajax'
27
+ 'pte-action': 'delete-images'
28
+ 'pte-nonce': $('#pte-delete-nonce').val()
29
+ # use ajax:global - false so the overlay isn't triggered
30
+ $.ajax
31
+ url: ajaxurl,
32
+ data: delete_options
33
+ global: false
34
+ dataType: "json"
35
+ success: deleteThumbsSuccessCallback
36
+
37
+ deleteThumbsSuccessCallback = (data, status, xhr) ->
38
+ log "===== DELETE SUCCESSFUL, DATA DUMP FOLLOWS ====="
39
+ log data
40
+ pte.parseServerLog data.log
41
+
42
+ # Make jQuery function for moveRight and moveLeft
43
+ # include:
44
+ # * callback support
45
+ # * show/hide ability
46
+ # * Make the left value dependent on screen size
47
+ #
48
+ # See:
49
+ # http://stackoverflow.com/questions/1058158/can-somebody-explain-jquery-queue-to-me/3314877#3314877
50
+ # TODO: Testing this needs to see if it runs for each element passed in
51
+ pte_queue = $({})
52
+ $.fn.extend
53
+ move: (options) ->
54
+ defaults =
55
+ direction: 'left'
56
+ speed: 500
57
+ easing: 'swing'
58
+ toggle: true
59
+ callback: null
60
+ callbackargs: null
61
+ options = $.extend defaults, options
62
+
63
+ this.each ->
64
+ # Since no queue name defined, it will start automatically
65
+ pte_queue.queue (next) =>
66
+ $elem = $ this
67
+ # if this object is in view, move it out of view
68
+ # if this object is out of view, move it in view
69
+ direction = if options.direction == 'left' then -1 else 1
70
+ move_to = if $elem.css('left') == "0px" then $(window).width() * direction else 0
71
+
72
+ # if this object is currently hidden, show it
73
+ # if this object is currently shown, hide it
74
+ isVisible = $elem.is(':visible')
75
+ if (not isVisible)
76
+ $elem.show 0, ->
77
+ $(this).animate {'left': move_to}, options.speed, options.easing, next
78
+ else
79
+ $elem.animate {'left': move_to}, options.speed, options.easing
80
+ $elem.hide 0, next
81
+ true
82
+ if (options.callback)
83
+ pte_queue.queue (next) ->
84
+ if options.callbackargs?
85
+ options.callback.apply this, options.callbackargs
86
+ else
87
+ options.callback.apply this
88
+ next()
89
+ return this
90
+
91
+ moveRight: (options) ->
92
+ options = $.extend options, { direction: 'right' }
93
+ this.move options
94
+ moveLeft: (options) ->
95
+ options = $.extend options, { direction: 'left' }
96
+ this.move options
97
+
98
  window.goBack = (e) ->
99
  e?.preventDefault()
100
+ $('#stage2').moveRight()
101
+ $('#stage1').moveRight
102
+ callback: ->
103
+ deleteThumbs $('#pte-post-id').val()
104
+ # Reset stage2 to blank
105
+ $('#stage2').html ''
106
+ #callbackargs: [$('#pte-post-id').val()]
107
+ true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
 
110
 
111
  gcd = (a, b) ->
112
  return b if a is 0
113
  while b > 0
114
+ if a > b
115
  a = a - b
116
  else
117
  b = b - a
122
  # convert to crop/width/height
123
  # determine current ar and test against other ar's
124
  # throw exception if more than 1?
125
+ determineAspectRatio = (current_ar, size_info) ->
126
+ {crop, width, height} = size_info
 
127
  crop = +crop
128
  width = +width
129
  height = +height
130
  gc = gcd width, height
131
  if crop? and crop > 0
132
  tmp_ar = null
133
+ if (width? > 0 and height? > 0)
134
  if gc?
135
  tmp_ar = "#{ width / gc }:#{ height / gc }"
136
  else
137
  tmp_ar = "#{ width }:#{ height }"
138
  if current_ar? and tmp_ar? and tmp_ar isnt current_ar
139
+ throw objectL10n.aspect_ratio_disabled
 
140
  current_ar = tmp_ar
141
+ current_ar
142
+
143
+ pte.functions =
144
+ determineAspectRatio: determineAspectRatio
145
 
146
  do (pte) ->
147
  # Call this on page instantiation
148
+ # Initialize stage2 & stage3 to be set at screen width (for moveRight moveLeft functionality)
149
  editor = pte.editor = ->
150
+ configurePageDisplay()
151
  addRowListeners()
152
  initImgAreaSelect()
153
  addRowListener()
154
  addSubmitListener()
155
  addVerifyListener()
156
  addCheckAllNoneListener()
157
+ configureOverlay()
158
+ true
159
+ # ===========================================================
160
+ # End Editor INIT
161
+ # ===========================================================
162
 
163
+ # ===========================================================
164
+ # This configures our loading overlay
165
+ # ===========================================================
166
+ configureOverlay = ->
167
  $loading_screen = $('#pte-loading')
168
  closeLoadingScreen = ->
 
169
  $loading_screen.hide()
170
  true
171
+
172
+ # overlay starts by being shown, this should close it
173
  $('#pte-preview').load closeLoadingScreen
174
+
175
+ # AJAX calls will show/hide the overlay
176
  $loading_screen
177
  .ajaxStart( ->
178
  $(this).fadeIn 200
179
  ).ajaxStop( ->
180
  $(this).fadeOut 200
181
  )
182
+ # overlay starts by being shown, this WILL close it
183
  window.setTimeout closeLoadingScreen, 2000
184
  true
185
 
186
 
 
 
187
  # ===========================================================
188
  # Set the height of the options
189
  # ===========================================================
190
  # Sets a timeout to be a little bit more responsive
191
+ configurePageDisplay = ->
192
+ # Set the height of the side column
193
  reflow = new TimerFunc ->
194
+ log "===== REFLOW ====="
195
+ pte.fixThickbox window.parent
196
  offset = $("#pte-sizes").offset()
197
  window_height = $(window).height() - offset.top - 2
198
  $("#pte-sizes").height window_height
200
  # Add to the resize and load events
201
  $(window).resize(reflow.doFunc).load(reflow.doFunc)
202
 
203
+ # Set the left position of stages2,3
204
+ $('#stage2, #stage3').css
205
+ left: $(window).width()
206
+ true
207
+
208
 
209
  # ===========================================================
210
  # Code to highlight selected rows
211
  # ===========================================================
212
  addRowListeners = ->
213
  enableRowFeatures = ($elem) ->
214
+ # Check the checkbox
215
  $elem.delegate 'tr', 'click', (e) ->
216
  if e.target.type isnt 'checkbox'
217
  $('input:checkbox', this).click()
218
  true
219
+ # Style the row
220
  $elem.delegate 'input:checkbox', 'click', (e) ->
221
  if this.checked or $(this).is('input:checked')
222
  $(this).parents('tr').first().removeClass 'selected'
244
  instance: true
245
  onSelectEnd: (img, s) ->
246
  if s.width && s.width > 0 and s.height && s.height > 0 and $('.pte-size').filter(':checked').size() > 0
 
247
  $('#pte-submit').removeAttr('disabled')
248
  else
 
249
  $('#pte-submit').attr('disabled', true)
250
 
251
 
252
  initImgAreaSelect = ->
253
+ pte.ias = ias_instance = $('#pte-image img').imgAreaSelect ias_defaults
254
  iasSetAR = (ar) ->
255
+ log "===== SETTING ASPECTRATIO: #{ ar } ====="
256
  ias_instance.setOptions
257
  aspectRatio: ar
258
  ias_instance.update()
264
  # Setting aspectRatio
265
  # This is what happens when a box is checked
266
  # Functional call to reduce would work well here (underscore.js)
 
 
 
267
  # ===========================================================
268
  addRowListener = ->
269
+ pteVerifySubmitButtonHandler = new TimerFunc ->
270
+ # If the number of confirms clicked is > 0, enable the submit button
271
+ log "===== CHECK SUBMIT BUTTON ====="
272
+ if $('.pte-confirm').filter(':checked').size() > 0
273
+ log "ENABLE"
274
+ $('#pte-confirm').removeAttr('disabled')
275
+ else
276
+ log "DISABLE"
277
+ $('#pte-confirm').attr('disabled', true)
278
+ true
279
+ , 50
280
  pteCheckHandler = new TimerFunc ->
 
281
  ar = null
282
  selected_elements = $('input.pte-size').filter(':checked').each (i,elem) ->
283
  try
284
+ ar = determineAspectRatio ar, thumbnail_info[$(elem).val()]
285
  catch error
286
  ar = null
287
  if ar isnt ias_instance.getOptions().aspectRatio
294
  ias_defaults.onSelectEnd null, ias_instance.getSelection()
295
  true
296
  , 50
297
+ $.extend pte.functions,
298
+ pteVerifySubmitButtonHandler: pteVerifySubmitButtonHandler
299
  $('input.pte-size').click pteCheckHandler.doFunc
300
+ $('.pte-confirm').live 'click', (e) ->
301
+ pteVerifySubmitButtonHandler.doFunc()
302
 
303
 
304
  # ===========================================================
305
+ # Callback for resizing images (Stage 1 to 2) ###
306
  # ===========================================================
307
  # What do you do when you click submit --> onResizeImages
308
  addSubmitListener = ->
309
  $('#pte-submit').click (e) ->
 
310
  selection = ias_instance.getSelection()
311
  scale_factor = $('#pte-sizer').val()
312
+ submit_data =
313
  'id': $('#pte-post-id').val()
314
  'action': 'pte_ajax'
315
  'pte-action': 'resize-images'
320
  'y': Math.floor(selection.y1/scale_factor)
321
  'w': Math.floor(selection.width/scale_factor)
322
  'h': Math.floor(selection.height/scale_factor)
323
+ log "===== RESIZE-IMAGES ====="
324
  log submit_data
325
+ ias_instance.setOptions
326
  hide: true
327
  x1: 0
328
  y1: 0
337
 
338
  onResizeImages = (data, status, xhr) ->
339
  ### Evaluate data ###
340
+ log "===== RESIZE-IMAGES SUCCESS ====="
341
  log data
342
+ pte.parseServerLog data.log
343
  if data.error? and not data.thumbnails?
344
  alert(data.error)
345
  return
346
 
347
+ $('#stage1').moveLeft()
348
+ $('#stage2').html($('#stage2template').tmpl(data)).moveLeft
349
+ callback: pte.functions.pteVerifySubmitButtonHandler.doFunc
 
 
 
 
 
 
 
 
 
350
  false
351
  # ===========================================================
352
 
355
  # ===========================================================
356
  addVerifyListener = ->
357
  $('#pte-confirm').live 'click', (e) ->
 
358
  thumbnail_data = {}
359
  $('input.pte-confirm').filter(':checked').each (i, elem) ->
360
  size = $(elem).val()
365
  'pte-action': 'confirm-images'
366
  'pte-nonce': $('#pte-nonce').val()
367
  'pte-confirm': thumbnail_data
368
+ log "===== CONFIRM-IMAGES ====="
369
  log submit_data
370
  $.getJSON(ajaxurl, submit_data, onConfirmImages)
371
 
372
  onConfirmImages = (data, status, xhr) ->
373
+ log "===== CONFIRM-IMAGES SUCCESS ====="
374
  log data
375
+ pte.parseServerLog data.log
376
+ $('#stage2').moveLeft()
377
+ $('#stage3').html($('#stage3template').tmpl(data)).moveLeft()
 
 
 
 
 
 
 
 
378
  false
379
  # ===========================================================
380
 
387
  e?.preventDefault()
388
  elements = e.data?.selector ? '.pte-size'
389
  #$('.pte-size').filter(':checked').click()
 
390
  $(elements).filter(':checked').click()
391
 
392
  checkAllSizes = (e) ->
393
  e?.preventDefault()
394
  elements = e?.data?.selector ? '.pte-size'
 
395
  #$('.pte-size').not(':checked').click()
396
  $(elements).not(':checked').click()
397
 
402
 
403
  # Finished
404
  true
405
+
406
+ $.extend pte.functions,
407
+ iasSetAR: iasSetAR
408
 
js/pte.full.js CHANGED
@@ -483,22 +483,170 @@
483
  }
484
  })( jQuery );
485
  (function() {
486
- var $, TimerFunc, determineAspectRatio, gcd, pte, window;
487
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
488
  window = this;
489
  $ = window.jQuery;
490
  window.pte = pte = pte || {};
491
- window.log = function(obj) {
492
- if (!window.debug_enabled) {
493
- return true;
494
- }
495
- try {
496
- console.log(obj);
497
- } catch (error) {
498
- alert(obj);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
  return true;
501
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  /*
503
  POST-THUMBNAIL-EDITOR Script for Wordpress
504
 
@@ -506,9 +654,9 @@
506
  */
507
  (function(pte) {
508
  return pte.admin = function() {
509
- var $getLink, checkExistingThickbox, fixThickbox, image_id, injectPTE, launchPTE, pte_url, thickbox, timeout;
510
  timeout = 300;
511
- thickbox = "&TB_iframe=true&height=" + pte_tb_height + "&width=" + pte_tb_width;
512
  image_id = null;
513
  pte_url = function(override_id) {
514
  var id;
@@ -518,34 +666,12 @@
518
  $getLink = function(id) {
519
  return $("<a class=\"thickbox\" href=\"" + (pte_url(id)) + "\">" + objectL10n.PTE + "</a>");
520
  };
521
- fixThickbox = function(parent) {
522
- var height, p$, width;
523
- p$ = parent.jQuery;
524
- if (p$ === null) {
525
- return;
526
- }
527
- log("Got thickbox");
528
- width = pte_tb_width + 40;
529
- height = pte_tb_height;
530
- thickbox = p$("#TB_window").css({
531
- 'margin-left': 0 - (width / 2),
532
- 'width': width
533
- }).children("iframe").css({
534
- 'width': width
535
- });
536
- return parent.setTimeout(function() {
537
- return p$("iframe", thickbox).css({
538
- height: height + 100
539
- });
540
- }, 1000);
541
- };
542
  checkExistingThickbox = function(e) {
543
  log("Start PTE...");
544
  if (window.parent.frames.length > 0) {
545
  log("Modifying thickbox...");
546
  __bind(function() {
547
  window.parent.tb_click();
548
- fixThickbox(window.parent);
549
  return true;
550
  }, this)();
551
  return e.stopPropagation();
@@ -602,45 +728,103 @@
602
  return Math.floor(Math.random() * 1000001).toString(16);
603
  };
604
  window.debugTmpl = function(data) {
 
605
  log(data);
606
  return true;
607
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
608
  window.goBack = function(e) {
609
  if (e != null) {
610
  e.preventDefault();
611
  }
612
- return $('#stage2').animate({
613
- left: 1200
614
- }, 500, 'swing', function() {
615
- $(this).hide();
616
- return $('#stage1').show(0, function() {
617
- return $(this).animate({
618
- left: 0
619
- }, 500, 'swing', function() {
620
- var delete_options;
621
- log("okay cleanup");
622
- delete_options = {
623
- "id": $('#pte-post-id').val(),
624
- 'action': 'pte_ajax',
625
- 'pte-action': 'delete-images',
626
- 'pte-nonce': $('#pte-delete-nonce').val()
627
- };
628
- return $.ajax({
629
- url: ajaxurl,
630
- data: delete_options,
631
- global: false,
632
- dataType: "json",
633
- success: function(data, status, xhr) {
634
- if (data.error != null) {
635
- return log(data.error);
636
- } else {
637
- return log("Deleted tmp files");
638
- }
639
- }
640
- });
641
- });
642
- });
643
  });
 
644
  };
645
  gcd = function(a, b) {
646
  if (a === 0) {
@@ -658,9 +842,9 @@
658
  }
659
  return a;
660
  };
661
- determineAspectRatio = function(current_ar, size) {
662
- var crop, gc, height, tmp_ar, width, _ref;
663
- _ref = thumbnail_info[size], crop = _ref.crop, width = _ref.width, height = _ref.height;
664
  crop = +crop;
665
  width = +width;
666
  height = +height;
@@ -675,25 +859,32 @@
675
  }
676
  }
677
  if ((current_ar != null) && (tmp_ar != null) && tmp_ar !== current_ar) {
678
- throw "Too many Aspect Ratios. Disabling";
679
  }
680
- return current_ar = tmp_ar;
681
  }
 
 
 
 
682
  };
683
  (function(pte) {
684
- var addCheckAllNoneListener, addRowListener, addRowListeners, addSubmitListener, addVerifyListener, editor, iasSetAR, ias_defaults, ias_instance, initImgAreaSelect, setPageHeight;
685
  editor = pte.editor = function() {
686
- var $loading_screen, closeLoadingScreen;
687
- setPageHeight();
688
  addRowListeners();
689
  initImgAreaSelect();
690
  addRowListener();
691
  addSubmitListener();
692
  addVerifyListener();
693
  addCheckAllNoneListener();
 
 
 
 
 
694
  $loading_screen = $('#pte-loading');
695
  closeLoadingScreen = function() {
696
- log("Closing load screen");
697
  $loading_screen.hide();
698
  return true;
699
  };
@@ -706,16 +897,21 @@
706
  window.setTimeout(closeLoadingScreen, 2000);
707
  return true;
708
  };
709
- setPageHeight = function() {
710
  var reflow;
711
  reflow = new TimerFunc(function() {
712
  var offset, window_height;
713
- log("reflow called...");
 
714
  offset = $("#pte-sizes").offset();
715
  window_height = $(window).height() - offset.top - 2;
716
  return $("#pte-sizes").height(window_height);
717
  }, 100);
718
- return $(window).resize(reflow.doFunc).load(reflow.doFunc);
 
 
 
 
719
  };
720
  addRowListeners = function() {
721
  var enableRowFeatures;
@@ -749,32 +945,41 @@
749
  instance: true,
750
  onSelectEnd: function(img, s) {
751
  if (s.width && s.width > 0 && s.height && s.height > 0 && $('.pte-size').filter(':checked').size() > 0) {
752
- log("Enabling button");
753
  return $('#pte-submit').removeAttr('disabled');
754
  } else {
755
- log("Disabling button");
756
  return $('#pte-submit').attr('disabled', true);
757
  }
758
  }
759
  };
760
  initImgAreaSelect = function() {
761
- return ias_instance = $('#pte-image img').imgAreaSelect(ias_defaults);
762
  };
763
  iasSetAR = function(ar) {
764
- log("setting aspectRatio: " + ar);
765
  ias_instance.setOptions({
766
  aspectRatio: ar
767
  });
768
  return ias_instance.update();
769
  };
770
  addRowListener = function() {
771
- var pteCheckHandler;
 
 
 
 
 
 
 
 
 
 
 
772
  pteCheckHandler = new TimerFunc(function() {
773
  var ar, selected_elements;
774
  ar = null;
775
  selected_elements = $('input.pte-size').filter(':checked').each(function(i, elem) {
776
  try {
777
- ar = determineAspectRatio(ar, $(elem).val());
778
  } catch (error) {
779
  ar = null;
780
  if (ar !== ias_instance.getOptions().aspectRatio) {
@@ -788,14 +993,18 @@
788
  ias_defaults.onSelectEnd(null, ias_instance.getSelection());
789
  return true;
790
  }, 50);
791
- return $('input.pte-size').click(pteCheckHandler.doFunc);
 
 
 
 
 
 
792
  };
793
- /* Callback for resizing images (Stage 1 to 2) */
794
  addSubmitListener = function() {
795
  var onResizeImages;
796
  $('#pte-submit').click(function(e) {
797
  var scale_factor, selection, submit_data;
798
- log("Clicked Submit...");
799
  selection = ias_instance.getSelection();
800
  scale_factor = $('#pte-sizer').val();
801
  submit_data = {
@@ -810,6 +1019,7 @@
810
  'w': Math.floor(selection.width / scale_factor),
811
  'h': Math.floor(selection.height / scale_factor)
812
  };
 
813
  log(submit_data);
814
  ias_instance.setOptions({
815
  hide: true,
@@ -823,22 +1033,16 @@
823
  return true;
824
  });
825
  return onResizeImages = function(data, status, xhr) {
826
- /* Evaluate data */ log(data);
 
 
827
  if ((data.error != null) && !(data.thumbnails != null)) {
828
  alert(data.error);
829
  return;
830
  }
831
- $('#stage1').animate({
832
- left: -$(window).width()
833
- }, 500, 'swing', function() {
834
- $(this).hide();
835
- $('#stage2').html($('#stage2template').tmpl(data)).show(0, function() {
836
- $(this).animate({
837
- left: 0
838
- }, 500);
839
- return true;
840
- });
841
- return true;
842
  });
843
  return false;
844
  };
@@ -848,7 +1052,6 @@
848
  var onConfirmImages;
849
  $('#pte-confirm').live('click', function(e) {
850
  var submit_data, thumbnail_data;
851
- log("Confirming");
852
  thumbnail_data = {};
853
  $('input.pte-confirm').filter(':checked').each(function(i, elem) {
854
  var size;
@@ -862,28 +1065,21 @@
862
  'pte-nonce': $('#pte-nonce').val(),
863
  'pte-confirm': thumbnail_data
864
  };
 
865
  log(submit_data);
866
  return $.getJSON(ajaxurl, submit_data, onConfirmImages);
867
  });
868
  return onConfirmImages = function(data, status, xhr) {
 
869
  log(data);
870
- $('#stage2').animate({
871
- left: -$(window).width()
872
- }, 500, 'swing', function() {
873
- $(this).hide();
874
- $('#stage3').html($('#stage3template').tmpl(data)).show(0, function() {
875
- $(this).animate({
876
- left: 0
877
- }, 500);
878
- return true;
879
- });
880
- return true;
881
- });
882
  return false;
883
  };
884
  };
885
  /* Select ALL|NONE */
886
- return addCheckAllNoneListener = function() {
887
  var checkAllSizes, uncheckAllSizes;
888
  uncheckAllSizes = function(e) {
889
  var elements, _ref, _ref2;
@@ -911,5 +1107,8 @@
911
  }, uncheckAllSizes);
912
  return true;
913
  };
 
 
 
914
  })(pte);
915
  }).call(this);
483
  }
484
  })( jQuery );
485
  (function() {
486
+ var $, Message, TimerFunc, deleteThumbs, deleteThumbsSuccessCallback, determineAspectRatio, gcd, pte, pte_queue, toType, window;
487
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
488
  window = this;
489
  $ = window.jQuery;
490
  window.pte = pte = pte || {};
491
+ (function(pte) {
492
+ return pte.fixThickbox = function(parent) {
493
+ var $p, $thickbox, height, width;
494
+ $p = parent.jQuery;
495
+ if ($p === null || parent.frames.length < 1) {
496
+ return;
497
+ }
498
+ log("===== FIXING THICKBOX =====");
499
+ width = window.options.pte_tb_width + 30;
500
+ height = window.options.pte_tb_height + 38;
501
+ $thickbox = $p("#TB_window");
502
+ if ($thickbox.width() >= width && $thickbox.height() >= height) {
503
+ return;
504
+ }
505
+ log("THICKBOX: " + ($thickbox.width()) + " x " + ($thickbox.height()));
506
+ $thickbox.css({
507
+ 'margin-left': 0 - (width / 2),
508
+ 'width': width,
509
+ 'height': height
510
+ }).children("iframe").css({
511
+ 'width': width
512
+ });
513
+ return parent.setTimeout(function() {
514
+ if ($p("iframe", $thickbox).height() > height) {
515
+ return;
516
+ }
517
+ $p("iframe", $thickbox).css({
518
+ 'height': height
519
+ });
520
+ log("THICKBOX: " + ($thickbox.width()) + " x " + ($thickbox.height()));
521
+ return true;
522
+ }, 1000);
523
+ };
524
+ })(pte);
525
+ toType = function(obj) {
526
+ return {}.toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
527
+ };
528
+ Message = (function() {
529
+ function Message(message) {
530
+ this.message = message;
531
+ this.date = new Date();
532
  }
533
+ Message.prototype.toString = function() {
534
+ var D, M, d, h, m, message, pad, s, y;
535
+ pad = function(num, pad) {
536
+ while (("" + num).length < pad) {
537
+ num = "0" + num;
538
+ }
539
+ return num;
540
+ };
541
+ d = this.date;
542
+ y = pad(d.getUTCFullYear(), 4);
543
+ M = pad(d.getUTCMonth() + 1, 2);
544
+ D = pad(d.getUTCDate(), 2);
545
+ h = pad(d.getUTCHours(), 2);
546
+ m = pad(d.getUTCMinutes(), 2);
547
+ s = pad(d.getUTCSeconds(), 2);
548
+ switch (toType(this.message)) {
549
+ case "string":
550
+ message = this.message;
551
+ break;
552
+ default:
553
+ message = $.toJSON(this.message);
554
+ }
555
+ return "" + y + M + D + " " + h + ":" + m + ":" + s + " - [" + (toType(this.message)) + "] " + message;
556
+ };
557
+ return Message;
558
+ })();
559
+ (function(pte) {
560
+ pte.messages = [];
561
+ pte.log = function(obj) {
562
+ if (!window.options.pte_debug) {
563
+ return true;
564
+ }
565
+ try {
566
+ pte.messages.push(new Message(obj));
567
+ console.log(obj);
568
+ $('#pte-log-messages textarea').filter(':visible').val(pte.formatLog());
569
+ } catch (error) {
570
+
571
+ }
572
+ };
573
+ pte.formatLog = function() {
574
+ var log, message, _i, _len, _ref;
575
+ log = "";
576
+ _ref = pte.messages;
577
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
578
+ message = _ref[_i];
579
+ log += "" + message + "\n";
580
+ }
581
+ return log;
582
+ };
583
+ pte.parseServerLog = function(json) {
584
+ var message, _i, _len;
585
+ log("===== SERVER LOG =====");
586
+ if (((json != null ? json.length : void 0) != null) && json.length > 0) {
587
+ for (_i = 0, _len = json.length; _i < _len; _i++) {
588
+ message = json[_i];
589
+ log(message);
590
+ }
591
+ }
592
+ return true;
593
+ };
594
+ pte.sendToPastebin = function(text) {
595
+ var pastebin_url, post_data;
596
+ pastebin_url = "http://dpastey.appspot.com/";
597
+ post_data = {
598
+ title: "PostThumbnailEditor Log",
599
+ content: text,
600
+ lexer: "text",
601
+ format: "json",
602
+ expire_options: "2592000"
603
+ };
604
+ return $.ajax({
605
+ url: pastebin_url,
606
+ data: post_data,
607
+ dataType: "json",
608
+ global: false,
609
+ type: "POST",
610
+ error: function(xhr, status, errorThrown) {
611
+ $('#pte-log').fadeOut('900');
612
+ alert(objectL10n.pastebin_create_error);
613
+ log(xhr);
614
+ log(status);
615
+ return log(errorThrown);
616
+ },
617
+ success: function(data, status, xhr) {
618
+ $('#pte-log').fadeOut('900');
619
+ return prompt(objectL10n.pastebin_url, data.url);
620
+ }
621
+ });
622
+ };
623
  return true;
624
+ })(pte);
625
+ window.log = pte.log;
626
+ $(document).ready(function($) {
627
+ $('#test').click(function(e) {
628
+ e.stopImmediatePropagation();
629
+ return true;
630
+ });
631
+ $('#pastebin').click(function(e) {
632
+ return pte.sendToPastebin(pte.formatLog());
633
+ });
634
+ $('#clear-log').click(function(e) {
635
+ pte.messages = [];
636
+ return $('#pte-log-messages textarea').val(pte.formatLog());
637
+ });
638
+ $('#close-log').click(function(e) {
639
+ return $('#pte-log').fadeOut('900');
640
+ });
641
+ $('#pte-log-tools a').click(function(e) {
642
+ return e.preventDefault();
643
+ });
644
+ return $('body').delegate('.show-log-messages', 'click', function(e) {
645
+ e.preventDefault();
646
+ $('#pte-log-messages textarea').val(pte.formatLog());
647
+ return $('#pte-log').fadeIn('900');
648
+ });
649
+ });
650
  /*
651
  POST-THUMBNAIL-EDITOR Script for Wordpress
652
 
654
  */
655
  (function(pte) {
656
  return pte.admin = function() {
657
+ var $getLink, checkExistingThickbox, image_id, injectPTE, launchPTE, pte_url, thickbox, timeout;
658
  timeout = 300;
659
+ thickbox = "&TB_iframe=true&height=" + window.options.pte_tb_height + "&width=" + window.options.pte_tb_width;
660
  image_id = null;
661
  pte_url = function(override_id) {
662
  var id;
666
  $getLink = function(id) {
667
  return $("<a class=\"thickbox\" href=\"" + (pte_url(id)) + "\">" + objectL10n.PTE + "</a>");
668
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
  checkExistingThickbox = function(e) {
670
  log("Start PTE...");
671
  if (window.parent.frames.length > 0) {
672
  log("Modifying thickbox...");
673
  __bind(function() {
674
  window.parent.tb_click();
 
675
  return true;
676
  }, this)();
677
  return e.stopPropagation();
728
  return Math.floor(Math.random() * 1000001).toString(16);
729
  };
730
  window.debugTmpl = function(data) {
731
+ log("===== TEMPLATE DEBUG DATA FOLLOWS =====");
732
  log(data);
733
  return true;
734
  };
735
+ deleteThumbs = function(id) {
736
+ var delete_options;
737
+ delete_options = {
738
+ "id": id,
739
+ 'action': 'pte_ajax',
740
+ 'pte-action': 'delete-images',
741
+ 'pte-nonce': $('#pte-delete-nonce').val()
742
+ };
743
+ return $.ajax({
744
+ url: ajaxurl,
745
+ data: delete_options,
746
+ global: false,
747
+ dataType: "json",
748
+ success: deleteThumbsSuccessCallback
749
+ });
750
+ };
751
+ deleteThumbsSuccessCallback = function(data, status, xhr) {
752
+ log("===== DELETE SUCCESSFUL, DATA DUMP FOLLOWS =====");
753
+ log(data);
754
+ return pte.parseServerLog(data.log);
755
+ };
756
+ pte_queue = $({});
757
+ $.fn.extend({
758
+ move: function(options) {
759
+ var defaults;
760
+ defaults = {
761
+ direction: 'left',
762
+ speed: 500,
763
+ easing: 'swing',
764
+ toggle: true,
765
+ callback: null,
766
+ callbackargs: null
767
+ };
768
+ options = $.extend(defaults, options);
769
+ this.each(function() {
770
+ return pte_queue.queue(__bind(function(next) {
771
+ var $elem, direction, isVisible, move_to;
772
+ $elem = $(this);
773
+ direction = options.direction === 'left' ? -1 : 1;
774
+ move_to = $elem.css('left') === "0px" ? $(window).width() * direction : 0;
775
+ isVisible = $elem.is(':visible');
776
+ if (!isVisible) {
777
+ $elem.show(0, function() {
778
+ return $(this).animate({
779
+ 'left': move_to
780
+ }, options.speed, options.easing, next);
781
+ });
782
+ } else {
783
+ $elem.animate({
784
+ 'left': move_to
785
+ }, options.speed, options.easing);
786
+ $elem.hide(0, next);
787
+ }
788
+ return true;
789
+ }, this));
790
+ });
791
+ if (options.callback) {
792
+ pte_queue.queue(function(next) {
793
+ if (options.callbackargs != null) {
794
+ options.callback.apply(this, options.callbackargs);
795
+ } else {
796
+ options.callback.apply(this);
797
+ }
798
+ return next();
799
+ });
800
+ }
801
+ return this;
802
+ },
803
+ moveRight: function(options) {
804
+ options = $.extend(options, {
805
+ direction: 'right'
806
+ });
807
+ return this.move(options);
808
+ },
809
+ moveLeft: function(options) {
810
+ options = $.extend(options, {
811
+ direction: 'left'
812
+ });
813
+ return this.move(options);
814
+ }
815
+ });
816
  window.goBack = function(e) {
817
  if (e != null) {
818
  e.preventDefault();
819
  }
820
+ $('#stage2').moveRight();
821
+ $('#stage1').moveRight({
822
+ callback: function() {
823
+ deleteThumbs($('#pte-post-id').val());
824
+ return $('#stage2').html('');
825
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
826
  });
827
+ return true;
828
  };
829
  gcd = function(a, b) {
830
  if (a === 0) {
842
  }
843
  return a;
844
  };
845
+ determineAspectRatio = function(current_ar, size_info) {
846
+ var crop, gc, height, tmp_ar, width;
847
+ crop = size_info.crop, width = size_info.width, height = size_info.height;
848
  crop = +crop;
849
  width = +width;
850
  height = +height;
859
  }
860
  }
861
  if ((current_ar != null) && (tmp_ar != null) && tmp_ar !== current_ar) {
862
+ throw objectL10n.aspect_ratio_disabled;
863
  }
864
+ current_ar = tmp_ar;
865
  }
866
+ return current_ar;
867
+ };
868
+ pte.functions = {
869
+ determineAspectRatio: determineAspectRatio
870
  };
871
  (function(pte) {
872
+ var addCheckAllNoneListener, addRowListener, addRowListeners, addSubmitListener, addVerifyListener, configureOverlay, configurePageDisplay, editor, iasSetAR, ias_defaults, ias_instance, initImgAreaSelect;
873
  editor = pte.editor = function() {
874
+ configurePageDisplay();
 
875
  addRowListeners();
876
  initImgAreaSelect();
877
  addRowListener();
878
  addSubmitListener();
879
  addVerifyListener();
880
  addCheckAllNoneListener();
881
+ configureOverlay();
882
+ return true;
883
+ };
884
+ configureOverlay = function() {
885
+ var $loading_screen, closeLoadingScreen;
886
  $loading_screen = $('#pte-loading');
887
  closeLoadingScreen = function() {
 
888
  $loading_screen.hide();
889
  return true;
890
  };
897
  window.setTimeout(closeLoadingScreen, 2000);
898
  return true;
899
  };
900
+ configurePageDisplay = function() {
901
  var reflow;
902
  reflow = new TimerFunc(function() {
903
  var offset, window_height;
904
+ log("===== REFLOW =====");
905
+ pte.fixThickbox(window.parent);
906
  offset = $("#pte-sizes").offset();
907
  window_height = $(window).height() - offset.top - 2;
908
  return $("#pte-sizes").height(window_height);
909
  }, 100);
910
+ $(window).resize(reflow.doFunc).load(reflow.doFunc);
911
+ $('#stage2, #stage3').css({
912
+ left: $(window).width()
913
+ });
914
+ return true;
915
  };
916
  addRowListeners = function() {
917
  var enableRowFeatures;
945
  instance: true,
946
  onSelectEnd: function(img, s) {
947
  if (s.width && s.width > 0 && s.height && s.height > 0 && $('.pte-size').filter(':checked').size() > 0) {
 
948
  return $('#pte-submit').removeAttr('disabled');
949
  } else {
 
950
  return $('#pte-submit').attr('disabled', true);
951
  }
952
  }
953
  };
954
  initImgAreaSelect = function() {
955
+ return pte.ias = ias_instance = $('#pte-image img').imgAreaSelect(ias_defaults);
956
  };
957
  iasSetAR = function(ar) {
958
+ log("===== SETTING ASPECTRATIO: " + ar + " =====");
959
  ias_instance.setOptions({
960
  aspectRatio: ar
961
  });
962
  return ias_instance.update();
963
  };
964
  addRowListener = function() {
965
+ var pteCheckHandler, pteVerifySubmitButtonHandler;
966
+ pteVerifySubmitButtonHandler = new TimerFunc(function() {
967
+ log("===== CHECK SUBMIT BUTTON =====");
968
+ if ($('.pte-confirm').filter(':checked').size() > 0) {
969
+ log("ENABLE");
970
+ $('#pte-confirm').removeAttr('disabled');
971
+ } else {
972
+ log("DISABLE");
973
+ $('#pte-confirm').attr('disabled', true);
974
+ }
975
+ return true;
976
+ }, 50);
977
  pteCheckHandler = new TimerFunc(function() {
978
  var ar, selected_elements;
979
  ar = null;
980
  selected_elements = $('input.pte-size').filter(':checked').each(function(i, elem) {
981
  try {
982
+ ar = determineAspectRatio(ar, thumbnail_info[$(elem).val()]);
983
  } catch (error) {
984
  ar = null;
985
  if (ar !== ias_instance.getOptions().aspectRatio) {
993
  ias_defaults.onSelectEnd(null, ias_instance.getSelection());
994
  return true;
995
  }, 50);
996
+ $.extend(pte.functions, {
997
+ pteVerifySubmitButtonHandler: pteVerifySubmitButtonHandler
998
+ });
999
+ $('input.pte-size').click(pteCheckHandler.doFunc);
1000
+ return $('.pte-confirm').live('click', function(e) {
1001
+ return pteVerifySubmitButtonHandler.doFunc();
1002
+ });
1003
  };
 
1004
  addSubmitListener = function() {
1005
  var onResizeImages;
1006
  $('#pte-submit').click(function(e) {
1007
  var scale_factor, selection, submit_data;
 
1008
  selection = ias_instance.getSelection();
1009
  scale_factor = $('#pte-sizer').val();
1010
  submit_data = {
1019
  'w': Math.floor(selection.width / scale_factor),
1020
  'h': Math.floor(selection.height / scale_factor)
1021
  };
1022
+ log("===== RESIZE-IMAGES =====");
1023
  log(submit_data);
1024
  ias_instance.setOptions({
1025
  hide: true,
1033
  return true;
1034
  });
1035
  return onResizeImages = function(data, status, xhr) {
1036
+ /* Evaluate data */ log("===== RESIZE-IMAGES SUCCESS =====");
1037
+ log(data);
1038
+ pte.parseServerLog(data.log);
1039
  if ((data.error != null) && !(data.thumbnails != null)) {
1040
  alert(data.error);
1041
  return;
1042
  }
1043
+ $('#stage1').moveLeft();
1044
+ $('#stage2').html($('#stage2template').tmpl(data)).moveLeft({
1045
+ callback: pte.functions.pteVerifySubmitButtonHandler.doFunc
 
 
 
 
 
 
 
 
1046
  });
1047
  return false;
1048
  };
1052
  var onConfirmImages;
1053
  $('#pte-confirm').live('click', function(e) {
1054
  var submit_data, thumbnail_data;
 
1055
  thumbnail_data = {};
1056
  $('input.pte-confirm').filter(':checked').each(function(i, elem) {
1057
  var size;
1065
  'pte-nonce': $('#pte-nonce').val(),
1066
  'pte-confirm': thumbnail_data
1067
  };
1068
+ log("===== CONFIRM-IMAGES =====");
1069
  log(submit_data);
1070
  return $.getJSON(ajaxurl, submit_data, onConfirmImages);
1071
  });
1072
  return onConfirmImages = function(data, status, xhr) {
1073
+ log("===== CONFIRM-IMAGES SUCCESS =====");
1074
  log(data);
1075
+ pte.parseServerLog(data.log);
1076
+ $('#stage2').moveLeft();
1077
+ $('#stage3').html($('#stage3template').tmpl(data)).moveLeft();
 
 
 
 
 
 
 
 
 
1078
  return false;
1079
  };
1080
  };
1081
  /* Select ALL|NONE */
1082
+ addCheckAllNoneListener = function() {
1083
  var checkAllSizes, uncheckAllSizes;
1084
  uncheckAllSizes = function(e) {
1085
  var elements, _ref, _ref2;
1107
  }, uncheckAllSizes);
1108
  return true;
1109
  };
1110
+ return $.extend(pte.functions, {
1111
+ iasSetAR: iasSetAR
1112
+ });
1113
  })(pte);
1114
  }).call(this);
js/pte.full.min.js CHANGED
@@ -1,25 +1,32 @@
1
- (function(a){function B(b,c,f,d){d={data:d||d===0||d===false?d:c?c.data:{},_wrap:c?c._wrap:null,tmpl:null,parent:c||null,nodes:[],calls:m,nest:n,wrap:v,html:s,update:w};b&&a.extend(d,b,{nodes:[],parent:c});if(f){d.tmpl=f;d._ctnt=d._ctnt||d.tmpl(a,d);d.key=++k;(A.length?x:q)[k]=d}return d}function E(b,c,f){var d;f=f?a.map(f,function(h){return typeof h==="string"?b.key?h.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+y+'="'+b.key+'" $2'):h:E(h,b,h._ctnt)}):b;if(c)return f;f=f.join("");f.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,
2
- function(h,i,o,t){d=a(o).get();l(d);if(i)d=I(i).concat(d);if(t)d=d.concat(I(t))});return d?d:I(f)}function I(b){var c=document.createElement("div");c.innerHTML=b;return a.makeArray(c.childNodes)}function F(b){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+a.trim(b).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
3
- function(c,f,d,h,i,o,t){c=a.tmpl.tag[d];if(!c)throw"Unknown template tag: "+d;d=c._default||[];if(o&&!/\w$/.test(i)){i+=o;o=""}if(i){i=G(i);t=t?","+G(t)+")":o?")":"";t=o?i.indexOf(".")>-1?i+G(o):"("+i+").call($item"+t:i;o=o?t:"(typeof("+i+")==='function'?("+i+").call($item):("+i+"))"}else o=t=d.$1||"null";h=G(h);return"');"+c[f?"close":"open"].split("$notnull_1").join(i?"typeof("+i+")!=='undefined' && ("+i+")!=null":"true").split("$1a").join(o).split("$1").join(t).split("$2").join(h||d.$2||"")+"__.push('"})+
4
- "');}return __;")}function p(b,c){b._wrap=E(b,true,a.isArray(c)?c:[j.test(c)?c:a(c).html()]).join("")}function G(b){return b?b.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function l(b){function c(H){function M(L){L+=f;r=i[L]=i[L]||B(r,q[r.parent.key+f]||r.parent)}var C,z=H,r,K;if(K=H.getAttribute(y)){for(;z.parentNode&&(z=z.parentNode).nodeType===1&&!(C=z.getAttribute(y)););if(C!==K){z=z.parentNode?z.nodeType===11?0:z.getAttribute(y)||0:0;if(!(r=q[K])){r=x[K];r=B(r,q[z]||x[z]);r.key=++k;q[k]=r}u&&
5
- M(K)}H.removeAttribute(y)}else if(u&&(r=a.data(H,"tmplItem"))){M(r.key);q[r.key]=r;z=(z=a.data(H.parentNode,"tmplItem"))?z.key:0}if(r){for(C=r;C&&C.key!=z;){C.nodes.push(H);C=C.parent}delete r._ctnt;delete r._wrap;a.data(H,"tmplItem",r)}}var f="_"+u,d,h,i={},o,t,J;o=0;for(t=b.length;o<t;o++)if((d=b[o]).nodeType===1){h=d.getElementsByTagName("*");for(J=h.length-1;J>=0;J--)c(h[J]);c(d)}}function m(b,c,f,d){if(!b)return A.pop();A.push({_:b,tmpl:c,item:this,data:f,options:d})}function n(b,c,f){return a.tmpl(a.template(b),
6
- c,f,this)}function v(b,c){var f=b.options||{};f.wrapped=c;return a.tmpl(a.template(b.tmpl),b.data,f,b.item)}function s(b,c){var f=this._wrap;return a.map(a(a.isArray(f)?f.join(""):f).filter(b||"*"),function(d){if(c)d=d.innerText||d.textContent;else{var h;if(!(h=d.outerHTML)){h=document.createElement("div");h.appendChild(d.cloneNode(true));h=h.innerHTML}d=h}return d})}function w(){var b=this.nodes;a.tmpl(null,null,null,this).insertBefore(b[0]);a(b).remove()}var D=a.fn.domManip,y="_tmplitem",j=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
7
- q={},x={},g,e={key:0,data:{}},k=0,u=0,A=[];a.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(b,c){a.fn[b]=function(f){var d=[];f=a(f);var h,i,o;h=this.length===1&&this[0].parentNode;g=q||{};if(h&&h.nodeType===11&&h.childNodes.length===1&&f.length===1){f[c](this[0]);d=this}else{i=0;for(o=f.length;i<o;i++){u=i;h=(i>0?this.clone(true):this).get();a(f[i])[c](h);d=d.concat(h)}u=0;d=this.pushStack(d,b,f.selector)}f=g;g=null;a.tmpl.complete(f);
8
- return d}});a.fn.extend({tmpl:function(b,c,f){return a.tmpl(this[0],b,c,f)},tmplItem:function(){return a.tmplItem(this[0])},template:function(b){return a.template(b,this[0])},domManip:function(b,c,f){if(b[0]&&a.isArray(b[0])){for(var d=a.makeArray(arguments),h=b[0],i=h.length,o=0,t;o<i&&!(t=a.data(h[o++],"tmplItem")););if(t&&u)d[2]=function(J){a.tmpl.afterManip(this,J,f)};D.apply(this,d)}else D.apply(this,arguments);u=0;g||a.tmpl.complete(q);return this}});a.extend({tmpl:function(b,c,f,d){var h=!d;
9
- if(h){d=e;b=a.template[b]||a.template(null,b);x={}}else if(!b){b=d.tmpl;q[d.key]=d;d.nodes=[];d.wrapped&&p(d,d.wrapped);return a(E(d,null,d.tmpl(a,d)))}if(!b)return[];if(typeof c==="function")c=c.call(d||{});f&&f.wrapped&&p(f,f.wrapped);c=a.isArray(c)?a.map(c,function(i){return i?B(f,d,b,i):null}):[B(f,d,b,c)];return h?a(E(d,null,c)):c},tmplItem:function(b){var c;if(b instanceof a)b=b[0];for(;b&&b.nodeType===1&&!(c=a.data(b,"tmplItem"))&&(b=b.parentNode););return c||e},template:function(b,c){if(c){if(typeof c===
10
- "string")c=F(c);else if(c instanceof a)c=c[0]||{};if(c.nodeType)c=a.data(c,"tmpl")||a.data(c,"tmpl",F(c.innerHTML));return typeof b==="string"?a.template[b]=c:c}return b?typeof b!=="string"?a.template(null,b):a.template[b]||a.template(null,j.test(b)?b:a(b)):null},encode:function(b){return(""+b).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});a.extend(a.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},
11
- wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){q=
12
- {}},afterManip:function(b,c,f){var d=c.nodeType===11?a.makeArray(c.childNodes):c.nodeType===1?[c]:[];f.call(b,c);l(d);u++}})})(jQuery);
13
- (function(){var a,B,E,I,F,p,G=function(l,m){return function(){return l.apply(m,arguments)}};p=this;a=p.jQuery;p.pte=F=F||{};p.log=function(l){if(!p.debug_enabled)return true;try{console.log(l)}catch(m){alert(l)}return true};(function(l){return l.admin=function(){var m,n,v,s,w,D,y;y="&TB_iframe=true&height="+pte_tb_height+"&width="+pte_tb_width;s=null;D=function(j){j=j||s||a("#attachment-id").val();return""+ajaxurl+"?action=pte_ajax&pte-action=launch&id="+j+y};m=function(j){return a('<a class="thickbox" href="'+
14
- D(j)+'">'+objectL10n.PTE+"</a>")};v=function(j){var q,x,g;x=j.jQuery;if(x!==null){log("Got thickbox");g=pte_tb_width+40;q=pte_tb_height;y=x("#TB_window").css({"margin-left":0-g/2,width:g}).children("iframe").css({width:g});return j.setTimeout(function(){return x("iframe",y).css({height:q+100})},1E3)}};n=function(j){log("Start PTE...");if(p.parent.frames.length>0){log("Modifying thickbox...");G(function(){p.parent.tb_click();v(p.parent);return true},this)();return j.stopPropagation()}};w=function(){var j;
15
- j=a("#imgedit-save-target-"+s);if((j!=null?j.size():void 0)<1){p.log("Edit Thumbnail Menu not visible, waiting for 300ms");p.setTimeout(w,300);return false}return j.append(m().click(n))};return function(){a(".media-item").each(function(j,q){var x;x=q.id.replace("media-item-","");return m(x).css({"font-size":".8em","margin-left":"5px"}).click(n).appendTo(a("tr.image-size th.label",q))});if(imageEdit.open!=null){imageEdit.oldopen=imageEdit.open;imageEdit.open=function(j,q){s=j;imageEdit.oldopen(j,q);
16
- return w()}}return true}()}})(F);B=function(){function l(m,n){this.fn=m;this.timeout=n;this.doFunc=G(this.doFunc,this);this.timer=null}l.prototype.doFunc=function(){p.clearTimeout(this.timer);this.timer=p.setTimeout(this.fn,this.timeout);return true};return l}();p.randomness=function(){return Math.floor(Math.random()*1000001).toString(16)};p.debugTmpl=function(l){log(l);return true};p.goBack=function(l){l!=null&&l.preventDefault();return a("#stage2").animate({left:1200},500,"swing",function(){a(this).hide();
17
- return a("#stage1").show(0,function(){return a(this).animate({left:0},500,"swing",function(){var m;log("okay cleanup");m={id:a("#pte-post-id").val(),action:"pte_ajax","pte-action":"delete-images","pte-nonce":a("#pte-delete-nonce").val()};return a.ajax({url:ajaxurl,data:m,global:false,dataType:"json",success:function(n){return n.error!=null?log(n.error):log("Deleted tmp files")}})})})})};I=function(l,m){if(l===0)return m;for(;m>0;)if(l>m)l-=m;else m-=l;if(l<0||m<0)return null;return l};E=function(l,
18
- m){var n,v,s,w;v=thumbnail_info[m];n=v.crop;w=v.width;s=v.height;n=+n;w=+w;s=+s;v=I(w,s);if(n!=null&&n>0){n=null;if((w!=null)>0&&(s!=null)>0)n=v!=null?""+w/v+":"+s/v:""+w+":"+s;if(l!=null&&n!=null&&n!==l)throw"Too many Aspect Ratios. Disabling";return n}};(function(l){var m,n,v,s,w,D,y,j,q,x;l.editor=function(){var g,e;x();v();q();n();s();w();m();g=a("#pte-loading");e=function(){log("Closing load screen");g.hide();return true};a("#pte-preview").load(e);g.ajaxStart(function(){return a(this).fadeIn(200)}).ajaxStop(function(){return a(this).fadeOut(200)});
19
- p.setTimeout(e,2E3);return true};x=function(){var g;g=new B(function(){var e;log("reflow called...");e=a("#pte-sizes").offset();e=a(p).height()-e.top-2;return a("#pte-sizes").height(e)},100);return a(p).resize(g.doFunc).load(g.doFunc)};v=function(){var g;g=function(e){e.delegate("tr","click",function(k){k.target.type!=="checkbox"&&a("input:checkbox",this).click();return true});return e.delegate("input:checkbox","click",function(){this.checked||a(this).is("input:checked")?a(this).parents("tr").first().removeClass("selected"):
20
- a(this).parents("tr").first().addClass("selected");return true})};g(a("#stage2"));return g(a("#stage1"))};j=null;y={keys:true,minWidth:3,minHeight:3,handles:true,zIndex:1200,instance:true,onSelectEnd:function(g,e){if(e.width&&e.width>0&&e.height&&e.height>0&&a(".pte-size").filter(":checked").size()>0){log("Enabling button");return a("#pte-submit").removeAttr("disabled")}else{log("Disabling button");return a("#pte-submit").attr("disabled",true)}}};q=function(){return j=a("#pte-image img").imgAreaSelect(y)};
21
- D=function(g){log("setting aspectRatio: "+g);j.setOptions({aspectRatio:g});return j.update()};n=function(){var g;g=new B(function(){var e;e=null;a("input.pte-size").filter(":checked").each(function(k,u){try{e=E(e,a(u).val())}catch(A){e=null;e!==j.getOptions().aspectRatio&&alert(A);return false}return true});D(e);y.onSelectEnd(null,j.getSelection());return true},50);return a("input.pte-size").click(g.doFunc)};s=function(){var g;a("#pte-submit").click(function(){var e,k;log("Clicked Submit...");k=j.getSelection();
22
- e=a("#pte-sizer").val();e={id:a("#pte-post-id").val(),action:"pte_ajax","pte-action":"resize-images","pte-sizes[]":a(".pte-size").filter(":checked").map(function(){return a(this).val()}).get(),x:Math.floor(k.x1/e),y:Math.floor(k.y1/e),w:Math.floor(k.width/e),h:Math.floor(k.height/e)};log(e);j.setOptions({hide:true,x1:0,y1:0,x2:0,y2:0});a("#pte-submit").attr("disabled",true);a.getJSON(ajaxurl,e,g);return true});return g=function(e){log(e);if(e.error!=null&&e.thumbnails==null)alert(e.error);else{a("#stage1").animate({left:-a(p).width()},
23
- 500,"swing",function(){a(this).hide();a("#stage2").html(a("#stage2template").tmpl(e)).show(0,function(){a(this).animate({left:0},500);return true});return true});return false}}};w=function(){var g;a("#pte-confirm").live("click",function(){var e,k;log("Confirming");k={};a("input.pte-confirm").filter(":checked").each(function(u,A){var b;b=a(A).val();return k[b]=a("#pte-"+b+"-file").val()});e={id:a("#pte-post-id").val(),action:"pte_ajax","pte-action":"confirm-images","pte-nonce":a("#pte-nonce").val(),
24
- "pte-confirm":k};log(e);return a.getJSON(ajaxurl,e,g)});return g=function(e){log(e);a("#stage2").animate({left:-a(p).width()},500,"swing",function(){a(this).hide();a("#stage3").html(a("#stage3template").tmpl(e)).show(0,function(){a(this).animate({left:0},500);return true});return true});return false}};return m=function(){var g,e;e=function(k){var u,A;k!=null&&k.preventDefault();k=(u=(A=k.data)!=null?A.selector:void 0)!=null?u:".pte-size";return a(k).filter(":checked").click()};g=function(k){var u,
25
- A;k!=null&&k.preventDefault();k=(u=k!=null?(A=k.data)!=null?A.selector:void 0:void 0)!=null?u:".pte-size";return a(k).not(":checked").click()};a("#pte-selectors .all").click(g);a("#pte-selectors .none").click(e).click();a("#stage2").delegate("#pte-stage2-selectors .all","click",{selector:".pte-confirm"},g);a("#stage2").delegate("#pte-stage2-selectors .none","click",{selector:".pte-confirm"},e);return true}})(F)}).call(this);
 
 
 
 
 
 
 
1
+ (function(a){function A(f,c,d,b){b={data:b||b===0||b===false?b:c?c.data:{},_wrap:c?c._wrap:null,tmpl:null,parent:c||null,nodes:[],calls:G,nest:H,wrap:o,html:I,update:e};f&&a.extend(b,f,{nodes:[],parent:c});if(d){b.tmpl=d;b._ctnt=b._ctnt||b.tmpl(a,b);b.key=++s;(x.length?m:j)[s]=b}return b}function y(f,c,d){var b;d=d?a.map(d,function(k){return typeof k==="string"?f.key?k.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+h+'="'+f.key+'" $2'):k:y(k,f,k._ctnt)}):f;if(c)return d;d=d.join("");d.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,
2
+ function(k,l,n,t){b=a(n).get();u(b);if(l)b=D(l).concat(b);if(t)b=b.concat(D(t))});return b?b:D(d)}function D(f){var c=document.createElement("div");c.innerHTML=f;return a.makeArray(c.childNodes)}function J(f){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+a.trim(f).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
3
+ function(c,d,b,k,l,n,t){c=a.tmpl.tag[b];if(!c)throw"Unknown template tag: "+b;b=c._default||[];if(n&&!/\w$/.test(l)){l+=n;n=""}if(l){l=B(l);t=t?","+B(t)+")":n?")":"";t=n?l.indexOf(".")>-1?l+B(n):"("+l+").call($item"+t:l;n=n?t:"(typeof("+l+")==='function'?("+l+").call($item):("+l+"))"}else n=t=b.$1||"null";k=B(k);return"');"+c[d?"close":"open"].split("$notnull_1").join(l?"typeof("+l+")!=='undefined' && ("+l+")!=null":"true").split("$1a").join(n).split("$1").join(t).split("$2").join(k||b.$2||"")+"__.push('"})+
4
+ "');}return __;")}function E(f,c){f._wrap=y(f,true,a.isArray(c)?c:[i.test(c)?c:a(c).html()]).join("")}function B(f){return f?f.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function u(f){function c(C){function M(L){L+=d;r=l[L]=l[L]||A(r,j[r.parent.key+d]||r.parent)}var z,w=C,r,K;if(K=C.getAttribute(h)){for(;w.parentNode&&(w=w.parentNode).nodeType===1&&!(z=w.getAttribute(h)););if(z!==K){w=w.parentNode?w.nodeType===11?0:w.getAttribute(h)||0:0;if(!(r=j[K])){r=m[K];r=A(r,j[w]||m[w]);r.key=++s;j[s]=r}v&&
5
+ M(K)}C.removeAttribute(h)}else if(v&&(r=a.data(C,"tmplItem"))){M(r.key);j[r.key]=r;w=(w=a.data(C.parentNode,"tmplItem"))?w.key:0}if(r){for(z=r;z&&z.key!=w;){z.nodes.push(C);z=z.parent}delete r._ctnt;delete r._wrap;a.data(C,"tmplItem",r)}}var d="_"+v,b,k,l={},n,t,F;n=0;for(t=f.length;n<t;n++)if((b=f[n]).nodeType===1){k=b.getElementsByTagName("*");for(F=k.length-1;F>=0;F--)c(k[F]);c(b)}}function G(f,c,d,b){if(!f)return x.pop();x.push({_:f,tmpl:c,item:this,data:d,options:b})}function H(f,c,d){return a.tmpl(a.template(f),
6
+ c,d,this)}function o(f,c){var d=f.options||{};d.wrapped=c;return a.tmpl(a.template(f.tmpl),f.data,d,f.item)}function I(f,c){var d=this._wrap;return a.map(a(a.isArray(d)?d.join(""):d).filter(f||"*"),function(b){if(c)b=b.innerText||b.textContent;else{var k;if(!(k=b.outerHTML)){k=document.createElement("div");k.appendChild(b.cloneNode(true));k=k.innerHTML}b=k}return b})}function e(){var f=this.nodes;a.tmpl(null,null,null,this).insertBefore(f[0]);a(f).remove()}var g=a.fn.domManip,h="_tmplitem",i=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
7
+ j={},m={},q,p={key:0,data:{}},s=0,v=0,x=[];a.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(f,c){a.fn[f]=function(d){var b=[];d=a(d);var k,l,n;k=this.length===1&&this[0].parentNode;q=j||{};if(k&&k.nodeType===11&&k.childNodes.length===1&&d.length===1){d[c](this[0]);b=this}else{l=0;for(n=d.length;l<n;l++){v=l;k=(l>0?this.clone(true):this).get();a(d[l])[c](k);b=b.concat(k)}v=0;b=this.pushStack(b,f,d.selector)}d=q;q=null;a.tmpl.complete(d);
8
+ return b}});a.fn.extend({tmpl:function(f,c,d){return a.tmpl(this[0],f,c,d)},tmplItem:function(){return a.tmplItem(this[0])},template:function(f){return a.template(f,this[0])},domManip:function(f,c,d){if(f[0]&&a.isArray(f[0])){for(var b=a.makeArray(arguments),k=f[0],l=k.length,n=0,t;n<l&&!(t=a.data(k[n++],"tmplItem")););if(t&&v)b[2]=function(F){a.tmpl.afterManip(this,F,d)};g.apply(this,b)}else g.apply(this,arguments);v=0;q||a.tmpl.complete(j);return this}});a.extend({tmpl:function(f,c,d,b){var k=!b;
9
+ if(k){b=p;f=a.template[f]||a.template(null,f);m={}}else if(!f){f=b.tmpl;j[b.key]=b;b.nodes=[];b.wrapped&&E(b,b.wrapped);return a(y(b,null,b.tmpl(a,b)))}if(!f)return[];if(typeof c==="function")c=c.call(b||{});d&&d.wrapped&&E(d,d.wrapped);c=a.isArray(c)?a.map(c,function(l){return l?A(d,b,f,l):null}):[A(d,b,f,c)];return k?a(y(b,null,c)):c},tmplItem:function(f){var c;if(f instanceof a)f=f[0];for(;f&&f.nodeType===1&&!(c=a.data(f,"tmplItem"))&&(f=f.parentNode););return c||p},template:function(f,c){if(c){if(typeof c===
10
+ "string")c=J(c);else if(c instanceof a)c=c[0]||{};if(c.nodeType)c=a.data(c,"tmpl")||a.data(c,"tmpl",J(c.innerHTML));return typeof f==="string"?a.template[f]=c:c}return f?typeof f!=="string"?a.template(null,f):a.template[f]||a.template(null,i.test(f)?f:a(f)):null},encode:function(f){return(""+f).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});a.extend(a.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},
11
+ wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){j=
12
+ {}},afterManip:function(f,c,d){var b=c.nodeType===11?a.makeArray(c.childNodes):c.nodeType===1?[c]:[];d.call(f,c);u(b);v++}})})(jQuery);
13
+ (function(){var a,A,y,D,J,E,B,u,G,H,o,I=function(e,g){return function(){return e.apply(g,arguments)}};o=this;a=o.jQuery;o.pte=u=u||{};(function(e){return e.fixThickbox=function(g){var h,i,j,m;h=g.jQuery;if(!(h===null||g.frames.length<1)){log("===== FIXING THICKBOX =====");m=o.options.pte_tb_width+30;j=o.options.pte_tb_height+38;i=h("#TB_window");if(!(i.width()>=m&&i.height()>=j)){log("THICKBOX: "+i.width()+" x "+i.height());i.css({"margin-left":0-m/2,width:m,height:j}).children("iframe").css({width:m});
14
+ return g.setTimeout(function(){if(!(h("iframe",i).height()>j)){h("iframe",i).css({height:j});log("THICKBOX: "+i.width()+" x "+i.height());return true}},1E3)}}}})(u);H=function(e){return{}.toString.call(e).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};A=function(){function e(g){this.message=g;this.date=new Date}e.prototype.toString=function(){var g,h,i,j,m,q,p;q=function(s,v){for(;(""+s).length<v;)s="0"+s;return s};i=this.date;p=q(i.getUTCFullYear(),4);h=q(i.getUTCMonth()+1,2);g=q(i.getUTCDate(),2);j=
15
+ q(i.getUTCHours(),2);m=q(i.getUTCMinutes(),2);q=q(i.getUTCSeconds(),2);switch(H(this.message)){case "string":i=this.message;break;default:i=a.toJSON(this.message)}return""+p+h+g+" "+j+":"+m+":"+q+" - ["+H(this.message)+"] "+i};return e}();(function(e){e.messages=[];e.log=function(g){if(!o.options.pte_debug)return true;try{e.messages.push(new A(g));console.log(g);a("#pte-log-messages textarea").filter(":visible").val(e.formatLog())}catch(h){}};e.formatLog=function(){var g,h,i,j,m;g="";m=e.messages;
16
+ i=0;for(j=m.length;i<j;i++){h=m[i];g+=""+h+"\n"}return g};e.parseServerLog=function(g){var h,i,j;log("===== SERVER LOG =====");if((g!=null?g.length:void 0)!=null&&g.length>0){i=0;for(j=g.length;i<j;i++){h=g[i];log(h)}}return true};e.sendToPastebin=function(g){return a.ajax({url:"http://dpastey.appspot.com/",data:{title:"PostThumbnailEditor Log",content:g,lexer:"text",format:"json",expire_options:"2592000"},dataType:"json",global:false,type:"POST",error:function(h,i,j){a("#pte-log").fadeOut("900");
17
+ alert(objectL10n.pastebin_create_error);log(h);log(i);return log(j)},success:function(h){a("#pte-log").fadeOut("900");return prompt(objectL10n.pastebin_url,h.url)}})};return true})(u);o.log=u.log;a(document).ready(function(e){e("#test").click(function(g){g.stopImmediatePropagation();return true});e("#pastebin").click(function(){return u.sendToPastebin(u.formatLog())});e("#clear-log").click(function(){u.messages=[];return e("#pte-log-messages textarea").val(u.formatLog())});e("#close-log").click(function(){return e("#pte-log").fadeOut("900")});
18
+ e("#pte-log-tools a").click(function(g){return g.preventDefault()});return e("body").delegate(".show-log-messages","click",function(g){g.preventDefault();e("#pte-log-messages textarea").val(u.formatLog());return e("#pte-log").fadeIn("900")})});(function(e){return e.admin=function(){var g,h,i,j,m,q;q="&TB_iframe=true&height="+o.options.pte_tb_height+"&width="+o.options.pte_tb_width;i=null;m=function(p){p=p||i||a("#attachment-id").val();return""+ajaxurl+"?action=pte_ajax&pte-action=launch&id="+p+q};
19
+ g=function(p){return a('<a class="thickbox" href="'+m(p)+'">'+objectL10n.PTE+"</a>")};h=function(p){log("Start PTE...");if(o.parent.frames.length>0){log("Modifying thickbox...");I(function(){o.parent.tb_click();return true},this)();return p.stopPropagation()}};j=function(){var p;p=a("#imgedit-save-target-"+i);if((p!=null?p.size():void 0)<1){o.log("Edit Thumbnail Menu not visible, waiting for 300ms");o.setTimeout(j,300);return false}return p.append(g().click(h))};return function(){a(".media-item").each(function(p,
20
+ s){var v;v=s.id.replace("media-item-","");return g(v).css({"font-size":".8em","margin-left":"5px"}).click(h).appendTo(a("tr.image-size th.label",s))});if(imageEdit.open!=null){imageEdit.oldopen=imageEdit.open;imageEdit.open=function(p,s){i=p;imageEdit.oldopen(p,s);return j()}}return true}()}})(u);y=function(){function e(g,h){this.fn=g;this.timeout=h;this.doFunc=I(this.doFunc,this);this.timer=null}e.prototype.doFunc=function(){o.clearTimeout(this.timer);this.timer=o.setTimeout(this.fn,this.timeout);
21
+ return true};return e}();o.randomness=function(){return Math.floor(Math.random()*1000001).toString(16)};o.debugTmpl=function(e){log("===== TEMPLATE DEBUG DATA FOLLOWS =====");log(e);return true};D=function(e){e={id:e,action:"pte_ajax","pte-action":"delete-images","pte-nonce":a("#pte-delete-nonce").val()};return a.ajax({url:ajaxurl,data:e,global:false,dataType:"json",success:J})};J=function(e){log("===== DELETE SUCCESSFUL, DATA DUMP FOLLOWS =====");log(e);return u.parseServerLog(e.log)};G=a({});a.fn.extend({move:function(e){e=
22
+ a.extend({direction:"left",speed:500,easing:"swing",toggle:true,callback:null,callbackargs:null},e);this.each(function(){return G.queue(I(function(g){var h,i,j;h=a(this);i=e.direction==="left"?-1:1;j=h.css("left")==="0px"?a(o).width()*i:0;if(h.is(":visible")){h.animate({left:j},e.speed,e.easing);h.hide(0,g)}else h.show(0,function(){return a(this).animate({left:j},e.speed,e.easing,g)});return true},this))});e.callback&&G.queue(function(g){e.callbackargs!=null?e.callback.apply(this,e.callbackargs):
23
+ e.callback.apply(this);return g()});return this},moveRight:function(e){e=a.extend(e,{direction:"right"});return this.move(e)},moveLeft:function(e){e=a.extend(e,{direction:"left"});return this.move(e)}});o.goBack=function(e){e!=null&&e.preventDefault();a("#stage2").moveRight();a("#stage1").moveRight({callback:function(){D(a("#pte-post-id").val());return a("#stage2").html("")}});return true};B=function(e,g){if(e===0)return g;for(;g>0;)if(e>g)e-=g;else g-=e;if(e<0||g<0)return null;return e};E=function(e,
24
+ g){var h,i,j,m;h=g.crop;m=g.width;j=g.height;h=+h;m=+m;j=+j;i=B(m,j);if(h!=null&&h>0){h=null;if((m!=null)>0&&(j!=null)>0)h=i!=null?""+m/i+":"+j/i:""+m+":"+j;if(e!=null&&h!=null&&h!==e)throw objectL10n.aspect_ratio_disabled;e=h}return e};u.functions={determineAspectRatio:E};(function(e){var g,h,i,j,m,q,p,s,v,x,f;e.editor=function(){p();i();f();h();j();m();g();q();return true};q=function(){var c,d;c=a("#pte-loading");d=function(){c.hide();return true};a("#pte-preview").load(d);c.ajaxStart(function(){return a(this).fadeIn(200)}).ajaxStop(function(){return a(this).fadeOut(200)});
25
+ o.setTimeout(d,2E3);return true};p=function(){var c;c=new y(function(){var d;log("===== REFLOW =====");e.fixThickbox(o.parent);d=a("#pte-sizes").offset();d=a(o).height()-d.top-2;return a("#pte-sizes").height(d)},100);a(o).resize(c.doFunc).load(c.doFunc);a("#stage2, #stage3").css({left:a(o).width()});return true};i=function(){var c;c=function(d){d.delegate("tr","click",function(b){b.target.type!=="checkbox"&&a("input:checkbox",this).click();return true});return d.delegate("input:checkbox","click",
26
+ function(){this.checked||a(this).is("input:checked")?a(this).parents("tr").first().removeClass("selected"):a(this).parents("tr").first().addClass("selected");return true})};c(a("#stage2"));return c(a("#stage1"))};x=null;v={keys:true,minWidth:3,minHeight:3,handles:true,zIndex:1200,instance:true,onSelectEnd:function(c,d){return d.width&&d.width>0&&d.height&&d.height>0&&a(".pte-size").filter(":checked").size()>0?a("#pte-submit").removeAttr("disabled"):a("#pte-submit").attr("disabled",true)}};f=function(){return e.ias=
27
+ x=a("#pte-image img").imgAreaSelect(v)};s=function(c){log("===== SETTING ASPECTRATIO: "+c+" =====");x.setOptions({aspectRatio:c});return x.update()};h=function(){var c,d;d=new y(function(){log("===== CHECK SUBMIT BUTTON =====");if(a(".pte-confirm").filter(":checked").size()>0){log("ENABLE");a("#pte-confirm").removeAttr("disabled")}else{log("DISABLE");a("#pte-confirm").attr("disabled",true)}return true},50);c=new y(function(){var b;b=null;a("input.pte-size").filter(":checked").each(function(k,l){try{b=
28
+ E(b,thumbnail_info[a(l).val()])}catch(n){b=null;b!==x.getOptions().aspectRatio&&alert(n);return false}return true});s(b);v.onSelectEnd(null,x.getSelection());return true},50);a.extend(e.functions,{pteVerifySubmitButtonHandler:d});a("input.pte-size").click(c.doFunc);return a(".pte-confirm").live("click",function(){return d.doFunc()})};j=function(){var c;a("#pte-submit").click(function(){var d,b;b=x.getSelection();d=a("#pte-sizer").val();d={id:a("#pte-post-id").val(),action:"pte_ajax","pte-action":"resize-images",
29
+ "pte-sizes[]":a(".pte-size").filter(":checked").map(function(){return a(this).val()}).get(),x:Math.floor(b.x1/d),y:Math.floor(b.y1/d),w:Math.floor(b.width/d),h:Math.floor(b.height/d)};log("===== RESIZE-IMAGES =====");log(d);x.setOptions({hide:true,x1:0,y1:0,x2:0,y2:0});a("#pte-submit").attr("disabled",true);a.getJSON(ajaxurl,d,c);return true});return c=function(d){log("===== RESIZE-IMAGES SUCCESS =====");log(d);e.parseServerLog(d.log);if(d.error!=null&&d.thumbnails==null)alert(d.error);else{a("#stage1").moveLeft();
30
+ a("#stage2").html(a("#stage2template").tmpl(d)).moveLeft({callback:e.functions.pteVerifySubmitButtonHandler.doFunc});return false}}};m=function(){var c;a("#pte-confirm").live("click",function(){var d,b;b={};a("input.pte-confirm").filter(":checked").each(function(k,l){var n;n=a(l).val();return b[n]=a("#pte-"+n+"-file").val()});d={id:a("#pte-post-id").val(),action:"pte_ajax","pte-action":"confirm-images","pte-nonce":a("#pte-nonce").val(),"pte-confirm":b};log("===== CONFIRM-IMAGES =====");log(d);return a.getJSON(ajaxurl,
31
+ d,c)});return c=function(d){log("===== CONFIRM-IMAGES SUCCESS =====");log(d);e.parseServerLog(d.log);a("#stage2").moveLeft();a("#stage3").html(a("#stage3template").tmpl(d)).moveLeft();return false}};g=function(){var c,d;d=function(b){var k,l;b!=null&&b.preventDefault();b=(k=(l=b.data)!=null?l.selector:void 0)!=null?k:".pte-size";return a(b).filter(":checked").click()};c=function(b){var k,l;b!=null&&b.preventDefault();b=(k=b!=null?(l=b.data)!=null?l.selector:void 0:void 0)!=null?k:".pte-size";return a(b).not(":checked").click()};
32
+ a("#pte-selectors .all").click(c);a("#pte-selectors .none").click(d).click();a("#stage2").delegate("#pte-stage2-selectors .all","click",{selector:".pte-confirm"},c);a("#stage2").delegate("#pte-stage2-selectors .none","click",{selector:".pte-confirm"},d);return true};return a.extend(e.functions,{iasSetAR:s})})(u)}).call(this);
js/pte_admin.coffee CHANGED
@@ -7,7 +7,7 @@ do (pte) ->
7
 
8
  pte.admin = ->
9
  timeout = 300
10
- thickbox = """&TB_iframe=true&height=#{ pte_tb_height }&width=#{ pte_tb_width }"""
11
  image_id = null
12
  pte_url = (override_id) ->
13
  id = override_id || image_id || $("#attachment-id").val()
@@ -17,27 +17,8 @@ do (pte) ->
17
 
18
 
19
 
20
- fixThickbox = (parent) ->
21
- p$ = parent.jQuery
22
- if p$ == null then return
23
- log "Got thickbox"
24
- width = pte_tb_width + 40
25
- height = pte_tb_height
26
- thickbox = p$("#TB_window").css
27
- 'margin-left': 0 - (width / 2)
28
- 'width': width
29
- .children("iframe").css
30
- 'width': width
31
- parent.setTimeout ->
32
- p$("iframe", thickbox).css
33
- height: height + 100
34
- #.resize()
35
- , 1000
36
-
37
  checkExistingThickbox = (e) ->
38
  log "Start PTE..."
39
- #if (window.parent?.tb_remove?)
40
- #if window.parent isnt window
41
  if window.parent.frames.length > 0
42
  log "Modifying thickbox..."
43
  # Bind the current context (a href=...) so that thickbox
@@ -45,10 +26,6 @@ do (pte) ->
45
  do =>
46
  #window.parent.setTimeout tb_click, 0
47
  window.parent.tb_click()
48
- # Set the correct width/height
49
- fixThickbox(window.parent)
50
- #$(window.parent.document).append(this).click()
51
- #$(this).appendTo($("body", window.parent.document)).unbind().click()
52
  true
53
  e.stopPropagation()
54
  #
7
 
8
  pte.admin = ->
9
  timeout = 300
10
+ thickbox = """&TB_iframe=true&height=#{ window.options.pte_tb_height }&width=#{ window.options.pte_tb_width }"""
11
  image_id = null
12
  pte_url = (override_id) ->
13
  id = override_id || image_id || $("#attachment-id").val()
17
 
18
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  checkExistingThickbox = (e) ->
21
  log "Start PTE..."
 
 
22
  if window.parent.frames.length > 0
23
  log "Modifying thickbox..."
24
  # Bind the current context (a href=...) so that thickbox
26
  do =>
27
  #window.parent.setTimeout tb_click, 0
28
  window.parent.tb_click()
 
 
 
 
29
  true
30
  e.stopPropagation()
31
  #
js/stage1.js ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function stageOne(pte){
2
+ module("Stage 1");
3
+ test("All/None javascript", function() {
4
+ $menu = $('#pte-selectors');
5
+ $menu.find('.all').click();
6
+ equal($('.pte-size').not(':checked').size(), 0, "All sizes should be clicked");
7
+ $menu.find('.none').click();
8
+ equal($('.pte-size').filter(':checked').size(), 0, "No sizes should be clicked");
9
+ });
10
+
11
+ test("DetermineAspectRatio", function(){
12
+ ok(pte.functions.determineAspectRatio, "determineAspectRatio function exists");
13
+ equal(pte.functions.determineAspectRatio(null, {crop: 1, width: 10, height: 10}),
14
+ "1:1",
15
+ "10x10");
16
+ equal(pte.functions.determineAspectRatio(null, {crop: 1, width: 20, height: 10}),
17
+ "2:1",
18
+ "20x10");
19
+ equal(pte.functions.determineAspectRatio(null, {crop: 0, width: 20, height: 10}),
20
+ null,
21
+ "20x10 - crop set to 0");
22
+ equal(pte.functions.determineAspectRatio("20:1", {crop: 0, width: 20, height: 10}),
23
+ '20:1',
24
+ "20x10 - crop set to 0, previous AR set");
25
+ equal(pte.functions.determineAspectRatio("2:1", {crop: 1, width: 20, height: 10}),
26
+ "2:1",
27
+ "20x10 - previous AR set to 2:1");
28
+ raises(function(){ pte.functions.determineAspectRatio("20:1", {crop: 1, width: 20, height: 10});},
29
+ "20x10 - previous AR set to something different");
30
+ });
31
+
32
+ test("ImgAreaSelect", function(){
33
+ ok(pte.ias, "ImgAreaSelect plugin activated");
34
+ ok(pte.functions.iasSetAR, "iasSetAR function exists");
35
+ getImgAreaSelect = function(){ return pte.ias.getOptions()['aspectRatio']; };
36
+ equal(getImgAreaSelect(), udf, "No aspect ratio should be set");
37
+ pte.functions.iasSetAR("1:1");
38
+ equal(getImgAreaSelect(), "1:1", "aspect ratio should be set");
39
+ });
40
+
41
+ test("Submit button",function(){
42
+ $submit = $('#pte-submit');
43
+ ok($submit.is(':disabled'), "Submit button shouldn't be enabled");
44
+ $('#pte-selectors').find('.all').click();
45
+ ok($submit.is(':disabled'), "Submit button shouldn't be enabled");
46
+ //pte.functions.iasSetAR("1:1");
47
+ // Select the whole image
48
+ var $img = $('#pte-preview');
49
+ //pte.ias.setSelection(0,0,$img.width(), $img.height());
50
+ pte.ias.setOptions({ x1: 0
51
+ , x2: $img.width()
52
+ , y1: 0
53
+ , y2: $img.height()
54
+ , show: true
55
+ });
56
+ pte.ias.update();
57
+ stop();
58
+ window.setTimeout( function(){
59
+ ok($submit.is(':enabled'), "Submit button should be enabled");
60
+ $('#pte-selectors').find('.none').click();
61
+ window.setTimeout( function(){
62
+ ok($submit.is(':disabled'), "Submit button shouldn't be enabled");
63
+ start();
64
+ }, 500 );
65
+ }, 500 );
66
+ });
67
+
68
+ test("Go to Stage 2", function(){
69
+ stop();
70
+ $('#pte-selectors').find('.all').click();
71
+ $('#pte-submit').click()
72
+ window.setTimeout(function(){
73
+ ok($('#stage2').children().size() > 0, "Stage 2 loaded");
74
+ start();
75
+ window.setTimeout( function(){ stageTwo(pte);}, 100 );
76
+ }, 30000);
77
+ });
78
+ }
js/stage2.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function stageTwo(pte){
2
+ module("Stage 2");
3
+ test("All/None javascript", function(){
4
+ expect(4);
5
+ var $menu = $('#pte-stage2-selectors');
6
+ var $verify = $('.pte-confirm');
7
+ ok($verify.size() > 0, "Thumbnails present");
8
+ equal($verify.not(':checked').size(), 0, "All sizes should be checked");
9
+ $menu.find('.none').click();
10
+ stop();
11
+ window.setTimeout(function(){
12
+ equal($('.pte-confirm').filter(':checked').size(), 0, "No sizes should be checked");
13
+ $menu.find('.all').click();
14
+ window.setTimeout(function(){
15
+ equal($verify.not(':checked').size(), 0, "All sizes should be checked");
16
+ start();
17
+ }, 200 );
18
+ }, 200 );
19
+ });
20
+
21
+ // Test the submit button
22
+ test("Submit button",function(){
23
+ //expect(2);
24
+ var $submit = $('#pte-confirm');
25
+ ok($submit.is(':enabled'), "Submit button should be enabled");
26
+ $('#pte-stage2-selectors').find('.none').click();
27
+ //window.setTimeout(function(){
28
+ // ok($submit.is(':disabled'), "Submit button shouldn't be enabled");
29
+ // start();
30
+ //}, 500 );
31
+ });
32
+
33
+ asyncTest("Test going back", function(){
34
+ $('.stage-navigation').click();
35
+ window.setTimeout(function(){
36
+ ok($('#stage2').children().size() == 0, "Stage 2 unloaded");
37
+ start();
38
+ //window.setTimeout( function(){ stageOne(pte);}, 100 );
39
+ }, 5000);
40
+ });
41
+ }
local.mk DELETED
@@ -1,9 +0,0 @@
1
- GOOGLE_WORK = $(wildcard /home/brent/build/closure/compiler.jar)
2
- GOOGLE = $(if $(GOOGLE_WORK),$(GOOGLE_WORK),$(shell cygpath -w -a ~/build/google_closure/compiler.jar))
3
-
4
- YUI_WORK = $(wildcard /home/brent/build/yui_compressor/yuicompressor-2.4.6/build/yuicompressor-2.4.6.jar)
5
- YUI = $(if $(YUI_WORK),$(YUI_WORK),$(shell cygpath -w -a ~/build/yuicompressor-2.4.6/build/yuicompressor-2.4.6.jar))
6
-
7
- #JSMINIFIER = java -jar "$(GOOGLE)" --js $(JSOUTPUT_DEV) --js_output_file $(JSOUTPUT_MIN)
8
- #JSMINIFIER = java -jar "$(GOOGLE)" --js $(JSOUTPUT_DEV) --js_output_file $(JSOUTPUT_MIN) --compilation_level ADVANCED_OPTIMIZATIONS
9
- #CSSMINIFIER = java -jar "$(YUI)" --type css -o $(CSSOUTPUT_MIN) $(CSSOUTPUT_DEV)
 
 
 
 
 
 
 
 
 
pte_functions.php → php/functions.php RENAMED
File without changes
php/log.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PteLogMessage
4
+ {
5
+ public static $ERROR = 1;
6
+ public static $WARN = 2;
7
+ public static $DEBUG = 4;
8
+ protected $message;
9
+ protected $type;
10
+ protected $date;
11
+
12
+ private function getTypeString(){
13
+ switch ($this->type){
14
+ case self::$ERROR:
15
+ return __( "ERROR", PTE_DOMAIN );
16
+ break;
17
+ case self::$WARN:
18
+ return __( "WARNING", PTE_DOMAIN );
19
+ break;
20
+ default:
21
+ return __( "DEBUG", PTE_DOMAIN );
22
+ }
23
+ }
24
+
25
+ public function __construct( $type, $message ){
26
+ if ( !is_int( $type ) || !( $type & self::max_log_level() ) ){
27
+ throw new Exception( "Invalid Log Type: '{$type}'" );
28
+ }
29
+ $this->type = $type;
30
+ $this->message = $message;
31
+ $this->date = getdate();
32
+ }
33
+
34
+ public function __toString(){
35
+ $type = $this->getTypeString();
36
+ return sprintf( "[%s] - %s", $type, $this->message );
37
+ }
38
+ public function getType(){
39
+ return $this->type;
40
+ }
41
+ public function getMessage(){
42
+ return $this->message;
43
+ }
44
+ public static function max_log_level(){
45
+ return self::$ERROR | self::$WARN | self::$DEBUG;
46
+ }
47
+ }
48
+
49
+ class PteLogger {
50
+ private static $instance;
51
+ private $messages = array();
52
+ private $counts = array();
53
+ //private $defaulttype = 4;
54
+ //private $defaulttype = PteLogMessage::$DEBUG;
55
+ private $defaulttype = NULL;
56
+
57
+ private function __construct() {
58
+ $this->defaulttype = PteLogMessage::$DEBUG;
59
+ }
60
+
61
+ public static function singleton()
62
+ {
63
+ if (!isset(self::$instance)) {
64
+ $className = __CLASS__;
65
+ self::$instance = new $className;
66
+ }
67
+ return self::$instance;
68
+ }
69
+
70
+ private function add_message( $message ){
71
+ $type = $message->getType();
72
+
73
+ if ( ! isset( $this->counts[ $type ] ) ){
74
+ $this->counts[ $message->getType() ] = 1;
75
+ }
76
+ else {
77
+ $this->counts[ $message->getType() ]++;
78
+ }
79
+ $this->messages[] = $message;
80
+ }
81
+
82
+ public function get_log_count( $type ){
83
+ return is_int( $this->counts[ $type ] ) ? $this->counts[$type] : 0;
84
+ }
85
+
86
+ /*
87
+ * pte_log
88
+ */
89
+ private function pte_log($message, $type=NULL){
90
+ if ( ! $message instanceof PteLogMessage ){
91
+ if ( is_string( $message ) ){
92
+ if ( is_null( $type ) ){
93
+ $type = $defaulttype;
94
+ }
95
+ try {
96
+ $message = new PteLogMessage( $type, $message );
97
+ }
98
+ catch ( Exception $e ){
99
+ printf( __( "ERROR Logging Message: %s", PTE_DOMAIN ), $message );
100
+ }
101
+ }
102
+ else{
103
+ return false;
104
+ }
105
+ }
106
+ // If debug isn't enabled only track WARN and ERROR messages
107
+ // (throw away DEBUG messages)
108
+ $options = pte_get_options();
109
+ if ( ! $options['pte_debug'] and $type == PteLogMessage::$DEBUG ){
110
+ return false;
111
+ }
112
+
113
+ $this->add_message( $message );
114
+ return true;
115
+ }
116
+
117
+ /*
118
+ * pte_log helper functions
119
+ */
120
+ public function error( $message ){
121
+ $this->pte_log( $message, PteLogMessage::$ERROR );
122
+ }
123
+ public function warn( $message ){
124
+ $this->pte_log( $message, PteLogMessage::$WARN );
125
+ }
126
+ public function debug($message){
127
+ $this->pte_log( $message, PteLogMessage::$DEBUG );
128
+ }
129
+
130
+ public function get_logs( $levels=NULL ){
131
+ // Check that $levels is valid
132
+ $max = PteLogMessage::max_log_level();
133
+ if ( !is_int( $levels ) or $levels < 0 or $levels > $max ){
134
+ $levels = $max;
135
+ }
136
+
137
+ foreach ( $this->messages as $message ){
138
+ // If the current Level is requested, add to output
139
+ if ( $levels & $message->getType() ){
140
+ $output[] = $message->__toString();
141
+ }
142
+ }
143
+ return $output;
144
+ }
145
+
146
+ }
147
+
148
+ ?>
php/options.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Anonymous Functions that can't be anonymous thanks to
4
+ // some versions of PHP
5
+ function pte_noop(){}
6
+ function pte_edit_posts_cap( $capability ){ return 'edit_posts'; }
7
+ function pte_site_options_html(){
8
+ _e( "These site-wide settings can only be changed by an administrator", PTE_DOMAIN );
9
+ }
10
+
11
+ //http://ottopress.com/2009/wordpress-settings-api-tutorial/
12
+ function pte_options_init(){
13
+ add_filter( 'option_page_capability_pte_options', 'pte_edit_posts_cap' );
14
+ register_setting( 'pte_options',
15
+ pte_get_option_name(),
16
+ 'pte_options_validate' );
17
+
18
+ add_settings_section( 'pte_main'
19
+ , __('User Options', PTE_DOMAIN)
20
+ , 'pte_noop'
21
+ , 'pte' );
22
+
23
+ add_settings_field( 'pte_dimensions',
24
+ __('Thickbox dimensions', PTE_DOMAIN),
25
+ 'pte_dimensions_display',
26
+ 'pte',
27
+ 'pte_main' );
28
+
29
+ add_settings_field( 'pte_debug',
30
+ __('Debug', PTE_DOMAIN),
31
+ 'pte_debug_display',
32
+ 'pte',
33
+ 'pte_main' );
34
+
35
+ add_settings_field( 'pte_reset',
36
+ __('Reset to defaults', PTE_DOMAIN),
37
+ 'pte_reset_display',
38
+ 'pte',
39
+ 'pte_main' );
40
+
41
+ // Only show for admins...//
42
+ if ( current_user_can( 'manage_options' ) ){
43
+ register_setting( 'pte_options',
44
+ 'pte-site-options',
45
+ 'pte_site_options_validate' );
46
+ add_settings_section( 'pte_site'
47
+ , __('Site Options', PTE_DOMAIN)
48
+ , 'pte_site_options_html'
49
+ , 'pte' );
50
+ add_settings_field( 'pte_sizes',
51
+ __('Thumbnails', PTE_DOMAIN),
52
+ 'pte_sizes_display',
53
+ 'pte',
54
+ 'pte_site' );
55
+ }
56
+ // End Admin only
57
+
58
+ }
59
+
60
+ function pte_options_page(){
61
+ /*<code><pre><?php print_r( pte_get_options() ); ?></pre></code>*/
62
+ ?>
63
+ <div class="wrap">
64
+ <h2><?php _e('Post Thumbnail Editor', PTE_DOMAIN); ?></h2>
65
+ <form action="options.php" method="post">
66
+ <?php settings_fields('pte_options'); ?>
67
+ <?php do_settings_sections('pte'); ?>
68
+ <p class="submit">
69
+ <input class="button-primary"
70
+ name="Submit"
71
+ type="submit"
72
+ value="<?php esc_attr_e('Save Changes', PTE_DOMAIN); ?>" />
73
+ </p>
74
+ </form>
75
+ </div>
76
+ <?php
77
+ }
78
+
79
+ /*********** Internal to options **************************************/
80
+
81
+ function pte_site_options_validate( $input ){
82
+ //$sizes = pte_get_alternate_sizes(false);
83
+ if ( !current_user_can( 'manage_options' ) ){
84
+ add_settings_error('pte_options_site'
85
+ , 'pte_options_error'
86
+ , __( "Only users with the 'manage_options' capability may make changes to these settings.", PTE_DOMAIN ) );
87
+ return pte_get_site_options();
88
+ }
89
+ $sizes = get_intermediate_image_sizes();
90
+
91
+ $pte_hidden_sizes = array();
92
+
93
+ foreach ( $sizes as $size ){
94
+ // Hidden
95
+ if ( is_array( $input['pte_hidden_sizes'] )
96
+ and in_array( $size, $input['pte_hidden_sizes'] ) ){
97
+ $pte_hidden_sizes[] = $size;
98
+ }
99
+ }
100
+
101
+
102
+ $output = array( 'pte_hidden_sizes' => $pte_hidden_sizes );
103
+ return $output;
104
+ }
105
+
106
+ function pte_options_validate( $input ){
107
+ $options = pte_get_user_options();
108
+
109
+ if ( isset( $input['reset'] ) ){
110
+ return array();
111
+ }
112
+ $options['pte_debug'] = isset( $input['pte_debug'] );
113
+
114
+ $tmp_width = (int) preg_replace( "/[\D]/", "", $input['pte_tb_width'] );
115
+ if ( !is_int( $tmp_width ) || $tmp_width < 750 ){
116
+ add_settings_error('pte_options'
117
+ , 'pte_options_error'
118
+ , __( "Thickbox width must be at least 750 pixels.", PTE_DOMAIN ) );
119
+ }
120
+ else {
121
+ $options['pte_tb_width'] = $tmp_width;
122
+ }
123
+
124
+ $tmp_height = (int) preg_replace( "/[\D]/", "", $input['pte_tb_height'] );
125
+ if ( !is_int( $tmp_height ) || $tmp_height < 550 ){
126
+ add_settings_error('pte_options'
127
+ , 'pte_options_error'
128
+ , __( "Thickbox height must be greater than 550 pixels.", PTE_DOMAIN ) );
129
+ }
130
+ else {
131
+ $options['pte_tb_height'] = $tmp_height;
132
+ }
133
+
134
+ return $options;
135
+ }
136
+
137
+ function pte_dimensions_display(){
138
+ $options = pte_get_options();
139
+ $option_label = pte_get_option_name();
140
+
141
+ ?>
142
+ <label for="pte_tb_width"><?php _e( 'Width:', PTE_DOMAIN ); ?></label><br/>
143
+ <span><input class="small-text" type="text" name="<?php
144
+ print $option_label;
145
+ ?>[pte_tb_width]" value="<?php print $options['pte_tb_width']; ?>" id="pte_tb_width">&nbsp;
146
+ <?php _e("Set this to a value greater than 750.", PTE_DOMAIN); ?>
147
+ </span>
148
+
149
+ <br/>
150
+
151
+ <span>
152
+ <label for="pte_tb_height"><?php
153
+ _e( 'Height:', PTE_DOMAIN );
154
+ ?></label><br/><input class="small-text" type="text" name="<?php
155
+ print $option_label;
156
+ ?>[pte_tb_height]" value="<?php print $options['pte_tb_height']; ?>" id="pte_tb_height">&nbsp;
157
+ <?php _e("Set this to a value greater than 550.", PTE_DOMAIN);
158
+ print( "</span>" );
159
+ }
160
+
161
+ function pte_debug_display(){
162
+ $options = pte_get_options();
163
+ $option_label = pte_get_option_name();
164
+ ?>
165
+ <span><input type="checkbox" name="<?php
166
+ print $option_label
167
+ ?>[pte_debug]" <?php
168
+ if ( $options['pte_debug'] ): print "checked"; endif;
169
+ ?> id="pte_debug"/>&nbsp;<label for="pte_debug"><?php _e( 'Enable debugging', PTE_DOMAIN ); ?></label>
170
+ </span>
171
+ <?php
172
+ }
173
+
174
+ function pte_reset_display(){
175
+ ?>
176
+ <input class="button-secondary" name="<?php
177
+ echo( pte_get_option_name() );
178
+ ?>[reset]" type="submit" value="<?php esc_attr_e('Reset User Options', PTE_DOMAIN); ?>" />
179
+ <?php
180
+ }
181
+
182
+ function pte_gcd($a, $b){
183
+ if ( $a == 0 ) return b;
184
+ while( $b > 0 ){
185
+ if ( $a > $b ){
186
+ $a = $a - $b;
187
+ }
188
+ else {
189
+ $b = $b - $a;
190
+ }
191
+ }
192
+ if ( $a < 0 or $b < 0 ){
193
+ return null;
194
+ }
195
+ return $a;
196
+ }
197
+
198
+ function pte_sizes_display(){
199
+ require_once( 'functions.php' );
200
+ $options = pte_get_options();
201
+
202
+ // Table Header
203
+ ?>
204
+ <table><tr><th><?php _e("Post Thumbnail", PTE_DOMAIN); ?></th>
205
+ <th><?php _e( "Hidden", PTE_DOMAIN ); ?></th>
206
+ </tr>
207
+ <?php
208
+ // End table header
209
+
210
+ $sizes = pte_get_alternate_sizes(false);
211
+
212
+ foreach ( $sizes as $size => $size_data ){
213
+ $hidden = ( in_array( $size, $options['pte_hidden_sizes'] ) ) ?
214
+ "checked":"";
215
+
216
+ print( "<tr><td><label for='{$size}'>{$size}</label></td>"
217
+ . "<td><input type='checkbox' id='{$size}' name='pte-site-options[pte_hidden_sizes][]'"
218
+ . " value='{$size}' {$hidden}></td>"
219
+ . "</tr>"
220
+ );
221
+ }
222
+
223
+ print( '</table>' );
224
+ }
225
+ ?>
post-thumbnail-editor.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin URI: http://wordpress.org/extend/plugins/post-thumbnail-editor/
4
  Author: sewpafly
5
  Author URI: http://sewpafly.github.com/post-thumbnail-editor
6
- Version: 1.0.0
7
  Description: Individually manage your post thumbnails
8
 
9
  LICENSE
@@ -34,14 +34,51 @@
34
  */
35
  define( 'PTE_PLUGINURL', plugins_url(basename( dirname(__FILE__))) . "/");
36
  define( 'PTE_PLUGINPATH', dirname(__FILE__) . "/");
37
- define( 'PTE_VERSION', "1.0.0");
38
- define( 'PTE_TB_WIDTH', 750 ); // Only edit this if you feel like living dangerously... Thar be dragons...
39
- define( 'PTE_TB_HEIGHT', 550 ); // This could go larger but I wouldn't go much smaller
40
- // Pictures take up 400px with the header and potential error space
41
- // 600 seems the best safe number.
42
- // Difficult to say with different screen heights
43
 
44
- define( 'PTE_DEBUG', false ); // Eventually add a control panel option for this
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  /*
47
  * Put Hooks and immediate hook functions in this file
@@ -55,8 +92,9 @@ function pte_enable_thickbox(){
55
 
56
  function pte_admin_media_scripts(){
57
  pte_enable_thickbox();
 
58
 
59
- if ( PTE_DEBUG ){
60
  wp_enqueue_script( 'pte'
61
  , PTE_PLUGINURL . 'js/pte.full.js'
62
  , array('jquery')
@@ -78,25 +116,27 @@ function pte_admin_media_scripts(){
78
  }
79
 
80
  function pte_enable_admin_js(){
81
- $debug = PTE_DEBUG ? "var debug_enabled = true;" : "";
82
- $pte_tb_width = PTE_TB_WIDTH;
83
- $pte_tb_height = PTE_TB_HEIGHT;
84
  echo <<<EOT
85
  <script type="text/javascript">
86
- {$debug}
87
- var pte_tb_width = {$pte_tb_width};
88
- var pte_tb_height = {$pte_tb_height};
89
  jQuery( function(){ pte.admin(); } );
90
  </script>
91
  EOT;
92
  }
93
 
 
94
  function pte_ajax(){
95
  // Move all adjuntant functions to a separate file and include that here
96
- require_once(PTE_PLUGINPATH . 'pte_functions.php');
 
 
97
 
98
  switch ($_GET['pte-action'])
99
  {
 
 
 
100
  case "launch":
101
  pte_launch();
102
  break;
@@ -110,21 +150,44 @@ function pte_ajax(){
110
  pte_delete_images();
111
  break;
112
  }
113
- die(-1);
114
  }
115
 
116
  function pte_media_row_actions($actions, $post, $detached){
 
117
  if ( !current_user_can( 'edit_post', $post->ID ) ){
118
  return $actions;
119
  }
 
120
  $pte_url = admin_url('admin-ajax.php')
121
  . "?action=pte_ajax&pte-action=launch&id="
122
  . $post->ID
123
- . "&TB_iframe=true&height=". PTE_TB_HEIGHT ."&width=". PTE_TB_WIDTH;
124
- $actions['pte'] = "<a class='thickbox' href='${pte_url}' title='Edit Thumbnails'>Thumbnails</a>";
 
 
125
  return $actions;
126
  }
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  /* This is the main admin media page */
129
  add_action('admin_print_styles-media.php', 'pte_admin_media_scripts');
130
 
@@ -143,4 +206,15 @@ add_filter('media_row_actions', 'pte_media_row_actions', 10, 3); // priority: 10
143
  /* For all purpose needs */
144
  add_action('wp_ajax_pte_ajax', 'pte_ajax');
145
 
 
 
 
 
 
 
 
 
 
 
 
146
  ?>
3
  Plugin URI: http://wordpress.org/extend/plugins/post-thumbnail-editor/
4
  Author: sewpafly
5
  Author URI: http://sewpafly.github.com/post-thumbnail-editor
6
+ Version: 1.0.1
7
  Description: Individually manage your post thumbnails
8
 
9
  LICENSE
34
  */
35
  define( 'PTE_PLUGINURL', plugins_url(basename( dirname(__FILE__))) . "/");
36
  define( 'PTE_PLUGINPATH', dirname(__FILE__) . "/");
37
+ define( 'PTE_DOMAIN', "post-thumbnail-editor");
38
+ define( 'PTE_VERSION', "1.0.1");
 
 
 
 
39
 
40
+ /*
41
+ * Option Functionality
42
+ */
43
+ function pte_get_option_name(){
44
+ global $current_user;
45
+ if ( ! isset( $current_user ) ){
46
+ get_currentuserinfo();
47
+ }
48
+ return "pte-option-{$current_user->ID}";
49
+ }
50
+
51
+ function pte_get_user_options(){
52
+ $pte_options = get_option( pte_get_option_name() );
53
+ if ( !is_array( $pte_options ) ){
54
+ $pte_options = array();
55
+ }
56
+ $defaults = array( 'pte_tb_width' => 750
57
+ , 'pte_tb_height' => 550
58
+ , 'pte_debug' => false
59
+ );
60
+ return array_merge( $defaults, $pte_options );
61
+ }
62
+
63
+ function pte_get_site_options(){
64
+ $pte_site_options = get_option( 'pte-site-options' );
65
+ if ( !is_array( $pte_site_options ) ){
66
+ $pte_site_options = array();
67
+ }
68
+ $defaults = array( 'pte_hidden_sizes' => array() );
69
+ return array_merge( $defaults, $pte_site_options );
70
+ }
71
+
72
+ function pte_get_options(){
73
+ global $pte_options, $current_user;
74
+ if ( isset( $pte_options ) ){
75
+ return $pte_options;
76
+ }
77
+
78
+ $pte_options = array_merge( pte_get_user_options(), pte_get_site_options() );
79
+
80
+ return $pte_options;
81
+ }
82
 
83
  /*
84
  * Put Hooks and immediate hook functions in this file
92
 
93
  function pte_admin_media_scripts(){
94
  pte_enable_thickbox();
95
+ $options = pte_get_options();
96
 
97
+ if ( $options['pte_debug'] ){
98
  wp_enqueue_script( 'pte'
99
  , PTE_PLUGINURL . 'js/pte.full.js'
100
  , array('jquery')
116
  }
117
 
118
  function pte_enable_admin_js(){
119
+ $options = json_encode( pte_get_options() );
 
 
120
  echo <<<EOT
121
  <script type="text/javascript">
122
+ var options = {$options};
 
 
123
  jQuery( function(){ pte.admin(); } );
124
  </script>
125
  EOT;
126
  }
127
 
128
+ // Base url/function. All pte interactions go through here
129
  function pte_ajax(){
130
  // Move all adjuntant functions to a separate file and include that here
131
+ require_once(PTE_PLUGINPATH . 'php/functions.php');
132
+ $logger = PteLogger::singleton();
133
+ $logger->debug( "PARAMETERS: " . print_r( $_REQUEST, true ) );
134
 
135
  switch ($_GET['pte-action'])
136
  {
137
+ case "test":
138
+ pte_test();
139
+ break;
140
  case "launch":
141
  pte_launch();
142
  break;
150
  pte_delete_images();
151
  break;
152
  }
153
+ die();
154
  }
155
 
156
  function pte_media_row_actions($actions, $post, $detached){
157
+ // Add capability check
158
  if ( !current_user_can( 'edit_post', $post->ID ) ){
159
  return $actions;
160
  }
161
+ $options = pte_get_options();
162
  $pte_url = admin_url('admin-ajax.php')
163
  . "?action=pte_ajax&pte-action=launch&id="
164
  . $post->ID
165
+ . "&TB_iframe=true&height={$options['pte_tb_height']}&width={$options['pte_tb_width']}";
166
+ $actions['pte'] = "<a class='thickbox' href='${pte_url}' title='"
167
+ . __( 'Edit Thumbnails', PTE_DOMAIN )
168
+ . "'>" . __( 'Thumbnails', PTE_DOMAIN ) . "</a>";
169
  return $actions;
170
  }
171
 
172
+ // Anonymous function (which apparently some versions of PHP will whine about)
173
+ function pte_launch_options_page(){
174
+ require_once( PTE_PLUGINPATH . 'php/options.php' ); pte_options_page();
175
+ }
176
+
177
+ function pte_admin_menu(){
178
+ add_options_page( __('Post Thumbnail Editor', PTE_DOMAIN) . "-title",
179
+ __('Post Thumbnail Editor', PTE_DOMAIN),
180
+ 'edit_posts', // Set the capability to null as every user can have different settings set
181
+ 'pte',
182
+ 'pte_launch_options_page'
183
+ );
184
+ }
185
+
186
+ function pte_options(){
187
+ require_once( PTE_PLUGINPATH . 'php/options.php' );
188
+ pte_options_init();
189
+ }
190
+
191
  /* This is the main admin media page */
192
  add_action('admin_print_styles-media.php', 'pte_admin_media_scripts');
193
 
206
  /* For all purpose needs */
207
  add_action('wp_ajax_pte_ajax', 'pte_ajax');
208
 
209
+ /* Add Settings Page */
210
+ add_action( 'admin_menu', 'pte_admin_menu' );
211
+ add_action( 'settings_page_pte', 'pte_options' );
212
+ add_action( 'load-options.php', 'pte_options' );
213
+ //add_action( 'admin_init', 'pte_options' );
214
+
215
+ /** End Settings Hooks **/
216
+
217
+ load_plugin_textdomain( PTE_DOMAIN
218
+ , false
219
+ , basename( PTE_PLUGINPATH ) . DIRECTORY_SEPARATOR . "i18n" );
220
  ?>