Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <style>
- * {
- box-sizing: border-box;
- }
- .wrapper {
- position: relative;
- width: 20em;
- z-index: 9;
- background-color: #f1f1f1;
- border: 1px solid #d3d3d3;
- border-radius: 2%;
- box-sizing: border-box;
- }
- .wrapper > div {
- border-radius: 5px;
- padding: 2px;
- }
- .wrapper {
- display: grid;
- grid-template-columns: repeat(3, 1fr);
- grid-gap: 10px;
- grid-auto-rows: minmax(50px, auto);
- }
- .output {
- grid-column: 3 / 4;
- grid-row: 2 / 3;
- }
- .timers {
- margin-right: 5px;
- position: absolute;
- bottom:0px;
- right: 0px;
- grid-column: 3 / 4;
- grid-row: 3 / 5;
- }
- .timer,
- .date {
- width: 150px;
- }
- .inputs {
- width:100px;
- grid-column: 1/3;
- grid-row: 2 / 5;
- }
- .header {
- text-align: center;
- cursor: move;
- background-color: #2196F3;
- color: #fff;
- grid-column: 1/4;
- grid-row: 1 / 2;
- }
- a {
- text-decoration: none;
- }
- .output-dropdown{
- position: relative;
- display: inline-block;
- text-align: left;
- width: 150px;
- }
- .dropdown {
- position: relative;
- display: inline-block;
- text-align: left;
- width: 100%;
- margin-bottom: 30px;
- }
- .dropdown-text {
- cursor: pointer;
- position: absolute;
- text-indent: 10px;
- line-height: 32px;
- background-color: #eee;
- border: 1px solid #ccc;
- border-radius: 3px;
- box-shadow: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 1px 3px rgba(0, 0, 0, .1);
- width: 100%;
- }
- .dropdown-text:after {
- position: absolute;
- right: 6px;
- top: 15px;
- content: '';
- width: 0px;
- height: 0px;
- border-style: solid;
- border-width: 5px 4px 0 4px;
- border-color: #555 transparent transparent transparent;
- }
- .dropdown-text,
- .dropdown-content a {
- color: #333;
- text-shadow: 0 1px #fff;
- }
- .dropdown-toggle {
- font-size: 0;
- z-index: 1;
- cursor: pointer;
- position: absolute;
- top: 0;
- border: none;
- padding: 0;
- margin: 0 0 0 1px;
- background: transparent;
- text-indent: -10px;
- height: 34px;
- width: 100%;
- }
- .dropdown-toggle:focus {
- outline: 0;
- }
- .dropdown-content {
- -webkit-transition: all .25s ease;
- -moz-transition: all .25s ease;
- -ms-transition: all .25s ease;
- -o-transition: all .25s ease;
- transition: all .25s ease;
- list-style-type: none;
- position: absolute;
- top: 32px;
- padding: 0;
- margin: 0;
- opacity: 0;
- visibility: hidden;
- border-radius: 3px;
- text-indent: 10px;
- line-height: 32px;
- background-color: #eee;
- border: 1px solid #ccc;
- width: 140px;
- z-index: 50;
- }
- .dropdown-content a {
- display: block;
- }
- .dropdown-content a:hover {
- background: #e8e8e8;
- }
- .dropdown-toggle:hover ~ .dropdown-text,
- .dropdown-toggle:focus ~ .dropdown-text {
- background-color: #e8e8e8;
- }
- .dropdown-toggle:focus ~ .dropdown-text {
- box-shadow: 0 1px 3px rgba(0, 0, 0, .2) inset, 0 1px 0 rgba(255, 255, 255, 0.8);
- z-index: 2;
- }
- .dropdown-toggle:focus ~ .dropdown-text:after {
- border-width: 0 4px 5px 4px;
- border-color: transparent transparent #555 transparent;
- }
- .dropdown-content:hover,
- .dropdown-toggle:focus ~ .dropdown-content {
- opacity: 1;
- visibility: visible;
- top: 42px;
- }
- .savebtn{
- background-color: rgba(68, 243, 33, 0.459);
- color: #fff;
- }
- </style>
- <body onload="GenerateBlocks()">
- <div id="canvas"><button onclick="GenerateBlocks()">Generate Block</button></div>
- </body>
- <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
- <script>
- function dragElement(elmnt) {
- var pos1 = 0,
- pos2 = 0,
- pos3 = 0,
- pos4 = 0;
- if (document.getElementById(elmnt.id + "header")) {
- document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
- }
- function dragMouseDown(e) {
- e = e || window.event;
- e.preventDefault();
- pos3 = e.clientX;
- pos4 = e.clientY;
- document.onmouseup = closeDragElement;
- document.onmousemove = elementDrag;
- }
- function elementDrag(e) {
- e = e || window.event;
- e.preventDefault();
- pos1 = pos3 - e.clientX;
- pos2 = pos4 - e.clientY;
- pos3 = e.clientX;
- pos4 = e.clientY;
- elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
- elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
- }
- function closeDragElement() {
- document.onmouseup = null;
- document.onmousemove = null;
- }
- }
- var GlobalID = 0;
- var GlobalBlockArray = [];
- function GenerateBlocks() {
- var OutputOptions = 5;
- var InputOptions = 5;
- var Inputs;
- Block = '<div id="Movable';
- Block += GlobalID;
- Block += '" class="wrapper">' +
- '<div class="output">' +
- '<div class="output-dropdown">' +
- '<input class="dropdown-toggle" type="text">' +
- '<div class="dropdown-text">Output</div>' +
- '<ul class="dropdown-content">';
- for (k = 0; k < OutputOptions; k++) {
- Block += '<li><a id="';
- Block += k;
- Block += '"href="#">Output';
- Block += k;
- Block += '</a></li>';
- }
- Block += '</ul>' +
- '</div>' +
- '</div>' +
- '<div class="timers">' +
- '<input class="timer" type="text" placeholder="timer">' +
- '<input class="date" type="datetime-local" id="myLocalDate" step="2">' +
- '</div>' +
- '<div class="inputs">';
- for (i = 0; i < 6; i++) {
- Inputs = '<div id="Dropdown';
- Inputs += i;
- Inputs += '"class="dropdown">' +
- '<input class="dropdown-toggle" type="text">' +
- '<div class="dropdown-text">Input</div>' +
- '<ul class="dropdown-content">';
- for (b = 0; b < InputOptions; b++) {
- Inputs += '<li><a id="';
- Inputs += (b + 10);
- Inputs += '"href="#">Input';
- Inputs += (b + 10);
- Inputs += '</a></li>';
- }
- Inputs += '</ul></div>';
- Block += Inputs;
- }
- Block += '</div>' +
- '<div id="Movable';
- Block += GlobalID;
- Block += 'header" class="header">' +
- 'Itt mozgathatod<br>' +
- '<button class="savebtn">Save</button>' +
- '</div>' +
- '</div>' +
- '</div>';
- document.getElementById("canvas").innerHTML += Block;
- GlobalBlockArray.push("Movable" + GlobalID);
- for(l = 0;l< GlobalBlockArray.length; l++){
- dragElement(document.getElementById(GlobalBlockArray[l]));
- }
- $('.savebtn').on('click', function() {
- var parent_id = $(this).parent().parent();
- console.log(parent_id);
- })
- GlobalID++;
- }
- </script>
- </html>
Add Comment
Please, Sign In to add comment