Enhance the impact of "dialogs" to the fullest extent or minimize it to achieve the

How can I position the minimized dialog on the bottom of the div when appending dialogs next to each other in a FB messaging system?

To achieve a Facebook messaging effect, the titlebar must go down when minimizing/maximizing the dialog. Perform the following steps: Open 2 or more dialogs by clicking the "create" button and then click on the titlebar.

Click couple times on "create" button

Answer №1

To maintain the same order when adding new popups, replace float: right with display: inline-block in the CSS for .private-section and use prepend() instead of append().

There is still an area at the bottom that requires handling when all popups are collapsed, but that's the general concept.

Private = {
count: 0,
windowsOpen: [],
closeDialog: function(evt){
evt.parent().parent().remove()
Private.removeFromArray(evt.parent().text())
},
    createDialog: function(nickname) {
        var dialog = $("#private-dialog"),
dialogCloseButton = $("<span />", {
class: "ct icon-cancel close-private-dialog"
}),
            dialogHeader = $("<div />", {
                class: "private-section"
            }),
            dialogInit = $("<div />", {
                class: "private-init",
                html: "Here will come the messages"
            }),
            dialogTitle = $("<div />", {
                class: "private-title",
                html: nickname
            });

dialogTitle.append(dialogCloseButton)
        dialogHeader.append(dialogTitle, dialogInit)
        dialog.prepend(dialogHeader)
    },
dialogChecker: function(nickname){
if(Private.windowsOpen.indexOf(nickname) === -1){
Private.windowsOpen.push(nickname)
Private.createDialog(nickname)
} else {
console.log("this dialog is already open")
}
},
dialogHandler: function(nickname){
Private.dialogChecker(nickname)
},
dialogSize: function(evt){
evt.next().toggle()
},
    events: function() {
    $("#create").on("click", function(){
        Private.openDialog()
        })
        $(document).on("click", ".close-private-dialog", function(){
Private.closeDialog($(this))
        })
        $(document).on("click", ".private-title", function(){
Private.dialogSize($(this))
        })
    },
    init: function() {
        Private.events()
    },
    openDialog: function(){
       var nick = "test" + Private.count;
        
        Private.dialogChecker(nick)
        
        Private.count++;
    },
removeFromArray: function(nickname){
if(Private.windowsOpen.indexOf(nickname) !== -1){
var index = Private.windowsOpen.indexOf(nickname);
Private.windowsOpen.splice(index, 1)
}
}
}

Private.init()
#main-container {
    position: absolute;
    border: 1px solid red;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

#private-dialog {
    position: absolute;
    bottom: 0;
    right: 0;
}

.private-section {
    display: inline-block;
    width: 7em;
    margin-left: 2px;
}

.private-title {
    background-color: #e01859;
    color: #FFF;
    padding: .5rem;
    border-radius: .3rem .3rem 0 0;
    box-shadow: 0px -2px 1px rgba(16, 13, 14, 0.39);
    cursor: pointer;
}

.private-init {
    background-color: #FFF;
    height: 5em;
    padding: 1em;
}

.private-section > .icon-cancel:before {
    float: right;
    margin-top: 2px;
}

