Skip to content

Commit

Permalink
add modal window
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightDanila committed Jun 10, 2016
1 parent b18a6e7 commit ee1538f
Show file tree
Hide file tree
Showing 7 changed files with 402 additions and 5 deletions.
Binary file added favicon.ico
Binary file not shown.
54 changes: 49 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>three.js webgl - io - scene loader</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">

<link rel="icon" href="favicon.ico">
<!-- jQuery -->


Expand All @@ -21,6 +21,16 @@
<link href="js_css/toolBar/headerWhiteStyle.css" rel="stylesheet" type="text/css"/>
-->
<link href="js_css/toolBar/headerDarkStyle.css" rel="stylesheet" type="text/css"/>

<!-- MODAL WINDOW -->
<!--
<link rel="stylesheet" href="js_css/modelWindow/modelWindowWhite.css">
-->
<link rel="stylesheet" href="js_css/modalWindow/modalWindowDark.css">
<link rel="stylesheet" href="js_css/modalWindow/modalWindow.css">
<link rel="stylesheet" href="js_css/modalWindow/modalWindowStyles.css">
<script src="js_css/modalWindow/modalWindow.js"></script>

</head>

<body>
Expand All @@ -33,8 +43,8 @@
<ul>
<li><a class="header-item" href="http://fpm.dnu.dp.ua/">ФПМ</a></li>
<li><a class="header-item" href="docs/Diploma_Egoshkin_v0.1.docx">Текст Диплома</a></li>
<li><a class="header-item" href="http://www.w3.org/Consortium/siteindex">Параметры</a></li>
<li class="last-item"><a class="header-item" href="http://www.w3.org/Consortium/new-to-w3c">О Проекте</a></li>
<li><a class="header-item" href = "#" id="Settings">Параметры</a></li>
<li class="last-item"><a class="header-item" href="#" id="About">О Проекте</a></li>
</ul>
</div>
<div id="progress">
Expand All @@ -49,6 +59,40 @@
</center>
</div>

<!-- The Modal Settings -->
<div id="MWSettings">
<!-- Modal content -->
<div id = "MWSettingsContent">
<div id = "MWSettingsClose">X</div>
<p>Этот пункт находится в разработке :)</p>
</div>
</div>
<script>
modalWindowInitFullBG("MWSettings", "MWSettingsContent", "MW-content-fpm3d", "Settings", "MWSettingsClose", "MW-close-btn-fpm3d", 1);
</script>
<!-- The Modal -->
<div id="MWAbout">
<!-- Modal content About -->
<div id = "MWAboutContent">
<div id = "MWAboutClose">X</div>
<div style="text-align: left">
<h1>О проекте</h1>
<h3>Дипломная работа</h3>
<div>Студента 4 курса</div>
<div>Егошкина Данилы Игоревича</div>
<div>Руководитель дипломной работы:</div>
<div>Гук Наталия Анатольевна, доктор физико-математических наук, профессор.</div>
<br>
<br>
<br>
<br>
<div>Факультет Прикладной Математики</div>
</div>
</div>
</div>
<script>
modalWindowInitFullBG("MWAbout", "MWAboutContent", "MW-content-fpm3d", "About", "MWAboutClose", "MW-close-btn-fpm3d", 1);
</script>

<script src="js/libs/jquery/jquery.js"></script>
<script src="js_css/loadingStatusBarCircle/loadingStatusBarCircle.js"></script>
Expand Down Expand Up @@ -201,7 +245,7 @@
THREE.Loader.Handlers.add(/\.dds$/i, new THREE.DDSLoader());

var loader = new THREE.SceneLoader();

loader.addGeometryHandler("binary", THREE.BinaryLoader);
loader.addGeometryHandler("ctm", THREE.CTMLoader);
loader.addGeometryHandler("vtk", THREE.VTKLoader);
Expand Down Expand Up @@ -243,7 +287,7 @@
///////////// LoadFunction /////////////////////////////////////////////

