Skip to content

Instantly share code, notes, and snippets.

@imjoshdean
Created January 8, 2016 16:54
Show Gist options
  • Save imjoshdean/6027f59afdca87bc56d5 to your computer and use it in GitHub Desktop.
Save imjoshdean/6027f59afdca87bc56d5 to your computer and use it in GitHub Desktop.
WindowState close function that works with
var WindowState = Construct.extend({ }, {
close: function(win, force, predicate) {
if(this[win]) {
if(can.isArray(this[win])) {
// if no predicate is defined, _.filter will return the entire list
_.filter(this[win], predicate).forEach(this.proxy(function(item) {
var index = this[win].indexOf(item);
item.close(true);
this[win].splice(index, 1);
}));
}
else {
this[win].close(true);
this[win] = undefined;
}
return true;
}
if(win.id) {
if(this.main && this.main.id === win.id) {
this.savePosition('main');
if (force) {
// log out from CAS and close window
Endo.CAS.logout();
ExoUtils.stopPresenter();
win.close();
} else {
this.hide(win);
}
} else if (this.preferences && this.preferences.id === win.id) {
// preferences data last update before closing
if (Endo.PreferencesActionThread) {
Endo.PreferencesActionThread.finalUpdate(
this.proxy(function(win) {
win.close();
},
win));
}
} else {
win.close();
}
return true;
}
return false;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment