forked from alan-wu/MPB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
206 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="portalGridView"> | ||
<div class="portalGridViewContainer"> | ||
<div class="Row"> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.portalGridView { | ||
position:absolute; | ||
/* Full height */ | ||
height: 100%; | ||
left:12%; | ||
width:88%; | ||
/* Center and scale the image nicely */ | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
overflow-y:hidden; | ||
z-index:1; | ||
} | ||
.portalGridView .Row { | ||
display: grid; | ||
width: 100%; /*Optional*/ | ||
border-spacing: 10px; /*Optional*/ | ||
grid-template-columns: auto auto; | ||
} | ||
.portalGridView .Row .Column { | ||
transition: transform .2s; | ||
background: rgba(1,1,1,0); | ||
} | ||
|
||
.portalGridViewContainer { | ||
width:100%; | ||
height:100%; | ||
z-index:1; | ||
text-align: center; | ||
position: absolute; | ||
overflow-y:auto; | ||
} | ||
|
||
@media only screen and (max-width: 600px) { | ||
.portalGridView .Row { | ||
grid-template-columns: auto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
require("../styles/gridView.css") | ||
var ResizeSensor = require('css-element-queries/src/ResizeSensor'); | ||
|
||
exports.GridView = function(containerIn) { | ||
var container = containerIn; | ||
var parent = undefined; | ||
var rowElement = undefined; | ||
var template = require("../snippets/gridView.html"); | ||
var _this = this; | ||
var dialogs = []; | ||
var sensor = undefined; | ||
this.isEnabled = false; | ||
|
||
this.enable = function(managerItems) { | ||
if (_this.isEnabled == false) { | ||
parent[0].style.display = "block"; | ||
_this.isEnabled = true; | ||
for (var i = 0; i < managerItems.length; i++) { | ||
_this.addManagerItem(managerItems[i]); | ||
} | ||
} | ||
} | ||
|
||
this.disable = function() { | ||
parent[0].style.display = "none"; | ||
_this.isEnabled = false; | ||
for (var i = 0; i < dialogs.length; i++) { | ||
dialogs[i].undock(); | ||
} | ||
dialogs = []; | ||
rowElement.innerHTML = ""; | ||
} | ||
|
||
var getNewItemContainer = function() { | ||
var itemTemplate = '<div class="Column"><div class="itemContainment" style="height:800px;"></div></div>'; | ||
var item = $(itemTemplate); | ||
var itemContainment = item.find(".itemContainment")[0]; | ||
rowElement.appendChild(item[0]); | ||
return itemContainment; | ||
} | ||
|
||
var removeContainer = function(containment) { | ||
if (containment.parentNode.parentNode === rowElement) { | ||
rowElement.removeChild(containment.parentNode); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
var updateSize = function() { | ||
if (_this.isEnabled) { | ||
for (var i = 0; i < dialogs.length; i++) { | ||
dialogs[i].setWidth("100%"); | ||
dialogs[i].setHeight("100%"); | ||
} | ||
} | ||
} | ||
|
||
this.addManagerItem = function(item) { | ||
if (_this.isEnabled) { | ||
var dialog = item.getDialog(); | ||
if (dialog && (dialogs.includes(dialog)== false)) { | ||
var containment = getNewItemContainer(); | ||
dialog.dockToContainment(containment); | ||
dialogs.push(dialog); | ||
updateSize(); | ||
} | ||
} | ||
} | ||
|
||
|
||
var removeDialog = function(dialog) { | ||
if (dialog && (dialogs.includes(dialog) == true)) { | ||
var containment = dialog.getContainment(); | ||
if (removeContainer(containment)) { | ||
dialog.undock(); | ||
var index = dialogs.indexOf(dialog); | ||
if (index > -1) { | ||
dialogs.splice(index, 1); | ||
} | ||
updateSize(); | ||
} | ||
} | ||
} | ||
|
||
this.removeManagerItem = function(item) { | ||
var dialog = item.getDialog(); | ||
removeDialog(dialog); | ||
} | ||
|
||
var resize = function() { | ||
return function() { | ||
updateSize(); | ||
} | ||
} | ||
|
||
var setup = function() { | ||
parent = $(template); | ||
rowElement = parent.find(".Row")[0]; | ||
container.appendChild(parent[0]); | ||
parent.find(".portalGridViewContainer")[0].onscroll = resize(); | ||
sensor = new ResizeSensor(parent[0], resize()); | ||
} | ||
|
||
setup(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters