Skip to content

Commit

Permalink
Merge pull request nextapps-de#104 from h3rb/master
Browse files Browse the repository at this point in the history
implement onhide, onshow, onmaximize, onminimize, onwindowize, onfullscreen
  • Loading branch information
ts-thomas authored Aug 7, 2022
2 parents d1088d1 + 8cdce6f commit b65c8a1
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 8 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,42 @@ Instance properties:
<td>Callback triggered when the window resizes. The keyword <code>this</code> inside the callback function refers to the corresponding WinBox instance.</td>
</tr>
<tr></tr>
<tr>
<td>onfullscreen</td>
<td>function()</td>
<td>Callback triggered when the window enters fullscreen.</td>
</tr>
<tr></tr>
<tr>
<td>onminimize</td>
<td>function()</td>
<td>Callback triggered when the window enters minimized mode.</td>
</tr>
<tr></tr>
<tr>
<td>onmaximize</td>
<td>function()</td>
<td>Callback triggered when the window enters maximize mode.</td>
</tr>
<tr></tr>
<tr>
<td>onwindowize</td>
<td>function()</td>
<td>Callback triggered when the window returns to a windowed state from a Fullscreen, Minimized or Maximized state.</td>
</tr>
<tr></tr>
<tr>
<td>onhide</td>
<td>function()</td>
<td>Callback triggered when the window is hidden with win.hide()</td>
</tr>
<tr></tr>
<tr>
<td>onshow</td>
<td>function()</td>
<td>Callback triggered when the window is shown with win.show()</td>
</tr>
<tr></tr>
<tr>
<td>onclose</td>
<td>function(force)</td>
Expand Down Expand Up @@ -883,6 +919,18 @@ var winbox = WinBox({
console.log("width", width);
console.log("height", height);
},
onfullscreen: function(){
this.setBackground("#666");
},
onminimize: function(){
this.setBackground("#999");
},
onmaximize: function(){
this.setBackground("#AAA");
},
onwindowize: function(){
this.setBackground("#DDD");
},
onmove: function(x, y){
console.log("x", x);
console.log("y", y);
Expand Down
6 changes: 6 additions & 0 deletions src/js/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ import WinBox from "./winbox.js";
/** @export */ WinBox.onblur;
/** @export */ WinBox.onmove;
/** @export */ WinBox.onresize;
/** @export */ WinBox.onfullscreen;
/** @export */ WinBox.onmaximize;
/** @export */ WinBox.onminimize;
/** @export */ WinBox.onwindowize;
/** @export */ WinBox.onhide;
/** @export */ WinBox.onshow;
/** @export */ WinBox.winbox;

window["WinBox"] = WinBox;
34 changes: 26 additions & 8 deletions src/js/winbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ function WinBox(params, _title){
onblur,
onmove,
onresize,
onfullscreen,
onmaximize,
onminimize,
onwindowize,
onhide,
onshow,
background,
border,
classname,
Expand Down Expand Up @@ -114,6 +120,12 @@ function WinBox(params, _title){
onblur = params["onblur"];
onmove = params["onmove"];
onresize = params["onresize"];
onfullscreen = params["onfullscreen"];
onmaximize = params["onmaximize"];
onminimize = params["onminimize"];
onwindowize = params["onwindowize"];
onhide = params["onhide"];
onshow = params["onshow"];
background = params["background"];
border = params["border"];
classname = params["class"];
Expand Down Expand Up @@ -190,6 +202,12 @@ function WinBox(params, _title){
this.onblur = onblur;
this.onmove = onmove;
this.onresize = onresize;
this.onfullscreen = onfullscreen;
this.onmaximize = onmaximize;
this.onminimize = onminimize;
this.onwindowize = onwindowize;
this.onhide = onhide;
this.onshow = onshow;
this.splitscreen = splitscreen;

if(max){
Expand Down Expand Up @@ -717,7 +735,7 @@ WinBox.prototype.focus = function(){
*/

WinBox.prototype.hide = function(){

this.onhide && this.onhide();
return this.addClass("hide");
};

Expand All @@ -726,7 +744,7 @@ WinBox.prototype.hide = function(){
*/

WinBox.prototype.show = function(){

this.onshow && this.onshow();
return this.removeClass("hide");
};

Expand All @@ -746,6 +764,7 @@ WinBox.prototype.minimize = function(state){

remove_min_stack(this);
this.resize().move().focus();
this.onwindowize && this.onwindowize();
}
else if((state !== false) && !this.min){

Expand All @@ -754,12 +773,14 @@ WinBox.prototype.minimize = function(state){
this.dom.title = this.title;
this.addClass("min");
this.min = true;
this.onminimize && this.onminimize();
}

if(this.max){

this.removeClass("max");
this.max = false;
this.onminimize && this.onminimize();
}

return this;
Expand Down Expand Up @@ -793,10 +814,12 @@ WinBox.prototype.maximize = function(state){
this.top,
true
);
this.onmaximize && this.onmaximize();
}
else{

this.resize().move().removeClass("max");
this.onwindowize && this.onwindowize();
}
}

Expand Down Expand Up @@ -829,14 +852,9 @@ WinBox.prototype.fullscreen = function(state){
//this.dom[prefix_request]();
this.body[prefix_request]();
is_fullscreen = true;
this.onfullscreen && this.onfullscreen();
}

// dispatch resize callback on fullscreen?

// else{
//
// this.onresize && this.onresize(this.width, this.height);
// }
}

return this;
Expand Down

0 comments on commit b65c8a1

Please sign in to comment.