From e6e27fd29e362aadf9f4814363fdf26ed4f7919f Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 29 Oct 2012 19:18:27 +0000 Subject: [PATCH 001/150] Add category ACL check to export conversion to human values --- importexport/inc/class.importexport_export_csv.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/importexport/inc/class.importexport_export_csv.inc.php b/importexport/inc/class.importexport_export_csv.inc.php index 474ab78324..3816952952 100644 --- a/importexport/inc/class.importexport_export_csv.inc.php +++ b/importexport/inc/class.importexport_export_csv.inc.php @@ -376,7 +376,8 @@ class importexport_export_csv implements importexport_iface_export_record $cats = array(); $ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name); foreach($ids as $n => $cat_id) { - if ($cat_id) $cats[] = $GLOBALS['egw']->categories->id2name($cat_id); + if ($cat_id && $GLOBALS['egw']->categories->check_perms(EGW_ACL_READ,$cat_id)) + $cats[] = $GLOBALS['egw']->categories->id2name($cat_id); } $record->$name = implode(', ',$cats); } From 71cebbf12ea208b2db6e9ae298eb064b69c66304 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 30 Oct 2012 10:02:37 +0000 Subject: [PATCH 002/150] allow to query cache for multiple locations at once: $location param to getCache is an array and returned is an array indexed by these locations (not found entries are NOT returned --- phpgwapi/inc/class.egw_cache.inc.php | 135 +++++++++++++++--- phpgwapi/inc/class.egw_cache_memcache.inc.php | 31 +++- 2 files changed, 147 insertions(+), 19 deletions(-) diff --git a/phpgwapi/inc/class.egw_cache.inc.php b/phpgwapi/inc/class.egw_cache.inc.php index 0857326589..a4cf451c0f 100644 --- a/phpgwapi/inc/class.egw_cache.inc.php +++ b/phpgwapi/inc/class.egw_cache.inc.php @@ -108,11 +108,12 @@ class egw_cache * * @param string $level use egw_cache::(TREE|INSTANCE|SESSION|REQUEST) * @param string $app application storing data - * @param string $location location name for data + * @param string|array $location location(s) name for data * @param callback $callback=null callback to get/create the value, if it's not cache * @param array $callback_params=array() array with parameters for the callback * @param int $expiration=0 expiration time in seconds, default 0 = never - * @return mixed NULL if data not found in cache (and no callback specified) + * @return mixed NULL if data not found in cache (and no callback specified) or + * if $location is an array: location => data pairs for existing location-data, non-existing is not returned */ static public function getCache($level,$app,$location,$callback=null,array $callback_params=array(),$expiration=0) { @@ -120,7 +121,11 @@ class egw_cache { case self::SESSION: case self::REQUEST: - return call_user_func(array(__CLASS__,'get'.$level),$app,$location,$callback,$callback_params,$expiration); + foreach((array)$location as $l) + { + $data[$l] = call_user_func(array(__CLASS__,'get'.$level),$app,$l,$callback,$callback_params,$expiration); + } + return is_array($location) ? $data : $data[$l]; case self::INSTANCE: case self::TREE: @@ -129,17 +134,39 @@ class egw_cache return null; } try { - $data = $provider->get($keys=self::keys($level,$app,$location)); + if (is_array($location)) + { + if (!is_null($callback)) + { + throw new egw_exception_wrong_parameter(__METHOD__."() you can NOT use multiple locations (\$location parameter is an array) together with a callback!"); + } + if (is_a($provider, 'egw_cache_provider_multiple')) + { + $data = $provider->mget($keys=self::keys($level,$app,$location)); + } + else // default implementation calls get multiple times + { + $data = array(); + foreach($location as $l) + { + $data[$l] = $provider->get($keys=self::keys($level,$app,$l)); + if (!isset($data[$l])) unset($data[$l]); + } + } + } + else + { + $data = $provider->get($keys=self::keys($level,$app,$location)); + if (is_null($data) && !is_null($callback)) + { + $data = call_user_func_array($callback,$callback_params); + $provider->set($keys,$data,$expiration); + } + } } catch(Exception $e) { $data = null; } - if (is_null($data) && !is_null($callback)) - { - //error_log(__METHOD__."($level,$app,$location,".array2string($callback).','.array2string($callback_params).",$expiration) calling calback to create data."); - $data = call_user_func_array($callback,$callback_params); - $provider->set($keys,$data,$expiration); - } return $data; } throw new egw_exception_wrong_parameter(__METHOD__."() unknown level '$level'!"); @@ -571,6 +598,24 @@ interface egw_cache_provider function delete(array $keys); } +/** + * Interface for a caching provider for tree and instance level + * + * The provider can eg. create subdirs under /tmp for each key + * to store data as a file or concat them with a separator to + * get a single string key to eg. store data in memcached + */ +interface egw_cache_provider_multiple +{ + /** + * Get multiple data from the cache + * + * @param array $keys eg. array of array($level,$app,array $locations) + * @return array key => data stored, not found keys are NOT returned + */ + function mget(array $keys); +} + abstract class egw_cache_provider_check implements egw_cache_provider { /** @@ -581,12 +626,17 @@ abstract class egw_cache_provider_check implements egw_cache_provider */ function check($verbose=false) { + // set us up as provider for egw_cache class + $GLOBALS['egw_info']['server']['install_id'] = md5(microtime(true)); + egw_cache::$default_provider = $this; + $failed = 0; foreach(array( egw_cache::TREE => 'tree', egw_cache::INSTANCE => 'instance', ) as $level => $label) { + $locations = array(); foreach(array('string',123,true,false,null,array(),array(1,2,3)) as $data) { $location = md5(microtime(true).$label.serialize($data)); @@ -607,6 +657,15 @@ abstract class egw_cache_provider_check implements egw_cache_provider if ($verbose) echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n"; ++$failed; } + if (is_a($this, 'egw_cache_provider_multiple')) + { + $mget_after_set = $this->mget(array($level,__CLASS__,array($location))); + if ($mget_after_set[$location] !== $data) + { + if ($verbose) echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n"; + ++$failed; + } + } if (($delete = $this->delete(array($level,__CLASS__,$location))) !== true) { if ($verbose) echo "$label: delete returned ".array2string($delete)." !== TRUE\n"; @@ -618,6 +677,46 @@ abstract class egw_cache_provider_check implements egw_cache_provider if ($verbose) echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n"; ++$failed; } + // prepare for mget of everything + if (is_a($this, 'egw_cache_provider_multiple')) + { + $locations[$location] = $data; + $mget_after_delete = $this->mget(array($level,__CLASS__,array($location))); + if (isset($mget_after_delete[$location])) + { + if ($verbose) echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n"; + ++$failed; + } + $this->set(array($level,__CLASS__,$location), $data, 10); + } + elseif (!is_null($data)) // emulation can NOT distinquish between null and not set + { + $locations[$location] = $data; + egw_cache::setCache($level, __CLASS__, $location, $data); + } + } + // get all above in one request + $keys = array_keys($locations); + $keys_bogus = array_merge(array('not-set'),array_keys($locations),array('not-set-too')); + if (is_a($this, 'egw_cache_provider_multiple')) + { + $mget = $this->mget(array($level,__CLASS__,$keys)); + $mget_bogus = $this->mget(array($level,__CLASS__,$keys_bogus)); + } + else + { + $mget = egw_cache::getCache($level, __CLASS__, $keys); + $mget_bogus = egw_cache::getCache($level, __CLASS__, $keys_bogus); + } + if ($mget !== $locations) + { + if ($verbose) echo "$label: mget=
".array2string($mget)." !==
".array2string($locations)."\n"; + ++$failed; + } + if ($mget_bogus !== $locations) + { + if ($verbose) echo "$label: mget(".array2string($keys_bogus).")=
".array2string($mget_bogus)." !==
".array2string($locations)."\n"; + ++$failed; } } @@ -625,15 +724,9 @@ abstract class egw_cache_provider_check implements egw_cache_provider } } -// setting apc as default provider, if apc_fetch function exists AND further checks in egw_cache_apc recommed it -if (is_null(egw_cache::$default_provider)) -{ - egw_cache::$default_provider = function_exists('apc_fetch') && egw_cache_apc::available() ? 'egw_cache_apc' : 'egw_cache_files'; -} - // some testcode, if this file is called via it's URL // can be run on command-line: sudo php -d apc.enable_cli=1 -f phpgwapi/inc/class.egw_cache.inc.php -/*if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) +if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) { if (!isset($_SERVER['HTTP_HOST'])) { @@ -670,4 +763,10 @@ if (is_null(egw_cache::$default_provider)) printf($e->getMessage()."\n\n"); } } -}*/ +} + +// setting apc as default provider, if apc_fetch function exists AND further checks in egw_cache_apc recommed it +if (is_null(egw_cache::$default_provider)) +{ + egw_cache::$default_provider = function_exists('apc_fetch') && egw_cache_apc::available() ? 'egw_cache_apc' : 'egw_cache_files'; +} diff --git a/phpgwapi/inc/class.egw_cache_memcache.inc.php b/phpgwapi/inc/class.egw_cache_memcache.inc.php index fb27d1ab79..3d5d18cee4 100644 --- a/phpgwapi/inc/class.egw_cache_memcache.inc.php +++ b/phpgwapi/inc/class.egw_cache_memcache.inc.php @@ -22,7 +22,7 @@ * * You can set more then one server and specify a port, if it's not the default one 11211. */ -class egw_cache_memcache extends egw_cache_provider_check implements egw_cache_provider +class egw_cache_memcache extends egw_cache_provider_check implements egw_cache_provider_multiple { /** * Instance of Memcache @@ -95,6 +95,35 @@ class egw_cache_memcache extends egw_cache_provider_check implements egw_cache_p return unserialize($data); } + /** + * Get multiple data from the cache + * + * @param array $keys eg. array of array($level,$app,array $locations) + * @return array key => data stored, not found keys are NOT returned + */ + function mget(array $keys) + { + $locations = array_pop($keys); + $prefix = self::key($keys); + foreach($locations as &$location) + { + $location = $prefix.'::'.$location; + } + if (($multiple = $this->memcache->get($locations)) === false) + { + return array(); + } + $ret = array(); + $prefix_len = strlen($prefix)+2; + foreach($multiple as $location => $data) + { + $key = substr($location,$prefix_len); + error_log(__METHOD__."(".array2string($locations).") key='$key' found ".bytes($data)." bytes)."); + $ret[$key] = unserialize($data); + } + return $ret; + } + /** * Delete some data from the cache * From 7cd606e5295a264730bece0b20038d695bd8f6e9 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 30 Oct 2012 10:22:05 +0000 Subject: [PATCH 003/150] cumulate group-preferences of all memberships of a user, not just his primary group --- phpgwapi/inc/class.preferences.inc.php | 35 +++++++++++++++----------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/phpgwapi/inc/class.preferences.inc.php b/phpgwapi/inc/class.preferences.inc.php index 4a1b857d5a..4f40925410 100644 --- a/phpgwapi/inc/class.preferences.inc.php +++ b/phpgwapi/inc/class.preferences.inc.php @@ -18,7 +18,7 @@ * the prefs are read into 5 arrays: * $data the effective prefs used everywhere in phpgw, they are merged from the other 3 arrays * $user the stored user prefs, only used for manipulating and storeing the user prefs - * $group the stored prefs of users primary groupd, only used for manipulating and storeing the user prefs + * $group the stored prefs of all group-memberships of current user, can NOT be deleted or stored directly! * $default the default preferences, always used when the user has no own preference set * $forced forced preferences set by the admin, they take precedence over user or default prefs * @@ -155,12 +155,11 @@ class preferences */ function cache_read($ids) { - $prefs = $db_read = array(); - + $prefs = egw_cache::getInstance(__CLASS__, $ids); + $db_read = array(); foreach((array)$ids as $id) { - $prefs[$id] = egw_cache::getInstance(__CLASS__, $id); - // if prefs are not returned (null) or not an array, read them from db + // if prefs are not returned, null or not an array, read them from db if (!isset($prefs[$id]) && !is_array($prefs[$id])) $db_read[] = $id; } if ($db_read) @@ -345,13 +344,17 @@ class preferences $this->session = array(); } $this->forced = $this->default = $this->user = $this->group = array(); - $primary_group = accounts::id2name($this->account_id, 'account_primary_group'); - foreach($this->cache_read(array( - self::DEFAULT_ID, - self::FORCED_ID, - $this->account_id, - $primary_group+self::DEFAULT_ID, // need to offset it with DEFAULT_ID = -2! - )) as $id => $values) + $to_read = array(self::DEFAULT_ID,self::FORCED_ID,$this->account_id); + if ($this->account_id > 0) + { + $primary_group = accounts::id2name($this->account_id, 'account_primary_group'); + foreach($GLOBALS['egw']->accounts->memberships($this->account_id, true) as $gid) + { + if ($gid != $primary_group) $to_read[] = $gid + self::DEFAULT_ID; // need to offset it with DEFAULT_ID = -2! + } + $to_read[] = $primary_group + self::DEFAULT_ID; + } + foreach($this->cache_read($to_read) as $id => $values) { switch($id) { @@ -365,7 +368,10 @@ class preferences $this->user = $values; break; default: - $this->group = $values; + foreach($values as $app => $vals) + { + $this->group[$app] = $vals + (array)$this->group[$app]; + } break; } } @@ -750,8 +756,7 @@ class preferences $prefs = &$this->default; break; case 'group': - $account_id = $GLOBALS['egw']->accounts->id2name($this->account_id,'account_primary_group')+self::DEFAULT_ID; - $prefs = &$this->group; + throw new egw_exception_wrong_parameter("Can NOT save group preferences, as they are from multiple groups!"); break; default: $account_id = (int)$this->account_id; From d28f83d70e92d0e9c3aab8506721cddb2b247c81 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 30 Oct 2012 12:25:10 +0000 Subject: [PATCH 004/150] disable permanent error-log and tests --- phpgwapi/inc/class.egw_cache.inc.php | 4 ++-- phpgwapi/inc/class.egw_cache_memcache.inc.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpgwapi/inc/class.egw_cache.inc.php b/phpgwapi/inc/class.egw_cache.inc.php index a4cf451c0f..374b969064 100644 --- a/phpgwapi/inc/class.egw_cache.inc.php +++ b/phpgwapi/inc/class.egw_cache.inc.php @@ -726,7 +726,7 @@ abstract class egw_cache_provider_check implements egw_cache_provider // some testcode, if this file is called via it's URL // can be run on command-line: sudo php -d apc.enable_cli=1 -f phpgwapi/inc/class.egw_cache.inc.php -if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) +/*if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) { if (!isset($_SERVER['HTTP_HOST'])) { @@ -763,7 +763,7 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) printf($e->getMessage()."\n\n"); } } -} +}*/ // setting apc as default provider, if apc_fetch function exists AND further checks in egw_cache_apc recommed it if (is_null(egw_cache::$default_provider)) diff --git a/phpgwapi/inc/class.egw_cache_memcache.inc.php b/phpgwapi/inc/class.egw_cache_memcache.inc.php index 3d5d18cee4..5e8f07aaba 100644 --- a/phpgwapi/inc/class.egw_cache_memcache.inc.php +++ b/phpgwapi/inc/class.egw_cache_memcache.inc.php @@ -118,7 +118,7 @@ class egw_cache_memcache extends egw_cache_provider_check implements egw_cache_p foreach($multiple as $location => $data) { $key = substr($location,$prefix_len); - error_log(__METHOD__."(".array2string($locations).") key='$key' found ".bytes($data)." bytes)."); + //error_log(__METHOD__."(".array2string($locations).") key='$key' found ".bytes($data)." bytes)."); $ret[$key] = unserialize($data); } return $ret; From 40bf41ccdc2029c29b58035729890fffe839a604 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 30 Oct 2012 12:57:07 +0000 Subject: [PATCH 005/150] do NOT track creator, as it does not change, only shows up in history sometimes, because eg. iCal import does not set it --- calendar/inc/class.calendar_tracking.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/calendar/inc/class.calendar_tracking.inc.php b/calendar/inc/class.calendar_tracking.inc.php index 4ac2d1083f..a56f6f2dc4 100644 --- a/calendar/inc/class.calendar_tracking.inc.php +++ b/calendar/inc/class.calendar_tracking.inc.php @@ -54,7 +54,6 @@ class calendar_tracking extends bo_tracking 'reference' => 'reference', 'non_blocking' => 'non_blocking', 'special' => 'special', - 'creator' => 'creator', 'recurrence' => 'recurrence', 'tz_id' => 'tz_id', @@ -82,7 +81,6 @@ class calendar_tracking extends bo_tracking 'reference' => 'reference', 'non_blocking' => 'non blocking', 'special' => 'special', - 'creator' => 'creator', 'recurrence'=> 'recurrence', 'tz_id' => 'timezone', From b61d5d537fef06f2d95da0df14d1cc00ad13d242 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 30 Oct 2012 13:36:21 +0000 Subject: [PATCH 006/150] download etemplate.inc.php distribution file, if webserver has no write rights to setup directory --- etemplate/inc/class.soetemplate.inc.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/etemplate/inc/class.soetemplate.inc.php b/etemplate/inc/class.soetemplate.inc.php index 3d4deb7bbc..7f44319d59 100644 --- a/etemplate/inc/class.soetemplate.inc.php +++ b/etemplate/inc/class.soetemplate.inc.php @@ -875,19 +875,23 @@ class soetemplate $dir = EGW_SERVER_ROOT . "/$app/setup"; if (!is_writeable($dir)) { - return lang("Error: webserver is not allowed to write into '%1' !!!",$dir); + // if dir is not writable, download file + html::content_header('etemplates.inc.php','application/octet-stream'); + $file = 'php://stdout'; } - $file = "$dir/etemplates.inc.php"; - if (file_exists($file)) + else { - $old_file = "$dir/etemplates.old.inc.php"; - if (file_exists($old_file)) + $file = "$dir/etemplates.inc.php"; + if (file_exists($file)) { - unlink($old_file); + $old_file = "$dir/etemplates.old.inc.php"; + if (file_exists($old_file)) + { + unlink($old_file); + } + rename($file,$old_file); } - rename($file,$old_file); } - if (!($f = fopen($file,'w'))) { return 0; @@ -930,6 +934,8 @@ class soetemplate } fclose($f); + if ($file == 'php://stdout') common::egw_exit(); + return lang("%1 eTemplates for Application '%2' dumped to '%3'",$n,$app,$file); } From 627c65e6dd6c68fef13dd5dc4d7841f10913ab9b Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 30 Oct 2012 14:24:08 +0000 Subject: [PATCH 007/150] * eMail/HTMLawed: introduce and use new make_tag_strict option 3, to exclude font from applying strict measures to it --- phpgwapi/inc/class.egw_htmLawed.inc.php | 3 ++- phpgwapi/inc/htmLawed/htmLawed.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phpgwapi/inc/class.egw_htmLawed.inc.php b/phpgwapi/inc/class.egw_htmLawed.inc.php index f584edaf39..6a0e67d05e 100644 --- a/phpgwapi/inc/class.egw_htmLawed.inc.php +++ b/phpgwapi/inc/class.egw_htmLawed.inc.php @@ -64,7 +64,7 @@ class egw_htmLawed 'hook_tag'=>array('', '', 'name of custom function to further check attribute values', '25'), 'keep_bad'=>array('7', '6', 'keep, or remove bad tag content', '0'), 'lc_std_val'=>array('2', '1', 'lower-case std. attribute values like radio', '0'), - 'make_tag_strict'=>array('3', 'nil', 'transform deprecated elements', 'nil'), + 'make_tag_strict'=>array('3', 'nil', 'transform deprecated elements', 'nil'), 3 is a new own config value, to indicate that transformation is to be performed, but don't transform font as size transformation of numeric sizes to keywords alters the intended result too much 'named_entity'=>array('2', '1', 'allow named entities, or convert numeric ones', '0'), 'no_deprecated_attr'=>array('3', '1', 'allow deprecated attributes, or transform them', '0'), 'parent'=>array('', 'div', 'name of parent element', '25'), @@ -81,6 +81,7 @@ class egw_htmLawed */ $this->Configuration = array('comment'=>1, //remove comments + 'make_tag_strict'=>3,//3 is a new own config value, to indicate that transformation is to be performed, but don't transform font, as size transformation of numeric sizes to keywords alters the intended result too much 'balance'=>0,//turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering) 'tidy'=>1, 'elements' => "* -script", diff --git a/phpgwapi/inc/htmLawed/htmLawed.php b/phpgwapi/inc/htmLawed/htmLawed.php index b6a3c74451..99ea4ee0e3 100644 --- a/phpgwapi/inc/htmLawed/htmLawed.php +++ b/phpgwapi/inc/htmLawed/htmLawed.php @@ -631,7 +631,7 @@ if($e == 'dir' or $e == 'menu'){$e = 'ul'; return '';} if($e == 's' or $e == 'strike'){$e = 'span'; return 'text-decoration: line-through;';} if($e == 'u'){$e = 'span'; return 'text-decoration: underline;';} static $fs = array('0'=>'xx-small', '1'=>'xx-small', '2'=>'small', '3'=>'medium', '4'=>'large', '5'=>'x-large', '6'=>'xx-large', '7'=>'300%', '-1'=>'smaller', '-2'=>'60%', '+1'=>'larger', '+2'=>'150%', '+3'=>'200%', '+4'=>'300%'); -if($e == 'font'){ +if($e == 'font' && $t !=3){//3 is a new make_tag_strict config value, to indicate that transformation is to be performed, but don't transform font, as size transformation of numeric sizes to keywords alters the intended result too much $a2 = ''; if(preg_match('`face\s*=\s*(\'|")([^=]+?)\\1`i', $a, $m) or preg_match('`face\s*=(\s*)(\S+)`i', $a, $m)){ $a2 .= ' font-family: '. str_replace('"', '\'', trim($m[2])). ';'; From 49a0d7032442a013e40f918da3de1b87d57131ac Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 30 Oct 2012 14:43:10 +0000 Subject: [PATCH 008/150] correctly urlencode redirects if we have no ntlm available --- phpgwapi/ntlm/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpgwapi/ntlm/index.php b/phpgwapi/ntlm/index.php index 32d0481f82..fb58afc78c 100644 --- a/phpgwapi/ntlm/index.php +++ b/phpgwapi/ntlm/index.php @@ -67,7 +67,7 @@ function check_access(&$account) } else { - header('Location: ../../login.php'.(isset($_REQUEST['phpgw_forward']) ? '?phpgw_forward='.$_REQUEST['phpgw_forward'] : '')); + header('Location: ../../login.php'.(isset($_REQUEST['phpgw_forward']) ? '?phpgw_forward='.urlencode($_REQUEST['phpgw_forward']) : '')); } exit; } From 10e2e6556a216b9ff2a049bde0a98e349ad76fff Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 30 Oct 2012 16:34:27 +0000 Subject: [PATCH 009/150] * Notifications: activate links when creating a html mail from a plain-text one --- notifications/inc/class.notifications.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notifications/inc/class.notifications.inc.php b/notifications/inc/class.notifications.inc.php index 518ea4ffa9..27f27ab11f 100644 --- a/notifications/inc/class.notifications.inc.php +++ b/notifications/inc/class.notifications.inc.php @@ -554,7 +554,7 @@ final class notifications { if(!empty($_message_plain)) { $messages['plain'] = $_message_plain; } else { - $messages['plain'] = strip_tags($_message_html); + $messages['plain'] = translation::convertHTMLToText($_message_html, false, true); } if(!empty($_message_html)) { @@ -574,7 +574,7 @@ final class notifications { */ public static function plain2html($_plain) { - return nl2br(html::htmlspecialchars($_plain, true)); + return html::activate_links(nl2br(html::htmlspecialchars($_plain, true))); } /** From 1da2374c8858e9f9889c73bf39e0986af73a39d9 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 30 Oct 2012 16:48:07 +0000 Subject: [PATCH 010/150] display thumbnail now for images up to 1.6M, which seem to work with our current recommended memory_limit of 128M --- etemplate/inc/class.vfs_widget.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etemplate/inc/class.vfs_widget.inc.php b/etemplate/inc/class.vfs_widget.inc.php index c41dc1ad88..fdfdf09d32 100644 --- a/etemplate/inc/class.vfs_widget.inc.php +++ b/etemplate/inc/class.vfs_widget.inc.php @@ -323,7 +323,7 @@ class vfs_widget (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' && (string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' && // check the size of the image, as too big images get no icon, but a PHP Fatal error: Allowed memory size exhausted - (!is_array($value) && ($stat = egw_vfs::stat($path)) ? $stat['size'] : $value['size']) < 600000) + (!is_array($value) && ($stat = egw_vfs::stat($path)) ? $stat['size'] : $value['size']) < 1600000) { if (substr($path,0,6) == '/apps/') { From fb77a9009d95915946ab8476be733f1b66939aba Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 31 Oct 2012 09:18:39 +0000 Subject: [PATCH 011/150] * eTemplate/all apps: fixed not working display of floating point values in input fields for Chrome or Safarie (browsers supporting html5 input type="number") --- etemplate/inc/class.etemplate_old.inc.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.etemplate_old.inc.php b/etemplate/inc/class.etemplate_old.inc.php index 2629e674db..ee04559e9a 100644 --- a/etemplate/inc/class.etemplate_old.inc.php +++ b/etemplate/inc/class.etemplate_old.inc.php @@ -1986,6 +1986,11 @@ class etemplate_old extends boetemplate /** * Format a number according to user prefs with decimal and thousands separator (later only for readonly) * + * HTML5 input type=number requires a float value with a dot, not comma! + * Chrome 22 and Safari 6 shows no value if a comma is used, + * while FF 16, IE 9 and 10 have no support for input type=number :-( + * --> use . as decimal separator for browser supporting html5 input type=number + * * @param int|float|string $number * @param int $num_decimal_places=2 * @param boolean $readonly=true @@ -2002,7 +2007,13 @@ class etemplate_old extends boetemplate } if ((string)$number === '') return ''; - return number_format(str_replace(' ','',$number),$num_decimal_places,$dec_separator,$readonly ? $thousands_separator : ''); + $ret = number_format(str_replace(' ','',$number), $num_decimal_places, + // need to use '.' as decimal separator for all browser supporting html5 input type=number + $dec_sep_used=$readonly || !in_array(html::$user_agent, array('chrome', 'safari', 'opera')) ? + $dec_separator : '.', + $readonly ? $thousands_separator : ''); + //error_log(__METHOD__."($number, $num_decimal_places, $readonly) html::user_agent=".html::$user_agent.", dec_sep='$dec_separator' --> '$dec_sep_used', thousands_sep='$thousands_separator' returning '$ret'"); + return $ret; } /** From 6e374a46975713cd17cd051c94b01ccb475898fb Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Wed, 31 Oct 2012 13:47:10 +0000 Subject: [PATCH 012/150] allow/support questionmark for first additional parameter after email --- etemplate/inc/class.url_widget.inc.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/etemplate/inc/class.url_widget.inc.php b/etemplate/inc/class.url_widget.inc.php index 4cb00862b1..045d6de68e 100644 --- a/etemplate/inc/class.url_widget.inc.php +++ b/etemplate/inc/class.url_widget.inc.php @@ -128,6 +128,15 @@ class url_widget //error_log(__METHOD__.__LINE__.$email.' '.$addoptions); $rfc822 = $value = $email; } + else + { + if (($q_pos = strpos(substr($value,$at_pos),'?')) !== false) + { + $email = substr($value,0,$q_pos+$at_pos); + $addoptions = substr($value, $q_pos+$at_pos+1); + $rfc822 = $value = $email; + } + } if (strlen($value) > $size) // shorten the name to size-2 plus '...' { $value = substr($value,0,$size-2).'...'; From b514745d01e674b36f1faf63a30da08ab3575967 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 31 Oct 2012 13:56:40 +0000 Subject: [PATCH 013/150] * Admin: new function "Clear cache and register hooks", also called automatic when restoring a backup --- .../class.admin_prefs_sidebox_hooks.inc.php | 4 +- admin/lang/egw_de.lang | 2 +- admin/lang/egw_en.lang | 2 +- phpgwapi/inc/class.db_backup.inc.php | 6 +- phpgwapi/inc/class.egw_cache.inc.php | 87 ++++++++++++++++++- 5 files changed, 94 insertions(+), 7 deletions(-) diff --git a/admin/inc/class.admin_prefs_sidebox_hooks.inc.php b/admin/inc/class.admin_prefs_sidebox_hooks.inc.php index 8f2a1826bd..cbd39cbc40 100644 --- a/admin/inc/class.admin_prefs_sidebox_hooks.inc.php +++ b/admin/inc/class.admin_prefs_sidebox_hooks.inc.php @@ -98,7 +98,7 @@ class admin_prefs_sidebox_hooks if (! $GLOBALS['egw']->acl->check('applications_access',16,'admin')) { - $file['Find and Register all Application Hooks'] = egw::link('/index.php','menuaction=admin.admin_prefs_sidebox_hooks.register_all_hooks'); + $file['Clear cache and register hooks'] = egw::link('/index.php','menuaction=admin.admin_prefs_sidebox_hooks.register_all_hooks'); } if (! $GLOBALS['egw']->acl->check('asyncservice_access',1,'admin')) @@ -141,6 +141,8 @@ class admin_prefs_sidebox_hooks { $GLOBALS['egw']->redirect_link('/index.php'); } + egw_cache::flush(egw_cache::INSTANCE); + $GLOBALS['egw']->hooks->register_all_hooks(); common::delete_image_map(); diff --git a/admin/lang/egw_de.lang b/admin/lang/egw_de.lang index 63e3db4f32..7958fdfc7b 100644 --- a/admin/lang/egw_de.lang +++ b/admin/lang/egw_de.lang @@ -132,6 +132,7 @@ check categories for not (longer) existing accounts admin de Prüfe Kategorien a check ip address of all sessions admin de IP-Adresse für alle Sessions überprüfen check items to %1 to %2 for %3 admin de Durch Abhaken %3 in %2 %1 children admin de Kinder +clear cache and register hooks admin de Cache löschen und Hooks registrieren click to select a color admin de Anklicken um eine Farbe auszuwählen color admin de Farbe command scheduled to run at %1 admin de Ausführung des Befehls eingeplant am/um %1 @@ -289,7 +290,6 @@ false admin de Falsch field '%1' already exists !!! admin de Feld '%1' existiert bereits !!! file space admin de Speicherplatz file space must be an integer admin de Speicherplatz muss eine Zahl sein -find and register all application hooks admin de Suchen und registrieren der "Hooks" aller Anwendungen for the times above admin de für die oben angegebenen Zeiten for the times below (empty values count as '*', all empty = every minute) admin de für die darunter angegebenen Zeiten (leere Felder zählen als "*", alles leer = jede Minute) force password strength (1-5, default empty: no check against rules for a strong password)? admin de Erzwinge eine gewisse Qualität der Passwörter im Passwort-Ändern Dialog (1-5, 1:gering, 5=stark; Default=leer kein Check gegen Regeln zur Passwortqualität) diff --git a/admin/lang/egw_en.lang b/admin/lang/egw_en.lang index 127633c72f..482ad8af0f 100644 --- a/admin/lang/egw_en.lang +++ b/admin/lang/egw_en.lang @@ -132,6 +132,7 @@ check categories for not (longer) existing accounts admin en Check categories fo check ip address of all sessions admin en Check IP address of all sessions check items to %1 to %2 for %3 admin en Check items to %1 to %2 for %3 children admin en Children +clear cache and register hooks admin en Clear cache and register hooks click to select a color admin en Click to select a color color admin en Color command scheduled to run at %1 admin en Command scheduled to run at %1 @@ -289,7 +290,6 @@ false admin en False field '%1' already exists !!! admin en Field '%1' already exists! file space admin en File space file space must be an integer admin en File space must be an integer -find and register all application hooks admin en Find and register all application hooks for the times above admin en For the times above for the times below (empty values count as '*', all empty = every minute) admin en For the times below: empty values count as '*', all empty = every minute. force password strength (1-5, default empty: no check against rules for a strong password)? admin en Set required password strength. 1 = weak, up to 5 = very strong. Default = empty, no password strength checked diff --git a/phpgwapi/inc/class.db_backup.inc.php b/phpgwapi/inc/class.db_backup.inc.php index 64ac0a5b3e..3ecc954e0c 100644 --- a/phpgwapi/inc/class.db_backup.inc.php +++ b/phpgwapi/inc/class.db_backup.inc.php @@ -620,12 +620,12 @@ class db_backup { return lang('Restore failed'); } + // flush instance cache + egw_cache::flush(egw_cache::INSTANCE); + // search-and-register-hooks $GLOBALS['egw']->hooks->register_all_hooks(); - // invalidate categories cache, it's instance wide - categories::invalidate_cache(); - return ''; } diff --git a/phpgwapi/inc/class.egw_cache.inc.php b/phpgwapi/inc/class.egw_cache.inc.php index 374b969064..886cc160f2 100644 --- a/phpgwapi/inc/class.egw_cache.inc.php +++ b/phpgwapi/inc/class.egw_cache.inc.php @@ -512,6 +512,62 @@ class egw_cache return $GLOBALS['egw_info']['server'][$name]; } + /** + * Flush (delete) whole (instance) cache or application/class specific part of it + * + * @param $string $level=self::INSTANCE + * @param string $app=null + */ + static public function flush($level=self::INSTANCE, $app=null) + { + $ret = true; + if (!($provider = self::get_provider($level))) + { + $ret = false; + } + else + { + $keys = array($level); + if ($app) $keys[] = $app; + if (!$provider->flush($keys)) + { + if ($level == self::INSTANCE) + { + self::generate_instance_key(); + } + else + { + $ret = false; + } + } + } + //error_log(__METHOD__."('$level', '$app') returning ".array2string($ret)); + return $ret; + } + + /** + * Key used for instance specific data + * + * @var string + */ + private static $instance_key; + + /** + * Generate a new instance key and by doing so effectivly flushes whole instance cache + * + * @return string new key also stored in self::$instance_key + */ + static public function generate_instance_key() + { + $install_id = self::get_system_config('install_id'); + + self::$instance_key = self::INSTANCE.'-'.$install_id.'-'.microtime(true); + self::setTree(__CLASS__, $install_id, self::$instance_key); + + //error_log(__METHOD__."() install_id='$install_id' returning '".self::$instance_key."'"); + return self::$instance_key; + } + /** * Get keys array from $level, $app and $location * @@ -537,7 +593,13 @@ class egw_cache } break; case self::INSTANCE: - $bases[$level] = $level.'-'.self::get_system_config('install_id'); + if (!isset(self::$instance_key)) + { + self::$instance_key = self::getTree(__CLASS__, self::get_system_config('install_id')); + //error_log(__METHOD__."('$level',...) instance_key read from tree-cache=".array2string(self::$instance_key)); + if (!isset(self::$instance_key)) self::generate_instance_key(); + } + $bases[$level] = self::$instance_key; break; } } @@ -596,6 +658,16 @@ interface egw_cache_provider * @return boolean true on success, false on error (eg. $key not set) */ function delete(array $keys); + + /** + * Delete all data under given keys + * + * Providers can return false, if they do not support flushing part of the cache (eg. memcache) + * + * @param array $keys eg. array($level,$app,$location) + * @return boolean true on success, false on error (eg. $key not set) + */ + function flush(array $keys); } /** @@ -722,6 +794,19 @@ abstract class egw_cache_provider_check implements egw_cache_provider return $failed; } + + /** + * Delete all data under given keys + * + * Providers can return false, if they do not support flushing part of the cache (eg. memcache) + * + * @param array $keys eg. array($level,$app,$location) + * @return boolean true on success, false on error (eg. $key not set) + */ + function flush(array $keys) + { + return false; + } } // some testcode, if this file is called via it's URL From 8c4125e75cc72b6c0d50a83dc4e3d491f73dc4fd Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 31 Oct 2012 14:00:34 +0000 Subject: [PATCH 014/150] * Admin: new function "Clear cache and register hooks", also called automatic when restoring a backup --- phpgwapi/inc/class.egw_cache_apc.inc.php | 19 +++++++++- phpgwapi/inc/class.egw_cache_files.inc.php | 43 ++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/phpgwapi/inc/class.egw_cache_apc.inc.php b/phpgwapi/inc/class.egw_cache_apc.inc.php index 6cc83c0645..5c13d09f28 100644 --- a/phpgwapi/inc/class.egw_cache_apc.inc.php +++ b/phpgwapi/inc/class.egw_cache_apc.inc.php @@ -116,13 +116,30 @@ class egw_cache_apc extends egw_cache_provider_check implements egw_cache_provid return apc_delete(self::key($keys)); } + /** + * Delete all data under given keys + * + * @param array $keys eg. array($level,$app,$location) + * @return boolean true on success, false on error (eg. $key not set) + */ + function flush(array $keys) + { + //error_log(__METHOD__."(".array2string($keys).")"); + foreach(new APCIterator('user', $preg='/^'.preg_quote(self::key($keys).'/')) as $item) + { + //error_log(__METHOD__."(".array2string($keys).") preg='$preg': calling apc_delete('$item[key]')"); + apc_delete($item['key']); + } + return true; + } + /** * Create a single key from $keys * * @param array $keys * @return string */ - private function key(array $keys) + private static function key(array $keys) { return implode('::',$keys); } diff --git a/phpgwapi/inc/class.egw_cache_files.inc.php b/phpgwapi/inc/class.egw_cache_files.inc.php index 78441d1663..7a49a8a66d 100644 --- a/phpgwapi/inc/class.egw_cache_files.inc.php +++ b/phpgwapi/inc/class.egw_cache_files.inc.php @@ -114,6 +114,49 @@ class egw_cache_files extends egw_cache_provider_check implements egw_cache_prov return unlink($fname); } + /** + * Delete all data under given keys + * + * @param array $keys eg. array($level,$app,$location) + * @return boolean true on success, false on error (eg. $key not set) + */ + function flush(array $keys) + { + $dir = $this->filename($keys, false); + + return file_exists($dir) ? self::rm_recursive($dir) : true; + } + + /** + * Recursive delete a path + * + * @param string $path + * @return boolean true on success, false otherwise + */ + private static function rm_recursive($path) + { + if (!is_dir($path)) + { + return unlink($path); + } + foreach(scandir($path) as $file) + { + if ($file == '.' || $file == '..') continue; + + $file = $path.'/'.$file; + + if (is_dir($file)) + { + if (!self::rm_recursive($file)) return false; + } + else + { + if (!unlink($path.'/'.$file)) return false; + } + } + return rmdir($path); + } + /** * Create a path from $keys and $basepath * From 06bc5ea552c3130ca8fe0c9e7c3426de0b38727b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 31 Oct 2012 14:16:17 +0000 Subject: [PATCH 015/150] do NOT delete preferences, before writing them in preferences::save_repository (might be cause for race-condition causing preferences to be lost) --- phpgwapi/inc/class.preferences.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpgwapi/inc/class.preferences.inc.php b/phpgwapi/inc/class.preferences.inc.php index 4f40925410..1bb112abd6 100644 --- a/phpgwapi/inc/class.preferences.inc.php +++ b/phpgwapi/inc/class.preferences.inc.php @@ -769,8 +769,6 @@ class preferences (!($old_prefs = $this->cache_read($account_id)) || $old_prefs[$account_id] != $prefs)) { $this->db->transaction_begin(); - $this->db->delete($this->table,array('preference_owner' => $account_id),__LINE__,__FILE__); - foreach($prefs as $app => $value) { if (!is_array($value) || !$value) From 3625cfb8552c2d69a6418401856a36fa27d5e51a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 31 Oct 2012 17:17:28 +0000 Subject: [PATCH 016/150] setup too: new function "Clear cache and register hooks", also called automatic when restoring a backup --- setup/applications.php | 2 ++ setup/inc/class.setup_html.inc.php | 6 +++--- setup/lang/egw_de.lang | 2 +- setup/lang/egw_en.lang | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/setup/applications.php b/setup/applications.php index 44643d077d..a4b2bc0cd0 100644 --- a/setup/applications.php +++ b/setup/applications.php @@ -232,6 +232,8 @@ else if(@get_var('hooks', Array('GET'))) { + egw_cache::flush(egw_cache::INSTANCE); + // Find & register all application hooks foreach($setup_info as $appname => $info) { diff --git a/setup/inc/class.setup_html.inc.php b/setup/inc/class.setup_html.inc.php index 0592b413d9..915c96a6e6 100644 --- a/setup/inc/class.setup_html.inc.php +++ b/setup/inc/class.setup_html.inc.php @@ -69,7 +69,7 @@ class setup_html } $GLOBALS['header_template']->set_var('domain',''); - + $setting = get_var('setting',Array('POST')); while($setting && list($k,$v) = @each($setting)) { @@ -135,7 +135,7 @@ class setup_html { $btn_logout = '' . lang('Logout').''; $check_install = ''.lang('Check installation').''; - $register_hooks = ''.lang('Find and Register all Application Hooks').''; + $register_hooks = ''.lang('Clear cache and register hooks').''; } $GLOBALS['setup_tpl']->set_var('lang_setup', lang('setup')); @@ -305,7 +305,7 @@ class setup_html } } $select .= '' . "\n"; - + return $select; } diff --git a/setup/lang/egw_de.lang b/setup/lang/egw_de.lang index 27603a0cb8..26a7660679 100644 --- a/setup/lang/egw_de.lang +++ b/setup/lang/egw_de.lang @@ -151,6 +151,7 @@ checking php.ini setup de Überprüfe die php.ini Datei checking required php version %1 (recommended %2) setup de Überprüfe benötigte PHP Version %1 (empfohlen %2) checking the egroupware installation setup de Überprüfe die EGroupware-Installation checks egroupware's installed, it's versions and necessary upgrads (return values see --exit-codes) setup de Überprüft ob EGroupware installiert ist, die Version und notwendige Aktualisierungen (Rückgabewerte siehe --exit-codes) +clear cache and register hooks setup de Cache löschen und Hooks registrieren click here to return to setup. setup de Hier klicken um zu Setup zurück zu kehren. click here setup de Hier klicken click here to re-run the installation tests setup de zum Wiederholen der Installationstests hier klicken @@ -294,7 +295,6 @@ file uploads are switched off: you can not use any of the filemanagers, nor can filename setup de Dateiname filesystem setup de Dateisystem filesystem (default) setup de Dateisystem (Vorgabe) -find and register all application hooks setup de Suchen und registrieren der "Hooks" aller Anwendungen force selectbox setup de Auswahl erzwingen give admin access to all installed apps setup de Admin Zugang zu allen installierten Anwendungen geben gives further options setup de gibt zusätzliche Optionen diff --git a/setup/lang/egw_en.lang b/setup/lang/egw_en.lang index 9fd72ea15b..403036ef85 100644 --- a/setup/lang/egw_en.lang +++ b/setup/lang/egw_en.lang @@ -151,6 +151,7 @@ checking php.ini setup en Checking php.ini checking required php version %1 (recommended %2) setup en Checking required PHP version %1 (recommended %2) checking the egroupware installation setup en Checking the eGroupWare Installation checks egroupware's installed, it's versions and necessary upgrads (return values see --exit-codes) setup en Checks EGroupware, it's versions and necessary upgrades (return values see --exit-codes) +clear cache and register hooks setup en Clear cache and register hooks click here to return to setup. setup en Click here to return to setup. click here setup en Click here click here to re-run the installation tests setup en Click here to re-run the installation tests @@ -294,7 +295,6 @@ file uploads are switched off: you can not use any of the filemanagers, nor can filename setup en File name filesystem setup en File system filesystem (default) setup en File system (default) -find and register all application hooks setup en Find and register all application hooks force selectbox setup en Force select box give admin access to all installed apps setup en Give admin access to all installed apps gives further options setup en Gives further options From 343ffd9149fea63d56cec9aeea3e6dec089fde0f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 31 Oct 2012 18:00:28 +0000 Subject: [PATCH 017/150] get filemanager select click on subdirs working again in old eTemplate --- filemanager/inc/class.filemanager_select.inc.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/filemanager/inc/class.filemanager_select.inc.php b/filemanager/inc/class.filemanager_select.inc.php index b447ea70fc..b86f1c324a 100644 --- a/filemanager/inc/class.filemanager_select.inc.php +++ b/filemanager/inc/class.filemanager_select.inc.php @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @package filemanager * @author Ralf Becker - * @copyright (c) 2009 by Ralf Becker + * @copyright (c) 2009-2012 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -220,6 +220,9 @@ class filemanager_select { $content['path'] = filemanager_ui::get_home_dir(); } + $tpl = new etemplate('filemanager.select'); + $et2 = class_exists('etemplate_widget', false) && is_a($tpl, 'etemplate_widget'); + if (!($files = egw_vfs::find($content['path'],array( 'dirsontop' => true, 'order' => 'name', @@ -248,7 +251,7 @@ class filemanager_select 'name' => $name, 'path' => $path, 'mime' => $mime, - 'onclick' => $is_dir ? "return select_goto('".addslashes($path)."',widget);" : + 'onclick' => $is_dir ? "return select_goto('".addslashes($path)."'".($et2?',widget':'').");" : ($content['mode'] != 'open-multiple' ? "return select_show('".addslashes($name)."');" : "return select_toggle('".addslashes($name)."');"), ); @@ -301,11 +304,10 @@ function select_toggle(file) '; // scroll to end of path - $GLOBALS['egw']->js->set_onload("var p = document.getElementById('exec[path][c". (count(explode('/',$content['path']))-1) ."]'); if (p) scrollIntoView();"); + $GLOBALS['egw']->js->set_onload("var p = document.getElementById('exec[path][c". (count(explode('/',$content['path']))-1) ."]'); if (p) p.scrollIntoView();"); //_debug_array($readonlys); egw_session::appsession('select_path','filemanger',$content['path']); - $tpl = new etemplate('filemanager.select'); $preserve = array( 'mode' => $content['mode'], 'method' => $content['method'], From 7bb16b48233bde16d6e6e5074da7fbca98f90c4e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 31 Oct 2012 18:20:34 +0000 Subject: [PATCH 018/150] * Filemanager: ability to create a directory in open or save-as dialog --- filemanager/inc/class.filemanager_select.inc.php | 10 ++++++++++ filemanager/setup/etemplates.inc.php | 5 +++-- filemanager/templates/default/select.xet | 6 ++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/filemanager/inc/class.filemanager_select.inc.php b/filemanager/inc/class.filemanager_select.inc.php index b86f1c324a..df1048f73c 100644 --- a/filemanager/inc/class.filemanager_select.inc.php +++ b/filemanager/inc/class.filemanager_select.inc.php @@ -126,6 +126,14 @@ class filemanager_select case 'home': $content['path'] = filemanager_ui::get_home_dir(); break; + case 'createdir': + if (!@egw_vfs::mkdir($content['path'],null,STREAM_MKDIR_RECURSIVE)) + { + $content['msg'] = !egw_vfs::is_writable(dirname($content['path'])) ? + lang('Permission denied!') : lang('Failed to create directory!'); + $content['path'] = $content['old_path']; + } + break; case 'ok': $copy_result = null; if (isset($content['file_upload']['name']) && is_uploaded_file($content['file_upload']['tmp_name'])) @@ -263,6 +271,7 @@ class filemanager_select } if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line } + $readonlys['button[createdir]'] = !egw_vfs::is_writable($content['path']); $content['js'] = '\n"; + $content['js'] .= ' window.close();'; + echo ''; common::egw_exit(); } $content['link_to']['to_id'] = $content['id']; - $GLOBALS['egw_info']['flags']['java_script'] .= ""; + $GLOBALS['egw_info']['flags']['java_script'] .= ""; break; case 'delete': if($this->action('delete',array($content['id']),false,$success,$failed,$action_msg,'',$content['msg'])) { - echo "\n"; + $js = "opener.egw_refresh('".str_replace("'","\\'",lang('Contact deleted'))."','addressbook',{$content['id']},'delete'); window.close();"; + echo ''; common::egw_exit(); } else From ec2f7879d42870e66b1a7e65f4284a907dabab09 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 9 Nov 2012 09:33:22 +0000 Subject: [PATCH 033/150] * Calendar: fix for failed 1.9.006 update: PostgreSQL needs temporary a nullable range_start column, to not stall on broken events without dates --- calendar/setup/tables_update.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php index 1b202e897b..6884788a15 100644 --- a/calendar/setup/tables_update.inc.php +++ b/calendar/setup/tables_update.inc.php @@ -2162,11 +2162,11 @@ function calendar_upgrade1_9_005() */ function calendar_upgrade1_9_006() { + // PostgreSQL needs temporary a nullable column, to not stall on broken events without dates! + // We add that constrain in 1.9.007, after deleting all rows with range_start=0 OR range_start IS NULL $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','range_start',array( 'type' => 'int', 'precision' => '8', - 'nullable' => False, - 'default' => '0', // PostgreSQL needs a temporary default, to create a nullable column! 'comment' => 'startdate (of range)' )); $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET range_start = (SELECT MIN(cal_start) FROM egw_cal_dates WHERE egw_cal_dates.cal_id=egw_cal.cal_id)', __LINE__, __FILE__); From 5057d1735edc8d5d90e9cb8effddda4f5e1299d8 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 9 Nov 2012 17:14:02 +0000 Subject: [PATCH 034/150] Allow viewing / editing deleted exceptions by editing the series --- calendar/inc/class.calendar_uiforms.inc.php | 2 +- calendar/inc/class.calendar_uilist.inc.php | 6 +++--- calendar/js/app.js | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 83cfadd5ea..0cbf9c45a5 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -1496,7 +1496,7 @@ function replace_eTemplate_onsubmit() { $content['alarm'] = false; } - $content['msg'] = $msg; + $content['msg'] = $msg ? $msg : $_GET['msg']; if ($view) { diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index 19430482e4..662b8b2858 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -364,11 +364,11 @@ class calendar_uilist extends calendar_ui { $event['class'] .= 'rowDeleted '; } - // Disable everything for 'deleted' exceptions - there's nothing - // logical to do except undelete it + // Disable delete for 'deleted' exceptions - deleting the exception + // would put it back, which you do from the series, not purge it if($search_params['filter'] == 'deleted' && $event['recur_type']) { - $event['class'] .= ' rowNoView rowNoDelete rowDeleted'; + $event['class'] .= ' rowDeleted rowNoDelete'; } // Filemanager disabled for other applications diff --git a/calendar/js/app.js b/calendar/js/app.js index d66702346d..53872cc40b 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -53,11 +53,19 @@ function cal_open(_action, _senders) var id = _senders[0].id; var matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/); var backup = _action.data; - if (matches) + var row = _senders[0].iface.node; + + if (matches && !$j(row).hasClass("rowDeleted")) { edit_series(matches[1],matches[2]); return; } + else if (matches && $j(row).hasClass("rowDeleted") && _action.data.url) + { + // Trying to edit a deleted exception, use original event & add a message + _senders[0].id = matches[1]; + _action.data.url += '&msg='+encodeURIComponent(egw.lang('Editing series')); + } else if (matches = id.match(/^([a-z_-]+)([0-9]+)/i)) { var app = matches[1]; From 2ecd33725d217bf85660d9400e5aba08f3c7a85e Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 9 Nov 2012 18:04:08 +0000 Subject: [PATCH 035/150] Add an action for deleted recurring events to delete the whole series --- calendar/inc/class.calendar_uilist.inc.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index 662b8b2858..695ed18c38 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -368,7 +368,7 @@ class calendar_uilist extends calendar_ui // would put it back, which you do from the series, not purge it if($search_params['filter'] == 'deleted' && $event['recur_type']) { - $event['class'] .= ' rowDeleted rowNoDelete'; + $event['class'] .= ' rowSeriesDeleted rowDeleted rowNoDelete'; } // Filemanager disabled for other applications @@ -585,6 +585,12 @@ class calendar_uilist extends calendar_ui } switch($action) { + case 'purgeseries': + // Delete an already deleted series + $recur_date = null; + // Make sure entire series is gone + $this->bo->delete($id, $recur_date,false,$skip_notification); + // fall through case 'delete': $action_msg = lang('deleted'); if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification)) @@ -857,16 +863,25 @@ class calendar_uilist extends calendar_ui 'confirm_multiple' => 'Delete these entries', 'group' => $group, 'disableClass' => 'rowNoDelete', + 'hideOnDisabled' => true, ); // Add in deleted for admins if($GLOBALS['egw_info']['server']['calendar_delete_history']) { + $actions['purgeseries'] = array( + 'caption' => 'Delete series', + 'confirm' => 'Delete series', + 'icon' => 'delete', + 'group' => $group, + 'enableClass' => 'rowSeriesDeleted', + 'disableClass' => 'rowNoDelete', + 'hideOnDisabled' => true, + ); $actions['undelete'] = array( 'caption' => 'Un-delete', 'hint' => 'Recover this event', 'icon' => 'revert', 'group' => $group, - 'enabled' => 'javaScript:nm_enableClass', 'enableClass' => 'rowDeleted', 'hideOnDisabled' => true, ); From 4420b4b1157961f32d6480207d3a0a436a998cdb Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 9 Nov 2012 18:38:48 +0000 Subject: [PATCH 036/150] If opening window is not addressbook, update addressbook window too --- addressbook/inc/class.addressbook_ui.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index bf92d7a300..cc31f8c811 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -1641,7 +1641,8 @@ class addressbook_ui extends addressbook_bo { egw_link::link('addressbook',$content['id'],$links); } - $content['js'] = "opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','addressbook',{$content['id']});"; + $content['js'] = "opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','addressbook',{$content['id']}); if(opener.egw_getAppName() != 'addressbook') { opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','addressbook',{$content['id']},null,'addressbook');}"; +error_log($GLOBALS['egw_info']['flags']['currentapp']); if ($button == 'save') { $content['js'] .= ' window.close();'; @@ -1655,7 +1656,7 @@ class addressbook_ui extends addressbook_bo 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'); window.close();"; + $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(); } From 234a8a8154ce41b7418a759297fa5355d7399a4f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 12 Nov 2012 09:48:31 +0000 Subject: [PATCH 037/150] check if we use cookies for the session, but no cookie set: happens eg. in sitemgr (when redirecting to a different domain) or with new java notification app --- phpgwapi/inc/class.egw_session.inc.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/phpgwapi/inc/class.egw_session.inc.php b/phpgwapi/inc/class.egw_session.inc.php index f5ab6af9c8..5857d11b22 100644 --- a/phpgwapi/inc/class.egw_session.inc.php +++ b/phpgwapi/inc/class.egw_session.inc.php @@ -256,7 +256,7 @@ class egw_session */ function commit_session() { - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() sessionid=$this->sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR])); + if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() sessionid=$this->sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR]).' '.function_backtrace()); self::encrypt($this->kp3); session_write_close(); @@ -811,7 +811,7 @@ class egw_session { $sessionid = false; } - if (self::ERROR_LOG_DEBUG) error_log(__METHOD__.'() returning '.print_r($sessionid,true)); + if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() _SERVER[REQUEST_URI]='$_SERVER[REQUEST_URI]' returning ".print_r($sessionid,true)); return $sessionid; } @@ -1023,6 +1023,19 @@ class egw_session ),__LINE__,__FILE__)->fetchColumn(); //error_log(__METHOD__."() sessionid=$this->sessionid --> sessionid_access_log=$this->sessionid_access_log"); } + + // check if we use cookies for the session, but no cookie set + // happens eg. in sitemgr (when redirecting to a different domain) or with new java notification app + if ($GLOBALS['egw_info']['server']['usecookies'] && isset($_REQUEST[self::EGW_SESSION_NAME]) && + $_REQUEST[self::EGW_SESSION_NAME] === $this->sessionid && + (!isset($_COOKIE[self::EGW_SESSION_NAME]) || $_COOKIE[self::EGW_SESSION_NAME] !== $_REQUEST[self::EGW_SESSION_NAME])) + { + if (self::ERROR_LOG_DEBUG) error_log("--> session::verify($sessionid) SUCCESS, but NO required cookies set --> setting them now"); + self::egw_setcookie(self::EGW_SESSION_NAME,$this->sessionid); + self::egw_setcookie('kp3',$this->kp3); + self::egw_setcookie('domain',$this->account_domain); + } + if (self::ERROR_LOG_DEBUG) error_log("--> session::verify($sessionid) SUCCESS"); return true; From f72a582532e472b8e1d7bba0f91036a6643d7265 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 12 Nov 2012 19:29:23 +0000 Subject: [PATCH 038/150] Use chosen plugin for to get fancy selectboxes. Selectboxes with more than 12 options get it turned on automatically --- etemplate/inc/class.etemplate_old.inc.php | 16 +- etemplate/inc/class.select_widget.inc.php | 9 +- phpgwapi/inc/class.egw_framework.inc.php | 3 + phpgwapi/inc/class.html.inc.php | 10 +- phpgwapi/js/jquery/chosen/.gitignore | 3 + phpgwapi/js/jquery/chosen/LICENSE.md | 24 + phpgwapi/js/jquery/chosen/README.md | 50 + phpgwapi/js/jquery/chosen/chosen-sprite.png | Bin 0 -> 559 bytes phpgwapi/js/jquery/chosen/chosen.css | 394 +++++ phpgwapi/js/jquery/chosen/chosen.jquery.js | 1018 +++++++++++++ .../js/jquery/chosen/chosen.jquery.min.js | 10 + phpgwapi/js/jquery/chosen/chosen.proto.js | 1025 +++++++++++++ phpgwapi/js/jquery/chosen/chosen.proto.min.js | 10 + phpgwapi/js/jquery/chosen/example.jquery.html | 1333 +++++++++++++++++ phpgwapi/js/jquery/chosen/package.json | 18 + phpgwapi/js/jsapi/egw_utils.js | 41 + 16 files changed, 3960 insertions(+), 4 deletions(-) create mode 100644 phpgwapi/js/jquery/chosen/.gitignore create mode 100644 phpgwapi/js/jquery/chosen/LICENSE.md create mode 100644 phpgwapi/js/jquery/chosen/README.md create mode 100644 phpgwapi/js/jquery/chosen/chosen-sprite.png create mode 100644 phpgwapi/js/jquery/chosen/chosen.css create mode 100644 phpgwapi/js/jquery/chosen/chosen.jquery.js create mode 100644 phpgwapi/js/jquery/chosen/chosen.jquery.min.js create mode 100644 phpgwapi/js/jquery/chosen/chosen.proto.js create mode 100644 phpgwapi/js/jquery/chosen/chosen.proto.min.js create mode 100644 phpgwapi/js/jquery/chosen/example.jquery.html create mode 100644 phpgwapi/js/jquery/chosen/package.json diff --git a/etemplate/inc/class.etemplate_old.inc.php b/etemplate/inc/class.etemplate_old.inc.php index ee04559e9a..d6c8acfc77 100644 --- a/etemplate/inc/class.etemplate_old.inc.php +++ b/etemplate/inc/class.etemplate_old.inc.php @@ -1576,9 +1576,21 @@ class etemplate_old extends boetemplate if ($set_readonlys_all) unset($readonlys['__ALL__']); break; - case 'select': // size:[linesOnMultiselect|emptyLabel,extraStyleMulitselect] + case 'select': // size:[linesOnMultiselect|emptyLabel,extraStyleMulitselect, [,]{5} enhance] $sels = array(); list($multiple,$extraStyleMultiselect) = explode(',',$cell_options,2); + + // Allow widget to specify using enhanced select or not + $c_options = explode(',',$cell_options); + if(array_key_exists('enhance', $cell)) + { + $enhance = $cell['enhance']; + } + else if (count($c_options >= 8)) + { + $enhance = ($c_options[7] == '1' || $c_options[7] == 'true'); + } + if (!empty($multiple) && 0+$multiple <= 0) { $sels[''] = $multiple < 0 ? 'all' : $multiple; @@ -1634,7 +1646,7 @@ class etemplate_old extends boetemplate else { $html .= html::select($form_name.($multiple > 1 ? '[]' : ''),$value,$sels, - $cell['no_lang'],$options,$multiple); + $cell['no_lang'],$options,$multiple,$enhance); } if (!self::$request->isset_to_process($form_name)) { diff --git a/etemplate/inc/class.select_widget.inc.php b/etemplate/inc/class.select_widget.inc.php index 493cb92b37..0d373ab473 100644 --- a/etemplate/inc/class.select_widget.inc.php +++ b/etemplate/inc/class.select_widget.inc.php @@ -102,7 +102,8 @@ class select_widget */ function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) { - list($rows,$type,$type2,$type3,$type4,$type5,$type6) = explode(',',$cell['size']); + list($rows,$type,$type2,$type3,$type4,$type5,$type6,$enhance) = explode(',',$cell['size']); +echo "$name ($rows,$type,$type2,$type3,$type4,$type5,$type6,$enhance)
"; $extension_data['type'] = $cell['type']; @@ -416,6 +417,7 @@ class select_widget $cell['sel_options'][$n] = sprintf($format,$n); } $cell['no_lang'] = True; + $cell['enhance'] = false; break; case 'select-hour': @@ -426,6 +428,7 @@ class select_widget sprintf('%02d',$h); } $cell['no_lang'] = True; + $cell['enhance'] = false; break; case 'select-app': // type2: ''=users enabled apps, 'installed', 'all' = not installed ones too @@ -482,6 +485,10 @@ class select_widget } break; } + if(!array_key_exists('enhance', $cell) && !is_null($enhance)) + { + $cell['enhance'] = $enhance; + } if ($rows > 1) { unset($cell['sel_options']['']); diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index 6698451dc6..937d93b5ad 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -729,6 +729,9 @@ abstract class egw_framework self::includeCSS($print_css, null, false); // false = prepend (add as first) file self::includeCSS($theme_css, null, false); + // Enhanced selectboxes + self::includeCSS('/phpgwapi/js/jquery/chosen/chosen.css'); + // search for app specific css file self::includeCSS($GLOBALS['egw_info']['flags']['currentapp'], 'app'); diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 9ce781b2e3..84afb0e0a4 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -219,10 +219,13 @@ class html * @param boolean $no_lang NOT run the labels of the options through lang(), default false=use lang() * @param string $options additional options (e.g. 'width') * @param int $multiple number of lines for a multiselect, default 0 = no multiselect, < 0 sets size without multiple + * @param boolean $enhanced Use enhanced selectbox with search. Null for default yes if more than 12 options. * @return string to set for a template or to echo into html page */ - static function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0) + static function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0,$enhanced=null) { + if(is_null($enhanced)) $enhanced = (count($arr) > 12); + if (!is_array($arr)) { $arr = array('no','yes'); @@ -284,6 +287,11 @@ class html } $out .= "\n"; + if($enhanced) { + egw_framework::validate_file('/phpgwapi/js/jquery/chosen/chosen.jquery.min.js'); + egw_framework::includeCSS('/phpgwapi/js/jquery/chosen/chosen.css',null,false); + $out .= "\n"; + } return $out; } diff --git a/phpgwapi/js/jquery/chosen/.gitignore b/phpgwapi/js/jquery/chosen/.gitignore new file mode 100644 index 0000000000..7133b439fd --- /dev/null +++ b/phpgwapi/js/jquery/chosen/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +node_modules +.project diff --git a/phpgwapi/js/jquery/chosen/LICENSE.md b/phpgwapi/js/jquery/chosen/LICENSE.md new file mode 100644 index 0000000000..80109bba80 --- /dev/null +++ b/phpgwapi/js/jquery/chosen/LICENSE.md @@ -0,0 +1,24 @@ +# Chosen, a Select Box Enhancer for jQuery and Protoype +## by Patrick Filler for [Harvest](http://getharvest.com) + +Available for use under the [MIT License](http://en.wikipedia.org/wiki/MIT_License) + +Copyright (c) 2011 by Harvest + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/phpgwapi/js/jquery/chosen/README.md b/phpgwapi/js/jquery/chosen/README.md new file mode 100644 index 0000000000..a5039ef464 --- /dev/null +++ b/phpgwapi/js/jquery/chosen/README.md @@ -0,0 +1,50 @@ +# Chosen + +Chosen is a library for making long, unwieldy select boxes more user friendly. + +- jQuery support: 1.4+ +- Prototype support: 1.7+ + +For documentation, usage, and examples, see: +http://harvesthq.github.com/chosen + +### Contributing to Chosen + +Contributions and pull requests are very welcome. Please follow these guidelines when submitting new code. + +1. Make all changes in Coffeescript files, **not** JavaScript files. +2. For feature changes, update both jQuery *and* Prototype versions +3. Use `npm install -d` to install the correct development dependencies. +4. Use `cake build` or `cake watch` to generate Chosen's JavaScript file and minified version. +5. Don't touch the `VERSION` file +6. Submit a Pull Request using GitHub. + +### Using CoffeeScript & Cake + +First, make sure you have the proper CoffeeScript / Cake set-up in place. We have added a package.json that makes this easy: + +``` +npm install -d +``` + +This will install `coffee-script` and `uglifyjs`. + +Once you're configured, building the JavasScript from the command line is easy: + + cake build # build Chosen from source + cake watch # watch coffee/ for changes and build Chosen + +If you're interested, you can find the recipes in Cakefile. + + +### Chosen Credits + +- Built by [Harvest](http://www.getharvest.com/). Want to work on projects like this? [We’re hiring](http://www.getharvest.com/careers)! +- Concept and development by [Patrick Filler](http://www.patrickfiller.com/) +- Design and CSS by [Matthew Lettini](http://matthewlettini.com/) + +### Notable Forks + +- [Chosen for MooTools](https://github.com/julesjanssen/chosen), by Jules Janssen +- [Chosen Drupal 7 Module](http://drupal.org/project/chosen), by Pol Dell'Aiera, Arshad Chummun, Bart Feenstra, Kálmán Hosszu, etc. +- [Chosen CakePHP Plugin](https://github.com/paulredmond/chosen-cakephp), by Paul Redmond diff --git a/phpgwapi/js/jquery/chosen/chosen-sprite.png b/phpgwapi/js/jquery/chosen/chosen-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..113dc9885a6b864ac154b266f024b4597f5c6ae7 GIT binary patch literal 559 zcmV+~0?_@5P)7_w9?!Y=&fGw`Tn=~{*Ton1uJA6{0|TOO2&BQ5HsK)1f-8_= zX_7tWzO=>&TSAbor(8d*in_8nYza}~$VhQ@!VyE5(mbqHI3iLyW7NYng`2gyw{w@M zv1lD|8e5_--EQGNFyBI9Dm%P2^&4|~A8h_6JOwVrJdj*~F_*$UV4Lqxwour8q(n*7 zkflFi+GT_()i#XZnd?O10H>gQ&_n|%z37lBGo2_bA2`{-9A0pctz^q&lZEfVJs1{! zF;D>4e-);bob|{m{RT>)$kHVH!F`36uG0Us4@ZUIJNV@Kb5+!py=js37mE_FMvAKw zj*G~aIL$}23dcoCzleIVN?OtPaAnbY' + option.html + ''; + } else { + return ""; + } + }; + + AbstractChosen.prototype.results_update_field = function() { + if (!this.is_multiple) this.results_reset_cleanup(); + this.result_clear_highlight(); + this.result_single_selected = null; + return this.results_build(); + }; + + AbstractChosen.prototype.results_toggle = function() { + if (this.results_showing) { + return this.results_hide(); + } else { + return this.results_show(); + } + }; + + AbstractChosen.prototype.results_search = function(evt) { + if (this.results_showing) { + return this.winnow_results(); + } else { + return this.results_show(); + } + }; + + AbstractChosen.prototype.keyup_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + switch (stroke) { + case 8: + if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) { + return this.keydown_backstroke(); + } else if (!this.pending_backstroke) { + this.result_clear_highlight(); + return this.results_search(); + } + break; + case 13: + evt.preventDefault(); + if (this.results_showing) return this.result_select(evt); + break; + case 27: + if (this.results_showing) this.results_hide(); + return true; + case 9: + case 38: + case 40: + case 16: + case 91: + case 17: + break; + default: + return this.results_search(); + } + }; + + AbstractChosen.prototype.generate_field_id = function() { + var new_id; + new_id = this.generate_random_id(); + this.form_field.id = new_id; + return new_id; + }; + + AbstractChosen.prototype.generate_random_char = function() { + var chars, newchar, rand; + chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + rand = Math.floor(Math.random() * chars.length); + return newchar = chars.substring(rand, rand + 1); + }; + + return AbstractChosen; + + })(); + + root.AbstractChosen = AbstractChosen; + +}).call(this); + +/* +Chosen source: generate output using 'cake build' +Copyright (c) 2011 by Harvest +*/ + +(function() { + var $, Chosen, get_side_border_padding, root, + __hasProp = Object.prototype.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; + + root = this; + + $ = jQuery; + + $.fn.extend({ + chosen: function(options) { + if ($.browser.msie && ($.browser.version === "6.0" || ($.browser.version === "7.0" && document.documentMode === 7))) { + return this; + } + return this.each(function(input_field) { + var $this; + $this = $(this); + if (!$this.hasClass("chzn-done")) { + return $this.data('chosen', new Chosen(this, options)); + } + }); + } + }); + + Chosen = (function(_super) { + + __extends(Chosen, _super); + + function Chosen() { + Chosen.__super__.constructor.apply(this, arguments); + } + + Chosen.prototype.setup = function() { + this.form_field_jq = $(this.form_field); + this.current_value = this.form_field_jq.val(); + return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl"); + }; + + Chosen.prototype.finish_setup = function() { + return this.form_field_jq.addClass("chzn-done"); + }; + + Chosen.prototype.set_up_html = function() { + var container_div, dd_top, dd_width, sf_width; + this.container_id = this.form_field.id.length ? this.form_field.id.replace(/[^\w]/g, '_') : this.generate_field_id(); + this.container_id += "_chzn"; + this.f_width = egw.getHiddenDimensions ? egw.getHiddenDimensions(this.form_field,true)['w'] : this.form_field_jq.outerWidth(); + container_div = $("
", { + id: this.container_id, + "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''), + style: 'width: ' + this.f_width + 'px;' + }); + if (this.is_multiple) { + container_div.html('
    '); + } else { + container_div.html('' + this.default_text + '
      '); + } + this.form_field_jq.hide().after(container_div); + this.container = $('#' + this.container_id); + this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single")); + this.dropdown = this.container.find('div.chzn-drop').first(); + dd_top = this.container.height(); + dd_width = this.f_width - get_side_border_padding(this.dropdown); + this.dropdown.css({ + "width": dd_width + "px", + "top": dd_top + "px" + }); + this.search_field = this.container.find('input').first(); + this.search_results = this.container.find('ul.chzn-results').first(); + this.search_field_scale(); + this.search_no_results = this.container.find('li.no-results').first(); + if (this.is_multiple) { + this.search_choices = this.container.find('ul.chzn-choices').first(); + this.search_container = this.container.find('li.search-field').first(); + } else { + this.search_container = this.container.find('div.chzn-search').first(); + this.selected_item = this.container.find('.chzn-single').first(); + sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field); + this.search_field.css({ + "width": sf_width + "px" + }); + } + this.results_build(); + this.set_tab_index(); + return this.form_field_jq.trigger("liszt:ready", { + chosen: this + }); + }; + + Chosen.prototype.register_observers = function() { + var _this = this; + this.container.mousedown(function(evt) { + return _this.container_mousedown(evt); + }); + this.container.mouseup(function(evt) { + return _this.container_mouseup(evt); + }); + this.container.mouseenter(function(evt) { + return _this.mouse_enter(evt); + }); + this.container.mouseleave(function(evt) { + return _this.mouse_leave(evt); + }); + this.search_results.mouseup(function(evt) { + return _this.search_results_mouseup(evt); + }); + this.search_results.mouseover(function(evt) { + return _this.search_results_mouseover(evt); + }); + this.search_results.mouseout(function(evt) { + return _this.search_results_mouseout(evt); + }); + this.form_field_jq.bind("liszt:updated", function(evt) { + return _this.results_update_field(evt); + }); + this.form_field_jq.bind("liszt:activate", function(evt) { + return _this.activate_field(evt); + }); + this.form_field_jq.bind("liszt:open", function(evt) { + return _this.container_mousedown(evt); + }); + this.search_field.blur(function(evt) { + return _this.input_blur(evt); + }); + this.search_field.keyup(function(evt) { + return _this.keyup_checker(evt); + }); + this.search_field.keydown(function(evt) { + return _this.keydown_checker(evt); + }); + this.search_field.focus(function(evt) { + return _this.input_focus(evt); + }); + if (this.is_multiple) { + return this.search_choices.click(function(evt) { + return _this.choices_click(evt); + }); + } else { + return this.container.click(function(evt) { + return evt.preventDefault(); + }); + } + }; + + Chosen.prototype.search_field_disabled = function() { + this.is_disabled = this.form_field_jq[0].disabled; + if (this.is_disabled) { + this.container.addClass('chzn-disabled'); + this.search_field[0].disabled = true; + if (!this.is_multiple) { + this.selected_item.unbind("focus", this.activate_action); + } + return this.close_field(); + } else { + this.container.removeClass('chzn-disabled'); + this.search_field[0].disabled = false; + if (!this.is_multiple) { + return this.selected_item.bind("focus", this.activate_action); + } + } + }; + + Chosen.prototype.container_mousedown = function(evt) { + var target_closelink; + if (!this.is_disabled) { + target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false; + if (evt && evt.type === "mousedown" && !this.results_showing) { + evt.stopPropagation(); + } + if (!this.pending_destroy_click && !target_closelink) { + if (!this.active_field) { + if (this.is_multiple) this.search_field.val(""); + $(document).click(this.click_test_action); + this.results_show(); + } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) { + evt.preventDefault(); + this.results_toggle(); + } + return this.activate_field(); + } else { + return this.pending_destroy_click = false; + } + } + }; + + Chosen.prototype.container_mouseup = function(evt) { + if (evt.target.nodeName === "ABBR" && !this.is_disabled) { + return this.results_reset(evt); + } + }; + + Chosen.prototype.blur_test = function(evt) { + if (!this.active_field && this.container.hasClass("chzn-container-active")) { + return this.close_field(); + } + }; + + Chosen.prototype.close_field = function() { + $(document).unbind("click", this.click_test_action); + this.active_field = false; + this.results_hide(); + this.container.removeClass("chzn-container-active"); + this.winnow_results_clear(); + this.clear_backstroke(); + this.show_search_field_default(); + return this.search_field_scale(); + }; + + Chosen.prototype.activate_field = function() { + this.container.addClass("chzn-container-active"); + this.active_field = true; + this.search_field.val(this.search_field.val()); + return this.search_field.focus(); + }; + + Chosen.prototype.test_active_click = function(evt) { + if ($(evt.target).parents('#' + this.container_id).length) { + return this.active_field = true; + } else { + return this.close_field(); + } + }; + + Chosen.prototype.results_build = function() { + var content, data, _i, _len, _ref; + this.parsing = true; + this.results_data = root.SelectParser.select_to_array(this.form_field); + if (this.is_multiple && this.choices > 0) { + this.search_choices.find("li.search-choice").remove(); + this.choices = 0; + } else if (!this.is_multiple) { + this.selected_item.addClass("chzn-default").find("span").text(this.default_text); + if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) { + this.container.addClass("chzn-container-single-nosearch"); + } else { + this.container.removeClass("chzn-container-single-nosearch"); + } + } + content = ''; + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + data = _ref[_i]; + if (data.group) { + content += this.result_add_group(data); + } else if (!data.empty) { + content += this.result_add_option(data); + if (data.selected && this.is_multiple) { + this.choice_build(data); + } else if (data.selected && !this.is_multiple) { + this.selected_item.removeClass("chzn-default").find("span").text(data.text); + if (this.allow_single_deselect) this.single_deselect_control_build(); + } + } + } + this.search_field_disabled(); + this.show_search_field_default(); + this.search_field_scale(); + this.search_results.html(content); + return this.parsing = false; + }; + + Chosen.prototype.result_add_group = function(group) { + if (!group.disabled) { + group.dom_id = this.container_id + "_g_" + group.array_index; + return '
    • ' + $("
      ").text(group.label).html() + '
    • '; + } else { + return ""; + } + }; + + Chosen.prototype.result_do_highlight = function(el) { + var high_bottom, high_top, maxHeight, visible_bottom, visible_top; + if (el.length) { + this.result_clear_highlight(); + this.result_highlight = el; + this.result_highlight.addClass("highlighted"); + maxHeight = parseInt(this.search_results.css("maxHeight"), 10); + visible_top = this.search_results.scrollTop(); + visible_bottom = maxHeight + visible_top; + high_top = this.result_highlight.position().top + this.search_results.scrollTop(); + high_bottom = high_top + this.result_highlight.outerHeight(); + if (high_bottom >= visible_bottom) { + return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0); + } else if (high_top < visible_top) { + return this.search_results.scrollTop(high_top); + } + } + }; + + Chosen.prototype.result_clear_highlight = function() { + if (this.result_highlight) this.result_highlight.removeClass("highlighted"); + return this.result_highlight = null; + }; + + Chosen.prototype.results_show = function() { + var dd_top; + if (!this.is_multiple) { + this.selected_item.addClass("chzn-single-with-drop"); + if (this.result_single_selected) { + this.result_do_highlight(this.result_single_selected); + } + } else if (this.max_selected_options <= this.choices) { + this.form_field_jq.trigger("liszt:maxselected", { + chosen: this + }); + return false; + } + dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1; + this.form_field_jq.trigger("liszt:showing_dropdown", { + chosen: this + }); + this.dropdown.css({ + "top": dd_top + "px", + "left": 0 + }); + this.results_showing = true; + this.search_field.focus(); + this.search_field.val(this.search_field.val()); + return this.winnow_results(); + }; + + Chosen.prototype.results_hide = function() { + if (!this.is_multiple) { + this.selected_item.removeClass("chzn-single-with-drop"); + } + this.result_clear_highlight(); + this.form_field_jq.trigger("liszt:hiding_dropdown", { + chosen: this + }); + this.dropdown.css({ + "left": "-9000px" + }); + return this.results_showing = false; + }; + + Chosen.prototype.set_tab_index = function(el) { + var ti; + if (this.form_field_jq.attr("tabindex")) { + ti = this.form_field_jq.attr("tabindex"); + this.form_field_jq.attr("tabindex", -1); + return this.search_field.attr("tabindex", ti); + } + }; + + Chosen.prototype.show_search_field_default = function() { + if (this.is_multiple && this.choices < 1 && !this.active_field) { + this.search_field.val(this.default_text); + return this.search_field.addClass("default"); + } else { + this.search_field.val(""); + return this.search_field.removeClass("default"); + } + }; + + Chosen.prototype.search_results_mouseup = function(evt) { + var target; + target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); + if (target.length) { + this.result_highlight = target; + this.result_select(evt); + return this.search_field.focus(); + } + }; + + Chosen.prototype.search_results_mouseover = function(evt) { + var target; + target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); + if (target) return this.result_do_highlight(target); + }; + + Chosen.prototype.search_results_mouseout = function(evt) { + if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) { + return this.result_clear_highlight(); + } + }; + + Chosen.prototype.choices_click = function(evt) { + evt.preventDefault(); + if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) { + return this.results_show(); + } + }; + + Chosen.prototype.choice_build = function(item) { + var choice_id, html, link, + _this = this; + if (this.is_multiple && this.max_selected_options <= this.choices) { + this.form_field_jq.trigger("liszt:maxselected", { + chosen: this + }); + return false; + } + choice_id = this.container_id + "_c_" + item.array_index; + this.choices += 1; + if (item.disabled) { + html = '
    • ' + item.html + '
    • '; + } else { + html = '
    • ' + item.html + '
    • '; + } + this.search_container.before(html); + link = $('#' + choice_id).find("a").first(); + return link.click(function(evt) { + return _this.choice_destroy_link_click(evt); + }); + }; + + Chosen.prototype.choice_destroy_link_click = function(evt) { + evt.preventDefault(); + if (!this.is_disabled) { + this.pending_destroy_click = true; + return this.choice_destroy($(evt.target)); + } else { + return evt.stopPropagation; + } + }; + + Chosen.prototype.choice_destroy = function(link) { + if (this.result_deselect(link.attr("rel"))) { + this.choices -= 1; + this.show_search_field_default(); + if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) { + this.results_hide(); + } + return link.parents('li').first().remove(); + } + }; + + Chosen.prototype.results_reset = function() { + this.form_field.options[0].selected = true; + this.selected_item.find("span").text(this.default_text); + if (!this.is_multiple) this.selected_item.addClass("chzn-default"); + this.show_search_field_default(); + this.results_reset_cleanup(); + this.form_field_jq.trigger("change"); + if (this.active_field) return this.results_hide(); + }; + + Chosen.prototype.results_reset_cleanup = function() { + this.current_value = this.form_field_jq.val(); + return this.selected_item.find("abbr").remove(); + }; + + Chosen.prototype.result_select = function(evt) { + var high, high_id, item, position; + if (this.result_highlight) { + high = this.result_highlight; + high_id = high.attr("id"); + this.result_clear_highlight(); + if (this.is_multiple) { + this.result_deactivate(high); + } else { + this.search_results.find(".result-selected").removeClass("result-selected"); + this.result_single_selected = high; + this.selected_item.removeClass("chzn-default"); + } + high.addClass("result-selected"); + position = high_id.substr(high_id.lastIndexOf("_") + 1); + item = this.results_data[position]; + item.selected = true; + this.form_field.options[item.options_index].selected = true; + if (this.is_multiple) { + this.choice_build(item); + } else { + this.selected_item.find("span").first().text(item.text); + if (this.allow_single_deselect) this.single_deselect_control_build(); + } + if (!(evt.metaKey && this.is_multiple)) this.results_hide(); + this.search_field.val(""); + if (this.is_multiple || this.form_field_jq.val() !== this.current_value) { + this.form_field_jq.trigger("change", { + 'selected': this.form_field.options[item.options_index].value + }); + } + this.current_value = this.form_field_jq.val(); + return this.search_field_scale(); + } + }; + + Chosen.prototype.result_activate = function(el) { + return el.addClass("active-result"); + }; + + Chosen.prototype.result_deactivate = function(el) { + return el.removeClass("active-result"); + }; + + Chosen.prototype.result_deselect = function(pos) { + var result, result_data; + result_data = this.results_data[pos]; + if (!this.form_field.options[result_data.options_index].disabled) { + result_data.selected = false; + this.form_field.options[result_data.options_index].selected = false; + result = $("#" + this.container_id + "_o_" + pos); + result.removeClass("result-selected").addClass("active-result").show(); + this.result_clear_highlight(); + this.winnow_results(); + this.form_field_jq.trigger("change", { + deselected: this.form_field.options[result_data.options_index].value + }); + this.search_field_scale(); + return true; + } else { + return false; + } + }; + + Chosen.prototype.single_deselect_control_build = function() { + if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) { + return this.selected_item.find("span").first().after(""); + } + }; + + Chosen.prototype.winnow_results = function() { + var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref; + this.no_results_clear(); + results = 0; + searchText = this.search_field.val() === this.default_text ? "" : $('
      ').text($.trim(this.search_field.val())).html(); + regexAnchor = this.search_contains ? "" : "^"; + regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + option = _ref[_i]; + if (!option.disabled && !option.empty) { + if (option.group) { + $('#' + option.dom_id).css('display', 'none'); + } else if (!(this.is_multiple && option.selected)) { + found = false; + result_id = option.dom_id; + result = $("#" + result_id); + if (regex.test(option.html)) { + found = true; + results += 1; + } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) { + parts = option.html.replace(/\[|\]/g, "").split(" "); + if (parts.length) { + for (_j = 0, _len2 = parts.length; _j < _len2; _j++) { + part = parts[_j]; + if (regex.test(part)) { + found = true; + results += 1; + } + } + } + } + if (found) { + if (searchText.length) { + startpos = option.html.search(zregex); + text = option.html.substr(0, startpos + searchText.length) + '' + option.html.substr(startpos + searchText.length); + text = text.substr(0, startpos) + '' + text.substr(startpos); + } else { + text = option.html; + } + result.html(text); + this.result_activate(result); + if (option.group_array_index != null) { + $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item'); + } + } else { + if (this.result_highlight && result_id === this.result_highlight.attr('id')) { + this.result_clear_highlight(); + } + this.result_deactivate(result); + } + } + } + } + if (results < 1 && searchText.length) { + return this.no_results(searchText); + } else { + return this.winnow_results_set_highlight(); + } + }; + + Chosen.prototype.winnow_results_clear = function() { + var li, lis, _i, _len, _results; + this.search_field.val(""); + lis = this.search_results.find("li"); + _results = []; + for (_i = 0, _len = lis.length; _i < _len; _i++) { + li = lis[_i]; + li = $(li); + if (li.hasClass("group-result")) { + _results.push(li.css('display', 'auto')); + } else if (!this.is_multiple || !li.hasClass("result-selected")) { + _results.push(this.result_activate(li)); + } else { + _results.push(void 0); + } + } + return _results; + }; + + Chosen.prototype.winnow_results_set_highlight = function() { + var do_high, selected_results; + if (!this.result_highlight) { + selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : []; + do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first(); + if (do_high != null) return this.result_do_highlight(do_high); + } + }; + + Chosen.prototype.no_results = function(terms) { + var no_results_html; + no_results_html = $('
    • ' + this.results_none_found + ' ""
    • '); + no_results_html.find("span").first().html(terms); + return this.search_results.append(no_results_html); + }; + + Chosen.prototype.no_results_clear = function() { + return this.search_results.find(".no-results").remove(); + }; + + Chosen.prototype.keydown_arrow = function() { + var first_active, next_sib; + if (!this.result_highlight) { + first_active = this.search_results.find("li.active-result").first(); + if (first_active) this.result_do_highlight($(first_active)); + } else if (this.results_showing) { + next_sib = this.result_highlight.nextAll("li.active-result").first(); + if (next_sib) this.result_do_highlight(next_sib); + } + if (!this.results_showing) return this.results_show(); + }; + + Chosen.prototype.keyup_arrow = function() { + var prev_sibs; + if (!this.results_showing && !this.is_multiple) { + return this.results_show(); + } else if (this.result_highlight) { + prev_sibs = this.result_highlight.prevAll("li.active-result"); + if (prev_sibs.length) { + return this.result_do_highlight(prev_sibs.first()); + } else { + if (this.choices > 0) this.results_hide(); + return this.result_clear_highlight(); + } + } + }; + + Chosen.prototype.keydown_backstroke = function() { + var next_available_destroy; + if (this.pending_backstroke) { + this.choice_destroy(this.pending_backstroke.find("a").first()); + return this.clear_backstroke(); + } else { + next_available_destroy = this.search_container.siblings("li.search-choice").last(); + if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) { + this.pending_backstroke = next_available_destroy; + if (this.single_backstroke_delete) { + return this.keydown_backstroke(); + } else { + return this.pending_backstroke.addClass("search-choice-focus"); + } + } + } + }; + + Chosen.prototype.clear_backstroke = function() { + if (this.pending_backstroke) { + this.pending_backstroke.removeClass("search-choice-focus"); + } + return this.pending_backstroke = null; + }; + + Chosen.prototype.keydown_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke(); + switch (stroke) { + case 8: + this.backstroke_length = this.search_field.val().length; + break; + case 9: + if (this.results_showing && !this.is_multiple) this.result_select(evt); + this.mouse_on_container = false; + break; + case 13: + evt.preventDefault(); + break; + case 38: + evt.preventDefault(); + this.keyup_arrow(); + break; + case 40: + this.keydown_arrow(); + break; + } + }; + + Chosen.prototype.search_field_scale = function() { + var dd_top, div, h, style, style_block, styles, w, _i, _len; + if (this.is_multiple) { + h = 0; + w = 0; + style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"; + styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing']; + for (_i = 0, _len = styles.length; _i < _len; _i++) { + style = styles[_i]; + style_block += style + ":" + this.search_field.css(style) + ";"; + } + div = $('
      ', { + 'style': style_block + }); + div.text(this.search_field.val()); + $('body').append(div); + w = div.width() + 25; + div.remove(); + if (w > this.f_width - 10) w = this.f_width - 10; + this.search_field.css({ + 'width': w + 'px' + }); + dd_top = this.container.height(); + return this.dropdown.css({ + "top": dd_top + "px" + }); + } + }; + + Chosen.prototype.generate_random_id = function() { + var string; + string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char(); + while ($("#" + string).length > 0) { + string += this.generate_random_char(); + } + return string; + }; + + return Chosen; + + })(AbstractChosen); + + get_side_border_padding = function(elmt) { + var side_border_padding; + return side_border_padding = elmt.outerWidth() - elmt.width(); + }; + + root.get_side_border_padding = get_side_border_padding; + +}).call(this); diff --git a/phpgwapi/js/jquery/chosen/chosen.jquery.min.js b/phpgwapi/js/jquery/chosen/chosen.jquery.min.js new file mode 100644 index 0000000000..d089017fc5 --- /dev/null +++ b/phpgwapi/js/jquery/chosen/chosen.jquery.min.js @@ -0,0 +1,10 @@ +// Chosen, a Select Box Enhancer for jQuery and Protoype +// by Patrick Filler for Harvest, http://getharvest.com +// +// Version 0.9.8 +// Full source at https://github.com/harvesthq/chosen +// Copyright (c) 2011 Harvest http://getharvest.com + +// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md +// This file is generated by `cake build`, do not edit it by hand. +(function(){var SelectParser;SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(child){return child.nodeName.toUpperCase()==="OPTGROUP"?this.add_group(child):this.add_option(child)},SelectParser.prototype.add_group=function(group){var group_position,option,_i,_len,_ref,_results;group_position=this.parsed.length,this.parsed.push({array_index:group_position,group:!0,label:group.label,children:0,disabled:group.disabled}),_ref=group.childNodes,_results=[];for(_i=0,_len=_ref.length;_i<_len;_i++)option=_ref[_i],_results.push(this.add_option(option,group_position,group.disabled));return _results},SelectParser.prototype.add_option=function(option,group_position,group_disabled){if(option.nodeName.toUpperCase()==="OPTION")return option.text!==""?(group_position!=null&&(this.parsed[group_position].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:option.value,text:option.text,html:option.innerHTML,selected:option.selected,disabled:group_disabled===!0?group_disabled:option.disabled,group_array_index:group_position,classes:option.className,style:option.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},SelectParser}(),SelectParser.select_to_array=function(select){var child,parser,_i,_len,_ref;parser=new SelectParser,_ref=select.childNodes;for(_i=0,_len=_ref.length;_i<_len;_i++)child=_ref[_i],parser.add_node(child);return parser.parsed},this.SelectParser=SelectParser}).call(this),function(){var AbstractChosen,root;root=this,AbstractChosen=function(){function AbstractChosen(form_field,options){this.form_field=form_field,this.options=options!=null?options:{},this.set_default_values(),this.is_multiple=this.form_field.multiple,this.set_default_text(),this.setup(),this.set_up_html(),this.register_observers(),this.finish_setup()}return AbstractChosen.prototype.set_default_values=function(){var _this=this;return this.click_test_action=function(evt){return _this.test_active_click(evt)},this.activate_action=function(evt){return _this.activate_field(evt)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.allow_single_deselect=this.options.allow_single_deselect!=null&&this.form_field.options[0]!=null&&this.form_field.options[0].text===""?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity},AbstractChosen.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||"No results match"},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(evt){var _this=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return _this.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(evt){var _this=this;if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(){return _this.blur_test()},100)},AbstractChosen.prototype.result_add_option=function(option){var classes,style;return option.disabled?"":(option.dom_id=this.container_id+"_o_"+option.array_index,classes=option.selected&&this.is_multiple?[]:["active-result"],option.selected&&classes.push("result-selected"),option.group_array_index!=null&&classes.push("group-option"),option.classes!==""&&classes.push(option.classes),style=option.style.cssText!==""?' style="'+option.style+'"':"",'
    • "+option.html+"
    • ")},AbstractChosen.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(evt){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.keyup_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale();switch(stroke){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:evt.preventDefault();if(this.results_showing)return this.result_select(evt);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.generate_field_id=function(){var new_id;return new_id=this.generate_random_id(),this.form_field.id=new_id,new_id},AbstractChosen.prototype.generate_random_char=function(){var chars,newchar,rand;return chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",rand=Math.floor(Math.random()*chars.length),newchar=chars.substring(rand,rand+1)},AbstractChosen}(),root.AbstractChosen=AbstractChosen}.call(this),function(){var $,Chosen,get_side_border_padding,root,__hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)__hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child};root=this,$=jQuery,$.fn.extend({chosen:function(options){return $.browser.msie&&($.browser.version==="6.0"||$.browser.version==="7.0"&&document.documentMode===7)?this:this.each(function(input_field){var $this;$this=$(this);if(!$this.hasClass("chzn-done"))return $this.data("chosen",new Chosen(this,options))})}}),Chosen=function(_super){function Chosen(){Chosen.__super__.constructor.apply(this,arguments)}return __extends(Chosen,_super),Chosen.prototype.setup=function(){return this.form_field_jq=$(this.form_field),this.current_value=this.form_field_jq.val(),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},Chosen.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},Chosen.prototype.set_up_html=function(){var container_div,dd_top,dd_width,sf_width;return this.container_id=this.form_field.id.length?this.form_field.id.replace(/[^\w]/g,"_"):this.generate_field_id(),this.container_id+="_chzn",this.f_width = egw.getHiddenDimensions ? egw.getHiddenDimensions(this.form_field,true)['w'] : this.form_field_jq.outerWidth(),container_div=$("
      ",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?container_div.html('
        '):container_div.html(''+this.default_text+'
          '),this.form_field_jq.hide().after(container_div),this.container=$("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),dd_top=this.container.height(),dd_width=this.f_width-get_side_border_padding(this.dropdown),this.dropdown.css({width:dd_width+"px",top:dd_top+"px"}),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chzn-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chzn-search").first(),this.selected_item=this.container.find(".chzn-single").first(),sf_width=dd_width-get_side_border_padding(this.search_container)-get_side_border_padding(this.search_field),this.search_field.css({width:sf_width+"px"})),this.results_build(),this.set_tab_index(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var _this=this;return this.container.mousedown(function(evt){return _this.container_mousedown(evt)}),this.container.mouseup(function(evt){return _this.container_mouseup(evt)}),this.container.mouseenter(function(evt){return _this.mouse_enter(evt)}),this.container.mouseleave(function(evt){return _this.mouse_leave(evt)}),this.search_results.mouseup(function(evt){return _this.search_results_mouseup(evt)}),this.search_results.mouseover(function(evt){return _this.search_results_mouseover(evt)}),this.search_results.mouseout(function(evt){return _this.search_results_mouseout(evt)}),this.form_field_jq.bind("liszt:updated",function(evt){return _this.results_update_field(evt)}),this.form_field_jq.bind("liszt:activate",function(evt){return _this.activate_field(evt)}),this.form_field_jq.bind("liszt:open",function(evt){return _this.container_mousedown(evt)}),this.search_field.blur(function(evt){return _this.input_blur(evt)}),this.search_field.keyup(function(evt){return _this.keyup_checker(evt)}),this.search_field.keydown(function(evt){return _this.keydown_checker(evt)}),this.search_field.focus(function(evt){return _this.input_focus(evt)}),this.is_multiple?this.search_choices.click(function(evt){return _this.choices_click(evt)}):this.container.click(function(evt){return evt.preventDefault()})},Chosen.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq[0].disabled;if(this.is_disabled)return this.container.addClass("chzn-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus",this.activate_action),this.close_field();this.container.removeClass("chzn-disabled"),this.search_field[0].disabled=!1;if(!this.is_multiple)return this.selected_item.bind("focus",this.activate_action)},Chosen.prototype.container_mousedown=function(evt){var target_closelink;if(!this.is_disabled)return target_closelink=evt!=null?$(evt.target).hasClass("search-choice-close"):!1,evt&&evt.type==="mousedown"&&!this.results_showing&&evt.stopPropagation(),!this.pending_destroy_click&&!target_closelink?(this.active_field?!this.is_multiple&&evt&&($(evt.target)[0]===this.selected_item[0]||$(evt.target).parents("a.chzn-single").length)&&(evt.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),$(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},Chosen.prototype.container_mouseup=function(evt){if(evt.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(evt)},Chosen.prototype.blur_test=function(evt){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},Chosen.prototype.close_field=function(){return $(document).unbind("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(evt){return $(evt.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){var content,data,_i,_len,_ref;this.parsing=!0,this.results_data=root.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||(this.selected_item.addClass("chzn-default").find("span").text(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),content="",_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++)data=_ref[_i],data.group?content+=this.result_add_group(data):data.empty||(content+=this.result_add_option(data),data.selected&&this.is_multiple?this.choice_build(data):data.selected&&!this.is_multiple&&(this.selected_item.removeClass("chzn-default").find("span").text(data.text),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.html(content),this.parsing=!1},Chosen.prototype.result_add_group=function(group){return group.disabled?"":(group.dom_id=this.container_id+"_g_"+group.array_index,'
        • '+$("
          ").text(group.label).html()+"
        • ")},Chosen.prototype.result_do_highlight=function(el){var high_bottom,high_top,maxHeight,visible_bottom,visible_top;if(el.length){this.result_clear_highlight(),this.result_highlight=el,this.result_highlight.addClass("highlighted"),maxHeight=parseInt(this.search_results.css("maxHeight"),10),visible_top=this.search_results.scrollTop(),visible_bottom=maxHeight+visible_top,high_top=this.result_highlight.position().top+this.search_results.scrollTop(),high_bottom=high_top+this.result_highlight.outerHeight();if(high_bottom>=visible_bottom)return this.search_results.scrollTop(high_bottom-maxHeight>0?high_bottom-maxHeight:0);if(high_top'+item.html+"":html='
        • '+item.html+'
        • ',this.search_container.before(html),link=$("#"+choice_id).find("a").first(),link.click(function(evt){return _this.choice_destroy_link_click(evt)}))},Chosen.prototype.choice_destroy_link_click=function(evt){return evt.preventDefault(),this.is_disabled?evt.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy($(evt.target)))},Chosen.prototype.choice_destroy=function(link){if(this.result_deselect(link.attr("rel")))return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),link.parents("li").first().remove()},Chosen.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),this.is_multiple||this.selected_item.addClass("chzn-default"),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change");if(this.active_field)return this.results_hide()},Chosen.prototype.results_reset_cleanup=function(){return this.current_value=this.form_field_jq.val(),this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(evt){var high,high_id,item,position;if(this.result_highlight)return high=this.result_highlight,high_id=high.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(high):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=high,this.selected_item.removeClass("chzn-default")),high.addClass("result-selected"),position=high_id.substr(high_id.lastIndexOf("_")+1),item=this.results_data[position],item.selected=!0,this.form_field.options[item.options_index].selected=!0,this.is_multiple?this.choice_build(item):(this.selected_item.find("span").first().text(item.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!evt.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field_jq.val()!==this.current_value)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[item.options_index].value}),this.current_value=this.form_field_jq.val(),this.search_field_scale()},Chosen.prototype.result_activate=function(el){return el.addClass("active-result")},Chosen.prototype.result_deactivate=function(el){return el.removeClass("active-result")},Chosen.prototype.result_deselect=function(pos){var result,result_data;return result_data=this.results_data[pos],this.form_field.options[result_data.options_index].disabled?!1:(result_data.selected=!1,this.form_field.options[result_data.options_index].selected=!1,result=$("#"+this.container_id+"_o_"+pos),result.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[result_data.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&this.selected_item.find("abbr").length<1)return this.selected_item.find("span").first().after('')},Chosen.prototype.winnow_results=function(){var found,option,part,parts,regex,regexAnchor,result,result_id,results,searchText,startpos,text,zregex,_i,_j,_len,_len2,_ref;this.no_results_clear(),results=0,searchText=this.search_field.val()===this.default_text?"":$("
          ").text($.trim(this.search_field.val())).html(),regexAnchor=this.search_contains?"":"^",regex=new RegExp(regexAnchor+searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),zregex=new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++){option=_ref[_i];if(!option.disabled&&!option.empty)if(option.group)$("#"+option.dom_id).css("display","none");else if(!this.is_multiple||!option.selected){found=!1,result_id=option.dom_id,result=$("#"+result_id);if(regex.test(option.html))found=!0,results+=1;else if(option.html.indexOf(" ")>=0||option.html.indexOf("[")===0){parts=option.html.replace(/\[|\]/g,"").split(" ");if(parts.length)for(_j=0,_len2=parts.length;_j<_len2;_j++)part=parts[_j],regex.test(part)&&(found=!0,results+=1)}found?(searchText.length?(startpos=option.html.search(zregex),text=option.html.substr(0,startpos+searchText.length)+""+option.html.substr(startpos+searchText.length),text=text.substr(0,startpos)+""+text.substr(startpos)):text=option.html,result.html(text),this.result_activate(result),option.group_array_index!=null&&$("#"+this.results_data[option.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&result_id===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(result))}}return results<1&&searchText.length?this.no_results(searchText):this.winnow_results_set_highlight()},Chosen.prototype.winnow_results_clear=function(){var li,lis,_i,_len,_results;this.search_field.val(""),lis=this.search_results.find("li"),_results=[];for(_i=0,_len=lis.length;_i<_len;_i++)li=lis[_i],li=$(li),li.hasClass("group-result")?_results.push(li.css("display","auto")):!this.is_multiple||!li.hasClass("result-selected")?_results.push(this.result_activate(li)):_results.push(void 0);return _results},Chosen.prototype.winnow_results_set_highlight=function(){var do_high,selected_results;if(!this.result_highlight){selected_results=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),do_high=selected_results.length?selected_results.first():this.search_results.find(".active-result").first();if(do_high!=null)return this.result_do_highlight(do_high)}},Chosen.prototype.no_results=function(terms){var no_results_html;return no_results_html=$('
        • '+this.results_none_found+' ""
        • '),no_results_html.find("span").first().html(terms),this.search_results.append(no_results_html)},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var first_active,next_sib;this.result_highlight?this.results_showing&&(next_sib=this.result_highlight.nextAll("li.active-result").first(),next_sib&&this.result_do_highlight(next_sib)):(first_active=this.search_results.find("li.active-result").first(),first_active&&this.result_do_highlight($(first_active)));if(!this.results_showing)return this.results_show()},Chosen.prototype.keyup_arrow=function(){var prev_sibs;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return prev_sibs=this.result_highlight.prevAll("li.active-result"),prev_sibs.length?this.result_do_highlight(prev_sibs.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},Chosen.prototype.keydown_backstroke=function(){var next_available_destroy;if(this.pending_backstroke)return this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke();next_available_destroy=this.search_container.siblings("li.search-choice").last();if(next_available_destroy.length&&!next_available_destroy.hasClass("search-choice-disabled"))return this.pending_backstroke=next_available_destroy,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale(),stroke!==8&&this.pending_backstroke&&this.clear_backstroke();switch(stroke){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(evt),this.mouse_on_container=!1;break;case 13:evt.preventDefault();break;case 38:evt.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var dd_top,div,h,style,style_block,styles,w,_i,_len;if(this.is_multiple){h=0,w=0,style_block="position:absolute; left: -1000px; top: -1000px; display:none;",styles=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(_i=0,_len=styles.length;_i<_len;_i++)style=styles[_i],style_block+=style+":"+this.search_field.css(style)+";";return div=$("
          ",{style:style_block}),div.text(this.search_field.val()),$("body").append(div),w=div.width()+25,div.remove(),w>this.f_width-10&&(w=this.f_width-10),this.search_field.css({width:w+"px"}),dd_top=this.container.height(),this.dropdown.css({top:dd_top+"px"})}},Chosen.prototype.generate_random_id=function(){var string;string="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while($("#"+string).length>0)string+=this.generate_random_char();return string},Chosen}(AbstractChosen),get_side_border_padding=function(elmt){var side_border_padding;return side_border_padding=elmt.outerWidth()-elmt.width()},root.get_side_border_padding=get_side_border_padding}.call(this); diff --git a/phpgwapi/js/jquery/chosen/chosen.proto.js b/phpgwapi/js/jquery/chosen/chosen.proto.js new file mode 100644 index 0000000000..017f3b3516 --- /dev/null +++ b/phpgwapi/js/jquery/chosen/chosen.proto.js @@ -0,0 +1,1025 @@ +// Chosen, a Select Box Enhancer for jQuery and Protoype +// by Patrick Filler for Harvest, http://getharvest.com +// +// Version 0.9.8 +// Full source at https://github.com/harvesthq/chosen +// Copyright (c) 2011 Harvest http://getharvest.com + +// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md +// This file is generated by `cake build`, do not edit it by hand. +(function() { + var SelectParser; + + SelectParser = (function() { + + function SelectParser() { + this.options_index = 0; + this.parsed = []; + } + + SelectParser.prototype.add_node = function(child) { + if (child.nodeName.toUpperCase() === "OPTGROUP") { + return this.add_group(child); + } else { + return this.add_option(child); + } + }; + + SelectParser.prototype.add_group = function(group) { + var group_position, option, _i, _len, _ref, _results; + group_position = this.parsed.length; + this.parsed.push({ + array_index: group_position, + group: true, + label: group.label, + children: 0, + disabled: group.disabled + }); + _ref = group.childNodes; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + option = _ref[_i]; + _results.push(this.add_option(option, group_position, group.disabled)); + } + return _results; + }; + + SelectParser.prototype.add_option = function(option, group_position, group_disabled) { + if (option.nodeName.toUpperCase() === "OPTION") { + if (option.text !== "") { + if (group_position != null) this.parsed[group_position].children += 1; + this.parsed.push({ + array_index: this.parsed.length, + options_index: this.options_index, + value: option.value, + text: option.text, + html: option.innerHTML, + selected: option.selected, + disabled: group_disabled === true ? group_disabled : option.disabled, + group_array_index: group_position, + classes: option.className, + style: option.style.cssText + }); + } else { + this.parsed.push({ + array_index: this.parsed.length, + options_index: this.options_index, + empty: true + }); + } + return this.options_index += 1; + } + }; + + return SelectParser; + + })(); + + SelectParser.select_to_array = function(select) { + var child, parser, _i, _len, _ref; + parser = new SelectParser(); + _ref = select.childNodes; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + child = _ref[_i]; + parser.add_node(child); + } + return parser.parsed; + }; + + this.SelectParser = SelectParser; + +}).call(this); + +/* +Chosen source: generate output using 'cake build' +Copyright (c) 2011 by Harvest +*/ + +(function() { + var AbstractChosen, root; + + root = this; + + AbstractChosen = (function() { + + function AbstractChosen(form_field, options) { + this.form_field = form_field; + this.options = options != null ? options : {}; + this.set_default_values(); + this.is_multiple = this.form_field.multiple; + this.set_default_text(); + this.setup(); + this.set_up_html(); + this.register_observers(); + this.finish_setup(); + } + + AbstractChosen.prototype.set_default_values = function() { + var _this = this; + this.click_test_action = function(evt) { + return _this.test_active_click(evt); + }; + this.activate_action = function(evt) { + return _this.activate_field(evt); + }; + this.active_field = false; + this.mouse_on_container = false; + this.results_showing = false; + this.result_highlighted = null; + this.result_single_selected = null; + this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false; + this.disable_search_threshold = this.options.disable_search_threshold || 0; + this.disable_search = this.options.disable_search || false; + this.search_contains = this.options.search_contains || false; + this.choices = 0; + this.single_backstroke_delete = this.options.single_backstroke_delete || false; + return this.max_selected_options = this.options.max_selected_options || Infinity; + }; + + AbstractChosen.prototype.set_default_text = function() { + if (this.form_field.getAttribute("data-placeholder")) { + this.default_text = this.form_field.getAttribute("data-placeholder"); + } else if (this.is_multiple) { + this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || "Select Some Options"; + } else { + this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || "Select an Option"; + } + return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || "No results match"; + }; + + AbstractChosen.prototype.mouse_enter = function() { + return this.mouse_on_container = true; + }; + + AbstractChosen.prototype.mouse_leave = function() { + return this.mouse_on_container = false; + }; + + AbstractChosen.prototype.input_focus = function(evt) { + var _this = this; + if (this.is_multiple) { + if (!this.active_field) { + return setTimeout((function() { + return _this.container_mousedown(); + }), 50); + } + } else { + if (!this.active_field) return this.activate_field(); + } + }; + + AbstractChosen.prototype.input_blur = function(evt) { + var _this = this; + if (!this.mouse_on_container) { + this.active_field = false; + return setTimeout((function() { + return _this.blur_test(); + }), 100); + } + }; + + AbstractChosen.prototype.result_add_option = function(option) { + var classes, style; + if (!option.disabled) { + option.dom_id = this.container_id + "_o_" + option.array_index; + classes = option.selected && this.is_multiple ? [] : ["active-result"]; + if (option.selected) classes.push("result-selected"); + if (option.group_array_index != null) classes.push("group-option"); + if (option.classes !== "") classes.push(option.classes); + style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : ""; + return '
        • ' + option.html + '
        • '; + } else { + return ""; + } + }; + + AbstractChosen.prototype.results_update_field = function() { + if (!this.is_multiple) this.results_reset_cleanup(); + this.result_clear_highlight(); + this.result_single_selected = null; + return this.results_build(); + }; + + AbstractChosen.prototype.results_toggle = function() { + if (this.results_showing) { + return this.results_hide(); + } else { + return this.results_show(); + } + }; + + AbstractChosen.prototype.results_search = function(evt) { + if (this.results_showing) { + return this.winnow_results(); + } else { + return this.results_show(); + } + }; + + AbstractChosen.prototype.keyup_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + switch (stroke) { + case 8: + if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) { + return this.keydown_backstroke(); + } else if (!this.pending_backstroke) { + this.result_clear_highlight(); + return this.results_search(); + } + break; + case 13: + evt.preventDefault(); + if (this.results_showing) return this.result_select(evt); + break; + case 27: + if (this.results_showing) this.results_hide(); + return true; + case 9: + case 38: + case 40: + case 16: + case 91: + case 17: + break; + default: + return this.results_search(); + } + }; + + AbstractChosen.prototype.generate_field_id = function() { + var new_id; + new_id = this.generate_random_id(); + this.form_field.id = new_id; + return new_id; + }; + + AbstractChosen.prototype.generate_random_char = function() { + var chars, newchar, rand; + chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + rand = Math.floor(Math.random() * chars.length); + return newchar = chars.substring(rand, rand + 1); + }; + + return AbstractChosen; + + })(); + + root.AbstractChosen = AbstractChosen; + +}).call(this); + +/* +Chosen source: generate output using 'cake build' +Copyright (c) 2011 by Harvest +*/ + +(function() { + var Chosen, get_side_border_padding, root, + __hasProp = Object.prototype.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; + + root = this; + + Chosen = (function(_super) { + + __extends(Chosen, _super); + + function Chosen() { + Chosen.__super__.constructor.apply(this, arguments); + } + + Chosen.prototype.setup = function() { + this.current_value = this.form_field.value; + return this.is_rtl = this.form_field.hasClassName("chzn-rtl"); + }; + + Chosen.prototype.finish_setup = function() { + return this.form_field.addClassName("chzn-done"); + }; + + Chosen.prototype.set_default_values = function() { + Chosen.__super__.set_default_values.call(this); + this.single_temp = new Template('#{default}
            '); + this.multi_temp = new Template('
              '); + this.choice_temp = new Template('
            • #{choice}
            • '); + this.choice_noclose_temp = new Template('
            • #{choice}
            • '); + return this.no_results_temp = new Template('
            • ' + this.results_none_found + ' "#{terms}"
            • '); + }; + + Chosen.prototype.set_up_html = function() { + var base_template, container_props, dd_top, dd_width, sf_width; + this.container_id = this.form_field.identify().replace(/[^\w]/g, '_') + "_chzn"; + this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth(); + container_props = { + 'id': this.container_id, + 'class': "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''), + 'style': 'width: ' + this.f_width + 'px' + }; + base_template = this.is_multiple ? new Element('div', container_props).update(this.multi_temp.evaluate({ + "default": this.default_text + })) : new Element('div', container_props).update(this.single_temp.evaluate({ + "default": this.default_text + })); + this.form_field.hide().insert({ + after: base_template + }); + this.container = $(this.container_id); + this.container.addClassName("chzn-container-" + (this.is_multiple ? "multi" : "single")); + this.dropdown = this.container.down('div.chzn-drop'); + dd_top = this.container.getHeight(); + dd_width = this.f_width - get_side_border_padding(this.dropdown); + this.dropdown.setStyle({ + "width": dd_width + "px", + "top": dd_top + "px" + }); + this.search_field = this.container.down('input'); + this.search_results = this.container.down('ul.chzn-results'); + this.search_field_scale(); + this.search_no_results = this.container.down('li.no-results'); + if (this.is_multiple) { + this.search_choices = this.container.down('ul.chzn-choices'); + this.search_container = this.container.down('li.search-field'); + } else { + this.search_container = this.container.down('div.chzn-search'); + this.selected_item = this.container.down('.chzn-single'); + sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field); + this.search_field.setStyle({ + "width": sf_width + "px" + }); + } + this.results_build(); + this.set_tab_index(); + return this.form_field.fire("liszt:ready", { + chosen: this + }); + }; + + Chosen.prototype.register_observers = function() { + var _this = this; + this.container.observe("mousedown", function(evt) { + return _this.container_mousedown(evt); + }); + this.container.observe("mouseup", function(evt) { + return _this.container_mouseup(evt); + }); + this.container.observe("mouseenter", function(evt) { + return _this.mouse_enter(evt); + }); + this.container.observe("mouseleave", function(evt) { + return _this.mouse_leave(evt); + }); + this.search_results.observe("mouseup", function(evt) { + return _this.search_results_mouseup(evt); + }); + this.search_results.observe("mouseover", function(evt) { + return _this.search_results_mouseover(evt); + }); + this.search_results.observe("mouseout", function(evt) { + return _this.search_results_mouseout(evt); + }); + this.form_field.observe("liszt:updated", function(evt) { + return _this.results_update_field(evt); + }); + this.form_field.observe("liszt:activate", function(evt) { + return _this.activate_field(evt); + }); + this.form_field.observe("liszt:open", function(evt) { + return _this.container_mousedown(evt); + }); + this.search_field.observe("blur", function(evt) { + return _this.input_blur(evt); + }); + this.search_field.observe("keyup", function(evt) { + return _this.keyup_checker(evt); + }); + this.search_field.observe("keydown", function(evt) { + return _this.keydown_checker(evt); + }); + this.search_field.observe("focus", function(evt) { + return _this.input_focus(evt); + }); + if (this.is_multiple) { + return this.search_choices.observe("click", function(evt) { + return _this.choices_click(evt); + }); + } else { + return this.container.observe("click", function(evt) { + return evt.preventDefault(); + }); + } + }; + + Chosen.prototype.search_field_disabled = function() { + this.is_disabled = this.form_field.disabled; + if (this.is_disabled) { + this.container.addClassName('chzn-disabled'); + this.search_field.disabled = true; + if (!this.is_multiple) { + this.selected_item.stopObserving("focus", this.activate_action); + } + return this.close_field(); + } else { + this.container.removeClassName('chzn-disabled'); + this.search_field.disabled = false; + if (!this.is_multiple) { + return this.selected_item.observe("focus", this.activate_action); + } + } + }; + + Chosen.prototype.container_mousedown = function(evt) { + var target_closelink; + if (!this.is_disabled) { + target_closelink = evt != null ? evt.target.hasClassName("search-choice-close") : false; + if (evt && evt.type === "mousedown" && !this.results_showing) evt.stop(); + if (!this.pending_destroy_click && !target_closelink) { + if (!this.active_field) { + if (this.is_multiple) this.search_field.clear(); + document.observe("click", this.click_test_action); + this.results_show(); + } else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chzn-single"))) { + this.results_toggle(); + } + return this.activate_field(); + } else { + return this.pending_destroy_click = false; + } + } + }; + + Chosen.prototype.container_mouseup = function(evt) { + if (evt.target.nodeName === "ABBR" && !this.is_disabled) { + return this.results_reset(evt); + } + }; + + Chosen.prototype.blur_test = function(evt) { + if (!this.active_field && this.container.hasClassName("chzn-container-active")) { + return this.close_field(); + } + }; + + Chosen.prototype.close_field = function() { + document.stopObserving("click", this.click_test_action); + this.active_field = false; + this.results_hide(); + this.container.removeClassName("chzn-container-active"); + this.winnow_results_clear(); + this.clear_backstroke(); + this.show_search_field_default(); + return this.search_field_scale(); + }; + + Chosen.prototype.activate_field = function() { + this.container.addClassName("chzn-container-active"); + this.active_field = true; + this.search_field.value = this.search_field.value; + return this.search_field.focus(); + }; + + Chosen.prototype.test_active_click = function(evt) { + if (evt.target.up('#' + this.container_id)) { + return this.active_field = true; + } else { + return this.close_field(); + } + }; + + Chosen.prototype.results_build = function() { + var content, data, _i, _len, _ref; + this.parsing = true; + this.results_data = root.SelectParser.select_to_array(this.form_field); + if (this.is_multiple && this.choices > 0) { + this.search_choices.select("li.search-choice").invoke("remove"); + this.choices = 0; + } else if (!this.is_multiple) { + this.selected_item.addClassName("chzn-default").down("span").update(this.default_text); + if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) { + this.container.addClassName("chzn-container-single-nosearch"); + } else { + this.container.removeClassName("chzn-container-single-nosearch"); + } + } + content = ''; + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + data = _ref[_i]; + if (data.group) { + content += this.result_add_group(data); + } else if (!data.empty) { + content += this.result_add_option(data); + if (data.selected && this.is_multiple) { + this.choice_build(data); + } else if (data.selected && !this.is_multiple) { + this.selected_item.removeClassName("chzn-default").down("span").update(data.html); + if (this.allow_single_deselect) this.single_deselect_control_build(); + } + } + } + this.search_field_disabled(); + this.show_search_field_default(); + this.search_field_scale(); + this.search_results.update(content); + return this.parsing = false; + }; + + Chosen.prototype.result_add_group = function(group) { + if (!group.disabled) { + group.dom_id = this.container_id + "_g_" + group.array_index; + return '
            • ' + group.label.escapeHTML() + '
            • '; + } else { + return ""; + } + }; + + Chosen.prototype.result_do_highlight = function(el) { + var high_bottom, high_top, maxHeight, visible_bottom, visible_top; + this.result_clear_highlight(); + this.result_highlight = el; + this.result_highlight.addClassName("highlighted"); + maxHeight = parseInt(this.search_results.getStyle('maxHeight'), 10); + visible_top = this.search_results.scrollTop; + visible_bottom = maxHeight + visible_top; + high_top = this.result_highlight.positionedOffset().top; + high_bottom = high_top + this.result_highlight.getHeight(); + if (high_bottom >= visible_bottom) { + return this.search_results.scrollTop = (high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0; + } else if (high_top < visible_top) { + return this.search_results.scrollTop = high_top; + } + }; + + Chosen.prototype.result_clear_highlight = function() { + if (this.result_highlight) { + this.result_highlight.removeClassName('highlighted'); + } + return this.result_highlight = null; + }; + + Chosen.prototype.results_show = function() { + var dd_top; + if (!this.is_multiple) { + this.selected_item.addClassName('chzn-single-with-drop'); + if (this.result_single_selected) { + this.result_do_highlight(this.result_single_selected); + } + } else if (this.max_selected_options <= this.choices) { + this.form_field.fire("liszt:maxselected", { + chosen: this + }); + return false; + } + dd_top = this.is_multiple ? this.container.getHeight() : this.container.getHeight() - 1; + this.form_field.fire("liszt:showing_dropdown", { + chosen: this + }); + this.dropdown.setStyle({ + "top": dd_top + "px", + "left": 0 + }); + this.results_showing = true; + this.search_field.focus(); + this.search_field.value = this.search_field.value; + return this.winnow_results(); + }; + + Chosen.prototype.results_hide = function() { + if (!this.is_multiple) { + this.selected_item.removeClassName('chzn-single-with-drop'); + } + this.result_clear_highlight(); + this.form_field.fire("liszt:hiding_dropdown", { + chosen: this + }); + this.dropdown.setStyle({ + "left": "-9000px" + }); + return this.results_showing = false; + }; + + Chosen.prototype.set_tab_index = function(el) { + var ti; + if (this.form_field.tabIndex) { + ti = this.form_field.tabIndex; + this.form_field.tabIndex = -1; + return this.search_field.tabIndex = ti; + } + }; + + Chosen.prototype.show_search_field_default = function() { + if (this.is_multiple && this.choices < 1 && !this.active_field) { + this.search_field.value = this.default_text; + return this.search_field.addClassName("default"); + } else { + this.search_field.value = ""; + return this.search_field.removeClassName("default"); + } + }; + + Chosen.prototype.search_results_mouseup = function(evt) { + var target; + target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result"); + if (target) { + this.result_highlight = target; + this.result_select(evt); + return this.search_field.focus(); + } + }; + + Chosen.prototype.search_results_mouseover = function(evt) { + var target; + target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result"); + if (target) return this.result_do_highlight(target); + }; + + Chosen.prototype.search_results_mouseout = function(evt) { + if (evt.target.hasClassName('active-result') || evt.target.up('.active-result')) { + return this.result_clear_highlight(); + } + }; + + Chosen.prototype.choices_click = function(evt) { + evt.preventDefault(); + if (this.active_field && !(evt.target.hasClassName('search-choice') || evt.target.up('.search-choice')) && !this.results_showing) { + return this.results_show(); + } + }; + + Chosen.prototype.choice_build = function(item) { + var choice_id, link, + _this = this; + if (this.is_multiple && this.max_selected_options <= this.choices) { + this.form_field.fire("liszt:maxselected", { + chosen: this + }); + return false; + } + choice_id = this.container_id + "_c_" + item.array_index; + this.choices += 1; + this.search_container.insert({ + before: (item.disabled ? this.choice_noclose_temp : this.choice_temp).evaluate({ + id: choice_id, + choice: item.html, + position: item.array_index + }) + }); + if (!item.disabled) { + link = $(choice_id).down('a'); + return link.observe("click", function(evt) { + return _this.choice_destroy_link_click(evt); + }); + } + }; + + Chosen.prototype.choice_destroy_link_click = function(evt) { + evt.preventDefault(); + if (!this.is_disabled) { + this.pending_destroy_click = true; + return this.choice_destroy(evt.target); + } + }; + + Chosen.prototype.choice_destroy = function(link) { + if (this.result_deselect(link.readAttribute("rel"))) { + this.choices -= 1; + this.show_search_field_default(); + if (this.is_multiple && this.choices > 0 && this.search_field.value.length < 1) { + this.results_hide(); + } + return link.up('li').remove(); + } + }; + + Chosen.prototype.results_reset = function() { + this.form_field.options[0].selected = true; + this.selected_item.down("span").update(this.default_text); + if (!this.is_multiple) this.selected_item.addClassName("chzn-default"); + this.show_search_field_default(); + this.results_reset_cleanup(); + if (typeof Event.simulate === 'function') this.form_field.simulate("change"); + if (this.active_field) return this.results_hide(); + }; + + Chosen.prototype.results_reset_cleanup = function() { + var deselect_trigger; + this.current_value = this.form_field.value; + deselect_trigger = this.selected_item.down("abbr"); + if (deselect_trigger) return deselect_trigger.remove(); + }; + + Chosen.prototype.result_select = function(evt) { + var high, item, position; + if (this.result_highlight) { + high = this.result_highlight; + this.result_clear_highlight(); + if (this.is_multiple) { + this.result_deactivate(high); + } else { + this.search_results.descendants(".result-selected").invoke("removeClassName", "result-selected"); + this.selected_item.removeClassName("chzn-default"); + this.result_single_selected = high; + } + high.addClassName("result-selected"); + position = high.id.substr(high.id.lastIndexOf("_") + 1); + item = this.results_data[position]; + item.selected = true; + this.form_field.options[item.options_index].selected = true; + if (this.is_multiple) { + this.choice_build(item); + } else { + this.selected_item.down("span").update(item.html); + if (this.allow_single_deselect) this.single_deselect_control_build(); + } + if (!(evt.metaKey && this.is_multiple)) this.results_hide(); + this.search_field.value = ""; + if (typeof Event.simulate === 'function' && (this.is_multiple || this.form_field.value !== this.current_value)) { + this.form_field.simulate("change"); + } + this.current_value = this.form_field.value; + return this.search_field_scale(); + } + }; + + Chosen.prototype.result_activate = function(el) { + return el.addClassName("active-result"); + }; + + Chosen.prototype.result_deactivate = function(el) { + return el.removeClassName("active-result"); + }; + + Chosen.prototype.result_deselect = function(pos) { + var result, result_data; + result_data = this.results_data[pos]; + if (!this.form_field.options[result_data.options_index].disabled) { + result_data.selected = false; + this.form_field.options[result_data.options_index].selected = false; + result = $(this.container_id + "_o_" + pos); + result.removeClassName("result-selected").addClassName("active-result").show(); + this.result_clear_highlight(); + this.winnow_results(); + if (typeof Event.simulate === 'function') { + this.form_field.simulate("change"); + } + this.search_field_scale(); + return true; + } else { + return false; + } + }; + + Chosen.prototype.single_deselect_control_build = function() { + if (this.allow_single_deselect && !this.selected_item.down("abbr")) { + return this.selected_item.down("span").insert({ + after: "" + }); + } + }; + + Chosen.prototype.winnow_results = function() { + var found, option, part, parts, regex, regexAnchor, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref; + this.no_results_clear(); + results = 0; + searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip().escapeHTML(); + regexAnchor = this.search_contains ? "" : "^"; + regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + option = _ref[_i]; + if (!option.disabled && !option.empty) { + if (option.group) { + $(option.dom_id).hide(); + } else if (!(this.is_multiple && option.selected)) { + found = false; + result_id = option.dom_id; + if (regex.test(option.html)) { + found = true; + results += 1; + } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) { + parts = option.html.replace(/\[|\]/g, "").split(" "); + if (parts.length) { + for (_j = 0, _len2 = parts.length; _j < _len2; _j++) { + part = parts[_j]; + if (regex.test(part)) { + found = true; + results += 1; + } + } + } + } + if (found) { + if (searchText.length) { + startpos = option.html.search(zregex); + text = option.html.substr(0, startpos + searchText.length) + '
              ' + option.html.substr(startpos + searchText.length); + text = text.substr(0, startpos) + '' + text.substr(startpos); + } else { + text = option.html; + } + if ($(result_id).innerHTML !== text) $(result_id).update(text); + this.result_activate($(result_id)); + if (option.group_array_index != null) { + $(this.results_data[option.group_array_index].dom_id).setStyle({ + display: 'list-item' + }); + } + } else { + if ($(result_id) === this.result_highlight) { + this.result_clear_highlight(); + } + this.result_deactivate($(result_id)); + } + } + } + } + if (results < 1 && searchText.length) { + return this.no_results(searchText); + } else { + return this.winnow_results_set_highlight(); + } + }; + + Chosen.prototype.winnow_results_clear = function() { + var li, lis, _i, _len, _results; + this.search_field.clear(); + lis = this.search_results.select("li"); + _results = []; + for (_i = 0, _len = lis.length; _i < _len; _i++) { + li = lis[_i]; + if (li.hasClassName("group-result")) { + _results.push(li.show()); + } else if (!this.is_multiple || !li.hasClassName("result-selected")) { + _results.push(this.result_activate(li)); + } else { + _results.push(void 0); + } + } + return _results; + }; + + Chosen.prototype.winnow_results_set_highlight = function() { + var do_high; + if (!this.result_highlight) { + if (!this.is_multiple) { + do_high = this.search_results.down(".result-selected.active-result"); + } + if (!(do_high != null)) { + do_high = this.search_results.down(".active-result"); + } + if (do_high != null) return this.result_do_highlight(do_high); + } + }; + + Chosen.prototype.no_results = function(terms) { + return this.search_results.insert(this.no_results_temp.evaluate({ + terms: terms + })); + }; + + Chosen.prototype.no_results_clear = function() { + var nr, _results; + nr = null; + _results = []; + while (nr = this.search_results.down(".no-results")) { + _results.push(nr.remove()); + } + return _results; + }; + + Chosen.prototype.keydown_arrow = function() { + var actives, nexts, sibs; + actives = this.search_results.select("li.active-result"); + if (actives.length) { + if (!this.result_highlight) { + this.result_do_highlight(actives.first()); + } else if (this.results_showing) { + sibs = this.result_highlight.nextSiblings(); + nexts = sibs.intersect(actives); + if (nexts.length) this.result_do_highlight(nexts.first()); + } + if (!this.results_showing) return this.results_show(); + } + }; + + Chosen.prototype.keyup_arrow = function() { + var actives, prevs, sibs; + if (!this.results_showing && !this.is_multiple) { + return this.results_show(); + } else if (this.result_highlight) { + sibs = this.result_highlight.previousSiblings(); + actives = this.search_results.select("li.active-result"); + prevs = sibs.intersect(actives); + if (prevs.length) { + return this.result_do_highlight(prevs.first()); + } else { + if (this.choices > 0) this.results_hide(); + return this.result_clear_highlight(); + } + } + }; + + Chosen.prototype.keydown_backstroke = function() { + var next_available_destroy; + if (this.pending_backstroke) { + this.choice_destroy(this.pending_backstroke.down("a")); + return this.clear_backstroke(); + } else { + next_available_destroy = this.search_container.siblings().last(); + if (next_available_destroy && next_available_destroy.hasClassName("search-choice") && !next_available_destroy.hasClassName("search-choice-disabled")) { + this.pending_backstroke = next_available_destroy; + if (this.pending_backstroke) { + this.pending_backstroke.addClassName("search-choice-focus"); + } + if (this.single_backstroke_delete) { + return this.keydown_backstroke(); + } else { + return this.pending_backstroke.addClassName("search-choice-focus"); + } + } + } + }; + + Chosen.prototype.clear_backstroke = function() { + if (this.pending_backstroke) { + this.pending_backstroke.removeClassName("search-choice-focus"); + } + return this.pending_backstroke = null; + }; + + Chosen.prototype.keydown_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke(); + switch (stroke) { + case 8: + this.backstroke_length = this.search_field.value.length; + break; + case 9: + if (this.results_showing && !this.is_multiple) this.result_select(evt); + this.mouse_on_container = false; + break; + case 13: + evt.preventDefault(); + break; + case 38: + evt.preventDefault(); + this.keyup_arrow(); + break; + case 40: + this.keydown_arrow(); + break; + } + }; + + Chosen.prototype.search_field_scale = function() { + var dd_top, div, h, style, style_block, styles, w, _i, _len; + if (this.is_multiple) { + h = 0; + w = 0; + style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"; + styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing']; + for (_i = 0, _len = styles.length; _i < _len; _i++) { + style = styles[_i]; + style_block += style + ":" + this.search_field.getStyle(style) + ";"; + } + div = new Element('div', { + 'style': style_block + }).update(this.search_field.value.escapeHTML()); + document.body.appendChild(div); + w = Element.measure(div, 'width') + 25; + div.remove(); + if (w > this.f_width - 10) w = this.f_width - 10; + this.search_field.setStyle({ + 'width': w + 'px' + }); + dd_top = this.container.getHeight(); + return this.dropdown.setStyle({ + "top": dd_top + "px" + }); + } + }; + + return Chosen; + + })(AbstractChosen); + + root.Chosen = Chosen; + + if (Prototype.Browser.IE) { + if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { + Prototype.BrowserFeatures['Version'] = new Number(RegExp.$1); + } + } + + get_side_border_padding = function(elmt) { + var layout, side_border_padding; + layout = new Element.Layout(elmt); + return side_border_padding = layout.get("border-left") + layout.get("border-right") + layout.get("padding-left") + layout.get("padding-right"); + }; + + root.get_side_border_padding = get_side_border_padding; + +}).call(this); diff --git a/phpgwapi/js/jquery/chosen/chosen.proto.min.js b/phpgwapi/js/jquery/chosen/chosen.proto.min.js new file mode 100644 index 0000000000..2fb90cd3ab --- /dev/null +++ b/phpgwapi/js/jquery/chosen/chosen.proto.min.js @@ -0,0 +1,10 @@ +// Chosen, a Select Box Enhancer for jQuery and Protoype +// by Patrick Filler for Harvest, http://getharvest.com +// +// Version 0.9.8 +// Full source at https://github.com/harvesthq/chosen +// Copyright (c) 2011 Harvest http://getharvest.com + +// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md +// This file is generated by `cake build`, do not edit it by hand. +(function(){var SelectParser;SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(child){return child.nodeName.toUpperCase()==="OPTGROUP"?this.add_group(child):this.add_option(child)},SelectParser.prototype.add_group=function(group){var group_position,option,_i,_len,_ref,_results;group_position=this.parsed.length,this.parsed.push({array_index:group_position,group:!0,label:group.label,children:0,disabled:group.disabled}),_ref=group.childNodes,_results=[];for(_i=0,_len=_ref.length;_i<_len;_i++)option=_ref[_i],_results.push(this.add_option(option,group_position,group.disabled));return _results},SelectParser.prototype.add_option=function(option,group_position,group_disabled){if(option.nodeName.toUpperCase()==="OPTION")return option.text!==""?(group_position!=null&&(this.parsed[group_position].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:option.value,text:option.text,html:option.innerHTML,selected:option.selected,disabled:group_disabled===!0?group_disabled:option.disabled,group_array_index:group_position,classes:option.className,style:option.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},SelectParser}(),SelectParser.select_to_array=function(select){var child,parser,_i,_len,_ref;parser=new SelectParser,_ref=select.childNodes;for(_i=0,_len=_ref.length;_i<_len;_i++)child=_ref[_i],parser.add_node(child);return parser.parsed},this.SelectParser=SelectParser}).call(this),function(){var AbstractChosen,root;root=this,AbstractChosen=function(){function AbstractChosen(form_field,options){this.form_field=form_field,this.options=options!=null?options:{},this.set_default_values(),this.is_multiple=this.form_field.multiple,this.set_default_text(),this.setup(),this.set_up_html(),this.register_observers(),this.finish_setup()}return AbstractChosen.prototype.set_default_values=function(){var _this=this;return this.click_test_action=function(evt){return _this.test_active_click(evt)},this.activate_action=function(evt){return _this.activate_field(evt)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.allow_single_deselect=this.options.allow_single_deselect!=null&&this.form_field.options[0]!=null&&this.form_field.options[0].text===""?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity},AbstractChosen.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||"No results match"},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(evt){var _this=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return _this.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(evt){var _this=this;if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(){return _this.blur_test()},100)},AbstractChosen.prototype.result_add_option=function(option){var classes,style;return option.disabled?"":(option.dom_id=this.container_id+"_o_"+option.array_index,classes=option.selected&&this.is_multiple?[]:["active-result"],option.selected&&classes.push("result-selected"),option.group_array_index!=null&&classes.push("group-option"),option.classes!==""&&classes.push(option.classes),style=option.style.cssText!==""?' style="'+option.style+'"':"",'
            • "+option.html+"
            • ")},AbstractChosen.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(evt){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.keyup_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale();switch(stroke){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:evt.preventDefault();if(this.results_showing)return this.result_select(evt);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.generate_field_id=function(){var new_id;return new_id=this.generate_random_id(),this.form_field.id=new_id,new_id},AbstractChosen.prototype.generate_random_char=function(){var chars,newchar,rand;return chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",rand=Math.floor(Math.random()*chars.length),newchar=chars.substring(rand,rand+1)},AbstractChosen}(),root.AbstractChosen=AbstractChosen}.call(this),function(){var Chosen,get_side_border_padding,root,__hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)__hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child};root=this,Chosen=function(_super){function Chosen(){Chosen.__super__.constructor.apply(this,arguments)}return __extends(Chosen,_super),Chosen.prototype.setup=function(){return this.current_value=this.form_field.value,this.is_rtl=this.form_field.hasClassName("chzn-rtl")},Chosen.prototype.finish_setup=function(){return this.form_field.addClassName("chzn-done")},Chosen.prototype.set_default_values=function(){return Chosen.__super__.set_default_values.call(this),this.single_temp=new Template('#{default}
                '),this.multi_temp=new Template('
                  '),this.choice_temp=new Template('
                • #{choice}
                • '),this.choice_noclose_temp=new Template('
                • #{choice}
                • '),this.no_results_temp=new Template('
                • '+this.results_none_found+' "#{terms}"
                • ')},Chosen.prototype.set_up_html=function(){var base_template,container_props,dd_top,dd_width,sf_width;return this.container_id=this.form_field.identify().replace(/[^\w]/g,"_")+"_chzn",this.f_width=this.form_field.getStyle("width")?parseInt(this.form_field.getStyle("width"),10):this.form_field.getWidth(),container_props={id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px"},base_template=this.is_multiple?(new Element("div",container_props)).update(this.multi_temp.evaluate({"default":this.default_text})):(new Element("div",container_props)).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:base_template}),this.container=$(this.container_id),this.container.addClassName("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.down("div.chzn-drop"),dd_top=this.container.getHeight(),dd_width=this.f_width-get_side_border_padding(this.dropdown),this.dropdown.setStyle({width:dd_width+"px",top:dd_top+"px"}),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chzn-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chzn-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chzn-search"),this.selected_item=this.container.down(".chzn-single"),sf_width=dd_width-get_side_border_padding(this.search_container)-get_side_border_padding(this.search_field),this.search_field.setStyle({width:sf_width+"px"})),this.results_build(),this.set_tab_index(),this.form_field.fire("liszt:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var _this=this;return this.container.observe("mousedown",function(evt){return _this.container_mousedown(evt)}),this.container.observe("mouseup",function(evt){return _this.container_mouseup(evt)}),this.container.observe("mouseenter",function(evt){return _this.mouse_enter(evt)}),this.container.observe("mouseleave",function(evt){return _this.mouse_leave(evt)}),this.search_results.observe("mouseup",function(evt){return _this.search_results_mouseup(evt)}),this.search_results.observe("mouseover",function(evt){return _this.search_results_mouseover(evt)}),this.search_results.observe("mouseout",function(evt){return _this.search_results_mouseout(evt)}),this.form_field.observe("liszt:updated",function(evt){return _this.results_update_field(evt)}),this.form_field.observe("liszt:activate",function(evt){return _this.activate_field(evt)}),this.form_field.observe("liszt:open",function(evt){return _this.container_mousedown(evt)}),this.search_field.observe("blur",function(evt){return _this.input_blur(evt)}),this.search_field.observe("keyup",function(evt){return _this.keyup_checker(evt)}),this.search_field.observe("keydown",function(evt){return _this.keydown_checker(evt)}),this.search_field.observe("focus",function(evt){return _this.input_focus(evt)}),this.is_multiple?this.search_choices.observe("click",function(evt){return _this.choices_click(evt)}):this.container.observe("click",function(evt){return evt.preventDefault()})},Chosen.prototype.search_field_disabled=function(){this.is_disabled=this.form_field.disabled;if(this.is_disabled)return this.container.addClassName("chzn-disabled"),this.search_field.disabled=!0,this.is_multiple||this.selected_item.stopObserving("focus",this.activate_action),this.close_field();this.container.removeClassName("chzn-disabled"),this.search_field.disabled=!1;if(!this.is_multiple)return this.selected_item.observe("focus",this.activate_action)},Chosen.prototype.container_mousedown=function(evt){var target_closelink;if(!this.is_disabled)return target_closelink=evt!=null?evt.target.hasClassName("search-choice-close"):!1,evt&&evt.type==="mousedown"&&!this.results_showing&&evt.stop(),!this.pending_destroy_click&&!target_closelink?(this.active_field?!this.is_multiple&&evt&&(evt.target===this.selected_item||evt.target.up("a.chzn-single"))&&this.results_toggle():(this.is_multiple&&this.search_field.clear(),document.observe("click",this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},Chosen.prototype.container_mouseup=function(evt){if(evt.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(evt)},Chosen.prototype.blur_test=function(evt){if(!this.active_field&&this.container.hasClassName("chzn-container-active"))return this.close_field()},Chosen.prototype.close_field=function(){return document.stopObserving("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClassName("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClassName("chzn-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value,this.search_field.focus()},Chosen.prototype.test_active_click=function(evt){return evt.target.up("#"+this.container_id)?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){var content,data,_i,_len,_ref;this.parsing=!0,this.results_data=root.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.select("li.search-choice").invoke("remove"),this.choices=0):this.is_multiple||(this.selected_item.addClassName("chzn-default").down("span").update(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClassName("chzn-container-single-nosearch"):this.container.removeClassName("chzn-container-single-nosearch")),content="",_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++)data=_ref[_i],data.group?content+=this.result_add_group(data):data.empty||(content+=this.result_add_option(data),data.selected&&this.is_multiple?this.choice_build(data):data.selected&&!this.is_multiple&&(this.selected_item.removeClassName("chzn-default").down("span").update(data.html),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.update(content),this.parsing=!1},Chosen.prototype.result_add_group=function(group){return group.disabled?"":(group.dom_id=this.container_id+"_g_"+group.array_index,'
                • '+group.label.escapeHTML()+"
                • ")},Chosen.prototype.result_do_highlight=function(el){var high_bottom,high_top,maxHeight,visible_bottom,visible_top;this.result_clear_highlight(),this.result_highlight=el,this.result_highlight.addClassName("highlighted"),maxHeight=parseInt(this.search_results.getStyle("maxHeight"),10),visible_top=this.search_results.scrollTop,visible_bottom=maxHeight+visible_top,high_top=this.result_highlight.positionedOffset().top,high_bottom=high_top+this.result_highlight.getHeight();if(high_bottom>=visible_bottom)return this.search_results.scrollTop=high_bottom-maxHeight>0?high_bottom-maxHeight:0;if(high_top0&&this.search_field.value.length<1&&this.results_hide(),link.up("li").remove()},Chosen.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.down("span").update(this.default_text),this.is_multiple||this.selected_item.addClassName("chzn-default"),this.show_search_field_default(),this.results_reset_cleanup(),typeof Event.simulate=="function"&&this.form_field.simulate("change");if(this.active_field)return this.results_hide()},Chosen.prototype.results_reset_cleanup=function(){var deselect_trigger;this.current_value=this.form_field.value,deselect_trigger=this.selected_item.down("abbr");if(deselect_trigger)return deselect_trigger.remove()},Chosen.prototype.result_select=function(evt){var high,item,position;if(this.result_highlight)return high=this.result_highlight,this.result_clear_highlight(),this.is_multiple?this.result_deactivate(high):(this.search_results.descendants(".result-selected").invoke("removeClassName","result-selected"),this.selected_item.removeClassName("chzn-default"),this.result_single_selected=high),high.addClassName("result-selected"),position=high.id.substr(high.id.lastIndexOf("_")+1),item=this.results_data[position],item.selected=!0,this.form_field.options[item.options_index].selected=!0,this.is_multiple?this.choice_build(item):(this.selected_item.down("span").update(item.html),this.allow_single_deselect&&this.single_deselect_control_build()),(!evt.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.value="",typeof Event.simulate=="function"&&(this.is_multiple||this.form_field.value!==this.current_value)&&this.form_field.simulate("change"),this.current_value=this.form_field.value,this.search_field_scale()},Chosen.prototype.result_activate=function(el){return el.addClassName("active-result")},Chosen.prototype.result_deactivate=function(el){return el.removeClassName("active-result")},Chosen.prototype.result_deselect=function(pos){var result,result_data;return result_data=this.results_data[pos],this.form_field.options[result_data.options_index].disabled?!1:(result_data.selected=!1,this.form_field.options[result_data.options_index].selected=!1,result=$(this.container_id+"_o_"+pos),result.removeClassName("result-selected").addClassName("active-result").show(),this.result_clear_highlight(),this.winnow_results(),typeof Event.simulate=="function"&&this.form_field.simulate("change"),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&!this.selected_item.down("abbr"))return this.selected_item.down("span").insert({after:''})},Chosen.prototype.winnow_results=function(){var found,option,part,parts,regex,regexAnchor,result_id,results,searchText,startpos,text,zregex,_i,_j,_len,_len2,_ref;this.no_results_clear(),results=0,searchText=this.search_field.value===this.default_text?"":this.search_field.value.strip().escapeHTML(),regexAnchor=this.search_contains?"":"^",regex=new RegExp(regexAnchor+searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),zregex=new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++){option=_ref[_i];if(!option.disabled&&!option.empty)if(option.group)$(option.dom_id).hide();else if(!this.is_multiple||!option.selected){found=!1,result_id=option.dom_id;if(regex.test(option.html))found=!0,results+=1;else if(option.html.indexOf(" ")>=0||option.html.indexOf("[")===0){parts=option.html.replace(/\[|\]/g,"").split(" ");if(parts.length)for(_j=0,_len2=parts.length;_j<_len2;_j++)part=parts[_j],regex.test(part)&&(found=!0,results+=1)}found?(searchText.length?(startpos=option.html.search(zregex),text=option.html.substr(0,startpos+searchText.length)+"
                  "+option.html.substr(startpos+searchText.length),text=text.substr(0,startpos)+""+text.substr(startpos)):text=option.html,$(result_id).innerHTML!==text&&$(result_id).update(text),this.result_activate($(result_id)),option.group_array_index!=null&&$(this.results_data[option.group_array_index].dom_id).setStyle({display:"list-item"})):($(result_id)===this.result_highlight&&this.result_clear_highlight(),this.result_deactivate($(result_id)))}}return results<1&&searchText.length?this.no_results(searchText):this.winnow_results_set_highlight()},Chosen.prototype.winnow_results_clear=function(){var li,lis,_i,_len,_results;this.search_field.clear(),lis=this.search_results.select("li"),_results=[];for(_i=0,_len=lis.length;_i<_len;_i++)li=lis[_i],li.hasClassName("group-result")?_results.push(li.show()):!this.is_multiple||!li.hasClassName("result-selected")?_results.push(this.result_activate(li)):_results.push(void 0);return _results},Chosen.prototype.winnow_results_set_highlight=function(){var do_high;if(!this.result_highlight){this.is_multiple||(do_high=this.search_results.down(".result-selected.active-result")),do_high==null&&(do_high=this.search_results.down(".active-result"));if(do_high!=null)return this.result_do_highlight(do_high)}},Chosen.prototype.no_results=function(terms){return this.search_results.insert(this.no_results_temp.evaluate({terms:terms}))},Chosen.prototype.no_results_clear=function(){var nr,_results;nr=null,_results=[];while(nr=this.search_results.down(".no-results"))_results.push(nr.remove());return _results},Chosen.prototype.keydown_arrow=function(){var actives,nexts,sibs;actives=this.search_results.select("li.active-result");if(actives.length){this.result_highlight?this.results_showing&&(sibs=this.result_highlight.nextSiblings(),nexts=sibs.intersect(actives),nexts.length&&this.result_do_highlight(nexts.first())):this.result_do_highlight(actives.first());if(!this.results_showing)return this.results_show()}},Chosen.prototype.keyup_arrow=function(){var actives,prevs,sibs;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return sibs=this.result_highlight.previousSiblings(),actives=this.search_results.select("li.active-result"),prevs=sibs.intersect(actives),prevs.length?this.result_do_highlight(prevs.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},Chosen.prototype.keydown_backstroke=function(){var next_available_destroy;if(this.pending_backstroke)return this.choice_destroy(this.pending_backstroke.down("a")),this.clear_backstroke();next_available_destroy=this.search_container.siblings().last();if(next_available_destroy&&next_available_destroy.hasClassName("search-choice")&&!next_available_destroy.hasClassName("search-choice-disabled"))return this.pending_backstroke=next_available_destroy,this.pending_backstroke&&this.pending_backstroke.addClassName("search-choice-focus"),this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClassName("search-choice-focus")},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale(),stroke!==8&&this.pending_backstroke&&this.clear_backstroke();switch(stroke){case 8:this.backstroke_length=this.search_field.value.length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(evt),this.mouse_on_container=!1;break;case 13:evt.preventDefault();break;case 38:evt.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var dd_top,div,h,style,style_block,styles,w,_i,_len;if(this.is_multiple){h=0,w=0,style_block="position:absolute; left: -1000px; top: -1000px; display:none;",styles=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(_i=0,_len=styles.length;_i<_len;_i++)style=styles[_i],style_block+=style+":"+this.search_field.getStyle(style)+";";return div=(new Element("div",{style:style_block})).update(this.search_field.value.escapeHTML()),document.body.appendChild(div),w=Element.measure(div,"width")+25,div.remove(),w>this.f_width-10&&(w=this.f_width-10),this.search_field.setStyle({width:w+"px"}),dd_top=this.container.getHeight(),this.dropdown.setStyle({top:dd_top+"px"})}},Chosen}(AbstractChosen),root.Chosen=Chosen,Prototype.Browser.IE&&/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&(Prototype.BrowserFeatures.Version=new Number(RegExp.$1)),get_side_border_padding=function(elmt){var layout,side_border_padding;return layout=new Element.Layout(elmt),side_border_padding=layout.get("border-left")+layout.get("border-right")+layout.get("padding-left")+layout.get("padding-right")},root.get_side_border_padding=get_side_border_padding}.call(this); \ No newline at end of file diff --git a/phpgwapi/js/jquery/chosen/example.jquery.html b/phpgwapi/js/jquery/chosen/example.jquery.html new file mode 100644 index 0000000000..5ec7c477c1 --- /dev/null +++ b/phpgwapi/js/jquery/chosen/example.jquery.html @@ -0,0 +1,1333 @@ + + + + + + + +
                  +
                  +

                  Chosen

                  +

                  Chosen is a JavaScript plugin for Prototype and jQuery that makes long, unwieldy select boxes much more user-friendly. For more information (including usage, explanation and faqs), check out the online documentation.

                  + +

                  Standard Select

                  +
                  +
                  + Turns This + +
                  +
                  + Into This + +
                  +
                  + +

                  Multiple Select

                  +
                  +
                  + Turns This + +
                  +
                  + Into This + +
                  +
                  + +

                  <optgroup> Support

                  +
                  +
                  + Single Select with Groups + +
                  +
                  + Multiple Select with Groups + +
                  +
                  + +

                  Selected and Disabled Support

                  +
                  +

                  Chosen automatically highlights selected options and removes disabled options.

                  +
                  + Single Select + +
                  +
                  + Multiple Select + +
                  +
                  + +
                  +

                  It is also possible to prevent selected options being deselected by also making them disabled.

                  +
                  + +
                  +
                  + +

                  Default Text Support

                  +
                  +

                  Chosen automatically sets the default field text ("Choose a country...") by reading the select element's data-placeholder value. If no data-placeholder value is present, it will default to "Select Some Option" or "Select Some Options" depending on whether the select is single or multiple. You can change these elements in the plugin js file as you see fit.

                  + <select data-placeholder="Choose a country..." style="width:350px;" multiple class="chzn-select"> +

                  Note: on single selects, the first element is assumed to be selected by the browser. To take advantage of the default text support, you will need to include a blank option as the first element of your select list.

                  +
                  + +

                  No Results Text Support

                  +
                  +

                  Setting the "No results" search text is as easy as passing an option when you create Chosen:

                  + + $(".chzn-select").chosen({no_results_text: "No results matched"}); + +
                  + +

                  Limit Selected Options in Multiselect

                  +
                  +

                  You can easily limit how many options can user select:

                  + + $(".chzn-select").chosen({max_selected_options: 5}); + +

                  If you try to select another option with limit reached liszt:maxselected event is triggered:

                  + + $(".chzn-select").bind("liszt:maxselected", function () { ... }); + +
                  + +

                  Allow Deselect on Single Selects

                  +
                  +

                  When a single select box isn't a required field, you can set allow_single_deselect: true and Chosen will add a UI element for option deselection. This will only work if the first option has blank text.

                  +
                  + +
                  +
                  + +

                  Right to Left Support

                  +
                  +

                  Chosen supports right to left select boxes too. just add "chzn-rtl" in addition to "chzn-select" to your select tags and you are good to go.

                  +

                  <select class="chzn-select chzn-rtl">

                  +
                  + Single right to left select + +
                  +
                  + Multiple right to left select + +
                  +
                  + +

                  Change / Update Events

                  +
                  +
                    +
                  • +

                    Form Field Change

                    +

                    When working with form fields, you often want to perform some behavior after a value has been selected or deselected. Whenever a user selects a field in Chosen, it triggers a "change" event* on the original form field. That let's you do something like this:

                    +

                    $("#form_field").chosen().change( … );

                    +

                    Note: Prototype doesn't offer support for triggering standard browser events. Event.simulate is required to trigger the change event when using the Prototype version.

                    +
                  • +
                  • +

                    Updating Chosen Dynamically

                    +

                    If you need to update the options in your select field and want Chosen to pick up the changes, you'll need to trigger the "liszt:updated" event on the field. Chosen will re-build itself based on the updated content.

                    +
                      +
                    • jQuery Version: $("#form_field").trigger("liszt:updated");
                    • +
                    • Prototype Version: Event.fire($("form_field"), "liszt:updated");
                    • +
                    +
                  • +
                  +
                  + +

                  Setup (for jQuery)

                  +

                  Using Chosen is easy as can be.

                  +
                    +
                  1. Download the plugin and copy the chosen files to your app.
                  2. +
                  3. Activate the plugin on the select boxes of your choice: $(".chzn-select").chosen()
                  4. +
                  5. Disco.
                  6. +
                  + +
                  + + + +
                  + + diff --git a/phpgwapi/js/jquery/chosen/package.json b/phpgwapi/js/jquery/chosen/package.json new file mode 100644 index 0000000000..a97f4f48b7 --- /dev/null +++ b/phpgwapi/js/jquery/chosen/package.json @@ -0,0 +1,18 @@ +{ + "author": "harvest", + "name": "chosen", + "version": "0.9.8", + "description": "Chosen is a JavaScript plugin that makes long, unwieldy select boxes much more user-friendly. It is currently available in both jQuery and Prototype flavors.", + "repository": { + "type": "git", + "url": "https://github.com/harvesthq/chosen" + }, + "engines": { + "node": ">=0.4.0" + }, + "dependencies": {}, + "devDependencies": { + "coffee-script": ">= 1.2", + "uglify-js": ">= 1.2.5" + } +} \ No newline at end of file diff --git a/phpgwapi/js/jsapi/egw_utils.js b/phpgwapi/js/jsapi/egw_utils.js index fc6ea14ce7..41b9b9a481 100644 --- a/phpgwapi/js/jsapi/egw_utils.js +++ b/phpgwapi/js/jsapi/egw_utils.js @@ -204,6 +204,47 @@ egw.extend('utils', egw.MODULE_GLOBAL, function() { */ encodePathComponent: function(_comp) { return _comp.replace(/#/g,'%23').replace(/\?/g,'%3F').replace(/\//g,''); + }, + + /** + * If an element has display: none (or a parent like that), it has no size. + * Use this to get its dimensions anyway. + * + * @param element HTML element + * @param boolOuter Pass true to get outerWidth() / outerHeight() instead of width() / height() + * + * @return Object [w: width, h: height] + * + * @author Ryan Wheale + * @see http://www.foliotek.com/devblog/getting-the-width-of-a-hidden-element-with-jquery-using-width/ + */ + getHiddenDimensions: function(element, boolOuter) { + var $item = $j(element); + var props = { position: "absolute", visibility: "hidden", display: "block" }; + var dim = { "w":0, "h":0 }; + var $hiddenParents = $item.parents().andSelf().not(":visible"); + + var oldProps = []; + $hiddenParents.each(function() { + var old = {}; + for ( var name in props ) { + old[ name ] = this.style[ name ]; + this.style[ name ] = props[ name ]; + } + oldProps.push(old); + }); + + dim.w = (boolOuter === true) ? $item.outerWidth() : $item.width(); + dim.h = (boolOuter === true) ? $item.outerHeight() : $item.height(); + + $hiddenParents.each(function(i) { + var old = oldProps[i]; + for ( var name in props ) { + this.style[ name ] = old[ name ]; + } + }); + //$.log(”w: ” + dim.w + ”, h:” + dim.h) + return dim; } }; From bc275bef4147d7a629d3e82e76b6fdb6775bde04 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 12 Nov 2012 19:32:35 +0000 Subject: [PATCH 039/150] Remove accidentally committed debug --- etemplate/inc/class.select_widget.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/etemplate/inc/class.select_widget.inc.php b/etemplate/inc/class.select_widget.inc.php index 0d373ab473..0e46f97c0b 100644 --- a/etemplate/inc/class.select_widget.inc.php +++ b/etemplate/inc/class.select_widget.inc.php @@ -103,7 +103,6 @@ class select_widget function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) { list($rows,$type,$type2,$type3,$type4,$type5,$type6,$enhance) = explode(',',$cell['size']); -echo "$name ($rows,$type,$type2,$type3,$type4,$type5,$type6,$enhance)
                  "; $extension_data['type'] = $cell['type']; From 39e3d199fc4a692ed34472d429f85d680f3b9362 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 13 Nov 2012 09:53:06 +0000 Subject: [PATCH 040/150] * Calendar: ignore (unchangeable) status of groups for setting line-type of events: all users of a group-invitation accepted --> solid line for all accepted --- calendar/inc/class.calendar_uiviews.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index 572250b740..8d5ae141a6 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @package calendar * @author Ralf Becker - * @copyright (c) 2004-10 by RalfBecker-At-outdoor-training.de + * @copyright (c) 2004-12 by RalfBecker-At-outdoor-training.de * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -1759,6 +1759,8 @@ function open_edit(series) $status_class = 'calEventAllAccepted'; foreach($event['participants'] as $id => $status) { + if ($id < 0) continue; // as we cant accept/reject groups, we dont care about them here + calendar_so::split_status($status,$quantity,$role); switch ($status) From d6ce940eb0bb92820efa9908061271e9ec2c2680 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 13 Nov 2012 11:23:29 +0000 Subject: [PATCH 041/150] * Calendar: sort participants by there name --- calendar/inc/class.calendar_bo.inc.php | 2 + calendar/inc/class.calendar_uiforms.inc.php | 49 +++++++++++++++------ 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index 92c550651c..53eb4caa42 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -1550,6 +1550,8 @@ class calendar_bo $names[$id] .= ' '.$role; } } + natcasesort($names); + return $names; } diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 0cbf9c45a5..5988ed7c8a 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @package calendar * @author Ralf Becker - * @copyright (c) 2004-11 by RalfBecker-At-outdoor-training.de + * @copyright (c) 2004-12 by RalfBecker-At-outdoor-training.de * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -1101,6 +1101,36 @@ class calendar_uiforms extends calendar_ui return "window.open('".egw::link('/index.php',$vars)."','_blank','width=700,height=700,scrollbars=yes,status=no');"; } + /** + * Get title of a uid / calendar participant + * + * @param int|string $uid + * @return string + */ + public function get_title($uid) + { + if (is_numeric($uid)) + { + return common::grab_owner_name($uid); + } + elseif (($info = $this->bo->resource_info($uid))) + { + return $info['name'] ? $info['name'] : $info['email']; + } + return '#'.$uid; + } + + /** + * Compare two uid by there title + * + * @param int|string $uid1 + * @param int|string $uid2 + * @return int see strnatcasecmp + */ + public function uid_title_cmp($uid1, $uid2) + { + return strnatcasecmp($this->get_title($uid1), $this->get_title($uid2)); + } /** * Edit a calendar event @@ -1355,6 +1385,8 @@ function replace_eTemplate_onsubmit() { $name = $this->bo->resources[$type]['app']; } + // sort participants (in there group/app) by title + uksort($participants, array($this, 'uid_title_cmp')); foreach($participants as $id => $status) { $uid = $type == 'u' ? $id : $type.$id; @@ -1386,23 +1418,14 @@ function replace_eTemplate_onsubmit() $readonlys[$row.'[status]'] = !$this->bo->check_status_perms($uid,$event); $readonlys["delete[$uid]"] = $preserv['hide_delete'] || !$this->bo->check_perms(EGW_ACL_EDIT,$event); // todo: make the participants available as links with email as title - if ($name == 'accounts') - { - $content['participants'][$row++]['title'] = common::grab_owner_name($id); - } - elseif (($info = $this->bo->resource_info($uid))) - { - $content['participants'][$row++]['title'] = $info['name'] ? $info['name'] : $info['email']; - } - else - { - $content['participants'][$row++]['title'] = '#'.$uid; - } + $content['participants'][$row++]['title'] = $this->get_title($uid); // enumerate group-invitations, so people can accept/reject them if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' && ($members = $GLOBALS['egw']->accounts->members($id,true))) { $sel_options['status']['G'] = lang('Select one'); + // sort members by title + usort($members, array($this, 'uid_title_cmp')); foreach($members as $member) { if (!isset($participants[$member]) && $this->bo->check_perms(EGW_ACL_READ,0,$member)) From 04017a728b2223df7ced0aced4cbb3ae79e29ba1 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 13 Nov 2012 12:07:10 +0000 Subject: [PATCH 042/150] * InfoLog: switching to a group-type resets access to "public" and disables access in edit --- infolog/inc/class.infolog_bo.inc.php | 1 + infolog/inc/class.infolog_ui.inc.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/infolog/inc/class.infolog_bo.inc.php b/infolog/inc/class.infolog_bo.inc.php index 35ea7588eb..de7334ee4c 100644 --- a/infolog/inc/class.infolog_bo.inc.php +++ b/infolog/inc/class.infolog_bo.inc.php @@ -851,6 +851,7 @@ class infolog_bo return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights) } } + $values['info_access'] = 'public'; // group-owners are allways public } elseif (!$values['info_id'] && !$values['info_owner'] || $GLOBALS['egw']->accounts->get_type($values['info_owner']) == 'g') { diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index ddb00453fb..d698787d41 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1323,7 +1323,9 @@ else $entry['info_type'] = $settings; try { $this->bo->write($entry, true,true,true,$skip_notifications,true); // Throw exceptions - } catch (egw_exception_wrong_userinput $e) { + } + catch (egw_exception_wrong_userinput $e) + { $msg .= "\n".$e->getMessage(); $failed++; break; @@ -1946,6 +1948,8 @@ else //echo "

                  setting type to r/o as user has no delete rights from group #$group

                  \n"; $readonlys['info_type'] = true; } + // disable info_access for group-owners + $readonlys['info_access'] = true; } elseif($GLOBALS['egw']->accounts->get_type($content['info_owner']) == 'g') { From ae28edb43a0e29d9b6ac6122e2ebf391a5adb72e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 13 Nov 2012 13:31:44 +0000 Subject: [PATCH 043/150] * Calendar: notify responsible for a resource "participating" in a private event only with privacy-cleared details --- calendar/inc/class.calendar_boupdate.inc.php | 26 +++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index cff735572e..4082caf3dc 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -723,7 +723,6 @@ class calendar_boupdate extends calendar_bo { $notify_msg = $this->cal_prefs['notifyAdded']; // use a default } - $details = $this->_get_event_details($event,$action,$event_arr,$disinvited); // add all group-members to the notification, unless they are already participants foreach($to_notify as $userid => $statusid) @@ -755,7 +754,18 @@ class calendar_boupdate extends calendar_bo if (!is_numeric($userid)) { $res_info = $this->resource_info($userid); + + // check if responsible of a resource has read rights on event (might be private!) + if ($res_info['app'] == 'resources' && $res_info['responsible'] && + !$this->check_perms(EGW_ACL_READ, $event, 0, 'ts', null, $res_info['responsible'])) + { + // --> use only details from (private-)cleared event only containing resource ($userid) + // reading server timezone, to be able to use cleared event for iCal generation further down + $cleared_event = $this->read($event['id'], null, true, 'server'); + $this->clear_private_infos($cleared_event, array($userid)); + } $userid = $res_info['responsible']; + if (!isset($userid)) { if (empty($res_info['email'])) continue; // no way to notify @@ -791,7 +801,7 @@ class calendar_boupdate extends calendar_bo $GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository(); $GLOBALS['egw']->accounts->get_account_name($userid,$lid,$details['to-firstname'],$details['to-lastname']); - $details['to-fullname'] = common::display_fullname('',$details['to-firstname'],$details['to-lastname']); + $fullname = common::display_fullname('',$details['to-firstname'],$details['to-lastname']); } else // external email address: use preferences of event-owner, plus some hardcoded settings (eg. ical notification) { @@ -803,18 +813,22 @@ class calendar_boupdate extends calendar_bo $part_prefs = $owner_prefs; $part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals']; $part_prefs['calendar']['update_format'] = 'ical'; // use ical format - $details['to-fullname'] = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid; + $fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid; } if (!self::update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event,$role)) { continue; } + if ($lang !== $part_prefs['common']['lang']) { translation::init(); - $details = $this->_get_event_details($event,$action,$event_arr,$disinvited); $lang = $part_prefs['common']['lang']; } + $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, + $action, $event_arr, $disinvited); + $details['to-fullname'] = $fullname; + // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; $timezone = new DateTimeZone($part_prefs['common']['tz']); @@ -856,7 +870,7 @@ class calendar_boupdate extends calendar_bo $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ // we need to pass $event[id] so iCal class reads event again, // as event is in user TZ, but iCal class expects server TZ! - $ics = $calendar_ical->exportVCal(array($event['id']),'2.0',$method); + $ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']),'2.0',$method); unset($calendar_ical); } $attachment = array( @@ -865,7 +879,7 @@ class calendar_boupdate extends calendar_bo 'encoding' => '8bit', 'type' => 'text/calendar; method='.$method, ); - $subject = $event['title']; + $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; // fall through case 'extended': From 052897fcd8169ee99cbcb833715ee414709878d0 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 13 Nov 2012 17:26:31 +0000 Subject: [PATCH 044/150] - Add display filter to view resources, accessories, or both - Change view accessories activity to depend on the existance of accessories in DB, not links - Add view accessories action to context menu --- resources/inc/class.resources_bo.inc.php | 59 +++++++++++++++++------- resources/inc/class.resources_ui.inc.php | 24 ++++++++-- resources/lang/egw_en.lang | 2 + 3 files changed, 65 insertions(+), 20 deletions(-) diff --git a/resources/inc/class.resources_bo.inc.php b/resources/inc/class.resources_bo.inc.php index 70a148f5f6..5da06521e2 100755 --- a/resources/inc/class.resources_bo.inc.php +++ b/resources/inc/class.resources_bo.inc.php @@ -38,6 +38,16 @@ class resources_bo */ var $cats; + /** + * List of filter options + */ + public static $filter_options = array( + -1 => 'resources', + -2 => 'accessories', + -3 => 'resources and accessories' + // Accessories of a resource added when resource selected + ); + function __construct() { $this->so = new resources_so(); @@ -71,8 +81,34 @@ class resources_bo if ($this->debug) _debug_array($query); $read_onlys = 'res_id,name,short_description,quantity,useable,bookable,buyable,cat_id,location,storage_info'; - $accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1; - $filter = array('accessory_of' => $accessory_of); + $filter = array(); + $join = ''; + $extra_cols = array(); + + // Sub-query to get the count of accessories + $acc_join = "LEFT JOIN (SELECT accessory_of AS accessory_id, count(res_id) as acc_count FROM {$this->so->table_name} GROUP BY accessory_of) AS acc ON acc.accessory_id = {$this->so->table_name}.res_id "; + + switch($query['filter2']) + { + case -1: + // Resources only + $filter['accessory_of'] = -1; + $join = $acc_join; + $extra_cols[] = 'acc_count'; + break; + case -2: + // Accessories only + $filter[] = 'accessory_of != -1'; + break; + case -3: + // All + $join = $acc_join; + $extra_cols[] = 'acc_count'; + break; + default: + $filter['accessory_of'] = $query['view_accs_of']; + } + if ($query['filter']) { if (($children = $this->acl->get_cats(EGW_ACL_READ,$query['filter']))) @@ -102,7 +138,7 @@ class resources_bo $start = (int)$query['start']; foreach ($filter as $k => $v) $query['col_filter'][$k] = $v; - $this->so->get_rows($query, $rows, $readonlys); + $this->so->get_rows($query, $rows, $readonlys, $join, false, false, $extra_cols); $nr = $this->so->total; // we are called to serve bookable resources (e.g. calendar-dialog) @@ -150,21 +186,12 @@ class resources_bo $readonlys["buyable[$resource[res_id]]"] = true; $resource['class'] .= 'no_buy '; } - $readonlys["view_acc[$resource[res_id]]"] = true; - $links = egw_link::get_links('resources',$resource['res_id']); - if(count($links) != 0 && $accessory_of == -1) + $readonlys["view_acc[{$resource['res_id']}]"] = ($resource['acc_count'] == 0); + if($resource['acc_count']) { - foreach ($links as $link_num => $link) - { - if($link['app'] == 'resources') - { - if($this->so->get_value('accessory_of',$link['res_id']) != -1) - { - $readonlys["view_acc[$resource[res_id]]"] = false; - } - } - } + $resource['class'] .= 'hasAccessories '; } + $rows[$num]['picture_thumb'] = $this->get_picture($resource); $rows[$num]['admin'] = $this->acl->get_cat_admin($resource['cat_id']); } diff --git a/resources/inc/class.resources_ui.inc.php b/resources/inc/class.resources_ui.inc.php index 0b9ce5630c..f527b754a0 100755 --- a/resources/inc/class.resources_ui.inc.php +++ b/resources/inc/class.resources_ui.inc.php @@ -58,6 +58,7 @@ class resources_ui { unset($sessiondata['view_accs_of']); unset($sessiondata['no_filter']); + unset($sessiondata['filter2']); $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata); return $this->index(); } @@ -120,8 +121,7 @@ class resources_ui $content['nm']['get_rows'] = 'resources.resources_bo.get_rows'; $content['nm']['no_filter'] = False; $content['nm']['filter_label'] = lang('Category'); - $content['nm']['filter_help'] = lang('Select a category'); // is this used??? - $content['nm']['no_filter2'] = true; + $content['nm']['filter2_label'] = 'Display'; $content['nm']['filter_no_lang'] = true; $content['nm']['no_cat'] = true; $content['nm']['bottom_too'] = true; @@ -136,9 +136,15 @@ class resources_ui $content['nm'] = $nm_session_data; } $content['nm']['options-filter']= array(''=>lang('all categories'))+(array)$this->bo->acl->get_cats(EGW_ACL_READ); + $content['nm']['options-filter2'] = resources_bo::$filter_options; + if($_GET['search']) { $content['nm']['search'] = $_GET['search']; } + if($_GET['view_accs_of']) + { + $content['nm']['view_accs_of'] = (int)$_GET['view_accs_of']; + } $content['nm']['actions'] = $this->get_actions(); // check if user is permitted to add resources @@ -181,10 +187,10 @@ class resources_ui if($content['nm']['view_accs_of']) { $master = $this->bo->so->read(array('res_id' => $content['nm']['view_accs_of'])); - $content['view_accs_of'] = $content['nm']['view_accs_of']; + $content['view_accs_of'] = $content['nm']['filter2'] = $content['nm']['view_accs_of']; + $content['nm']['options-filter2'] = array($master['res_id'] => lang('accessories of') . ' ' . $master['name']); $content['nm']['get_rows'] = 'resources.resources_bo.get_rows'; $content['nm']['no_filter'] = true; - $content['nm']['no_filter2'] = true; $no_button['back'] = false; $no_button['add'] = true; $no_button['add_sub'] = false; @@ -222,6 +228,16 @@ class resources_ui 'popup' => egw_link::get_registry('resources', 'view_popup'), 'group' => $group, ), + 'view-acc' => array( + 'caption' => 'View accessories', + 'icon' => 'view_acc', + 'allowOnMultiple' => false, + 'url' => 'menuaction=resources.resources_ui.index&view_accs_of=$id', + 'group' => $group, + 'enableClass' => 'hasAccessories' + ), + + 'add' => array( 'caption' => 'Add', 'url' => 'menuaction=resources.resources_ui.edit', diff --git a/resources/lang/egw_en.lang b/resources/lang/egw_en.lang index 0859db056c..9db05752d2 100644 --- a/resources/lang/egw_en.lang +++ b/resources/lang/egw_en.lang @@ -1,4 +1,5 @@ accessories of resources en Accessories of +accessories resources en Accessories accessories: resources en Accessories: actions resources en Actions add accessory resources en Add accessory @@ -82,6 +83,7 @@ read permissions resources en Read permissions related links resources en Related links resource id resources en Resource ID resources common en Resources +resources and accessories resources en Resources and Accessories resources csv export resources en Resources CSV export resources csv import resources en Resources CSV import resources list resources en Resources list From 8b55a21206663958b33e4ed6f229646d8dd602f1 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 13 Nov 2012 22:14:00 +0000 Subject: [PATCH 045/150] More changes to use chosen for fancy selectboxes - apply to egw multi-select and select user too --- etemplate/inc/class.etemplate_old.inc.php | 6 +- etemplate/inc/class.nextmatch_widget.inc.php | 2 + phpgwapi/inc/class.html.inc.php | 15 +- phpgwapi/inc/class.uiaccountsel.inc.php | 13 +- phpgwapi/js/jquery/chosen/.gitignore | 3 - phpgwapi/js/jquery/chosen/chosen.css | 11 +- phpgwapi/js/jquery/chosen/chosen.jquery.js | 39 +- .../js/jquery/chosen/chosen.jquery.min.js | 10 - phpgwapi/js/jquery/chosen/chosen.proto.js | 1025 ----------------- phpgwapi/js/jquery/chosen/chosen.proto.min.js | 10 - 10 files changed, 69 insertions(+), 1065 deletions(-) delete mode 100644 phpgwapi/js/jquery/chosen/.gitignore delete mode 100644 phpgwapi/js/jquery/chosen/chosen.jquery.min.js delete mode 100644 phpgwapi/js/jquery/chosen/chosen.proto.js delete mode 100644 phpgwapi/js/jquery/chosen/chosen.proto.min.js diff --git a/etemplate/inc/class.etemplate_old.inc.php b/etemplate/inc/class.etemplate_old.inc.php index d6c8acfc77..131d1605f3 100644 --- a/etemplate/inc/class.etemplate_old.inc.php +++ b/etemplate/inc/class.etemplate_old.inc.php @@ -1586,8 +1586,9 @@ class etemplate_old extends boetemplate { $enhance = $cell['enhance']; } - else if (count($c_options >= 8)) + else if (count($c_options) >= 8) { + // 8 or more optionsu - #7 is enhance flag $enhance = ($c_options[7] == '1' || $c_options[7] == 'true'); } @@ -1641,7 +1642,8 @@ class etemplate_old extends boetemplate if ($multiple && is_numeric($multiple)) // eg. "3+" would give a regular multiselectbox { $html .= html::checkbox_multiselect($form_name.($multiple > 1 ? '[]' : ''),$value,$sels, - $cell['no_lang'],$options,$multiple,$multiple[0]!=='0',$extraStyleMultiselect); + $cell['no_lang'],$options,$multiple,$multiple[0]!=='0', + $extraStyleMultiselect,$enhance); } else { diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index a51cf732f1..fd4ed908ed 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -484,6 +484,8 @@ class nextmatch_widget if (is_object($nextmatch)) { $size =& $nextmatch->get_cell_attribute('selectcols','size'); + // Don't change to fancy multi-select here + $nextmatch->set_cell_attribute('selectcols','enhance',false); if ($size > count($value['options-selectcols'])) $size = '0'.count($value['options-selectcols']); if (!$GLOBALS['egw_info']['user']['apps']['admin']) { diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 84afb0e0a4..95fa513942 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -51,6 +51,11 @@ class html */ static $api_js_url; + /** + * Automatically turn on enhanced selectboxes if there's more than this many options + */ + const SELECT_ENHANCED_ROW_COUNT = 12; + /** * initialise our static vars */ @@ -224,7 +229,7 @@ class html */ static function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0,$enhanced=null) { - if(is_null($enhanced)) $enhanced = (count($arr) > 12); + if(is_null($enhanced)) $enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT); if (!is_array($arr)) { @@ -288,7 +293,7 @@ class html $out .= "\n"; if($enhanced) { - egw_framework::validate_file('/phpgwapi/js/jquery/chosen/chosen.jquery.min.js'); + egw_framework::validate_file('/phpgwapi/js/jquery/chosen/chosen.jquery.js'); egw_framework::includeCSS('/phpgwapi/js/jquery/chosen/chosen.css',null,false); $out .= "\n"; } @@ -311,9 +316,11 @@ class html * @param string $style='' extra style settings like "width: 100%", default '' none * @return string to set for a template or to echo into html page */ - static function checkbox_multiselect($name, $key, $arr=0,$no_lang=false,$options='',$multiple=3,$selected_first=true,$style='') + static function checkbox_multiselect($name, $key, $arr=0,$no_lang=false,$options='',$multiple=3,$selected_first=true,$style='',$enhanced = null) { //echo "

                  checkbox_multiselect('$name',".array2string($key).",".array2string($arr).",$no_lang,'$options',$multiple,$selected_first,'$style')

                  \n"; + if(is_null($enhanced)) $enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT); + if (!is_array($arr)) { $arr = array('no','yes'); @@ -326,6 +333,8 @@ class html } $base_name = substr($name,0,-2); + if($enhanced) return self::select($name, $key, $arr,$no_lang,$options,$multiple,$enhanced); + if (!is_array($key)) { // explode on ',' only if multiple values expected and the key contains just numbers and commas diff --git a/phpgwapi/inc/class.uiaccountsel.inc.php b/phpgwapi/inc/class.uiaccountsel.inc.php index 8c594597d3..11d083d1fe 100644 --- a/phpgwapi/inc/class.uiaccountsel.inc.php +++ b/phpgwapi/inc/class.uiaccountsel.inc.php @@ -52,6 +52,10 @@ class uiaccountsel { $this->account_selection = 'primary_group'; } + + // Include these here, framework may have already sent header by the time the account select is made + egw_framework::validate_file('/phpgwapi/js/jquery/chosen/chosen.jquery.js'); + egw_framework::includeCSS('/phpgwapi/js/jquery/chosen/chosen.css',null,false); } /** @@ -292,7 +296,11 @@ class uiaccountsel } elseif (!$only_groups && ($lines == 1 || $lines > 0 && $this->account_selection == 'primary_group')) { - $js = "if (selectBox = document.getElementById('$element_id')) if (!selectBox.multiple) {selectBox.size=$multi_size; selectBox.multiple=true; if (selectBox.options[0].value=='') selectBox.options[0] = null;"; + $js = "if (selectBox = document.getElementById('$element_id')) if (!selectBox.multiple) { if(\$j(selectBox).unchosen) \$j(selectBox).unchosen(); selectBox.size=$multi_size; selectBox.multiple=true; if (selectBox.options[0].value=='') selectBox.options[0] = null;"; + if(count($select) > html::SELECT_ENHANCED_ROW_COUNT) + { + $js .= "\$j(selectBox).css('width','100%').chosen({placeholder_text: '".lang('Select multiple accounts')."'}); "; + } if (!in_array($this->account_selection,array('groupmembers','selectbox'))) // no popup! { $js .= " this.src='".common::image('phpgwapi','search')."'; this.title='". @@ -301,7 +309,7 @@ class uiaccountsel } else { - $js .= " this.style.display='none'; selectBox.style.width='100%';"; + $js .= "this.style.display='none'; selectBox.style.width='100%';"; } $js .= "} return false;"; $html .= html::submit_button('search','Select multiple accounts',$js,false, @@ -329,6 +337,7 @@ function addOption(id,label,value,do_onchange) selectBox.options[selectBox.length] = new Option(label,value,false,true); } if (selectBox.onchange && do_onchange) selectBox.onchange(); + $j(selectBox).trigger("liszt:updated"); } '; $GLOBALS['egw_info']['flags']['uiaccountsel']['addOption_installed'] = True; diff --git a/phpgwapi/js/jquery/chosen/.gitignore b/phpgwapi/js/jquery/chosen/.gitignore deleted file mode 100644 index 7133b439fd..0000000000 --- a/phpgwapi/js/jquery/chosen/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -node_modules -.project diff --git a/phpgwapi/js/jquery/chosen/chosen.css b/phpgwapi/js/jquery/chosen/chosen.css index 71cffa261e..b6b183fdb0 100644 --- a/phpgwapi/js/jquery/chosen/chosen.css +++ b/phpgwapi/js/jquery/chosen/chosen.css @@ -156,7 +156,7 @@ border: 0 !important; font-family: sans-serif; font-size: 100%; - height: 15px; + height: 12px; padding: 5px; margin: 1px 0; outline: 0; @@ -186,9 +186,9 @@ box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05); color: #333; border: 1px solid #aaaaaa; - line-height: 13px; + line-height: 12px; padding: 3px 20px 3px 5px; - margin: 3px 0 3px 5px; + margin: 2px 0 2px 1px; position: relative; cursor: default; } @@ -230,7 +230,7 @@ .chzn-container .chzn-results { margin: 0 4px 4px 0; max-height: 240px; - padding: 0 0 0 4px; + padding: 0 0 0 0px; position: relative; overflow-x: hidden; overflow-y: auto; @@ -242,8 +242,7 @@ } .chzn-container .chzn-results li { display: none; - line-height: 15px; - padding: 5px 6px; + padding: 3px 6px; margin: 0; list-style: none; } diff --git a/phpgwapi/js/jquery/chosen/chosen.jquery.js b/phpgwapi/js/jquery/chosen/chosen.jquery.js index e940f8b2c4..75552922f4 100644 --- a/phpgwapi/js/jquery/chosen/chosen.jquery.js +++ b/phpgwapi/js/jquery/chosen/chosen.jquery.js @@ -249,10 +249,7 @@ Copyright (c) 2011 by Harvest }; AbstractChosen.prototype.generate_field_id = function() { - var new_id; - new_id = this.generate_random_id(); - this.form_field.id = new_id; - return new_id; + return this.generate_random_id(); }; AbstractChosen.prototype.generate_random_char = function() { @@ -296,6 +293,18 @@ Copyright (c) 2011 by Harvest return $this.data('chosen', new Chosen(this, options)); } }); + }, + unchosen: function() { + return $(this).each(function(input_field) { + var chosen, element; + element = $(this); + chosen = element.data("chosen"); + if (chosen) { + chosen.remove(); + element.data("chosen", null); + } + return element; + }); } }); @@ -419,6 +428,15 @@ Copyright (c) 2011 by Harvest } }; + Chosen.prototype.unregister_observers = function() { + return this.form_field_jq.unbind(); + }; + + Chosen.prototype.remove_html = function() { + this.form_field_jq.show().removeClass('chzn-done'); + return this.container.remove(); + }; + Chosen.prototype.search_field_disabled = function() { this.is_disabled = this.form_field_jq[0].disabled; if (this.is_disabled) { @@ -619,6 +637,13 @@ Copyright (c) 2011 by Harvest } }; + Chosen.prototype.reset_tab_index = function() { + var tabbed_item; + tabbed_item = this.is_multiple ? this.search_field : this.selected_item; + this.form_field_jq.attr("tabindex",tabbed_item.attr("tabindex")); + return tabbed_item.attr("tabindex") - 1; + }; + Chosen.prototype.show_search_field_default = function() { if (this.is_multiple && this.choices < 1 && !this.active_field) { this.search_field.val(this.default_text); @@ -888,6 +913,12 @@ Copyright (c) 2011 by Harvest return this.search_results.find(".no-results").remove(); }; + Chosen.prototype.remove = function() { + this.reset_tab_index(); + this.unregister_observers(); + return this.remove_html(); + }; + Chosen.prototype.keydown_arrow = function() { var first_active, next_sib; if (!this.result_highlight) { diff --git a/phpgwapi/js/jquery/chosen/chosen.jquery.min.js b/phpgwapi/js/jquery/chosen/chosen.jquery.min.js deleted file mode 100644 index d089017fc5..0000000000 --- a/phpgwapi/js/jquery/chosen/chosen.jquery.min.js +++ /dev/null @@ -1,10 +0,0 @@ -// Chosen, a Select Box Enhancer for jQuery and Protoype -// by Patrick Filler for Harvest, http://getharvest.com -// -// Version 0.9.8 -// Full source at https://github.com/harvesthq/chosen -// Copyright (c) 2011 Harvest http://getharvest.com - -// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md -// This file is generated by `cake build`, do not edit it by hand. -(function(){var SelectParser;SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(child){return child.nodeName.toUpperCase()==="OPTGROUP"?this.add_group(child):this.add_option(child)},SelectParser.prototype.add_group=function(group){var group_position,option,_i,_len,_ref,_results;group_position=this.parsed.length,this.parsed.push({array_index:group_position,group:!0,label:group.label,children:0,disabled:group.disabled}),_ref=group.childNodes,_results=[];for(_i=0,_len=_ref.length;_i<_len;_i++)option=_ref[_i],_results.push(this.add_option(option,group_position,group.disabled));return _results},SelectParser.prototype.add_option=function(option,group_position,group_disabled){if(option.nodeName.toUpperCase()==="OPTION")return option.text!==""?(group_position!=null&&(this.parsed[group_position].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:option.value,text:option.text,html:option.innerHTML,selected:option.selected,disabled:group_disabled===!0?group_disabled:option.disabled,group_array_index:group_position,classes:option.className,style:option.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},SelectParser}(),SelectParser.select_to_array=function(select){var child,parser,_i,_len,_ref;parser=new SelectParser,_ref=select.childNodes;for(_i=0,_len=_ref.length;_i<_len;_i++)child=_ref[_i],parser.add_node(child);return parser.parsed},this.SelectParser=SelectParser}).call(this),function(){var AbstractChosen,root;root=this,AbstractChosen=function(){function AbstractChosen(form_field,options){this.form_field=form_field,this.options=options!=null?options:{},this.set_default_values(),this.is_multiple=this.form_field.multiple,this.set_default_text(),this.setup(),this.set_up_html(),this.register_observers(),this.finish_setup()}return AbstractChosen.prototype.set_default_values=function(){var _this=this;return this.click_test_action=function(evt){return _this.test_active_click(evt)},this.activate_action=function(evt){return _this.activate_field(evt)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.allow_single_deselect=this.options.allow_single_deselect!=null&&this.form_field.options[0]!=null&&this.form_field.options[0].text===""?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity},AbstractChosen.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||"No results match"},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(evt){var _this=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return _this.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(evt){var _this=this;if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(){return _this.blur_test()},100)},AbstractChosen.prototype.result_add_option=function(option){var classes,style;return option.disabled?"":(option.dom_id=this.container_id+"_o_"+option.array_index,classes=option.selected&&this.is_multiple?[]:["active-result"],option.selected&&classes.push("result-selected"),option.group_array_index!=null&&classes.push("group-option"),option.classes!==""&&classes.push(option.classes),style=option.style.cssText!==""?' style="'+option.style+'"':"",'
                • "+option.html+"
                • ")},AbstractChosen.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(evt){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.keyup_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale();switch(stroke){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:evt.preventDefault();if(this.results_showing)return this.result_select(evt);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.generate_field_id=function(){var new_id;return new_id=this.generate_random_id(),this.form_field.id=new_id,new_id},AbstractChosen.prototype.generate_random_char=function(){var chars,newchar,rand;return chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",rand=Math.floor(Math.random()*chars.length),newchar=chars.substring(rand,rand+1)},AbstractChosen}(),root.AbstractChosen=AbstractChosen}.call(this),function(){var $,Chosen,get_side_border_padding,root,__hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)__hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child};root=this,$=jQuery,$.fn.extend({chosen:function(options){return $.browser.msie&&($.browser.version==="6.0"||$.browser.version==="7.0"&&document.documentMode===7)?this:this.each(function(input_field){var $this;$this=$(this);if(!$this.hasClass("chzn-done"))return $this.data("chosen",new Chosen(this,options))})}}),Chosen=function(_super){function Chosen(){Chosen.__super__.constructor.apply(this,arguments)}return __extends(Chosen,_super),Chosen.prototype.setup=function(){return this.form_field_jq=$(this.form_field),this.current_value=this.form_field_jq.val(),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},Chosen.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},Chosen.prototype.set_up_html=function(){var container_div,dd_top,dd_width,sf_width;return this.container_id=this.form_field.id.length?this.form_field.id.replace(/[^\w]/g,"_"):this.generate_field_id(),this.container_id+="_chzn",this.f_width = egw.getHiddenDimensions ? egw.getHiddenDimensions(this.form_field,true)['w'] : this.form_field_jq.outerWidth(),container_div=$("
                  ",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?container_div.html('
                    '):container_div.html(''+this.default_text+'
                      '),this.form_field_jq.hide().after(container_div),this.container=$("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),dd_top=this.container.height(),dd_width=this.f_width-get_side_border_padding(this.dropdown),this.dropdown.css({width:dd_width+"px",top:dd_top+"px"}),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chzn-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chzn-search").first(),this.selected_item=this.container.find(".chzn-single").first(),sf_width=dd_width-get_side_border_padding(this.search_container)-get_side_border_padding(this.search_field),this.search_field.css({width:sf_width+"px"})),this.results_build(),this.set_tab_index(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var _this=this;return this.container.mousedown(function(evt){return _this.container_mousedown(evt)}),this.container.mouseup(function(evt){return _this.container_mouseup(evt)}),this.container.mouseenter(function(evt){return _this.mouse_enter(evt)}),this.container.mouseleave(function(evt){return _this.mouse_leave(evt)}),this.search_results.mouseup(function(evt){return _this.search_results_mouseup(evt)}),this.search_results.mouseover(function(evt){return _this.search_results_mouseover(evt)}),this.search_results.mouseout(function(evt){return _this.search_results_mouseout(evt)}),this.form_field_jq.bind("liszt:updated",function(evt){return _this.results_update_field(evt)}),this.form_field_jq.bind("liszt:activate",function(evt){return _this.activate_field(evt)}),this.form_field_jq.bind("liszt:open",function(evt){return _this.container_mousedown(evt)}),this.search_field.blur(function(evt){return _this.input_blur(evt)}),this.search_field.keyup(function(evt){return _this.keyup_checker(evt)}),this.search_field.keydown(function(evt){return _this.keydown_checker(evt)}),this.search_field.focus(function(evt){return _this.input_focus(evt)}),this.is_multiple?this.search_choices.click(function(evt){return _this.choices_click(evt)}):this.container.click(function(evt){return evt.preventDefault()})},Chosen.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq[0].disabled;if(this.is_disabled)return this.container.addClass("chzn-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus",this.activate_action),this.close_field();this.container.removeClass("chzn-disabled"),this.search_field[0].disabled=!1;if(!this.is_multiple)return this.selected_item.bind("focus",this.activate_action)},Chosen.prototype.container_mousedown=function(evt){var target_closelink;if(!this.is_disabled)return target_closelink=evt!=null?$(evt.target).hasClass("search-choice-close"):!1,evt&&evt.type==="mousedown"&&!this.results_showing&&evt.stopPropagation(),!this.pending_destroy_click&&!target_closelink?(this.active_field?!this.is_multiple&&evt&&($(evt.target)[0]===this.selected_item[0]||$(evt.target).parents("a.chzn-single").length)&&(evt.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),$(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},Chosen.prototype.container_mouseup=function(evt){if(evt.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(evt)},Chosen.prototype.blur_test=function(evt){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},Chosen.prototype.close_field=function(){return $(document).unbind("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(evt){return $(evt.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){var content,data,_i,_len,_ref;this.parsing=!0,this.results_data=root.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||(this.selected_item.addClass("chzn-default").find("span").text(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),content="",_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++)data=_ref[_i],data.group?content+=this.result_add_group(data):data.empty||(content+=this.result_add_option(data),data.selected&&this.is_multiple?this.choice_build(data):data.selected&&!this.is_multiple&&(this.selected_item.removeClass("chzn-default").find("span").text(data.text),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.html(content),this.parsing=!1},Chosen.prototype.result_add_group=function(group){return group.disabled?"":(group.dom_id=this.container_id+"_g_"+group.array_index,'
                    • '+$("
                      ").text(group.label).html()+"
                    • ")},Chosen.prototype.result_do_highlight=function(el){var high_bottom,high_top,maxHeight,visible_bottom,visible_top;if(el.length){this.result_clear_highlight(),this.result_highlight=el,this.result_highlight.addClass("highlighted"),maxHeight=parseInt(this.search_results.css("maxHeight"),10),visible_top=this.search_results.scrollTop(),visible_bottom=maxHeight+visible_top,high_top=this.result_highlight.position().top+this.search_results.scrollTop(),high_bottom=high_top+this.result_highlight.outerHeight();if(high_bottom>=visible_bottom)return this.search_results.scrollTop(high_bottom-maxHeight>0?high_bottom-maxHeight:0);if(high_top'+item.html+"":html='
                    • '+item.html+'
                    • ',this.search_container.before(html),link=$("#"+choice_id).find("a").first(),link.click(function(evt){return _this.choice_destroy_link_click(evt)}))},Chosen.prototype.choice_destroy_link_click=function(evt){return evt.preventDefault(),this.is_disabled?evt.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy($(evt.target)))},Chosen.prototype.choice_destroy=function(link){if(this.result_deselect(link.attr("rel")))return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),link.parents("li").first().remove()},Chosen.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),this.is_multiple||this.selected_item.addClass("chzn-default"),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change");if(this.active_field)return this.results_hide()},Chosen.prototype.results_reset_cleanup=function(){return this.current_value=this.form_field_jq.val(),this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(evt){var high,high_id,item,position;if(this.result_highlight)return high=this.result_highlight,high_id=high.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(high):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=high,this.selected_item.removeClass("chzn-default")),high.addClass("result-selected"),position=high_id.substr(high_id.lastIndexOf("_")+1),item=this.results_data[position],item.selected=!0,this.form_field.options[item.options_index].selected=!0,this.is_multiple?this.choice_build(item):(this.selected_item.find("span").first().text(item.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!evt.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field_jq.val()!==this.current_value)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[item.options_index].value}),this.current_value=this.form_field_jq.val(),this.search_field_scale()},Chosen.prototype.result_activate=function(el){return el.addClass("active-result")},Chosen.prototype.result_deactivate=function(el){return el.removeClass("active-result")},Chosen.prototype.result_deselect=function(pos){var result,result_data;return result_data=this.results_data[pos],this.form_field.options[result_data.options_index].disabled?!1:(result_data.selected=!1,this.form_field.options[result_data.options_index].selected=!1,result=$("#"+this.container_id+"_o_"+pos),result.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[result_data.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&this.selected_item.find("abbr").length<1)return this.selected_item.find("span").first().after('')},Chosen.prototype.winnow_results=function(){var found,option,part,parts,regex,regexAnchor,result,result_id,results,searchText,startpos,text,zregex,_i,_j,_len,_len2,_ref;this.no_results_clear(),results=0,searchText=this.search_field.val()===this.default_text?"":$("
                      ").text($.trim(this.search_field.val())).html(),regexAnchor=this.search_contains?"":"^",regex=new RegExp(regexAnchor+searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),zregex=new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++){option=_ref[_i];if(!option.disabled&&!option.empty)if(option.group)$("#"+option.dom_id).css("display","none");else if(!this.is_multiple||!option.selected){found=!1,result_id=option.dom_id,result=$("#"+result_id);if(regex.test(option.html))found=!0,results+=1;else if(option.html.indexOf(" ")>=0||option.html.indexOf("[")===0){parts=option.html.replace(/\[|\]/g,"").split(" ");if(parts.length)for(_j=0,_len2=parts.length;_j<_len2;_j++)part=parts[_j],regex.test(part)&&(found=!0,results+=1)}found?(searchText.length?(startpos=option.html.search(zregex),text=option.html.substr(0,startpos+searchText.length)+""+option.html.substr(startpos+searchText.length),text=text.substr(0,startpos)+""+text.substr(startpos)):text=option.html,result.html(text),this.result_activate(result),option.group_array_index!=null&&$("#"+this.results_data[option.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&result_id===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(result))}}return results<1&&searchText.length?this.no_results(searchText):this.winnow_results_set_highlight()},Chosen.prototype.winnow_results_clear=function(){var li,lis,_i,_len,_results;this.search_field.val(""),lis=this.search_results.find("li"),_results=[];for(_i=0,_len=lis.length;_i<_len;_i++)li=lis[_i],li=$(li),li.hasClass("group-result")?_results.push(li.css("display","auto")):!this.is_multiple||!li.hasClass("result-selected")?_results.push(this.result_activate(li)):_results.push(void 0);return _results},Chosen.prototype.winnow_results_set_highlight=function(){var do_high,selected_results;if(!this.result_highlight){selected_results=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),do_high=selected_results.length?selected_results.first():this.search_results.find(".active-result").first();if(do_high!=null)return this.result_do_highlight(do_high)}},Chosen.prototype.no_results=function(terms){var no_results_html;return no_results_html=$('
                    • '+this.results_none_found+' ""
                    • '),no_results_html.find("span").first().html(terms),this.search_results.append(no_results_html)},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var first_active,next_sib;this.result_highlight?this.results_showing&&(next_sib=this.result_highlight.nextAll("li.active-result").first(),next_sib&&this.result_do_highlight(next_sib)):(first_active=this.search_results.find("li.active-result").first(),first_active&&this.result_do_highlight($(first_active)));if(!this.results_showing)return this.results_show()},Chosen.prototype.keyup_arrow=function(){var prev_sibs;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return prev_sibs=this.result_highlight.prevAll("li.active-result"),prev_sibs.length?this.result_do_highlight(prev_sibs.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},Chosen.prototype.keydown_backstroke=function(){var next_available_destroy;if(this.pending_backstroke)return this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke();next_available_destroy=this.search_container.siblings("li.search-choice").last();if(next_available_destroy.length&&!next_available_destroy.hasClass("search-choice-disabled"))return this.pending_backstroke=next_available_destroy,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale(),stroke!==8&&this.pending_backstroke&&this.clear_backstroke();switch(stroke){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(evt),this.mouse_on_container=!1;break;case 13:evt.preventDefault();break;case 38:evt.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var dd_top,div,h,style,style_block,styles,w,_i,_len;if(this.is_multiple){h=0,w=0,style_block="position:absolute; left: -1000px; top: -1000px; display:none;",styles=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(_i=0,_len=styles.length;_i<_len;_i++)style=styles[_i],style_block+=style+":"+this.search_field.css(style)+";";return div=$("
                      ",{style:style_block}),div.text(this.search_field.val()),$("body").append(div),w=div.width()+25,div.remove(),w>this.f_width-10&&(w=this.f_width-10),this.search_field.css({width:w+"px"}),dd_top=this.container.height(),this.dropdown.css({top:dd_top+"px"})}},Chosen.prototype.generate_random_id=function(){var string;string="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while($("#"+string).length>0)string+=this.generate_random_char();return string},Chosen}(AbstractChosen),get_side_border_padding=function(elmt){var side_border_padding;return side_border_padding=elmt.outerWidth()-elmt.width()},root.get_side_border_padding=get_side_border_padding}.call(this); diff --git a/phpgwapi/js/jquery/chosen/chosen.proto.js b/phpgwapi/js/jquery/chosen/chosen.proto.js deleted file mode 100644 index 017f3b3516..0000000000 --- a/phpgwapi/js/jquery/chosen/chosen.proto.js +++ /dev/null @@ -1,1025 +0,0 @@ -// Chosen, a Select Box Enhancer for jQuery and Protoype -// by Patrick Filler for Harvest, http://getharvest.com -// -// Version 0.9.8 -// Full source at https://github.com/harvesthq/chosen -// Copyright (c) 2011 Harvest http://getharvest.com - -// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md -// This file is generated by `cake build`, do not edit it by hand. -(function() { - var SelectParser; - - SelectParser = (function() { - - function SelectParser() { - this.options_index = 0; - this.parsed = []; - } - - SelectParser.prototype.add_node = function(child) { - if (child.nodeName.toUpperCase() === "OPTGROUP") { - return this.add_group(child); - } else { - return this.add_option(child); - } - }; - - SelectParser.prototype.add_group = function(group) { - var group_position, option, _i, _len, _ref, _results; - group_position = this.parsed.length; - this.parsed.push({ - array_index: group_position, - group: true, - label: group.label, - children: 0, - disabled: group.disabled - }); - _ref = group.childNodes; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - option = _ref[_i]; - _results.push(this.add_option(option, group_position, group.disabled)); - } - return _results; - }; - - SelectParser.prototype.add_option = function(option, group_position, group_disabled) { - if (option.nodeName.toUpperCase() === "OPTION") { - if (option.text !== "") { - if (group_position != null) this.parsed[group_position].children += 1; - this.parsed.push({ - array_index: this.parsed.length, - options_index: this.options_index, - value: option.value, - text: option.text, - html: option.innerHTML, - selected: option.selected, - disabled: group_disabled === true ? group_disabled : option.disabled, - group_array_index: group_position, - classes: option.className, - style: option.style.cssText - }); - } else { - this.parsed.push({ - array_index: this.parsed.length, - options_index: this.options_index, - empty: true - }); - } - return this.options_index += 1; - } - }; - - return SelectParser; - - })(); - - SelectParser.select_to_array = function(select) { - var child, parser, _i, _len, _ref; - parser = new SelectParser(); - _ref = select.childNodes; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - child = _ref[_i]; - parser.add_node(child); - } - return parser.parsed; - }; - - this.SelectParser = SelectParser; - -}).call(this); - -/* -Chosen source: generate output using 'cake build' -Copyright (c) 2011 by Harvest -*/ - -(function() { - var AbstractChosen, root; - - root = this; - - AbstractChosen = (function() { - - function AbstractChosen(form_field, options) { - this.form_field = form_field; - this.options = options != null ? options : {}; - this.set_default_values(); - this.is_multiple = this.form_field.multiple; - this.set_default_text(); - this.setup(); - this.set_up_html(); - this.register_observers(); - this.finish_setup(); - } - - AbstractChosen.prototype.set_default_values = function() { - var _this = this; - this.click_test_action = function(evt) { - return _this.test_active_click(evt); - }; - this.activate_action = function(evt) { - return _this.activate_field(evt); - }; - this.active_field = false; - this.mouse_on_container = false; - this.results_showing = false; - this.result_highlighted = null; - this.result_single_selected = null; - this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false; - this.disable_search_threshold = this.options.disable_search_threshold || 0; - this.disable_search = this.options.disable_search || false; - this.search_contains = this.options.search_contains || false; - this.choices = 0; - this.single_backstroke_delete = this.options.single_backstroke_delete || false; - return this.max_selected_options = this.options.max_selected_options || Infinity; - }; - - AbstractChosen.prototype.set_default_text = function() { - if (this.form_field.getAttribute("data-placeholder")) { - this.default_text = this.form_field.getAttribute("data-placeholder"); - } else if (this.is_multiple) { - this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || "Select Some Options"; - } else { - this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || "Select an Option"; - } - return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || "No results match"; - }; - - AbstractChosen.prototype.mouse_enter = function() { - return this.mouse_on_container = true; - }; - - AbstractChosen.prototype.mouse_leave = function() { - return this.mouse_on_container = false; - }; - - AbstractChosen.prototype.input_focus = function(evt) { - var _this = this; - if (this.is_multiple) { - if (!this.active_field) { - return setTimeout((function() { - return _this.container_mousedown(); - }), 50); - } - } else { - if (!this.active_field) return this.activate_field(); - } - }; - - AbstractChosen.prototype.input_blur = function(evt) { - var _this = this; - if (!this.mouse_on_container) { - this.active_field = false; - return setTimeout((function() { - return _this.blur_test(); - }), 100); - } - }; - - AbstractChosen.prototype.result_add_option = function(option) { - var classes, style; - if (!option.disabled) { - option.dom_id = this.container_id + "_o_" + option.array_index; - classes = option.selected && this.is_multiple ? [] : ["active-result"]; - if (option.selected) classes.push("result-selected"); - if (option.group_array_index != null) classes.push("group-option"); - if (option.classes !== "") classes.push(option.classes); - style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : ""; - return '
                    • ' + option.html + '
                    • '; - } else { - return ""; - } - }; - - AbstractChosen.prototype.results_update_field = function() { - if (!this.is_multiple) this.results_reset_cleanup(); - this.result_clear_highlight(); - this.result_single_selected = null; - return this.results_build(); - }; - - AbstractChosen.prototype.results_toggle = function() { - if (this.results_showing) { - return this.results_hide(); - } else { - return this.results_show(); - } - }; - - AbstractChosen.prototype.results_search = function(evt) { - if (this.results_showing) { - return this.winnow_results(); - } else { - return this.results_show(); - } - }; - - AbstractChosen.prototype.keyup_checker = function(evt) { - var stroke, _ref; - stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; - this.search_field_scale(); - switch (stroke) { - case 8: - if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) { - return this.keydown_backstroke(); - } else if (!this.pending_backstroke) { - this.result_clear_highlight(); - return this.results_search(); - } - break; - case 13: - evt.preventDefault(); - if (this.results_showing) return this.result_select(evt); - break; - case 27: - if (this.results_showing) this.results_hide(); - return true; - case 9: - case 38: - case 40: - case 16: - case 91: - case 17: - break; - default: - return this.results_search(); - } - }; - - AbstractChosen.prototype.generate_field_id = function() { - var new_id; - new_id = this.generate_random_id(); - this.form_field.id = new_id; - return new_id; - }; - - AbstractChosen.prototype.generate_random_char = function() { - var chars, newchar, rand; - chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - rand = Math.floor(Math.random() * chars.length); - return newchar = chars.substring(rand, rand + 1); - }; - - return AbstractChosen; - - })(); - - root.AbstractChosen = AbstractChosen; - -}).call(this); - -/* -Chosen source: generate output using 'cake build' -Copyright (c) 2011 by Harvest -*/ - -(function() { - var Chosen, get_side_border_padding, root, - __hasProp = Object.prototype.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; - - root = this; - - Chosen = (function(_super) { - - __extends(Chosen, _super); - - function Chosen() { - Chosen.__super__.constructor.apply(this, arguments); - } - - Chosen.prototype.setup = function() { - this.current_value = this.form_field.value; - return this.is_rtl = this.form_field.hasClassName("chzn-rtl"); - }; - - Chosen.prototype.finish_setup = function() { - return this.form_field.addClassName("chzn-done"); - }; - - Chosen.prototype.set_default_values = function() { - Chosen.__super__.set_default_values.call(this); - this.single_temp = new Template('#{default}
                        '); - this.multi_temp = new Template('
                          '); - this.choice_temp = new Template('
                        • #{choice}
                        • '); - this.choice_noclose_temp = new Template('
                        • #{choice}
                        • '); - return this.no_results_temp = new Template('
                        • ' + this.results_none_found + ' "#{terms}"
                        • '); - }; - - Chosen.prototype.set_up_html = function() { - var base_template, container_props, dd_top, dd_width, sf_width; - this.container_id = this.form_field.identify().replace(/[^\w]/g, '_') + "_chzn"; - this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth(); - container_props = { - 'id': this.container_id, - 'class': "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''), - 'style': 'width: ' + this.f_width + 'px' - }; - base_template = this.is_multiple ? new Element('div', container_props).update(this.multi_temp.evaluate({ - "default": this.default_text - })) : new Element('div', container_props).update(this.single_temp.evaluate({ - "default": this.default_text - })); - this.form_field.hide().insert({ - after: base_template - }); - this.container = $(this.container_id); - this.container.addClassName("chzn-container-" + (this.is_multiple ? "multi" : "single")); - this.dropdown = this.container.down('div.chzn-drop'); - dd_top = this.container.getHeight(); - dd_width = this.f_width - get_side_border_padding(this.dropdown); - this.dropdown.setStyle({ - "width": dd_width + "px", - "top": dd_top + "px" - }); - this.search_field = this.container.down('input'); - this.search_results = this.container.down('ul.chzn-results'); - this.search_field_scale(); - this.search_no_results = this.container.down('li.no-results'); - if (this.is_multiple) { - this.search_choices = this.container.down('ul.chzn-choices'); - this.search_container = this.container.down('li.search-field'); - } else { - this.search_container = this.container.down('div.chzn-search'); - this.selected_item = this.container.down('.chzn-single'); - sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field); - this.search_field.setStyle({ - "width": sf_width + "px" - }); - } - this.results_build(); - this.set_tab_index(); - return this.form_field.fire("liszt:ready", { - chosen: this - }); - }; - - Chosen.prototype.register_observers = function() { - var _this = this; - this.container.observe("mousedown", function(evt) { - return _this.container_mousedown(evt); - }); - this.container.observe("mouseup", function(evt) { - return _this.container_mouseup(evt); - }); - this.container.observe("mouseenter", function(evt) { - return _this.mouse_enter(evt); - }); - this.container.observe("mouseleave", function(evt) { - return _this.mouse_leave(evt); - }); - this.search_results.observe("mouseup", function(evt) { - return _this.search_results_mouseup(evt); - }); - this.search_results.observe("mouseover", function(evt) { - return _this.search_results_mouseover(evt); - }); - this.search_results.observe("mouseout", function(evt) { - return _this.search_results_mouseout(evt); - }); - this.form_field.observe("liszt:updated", function(evt) { - return _this.results_update_field(evt); - }); - this.form_field.observe("liszt:activate", function(evt) { - return _this.activate_field(evt); - }); - this.form_field.observe("liszt:open", function(evt) { - return _this.container_mousedown(evt); - }); - this.search_field.observe("blur", function(evt) { - return _this.input_blur(evt); - }); - this.search_field.observe("keyup", function(evt) { - return _this.keyup_checker(evt); - }); - this.search_field.observe("keydown", function(evt) { - return _this.keydown_checker(evt); - }); - this.search_field.observe("focus", function(evt) { - return _this.input_focus(evt); - }); - if (this.is_multiple) { - return this.search_choices.observe("click", function(evt) { - return _this.choices_click(evt); - }); - } else { - return this.container.observe("click", function(evt) { - return evt.preventDefault(); - }); - } - }; - - Chosen.prototype.search_field_disabled = function() { - this.is_disabled = this.form_field.disabled; - if (this.is_disabled) { - this.container.addClassName('chzn-disabled'); - this.search_field.disabled = true; - if (!this.is_multiple) { - this.selected_item.stopObserving("focus", this.activate_action); - } - return this.close_field(); - } else { - this.container.removeClassName('chzn-disabled'); - this.search_field.disabled = false; - if (!this.is_multiple) { - return this.selected_item.observe("focus", this.activate_action); - } - } - }; - - Chosen.prototype.container_mousedown = function(evt) { - var target_closelink; - if (!this.is_disabled) { - target_closelink = evt != null ? evt.target.hasClassName("search-choice-close") : false; - if (evt && evt.type === "mousedown" && !this.results_showing) evt.stop(); - if (!this.pending_destroy_click && !target_closelink) { - if (!this.active_field) { - if (this.is_multiple) this.search_field.clear(); - document.observe("click", this.click_test_action); - this.results_show(); - } else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chzn-single"))) { - this.results_toggle(); - } - return this.activate_field(); - } else { - return this.pending_destroy_click = false; - } - } - }; - - Chosen.prototype.container_mouseup = function(evt) { - if (evt.target.nodeName === "ABBR" && !this.is_disabled) { - return this.results_reset(evt); - } - }; - - Chosen.prototype.blur_test = function(evt) { - if (!this.active_field && this.container.hasClassName("chzn-container-active")) { - return this.close_field(); - } - }; - - Chosen.prototype.close_field = function() { - document.stopObserving("click", this.click_test_action); - this.active_field = false; - this.results_hide(); - this.container.removeClassName("chzn-container-active"); - this.winnow_results_clear(); - this.clear_backstroke(); - this.show_search_field_default(); - return this.search_field_scale(); - }; - - Chosen.prototype.activate_field = function() { - this.container.addClassName("chzn-container-active"); - this.active_field = true; - this.search_field.value = this.search_field.value; - return this.search_field.focus(); - }; - - Chosen.prototype.test_active_click = function(evt) { - if (evt.target.up('#' + this.container_id)) { - return this.active_field = true; - } else { - return this.close_field(); - } - }; - - Chosen.prototype.results_build = function() { - var content, data, _i, _len, _ref; - this.parsing = true; - this.results_data = root.SelectParser.select_to_array(this.form_field); - if (this.is_multiple && this.choices > 0) { - this.search_choices.select("li.search-choice").invoke("remove"); - this.choices = 0; - } else if (!this.is_multiple) { - this.selected_item.addClassName("chzn-default").down("span").update(this.default_text); - if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) { - this.container.addClassName("chzn-container-single-nosearch"); - } else { - this.container.removeClassName("chzn-container-single-nosearch"); - } - } - content = ''; - _ref = this.results_data; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - data = _ref[_i]; - if (data.group) { - content += this.result_add_group(data); - } else if (!data.empty) { - content += this.result_add_option(data); - if (data.selected && this.is_multiple) { - this.choice_build(data); - } else if (data.selected && !this.is_multiple) { - this.selected_item.removeClassName("chzn-default").down("span").update(data.html); - if (this.allow_single_deselect) this.single_deselect_control_build(); - } - } - } - this.search_field_disabled(); - this.show_search_field_default(); - this.search_field_scale(); - this.search_results.update(content); - return this.parsing = false; - }; - - Chosen.prototype.result_add_group = function(group) { - if (!group.disabled) { - group.dom_id = this.container_id + "_g_" + group.array_index; - return '
                        • ' + group.label.escapeHTML() + '
                        • '; - } else { - return ""; - } - }; - - Chosen.prototype.result_do_highlight = function(el) { - var high_bottom, high_top, maxHeight, visible_bottom, visible_top; - this.result_clear_highlight(); - this.result_highlight = el; - this.result_highlight.addClassName("highlighted"); - maxHeight = parseInt(this.search_results.getStyle('maxHeight'), 10); - visible_top = this.search_results.scrollTop; - visible_bottom = maxHeight + visible_top; - high_top = this.result_highlight.positionedOffset().top; - high_bottom = high_top + this.result_highlight.getHeight(); - if (high_bottom >= visible_bottom) { - return this.search_results.scrollTop = (high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0; - } else if (high_top < visible_top) { - return this.search_results.scrollTop = high_top; - } - }; - - Chosen.prototype.result_clear_highlight = function() { - if (this.result_highlight) { - this.result_highlight.removeClassName('highlighted'); - } - return this.result_highlight = null; - }; - - Chosen.prototype.results_show = function() { - var dd_top; - if (!this.is_multiple) { - this.selected_item.addClassName('chzn-single-with-drop'); - if (this.result_single_selected) { - this.result_do_highlight(this.result_single_selected); - } - } else if (this.max_selected_options <= this.choices) { - this.form_field.fire("liszt:maxselected", { - chosen: this - }); - return false; - } - dd_top = this.is_multiple ? this.container.getHeight() : this.container.getHeight() - 1; - this.form_field.fire("liszt:showing_dropdown", { - chosen: this - }); - this.dropdown.setStyle({ - "top": dd_top + "px", - "left": 0 - }); - this.results_showing = true; - this.search_field.focus(); - this.search_field.value = this.search_field.value; - return this.winnow_results(); - }; - - Chosen.prototype.results_hide = function() { - if (!this.is_multiple) { - this.selected_item.removeClassName('chzn-single-with-drop'); - } - this.result_clear_highlight(); - this.form_field.fire("liszt:hiding_dropdown", { - chosen: this - }); - this.dropdown.setStyle({ - "left": "-9000px" - }); - return this.results_showing = false; - }; - - Chosen.prototype.set_tab_index = function(el) { - var ti; - if (this.form_field.tabIndex) { - ti = this.form_field.tabIndex; - this.form_field.tabIndex = -1; - return this.search_field.tabIndex = ti; - } - }; - - Chosen.prototype.show_search_field_default = function() { - if (this.is_multiple && this.choices < 1 && !this.active_field) { - this.search_field.value = this.default_text; - return this.search_field.addClassName("default"); - } else { - this.search_field.value = ""; - return this.search_field.removeClassName("default"); - } - }; - - Chosen.prototype.search_results_mouseup = function(evt) { - var target; - target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result"); - if (target) { - this.result_highlight = target; - this.result_select(evt); - return this.search_field.focus(); - } - }; - - Chosen.prototype.search_results_mouseover = function(evt) { - var target; - target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result"); - if (target) return this.result_do_highlight(target); - }; - - Chosen.prototype.search_results_mouseout = function(evt) { - if (evt.target.hasClassName('active-result') || evt.target.up('.active-result')) { - return this.result_clear_highlight(); - } - }; - - Chosen.prototype.choices_click = function(evt) { - evt.preventDefault(); - if (this.active_field && !(evt.target.hasClassName('search-choice') || evt.target.up('.search-choice')) && !this.results_showing) { - return this.results_show(); - } - }; - - Chosen.prototype.choice_build = function(item) { - var choice_id, link, - _this = this; - if (this.is_multiple && this.max_selected_options <= this.choices) { - this.form_field.fire("liszt:maxselected", { - chosen: this - }); - return false; - } - choice_id = this.container_id + "_c_" + item.array_index; - this.choices += 1; - this.search_container.insert({ - before: (item.disabled ? this.choice_noclose_temp : this.choice_temp).evaluate({ - id: choice_id, - choice: item.html, - position: item.array_index - }) - }); - if (!item.disabled) { - link = $(choice_id).down('a'); - return link.observe("click", function(evt) { - return _this.choice_destroy_link_click(evt); - }); - } - }; - - Chosen.prototype.choice_destroy_link_click = function(evt) { - evt.preventDefault(); - if (!this.is_disabled) { - this.pending_destroy_click = true; - return this.choice_destroy(evt.target); - } - }; - - Chosen.prototype.choice_destroy = function(link) { - if (this.result_deselect(link.readAttribute("rel"))) { - this.choices -= 1; - this.show_search_field_default(); - if (this.is_multiple && this.choices > 0 && this.search_field.value.length < 1) { - this.results_hide(); - } - return link.up('li').remove(); - } - }; - - Chosen.prototype.results_reset = function() { - this.form_field.options[0].selected = true; - this.selected_item.down("span").update(this.default_text); - if (!this.is_multiple) this.selected_item.addClassName("chzn-default"); - this.show_search_field_default(); - this.results_reset_cleanup(); - if (typeof Event.simulate === 'function') this.form_field.simulate("change"); - if (this.active_field) return this.results_hide(); - }; - - Chosen.prototype.results_reset_cleanup = function() { - var deselect_trigger; - this.current_value = this.form_field.value; - deselect_trigger = this.selected_item.down("abbr"); - if (deselect_trigger) return deselect_trigger.remove(); - }; - - Chosen.prototype.result_select = function(evt) { - var high, item, position; - if (this.result_highlight) { - high = this.result_highlight; - this.result_clear_highlight(); - if (this.is_multiple) { - this.result_deactivate(high); - } else { - this.search_results.descendants(".result-selected").invoke("removeClassName", "result-selected"); - this.selected_item.removeClassName("chzn-default"); - this.result_single_selected = high; - } - high.addClassName("result-selected"); - position = high.id.substr(high.id.lastIndexOf("_") + 1); - item = this.results_data[position]; - item.selected = true; - this.form_field.options[item.options_index].selected = true; - if (this.is_multiple) { - this.choice_build(item); - } else { - this.selected_item.down("span").update(item.html); - if (this.allow_single_deselect) this.single_deselect_control_build(); - } - if (!(evt.metaKey && this.is_multiple)) this.results_hide(); - this.search_field.value = ""; - if (typeof Event.simulate === 'function' && (this.is_multiple || this.form_field.value !== this.current_value)) { - this.form_field.simulate("change"); - } - this.current_value = this.form_field.value; - return this.search_field_scale(); - } - }; - - Chosen.prototype.result_activate = function(el) { - return el.addClassName("active-result"); - }; - - Chosen.prototype.result_deactivate = function(el) { - return el.removeClassName("active-result"); - }; - - Chosen.prototype.result_deselect = function(pos) { - var result, result_data; - result_data = this.results_data[pos]; - if (!this.form_field.options[result_data.options_index].disabled) { - result_data.selected = false; - this.form_field.options[result_data.options_index].selected = false; - result = $(this.container_id + "_o_" + pos); - result.removeClassName("result-selected").addClassName("active-result").show(); - this.result_clear_highlight(); - this.winnow_results(); - if (typeof Event.simulate === 'function') { - this.form_field.simulate("change"); - } - this.search_field_scale(); - return true; - } else { - return false; - } - }; - - Chosen.prototype.single_deselect_control_build = function() { - if (this.allow_single_deselect && !this.selected_item.down("abbr")) { - return this.selected_item.down("span").insert({ - after: "" - }); - } - }; - - Chosen.prototype.winnow_results = function() { - var found, option, part, parts, regex, regexAnchor, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref; - this.no_results_clear(); - results = 0; - searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip().escapeHTML(); - regexAnchor = this.search_contains ? "" : "^"; - regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); - zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); - _ref = this.results_data; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - option = _ref[_i]; - if (!option.disabled && !option.empty) { - if (option.group) { - $(option.dom_id).hide(); - } else if (!(this.is_multiple && option.selected)) { - found = false; - result_id = option.dom_id; - if (regex.test(option.html)) { - found = true; - results += 1; - } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) { - parts = option.html.replace(/\[|\]/g, "").split(" "); - if (parts.length) { - for (_j = 0, _len2 = parts.length; _j < _len2; _j++) { - part = parts[_j]; - if (regex.test(part)) { - found = true; - results += 1; - } - } - } - } - if (found) { - if (searchText.length) { - startpos = option.html.search(zregex); - text = option.html.substr(0, startpos + searchText.length) + '
                          ' + option.html.substr(startpos + searchText.length); - text = text.substr(0, startpos) + '' + text.substr(startpos); - } else { - text = option.html; - } - if ($(result_id).innerHTML !== text) $(result_id).update(text); - this.result_activate($(result_id)); - if (option.group_array_index != null) { - $(this.results_data[option.group_array_index].dom_id).setStyle({ - display: 'list-item' - }); - } - } else { - if ($(result_id) === this.result_highlight) { - this.result_clear_highlight(); - } - this.result_deactivate($(result_id)); - } - } - } - } - if (results < 1 && searchText.length) { - return this.no_results(searchText); - } else { - return this.winnow_results_set_highlight(); - } - }; - - Chosen.prototype.winnow_results_clear = function() { - var li, lis, _i, _len, _results; - this.search_field.clear(); - lis = this.search_results.select("li"); - _results = []; - for (_i = 0, _len = lis.length; _i < _len; _i++) { - li = lis[_i]; - if (li.hasClassName("group-result")) { - _results.push(li.show()); - } else if (!this.is_multiple || !li.hasClassName("result-selected")) { - _results.push(this.result_activate(li)); - } else { - _results.push(void 0); - } - } - return _results; - }; - - Chosen.prototype.winnow_results_set_highlight = function() { - var do_high; - if (!this.result_highlight) { - if (!this.is_multiple) { - do_high = this.search_results.down(".result-selected.active-result"); - } - if (!(do_high != null)) { - do_high = this.search_results.down(".active-result"); - } - if (do_high != null) return this.result_do_highlight(do_high); - } - }; - - Chosen.prototype.no_results = function(terms) { - return this.search_results.insert(this.no_results_temp.evaluate({ - terms: terms - })); - }; - - Chosen.prototype.no_results_clear = function() { - var nr, _results; - nr = null; - _results = []; - while (nr = this.search_results.down(".no-results")) { - _results.push(nr.remove()); - } - return _results; - }; - - Chosen.prototype.keydown_arrow = function() { - var actives, nexts, sibs; - actives = this.search_results.select("li.active-result"); - if (actives.length) { - if (!this.result_highlight) { - this.result_do_highlight(actives.first()); - } else if (this.results_showing) { - sibs = this.result_highlight.nextSiblings(); - nexts = sibs.intersect(actives); - if (nexts.length) this.result_do_highlight(nexts.first()); - } - if (!this.results_showing) return this.results_show(); - } - }; - - Chosen.prototype.keyup_arrow = function() { - var actives, prevs, sibs; - if (!this.results_showing && !this.is_multiple) { - return this.results_show(); - } else if (this.result_highlight) { - sibs = this.result_highlight.previousSiblings(); - actives = this.search_results.select("li.active-result"); - prevs = sibs.intersect(actives); - if (prevs.length) { - return this.result_do_highlight(prevs.first()); - } else { - if (this.choices > 0) this.results_hide(); - return this.result_clear_highlight(); - } - } - }; - - Chosen.prototype.keydown_backstroke = function() { - var next_available_destroy; - if (this.pending_backstroke) { - this.choice_destroy(this.pending_backstroke.down("a")); - return this.clear_backstroke(); - } else { - next_available_destroy = this.search_container.siblings().last(); - if (next_available_destroy && next_available_destroy.hasClassName("search-choice") && !next_available_destroy.hasClassName("search-choice-disabled")) { - this.pending_backstroke = next_available_destroy; - if (this.pending_backstroke) { - this.pending_backstroke.addClassName("search-choice-focus"); - } - if (this.single_backstroke_delete) { - return this.keydown_backstroke(); - } else { - return this.pending_backstroke.addClassName("search-choice-focus"); - } - } - } - }; - - Chosen.prototype.clear_backstroke = function() { - if (this.pending_backstroke) { - this.pending_backstroke.removeClassName("search-choice-focus"); - } - return this.pending_backstroke = null; - }; - - Chosen.prototype.keydown_checker = function(evt) { - var stroke, _ref; - stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; - this.search_field_scale(); - if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke(); - switch (stroke) { - case 8: - this.backstroke_length = this.search_field.value.length; - break; - case 9: - if (this.results_showing && !this.is_multiple) this.result_select(evt); - this.mouse_on_container = false; - break; - case 13: - evt.preventDefault(); - break; - case 38: - evt.preventDefault(); - this.keyup_arrow(); - break; - case 40: - this.keydown_arrow(); - break; - } - }; - - Chosen.prototype.search_field_scale = function() { - var dd_top, div, h, style, style_block, styles, w, _i, _len; - if (this.is_multiple) { - h = 0; - w = 0; - style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"; - styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing']; - for (_i = 0, _len = styles.length; _i < _len; _i++) { - style = styles[_i]; - style_block += style + ":" + this.search_field.getStyle(style) + ";"; - } - div = new Element('div', { - 'style': style_block - }).update(this.search_field.value.escapeHTML()); - document.body.appendChild(div); - w = Element.measure(div, 'width') + 25; - div.remove(); - if (w > this.f_width - 10) w = this.f_width - 10; - this.search_field.setStyle({ - 'width': w + 'px' - }); - dd_top = this.container.getHeight(); - return this.dropdown.setStyle({ - "top": dd_top + "px" - }); - } - }; - - return Chosen; - - })(AbstractChosen); - - root.Chosen = Chosen; - - if (Prototype.Browser.IE) { - if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { - Prototype.BrowserFeatures['Version'] = new Number(RegExp.$1); - } - } - - get_side_border_padding = function(elmt) { - var layout, side_border_padding; - layout = new Element.Layout(elmt); - return side_border_padding = layout.get("border-left") + layout.get("border-right") + layout.get("padding-left") + layout.get("padding-right"); - }; - - root.get_side_border_padding = get_side_border_padding; - -}).call(this); diff --git a/phpgwapi/js/jquery/chosen/chosen.proto.min.js b/phpgwapi/js/jquery/chosen/chosen.proto.min.js deleted file mode 100644 index 2fb90cd3ab..0000000000 --- a/phpgwapi/js/jquery/chosen/chosen.proto.min.js +++ /dev/null @@ -1,10 +0,0 @@ -// Chosen, a Select Box Enhancer for jQuery and Protoype -// by Patrick Filler for Harvest, http://getharvest.com -// -// Version 0.9.8 -// Full source at https://github.com/harvesthq/chosen -// Copyright (c) 2011 Harvest http://getharvest.com - -// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md -// This file is generated by `cake build`, do not edit it by hand. -(function(){var SelectParser;SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(child){return child.nodeName.toUpperCase()==="OPTGROUP"?this.add_group(child):this.add_option(child)},SelectParser.prototype.add_group=function(group){var group_position,option,_i,_len,_ref,_results;group_position=this.parsed.length,this.parsed.push({array_index:group_position,group:!0,label:group.label,children:0,disabled:group.disabled}),_ref=group.childNodes,_results=[];for(_i=0,_len=_ref.length;_i<_len;_i++)option=_ref[_i],_results.push(this.add_option(option,group_position,group.disabled));return _results},SelectParser.prototype.add_option=function(option,group_position,group_disabled){if(option.nodeName.toUpperCase()==="OPTION")return option.text!==""?(group_position!=null&&(this.parsed[group_position].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:option.value,text:option.text,html:option.innerHTML,selected:option.selected,disabled:group_disabled===!0?group_disabled:option.disabled,group_array_index:group_position,classes:option.className,style:option.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},SelectParser}(),SelectParser.select_to_array=function(select){var child,parser,_i,_len,_ref;parser=new SelectParser,_ref=select.childNodes;for(_i=0,_len=_ref.length;_i<_len;_i++)child=_ref[_i],parser.add_node(child);return parser.parsed},this.SelectParser=SelectParser}).call(this),function(){var AbstractChosen,root;root=this,AbstractChosen=function(){function AbstractChosen(form_field,options){this.form_field=form_field,this.options=options!=null?options:{},this.set_default_values(),this.is_multiple=this.form_field.multiple,this.set_default_text(),this.setup(),this.set_up_html(),this.register_observers(),this.finish_setup()}return AbstractChosen.prototype.set_default_values=function(){var _this=this;return this.click_test_action=function(evt){return _this.test_active_click(evt)},this.activate_action=function(evt){return _this.activate_field(evt)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.allow_single_deselect=this.options.allow_single_deselect!=null&&this.form_field.options[0]!=null&&this.form_field.options[0].text===""?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity},AbstractChosen.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||"No results match"},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(evt){var _this=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return _this.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(evt){var _this=this;if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(){return _this.blur_test()},100)},AbstractChosen.prototype.result_add_option=function(option){var classes,style;return option.disabled?"":(option.dom_id=this.container_id+"_o_"+option.array_index,classes=option.selected&&this.is_multiple?[]:["active-result"],option.selected&&classes.push("result-selected"),option.group_array_index!=null&&classes.push("group-option"),option.classes!==""&&classes.push(option.classes),style=option.style.cssText!==""?' style="'+option.style+'"':"",'
                        • "+option.html+"
                        • ")},AbstractChosen.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(evt){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.keyup_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale();switch(stroke){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:evt.preventDefault();if(this.results_showing)return this.result_select(evt);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.generate_field_id=function(){var new_id;return new_id=this.generate_random_id(),this.form_field.id=new_id,new_id},AbstractChosen.prototype.generate_random_char=function(){var chars,newchar,rand;return chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",rand=Math.floor(Math.random()*chars.length),newchar=chars.substring(rand,rand+1)},AbstractChosen}(),root.AbstractChosen=AbstractChosen}.call(this),function(){var Chosen,get_side_border_padding,root,__hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)__hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child};root=this,Chosen=function(_super){function Chosen(){Chosen.__super__.constructor.apply(this,arguments)}return __extends(Chosen,_super),Chosen.prototype.setup=function(){return this.current_value=this.form_field.value,this.is_rtl=this.form_field.hasClassName("chzn-rtl")},Chosen.prototype.finish_setup=function(){return this.form_field.addClassName("chzn-done")},Chosen.prototype.set_default_values=function(){return Chosen.__super__.set_default_values.call(this),this.single_temp=new Template('#{default}
                            '),this.multi_temp=new Template('
                              '),this.choice_temp=new Template('
                            • #{choice}
                            • '),this.choice_noclose_temp=new Template('
                            • #{choice}
                            • '),this.no_results_temp=new Template('
                            • '+this.results_none_found+' "#{terms}"
                            • ')},Chosen.prototype.set_up_html=function(){var base_template,container_props,dd_top,dd_width,sf_width;return this.container_id=this.form_field.identify().replace(/[^\w]/g,"_")+"_chzn",this.f_width=this.form_field.getStyle("width")?parseInt(this.form_field.getStyle("width"),10):this.form_field.getWidth(),container_props={id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px"},base_template=this.is_multiple?(new Element("div",container_props)).update(this.multi_temp.evaluate({"default":this.default_text})):(new Element("div",container_props)).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:base_template}),this.container=$(this.container_id),this.container.addClassName("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.down("div.chzn-drop"),dd_top=this.container.getHeight(),dd_width=this.f_width-get_side_border_padding(this.dropdown),this.dropdown.setStyle({width:dd_width+"px",top:dd_top+"px"}),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chzn-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chzn-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chzn-search"),this.selected_item=this.container.down(".chzn-single"),sf_width=dd_width-get_side_border_padding(this.search_container)-get_side_border_padding(this.search_field),this.search_field.setStyle({width:sf_width+"px"})),this.results_build(),this.set_tab_index(),this.form_field.fire("liszt:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var _this=this;return this.container.observe("mousedown",function(evt){return _this.container_mousedown(evt)}),this.container.observe("mouseup",function(evt){return _this.container_mouseup(evt)}),this.container.observe("mouseenter",function(evt){return _this.mouse_enter(evt)}),this.container.observe("mouseleave",function(evt){return _this.mouse_leave(evt)}),this.search_results.observe("mouseup",function(evt){return _this.search_results_mouseup(evt)}),this.search_results.observe("mouseover",function(evt){return _this.search_results_mouseover(evt)}),this.search_results.observe("mouseout",function(evt){return _this.search_results_mouseout(evt)}),this.form_field.observe("liszt:updated",function(evt){return _this.results_update_field(evt)}),this.form_field.observe("liszt:activate",function(evt){return _this.activate_field(evt)}),this.form_field.observe("liszt:open",function(evt){return _this.container_mousedown(evt)}),this.search_field.observe("blur",function(evt){return _this.input_blur(evt)}),this.search_field.observe("keyup",function(evt){return _this.keyup_checker(evt)}),this.search_field.observe("keydown",function(evt){return _this.keydown_checker(evt)}),this.search_field.observe("focus",function(evt){return _this.input_focus(evt)}),this.is_multiple?this.search_choices.observe("click",function(evt){return _this.choices_click(evt)}):this.container.observe("click",function(evt){return evt.preventDefault()})},Chosen.prototype.search_field_disabled=function(){this.is_disabled=this.form_field.disabled;if(this.is_disabled)return this.container.addClassName("chzn-disabled"),this.search_field.disabled=!0,this.is_multiple||this.selected_item.stopObserving("focus",this.activate_action),this.close_field();this.container.removeClassName("chzn-disabled"),this.search_field.disabled=!1;if(!this.is_multiple)return this.selected_item.observe("focus",this.activate_action)},Chosen.prototype.container_mousedown=function(evt){var target_closelink;if(!this.is_disabled)return target_closelink=evt!=null?evt.target.hasClassName("search-choice-close"):!1,evt&&evt.type==="mousedown"&&!this.results_showing&&evt.stop(),!this.pending_destroy_click&&!target_closelink?(this.active_field?!this.is_multiple&&evt&&(evt.target===this.selected_item||evt.target.up("a.chzn-single"))&&this.results_toggle():(this.is_multiple&&this.search_field.clear(),document.observe("click",this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},Chosen.prototype.container_mouseup=function(evt){if(evt.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(evt)},Chosen.prototype.blur_test=function(evt){if(!this.active_field&&this.container.hasClassName("chzn-container-active"))return this.close_field()},Chosen.prototype.close_field=function(){return document.stopObserving("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClassName("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClassName("chzn-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value,this.search_field.focus()},Chosen.prototype.test_active_click=function(evt){return evt.target.up("#"+this.container_id)?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){var content,data,_i,_len,_ref;this.parsing=!0,this.results_data=root.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.select("li.search-choice").invoke("remove"),this.choices=0):this.is_multiple||(this.selected_item.addClassName("chzn-default").down("span").update(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClassName("chzn-container-single-nosearch"):this.container.removeClassName("chzn-container-single-nosearch")),content="",_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++)data=_ref[_i],data.group?content+=this.result_add_group(data):data.empty||(content+=this.result_add_option(data),data.selected&&this.is_multiple?this.choice_build(data):data.selected&&!this.is_multiple&&(this.selected_item.removeClassName("chzn-default").down("span").update(data.html),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.update(content),this.parsing=!1},Chosen.prototype.result_add_group=function(group){return group.disabled?"":(group.dom_id=this.container_id+"_g_"+group.array_index,'
                            • '+group.label.escapeHTML()+"
                            • ")},Chosen.prototype.result_do_highlight=function(el){var high_bottom,high_top,maxHeight,visible_bottom,visible_top;this.result_clear_highlight(),this.result_highlight=el,this.result_highlight.addClassName("highlighted"),maxHeight=parseInt(this.search_results.getStyle("maxHeight"),10),visible_top=this.search_results.scrollTop,visible_bottom=maxHeight+visible_top,high_top=this.result_highlight.positionedOffset().top,high_bottom=high_top+this.result_highlight.getHeight();if(high_bottom>=visible_bottom)return this.search_results.scrollTop=high_bottom-maxHeight>0?high_bottom-maxHeight:0;if(high_top0&&this.search_field.value.length<1&&this.results_hide(),link.up("li").remove()},Chosen.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.down("span").update(this.default_text),this.is_multiple||this.selected_item.addClassName("chzn-default"),this.show_search_field_default(),this.results_reset_cleanup(),typeof Event.simulate=="function"&&this.form_field.simulate("change");if(this.active_field)return this.results_hide()},Chosen.prototype.results_reset_cleanup=function(){var deselect_trigger;this.current_value=this.form_field.value,deselect_trigger=this.selected_item.down("abbr");if(deselect_trigger)return deselect_trigger.remove()},Chosen.prototype.result_select=function(evt){var high,item,position;if(this.result_highlight)return high=this.result_highlight,this.result_clear_highlight(),this.is_multiple?this.result_deactivate(high):(this.search_results.descendants(".result-selected").invoke("removeClassName","result-selected"),this.selected_item.removeClassName("chzn-default"),this.result_single_selected=high),high.addClassName("result-selected"),position=high.id.substr(high.id.lastIndexOf("_")+1),item=this.results_data[position],item.selected=!0,this.form_field.options[item.options_index].selected=!0,this.is_multiple?this.choice_build(item):(this.selected_item.down("span").update(item.html),this.allow_single_deselect&&this.single_deselect_control_build()),(!evt.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.value="",typeof Event.simulate=="function"&&(this.is_multiple||this.form_field.value!==this.current_value)&&this.form_field.simulate("change"),this.current_value=this.form_field.value,this.search_field_scale()},Chosen.prototype.result_activate=function(el){return el.addClassName("active-result")},Chosen.prototype.result_deactivate=function(el){return el.removeClassName("active-result")},Chosen.prototype.result_deselect=function(pos){var result,result_data;return result_data=this.results_data[pos],this.form_field.options[result_data.options_index].disabled?!1:(result_data.selected=!1,this.form_field.options[result_data.options_index].selected=!1,result=$(this.container_id+"_o_"+pos),result.removeClassName("result-selected").addClassName("active-result").show(),this.result_clear_highlight(),this.winnow_results(),typeof Event.simulate=="function"&&this.form_field.simulate("change"),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&!this.selected_item.down("abbr"))return this.selected_item.down("span").insert({after:''})},Chosen.prototype.winnow_results=function(){var found,option,part,parts,regex,regexAnchor,result_id,results,searchText,startpos,text,zregex,_i,_j,_len,_len2,_ref;this.no_results_clear(),results=0,searchText=this.search_field.value===this.default_text?"":this.search_field.value.strip().escapeHTML(),regexAnchor=this.search_contains?"":"^",regex=new RegExp(regexAnchor+searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),zregex=new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++){option=_ref[_i];if(!option.disabled&&!option.empty)if(option.group)$(option.dom_id).hide();else if(!this.is_multiple||!option.selected){found=!1,result_id=option.dom_id;if(regex.test(option.html))found=!0,results+=1;else if(option.html.indexOf(" ")>=0||option.html.indexOf("[")===0){parts=option.html.replace(/\[|\]/g,"").split(" ");if(parts.length)for(_j=0,_len2=parts.length;_j<_len2;_j++)part=parts[_j],regex.test(part)&&(found=!0,results+=1)}found?(searchText.length?(startpos=option.html.search(zregex),text=option.html.substr(0,startpos+searchText.length)+"
                              "+option.html.substr(startpos+searchText.length),text=text.substr(0,startpos)+""+text.substr(startpos)):text=option.html,$(result_id).innerHTML!==text&&$(result_id).update(text),this.result_activate($(result_id)),option.group_array_index!=null&&$(this.results_data[option.group_array_index].dom_id).setStyle({display:"list-item"})):($(result_id)===this.result_highlight&&this.result_clear_highlight(),this.result_deactivate($(result_id)))}}return results<1&&searchText.length?this.no_results(searchText):this.winnow_results_set_highlight()},Chosen.prototype.winnow_results_clear=function(){var li,lis,_i,_len,_results;this.search_field.clear(),lis=this.search_results.select("li"),_results=[];for(_i=0,_len=lis.length;_i<_len;_i++)li=lis[_i],li.hasClassName("group-result")?_results.push(li.show()):!this.is_multiple||!li.hasClassName("result-selected")?_results.push(this.result_activate(li)):_results.push(void 0);return _results},Chosen.prototype.winnow_results_set_highlight=function(){var do_high;if(!this.result_highlight){this.is_multiple||(do_high=this.search_results.down(".result-selected.active-result")),do_high==null&&(do_high=this.search_results.down(".active-result"));if(do_high!=null)return this.result_do_highlight(do_high)}},Chosen.prototype.no_results=function(terms){return this.search_results.insert(this.no_results_temp.evaluate({terms:terms}))},Chosen.prototype.no_results_clear=function(){var nr,_results;nr=null,_results=[];while(nr=this.search_results.down(".no-results"))_results.push(nr.remove());return _results},Chosen.prototype.keydown_arrow=function(){var actives,nexts,sibs;actives=this.search_results.select("li.active-result");if(actives.length){this.result_highlight?this.results_showing&&(sibs=this.result_highlight.nextSiblings(),nexts=sibs.intersect(actives),nexts.length&&this.result_do_highlight(nexts.first())):this.result_do_highlight(actives.first());if(!this.results_showing)return this.results_show()}},Chosen.prototype.keyup_arrow=function(){var actives,prevs,sibs;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return sibs=this.result_highlight.previousSiblings(),actives=this.search_results.select("li.active-result"),prevs=sibs.intersect(actives),prevs.length?this.result_do_highlight(prevs.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},Chosen.prototype.keydown_backstroke=function(){var next_available_destroy;if(this.pending_backstroke)return this.choice_destroy(this.pending_backstroke.down("a")),this.clear_backstroke();next_available_destroy=this.search_container.siblings().last();if(next_available_destroy&&next_available_destroy.hasClassName("search-choice")&&!next_available_destroy.hasClassName("search-choice-disabled"))return this.pending_backstroke=next_available_destroy,this.pending_backstroke&&this.pending_backstroke.addClassName("search-choice-focus"),this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClassName("search-choice-focus")},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale(),stroke!==8&&this.pending_backstroke&&this.clear_backstroke();switch(stroke){case 8:this.backstroke_length=this.search_field.value.length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(evt),this.mouse_on_container=!1;break;case 13:evt.preventDefault();break;case 38:evt.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var dd_top,div,h,style,style_block,styles,w,_i,_len;if(this.is_multiple){h=0,w=0,style_block="position:absolute; left: -1000px; top: -1000px; display:none;",styles=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(_i=0,_len=styles.length;_i<_len;_i++)style=styles[_i],style_block+=style+":"+this.search_field.getStyle(style)+";";return div=(new Element("div",{style:style_block})).update(this.search_field.value.escapeHTML()),document.body.appendChild(div),w=Element.measure(div,"width")+25,div.remove(),w>this.f_width-10&&(w=this.f_width-10),this.search_field.setStyle({width:w+"px"}),dd_top=this.container.getHeight(),this.dropdown.setStyle({top:dd_top+"px"})}},Chosen}(AbstractChosen),root.Chosen=Chosen,Prototype.Browser.IE&&/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&(Prototype.BrowserFeatures.Version=new Number(RegExp.$1)),get_side_border_padding=function(elmt){var layout,side_border_padding;return layout=new Element.Layout(elmt),side_border_padding=layout.get("border-left")+layout.get("border-right")+layout.get("padding-left")+layout.get("padding-right")},root.get_side_border_padding=get_side_border_padding}.call(this); \ No newline at end of file From a367693ac09c3f5fe9f954c10fa63bbc5e7bfd6b Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 13 Nov 2012 22:31:57 +0000 Subject: [PATCH 046/150] Fix CC line search display --- infolog/js/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infolog/js/edit.js b/infolog/js/edit.js index a5441a21e4..f8963287c8 100644 --- a/infolog/js/edit.js +++ b/infolog/js/edit.js @@ -8,7 +8,7 @@ function add_email_from_ab(ab_id,info_cc) if (!ab || !ab.value) { - jQuery("tr.hiddenRow").css("display", "block"); + jQuery("tr.hiddenRow").css("display", "table-row"); } else { From 4cb4835544e91858a34e8ef3ef0fe82741cb03d7 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 13 Nov 2012 23:12:27 +0000 Subject: [PATCH 047/150] Default vcard export charset to user preference --- addressbook/setup/importexport_default.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addressbook/setup/importexport_default.xml b/addressbook/setup/importexport_default.xml index 9c9a30cd55..82215338c3 100644 --- a/addressbook/setup/importexport_default.xml +++ b/addressbook/setup/importexport_default.xml @@ -27,7 +27,9 @@ Default - + + user + 2012-10-23 09:46:56 From ac67c9ed806eaa26c619e4eaf53a84112c405a81 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 14 Nov 2012 14:23:00 +0000 Subject: [PATCH 048/150] log sql by setting $this->debug = true, before calling so_sql::search() --- etemplate/inc/class.so_sql.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etemplate/inc/class.so_sql.inc.php b/etemplate/inc/class.so_sql.inc.php index 218c22facc..7a09d8927d 100644 --- a/etemplate/inc/class.so_sql.inc.php +++ b/etemplate/inc/class.so_sql.inc.php @@ -1033,6 +1033,7 @@ class so_sql } } $rs = $this->db->union($union,__LINE__,__FILE__,$order_by,$start,$num_rows); + if ($this->debug) error_log(__METHOD__."() ".$this->db->Query_ID->sql); $cols = $union_cols; $union = $union_cols = array(); @@ -1056,6 +1057,7 @@ class so_sql } $rs = $this->db->select($this->table_name,$mysql_calc_rows.$colums,$query,__LINE__,__FILE__, $start,$order_by,$this->app,$num_rows,$join); + if ($this->debug) error_log(__METHOD__."() ".$this->db->Query_ID->sql); $cols = $this->_get_columns($only_keys,$extra_cols); } if ((int) $this->debug >= 4) echo "

                              sql='{$this->db->Query_ID->sql}'

                              \n"; From 94f84ce2b78fd4b0295e3afbf55e37660c262775 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 14 Nov 2012 16:10:51 +0000 Subject: [PATCH 049/150] Default import vCard charset to user preference --- addressbook/setup/importexport_default.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addressbook/setup/importexport_default.xml b/addressbook/setup/importexport_default.xml index 82215338c3..85b9a977bc 100644 --- a/addressbook/setup/importexport_default.xml +++ b/addressbook/setup/importexport_default.xml @@ -15,9 +15,10 @@ Default
                              + user personal - 2012-10-23 09:46:56 + 2012-11-14 09:10:11 export-addressbook-vcard From a0a6e14154ecebdaeb3ea45c02605d17127bbc79 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 14 Nov 2012 16:25:21 +0000 Subject: [PATCH 050/150] Revert changes to delete view - exceptions no longer shown --- calendar/inc/class.calendar_so.inc.php | 30 ++---------- calendar/inc/class.calendar_uiforms.inc.php | 2 +- calendar/inc/class.calendar_uilist.inc.php | 51 +++------------------ calendar/js/app.js | 10 +--- 4 files changed, 13 insertions(+), 80 deletions(-) diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index 7954a921fb..5db9309297 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -487,11 +487,7 @@ class calendar_so $where['cal_public'] = 1; $where[] = "$this->user_table.cal_status NOT IN ('R','X')"; break; case 'deleted': - // Change source of recur date to get deleted recurrence exceptions - $cols = str_replace("{$this->user_table}.cal_recur_date","{$this->dates_table}.cal_start AS cal_recur_date",$cols); - $remove_rejected_by_user = false; - $where[] = "$this->user_table.cal_recur_date=0"; - $where[] = "($this->cal_table.cal_deleted IS NOT NULL OR (recur_exception=1 AND $this->user_table.cal_recur_date = 0))"; break; + $where[] = 'cal_deleted IS NOT NULL'; break; case 'unknown': $where[] = "$this->user_table.cal_status='U'"; break; case 'not-unknown': @@ -575,11 +571,6 @@ class calendar_so if ($params['enum_recuring']) // dates table join only needed to enum recuring events { $select['join'] = "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$select['join']; - // Add in deleted exceptions to recurring - if($filter == 'deleted') - { - $select['join'] .= "LEFT JOIN (SELECT egw_cal.cal_reference AS ref, egw_cal.cal_recurrence AS rec FROM $this->cal_table) AS cal_exception ON $this->cal_table.cal_id = cal_exception.ref AND $this->dates_table.cal_start = cal_exception.rec "; - } } $selects = array(); // we check if there are parts to use for the construction of our UNION query, @@ -592,10 +583,7 @@ class calendar_so $selects[count($selects)-1]['where'][] = $user_sql; if ($params['enum_recuring']) { - if($filter != 'deleted') - { - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; - } + $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; $selects[] = $select; $selects[count($selects)-1]['where'][] = $user_sql; $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; @@ -608,10 +596,7 @@ class calendar_so $selects[count($selects)-1]['where'][] = $owner_or; if ($params['enum_recuring']) { - if($filter != 'deleted') - { - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; - } + $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; $selects[] = $select; $selects[count($selects)-1]['where'][] = $owner_or; $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; @@ -624,10 +609,7 @@ class calendar_so $selects[] = $select; if ($params['enum_recuring']) { - if($filter != 'deleted') - { - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; - } + $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; $selects[] = $select; $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; } @@ -643,10 +625,6 @@ class calendar_so { $selects[$key]['cols'] = str_replace('cal_start','MIN(cal_start) AS cal_start',$selects[$key]['cols']); } - if($filter == 'deleted') - { - $selects[$key]['cols'] = str_replace("{$this->user_table}.cal_recur_date","{$this->dates_table}.cal_start AS cal_recur_date",$selects[$key]['cols']); - } } if (!isset($param['cols'])) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 5988ed7c8a..e14734efca 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -1519,7 +1519,7 @@ function replace_eTemplate_onsubmit() { $content['alarm'] = false; } - $content['msg'] = $msg ? $msg : $_GET['msg']; + $content['msg'] = $msg; if ($view) { diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index 695ed18c38..66b4ed9048 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -364,13 +364,6 @@ class calendar_uilist extends calendar_ui { $event['class'] .= 'rowDeleted '; } - // Disable delete for 'deleted' exceptions - deleting the exception - // would put it back, which you do from the series, not purge it - if($search_params['filter'] == 'deleted' && $event['recur_type']) - { - $event['class'] .= ' rowSeriesDeleted rowDeleted rowNoDelete'; - } - // Filemanager disabled for other applications $readonlys['filemanager['.$event['id'].']'] = !is_numeric($event['id']); @@ -585,12 +578,6 @@ class calendar_uilist extends calendar_ui } switch($action) { - case 'purgeseries': - // Delete an already deleted series - $recur_date = null; - // Make sure entire series is gone - $this->bo->delete($id, $recur_date,false,$skip_notification); - // fall through case 'delete': $action_msg = lang('deleted'); if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification)) @@ -604,28 +591,14 @@ class calendar_uilist extends calendar_ui break; case 'undelete': $action_msg = lang('recovered'); - if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT,$id)) + if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT,$id) && + is_array($event) && $event['deleted']) { - if(is_array($event) && $event['deleted']) + $event['deleted'] = null; + if($this->bo->save($event)) { - $event['deleted'] = null; - if($this->bo->save($event)) - { - $success++; - break; - } - } - // Undelete an exception by removing it - else if (is_array($event) && $event['recur_type']) - { - $original = $this->bo->read($id); - $key = array_search($recur_date, $original['recur_exception']); - if($key !== false) unset($original['recur_exception'][$key]); - if($key !== false && $this->bo->save($original)) - { - $success++; - break; - } + $success++; + break; } } $failed++; @@ -863,25 +836,15 @@ class calendar_uilist extends calendar_ui 'confirm_multiple' => 'Delete these entries', 'group' => $group, 'disableClass' => 'rowNoDelete', - 'hideOnDisabled' => true, ); // Add in deleted for admins if($GLOBALS['egw_info']['server']['calendar_delete_history']) { - $actions['purgeseries'] = array( - 'caption' => 'Delete series', - 'confirm' => 'Delete series', - 'icon' => 'delete', - 'group' => $group, - 'enableClass' => 'rowSeriesDeleted', - 'disableClass' => 'rowNoDelete', - 'hideOnDisabled' => true, - ); $actions['undelete'] = array( 'caption' => 'Un-delete', 'hint' => 'Recover this event', - 'icon' => 'revert', 'group' => $group, + 'enabled' => 'javaScript:nm_enableClass', 'enableClass' => 'rowDeleted', 'hideOnDisabled' => true, ); diff --git a/calendar/js/app.js b/calendar/js/app.js index 53872cc40b..d66702346d 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -53,19 +53,11 @@ function cal_open(_action, _senders) var id = _senders[0].id; var matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/); var backup = _action.data; - var row = _senders[0].iface.node; - - if (matches && !$j(row).hasClass("rowDeleted")) + if (matches) { edit_series(matches[1],matches[2]); return; } - else if (matches && $j(row).hasClass("rowDeleted") && _action.data.url) - { - // Trying to edit a deleted exception, use original event & add a message - _senders[0].id = matches[1]; - _action.data.url += '&msg='+encodeURIComponent(egw.lang('Editing series')); - } else if (matches = id.match(/^([a-z_-]+)([0-9]+)/i)) { var app = matches[1]; From 0f1b273cb197f57fee764c99d92ea5c24a05a00a Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 14 Nov 2012 18:00:02 +0000 Subject: [PATCH 051/150] - Add accessory of selectbox to move accessories between resources - Remove 'back' button, viewing accessories of a resource now uses nm filter entirely - Remove view, using read-only edit --- resources/inc/class.resources_bo.inc.php | 9 +- resources/inc/class.resources_ui.inc.php | 136 ++++-------------- resources/setup/etemplates.inc.php | 16 ++- resources/templates/default/edit.xet | 176 ++++++++++++++++++----- resources/templates/default/show.xet | 4 +- 5 files changed, 190 insertions(+), 151 deletions(-) diff --git a/resources/inc/class.resources_bo.inc.php b/resources/inc/class.resources_bo.inc.php index 5da06521e2..c9310a15f8 100755 --- a/resources/inc/class.resources_bo.inc.php +++ b/resources/inc/class.resources_bo.inc.php @@ -68,6 +68,7 @@ class resources_bo */ function get_rows($query,&$rows,&$readonlys) { + $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$query); if ($query['store_state']) // request to store state in session and filter in prefs? { egw_cache::setSession('resources',$query['store_state'],$query); @@ -106,7 +107,7 @@ class resources_bo $extra_cols[] = 'acc_count'; break; default: - $filter['accessory_of'] = $query['view_accs_of']; + $filter['accessory_of'] = $query['filter2']; } if ($query['filter']) @@ -164,7 +165,7 @@ class resources_bo $readonlys["delete[$resource[res_id]]"] = true; $resource['class'] .= 'no_delete '; } - if ((!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_ADD)) || $accessory_of != -1) + if ((!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_ADD)) || $resource['accessory_of'] != -1) { $readonlys["new_acc[$resource[res_id]]"] = true; $resource['class'] .= 'no_new_accessory '; @@ -438,6 +439,10 @@ class resources_bo if($options['start'] || $options['num_rows']) { $limit = array($options['start'], $options['num_rows']); } + if($options['accessory_of']) + { + $filter['accessory_of'] = $options['accessory_of']; + } $data = $this->so->search($criteria,$only_keys,$order_by='name',$extra_cols='',$wildcard='%',$empty,$op='OR',$limit,$filter); // maybe we need to check disponibility of the searched resources in the calendar if $pattern ['exec'] contains some extra args $show_conflict=False; diff --git a/resources/inc/class.resources_ui.inc.php b/resources/inc/class.resources_ui.inc.php index f527b754a0..585e911903 100755 --- a/resources/inc/class.resources_ui.inc.php +++ b/resources/inc/class.resources_ui.inc.php @@ -20,7 +20,6 @@ class resources_ui var $public_functions = array( 'index' => True, 'edit' => True, - 'show' => True, 'select' => True, 'writeLangFile' => True ); @@ -54,14 +53,6 @@ class resources_ui unset($sessiondata['rows']); $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata); - if (isset($content['back'])) - { - unset($sessiondata['view_accs_of']); - unset($sessiondata['no_filter']); - unset($sessiondata['filter2']); - $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata); - return $this->index(); - } if (isset($content['btn_delete_selected'])) { foreach($content['nm']['rows'] as $row) @@ -82,7 +73,7 @@ class resources_ui } if(isset($row['view_acc'])) { - $sessiondata['view_accs_of'] = array_search('pressed',$row['view_acc']); + $sessiondata['filter2'] = array_search('pressed',$row['view_acc']); $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata); return $this->index(); } @@ -143,7 +134,7 @@ class resources_ui } if($_GET['view_accs_of']) { - $content['nm']['view_accs_of'] = (int)$_GET['view_accs_of']; + $content['nm']['filter2'] = (int)$_GET['view_accs_of']; } $content['nm']['actions'] = $this->get_actions(); @@ -153,7 +144,6 @@ class resources_ui $no_button['add'] = true; } $no_button['back'] = true; - $no_button['add_sub'] = true; $GLOBALS['egw_info']['flags']['app_header'] = lang('resources'); $GLOBALS['egw_info']['flags']['java_script'] .= "\n"; - $GLOBALS['egw']->common->egw_exit(); - } - if(isset($content['btn_edit'])) - { - return $this->edit($content['res_id']); - } - - } - if (isset($_GET['res_id'])) $res_id = $_GET['res_id']; - - $content = array('res_id' => $res_id); - $content = $this->bo->read($res_id); - $content['gen_src_list'] = strpos($content['picture_src'],'.') !== false ? $content['picture_src'] : false; - $content['picture_src'] = strpos($content['picture_src'],'.') !== false ? 'gen_src' : $content['picture_src']; - $content['link_to'] = array( - 'to_id' => $res_id, - 'to_app' => 'resources' - ); - - $content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true); - $content['quantity'] = $content['quantity'] ? $content['quantity'] : 1; - $content['useable'] = $content['useable'] ? $content['useable'] : 1; - - $content['quantity'] = ($content['useable'] == $content['quantity']) ? $content['quantity'] : $content['quantity'].' ('.lang('useable').' '.$content['useable'].')'; - - //$sel_options['gen_src_list'] = $this->bo->get_genpicturelist(); - - $content['cat_name'] = $this->bo->acl->get_cat_name($content['cat_id']); - $content['cat_admin'] = $this->bo->acl->get_cat_admin($content['cat_id']); - -/* if($content['accessory_of'] > 0) - { - $catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']); - $sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]); - } -*/ - $content['description'] = chop($content['long_description']) ? $content['long_description'] : (chop($content['short_description']) ? $content['short_description'] : lang("no description available")); - $content['description'] = $content['description'] ? $content['description'] : lang('no description available'); - $content['link_to'] = array( - 'to_id' => $res_id, - 'to_app' => 'resources' - ); - $sel_options = array(); - $no_button = array( - 'btn_buy' => !$content['buyable'], - 'btn_book' => !$content['bookable'], - 'btn_calendar' => !$content['bookable'], - 'btn_edit' => !$this->bo->acl->is_permitted($content['cat_id'],EGW_ACL_EDIT), - 'btn_delete' => !$this->bo->acl->is_permitted($content['cat_id'],EGW_ACL_DELETE) - ); - $preserv = $content; - $this->tmpl->read('resources.showdetails'); - return $this->tmpl->exec('resources.resources_ui.show',$content,$sel_options,$no_button,$preserv,2); - + return $this->tmpl->exec('resources.resources_ui.edit',$content,$sel_options,$read_only,$preserv,2); } /** diff --git a/resources/setup/etemplates.inc.php b/resources/setup/etemplates.inc.php index 478fa3af5d..79793aa2f1 100644 --- a/resources/setup/etemplates.inc.php +++ b/resources/setup/etemplates.inc.php @@ -2,7 +2,7 @@ /** * EGroupware - eTemplates for Application resources * http://www.egroupware.org - * generated by soetemplate::dump4setup() 2012-11-06 16:10 + * generated by soetemplate::dump4setup() 2012-11-14 10:58 * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package resources @@ -20,6 +20,18 @@ $templ_data[] = array('name' => 'resources.admin','template' => '','lang' => '', $templ_data[] = array('name' => 'resources.edit','template' => '','lang' => '','group' => '0','version' => '1.5.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:1:{s:1:"A";s:3:"700";}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";}}i:2;a:1:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:5:{s:4:"type";s:4:"text";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";s:4:"help";s:16:"Name of resource";s:6:"needed";s:1:"1";}i:2;a:3:{s:4:"type";s:4:"text";s:5:"label";s:16:"Inventory number";s:4:"name";s:16:"inventory_number";}i:3;a:7:{s:4:"type";s:6:"select";s:5:"label";s:8:"Category";s:7:"no_lang";s:1:"1";s:4:"name";s:6:"cat_id";s:6:"needed";s:1:"1";s:4:"help";s:44:"Which category does this resource belong to?";s:5:"align";s:5:"right";}}}i:3;a:1:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:19:"resources.edit_tabs";}}i:4;a:1:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:22:"resources.edit_buttons";}}}s:4:"rows";i:4;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1221027586',); +$templ_data[] = array('name' => 'resources.edit.accessories','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:19:"resources.show.rows";}}}s:4:"rows";i:1;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1352913344',); + +$templ_data[] = array('name' => 'resources.edit.custom','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:1:{s:2:"c1";s:4:",top";}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:12:"customfields";}}i:2;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:2;s:4:"cols";i:1;s:4:"size";s:7:"700,380";s:7:"options";a:2:{i:0;s:3:"700";i:1;s:3:"380";}}}','size' => '700,380','style' => '','modified' => '1352913557',); + +$templ_data[] = array('name' => 'resources.edit.general','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:9:{i:0;a:2:{s:1:"C";s:2:"10";s:2:"h8";s:4:"100%";}i:1;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:19:"Description (short)";}s:1:"B";a:4:{s:4:"type";s:4:"text";s:4:"size";s:6:"50,100";s:4:"name";s:17:"short_description";s:4:"help";s:29:"Short description of resource";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:29:"Short description of resource";}}i:2;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"Location";}s:1:"B";a:4:{s:4:"type";s:4:"text";s:4:"size";s:6:"50,100";s:4:"name";s:8:"location";s:4:"help";s:20:"Location of resource";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:28:"Where to find this resource?";}}i:3;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:19:"Storage information";}s:1:"B";a:4:{s:4:"type";s:4:"text";s:4:"size";s:6:"50,100";s:4:"name";s:12:"storage_info";s:4:"help";s:25:"Information about storage";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:25:"Information about storage";}}i:4;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"Quantity";}s:1:"B";a:4:{s:4:"type";s:4:"text";s:4:"size";s:4:"5,10";s:4:"name";s:8:"quantity";s:4:"help";s:20:"Quantity of resource";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:20:"Quantity of resource";}}i:5;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:7:"Useable";}s:1:"B";a:4:{s:4:"type";s:4:"text";s:4:"size";s:4:"5,10";s:4:"name";s:7:"useable";s:4:"help";s:29:"How many of them are useable?";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:38:"How many of the resources are useable?";}}i:6;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"Bookable";}s:1:"B";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:8:"bookable";s:4:"help";s:21:"Is resource bookable?";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:26:"Is this resource bookable?";}}i:7;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:12:"Accessory of";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:12:"accessory_of";s:4:"size";s:4:"None";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}i:8;a:4:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:7:"Buyable";s:8:"disabled";s:1:"1";}s:1:"B";a:4:{s:4:"type";s:8:"checkbox";s:4:"name";s:7:"buyable";s:4:"help";s:20:"Is resource buyable?";s:8:"disabled";s:1:"1";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:3:{s:4:"type";s:5:"label";s:5:"label";s:25:"Is this resource buyable?";s:8:"disabled";s:1:"1";}}}s:4:"rows";i:8;s:4:"cols";i:4;s:4:"size";s:7:"700,380";s:7:"options";a:2:{i:0;s:3:"700";i:1;s:3:"380";}}}','size' => '700,380','style' => '','modified' => '1352913589',); + +$templ_data[] = array('name' => 'resources.edit.links','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:7:{s:1:"A";s:3:"100";s:2:"c1";s:2:"th";s:2:"c2";s:3:"row";s:2:"c3";s:2:"th";s:2:"c4";s:11:"row_off,top";s:2:"h4";s:3:"164";s:2:"h5";s:4:"100%";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:16:"Create new links";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:3:{s:4:"type";s:7:"link-to";s:4:"span";s:3:"all";s:4:"name";s:7:"link_to";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:14:"Existing links";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:4;a:2:{s:1:"A";a:3:{s:4:"type";s:9:"link-list";s:4:"span";s:3:"all";s:4:"name";s:7:"link_to";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:5;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:5;s:4:"cols";i:2;s:4:"size";s:7:"700,380";s:7:"options";a:2:{i:0;s:3:"700";i:1;s:3:"380";}}}','size' => '700,380','style' => '','modified' => '1352913520',); + +$templ_data[] = array('name' => 'resources.edit.page','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:1:{s:2:"c1";s:4:",top";}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"htmlarea";s:4:"name";s:16:"long_description";s:4:"help";s:26:"Web-Site for this resource";s:4:"size";s:23:"simple,350px,700px,true";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:8:"100%,380";s:7:"options";a:2:{i:0;s:4:"100%";i:1;s:3:"380";}}}','size' => '100%,380','style' => '','modified' => '1352913491',); + +$templ_data[] = array('name' => 'resources.edit.pictures','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:2:{s:2:"c1";s:4:",top";s:2:"h2";s:4:"100%";}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:2:{s:4:"type";s:5:"image";s:4:"name";s:16:"resource_picture";}i:2;a:1:{s:4:"type";s:5:"label";}}i:2;a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";i:1;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:0:{}i:1;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:26:"Use general resources icon";s:5:"align";s:5:"right";}s:1:"B";a:3:{s:4:"type";s:5:"radio";s:4:"size";s:7:"gen_src";s:4:"name";s:11:"picture_src";}s:1:"C";a:3:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"gen_src_list";}}i:2;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:23:"Use the category\'s icon";s:5:"align";s:5:"right";}s:1:"B";a:3:{s:4:"type";s:5:"radio";s:4:"size";s:7:"cat_src";s:4:"name";s:11:"picture_src";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:3;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:15:"Use own picture";s:5:"align";s:5:"right";}s:1:"B";a:3:{s:4:"type";s:5:"radio";s:4:"size";s:7:"own_src";s:4:"name";s:11:"picture_src";}s:1:"C";a:2:{s:4:"type";s:4:"file";s:4:"name";s:8:"own_file";}}}s:4:"rows";i:3;s:4:"cols";i:3;}s:5:"label";s:14:"picture source";}}}i:2;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:2;s:4:"cols";i:1;s:4:"size";s:7:"700,380";s:7:"options";a:2:{i:0;s:3:"700";i:1;s:3:"380";}}}','size' => '700,380','style' => '','modified' => '1352913451',); + $templ_data[] = array('name' => 'resources.edit_buttons','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:1:{s:1:"C";s:4:"100%";}i:1;a:3:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:4:"save";s:4:"help";s:21:"Saves entry and exits";}s:1:"B";a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:7:"onclick";s:15:"window.close();";}s:1:"C";a:5:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:5:"align";s:5:"right";s:4:"name";s:6:"delete";s:7:"onclick";s:61:"return confirm(\'Do you really want do delte this resource?\');";}}}s:4:"rows";i:1;s:4:"cols";i:3;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '','modified' => '1093597552',); $templ_data[] = array('name' => 'resources.edit_pictures','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:3:{s:2:"c1";s:3:"nmr";s:2:"c2";s:3:"nmr";s:2:"c3";s:3:"nmr";}i:1;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:26:"Use general resources icon";s:5:"align";s:5:"right";}s:1:"B";a:3:{s:4:"type";s:5:"radio";s:4:"size";s:7:"gen_src";s:4:"name";s:11:"picture_src";}s:1:"C";a:3:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"gen_src_list";}}i:2;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:23:"Use the category\'s icon";s:5:"align";s:5:"right";}s:1:"B";a:3:{s:4:"type";s:5:"radio";s:4:"size";s:7:"cat_src";s:4:"name";s:11:"picture_src";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:3;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:15:"Use own picture";s:5:"align";s:5:"right";}s:1:"B";a:3:{s:4:"type";s:5:"radio";s:4:"size";s:7:"own_src";s:4:"name";s:11:"picture_src";}s:1:"C";a:2:{s:4:"type";s:4:"file";s:4:"name";s:8:"own_file";}}}s:4:"rows";i:3;s:4:"cols";i:3;}}','size' => '','style' => '','modified' => '1108638846',); @@ -69,7 +81,7 @@ $templ_data[] = array('name' => 'resources.show.actions_header','template' => '' $templ_data[] = array('name' => 'resources.show.nm_right','template' => '','lang' => '','group' => '0','version' => '1.9.002','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:10:"buttononly";s:5:"label";s:3:"Add";s:7:"onclick";s:206:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.edit\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false; return false;";s:4:"name";s:3:"add";}}}s:4:"rows";i:1;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1331036827',); -$templ_data[] = array('name' => 'resources.show.rows','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:4:{s:1:"C";s:2:"3%";s:2:"c1";s:3:"nmh";s:2:"c2";s:24:"nmr $row_cont[class],top";s:1:"G";s:2:"5%";}i:1;a:7:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";}i:2;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:17:"Short description";s:4:"name";s:17:"short_description";}}s:1:"C";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:7:"Useable";s:4:"name";s:7:"useable";s:4:"help";s:36:"How many of this resource are usable";}i:2;a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Quantity";s:4:"name";s:8:"quantity";s:4:"help";s:32:"How many of this resource exists";}}s:1:"D";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Category";s:4:"name";s:6:"cat_id";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:13:"Administrator";}}s:1:"E";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Location";s:4:"name";s:8:"location";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:19:"Storage information";}}s:1:"F";a:2:{s:4:"type";s:22:"nextmatch-customfields";s:4:"name";s:12:"customfields";}s:1:"G";a:7:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"4";i:1;a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:7:"Actions";s:4:"name";s:14:"legacy_actions";}i:2;a:1:{s:4:"type";s:5:"label";}i:3;a:2:{s:4:"type";s:5:"label";s:6:"needed";s:1:"1";}s:5:"align";s:5:"right";i:4;a:11:{s:4:"type";s:6:"button";s:4:"size";s:9:"check.png";s:5:"label";s:9:"Check all";s:5:"align";s:5:"right";s:4:"name";s:9:"check_all";s:4:"help";s:9:"Check all";i:1;a:1:{s:4:"type";s:5:"label";}i:2;a:1:{s:4:"type";s:5:"label";}i:3;a:1:{s:4:"type";s:5:"label";}s:6:"needed";s:1:"1";s:7:"onclick";s:76:"toggle_all(this.form,form::name(\'nm[rows][checkbox][]\'),true); return false;";}}}i:2;a:7:{s:1:"A";a:5:{s:4:"type";s:6:"button";s:5:"align";s:6:"center";s:4:"name";s:21:"${row}[picture_thumb]";s:4:"size";s:24:"$row_cont[picture_thumb]";s:7:"onclick";s:216:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.show&res_id=$row_cont[res_id]\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\');return false;";}s:1:"B";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"${row}[name]";}i:2;a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:25:"${row}[short_description]";}}s:1:"C";a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";s:5:"align";s:5:"right";i:1;a:4:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:5:"align";s:5:"right";s:4:"name";s:15:"${row}[useable]";}i:2;a:4:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:5:"align";s:5:"right";s:4:"name";s:16:"${row}[quantity]";}}s:1:"D";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:10:"select-cat";s:7:"no_lang";s:1:"1";s:4:"name";s:14:"${row}[cat_id]";s:8:"readonly";s:1:"1";}i:2;a:4:{s:4:"type";s:14:"select-account";s:7:"no_lang";s:1:"1";s:4:"name";s:13:"${row}[admin]";s:8:"readonly";s:1:"1";}}s:1:"E";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:16:"${row}[location]";}i:2;a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:20:"${row}[storage_info]";}}s:1:"F";a:2:{s:4:"type";s:17:"customfields-list";s:4:"name";s:4:"$row";}s:1:"G";a:7:{s:4:"type";s:4:"grid";s:5:"align";s:5:"right";s:4:"data";a:3:{i:0;a:0:{}i:1;a:4:{s:1:"A";a:8:{s:4:"type";s:6:"button";s:4:"size";s:17:"navbar,trams16x16";s:5:"label";s:18:"Book this resource";s:5:"align";s:6:"center";s:4:"help";s:18:"Book this resource";s:7:"onclick";s:223:"window.open(egw::link(\'/index.php\',\'menuaction=calendar.calendar_uiforms.edit&participants=r$cont[res_id]\'),\'\',\'dependent=yes,width=750,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;";s:4:"name";s:23:"bookable[$cont[res_id]]";s:4:"span";s:8:",image16";}s:1:"B";a:7:{s:4:"type";s:6:"button";s:4:"size";s:15:"edit,trans16x16";s:5:"label";s:4:"Edit";s:5:"align";s:6:"center";s:4:"help";s:15:"Edit this entry";s:7:"onclick";s:213:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.edit&res_id=$cont[res_id]\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;";s:4:"name";s:19:"edit[$cont[res_id]]";}s:1:"C";a:7:{s:4:"type";s:6:"button";s:4:"size";s:14:"new,trans16x16";s:5:"label";s:38:"Create new accessory for this resource";s:5:"align";s:6:"center";s:4:"name";s:22:"new_acc[$cont[res_id]]";s:4:"help";s:38:"Create new accessory for this resource";s:7:"onclick";s:228:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.edit&res_id=0&accessory_of=$cont[res_id]\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;";}s:1:"D";a:7:{s:4:"type";s:6:"button";s:4:"size";s:15:"view,trans16x16";s:5:"label";s:4:"View";s:5:"align";s:5:"right";s:4:"name";s:19:"view[$cont[res_id]]";s:4:"help";s:15:"View this entry";s:7:"onclick";s:213:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.show&res_id=$cont[res_id]\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;";}}i:2;a:4:{s:1:"A";a:7:{s:4:"type";s:6:"button";s:4:"size";s:27:"calendar/planner,trans16x16";s:5:"label";s:25:"Show calendar of resource";s:5:"align";s:6:"center";s:4:"help";s:25:"Show calendar of resource";s:4:"name";s:23:"calendar[$cont[res_id]]";s:7:"onclick";s:129:"location=egw::link(\'/index.php\',\'menuaction=calendar.calendar_uiviews.planner&sortby=user&owner=0,r$cont[res_id]\'); return false;";}s:1:"B";a:7:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:5:"align";s:6:"center";s:4:"name";s:21:"delete[$cont[res_id]]";s:4:"help";s:17:"Delete this entry";s:7:"onclick";s:36:"return confirm(\'Delete this entry\');";s:4:"size";s:17:"delete,trans16x16";}s:1:"C";a:6:{s:4:"type";s:6:"button";s:4:"size";s:19:"view_acc,trans16x16";s:5:"label";s:34:"View accessories for this resource";s:5:"align";s:6:"center";s:4:"name";s:23:"view_acc[$cont[res_id]]";s:4:"help";s:34:"View accessories for this resource";}s:1:"D";a:4:{s:4:"type";s:8:"checkbox";s:5:"align";s:5:"right";s:4:"name";s:10:"checkbox[]";s:4:"size";s:13:"$cont[res_id]";}}}s:4:"rows";i:2;s:4:"cols";i:4;s:4:"name";s:6:"${row}";s:7:"options";a:0:{}}}}s:4:"rows";i:2;s:4:"cols";i:7;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1300835999',); +$templ_data[] = array('name' => 'resources.show.rows','template' => '','lang' => '','group' => '0','version' => '1.9.002','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:4:{s:1:"C";s:2:"3%";s:2:"c1";s:3:"nmh";s:2:"c2";s:24:"nmr $row_cont[class],top";s:1:"G";s:2:"5%";}i:1;a:7:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";}i:2;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:17:"Short description";s:4:"name";s:17:"short_description";}}s:1:"C";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:7:"Useable";s:4:"name";s:7:"useable";s:4:"help";s:36:"How many of this resource are usable";}i:2;a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Quantity";s:4:"name";s:8:"quantity";s:4:"help";s:32:"How many of this resource exists";}}s:1:"D";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Category";s:4:"name";s:6:"cat_id";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:13:"Administrator";}}s:1:"E";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Location";s:4:"name";s:8:"location";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:19:"Storage information";}}s:1:"F";a:2:{s:4:"type";s:22:"nextmatch-customfields";s:4:"name";s:12:"customfields";}s:1:"G";a:7:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"4";i:1;a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:7:"Actions";s:4:"name";s:14:"legacy_actions";}i:2;a:1:{s:4:"type";s:5:"label";}i:3;a:2:{s:4:"type";s:5:"label";s:6:"needed";s:1:"1";}s:5:"align";s:5:"right";i:4;a:11:{s:4:"type";s:6:"button";s:4:"size";s:9:"check.png";s:5:"label";s:9:"Check all";s:5:"align";s:5:"right";s:4:"name";s:9:"check_all";s:4:"help";s:9:"Check all";i:1;a:1:{s:4:"type";s:5:"label";}i:2;a:1:{s:4:"type";s:5:"label";}i:3;a:1:{s:4:"type";s:5:"label";}s:6:"needed";s:1:"1";s:7:"onclick";s:76:"toggle_all(this.form,form::name(\'nm[rows][checkbox][]\'),true); return false;";}}}i:2;a:7:{s:1:"A";a:5:{s:4:"type";s:6:"button";s:5:"align";s:6:"center";s:4:"name";s:21:"${row}[picture_thumb]";s:4:"size";s:24:"$row_cont[picture_thumb]";s:7:"onclick";s:216:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.show&res_id=$row_cont[res_id]\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\');return false;";}s:1:"B";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"${row}[name]";}i:2;a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:25:"${row}[short_description]";}}s:1:"C";a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";s:5:"align";s:5:"right";i:1;a:4:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:5:"align";s:5:"right";s:4:"name";s:15:"${row}[useable]";}i:2;a:4:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:5:"align";s:5:"right";s:4:"name";s:16:"${row}[quantity]";}}s:1:"D";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:10:"select-cat";s:7:"no_lang";s:1:"1";s:4:"name";s:14:"${row}[cat_id]";s:8:"readonly";s:1:"1";}i:2;a:4:{s:4:"type";s:14:"select-account";s:7:"no_lang";s:1:"1";s:4:"name";s:13:"${row}[admin]";s:8:"readonly";s:1:"1";}}s:1:"E";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:16:"${row}[location]";}i:2;a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:20:"${row}[storage_info]";}}s:1:"F";a:2:{s:4:"type";s:17:"customfields-list";s:4:"name";s:4:"$row";}s:1:"G";a:7:{s:4:"type";s:4:"grid";s:5:"align";s:5:"right";s:4:"data";a:3:{i:0;a:0:{}i:1;a:4:{s:1:"A";a:8:{s:4:"type";s:6:"button";s:4:"size";s:17:"navbar,trams16x16";s:5:"label";s:18:"Book this resource";s:5:"align";s:6:"center";s:4:"help";s:18:"Book this resource";s:7:"onclick";s:223:"window.open(egw::link(\'/index.php\',\'menuaction=calendar.calendar_uiforms.edit&participants=r$cont[res_id]\'),\'\',\'dependent=yes,width=750,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;";s:4:"name";s:23:"bookable[$cont[res_id]]";s:4:"span";s:8:",image16";}s:1:"B";a:7:{s:4:"type";s:6:"button";s:4:"size";s:15:"edit,trans16x16";s:5:"label";s:4:"Edit";s:5:"align";s:6:"center";s:4:"help";s:15:"Edit this entry";s:7:"onclick";s:213:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.edit&res_id=$cont[res_id]\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;";s:4:"name";s:19:"edit[$cont[res_id]]";}s:1:"C";a:7:{s:4:"type";s:6:"button";s:4:"size";s:14:"new,trans16x16";s:5:"label";s:38:"Create new accessory for this resource";s:5:"align";s:6:"center";s:4:"name";s:22:"new_acc[$cont[res_id]]";s:4:"help";s:38:"Create new accessory for this resource";s:7:"onclick";s:228:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.edit&res_id=0&accessory_of=$cont[res_id]\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}i:2;a:4:{s:1:"A";a:7:{s:4:"type";s:6:"button";s:4:"size";s:27:"calendar/planner,trans16x16";s:5:"label";s:25:"Show calendar of resource";s:5:"align";s:6:"center";s:4:"help";s:25:"Show calendar of resource";s:4:"name";s:23:"calendar[$cont[res_id]]";s:7:"onclick";s:129:"location=egw::link(\'/index.php\',\'menuaction=calendar.calendar_uiviews.planner&sortby=user&owner=0,r$cont[res_id]\'); return false;";}s:1:"B";a:7:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:5:"align";s:6:"center";s:4:"name";s:21:"delete[$cont[res_id]]";s:4:"help";s:17:"Delete this entry";s:7:"onclick";s:36:"return confirm(\'Delete this entry\');";s:4:"size";s:17:"delete,trans16x16";}s:1:"C";a:6:{s:4:"type";s:6:"button";s:4:"size";s:19:"view_acc,trans16x16";s:5:"label";s:34:"View accessories for this resource";s:5:"align";s:6:"center";s:4:"name";s:23:"view_acc[$cont[res_id]]";s:4:"help";s:34:"View accessories for this resource";}s:1:"D";a:4:{s:4:"type";s:8:"checkbox";s:5:"align";s:5:"right";s:4:"name";s:10:"checkbox[]";s:4:"size";s:13:"$cont[res_id]";}}}s:4:"rows";i:2;s:4:"cols";i:4;s:4:"name";s:6:"${row}";s:7:"options";a:0:{}}}}s:4:"rows";i:2;s:4:"cols";i:7;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1352911617',); $templ_data[] = array('name' => 'resources.showdetails','template' => '','lang' => '','group' => '0','version' => '1.5.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:8:{i:0;a:8:{s:2:"c1";s:3:"nmh";s:1:"B";s:4:"100%";s:2:"c5";s:2:"th";s:2:"h3";s:2:"1%";s:2:"c6";s:11:"row_off,top";s:1:"A";s:3:"43%";s:2:"h1";s:5:"240px";s:2:"h5";s:10:",@!link_to";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"image";s:4:"name";s:16:"resource_picture";s:5:"align";s:6:"center";}s:1:"B";a:4:{s:4:"type";s:4:"grid";s:4:"data";a:9:{i:0;a:1:{s:2:"c5";s:4:",top";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"size";s:1:"b";s:5:"label";s:5:"Name:";}s:1:"B";a:4:{s:4:"type";s:5:"label";s:4:"size";s:1:"b";s:7:"no_lang";s:1:"1";s:4:"name";s:4:"name";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:17:"Inventory number:";}s:1:"B";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:16:"inventory_number";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:9:"Category:";}s:1:"B";a:3:{s:4:"type";s:10:"select-cat";s:4:"name";s:6:"cat_id";s:8:"readonly";s:1:"1";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:13:"Responsible: ";}s:1:"B";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:9:"cat_admin";s:8:"readonly";s:1:"1";}}i:5;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:10:"Quantity: ";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:4:"name";s:8:"quantity";}}i:6;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"Useable:";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:4:"name";s:7:"useable";}}i:7;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:9:"Location:";}s:1:"B";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:8:"location";}}i:8;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:20:"Storage information:";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"storage_info";}}}s:4:"rows";i:8;s:4:"cols";i:2;}}i:2;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:4:{s:4:"type";s:4:"html";s:4:"span";s:1:"2";s:4:"name";s:11:"description";s:8:"readonly";s:1:"1";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:4;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:5;a:2:{s:1:"A";a:6:{s:4:"type";s:5:"label";s:4:"span";s:1:"2";s:4:"data";a:2:{i:0;a:1:{s:1:"A";s:4:"100%";}i:1;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:13:"Related links";}s:1:"B";a:6:{s:4:"type";s:6:"button";s:5:"label";s:17:"Buy this resource";s:5:"align";s:5:"right";s:4:"size";s:7:"buyable";s:4:"help";s:17:"Buy this resource";s:4:"name";s:11:"btn_buyable";}s:1:"C";a:4:{s:4:"type";s:6:"button";s:5:"label";s:18:"Book this resource";s:4:"name";s:12:"btn_bookable";s:4:"size";s:8:"bookable";}s:1:"D";a:5:{s:4:"type";s:6:"button";s:5:"label";s:4:"edit";s:4:"name";s:8:"btn_edit";s:4:"size";s:4:"edit";s:4:"help";s:4:"edit";}}}s:4:"rows";i:1;s:4:"cols";i:4;s:5:"label";s:13:"Related links";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:6;a:2:{s:1:"A";a:4:{s:4:"type";s:9:"link-list";s:4:"span";s:3:"all";s:4:"name";s:7:"link_to";s:8:"readonly";s:1:"1";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:7;a:2:{s:1:"A";a:8:{s:4:"type";s:4:"hbox";s:5:"label";s:6:"Cancel";s:4:"span";s:1:"2";s:4:"size";s:1:"2";i:1;a:9:{s:4:"type";s:4:"hbox";s:5:"label";s:4:"Edit";s:4:"span";s:1:"2";s:4:"name";s:8:"btn_edit";s:4:"size";s:1:"4";i:1;a:5:{s:4:"type";s:6:"button";s:5:"label";s:4:"Edit";s:4:"span";s:1:"2";s:4:"name";s:8:"btn_edit";s:4:"help";s:16:"Buy this article";}i:2;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:7:"onclick";s:14:"window.close()";}i:3;a:6:{s:4:"type";s:6:"button";s:5:"label";s:8:"Calendar";s:4:"span";s:1:"2";s:4:"name";s:12:"btn_calendar";s:4:"help";s:25:"Show calendar of resource";s:7:"onclick";s:120:"opener.location=egw::link(\'/index.php\',\'menuaction=calendar.calendar_uiviews.month&owner=r$cont[res_id]\'); return false;";}i:4;a:5:{s:4:"type";s:6:"button";s:5:"label";s:4:"Book";s:7:"onclick";s:209:"window.open(egw::link(\'/index.php\',\'menuaction=calendar.calendar_uiforms.edit&participants=r$cont[res_id]\'),\'\',\'dependent=yes,width=750,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\');";s:4:"name";s:8:"btn_book";s:4:"help";s:18:"Book this resource";}}i:2;a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"1";s:5:"align";s:5:"right";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:7:"onclick";s:61:"return confirm(\'Do you really want do delte this resource?\');";s:4:"name";s:10:"btn_delete";}}i:3;a:1:{s:4:"type";s:5:"label";}i:4;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:4:"name";s:10:"btn_delete";s:5:"align";s:5:"right";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:7;s:4:"cols";i:2;s:4:"size";s:7:"750,480";s:7:"options";a:2:{i:0;s:3:"750";i:1;s:3:"480";}}}','size' => '750,480','style' => '','modified' => '1129667646',); diff --git a/resources/templates/default/edit.xet b/resources/templates/default/edit.xet index 7fc7dbed74..7fcc07ea88 100644 --- a/resources/templates/default/edit.xet +++ b/resources/templates/default/edit.xet @@ -1,60 +1,162 @@ -