scratch – Diff between revs 58 and 125
?pathlinks?
Rev 58 | Rev 125 | |||
---|---|---|---|---|
1 | /* =========================================================== |
1 | /* =========================================================== |
|
2 | * trumbowyg.noembed.js v1.0 |
2 | * trumbowyg.noembed.js v1.0 |
|
3 | * noEmbed plugin for Trumbowyg |
3 | * noEmbed plugin for Trumbowyg |
|
4 | * http://alex-d.github.com/Trumbowyg |
4 | * http://alex-d.github.com/Trumbowyg |
|
5 | * =========================================================== |
5 | * =========================================================== |
|
6 | * Author : Jake Johns (jakejohns) |
6 | * Author : Jake Johns (jakejohns) |
|
7 | */ |
7 | */ |
|
8 | |
8 | |
|
9 | (function ($) { |
9 | (function ($) { |
|
10 | 'use strict'; |
10 | 'use strict'; |
|
11 | |
11 | |
|
12 | var defaultOptions = { |
12 | var defaultOptions = { |
|
13 | proxy: 'https://noembed.com/embed?nowrap=on', |
13 | proxy: 'https://noembed.com/embed?nowrap=on', |
|
14 | urlFiled: 'url', |
14 | urlFiled: 'url', |
|
15 | data: [], |
15 | data: [], |
|
16 | success: undefined, |
16 | success: undefined, |
|
17 | error: undefined |
17 | error: undefined |
|
18 | }; |
18 | }; |
|
19 | |
19 | |
|
20 | $.extend(true, $.trumbowyg, { |
20 | $.extend(true, $.trumbowyg, { |
|
21 | langs: { |
21 | langs: { |
|
22 | en: { |
22 | en: { |
|
23 | noembed: 'noEmbed', |
23 | noembed: 'noEmbed', |
|
24 | noembedError: 'Error' |
24 | noembedError: 'Error' |
|
25 | }, |
25 | }, |
|
26 | sk: { |
26 | sk: { |
|
27 | noembedError: 'Chyba' |
27 | noembedError: 'Chyba' |
|
28 | }, |
28 | }, |
|
29 | fr: { |
29 | fr: { |
|
30 | noembed: 'noEmbed', |
30 | noembed: 'noEmbed', |
|
31 | noembedError: 'Erreur' |
31 | noembedError: 'Erreur' |
|
32 | }, |
32 | }, |
|
33 | cs: { |
33 | cs: { |
|
34 | noembedError: 'Chyba' |
34 | noembedError: 'Chyba' |
|
- | 35 | }, |
||
- | 36 | ja: { |
||
- | 37 | noembed: 'noEmbed', |
||
- | 38 | noembedError: 'エラー' |
||
35 | } |
39 | } |
|
36 | }, |
40 | }, |
|
37 | |
41 | |
|
38 | plugins: { |
42 | plugins: { |
|
39 | noembed: { |
43 | noembed: { |
|
40 | init: function (trumbowyg) { |
44 | init: function (trumbowyg) { |
|
41 | trumbowyg.o.plugins.noembed = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.noembed || {}); |
45 | trumbowyg.o.plugins.noembed = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.noembed || {}); |
|
42 | |
46 | |
|
43 | var btnDef = { |
47 | var btnDef = { |
|
44 | fn: function () { |
48 | fn: function () { |
|
45 | var $modal = trumbowyg.openModalInsert( |
49 | var $modal = trumbowyg.openModalInsert( |
|
46 | // Title |
50 | // Title |
|
47 | trumbowyg.lang.noembed, |
51 | trumbowyg.lang.noembed, |
|
48 | |
52 | |
|
49 | // Fields |
53 | // Fields |
|
50 | { |
54 | { |
|
51 | url: { |
55 | url: { |
|
52 | label: 'URL', |
56 | label: 'URL', |
|
53 | required: true |
57 | required: true |
|
54 | } |
58 | } |
|
55 | }, |
59 | }, |
|
56 | |
60 | |
|
57 | // Callback |
61 | // Callback |
|
58 | function (data) { |
62 | function (data) { |
|
59 | $.ajax({ |
63 | $.ajax({ |
|
60 | url: trumbowyg.o.plugins.noembed.proxy, |
64 | url: trumbowyg.o.plugins.noembed.proxy, |
|
61 | type: 'GET', |
65 | type: 'GET', |
|
62 | data: data, |
66 | data: data, |
|
63 | cache: false, |
67 | cache: false, |
|
64 | dataType: 'json', |
68 | dataType: 'json', |
|
65 | |
69 | |
|
66 | success: trumbowyg.o.plugins.noembed.success || function (data) { |
70 | success: trumbowyg.o.plugins.noembed.success || function (data) { |
|
67 | if (data.html) { |
71 | if (data.html) { |
|
68 | trumbowyg.execCmd('insertHTML', data.html); |
72 | trumbowyg.execCmd('insertHTML', data.html); |
|
69 | setTimeout(function () { |
73 | setTimeout(function () { |
|
70 | trumbowyg.closeModal(); |
74 | trumbowyg.closeModal(); |
|
71 | }, 250); |
75 | }, 250); |
|
72 | } else { |
76 | } else { |
|
73 | trumbowyg.addErrorOnModalField( |
77 | trumbowyg.addErrorOnModalField( |
|
74 | $('input[type=text]', $modal), |
78 | $('input[type=text]', $modal), |
|
75 | data.error |
79 | data.error |
|
76 | ); |
80 | ); |
|
77 | } |
81 | } |
|
78 | }, |
82 | }, |
|
79 | error: trumbowyg.o.plugins.noembed.error || function () { |
83 | error: trumbowyg.o.plugins.noembed.error || function () { |
|
80 | trumbowyg.addErrorOnModalField( |
84 | trumbowyg.addErrorOnModalField( |
|
81 | $('input[type=text]', $modal), |
85 | $('input[type=text]', $modal), |
|
82 | trumbowyg.lang.noembedError |
86 | trumbowyg.lang.noembedError |
|
83 | ); |
87 | ); |
|
84 | } |
88 | } |
|
85 | }); |
89 | }); |
|
86 | } |
90 | } |
|
87 | ); |
91 | ); |
|
88 | } |
92 | } |
|
89 | }; |
93 | }; |
|
90 | |
94 | |
|
91 | trumbowyg.addBtnDef('noembed', btnDef); |
95 | trumbowyg.addBtnDef('noembed', btnDef); |
|
92 | } |
96 | } |
|
93 | } |
97 | } |
|
94 | } |
98 | } |
|
95 | }); |
99 | }); |
|
96 | })(jQuery); |
100 | })(jQuery); |
|
97 | |
101 | |