Post Thumbnail Editor - Version 1.0.7

Version Description

  • Updated for Wordpress 3.5 (introduces backwards incompatible changes)
  • Other bug fixes
Download this release

Release Info

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

Code changes from version 1.0.5 to 1.0.7

Makefile ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ JSOUTPUT_DEV = js/pte.full.dev.js
3
+ JSOUTPUT_MIN = js/pte.full.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
+ TMPFILE := $(shell mktemp)
12
+
13
+
14
+ CSSOUTPUT_DEV = css/pte.dev.css
15
+ CSSOUTPUT_MIN = css/pte.css
16
+ SCSSFILE = css/pte.scss
17
+ SASS = sass
18
+ CSSFILES = css/reset.css
19
+
20
+ # create/overwrite the JSMINIFIER command for local
21
+ # local.mk is not tracked in git project
22
+ include $(wildcard local.mk)
23
+
24
+ # The GOOGLE macro is defined in local.mk to point to compiler.jar
25
+ ifdef GOOGLE
26
+ JSMINIFIER = java -jar "$(GOOGLE)" --js $(JSOUTPUT_DEV) --js_output_file $(JSOUTPUT_MIN)
27
+ else
28
+ JSMINIFIER = cp $(JSOUTPUT_DEV) $(JSOUTPUT_MIN)
29
+ endif
30
+
31
+ # The YUI macro is defined in local.mk to point to yuicompressor.jar
32
+ ifdef YUI
33
+ CSSMINIFIER = java -jar "$(YUI)" --type css -o $(CSSOUTPUT_MIN) $(CSSOUTPUT_DEV)
34
+ else
35
+ CSSMINIFIER = cp $(CSSOUTPUT_DEV) $(CSSOUTPUT_MIN)
36
+ endif
37
+
38
+
39
+ # A simple make will compile the js/css and minify them
40
+ all: minify-js minify-css trans
41
+
42
+ # Build javascript
43
+ $(JSOUTPUT_MIN): $(JSOUTPUT_DEV)
44
+ @echo "Minifying javascript"
45
+ $(JSMINIFIER)
46
+
47
+ $(JSOUTPUT_DEV): $(COFFEE_FILES) $(JS_FILES)
48
+ @echo "Building javascript"
49
+ cat $(JS_FILES) > $(JSOUTPUT_DEV)
50
+ cat $(COFFEE_FILES) > $(TMPFILE)
51
+ $(COFFEE) $(COFFEE_FLAGS) < $(TMPFILE) >> $(JSOUTPUT_DEV)
52
+
53
+
54
+ # BUILD CSS
55
+ $(CSSOUTPUT_DEV): $(SCSSFILE) $(CSSFILES)
56
+ @echo "Building CSS"
57
+ cat $(CSSFILES) > $(CSSOUTPUT_DEV)
58
+ $(SASS) $(SCSSFILE) >> $(CSSOUTPUT_DEV)
59
+
60
+ $(CSSOUTPUT_MIN): $(CSSOUTPUT_DEV)
61
+ @echo "Minifying CSS"
62
+ $(CSSMINIFIER)
63
+
64
+ # Shortcuts
65
+ js: $(JSOUTPUT_DEV)
66
+ minify-js: $(JSOUTPUT_MIN)
67
+ css: $(CSSOUTPUT_DEV)
68
+ minify-css: $(CSSOUTPUT_MIN)
69
+
70
+ # i18n - Defined in local.mk to point to wordpress makepot.php script
71
+ trans:
72
+ @echo "Creating Internationalization Template"
73
+ ifdef I18N
74
+ cd i18n; \
75
+ php '$(I18N)' wp-plugin ../
76
+ endif
77
+
78
+ # Clean
79
+ OUTPUTFILES = $(wildcard $(CSSOUTPUT_MIN) $(CSSOUTPUT_DEV) $(JSOUTPUT_MIN) $(JSOUTPUT_DEV))
80
+ clean:
81
+ @echo "Cleaning up"
82
+ $(if $(OUTPUTFILES), rm $(OUTPUTFILES))
83
+
84
+ # vi: ts=3
README.txt CHANGED
@@ -2,8 +2,8 @@
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
6
- Tested up to: 3.3.1
7
  Stable tag: trunk
8
 
9
  Fed up with the lack of automated tools to properly crop and scale post thumbnails? Maybe this plugin can help.
@@ -63,6 +63,10 @@ Using a version with [json_encode](http://www.php.net/manual/en/function.json-en
63
 
64
  == Changelog ==
65
 
 
 
 
 
66
  = 1.0.5 =
67
  * Fix custom sizes with either height or width set to '0'
68
  * Added German translation
@@ -102,6 +106,9 @@ Using a version with [json_encode](http://www.php.net/manual/en/function.json-en
102
 
103
  == Upgrade Notice ==
104
 
 
 
 
105
  = 1.0.5 =
106
  Bugfix & added German translation
107
 
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.5
6
+ Tested up to: 3.5
7
  Stable tag: trunk
8
 
9
  Fed up with the lack of automated tools to properly crop and scale post thumbnails? Maybe this plugin can help.
63
 
64
  == Changelog ==
65
 
66
+ = 1.0.7 =
67
+ * Updated for Wordpress 3.5 (introduces backwards incompatible changes)
68
+ * Other bug fixes
69
+
70
  = 1.0.5 =
71
  * Fix custom sizes with either height or width set to '0'
72
  * Added German translation
106
 
107
  == Upgrade Notice ==
108
 
109
+ = 1.0.7 =
110
+ Only for Wordpress 3.5+ (bug fixes)
111
+
112
  = 1.0.5 =
113
  Bugfix & added German translation
114
 
apps/jquery-tmpl/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- build/dist
2
- docs
3
- .project
4
- *~
5
- *.diff
6
- *.patch
7
- .DS_Store
 
 
 
 
 
 
 
css/pte.css CHANGED
@@ -1,304 +1 @@
1
-
2
- /* http://meyerweb.com/eric/tools/css/reset/
3
- v2.0 | 20110126
4
- License: none (public domain)
5
- */
6
-
7
- html, body, div, span, applet, object, iframe,
8
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
9
- a, abbr, acronym, address, big, cite, code,
10
- del, dfn, em, img, ins, kbd, q, s, samp,
11
- small, strike, strong, sub, sup, tt, var,
12
- b, u, i, center,
13
- dl, dt, dd, ol, ul, li,
14
- fieldset, form, label, legend,
15
- table, caption, tbody, tfoot, thead, tr, th, td,
16
- article, aside, canvas, details, embed,
17
- figure, figcaption, footer, header, hgroup,
18
- menu, nav, output, ruby, section, summary,
19
- time, mark, audio, video {
20
- margin: 0;
21
- padding: 0;
22
- border: 0;
23
- font-size: 100%;
24
- font: inherit;
25
- vertical-align: baseline;
26
- }
27
- /* HTML5 display-role reset for older browsers */
28
- article, aside, details, figcaption, figure,
29
- footer, header, hgroup, menu, nav, section {
30
- display: block;
31
- }
32
- body {
33
- line-height: 1;
34
- }
35
- ol, ul {
36
- list-style: none;
37
- }
38
- blockquote, q {
39
- quotes: none;
40
- }
41
- blockquote:before, blockquote:after,
42
- q:before, q:after {
43
- content: '';
44
- content: none;
45
- }
46
- table {
47
- border-collapse: collapse;
48
- border-spacing: 0;
49
- }
50
- /* Generated variables */
51
- a.stage-navigation, a.stage-navigation:visited {
52
- color: #38ab36;
53
- font-family: 'Amaranth', serif;
54
- font-size: 0.8em;
55
- font-style: italic;
56
- text-decoration: none;
57
- text-shadow: none; }
58
- a.stage-navigation img, a.stage-navigation:visited img {
59
- border: none;
60
- vertical-align: bottom; }
61
-
62
- a {
63
- color: #444;
64
- font-family: 'Amaranth', serif;
65
- font-style: italic;
66
- text-shadow: none; }
67
- a:visited {
68
- color: #black; }
69
- a img {
70
- vertical-align: bottom; }
71
-
72
- h1 {
73
- color: #2386e2;
74
- font-family: 'Amaranth', serif;
75
- font-style: italic;
76
- font-size: 1.6em;
77
- text-shadow: white 1px 1px 5px, 2px 2px 10px #999; }
78
-
79
- body {
80
- font-family: 'PT Serif', serif;
81
- /*font-family: 'Puritan', serif;*/
82
- /*overflow: auto;*/
83
- overflow-x: hidden;
84
- margin: auto;
85
- max-width: 750px;
86
- background-color: #efefef;
87
- /*position: relative;*/
88
- /*border: 1px solid black;*/ }
89
-
90
- #pte-image {
91
- float: left;
92
- margin-top: 5px;
93
- width: 402px; }
94
- #pte-image img {
95
- display: block;
96
- margin: auto; }
97
-
98
- #pte-buttons button {
99
- font-family: "Amaranth", Tahoma, sans-serif;
100
- font-size: larger;
101
- line-height: 130%;
102
- margin: 10px auto;
103
- padding: 10px;
104
- width: 100%; }
105
-
106
- #pte-confirm {
107
- font-family: "Amaranth", Tahoma, sans-serif;
108
- font-size: larger;
109
- line-height: 130%;
110
- margin: 10px auto;
111
- padding: 10px;
112
- width: 75%; }
113
-
114
- #pte-sizes-container {
115
- overflow: auto;
116
- padding-left: 15px;
117
- float: left;
118
- width: 331px; }
119
-
120
- #pte-selectors, #pte-stage2-selectors {
121
- margin-bottom: 10px; }
122
-
123
- #pte-sizes {
124
- overflow-x: hidden;
125
- overflow-y: scroll;
126
- position: relative;
127
- border: 1px solid #dddddd;
128
- /*width: $pte-sizes-width;*/
129
- /*width: 100%;*/ }
130
- #pte-sizes img {
131
- max-width: 296px; }
132
-
133
- table tr {
134
- border-bottom: 1px solid #dddddd; }
135
- table tr.selected {
136
- background-color: #fff; }
137
-
138
- table td {
139
- position: relative;
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
- /*}*/
153
- .pte-size-label {
154
- /*background: #bcbcbc;*/
155
- background: #cdcdcd;
156
- bottom: 0;
157
- font-family: 'Amaranth', serif;
158
- font-weight: bolder;
159
- padding: 5px 0px 7px 5px;
160
- /*padding: 5px;*/ }
161
- .pte-size-label .actual {
162
- font-size: 0.8em;
163
- font-weight: normal; }
164
-
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;
275
- left: 0;
276
- position: relative;
277
- top: 0;
278
- /*overflow: hidden;*/
279
- /*width: $width;*/ }
280
-
281
- #stage2, #stage3 {
282
- display: none;
283
- /*left: $width * 2;*/
284
- width: 750px; }
285
-
286
- table {
287
- width: 100%; }
288
-
289
- #stage2 img {
290
- /*max-width: 100%;*/
291
- max-width: 710px; }
292
-
293
- #error {
294
- color: #aa0000; }
295
- #error ul {
296
- list-style: disc;
297
- margin: 10px 0px 10px 20px;
298
- /*li { */
299
- /* list-style-image: 'disc';*/
300
- /*} */ }
301
-
302
- #success {
303
- color: #38ab36;
304
- 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.dev.css ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* http://meyerweb.com/eric/tools/css/reset/
3
+ v2.0 | 20110126
4
+ License: none (public domain)
5
+ */
6
+
7
+ html, body, div, span, applet, object, iframe,
8
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
9
+ a, abbr, acronym, address, big, cite, code,
10
+ del, dfn, em, img, ins, kbd, q, s, samp,
11
+ small, strike, strong, sub, sup, tt, var,
12
+ b, u, i, center,
13
+ dl, dt, dd, ol, ul, li,
14
+ fieldset, form, label, legend,
15
+ table, caption, tbody, tfoot, thead, tr, th, td,
16
+ article, aside, canvas, details, embed,
17
+ figure, figcaption, footer, header, hgroup,
18
+ menu, nav, output, ruby, section, summary,
19
+ time, mark, audio, video {
20
+ margin: 0;
21
+ padding: 0;
22
+ border: 0;
23
+ font-size: 100%;
24
+ font: inherit;
25
+ vertical-align: baseline;
26
+ }
27
+ /* HTML5 display-role reset for older browsers */
28
+ article, aside, details, figcaption, figure,
29
+ footer, header, hgroup, menu, nav, section {
30
+ display: block;
31
+ }
32
+ body {
33
+ line-height: 1;
34
+ }
35
+ ol, ul {
36
+ list-style: none;
37
+ }
38
+ blockquote, q {
39
+ quotes: none;
40
+ }
41
+ blockquote:before, blockquote:after,
42
+ q:before, q:after {
43
+ content: '';
44
+ content: none;
45
+ }
46
+ table {
47
+ border-collapse: collapse;
48
+ border-spacing: 0;
49
+ }
50
+ /* Generated variables */
51
+ a.stage-navigation, a.stage-navigation:visited {
52
+ color: #38ab36;
53
+ font-family: "Amaranth", serif;
54
+ font-size: 0.8em;
55
+ font-style: italic;
56
+ text-decoration: none;
57
+ text-shadow: none; }
58
+ a.stage-navigation img, a.stage-navigation:visited img {
59
+ border: none;
60
+ vertical-align: bottom; }
61
+
62
+ a {
63
+ color: #444;
64
+ font-family: "Amaranth", serif;
65
+ font-style: italic;
66
+ text-shadow: none; }
67
+ a:visited {
68
+ color: #black; }
69
+ a img {
70
+ vertical-align: bottom; }
71
+
72
+ h1 {
73
+ color: #2386e2;
74
+ font-family: "Amaranth", serif;
75
+ font-style: italic;
76
+ font-size: 1.6em;
77
+ text-shadow: white 1px 1px 5px, 2px 2px 10px #999999; }
78
+
79
+ body {
80
+ font-family: "PT Serif", serif;
81
+ /*font-family: 'Puritan', serif;*/
82
+ /*overflow: auto;*/
83
+ overflow-x: hidden;
84
+ margin: auto;
85
+ max-width: 750px;
86
+ background-color: #efefef;
87
+ /*position: relative;*/
88
+ /*border: 1px solid black;*/ }
89
+
90
+ #pte-image {
91
+ float: left;
92
+ margin-top: 5px;
93
+ width: 402px; }
94
+ #pte-image img {
95
+ display: block;
96
+ margin: auto; }
97
+
98
+ #pte-buttons button {
99
+ font-family: "Amaranth", Tahoma, sans-serif;
100
+ font-size: larger;
101
+ line-height: 130%;
102
+ margin: 10px auto;
103
+ padding: 10px;
104
+ width: 100%; }
105
+
106
+ #pte-confirm {
107
+ font-family: "Amaranth", Tahoma, sans-serif;
108
+ font-size: larger;
109
+ line-height: 130%;
110
+ margin: 10px auto;
111
+ padding: 10px;
112
+ width: 75%; }
113
+
114
+ #pte-sizes-container {
115
+ overflow: auto;
116
+ padding-left: 15px;
117
+ float: left;
118
+ width: 331px; }
119
+
120
+ #pte-selectors, #pte-stage2-selectors {
121
+ margin-bottom: 10px; }
122
+
123
+ #pte-sizes {
124
+ overflow-x: hidden;
125
+ overflow-y: scroll;
126
+ position: relative;
127
+ border: 1px solid #dddddd;
128
+ /*width: $pte-sizes-width;*/
129
+ /*width: 100%;*/ }
130
+ #pte-sizes img {
131
+ max-width: 296px; }
132
+
133
+ table tr {
134
+ border-bottom: 1px solid #dddddd; }
135
+ table tr.selected {
136
+ background-color: #fff; }
137
+
138
+ table td {
139
+ position: relative;
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
+ /*}*/
153
+ .pte-size-label {
154
+ /*background: #bcbcbc;*/
155
+ background: #cdcdcd;
156
+ bottom: 0;
157
+ font-family: "Amaranth", serif;
158
+ font-weight: bolder;
159
+ padding: 5px 0px 7px 5px;
160
+ /*padding: 5px;*/ }
161
+ .pte-size-label .actual {
162
+ font-size: 0.8em;
163
+ font-weight: normal; }
164
+
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;
275
+ left: 0;
276
+ position: relative;
277
+ top: 0;
278
+ /*overflow: hidden;*/
279
+ /*width: $width;*/ }
280
+
281
+ #stage2, #stage3 {
282
+ display: none;
283
+ /*left: $width * 2;*/
284
+ width: 750px; }
285
+
286
+ table {
287
+ width: 100%; }
288
+
289
+ #stage2 img {
290
+ /*max-width: 100%;*/
291
+ max-width: 710px; }
292
+
293
+ #error {
294
+ color: #aa0000; }
295
+ #error ul {
296
+ list-style: disc;
297
+ margin: 10px 0px 10px 20px;
298
+ /*li { */
299
+ /* list-style-image: 'disc';*/
300
+ /*} */ }
301
+
302
+ #success {
303
+ color: #38ab36;
304
+ font-size: 1.5em; }
css/pte.min.css DELETED
@@ -1 +0,0 @@
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}
 
html/pte.php CHANGED
@@ -4,10 +4,11 @@
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 ) ); ?>;
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
+ <link rel="stylesheet" type="text/css" href="<?php echo( $style_url ); ?>">
8
+ <script
9
+ src="<?php echo( $script_url ); ?>"
10
+ type="text/javascript"
11
+ charset="utf-8"></script>
12
  <script type="text/javascript" charset="utf-8">
13
  var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
14
  var thumbnail_info = <?php print( json_encode( $size_information ) ); ?>;
js/pte.coffee CHANGED
@@ -134,7 +134,7 @@ determineAspectRatio = (current_ar, size_info) ->
134
  gc = gcd width, height
135
  if crop? and crop > 0
136
  tmp_ar = null
137
- if (width? > 0 and height? > 0)
138
  if gc?
139
  tmp_ar = "#{ width / gc }:#{ height / gc }"
140
  else
@@ -292,7 +292,8 @@ do (pte) ->
292
  catch error
293
  ar = null
294
  if ar isnt ias_instance.getOptions().aspectRatio
295
- alert error
 
296
  return false
297
  true
298
  iasSetAR ar
134
  gc = gcd width, height
135
  if crop? and crop > 0
136
  tmp_ar = null
137
+ if (width? and width > 0 and height? and height > 0)
138
  if gc?
139
  tmp_ar = "#{ width / gc }:#{ height / gc }"
140
  else
292
  catch error
293
  ar = null
294
  if ar isnt ias_instance.getOptions().aspectRatio
295
+ log "Setting Aspect Ratio to null"
296
+ #alert error
297
  return false
298
  true
299
  iasSetAR ar
