-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from iNewLegend/draft/dev-mvc
Draft/dev mvc
- Loading branch information
Showing
70 changed files
with
1,455 additions
and
983 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
npm-debug.log | ||
node_modules | ||
.idea | ||
app.bundle.js | ||
|
||
frontend/dist/mvc.bundle.js |
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
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
File renamed without changes.
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,26 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Dev</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style> | ||
div { | ||
width: 500px; | ||
height: 500px; | ||
border: 1px solid black; | ||
padding: 20px; | ||
margin: 20px; | ||
background: yellow; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="root"> | ||
Root | ||
</div> | ||
<script type="module" src="index.js"></script> | ||
</body> | ||
</html> |
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,88 @@ | ||
import Component from './modules/component'; | ||
|
||
class Container extends Component { | ||
initialize() { | ||
this.events = { | ||
onRender: () => {}, | ||
} | ||
|
||
super.initialize(); | ||
} | ||
|
||
afterRender() { | ||
super.afterRender(); | ||
|
||
this.events.onRender(); | ||
} | ||
|
||
set( child ) { | ||
this.child = child; | ||
this.child.render(); | ||
} | ||
/** | ||
* Function on() : Declare event callback | ||
* | ||
* @param {'render'} event | ||
* @param {{function()}} callback | ||
*/ | ||
on(event, callback) { | ||
switch (event) { | ||
case 'render': { | ||
this.events.onRender = callback; | ||
} break; | ||
|
||
default: { | ||
alert(`${this.constructor.name}::on() -> invalid event type: '${event}'`); | ||
} | ||
} | ||
} | ||
} | ||
|
||
class Page extends Container { | ||
|
||
} | ||
|
||
class PageContainer extends Container { | ||
|
||
} | ||
|
||
class CatalogPage extends Page { | ||
onClick = () => { | ||
alert( 'page home'); | ||
}; | ||
} | ||
|
||
|
||
|
||
class App { | ||
initialize() { | ||
this.elements = { | ||
root: document.getElementById('root'), | ||
}; | ||
|
||
this.app = new Component(this.elements.root, `<div class="app">App</div>`); | ||
|
||
this.pageContainer = new PageContainer( this.app, '<div class="page">Page Container</div>' ); | ||
|
||
this.pageContainer.on('render', this.onPageContainerRender.bind( this ) ); | ||
|
||
this.homePage = new CatalogPage( this.pageContainer, '<div class="homepage">Home Page</div>') | ||
|
||
this.app.render(); | ||
|
||
this.pageContainer.render(); | ||
|
||
this.pageContainer.set( this.homePage ); | ||
|
||
} | ||
|
||
onPageContainerRender() { | ||
console.log('onPageContainerRender'); | ||
} | ||
} | ||
|
||
const app = new App(); | ||
|
||
app.initialize(); | ||
|
||
|
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,26 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Dev</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style> | ||
div { | ||
width: 500px; | ||
height: 500px; | ||
border: 1px solid black; | ||
padding: 20px; | ||
margin: 20px; | ||
background: yellow; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="root"> | ||
Root | ||
</div> | ||
<script src="../../frontend/dist/mvc.bundle.js"></script> | ||
</body> | ||
</html> |
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,76 @@ | ||
import * as Core from '../../frontend/core/index.js'; | ||
import Modules from '../../frontend/modules/index.js'; | ||
|
||
class PageContainer extends Core.Container { | ||
|
||
} | ||
|
||
class Page extends Core.Container { | ||
|
||
} | ||
|
||
class CatalogPage extends Page { | ||
onClick = () => { | ||
alert( 'page home'); | ||
}; | ||
} | ||
|
||
|
||
class Item extends Modules.Component { | ||
template() { | ||
return '' + | ||
'<div class"item">' + | ||
'<h1 onClick="this.onItemClick()">Item</h1>' + | ||
'<input type="text" onchange="this.onInputChanged( event )">' + | ||
'</div' | ||
; | ||
} | ||
|
||
onInputChanged( event ) { // controller | ||
debugger; | ||
} | ||
|
||
onItemClick() { | ||
alert('on item heading click'); | ||
} | ||
|
||
onClick = () => { | ||
alert('Hello from item class view'); | ||
} | ||
} | ||
|
||
|
||
class App { | ||
initialize() { | ||
this.elements = { | ||
root: document.getElementById('root'), | ||
}; | ||
|
||
this.app = new Core.Element(this.elements.root, `<div class="app">App</div>`); | ||
|
||
this.pageContainer = new PageContainer( this.app, '<div class="page">Page Container</div>' ); | ||
|
||
this.pageContainer.on('render', this.onPageContainerRender.bind( this ) ); | ||
|
||
this.homePage = new CatalogPage( this.pageContainer, '<div class="homepage">Home Page</div>') | ||
|
||
this.app.render(); | ||
|
||
this.pageContainer.set( this.homePage ); | ||
this.pageContainer.render(); | ||
} | ||
|
||
onPageContainerRender() { | ||
console.log( 'onPageContainerRender' ); | ||
|
||
const item = new Item( this.homePage ); | ||
item.render(); | ||
} | ||
|
||
} | ||
|
||
const app = new App(); | ||
|
||
app.initialize(); | ||
|
||
|
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
Oops, something went wrong.