Comment out some of the sidebar code that is no longer used and add a cookie set and get for sticky chat view

This commit is contained in:
John McLear 2012-01-28 22:24:14 +00:00
parent 3ca5a0877b
commit e68643b67e
2 changed files with 24 additions and 8 deletions

View File

@ -22,6 +22,7 @@
var padutils = require('/pad_utils').padutils; var padutils = require('/pad_utils').padutils;
var browser = require('/ace2_common').browser; var browser = require('/ace2_common').browser;
var padcookie = require('/pad_cookie').padcookie;
var chat = (function() var chat = (function()
{ {
@ -69,16 +70,17 @@ var chat = (function()
chatMentions = 0; chatMentions = 0;
document.title = title; document.title = title;
}, },
stickToScreen: function() // Make chat stick to right hand side of screen stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen
{ {
console.log(isStuck);
chat.show(); chat.show();
if(!isStuck) { // Stick it to if(!isStuck || fromInitialCall) { // Stick it to
padcookie.setPref("chatAlwaysVisible", true);
$('#chatbox').css({"right":"0px", "top":"36px", "border-radius":"0px", "height":"auto", "border-right":"none", "border-left":"1px solid #ccc", "border-top":"none", "background-color":"#f1f1f1", "width":"185px"}); $('#chatbox').css({"right":"0px", "top":"36px", "border-radius":"0px", "height":"auto", "border-right":"none", "border-left":"1px solid #ccc", "border-top":"none", "background-color":"#f1f1f1", "width":"185px"});
$('#chattext').css({"top":"0px"}); $('#chattext').css({"top":"0px"});
$('#editorcontainer').css({"right":"192px", "width":"auto"}); $('#editorcontainer').css({"right":"192px", "width":"auto"});
isStuck = true; isStuck = true;
} else { // Unstick it } else { // Unstick it
padcookie.setPref("chatAlwaysVisible", false);
$('#chatbox').css({"right":"20px", "top":"auto", "border-top-left-radius":"5px", "border-top-right-radius":"5px", "border-right":"1px solid #999", "height":"200px", "border-top":"1px solid #999", "background-color":"#f7f7f7"}); $('#chatbox').css({"right":"20px", "top":"auto", "border-top-left-radius":"5px", "border-top-right-radius":"5px", "border-right":"1px solid #999", "height":"200px", "border-top":"1px solid #999", "background-color":"#f7f7f7"});
$('#chattext').css({"top":"25px"}); $('#chattext').css({"top":"25px"});
$('#editorcontainer').css({"right":"0px", "width":"100%"}); $('#editorcontainer').css({"right":"0px", "width":"100%"});

View File

@ -358,7 +358,6 @@ function handshake()
} }
} }
}); });
// Bind the colorpicker // Bind the colorpicker
var fb = $('#colorpicker').farbtastic({ callback: '#mycolorpickerpreview', width: 220}); var fb = $('#colorpicker').farbtastic({ callback: '#mycolorpickerpreview', width: 220});
} }
@ -450,7 +449,7 @@ var pad = {
padcookie.init(clientVars.cookiePrefsToSet); padcookie.init(clientVars.cookiePrefsToSet);
$("#widthprefcheck").click(pad.toggleWidthPref); $("#widthprefcheck").click(pad.toggleWidthPref);
$("#sidebarcheck").click(pad.toggleSidebar); // $("#sidebarcheck").click(pad.togglewSidebar);
pad.myUserInfo = { pad.myUserInfo = {
userId: clientVars.userId, userId: clientVars.userId,
@ -775,15 +774,17 @@ var pad = {
padsavedrevs.handleIsFullyConnected(isConnected); padsavedrevs.handleIsFullyConnected(isConnected);
pad.determineSidebarVisibility(isConnected && !isInitialConnect); // pad.determineSidebarVisibility(isConnected && !isInitialConnect);
pad.determineChatVisibility(isConnected && !isInitialConnect);
}, },
determineSidebarVisibility: function(asNowConnectedFeedback) /* determineSidebarVisibility: function(asNowConnectedFeedback)
{ {
if (pad.isFullyConnected()) if (pad.isFullyConnected())
{ {
var setSidebarVisibility = padutils.getCancellableAction("set-sidebar-visibility", function() var setSidebarVisibility = padutils.getCancellableAction("set-sidebar-visibility", function()
{ {
$("body").toggleClass('hidesidebar', !! padcookie.getPref('hideSidebar')); // $("body").toggleClass('hidesidebar', !! padcookie.getPref('hideSidebar'));
}); });
window.setTimeout(setSidebarVisibility, asNowConnectedFeedback ? 3000 : 0); window.setTimeout(setSidebarVisibility, asNowConnectedFeedback ? 3000 : 0);
} }
@ -793,6 +794,17 @@ var pad = {
$("body").removeClass('hidesidebar'); $("body").removeClass('hidesidebar');
} }
}, },
*/
determineChatVisibility: function(asNowConnectedFeedback){
var chatVisCookie = padcookie.getPref('chatAlwaysVisible');
if(chatVisCookie){ // if the cookie is set for chat always visible
chat.stickToScreen(true); // stick it to the screen
$('#options-stickychat').prop("checked", true); // set the checkbox to on
}
else{
$('#options-stickychat').prop("checked", false); // set the checkbox for off
}
},
handleCollabAction: function(action) handleCollabAction: function(action)
{ {
if (action == "commitPerformed") if (action == "commitPerformed")
@ -841,6 +853,7 @@ var pad = {
$("#widthprefcheck").toggleClass('widthprefchecked', !! newValue).toggleClass('widthprefunchecked', !newValue); $("#widthprefcheck").toggleClass('widthprefchecked', !! newValue).toggleClass('widthprefunchecked', !newValue);
pad.handleWidthChange(); pad.handleWidthChange();
}, },
/*
toggleSidebar: function() toggleSidebar: function()
{ {
var newValue = !padcookie.getPref('hideSidebar'); var newValue = !padcookie.getPref('hideSidebar');
@ -848,6 +861,7 @@ var pad = {
$("#sidebarcheck").toggleClass('sidebarchecked', !newValue).toggleClass('sidebarunchecked', !! newValue); $("#sidebarcheck").toggleClass('sidebarchecked', !newValue).toggleClass('sidebarunchecked', !! newValue);
pad.determineSidebarVisibility(); pad.determineSidebarVisibility();
}, },
*/
handleWidthChange: function() handleWidthChange: function()
{ {
var isFullWidth = padcookie.getPref('fullWidth'); var isFullWidth = padcookie.getPref('fullWidth');