js/pte.full.dev.js ADDED
@@ -0,0 +1,1185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery Templates Plugin 1.0.0pre
3
+ * http://github.com/jquery/jquery-tmpl
4
+ * Requires jQuery 1.4.2
5
+ *
6
+ * Copyright Software Freedom Conservancy, Inc.
7
+ * Dual licensed under the MIT or GPL Version 2 licenses.
8
+ * http://jquery.org/license
9
+ */
10
+ (function( jQuery, undefined ){
11
+ var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
12
+ newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
13
+
14
+ function newTmplItem( options, parentItem, fn, data ) {
15
+ // Returns a template item data structure for a new rendered instance of a template (a 'template item').
16
+ // The content field is a hierarchical array of strings and nested items (to be
17
+ // removed and replaced by nodes field of dom elements, once inserted in DOM).
18
+ var newItem = {
19
+ data: data || (data === 0 || data === false) ? data : (parentItem ? parentItem.data : {}),
20
+ _wrap: parentItem ? parentItem._wrap : null,
21
+ tmpl: null,
22
+ parent: parentItem || null,
23
+ nodes: [],
24
+ calls: tiCalls,
25
+ nest: tiNest,
26
+ wrap: tiWrap,
27
+ html: tiHtml,
28
+ update: tiUpdate
29
+ };
30
+ if ( options ) {
31
+ jQuery.extend( newItem, options, { nodes: [], parent: parentItem });
32
+ }
33
+ if ( fn ) {
34
+ // Build the hierarchical content to be used during insertion into DOM
35
+ newItem.tmpl = fn;
36
+ newItem._ctnt = newItem._ctnt || newItem.tmpl( jQuery, newItem );
37
+ newItem.key = ++itemKey;
38
+ // Keep track of new template item, until it is stored as jQuery Data on DOM element
39
+ (stack.length ? wrappedItems : newTmplItems)[itemKey] = newItem;
40
+ }
41
+ return newItem;
42
+ }
43
+
44
+ // Override appendTo etc., in order to provide support for targeting multiple elements. (This code would disappear if integrated in jquery core).
45
+ jQuery.each({
46
+ appendTo: "append",
47
+ prependTo: "prepend",
48
+ insertBefore: "before",
49
+ insertAfter: "after",
50
+ replaceAll: "replaceWith"
51
+ }, function( name, original ) {
52
+ jQuery.fn[ name ] = function( selector ) {
53
+ var ret = [], insert = jQuery( selector ), elems, i, l, tmplItems,
54
+ parent = this.length === 1 && this[0].parentNode;
55
+
56
+ appendToTmplItems = newTmplItems || {};
57
+ if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
58
+ insert[ original ]( this[0] );
59
+ ret = this;
60
+ } else {
61
+ for ( i = 0, l = insert.length; i < l; i++ ) {
62
+ cloneIndex = i;
63
+ elems = (i > 0 ? this.clone(true) : this).get();
64
+ jQuery( insert[i] )[ original ]( elems );
65
+ ret = ret.concat( elems );
66
+ }
67
+ cloneIndex = 0;
68
+ ret = this.pushStack( ret, name, insert.selector );
69
+ }
70
+ tmplItems = appendToTmplItems;
71
+ appendToTmplItems = null;
72
+ jQuery.tmpl.complete( tmplItems );
73
+ return ret;
74
+ };
75
+ });
76
+
77
+ jQuery.fn.extend({
78
+ // Use first wrapped element as template markup.
79
+ // Return wrapped set of template items, obtained by rendering template against data.
80
+ tmpl: function( data, options, parentItem ) {
81
+ return jQuery.tmpl( this[0], data, options, parentItem );
82
+ },
83
+
84
+ // Find which rendered template item the first wrapped DOM element belongs to
85
+ tmplItem: function() {
86
+ return jQuery.tmplItem( this[0] );
87
+ },
88
+
89
+ // Consider the first wrapped element as a template declaration, and get the compiled template or store it as a named template.
90
+ template: function( name ) {
91
+ return jQuery.template( name, this[0] );
92
+ },
93
+
94
+ domManip: function( args, table, callback, options ) {
95
+ if ( args[0] && jQuery.isArray( args[0] )) {
96
+ var dmArgs = jQuery.makeArray( arguments ), elems = args[0], elemsLength = elems.length, i = 0, tmplItem;
97
+ while ( i < elemsLength && !(tmplItem = jQuery.data( elems[i++], "tmplItem" ))) {}
98
+ if ( tmplItem && cloneIndex ) {
99
+ dmArgs[2] = function( fragClone ) {
100
+ // Handler called by oldManip when rendered template has been inserted into DOM.
101
+ jQuery.tmpl.afterManip( this, fragClone, callback );
102
+ };
103
+ }
104
+ oldManip.apply( this, dmArgs );
105
+ } else {
106
+ oldManip.apply( this, arguments );
107
+ }
108
+ cloneIndex = 0;
109
+ if ( !appendToTmplItems ) {
110
+ jQuery.tmpl.complete( newTmplItems );
111
+ }
112
+ return this;
113
+ }
114
+ });
115
+
116
+ jQuery.extend({
117
+ // Return wrapped set of template items, obtained by rendering template against data.
118
+ tmpl: function( tmpl, data, options, parentItem ) {
119
+ var ret, topLevel = !parentItem;
120
+ if ( topLevel ) {
121
+ // This is a top-level tmpl call (not from a nested template using {{tmpl}})
122
+ parentItem = topTmplItem;
123
+ tmpl = jQuery.template[tmpl] || jQuery.template( null, tmpl );
124
+ wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level
125
+ } else if ( !tmpl ) {
126
+ // The template item is already associated with DOM - this is a refresh.
127
+ // Re-evaluate rendered template for the parentItem
128
+ tmpl = parentItem.tmpl;
129
+ newTmplItems[parentItem.key] = parentItem;
130
+ parentItem.nodes = [];
131
+ if ( parentItem.wrapped ) {
132
+ updateWrapped( parentItem, parentItem.wrapped );
133
+ }
134
+ // Rebuild, without creating a new template item
135
+ return jQuery( build( parentItem, null, parentItem.tmpl( jQuery, parentItem ) ));
136
+ }
137
+ if ( !tmpl ) {
138
+ return []; // Could throw...
139
+ }
140
+ if ( typeof data === "function" ) {
141
+ data = data.call( parentItem || {} );
142
+ }
143
+ if ( options && options.wrapped ) {
144
+ updateWrapped( options, options.wrapped );
145
+ }
146
+ ret = jQuery.isArray( data ) ?
147
+ jQuery.map( data, function( dataItem ) {
148
+ return dataItem ? newTmplItem( options, parentItem, tmpl, dataItem ) : null;
149
+ }) :
150
+ [ newTmplItem( options, parentItem, tmpl, data ) ];
151
+ return topLevel ? jQuery( build( parentItem, null, ret ) ) : ret;
152
+ },
153
+
154
+ // Return rendered template item for an element.
155
+ tmplItem: function( elem ) {
156
+ var tmplItem;
157
+ if ( elem instanceof jQuery ) {
158
+ elem = elem[0];
159
+ }
160
+ while ( elem && elem.nodeType === 1 && !(tmplItem = jQuery.data( elem, "tmplItem" )) && (elem = elem.parentNode) ) {}
161
+ return tmplItem || topTmplItem;
162
+ },
163
+
164
+ // Set:
165
+ // Use $.template( name, tmpl ) to cache a named template,
166
+ // where tmpl is a template string, a script element or a jQuery instance wrapping a script element, etc.
167
+ // Use $( "selector" ).template( name ) to provide access by name to a script block template declaration.
168
+
169
+ // Get:
170
+ // Use $.template( name ) to access a cached template.
171
+ // Also $( selectorToScriptBlock ).template(), or $.template( null, templateString )
172
+ // will return the compiled template, without adding a name reference.
173
+ // If templateString includes at least one HTML tag, $.template( templateString ) is equivalent
174
+ // to $.template( null, templateString )
175
+ template: function( name, tmpl ) {
176
+ if (tmpl) {
177
+ // Compile template and associate with name
178
+ if ( typeof tmpl === "string" ) {
179
+ // This is an HTML string being passed directly in.
180
+ tmpl = buildTmplFn( tmpl );
181
+ } else if ( tmpl instanceof jQuery ) {
182
+ tmpl = tmpl[0] || {};
183
+ }
184
+ if ( tmpl.nodeType ) {
185
+ // If this is a template block, use cached copy, or generate tmpl function and cache.
186
+ tmpl = jQuery.data( tmpl, "tmpl" ) || jQuery.data( tmpl, "tmpl", buildTmplFn( tmpl.innerHTML ));
187
+ // Issue: In IE, if the container element is not a script block, the innerHTML will remove quotes from attribute values whenever the value does not include white space.
188
+ // This means that foo="${x}" will not work if the value of x includes white space: foo="${x}" -> foo=value of x.
189
+ // To correct this, include space in tag: foo="${ x }" -> foo="value of x"
190
+ }
191
+ return typeof name === "string" ? (jQuery.template[name] = tmpl) : tmpl;
192
+ }
193
+ // Return named compiled template
194
+ return name ? (typeof name !== "string" ? jQuery.template( null, name ):
195
+ (jQuery.template[name] ||
196
+ // If not in map, and not containing at least on HTML tag, treat as a selector.
197
+ // (If integrated with core, use quickExpr.exec)
198
+ jQuery.template( null, htmlExpr.test( name ) ? name : jQuery( name )))) : null;
199
+ },
200
+
201
+ encode: function( text ) {
202
+ // Do HTML encoding replacing < > & and ' and " by corresponding entities.
203
+ return ("" + text).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;");
204
+ }
205
+ });
206
+
207
+ jQuery.extend( jQuery.tmpl, {
208
+ tag: {
209
+ "tmpl": {
210
+ _default: { $2: "null" },
211
+ open: "if($notnull_1){__=__.concat($item.nest($1,$2));}"
212
+ // tmpl target parameter can be of type function, so use $1, not $1a (so not auto detection of functions)
213
+ // This means that {{tmpl foo}} treats foo as a template (which IS a function).
214
+ // Explicit parens can be used if foo is a function that returns a template: {{tmpl foo()}}.
215
+ },
216
+ "wrap": {
217
+ _default: { $2: "null" },
218
+ open: "$item.calls(__,$1,$2);__=[];",
219
+ close: "call=$item.calls();__=call._.concat($item.wrap(call,__));"
220
+ },
221
+ "each": {
222
+ _default: { $2: "$index, $value" },
223
+ open: "if($notnull_1){$.each($1a,function($2){with(this){",
224
+ close: "}});}"
225
+ },
226
+ "if": {
227
+ open: "if(($notnull_1) && $1a){",
228
+ close: "}"
229
+ },
230
+ "else": {
231
+ _default: { $1: "true" },
232
+ open: "}else if(($notnull_1) && $1a){"
233
+ },
234
+ "html": {
235
+ // Unecoded expression evaluation.
236
+ open: "if($notnull_1){__.push($1a);}"
237
+ },
238
+ "=": {
239
+ // Encoded expression evaluation. Abbreviated form is ${}.
240
+ _default: { $1: "$data" },
241
+ open: "if($notnull_1){__.push($.encode($1a));}"
242
+ },
243
+ "!": {
244
+ // Comment tag. Skipped by parser
245
+ open: ""
246
+ }
247
+ },
248
+
249
+ // This stub can be overridden, e.g. in jquery.tmplPlus for providing rendered events
250
+ complete: function( items ) {
251
+ newTmplItems = {};
252
+ },
253
+
254
+ // Call this from code which overrides domManip, or equivalent
255
+ // Manage cloning/storing template items etc.
256
+ afterManip: function afterManip( elem, fragClone, callback ) {
257
+ // Provides cloned fragment ready for fixup prior to and after insertion into DOM
258
+ var content = fragClone.nodeType === 11 ?
259
+ jQuery.makeArray(fragClone.childNodes) :
260
+ fragClone.nodeType === 1 ? [fragClone] : [];
261
+
262
+ // Return fragment to original caller (e.g. append) for DOM insertion
263
+ callback.call( elem, fragClone );
264
+
265
+ // Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by jQuery.data.
266
+ storeTmplItems( content );
267
+ cloneIndex++;
268
+ }
269
+ });
270
+
271
+ //========================== Private helper functions, used by code above ==========================
272
+
273
+ function build( tmplItem, nested, content ) {
274
+ // Convert hierarchical content into flat string array
275
+ // and finally return array of fragments ready for DOM insertion
276
+ var frag, ret = content ? jQuery.map( content, function( item ) {
277
+ return (typeof item === "string") ?
278
+ // Insert template item annotations, to be converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
279
+ (tmplItem.key ? item.replace( /(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" + tmplItem.key + "\" $2" ) : item) :
280
+ // This is a child template item. Build nested template.
281
+ build( item, tmplItem, item._ctnt );
282
+ }) :
283
+ // If content is not defined, insert tmplItem directly. Not a template item. May be a string, or a string array, e.g. from {{html $item.html()}}.
284
+ tmplItem;
285
+ if ( nested ) {
286
+ return ret;
287
+ }
288
+
289
+ // top-level template
290
+ ret = ret.join("");
291
+
292
+ // Support templates which have initial or final text nodes, or consist only of text
293
+ // Also support HTML entities within the HTML markup.
294
+ ret.replace( /^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function( all, before, middle, after) {
295
+ frag = jQuery( middle ).get();
296
+
297
+ storeTmplItems( frag );
298
+ if ( before ) {
299
+ frag = unencode( before ).concat(frag);
300
+ }
301
+ if ( after ) {
302
+ frag = frag.concat(unencode( after ));
303
+ }
304
+ });
305
+ return frag ? frag : unencode( ret );
306
+ }
307
+
308
+ function unencode( text ) {
309
+ // Use createElement, since createTextNode will not render HTML entities correctly
310
+ var el = document.createElement( "div" );
311
+ el.innerHTML = text;
312
+ return jQuery.makeArray(el.childNodes);
313
+ }
314
+
315
+ // Generate a reusable function that will serve to render a template against data
316
+ function buildTmplFn( markup ) {
317
+ return new Function("jQuery","$item",
318
+ // Use the variable __ to hold a string array while building the compiled template. (See https://github.com/jquery/jquery-tmpl/issues#issue/10).
319
+ "var $=jQuery,call,__=[],$data=$item.data;" +
320
+
321
+ // Introduce the data as local variables using with(){}
322
+ "with($data){__.push('" +
323
+
324
+ // Convert the template into pure JavaScript
325
+ jQuery.trim(markup)
326
+ .replace( /([\\'])/g, "\\$1" )
327
+ .replace( /[\r\t\n]/g, " " )
328
+ .replace( /\$\{([^\}]*)\}/g, "{{= $1}}" )
329
+ .replace( /\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
330
+ function( all, slash, type, fnargs, target, parens, args ) {
331
+ var tag = jQuery.tmpl.tag[ type ], def, expr, exprAutoFnDetect;
332
+ if ( !tag ) {
333
+ throw "Unknown template tag: " + type;
334
+ }
335
+ def = tag._default || [];
336
+ if ( parens && !/\w$/.test(target)) {
337
+ target += parens;
338
+ parens = "";
339
+ }
340
+ if ( target ) {
341
+ target = unescape( target );
342
+ args = args ? ("," + unescape( args ) + ")") : (parens ? ")" : "");
343
+ // Support for target being things like a.toLowerCase();
344
+ // In that case don't call with template item as 'this' pointer. Just evaluate...
345
+ expr = parens ? (target.indexOf(".") > -1 ? target + unescape( parens ) : ("(" + target + ").call($item" + args)) : target;
346
+ exprAutoFnDetect = parens ? expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" + target + "))";
347
+ } else {
348
+ exprAutoFnDetect = expr = def.$1 || "null";
349
+ }
350
+ fnargs = unescape( fnargs );
351
+ return "');" +
352
+ tag[ slash ? "close" : "open" ]
353
+ .split( "$notnull_1" ).join( target ? "typeof(" + target + ")!=='undefined' && (" + target + ")!=null" : "true" )
354
+ .split( "$1a" ).join( exprAutoFnDetect )
355
+ .split( "$1" ).join( expr )
356
+ .split( "$2" ).join( fnargs || def.$2 || "" ) +
357
+ "__.push('";
358
+ }) +
359
+ "');}return __;"
360
+ );
361
+ }
362
+ function updateWrapped( options, wrapped ) {
363
+ // Build the wrapped content.
364
+ options._wrap = build( options, true,
365
+ // Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.
366
+ jQuery.isArray( wrapped ) ? wrapped : [htmlExpr.test( wrapped ) ? wrapped : jQuery( wrapped ).html()]
367
+ ).join("");
368
+ }
369
+
370
+ function unescape( args ) {
371
+ return args ? args.replace( /\\'/g, "'").replace(/\\\\/g, "\\" ) : null;
372
+ }
373
+ function outerHtml( elem ) {
374
+ var div = document.createElement("div");
375
+ div.appendChild( elem.cloneNode(true) );
376
+ return div.innerHTML;
377
+ }
378
+
379
+ // Store template items in jQuery.data(), ensuring a unique tmplItem data data structure for each rendered template instance.
380
+ function storeTmplItems( content ) {
381
+ var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
382
+ for ( i = 0, l = content.length; i < l; i++ ) {
383
+ if ( (elem = content[i]).nodeType !== 1 ) {
384
+ continue;
385
+ }
386
+ elems = elem.getElementsByTagName("*");
387
+ for ( m = elems.length - 1; m >= 0; m-- ) {
388
+ processItemKey( elems[m] );
389
+ }
390
+ processItemKey( elem );
391
+ }
392
+ function processItemKey( el ) {
393
+ var pntKey, pntNode = el, pntItem, tmplItem, key;
394
+ // Ensure that each rendered template inserted into the DOM has its own template item,
395
+ if ( (key = el.getAttribute( tmplItmAtt ))) {
396
+ while ( pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute( tmplItmAtt ))) { }
397
+ if ( pntKey !== key ) {
398
+ // The next ancestor with a _tmplitem expando is on a different key than this one.
399
+ // So this is a top-level element within this template item
400
+ // Set pntNode to the key of the parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.
401
+ pntNode = pntNode.parentNode ? (pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute( tmplItmAtt ) || 0)) : 0;
402
+ if ( !(tmplItem = newTmplItems[key]) ) {
403
+ // The item is for wrapped content, and was copied from the temporary parent wrappedItem.
404
+ tmplItem = wrappedItems[key];
405
+ tmplItem = newTmplItem( tmplItem, newTmplItems[pntNode]||wrappedItems[pntNode] );
406
+ tmplItem.key = ++itemKey;
407
+ newTmplItems[itemKey] = tmplItem;
408
+ }
409
+ if ( cloneIndex ) {
410
+ cloneTmplItem( key );
411
+ }
412
+ }
413
+ el.removeAttribute( tmplItmAtt );
414
+ } else if ( cloneIndex && (tmplItem = jQuery.data( el, "tmplItem" )) ) {
415
+ // This was a rendered element, cloned during append or appendTo etc.
416
+ // TmplItem stored in jQuery data has already been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.
417
+ cloneTmplItem( tmplItem.key );
418
+ newTmplItems[tmplItem.key] = tmplItem;
419
+ pntNode = jQuery.data( el.parentNode, "tmplItem" );
420
+ pntNode = pntNode ? pntNode.key : 0;
421
+ }
422
+ if ( tmplItem ) {
423
+ pntItem = tmplItem;
424
+ // Find the template item of the parent element.
425
+ // (Using !=, not !==, since pntItem.key is number, and pntNode may be a string)
426
+ while ( pntItem && pntItem.key != pntNode ) {
427
+ // Add this element as a top-level node for this rendered template item, as well as for any
428
+ // ancestor items between this item and the item of its parent element
429
+ pntItem.nodes.push( el );
430
+ pntItem = pntItem.parent;
431
+ }
432
+ // Delete content built during rendering - reduce API surface area and memory use, and avoid exposing of stale data after rendering...
433
+ delete tmplItem._ctnt;
434
+ delete tmplItem._wrap;
435
+ // Store template item as jQuery data on the element
436
+ jQuery.data( el, "tmplItem", tmplItem );
437
+ }
438
+ function cloneTmplItem( key ) {
439
+ key = key + keySuffix;
440
+ tmplItem = newClonedItems[key] =
441
+ (newClonedItems[key] || newTmplItem( tmplItem, newTmplItems[tmplItem.parent.key + keySuffix] || tmplItem.parent ));
442
+ }
443
+ }
444
+ }
445
+
446
+ //---- Helper functions for template item ----
447
+
448
+ function tiCalls( content, tmpl, data, options ) {
449
+ if ( !content ) {
450
+ return stack.pop();
451
+ }
452
+ stack.push({ _: content, tmpl: tmpl, item:this, data: data, options: options });
453
+ }
454
+
455
+ function tiNest( tmpl, data, options ) {
456
+ // nested template, using {{tmpl}} tag
457
+ return jQuery.tmpl( jQuery.template( tmpl ), data, options, this );
458
+ }
459
+
460
+ function tiWrap( call, wrapped ) {
461
+ // nested template, using {{wrap}} tag
462
+ var options = call.options || {};
463
+ options.wrapped = wrapped;
464
+ // Apply the template, which may incorporate wrapped content,
465
+ return jQuery.tmpl( jQuery.template( call.tmpl ), call.data, options, call.item );
466
+ }
467
+
468
+ function tiHtml( filter, textOnly ) {
469
+ var wrapped = this._wrap;
470
+ return jQuery.map(
471
+ jQuery( jQuery.isArray( wrapped ) ? wrapped.join("") : wrapped ).filter( filter || "*" ),
472
+ function(e) {
473
+ return textOnly ?
474
+ e.innerText || e.textContent :
475
+ e.outerHTML || outerHtml(e);
476
+ });
477
+ }
478
+
479
+ function tiUpdate() {
480
+ var coll = this.nodes;
481
+ jQuery.tmpl( null, null, null, this).insertBefore( coll[0] );
482
+ jQuery( coll ).remove();
483
+ }
484
+ })( jQuery );
485
+ (function() {
486
+ var $, Message, TimerFunc, deleteThumbs, deleteThumbsSuccessCallback, determineAspectRatio, gcd, pte, pte_queue, toType, window,
487
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
488
+
489
+ window = this;
490
+
491
+ $ = window.jQuery;
492
+
493
+ window.pte = pte = pte || {};
494
+
495
+ (function(pte) {
496
+ return pte.fixThickbox = function(parent) {
497
+ var $p, $thickbox, height, width;
498
+ $p = parent.jQuery;
499
+ if ($p === null || parent.frames.length < 1) {
500
+ return;
501
+ }
502
+ log("===== FIXING THICKBOX =====");
503
+ width = window.options.pte_tb_width + 30;
504
+ height = window.options.pte_tb_height + 38;
505
+ $thickbox = $p("#TB_window");
506
+ if ($thickbox.width() >= width && $thickbox.height() >= height) {
507
+ return;
508
+ }
509
+ log("THICKBOX: " + ($thickbox.width()) + " x " + ($thickbox.height()));
510
+ $thickbox.css({
511
+ 'margin-left': 0 - (width / 2),
512
+ 'width': width,
513
+ 'height': height
514
+ }).children("iframe").css({
515
+ 'width': width
516
+ });
517
+ return parent.setTimeout(function() {
518
+ if ($p("iframe", $thickbox).height() > height) {
519
+ return;
520
+ }
521
+ $p("iframe", $thickbox).css({
522
+ 'height': height
523
+ });
524
+ log("THICKBOX: " + ($thickbox.width()) + " x " + ($thickbox.height()));
525
+ return true;
526
+ }, 1000);
527
+ };
528
+ })(pte);
529
+
530
+ toType = function(obj) {
531
+ return {}.toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
532
+ };
533
+
534
+ Message = (function() {
535
+
536
+ function Message(message) {
537
+ this.message = message;
538
+ this.date = new Date();
539
+ }
540
+
541
+ Message.prototype.toString = function() {
542
+ var D, M, d, h, m, message, pad, s, y;
543
+ pad = function(num, pad) {
544
+ while (("" + num).length < pad) {
545
+ num = "0" + num;
546
+ }
547
+ return num;
548
+ };
549
+ d = this.date;
550
+ y = pad(d.getUTCFullYear(), 4);
551
+ M = pad(d.getUTCMonth() + 1, 2);
552
+ D = pad(d.getUTCDate(), 2);
553
+ h = pad(d.getUTCHours(), 2);
554
+ m = pad(d.getUTCMinutes(), 2);
555
+ s = pad(d.getUTCSeconds(), 2);
556
+ switch (toType(this.message)) {
557
+ case "string":
558
+ message = this.message;
559
+ break;
560
+ default:
561
+ message = $.toJSON(this.message);
562
+ }
563
+ return "" + y + M + D + " " + h + ":" + m + ":" + s + " - [" + (toType(this.message)) + "] " + message;
564
+ };
565
+
566
+ return Message;
567
+
568
+ })();
569
+
570
+ (function(pte) {
571
+ pte.messages = [];
572
+ pte.log = function(obj) {
573
+ if (!window.options.pte_debug) {
574
+ return true;
575
+ }
576
+ try {
577
+ pte.messages.push(new Message(obj));
578
+ console.log(obj);
579
+ $('#pte-log-messages textarea').filter(':visible').val(pte.formatLog());
580
+ } catch (error) {
581
+
582
+ }
583
+ };
584
+ pte.formatLog = function() {
585
+ var log, message, _i, _len, _ref;
586
+ log = "";
587
+ _ref = pte.messages;
588
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
589
+ message = _ref[_i];
590
+ log += "" + message + "\n";
591
+ }
592
+ return log;
593
+ };
594
+ pte.parseServerLog = function(json) {
595
+ var message, _i, _len;
596
+ log("===== SERVER LOG =====");
597
+ if (((json != null ? json.length : void 0) != null) && json.length > 0) {
598
+ for (_i = 0, _len = json.length; _i < _len; _i++) {
599
+ message = json[_i];
600
+ log(message);
601
+ }
602
+ }
603
+ return true;
604
+ };
605
+ pte.sendToPastebin = function(text) {
606
+ var pastebin_url, post_data;
607
+ pastebin_url = "http://dpastey.appspot.com/";
608
+ post_data = {
609
+ title: "PostThumbnailEditor Log",
610
+ content: text,
611
+ lexer: "text",
612
+ format: "json",
613
+ expire_options: "2592000"
614
+ };
615
+ return $.ajax({
616
+ url: pastebin_url,
617
+ data: post_data,
618
+ dataType: "json",
619
+ global: false,
620
+ type: "POST",
621
+ error: function(xhr, status, errorThrown) {
622
+ $('#pte-log').fadeOut('900');
623
+ alert(objectL10n.pastebin_create_error);
624
+ log(xhr);
625
+ log(status);
626
+ return log(errorThrown);
627
+ },
628
+ success: function(data, status, xhr) {
629
+ $('#pte-log').fadeOut('900');
630
+ return prompt(objectL10n.pastebin_url, data.url);
631
+ }
632
+ });
633
+ };
634
+ return true;
635
+ })(pte);
636
+
637
+ window.log = pte.log;
638
+
639
+ $(document).ready(function($) {
640
+ $('#test').click(function(e) {
641
+ e.stopImmediatePropagation();
642
+ return true;
643
+ });
644
+ $('#pastebin').click(function(e) {
645
+ return pte.sendToPastebin(pte.formatLog());
646
+ });
647
+ $('#clear-log').click(function(e) {
648
+ pte.messages = [];
649
+ return $('#pte-log-messages textarea').val(pte.formatLog());
650
+ });
651
+ $('#close-log').click(function(e) {
652
+ return $('#pte-log').fadeOut('900');
653
+ });
654
+ $('#pte-log-tools a').click(function(e) {
655
+ return e.preventDefault();
656
+ });
657
+ return $('body').delegate('.show-log-messages', 'click', function(e) {
658
+ e.preventDefault();
659
+ $('#pte-log-messages textarea').val(pte.formatLog());
660
+ return $('#pte-log').fadeIn('900');
661
+ });
662
+ });
663
+
664
+ /*
665
+ POST-THUMBNAIL-EDITOR Script for Wordpress
666
+
667
+ Hooks into the Wordpress Media Library
668
+ */
669
+
670
+
671
+ (function(pte) {
672
+ pte.media = function() {
673
+ var injectTemplate, template;
674
+ template = $("#tmpl-attachment-details").text();
675
+ injectTemplate = "<a target=\"_blank\" href=\"" + ajaxurl + "?action=pte_ajax&pte-action=launch&id={{data.id}}\">\n " + objectL10n.PTE + "\n</a>";
676
+ template = template.replace(/(<div class="compat-meta">)/, "" + injectTemplate + "\n$1");
677
+ return $("#tmpl-attachment-details").text(template);
678
+ };
679
+ return pte.admin = function() {
680
+ var $getLink, checkExistingThickbox, image_id, injectPTE, launchPTE, pte_url, thickbox, timeout;
681
+ timeout = 300;
682
+ thickbox = "&TB_iframe=true&height=" + window.options.pte_tb_height + "&width=" + window.options.pte_tb_width;
683
+ image_id = null;
684
+ pte_url = function(override_id) {
685
+ var id;
686
+ id = override_id || image_id || $("#attachment-id").val();
687
+ return "" + ajaxurl + "?action=pte_ajax&pte-action=launch&id=" + id + thickbox;
688
+ };
689
+ $getLink = function(id) {
690
+ return $("<a class=\"thickbox\" href=\"" + (pte_url(id)) + "\">" + objectL10n.PTE + "</a>");
691
+ };
692
+ checkExistingThickbox = function(e) {
693
+ var _this = this;
694
+ log("Start PTE...");
695
+ if (window.parent.frames.length > 0) {
696
+ log("Modifying thickbox...");
697
+ (function() {
698
+ window.parent.tb_click();
699
+ return true;
700
+ })();
701
+ return e.stopPropagation();
702
+ }
703
+ };
704
+ injectPTE = function() {
705
+ var $editmenu, matches;
706
+ $('.media-item').each(function(i, elem) {
707
+ var post_id;
708
+ post_id = elem.id.replace("media-item-", "");
709
+ return $getLink(post_id).css({
710
+ 'font-size': '.8em',
711
+ 'margin-left': '5px'
712
+ }).click(checkExistingThickbox).appendTo($('tr.image-size th.label', elem));
713
+ });
714
+ if (imageEdit.open != null) {
715
+ imageEdit.oldopen = imageEdit.open;
716
+ imageEdit.open = function(id, nonce) {
717
+ image_id = id;
718
+ imageEdit.oldopen(id, nonce);
719
+ return launchPTE();
720
+ };
721
+ }
722
+ $editmenu = $("p[id^=\"imgedit-save-target-\"]");
723
+ if (($editmenu != null ? $editmenu.length : void 0) > 0) {
724
+ matches = $editmenu[0].id.match(/imgedit-save-target-(\d+)/);
725
+ if (matches[1] != null) {
726
+ image_id = matches[1];
727
+ launchPTE();
728
+ }
729
+ }
730
+ return true;
731
+ };
732
+ launchPTE = function() {
733
+ var $editmenu, selector;
734
+ selector = "#imgedit-save-target-" + image_id;
735
+ $editmenu = $(selector);
736
+ if (($editmenu != null ? $editmenu.size() : void 0) < 1) {
737
+ window.log("Edit Thumbnail Menu not visible, waiting for " + timeout + "ms");
738
+ window.setTimeout(launchPTE, timeout);
739
+ return false;
740
+ }
741
+ return $editmenu.append($getLink().click(checkExistingThickbox));
742
+ };
743
+ return injectPTE();
744
+ };
745
+ })(pte);
746
+
747
+ TimerFunc = (function() {
748
+
749
+ function TimerFunc(fn, timeout) {
750
+ this.fn = fn;
751
+ this.timeout = timeout;
752
+ this.doFunc = __bind(this.doFunc, this);
753
+
754
+ this.timer = null;
755
+ }
756
+
757
+ TimerFunc.prototype.doFunc = function(e) {
758
+ window.clearTimeout(this.timer);
759
+ this.timer = window.setTimeout(this.fn, this.timeout);
760
+ return true;
761
+ };
762
+
763
+ return TimerFunc;
764
+
765
+ })();
766
+
767
+ window.randomness = function() {
768
+ return Math.floor(Math.random() * 1000001).toString(16);
769
+ };
770
+
771
+ window.debugTmpl = function(data) {
772
+ log("===== TEMPLATE DEBUG DATA FOLLOWS =====");
773
+ log(data);
774
+ return true;
775
+ };
776
+
777
+ deleteThumbs = function(id) {
778
+ var delete_options;
779
+ delete_options = {
780
+ "id": id,
781
+ 'action': 'pte_ajax',
782
+ 'pte-action': 'delete-images',
783
+ 'pte-nonce': $('#pte-delete-nonce').val()
784
+ };
785
+ return $.ajax({
786
+ url: ajaxurl,
787
+ data: delete_options,
788
+ global: false,
789
+ dataType: "json",
790
+ success: deleteThumbsSuccessCallback
791
+ });
792
+ };
793
+
794
+ deleteThumbsSuccessCallback = function(data, status, xhr) {
795
+ log("===== DELETE SUCCESSFUL, DATA DUMP FOLLOWS =====");
796
+ log(data);
797
+ return pte.parseServerLog(data.log);
798
+ };
799
+
800
+ pte_queue = $({});
801
+
802
+ $.fn.extend({
803
+ move: function(options) {
804
+ var defaults;
805
+ defaults = {
806
+ direction: 'left',
807
+ speed: 500,
808
+ easing: 'swing',
809
+ toggle: true,
810
+ callback: null,
811
+ callbackargs: null
812
+ };
813
+ options = $.extend(defaults, options);
814
+ this.each(function() {
815
+ var _this = this;
816
+ return pte_queue.queue(function(next) {
817
+ var $elem, direction, isVisible, move_to;
818
+ $elem = $(_this);
819
+ direction = options.direction === 'left' ? -1 : 1;
820
+ move_to = $elem.css('left') === "0px" ? $(window).width() * direction : 0;
821
+ isVisible = $elem.is(':visible');
822
+ log([direction, move_to, isVisible]);
823
+ if (!isVisible) {
824
+ $elem.show(0, function() {
825
+ return $(this).animate({
826
+ 'left': move_to
827
+ }, options.speed, options.easing, next);
828
+ });
829
+ } else {
830
+ $elem.animate({
831
+ 'left': move_to
832
+ }, options.speed, options.easing);
833
+ $elem.hide(0, next);
834
+ }
835
+ return true;
836
+ });
837
+ });
838
+ if (options.callback != null) {
839
+ pte_queue.queue(function(next) {
840
+ if (options.callbackargs != null) {
841
+ log("running callback with arguments");
842
+ options.callback.apply(this, options.callbackargs);
843
+ } else {
844
+ log("running callback with no arguments");
845
+ options.callback.apply(this);
846
+ }
847
+ log("finished running callback");
848
+ return next();
849
+ });
850
+ }
851
+ return this;
852
+ },
853
+ moveRight: function(options) {
854
+ options = $.extend(options, {
855
+ direction: 'right'
856
+ });
857
+ return this.move(options);
858
+ },
859
+ moveLeft: function(options) {
860
+ options = $.extend(options, {
861
+ direction: 'left'
862
+ });
863
+ return this.move(options);
864
+ }
865
+ });
866
+
867
+ window.goBack = function(e) {
868
+ if (e != null) {
869
+ e.preventDefault();
870
+ }
871
+ $('#stage2').moveRight();
872
+ $('#stage1').moveRight({
873
+ callback: function() {
874
+ deleteThumbs($('#pte-post-id').val());
875
+ return $('#stage2').html('');
876
+ }
877
+ });
878
+ return true;
879
+ };
880
+
881
+ gcd = function(a, b) {
882
+ if (a === 0) {
883
+ return b;
884
+ }
885
+ while (b > 0) {
886
+ if (a > b) {
887
+ a = a - b;
888
+ } else {
889
+ b = b - a;
890
+ }
891
+ }
892
+ if (a < 0 || b < 0) {
893
+ return null;
894
+ }
895
+ return a;
896
+ };
897
+
898
+ determineAspectRatio = function(current_ar, size_info) {
899
+ var crop, gc, height, tmp_ar, width;
900
+ crop = size_info.crop, width = size_info.width, height = size_info.height;
901
+ crop = +crop;
902
+ width = +width;
903
+ height = +height;
904
+ gc = gcd(width, height);
905
+ if ((crop != null) && crop > 0) {
906
+ tmp_ar = null;
907
+ if ((width != null) && width > 0 && (height != null) && height > 0) {
908
+ if (gc != null) {
909
+ tmp_ar = "" + (width / gc) + ":" + (height / gc);
910
+ } else {
911
+ tmp_ar = "" + width + ":" + height;
912
+ }
913
+ }
914
+ if ((current_ar != null) && (tmp_ar != null) && tmp_ar !== current_ar) {
915
+ throw objectL10n.aspect_ratio_disabled;
916
+ }
917
+ current_ar = tmp_ar;
918
+ }
919
+ return current_ar;
920
+ };
921
+
922
+ pte.functions = {
923
+ determineAspectRatio: determineAspectRatio
924
+ };
925
+
926
+ (function(pte) {
927
+ var addCheckAllNoneListener, addRowListener, addRowListeners, addSubmitListener, addVerifyListener, configureOverlay, configurePageDisplay, editor, iasSetAR, ias_defaults, ias_instance, initImgAreaSelect;
928
+ editor = pte.editor = function() {
929
+ configurePageDisplay();
930
+ addRowListeners();
931
+ initImgAreaSelect();
932
+ addRowListener();
933
+ addSubmitListener();
934
+ addVerifyListener();
935
+ addCheckAllNoneListener();
936
+ configureOverlay();
937
+ return true;
938
+ };
939
+ configureOverlay = function() {
940
+ var $loading_screen, closeLoadingScreen;
941
+ $loading_screen = $('#pte-loading');
942
+ closeLoadingScreen = function() {
943
+ $loading_screen.hide();
944
+ return true;
945
+ };
946
+ $('#pte-preview').load(closeLoadingScreen);
947
+ $loading_screen.ajaxStart(function() {
948
+ return $(this).fadeIn(200);
949
+ }).ajaxStop(function() {
950
+ return $(this).fadeOut(200);
951
+ });
952
+ window.setTimeout(closeLoadingScreen, 2000);
953
+ return true;
954
+ };
955
+ configurePageDisplay = function() {
956
+ var reflow;
957
+ reflow = new TimerFunc(function() {
958
+ var offset, window_height;
959
+ log("===== REFLOW =====");
960
+ pte.fixThickbox(window.parent);
961
+ offset = $("#pte-sizes").offset();
962
+ window_height = $(window).height() - offset.top - 2;
963
+ $("#pte-sizes").height(window_height);
964
+ log("WINDOW WIDTH: " + ($(window).width()));
965
+ $('#stage2, #stage3').filter(":hidden").css({
966
+ left: $(window).width()
967
+ });
968
+ return true;
969
+ }, 100);
970
+ $(window).resize(reflow.doFunc).load(reflow.doFunc);
971
+ return true;
972
+ };
973
+ addRowListeners = function() {
974
+ var enableRowFeatures;
975
+ enableRowFeatures = function($elem) {
976
+ $elem.delegate('tr', 'click', function(e) {
977
+ if (e.target.type !== 'checkbox') {
978
+ $('input:checkbox', this).click();
979
+ }
980
+ return true;
981
+ });
982
+ return $elem.delegate('input:checkbox', 'click', function(e) {
983
+ if (this.checked || $(this).is('input:checked')) {
984
+ $(this).parents('tr').first().removeClass('selected');
985
+ } else {
986
+ $(this).parents('tr').first().addClass('selected');
987
+ }
988
+ return true;
989
+ });
990
+ };
991
+ enableRowFeatures($('#stage2'));
992
+ return enableRowFeatures($('#stage1'));
993
+ };
994
+ /* Enable imgareaselect plugin
995
+ */
996
+
997
+ ias_instance = null;
998
+ ias_defaults = {
999
+ keys: true,
1000
+ minWidth: 3,
1001
+ minHeight: 3,
1002
+ handles: true,
1003
+ zIndex: 1200,
1004
+ instance: true,
1005
+ onSelectEnd: function(img, s) {
1006
+ if (s.width && s.width > 0 && s.height && s.height > 0 && $('.pte-size').filter(':checked').size() > 0) {
1007
+ return $('#pte-submit').removeAttr('disabled');
1008
+ } else {
1009
+ return $('#pte-submit').attr('disabled', true);
1010
+ }
1011
+ }
1012
+ };
1013
+ initImgAreaSelect = function() {
1014
+ return pte.ias = ias_instance = $('#pte-image img').imgAreaSelect(ias_defaults);
1015
+ };
1016
+ iasSetAR = function(ar) {
1017
+ log("===== SETTING ASPECTRATIO: " + ar + " =====");
1018
+ ias_instance.setOptions({
1019
+ aspectRatio: ar
1020
+ });
1021
+ return ias_instance.update();
1022
+ };
1023
+ addRowListener = function() {
1024
+ var pteCheckHandler, pteVerifySubmitButtonHandler;
1025
+ pteVerifySubmitButtonHandler = new TimerFunc(function() {
1026
+ log("===== CHECK SUBMIT BUTTON =====");
1027
+ if ($('.pte-confirm').filter(':checked').size() > 0) {
1028
+ log("ENABLE");
1029
+ $('#pte-confirm').removeAttr('disabled');
1030
+ } else {
1031
+ log("DISABLE");
1032
+ $('#pte-confirm').attr('disabled', true);
1033
+ }
1034
+ return true;
1035
+ }, 50);
1036
+ pteCheckHandler = new TimerFunc(function() {
1037
+ var ar, selected_elements;
1038
+ ar = null;
1039
+ selected_elements = $('input.pte-size').filter(':checked').each(function(i, elem) {
1040
+ try {
1041
+ ar = determineAspectRatio(ar, thumbnail_info[$(elem).val()]);
1042
+ } catch (error) {
1043
+ ar = null;
1044
+ if (ar !== ias_instance.getOptions().aspectRatio) {
1045
+ log("Setting Aspect Ratio to null");
1046
+ }
1047
+ return false;
1048
+ }
1049
+ return true;
1050
+ });
1051
+ iasSetAR(ar);
1052
+ ias_defaults.onSelectEnd(null, ias_instance.getSelection());
1053
+ return true;
1054
+ }, 50);
1055
+ $.extend(pte.functions, {
1056
+ pteVerifySubmitButtonHandler: pteVerifySubmitButtonHandler
1057
+ });
1058
+ $('input.pte-size').click(pteCheckHandler.doFunc);
1059
+ return $('.pte-confirm').live('click', function(e) {
1060
+ return pteVerifySubmitButtonHandler.doFunc();
1061
+ });
1062
+ };
1063
+ addSubmitListener = function() {
1064
+ var onResizeImages;
1065
+ $('#pte-submit').click(function(e) {
1066
+ var scale_factor, selection, submit_data;
1067
+ selection = ias_instance.getSelection();
1068
+ scale_factor = $('#pte-sizer').val();
1069
+ submit_data = {
1070
+ 'id': $('#pte-post-id').val(),
1071
+ 'action': 'pte_ajax',
1072
+ 'pte-action': 'resize-images',
1073
+ 'pte-sizes[]': $('.pte-size').filter(':checked').map(function() {
1074
+ return $(this).val();
1075
+ }).get(),
1076
+ 'x': Math.floor(selection.x1 / scale_factor),
1077
+ 'y': Math.floor(selection.y1 / scale_factor),
1078
+ 'w': Math.floor(selection.width / scale_factor),
1079
+ 'h': Math.floor(selection.height / scale_factor)
1080
+ };
1081
+ log("===== RESIZE-IMAGES =====");
1082
+ log(submit_data);
1083
+ if (isNaN(submit_data.x) || isNaN(submit_data.y) || isNaN(submit_data.w) || isNaN(submit_data.h)) {
1084
+ alert(objectL10n.crop_submit_data_error);
1085
+ log("ERROR with submit_data and NaN's");
1086
+ return false;
1087
+ }
1088
+ ias_instance.setOptions({
1089
+ hide: true,
1090
+ x1: 0,
1091
+ y1: 0,
1092
+ x2: 0,
1093
+ y2: 0
1094
+ });
1095
+ $('#pte-submit').attr('disabled', true);
1096
+ $.getJSON(ajaxurl, submit_data, onResizeImages);
1097
+ return true;
1098
+ });
1099
+ return onResizeImages = function(data, status, xhr) {
1100
+ /* Evaluate data
1101
+ */
1102
+ log("===== RESIZE-IMAGES SUCCESS =====");
1103
+ log(data);
1104
+ pte.parseServerLog(data.log);
1105
+ if ((data.error != null) && !(data.thumbnails != null)) {
1106
+ alert(data.error);
1107
+ return;
1108
+ }
1109
+ $('#stage1').moveLeft();
1110
+ $('#stage2').html($('#stage2template').tmpl(data)).moveLeft({
1111
+ callback: pte.functions.pteVerifySubmitButtonHandler.doFunc
1112
+ });
1113
+ return false;
1114
+ };
1115
+ };
1116
+ /* Callback for Stage 2 to 3
1117
+ */
1118
+
1119
+ addVerifyListener = function() {
1120
+ var onConfirmImages;
1121
+ $('#pte-confirm').live('click', function(e) {
1122
+ var submit_data, thumbnail_data;
1123
+ thumbnail_data = {};
1124
+ $('input.pte-confirm').filter(':checked').each(function(i, elem) {
1125
+ var size;
1126
+ size = $(elem).val();
1127
+ return thumbnail_data[size] = $(elem).parent().parent().find('.pte-file').val();
1128
+ });
1129
+ submit_data = {
1130
+ 'id': $('#pte-post-id').val(),
1131
+ 'action': 'pte_ajax',
1132
+ 'pte-action': 'confirm-images',
1133
+ 'pte-nonce': $('#pte-nonce').val(),
1134
+ 'pte-confirm': thumbnail_data
1135
+ };
1136
+ log("===== CONFIRM-IMAGES =====");
1137
+ log(submit_data);
1138
+ return $.getJSON(ajaxurl, submit_data, onConfirmImages);
1139
+ });
1140
+ return onConfirmImages = function(data, status, xhr) {
1141
+ log("===== CONFIRM-IMAGES SUCCESS =====");
1142
+ log(data);
1143
+ pte.parseServerLog(data.log);
1144
+ $('#stage2').moveLeft();
1145
+ $('#stage3').html($('#stage3template').tmpl(data)).moveLeft();
1146
+ return false;
1147
+ };
1148
+ };
1149
+ /* Select ALL|NONE
1150
+ */
1151
+
1152
+ addCheckAllNoneListener = function() {
1153
+ var checkAllSizes, uncheckAllSizes;
1154
+ uncheckAllSizes = function(e) {
1155
+ var elements, _ref, _ref1;
1156
+ if (e != null) {
1157
+ e.preventDefault();
1158
+ }
1159
+ elements = (_ref = (_ref1 = e.data) != null ? _ref1.selector : void 0) != null ? _ref : '.pte-size';
1160
+ return $(elements).filter(':checked').click();
1161
+ };
1162
+ checkAllSizes = function(e) {
1163
+ var elements, _ref, _ref1;
1164
+ if (e != null) {
1165
+ e.preventDefault();
1166
+ }
1167
+ elements = (_ref = e != null ? (_ref1 = e.data) != null ? _ref1.selector : void 0 : void 0) != null ? _ref : '.pte-size';
1168
+ return $(elements).not(':checked').click();
1169
+ };
1170
+ $("#pte-selectors .all").click(checkAllSizes);
1171
+ $("#pte-selectors .none").click(uncheckAllSizes).click();
1172
+ $('#stage2').delegate('#pte-stage2-selectors .all', 'click', {
1173
+ selector: '.pte-confirm'
1174
+ }, checkAllSizes);
1175
+ $('#stage2').delegate('#pte-stage2-selectors .none', 'click', {
1176
+ selector: '.pte-confirm'
1177
+ }, uncheckAllSizes);
1178
+ return true;
1179
+ };
1180
+ return $.extend(pte.functions, {
1181
+ iasSetAR: iasSetAR
1182
+ });
1183
+ })(pte);
1184
+
1185
+ }).call(this);
js/pte.full.js CHANGED
@@ -1,1125 +1,33 @@
1
- /*!
2
- * jQuery Templates Plugin 1.0.0pre
3
- * http://github.com/jquery/jquery-tmpl
4
- * Requires jQuery 1.4.2
5
- *
6
- * Copyright Software Freedom Conservancy, Inc.
7
- * Dual licensed under the MIT or GPL Version 2 licenses.
8
- * http://jquery.org/license
9
- */
10
- (function( jQuery, undefined ){
11
- var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
12
- newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
13
-
14
- function newTmplItem( options, parentItem, fn, data ) {
15
- // Returns a template item data structure for a new rendered instance of a template (a 'template item').
16
- // The content field is a hierarchical array of strings and nested items (to be
17
- // removed and replaced by nodes field of dom elements, once inserted in DOM).
18
- var newItem = {
19
- data: data || (data === 0 || data === false) ? data : (parentItem ? parentItem.data : {}),
20
- _wrap: parentItem ? parentItem._wrap : null,
21
- tmpl: null,
22
- parent: parentItem || null,
23
- nodes: [],
24
- calls: tiCalls,
25
- nest: tiNest,
26
- wrap: tiWrap,
27
- html: tiHtml,
28
- update: tiUpdate
29
- };
30
- if ( options ) {
31
- jQuery.extend( newItem, options, { nodes: [], parent: parentItem });
32
- }
33
- if ( fn ) {
34
- // Build the hierarchical content to be used during insertion into DOM
35
- newItem.tmpl = fn;
36
- newItem._ctnt = newItem._ctnt || newItem.tmpl( jQuery, newItem );
37
- newItem.key = ++itemKey;
38
- // Keep track of new template item, until it is stored as jQuery Data on DOM element
39
- (stack.length ? wrappedItems : newTmplItems)[itemKey] = newItem;
40
- }
41
- return newItem;
42
- }
43
-
44
- // Override appendTo etc., in order to provide support for targeting multiple elements. (This code would disappear if integrated in jquery core).
45
- jQuery.each({
46
- appendTo: "append",
47
- prependTo: "prepend",
48
- insertBefore: "before",
49
- insertAfter: "after",
50
- replaceAll: "replaceWith"
51
- }, function( name, original ) {
52
- jQuery.fn[ name ] = function( selector ) {
53
- var ret = [], insert = jQuery( selector ), elems, i, l, tmplItems,
54
- parent = this.length === 1 && this[0].parentNode;
55
-
56
- appendToTmplItems = newTmplItems || {};
57
- if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
58
- insert[ original ]( this[0] );
59
- ret = this;
60
- } else {
61
- for ( i = 0, l = insert.length; i < l; i++ ) {
62
- cloneIndex = i;
63
- elems = (i > 0 ? this.clone(true) : this).get();
64
- jQuery( insert[i] )[ original ]( elems );
65
- ret = ret.concat( elems );
66
- }
67
- cloneIndex = 0;
68
- ret = this.pushStack( ret, name, insert.selector );
69
- }
70
- tmplItems = appendToTmplItems;
71
- appendToTmplItems = null;
72
- jQuery.tmpl.complete( tmplItems );
73
- return ret;
74
- };
75
- });
76
-
77
- jQuery.fn.extend({
78
- // Use first wrapped element as template markup.
79
- // Return wrapped set of template items, obtained by rendering template against data.
80
- tmpl: function( data, options, parentItem ) {
81
- return jQuery.tmpl( this[0], data, options, parentItem );
82
- },
83
-
84
- // Find which rendered template item the first wrapped DOM element belongs to
85
- tmplItem: function() {
86
- return jQuery.tmplItem( this[0] );
87
- },
88
-
89
- // Consider the first wrapped element as a template declaration, and get the compiled template or store it as a named template.
90
- template: function( name ) {
91
- return jQuery.template( name, this[0] );
92
- },
93
-
94
- domManip: function( args, table, callback, options ) {
95
- if ( args[0] && jQuery.isArray( args[0] )) {
96
- var dmArgs = jQuery.makeArray( arguments ), elems = args[0], elemsLength = elems.length, i = 0, tmplItem;
97
- while ( i < elemsLength && !(tmplItem = jQuery.data( elems[i++], "tmplItem" ))) {}
98
- if ( tmplItem && cloneIndex ) {
99
- dmArgs[2] = function( fragClone ) {
100
- // Handler called by oldManip when rendered template has been inserted into DOM.
101
- jQuery.tmpl.afterManip( this, fragClone, callback );
102
- };
103
- }
104
- oldManip.apply( this, dmArgs );
105
- } else {
106
- oldManip.apply( this, arguments );
107
- }
108
- cloneIndex = 0;
109
- if ( !appendToTmplItems ) {
110
- jQuery.tmpl.complete( newTmplItems );
111
- }
112
- return this;
113
- }
114
- });
115
-
116
- jQuery.extend({
117
- // Return wrapped set of template items, obtained by rendering template against data.
118
- tmpl: function( tmpl, data, options, parentItem ) {
119
- var ret, topLevel = !parentItem;
120
- if ( topLevel ) {
121
- // This is a top-level tmpl call (not from a nested template using {{tmpl}})
122
- parentItem = topTmplItem;
123
- tmpl = jQuery.template[tmpl] || jQuery.template( null, tmpl );
124
- wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level
125
- } else if ( !tmpl ) {
126
- // The template item is already associated with DOM - this is a refresh.
127
- // Re-evaluate rendered template for the parentItem
128
- tmpl = parentItem.tmpl;
129
- newTmplItems[parentItem.key] = parentItem;
130
- parentItem.nodes = [];
131
- if ( parentItem.wrapped ) {
132
- updateWrapped( parentItem, parentItem.wrapped );
133
- }
134
- // Rebuild, without creating a new template item
135
- return jQuery( build( parentItem, null, parentItem.tmpl( jQuery, parentItem ) ));
136
- }
137
- if ( !tmpl ) {
138
- return []; // Could throw...
139
- }
140
- if ( typeof data === "function" ) {
141
- data = data.call( parentItem || {} );
142
- }
143
- if ( options && options.wrapped ) {
144
- updateWrapped( options, options.wrapped );
145
- }
146
- ret = jQuery.isArray( data ) ?
147
- jQuery.map( data, function( dataItem ) {
148
- return dataItem ? newTmplItem( options, parentItem, tmpl, dataItem ) : null;
149
- }) :
150
- [ newTmplItem( options, parentItem, tmpl, data ) ];
151
- return topLevel ? jQuery( build( parentItem, null, ret ) ) : ret;
152
- },
153
-
154
- // Return rendered template item for an element.
155
- tmplItem: function( elem ) {
156
- var tmplItem;
157
- if ( elem instanceof jQuery ) {
158
- elem = elem[0];
159
- }
160
- while ( elem && elem.nodeType === 1 && !(tmplItem = jQuery.data( elem, "tmplItem" )) && (elem = elem.parentNode) ) {}
161
- return tmplItem || topTmplItem;
162
- },
163
-
164
- // Set:
165
- // Use $.template( name, tmpl ) to cache a named template,
166
- // where tmpl is a template string, a script element or a jQuery instance wrapping a script element, etc.
167
- // Use $( "selector" ).template( name ) to provide access by name to a script block template declaration.
168
-
169
- // Get:
170
- // Use $.template( name ) to access a cached template.
171
- // Also $( selectorToScriptBlock ).template(), or $.template( null, templateString )
172
- // will return the compiled template, without adding a name reference.
173
- // If templateString includes at least one HTML tag, $.template( templateString ) is equivalent
174
- // to $.template( null, templateString )
175
- template: function( name, tmpl ) {
176
- if (tmpl) {
177
- // Compile template and associate with name
178
- if ( typeof tmpl === "string" ) {
179
- // This is an HTML string being passed directly in.
180
- tmpl = buildTmplFn( tmpl );
181
- } else if ( tmpl instanceof jQuery ) {
182
- tmpl = tmpl[0] || {};
183
- }
184
- if ( tmpl.nodeType ) {
185
- // If this is a template block, use cached copy, or generate tmpl function and cache.
186
- tmpl = jQuery.data( tmpl, "tmpl" ) || jQuery.data( tmpl, "tmpl", buildTmplFn( tmpl.innerHTML ));
187
- // Issue: In IE, if the container element is not a script block, the innerHTML will remove quotes from attribute values whenever the value does not include white space.
188
- // This means that foo="${x}" will not work if the value of x includes white space: foo="${x}" -> foo=value of x.
189
- // To correct this, include space in tag: foo="${ x }" -> foo="value of x"
190
- }
191
- return typeof name === "string" ? (jQuery.template[name] = tmpl) : tmpl;
192
- }
193
- // Return named compiled template
194
- return name ? (typeof name !== "string" ? jQuery.template( null, name ):
195
- (jQuery.template[name] ||
196
- // If not in map, and not containing at least on HTML tag, treat as a selector.
197
- // (If integrated with core, use quickExpr.exec)
198
- jQuery.template( null, htmlExpr.test( name ) ? name : jQuery( name )))) : null;
199
- },
200
-
201
- encode: function( text ) {
202
- // Do HTML encoding replacing < > & and ' and " by corresponding entities.
203
- return ("" + text).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;");
204
- }
205
- });
206
-
207
- jQuery.extend( jQuery.tmpl, {
208
- tag: {
209
- "tmpl": {
210
- _default: { $2: "null" },
211
- open: "if($notnull_1){__=__.concat($item.nest($1,$2));}"
212
- // tmpl target parameter can be of type function, so use $1, not $1a (so not auto detection of functions)
213
- // This means that {{tmpl foo}} treats foo as a template (which IS a function).
214
- // Explicit parens can be used if foo is a function that returns a template: {{tmpl foo()}}.
215
- },
216
- "wrap": {
217
- _default: { $2: "null" },
218
- open: "$item.calls(__,$1,$2);__=[];",
219
- close: "call=$item.calls();__=call._.concat($item.wrap(call,__));"
220
- },
221
- "each": {
222
- _default: { $2: "$index, $value" },
223
- open: "if($notnull_1){$.each($1a,function($2){with(this){",
224
- close: "}});}"
225
- },
226
- "if": {
227
- open: "if(($notnull_1) && $1a){",
228
- close: "}"
229
- },
230
- "else": {
231
- _default: { $1: "true" },
232
- open: "}else if(($notnull_1) && $1a){"
233
- },
234
- "html": {
235
- // Unecoded expression evaluation.
236
- open: "if($notnull_1){__.push($1a);}"
237
- },
238
- "=": {
239
- // Encoded expression evaluation. Abbreviated form is ${}.
240
- _default: { $1: "$data" },
241
- open: "if($notnull_1){__.push($.encode($1a));}"
242
- },
243
- "!": {
244
- // Comment tag. Skipped by parser
245
- open: ""
246
- }
247
- },
248
-
249
- // This stub can be overridden, e.g. in jquery.tmplPlus for providing rendered events
250
- complete: function( items ) {
251
- newTmplItems = {};
252
- },
253
-
254
- // Call this from code which overrides domManip, or equivalent
255
- // Manage cloning/storing template items etc.
256
- afterManip: function afterManip( elem, fragClone, callback ) {
257
- // Provides cloned fragment ready for fixup prior to and after insertion into DOM
258
- var content = fragClone.nodeType === 11 ?
259
- jQuery.makeArray(fragClone.childNodes) :
260
- fragClone.nodeType === 1 ? [fragClone] : [];
261
-
262
- // Return fragment to original caller (e.g. append) for DOM insertion
263
- callback.call( elem, fragClone );
264
-
265
- // Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by jQuery.data.
266
- storeTmplItems( content );
267
- cloneIndex++;
268
- }
269
- });
270
-
271
- //========================== Private helper functions, used by code above ==========================
272
-
273
- function build( tmplItem, nested, content ) {
274
- // Convert hierarchical content into flat string array
275
- // and finally return array of fragments ready for DOM insertion
276
- var frag, ret = content ? jQuery.map( content, function( item ) {
277
- return (typeof item === "string") ?
278
- // Insert template item annotations, to be converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
279
- (tmplItem.key ? item.replace( /(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" + tmplItem.key + "\" $2" ) : item) :
280
- // This is a child template item. Build nested template.
281
- build( item, tmplItem, item._ctnt );
282
- }) :
283
- // If content is not defined, insert tmplItem directly. Not a template item. May be a string, or a string array, e.g. from {{html $item.html()}}.
284
- tmplItem;
285
- if ( nested ) {
286
- return ret;
287
- }
288
-
289
- // top-level template
290
- ret = ret.join("");
291
-
292
- // Support templates which have initial or final text nodes, or consist only of text
293
- // Also support HTML entities within the HTML markup.
294
- ret.replace( /^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function( all, before, middle, after) {
295
- frag = jQuery( middle ).get();
296
-
297
- storeTmplItems( frag );
298
- if ( before ) {
299
- frag = unencode( before ).concat(frag);
300
- }
301
- if ( after ) {
302
- frag = frag.concat(unencode( after ));
303
- }
304
- });
305
- return frag ? frag : unencode( ret );
306
- }
307
-
308
- function unencode( text ) {
309
- // Use createElement, since createTextNode will not render HTML entities correctly
310
- var el = document.createElement( "div" );
311
- el.innerHTML = text;
312
- return jQuery.makeArray(el.childNodes);
313
- }
314
-
315
- // Generate a reusable function that will serve to render a template against data
316
- function buildTmplFn( markup ) {
317
- return new Function("jQuery","$item",
318
- // Use the variable __ to hold a string array while building the compiled template. (See https://github.com/jquery/jquery-tmpl/issues#issue/10).
319
- "var $=jQuery,call,__=[],$data=$item.data;" +
320
-
321
- // Introduce the data as local variables using with(){}
322
- "with($data){__.push('" +
323
-
324
- // Convert the template into pure JavaScript
325
- jQuery.trim(markup)
326
- .replace( /([\\'])/g, "\\$1" )
327
- .replace( /[\r\t\n]/g, " " )
328
- .replace( /\$\{([^\}]*)\}/g, "{{= $1}}" )
329
- .replace( /\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
330
- function( all, slash, type, fnargs, target, parens, args ) {
331
- var tag = jQuery.tmpl.tag[ type ], def, expr, exprAutoFnDetect;
332
- if ( !tag ) {
333
- throw "Unknown template tag: " + type;
334
- }
335
- def = tag._default || [];
336
- if ( parens && !/\w$/.test(target)) {
337
- target += parens;
338
- parens = "";
339
- }
340
- if ( target ) {
341
- target = unescape( target );
342
- args = args ? ("," + unescape( args ) + ")") : (parens ? ")" : "");
343
- // Support for target being things like a.toLowerCase();
344
- // In that case don't call with template item as 'this' pointer. Just evaluate...
345
- expr = parens ? (target.indexOf(".") > -1 ? target + unescape( parens ) : ("(" + target + ").call($item" + args)) : target;
346
- exprAutoFnDetect = parens ? expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" + target + "))";
347
- } else {
348
- exprAutoFnDetect = expr = def.$1 || "null";
349
- }
350
- fnargs = unescape( fnargs );
351
- return "');" +
352
- tag[ slash ? "close" : "open" ]
353
- .split( "$notnull_1" ).join( target ? "typeof(" + target + ")!=='undefined' && (" + target + ")!=null" : "true" )
354
- .split( "$1a" ).join( exprAutoFnDetect )
355
- .split( "$1" ).join( expr )
356
- .split( "$2" ).join( fnargs || def.$2 || "" ) +
357
- "__.push('";
358
- }) +
359
- "');}return __;"
360
- );
361
- }
362
- function updateWrapped( options, wrapped ) {
363
- // Build the wrapped content.
364
- options._wrap = build( options, true,
365
- // Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.
366
- jQuery.isArray( wrapped ) ? wrapped : [htmlExpr.test( wrapped ) ? wrapped : jQuery( wrapped ).html()]
367
- ).join("");
368
- }
369
-
370
- function unescape( args ) {
371
- return args ? args.replace( /\\'/g, "'").replace(/\\\\/g, "\\" ) : null;
372
- }
373
- function outerHtml( elem ) {
374
- var div = document.createElement("div");
375
- div.appendChild( elem.cloneNode(true) );
376
- return div.innerHTML;
377
- }
378
-
379
- // Store template items in jQuery.data(), ensuring a unique tmplItem data data structure for each rendered template instance.
380
- function storeTmplItems( content ) {
381
- var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
382
- for ( i = 0, l = content.length; i < l; i++ ) {
383
- if ( (elem = content[i]).nodeType !== 1 ) {
384
- continue;
385
- }
386
- elems = elem.getElementsByTagName("*");
387
- for ( m = elems.length - 1; m >= 0; m-- ) {
388
- processItemKey( elems[m] );
389
- }
390
- processItemKey( elem );
391
- }
392
- function processItemKey( el ) {
393
- var pntKey, pntNode = el, pntItem, tmplItem, key;
394
- // Ensure that each rendered template inserted into the DOM has its own template item,
395
- if ( (key = el.getAttribute( tmplItmAtt ))) {
396
- while ( pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute( tmplItmAtt ))) { }
397
- if ( pntKey !== key ) {
398
- // The next ancestor with a _tmplitem expando is on a different key than this one.
399
- // So this is a top-level element within this template item
400
- // Set pntNode to the key of the parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.
401
- pntNode = pntNode.parentNode ? (pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute( tmplItmAtt ) || 0)) : 0;
402
- if ( !(tmplItem = newTmplItems[key]) ) {
403
- // The item is for wrapped content, and was copied from the temporary parent wrappedItem.
404
- tmplItem = wrappedItems[key];
405
- tmplItem = newTmplItem( tmplItem, newTmplItems[pntNode]||wrappedItems[pntNode] );
406
- tmplItem.key = ++itemKey;
407
- newTmplItems[itemKey] = tmplItem;
408
- }
409
- if ( cloneIndex ) {
410
- cloneTmplItem( key );
411
- }
412
- }
413
- el.removeAttribute( tmplItmAtt );
414
- } else if ( cloneIndex && (tmplItem = jQuery.data( el, "tmplItem" )) ) {
415
- // This was a rendered element, cloned during append or appendTo etc.
416
- // TmplItem stored in jQuery data has already been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.
417
- cloneTmplItem( tmplItem.key );
418
- newTmplItems[tmplItem.key] = tmplItem;
419
- pntNode = jQuery.data( el.parentNode, "tmplItem" );
420
- pntNode = pntNode ? pntNode.key : 0;
421
- }
422
- if ( tmplItem ) {
423
- pntItem = tmplItem;
424
- // Find the template item of the parent element.
425
- // (Using !=, not !==, since pntItem.key is number, and pntNode may be a string)
426
- while ( pntItem && pntItem.key != pntNode ) {
427
- // Add this element as a top-level node for this rendered template item, as well as for any
428
- // ancestor items between this item and the item of its parent element
429
- pntItem.nodes.push( el );
430
- pntItem = pntItem.parent;
431
- }
432
- // Delete content built during rendering - reduce API surface area and memory use, and avoid exposing of stale data after rendering...
433
- delete tmplItem._ctnt;
434
- delete tmplItem._wrap;
435
- // Store template item as jQuery data on the element
436
- jQuery.data( el, "tmplItem", tmplItem );
437
- }
438
- function cloneTmplItem( key ) {
439
- key = key + keySuffix;
440
- tmplItem = newClonedItems[key] =
441
- (newClonedItems[key] || newTmplItem( tmplItem, newTmplItems[tmplItem.parent.key + keySuffix] || tmplItem.parent ));
442
- }
443
- }
444
- }
445
-
446
- //---- Helper functions for template item ----
447
-
448
- function tiCalls( content, tmpl, data, options ) {
449
- if ( !content ) {
450
- return stack.pop();
451
- }
452
- stack.push({ _: content, tmpl: tmpl, item:this, data: data, options: options });
453
- }
454
-
455
- function tiNest( tmpl, data, options ) {
456
- // nested template, using {{tmpl}} tag
457
- return jQuery.tmpl( jQuery.template( tmpl ), data, options, this );
458
- }
459
-
460
- function tiWrap( call, wrapped ) {
461
- // nested template, using {{wrap}} tag
462
- var options = call.options || {};
463
- options.wrapped = wrapped;
464
- // Apply the template, which may incorporate wrapped content,
465
- return jQuery.tmpl( jQuery.template( call.tmpl ), call.data, options, call.item );
466
- }
467
-
468
- function tiHtml( filter, textOnly ) {
469
- var wrapped = this._wrap;
470
- return jQuery.map(
471
- jQuery( jQuery.isArray( wrapped ) ? wrapped.join("") : wrapped ).filter( filter || "*" ),
472
- function(e) {
473
- return textOnly ?
474
- e.innerText || e.textContent :
475
- e.outerHTML || outerHtml(e);
476
- });
477
- }
478
-
479
- function tiUpdate() {
480
- var coll = this.nodes;
481
- jQuery.tmpl( null, null, null, this).insertBefore( coll[0] );
482
- jQuery( coll ).remove();
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
-
653
- Hooks into the Wordpress Media Library
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;
663
- id = override_id || image_id || $("#attachment-id").val();
664
- return "" + ajaxurl + "?action=pte_ajax&pte-action=launch&id=" + id + thickbox;
665
- };
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();
678
- }
679
- };
680
- injectPTE = function() {
681
- $('.media-item').each(function(i, elem) {
682
- var post_id;
683
- post_id = elem.id.replace("media-item-", "");
684
- return $getLink(post_id).css({
685
- 'font-size': '.8em',
686
- 'margin-left': '5px'
687
- }).click(checkExistingThickbox).appendTo($('tr.image-size th.label', elem));
688
- });
689
- if (imageEdit.open != null) {
690
- imageEdit.oldopen = imageEdit.open;
691
- imageEdit.open = function(id, nonce) {
692
- image_id = id;
693
- imageEdit.oldopen(id, nonce);
694
- return launchPTE();
695
- };
696
- }
697
- return true;
698
- };
699
- launchPTE = function() {
700
- var $editmenu, selector;
701
- selector = "#imgedit-save-target-" + image_id;
702
- $editmenu = $(selector);
703
- if (($editmenu != null ? $editmenu.size() : void 0) < 1) {
704
- window.log("Edit Thumbnail Menu not visible, waiting for " + timeout + "ms");
705
- window.setTimeout(launchPTE, timeout);
706
- return false;
707
- }
708
- return $editmenu.append($getLink().click(checkExistingThickbox));
709
- };
710
- return injectPTE();
711
- };
712
- })(pte);
713
- TimerFunc = (function() {
714
- function TimerFunc(fn, timeout) {
715
- this.fn = fn;
716
- this.timeout = timeout;
717
- this.doFunc = __bind(this.doFunc, this);
718
- this.timer = null;
719
- }
720
- TimerFunc.prototype.doFunc = function(e) {
721
- window.clearTimeout(this.timer);
722
- this.timer = window.setTimeout(this.fn, this.timeout);
723
- return true;
724
- };
725
- return TimerFunc;
726
- })();
727
- window.randomness = function() {
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
- log([direction, move_to, isVisible]);
777
- if (!isVisible) {
778
- $elem.show(0, function() {
779
- return $(this).animate({
780
- 'left': move_to
781
- }, options.speed, options.easing, next);
782
- });
783
- } else {
784
- $elem.animate({
785
- 'left': move_to
786
- }, options.speed, options.easing);
787
- $elem.hide(0, next);
788
- }
789
- return true;
790
- }, this));
791
- });
792
- if (options.callback != null) {
793
- pte_queue.queue(function(next) {
794
- if (options.callbackargs != null) {
795
- log("running callback with arguments");
796
- options.callback.apply(this, options.callbackargs);
797
- } else {
798
- log("running callback with no arguments");
799
- options.callback.apply(this);
800
- }
801
- log("finished running callback");
802
- return next();
803
- });
804
- }
805
- return this;
806
- },
807
- moveRight: function(options) {
808
- options = $.extend(options, {
809
- direction: 'right'
810
- });
811
- return this.move(options);
812
- },
813
- moveLeft: function(options) {
814
- options = $.extend(options, {
815
- direction: 'left'
816
- });
817
- return this.move(options);
818
- }
819
- });
820
- window.goBack = function(e) {
821
- if (e != null) {
822
- e.preventDefault();
823
- }
824
- $('#stage2').moveRight();
825
- $('#stage1').moveRight({
826
- callback: function() {
827
- deleteThumbs($('#pte-post-id').val());
828
- return $('#stage2').html('');
829
- }
830
- });
831
- return true;
832
- };
833
- gcd = function(a, b) {
834
- if (a === 0) {
835
- return b;
836
- }
837
- while (b > 0) {
838
- if (a > b) {
839
- a = a - b;
840
- } else {
841
- b = b - a;
842
- }
843
- }
844
- if (a < 0 || b < 0) {
845
- return null;
846
- }
847
- return a;
848
- };
849
- determineAspectRatio = function(current_ar, size_info) {
850
- var crop, gc, height, tmp_ar, width;
851
- crop = size_info.crop, width = size_info.width, height = size_info.height;
852
- crop = +crop;
853
- width = +width;
854
- height = +height;
855
- gc = gcd(width, height);
856
- if ((crop != null) && crop > 0) {
857
- tmp_ar = null;
858
- if ((width != null) > 0 && (height != null) > 0) {
859
- if (gc != null) {
860
- tmp_ar = "" + (width / gc) + ":" + (height / gc);
861
- } else {
862
- tmp_ar = "" + width + ":" + height;
863
- }
864
- }
865
- if ((current_ar != null) && (tmp_ar != null) && tmp_ar !== current_ar) {
866
- throw objectL10n.aspect_ratio_disabled;
867
- }
868
- current_ar = tmp_ar;
869
- }
870
- return current_ar;
871
- };
872
- pte.functions = {
873
- determineAspectRatio: determineAspectRatio
874
- };
875
- (function(pte) {
876
- var addCheckAllNoneListener, addRowListener, addRowListeners, addSubmitListener, addVerifyListener, configureOverlay, configurePageDisplay, editor, iasSetAR, ias_defaults, ias_instance, initImgAreaSelect;
877
- editor = pte.editor = function() {
878
- configurePageDisplay();
879
- addRowListeners();
880
- initImgAreaSelect();
881
- addRowListener();
882
- addSubmitListener();
883
- addVerifyListener();
884
- addCheckAllNoneListener();
885
- configureOverlay();
886
- return true;
887
- };
888
- configureOverlay = function() {
889
- var $loading_screen, closeLoadingScreen;
890
- $loading_screen = $('#pte-loading');
891
- closeLoadingScreen = function() {
892
- $loading_screen.hide();
893
- return true;
894
- };
895
- $('#pte-preview').load(closeLoadingScreen);
896
- $loading_screen.ajaxStart(function() {
897
- return $(this).fadeIn(200);
898
- }).ajaxStop(function() {
899
- return $(this).fadeOut(200);
900
- });
901
- window.setTimeout(closeLoadingScreen, 2000);
902
- return true;
903
- };
904
- configurePageDisplay = function() {
905
- var reflow;
906
- reflow = new TimerFunc(function() {
907
- var offset, window_height;
908
- log("===== REFLOW =====");
909
- pte.fixThickbox(window.parent);
910
- offset = $("#pte-sizes").offset();
911
- window_height = $(window).height() - offset.top - 2;
912
- $("#pte-sizes").height(window_height);
913
- log("WINDOW WIDTH: " + ($(window).width()));
914
- $('#stage2, #stage3').filter(":hidden").css({
915
- left: $(window).width()
916
- });
917
- return true;
918
- }, 100);
919
- $(window).resize(reflow.doFunc).load(reflow.doFunc);
920
- return true;
921
- };
922
- addRowListeners = function() {
923
- var enableRowFeatures;
924
- enableRowFeatures = function($elem) {
925
- $elem.delegate('tr', 'click', function(e) {
926
- if (e.target.type !== 'checkbox') {
927
- $('input:checkbox', this).click();
928
- }
929
- return true;
930
- });
931
- return $elem.delegate('input:checkbox', 'click', function(e) {
932
- if (this.checked || $(this).is('input:checked')) {
933
- $(this).parents('tr').first().removeClass('selected');
934
- } else {
935
- $(this).parents('tr').first().addClass('selected');
936
- }
937
- return true;
938
- });
939
- };
940
- enableRowFeatures($('#stage2'));
941
- return enableRowFeatures($('#stage1'));
942
- };
943
- /* Enable imgareaselect plugin */
944
- ias_instance = null;
945
- ias_defaults = {
946
- keys: true,
947
- minWidth: 3,
948
- minHeight: 3,
949
- handles: true,
950
- zIndex: 1200,
951
- instance: true,
952
- onSelectEnd: function(img, s) {
953
- if (s.width && s.width > 0 && s.height && s.height > 0 && $('.pte-size').filter(':checked').size() > 0) {
954
- return $('#pte-submit').removeAttr('disabled');
955
- } else {
956
- return $('#pte-submit').attr('disabled', true);
957
- }
958
- }
959
- };
960
- initImgAreaSelect = function() {
961
- return pte.ias = ias_instance = $('#pte-image img').imgAreaSelect(ias_defaults);
962
- };
963
- iasSetAR = function(ar) {
964
- log("===== SETTING ASPECTRATIO: " + ar + " =====");
965
- ias_instance.setOptions({
966
- aspectRatio: ar
967
- });
968
- return ias_instance.update();
969
- };
970
- addRowListener = function() {
971
- var pteCheckHandler, pteVerifySubmitButtonHandler;
972
- pteVerifySubmitButtonHandler = new TimerFunc(function() {
973
- log("===== CHECK SUBMIT BUTTON =====");
974
- if ($('.pte-confirm').filter(':checked').size() > 0) {
975
- log("ENABLE");
976
- $('#pte-confirm').removeAttr('disabled');
977
- } else {
978
- log("DISABLE");
979
- $('#pte-confirm').attr('disabled', true);
980
- }
981
- return true;
982
- }, 50);
983
- pteCheckHandler = new TimerFunc(function() {
984
- var ar, selected_elements;
985
- ar = null;
986
- selected_elements = $('input.pte-size').filter(':checked').each(function(i, elem) {
987
- try {
988
- ar = determineAspectRatio(ar, thumbnail_info[$(elem).val()]);
989
- } catch (error) {
990
- ar = null;
991
- if (ar !== ias_instance.getOptions().aspectRatio) {
992
- alert(error);
993
- }
994
- return false;
995
- }
996
- return true;
997
- });
998
- iasSetAR(ar);
999
- ias_defaults.onSelectEnd(null, ias_instance.getSelection());
1000
- return true;
1001
- }, 50);
1002
- $.extend(pte.functions, {
1003
- pteVerifySubmitButtonHandler: pteVerifySubmitButtonHandler
1004
- });
1005
- $('input.pte-size').click(pteCheckHandler.doFunc);
1006
- return $('.pte-confirm').live('click', function(e) {
1007
- return pteVerifySubmitButtonHandler.doFunc();
1008
- });
1009
- };
1010
- addSubmitListener = function() {
1011
- var onResizeImages;
1012
- $('#pte-submit').click(function(e) {
1013
- var scale_factor, selection, submit_data;
1014
- selection = ias_instance.getSelection();
1015
- scale_factor = $('#pte-sizer').val();
1016
- submit_data = {
1017
- 'id': $('#pte-post-id').val(),
1018
- 'action': 'pte_ajax',
1019
- 'pte-action': 'resize-images',
1020
- 'pte-sizes[]': $('.pte-size').filter(':checked').map(function() {
1021
- return $(this).val();
1022
- }).get(),
1023
- 'x': Math.floor(selection.x1 / scale_factor),
1024
- 'y': Math.floor(selection.y1 / scale_factor),
1025
- 'w': Math.floor(selection.width / scale_factor),
1026
- 'h': Math.floor(selection.height / scale_factor)
1027
- };
1028
- log("===== RESIZE-IMAGES =====");
1029
- log(submit_data);
1030
- if (isNaN(submit_data.x) || isNaN(submit_data.y) || isNaN(submit_data.w) || isNaN(submit_data.h)) {
1031
- alert(objectL10n.crop_submit_data_error);
1032
- log("ERROR with submit_data and NaN's");
1033
- return false;
1034
- }
1035
- ias_instance.setOptions({
1036
- hide: true,
1037
- x1: 0,
1038
- y1: 0,
1039
- x2: 0,
1040
- y2: 0
1041
- });
1042
- $('#pte-submit').attr('disabled', true);
1043
- $.getJSON(ajaxurl, submit_data, onResizeImages);
1044
- return true;
1045
- });
1046
- return onResizeImages = function(data, status, xhr) {
1047
- /* Evaluate data */ log("===== RESIZE-IMAGES SUCCESS =====");
1048
- log(data);
1049
- pte.parseServerLog(data.log);
1050
- if ((data.error != null) && !(data.thumbnails != null)) {
1051
- alert(data.error);
1052
- return;
1053
- }
1054
- $('#stage1').moveLeft();
1055
- $('#stage2').html($('#stage2template').tmpl(data)).moveLeft({
1056
- callback: pte.functions.pteVerifySubmitButtonHandler.doFunc
1057
- });
1058
- return false;
1059
- };
1060
- };
1061
- /* Callback for Stage 2 to 3 */
1062
- addVerifyListener = function() {
1063
- var onConfirmImages;
1064
- $('#pte-confirm').live('click', function(e) {
1065
- var submit_data, thumbnail_data;
1066
- thumbnail_data = {};
1067
- $('input.pte-confirm').filter(':checked').each(function(i, elem) {
1068
- var size;
1069
- size = $(elem).val();
1070
- return thumbnail_data[size] = $(elem).parent().parent().find('.pte-file').val();
1071
- });
1072
- submit_data = {
1073
- 'id': $('#pte-post-id').val(),
1074
- 'action': 'pte_ajax',
1075
- 'pte-action': 'confirm-images',
1076
- 'pte-nonce': $('#pte-nonce').val(),
1077
- 'pte-confirm': thumbnail_data
1078
- };
1079
- log("===== CONFIRM-IMAGES =====");
1080
- log(submit_data);
1081
- return $.getJSON(ajaxurl, submit_data, onConfirmImages);
1082
- });
1083
- return onConfirmImages = function(data, status, xhr) {
1084
- log("===== CONFIRM-IMAGES SUCCESS =====");
1085
- log(data);
1086
- pte.parseServerLog(data.log);
1087
- $('#stage2').moveLeft();
1088
- $('#stage3').html($('#stage3template').tmpl(data)).moveLeft();
1089
- return false;
1090
- };
1091
- };
1092
- /* Select ALL|NONE */
1093
- addCheckAllNoneListener = function() {
1094
- var checkAllSizes, uncheckAllSizes;
1095
- uncheckAllSizes = function(e) {
1096
- var elements, _ref, _ref2;
1097
- if (e != null) {
1098
- e.preventDefault();
1099
- }
1100
- elements = (_ref = (_ref2 = e.data) != null ? _ref2.selector : void 0) != null ? _ref : '.pte-size';
1101
- return $(elements).filter(':checked').click();
1102
- };
1103
- checkAllSizes = function(e) {
1104
- var elements, _ref, _ref2;
1105
- if (e != null) {
1106
- e.preventDefault();
1107
- }
1108
- elements = (_ref = e != null ? (_ref2 = e.data) != null ? _ref2.selector : void 0 : void 0) != null ? _ref : '.pte-size';
1109
- return $(elements).not(':checked').click();
1110
- };
1111
- $("#pte-selectors .all").click(checkAllSizes);
1112
- $("#pte-selectors .none").click(uncheckAllSizes).click();
1113
- $('#stage2').delegate('#pte-stage2-selectors .all', 'click', {
1114
- selector: '.pte-confirm'
1115
- }, checkAllSizes);
1116
- $('#stage2').delegate('#pte-stage2-selectors .none', 'click', {
1117
- selector: '.pte-confirm'
1118
- }, uncheckAllSizes);
1119
- return true;
1120
- };
1121
- return $.extend(pte.functions, {
1122
- iasSetAR: iasSetAR
1123
- });
1124
- })(pte);
1125
- }).call(this);
1
+ (function(c){function t(b,f,m,e){e={data:e||0===e||!1===e?e:f?f.data:{},_wrap:f?f._wrap:null,tmpl:null,parent:f||null,nodes:[],calls:j,nest:D,wrap:x,html:E,update:F};b&&c.extend(e,b,{nodes:[],parent:f});m&&(e.tmpl=m,e._ctnt=e._ctnt||e.tmpl(c,e),e.key=++l,(a.length?u:n)[l]=e);return e}function v(b,f,a){var e;a=a?c.map(a,function(f){return"string"===typeof f?b.key?f.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+q+'="'+b.key+'" $2'):f:v(f,b,f._ctnt)}):b;if(f)return a;a=a.join("");a.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,
2
+ function(b,f,a,m){e=c(a).get();y(e);f&&(e=w(f).concat(e));m&&(e=e.concat(w(m)))});return e?e:w(a)}function w(b){var f=document.createElement("div");f.innerHTML=b;return c.makeArray(f.childNodes)}function A(b){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+c.trim(b).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
3
+ function(b,a,e,g,h,k,d){b=c.tmpl.tag[e];if(!b)throw"Unknown template tag: "+e;e=b._default||[];k&&!/\w$/.test(h)&&(h+=k,k="");h?(h=r(h),d=d?","+r(d)+")":k?")":"",d=k?-1<h.indexOf(".")?h+r(k):"("+h+").call($item"+d:h,k=k?d:"(typeof("+h+")==='function'?("+h+").call($item):("+h+"))"):k=d=e.$1||"null";g=r(g);return"');"+b[a?"close":"open"].split("$notnull_1").join(h?"typeof("+h+")!=='undefined' && ("+h+")!=null":"true").split("$1a").join(k).split("$1").join(d).split("$2").join(g||e.$2||"")+"__.push('"})+
4
+ "');}return __;")}function d(b,f){b._wrap=v(b,!0,c.isArray(f)?f:[B.test(f)?f:c(f).html()]).join("")}function r(b){return b?b.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function y(b){function f(b){function f(b){b+=a;d=h[b]=h[b]||t(d,n[d.parent.key+a]||d.parent)}var e,g=b,d,k;if(k=b.getAttribute(q)){for(;g.parentNode&&1===(g=g.parentNode).nodeType&&!(e=g.getAttribute(q)););if(e!==k){g=g.parentNode?11===g.nodeType?0:g.getAttribute(q)||0:0;if(!(d=n[k]))d=u[k],d=t(d,n[g]||u[g]),d.key=++l,n[l]=d;p&&
5
+ f(k)}b.removeAttribute(q)}else if(p&&(d=c.data(b,"tmplItem")))f(d.key),n[d.key]=d,g=(g=c.data(b.parentNode,"tmplItem"))?g.key:0;if(d){for(e=d;e&&e.key!=g;)e.nodes.push(b),e=e.parent;delete d._ctnt;delete d._wrap;c.data(b,"tmplItem",d)}}var a="_"+p,e,g,h={},k,d,j;k=0;for(d=b.length;k<d;k++)if(1===(e=b[k]).nodeType){g=e.getElementsByTagName("*");for(j=g.length-1;0<=j;j--)f(g[j]);f(e)}}function j(b,f,c,e){if(!b)return a.pop();a.push({_:b,tmpl:f,item:this,data:c,options:e})}function D(b,f,a){return c.tmpl(c.template(b),
6
+ f,a,this)}function x(b,f){var a=b.options||{};a.wrapped=f;return c.tmpl(c.template(b.tmpl),b.data,a,b.item)}function E(b,f){var a=this._wrap;return c.map(c(c.isArray(a)?a.join(""):a).filter(b||"*"),function(b){if(f)b=b.innerText||b.textContent;else{var a;if(!(a=b.outerHTML))a=document.createElement("div"),a.appendChild(b.cloneNode(!0)),a=a.innerHTML;b=a}return b})}function F(){var b=this.nodes;c.tmpl(null,null,null,this).insertBefore(b[0]);c(b).remove()}var C=c.fn.domManip,q="_tmplitem",B=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
7
+ n={},u={},s,z={key:0,data:{}},l=0,p=0,a=[];c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(b,f){c.fn[b]=function(a){var e=[];a=c(a);var g,d,k;g=1===this.length&&this[0].parentNode;s=n||{};if(g&&11===g.nodeType&&1===g.childNodes.length&&1===a.length)a[f](this[0]),e=this;else{d=0;for(k=a.length;d<k;d++)p=d,g=(0<d?this.clone(!0):this).get(),c(a[d])[f](g),e=e.concat(g);p=0;e=this.pushStack(e,b,a.selector)}a=s;s=null;c.tmpl.complete(a);
8
+ return e}});c.fn.extend({tmpl:function(b,a,d){return c.tmpl(this[0],b,a,d)},tmplItem:function(){return c.tmplItem(this[0])},template:function(b){return c.template(b,this[0])},domManip:function(b,a,d,e){if(b[0]&&c.isArray(b[0])){for(var g=c.makeArray(arguments),h=b[0],k=h.length,j=0,l;j<k&&!(l=c.data(h[j++],"tmplItem")););l&&p&&(g[2]=function(b){c.tmpl.afterManip(this,b,d)});C.apply(this,g)}else C.apply(this,arguments);p=0;s||c.tmpl.complete(n);return this}});c.extend({tmpl:function(b,a,m,e){var g=
9
+ !e;if(g)e=z,b=c.template[b]||c.template(null,b),u={};else if(!b)return b=e.tmpl,n[e.key]=e,e.nodes=[],e.wrapped&&d(e,e.wrapped),c(v(e,null,e.tmpl(c,e)));if(!b)return[];"function"===typeof a&&(a=a.call(e||{}));m&&m.wrapped&&d(m,m.wrapped);a=c.isArray(a)?c.map(a,function(a){return a?t(m,e,b,a):null}):[t(m,e,b,a)];return g?c(v(e,null,a)):a},tmplItem:function(b){var a;for(b instanceof c&&(b=b[0]);b&&1===b.nodeType&&!(a=c.data(b,"tmplItem"))&&(b=b.parentNode););return a||z},template:function(b,a){return a?
10
+ ("string"===typeof a?a=A(a):a instanceof c&&(a=a[0]||{}),a.nodeType&&(a=c.data(a,"tmpl")||c.data(a,"tmpl",A(a.innerHTML))),"string"===typeof b?c.template[b]=a:a):b?"string"!==typeof b?c.template(null,b):c.template[b]||c.template(null,B.test(b)?b:c(b)):null},encode:function(b){return(""+b).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});c.extend(c.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},
11
+ 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(){n={}},afterManip:function(b,
12
+ a,d){var e=11===a.nodeType?c.makeArray(a.childNodes):1===a.nodeType?[a]:[];d.call(b,a);y(e);p++}})})(jQuery);
13
+ (function(){var c,t,v,w,A,d,r,y,j;j=this;c=j.jQuery;j.pte=d=d||{};d.fixThickbox=function(a){var b,c,d,e;b=a.jQuery;if(!(null===b||1>a.frames.length))if(log("===== FIXING THICKBOX ====="),e=j.options.pte_tb_width+30,d=j.options.pte_tb_height+38,c=b("#TB_window"),!(c.width()>=e&&c.height()>=d))return log("THICKBOX: "+c.width()+" x "+c.height()),c.css({"margin-left":0-e/2,width:e,height:d}).children("iframe").css({width:e}),a.setTimeout(function(){if(!(b("iframe",c).height()>d))return b("iframe",c).css({height:d}),
14
+ log("THICKBOX: "+c.width()+" x "+c.height()),!0},1E3)};y=function(a){return{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};var D=function(a){this.message=a;this.date=new Date};D.prototype.toString=function(){var a,b,f,d,e,g,h;g=function(a,b){for(;(""+a).length<b;)a="0"+a;return a};f=this.date;h=g(f.getUTCFullYear(),4);b=g(f.getUTCMonth()+1,2);a=g(f.getUTCDate(),2);d=g(f.getUTCHours(),2);e=g(f.getUTCMinutes(),2);g=g(f.getUTCSeconds(),2);switch(y(this.message)){case "string":f=this.message;
15
+ break;default:f=c.toJSON(this.message)}return""+h+b+a+" "+d+":"+e+":"+g+" - ["+y(this.message)+"] "+f};d.messages=[];d.log=function(a){if(!j.options.pte_debug)return!0;try{d.messages.push(new D(a)),console.log(a),c("#pte-log-messages textarea").filter(":visible").val(d.formatLog())}catch(b){}};d.formatLog=function(){var a,b,c,m,e;a="";e=d.messages;c=0;for(m=e.length;c<m;c++)b=e[c],a+=""+b+"\n";return a};d.parseServerLog=function(a){var b,c,d;log("===== SERVER LOG =====");if(null!=(null!=a?a.length:
16
+ void 0)&&0<a.length){c=0;for(d=a.length;c<d;c++)b=a[c],log(b)}return!0};d.sendToPastebin=function(a){return c.ajax({url:"http://dpastey.appspot.com/",data:{title:"PostThumbnailEditor Log",content:a,lexer:"text",format:"json",expire_options:"2592000"},dataType:"json",global:!1,type:"POST",error:function(a,f,d){c("#pte-log").fadeOut("900");alert(objectL10n.pastebin_create_error);log(a);log(f);return log(d)},success:function(a){c("#pte-log").fadeOut("900");return prompt(objectL10n.pastebin_url,a.url)}})};
17
+ j.log=d.log;c(document).ready(function(a){a("#test").click(function(a){a.stopImmediatePropagation();return!0});a("#pastebin").click(function(){return d.sendToPastebin(d.formatLog())});a("#clear-log").click(function(){d.messages=[];return a("#pte-log-messages textarea").val(d.formatLog())});a("#close-log").click(function(){return a("#pte-log").fadeOut("900")});a("#pte-log-tools a").click(function(a){return a.preventDefault()});return a("body").delegate(".show-log-messages","click",function(b){b.preventDefault();
18
+ a("#pte-log-messages textarea").val(d.formatLog());return a("#pte-log").fadeIn("900")})});d.media=function(){var a;a=c("#tmpl-attachment-details").text();a=a.replace(/(<div class="compat-meta">)/,""+('<a target="_blank" href="'+ajaxurl+'?action=pte_ajax&pte-action=launch&id={{data.id}}">\n\t'+objectL10n.PTE+"\n</a>")+"\n$1");return c("#tmpl-attachment-details").text(a)};d.admin=function(){var a,b,f,d,e,g;g="&TB_iframe=true&height="+j.options.pte_tb_height+"&width="+j.options.pte_tb_width;f=null;e=
19
+ function(a){a=a||f||c("#attachment-id").val();return""+ajaxurl+"?action=pte_ajax&pte-action=launch&id="+a+g};a=function(a){return c('<a class="thickbox" href="'+e(a)+'">'+objectL10n.PTE+"</a>")};b=function(a){log("Start PTE...");if(0<j.parent.frames.length)return log("Modifying thickbox..."),j.parent.tb_click(),a.stopPropagation()};d=function(){var e;e=c("#imgedit-save-target-"+f);return 1>(null!=e?e.size():void 0)?(j.log("Edit Thumbnail Menu not visible, waiting for 300ms"),j.setTimeout(d,300),!1):
20
+ e.append(a().click(b))};var h;c(".media-item").each(function(e,f){var d;d=f.id.replace("media-item-","");return a(d).css({"font-size":".8em","margin-left":"5px"}).click(b).appendTo(c("tr.image-size th.label",f))});null!=imageEdit.open&&(imageEdit.oldopen=imageEdit.open,imageEdit.open=function(a,b){f=a;imageEdit.oldopen(a,b);return d()});h=c('p[id^="imgedit-save-target-"]');if(0<(null!=h?h.length:void 0))h=h[0].id.match(/imgedit-save-target-(\d+)/),null!=h[1]&&(f=h[1],d());return!0};var x=function(a,
21
+ b){this.fn=a;this.timeout=b;var c=this.doFunc,d=this;this.doFunc=function(){return c.apply(d,arguments)};this.timer=null};x.prototype.doFunc=function(){j.clearTimeout(this.timer);this.timer=j.setTimeout(this.fn,this.timeout);return!0};j.randomness=function(){return Math.floor(1000001*Math.random()).toString(16)};j.debugTmpl=function(a){log("===== TEMPLATE DEBUG DATA FOLLOWS =====");log(a);return!0};t=function(a){a={id:a,action:"pte_ajax","pte-action":"delete-images","pte-nonce":c("#pte-delete-nonce").val()};
22
+ return c.ajax({url:ajaxurl,data:a,global:!1,dataType:"json",success:v})};v=function(a){log("===== DELETE SUCCESSFUL, DATA DUMP FOLLOWS =====");log(a);return d.parseServerLog(a.log)};r=c({});c.fn.extend({move:function(a){a=c.extend({direction:"left",speed:500,easing:"swing",toggle:!0,callback:null,callbackargs:null},a);this.each(function(){var b=this;return r.queue(function(f){var d,e,g,h;d=c(b);e="left"===a.direction?-1:1;h="0px"===d.css("left")?c(j).width()*e:0;g=d.is(":visible");log([e,h,g]);g?
23
+ (d.animate({left:h},a.speed,a.easing),d.hide(0,f)):d.show(0,function(){return c(this).animate({left:h},a.speed,a.easing,f)});return!0})});null!=a.callback&&r.queue(function(b){null!=a.callbackargs?(log("running callback with arguments"),a.callback.apply(this,a.callbackargs)):(log("running callback with no arguments"),a.callback.apply(this));log("finished running callback");return b()});return this},moveRight:function(a){a=c.extend(a,{direction:"right"});return this.move(a)},moveLeft:function(a){a=
24
+ c.extend(a,{direction:"left"});return this.move(a)}});j.goBack=function(a){null!=a&&a.preventDefault();c("#stage2").moveRight();c("#stage1").moveRight({callback:function(){t(c("#pte-post-id").val());return c("#stage2").html("")}});return!0};A=function(a,b){if(0===a)return b;for(;0<b;)a>b?a-=b:b-=a;return 0>a||0>b?null:a};w=function(a,b){var c,d,e,g;c=b.crop;g=b.width;e=b.height;c=+c;g=+g;e=+e;d=A(g,e);if(null!=c&&0<c){c=null;null!=g&&(0<g&&null!=e&&0<e)&&(c=null!=d?""+g/d+":"+e/d:""+g+":"+e);if(null!=
25
+ a&&null!=c&&c!==a)throw objectL10n.aspect_ratio_disabled;a=c}return a};d.functions={determineAspectRatio:w};var E,F,C,q,B,n,u,s,z,l,p;d.editor=function(){u();C();p();F();q();B();E();n();return!0};n=function(){var a,b;a=c("#pte-loading");b=function(){a.hide();return!0};c("#pte-preview").load(b);a.ajaxStart(function(){return c(this).fadeIn(200)}).ajaxStop(function(){return c(this).fadeOut(200)});j.setTimeout(b,2E3);return!0};u=function(){var a;a=new x(function(){var a;log("===== REFLOW =====");d.fixThickbox(j.parent);
26
+ a=c("#pte-sizes").offset();a=c(j).height()-a.top-2;c("#pte-sizes").height(a);log("WINDOW WIDTH: "+c(j).width());c("#stage2, #stage3").filter(":hidden").css({left:c(j).width()});return!0},100);c(j).resize(a.doFunc).load(a.doFunc);return!0};C=function(){var a;a=function(a){a.delegate("tr","click",function(a){"checkbox"!==a.target.type&&c("input:checkbox",this).click();return!0});return a.delegate("input:checkbox","click",function(){this.checked||c(this).is("input:checked")?c(this).parents("tr").first().removeClass("selected"):
27
+ c(this).parents("tr").first().addClass("selected");return!0})};a(c("#stage2"));return a(c("#stage1"))};l=null;z={keys:!0,minWidth:3,minHeight:3,handles:!0,zIndex:1200,instance:!0,onSelectEnd:function(a,b){return b.width&&0<b.width&&b.height&&0<b.height&&0<c(".pte-size").filter(":checked").size()?c("#pte-submit").removeAttr("disabled"):c("#pte-submit").attr("disabled",!0)}};p=function(){return d.ias=l=c("#pte-image img").imgAreaSelect(z)};s=function(a){log("===== SETTING ASPECTRATIO: "+a+" =====");
28
+ l.setOptions({aspectRatio:a});return l.update()};F=function(){var a,b;b=new x(function(){log("===== CHECK SUBMIT BUTTON =====");0<c(".pte-confirm").filter(":checked").size()?(log("ENABLE"),c("#pte-confirm").removeAttr("disabled")):(log("DISABLE"),c("#pte-confirm").attr("disabled",!0));return!0},50);a=new x(function(){var a;a=null;c("input.pte-size").filter(":checked").each(function(b,e){try{a=w(a,thumbnail_info[c(e).val()])}catch(d){return a=null,a!==l.getOptions().aspectRatio&&log("Setting Aspect Ratio to null"),
29
+ !1}return!0});s(a);z.onSelectEnd(null,l.getSelection());return!0},50);c.extend(d.functions,{pteVerifySubmitButtonHandler:b});c("input.pte-size").click(a.doFunc);return c(".pte-confirm").live("click",function(){return b.doFunc()})};q=function(){var a;c("#pte-submit").click(function(){var b,d;d=l.getSelection();b=c("#pte-sizer").val();b={id:c("#pte-post-id").val(),action:"pte_ajax","pte-action":"resize-images","pte-sizes[]":c(".pte-size").filter(":checked").map(function(){return c(this).val()}).get(),
30
+ x:Math.floor(d.x1/b),y:Math.floor(d.y1/b),w:Math.floor(d.width/b),h:Math.floor(d.height/b)};log("===== RESIZE-IMAGES =====");log(b);if(isNaN(b.x)||isNaN(b.y)||isNaN(b.w)||isNaN(b.h))return alert(objectL10n.crop_submit_data_error),log("ERROR with submit_data and NaN's"),!1;l.setOptions({hide:!0,x1:0,y1:0,x2:0,y2:0});c("#pte-submit").attr("disabled",!0);c.getJSON(ajaxurl,b,a);return!0});return a=function(a){log("===== RESIZE-IMAGES SUCCESS =====");log(a);d.parseServerLog(a.log);if(null!=a.error&&null==
31
+ a.thumbnails)alert(a.error);else return c("#stage1").moveLeft(),c("#stage2").html(c("#stage2template").tmpl(a)).moveLeft({callback:d.functions.pteVerifySubmitButtonHandler.doFunc}),!1}};B=function(){var a;c("#pte-confirm").live("click",function(){var b,d;d={};c("input.pte-confirm").filter(":checked").each(function(a,b){var g;g=c(b).val();return d[g]=c(b).parent().parent().find(".pte-file").val()});b={id:c("#pte-post-id").val(),action:"pte_ajax","pte-action":"confirm-images","pte-nonce":c("#pte-nonce").val(),
32
+ "pte-confirm":d};log("===== CONFIRM-IMAGES =====");log(b);return c.getJSON(ajaxurl,b,a)});return a=function(a){log("===== CONFIRM-IMAGES SUCCESS =====");log(a);d.parseServerLog(a.log);c("#stage2").moveLeft();c("#stage3").html(c("#stage3template").tmpl(a)).moveLeft();return!1}};E=function(){var a,b;b=function(a){var b,d;null!=a&&a.preventDefault();a=null!=(b=null!=(d=a.data)?d.selector:void 0)?b:".pte-size";return c(a).filter(":checked").click()};a=function(a){var b,d;null!=a&&a.preventDefault();a=
33
+ null!=(b=null!=a?null!=(d=a.data)?d.selector:void 0:void 0)?b:".pte-size";return c(a).not(":checked").click()};c("#pte-selectors .all").click(a);c("#pte-selectors .none").click(b).click();c("#stage2").delegate("#pte-stage2-selectors .all","click",{selector:".pte-confirm"},a);c("#stage2").delegate("#pte-stage2-selectors .none","click",{selector:".pte-confirm"},b);return!0};c.extend(d.functions,{iasSetAR:s})}).call(this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/pte.full.min.js DELETED
@@ -1,33 +0,0 @@
1
- (function(b){function t(j,c,g,e){e={data:e||e===0||e===!1?e:c?c.data:{},_wrap:c?c._wrap:null,tmpl:null,parent:c||null,nodes:[],calls:x,nest:y,wrap:f,html:z,update:a};j&&b.extend(e,j,{nodes:[],parent:c});if(g)e.tmpl=g,e._ctnt=e._ctnt||e.tmpl(b,e),e.key=++s,(o.length?k:i)[s]=e;return e}function r(a,c,g){var e,g=g?b.map(g,function(b){return typeof b==="string"?a.key?b.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+l+'="'+a.key+'" $2'):b:r(b,a,b._ctnt)}):a;if(c)return g;g=g.join("");g.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,
2
- function(g,c,a,j){e=b(a).get();n(e);c&&(e=v(c).concat(e));j&&(e=e.concat(v(j)))});return e?e:v(g)}function v(a){var c=document.createElement("div");c.innerHTML=a;return b.makeArray(c.childNodes)}function A(a){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+b.trim(a).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
3
- function(c,g,e,a,j,h,d){c=b.tmpl.tag[e];if(!c)throw"Unknown template tag: "+e;e=c._default||[];h&&!/\w$/.test(j)&&(j+=h,h="");j?(j=u(j),d=d?","+u(d)+")":h?")":"",d=h?j.indexOf(".")>-1?j+u(h):"("+j+").call($item"+d:j,h=h?d:"(typeof("+j+")==='function'?("+j+").call($item):("+j+"))"):h=d=e.$1||"null";a=u(a);return"');"+c[g?"close":"open"].split("$notnull_1").join(j?"typeof("+j+")!=='undefined' && ("+j+")!=null":"true").split("$1a").join(h).split("$1").join(d).split("$2").join(a||e.$2||"")+"__.push('"})+
4
- "');}return __;")}function w(a,c){a._wrap=r(a,!0,b.isArray(c)?c:[d.test(c)?c:b(c).html()]).join("")}function u(b){return b?b.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function n(a){function c(a){function c(b){var B;b+=g;B=d[b]=d[b]||t(h,i[h.parent.key+g]||h.parent),h=B}var e,j=a,h,f;if(f=a.getAttribute(l)){for(;j.parentNode&&(j=j.parentNode).nodeType===1&&!(e=j.getAttribute(l)););if(e!==f){j=j.parentNode?j.nodeType===11?0:j.getAttribute(l)||0:0;if(!(h=i[f]))h=k[f],h=t(h,i[j]||k[j]),h.key=++s,
5
- i[s]=h;p&&c(f)}a.removeAttribute(l)}else if(p&&(h=b.data(a,"tmplItem")))c(h.key),i[h.key]=h,j=(j=b.data(a.parentNode,"tmplItem"))?j.key:0;if(h){for(e=h;e&&e.key!=j;)e.nodes.push(a),e=e.parent;delete h._ctnt;delete h._wrap;b.data(a,"tmplItem",h)}}var g="_"+p,e,h,d={},f,q,m;f=0;for(q=a.length;f<q;f++)if((e=a[f]).nodeType===1){h=e.getElementsByTagName("*");for(m=h.length-1;m>=0;m--)c(h[m]);c(e)}}function x(b,a,g,e){if(!b)return o.pop();o.push({_:b,tmpl:a,item:this,data:g,options:e})}function y(a,c,g){return b.tmpl(b.template(a),
6
- c,g,this)}function f(a,c){var g=a.options||{};g.wrapped=c;return b.tmpl(b.template(a.tmpl),a.data,g,a.item)}function z(a,c){var g=this._wrap;return b.map(b(b.isArray(g)?g.join(""):g).filter(a||"*"),function(b){if(c)b=b.innerText||b.textContent;else{var a;if(!(a=b.outerHTML))a=document.createElement("div"),a.appendChild(b.cloneNode(!0)),a=a.innerHTML;b=a}return b})}function a(){var a=this.nodes;b.tmpl(null,null,null,this).insertBefore(a[0]);b(a).remove()}var h=b.fn.domManip,l="_tmplitem",d=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
7
- i={},k={},m,q={key:0,data:{}},s=0,p=0,o=[];b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,c){b.fn[a]=function(g){var e=[],g=b(g),h,d,l;h=this.length===1&&this[0].parentNode;m=i||{};if(h&&h.nodeType===11&&h.childNodes.length===1&&g.length===1)g[c](this[0]),e=this;else{d=0;for(l=g.length;d<l;d++)p=d,h=(d>0?this.clone(!0):this).get(),b(g[d])[c](h),e=e.concat(h);p=0;e=this.pushStack(e,a,g.selector)}g=m;m=null;b.tmpl.complete(g);
8
- return e}});b.fn.extend({tmpl:function(a,c,g){return b.tmpl(this[0],a,c,g)},tmplItem:function(){return b.tmplItem(this[0])},template:function(a){return b.template(a,this[0])},domManip:function(a,c,g,e){if(a[0]&&b.isArray(a[0])){for(var d=b.makeArray(arguments),l=a[0],f=l.length,k=0,q;k<f&&!(q=b.data(l[k++],"tmplItem")););q&&p&&(d[2]=function(a){b.tmpl.afterManip(this,a,g)});h.apply(this,d)}else h.apply(this,arguments);p=0;m||b.tmpl.complete(i);return this}});b.extend({tmpl:function(a,c,g,e){var h=
9
- !e;if(h)e=q,a=b.template[a]||b.template(null,a),k={};else if(!a)return a=e.tmpl,i[e.key]=e,e.nodes=[],e.wrapped&&w(e,e.wrapped),b(r(e,null,e.tmpl(b,e)));if(!a)return[];typeof c==="function"&&(c=c.call(e||{}));g&&g.wrapped&&w(g,g.wrapped);c=b.isArray(c)?b.map(c,function(b){return b?t(g,e,a,b):null}):[t(g,e,a,c)];return h?b(r(e,null,c)):c},tmplItem:function(a){var c;for(a instanceof b&&(a=a[0]);a&&a.nodeType===1&&!(c=b.data(a,"tmplItem"))&&(a=a.parentNode););return c||q},template:function(a,c){return c?
10
- (typeof c==="string"?c=A(c):c instanceof b&&(c=c[0]||{}),c.nodeType&&(c=b.data(c,"tmpl")||b.data(c,"tmpl",A(c.innerHTML))),typeof a==="string"?b.template[a]=c:c):a?typeof a!=="string"?b.template(null,a):b.template[a]||b.template(null,d.test(a)?a:b(a)):null},encode:function(a){return(""+a).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});b.extend(b.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},
11
- 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(){i={}},afterManip:function(a,
12
- c,h){var e=c.nodeType===11?b.makeArray(c.childNodes):c.nodeType===1?[c]:[];h.call(a,c);n(e);p++}})})(jQuery);
13
- (function(){var b,t,r,v,A,w,u,n,x,y,f,z=function(a,b){return function(){return a.apply(b,arguments)}};f=this;b=f.jQuery;f.pte=n=n||{};(function(a){return a.fixThickbox=function(a){var b,d,i,k;b=a.jQuery;if(!(b===null||a.frames.length<1))if(log("===== FIXING THICKBOX ====="),k=f.options.pte_tb_width+30,i=f.options.pte_tb_height+38,d=b("#TB_window"),!(d.width()>=k&&d.height()>=i))return log("THICKBOX: "+d.width()+" x "+d.height()),d.css({"margin-left":0-k/2,width:k,height:i}).children("iframe").css({width:k}),
14
- a.setTimeout(function(){if(!(b("iframe",d).height()>i))return b("iframe",d).css({height:i}),log("THICKBOX: "+d.width()+" x "+d.height()),!0},1E3)}})(n);y=function(a){return{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};t=function(){function a(a){this.message=a;this.date=new Date}a.prototype.toString=function(){var a,l,d,i,f,m,q;m=function(a,b){for(;(""+a).length<b;)a="0"+a;return a};d=this.date;q=m(d.getUTCFullYear(),4);l=m(d.getUTCMonth()+1,2);a=m(d.getUTCDate(),2);i=m(d.getUTCHours(),
15
- 2);f=m(d.getUTCMinutes(),2);m=m(d.getUTCSeconds(),2);switch(y(this.message)){case "string":d=this.message;break;default:d=b.toJSON(this.message)}return""+q+l+a+" "+i+":"+f+":"+m+" - ["+y(this.message)+"] "+d};return a}();(function(a){a.messages=[];a.log=function(h){if(!f.options.pte_debug)return!0;try{a.messages.push(new t(h)),console.log(h),b("#pte-log-messages textarea").filter(":visible").val(a.formatLog())}catch(l){}};a.formatLog=function(){var b,l,d,i,f;b="";f=a.messages;d=0;for(i=f.length;d<
16
- i;d++)l=f[d],b+=""+l+"\n";return b};a.parseServerLog=function(a){var b,d,f;log("===== SERVER LOG =====");if((a!=null?a.length:void 0)!=null&&a.length>0){d=0;for(f=a.length;d<f;d++)b=a[d],log(b)}return!0};a.sendToPastebin=function(a){return b.ajax({url:"http://dpastey.appspot.com/",data:{title:"PostThumbnailEditor Log",content:a,lexer:"text",format:"json",expire_options:"2592000"},dataType:"json",global:!1,type:"POST",error:function(a,h,f){b("#pte-log").fadeOut("900");alert(objectL10n.pastebin_create_error);
17
- log(a);log(h);return log(f)},success:function(a){b("#pte-log").fadeOut("900");return prompt(objectL10n.pastebin_url,a.url)}})};return!0})(n);f.log=n.log;b(document).ready(function(a){a("#test").click(function(a){a.stopImmediatePropagation();return!0});a("#pastebin").click(function(){return n.sendToPastebin(n.formatLog())});a("#clear-log").click(function(){n.messages=[];return a("#pte-log-messages textarea").val(n.formatLog())});a("#close-log").click(function(){return a("#pte-log").fadeOut("900")});
18
- a("#pte-log-tools a").click(function(a){return a.preventDefault()});return a("body").delegate(".show-log-messages","click",function(b){b.preventDefault();a("#pte-log-messages textarea").val(n.formatLog());return a("#pte-log").fadeIn("900")})});(function(a){return a.admin=function(){var a,l,d,i,k,m;m="&TB_iframe=true&height="+f.options.pte_tb_height+"&width="+f.options.pte_tb_width;d=null;k=function(a){a=a||d||b("#attachment-id").val();return""+ajaxurl+"?action=pte_ajax&pte-action=launch&id="+a+m};
19
- a=function(a){return b('<a class="thickbox" href="'+k(a)+'">'+objectL10n.PTE+"</a>")};l=function(a){log("Start PTE...");if(f.parent.frames.length>0)return log("Modifying thickbox..."),z(function(){f.parent.tb_click();return!0},this)(),a.stopPropagation()};i=function(){var k;k=b("#imgedit-save-target-"+d);return(k!=null?k.size():void 0)<1?(f.log("Edit Thumbnail Menu not visible, waiting for 300ms"),f.setTimeout(i,300),!1):k.append(a().click(l))};return function(){b(".media-item").each(function(d,f){var i;
20
- i=f.id.replace("media-item-","");return a(i).css({"font-size":".8em","margin-left":"5px"}).click(l).appendTo(b("tr.image-size th.label",f))});if(imageEdit.open!=null)imageEdit.oldopen=imageEdit.open,imageEdit.open=function(a,b){d=a;imageEdit.oldopen(a,b);return i()};return!0}()}})(n);r=function(){function a(a,b){this.fn=a;this.timeout=b;this.doFunc=z(this.doFunc,this);this.timer=null}a.prototype.doFunc=function(){f.clearTimeout(this.timer);this.timer=f.setTimeout(this.fn,this.timeout);return!0};return a}();
21
- f.randomness=function(){return Math.floor(Math.random()*1000001).toString(16)};f.debugTmpl=function(a){log("===== TEMPLATE DEBUG DATA FOLLOWS =====");log(a);return!0};v=function(a){a={id:a,action:"pte_ajax","pte-action":"delete-images","pte-nonce":b("#pte-delete-nonce").val()};return b.ajax({url:ajaxurl,data:a,global:!1,dataType:"json",success:A})};A=function(a){log("===== DELETE SUCCESSFUL, DATA DUMP FOLLOWS =====");log(a);return n.parseServerLog(a.log)};x=b({});b.fn.extend({move:function(a){a=b.extend({direction:"left",
22
- speed:500,easing:"swing",toggle:!0,callback:null,callbackargs:null},a);this.each(function(){return x.queue(z(function(h){var l,d,i,k;l=b(this);d=a.direction==="left"?-1:1;k=l.css("left")==="0px"?b(f).width()*d:0;i=l.is(":visible");log([d,k,i]);i?(l.animate({left:k},a.speed,a.easing),l.hide(0,h)):l.show(0,function(){return b(this).animate({left:k},a.speed,a.easing,h)});return!0},this))});a.callback!=null&&x.queue(function(b){a.callbackargs!=null?(log("running callback with arguments"),a.callback.apply(this,
23
- a.callbackargs)):(log("running callback with no arguments"),a.callback.apply(this));log("finished running callback");return b()});return this},moveRight:function(a){a=b.extend(a,{direction:"right"});return this.move(a)},moveLeft:function(a){a=b.extend(a,{direction:"left"});return this.move(a)}});f.goBack=function(a){a!=null&&a.preventDefault();b("#stage2").moveRight();b("#stage1").moveRight({callback:function(){v(b("#pte-post-id").val());return b("#stage2").html("")}});return!0};u=function(a,b){if(a===
24
- 0)return b;for(;b>0;)a>b?a-=b:b-=a;return a<0||b<0?null:a};w=function(a,b){var f,d,i,k;f=b.crop;k=b.width;i=b.height;f=+f;k=+k;i=+i;d=u(k,i);if(f!=null&&f>0){f=null;(k!=null)>0&&(i!=null)>0&&(f=d!=null?""+k/d+":"+i/d:""+k+":"+i);if(a!=null&&f!=null&&f!==a)throw objectL10n.aspect_ratio_disabled;a=f}return a};n.functions={determineAspectRatio:w};(function(a){var h,l,d,i,k,m,n,s,p,o,j;a.editor=function(){n();d();j();l();i();k();h();m();return!0};m=function(){var a,g;a=b("#pte-loading");g=function(){a.hide();
25
- return!0};b("#pte-preview").load(g);a.ajaxStart(function(){return b(this).fadeIn(200)}).ajaxStop(function(){return b(this).fadeOut(200)});f.setTimeout(g,2E3);return!0};n=function(){var c;c=new r(function(){var c;log("===== REFLOW =====");a.fixThickbox(f.parent);c=b("#pte-sizes").offset();c=b(f).height()-c.top-2;b("#pte-sizes").height(c);log("WINDOW WIDTH: "+b(f).width());b("#stage2, #stage3").filter(":hidden").css({left:b(f).width()});return!0},100);b(f).resize(c.doFunc).load(c.doFunc);return!0};
26
- d=function(){var a;a=function(a){a.delegate("tr","click",function(a){a.target.type!=="checkbox"&&b("input:checkbox",this).click();return!0});return a.delegate("input:checkbox","click",function(){this.checked||b(this).is("input:checked")?b(this).parents("tr").first().removeClass("selected"):b(this).parents("tr").first().addClass("selected");return!0})};a(b("#stage2"));return a(b("#stage1"))};o=null;p={keys:!0,minWidth:3,minHeight:3,handles:!0,zIndex:1200,instance:!0,onSelectEnd:function(a,g){return g.width&&
27
- g.width>0&&g.height&&g.height>0&&b(".pte-size").filter(":checked").size()>0?b("#pte-submit").removeAttr("disabled"):b("#pte-submit").attr("disabled",!0)}};j=function(){return a.ias=o=b("#pte-image img").imgAreaSelect(p)};s=function(a){log("===== SETTING ASPECTRATIO: "+a+" =====");o.setOptions({aspectRatio:a});return o.update()};l=function(){var c,g;g=new r(function(){log("===== CHECK SUBMIT BUTTON =====");b(".pte-confirm").filter(":checked").size()>0?(log("ENABLE"),b("#pte-confirm").removeAttr("disabled")):
28
- (log("DISABLE"),b("#pte-confirm").attr("disabled",!0));return!0},50);c=new r(function(){var a;a=null;b("input.pte-size").filter(":checked").each(function(c,g){try{a=w(a,thumbnail_info[b(g).val()])}catch(d){return a=null,a!==o.getOptions().aspectRatio&&alert(d),!1}return!0});s(a);p.onSelectEnd(null,o.getSelection());return!0},50);b.extend(a.functions,{pteVerifySubmitButtonHandler:g});b("input.pte-size").click(c.doFunc);return b(".pte-confirm").live("click",function(){return g.doFunc()})};i=function(){var c;
29
- b("#pte-submit").click(function(){var a,e;e=o.getSelection();a=b("#pte-sizer").val();a={id:b("#pte-post-id").val(),action:"pte_ajax","pte-action":"resize-images","pte-sizes[]":b(".pte-size").filter(":checked").map(function(){return b(this).val()}).get(),x:Math.floor(e.x1/a),y:Math.floor(e.y1/a),w:Math.floor(e.width/a),h:Math.floor(e.height/a)};log("===== RESIZE-IMAGES =====");log(a);if(isNaN(a.x)||isNaN(a.y)||isNaN(a.w)||isNaN(a.h))return alert(objectL10n.crop_submit_data_error),log("ERROR with submit_data and NaN's"),
30
- !1;o.setOptions({hide:!0,x1:0,y1:0,x2:0,y2:0});b("#pte-submit").attr("disabled",!0);b.getJSON(ajaxurl,a,c);return!0});return c=function(c){log("===== RESIZE-IMAGES SUCCESS =====");log(c);a.parseServerLog(c.log);if(c.error!=null&&c.thumbnails==null)alert(c.error);else return b("#stage1").moveLeft(),b("#stage2").html(b("#stage2template").tmpl(c)).moveLeft({callback:a.functions.pteVerifySubmitButtonHandler.doFunc}),!1}};k=function(){var c;b("#pte-confirm").live("click",function(){var a,e;e={};b("input.pte-confirm").filter(":checked").each(function(a,
31
- c){var d;d=b(c).val();return e[d]=b(c).parent().parent().find(".pte-file").val()});a={id:b("#pte-post-id").val(),action:"pte_ajax","pte-action":"confirm-images","pte-nonce":b("#pte-nonce").val(),"pte-confirm":e};log("===== CONFIRM-IMAGES =====");log(a);return b.getJSON(ajaxurl,a,c)});return c=function(c){log("===== CONFIRM-IMAGES SUCCESS =====");log(c);a.parseServerLog(c.log);b("#stage2").moveLeft();b("#stage3").html(b("#stage3template").tmpl(c)).moveLeft();return!1}};h=function(){var a,d;d=function(a){var e;
32
- var c,d;a!=null&&a.preventDefault();e=(c=(d=a.data)!=null?d.selector:void 0)!=null?c:".pte-size",a=e;return b(a).filter(":checked").click()};a=function(a){var e;var c,d;a!=null&&a.preventDefault();e=(c=a!=null?(d=a.data)!=null?d.selector:void 0:void 0)!=null?c:".pte-size",a=e;return b(a).not(":checked").click()};b("#pte-selectors .all").click(a);b("#pte-selectors .none").click(d).click();b("#stage2").delegate("#pte-stage2-selectors .all","click",{selector:".pte-confirm"},a);b("#stage2").delegate("#pte-stage2-selectors .none",
33
- "click",{selector:".pte-confirm"},d);return!0};return b.extend(a.functions,{iasSetAR:s})})(n)}).call(this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/pte_admin.coffee CHANGED
@@ -5,6 +5,17 @@
5
  ###
6
  do (pte) ->
7
 
 
 
 
 
 
 
 
 
 
 
 
8
  pte.admin = ->
9
  timeout = 300
10
  thickbox = """&TB_iframe=true&height=#{ window.options.pte_tb_height }&width=#{ window.options.pte_tb_width }"""
@@ -49,6 +60,14 @@ do (pte) ->
49
  image_id = id
50
  imageEdit.oldopen id,nonce
51
  launchPTE()
 
 
 
 
 
 
 
 
52
  true
53
 
54
  launchPTE = ->
5
  ###
6
  do (pte) ->
7
 
8
+ pte.media = ->
9
+ # Add link to attachment-details template
10
+ template = $("#tmpl-attachment-details").text()
11
+ injectTemplate = """
12
+ <a target="_blank" href="#{ajaxurl}?action=pte_ajax&pte-action=launch&id={{data.id}}">
13
+ #{objectL10n.PTE}
14
+ </a>
15
+ """
16
+ template = template.replace(/(<div class="compat-meta">)/, "#{injectTemplate}\n$1")
17
+ $("#tmpl-attachment-details").text(template)
18
+
19
  pte.admin = ->
20
  timeout = 300
21
  thickbox = """&TB_iframe=true&height=#{ window.options.pte_tb_height }&width=#{ window.options.pte_tb_width }"""
60
  image_id = id
61
  imageEdit.oldopen id,nonce
62
  launchPTE()
63
+ # Does the imgedit-save-target already exist?
64
+ $editmenu = $("""p[id^="imgedit-save-target-"]""")
65
+ if $editmenu?.length > 0
66
+ #set the image_id & launch it
67
+ matches = $editmenu[0].id.match(/imgedit-save-target-(\d+)/)
68
+ if matches[1]?
69
+ image_id = matches[1]
70
+ launchPTE()
71
  true
72
 
73
  launchPTE = ->
php/functions.php CHANGED
@@ -223,43 +223,6 @@ function pte_test(){
223
  function pte_launch(){
224
  $logger = PteLogger::singleton();
225
  $options = pte_get_options();
226
- if ( $options['pte_debug'] ) {
227
- wp_enqueue_script( 'pte'
228
- , PTE_PLUGINURL . 'js/pte.full.js'
229
- , array('jquery','imgareaselect')
230
- , PTE_VERSION
231
- );
232
- wp_enqueue_script( 'jquery-json'
233
- , PTE_PLUGINURL . 'apps/jquery.json-2.2.min.js'
234
- , array('jquery')
235
- , '2.2'
236
- );
237
- wp_enqueue_style( 'pte'
238
- , PTE_PLUGINURL . 'css/pte.css'
239
- , array('imgareaselect')
240
- , PTE_VERSION
241
- );
242
- }
243
- else { // Minified versions
244
- wp_enqueue_script( 'pte'
245
- , PTE_PLUGINURL . 'js/pte.full.min.js'
246
- , array('jquery','imgareaselect')
247
- , PTE_VERSION
248
- );
249
- wp_enqueue_style( 'pte'
250
- , PTE_PLUGINURL . 'css/pte.min.css'
251
- , array('imgareaselect')
252
- , PTE_VERSION
253
- );
254
- }
255
- wp_localize_script('pte'
256
- , 'objectL10n'
257
- , array( 'pastebin_create_error' => __( 'Sorry, there was a problem trying to send to pastebin', PTE_DOMAIN )
258
- , 'pastebin_url' => __( 'PASTEBIN URL:', PTE_DOMAIN )
259
- , 'aspect_ratio_disabled' => __( 'Disabling aspect ratio', PTE_DOMAIN )
260
- , 'crop_submit_data_error' => __( 'Error parsing selection information', PTE_DOMAIN )
261
- )
262
- );
263
 
264
  $id = pte_check_id((int) $_GET['id']);
265
 
@@ -285,10 +248,18 @@ function pte_launch(){
285
 
286
  $sizer = $big > 400 ? 400 / $big : 1;
287
  $sizer = sprintf( "%.8F", $sizer );
 
288
  $logger->debug( "USER-AGENT: " . $_SERVER['HTTP_USER_AGENT'] );
289
  $logger->debug( "WORDPRESS: " . $GLOBALS['wp_version'] );
290
  $logger->debug( "SIZER: ${sizer}" );
291
- $logger->debug( "META: " . print_r( $meta, true ) );
 
 
 
 
 
 
 
292
 
293
  require( PTE_PLUGINPATH . "html/pte.php" );
294
  }
@@ -424,7 +395,10 @@ function pte_write_image( $image, $orig_type, $destfilename ){
424
  }
425
  else {
426
  // all other formats are converted to jpg
427
- if ( !imagejpeg( $image, $destfilename, 90) ){
 
 
 
428
  $logger->error("Resize path invalid: " . $destfilename);
429
  return false;
430
  }
223
  function pte_launch(){
224
  $logger = PteLogger::singleton();
225
  $options = pte_get_options();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
 
227
  $id = pte_check_id((int) $_GET['id']);
228
 
248
 
249
  $sizer = $big > 400 ? 400 / $big : 1;
250
  $sizer = sprintf( "%.8F", $sizer );
251
+ $logger->debug( "PTE-VERSION: " . PTE_VERSION );
252
  $logger->debug( "USER-AGENT: " . $_SERVER['HTTP_USER_AGENT'] );
253
  $logger->debug( "WORDPRESS: " . $GLOBALS['wp_version'] );
254
  $logger->debug( "SIZER: ${sizer}" );
255
+ $logger->debug( "SIZES: " . print_r(${size_information}, true) );
256
+
257
+ $script_url = PTE_PLUGINURL . 'php/load-scripts.php?load=jquery,imgareaselect,pte,jquery-json';
258
+ $style_url = PTE_PLUGINURL . 'php/load-styles.php?load=imgareaselect,pte';
259
+ if ( $options['pte_debug'] ){
260
+ $style_url .= "&d=1";
261
+ $script_url .= "&d=1";
262
+ }
263
 
264
  require( PTE_PLUGINPATH . "html/pte.php" );
265
  }
395
  }
396
  else {
397
  // all other formats are converted to jpg
398
+ $options = pte_get_options();
399
+ $quality = apply_filters('jpeg_quality', $options['pte_jpeg_compression'], 'pte_write_image');
400
+ $logger->debug("JPEG COMPRESSION: {$quality}");
401
+ if ( !imagejpeg( $image, $destfilename, $quality ) ){
402
  $logger->error("Resize path invalid: " . $destfilename);
403
  return false;
404
  }
php/load-scripts.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Disable error reporting
5
+ *
6
+ * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
7
+ */
8
+ error_reporting(0);
9
+
10
+ /** Set ABSPATH for execution */
11
+ //define( 'ABSPATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/' );
12
+ define( 'ABSPATH', dirname(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))))) . '/' );
13
+ define( 'WPINC', 'wp-includes' );
14
+ define( 'PLUGINPATH', '/wp-content/plugins/' . basename(dirname(dirname(__FILE__))));
15
+
16
+ /**
17
+ * @ignore
18
+ */
19
+ function __() {}
20
+
21
+ /**
22
+ * @ignore
23
+ */
24
+ function _x() {}
25
+
26
+ /**
27
+ * @ignore
28
+ */
29
+ function add_filter() {}
30
+
31
+ /**
32
+ * @ignore
33
+ */
34
+ function esc_attr() {}
35
+
36
+ /**
37
+ * @ignore
38
+ */
39
+ function apply_filters() {}
40
+
41
+ /**
42
+ * @ignore
43
+ */
44
+ function get_option() {}
45
+
46
+ /**
47
+ * @ignore
48
+ */
49
+ function is_lighttpd_before_150() {}
50
+
51
+ /**
52
+ * @ignore
53
+ */
54
+ function add_action() {}
55
+
56
+ /**
57
+ * @ignore
58
+ */
59
+ function did_action() {}
60
+
61
+ /**
62
+ * @ignore
63
+ */
64
+ function do_action_ref_array() {}
65
+
66
+ /**
67
+ * @ignore
68
+ */
69
+ function get_bloginfo() {}
70
+
71
+ /**
72
+ * @ignore
73
+ */
74
+ function is_admin() {return true;}
75
+
76
+ /**
77
+ * @ignore
78
+ */
79
+ function site_url() {}
80
+
81
+ /**
82
+ * @ignore
83
+ */
84
+ function admin_url() {}
85
+
86
+ /**
87
+ * @ignore
88
+ */
89
+ function home_url() {}
90
+
91
+ /**
92
+ * @ignore
93
+ */
94
+ function includes_url() {}
95
+
96
+ /**
97
+ * @ignore
98
+ */
99
+ function wp_guess_url() {}
100
+
101
+ if ( ! function_exists( 'json_encode' ) ) :
102
+ /**
103
+ * @ignore
104
+ */
105
+ function json_encode() {}
106
+ endif;
107
+
108
+ function get_file($path) {
109
+
110
+ if ( function_exists('realpath') )
111
+ $path = realpath($path);
112
+
113
+ if ( ! $path || ! @is_file($path) )
114
+ return '';
115
+
116
+ return @file_get_contents($path);
117
+ }
118
+
119
+ $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
120
+ $load = explode(',', $load);
121
+
122
+ if ( empty($load) )
123
+ exit;
124
+
125
+ require(ABSPATH . WPINC . '/script-loader.php');
126
+ require(ABSPATH . WPINC . '/version.php');
127
+
128
+ $compress = ( isset($_GET['c']) && $_GET['c'] );
129
+ $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
130
+ $expires_offset = 31536000;
131
+ $out = '';
132
+ $suffix = ( isset($_GET['d']) && $_GET['d'] ) ? '.dev' : '';
133
+ print("/** SUFFIX: '$suffix' **/\n");
134
+
135
+ $wp_scripts = new WP_Scripts();
136
+ wp_default_scripts($wp_scripts);
137
+ // TODO: Fix the dev/min dichotemy to mimic wordpress functionality
138
+ wp_register_script( 'pte'
139
+ , PLUGINPATH . "/js/pte.full${suffix}.js"
140
+ , array('jquery','imgareaselect')
141
+ );
142
+ wp_register_script( 'jquery-json'
143
+ , PLUGINPATH . '/apps/jquery.json-2.2.min.js'
144
+ , array('jquery')
145
+ );
146
+ wp_localize_script('pte'
147
+ , 'objectL10n'
148
+ , array( 'pastebin_create_error' => __( 'Sorry, there was a problem trying to send to pastebin', PTE_DOMAIN )
149
+ , 'pastebin_url' => __( 'PASTEBIN URL:', PTE_DOMAIN )
150
+ , 'aspect_ratio_disabled' => __( 'Disabling aspect ratio', PTE_DOMAIN )
151
+ , 'crop_submit_data_error' => __( 'Error parsing selection information', PTE_DOMAIN )
152
+ )
153
+ );
154
+
155
+ foreach( $load as $handle ) {
156
+ if ( !array_key_exists($handle, $wp_scripts->registered) )
157
+ continue;
158
+
159
+ $path = ABSPATH . $wp_scripts->registered[$handle]->src;
160
+ print("/** PATH: '$path' **/\n");
161
+ $out .= get_file($path) . "\n";
162
+ $localized = $wp_scripts->get_data($handle, 'data');
163
+ if ( !empty($localized) )
164
+ $out .= $localized . "\n";
165
+ }
166
+
167
+ header('Content-Type: application/x-javascript; charset=UTF-8');
168
+ header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
169
+ header("Cache-Control: public, max-age=$expires_offset");
170
+
171
+ if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
172
+ header('Vary: Accept-Encoding'); // Handle proxies
173
+ if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
174
+ header('Content-Encoding: deflate');
175
+ $out = gzdeflate( $out, 3 );
176
+ } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
177
+ header('Content-Encoding: gzip');
178
+ $out = gzencode( $out, 3 );
179
+ }
180
+ }
181
+
182
+ echo $out;
183
+ exit;
php/load-styles.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Disable error reporting
5
+ *
6
+ * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
7
+ */
8
+ error_reporting(0);
9
+
10
+ /** Set ABSPATH for execution */
11
+ //define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
12
+ define( 'ABSPATH', dirname(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))))) . '/' );
13
+ define( 'WPINC', 'wp-includes' );
14
+ define( 'PLUGINPATH', '/wp-content/plugins/' . basename(dirname(dirname(__FILE__))));
15
+
16
+ /**
17
+ * @ignore
18
+ */
19
+ function __() {}
20
+
21
+ /**
22
+ * @ignore
23
+ */
24
+ function _x() {}
25
+
26
+ /**
27
+ * @ignore
28
+ */
29
+ function add_filter() {}
30
+
31
+ /**
32
+ * @ignore
33
+ */
34
+ function esc_attr() {}
35
+
36
+ /**
37
+ * @ignore
38
+ */
39
+ function apply_filters() {}
40
+
41
+ /**
42
+ * @ignore
43
+ */
44
+ function get_option() {}
45
+
46
+ /**
47
+ * @ignore
48
+ */
49
+ function is_lighttpd_before_150() {}
50
+
51
+ /**
52
+ * @ignore
53
+ */
54
+ function add_action() {}
55
+
56
+ /**
57
+ * @ignore
58
+ */
59
+ function do_action_ref_array() {}
60
+
61
+ /**
62
+ * @ignore
63
+ */
64
+ function get_bloginfo() {}
65
+
66
+ /**
67
+ * @ignore
68
+ */
69
+ function is_admin() {return true;}
70
+
71
+ /**
72
+ * @ignore
73
+ */
74
+ function site_url() {}
75
+
76
+ /**
77
+ * @ignore
78
+ */
79
+ function admin_url() {}
80
+
81
+ /**
82
+ * @ignore
83
+ */
84
+ function wp_guess_url() {}
85
+
86
+ function get_file($path) {
87
+
88
+ if ( function_exists('realpath') )
89
+ $path = realpath($path);
90
+
91
+ if ( ! $path || ! @is_file($path) )
92
+ return '';
93
+
94
+ return @file_get_contents($path);
95
+ }
96
+
97
+ require(ABSPATH . '/wp-includes/script-loader.php');
98
+ require(ABSPATH . '/wp-includes/version.php');
99
+
100
+ $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
101
+ $load = explode(',', $load);
102
+
103
+ if ( empty($load) )
104
+ exit;
105
+
106
+ header('Content-Type: text/css');
107
+ header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
108
+ header("Cache-Control: public, max-age=$expires_offset");
109
+
110
+
111
+ $compress = ( isset($_GET['c']) && $_GET['c'] );
112
+ $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
113
+ $rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
114
+ $expires_offset = 31536000;
115
+ $out = '';
116
+ $suffix = ( isset($_GET['d']) && $_GET['d'] ) ? '.dev' : '';
117
+ //print("/** SUFFIX: '$suffix' **/\n");
118
+
119
+ $wp_styles = new WP_Styles();
120
+ wp_default_styles($wp_styles);
121
+ wp_register_style( 'pte'
122
+ , PLUGINPATH . "/css/pte${suffix}.css"
123
+ , array('imgareaselect')
124
+ );
125
+
126
+ foreach( $load as $handle ) {
127
+ if ( !array_key_exists($handle, $wp_styles->registered) ){
128
+ print( "/* Couldn't find ${handle} */\n" );
129
+ continue;
130
+ }
131
+
132
+ $style = $wp_styles->registered[$handle];
133
+ $path = ABSPATH . $style->src;
134
+ //$out .= "/** PATH: '$path' **/\n";
135
+
136
+ $content = get_file($path) . "\n";
137
+
138
+ if ( $rtl && isset($style->extra['rtl']) && $style->extra['rtl'] ) {
139
+ $rtl_path = is_bool($style->extra['rtl']) ? str_replace( '.css', '-rtl.css', $path ) : ABSPATH . $style->extra['rtl'];
140
+ $content .= get_file($rtl_path) . "\n";
141
+ }
142
+
143
+ // Replace wp-includes links
144
+ if ( strpos( $style->src, '/wp-includes/' ) === 0 ) {
145
+ $content = str_replace( 'border-anim-v.gif', '../../../../wp-includes/js/imgareaselect/border-anim-v.gif', $content);
146
+ $content = str_replace( 'border-anim-h.gif', '../../../../wp-includes/js/imgareaselect/border-anim-h.gif', $content);
147
+ }
148
+ $out .= $content;
149
+ }
150
+
151
+ if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
152
+ header('Vary: Accept-Encoding'); // Handle proxies
153
+ if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
154
+ header('Content-Encoding: deflate');
155
+ $out = gzdeflate( $out, 3 );
156
+ } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
157
+ header('Content-Encoding: gzip');
158
+ $out = gzencode( $out, 3 );
159
+ }
160
+ }
161
+
162
+ echo $out;
163
+ exit;
php/options.php CHANGED
@@ -20,6 +20,12 @@ function pte_options_init(){
20
  , 'pte_noop'
21
  , 'pte' );
