mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Add a button to insert the current time and user into infolog description
This commit is contained in:
parent
c37554a3c9
commit
833253e73d
@ -651,6 +651,93 @@ app.classes.infolog = AppJS.extend(
|
||||
if (_widget.get_value()) this.et2._inst.submit();
|
||||
},
|
||||
|
||||
/**
|
||||
* Insert text at the cursor position (or end) of a text field
|
||||
*
|
||||
* @param {et2_inputWidget|string} widget Either a widget object or it's ID
|
||||
* @param {string} [text=timestamp username] Text to insert
|
||||
*/
|
||||
insert_text: function(widget, text)
|
||||
{
|
||||
if(typeof widget == 'string')
|
||||
{
|
||||
et2 = etemplate2.getById('infolog-edit');
|
||||
if(et2)
|
||||
{
|
||||
widget = et2.widgetContainer.getWidgetById(widget);
|
||||
}
|
||||
}
|
||||
if(!widget || !widget.input)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!text)
|
||||
{
|
||||
var now = new Date();
|
||||
text = date(egw.preference('dateformat') + ' ' + (egw.preference("timeformat") === "12" ? "h:ia" : "H:i")+' ',now);
|
||||
|
||||
// Get properly formatted user name
|
||||
var user = parseInt(egw.user('account_id'));
|
||||
var accounts = egw.accounts('accounts');
|
||||
for(var j = 0; j < accounts.length; j++)
|
||||
{
|
||||
if(accounts[j].value === user)
|
||||
{
|
||||
text += accounts[j].label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
text += ': ';
|
||||
}
|
||||
|
||||
var input = widget.input[0];
|
||||
var scrollPos = input.scrollTop;
|
||||
var browser = ((input.selectionStart || input.selectionStart == "0") ?
|
||||
"standards" : (document.selection ? "ie" : false ) );
|
||||
|
||||
var pos = 0
|
||||
|
||||
// Find cursor or selection
|
||||
if (browser == "ie")
|
||||
{
|
||||
input.focus();
|
||||
var range = document.selection.createRange();
|
||||
range.moveStart ("character", -input.value.length);
|
||||
pos = range.text.length;
|
||||
}
|
||||
else if (browser == "standards")
|
||||
{
|
||||
pos = input.selectionStart
|
||||
};
|
||||
if(pos === 0 && input.value.length > 0)
|
||||
{
|
||||
pos = input.value.length;
|
||||
}
|
||||
|
||||
// Insert the text
|
||||
var front = (input.value).substring(0, pos);
|
||||
var back = (input.value).substring(pos, input.value.length);
|
||||
input.value = front+text+back;
|
||||
|
||||
// Clean up a little
|
||||
pos = pos + text.length;
|
||||
if (browser == "ie") {
|
||||
input.focus();
|
||||
var range = document.selection.createRange();
|
||||
range.moveStart ("character", -input.value.length);
|
||||
range.moveStart ("character", pos);
|
||||
range.moveEnd ("character", 0);
|
||||
range.select();
|
||||
}
|
||||
else if (browser == "standards") {
|
||||
input.selectionStart = pos;
|
||||
input.selectionEnd = pos;
|
||||
input.focus();
|
||||
}
|
||||
input.scrollTop = scrollPos;
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle encryption
|
||||
*
|
||||
|
@ -72,6 +72,14 @@ button#infolog-edit_encrypt {
|
||||
right: -2px;
|
||||
top: 3px;
|
||||
}
|
||||
td.infologTimestamp {
|
||||
position: relative;
|
||||
}
|
||||
button#infolog-edit_timestamp {
|
||||
position: absolute;
|
||||
right: 19px;
|
||||
top: 3px;
|
||||
}
|
||||
div#infolog-edit_infolog-edit-description {
|
||||
height: 250px;
|
||||
}
|
||||
|
@ -214,7 +214,9 @@
|
||||
<description/>
|
||||
</row>
|
||||
<row class="et2_toolbar">
|
||||
<buttononly label="Encrypt" id="encrypt" span="all" class="infologEncrypt" background_image="1" image="lock" onclick="app.infolog.toggleEncrypt"/>
|
||||
<description id="spacer" span="6"/>
|
||||
<buttononly statustext="Insert timestamp" id="timestamp" class="infologTimestamp" background_image="1" image="timestamp" onclick="app.infolog.insert_text('info_des');"/>
|
||||
<buttononly label="Encrypt" id="encrypt" class="infologEncrypt" background_image="1" image="lock" onclick="app.infolog.toggleEncrypt"/>
|
||||
</row>
|
||||
<row>
|
||||
<tabbox id="tabs" class="et2_nowrap" span="all" width="100%" tab_height="250px">
|
||||
|
@ -39,7 +39,7 @@
|
||||
}
|
||||
.normal,
|
||||
.normal_done {
|
||||
color: black;
|
||||
color: #000000;
|
||||
}
|
||||
.high {
|
||||
color: #cc0000;
|
||||
@ -145,6 +145,14 @@ button#infolog-edit_encrypt {
|
||||
right: -2px;
|
||||
top: 3px;
|
||||
}
|
||||
td.infologTimestamp {
|
||||
position: relative;
|
||||
}
|
||||
button#infolog-edit_timestamp {
|
||||
position: absolute;
|
||||
right: 19px;
|
||||
top: 3px;
|
||||
}
|
||||
div#infolog-edit_infolog-edit-description {
|
||||
height: 250px;
|
||||
}
|
||||
@ -414,6 +422,9 @@ input#infolog-edit_info_subject {
|
||||
button#infolog-edit_encrypt {
|
||||
top: 13px;
|
||||
}
|
||||
button#infolog-edit_timestamp {
|
||||
top: 13px;
|
||||
}
|
||||
/* tablets and smartphones */
|
||||
@media only screen and (max-device-width: 1024px) {
|
||||
#infolog-index_nm .gridCont_0_div_col_0.innerContainer {
|
||||
|
@ -400,7 +400,9 @@ input#infolog-edit_info_subject {width: 98% !important;}
|
||||
button#infolog-edit_encrypt {
|
||||
top: 13px;
|
||||
}
|
||||
|
||||
button#infolog-edit_timestamp {
|
||||
top: 13px;
|
||||
}
|
||||
|
||||
/* tablets and smartphones */
|
||||
@media only screen and (max-device-width:1024px) {
|
||||
|
BIN
infolog/templates/pixelegg/images/timestamp.png
Executable file
BIN
infolog/templates/pixelegg/images/timestamp.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Loading…
Reference in New Issue
Block a user