Skip to content

Commit 59e60d7

Browse files
committed
Added minimize and maximize functions , hightlight function doesn't work yet , need to fix(footer view render and highlight functions and to bind events)
1 parent f49e4de commit 59e60d7

File tree

4 files changed

+170
-18
lines changed

4 files changed

+170
-18
lines changed

EXERCISE/Exercise 4/app/controllers/controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var app = app || {};
8181

8282
for (var i = instanceStorage.length - 1; i >= 0; i--) {
8383
instanceStorage[i].destroy();
84-
};
84+
}
8585
};
8686

8787
/**
@@ -96,7 +96,7 @@ var app = app || {};
9696
name: templateName
9797
});
9898
}
99-
};
99+
}
100100

101101
/**
102102
* Get user specific configuration

EXERCISE/Exercise 4/app/views/footer-view.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ var app = app || {};
1515
this.el = document.getElementById('template-' + this.name);
1616

1717
if(this.selectors) {
18-
// in contentView selectors is undefined; in footer view we have createNewWindow and destroyWindow as selectors
18+
// in contentView selectors is undefined; in footer view we have createNewWindow and windowIcon as selectors
1919
for(var selector in this.selectors) {
2020
this.elements[selector] = document.querySelector(this.selectors[selector]);
2121
}
2222
}
2323

2424
this.iconList = this.el.firstChild;
2525

26+
// this.iconToHighlight = this.iconList.querySelector(this.selectors.windowIcon);
27+
this.elements.iconToHighlight =this.selectors.windowIcon;
28+
2629
this.events.on.call(this);
2730

2831
};
@@ -34,8 +37,11 @@ var app = app || {};
3437
on: function () {
3538

3639
Events.subscribe(this.elements.createNewWindow, 'click', this.createNewWindow.bind(this));
40+
// Events.subscribe(this.elements.iconToHighlight, 'click', this.iconHighlight.bind(this));
3741
app.events.listen('app:window:destroy', this.destroyWindow.bind(this));
3842
app.events.listen('app:window:created', this.createNewIcon.bind(this));
43+
44+
// Events.subscribe(this.iconToHighlight,'click', this.iconHighlight.bind(this));
3945
},
4046

4147
off: function () {
@@ -47,7 +53,6 @@ var app = app || {};
4753
* Create new Windown object
4854
*/
4955
app.FooterView.createNewWindow = function () {
50-
5156
// app.FooterView.el.firstChild.innerHTML += app.templates.footerTemplate;
5257
app.events.notify('app:window:create');
5358

@@ -88,28 +93,24 @@ var app = app || {};
8893

8994
};
9095

96+
app.FooterView.iconHighlight = function () {
97+
this.iconToHighlight.classList.add('iconhighlight');
98+
99+
app.events.notify('app:footericon:highlighted',{ id: this.iconList.id });
100+
};
101+
91102

92103
/***
93104
* Store cached elements
94105
*/
95106
app.FooterView.elements = {
96-
97107
};
98108
/***
99109
* Elements selectors
100110
*/
101111
app.FooterView.selectors = {
102112
createNewWindow: '.icon-smile',
103-
destroyWindow: '.window-tab'
113+
windowIcon: '.window-tab'
104114
};
105115

106-
// app.FooterView.iconcolor= function() {
107-
// var letters = '0123456789ABCDEF'.split('');
108-
// var color = '#';
109-
// for (var i = 0; i < 6; i++ ) {
110-
// color += letters[Math.floor(Math.random() * 16)];
111-
// }
112-
// return color;
113-
// };
114-
115116
})(window,app);

EXERCISE/Exercise 4/app/views/window-view.js

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var app = app || {};
1717
init: function (options) {
1818
this.template = options.template || app.templates.windowTemplate;
1919
this.id = options.id;
20-
this.type = options.type || 'maximized'; //minimized or maximized
20+
this.type = options.type || 'normalized'; //minimized or maximized
2121

2222
this.render();
2323

@@ -34,7 +34,11 @@ var app = app || {};
3434
this.wrapper.className='window';
3535
this.wrapper.innerHTML=this.template.join('');
3636
app.ContentView.el.appendChild(this.wrapper);
37+
3738
this.closeIcon = this.wrapper.querySelector(this.selectors.closeIcon);
39+
this.minimizeIcon = this.wrapper.querySelector(this.selectors.minimizeIcon);
40+
this.maximizeIcon = this.wrapper.querySelector(this.selectors.maximizeIcon);
41+
3842

3943
this.events.on.call(this);
4044
},
@@ -49,10 +53,56 @@ var app = app || {};
4953
app.events.notify('app:window:destroy',{id: this.id});
5054
},
5155