22
 
 
 
 
 
 
 
23
  add_settings_field( 'pte_dimensions',
24
  __('Thickbox dimensions', PTE_DOMAIN),
25
  'pte_dimensions_display',
@@ -52,6 +58,11 @@ function pte_options_init(){
52
  'pte_sizes_display',
53
  'pte',
54
  'pte_site' );
 
 
 
 
 
55
  }
56
  // End Admin only
57
 
@@ -98,8 +109,20 @@ function pte_site_options_validate( $input ){
98
  }
99
  }
100
 
 
 
 
 
 
 
 
 
 
 
101
 
102
- $output = array( 'pte_hidden_sizes' => $pte_hidden_sizes );
 
 
103
  return $output;
104
  }
105
 
@@ -110,6 +133,7 @@ function pte_options_validate( $input ){
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 ){
@@ -134,6 +158,19 @@ function pte_options_validate( $input ){
134
  return $options;
135
  }
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  function pte_dimensions_display(){
138
  $options = pte_get_options();
139
  $option_label = pte_get_option_name();
@@ -222,4 +259,17 @@ function pte_sizes_display(){
222
 
223
  print( '</table>' );
224
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  ?>
20
  , 'pte_noop'
21
  , 'pte' );
22
 
23
+ add_settings_field( 'pte_thickbox',
24
+ __('Thickbox', PTE_DOMAIN),
25
+ 'pte_thickbox_display',
26
+ 'pte',
27
+ 'pte_main' );
28
+
29
  add_settings_field( 'pte_dimensions',
30
  __('Thickbox dimensions', PTE_DOMAIN),
31
  'pte_dimensions_display',
58
  'pte_sizes_display',
59
  'pte',
60
  'pte_site' );
61
+ add_settings_field( 'pte_jpeg_compression',
62
+ __('JPEG Compression', PTE_DOMAIN),
63
+ 'pte_jpeg_compression_display',
64
+ 'pte',
65
+ 'pte_site' );
66
  }
67
  // End Admin only
68
 
109
  }
