Alice
view release on metacpan or search on metacpan
share/static/alice.js view on Meta::CPAN
this.submit.observe("click", function (e) {
this.input.send(); e.stop()}.bind(this));
this.tabs.observe("webkitTransitionEnd", this.shiftEnd.bind(this));
this.tabs.observe("transitionend", this.shiftEnd.bind(this));
this.makeSortable();
this.setupTopic();
this.setupNicklist();
this.setupMenus();
},
getBacklog: function (win, max, limit) {
this.connection.requestChunk(win.id, limit, max);
},
fetchOembeds: function(cb) {
var req = new XMLHttpRequest();
req.open("GET", "https://noembed.com/providers");
req.onreadystatechange = function(){
share/static/alice.js view on Meta::CPAN
win.scrollToPosition(position);
});
},
actionHandlers: {
join: function (action) {
var win = this.getWindow(action['window'].id);
if (!win) {
this.insertWindow(action['window'].id, action.html);
win = this.openWindow(action['window']);
this.updateOverflowMenus();
if (this.selectedSet && !this.currentSetContains(win)) {
if (confirm("You joined "+win.title+" which is not in the '"+this.selectedSet+"' set. Do you want to add it?")) {
this.tabsets[this.selectedSet].push(win.id);
win.show();
Alice.tabsets.submit(this.tabsets);
}
else {
win.hide();
}
}
share/static/alice.js view on Meta::CPAN
openWindow: function(serialized, msgid) {
if (!msgid) msgid = this.msgid();
var win = new Alice.Window(this, serialized, msgid);
this.addWindow(win);
return win;
},
addWindow: function(win) {
this.window_map.set(win.id, win);
if (window.fluid)
window.fluid.addDockMenuItem(win.title, win.focus.bind(win));
},
removeWindow: function(win) {
this.tabs_layout = this.tabs.getLayout();
this.windows().invoke("updateTabLayout");
if (win.active) this.focusLast();
if (window.fluid)
window.fluid.removeDockMenuItem(win.title);
if (win.id == this.previousFocus.id) {
this.previousFocus = 0;
}
this.window_map.unset(win.id);
this.connection.closeWindow(win);
win = null;
},
getWindow: function(windowId) {
return this.window_map.get(windowId);
share/static/alice.js view on Meta::CPAN
if (!nextTab) return;
var id = nextTab.id.replace('_tab','');
if (id != active.id) {
var win = this.getWindow(id);
win.focus();
return win;
}
},
updateOverflowMenus: function() {
var left = $('tab_menu_left');
var right = $('tab_menu_right');
left.removeClassName("unread");
left.removeClassName("highlight");
right.removeClassName("unread");
right.removeClassName("highlight");
var left_menu = left.down('ul');
var right_menu = right.down('ul');
share/static/alice.js view on Meta::CPAN
left_menu.innerHTML += sprintf('<li rel="%s" class="%s"><span>%s</span></a>', win.id, classes.join(" "), win.title)
}
else if (pos.right) {
var classes = win.statuses;
classes.each(function(c){right.addClassName(c)});
right_menu.innerHTML += sprintf('<li rel="%s" class="%s"><span>%s</span></a>', win.id, classes.join(" "), win.title)
}
}.bind(this));
this.toggleMenu(left, !!left_menu.innerHTML);
this.toggleMenu(right, !!right_menu.innerHTML);
},
toggleMenu: function(menu, active) {
if (active) {
menu.addClassName("active");
}
else {
menu.removeClassName("active");
}
},
nextUnreadWindow: function() {
var active = this.activeWindow();
share/static/alice.js view on Meta::CPAN
var left = current + shift;
var time = Math.min(Math.max(0.1, Math.abs(shift) / 100), 0.5);
this.tabs.style.webkitTransitionDuration = time+"s";
this.tabs.setStyle({left: left+"px"});
this.tabs_layout = this.tabs.getLayout();
},
shiftEnd: function(e) {
this.tabs_layout = this.tabs.getLayout();
this.updateOverflowMenus();
},
makeSortable: function() {
Sortable.create('tabs', {
overlap: 'horizontal',
constraint: 'horizontal',
format: /(.+)/,
only: ["info_tab", "channel_tab", "privmsg_tab"],
onUpdate: function (res) {
var tabs = res.childElements();
share/static/alice.js view on Meta::CPAN
window.fluid.dockBadge = 1;
},
clearMissed: function() {
if (!window.fluid) return;
window.fluid.dockBadge = "";
},
ready: function() {
this.freeze();
setTimeout(this.updateOverflowMenus.bind(this), 1000);
this.fetchOembeds(function() {
this.connection.connect(function() {
this.focusHash() || this.activeWindow().focus();
}.bind(this));
}.bind(this));
},
log: function () {
share/static/alice.js view on Meta::CPAN
this.selectSet(name);
var active = this.activeWindow();
if (!active.visible) {
active = this.nextWindow();
}
if (active) active.shiftTab();
setTimeout(this.updateOverflowMenus.bind(this), 2000);
}
},
selectSet: function(name) {
var hash = window.location.hash;
hash = hash.replace(/^[^\/]*/, name);
window.location.hash = hash;
window.location = window.location.toString();
this.selectedSet = name;
},
clearSet: function(elem) {
elem.up('ul').select('li').invoke('removeClassName', 'selectedset');
elem.addClassName('selectedset');
this.windows().invoke("show");
this.selectSet('');
this.updateOverflowMenus();
this.activeWindow().shiftTab();
},
currentSetContains: function(win) {
var set = this.selectedSet;
if (win.type == "channel" && set && this.tabsets[set]) {
return (this.tabsets[set].indexOf(win.id) >= 0);
}
return true;
},
share/static/alice.js view on Meta::CPAN
this.topic.observe(this.supportsTouch ? "touchstart" : "click", function(e) {
if (this.supportsTouch) e.stop();
if (this.topic.getStyle("height") == this.topic_height) {
this.topic.setStyle({height: "auto"});
} else {
this.topic.setStyle({height: this.topic_height});
}
}.bind(this));
},
setupMenus: function() {
var click = this.supportsTouch ? "touchend" : "mouseup";
$('join_button').observe(click, function (e) {
e.stop();
this.toggleJoin();
}.bind(this));
$('config_menu').on(click, ".dropdown li", function(e,li) {
e.stop();
var text = li.textContent;
share/static/alice.js view on Meta::CPAN
var windows = $('windows');
var toggle = $('nicklist_toggle');
var resize = function () {
var active = alice.activeWindow();
var position = active.captureScrollPosition();
var end = function(){
alice.freeze();
alice.tabs_width = $('tabs_container').getWidth();
alice.updateOverflowMenus();
active.scrollToPosition(position);
active.shiftTab();
window.onresize = resize;
};
var end_timer;
window.onresize = function() {
clearTimeout(end_timer);
end_timer = setTimeout(end, 1000);
share/static/alice.js view on Meta::CPAN
};
};
window.onmousemove = move;
window.onfocus = function () {
alice.input.focus();
alice.freeze();
alice.tabs_width = $('tabs_container').getWidth();
alice.updateOverflowMenus();
alice.isFocused = true
alice.clearMissed();
};
window.status = " ";
window.onblur = function () {
alice.isFocused = false
};
}
( run in 0.534 second using v1.01-cache-2.11-cpan-49f99fa48dc )