function createLoadScene() {

var result = {
scene: new THREE.Scene(),
camera: new THREE.PerspectiveCamera(80, window.innerWidth / window.innerHeight, 1, 1000)
Expand Down
24 changes: 24 additions & 0 deletions js_css/modalWindow/modalWindow.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : 11.06.2016, 1:27:54
Author : KnightDanila
*/

/* The Modal (background) */
.modal-window {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1000; /* Sit on top */
padding-top: 7%; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color Black */
background-color: rgba(0,0,0,0.4); /* If opacity work it will be like gloss*/
}
153 changes: 153 additions & 0 deletions js_css/modalWindow/modalWindow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
How to use it:
IN HTML
<!-- Trigger/Open The Modal -->
<button id="myBtn">Open Modal</button>
<!-- The Modal -->
<div id="myModal">
<!-- Modal content -->
<div id = "modalContent">
<div id = "close">X</div>
<p>Some text in the Modal..</p>
</div>
</div>
THEN IN JS
modalWindowInit("myModal", "modalContent", "myBtn", "close");
modalWindowTotalCloseBackground();
modalWindowAddCloseElemStyle("close", "MW-close-btn-fpm3d-dark");
modalWindowAddContentStyle("modalContent", "MW-content-fpm3d-dark");
ALSO NEED
<link rel="stylesheet" href="js/modelWindow/modelWindow.css">
<link rel="stylesheet" href="js/modelWindow/modelWindowStyles.css">
<script src="js/modelWindow/modelWindow.js"></script>
**/


// One global weriable
var MW_OPEN_ONCE = 0;
// Create from simple objects a modal windows. Itself adds styles
function modalWindowInit(winElemID, winElemContentID, openElemID, closeElemID) {
// Get the modal
var modal = document.getElementById(winElemID);
// Get the button that opens the modal
var btn = document.getElementById(openElemID);
// Get the <span> element that closes the modal
var span = document.getElementById(closeElemID);
// Get the modal content
var content = document.getElementById(winElemContentID);

content.className += "MW-content-simple";
modal.className += "modal-window";
span.className += "MW-close-btn-simple";
// When the user clicks the button, open the modal
btn.onclick = function () {
modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
MW_OPEN_ONCE = 1;
}

content.onclick = function () {
MW_OPEN_ONCE = 1;
}
}
function modalWindowInitFull(winElemID, winElemContentID, winElemContentStyle,
openElemID, closeElemID, closeElemStyle) {
// Get the modal
var modal = document.getElementById(winElemID);
// Get the button that opens the modal
var btn = document.getElementById(openElemID);
// Get the <span> element that closes the modal
var span = document.getElementById(closeElemID);
// Get the modal content
var content = document.getElementById(winElemContentID);

modal.className += "modal-window";
content.className += winElemContentStyle;
span.className += closeElemStyle;
// When the user clicks the button, open the modal
btn.onclick = function () {
modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
MW_OPEN_ONCE = 1;
}

content.onclick = function () {
MW_OPEN_ONCE = 1;
}
}
function modalWindowInitFullBG(winElemID, winElemContentID, winElemContentStyle,
openElemID, closeElemID, closeElemStyle, useBackgroundClose) {
// Get the modal
var modal = document.getElementById(winElemID);
// Get the button that opens the modal
var btn = document.getElementById(openElemID);
// Get the <span> element that closes the modal
var span = document.getElementById(closeElemID);
// Get the modal content
var content = document.getElementById(winElemContentID);

modal.className += "modal-window";
content.className += winElemContentStyle;
span.className += closeElemStyle;
// When the user clicks the button, open the modal
btn.onclick = function () {
modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
MW_OPEN_ONCE = 1;
}

content.onclick = function () {
MW_OPEN_ONCE = 1;
}
if (useBackgroundClose) {
modal.onclick = function () {
if (MW_OPEN_ONCE == 0) {
modal.style.display = "none";
}
MW_OPEN_ONCE = 0;
}
}
}
// Add style function NEED TO TEST
function modalWindowAddCloseElemStyle(closeElemID, ClassName) {
var span = document.getElementById(closeElemID);
span.className += " " + ClassName;
}
function modalWindowAddContentStyle(contentElemID, ClassName) {
var content = document.getElementById(contentElemID);
content.className += " " + ClassName;
}
// When the user clicks anywhere outside of the modal, close it NEED TO TEST - can shake all names and other
function modalWindowTotalCloseBackground() {
var total = document.getElementsByClassName("modal-window").length;
var modal;
for (var i = 0; i < total; i++) {
model = document.getElementsByClassName("modal-window")[i];
modal.onclick = function () {
if (MW_OPEN_ONCE == 0) {
modal.style.display = "none";
}
MW_OPEN_ONCE = 0;
}
}
}
35 changes: 35 additions & 0 deletions js_css/modalWindow/modalWindowDark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : 11.06.2016, 1:29:17
Author : KnightDanila
*/

.MW-content-fpm3d{
background-color: rgb(27, 28, 31);
margin: auto;
padding: 20px;
border: 1px solid #0FF;
width: 80%;
height: 70%;
color: white;
-webkit-box-shadow: 0px 8px 56px 4px rgba(0,255,255,0.75);
-moz-box-shadow: 0px 8px 56px 4px rgba(0,255,255,0.75);
box-shadow: 0px 8px 56px 4px rgba(0,255,255,0.75);
}
/* The Close Button */
.MW-close-btn-fpm3d{
color: #fff;
float: right;
font-size: 28px;
font-weight: bold;
}
.MW-close-btn-fpm3d:hover,
.MW-close-btn-fpm3d:focus {
color: #0ff;
text-decoration: none;
cursor: pointer;
}
Loading

0 comments on commit ee1538f

Please sign in to comment.