| | |
| | | this.goto_url('error', '_code=0x199'); |
| | | return; |
| | | } |
| | | |
| | | |
| | | // find all registered gui containers |
| | | for (var n in this.gui_containers) |
| | | this.gui_containers[n] = $('#'+this.gui_containers[n]); |
| | |
| | | // find all registered gui objects |
| | | for (var n in this.gui_objects) |
| | | this.gui_objects[n] = rcube_find_object(this.gui_objects[n]); |
| | | |
| | | // init registered buttons |
| | | this.init_buttons(); |
| | | |
| | | // tell parent window that this frame is loaded |
| | | if (this.env.framed && parent.rcmail && parent.rcmail.set_busy) |
| | |
| | | |
| | | if (this.env.permaurl) |
| | | this.enable_command('permaurl', true); |
| | | |
| | | |
| | | switch (this.task) |
| | | { |
| | | case 'mail': |
| | |
| | | this.enable_command('savedraft', true); |
| | | |
| | | document.onmouseup = function(e){ return p.doc_mouse_up(e); }; |
| | | |
| | | // init message compose form |
| | | this.init_messageform(); |
| | | } |
| | | |
| | | if (this.env.messagecount) |
| | |
| | | this.enable_command('purge', true); |
| | | |
| | | this.set_page_buttons(); |
| | | |
| | | // init message compose form |
| | | if (this.env.action=='compose') |
| | | this.init_messageform(); |
| | | |
| | | // show printing dialog |
| | | if (this.env.action=='print') |
| | |
| | | case 'settings': |
| | | this.enable_command('preferences', 'identities', 'save', 'folders', true); |
| | | |
| | | if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='add-identity') { |
| | | if (this.env.action=='identities') { |
| | | this.enable_command('add', this.env.identities_level < 2); |
| | | this.enable_command('delete', 'edit', true); |
| | | } |
| | | |
| | | if (this.env.action=='edit-identity' || this.env.action=='add-identity') |
| | | this.enable_command('save', true); |
| | | |
| | | if (this.env.action=='folders') |
| | | } |
| | | else if (this.env.action=='edit-identity' || this.env.action=='add-identity') { |
| | | this.enable_command('add', this.env.identities_level < 2); |
| | | this.enable_command('save', 'delete', 'edit', true); |
| | | } |
| | | else if (this.env.action=='folders') |
| | | this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'rename-folder', 'delete-folder', true); |
| | | |
| | | if (this.gui_objects.identitieslist) |
| | |
| | | if (this.env.iid) |
| | | this.identity_list.highlight_row(this.env.iid); |
| | | } |
| | | |
| | | if (this.gui_objects.subscriptionlist) |
| | | else if (this.gui_objects.sectionslist) |
| | | { |
| | | this.sections_list = new rcube_list_widget(this.gui_objects.sectionslist, {multiselect:false, draggable:false, keyboard:false}); |
| | | this.sections_list.addEventListener('select', function(o){ p.section_select(o); }); |
| | | this.sections_list.init(); |
| | | this.sections_list.focus(); |
| | | } |
| | | else if (this.gui_objects.subscriptionlist) |
| | | this.init_subscription_list(); |
| | | |
| | | break; |
| | |
| | | break; |
| | | |
| | | case 'spellcheck': |
| | | if (window.tinyMCE && tinyMCE.get('compose-body')) { |
| | | if (window.tinyMCE && tinyMCE.get(this.env.composebody)) { |
| | | tinyMCE.execCommand('mceSpellCheck', true); |
| | | } |
| | | else if (this.env.spellcheck && this.env.spellcheck.spellCheck && this.spellcheck_ready) { |
| | |
| | | var selection = this.message_list.get_selection(); |
| | | var rows = this.message_list.rows; |
| | | var id; |
| | | for (var n=0; n<selection.length; n++) |
| | | { |
| | | for (var n=0; n<selection.length; n++) { |
| | | id = selection[n]; |
| | | a_uids[a_uids.length] = id; |
| | | this.message_list.remove_row(id, (n == selection.length-1)); |
| | | this.message_list.remove_row(id, (this.env.display_next && n == selection.length-1)); |
| | | } |
| | | // make sure there are no selected rows |
| | | if (!this.env.display_next) |
| | | this.message_list.clear_selection(); |
| | | } |
| | | |
| | | // also send search request to get the right messages |
| | | if (this.env.search_request) |
| | | add_url += '&_search='+this.env.search_request; |
| | | |
| | | if (this.env.next_uid) |
| | | if (this.env.display_next && this.env.next_uid) |
| | | add_url += '&_next_uid='+this.env.next_uid; |
| | | |
| | | // send request to server |
| | |
| | | r_uids[r_uids.length] = uid; |
| | | |
| | | if (this.env.skip_deleted) |
| | | this.message_list.remove_row(uid, (i == this.message_list.selection.length-1)); |
| | | this.message_list.remove_row(uid, (this.env.display_next && i == this.message_list.selection.length-1)); |
| | | else |
| | | this.set_message(uid, 'deleted', true); |
| | | } |
| | | } |
| | | |
| | | // make sure there are no selected rows |
| | | if (this.env.skip_deleted && !this.env.display_next && this.message_list) |
| | | this.message_list.clear_selection(); |
| | | |
| | | add_url = '&_from='+(this.env.action ? this.env.action : ''); |
| | | |
| | |
| | | // also send search request to get the right messages |
| | | if (this.env.search_request) |
| | | add_url += '&_search='+this.env.search_request; |
| | | if (this.env.next_uid) |
| | | if (this.env.display_next && this.env.next_uid) |
| | | add_url += '&_next_uid='+this.env.next_uid; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // check for empty body |
| | | if ((!window.tinyMCE || !tinyMCE.get('compose-body')) && input_message.val() == '' && !confirm(this.get_label('nobodywarning'))) |
| | | if ((!window.tinyMCE || !tinyMCE.get(this.env.composebody)) |
| | | && input_message.val() == '' && !confirm(this.get_label('nobodywarning'))) |
| | | { |
| | | input_message.focus(); |
| | | return false; |
| | | } |
| | | else if (window.tinyMCE && tinyMCE.get('compose-body') && !tinyMCE.get('compose-body').getContent() && !confirm(this.get_label('nobodywarning'))) |
| | | else if (window.tinyMCE && tinyMCE.get(this.env.composebody) |
| | | && !tinyMCE.get(this.env.composebody).getContent() |
| | | && !confirm(this.get_label('nobodywarning'))) |
| | | { |
| | | tinyMCE.get('compose-body').focus(); |
| | | tinyMCE.get(this.env.composebody).focus(); |
| | | return false; |
| | | } |
| | | |
| | |
| | | this.stop_spellchecking(); |
| | | |
| | | // move body from html editor to textarea (just to be sure, #1485860) |
| | | if (window.tinyMCE && tinyMCE.get('compose-body')) |
| | | if (window.tinyMCE && tinyMCE.get(this.env.composebody)) |
| | | tinyMCE.triggerSave(); |
| | | |
| | | return true; |
| | |
| | | if (value_subject) |
| | | str += value_subject+':'; |
| | | |
| | | var editor = tinyMCE.get('compose-body'); |
| | | var editor = tinyMCE.get(this.env.composebody); |
| | | if (editor) |
| | | str += editor.getContent(); |
| | | else |
| | |
| | | } |
| | | else |
| | | { |
| | | var editor = tinyMCE.get('compose-body'); |
| | | var editor = tinyMCE.get(this.env.composebody); |
| | | |
| | | if (this.env.signatures) |
| | | { |
| | |
| | | this.subscription_list.init(); |
| | | } |
| | | |
| | | // preferences section select and load options frame |
| | | this.section_select = function(list) |
| | | { |
| | | var id = list.get_single_selection() |
| | | |
| | | if (id) { |
| | | var add_url = ''; |
| | | var target = window; |
| | | this.set_busy(true); |
| | | |
| | | if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) { |
| | | add_url = '&_framed=1'; |
| | | target = window.frames[this.env.contentframe]; |
| | | } |
| | | |
| | | target.location.href = this.env.comm_path+'&_action=edit-prefs&_section='+id+add_url; |
| | | } |
| | | |
| | | return true; |
| | | }; |
| | | |
| | | this.identity_select = function(list) |
| | | { |
| | | var id; |
| | |
| | | if (!id) |
| | | id = this.env.iid ? this.env.iid : selection[0]; |
| | | |
| | | // if (this.env.framed && id) |
| | | this.goto_url('delete-identity', '_iid='+id, true); |
| | | // append token to request |
| | | this.goto_url('delete-identity', '_iid='+id+'&_token='+this.env.request_token, true); |
| | | |
| | | return true; |
| | | }; |
| | | |
| | |
| | | |
| | | // eable/disable buttons for page shifting |
| | | this.set_page_buttons = function() |
| | | { |
| | | { |
| | | this.enable_command('nextpage', (this.env.pagecount > this.env.current_page)); |
| | | this.enable_command('lastpage', (this.env.pagecount > this.env.current_page)); |
| | | this.enable_command('previouspage', (this.env.current_page > 1)); |
| | | this.enable_command('firstpage', (this.env.current_page > 1)); |
| | | }; |
| | | |
| | | // set event handlers on registered buttons |
| | | this.init_buttons = function() |
| | | { |
| | | for (var cmd in this.buttons) { |
| | | if (typeof cmd != 'string') |
| | | continue; |
| | | |
| | | for (var i=0; i< this.buttons[cmd].length; i++) { |
| | | var prop = this.buttons[cmd][i]; |
| | | var elm = document.getElementById(prop.id); |
| | | if (!elm) |
| | | continue; |
| | | |
| | | var preload = false; |
| | | if (prop.type == 'image') { |
| | | elm = elm.parentNode; |
| | | preload = true; |
| | | } |
| | | |
| | | elm._command = cmd; |
| | | elm._id = prop.id; |
| | | if (prop.sel) { |
| | | elm.onmousedown = function(e){ return rcmail.button_sel(this._command, this._id); }; |
| | | elm.onmouseup = function(e){ return rcmail.button_out(this._command, this._id); }; |
| | | if (preload) |
| | | new Image().src = prop.sel; |
| | | } |
| | | if (prop.over) { |
| | | elm.onmouseover = function(e){ return rcmail.button_over(this._command, this._id); }; |
| | | elm.onmouseout = function(e){ return rcmail.button_out(this._command, this._id); }; |
| | | if (preload) |
| | | new Image().src = prop.over; |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // set button to a specific state |
| | | this.set_button = function(command, state) |
| | |
| | | |
| | | // mouse over button |
| | | this.button_over = function(command, id) |
| | | { |
| | | { |
| | | var a_buttons = this.buttons[command]; |
| | | var button, img; |
| | | var button, elm; |
| | | |
| | | if(!a_buttons || !a_buttons.length) |
| | | return false; |
| | | |
| | | for(var n=0; n<a_buttons.length; n++) |
| | | { |
| | | { |
| | | button = a_buttons[n]; |
| | | if(button.id==id && button.status=='act') |
| | | { |
| | | img = document.getElementById(button.id); |
| | | if (img && button.over) |
| | | img.src = button.over; |
| | | { |
| | | elm = document.getElementById(button.id); |
| | | if (elm && button.over) { |
| | | if (button.type == 'image') |
| | | elm.src = button.over; |
| | | else |
| | | elm.className = button.over; |
| | | } |
| | | } |
| | | |
| | | }; |
| | | } |
| | | }; |
| | | |
| | | // mouse down on button |
| | | this.button_sel = function(command, id) |
| | | { |
| | | { |
| | | var a_buttons = this.buttons[command]; |
| | | var button, img; |
| | | var button, elm; |
| | | |
| | | if(!a_buttons || !a_buttons.length) |
| | | return; |
| | | |
| | | for(var n=0; n<a_buttons.length; n++) |
| | | { |
| | | { |
| | | button = a_buttons[n]; |
| | | if(button.id==id && button.status=='act') |
| | | { |
| | | img = document.getElementById(button.id); |
| | | if (img && button.sel) |
| | | img.src = button.sel; |
| | | { |
| | | elm = document.getElementById(button.id); |
| | | if (elm && button.sel) { |
| | | if (button.type == 'image') |
| | | elm.src = button.sel; |
| | | else |
| | | elm.className = button.sel; |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | }; |
| | | |
| | | // mouse out of button |
| | | this.button_out = function(command, id) |
| | | { |
| | | { |
| | | var a_buttons = this.buttons[command]; |
| | | var button, img; |
| | | var button, elm; |
| | | |
| | | if(!a_buttons || !a_buttons.length) |
| | | return; |
| | | |
| | | for(var n=0; n<a_buttons.length; n++) |
| | | { |
| | | { |
| | | button = a_buttons[n]; |
| | | if(button.id==id && button.status=='act') |
| | | { |
| | | img = document.getElementById(button.id); |
| | | if (img && button.act) |
| | | img.src = button.act; |
| | | { |
| | | elm = document.getElementById(button.id); |
| | | if (elm && button.act) { |
| | | if (button.type == 'image') |
| | | elm.src = button.act; |
| | | else |
| | | elm.className = button.act; |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | }; |
| | | |
| | | // write to the document/window title |
| | | this.set_pagetitle = function(title) |