1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-12 13:34:29 +01:00

Nuweb drop

Signed-off-by: root <root@tdm-cloud.(none)>
This commit is contained in:
root 2019-03-09 12:32:11 +01:00
parent ee9a720f67
commit a7b55553ad
62 changed files with 1772 additions and 608 deletions

332
assets/nuweb/mdlio-app.css Executable file
View file

@ -0,0 +1,332 @@
@font-face {
font-family: "Material Design Icons";
src: url("https://cdn.materialdesignicons.com/1.9.32/fonts/materialdesignicons-webfont.eot?v=1.9.32");
src: url("https://cdn.materialdesignicons.com/1.9.32/fonts/materialdesignicons-webfont.eot?#iefix&v=1.9.32") format("embedded-opentype"), url("https://cdn.materialdesignicons.com/1.9.32/fonts/materialdesignicons-webfont.woff2?v=1.9.32") format("woff2"), url("https://cdn.materialdesignicons.com/1.9.32/fonts/materialdesignicons-webfont.woff?v=1.9.32") format("woff"), url("https://cdn.materialdesignicons.com/1.9.32/fonts/materialdesignicons-webfont.ttf?v=1.9.32") format("truetype"), url("https://cdn.materialdesignicons.com/1.9.32/fonts/materialdesignicons-webfont.svg?v=1.9.32#materialdesigniconsregular") format("svg");
font-weight: normal;
font-style: normal;
}
.item .mdl-card_title {
padding: 8px;
width: calc( 100% - 16px );
}
.item .mdl-card__title-text {
text-decoration:none;
font-family: "Roboto","Helvetica","Arial",sans-serif
}
.item.type-image.thumb .card-no-media {
display:none;
}
.item.type-image.thumb:hover .card-no-media {
display:block;
}
.item.type-person.thumb .card-title-wrapper {
height:0px;
position:relative;
overflow:visible;
}
.item .card-title-body {
width: 100%;
}
.item.type-person.thumb .card-title-body,
.item.type-image.thumb .card-title-body {
background: rgba(0,0,0,0.25);
color: #fff;
text-shadow: 0px 0px 7px rgba(0, 0, 0, 1);
bottom: 0px;
position: absolute;
}
.item.type-image.thumb .card-title-body {
display:none;
}
.item.type-person:hover .card-title-body,
.item.type-image:hover .card-title-body {
display: block;
}
input.material-icons[type="submit"] {
font-family: "Material Icons";
}
.file .mdl-card_title-text {
word-break:break-all;
}
.file .title:before {
font-family: "Material Design Icons";
margin-right:8px;
content: "\f214";
}
.file.type-directory .title:before {
content: "\f24b";
}
.file.type-person .title:before {
content: "\f004";
}
.file.type-image .title:before {
content: "\f21f";
}
.file.type-video .title:before {
content: "\f22b";
}
.file[data-mime="application/pdf"] .title:before {
content: "\f225"
}
.item .mdl-card.as-dialog {
position:fixed;
display:block;
top:100px;
/* max-width: 960px; */
width: calc( 100% - 140px);
height: calc( 100% - 140px);
z-index:6;
}
.item .mdl-card.as-dialog:before {
position:fixed;
display:block;
top:0px;
left:0px;
background:#000;
width:10%;
height:10%;
z-index:5;
content:"";
}
.selection-bar {
display:block !important;
opacity:0;
transform: translateY(-70px);
}
.selection-bar,
.selection-bar .mdl-layout__drawer-button {
color:rgba(0,0,0,.87);
}
.selection-mode .selection-bar {
display:block;
transform: translateY(0px);
opacity:1;
}
.selection-mode .selectable .action.select,
.selectable:hover .action.select {
display:block;
opacity:1;
}
.selectable>.action.select {
position:absolute;
left:-8px;
top:-12px;
background: #fff;
border-radius: 50%;
width:24px;
height:24px;
min-width:24px;
box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12);
z-index: 2;
/*display:none;*/
opacity:0;
}
.selection-bar,
.selectable .action.select {
transition: transform 0.3s ease, opacity 0.3s ease;
}
.item .mdl-card__actions {
display:none;
}
.mdl-card.upgraded .mdl-card__actions {
display:block;
}
.action.pin {
/* position:absolute; */
/* top:0px; */
/* right: 8px; */
}
.action.pin:before {
font-family: "Material Design Icons";
content: "\f403";
line-height:24px;
}
.item .mdl-card__actions {
text-align:right;
visibility: hidden;
opacity:0;
transition: transform 0.3s ease, opacity 0.3s ease;
}
.item .action.select i.material-icons {
font-size:14px;
}
.item.selected {
background:#555;
/*outline: 1px solid #555;*/
box-shadow: 0 0 8px rgba(0,0,0,0.87);
}
.item:hover .mdl-card__actions {
visibility: visible;
opacity:1;
}
.item.selected .action.select {
background: #555;
color: #fff;
display:block;
}
.item .mdl-button--icon {
min-width:32px;
}
.gallery {
width: calc(100% - 16px);
padding: 0px;
}
.breadcrumb {
margin-top: 24px;
display:block;
}
.breadcrumb + h1 {
margin-top:0px;
}
.gallery .item.mdl-card {
min-height: auto;
}
.gallery .item .mdl-card_media img {
width:100%;
height:auto;
}
.gallery .item.no-thumb .mdl-card_media a {
display: block;
/*min-height: 100px;*/
width:100%;
background: rgba(255,255,255,0.25);
text-decoration:none;
color:#fff;
vertical-align: middle;
text-align: center;
}
.item .mdl-card {
width:100%;
min-height:48px;
}
/*
.gallery .item.no-thumb.type-directory .mdl-card_media a::before {
content: "folder";
font-family: "Material Icons";
margin-right:8px;
font-size:128px;
line-height:128px;
text-decoration:none;
}
*/
.main-width {
max-width: 960px;
margin: auto;
position: relative;
}
@media (max-width: 976px) {
.main-width {
margin:0 8px;
}
}
#scooter {
position: absolute;
overflow: hidden;
top:0px;
width:100%;
bottom:0px;
height:0px;
}
#sizer {
background:rgba(0,0,0,0.10);
position:relative;
height:100%;
}
#sizer .gutter {
background:rgba(0,0,0,0.1);
height:100%;
}
/* Layout Hack */
.mdl-layout {
overflow: visible;
}
.mdl-layout__drawer {
position: fixed;
}
.mdl-layout__content {
display: block;
overflow: visible;
margin-top: 64px;
}
.is-small-screen .mdl-layout__content {
margin-top: 56px;
}
.mdl-layout__header {
position: fixed;
}
.mdl-layout__obfuscator {
position: fixed;
}