110
  }
111
 
112
+ // Check the JPEG Compression value
113
+ $tmp_jpeg_compression = (int) preg_replace( "/[\D]/", "", $input['pte_jpeg_compression'] );
114
+ if ( ! is_int( $tmp_jpeg_compression )
115
+ || $tmp_jpeg_compression < 0
116
+ || $tmp_jpeg_compression > 100 )
117
+ {
118
+ add_settings_error('pte_options_site'
119
+ , 'pte_options_error'
120
+ , __( "JPEG Compression needs to be set from 0 to 100.", PTE_DOMAIN ) );
121
+ }
122
 
123
+ $output = array( 'pte_hidden_sizes' => $pte_hidden_sizes
124
+ , 'pte_jpeg_compression' => $tmp_jpeg_compression
125
+ );
126
  return $output;
127
  }
128
 
133
  return array();
134
  }
135
  $options['pte_debug'] = isset( $input['pte_debug'] );
136
+ $options['pte_thickbox'] = isset( $input['pte_thickbox'] );
137
 
138
  $tmp_width = (int) preg_replace( "/[\D]/", "", $input['pte_tb_width'] );
139
  if ( !is_int( $tmp_width ) || $tmp_width < 750 ){
158
  return $options;
159
  }
160
 
161
+ function pte_thickbox_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_thickbox]" <?php
168
+ if ( $options['pte_thickbox'] ): print "checked"; endif;
169
+ ?> id="pte_thickbox"/>&nbsp;<label for="pte_thickbox"><?php _e( 'Enable Thickbox', PTE_DOMAIN ); ?></label>
170
+ </span>
171
+ <?php
172
+ }
173
+
174
  function pte_dimensions_display(){
175
  $options = pte_get_options();
176
  $option_label = pte_get_option_name();
259
 
260
  print( '</table>' );
261
  }
