Skip to content
Snippets Groups Projects
Commit d49c8b24 authored by mcmlxxix's avatar mcmlxxix
Browse files

current setter takes view index or title, load funclib.js

parent 3f71963c
No related branches found
No related tags found
No related merge requests found
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
* *
*/ */
load("funclib.js");
/* main layout object, intended to contain child layout view objects */ /* main layout object, intended to contain child layout view objects */
function Layout(frame) { function Layout(frame) {
...@@ -157,13 +159,8 @@ function Layout(frame) { ...@@ -157,13 +159,8 @@ function Layout(frame) {
return false; return false;
switch(cmd.toUpperCase()) { switch(cmd.toUpperCase()) {
case "\t": case "\t":
if(properties.views.length > 1) { if(properties.views.length > 1)
properties.views[properties.index].active = false; nextView();
properties.index++;
if(properties.index >= properties.views.length)
properties.index = 0;
properties.views[properties.index].active = true;
}
return true; return true;
default: default:
if(properties.views.length > 0) if(properties.views.length > 0)
...@@ -174,6 +171,19 @@ function Layout(frame) { ...@@ -174,6 +171,19 @@ function Layout(frame) {
} }
/* constructor */ /* constructor */
function nextView() {
var start = properties.index++;
while(start !== properties.index) {
if(properties.index >= properties.views.length)
properties.index = 0;
if(properties.views[properties.index].can_focus) {
properties.views[start].active = false;
properties.views[properties.index].active = true;
break;
}
properties.index++;
}
}
function init(frame) { function init(frame) {
if(frame instanceof Frame) if(frame instanceof Frame)
frames.main = frame; frames.main = frame;
...@@ -201,6 +211,7 @@ function LayoutView(title,frame,parent) { ...@@ -201,6 +211,7 @@ function LayoutView(title,frame,parent) {
show_title:true, show_title:true,
show_tabs:true, show_tabs:true,
show_border:true, show_border:true,
can_focus:true,
active:false active:false
} }
var frames={ var frames={
...@@ -271,19 +282,36 @@ function LayoutView(title,frame,parent) { ...@@ -271,19 +282,36 @@ function LayoutView(title,frame,parent) {
this.__defineGetter__("current",function() { this.__defineGetter__("current",function() {
return properties.tabs[properties.index]; return properties.tabs[properties.index];
}); });
this.__defineSetter__("current",function(index) { this.__defineSetter__("current",function(title_or_index) {
if(properties.tabs[index]) { if(isNaN(title_or_index)) {
if(properties.index == index) for(var t=0;t<properties.tabs.length;t++) {
return false; if(properties.tabs[t].title.toUpperCase() == title_or_index.toUpperCase()) {
if(properties.tabs[properties.index]) properties.tabs[properties.index].active=false;
properties.tabs[properties.index].active=false; properties.index = t;
properties.index=index; properties.tabs[properties.index].active=true;
setTabs();
return true;
}
}
}
else if(properties.tabs[title_or_index]) {
properties.tabs[properties.index].active=false;
properties.index = title_or_index;
properties.tabs[properties.index].active=true; properties.tabs[properties.index].active=true;
setTabs(); setTabs();
return true; return true;
} }
return false; return false;
}); });
this.__defineGetter__("can_focus",function() {
return settings.can_focus;
});
this.__defineSetter__("can_focus",function(bool) {
if(typeof bool !== "boolean")
return false;
settings.can_focus = bool;
return true;
});
this.__defineSetter__("active",function(bool) { this.__defineSetter__("active",function(bool) {
if(typeof bool !== "boolean") if(typeof bool !== "boolean")
return false; return false;
...@@ -377,6 +405,7 @@ function LayoutView(title,frame,parent) { ...@@ -377,6 +405,7 @@ function LayoutView(title,frame,parent) {
properties.index = properties.tabs.length-1; properties.index = properties.tabs.length-1;
properties.tabs[properties.index].active = true; properties.tabs[properties.index].active = true;
setTabs(); setTabs();
return true;
} }
break; break;
case KEY_RIGHT: case KEY_RIGHT:
...@@ -387,6 +416,7 @@ function LayoutView(title,frame,parent) { ...@@ -387,6 +416,7 @@ function LayoutView(title,frame,parent) {
properties.index = 0; properties.index = 0;
properties.tabs[properties.index].active = true; properties.tabs[properties.index].active = true;
setTabs(); setTabs();
return true;
} }
break; break;
default: default:
...@@ -436,10 +466,8 @@ function LayoutView(title,frame,parent) { ...@@ -436,10 +466,8 @@ function LayoutView(title,frame,parent) {
} }
tab.cycle = function() { tab.cycle = function() {
var chan = this.chat.channels[this.title.toUpperCase()]; var chan = this.chat.channels[this.title.toUpperCase()];
if(!chan) { if(!chan)
this.parent.delTab(this.title);
return false; return false;
}
while(chan.messages.length > 0) { while(chan.messages.length > 0) {
var msg = chan.messages.shift(); var msg = chan.messages.shift();
var str = ""; var str = "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment