A friend of mine who does development for the Caravel CMS got interested in roundcube yesterday when I was showing him the latest svn. Since I can't program my way out of a soggy paper bag with javascript I asked if he'd take a shot at making the preview pane resize able. A few hour later he threw me this diff that I've just installed and tested. Nifty stuff. I'm working on saving the size of the pane in user preferences but I wanted to get his unmodified code out here for anyone else to use/see. So here's the code to resize the preview pane courtesy of David Glick from the Caravel CMS crew.
-Ryan
-- Network Administrator Goshen College (574) 535-7004
--- program/include/main.inc (revision 408) +++ program/include/main.inc (working copy) @@ -1277,6 +1277,7 @@ // GENERAL 'loginform' => 'rcmail_login_form', 'username' => 'rcmail_current_username',
'splitter' => 'rcube_splitter',
// MAIL
'mailboxlist' => 'rcmail_mailbox_list',
@@ -1912,7 +1913,19 @@ return $select->show($set); }
+function rcube_splitter($attrib)
{
global $OUTPUT, $JS_OBJECT_NAME;
// register splitter in the system
$OUTPUT->add_script(sprintf("%s.register_splitter('%s', '%s', '%s');",
$JS_OBJECT_NAME,
$attrib['first'],
$attrib['second'],
$attrib['orientation']));
}
/****** debugging functions ********/
--- program/js/common.js (revision 408) +++ program/js/common.js (working copy) }
+/**
+function rcube_splitter(attrib)
this.layer = new rcube_layer(this.id, {x: this.p1pos.x, y: top, width: this.p1.offsetWidth, height: height, zindex: 1, vis: 1});
this.layer = new rcube_layer(this.id, {x: left, y: this.p1pos.y, width: width, height: this.p1.offsetHeight, zindex: 1, vis: 1});
this.elm.style.paddingTop = Math.floor(height / 2) + 'px';
this.elm.style.paddingLeft = Math.floor(width / 2) + 'px';
{
this.line.style.borderTopWidth = '1px';
this.line.style.width = '100%';
this.line.style.height = '1px';
}
{
this.line.style.borderLeftWidth = '1px';
this.line.style.width = '1px';
this.line.style.height = '100%';
}
{
if (iframes[n].contentDocument)
{
// I don't use the add_listener function for this one because I need to create closures to fetch
// the position of each iframe when the event is received
var s = this;
var id = iframes[n].id;
this.iframe_events[n] = function(e){ e._rc_pos_offset = rcube_get_object_pos(document.getElementById(id)); return s.onDrag(e); }
if (iframes[n].contentDocument.addEventListener)
iframes[n].contentDocument.addEventListener('mousemove', this.iframe_events[n], false);
else if (p.element.attachEvent)
iframes[n].contentDocument.attachEvent('onmousemove', this.iframe_events[n]);
else
iframes[n].contentDocument['onmousemove'] = this.iframe_events[n];
rcube_event.add_listener({element:iframes[n].contentDocument, event:'mouseup', object:this, method:'onDragStop'});
}
}
{
pos.x += e._rc_pos_offset.x;
pos.y += e._rc_pos_offset.y;
}
{
// resize the panels
if (pos.y > this.p1pos.y && pos.y < this.p2pos.y + this.p2.offsetHeight)
{
this.p1.style.height = Math.round(pos.y - this.p1pos.y - this.layer.height / 2 - 1) + 'px';
this.p2.style.top = Math.round(pos.y + this.layer.height / 2 + 1) + 'px';
}
// move the splitter handle
this.layer.move(this.layer.x, Math.round(pos.y - this.layer.height / 2 + 1));
}
{
if (pos.x > this.p1pos.x && pos.x < this.p2pos.x + this.p2.offsetWidth)
{
this.p1.style.width = Math.round(pos.x - this.p1pos.x - this.layer.width / 2 - 1) + 'px';
this.p2.style.left = Math.round(pos.x + this.layer.width / 2 + 1) + 'px';
}
this.layer.move(Math.round(pos.x - this.layer.width / 2 + 1), this.layer.y);
}
{
if (iframes[n].contentDocument)
{
if (this.iframe_events[n]) {
if (iframes[n].contentDocument.removeEventListener)
iframes[n].contentDocument.removeEventListener('mousemove', this.iframe_events[n], false);
else if (iframes[n].contentDocument.detachEvent)
iframes[n].contentDocument.detachEvent('onmousemove', this.iframe_events[n]);
else
iframes[n].contentDocument['onmousemove'] = null;
}
rcube_event.remove_listener({element:iframes[n].contentDocument, event:'mouseup', object:this, method:'onDragStop'});
}
}
// check if input is a valid email address // By Cal Henderson cal@iamcal.com // http://code.iamcal.com/php/rfc822/ Index: program/js/app.js =================================================================== --- program/js/app.js (revision 408) +++ program/js/app.js (working copy) @@ -24,6 +24,7 @@ this.env = new Object(); this.labels = new Object(); this.buttons = new Object();
@@ -78,6 +79,13 @@ };
@@ -108,6 +116,10 @@
// enable general commands
this.enable_command('logout', 'mail', 'addressbook', 'settings', true);
// initialize splitters
for (var n in this.splitters)
this.splitters[n].init();
switch (this.task) {
--- skins/default/common.css (revision 408) +++ skins/default/common.css (working copy) @@ -213,7 +213,20 @@ border: 1px solid #CCCCCC; }
+.splitter +{
+}
+.splitterLine +{
+}
/***** common table settings ******/
table.records-table thead tr td Index: skins/default/templates/mail.html =================================================================== --- skins/default/templates/mail.html (revision 408) +++ skins/default/templates/mail.html (working copy) @@ -55,6 +55,7 @@
</div>
<roundcube:if condition="config:preview_pane == true" /> +<roundcube:object name="splitter" first="mailcontframe" second="mailpreviewframe" orientation="horizontal" />
<div id="mailpreviewframe"> <roundcube:object name="messagecontentframe" id="messagecontframe" width="100%" height="100%" frameborder="0" src="/watermark.html" /> </div> Index: skins/default/templates/addressbook.html =================================================================== --- skins/default/templates/addressbook.html (revision 408) +++ skins/default/templates/addressbook.html (working copy) @@ -31,6 +31,8 @@ <roundcube:object name="addresslist" id="contacts-table" class="records-table" cellspacing="0" summary="Contacts list" /> </div>
+<roundcube:object name="splitter" first="addresslist" second="contacts-box" orientation="vertical" />
<div id="contacts-box"> <roundcube:object name="addressframe" id="contact-frame" width="100%" height="100%" frameborder="0" src="/watermark.html" /> </div>
Or maybe not... it works on our test box but not on anything else... guess he forgot something in the diff. I'll repost when I'm sure it working and stop wasting everyone's time.
-Ryan