Advertisement
lemansky

Untitled

Nov 13th, 2020
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.28 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Document</title>
  6.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
  7.     <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
  8.     <script>
  9.         document.addEventListener('DOMContentLoaded', function(event){
  10.             clean(document.body);
  11.  
  12.             let _buttons = document.getElementsByClassName('texts');
  13.             for (let index = 0; index < _buttons.length; index++) {
  14.                _buttons[index].addEventListener('click', function(){
  15.                    let _position = this.dataset.text;
  16.                    let _box = document.getElementById('position-text');
  17.                    
  18.                    // _box.classList.remove("text-" + _box.dataset.old);
  19.                    // _box.dataset.old = this.dataset.text;
  20.                    let _arrClasses = _box.className.split(" ");
  21.                    if(_arrClasses.length > 1){
  22.                       _box.classList.remove(_arrClasses[1]);
  23.                     }
  24.                    
  25.                     _box.classList.add("text-" + this.dataset.text);
  26.  
  27.                     let _active = document.getElementsByClassName('active');
  28.                     _active[0].classList.remove('active');
  29.                     this.classList.add('active');
  30.                 });
  31.             }
  32.  
  33.         });
  34.         const clean = (node) =>
  35.         {
  36.           for(var n = 0; n < node.childNodes.length; n ++)
  37.          {
  38.            var child = node.childNodes[n];
  39.            if
  40.            (
  41.              child.nodeType === 8
  42.              ||
  43.              (child.nodeType === 3 && !/\S/.test(child.nodeValue))
  44.            )
  45.            {
  46.              node.removeChild(child);
  47.              n --;
  48.            }
  49.            else if(child.nodeType === 1)
  50.            {
  51.              clean(child);
  52.            }
  53.          }
  54.        }
  55.     </script>
  56.     <style>
  57.         .disabled {
  58.             cursor: not-allowed;
  59.             background: #dddddd;
  60.             pointer-events:none;
  61.         }
  62.     </style>
  63. </head>
  64. <body>
  65.     <div class="container" style="margin-top:20px;margin-bottom:20px">
  66.         <div class="col-lg-6 col-md-6">
  67.             <div class="card">
  68.               <div class="card-heading p-2 bg-primary">Panel Heading</div>
  69.               <div class="card-body js-animation text-center" id="position-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</div>
  70.             </div>
  71.             <div class="col-md-offset-3 col-lg-offset-3">
  72.             <input type="button" class="texts btn btn-light active" value="Ляво" data-text="left">
  73.             <input type="button" class="texts btn btn-light " value="Център" data-text="center">
  74.             <input type="button" class="texts btn btn-light " value="Дясно" data-text="right">
  75.            
  76.         </div>
  77.         </div>
  78.  
  79.     </div>
  80.  
  81. </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement