1919//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020//SOFTWARE.
2121
22- import utils from './modules/utils.es6' ;
23- import Emoji from './modules/emoticons/emoji.es6' ;
24- import Smiley from './modules/emoticons/smiley.es6' ;
25- import Url from './modules/url.es6' ;
26- import Code from './modules/code/code.es6' ;
27- import Video from './modules/video/video.es6' ;
28- import Twitter from './modules/twitter/twitter.es6' ;
29- import Audio from './modules/audio/audio.es6' ;
30- import Image from './modules/image/image.es6' ;
31-
32- import helper from './modules/video/helper.es6' ;
22+ const utils = require ( './modules/utils.es6' ) ;
23+
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' ) ;
27+
28+ if ( build . TWITTER ) var Twitter = require ( './modules/twitter/twitter.es6' ) ;
29+
30+ const Code = require ( './modules/code/code.es6' ) ;
31+ const Video = require ( './modules/video/video.es6' ) ;
32+
33+ const Audio = require ( './modules/audio/audio.es6' ) ;
34+ const Image = require ( './modules/image/image.es6' ) ;
35+
36+ const helper = require ( './modules/video/helper.es6' ) ;
3337
3438( function ( ) {
3539
3640 var defaultOptions = {
37- link : true ,
38- linkOptions : {
39- target : 'self' ,
40- exclude : [ 'pdf' ]
41+ link : true ,
42+ linkOptions : {
43+ target : 'self' ,
44+ exclude : [ 'pdf' ]
4145 } ,
42- emoji : true ,
43- customEmoji : [ ] ,
44- fontIcons : true ,
45- highlightCode : true ,
46- videoJS : false ,
47- videojsOptions : {
48- fluid :true ,
49- preload :'metadata'
46+ emoji : true ,
47+ customEmoji : [ ] ,
48+ fontIcons : true ,
49+ highlightCode : true ,
50+ videoJS : false ,
51+ videojsOptions : {
52+ fluid : true ,
53+ preload : 'metadata'
5054 } ,
51- tweetsEmbed : true ,
52- tweetOptions : {
53- maxWidth : 550 ,
54- hideMedia : false ,
55- hideThread : false ,
56- align : 'none' ,
57- lang : 'en'
55+ tweetsEmbed : true ,
56+ tweetOptions : {
57+ maxWidth : 550 ,
58+ hideMedia : false ,
59+ hideThread : false ,
60+ align : 'none' ,
61+ lang : 'en'
5862 } ,
59- imageEmbed : true ,
60- videoEmbed : true ,
61- videoHeight : null ,
62- videoWidth : null ,
63- videoDetails : true ,
64- audioEmbed : true ,
65- excludeEmbed : [ ] ,
66- codeEmbedHeight : 500 ,
67- vineOptions : {
68- maxWidth : null ,
69- type : 'postcard' , //'postcard' or 'simple' embedding
70- responsive : true ,
71- width : 350 ,
72- height : 460
63+ imageEmbed : true ,
64+ videoEmbed : true ,
65+ videoHeight : null ,
66+ videoWidth : null ,
67+ videoDetails : true ,
68+ audioEmbed : true ,
69+ excludeEmbed : [ ] ,
70+ codeEmbedHeight : 500 ,
71+ vineOptions : {
72+ maxWidth : null ,
73+ type : 'postcard' , //'postcard' or 'simple' embedding
74+ responsive : true ,
75+ width : 350 ,
76+ height : 460
7377 } ,
74- googleAuthKey : 'AIzaSyCqFouT8h5DKAbxlrTZmjXEmNBjC69f0ts' ,
75- soundCloudOptions : {
76- height : 160 ,
77- themeColor : 'f50000' , //Hex Code of the player theme color
78- autoPlay : false ,
79- hideRelated : false ,
78+ googleAuthKey : 'AIzaSyCqFouT8h5DKAbxlrTZmjXEmNBjC69f0ts' ,
79+ soundCloudOptions : {
80+ height : 160 ,
81+ themeColor : 'f50000' , //Hex Code of the player theme color
82+ autoPlay : false ,
83+ hideRelated : false ,
8084 showComments : true ,
81- showUser : true ,
82- showReposts : false ,
83- visual : false , //Show/hide the big preview image
84- download : false //Show/Hide download buttons
85+ showUser : true ,
86+ showReposts : false ,
87+ visual : false , //Show/hide the big preview image
88+ download : false //Show/Hide download buttons
8589 } ,
86- beforeEmbedJSApply : function ( ) { } ,
87- afterEmbedJSApply : function ( ) { } ,
88- onVideoShow : function ( ) { } ,
89- onTweetsLoad : function ( ) { } ,
90- videojsCallback : function ( ) { }
90+ beforeEmbedJSApply : function ( ) { } ,
91+ afterEmbedJSApply : function ( ) { } ,
92+ onVideoShow : function ( ) { } ,
93+ onTweetsLoad : function ( ) { } ,
94+ videojsCallback : function ( ) { }
9195 } ;
9296
9397 class EmbedJS {
9498 constructor ( options , input ) {
9599 this . options = utils . deepExtend ( defaultOptions , options ) ;
96100 this . element = this . options . element || input ;
97- if ( ! this . element ) {
98- throw ReferenceError ( "You need to pass an element or the string that needs to be processed" ) ;
101+ if ( ! this . element ) {
102+ throw ReferenceError ( "You need to pass an element or the string that needs to be processed" ) ;
99103 }
100- this . input = this . element . innerHTML ;
104+ this . input = this . element . innerHTML ;
101105 }
102106
103107 /**
@@ -107,20 +111,21 @@ import helper from './modules/video/helper.es6';
107111 * @return {string } The processes resulting string
108112 */
109113 async process ( ) {
110- let input = this . input ;
111- let options = this . options ;
112- let embeds = [ ] ;
114+ let input = this . input ;
115+ let options = this . options ;
116+ let embeds = [ ] ;
113117
114118 this . options . beforeEmbedJSApply ( ) ;
115119
116- let output = options . link ? ( new Url ( input , options ) . process ( ) ) : output ;
117- output = options . emoji ? ( new Emoji ( output , options ) . process ( ) ) : output ;
118- output = options . fontIcons ? ( new Smiley ( output , options ) . process ( ) ) : output ;
120+ let output = options . link && build . LINK ? ( new Url ( input , options ) . process ( ) ) : output ;
121+ output = options . emoji && build . EMOJI ? ( new Emoji ( output , options ) . process ( ) ) : output ;
122+ output = options . fontIcons && build . SMILEY ? ( new Smiley ( output , options ) . process ( ) ) : output ;
119123 [ output , embeds ] = ( new Code ( input , output , options , embeds ) . process ( ) ) ;
120124 [ output , embeds ] = await ( new Video ( input , output , options , embeds ) . process ( ) ) ;
125+
121126 [ output , embeds ] = ( new Audio ( input , output , options , embeds ) . process ( ) ) ;
122127 [ output , embeds ] = ( new Image ( input , output , options , embeds ) . process ( ) ) ;
123- if ( options . tweetsEmbed ) {
128+ if ( options . tweetsEmbed && build . TWITTER ) {
124129 let twitter = new Twitter ( input , options , embeds ) ;
125130 embeds = options . tweetsEmbed ? await ( twitter . process ( ) ) : output ;
126131 }
@@ -143,12 +148,12 @@ import helper from './modules/video/helper.es6';
143148 let result = await this . process ( ) ;
144149 this . options . element . innerHTML = result ;
145150
146- if ( twttr ) {
147- //Load twitter data with styling
151+ if ( twttr && build . TWITTER ) {
152+ //Load twitter data with styling
148153 twttr . widgets . load ( this . options . element ) ;
149154
150155 //Execute the function after the widget is loaded
151- twttr . events . bind ( 'loaded' , ( ) => {
156+ twttr . events . bind ( 'loaded' , ( ) => {
152157 this . options . onTweetsLoad ( ) ;
153158 } ) ;
154159 }
@@ -165,7 +170,7 @@ import helper from './modules/video/helper.es6';
165170 * @param {Function } callback Function that is executed once the data is ready
166171 * @return { }
167172 */
168- async text ( callback ) {
173+ async text ( callback ) {
169174 let result = await this . process ( ) ;
170175 callback ( result ) ;
171176 }
0 commit comments