mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
userlist/embed working again
This commit is contained in:
parent
540156735c
commit
0b8b380d2b
6 changed files with 239 additions and 153 deletions
|
@ -81,29 +81,29 @@ var padeditbar = (function(){
|
|||
if (cmd == 'showusers') {
|
||||
// show users shows the current users on teh pad
|
||||
// get current height
|
||||
var editbarheight = $('#editbar').css('height');
|
||||
if (editbarheight == "36px"){
|
||||
var editbarheight = $('#users').css('display');
|
||||
if (editbarheight == "none"){
|
||||
// increase the size of the editbar
|
||||
$('#editbar').animate({height:'72px'});
|
||||
$('#editorcontainerbox').animate({top:'72px'});
|
||||
//$('#editbar').animate({height:'72px'});
|
||||
//$('#editorcontainerbox').animate({top:'72px'});
|
||||
$('#embed').hide();
|
||||
$('#users').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// increase the size of the editbar
|
||||
$('#editbar').animate({height:'36px'});
|
||||
$('#editorcontainerbox').animate({top:'36px'});
|
||||
//$('#editbar').animate({height:'36px'});
|
||||
//$('#editorcontainerbox').animate({top:'36px'});
|
||||
$('#users').hide();
|
||||
}
|
||||
}
|
||||
if (cmd == 'embed') {
|
||||
// embed shows the embed link
|
||||
// get current height
|
||||
var editbarheight = $('#editbar').css('height');
|
||||
if (editbarheight == "36px"){
|
||||
var editbarheight = $('#embed').css('display');
|
||||
if (editbarheight == "none"){
|
||||
// increase the size of the editbar
|
||||
$('#editbar').animate({height:'72px'});
|
||||
//$('#editbar').animate({height:'72px'});
|
||||
$('#editorcontainerbox').animate({top:'72px'});
|
||||
// hide the users
|
||||
$('#users').hide();
|
||||
|
@ -111,12 +111,13 @@ var padeditbar = (function(){
|
|||
padurl = document.location;
|
||||
// change the div contents to include the pad url in an input box
|
||||
$('#embed').html('<div id="embedcode">Embed code:<input id="embedinput" type="text" value="<iframe src="'+padurl+'" width=500 height=400>"</iframe>></div>');
|
||||
$('#users').hide();
|
||||
$('#embed').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// increase the size of the editbar
|
||||
$('#editbar').animate({height:'36px'});
|
||||
//$('#editbar').animate({height:'36px'});
|
||||
$('#editorcontainerbox').animate({top:'36px'});
|
||||
$('#embed').hide();
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ var padmodals = (function() {
|
|||
init: function() {
|
||||
self.initFeedback();
|
||||
self.initShareBox();
|
||||
console.log("self.initShareBox");
|
||||
},
|
||||
initFeedback: function() {
|
||||
/*var emailField = $("#feedbackbox-email");
|
||||
|
@ -78,8 +79,9 @@ var padmodals = (function() {
|
|||
});
|
||||
},
|
||||
initShareBox: function() {
|
||||
$("#sharebutton, #nootherusers a").click(function() {
|
||||
$("#sharebutton").click(function() {
|
||||
self.showShareBox();
|
||||
console.log("share");
|
||||
});
|
||||
$("#sharebox-hide").click(function() {
|
||||
self.hideModal();
|
||||
|
|
|
@ -20,67 +20,6 @@ var colorPickerOpen = false;
|
|||
var colorPickerSetup = false;
|
||||
var previousColorId = 0;
|
||||
|
||||
function getColorPickerSwatchIndex(jnode) {
|
||||
// return Number(jnode.get(0).className.match(/\bn([0-9]+)\b/)[1])-1;
|
||||
return $("#colorpickerswatches li").index(jnode);
|
||||
}
|
||||
function closeColorPicker(accept) {
|
||||
if (accept) {
|
||||
var newColorId = getColorPickerSwatchIndex($("#colorpickerswatches .picked"));
|
||||
if (newColorId >= 0) { // fails on NaN
|
||||
myUserInfo.colorId = newColorId;
|
||||
pad.notifyChangeColor(newColorId);
|
||||
}
|
||||
} else {
|
||||
pad.notifyChangeColor(previousColorId);
|
||||
}
|
||||
colorPickerOpen = false;
|
||||
$("#mycolorpicker").css('display', 'none');
|
||||
//renderMyUserInfo();
|
||||
}
|
||||
|
||||
function showColorPicker() {
|
||||
previousColorId = myUserInfo.colorId ;
|
||||
|
||||
if (! colorPickerOpen) {
|
||||
var palette = pad.getColorPalette();
|
||||
|
||||
if(!colorPickerSetup) {
|
||||
var colorsList = $("#colorpickerswatches")
|
||||
for(var i=0;i<palette.length;i++) {
|
||||
|
||||
var li = $('<li>', {
|
||||
style: 'background: '+palette[i]+';'
|
||||
});
|
||||
|
||||
li.appendTo(colorsList);
|
||||
|
||||
li.bind('click', function(event){
|
||||
$("#colorpickerswatches li").removeClass('picked');
|
||||
$(event.target).addClass("picked");
|
||||
|
||||
var newColorId = getColorPickerSwatchIndex($("#colorpickerswatches .picked"));
|
||||
pad.notifyChangeColor(newColorId);
|
||||
});
|
||||
|
||||
if(myUserInfo.colorId == i){
|
||||
$(event.target).addClass("picked");
|
||||
}
|
||||
}
|
||||
|
||||
colorPickerSetup = true;
|
||||
}
|
||||
|
||||
$("#mycolorpicker").css('display', 'block');
|
||||
colorPickerOpen = true;
|
||||
|
||||
$("#colorpickerswatches li").removeClass('picked');
|
||||
$($("#colorpickerswatches li")[myUserInfo.colorId]).addClass("picked"); //seems weird
|
||||
|
||||
//paduserlist.renderMyUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var paduserlist = (function() {
|
||||
|
||||
|
@ -366,26 +305,6 @@ var paduserlist = (function() {
|
|||
});
|
||||
}
|
||||
|
||||
function renderMyUserInfo() {
|
||||
if (myUserInfo.name) {
|
||||
$("#myusernameedit").removeClass("editempty").val(
|
||||
myUserInfo.name);
|
||||
}
|
||||
else {
|
||||
$("#myusernameedit").addClass("editempty").val(
|
||||
"< enter your name >");
|
||||
}
|
||||
if (colorPickerOpen) {
|
||||
$("#myswatchbox").addClass('myswatchboxunhoverable').removeClass(
|
||||
'myswatchboxhoverable');
|
||||
}
|
||||
else {
|
||||
$("#myswatchbox").addClass('myswatchboxhoverable').removeClass(
|
||||
'myswatchboxunhoverable');
|
||||
}
|
||||
$("#myswatch").css('background', pad.getColorPalette()[myUserInfo.colorId]);
|
||||
}
|
||||
|
||||
function findExistingIndex(userId) {
|
||||
var existingIndex = -1;
|
||||
for(var i=0;i<otherUsersInfo.length;i++) {
|
||||
|
@ -451,7 +370,7 @@ var paduserlist = (function() {
|
|||
var self = {
|
||||
init: function(myInitialUserInfo) {
|
||||
self.setMyUserInfo(myInitialUserInfo);
|
||||
|
||||
console.log(myInitialUserInfo);
|
||||
$("#otheruserstable tr").remove();
|
||||
|
||||
if (pad.getUserIsGuest()) {
|
||||
|
@ -466,7 +385,7 @@ var paduserlist = (function() {
|
|||
// wrap with setTimeout to do later because we get
|
||||
// a double "blur" fire in IE...
|
||||
window.setTimeout(function() {
|
||||
renderMyUserInfo();
|
||||
self.renderMyUserInfo();
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
|
@ -489,7 +408,7 @@ var paduserlist = (function() {
|
|||
setMyUserInfo: function(info) {
|
||||
myUserInfo = $.extend({}, info);
|
||||
|
||||
renderMyUserInfo();
|
||||
self.renderMyUserInfo();
|
||||
},
|
||||
userJoinOrUpdate: function(info) {
|
||||
if ((! info.userId) || (info.userId == myUserInfo.userId)) {
|
||||
|
@ -631,7 +550,89 @@ var paduserlist = (function() {
|
|||
pad.sendClientMessage(msg);
|
||||
|
||||
self.removeGuestPrompt(guestId);
|
||||
},
|
||||
renderMyUserInfo: function() {
|
||||
if (myUserInfo.name) {
|
||||
$("#myusernameedit").removeClass("editempty").val(
|
||||
myUserInfo.name);
|
||||
}
|
||||
else {
|
||||
$("#myusernameedit").addClass("editempty").val(
|
||||
"Enter your name");
|
||||
}
|
||||
if (colorPickerOpen) {
|
||||
$("#myswatchbox").addClass('myswatchboxunhoverable').removeClass(
|
||||
'myswatchboxhoverable');
|
||||
}
|
||||
else {
|
||||
$("#myswatchbox").addClass('myswatchboxhoverable').removeClass(
|
||||
'myswatchboxunhoverable');
|
||||
}
|
||||
$("#myswatch").css('background', pad.getColorPalette()[myUserInfo.colorId]);
|
||||
}
|
||||
};
|
||||
return self;
|
||||
}());
|
||||
}());
|
||||
|
||||
function getColorPickerSwatchIndex(jnode) {
|
||||
// return Number(jnode.get(0).className.match(/\bn([0-9]+)\b/)[1])-1;
|
||||
return $("#colorpickerswatches li").index(jnode);
|
||||
}
|
||||
function closeColorPicker(accept) {
|
||||
if (accept) {
|
||||
var newColorId = getColorPickerSwatchIndex($("#colorpickerswatches .picked"));
|
||||
if (newColorId >= 0) { // fails on NaN
|
||||
myUserInfo.colorId = newColorId;
|
||||
pad.notifyChangeColor(newColorId);
|
||||
}
|
||||
|
||||
paduserlist.renderMyUserInfo();
|
||||
} else {
|
||||
pad.notifyChangeColor(previousColorId);
|
||||
paduserlist.renderMyUserInfo();
|
||||
}
|
||||
|
||||
colorPickerOpen = false;
|
||||
$("#mycolorpicker").css('display', 'none');
|
||||
}
|
||||
|
||||
function showColorPicker() {
|
||||
previousColorId = myUserInfo.colorId ;
|
||||
|
||||
if (! colorPickerOpen) {
|
||||
var palette = pad.getColorPalette();
|
||||
|
||||
if(!colorPickerSetup) {
|
||||
var colorsList = $("#colorpickerswatches")
|
||||
for(var i=0;i<palette.length;i++) {
|
||||
|
||||
var li = $('<li>', {
|
||||
style: 'background: '+palette[i]+';'
|
||||
});
|
||||
|
||||
li.appendTo(colorsList);
|
||||
|
||||
li.bind('click', function(event){
|
||||
$("#colorpickerswatches li").removeClass('picked');
|
||||
$(event.target).addClass("picked");
|
||||
|
||||
var newColorId = getColorPickerSwatchIndex($("#colorpickerswatches .picked"));
|
||||
pad.notifyChangeColor(newColorId);
|
||||
});
|
||||
|
||||
if(myUserInfo.colorId == i){
|
||||
$(event.target).addClass("picked");
|
||||
}
|
||||
}
|
||||
|
||||
colorPickerSetup = true;
|
||||
}
|
||||
|
||||
$("#mycolorpicker").css('display', 'block');
|
||||
colorPickerOpen = true;
|
||||
|
||||
$("#colorpickerswatches li").removeClass('picked');
|
||||
$($("#colorpickerswatches li")[myUserInfo.colorId]).addClass("picked"); //seems weird
|
||||
console.log(paduserlist);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue