Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. renderInbox: function() {
  2.         // The same code, but using ES6 Promises.
  3.         localforage.iterate(function (value, key, iterationNumber) {
  4.             // Resulting key/value pair -- this callback
  5.             // will be executed for every item in the
  6.             // database.  
  7.             if(value.type == 'task') {
  8.                 var priority;
  9.                 if(value.priority === 'low') {
  10.                     priority = '<i class="far fa-circle" id="inbox-circle" style="color:blue"></i>'
  11.                 } else if(value.priority === 'medium') {
  12.                     priority = '<i class="far fa-circle" id="inbox-circle" style="color:yellow"></i>'
  13.                 } else {
  14.                     priority = '<i class="far fa-circle" id="inbox-circle" style="color:blue"></i>'
  15.                 }
  16.                 var inboxEl = document.getElementById('inbox');
  17.                 inboxEl.insertAdjacentHTML('beforeend', `<div class="row inbox-item">
  18.                                                             <div class="col-2 col-lg-2 d-flex align-items-center">
  19.                                                                 ${priority}
  20.                                                             </div>
  21.                                                             <div class="col-4 col-lg-6">${value.text}</div>
  22.                                                             <div class="col-4 col-lg-2">${value.dueDate}</div>
  23.                                                             <div class="col-2 col-lg-2 task-actions">
  24.                                                                 <i class="fas fa-ellipsis-h"></i>
  25.                                                             </div>
  26.                                                         </div>`);
  27.                
  28.             }
  29.                    
  30.         }).then(function () {
  31.             var matches = document.querySelectorAll(".fa-circle");
  32.             console.log(matches);
  33.             var i;
  34.             for (i = 0; i < matches.length; i++) {
  35.                 matches[i].addEventListener('mouseover', mouseOverEffect);      
  36.            
  37.             //x[0].innerHTML = '<i class="far fa-check-circle"></i>'
  38.             }
  39.             function mouseOverEffect() {
  40.                 //JQUERY, FIND A VANILLA JS SOLUTION?
  41.                 $("#inbox-circle").mouseover(function() {                    
  42.                     console.log($(this).hasClass('fa-circle'))
  43.                     if ($(this).hasClass('fa-circle')) {                                              
  44.                         $(this).removeClass( "fa-circle" ).addClass( "fa-check-circle" )
  45.  
  46.                     }
  47.                 });
  48.             }
  49.             return
  50.         }).catch(function (err) {            
  51.             console.log(err);
  52.         });
  53.         var collection = document.getElementsByClassName("fa-circle");        
  54.         var collectionArray = Array.from(collection)    
  55.        
  56.         for (var i = 0; i < collection.length; i++) {
  57.             collection[i].addEventListener('mouseover', mouseOverEffect);    
  58.      
  59.         }
  60.        
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement