Skip to content

Commit

Permalink
made lively_iframe live_programmable
Browse files Browse the repository at this point in the history
SQUASHED: AUTO-COMMIT-src-components-widgets-lively-iframe.html,AUTO-COMMIT-src-components-widgets-lively-iframe.js,AUTO-COMMIT-src-components-widgets-lively-iframe.js.l4a,
  • Loading branch information
onsetsu committed Aug 12, 2024
1 parent 4e7a62f commit adb0ecb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/components/widgets/lively-iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

input {
width: 40px;
width: 400px;
flex: 1;
margin: 2px;
}
Expand Down
68 changes: 46 additions & 22 deletions src/components/widgets/lively-iframe.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,60 @@
import Morph from 'src/components/widgets/lively-morph.js';

export default class LivelyIFrame extends Morph {

get input() {
return this.get("#input");
}

get frame() {
return this.get("#frame");
}

async initialize() {
this.windowTitle = "iFrame Browser"
var input = this.get("#input");
input.onchange = () => this.update();

if (!this.getAttribute("src")) {
this.setURL("//lively-kernel.org/")
} else {
this.setURL(this.getAttribute("src"))
this.windowTitle = "iFrame Browser";
this.input.onchange = () => this.update();

if (this.getAttribute("src")) {
this.setURL(this.getAttribute("src"));
}
}

update() {
var input = this.get("#input");
this.get("#frame").src = input.value;
const url = this.input.value;
this.updatePersistence(url);
this.updateFrame(url);
}

setURL(url){
this.setAttribute("src", url)
this.get("#input").value = url
this.get("#frame").src = url;

updateFrame(url) {
this.frame.src = url;
}


updatePersistence(url) {
this.setAttribute("src", url);
}

getURL() {
return this.getAttribute("src");
}

setURL(url) {
this.input.value = url;
this.updatePersistence(url);
this.updateFrame(url);
}

hideMenubar() {
this.get("#menubar").hidden = true
this.get("#menubar").hidden = true;
}

showMenubar() {
this.get("#menubar").hidden = false
this.get("#menubar").hidden = false;
}

livelyMigrate(other) {
this.setURL(other.getURL());
}

livelyExample() {
this.setURL('//lively-kernel.org/')
}

}

0 comments on commit adb0ecb

Please sign in to comment.