File tree Expand file tree Collapse file tree 7 files changed +115
-8
lines changed Expand file tree Collapse file tree 7 files changed +115
-8
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ var app = app || {};
43
43
app . events . listen ( 'app:layout:cached' , createLayout . bind ( this ) ) ;
44
44
} ;
45
45
46
+ app . windowInstances = [ ] ;
47
+
46
48
/***
47
49
* Internal application events
48
50
*/
Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ var app = app || {};
8
8
app . templates = {
9
9
10
10
layout : {
11
- footer : '<nav class="menu"><ul><li class="start"><a href="#" class="icon-smile"></a></li><li class="window-tab"><a href="#" class="icon-browser"></a></li></ul></nav>'
11
+ content : '<div id="template-content"></div>' ,
12
+ footer : '<nav class="menu" id="template-footer"><ul><li class="start"><a href="javascript:;" class="icon-smile"></a></li><li class="window-tab"><a href="#" class="icon-browser"></a></li></ul></nav>'
12
13
} ,
13
14
14
15
windowTemplate : [ '<section class="window" id="test">' ,
Original file line number Diff line number Diff line change
1
+ /***
2
+ * Content view
3
+ */
4
+ var app = app || { } ;
5
+
6
+ ( function ( global ) {
7
+
8
+ /***
9
+ * @param {Object } options
10
+ * returns void
11
+ */
12
+ function contentView ( options ) {
13
+
14
+ this . template = options . template ;
15
+ this . name = options . name ;
16
+ this . placeholder = document . getElementById ( 'placeholder-' + options . name ) ;
17
+
18
+
19
+
20
+ /***
21
+ * Bind event listeners to view elements
22
+ */
23
+ this . bindEvents = function ( ) {
24
+ app . events . listen ( 'app:window:create' , this . createNewWindow ) ;
25
+ } ;
26
+
27
+ this . unbindEvents = function ( ) {
28
+
29
+ } ;
30
+
31
+ /***
32
+ * Create new Windown object
33
+ */
34
+ this . createNewWindow = function ( ) {
35
+ console . log ( 2 ) ;
36
+ app . windowInstances . push ( new global . windowView ( {
37
+ /***
38
+ * TO DO Homework: create UNIQUE ID
39
+ */
40
+ id : app . windowInstances . length
41
+ } ) ) ;
42
+ } ;
43
+
44
+
45
+ this . render = function ( ) {
46
+
47
+ this . placeholder . innerHTML = this . template ;
48
+ this . el = document . getElementById ( 'template-' + options . name ) ;
49
+
50
+ this . bindEvents ( ) ;
51
+ } ;
52
+
53
+ this . destroy = function ( ) {
54
+ console . log ( 'destroy' , this . template ) ;
55
+ } ;
56
+
57
+ app . events . listen ( 'view:' + this . name + ':render' , this . render . bind ( this ) ) ;
58
+ } ;
59
+
60
+ app . contentView = contentView ;
61
+ } ) ( window ) ;
Original file line number Diff line number Diff line change 3
3
*/
4
4
var app = app || { } ;
5
5
6
- ( function ( ) {
6
+ ( function ( global ) {
7
7
8
8
/***
9
9
* @param {Object } options
@@ -15,13 +15,51 @@ var app = app || {};
15
15
this . name = options . name ;
16
16
this . placeholder = document . getElementById ( 'placeholder-' + options . name ) ;
17
17
18
+ /***
19
+ * Elements selectors
20
+ */
21
+ this . selectors = {
22
+ createNewWindow : '.icon-smile'
23
+ } ;
24
+
25
+ /***
26
+ * Store cached elements
27
+ */
28
+ this . elements = {
18
29
30
+ } ;
31
+
32
+ /***
33
+ * Bind event listeners to view elements
34
+ */
35
+ this . bindEvents = function ( ) {
36
+
37
+ Events . subscribe ( this . elements . createNewWindow , 'click' , this . createNewWindow ) ;
38
+ } ;
39
+
40
+ this . unbindEvents = function ( ) {
41
+
42
+ } ;
43
+
44
+ /***
45
+ * Create new Windown object
46
+ */
47
+ this . createNewWindow = function ( ) {
48
+ /***
49
+ * TO DO HOMEWORK: add icon for each new window
50
+ */
51
+ app . events . notify ( 'app:window:create' ) ;
52
+ } ;
19
53
20
54
21
55
this . render = function ( ) {
22
56
23
57
this . placeholder . innerHTML = this . template ;
24
- this . el = document . getElementById ( 'template-' + options . name )
58
+ this . el = document . getElementById ( 'template-' + options . name ) ;
59
+
60
+ this . elements . createNewWindow = this . el . querySelector ( this . selectors . createNewWindow ) ;
61
+
62
+ this . bindEvents ( ) ;
25
63
} ;
26
64
27
65
this . destroy = function ( ) {
@@ -32,4 +70,4 @@ var app = app || {};
32
70
} ;
33
71
34
72
app . footerView = footerView ;
35
- } ) ( ) ;
73
+ } ) ( window ) ;
Original file line number Diff line number Diff line change @@ -14,18 +14,19 @@ var app = app || {};
14
14
//Execpional template or default template
15
15
this . template = options . template || app . templates . windowTemplate ;
16
16
this . id = options . id ;
17
- this . type = options . type ; //minimized or maximized
17
+ this . type = options . type || 'maximized' ; //minimized or maximized
18
18
19
19
this . render = function ( ) {
20
20
21
- app . layout . content . el . innerHTML += this . template ;
21
+ app . layout . content . el . innerHTML += this . template . join ( '' ) ;
22
22
} ;
23
23
24
24
this . destroy = function ( ) {
25
25
console . log ( 'destroy' , this . template ) ;
26
26
} ;
27
27
28
- app . events . listen ( 'window:' + this . id + ':render' , this . render . bind ( this ) ) ;
28
+ this . render ( ) ;
29
+ // app.events.listen('window:' + this.id + ':render', this.render.bind(this));
29
30
} ;
30
31
31
32
window . windowView = windowView ;
Original file line number Diff line number Diff line change 22
22
< script type ="text/javascript " src ="app/components/events.js "> </ script >
23
23
< script type ="text/javascript " src ="app/templates/templates.js "> </ script >
24
24
< script type ="text/javascript " src ="app/views/footer-view.js "> </ script >
25
+ < script type ="text/javascript " src ="app/views/content-view.js "> </ script >
25
26
< script type ="text/javascript " src ="app/views/window-view.js "> </ script >
26
27
< script type ="text/javascript " src ="app/controllers/controller.js "> </ script >
27
28
Original file line number Diff line number Diff line change 38
38
width : 40px ;
39
39
height : 100% ;
40
40
text-align : center;
41
- padding : 14px 10px 0 10px ;
41
+ /* padding: 14px 10px 0 10px;*/
42
42
background-color : # ecf0f1 ;
43
43
border-right : 1px solid # ccc ;
44
44
}
56
56
.wrapper .menu li a {
57
57
font-size : 1.3em ;
58
58
color : # 31535c ;
59
+ display : inline-block;
60
+ width : 100% ;
61
+ line-height : 40px ;
59
62
}
60
63
61
64
.window {
You can’t perform that action at this time.
0 commit comments