You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
4.4 KiB
JavaScript

// TODO
3 years ago
// glyphs
// random position
// what buttons where
// colophone
// a bit more interface
// DONE
// Open window icon (on background 'desktop')
// Close window button (on 'window' itself)
3 years ago
$(document).ready(function(){
let corpi = {
0: {
id:'xpub',
3 years ago
glyph: '🖨️',
title: 'var xpub',
content: 'window.open() at PNF will be an interface for our XPUB program to speak/communicate to/with the public inside and outside of the physical space. We adjust, using windows in the street and in the browser in order to be able to communicate. This frames it as a "discursive/dialogical interface" through which attitudes, perspectives, backgrounds and situations are explored together in a program consisting of: presentations, workshops, publication launches, conversations and performances; both online and offline.'
},
1: {
id:'interface',
3 years ago
glyph: '📀',
title: 'const interface',
content: 'A window is a framing device, an interface through which we can look inside, to spaces where small groups meet, and outside to the world beyond. Screens and windows delineate boundaries between public and private. Working with(in) a limitation, a frame(work), a situation, a context means adjusting our work to the state of affairs; it changes our way of thinking/framing it. We adjust, in order to be able to communicate within a temporary window of time, reframing our intentions and seeking opportunities to share some real-time realness.'
},
2: {
id:'greetings',
3 years ago
glyph: '📌',
title: 'let greetings',
content: 'We are pleased to invite you to window.open(), a day-long festival, held by students and alumni of the Master of Experimental Publishing (XPUB) at Page Not Found.'
},
}
// generate divs
Object.values(corpi).forEach(corpus => {
3 years ago
$('#boxes' ).append(`<div class="ui-widget-content draggable resizable" id="${corpus['id']}"><h1>${corpus['title']}</h1><p>${corpus['content']}</p><button class="closable">X</button></div>`)
$("#icons").append(`<button onclick="$(${corpus['id']}).fadeIn()" class="icon">${corpus["glyph"]}</button>`)
});
//size window
function getWidth() {
return Math.max(
document.body.scrollWidth,
document.documentElement.scrollWidth,
document.body.offsetWidth,
document.documentElement.offsetWidth,
document.documentElement.clientWidth
);
}
var widthDrag = (getWidth())/2;
function getHeight() {
return Math.max(
document.body.scrollHeight,
document.documentElement.scrollHeight,
document.body.offsetHeight,
document.documentElement.offsetHeight,
document.documentElement.clientHeight
);
}
var heightDrag = (getHeight())/2;
// random
function getRndInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1) ) + min;
}
// DRAG and Z-INDEX priorities handler
var a = 3;
$( '.draggable' ).draggable({ containment: "window" },{ // Setup dragging and containment
start: function(event, ui) { $(this).css("z-index", a++); } // Initialize z-index for handelr
});
$('#dragZone div').click(function() { // Setup z-index handler
$(this).addClass('top').removeClass('bottom');
$(this).siblings().removeClass('top').addClass('bottom');
$(this).css("z-index", a++);
});
// CURSOR MOUSE DOWN
$('.draggable').on("mousedown", function(){
$('.draggable').css('cursor', 'grabbing');
}).on("mouseup mouseleave", function(){
$('.draggable').css('cursor', 'grab');
});
// RESIZE with aspect ratio
$( ".resizable" ).resizable({ aspectRatio:true, maxHeight:900, minHeight:200 });
$( ".resizableOriz" ).resizable({ aspectRatio:true, maxHeight:500, minHeight:200 });
// settings draggables
$( ".draggable" ).each(function() {
let rw = getRndInteger(widthDrag-500,widthDrag)
let rh = getRndInteger(heightDrag-200, heightDrag)
$( this ).css("width",rw);
$( this ).css("height",rh)
});
// close window
$(".closable").click(function() {
3 years ago
$( this ).parent().fadeOut();
});
});