From 7481c0a23c971aebea3592f992839cc5f665d069 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 20 Sep 2013 10:50:48 +0000 Subject: [PATCH] Run addressbook by et2 --- addressbook/inc/class.addressbook_ui.inc.php | 147 ++--- addressbook/js/app.js | 556 +++++++++++++------ addressbook/templates/default/edit.xet | 26 +- addressbook/templates/default/email.xet | 4 +- addressbook/templates/default/search.xet | 32 +- 5 files changed, 446 insertions(+), 319 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index f7d97f6e0f..66171e5cb9 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -68,7 +68,7 @@ class addressbook_ui extends addressbook_bo { parent::__construct($contact_app); - $this->tmpl = new etemplate(); + $this->tmpl = new etemplate_new(); $this->org_views = array( 'org_name' => lang('Organisations'), @@ -76,13 +76,6 @@ class addressbook_ui extends addressbook_bo 'org_name,org_unit' => lang('Organisations by departments'), ); - // our javascript - // to be moved in a seperate file if rewrite is over - if (strpos($GLOBALS['egw_info']['flags']['java_script'],'add_new_list') === false) - { - $GLOBALS['egw_info']['flags']['java_script'].= $this->js(); - } - // make sure the hook for export_limit is registered if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','addressbook')) $GLOBALS['egw']->hooks->register_single_app_hook('addressbook','export_limit'); @@ -221,7 +214,7 @@ class addressbook_ui extends addressbook_bo 'lettersearch' => true, 'do_email' => $do_email ? 1 : 0, 'default_cols' => '!cat_id,contact_created_contact_modified,distribution_list,contact_id,owner,legacy_actions', - 'filter2_onchange' => "if(this.value=='add') { add_new_list(typeof widget == 'undefined' ? document.getElementById('exec[nm][filter]').value : widget.header.filter.get_value()); this.value='';} else this.form.submit();", + 'filter2_onchange' => "app.addressbook.filter2_onchange();", 'manual' => $do_email ? ' ' : false, // space for the manual icon //'actions' => $this->get_actions(), // set on each request, as it depends on some filters 'row_id' => 'id', @@ -235,9 +228,7 @@ class addressbook_ui extends addressbook_bo if ($do_email) { - $content['nm']['filter2_onchange'] = str_replace('this.form.submit();', - "{ if (this.value && confirm('".lang('Add emails of whole distribution list?')."')) add_whole_list(this.value); else this.form.submit(); }", - $content['nm']['filter2_onchange']); + $content['nm']['filter2_onchange'] = 'app.addressbook.filter2_onchange_email();'; } // use the state of the last session stored in the user prefs if (($state = @unserialize($this->prefs[$do_email ? 'email_state' : 'index_state']))) @@ -339,7 +330,7 @@ class addressbook_ui extends addressbook_bo } $content['nm']['org_view_label'] = $sel_options['org_view'][(string) $content['nm']['org_view']]; - $this->tmpl->read(/*$do_email ? 'addressbook.email' :*/ 'addressbook.index'); + $this->tmpl->read($do_email ? 'addressbook.email' : 'addressbook.index'); return $this->tmpl->exec($do_email ? 'addressbook.addressbook_ui.emailpopup' : 'addressbook.addressbook_ui.index', $content,$sel_options,$readonlys,$preserv,$do_email ? 2 : 0); } @@ -427,11 +418,13 @@ class addressbook_ui extends addressbook_bo 'email' => array( 'caption' => lang('Add %1',lang('business email')), 'no_lang' => true, + 'onExecute' => 'javaScript:app.addressbook.addEmail', 'group' => ++$group, ), 'email_home' => array( 'caption' => lang('Add %1',lang('home email')), 'no_lang' => true, + 'onExecute' => 'javaScript:app.addressbook.addEmail', 'group' => $group, ), ); @@ -473,7 +466,7 @@ class addressbook_ui extends addressbook_bo 'list_add' => array( 'caption' => 'Add a new list', 'icon' => 'new', - 'onExecute' => 'javaScript:add_new_list', + 'onExecute' => 'javaScript:app.addressbook.add_new_list', ), ), 'group' => $group, @@ -493,7 +486,7 @@ class addressbook_ui extends addressbook_bo 'caption' => 'Remove from distribution list', 'confirm' => 'Remove selected contacts from distribution list', 'icon' => 'foldertree_nolines_minus', - 'enabled' => 'javaScript:nm_compare_field', + 'enabled' => 'javaScript:app.addressbook.nm_compare_field', 'fieldId' => 'exec[nm][filter2]', 'fieldValue' => '!', // enable if list != '' ), @@ -501,7 +494,7 @@ class addressbook_ui extends addressbook_bo 'caption' => 'Delete selected distribution list!', 'confirm' => 'Delete selected distribution list!', 'icon' => 'delete', - 'enabled' => 'javaScript:nm_compare_field', + 'enabled' => 'javaScript:app.addressbook.nm_compare_field', 'fieldId' => 'exec[nm][filter2]', 'fieldValue' => '!', // enable if list != '' ), @@ -556,7 +549,7 @@ class addressbook_ui extends addressbook_bo 'icon' => 'new', 'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id=$id', 'popup' => egw_link::get_registry('infolog', 'add_popup'), - 'onExecute' => 'javaScript:add_task', // call server for org-view only + 'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only ), ) ); @@ -572,7 +565,7 @@ class addressbook_ui extends addressbook_bo 'caption' => 'Show', 'icon' => 'view', 'url' => 'menuaction=calendar.calendar_uilist.listview&filter=all&owner=0,c$id', - 'onExecute' => 'javaScript:add_cal', // call server for org-view only + 'onExecute' => 'javaScript:app.addressbook.add_cal', // call server for org-view only 'targetapp' => 'calendar', // open in calendar tab ), 'calendar_add' => array( @@ -580,7 +573,7 @@ class addressbook_ui extends addressbook_bo 'icon' => 'new', 'url' => 'menuaction=calendar.calendar_uiforms.edit&participants=c$id', 'popup' => egw_link::get_registry('calendar', 'add_popup'), - 'onExecute' => 'javaScript:add_cal', // call server for org-view only + 'onExecute' => 'javaScript:app.addressbook.add_cal', // call server for org-view only ), ), ); @@ -628,7 +621,7 @@ class addressbook_ui extends addressbook_bo 'caption' => lang('Mail VCard'), 'icon' => 'filemanager/mail_post_to', 'group' => $group, - 'onExecute' => 'javaScript:adb_mail_vcard', + 'onExecute' => 'javaScript:app.addressbook.adb_mail_vcard', ); } ++$group; @@ -751,7 +744,7 @@ window.egw_LAB.wait(function() { $query['filter2'] = (int)$list; $this->action($email_type,array(),true,$success,$failed,$action_msg,$query,$msg); - $response = new xajaxResponse(); + $response = egw_json_response::get(); if ($success) $response->addScript(egw_framework::set_onload('')); @@ -771,7 +764,7 @@ window.egw_LAB.wait(function() { $response->addScript("alert('".addslashes($msg)."')"); $response->addScript('window.close();'); } - return $response->getXML(); + } /** @@ -995,6 +988,7 @@ window.egw_LAB.wait(function() { case 'email': case 'email_home': + error_log(__METHOD__. "() email"); $action == 'email' ? $action_fallback = 'email_home' : $action_fallback = 'email'; $action_msg = lang('added'); if($contact = $this->read($id)) @@ -1669,24 +1663,28 @@ window.egw_LAB.wait(function() { { egw_link::link('addressbook',$content['id'],$links); } - $content['js'] = "opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','addressbook','{$content['id']}', '" . ($content['id'] ? 'update' : 'add') . "', opener.egw_getAppName());"; - + $currentApp = $GLOBALS['egw']->currentapp; + error_log(__METHOD__. "() currentapp:" . $currentApp); + egw_framework::refresh_opener($content['msg'], 'addressbook',$content['id'], ($content['id'] ? 'update' : 'add')); if ($button == 'save') { - $content['js'] .= ' window.close();'; - echo ''; - common::egw_exit(); + egw_framework::window_close(); } $content['link_to']['to_id'] = $content['id']; - $GLOBALS['egw_info']['flags']['java_script'] .= ""; break; case 'delete': if($this->action('delete',array($content['id']),false,$success,$failed,$action_msg,'',$content['msg'])) { - $js = "opener.egw_refresh('".str_replace("'","\\'",lang('Contact deleted'))."','addressbook','{$content['id']}','delete'); if(opener.egw_getAppName() != 'addressbook') { opener.egw_refresh('".str_replace("'","\\'",lang('Contact deleted'))."','addressbook','{$content['id']}',null,'addressbook');} window.close();"; - echo ''; - common::egw_exit(); + if ($GLOBALS['egw']->currentapp == 'addressbook') + { + egw_framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete' ); + } + else + { + egw_framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], null, 'addressbook'); + egw_framework::window_close(); + } } else { @@ -1771,7 +1769,7 @@ window.egw_LAB.wait(function() { { if (!empty($content[$field])) { - egw_framework::set_onload("check_value(document.getElementById('exec[$field]'),0);"); + egw_framework::set_onload("app.addressbook.check_value(document.getElementById('exec[$field]'),0);"); break; } } @@ -1839,8 +1837,6 @@ window.egw_LAB.wait(function() { // how to display addresses $content['addr_format'] = $this->addr_format_by_country($content['adr_one_countryname']); $content['addr_format2'] = $this->addr_format_by_country($content['adr_two_countryname']); - $GLOBALS['egw']->js->set_onload('show_custom_country($j(\'select[id*="adr_one_countrycode"]\').get(0));'); - $GLOBALS['egw']->js->set_onload('show_custom_country($j(\'select[id*="adr_two_countrycode"]\').get(0));'); //_debug_array($content); $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(EGW_ACL_DELETE,$content); @@ -1919,7 +1915,7 @@ window.egw_LAB.wait(function() { if ($content['private']) $content['owner'] .= 'p'; - $GLOBALS['egw_info']['flags']['include_xajax'] = true; + //$GLOBALS['egw_info']['flags']['include_xajax'] = true; if (!$this->tmpl->read($this->content_types[$content['tid']]['options']['template'] ? $this->content_types[$content['tid']]['options']['template'] : 'addressbook.edit')) { @@ -2219,7 +2215,7 @@ window.egw_LAB.wait(function() { if(!empty($_content)) { $do_email = $_content['do_email']; - $response = new xajaxResponse(); + $response = egw_json_response::get(); $query = egw_session::appsession($do_email ? 'email' : 'index','addressbook'); @@ -2242,23 +2238,16 @@ window.egw_LAB.wait(function() { // store the advanced search in the session to call it again egw_session::appsession('advanced_search','addressbook',$query['advanced_search']); - - $response->addScript(" - var link = this.opener.location.href; - link = link.replace(/#/,''); - this.opener.location.href=link.replace(/\#/,''); - this.xajax_eT_wrapper(); - "); - if ($_content['button']['cancel']) $response->addScript('this.close();'); - - return $response->getXML(); + error_log(__METHOD__. "() call ADV" ); + if ($_content['button']['search']) $response->call("app.addressbook.adv_search"); + if ($_content['button']['cancel']) egw_framework::window_close (); //$response->addScript('this.close();'); } else { $do_email = strpos($_SERVER['HTTP_REFERER'],'emailpopup') !== false; } - $GLOBALS['egw_info']['flags']['include_xajax'] = true; - $GLOBALS['egw_info']['flags']['java_script'] .= ""; + //$GLOBALS['egw_info']['flags']['include_xajax'] = true; + //$GLOBALS['egw_info']['flags']['java_script'] .= ""; $GLOBALS['egw_info']['etemplate']['advanced_search'] = true; // initialize etemplate arrays @@ -2341,68 +2330,6 @@ window.egw_LAB.wait(function() { } } - /** - * Dynamic javascript functions - * - * All static stuff should go to addressbook/js/app.js - * - * @return string - */ - function js() - { - list($width,$height) = explode('x',egw_link::get_registry('felamimail','add_popup')); - - return ''; - } - /** * Migrate contacts to or from LDAP (called by Admin >> Addressbook >> Site configuration (Admin only) * diff --git a/addressbook/js/app.js b/addressbook/js/app.js index eb1ed3ddfa..4bcda7fad5 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -1,215 +1,415 @@ /** - * EGroupware addressbook static javascript code + * EGroupware - Addressbook - Javascript UI * - * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License - * @package addressbook * @link http://www.egroupware.org - * @author Ralf Becker - * @version $Id$ + * @package addressbook + * @author Hadi Nategh + * @copyright (c) 2008-13 by Ralf Becker + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version $id */ - /** - * Add appointment or show calendar for selected contacts, call default nm_action after some checks - * - * @param _action - * @param _senders + * UI for Addressbook + * + * @augments AppJS */ -function add_cal(_action, _senders) +app.addressbook = AppJS.extend( { - if (!_senders[0].id.match(/^[0-9]+$/)) + appname: 'addressbook', + /** + * et2 widget container + */ + et2: null, + /** + * path widget + */ + + /** + * Constructor + * + * @memberOf app.addressbook + */ + init: function() { - // send org-view requests to server - _action.data.nm_action = "submit"; - } - else + // call parent + this._super.apply(this, arguments); + }, + + /** + * Destructor + */ + destroy: function() { - // call nm_action's popup, but already replace id's in url, because they need to be prefix with a "c" - if (_action.data.popup) _action.data.nm_action = "popup"; - var ids = ""; - for (var i = 0; i < _senders.length; i++) + //delete this.et2; + // call parent + this._super.apply(this, arguments); + }, + + /** + * This function is called when the etemplate2 object is loaded + * and ready. If you must store a reference to the et2 object, + * make sure to clean it up in destroy(). + * + * @param _et2 etemplate2 Newly ready object + */ + et2_ready: function(et2) + { + // call parent + this._super.apply(this, arguments); + + if (typeof et2.templates['addressbook.edit'] != 'undefined') { - ids += "c" + _senders[i].id + ((i < _senders.length - 1) ? "," : ""); + this.show_custom_country($j('select[id*="adr_one_countrycode"]').get(0)); + this.show_custom_country($j('select[id*="adr_two_countrycode"]').get(0)); } - // we cant just replace $id, as under jdots this can get called multiple times (with already replaced url)! - _action.data.url = _action.data.url.replace(/(owner|participants)=(0%2C)?[^&]+/,"$1=$2"+ids); - } - nm_action(_action, _senders); -} -/** - * Add task for selected contacts, call default nm_action after some checks - * - * @param _action - * @param _senders - */ -function add_task(_action, _senders) -{ - if (!_senders[0].id.match(/^(addressbook::)?[0-9]+$/)) + jQuery('select[id*="adr_one_countrycode"]').each(function() { + app.addressbook.show_custom_country(this); + }); + jQuery('select[id*="adr_two_countrycode"]').each(function() { + app.addressbook.show_custom_country(this); + }); + }, + + /** + * Add appointment or show calendar for selected contacts, call default nm_action after some checks + * + * @param _action + * @param _senders + */ + add_cal: function(_action, _senders) { - // send org-view requests to server - _action.data.nm_action = "submit"; - } - else - { - // call nm_action's popup - _action.data.nm_action = "popup"; - } - nm_action(_action, _senders); -} - -function showphones(form) -{ - if (form) { - copyvalues(form,"tel_home","tel_home2"); - copyvalues(form,"tel_work","tel_work2"); - copyvalues(form,"tel_cell","tel_cell2"); - copyvalues(form,"tel_fax","tel_fax2"); - } -} - -function hidephones(form) -{ - if (form) { - copyvalues(form,"tel_home2","tel_home"); - copyvalues(form,"tel_work2","tel_work"); - copyvalues(form,"tel_cell2","tel_cell"); - copyvalues(form,"tel_fax2","tel_fax"); - } -} - -function copyvalues(form,src,dst) -{ - var srcelement = getElement(form,src); //ById("exec["+src+"]"); - var dstelement = getElement(form,dst); //ById("exec["+dst+"]"); - if (srcelement && dstelement) { - dstelement.value = srcelement.value; - } -} - -function getElement(form,pattern) -{ - for (i = 0; i < form.length; i++){ - if(form.elements[i].name){ - var found = form.elements[i].name.search("\\["+pattern+"\\]"); - if (found != -1){ - return form.elements[i]; - } - } - } -} - -function check_value(input, own_id) -{ - var values = egw_json_getFormValues(input.form).exec; // todo use eT2 method, if running under et2 - if(typeof values == 'undefined' && typeof etemplate2 != 'undefined') { - var template = etemplate2.getByApplication('addressbook')[0]; - values = template.getValues(template.widgetContainer); - } - - if (input.name.match(/n_/)) - { - var value = ''; - if (values.n_prefix) value += values.n_prefix+" "; - if (values.n_given) value += values.n_given+" "; - if (values.n_middle) value += values.n_middle+" "; - if (values.n_family) value += values.n_family+" "; - if (values.n_suffix) value += values.n_suffix; - - var name = document.getElementById("exec[n_fn]"); - if(name == null && template) + if (!_senders[0].id.match(/^[0-9]+$/)) { - name = template.widgetContainer.getWidgetById('n_fn'); - name.set_value(value); + // send org-view requests to server + _action.data.nm_action = "submit"; } else { - name.value = value; - } - } - var req = new egw_json_request('addressbook.addressbook_ui.ajax_check_values', [values, input.name, own_id]); - req.sendRequest(true, function(data) { - if (data.msg && confirm(data.msg)) - { - for(var id in data.doublicates) + // call nm_action's popup, but already replace id's in url, because they need to be prefix with a "c" + if (_action.data.popup) _action.data.nm_action = "popup"; + var ids = ""; + for (var i = 0; i < _senders.length; i++) { - egw.open(id, 'addressbook'); - //opener.egw_openWindowCentered2(egw_webserverUrl+'/index.php?menuaction=addressbook.addressbook_ui.edit&contact_id='+id, '_blank', 870, 480, 'yes', 'addressbook'); + ids += "c" + _senders[i].id + ((i < _senders.length - 1) ? "," : ""); } + // we cant just replace $id, as under jdots this can get called multiple times (with already replaced url)! + _action.data.url = _action.data.url.replace(/(owner|participants)=(0%2C)?[^&]+/,"$1=$2"+ids); } - if (typeof data.fileas_options == 'object') + nm_action(_action, _senders); + }, + + /** + * Add task for selected contacts, call default nm_action after some checks + * + * @param _action + * @param _senders + */ + add_task: function(_action, _senders) + { + if (!_senders[0].id.match(/^(addressbook::)?[0-9]+$/)) { - var selbox = document.getElementById("exec[fileas_type]"); - if (selbox) - { - for (var i=0; i < data.fileas_options.length; i++) - { - selbox.options[i].text = data.fileas_options[i]; + // send org-view requests to server + _action.data.nm_action = "submit"; + } + else + { + // call nm_action's popup + _action.data.nm_action = "popup"; + } + nm_action(_action, _senders); + }, + + showphones: function(form) + { + if (form) { + copyvalues(form,"tel_home","tel_home2"); + copyvalues(form,"tel_work","tel_work2"); + copyvalues(form,"tel_cell","tel_cell2"); + copyvalues(form,"tel_fax","tel_fax2"); + } + }, + + hidephones: function(form) + { + if (form) { + copyvalues(form,"tel_home2","tel_home"); + copyvalues(form,"tel_work2","tel_work"); + copyvalues(form,"tel_cell2","tel_cell"); + copyvalues(form,"tel_fax2","tel_fax"); + } + }, + + copyvalues: function(form,src,dst) + { + var srcelement = getElement(form,src); //ById("exec["+src+"]"); + var dstelement = getElement(form,dst); //ById("exec["+dst+"]"); + if (srcelement && dstelement) { + dstelement.value = srcelement.value; + } + }, + + getElement: function(form,pattern) + { + for (i = 0; i < form.length; i++){ + if(form.elements[i].name){ + var found = form.elements[i].name.search("\\["+pattern+"\\]"); + if (found != -1){ + return form.elements[i]; } } - else if (template && (selbox = template.widgetContainer.getWidgetById('fileas_type'))) + } + }, + + check_value: function(input, own_id) + { + var values = egw_json_getFormValues(input.form).exec; // todo use eT2 method, if running under et2 + if(typeof values == 'undefined' && typeof etemplate2 != 'undefined') { + var template = etemplate2.getByApplication('addressbook')[0]; + values = template.getValues(template.widgetContainer); + } + + if (input.name.match(/n_/)) + { + var value = ''; + if (values.n_prefix) value += values.n_prefix+" "; + if (values.n_given) value += values.n_given+" "; + if (values.n_middle) value += values.n_middle+" "; + if (values.n_family) value += values.n_family+" "; + if (values.n_suffix) value += values.n_suffix; + + var name = document.getElementById("exec[n_fn]"); + if(name == null && template) { - selbox.set_select_options(data.fileas_sel_options); + name = template.widgetContainer.getWidgetById('n_fn'); + name.set_value(value); + } + else + { + name.value = value; } } - }); -} + egw.json('addressbook.addressbook_ui.ajax_check_values', [values, input.name, own_id]).sendRequest(true, function(data) { + if (data.msg && confirm(data.msg)) + { + for(var id in data.doublicates) + { + egw.open(id, 'addressbook'); + //opener.egw_openWindowCentered2(egw_webserverUrl+'/index.php?menuaction=addressbook.addressbook_ui.edit&contact_id='+id, '_blank', 870, 480, 'yes', 'addressbook'); + } + } + if (typeof data.fileas_options == 'object') + { + var selbox = document.getElementById("exec[fileas_type]"); + if (selbox) + { + for (var i=0; i < data.fileas_options.length; i++) + { + selbox.options[i].text = data.fileas_options[i]; + } + } + else if (template && (selbox = template.widgetContainer.getWidgetById('fileas_type'))) + { + selbox.set_select_options(data.fileas_sel_options); + } + } + }); + }, -function add_whole_list(list) -{ - if (document.getElementById("exec[nm][email_type][email_home]").checked == true) + add_whole_list: function(list) { - email_type = "email_home"; - } - else - { - email_type = "email"; - } - xajax_doXMLHTTP("addressbook.addressbook_ui.ajax_add_whole_list",list,email_type); -} - -function show_custom_country(selectbox) -{ - if(!selectbox) return; - var custom_field_name = selectbox.name.replace("countrycode", "countryname"); - var custom_field = document.getElementById(custom_field_name); - if(custom_field && selectbox.value == "-custom-") { - custom_field.style.display = "inline"; - } - else if (custom_field) - { - if((selectbox.value == "" || selectbox.value == null) && custom_field.value != "") + if (document.getElementById("exec[nm][email_type][email_home]").checked == true) { - selectbox.value = "-custom-"; - // Chosen needs this to update - $j(selectbox).trigger("liszt:updated"); - - custom_field.style.display = "inline"; + email_type = "email_home"; } else { - custom_field.style.display = "none"; + email_type = "email"; } - } -} + var request = new egw_json_request("addressbook.addressbook_ui.ajax_add_whole_list",list,email_type); + request.sendRequest(true); + }, -function add_new_list(owner) -{ - var name = window.prompt(egw.lang('Name for the distribution list')); - if (name) + show_custom_country: function(selectbox) { - egw.open('','addressbook', 'list', { - 'add_list': name, - 'owner': owner - },'_self'); - } -} + if(!selectbox) return; + var custom_field_name = selectbox.name.replace("countrycode", "countryname"); + var custom_field = document.getElementById(custom_field_name); + if(custom_field && selectbox.value == "-custom-") { + custom_field.style.display = "inline"; + } + else if (custom_field) + { + if((selectbox.value == "" || selectbox.value == null) && custom_field.value != "") + { + selectbox.value = "-custom-"; + // Chosen needs this to update + $j(selectbox).trigger("liszt:updated"); -/** - * et2 specific initialization - can be moved to init() when addressbook gets converted to et2 - */ -$j('.et2_container').on('load',function() { - - $j('select[id*="adr_one_countrycode"]').each(function() {show_custom_country(this);}); - $j('select[id*="adr_two_countrycode"]').each(function() {show_custom_country(this);}); -}); + custom_field.style.display = "inline"; + } + else + { + custom_field.style.display = "none"; + } + } + }, + + add_new_list: function(owner) + { + var name = window.prompt(egw.lang('Name for the distribution list')); + if (name) + { + egw.open('','addressbook', 'list', { + 'add_list': name, + 'owner': owner + },'_self'); + } + }, + + filter2_onchange: function() + { + var filter2 = this.et2.getWidgetById('filter2'); + var widget = this.et2.getWidgetById('nm'); + + if(filter2.get_value()=='add') + { + this.add_new_list(typeof widget == 'undefined' ? this.et2.getWidgetById('filter').value : widget.header.filter.get_value()); + this.value=''; + } + }, + + filter2_onchnage_email: function () + { + this.form.submit(); + if (this.value && confirm('Add emails of whole distribution list?')) + { + this.add_whole_list(this.value); + } + else + { + this.form.submit(); + } + }, + + /** + * + */ + nm_compare_field: function() + { + var field = this.et2.getWidgetById('filter2'); + if (field) var val = field.get_value(); + if (val) + { + return nm_compare_field; + } + else + { + return false; + } + }, + + /** + * + */ + adv_search: function() + { + var link = opener.location.href; + link = link.replace(/#/,''); + opener.location.href=link.replace(/\#/,''); + }, + + /** + * + */ + adb_mail_vcard: function(_action, _elems) + { + var app_registry = egw.link_get_registry('felamimail'); + var link = egw().link("/index.php","menuaction=felamimail.uicompose.compose"); + for (var i = 0; i < _elems.length; i++) + { + link += "&preset[file][]="+encodeURIComponent("vfs://default/apps/addressbook/"+_elems[i].id+"/.entry"); + } + if (typeof app_registry['view'] != 'undefined' && typeof app_registry['view_popup'] != 'undefined' ) + { + var w_h =app_registry['view_popup'].split('x'); + if (w_h[1] == 'egw_getWindowOuterHeight()') w_h[1] = (screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight()); + egw_openWindowCentered2(link, '_blank', w_h[0], w_h[1], 'yes'); + } + + }, + + /** + * + */ + adb_get_selection: function(form) + { + var use_all = document.getElementById("exec[use_all]"); + var action = document.getElementById("exec[action]"); + egw_openWindowCentered(egw().link("/index.php","menuaction=importexport.uiexport.export_dialog&appname=addressbook")+ + "&selection="+( use_all.checked ? "use_all" : get_selected(form,"[rows][checked][]")),"Export",400,400); + action.value=""; + use_all.checked = false; + return false; + }, + + /** + * + */ + do_action: function(selbox) + { + if (selbox.value != "") + { + if (selbox.value == "infolog_add" && (ids = get_selected(selbox.form,"[rows][checked][]")) && !document.getElementById("exec[use_all]").checked) + { + win = window.open(egw().link("/index.php","menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id="+ids),_blank,width=750,height=550,left=100,top=200); + win.focus(); + } + else if (selbox.value == "cat_add") + { + win = window.open(egw().link("/etemplate/process_exec.php","menuaction=addressbook.addressbook_ui.cat_add"),_blank,width=300,height=400,left=100,top=200); + win.focus(); + } + else if (selbox.value == "remove_from_list") + { + if (confirm(lang('Remove selected contacts from distribution list'))) selbox.form.submit(); + } + else if (selbox.value == "delete_list") + { + if (confirm(lang('Delete selected distribution list!'))) selbox.form.submit(); + } + else if (selbox.value == "delete") + { + if (confirm(lang('Delete'))) selbox.form.submit(); + } + else + { + selbox.form.submit(); + } + selbox.value = ""; + } + }, + + n_fn_search: function () + { + jQuery('table.editname').css('display','inline'); + //var focElem = document.getElementById(form::name('n_prefix')); + if (!(typeof(focElem) == 'undefined') && typeof(focElem.focus)=='function') + { + //document.getElementById(form::name('n_prefix')).focus(); + } + }, + + xajax_et: function() + { + this.et2.getInstanceManager().submit(this.et2.getWidgetById('button[search]')); + return false; + }, + + addEmail: function() + { + //Not implemented + }, + +}); \ No newline at end of file diff --git a/addressbook/templates/default/edit.xet b/addressbook/templates/default/edit.xet index 10b725149f..745d649d83 100644 --- a/addressbook/templates/default/edit.xet +++ b/addressbook/templates/default/edit.xet @@ -28,23 +28,23 @@ - + - + - + - + - + @@ -101,12 +101,12 @@ - + - + @@ -131,7 +131,7 @@ - + @@ -151,7 +151,7 @@ - + @@ -215,7 +215,7 @@ - + @@ -235,7 +235,7 @@ - + @@ -611,12 +611,12 @@ - + - + diff --git a/addressbook/templates/default/email.xet b/addressbook/templates/default/email.xet index da1e8737cc..b86b96244e 100644 --- a/addressbook/templates/default/email.xet +++ b/addressbook/templates/default/email.xet @@ -2,12 +2,12 @@