262
+
263
+ function pte_jpeg_compression_display(){
264
+ $options = pte_get_options();
265
+ $option_label = pte_get_option_name();
266
+ ?>
267
+ <span><input class="small-text" type="text"
268
+ name="pte-site-options[pte_jpeg_compression]"
269
+ value="<?php print $options['pte_jpeg_compression']; ?>"
270
+ id="pte_jpeg_compression">&nbsp;
271
+ <?php _e("Set the compression level for resizing jpeg images (0 to 100).", PTE_DOMAIN); ?>
272
+ </span>
273
+ <?php
274
+ }
275
  ?>
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.5
7
  Description: Individually manage your post thumbnails
8
 
9
  LICENSE
@@ -35,7 +35,7 @@
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.5");
39
 
40
  /*
41
  * Option Functionality
@@ -56,6 +56,7 @@ function pte_get_user_options(){
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
  }
@@ -65,7 +66,9 @@ function pte_get_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
 
@@ -86,24 +89,29 @@ function pte_get_options(){
86
 
87
  /* Hook into the Edit Image page */
88
  function pte_enable_thickbox(){
89
- wp_enqueue_style( 'thickbox' );
90
- wp_enqueue_script( 'thickbox' );
 
 
 
 
91
  }
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')
101
  , PTE_VERSION
102
  );
103
  }
104
  else {
105
  wp_enqueue_script( 'pte'
106
- , PTE_PLUGINURL . 'js/pte.full.min.js'
107
  , array('jquery')
108
  , PTE_VERSION
109
  );
@@ -112,7 +120,13 @@ function pte_admin_media_scripts(){
112
  , 'objectL10n'
113
  , array('PTE' => __('Post Thumbnail Editor', PTE_DOMAIN))
114
  );
115
- add_action("admin_head","pte_enable_admin_js",100);
 
 
 
 
 
 
116
  }
117
 
118
  function pte_enable_admin_js(){
@@ -125,6 +139,16 @@ function pte_enable_admin_js(){
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
@@ -159,11 +183,14 @@ function pte_media_row_actions($actions, $post, $detached){
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;
@@ -189,15 +216,13 @@ function pte_options(){
189
  }
190
 
191
  /* This is the main admin media page */
192
- add_action('admin_print_styles-media.php', 'pte_admin_media_scripts');
193
-
194
- /* This is for the popup media page */
195
  /* Slight redirect so this isn't called on all versions of the media upload page */
196
- function pte_admin_media_upload(){
197
- add_action('admin_print_scripts-media-upload-popup', 'pte_admin_media_scripts');
198
  }
199
- add_action('media_upload_gallery', 'pte_admin_media_upload');
200
- add_action('media_upload_library', 'pte_admin_media_upload');
201
 
202
  /* Adds the Thumbnail option to the media library list */
203
  add_action('admin_print_styles-upload.php', 'pte_enable_thickbox');
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.7
7
  Description: Individually manage your post thumbnails
8
 
9
  LICENSE
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.7");
39
 
40
  /*
41
  * Option Functionality
56
  $defaults = array( 'pte_tb_width' => 750
57
  , 'pte_tb_height' => 550
58
  , 'pte_debug' => false
59
+ , 'pte_thickbox' => true
60
  );
61
  return array_merge( $defaults, $pte_options );
62
  }
66
  if ( !is_array( $pte_site_options ) ){
67
  $pte_site_options = array();
68
  }
69
+ $defaults = array( 'pte_hidden_sizes' => array()
70
+ , 'pte_jpeg_compression' => 90
71
+ );
72
  return array_merge( $defaults, $pte_site_options );
73
  }
74
 
89
 
90
  /* Hook into the Edit Image page */
91
  function pte_enable_thickbox(){
92
+ $options = pte_get_options();
93
+
94
+ if ( $options['pte_thickbox'] ){
95
+ wp_enqueue_style( 'thickbox' );
96
+ wp_enqueue_script( 'thickbox' );
97
+ }
98
  }
99
 
100
+ function pte_admin_media_scripts($post_type){
101
+ //print("yessir:$post_type:\n");
102
  $options = pte_get_options();
103
+ pte_enable_thickbox();
104
 
105
  if ( $options['pte_debug'] ){
106
  wp_enqueue_script( 'pte'
107
+ , PTE_PLUGINURL . 'js/pte.full.dev.js'
108
  , array('jquery')
109
  , PTE_VERSION
110
  );
111
  }
112
  else {
113
  wp_enqueue_script( 'pte'
114
+ , PTE_PLUGINURL . 'js/pte.full.js'
115
  , array('jquery')
116
  , PTE_VERSION
117
  );
120
  , 'objectL10n'
121
  , array('PTE' => __('Post Thumbnail Editor', PTE_DOMAIN))
122
  );
123
+ if ($post_type == "attachment") {
124
+ //add_action("admin_footer","pte_enable_admin_js",100);
125
+ add_action("admin_print_footer_scripts","pte_enable_admin_js",100);
126
+ }
127
+ else {
128
+ add_action("admin_print_footer_scripts","pte_enable_media_js",100);
129
+ }
130
  }
131
 
132
  function pte_enable_admin_js(){
139
  EOT;
140
  }
141
 
142
+ function pte_enable_media_js(){
143
+ $options = json_encode( pte_get_options() );
144
+ echo <<<EOT
145
+ <script type="text/javascript">
146
+ var options = {$options};
147
+ jQuery( function(){ pte.media(); } );
148
+ </script>
149
+ EOT;
150
+ }
151
+
152
  // Base url/function. All pte interactions go through here
153
  function pte_ajax(){
154
  // Move all adjuntant functions to a separate file and include that here
183
  return $actions;
184
  }
185
  $options = pte_get_options();
186
+
187
+ $thickbox = ( $options['pte_thickbox'] ) ? "class='thickbox'" : "";
188
  $pte_url = admin_url('admin-ajax.php')
189
  . "?action=pte_ajax&pte-action=launch&id="
190
  . $post->ID
191
  . "&TB_iframe=true&height={$options['pte_tb_height']}&width={$options['pte_tb_width']}";
192
+
193
+ $actions['pte'] = "<a ${thickbox} href='${pte_url}' title='"
194
  . __( 'Edit Thumbnails', PTE_DOMAIN )
195
  . "'>" . __( 'Thumbnails', PTE_DOMAIN ) . "</a>";
196
  return $actions;
216
  }
217
 
218
  /* This is the main admin media page */
219
+ /** For the "Edit Image" stuff **/
220
+ //add_action('edit_form_advanced', 'pte_admin_media_scripts');
221
+ add_action('dbx_post_advanced', 'pte_edit_form_hook_redirect');
222
  /* Slight redirect so this isn't called on all versions of the media upload page */
223
+ function pte_edit_form_hook_redirect(){
224
+ add_action('add_meta_boxes', 'pte_admin_media_scripts');
225
  }
 
 
226
 
227
  /* Adds the Thumbnail option to the media library list */
228
  add_action('admin_print_styles-upload.php', 'pte_enable_thickbox');