2222 * - Theme manager // this.theme = "dark";
2323 * - CSS loading
2424 *
25- * Update: 18/03/21 Current V.0.4
25+ * Update: 04/09/22 Current V.1.0
2626 * ----------------------------------------------------------------------------------------------------
2727 */
2828
@@ -41,8 +41,6 @@ class Messenger{
4141 //create the messenger container
4242 this . container = container ;
4343 this . id = this . generateId ( "messenger" ) ;
44-
45- //$(this.container).append(`<ul id="${this.id}" class="messenger"><li class="user sender receiver hidden"></li></ul>`);
4644
4745 this . containerEl = document . querySelector ( this . container ) ;
4846 document . querySelector ( this . container ) . insertAdjacentHTML ( 'beforeend' , `<ul id="${ this . id } " class="messenger"><li class="user sender receiver hidden"></li></ul>` ) ;
@@ -51,11 +49,19 @@ class Messenger{
5149
5250 this . manager = new Manager ( ) ;
5351
54- this . speed = speed ; //TODO setter speed //Change speed to delay ?
52+ this . speed = speed ;
5553 this . scrollSpeed = ( this . speed > 100 ? this . speed - 50 : 50 ) ;
5654
5755 this . automaticScroll = automaticScroll ;
5856
57+ //Importe CSS file
58+ const link = document . createElement ( 'link' ) ;
59+ link . rel = 'stylesheet' ;
60+ link . type = 'text/css' ;
61+ link . href = 'https://robert.data.bingo/tools/messenger/dist/messenger.min.css' ;
62+ link . media = 'all' ;
63+ document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( link ) ;
64+
5965 this . remove = {
6066 /**
6167 * Remove loading message
@@ -132,18 +138,9 @@ class Messenger{
132138 const self = this ;
133139 this . manager . enqueue ( ( ) => {
134140 self . remove . loader ( ) ;
135- if ( message ) {
136-
137- //$('#'+self.id).append(message);
138- this . messengerEl . insertAdjacentHTML ( 'beforeend' , message ) ;
139-
140- }
141- if ( self . automaticScroll ) {
142- self . smoothScroll ( ) ;
143- }
144- if ( callback instanceof Function ) {
145- callback ( ) ;
146- }
141+ if ( message ) self . messengerEl . insertAdjacentHTML ( 'beforeend' , message ) ;
142+ if ( self . automaticScroll ) self . smoothScroll ( ) ;
143+ if ( callback instanceof Function ) callback ( ) ;
147144 } , this . speed ) ;
148145 }
149146
@@ -157,7 +154,6 @@ class Messenger{
157154 * Surround a message with a li element and the user class
158155 *
159156 * @param {String } msg The HTML message content
160- *
161157 * @return {String } A surrounded message
162158 *
163159 */
@@ -169,7 +165,6 @@ class Messenger{
169165 * Add a comment (or not)
170166 *
171167 * @param {String } comment Optional comment of the message
172- *
173168 * @return {String } Comment HTML element
174169 *
175170 */
@@ -215,10 +210,7 @@ class Messenger{
215210 */
216211 update ( el , type , options , { comment, callback} = { comment : null , callback : null } ) {
217212 if ( type == "text" ) {
218-
219- //$(el).html(options);
220213 el . innerHTML = options ;
221-
222214 if ( comment ) {
223215 //TO ADD
224216 //$(el).parent().append(this.comment(comment));
@@ -622,9 +614,8 @@ class Messenger{
622614 ) ;
623615 }
624616
625- //TODO
626617 /**
627- * Create a image message from a video element
618+ * TO IMPROVE : Create a image message from a video element
628619 *
629620 * @param {Html element } video
630621 *
0 commit comments