@@ -165,8 +165,7 @@ export default class EmbedJS {
165165
166166 /**
167167 * Processes the string and performs all the insertions and manipulations based on
168- * the options and the input provided by the user. This is an asynchronous function using the async/await
169- * feature of ES7 and this returns a promise which is resolved once the result data is ready
168+ * the options and the input provided by the user. This returns a promise which is resolved once the result data is ready
170169 * @return {Promise } The processes resulting string
171170 */
172171 process ( ) {
@@ -178,9 +177,8 @@ export default class EmbedJS {
178177 this . options . beforeEmbedJSApply ( ) ;
179178
180179 return new Promise ( ( resolve ) => {
181- if ( options . link ) {
182- output = new Url ( input , options ) . process ( )
183- }
180+ if ( LINK && options . link )
181+ output = new Url ( input , options ) . process ( ) ;
184182
185183 let openGraphPromise = OPENGRAPH && options . openGraphEndpoint ? new OpenGraph ( input , output , options , embeds ) . process ( ) : Promise . resolve ( [ output , embeds ] ) ;
186184
@@ -312,21 +310,34 @@ export default class EmbedJS {
312310 return new Promise ( ( resolve ) => {
313311 this . process ( ) . then ( ( data ) => {
314312 this . options . input . innerHTML = data ;
315- applyVideoJS ( this . options ) ;
313+ this . listen ( ) ;
314+ resolve ( this . data ) ;
315+ } )
316+ } )
317+ }
316318
317- playVideo ( this . options ) ;
319+ /**
320+ * This method listens to all the events like click, handle
321+ * events to be done after an element has been rendered. These
322+ * include twitter widget rendering, gist embedding, click event listeners .
323+ */
324+ listen ( ) {
325+ applyVideoJS ( this . options ) ;
318326
319- let event = new Event ( 'rendered' ) ;
320- this . options . input . dispatchEvent ( event ) ;
327+ playVideo ( this . options ) ;
321328
322- this . options . afterEmbedJSApply ( ) ;
329+ let event = new Event ( 'rendered' ) ;
330+ this . options . input . dispatchEvent ( event ) ;
323331
324- resolve ( this . data ) ;
325- } )
326- } )
332+ this . options . afterEmbedJSApply ( ) ;
327333 }
328334
329335
336+ /**
337+ * This function updates the parametrs of the current instance
338+ * @param options New updated options object. will be extended with the older options
339+ * @param template [optional] the new template instance
340+ */
330341 update ( options , template ) {
331342
332343 if ( options )
@@ -344,7 +355,7 @@ export default class EmbedJS {
344355 * @return Promise
345356 */
346357 text ( ) {
347- return new Promise ( function ( resolve ) {
358+ return new Promise ( ( resolve ) => {
348359 this . process ( ) . then ( ( ) => {
349360 resolve ( this . data )
350361 } )
0 commit comments