1 | declare namespace FomanticUI {
|
2 | interface Embed {
|
3 | settings: EmbedSettings;
|
4 |
|
5 | /**
|
6 | * Changes iframe to a new content source.
|
7 | */
|
8 | (behavior: 'change', source: string, id: string, url: string): JQuery;
|
9 |
|
10 | /**
|
11 | * Removes embed and shows placeholder content if available.
|
12 | */
|
13 | (behavior: 'reset'): JQuery;
|
14 |
|
15 | /**
|
16 | * Shows embed content.
|
17 | */
|
18 | (behavior: 'show'): JQuery;
|
19 |
|
20 | /**
|
21 | * Hides embed content and shows placeholder content.
|
22 | */
|
23 | (behavior: 'hide'): JQuery;
|
24 |
|
25 | /**
|
26 | * Returns current content id.
|
27 | */
|
28 | (behavior: 'get id'): string;
|
29 |
|
30 | /**
|
31 | * Returns placeholder image url.
|
32 | */
|
33 | (behavior: 'get placeholder'): string;
|
34 |
|
35 | /**
|
36 | * Returns source name.
|
37 | */
|
38 | (behavior: 'get sources'): string;
|
39 |
|
40 | /**
|
41 | * Returns source type.
|
42 | */
|
43 | (behavior: 'get sources'): string;
|
44 |
|
45 | /**
|
46 | * Returns URL with all parameters added.
|
47 | */
|
48 | (behavior: 'get url'): string;
|
49 |
|
50 | /**
|
51 | * Returns whether embed content has placeholder.
|
52 | */
|
53 | (behavior: 'has placeholder'): boolean;
|
54 |
|
55 | /**
|
56 | * Destroys instance and removes all events.
|
57 | */
|
58 | (behavior: 'destroy'): JQuery;
|
59 |
|
60 | <K extends keyof EmbedSettings>(behavior: 'setting', name: K, value?: undefined, ): Partial<Pick<EmbedSettings, keyof EmbedSettings>>;
|
61 | <K extends keyof EmbedSettings>(behavior: 'setting', name: K, value: EmbedSettings[K]): JQuery;
|
62 | (behavior: 'setting', value: Partial<Pick<EmbedSettings, keyof EmbedSettings>>): JQuery;
|
63 | (settings?: Partial<Pick<EmbedSettings, keyof EmbedSettings>>): JQuery;
|
64 | }
|
65 |
|
66 | /**
|
67 | * @see {@link https://fomantic-ui.com/modules/embed.html#/settings}
|
68 | */
|
69 | interface EmbedSettings {
|
70 | // region Embed Settings
|
71 |
|
72 | /**
|
73 | * Specifies an icon to use with placeholder content.
|
74 | * @default false
|
75 | */
|
76 | icon: false | string;
|
77 |
|
78 | /**
|
79 | * Specifies a source to use, if no source is provided it will be determined from the domain of a specified url.
|
80 | * @default false
|
81 | */
|
82 | source: false | string;
|
83 |
|
84 | /**
|
85 | * Specifies a url to use for embed.
|
86 | * @default false
|
87 | */
|
88 | url: false | string;
|
89 |
|
90 | /**
|
91 | * Specifies an id value to replace with the '{id}' value found in templated urls.
|
92 | * @default false
|
93 | */
|
94 | id: false | string;
|
95 |
|
96 | /**
|
97 | * Specify an object containing key/value pairs to add to the iframes GET parameters.
|
98 | * @default false
|
99 | */
|
100 | parameters: false | object;
|
101 |
|
102 | // endregion
|
103 |
|
104 | // region Video Settings
|
105 |
|
106 | /**
|
107 | * Default setting 'auto' will only autoplay content when a placeholder is specified.
|
108 | * Setting to 'true' or 'false' will force autoplay.
|
109 | * @default 'auto'
|
110 | */
|
111 | autoplay: 'auto' | boolean;
|
112 |
|
113 | /**
|
114 | * Default setting 'auto' will only autoplay content when a placeholder is specified.
|
115 | * Setting to 'true' or 'false' will force autoplay.
|
116 | * @default '#444'
|
117 | */
|
118 | color: string;
|
119 |
|
120 | /**
|
121 | * Whether to prefer HD content.
|
122 | * @default true
|
123 | */
|
124 | hd: boolean;
|
125 |
|
126 | /**
|
127 | * Whether to show networks branded UI like title cards, or after video calls to action.
|
128 | * @default false
|
129 | */
|
130 | brandedUI: boolean;
|
131 |
|
132 | // endregion
|
133 |
|
134 | // region Callbacks
|
135 |
|
136 | /**
|
137 | * Callback when iframe is generated.
|
138 | */
|
139 | onCreate(this: JQuery, url: string): void;
|
140 |
|
141 | /**
|
142 | * Whenever an iframe contents is shown.
|
143 | */
|
144 | onDisplay(this: JQuery): void;
|
145 |
|
146 | /**
|
147 | * Whenever the module is cleared.
|
148 | */
|
149 | onReset(this: JQuery): void;
|
150 |
|
151 | /**
|
152 | * Callback immediately before Embed is removed from DOM.
|
153 | */
|
154 | onPlaceholderDisplay(this: JQuery): void;
|
155 |
|
156 | /**
|
157 | * Callback when module parameters are determined.
|
158 | * Allows you to adjust parameters at run time by returning a new parameters object.
|
159 | */
|
160 | onEmbed(this: JQuery, parameters: object): void;
|
161 |
|
162 | // endregion
|
163 |
|
164 | // region DOM Settings
|
165 |
|
166 | /**
|
167 | * DOM Selectors used internally.
|
168 | * Selectors used to find parts of a module.
|
169 | */
|
170 | selector: Embed.SelectorSettings;
|
171 |
|
172 | /**
|
173 | * HTML Data attributes used to store data.
|
174 | */
|
175 | metadata: Embed.MetadataSettings;
|
176 |
|
177 | /**
|
178 | * Class names used to determine element state.
|
179 | */
|
180 | className: Embed.ClassNameSettings;
|
181 |
|
182 | /**
|
183 | *
|
184 | */
|
185 | templates: Embed.TemplateSettings;
|
186 |
|
187 | // endregion
|
188 |
|
189 | // region Debug Settings
|
190 |
|
191 | /**
|
192 | * Name used in log statements
|
193 | * @default 'Embed''
|
194 | */
|
195 | name: string;
|
196 |
|
197 | /**
|
198 | * Event namespace. Makes sure module teardown does not effect other events attached to an element.
|
199 | * @default 'embed''
|
200 | */
|
201 | namespace: string;
|
202 |
|
203 | /**
|
204 | * Silences all console output including error messages, regardless of other debug settings.
|
205 | * @default false
|
206 | */
|
207 | silent: boolean;
|
208 |
|
209 | /**
|
210 | * Debug output to console
|
211 | * @default false
|
212 | */
|
213 | debug: boolean;
|
214 |
|
215 | /**
|
216 | * Show console.table output with performance metrics
|
217 | * @default true
|
218 | */
|
219 | performance: boolean;
|
220 |
|
221 | /**
|
222 | * Debug output includes all internal behaviors
|
223 | * @default false
|
224 | */
|
225 | verbose: boolean;
|
226 |
|
227 | error: Embed.ErrorSettings;
|
228 |
|
229 | // endregion
|
230 | }
|
231 |
|
232 | namespace Embed {
|
233 | type SelectorSettings = Partial<Pick<Settings.Selectors, keyof Settings.Selectors>>;
|
234 | type MetadataSettings = Partial<Pick<Settings.Metadatas, keyof Settings.Metadatas>>;
|
235 | type ClassNameSettings = Partial<Pick<Settings.ClassNames, keyof Settings.ClassNames>>;
|
236 | type TemplateSettings = Partial<Pick<Settings.Templates, keyof Settings.Templates>>;
|
237 | type ErrorSettings = Partial<Pick<Settings.Errors, keyof Settings.Errors>>;
|
238 |
|
239 | namespace Settings {
|
240 | interface Selectors {
|
241 | /**
|
242 | * @default '.embed'
|
243 | */
|
244 | embed: string;
|
245 |
|
246 | /**
|
247 | * @default '.placeholder'
|
248 | */
|
249 | placeholder: string;
|
250 |
|
251 | /**
|
252 | * @default '.icon'
|
253 | */
|
254 | icon: string;
|
255 | }
|
256 |
|
257 | interface Metadatas {
|
258 | /**
|
259 | * @default 'id'
|
260 | */
|
261 | id: string;
|
262 |
|
263 | /**
|
264 | * @default 'icon'
|
265 | */
|
266 | icon: string;
|
267 |
|
268 | /**
|
269 | * @default 'placeholder'
|
270 | */
|
271 | placeholder: string;
|
272 |
|
273 | /**
|
274 | * @default 'source'
|
275 | */
|
276 | source: string;
|
277 |
|
278 | /**
|
279 | * @default 'url'
|
280 | */
|
281 | url: string;
|
282 | }
|
283 |
|
284 | interface ClassNames {
|
285 | /**
|
286 | * @default 'active'
|
287 | */
|
288 | active: string;
|
289 |
|
290 | /**
|
291 | * @default 'embed'
|
292 | */
|
293 | embed: string;
|
294 | }
|
295 |
|
296 | interface Templates {
|
297 | /**
|
298 | * @default function
|
299 | */
|
300 | deQuote(string: string, encode: boolean): string;
|
301 |
|
302 | /**
|
303 | * @default function
|
304 | */
|
305 | iframe(url: string, parameters: any): string;
|
306 |
|
307 | /**
|
308 | * @default function
|
309 | */
|
310 | placeholder(image: string, icon: string): string;
|
311 | }
|
312 |
|
313 | interface Errors {
|
314 | /**
|
315 | * @default 'No URL specified'
|
316 | */
|
317 | noURL: string;
|
318 |
|
319 | /**
|
320 | * @default 'The method you called is not defined'
|
321 | */
|
322 | method: string;
|
323 | }
|
324 | }
|
325 | }
|
326 | }
|