11//The MIT License (MIT)
2- //Copyright (c) 2014 Ritesh Kumar
2+ //Copyright (c) 2015 Ritesh Kumar
33//
44//Permission is hereby granted, free of charge, to any person obtaining a copy
55//of this software and associated documentation files (the "Software"), to deal
2121
2222const utils = require ( './modules/utils.es6' ) ;
2323
24- if ( build . EMOJI ) var Emoji = require ( './modules/emoticons/emoji.es6' ) ;
25- if ( build . SMILEY ) var Smiley = require ( './modules/emoticons/smiley.es6' ) ;
26- if ( build . LINK ) var Url = require ( './modules/url.es6' ) ;
24+ if ( build . EMOJI ) var Emoji = require ( './modules/emoticons/emoji.es6' ) ;
25+ if ( build . SMILEY ) var Smiley = require ( './modules/emoticons/smiley.es6' ) ;
26+ if ( build . LINK ) var Url = require ( './modules/url.es6' ) ;
2727
28- if ( build . TWITTER ) var Twitter = require ( './modules/twitter/twitter.es6' ) ;
29- if ( build . MAP ) var Gmap = require ( './modules/map/map.es6' ) ;
30- if ( build . MARKDOWN ) var Markdown = require ( './modules/markdown.es6' ) ;
28+ if ( build . TWITTER ) var Twitter = require ( './modules/twitter/twitter.es6' ) ;
29+ if ( build . MAP ) var Gmap = require ( './modules/map/map.es6' ) ;
30+ if ( build . MARKDOWN ) var Markdown = require ( './modules/markdown.es6' ) ;
3131
32- const Code = require ( './modules/code/code.es6' ) ;
33- const Video = require ( './modules/video/video.es6' ) ;
34-
35- const Audio = require ( './modules/audio/audio.es6' ) ;
36- const Image = require ( './modules/image/image.es6' ) ;
37-
38- const helper = require ( './modules/video/helper.es6' ) ;
32+ const Code = require ( './modules/code/code.es6' ) ;
33+ const Video = require ( './modules/video/video.es6' ) ;
34+ const Audio = require ( './modules/audio/audio.es6' ) ;
35+ const Image = require ( './modules/image/image.es6' ) ;
36+ const helper = require ( './modules/video/helper.es6' ) ;
3937
4038( function ( ) {
4139
4240 var globalOptions ;
4341
4442 var defaultOptions = {
45- marked : false ,
46- markedOptions : { } ,
47- link : true ,
48- linkOptions : {
49- target : 'self' ,
50- exclude : [ 'pdf' ] ,
51- rel : ''
43+ marked : false ,
44+ markedOptions : { } ,
45+ link : true ,
46+ linkOptions : {
47+ target : 'self' ,
48+ exclude : [ 'pdf' ] ,
49+ rel : ''
5250 } ,
53- emoji : true ,
54- customEmoji : [ ] ,
55- fontIcons : true ,
56- customFontIcons : [ ] ,
57- highlightCode : true ,
58- videoJS : false ,
59- videojsOptions : {
60- fluid : true ,
61- preload : 'metadata'
51+ emoji : true ,
52+ customEmoji : [ ] ,
53+ fontIcons : true ,
54+ customFontIcons : [ ] ,
55+ highlightCode : true ,
56+ videoJS : false ,
57+ videojsOptions : {
58+ fluid : true ,
59+ preload : 'metadata'
6260 } ,
63- locationEmbed : true ,
64- mapOptions : {
65- mode : 'place'
61+ locationEmbed : true ,
62+ mapOptions : {
63+ mode : 'place'
6664 } ,
67- tweetsEmbed : true ,
68- tweetOptions : {
69- maxWidth : 550 ,
70- hideMedia : false ,
71- hideThread : false ,
72- align : 'none' ,
73- lang : 'en'
65+ tweetsEmbed : true ,
66+ tweetOptions : {
67+ maxWidth : 550 ,
68+ hideMedia : false ,
69+ hideThread : false ,
70+ align : 'none' ,
71+ lang : 'en'
7472 } ,
75- imageEmbed : true ,
76- videoEmbed : true ,
77- videoHeight : null ,
78- videoWidth : null ,
79- videoDetails : true ,
80- audioEmbed : true ,
81- excludeEmbed : [ ] ,
82- codeEmbedHeight : 500 ,
83- vineOptions : {
84- maxWidth : null ,
85- type : 'postcard' , //'postcard' or 'simple' embedding
86- responsive : true ,
87- width : 350 ,
88- height : 460
73+ imageEmbed : true ,
74+ videoEmbed : true ,
75+ videoHeight : null ,
76+ videoWidth : null ,
77+ videoDetails : true ,
78+ audioEmbed : true ,
79+ excludeEmbed : [ ] ,
80+ inlineEmbed : [ ] ,
81+ inlineText : true ,
82+ codeEmbedHeight : 500 ,
83+ vineOptions : {
84+ maxWidth : null ,
85+ type : 'postcard' , //'postcard' or 'simple' embedding
86+ responsive : true ,
87+ width : 350 ,
88+ height : 460
8989 } ,
90- googleAuthKey : '' ,
91- soundCloudOptions : {
92- height : 160 ,
93- themeColor : 'f50000' , //Hex Code of the player theme color
94- autoPlay : false ,
95- hideRelated : false ,
96- showComments : true ,
97- showUser : true ,
98- showReposts : false ,
99- visual : false , //Show/hide the big preview image
100- download : false //Show/Hide download buttons
90+ googleAuthKey : '' ,
91+ soundCloudOptions : {
92+ height : 160 ,
93+ themeColor : 'f50000' , //Hex Code of the player theme color
94+ autoPlay : false ,
95+ hideRelated : false ,
96+ showComments : true ,
97+ showUser : true ,
98+ showReposts : false ,
99+ visual : false , //Show/hide the big preview image
100+ download : false //Show/Hide download buttons
101101 } ,
102- beforeEmbedJSApply : function ( ) { } ,
103- afterEmbedJSApply : function ( ) { } ,
104- onVideoShow : function ( ) { } ,
105- onTweetsLoad : function ( ) { } ,
106- videojsCallback : function ( ) { }
102+ beforeEmbedJSApply : function ( ) { } ,
103+ afterEmbedJSApply : function ( ) { } ,
104+ onVideoShow : function ( ) { } ,
105+ onTweetsLoad : function ( ) { } ,
106+ videojsCallback : function ( ) { }
107107 } ;
108108
109109 class EmbedJS {
@@ -139,15 +139,16 @@ const helper = require('./modules/video/helper.es6');
139139
140140 this . options . beforeEmbedJSApply ( ) ;
141141
142- let output = options . link && build . LINK ? ( new Url ( input , options ) . process ( ) ) : input ;
143- output = options . marked && build . MARKDOWN ? ( new Markdown ( output , options ) . process ( ) ) : output ;
144- output = options . emoji && build . EMOJI ? ( new Emoji ( output , options ) . process ( ) ) : output ;
145- output = options . fontIcons && build . SMILEY ? ( new Smiley ( output , options ) . process ( ) ) : output ;
142+ let output = options . link && build . LINK ? ( new Url ( input , options ) . process ( ) ) : input ;
143+ output = options . marked && build . MARKDOWN ? ( new Markdown ( output , options ) . process ( ) ) : output ;
144+ output = options . emoji && build . EMOJI ? ( new Emoji ( output , options ) . process ( ) ) : output ;
145+ output = options . fontIcons && build . SMILEY ? ( new Smiley ( output , options ) . process ( ) ) : output ;
146146 [ output , embeds ] = ( new Code ( input , output , options , embeds ) . process ( ) ) ;
147147 [ output , embeds ] = await ( new Video ( input , output , options , embeds ) . process ( ) ) ;
148148 [ output , embeds ] = options . locationEmbed ? await ( new Gmap ( input , output , options , embeds ) . process ( ) ) : [ output , embeds ] ;
149149 [ output , embeds ] = ( new Audio ( input , output , options , embeds ) . process ( ) ) ;
150150 [ output , embeds ] = ( new Image ( input , output , options , embeds ) . process ( ) ) ;
151+
151152 if ( options . tweetsEmbed && build . TWITTER ) {
152153 this . twitter = new Twitter ( input , options , embeds ) ;
153154 embeds = options . tweetsEmbed ? await ( this . twitter . process ( ) ) : output ;
@@ -201,9 +202,20 @@ const helper = require('./modules/video/helper.es6');
201202 let ejs = {
202203 instances : [ ] ,
203204 elements : [ ] ,
205+
206+ /**
207+ * Sets options globally
208+ * @param {object } options
209+ */
204210 setOptions : function ( options ) {
205211 globalOptions = utils . deepExtend ( defaultOptions , options )
206212 } ,
213+
214+ /**
215+ * Applies embed.js to all the elements with the class name provided as option
216+ * @param {string } className
217+ * @return {null }
218+ */
207219 applyEmbedJS : function ( className ) {
208220 this . elements = document . getElementsByClassName ( className )
209221 for ( let i = 0 ; i < this . elements . length ; i ++ ) {
@@ -214,6 +226,11 @@ const helper = require('./modules/video/helper.es6');
214226 this . instances [ i ] . render ( )
215227 }
216228 } ,
229+
230+ /**
231+ * Destroys all the instances of EmbedJS created by using ejs.applyEmbedJS method.
232+ * @return {null }
233+ */
217234 destroyEmbedJS : function ( ) {
218235 for ( let i = 0 ; i < this . elements . length ; i ++ ) {
219236 this . instances [ i ] . destroy ( )
0 commit comments