Skip to content

Commit 500a355

Browse files
author
jasgeet
committed
Updated code to use froala-v3 editor
1 parent 6a0f950 commit 500a355

File tree

1 file changed

+61
-59
lines changed

1 file changed

+61
-59
lines changed

examples/index.html

+61-59
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h2>Sample 1: Save to disk</h2>
7070
</form>
7171
</div>
7272
<script>
73-
$(function() {
73+
(function() {
7474
var editor = new FroalaEditor('#edit', {
7575

7676
imageUploadURL: '/upload_image',
@@ -86,11 +86,12 @@ <h2>Sample 1: Save to disk</h2>
8686
imageManagerLoadURL: '/load_images',
8787
imageManagerDeleteURL: "/delete_image",
8888
imageManagerDeleteMethod: "POST",
89-
89+
9090
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) {
9495
$.ajax({
9596
// Request method.
9697
method: "POST",
@@ -109,8 +110,9 @@ <h2>Sample 1: Save to disk</h2>
109110
.fail (function (err) {
110111
console.log ('image delete problem: ' + JSON.stringify(err));
111112
})
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) {
114116
$.ajax({
115117
// Request method.
116118
method: "POST",
@@ -129,11 +131,9 @@ <h2>Sample 1: Save to disk</h2>
129131
.fail (function (err) {
130132
console.log ('video delete problem: ' + JSON.stringify(err));
131133
})
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) {
137137
$.ajax({
138138
// Request method.
139139
method: "POST",
@@ -152,8 +152,10 @@ <h2>Sample 1: Save to disk</h2>
152152
.fail (function (err) {
153153
console.log ('file delete problem: ' + JSON.stringify(err));
154154
})
155-
})
156-
});
155+
}
156+
}
157+
});
158+
})();
157159
</script>
158160

159161
<div class="sample">
@@ -163,9 +165,9 @@ <h2>Sample 2: Save to disk (resize on server)</h2>
163165
</form>
164166
</div>
165167
<script>
166-
$(function() {
168+
(function() {
167169
var editor2 = new FroalaEditor('#edit-resize', {
168-
170+
169171
imageUploadURL: '/upload_image_resize',
170172
imageUploadParams: {
171173
id: 'my_editor'
@@ -178,37 +180,35 @@ <h2>Sample 2: Save to disk (resize on server)</h2>
178180

179181
imageManagerLoadURL: '/load_images',
180182
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",
207184

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) {
208209
$.ajax({
209210
// Request method.
210211
method: "POST",
211-
212212
// Request URL.
213213
url: "/delete_file",
214214

@@ -223,8 +223,10 @@ <h2>Sample 2: Save to disk (resize on server)</h2>
223223
.fail (function (err) {
224224
console.log ('file delete problem: ' + JSON.stringify(err));
225225
})
226-
})
227-
});
226+
}
227+
}
228+
});
229+
})();
228230
</script>
229231

230232
<div class="sample">
@@ -234,7 +236,7 @@ <h2>Sample 3: Save to disk with custom validation: Images must be squares (width
234236
</form>
235237
</div>
236238
<script>
237-
$(function() {
239+
(function() {
238240
var editor3 = new FroalaEditor('#edit-validation', {
239241

240242
imageUploadURL: '/upload_image_validation',
@@ -252,10 +254,10 @@ <h2>Sample 3: Save to disk with custom validation: Images must be squares (width
252254

253255
imageManagerLoadURL: '/load_images',
254256
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) {
259261
$.ajax({
260262
// Request method.
261263
method: "POST",
@@ -274,11 +276,9 @@ <h2>Sample 3: Save to disk with custom validation: Images must be squares (width
274276
.fail (function (err) {
275277
console.log ('image delete problem: ' + JSON.stringify(err));
276278
})
277-
});
278-
279+
},
279280
// Catch image removal from the editor.
280-
editor3.events.on('froalaEditor.file.unlink', function (e, editor, link) {
281-
281+
'file.unlink': function (link) {
282282
$.ajax({
283283
// Request method.
284284
method: "POST",
@@ -297,8 +297,10 @@ <h2>Sample 3: Save to disk with custom validation: Images must be squares (width
297297
.fail (function (err) {
298298
console.log ('file delete problem: ' + JSON.stringify(err));
299299
})
300-
})
301-
});
300+
}
301+
}
302+
});
303+
})();
302304
</script>
303305

304306
<div class="sample">
@@ -309,18 +311,18 @@ <h2>Sample 4: Save to Amazon using signature version 4</h2>
309311
</div>
310312

311313
<script>
312-
$(function() {
314+
(function() {
313315

314316
$.get( "get_amazon", {})
315317
.done(function( data ) {
316-
318+
317319
new FroalaEditor('#edit-amazon', {
318320
imageUploadToS3: data,
319321
fileUploadToS3: data,
320322
videoUploadToS3: data
321323
})
322324
});
323-
});
325+
})();
324326
</script>
325327

326328
</body>

0 commit comments

Comments
 (0)