.close-private-dialog {
    float: right;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="main-container">
    Click couple times on "create"  button
    <button id="create">
        create
    </button>
    <div id="private-dialog">
    </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieving data from an AJAX call and populating a knockout.js observableArray()

This phenomenon confuses me. There must be some small detail that I am missing here. My goal is to load a simple observableArray in knockout using an ajax call. javascript // We initialize the array with an empty array. var data = []; var viewModel = ...

What is the best way to extract information from a JSON XHR request and incorporate it into my template?

I am brand new to using Ember. Right now, my main goal is to connect to an API that provides random text and then show that text on a webpage. The specific API endpoint I am using is "" which will give back a response in JSON format. app/controllers/rando ...

Enhancing jQuery's ScrollTop Functionality

My jQuery script for scrolling to the top of a container seems to accelerate after it starts. It begins slowly and then speeds up. Is there a way to prevent this lag at the beginning and maintain a consistent speed throughout the entire scroll? // Once t ...

Ways to create distance between two Table Rows in Material-UI TableRow

const useRowStyles = makeStyles({ root: ({ open }) => ({ backgroundColor: open ? "#F5F6FF" : "white", backgroundOrigin: "border-box", spacing: 8, "& > *": { height: "64px", ...

MANDATORY activation of CONFIRMATION

Hello everyone, I'm seeking assistance with my code. Below is the form code I need help with: <form action="input.php" method="POST"> <input type="text" class="input" name="firstname" placeholder="First Name" required> <input t ...

Is there an easier method to utilize ES6's property shorthand when passing an object in TypeScript, without needing to prefix arguments with interface names?

When working with JavaScript, I often find myself writing functions like the one below to utilize ES6's property shorthand feature: function exampleFunction({param1, param2}) { console.log(param1 + " " + param2); } //Usage: const param1 = "param1" ...

Issues with the disappearance of elements when using the Toggle() function

I've created a toggle feature for displaying a sub menu (.li-one) when clicking on the main menu (.ul-one). The issue arises when you click on another menu item, as the previous one does not disappear unless you click outside of the .main-nav div. Is ...

Customizing the color of pagination in Bootstrap

Here is the pagination control I am working on: https://i.sstatic.net/iVufm.png I have been trying to change the color of the pagination labels to purple, but my CSS overrides are not working. Here is what I currently have in my stylesheet: /* Paginatio ...

Error in Laravel Mix Vuejs component: Syntax problem detected in <template />

My development environment involves Windows 10 OS and I have created a Laravel 8 project integrated with VueJs. However, when I try to access the file ./components/app.vue, it returns a SyntaxError: Unexpected token (1:0) The content of the app.vue file i ...

Surprising outcome when attempting to load a partial view into an Internet Explorer 8 DOM using jQuery Ajax

Encountering a peculiar issue while loading a Partial View with jQuery Ajax in IE8. The result appears distorted when viewed using this browser. The hypothetical Partial View causing trouble looks like this: <aside>Example test</aside> After ...

Select information from an array and store it within an object

I want to extract all objects from an array and combine them into a single object. Here is the current array data: userData = [ {"key":"firstName","checked":true}, {"key":"lastName","checked":true ...

The behavior of -webkit-border-radius differs from that of -moz-border-radius

My website is displaying differently on Safari compared to Firefox. I want the CSS to make it look consistent across both browsers. I understand that I could use two div boxes - one for the outline and one for the image. However, I prefer how Firefox only ...

Utilize jQuery to dynamically swap out a CSS stylesheet in response to changes in the body class

In the head section of my HTML, I have the following stylesheet: <link rel="stylesheet" href="/templates/jooswatch-v3-5/css/bootswatch/superhero/bootstrap.min.css"> I want to replace this stylesheet with different ones based on changes in the body# ...

Managing numerous API requests in React Native

As I work on implementing a search field, I've encountered a challenge. Whenever a user enters text in the search field, a timer resets to 300 ms before an API call is sent to fetch autocomplete results. After receiving these results, the app then wai ...

Stable navigation bar implemented with a grid design

I'm struggling with creating Navbars in Grid Layout. https://codepen.io/Aeshtray/pen/BdqeZL For mobile view, I want the Navbar to be fixed horizontally (as currently coded), but once reaching a width of 500px, I need it to become vertically fixed on ...

Utilizing Javascript Regular Expressions to extract specified parameters from URLs with specific patterns

I am facing a specific issue with pure vanilla javascript. My task is to extract the values of A, B & C from various URL patterns, excluding any instances where the value is "XX". A, B, and C are static words that can appear in different positions wit ...

Struggling to iterate through the children of a variable with the help of express-handlebars?

Currently, I am in the process of developing an application using Javascript along with express, express-handlebars, and MySQL. One of my main tasks is to establish a route that follows the pattern '/viewowner/:ID/scoreboards/:year' where ID sig ...

execute a rigorous compilation during the ng build angular process

I am currently working on a project using angular-cli and I have configured my package.json with the following scripts: "scripts": { "ng": "ng", "build": "ng build --base-href /test/", "prod": "ng build --prod --base-href /test/" } According to the ...

What is the best jQuery event or method to use for attaching functionality to a dynamic button before it is clicked?

My goal is to connect a jQuery plugin to a button that is dynamically generated. I have attempted the following without success: $('.myButton').on('click', function() { $(this).file().choose(function(e, input) { // ... ...

Error -1 with JSON key

I've been tirelessly seeking the solution to this issue, but it eludes me. My goal is to retrieve the value by index of a JSON string. Despite the matching key, I'm getting -1 for the index. All I want is the value "Ethan" for the key username. ...