diff --git a/infolog/js/app.js b/infolog/js/app.js index df000063ad..bfbfc47867 100644 --- a/infolog/js/app.js +++ b/infolog/js/app.js @@ -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 * diff --git a/infolog/templates/default/app.css b/infolog/templates/default/app.css index 9085690339..16fc3c04e0 100644 --- a/infolog/templates/default/app.css +++ b/infolog/templates/default/app.css @@ -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; } diff --git a/infolog/templates/default/edit.xet b/infolog/templates/default/edit.xet index 48b365b807..7e22791639 100644 --- a/infolog/templates/default/edit.xet +++ b/infolog/templates/default/edit.xet @@ -214,7 +214,9 @@ - + + + diff --git a/infolog/templates/pixelegg/app.css b/infolog/templates/pixelegg/app.css index a082aca253..66d641ac8d 100755 --- a/infolog/templates/pixelegg/app.css +++ b/infolog/templates/pixelegg/app.css @@ -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 { diff --git a/infolog/templates/pixelegg/app.less b/infolog/templates/pixelegg/app.less index 2716f7e376..46bb70cb19 100755 --- a/infolog/templates/pixelegg/app.less +++ b/infolog/templates/pixelegg/app.less @@ -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) { diff --git a/infolog/templates/pixelegg/images/timestamp.png b/infolog/templates/pixelegg/images/timestamp.png new file mode 100755 index 0000000000..ad9b59d937 Binary files /dev/null and b/infolog/templates/pixelegg/images/timestamp.png differ