444
assets/nuweb/mdlio-app.js Executable file
View file

@ -0,0 +1,444 @@
window.mdlio = {
outlayer: function(outlayer) {
this.outlayers = [];
if (outlayer) {
if (Array.isArray(outlayer)) {
for (var e of outlayer) {
this.outlayers.push(e);
}
} else {
this.outlayers.push(outlayer);
}
}
this.add = function(outlayer) {
this.outlayers.push(outlayer);
}
;
this.appended = function(items) {
mdlio.upgrade.appended(items);
for (outlayer of this.outlayers) {
outlayer.appended(items);
}
};
},
cards: {
upgrade: function(element) {
element.querySelectorAll(".mdl-card").forEach(mdlio.cards.upgradeCard)
},
upgradeCard: function(card) {
console.log(card);
if(card.querySelector(".mdl-card_title")) {
card.classList.add("has-title");
}
if(card.querySelector(".mdl-card__actions")) {
card.classList.add("has-actions");
}
const parent=card.parentNode;
const as=card.querySelector(".action.select");
/*if(parent.matches(".card-wrapper") && as) {
parent.appendChild(as);
}*/
card.classList.remove("upgradeable");
card.classList.add("upgraded");
},
},
lightbox: function(grid, selector, options) {
var pswpElement = document.querySelectorAll('.pswp')[0];
if (pswpElement == null ) {
pswpElement = mdlio.addPSWP();
}
/*this.box = $(grid).find(selector).simpleLightbox(options); */
var items = [];
this.items = items;
const linkClicked = function(e) {
console.log(this, this.lboxId);
e.preventDefault();
var options = {
index: this.lboxId
};
var gallery = new PhotoSwipe(pswpElement,PhotoSwipeUI_Default,items,options);
gallery.init();
};
this.appended = function(appendedItems) {
//this.box.destroy();
for (var item of appendedItems) {
var link = item.querySelector(selector);
if (link == null ) {
continue;
}
var img = link.querySelector('img');
var width = img.naturalWidth;
var height = img.naturalHeight;
var maybeSize = link.getAttribute('data-img-size');
if (maybeSize) {
console.log(maybeSize);
[ width , height ] = maybeSize.split('x').map(function(x) {
return Number.parseInt(x);
});
}
var slide = {
msrc: img.getAttribute('src'),
src: link.getAttribute('href'),
w: width,
h: height
};
console.log(slide);
var slideId = items.push(slide) - 1;
var links = item.querySelectorAll(selector);
for (link of links) {
if (link.getAttribute('href') == slide.src) {
link.lboxId = slideId;
link.addEventListener("click", linkClicked);
}
}
}
//this.box = $(grid).find(selector).simpleLightbox(options);
}
},
infiniteScroll: function(grid, item, nextPage, outlayer) {
var outlayers = new mdlio.outlayer(outlayer);
var infScroll = new InfiniteScroll(grid,{
path: nextPage,
hideNav: nextPage,
append: item,
outlayer: outlayers,
status: '.page-load-status',
scrollThresold: 100,
prefill: true //elementScroll: '.mdl-layout__content',
});
infScroll.outlayers = outlayers;
return infScroll;
},
cardsGallery: function(grid, item, lightboxItem) {
const lightbox = new mdlio.lightbox(grid,lightboxItem + " a");
const msnry = new Masonry(grid,{
itemSelector: 'none',
// select none at first
columnWidth: document.querySelector('#gutter'),
gutter: 0,
containerStyle: {
width: 'calc(100% - 16px)',
padding: '0px',
position: 'relative'
},
percentPosition: true,
// nicer reveal transition
visibleStyle: {
transform: 'translateY(0)',
opacity: 1
},
hiddenStyle: {
transform: 'translateY(100px)',
opacity: 0
},
});
this.lightbox = lightbox;
this.masonry = msnry;
imagesLoaded(grid, function() {
grid.classList.remove('are-images-unloaded');
msnry.options.itemSelector = item;
var items = grid.querySelectorAll(item);
lightbox.appended(items);
msnry.appended(items);
});
if (document.querySelector(".next-page")) {
this.infiniteScroll = new mdlio.infiniteScroll(grid,item,'.next-page',[msnry, this.lightbox]);
}
},
addPSWP: function() {
var body = document.querySelector('body');
var pswp = document.createElement('div');
pswp.classList.add('pswp');
pswp.innerHTML = `
<div class="pswp__bg"></div>
<div class="pswp__scroll-wrap">
<div class="pswp__container">
<div class="pswp__item"></div>
<div class="pswp__item"></div>
<div class="pswp__item"></div>
</div>
<div class="pswp__ui pswp__ui--hidden">
<div class="pswp__top-bar">
<div class="pswp__counter"></div>
<button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
<button class="pswp__button pswp__button--share" title="Share"></button>
<button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
<!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
<!-- element will get class pswp__preloader--active when preloader is running -->
<div class="pswp__preloader">
<div class="pswp__preloader__icn">
<div class="pswp__preloader__cut">
<div class="pswp__preloader__donut"></div>
</div>
</div>
</div>
</div>
<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
<div class="pswp__share-tooltip"></div>
</div>
<button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
</button>
<button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
</button>
<div class="pswp__caption">
<div class="pswp__caption__center"></div>
</div>
</div>
</div>`
body.appendChild(pswp);
return pswp;
},
forms: {
upgrade: function(element) {
element.querySelectorAll('form .async[type="submit"]').forEach(function(button) {
button.addEventListener("click", function(e) {
e.preventDefault();
const form = button.findParentBySelector("form");
$.ajax({
type: "POST",
cache: false,
url: form.action,
data: $(form).serialize(),
success: function(msg) {
console.log("Success", msg);
}
});
});
});
}
},
upgrade: {
initial: function() {
mdlio.upgrade.appended([document.querySelector("body")]);
},
appended: function(items) {
items.forEach(mdlio.upgrade.upgrade);
},
upgrade: function(item) {
for(const upgrader of mdlio.upgrade.upgraders) {
upgrader.upgrade(item);
}
},
upgraders: [],
},
selectable: new (function(){
this.availableActions = new Set();
const selected = new Set();
this.selected = selected;
const actionButtons = {};
this.displayToolbar = function() {
var toolbar;
if(!this.toolbar) {
toolbar = document.createElement("div");
toolbar.classList.add("selection-bar");
toolbar.classList.add("mdl-layout__header");
toolbar.classList.add("mdl-color--white");
const header = document.querySelector("header.mdl-layout__header");
toolbar.innerHTML=`
<div class="mdl-layout__header-row" >
<button class="cancel mdl-layout__drawer-button">
<i class="material-icons">arrow_back</i>
</button>
<span class="mdl-layout_title"><span>0</span> Selected</span>
<div class="mdl-layout-spacer"></div>
<div class="actions"></div>
</div>
`;
header.parentNode.appendChild(toolbar);
toolbar.querySelector("button.cancel").addEventListener("click",this.stopSelection);
this.toolbar = {
toolbar: toolbar,
counter: toolbar.querySelector(".mdl-layout_title span"),
actions: toolbar.querySelector(".actions")
};
}
toolbar = this.toolbar;
toolbar.counter.innerHTML = this.selected.size
};
this.addToolbarAction = function(action) {
this.availableActions.add(action);
var button = actionButtons[action];
if(!button) {
button = document.createElement("div");
button.innerHTML='<i class="material-icons"></i>'
button.classList.add("mdl-button");
button.classList.add("mdl-button--icon");
button.addEventListener("click", this.actionClickHandler);
button.dataset.action = action;
actionButtons[action] = button;
}
this.toolbar.actions.appendChild(button);
};
this.removeToolbarAction = function(action) {
this.availableActions.delete(action);
var button = actionButtons[action];
if (button) {
this.toolbar.actions.removeChild(button)
}
}
this.startSelection = function() {
this.displayToolbar();
document.querySelector("body").classList.add("selection-mode");
}
this.stopSelection = function() {
document.querySelector("body").classList.remove("selection-mode");
for (item of mdlio.selectable.selected) {
mdlio.selectable.unselect(item);
}
}
this.select = function(item) {
item.classList.add("selected");
this.selected.add(item);
this.startSelection();
var actions = item.querySelectorAll("[data-selectable-action]");
var actionsSet = new Set();
for (const action of actions) {
actionsSet.add(action.dataset.selectableAction);
}
console.log("actions", this.availableActions);
if(this.selected.size == 1) {
for(action of actionsSet) {
this.addToolbarAction(action);
}
} else {
for (const action of this.availableActions) {
if(!actionsSet.has(action)) {
this.removeToolbarAction(action);
}
}
}
};
this.unselect = function(item) {
item.classList.remove("selected");
this.selected.delete(item);
if(mdlio.selectable.selected.size == 0) {
this.stopSelection();
}
};
const actionsHandlers = {}
this.action = function(key, fn) {
actionsHandlers[key] = function(items) {items.forEach(fn)};
};
this.batchAction = function(key, fn) {
actionsHandlers[key] = fn;
};
this.actionClickHandler = function(ev) {
var action = this.dataset.action;
console.log("Invoking action", action, ev);
var handler = actionsHandlers[action];
if(handler) {
handler(Array.from(selected));
}
}
this.upgrade = function(item) {
var items=[];
if (item.matches(".selectable")) {
items=[item];
} else {
items=item.querySelectorAll(".selectable")
}
items.forEach(function(item) {
var selectButton = item.querySelector('.action.select');
if(!selectButton) {
selectButton = document.createElement("button");
selectButton.classList.add("mdl-button","mdl-button--icon");
selectButton.classList.add("action","select");
selectButton.innerHTML='<i class="material-icons">check</i>';
item.appendChild(selectButton);
}
selectButton.addEventListener("click", function(e) {
e.preventDefault();
if(item.classList.contains("selected")) {
mdlio.selectable.unselect(item);
} else {
mdlio.selectable.select(item);
}
});
})
};
})()
};
mdlio.upgrade.upgraders.push(mdlio.cards);
mdlio.upgrade.upgraders.push(mdlio.forms);
mdlio.upgrade.upgraders.push(mdlio.selectable);
Element.prototype.findParentBySelector = function(selector) {
console.log(this);
var cur = this.parentNode;
while (cur && !cur.matches(selector)) {
//keep going up until you find a match
cur = cur.parentNode;
//go up
}
return cur;
//will return null if not found
}
,
window.addEventListener('load', function() {
mdlio.upgrade.initial();
});
window.addEventListener('load', function() {
console.log("Content-loaded");
});