| | |
| | | |
| | | for (var key, i = 0; i < index.length; i++) { |
| | | key = index[i], formdata = this.local_storage_get_item('compose.' + key, null, true); |
| | | if (!formdata) { |
| | | continue; |
| | | } |
| | | // restore saved copy of current compose_id |
| | | if (formdata && formdata.changed && key == this.env.compose_id) { |
| | | if (formdata.changed && key == this.env.compose_id) { |
| | | this.restore_compose_form(key, html_mode); |
| | | break; |
| | | } |
| | | // skip records from 'other' drafts |
| | | if (this.env.draft_id && formdata.draft_id && formdata.draft_id != this.env.draft_id) { |
| | | continue; |
| | | } |
| | | // show dialog asking to restore the message |
| | | if (formdata && formdata.changed && formdata.session != this.env.session_id) { |
| | | if (formdata.changed && formdata.session != this.env.session_id) { |
| | | this.show_popup_dialog( |
| | | this.get_label('restoresavedcomposedata') |
| | | .replace('$date', new Date(formdata.changed).toLocaleString()) |
| | |
| | | } |
| | | }, |
| | | { |
| | | text: this.get_label('cancel'), |
| | | text: this.get_label('ignore'), |
| | | click: function(){ |
| | | $(this).dialog('close'); |
| | | } |
| | |
| | | if (this.env.draft_autosave) |
| | | this.save_timer = setTimeout(function(){ ref.command("savedraft"); }, this.env.draft_autosave * 1000); |
| | | |
| | | // save compose form content to local storage every 10 seconds |
| | | // TODO: track typing activity and only save on changes |
| | | if (!this.local_save_timer && window.localStorage) |
| | | this.local_save_timer = setInterval(function(){ ref.save_compose_form_local(); }, 10000); |
| | | // save compose form content to local storage every 5 seconds |
| | | if (!this.local_save_timer && window.localStorage) { |
| | | // track typing activity and only save on changes |
| | | this.compose_type_activity = this.compose_type_activity_last = 0; |
| | | $(document).bind('keypress', function(e){ ref.compose_type_activity++; }); |
| | | |
| | | this.local_save_timer = setInterval(function(){ |
| | | if (ref.compose_type_activity > ref.compose_type_activity_last) { |
| | | ref.save_compose_form_local(); |
| | | ref.compose_type_activity_last = ref.compose_type_activity; |
| | | } |
| | | }, 5000); |
| | | } |
| | | |
| | | // Unlock interface now that saving is complete |
| | | this.busy = false; |
| | |
| | | tinyMCE.triggerSave(); |
| | | } |
| | | |
| | | if (this.env.draft_id) { |
| | | formdata.draft_id = this.env.draft_id; |
| | | } |
| | | |
| | | $('input, select, textarea', this.gui_objects.messageform).each(function(i, elem){ |
| | | switch (elem.tagName.toLowerCase()) { |
| | | case 'input': |
| | |
| | | |
| | | default: |
| | | formdata[elem.name] = $(elem).val(); |
| | | if (formdata[elem.name] != '') |
| | | empty = false; |
| | | } |
| | | }); |
| | | |
| | |
| | | if (this.ksearch_input.setSelectionRange) |
| | | this.ksearch_input.setSelectionRange(cpos, cpos); |
| | | |
| | | if (trigger) |
| | | if (trigger) { |
| | | this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert }); |
| | | this.compose_type_activity++; |
| | | } |
| | | }; |
| | | |
| | | this.replace_group_recipients = function(id, recipients) |
| | |
| | | this.group2expand[id].input.value = this.group2expand[id].input.value.replace(this.group2expand[id].name, recipients); |
| | | this.triggerEvent('autocomplete_insert', { field:this.group2expand[id].input, insert:recipients }); |
| | | this.group2expand[id] = null; |
| | | this.compose_type_activity++; |
| | | } |
| | | }; |
| | | |