mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-15 11:36:53 -04:00
Merge ddba3878e9
into 26ccb1fa3e
This commit is contained in:
commit
71ad6bc250
12 changed files with 401 additions and 11 deletions
|
@ -33,7 +33,9 @@
|
||||||
"pad.settings.fontType.normal": "Normal",
|
"pad.settings.fontType.normal": "Normal",
|
||||||
"pad.settings.fontType.monospaced": "Monospace",
|
"pad.settings.fontType.monospaced": "Monospace",
|
||||||
"pad.settings.globalView": "Global View",
|
"pad.settings.globalView": "Global View",
|
||||||
|
"pad.settings.globalView.warning": "Warning: This will affect everyone's view of this pad.",
|
||||||
"pad.settings.language": "Language:",
|
"pad.settings.language": "Language:",
|
||||||
|
"pad.settings.ignoreglobal": "Ignore global settings",
|
||||||
"pad.importExport.import_export": "Import/Export",
|
"pad.importExport.import_export": "Import/Export",
|
||||||
"pad.importExport.import": "Upload any text file or document",
|
"pad.importExport.import": "Upload any text file or document",
|
||||||
"pad.importExport.importSuccessful": "Successful!",
|
"pad.importExport.importSuccessful": "Successful!",
|
||||||
|
|
|
@ -39,6 +39,7 @@ var Pad = function Pad(id) {
|
||||||
this.chatHead = -1;
|
this.chatHead = -1;
|
||||||
this.publicStatus = false;
|
this.publicStatus = false;
|
||||||
this.passwordHash = null;
|
this.passwordHash = null;
|
||||||
|
this.viewSettings = {};
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.savedRevisions = [];
|
this.savedRevisions = [];
|
||||||
};
|
};
|
||||||
|
@ -57,6 +58,14 @@ Pad.prototype.getPublicStatus = function getPublicStatus() {
|
||||||
return this.publicStatus;
|
return this.publicStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Pad.prototype.getViewSettings = function getViewSettings() {
|
||||||
|
return this.viewSettings;
|
||||||
|
};
|
||||||
|
|
||||||
|
Pad.prototype.getViewSetting = function getViewSettings(setting) {
|
||||||
|
return this.viewSettings[setting];
|
||||||
|
};
|
||||||
|
|
||||||
Pad.prototype.appendRevision = function appendRevision(aChangeset, author) {
|
Pad.prototype.appendRevision = function appendRevision(aChangeset, author) {
|
||||||
if(!author)
|
if(!author)
|
||||||
author = '';
|
author = '';
|
||||||
|
@ -513,6 +522,16 @@ Pad.prototype.setPublicStatus = function setPublicStatus(publicStatus) {
|
||||||
this.saveToDatabase();
|
this.saveToDatabase();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Pad.prototype.setViewSettings = function setPublicStatus(viewSettings) {
|
||||||
|
this.viewSettings = viewSettings;
|
||||||
|
this.saveToDatabase();
|
||||||
|
};
|
||||||
|
|
||||||
|
Pad.prototype.setViewSetting = function setPublicStatus(setting, value) {
|
||||||
|
this.viewSettings[setting] = value;
|
||||||
|
this.saveToDatabase();
|
||||||
|
};
|
||||||
|
|
||||||
Pad.prototype.setPassword = function setPassword(password) {
|
Pad.prototype.setPassword = function setPassword(password) {
|
||||||
this.passwordHash = password == null ? null : hash(password, generateSalt());
|
this.passwordHash = password == null ? null : hash(password, generateSalt());
|
||||||
this.saveToDatabase();
|
this.saveToDatabase();
|
||||||
|
|
|
@ -187,6 +187,8 @@ exports.handleMessage = function(client, message)
|
||||||
handleGetChatMessages(client, message);
|
handleGetChatMessages(client, message);
|
||||||
} else if (message.data.type == "SAVE_REVISION") {
|
} else if (message.data.type == "SAVE_REVISION") {
|
||||||
handleSaveRevisionMessage(client, message);
|
handleSaveRevisionMessage(client, message);
|
||||||
|
} else if (message.data.type == "GLOBAL_SETTING_CHANGED") {
|
||||||
|
handleGlobalSettingChangedMessage(client, message);
|
||||||
} else if (message.data.type == "CLIENT_MESSAGE" &&
|
} else if (message.data.type == "CLIENT_MESSAGE" &&
|
||||||
message.data.payload != null &&
|
message.data.payload != null &&
|
||||||
message.data.payload.type == "suggestUserName") {
|
message.data.payload.type == "suggestUserName") {
|
||||||
|
@ -254,6 +256,55 @@ function handleSaveRevisionMessage(client, message){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a global setting changed message
|
||||||
|
* @param client the client that send this message
|
||||||
|
* @param message the message from the client
|
||||||
|
*/
|
||||||
|
function handleGlobalSettingChangedMessage(client, message){
|
||||||
|
var padId = sessioninfos[client.id].padId;
|
||||||
|
var userId = sessioninfos[client.id].author;
|
||||||
|
|
||||||
|
if(message.data.setting == null)
|
||||||
|
{
|
||||||
|
messageLogger.warn("Dropped message, GlobalSettingChanged Message has no setting!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(message.data.value == null)
|
||||||
|
{
|
||||||
|
messageLogger.warn("Dropped message, GlobalSettingChanged Message has no value!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var setting = message.data.setting;
|
||||||
|
var value = message.data.value;
|
||||||
|
|
||||||
|
// check for illegal values
|
||||||
|
if(setting != "showLineNumbers" && setting != "showAuthorColors" && setting != "useMonospaceFont")
|
||||||
|
{
|
||||||
|
messageLogger.warn("Dropped message, GlobalSettingChanged Message has an invalid setting!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(value != true && value != false)
|
||||||
|
{
|
||||||
|
messageLogger.warn("Dropped message, GlobalSettingChanged Message has an invalid value!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
padManager.getPad(padId, function(err, pad)
|
||||||
|
{
|
||||||
|
if(ERR(err)) return;
|
||||||
|
|
||||||
|
// save changed value to the db
|
||||||
|
pad.setViewSetting(setting, value);
|
||||||
|
|
||||||
|
// tell the users that a setting has been changed
|
||||||
|
for (var i in pad2sessions[padId]) {
|
||||||
|
socketio.sockets.sockets[pad2sessions[padId][i]].json.send(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a custom message (sent via HTTP API request)
|
* Handles a custom message (sent via HTTP API request)
|
||||||
*
|
*
|
||||||
|
@ -983,6 +1034,7 @@ function handleClientReady(client, message)
|
||||||
"plugins": plugins.plugins,
|
"plugins": plugins.plugins,
|
||||||
"parts": plugins.parts,
|
"parts": plugins.parts,
|
||||||
},
|
},
|
||||||
|
"viewSettings": pad.getViewSettings(),
|
||||||
"initialChangesets": [] // FIXME: REMOVE THIS SHIT
|
"initialChangesets": [] // FIXME: REMOVE THIS SHIT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -807,6 +807,11 @@ input[type=checkbox] {
|
||||||
display: none;
|
display: none;
|
||||||
z-index: 500;
|
z-index: 500;
|
||||||
}
|
}
|
||||||
|
#globalViewWarning {
|
||||||
|
color: gray;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
.stickyChat {
|
.stickyChat {
|
||||||
background-color: #f1f1f1 !important;
|
background-color: #f1f1f1 !important;
|
||||||
right: 0px !important;
|
right: 0px !important;
|
||||||
|
|
|
@ -424,6 +424,11 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
else // there are still more messages, re-show the load-button
|
else // there are still more messages, re-show the load-button
|
||||||
$("#chatloadmessagesbutton").css("display", "block");
|
$("#chatloadmessagesbutton").css("display", "block");
|
||||||
}
|
}
|
||||||
|
else if (msg.type == "GLOBAL_SETTING_CHANGED")
|
||||||
|
{
|
||||||
|
if(!pad.padOptions.ignoreGlobalSettings)
|
||||||
|
pad.changeViewOption(msg.setting, msg.value, true);
|
||||||
|
}
|
||||||
else if (msg.type == "SERVER_MESSAGE")
|
else if (msg.type == "SERVER_MESSAGE")
|
||||||
{
|
{
|
||||||
callbacks.onServerMessage(msg.payload);
|
callbacks.onServerMessage(msg.payload);
|
||||||
|
@ -444,6 +449,14 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeGlobalSetting(setting, value)
|
||||||
|
{
|
||||||
|
sendMessage({ "type" : "GLOBAL_SETTING_CHANGED",
|
||||||
|
"setting" : setting,
|
||||||
|
"value" : value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function tellAceActiveAuthorInfo(userInfo)
|
function tellAceActiveAuthorInfo(userInfo)
|
||||||
{
|
{
|
||||||
tellAceAuthorInfo(userInfo.userId, userInfo.colorId);
|
tellAceAuthorInfo(userInfo.userId, userInfo.colorId);
|
||||||
|
@ -675,7 +688,8 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
getMissedChanges: getMissedChanges,
|
getMissedChanges: getMissedChanges,
|
||||||
callWhenNotCommitting: callWhenNotCommitting,
|
callWhenNotCommitting: callWhenNotCommitting,
|
||||||
addHistoricalAuthors: tellAceAboutHistoricalAuthors,
|
addHistoricalAuthors: tellAceAboutHistoricalAuthors,
|
||||||
setChannelState: setChannelState
|
setChannelState: setChannelState,
|
||||||
|
changeGlobalSetting: changeGlobalSetting
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(setUpSocket);
|
$(document).ready(setUpSocket);
|
||||||
|
|
|
@ -308,7 +308,7 @@ function handshake()
|
||||||
// If the noColors value is set to true then we need to hide the background colors on the ace spans
|
// If the noColors value is set to true then we need to hide the background colors on the ace spans
|
||||||
if (settings.noColors == true)
|
if (settings.noColors == true)
|
||||||
{
|
{
|
||||||
pad.changeViewOption('noColors', true);
|
pad.changeViewOption('showAuthorColors', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.rtlIsTrue == true)
|
if (settings.rtlIsTrue == true)
|
||||||
|
@ -321,6 +321,31 @@ function handshake()
|
||||||
{
|
{
|
||||||
pad.changeViewOption('useMonospaceFont', true);
|
pad.changeViewOption('useMonospaceFont', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// settings which are global for all users of this pad, these overwrite
|
||||||
|
// all settings set in cookies or by the user. They will also get updated
|
||||||
|
// via a collabClient-message when they're changed later.
|
||||||
|
var viewSettings = clientVars.viewSettings;
|
||||||
|
|
||||||
|
// set the private options here if there is no global setting
|
||||||
|
$("#options-global-colorscheck").prop("checked", $("#options-colorscheck").prop("checked"));
|
||||||
|
$("#options-global-linenoscheck").prop("checked", $("#options-linenoscheck").prop("checked"));
|
||||||
|
$("#global-viewfontmenu").val($("#global-viewfontmenu").val());
|
||||||
|
|
||||||
|
// check if they are set, if they are overwrite whatever is set by the user
|
||||||
|
if (typeof(viewSettings.showLineNumbers) != "undefined")
|
||||||
|
{
|
||||||
|
pad.changeViewOption('showLineNumbers', viewSettings.showLineNumbers, true);
|
||||||
|
}
|
||||||
|
if (typeof(viewSettings.showAuthorColors) != "undefined")
|
||||||
|
{
|
||||||
|
pad.changeViewOption('showAuthorColors', viewSettings.showAuthorColors, true);
|
||||||
|
}
|
||||||
|
if (typeof(viewSettings.useMonospaceFont) != "undefined")
|
||||||
|
{
|
||||||
|
pad.changeViewOption('useMonospaceFont', viewSettings.useMonospaceFont, true);
|
||||||
|
}
|
||||||
|
|
||||||
// if the globalUserName value is set we need to tell the server and the client about the new authorname
|
// if the globalUserName value is set we need to tell the server and the client about the new authorname
|
||||||
if (settings.globalUserName !== false)
|
if (settings.globalUserName !== false)
|
||||||
{
|
{
|
||||||
|
@ -553,15 +578,15 @@ var pad = {
|
||||||
changedBy: pad.myUserInfo.name || "unnamed"
|
changedBy: pad.myUserInfo.name || "unnamed"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
changeViewOption: function(key, value)
|
changeViewOption: function(key, value, global)
|
||||||
{
|
{
|
||||||
var options = {
|
var options = {
|
||||||
view: {}
|
view: {}
|
||||||
};
|
};
|
||||||
options.view[key] = value;
|
options.view[key] = value;
|
||||||
pad.handleOptionsChange(options);
|
pad.handleOptionsChange(options, global);
|
||||||
},
|
},
|
||||||
handleOptionsChange: function(opts)
|
handleOptionsChange: function(opts, global)
|
||||||
{
|
{
|
||||||
// opts object is a full set of options or just
|
// opts object is a full set of options or just
|
||||||
// some options to change
|
// some options to change
|
||||||
|
@ -575,7 +600,7 @@ var pad = {
|
||||||
{
|
{
|
||||||
pad.padOptions.view[k] = opts.view[k];
|
pad.padOptions.view[k] = opts.view[k];
|
||||||
}
|
}
|
||||||
padeditor.setViewOptions(pad.padOptions.view);
|
padeditor.setViewOptions(pad.padOptions.view, global);
|
||||||
}
|
}
|
||||||
if (opts.guestPolicy)
|
if (opts.guestPolicy)
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,6 +62,7 @@ var padeditor = (function()
|
||||||
},
|
},
|
||||||
initViewOptions: function()
|
initViewOptions: function()
|
||||||
{
|
{
|
||||||
|
// my view
|
||||||
padutils.bindCheckboxChange($("#options-linenoscheck"), function()
|
padutils.bindCheckboxChange($("#options-linenoscheck"), function()
|
||||||
{
|
{
|
||||||
pad.changeViewOption('showLineNumbers', padutils.getCheckbox($("#options-linenoscheck")));
|
pad.changeViewOption('showLineNumbers', padutils.getCheckbox($("#options-linenoscheck")));
|
||||||
|
@ -76,6 +77,24 @@ var padeditor = (function()
|
||||||
pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace');
|
pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// global view
|
||||||
|
padutils.bindCheckboxChange($("#options-global-linenoscheck"), function()
|
||||||
|
{
|
||||||
|
pad.collabClient.changeGlobalSetting("showLineNumbers", $("#options-global-linenoscheck").prop('checked'));
|
||||||
|
});
|
||||||
|
padutils.bindCheckboxChange($("#options-global-colorscheck"), function()
|
||||||
|
{
|
||||||
|
pad.collabClient.changeGlobalSetting("showAuthorColors", $("#options-global-colorscheck").prop('checked'));
|
||||||
|
});
|
||||||
|
padutils.bindCheckboxChange($("#options-ignore-global"), function()
|
||||||
|
{
|
||||||
|
pad.padOptions.ignoreGlobalSettings = $("#options-ignore-global").prop('checked');
|
||||||
|
});
|
||||||
|
$("#global-viewfontmenu").change(function()
|
||||||
|
{
|
||||||
|
pad.collabClient.changeGlobalSetting("useMonospaceFont", $("#global-viewfontmenu").val() == 'monospace');
|
||||||
|
});
|
||||||
|
|
||||||
html10n.bind('localized', function() {
|
html10n.bind('localized', function() {
|
||||||
$("#languagemenu").val(html10n.getLanguage());
|
$("#languagemenu").val(html10n.getLanguage());
|
||||||
// translate the value of 'unnamed' and 'Enter your name' textboxes in the userlist
|
// translate the value of 'unnamed' and 'Enter your name' textboxes in the userlist
|
||||||
|
@ -95,7 +114,7 @@ var padeditor = (function()
|
||||||
window.html10n.localize([$("#languagemenu").val(), 'en']);
|
window.html10n.localize([$("#languagemenu").val(), 'en']);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setViewOptions: function(newOptions)
|
setViewOptions: function(newOptions, global)
|
||||||
{
|
{
|
||||||
function getOption(key, defaultValue)
|
function getOption(key, defaultValue)
|
||||||
{
|
{
|
||||||
|
@ -113,18 +132,27 @@ var padeditor = (function()
|
||||||
|
|
||||||
v = getOption('showLineNumbers', true);
|
v = getOption('showLineNumbers', true);
|
||||||
self.ace.setProperty("showslinenumbers", v);
|
self.ace.setProperty("showslinenumbers", v);
|
||||||
padutils.setCheckbox($("#options-linenoscheck"), v);
|
if(global)
|
||||||
|
padutils.setCheckbox($("#options-global-linenoscheck"), v);
|
||||||
|
else
|
||||||
|
padutils.setCheckbox($("#options-linenoscheck"), v);
|
||||||
|
|
||||||
v = getOption('showAuthorColors', true);
|
v = getOption('showAuthorColors', true);
|
||||||
self.ace.setProperty("showsauthorcolors", v);
|
self.ace.setProperty("showsauthorcolors", v);
|
||||||
padutils.setCheckbox($("#options-colorscheck"), v);
|
if(global)
|
||||||
|
padutils.setCheckbox($("#options-global-colorscheck"), v);
|
||||||
|
else
|
||||||
|
padutils.setCheckbox($("#options-colorscheck"), v);
|
||||||
// Override from parameters if true
|
// Override from parameters if true
|
||||||
if (settings.noColors !== false)
|
if (settings.noColors !== false)
|
||||||
self.ace.setProperty("showsauthorcolors", !settings.noColors);
|
self.ace.setProperty("showsauthorcolors", !settings.noColors);
|
||||||
|
|
||||||
v = getOption('useMonospaceFont', false);
|
v = getOption('useMonospaceFont', false);
|
||||||
self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif"));
|
self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif"));
|
||||||
$("#viewfontmenu").val(v ? "monospace" : "normal");
|
if(global)
|
||||||
|
$("#global-viewfontmenu").val(v ? "monospace" : "normal");
|
||||||
|
else
|
||||||
|
$("#viewfontmenu").val(v ? "monospace" : "normal");
|
||||||
},
|
},
|
||||||
dispose: function()
|
dispose: function()
|
||||||
{
|
{
|
||||||
|
|
|
@ -217,6 +217,10 @@
|
||||||
<input type="checkbox" id="options-linenoscheck" checked>
|
<input type="checkbox" id="options-linenoscheck" checked>
|
||||||
<label for="options-linenoscheck" data-l10n-id="pad.settings.linenocheck"></label>
|
<label for="options-linenoscheck" data-l10n-id="pad.settings.linenocheck"></label>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<input type="checkbox" id="options-ignore-global">
|
||||||
|
<label for="options-ignore-global" data-l10n-id="pad.settings.ignoreglobal"></label>
|
||||||
|
</p>
|
||||||
<% e.end_block(); %>
|
<% e.end_block(); %>
|
||||||
<table>
|
<table>
|
||||||
<% e.begin_block("mySettings.dropdowns"); %>
|
<% e.begin_block("mySettings.dropdowns"); %>
|
||||||
|
@ -249,6 +253,22 @@
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<% e.begin_block("globalSettings"); %>
|
<% e.begin_block("globalSettings"); %>
|
||||||
<h2 data-l10n-id="pad.settings.globalView"></h2>
|
<h2 data-l10n-id="pad.settings.globalView"></h2>
|
||||||
|
<p>
|
||||||
|
<input type="checkbox" id="options-global-colorscheck">
|
||||||
|
<label for="options-global-colorscheck" data-l10n-id="pad.settings.colorcheck"></label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<input type="checkbox" id="options-global-linenoscheck">
|
||||||
|
<label for="options-global-linenoscheck" data-l10n-id="pad.settings.linenocheck"></label>
|
||||||
|
</p>
|
||||||
|
<% e.begin_block("globalSettings.dropdowns"); %>
|
||||||
|
<label for="global-viewfontmenu" data-l10n-id="pad.settings.fontType"></label>
|
||||||
|
<select id="global-viewfontmenu">
|
||||||
|
<option value="normal" data-l10n-id="pad.settings.fontType.normal"></option>
|
||||||
|
<option value="monospace" data-l10n-id="pad.settings.fontType.monospaced"></option>
|
||||||
|
</select>
|
||||||
|
<% e.end_block(); %>
|
||||||
|
<p data-l10n-id="pad.settings.globalView.warning" id="globalViewWarning"></p>
|
||||||
<% e.end_block(); %>
|
<% e.end_block(); %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe("font select", function(){
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("makes text monospace", function(done) {
|
it("makes text monospace locally", function(done) {
|
||||||
var inner$ = helper.padInner$;
|
var inner$ = helper.padInner$;
|
||||||
var chrome$ = helper.padChrome$;
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
@ -27,4 +27,29 @@ describe("font select", function(){
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("makes text monospace globally", function(done) {
|
||||||
|
var inner$ = helper.padInner$;
|
||||||
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
//click on the settings button to make settings visible
|
||||||
|
var $settingsButton = chrome$(".buttonicon-settings");
|
||||||
|
$settingsButton.click();
|
||||||
|
|
||||||
|
//get the font menu and monospace option
|
||||||
|
var $viewfontmenu = chrome$("#global-viewfontmenu");
|
||||||
|
var $monospaceoption = $viewfontmenu.find("[value=monospace]");
|
||||||
|
|
||||||
|
//select monospace and fire change event
|
||||||
|
$monospaceoption.attr('selected','selected');
|
||||||
|
$viewfontmenu.change();
|
||||||
|
|
||||||
|
helper.waitFor(function(){
|
||||||
|
return inner$("body").css("font-family").toLowerCase() == "monospace";
|
||||||
|
}, 10000).always(function(){
|
||||||
|
var newValue = inner$("body").css("font-family").toLowerCase();
|
||||||
|
expect(newValue).to.be("monospace");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
66
tests/frontend/specs/hide_author_colors.js
Normal file
66
tests/frontend/specs/hide_author_colors.js
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
describe("hiding author-colors", function(){
|
||||||
|
//create a new pad before each test run
|
||||||
|
beforeEach(function(cb){
|
||||||
|
helper.newPad(cb);
|
||||||
|
this.timeout(60000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("hides the author-colors locally", function(done) {
|
||||||
|
var inner$ = helper.padInner$;
|
||||||
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
//click on the settings button to make settings visible
|
||||||
|
var $settingsButton = chrome$(".buttonicon-settings");
|
||||||
|
$settingsButton.click();
|
||||||
|
|
||||||
|
//get the chat selector
|
||||||
|
var $colorsCheckbox = chrome$("#options-colorscheck");
|
||||||
|
|
||||||
|
//get the current status of the author-colors
|
||||||
|
var oldValue = inner$("body").hasClass("authorColors");
|
||||||
|
|
||||||
|
//select show author colors and fire change event
|
||||||
|
$colorsCheckbox.attr('selected','selected');
|
||||||
|
$colorsCheckbox.change();
|
||||||
|
$colorsCheckbox.click();
|
||||||
|
|
||||||
|
//get the current status of the author-colors
|
||||||
|
var newValue = inner$("body").hasClass("authorColors");
|
||||||
|
|
||||||
|
expect(oldValue).not.to.be(newValue);
|
||||||
|
expect(newValue).to.be($colorsCheckbox.prop("checked"));
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("hides the author-colors globally", function(done) {
|
||||||
|
var inner$ = helper.padInner$;
|
||||||
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
this.timeout(10000);
|
||||||
|
|
||||||
|
//click on the settings button to make settings visible
|
||||||
|
var $settingsButton = chrome$(".buttonicon-settings");
|
||||||
|
$settingsButton.click();
|
||||||
|
|
||||||
|
//get the chat selector
|
||||||
|
var $colorsCheckbox = chrome$("#options-global-colorscheck");
|
||||||
|
|
||||||
|
//get the current status of the author-colors
|
||||||
|
var oldValue = inner$("body").hasClass("authorColors");
|
||||||
|
|
||||||
|
//select show author colors and fire change event
|
||||||
|
$colorsCheckbox.attr('selected','selected');
|
||||||
|
$colorsCheckbox.change();
|
||||||
|
$colorsCheckbox.click();
|
||||||
|
|
||||||
|
helper.waitFor(function(){
|
||||||
|
return inner$("body").hasClass("authorColors") == !oldValue;
|
||||||
|
}, 10000).always(function(){
|
||||||
|
var newValue = inner$("body").hasClass("authorColors");
|
||||||
|
expect(oldValue).not.to.be(newValue);
|
||||||
|
expect(newValue).to.be($colorsCheckbox.prop("checked"));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
66
tests/frontend/specs/hide_line_numbers.js
Normal file
66
tests/frontend/specs/hide_line_numbers.js
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
describe("hiding linenumbers", function(){
|
||||||
|
//create a new pad before each test run
|
||||||
|
beforeEach(function(cb){
|
||||||
|
helper.newPad(cb);
|
||||||
|
this.timeout(60000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("hides the linenumbers locally", function(done) {
|
||||||
|
var outer$ = helper.padOuter$;
|
||||||
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
//click on the settings button to make settings visible
|
||||||
|
var $settingsButton = chrome$(".buttonicon-settings");
|
||||||
|
$settingsButton.click();
|
||||||
|
|
||||||
|
//get the chat selector
|
||||||
|
var $linesCheckbox = chrome$("#options-linenoscheck");
|
||||||
|
|
||||||
|
//get the current status of the linenumbers
|
||||||
|
var oldValue = outer$("#sidediv").hasClass("sidedivhidden");
|
||||||
|
|
||||||
|
//select show linenumbers and fire change event
|
||||||
|
$linesCheckbox.attr('selected','selected');
|
||||||
|
$linesCheckbox.change();
|
||||||
|
$linesCheckbox.click();
|
||||||
|
|
||||||
|
//get the current status of the linenumbers
|
||||||
|
var newValue = outer$("#sidediv").hasClass("sidedivhidden");
|
||||||
|
|
||||||
|
expect(oldValue).not.to.be(newValue);
|
||||||
|
expect(newValue).to.be(!$linesCheckbox.prop("checked"));
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("hides the linenumbers globally", function(done) {
|
||||||
|
var outer$ = helper.padOuter$;
|
||||||
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
this.timeout(10000);
|
||||||
|
|
||||||
|
//click on the settings button to make settings visible
|
||||||
|
var $settingsButton = chrome$(".buttonicon-settings");
|
||||||
|
$settingsButton.click();
|
||||||
|
|
||||||
|
//get the chat selector
|
||||||
|
var $linesCheckbox = chrome$("#options-global-linenoscheck");
|
||||||
|
|
||||||
|
//get the current status of the linenumbers
|
||||||
|
var oldValue = outer$("#sidediv").hasClass("sidedivhidden");
|
||||||
|
|
||||||
|
//select show linenumbers and fire change event
|
||||||
|
$linesCheckbox.attr('selected','selected');
|
||||||
|
$linesCheckbox.change();
|
||||||
|
$linesCheckbox.click();
|
||||||
|
|
||||||
|
helper.waitFor(function(){
|
||||||
|
return outer$("#sidediv").hasClass("sidedivhidden") == !oldValue;
|
||||||
|
}, 10000).always(function(){
|
||||||
|
var newValue = outer$("#sidediv").hasClass("sidedivhidden");
|
||||||
|
expect(oldValue).not.to.be(newValue);
|
||||||
|
expect(newValue).to.be(!$linesCheckbox.prop("checked"));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
68
tests/frontend/specs/ignore_global_settings.js
Normal file
68
tests/frontend/specs/ignore_global_settings.js
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
describe("ignoring global settings", function(){
|
||||||
|
//create a new pad before each test run
|
||||||
|
beforeEach(function(cb){
|
||||||
|
helper.newPad(cb);
|
||||||
|
this.timeout(60000);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 1. Ignore global settings
|
||||||
|
// 2. change linenumbers globally
|
||||||
|
// 3. Un-Ingore global settings
|
||||||
|
// 4. change author-colors
|
||||||
|
// 5. Check for *same* linenumbers and *changed* author-colors
|
||||||
|
it("tries to ignore global settings", function(done) {
|
||||||
|
var outer$ = helper.padOuter$;
|
||||||
|
var inner$ = helper.padInner$;
|
||||||
|
var chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
this.timeout(15000);
|
||||||
|
|
||||||
|
//click on the settings button to make settings visible
|
||||||
|
var $settingsButton = chrome$(".buttonicon-settings");
|
||||||
|
$settingsButton.click();
|
||||||
|
|
||||||
|
//get the chat selector
|
||||||
|
var $linesCheckbox = chrome$("#options-global-linenoscheck");
|
||||||
|
var $colorsGlobalCheckbox = chrome$("#options-global-colorscheck");
|
||||||
|
var $ignoreGlobalCheckbox = chrome$("#options-ignore-global");
|
||||||
|
|
||||||
|
//get the current status of the linenumbers
|
||||||
|
var oldValue_lines = outer$("#sidediv").hasClass("sidedivhidden");
|
||||||
|
var oldValue_color = inner$("body").hasClass("authorColors");
|
||||||
|
|
||||||
|
//ignore global settings
|
||||||
|
$ignoreGlobalCheckbox.attr('selected','selected');
|
||||||
|
$ignoreGlobalCheckbox.prop('checked', false); // make sure it's unchecked
|
||||||
|
$ignoreGlobalCheckbox.change();
|
||||||
|
$ignoreGlobalCheckbox.click(); // check it
|
||||||
|
|
||||||
|
//change linenumbers
|
||||||
|
$linesCheckbox.attr('selected','selected');
|
||||||
|
$linesCheckbox.change();
|
||||||
|
$linesCheckbox.click();
|
||||||
|
|
||||||
|
// wait for the server-event to come..
|
||||||
|
setTimeout(function() {
|
||||||
|
//unignore global settings
|
||||||
|
$ignoreGlobalCheckbox.attr('selected','selected');
|
||||||
|
$ignoreGlobalCheckbox.change();
|
||||||
|
$ignoreGlobalCheckbox.click();
|
||||||
|
|
||||||
|
//change colors
|
||||||
|
$colorsGlobalCheckbox.attr('selected','selected');
|
||||||
|
$colorsGlobalCheckbox.change();
|
||||||
|
$colorsGlobalCheckbox.click();
|
||||||
|
}, 2500);
|
||||||
|
|
||||||
|
helper.waitFor(function(){
|
||||||
|
return inner$("body").hasClass("authorColors") == !oldValue_color;
|
||||||
|
}, 10000).always(function(){
|
||||||
|
var newValue_lines = outer$("#sidediv").hasClass("sidedivhidden");
|
||||||
|
var newValue_color = inner$("body").hasClass("authorColors");
|
||||||
|
|
||||||
|
expect(newValue_color).not.to.be(oldValue_color);
|
||||||
|
expect(newValue_lines).to.be(oldValue_lines);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue