@@ -70,7 +70,7 @@ <h2>Sample 1: Save to disk</h2>
70
70
</ form >
71
71
</ div >
72
72
< script >
73
- $ ( function ( ) {
73
+ ( function ( ) {
74
74
var editor = new FroalaEditor ( '#edit' , {
75
75
76
76
imageUploadURL : '/upload_image' ,
@@ -86,11 +86,12 @@ <h2>Sample 1: Save to disk</h2>
86
86
imageManagerLoadURL : '/load_images' ,
87
87
imageManagerDeleteURL : "/delete_image" ,
88
88
imageManagerDeleteMethod : "POST" ,
89
-
89
+
90
90
videoUploadURL : '/upload_video' ,
91
- } ) ;
92
- // Catch image removal from the editor.
93
- editor . events . on ( 'froalaEditor.image.removed' , function ( e , editor , $img ) {
91
+
92
+ events : {
93
+ // Catch image removal from the editor.
94
+ 'image.removed' : function ( $img ) {
94
95
$ . ajax ( {
95
96
// Request method.
96
97
method : "POST" ,
@@ -109,8 +110,9 @@ <h2>Sample 1: Save to disk</h2>
109
110
. fail ( function ( err ) {
110
111
console . log ( 'image delete problem: ' + JSON . stringify ( err ) ) ;
111
112
} )
112
- } ) ;
113
- editor . events . on ( 'froalaEditor.video.removed' , function ( e , editor , $video ) {
113
+ } ,
114
+ // Catch video removal from the editor.
115
+ 'video.removed' : function ( $video ) {
114
116
$ . ajax ( {
115
117
// Request method.
116
118
method : "POST" ,
@@ -129,11 +131,9 @@ <h2>Sample 1: Save to disk</h2>
129
131
. fail ( function ( err ) {
130
132
console . log ( 'video delete problem: ' + JSON . stringify ( err ) ) ;
131
133
} )
132
- } ) ;
133
-
134
- // Catch image removal from the editor.
135
- editor . events . on ( 'froalaEditor.file.unlink' , function ( e , editor , link ) {
136
-
134
+ } ,
135
+ // Catch file removal from the editor.
136
+ 'file.unlink' :function ( link ) {
137
137
$ . ajax ( {
138
138
// Request method.
139
139
method : "POST" ,
@@ -152,8 +152,10 @@ <h2>Sample 1: Save to disk</h2>
152
152
. fail ( function ( err ) {
153
153
console . log ( 'file delete problem: ' + JSON . stringify ( err ) ) ;
154
154
} )
155
- } )
156
- } ) ;
155
+ }
156
+ }
157
+ } ) ;
158
+ } ) ( ) ;
157
159
</ script >
158
160
159
161
< div class ="sample ">
@@ -163,9 +165,9 @@ <h2>Sample 2: Save to disk (resize on server)</h2>
163
165
</ form >
164
166
</ div >
165
167
< script >
166
- $ ( function ( ) {
168
+ ( function ( ) {
167
169
var editor2 = new FroalaEditor ( '#edit-resize' , {
168
-
170
+
169
171
imageUploadURL : '/upload_image_resize' ,
170
172
imageUploadParams : {
171
173
id : 'my_editor'
@@ -178,37 +180,35 @@ <h2>Sample 2: Save to disk (resize on server)</h2>
178
180
179
181
imageManagerLoadURL : '/load_images' ,
180
182
imageManagerDeleteURL : "/delete_image" ,
181
- imageManagerDeleteMethod : "POST"
182
- } ) ;
183
- // Catch image removal from the editor.
184
- editor2 . events . on ( 'froalaEditor.image.removed' , function ( e , editor , $img ) {
185
- $ . ajax ( {
186
- // Request method.
187
- method : "POST" ,
188
-
189
- // Request URL.
190
- url : "/delete_image" ,
191
-
192
- // Request params.
193
- data : {
194
- src : $img . attr ( 'src' )
195
- }
196
- } )
197
- . done ( function ( data ) {
198
- console . log ( 'image was deleted' ) ;
199
- } )
200
- . fail ( function ( err ) {
201
- console . log ( 'image delete problem: ' + JSON . stringify ( err ) ) ;
202
- } )
203
- } )
204
-
205
- // Catch image removal from the editor.
206
- editor2 . events . on ( 'froalaEditor.file.unlink' , function ( e , editor , link ) {
183
+ imageManagerDeleteMethod : "POST" ,
207
184
185
+ events :{
186
+ // Catch image removal from the editor.
187
+ 'image.removed' : function ( $img ) {
188
+ $ . ajax ( {
189
+ // Request method.
190
+ method : "POST" ,
191
+
192
+ // Request URL.
193
+ url : "/delete_image" ,
194
+
195
+ // Request params.
196
+ data : {
197
+ src : $img . attr ( 'src' )
198
+ }
199
+ } )
200
+ . done ( function ( data ) {
201
+ console . log ( 'image was deleted' ) ;
202
+ } )
203
+ . fail ( function ( err ) {
204
+ console . log ( 'image delete problem: ' + JSON . stringify ( err ) ) ;
205
+ } )
206
+ } ,
207
+ // Catch file removal from the editor.
208
+ 'file.unlink' : function ( link ) {
208
209
$ . ajax ( {
209
210
// Request method.
210
211
method : "POST" ,
211
-
212
212
// Request URL.
213
213
url : "/delete_file" ,
214
214
@@ -223,8 +223,10 @@ <h2>Sample 2: Save to disk (resize on server)</h2>
223
223
. fail ( function ( err ) {
224
224
console . log ( 'file delete problem: ' + JSON . stringify ( err ) ) ;
225
225
} )
226
- } )
227
- } ) ;
226
+ }
227
+ }
228
+ } ) ;
229
+ } ) ( ) ;
228
230
</ script >
229
231
230
232
< div class ="sample ">
@@ -234,7 +236,7 @@ <h2>Sample 3: Save to disk with custom validation: Images must be squares (width
234
236
</ form >
235
237
</ div >
236
238
< script >
237
- $ ( function ( ) {
239
+ ( function ( ) {
238
240
var editor3 = new FroalaEditor ( '#edit-validation' , {
239
241
240
242
imageUploadURL : '/upload_image_validation' ,
@@ -252,10 +254,10 @@ <h2>Sample 3: Save to disk with custom validation: Images must be squares (width
252
254
253
255
imageManagerLoadURL : '/load_images' ,
254
256
imageManagerDeleteURL : "/delete_image" ,
255
- imageManagerDeleteMethod : "POST"
256
- } ) ;
257
- // Catch image removal from the editor.
258
- editor3 . events . on ( 'froalaEditor. image.removed', function ( e , editor , $img ) {
257
+ imageManagerDeleteMethod : "POST" ,
258
+ events : {
259
+ // Catch image removal from the editor.
260
+ ' image.removed': function ( e , editor , $img ) {
259
261
$ . ajax ( {
260
262
// Request method.
261
263
method : "POST" ,
@@ -274,11 +276,9 @@ <h2>Sample 3: Save to disk with custom validation: Images must be squares (width
274
276
. fail ( function ( err ) {
275
277
console . log ( 'image delete problem: ' + JSON . stringify ( err ) ) ;
276
278
} )
277
- } ) ;
278
-
279
+ } ,
279
280
// Catch image removal from the editor.
280
- editor3 . events . on ( 'froalaEditor.file.unlink' , function ( e , editor , link ) {
281
-
281
+ 'file.unlink' : function ( link ) {
282
282
$ . ajax ( {
283
283
// Request method.
284
284
method : "POST" ,
@@ -297,8 +297,10 @@ <h2>Sample 3: Save to disk with custom validation: Images must be squares (width
297
297
. fail ( function ( err ) {
298
298
console . log ( 'file delete problem: ' + JSON . stringify ( err ) ) ;
299
299
} )
300
- } )
301
- } ) ;
300
+ }
301
+ }
302
+ } ) ;
303
+ } ) ( ) ;
302
304
</ script >
303
305
304
306
< div class ="sample ">
@@ -309,18 +311,18 @@ <h2>Sample 4: Save to Amazon using signature version 4</h2>
309
311
</ div >
310
312
311
313
< script >
312
- $ ( function ( ) {
314
+ ( function ( ) {
313
315
314
316
$ . get ( "get_amazon" , { } )
315
317
. done ( function ( data ) {
316
-
318
+
317
319
new FroalaEditor ( '#edit-amazon' , {
318
320
imageUploadToS3 : data ,
319
321
fileUploadToS3 : data ,
320
322
videoUploadToS3 : data
321
323
} )
322
324
} ) ;
323
- } ) ;
325
+ } ) ( ) ;
324
326
</ script >
325
327
326
328
</ body >
0 commit comments