56+
minimize: function(){
57+
// this.wrapper.remove('fadeInUp');
58+
// this.wrapper.remove('animated');
59+
60+
this.wrapper.classList.add('fadeOutDown');
61+
this.wrapper.classList.add('animated');
62+
63+
app.events.notify('app:window:minimized');
64+
},
65+
66+
popup: function(){
67+
// this.wrapper.remove('fadeOutDown');
68+
// this.wrapper.remove('animated');
69+
70+
this.wrapper.classList.add('fadeInUp');
71+
this.wrapper.classList.add('animated');
72+
73+
app.events.notify('app:window:popup');
74+
},
75+
76+
maximize: function(){
77+
if(this.type === "maximized"){
78+
this.wrapper.removeAttribute("style");
79+
this.type="normalized";
80+
app.events.notify('app:window:normalized');
81+
}
82+
else{
83+
this.wrapper.style.maxWidth = "100%";
84+
this.wrapper.style.height = global.innerHeight-70+"px";
85+
this.type="maximized";
86+
app.events.notify('app:window:maximized');
87+
}
88+
},
89+
90+
highlight: function(evnt){
91+
for (var i = app.windowInstances.length - 1; i >= 0; i--) {
92+
if(app.windowInstances[i].id === evnt.detail.id){
93+
app.windowInstances[i].wrapper.classList.add('windowhighlight');
94+
this.popup();
95+
}
96+
}
97+
},
98+
5299
events: {
53100

54101
on: function () {
55102
Events.subscribe(this.closeIcon, 'click', this.destroy.bind(this));
103+
Events.subscribe(this.minimizeIcon, 'click', this.minimize.bind(this));
104+
Events.subscribe(this.maximizeIcon, 'click', this.maximize.bind(this));
105+
app.events.listen('app:footericon:highlighted', this.highlight.bind(this));
56106
},
57107

58108
off: function () {
@@ -61,7 +111,9 @@ var app = app || {};
61111
},
62112

63113
selectors: {
64-
closeIcon:'.icon-delete-circle'
114+
closeIcon:'.icon-delete-circle',
115+
minimizeIcon: '.icon-dash',
116+
maximizeIcon: '.icon-popup'
65117
}
66118
};
67119
})(window);

EXERCISE/Exercise 4/styles/style.css

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ body {
6464
.window {
6565
max-width: 70%;
6666
min-width: 400px;
67+
margin: 0 auto;
6768
border: 1px solid #ccc;
69+
transition: all .2s ease-in-out;
6870
}
6971

7072
.window .header {
@@ -125,4 +127,101 @@ body {
125127
border-right: 1px solid #ccc;
126128
background-color: #ecf0f1;
127129
font-family: Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif;
128-
}
130+
}
131+
132+
133+
/*
134+
* Css Animations
135+
*/
136+
137+
.animated {
138+
-webkit-animation-duration: 2s;
139+
animation-duration: 2s;
140+
-webkit-animation-fill-mode: both;
141+
animation-fill-mode: both;
142+
}
143+
144+
/*
145+
* Go Down
146+
*/
147+
148+
@-webkit-keyframes fadeOutDown {
149+
from {
150+
opacity: 1;
151+
}
152+
153+
to {
154+
opacity: 0;
155+
-webkit-transform: translate3d(0%, 100%, 0);
156+
transform: translate3d(-10%, 100%, 0);
157+
}
158+
}
159+
160+
@keyframes fadeOutDown {
161+
from {
162+
opacity: 1;
163+
}
164+
165+
to {
166+
opacity: 0;
167+
-webkit-transform: translate3d(0%, 100%, 0);
168+
transform: translate3d(-10%, 100%, 0);
169+
}
170+
}
171+
172+
.fadeOutDown {
173+
-webkit-animation-name: fadeOutDown;
174+
animation-name: fadeOutDown;
175+
}
176+
177+
@-webkit-keyframes fadeInUp {
178+
from {
179+
opacity: 0;
180+
-webkit-transform: translate3d(0, 100%, 0);
181+
transform: translate3d(0, 100%, 0);
182+
}
183+
184+
to {
185+
opacity: 1;
186+
-webkit-transform: none;
187+
transform: none;
188+
}
189+
}
190+
191+
/*
192+
* Go Up
193+
*/
194+
195+
@keyframes fadeInUp {
196+
from {
197+
opacity: 0;
198+
-webkit-transform: translate3d(0, 100%, 0);
199+
transform: translate3d(0, 100%, 0);
200+
}
201+
202+
to {
203+
opacity: 1;
204+
-webkit-transform: none;
205+
transform: none;
206+
}
207+
}
208+
209+
.fadeInUp {
210+
-webkit-animation-name: fadeInUp;
211+
animation-name: fadeInUp;
212+
}
213+
214+
/*
215+
* Highliting
216+
*/
217+
218+
/*.window:hover , */
219+
.windowhighlight{
220+
box-shadow: 0px 0px 26px 0px #05b4ba;
221+
/*zoom: 115%;*/
222+
transition: all .2s ease-in-out;
223+
transform: scale(1.1);
224+
}
225+
.iconhighlight{
226+
background-color: rgba(5,180,186,0.2);
227+
}

0 commit comments

Comments
 (0)