diff --git a/www/protected/components/UsuarioWeb.php b/www/protected/components/UsuarioWeb.php index 42898db..790ea17 100644 --- a/www/protected/components/UsuarioWeb.php +++ b/www/protected/components/UsuarioWeb.php @@ -88,6 +88,8 @@ class UsuarioWeb extends CWebUser { protected function loadUser() { if ($this->_model === null) { $this->_model = Usuario::model()->findByPk($this->id); + if ($this->_model === null) + throw new CHttpException(404, Yii::t('profind', 'La página solicitada no existe.')); } return $this->_model; } @@ -100,7 +102,6 @@ class UsuarioWeb extends CWebUser { return Subscripcion::model()->activa()->findByAttributes(array('id_usuario' => $this->id)); } - } ?> \ No newline at end of file diff --git a/www/protected/config/main.php b/www/protected/config/main.php index 8da5450..726b238 100644 --- a/www/protected/config/main.php +++ b/www/protected/config/main.php @@ -9,7 +9,7 @@ $config = array( 'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..', 'theme' => 'profind', - 'sourceLanguage' => 'es', + 'sourceLanguage' => 'en', 'language' => 'es', 'name' => 'PROFIND', 'defaultController' => 'usuario', @@ -22,12 +22,15 @@ $config = array( // Modelos 'application.models.*', 'application.models.formularios.*', + // Helpers 'application.helpers.*', + // Componentes y extensiones 'application.components.*', 'application.extensions.yii-mail.YiiMailMessage', 'application.extensions.PasswordHash.PasswordHash', + 'application.extensions.yii-chosen.Chosen', ), 'modules' => array( diff --git a/www/protected/config/mode_development.php b/www/protected/config/mode_development.php index 2d3f1c4..3bc54b2 100644 --- a/www/protected/config/mode_development.php +++ b/www/protected/config/mode_development.php @@ -89,14 +89,14 @@ $configSpecific = array( // Save log messages on file array( 'class' => 'CFileLogRoute', - 'levels' => 'error, warning, trace, info', - //'categories' => 'application.*', + 'levels' => 'trace', + 'categories' => 'application.*', ), // Show log messages on web pages array( 'class' => 'CWebLogRoute', - 'levels' => 'error, warning, trace', - //'categories' => 'application.*', + 'levels' => 'error, warning', + 'categories' => 'application.*', 'showInFireBug' => true, ), ), diff --git a/www/protected/controllers/CandidatoController.php b/www/protected/controllers/CandidatoController.php index d1a0492..0159774 100644 --- a/www/protected/controllers/CandidatoController.php +++ b/www/protected/controllers/CandidatoController.php @@ -28,6 +28,9 @@ class CandidatoController extends Controller { 'actions' => array('index', 'view', 'create', 'update', 'delete', 'admin', 'updateEstado'), 'users' => array('@'), ), + array('deny', // deny all users + 'users' => array('*'), + ), ); } @@ -67,44 +70,52 @@ class CandidatoController extends Controller { * @param integer $id el ID del candidato a modificar */ public function actionUpdate($id) { - $candidato = $this->loadModel($id); - + // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($candidato); if (isset($_POST['Candidato'])) { Yii::trace(CVarDumper::dumpAsString($_POST)); - + // Candidato $candidato->attributes = $_POST['Candidato']; - $ficheroFotografia = CUploadedFile::getInstance($candidato, 'ficheroFotografia'); + $ficheroFotografia = CUploadedFile::getInstance($candidato, 'ficheroFotografia'); $quitarFotografia = Yii::app()->request->getParam('quitar_fotografia', '0'); + + // Titulaciones del candidato + $listaTitulacionesBorrar = $candidato->titulaciones; + if (isset($_POST['CandidatoTitulacion'])) { + $listaTitulaciones = array(); + foreach ($_POST['CandidatoTitulacion'] as $titulacion) { + $candidatoTitulacion = new CandidatoTitulacion(); + $candidatoTitulacion->titulacion = $titulacion; + $candidatoTitulacion->candidato_id = $candidato->id; + $listaTitulaciones[] = $candidatoTitulacion; + } + $candidato->titulaciones = $listaTitulaciones; + } // Idiomas del candidato - $listaIdiomas = array(); $listaIdiomasBorrar = array(); - foreach ($_POST['CandidatoIdioma'] as $key => $idioma) { - if ($idioma['id']) - $candidatoIdioma = CandidatoIdioma::model()->findByPk($idioma['id']); - else - $candidatoIdioma = new CandidatoIdioma(); - $candidatoIdioma->attributes = $idioma; - $candidatoIdioma->candidato_id = $candidato->id; - - if ($idioma['_borrar']) - $listaIdiomasBorrar[] = $candidatoIdioma; - else - $listaIdiomas[] = $candidatoIdioma; - - Yii::trace('Idioma ' . $key); - Yii::trace(CVarDumper::dumpAsString($candidatoIdioma->attributes)); + if (isset($_POST['CandidatoIdioma'])) { + $listaIdiomas = array(); + foreach ($_POST['CandidatoIdioma'] as $key => $idioma) { + if ($idioma['id']) + $candidatoIdioma = CandidatoIdioma::model()->findByPk($idioma['id']); + else + $candidatoIdioma = new CandidatoIdioma(); + $candidatoIdioma->attributes = $idioma; + $candidatoIdioma->candidato_id = $candidato->id; + + if ($idioma['_borrar']) + $listaIdiomasBorrar[] = $candidatoIdioma; + else + $listaIdiomas[] = $candidatoIdioma; + } + $candidato->idiomas = $listaIdiomas; } - $candidato->idiomas = $listaIdiomas; - - Yii::trace('Idiomas a borrar'); - Yii::trace(CVarDumper::dumpAsString($listaIdiomasBorrar)); - + // Guardar los datos $transaccion = Yii::app()->db->beginTransaction(); try { @@ -116,13 +127,29 @@ class CandidatoController extends Controller { Yii::trace('Eliminando la fotografía del candidato', 'application.controllers.CandidatoController'); $candidato->fotografia->eliminarFotografia(); } - + if ($ficheroFotografia) { Yii::trace('Guardando la fotografía del candidato', 'application.controllers.CandidatoController'); $candidato->fotografia->guardarFotografia($ficheroFotografia); } + // Titulaciones + if (!empty($listaTitulacionesBorrar)) { + Yii::trace('Eliminando titulaciones marcadas para borrar', 'application.controllers.CandidatoController'); + foreach ($listaIdiomasBorrar as $candidatoTitulacion) { + if (!$candidatoTitulacion->delete()) + throw new CException('Error al eliminar una titulación del candidato'); + } + } + if (!empty($candidato->titulaciones)) { + Yii::trace('Guardando la lista de titulaciones', 'application.controllers.CandidatoController'); + foreach ($candidato->titulaciones as $candidatoTitulacion) { + if (!$candidatoTitulacion->save()) + throw new CException('Error al guardar una titulación del candidato'); + } + } + // Idiomas if (!empty($listaIdiomasBorrar)) { Yii::trace('Eliminando idiomas marcados para borrar', 'application.controllers.CandidatoController'); foreach ($listaIdiomasBorrar as $candidatoIdioma) { @@ -130,9 +157,8 @@ class CandidatoController extends Controller { throw new CException('Error al eliminar un idioma del candidato'); } } - if (!empty($candidato->idiomas)) { - Yii::trace('Guardando la lista de idiomas', 'application.controllers.CandidatoController'); + Yii::trace('Guardando la lista de idiomas', 'application.controllers.CandidatoController'); foreach ($candidato->idiomas as $candidatoIdioma) { if (!$candidatoIdioma->save()) throw new CException('Error al guardar un idioma del candidato'); @@ -144,15 +170,24 @@ class CandidatoController extends Controller { Yii::trace('Candidato guardado', 'application.controllers.CandidatoController'); Yii::app()->user->setFlash('success', Yii::t('profind', 'Se ha actualizado el candidato')); $this->redirect(array('index')); - } catch (Exception $e) { Yii::trace($e->getMessage(), 'application.controllers.CandidatoController'); $transaccion->rollBack(); - $errores = array_merge($candidato->getErrors() /*, $nueva_empresa->getErrors(), $nueva_subscripcion->getErrors()*/); - foreach ($errores as $campo => $mensaje) $resultado[$campo] = $mensaje; - Yii::trace(CVarDumper::dumpAsString($resultado), 'application.controllers.CandidatoController'); Yii::app()->user->setFlash('error', Yii::t('profind', 'Se ha producido un error al actualizar el candidato')); + + if (YII_DEBUG) { + $errores = $candidato->getErrors(); + if (isset($candidatoTitulacion)) + $errores = array_merge($errores, $candidatoTitulacion->getErrors()); + if (isset($candidatoIdioma)) + $errores = array_merge($errores, $candidatoIdioma->getErrors()); + + $resultado = array(); + foreach ($errores as $campo => $mensaje) + $resultado[$campo] = $mensaje; + Yii::trace(CVarDumper::dumpAsString($resultado), 'application.controllers.CandidatoController'); + } } } @@ -161,7 +196,6 @@ class CandidatoController extends Controller { )); } - public function actionUpdateEstado($id) { $model = $this->loadModel($id); diff --git a/www/protected/data/Capitales provincia españa.sql b/www/protected/data/Capitales provincia españa.sql deleted file mode 100644 index a73ca1e..0000000 --- a/www/protected/data/Capitales provincia españa.sql +++ /dev/null @@ -1,50 +0,0 @@ -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Vitoria'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Albacete'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Alicante'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Almería'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Ávila'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Badajoz'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Palma'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Barcelona'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Burgos'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Cáceres'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Cádiz'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Castellón de la Plana'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Ciudad Real'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Córdoba'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('La Coruña'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Cuenca'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Girona'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Granada'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Guadalajara'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('San Sebastián'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Huelva'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Huesca'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Jaén'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('León'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Lleida'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Logroño'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Lugo'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Madrid'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Málaga'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Murcia'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Pamplona'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Ourense'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Oviedo'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Palencia'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Las Palmas de Gran Canaria'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Pontevedra'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Salamanca'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Santa Cruz de Tenerife'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Santander'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Segovia'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Sevilla'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Soria'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Tarragona'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Teruel'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Toledo'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Valencia'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Valladolid'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Bilbao'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Zamora'); -INSERT INTO `tbl_poblaciones`(`poblacion`) VALUES ('Zaragoza'); diff --git a/www/protected/data/tbl_idiomas.sql b/www/protected/data/tbl_idiomas.sql new file mode 100644 index 0000000..a4280d2 --- /dev/null +++ b/www/protected/data/tbl_idiomas.sql @@ -0,0 +1,32 @@ +-- phpMyAdmin SQL Dump +-- version 3.3.2deb1ubuntu1 +-- http://www.phpmyadmin.net +-- +-- Servidor: localhost +-- Tiempo de generación: 24-10-2012 a las 13:42:04 +-- Versión del servidor: 5.1.63 +-- Versión de PHP: 5.3.2-1ubuntu4.18 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Base de datos: `intranet` +-- + +-- +-- Volcar la base de datos para la tabla `tbl_idiomas` +-- + +INSERT INTO `tbl_idiomas` (`id`, `descripcion`) VALUES +(1, 'Alemán'), +(2, 'Francés'), +(3, 'Japonés'), +(4, 'Inglés'), +(5, 'Italiano'), +(6, 'Portugués'); diff --git a/www/protected/data/tbl_poblaciones.sql b/www/protected/data/tbl_poblaciones.sql new file mode 100644 index 0000000..a3dd6ed --- /dev/null +++ b/www/protected/data/tbl_poblaciones.sql @@ -0,0 +1,81 @@ +-- phpMyAdmin SQL Dump +-- version 3.4.5 +-- http://www.phpmyadmin.net +-- +-- Servidor: localhost +-- Tiempo de generación: 24-10-2012 a las 11:41:30 +-- Versión del servidor: 5.5.16 +-- Versión de PHP: 5.3.8 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Base de datos: `usuarios_dev` +-- + +-- +-- Volcado de datos para la tabla `tbl_poblaciones` +-- + +INSERT INTO `tbl_poblaciones` (`id`, `poblacion`) VALUES +(1, 'Vitoria'), +(2, 'Albacete'), +(3, 'Alicante'), +(4, 'Almería'), +(5, 'Ávila'), +(6, 'Badajoz'), +(7, 'Palma'), +(8, 'Barcelona'), +(9, 'Burgos'), +(10, 'Cáceres'), +(11, 'Cádiz'), +(12, 'Castellón de la Plana'), +(13, 'Ciudad Real'), +(14, 'Córdoba'), +(15, 'La Coruña'), +(16, 'Cuenca'), +(17, 'Girona'), +(18, 'Granada'), +(19, 'Guadalajara'), +(20, 'San Sebastián'), +(21, 'Huelva'), +(22, 'Huesca'), +(23, 'Jaén'), +(24, 'León'), +(25, 'Lleida'), +(26, 'Logroño'), +(27, 'Lugo'), +(28, 'Madrid'), +(29, 'Málaga'), +(30, 'Murcia'), +(31, 'Pamplona'), +(32, 'Ourense'), +(33, 'Oviedo'), +(34, 'Palencia'), +(35, 'Las Palmas de Gran Canaria'), +(36, 'Pontevedra'), +(37, 'Salamanca'), +(38, 'Santa Cruz de Tenerife'), +(39, 'Santander'), +(40, 'Segovia'), +(41, 'Sevilla'), +(42, 'Soria'), +(43, 'Tarragona'), +(44, 'Teruel'), +(45, 'Toledo'), +(46, 'Valencia'), +(47, 'Valladolid'), +(48, 'Bilbao'), +(49, 'Zamora'), +(50, 'Zaragoza'); + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/www/protected/data/tbl_titulaciones.sql b/www/protected/data/tbl_titulaciones.sql new file mode 100644 index 0000000..2f0ae8a --- /dev/null +++ b/www/protected/data/tbl_titulaciones.sql @@ -0,0 +1,54 @@ +-- phpMyAdmin SQL Dump +-- version 3.3.2deb1ubuntu1 +-- http://www.phpmyadmin.net +-- +-- Servidor: localhost +-- Tiempo de generación: 24-10-2012 a las 13:40:04 +-- Versión del servidor: 5.1.63 +-- Versión de PHP: 5.3.2-1ubuntu4.18 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Base de datos: `intranet` +-- + +-- +-- Volcar la base de datos para la tabla `tbl_titulaciones` +-- + +INSERT INTO `tbl_titulaciones` (`id`, `descripcion`) VALUES +(1, 'Ciclo G.Sup. Administración Sistemas Informático'), +(2, 'Diplomado en Estadística'), +(4, 'FPII Téc. Especialista Administrativo Comercial'), +(5, 'FPIII Administración de Empresas'), +(6, 'Informática Gestión y Sistemas (No homologado)'), +(9, 'Ingeniería Superior en Electrónica'), +(10, 'Ingeniería Superior Informática'), +(12, 'Ingeniería Técnica Informática Sistemas'), +(13, 'Ingeniería Técnica Telecomunicaciones'), +(14, 'Ingenieria Superior Telecomunicaciones'), +(15, 'Ingenieria Técnica Informática Gestión'), +(16, 'Licenciado en Físicas'), +(17, 'Licenciado en Informática'), +(18, 'Licenciatura C. Químicas'), +(19, 'Ciclo G.Sup. Desarrollo Aplicaciones'), +(20, 'Licenciatura Publicidad y RRPP'), +(21, 'Diseño Gráfico (No homologado)'), +(22, 'FPII Informática'), +(23, 'ESO'), +(24, 'Licenciatura en Matemáticas'), +(25, 'Ingeniería Superior Industriales'), +(26, 'FPII Electrónica'), +(27, 'FPIII Informática y/o Electrónica'), +(28, 'BUP'), +(29, 'Licenciatura Otros'), +(30, 'Licenciatura en Economía'), +(31, 'Diplomado en Empresariales'), +(32, 'Ingeniería Técnica Industrial'); diff --git a/www/protected/extensions/yii-chosen/.hg_archival.txt b/www/protected/extensions/yii-chosen/.hg_archival.txt new file mode 100644 index 0000000..1f215ef --- /dev/null +++ b/www/protected/extensions/yii-chosen/.hg_archival.txt @@ -0,0 +1,5 @@ +repo: 71b41104a806e44aed263531d51071c76c7f288b +node: 5e65b1eb38fbb7017b67801337f40d7d3e7ec53d +branch: default +latesttag: null +latesttagdistance: 9 diff --git a/www/protected/extensions/yii-chosen/Chosen.php b/www/protected/extensions/yii-chosen/Chosen.php new file mode 100644 index 0000000..6739fa9 --- /dev/null +++ b/www/protected/extensions/yii-chosen/Chosen.php @@ -0,0 +1,148 @@ + + */ +class Chosen extends CInputWidget +{ + /** @var string Path to assets directory published in init() */ + private $assetsDir; + + /** @var bool Multiple or single item should be selected */ + public $multiple = false; + + /** @var string|null If is set will override default label "Select Some Options" */ + public $placeholderMultiple; + + /** @var string|null If is set will override default label "Select an Option" */ + public $placeholderSingle; + + /** + * @var bool Allow deselect single selected item from dropDown. + * Chosen will add a UI element for option deselection. + * This will only work if the first option has blank text. + */ + public $allowSingleDeselect = true; + + /** @var string|null If is set will override default label "No results match" */ + public $noResults; + + /** @var array Chosen script settings passed to $.fn.chosen() */ + private $settings = array(); + + /** @var array See CHtml::listData() */ + public $data; + + /** Publish assets and set default values for properties */ + public function init() + { + $dir = dirname(__FILE__) . '/assets'; + $this->assetsDir = Yii::app()->assetManager->publish($dir); + + if ($this->multiple) { + if (isset($this->htmlOptions['multiple'])) + $this->multiple = true; + elseif ($this->multiple) + $this->htmlOptions['multiple'] = true; + } + if ($this->multiple) { + if (isset($this->placeholderMultiple)) + $this->htmlOptions['data-placeholder'] = $this->placeholderMultiple; + else + $this->htmlOptions['data-placeholder'] = Yii::t('Chosen.main', "Select Some Options"); + } else { + + if (isset($this->placeholderSingle)) + $this->htmlOptions['data-placeholder'] = $this->placeholderSingle; + else + $this->htmlOptions['data-placeholder'] = Yii::t('Chosen.main', "Select an Option"); + } + + if (isset($this->noResults)) + $this->settings['no_results_text'] = $this->noResults; + else + $this->settings['no_results_text'] = Yii::t('Chosen.main', "No results match"); + if (!$this->multiple) + $this->settings['allow_single_deselect'] = $this->allowSingleDeselect; + } + + /** Render widget html and register client scripts */ + public function run() + { + list($name, $id) = $this->resolveNameID(); + if (isset($this->htmlOptions['id'])) + $id = $this->htmlOptions['id']; + else + $this->htmlOptions['id'] = $id; + if (isset($this->htmlOptions['name'])) + $name = $this->htmlOptions['name']; + + if ($this->multiple && substr($name, -2) !== '[]') + $name .= '[]'; + + if (isset($this->model)) { + echo CHtml::dropDownList($name, CHtml::value($this->model, $this->attribute), $this->data, $this->htmlOptions); + } else { + echo CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions); + } + $this->registerScripts($id); + } + + /** Register client scripts */ + private function registerScripts($id) + { + $cs = Yii::app()->getClientScript(); + $cs->registerCoreScript('jquery'); + if (defined('YII_DEBUG')) + $cs->registerScriptFile($this->assetsDir . '/chosen.jquery.js'); + else + $cs->registerScriptFile($this->assetsDir . '/chosen.jquery.min.js'); + + $cs->registerCssFile($this->assetsDir . '/chosen.css'); + + $settings = CJavaScript::encode($this->settings); + $cs->registerScript("{$id}_chosen", "$('#{$id}').chosen({$settings});"); + } + + /** Single item select */ + public static function dropDownList($name, $select, $data, $htmlOptions = array()) + { + return Yii::app()->getController()->widget(__CLASS__, array( + 'name' => $name, + 'value' => $select, + 'data' => $data, + 'htmlOptions' => $htmlOptions, + ), true); + } + + public static function activeDropDownList($model, $attribute, $data, $htmlOptions = array()) + { + return self::dropDownList(CHtml::activeName($model, $attribute), CHtml::value($model, $attribute), $data, $htmlOptions); + } + + /** Multiple items select */ + public static function multiSelect($name, $select, $data, $htmlOptions = array()) + { + if (substr($name, -2) !== '[]') + $name .= '[]'; + + return Yii::app()->getController()->widget(__CLASS__, array( + 'name' => $name, + 'value' => $select, + 'data' => $data, + 'htmlOptions' => $htmlOptions, + 'multiple' => true, + ), true); + } + + public static function activeMultiSelect($model, $attribute, $data, $htmlOptions = array()) + { + return self::multiSelect(CHtml::activeName($model, $attribute) . '[]', CHtml::value($model, $attribute), $data, $htmlOptions); + } + + +} diff --git a/www/themes/profind/lib/chosen/chosen-sprite.png b/www/protected/extensions/yii-chosen/assets/chosen-sprite.png similarity index 100% rename from www/themes/profind/lib/chosen/chosen-sprite.png rename to www/protected/extensions/yii-chosen/assets/chosen-sprite.png diff --git a/www/themes/profind/lib/chosen/chosen.css b/www/protected/extensions/yii-chosen/assets/chosen.css similarity index 64% rename from www/themes/profind/lib/chosen/chosen.css rename to www/protected/extensions/yii-chosen/assets/chosen.css index 8efd4ad..a4322c4 100644 --- a/www/themes/profind/lib/chosen/chosen.css +++ b/www/protected/extensions/yii-chosen/assets/chosen.css @@ -1,349 +1,396 @@ -/* @group Base */ -.chzn-container { - font-size: 13px; - position: relative; - display: inline-block; - zoom: 1; - *display: inline; -} -.chzn-container .chzn-drop { - background: #fff; - border: 1px solid #ccc; - border-top: 0; - position: absolute; - top: 29px; - left: 0; - -webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15); - -moz-box-shadow : 0 4px 5px rgba(0,0,0,.15); - -o-box-shadow : 0 4px 5px rgba(0,0,0,.15); - box-shadow : 0 4px 5px rgba(0,0,0,.15); - z-index: 1010; -} -/* @end */ - -/* @group Single Chosen */ -.chzn-container-single .chzn-single { - background-color: #ffffff; - -webkit-border-radius: 3px; - -moz-border-radius : 3px; - border-radius : 3px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -moz-background-clip : padding; - -webkit-background-clip: padding-box; - background-clip : padding-box; - border: 1px solid #ccc; - - display: block; - overflow: hidden; - white-space: nowrap; - position: relative; - height: 28px; - line-height: 27px; - padding: 0 0 0 8px; - color: #444444; - text-decoration: none; -} -.chzn-container-single .chzn-default { - color: #999; -} -.chzn-container-single .chzn-single span { - margin-right: 26px; - display: block; - overflow: hidden; - white-space: nowrap; - -o-text-overflow: ellipsis; - -ms-text-overflow: ellipsis; - text-overflow: ellipsis; -} -.chzn-container-single .chzn-single abbr { - display: block; - position: absolute; - right: 26px; - top: 9px; - width: 12px; - height: 13px; - font-size: 1px; - background: url('chosen-sprite.png') right top no-repeat; -} -.chzn-container-single .chzn-single abbr:hover { - background-position: right -11px; -} -.chzn-container-single.chzn-disabled .chzn-single abbr:hover { - background-position: right top; -} -.chzn-container-single .chzn-single div { - position: absolute; - right: 0; - top: 0; - display: block; - height: 100%; - width: 18px; -} -.chzn-container-single .chzn-single div b { - background: url('chosen-sprite.png') no-repeat 0 3px; - display: block; - width: 100%; - height: 100%; -} -.chzn-container-single .chzn-search { - padding: 3px 4px; - position: relative; - margin: 0; - white-space: nowrap; - z-index: 1010; -} -.chzn-container-single .chzn-search input { - background: #fff url('chosen-sprite.png') no-repeat 100% -22px; - background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff)); - background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%); - background: url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%); - background: url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%); - background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%); - background: url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%); - margin: 1px 0; - padding: 3px 20px 2px 5px; - outline: 0; - border: 1px solid #aaa; - font-family: sans-serif; - font-size: 13px; - min-height: 13px; -} -.chzn-container-single .chzn-drop { - -webkit-border-radius: 0 0 4px 4px; - -moz-border-radius : 0 0 4px 4px; - border-radius : 0 0 4px 4px; - -moz-background-clip : padding; - -webkit-background-clip: padding-box; - background-clip : padding-box; - margin-top: 1px; -} -/* @end */ - -.chzn-container-single-nosearch .chzn-search input { - position: absolute; - left: -9000px; -} - -/* @group Multi Chosen */ -.chzn-container-multi .chzn-choices { - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-border-radius:3px; - -moz-border-radius:3px; - border-radius:3px; - border:1px solid #ccc; - overflow:hidden; - margin: 0; - padding: 0 5px 0 0; - cursor: text; - overflow: hidden; - height: auto !important; - height: 1%; - position: relative; -} -.chzn-container-multi .chzn-choices li { - float: left; - list-style: none; -} -.chzn-container-multi .chzn-choices .search-field { - white-space: nowrap; - margin: 0; - padding: 0; -} -.chzn-container-multi .chzn-choices .search-field input { - color: #666; - background: transparent !important; - border: 0 !important; - font-family: sans-serif; - font-size: 100%; - height: 16px; - padding: 5px; - margin: 1px 0; - outline: 0; - -webkit-box-shadow: none; - -moz-box-shadow : none; - -o-box-shadow : none; - box-shadow : none; -} -.chzn-container-multi .chzn-choices .search-field .default { - color: #999; -} -.chzn-container-multi .chzn-choices .search-choice { - -webkit-border-radius: 3px; - -moz-border-radius : 3px; - border-radius : 3px; - -moz-background-clip : padding; - -webkit-background-clip: padding-box; - background-clip : padding-box; - background-color: #cee5f5; - color: #2b4f62; - line-height: 13px; - padding: 4px 20px 5px 5px; - margin: 3px 0 3px 5px; - position: relative; - cursor: default; -} -.chzn-container-multi .chzn-choices .search-choice-focus { - background: #d4d4d4; - color:#6a6a6a; -} -.chzn-container-multi .chzn-choices .search-choice .search-choice-close { - display: block; - position: absolute; - right: 3px; - top: 5px; - width: 12px; - height: 13px; - font-size: 1px; - background: url('chosen-sprite.png') right top no-repeat; -} -.chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover { - background-position: right -11px; -} -.chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close { - background-position: right -11px; -} -/* @end */ - -/* @group Results */ -.chzn-container .chzn-results { - margin: 0 2px 2px 0; - max-height: 240px; - padding: 0 0 0 4px; - position: relative; - overflow-x: hidden; - overflow-y: auto; - -webkit-overflow-scrolling: touch; -} -.chzn-container-multi .chzn-results { - margin: -1px 0 0; - padding: 0; -} -.chzn-container .chzn-results li { - display: none; - line-height: 15px; - padding: 5px 6px; - margin: 0; - list-style: none; -} -.chzn-container .chzn-results .active-result { - cursor: pointer; - display: list-item; -} -.chzn-container .chzn-results .highlighted { - background-color: #48A6D2; - color: #fff; -} -.chzn-container .chzn-results li em { - background: #feffde; - font-style: normal; -} -.chzn-container .chzn-results .highlighted em { - background: transparent; -} -.chzn-container .chzn-results .no-results { - background: #f4f4f4; - display: list-item; -} -.chzn-container .chzn-results .group-result { - cursor: default; - color: #999; - font-weight: bold; -} -.chzn-container .chzn-results .group-option { - padding-left: 15px; -} -.chzn-container-multi .chzn-drop .result-selected { - display: none; -} -.chzn-container .chzn-results-scroll { - background: white; - margin: 0 4px; - position: absolute; - text-align: center; - width: 321px; /* This should by dynamic with js */ - z-index: 1; -} -.chzn-container .chzn-results-scroll span { - display: inline-block; - height: 17px; - text-indent: -5000px; - width: 9px; -} -.chzn-container .chzn-results-scroll-down { - bottom: 0; -} -.chzn-container .chzn-results-scroll-down span { - background: url('chosen-sprite.png') no-repeat -4px -3px; -} -.chzn-container .chzn-results-scroll-up span { - background: url('chosen-sprite.png') no-repeat -22px -3px; -} -/* @end */ - -/* @group Active */ - -.chzn-container-active .chzn-single-with-drop { - -webkit-border-bottom-left-radius : 0; - -webkit-border-bottom-right-radius: 0; - -moz-border-radius-bottomleft : 0; - -moz-border-radius-bottomright: 0; - border-bottom-left-radius : 0; - border-bottom-right-radius: 0; -} -.chzn-container-active .chzn-single-with-drop div { - background: transparent; - border-left: none; -} -.chzn-container-active .chzn-single-with-drop div b { - background-position: -18px 3px; -} -.chzn-container-active .chzn-choices .search-field input { - color: #111 !important; -} -/* @end */ - -/* @group Disabled Support */ -.chzn-disabled { - cursor: default; - opacity:0.5 !important; -} -.chzn-disabled .chzn-single { - cursor: default; -} -.chzn-disabled .chzn-choices .search-choice .search-choice-close { - cursor: default; -} - -/* @group Right to Left */ -.chzn-rtl { text-align: right; } -.chzn-rtl .chzn-single { padding: 0 8px 0 0; overflow: visible; } -.chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; direction: rtl; } - -.chzn-rtl .chzn-single div { left: 3px; right: auto; } -.chzn-rtl .chzn-single abbr { - left: 26px; - right: auto; -} -.chzn-rtl .chzn-choices .search-field input { direction: rtl; } -.chzn-rtl .chzn-choices li { float: right; } -.chzn-rtl .chzn-choices .search-choice { padding: 3px 5px 3px 19px; margin: 3px 5px 3px 0; } -.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 4px; right: auto; background-position: right top;} -.chzn-rtl.chzn-container-single .chzn-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; } -.chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 15px; } -.chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; } -.chzn-rtl .chzn-search input { - background: #fff url('chosen-sprite.png') no-repeat -38px -22px; - background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff)); - background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%); - background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%); - background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%); - background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%); - background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%); - padding: 4px 5px 4px 20px; - direction: rtl; -} -/* @end */ +/* @group Base */ +.chzn-container { + font-size: 13px; + position: relative; + display: inline-block; + zoom: 1; + *display: inline; +} +.chzn-container .chzn-drop { + background: #fff; + border: 1px solid #aaa; + border-top: 0; + position: absolute; + top: 29px; + left: 0; + -webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15); + -moz-box-shadow : 0 4px 5px rgba(0,0,0,.15); + -o-box-shadow : 0 4px 5px rgba(0,0,0,.15); + box-shadow : 0 4px 5px rgba(0,0,0,.15); + z-index: 1010; +} +/* @end */ + +/* @group Single Chosen */ +.chzn-container-single .chzn-single { + background-color: #ffffff; + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0 ); + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4)); + background-image: -webkit-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); + background-image: -moz-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); + background-image: -o-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); + background-image: -ms-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); + background-image: linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); + -webkit-border-radius: 5px; + -moz-border-radius : 5px; + border-radius : 5px; + -moz-background-clip : padding; + -webkit-background-clip: padding-box; + background-clip : padding-box; + border: 1px solid #aaaaaa; + -webkit-box-shadow: 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1); + -moz-box-shadow : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1); + box-shadow : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1); + display: block; + overflow: hidden; + white-space: nowrap; + position: relative; + height: 23px; + line-height: 24px; + padding: 0 0 0 8px; + color: #444444; + text-decoration: none; +} +.chzn-container-single .chzn-default { + color: #999; +} +.chzn-container-single .chzn-single span { + margin-right: 26px; + display: block; + overflow: hidden; + white-space: nowrap; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; + text-overflow: ellipsis; +} +.chzn-container-single .chzn-single abbr { + display: block; + position: absolute; + right: 26px; + top: 6px; + width: 12px; + height: 13px; + font-size: 1px; + background: url('chosen-sprite.png') right top no-repeat; +} +.chzn-container-single .chzn-single abbr:hover { + background-position: right -11px; +} +.chzn-container-single.chzn-disabled .chzn-single abbr:hover { + background-position: right top; +} +.chzn-container-single .chzn-single div { + position: absolute; + right: 0; + top: 0; + display: block; + height: 100%; + width: 18px; +} +.chzn-container-single .chzn-single div b { + background: url('chosen-sprite.png') no-repeat 0 0; + display: block; + width: 100%; + height: 100%; +} +.chzn-container-single .chzn-search { + padding: 3px 4px; + position: relative; + margin: 0; + white-space: nowrap; + z-index: 1010; +} +.chzn-container-single .chzn-search input { + background: #fff url('chosen-sprite.png') no-repeat 100% -22px; + background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff)); + background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background: url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background: url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background: url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%); + margin: 1px 0; + padding: 4px 20px 4px 5px; + outline: 0; + border: 1px solid #aaa; + font-family: sans-serif; + font-size: 1em; +} +.chzn-container-single .chzn-drop { + -webkit-border-radius: 0 0 4px 4px; + -moz-border-radius : 0 0 4px 4px; + border-radius : 0 0 4px 4px; + -moz-background-clip : padding; + -webkit-background-clip: padding-box; + background-clip : padding-box; +} +/* @end */ + +.chzn-container-single-nosearch .chzn-search input { + position: absolute; + left: -9000px; +} + +/* @group Multi Chosen */ +.chzn-container-multi .chzn-choices { + background-color: #fff; + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff)); + background-image: -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background-image: -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background-image: -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background-image: -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background-image: linear-gradient(top, #eeeeee 1%, #ffffff 15%); + border: 1px solid #aaa; + margin: 0; + padding: 0; + cursor: text; + overflow: hidden; + height: auto !important; + height: 1%; + position: relative; +} +.chzn-container-multi .chzn-choices li { + float: left; + list-style: none; +} +.chzn-container-multi .chzn-choices .search-field { + white-space: nowrap; + margin: 0; + padding: 0; +} +.chzn-container-multi .chzn-choices .search-field input { + color: #666; + background: transparent !important; + border: 0 !important; + font-family: sans-serif; + font-size: 100%; + height: 15px; + padding: 5px; + margin: 1px 0; + outline: 0; + -webkit-box-shadow: none; + -moz-box-shadow : none; + -o-box-shadow : none; + box-shadow : none; +} +.chzn-container-multi .chzn-choices .search-field .default { + color: #999; +} +.chzn-container-multi .chzn-choices .search-choice { + -webkit-border-radius: 3px; + -moz-border-radius : 3px; + border-radius : 3px; + -moz-background-clip : padding; + -webkit-background-clip: padding-box; + background-clip : padding-box; + background-color: #e4e4e4; + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee', GradientType=0 ); + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee)); + background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); + background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); + background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); + background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); + background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); + -webkit-box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05); + -moz-box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05); + 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; + padding: 3px 20px 3px 5px; + margin: 3px 0 3px 5px; + position: relative; + cursor: default; +} +.chzn-container-multi .chzn-choices .search-choice-focus { + background: #d4d4d4; +} +.chzn-container-multi .chzn-choices .search-choice .search-choice-close { + display: block; + position: absolute; + right: 3px; + top: 4px; + width: 12px; + height: 13px; + font-size: 1px; + background: url('chosen-sprite.png') right top no-repeat; +} +.chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover { + background-position: right -11px; +} +.chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close { + background-position: right -11px; +} +/* @end */ + +/* @group Results */ +.chzn-container .chzn-results { + margin: 0 4px 4px 0; + max-height: 240px; + padding: 0 0 0 4px; + position: relative; + overflow-x: hidden; + overflow-y: auto; + -webkit-overflow-scrolling: touch; +} +.chzn-container-multi .chzn-results { + margin: -1px 0 0; + padding: 0; +} +.chzn-container .chzn-results li { + display: none; + line-height: 15px; + padding: 5px 6px; + margin: 0; + list-style: none; +} +.chzn-container .chzn-results .active-result { + cursor: pointer; + display: list-item; +} +.chzn-container .chzn-results .highlighted { + background-color: #3875d7; + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3875d7', endColorstr='#2a62bc', GradientType=0 ); + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc)); + background-image: -webkit-linear-gradient(top, #3875d7 20%, #2a62bc 90%); + background-image: -moz-linear-gradient(top, #3875d7 20%, #2a62bc 90%); + background-image: -o-linear-gradient(top, #3875d7 20%, #2a62bc 90%); + background-image: -ms-linear-gradient(top, #3875d7 20%, #2a62bc 90%); + background-image: linear-gradient(top, #3875d7 20%, #2a62bc 90%); + color: #fff; +} +.chzn-container .chzn-results li em { + background: #feffde; + font-style: normal; +} +.chzn-container .chzn-results .highlighted em { + background: transparent; +} +.chzn-container .chzn-results .no-results { + background: #f4f4f4; + display: list-item; +} +.chzn-container .chzn-results .group-result { + cursor: default; + color: #999; + font-weight: bold; +} +.chzn-container .chzn-results .group-option { + padding-left: 15px; +} +.chzn-container-multi .chzn-drop .result-selected { + display: none; +} +.chzn-container .chzn-results-scroll { + background: white; + margin: 0 4px; + position: absolute; + text-align: center; + width: 321px; /* This should by dynamic with js */ + z-index: 1; +} +.chzn-container .chzn-results-scroll span { + display: inline-block; + height: 17px; + text-indent: -5000px; + width: 9px; +} +.chzn-container .chzn-results-scroll-down { + bottom: 0; +} +.chzn-container .chzn-results-scroll-down span { + background: url('chosen-sprite.png') no-repeat -4px -3px; +} +.chzn-container .chzn-results-scroll-up span { + background: url('chosen-sprite.png') no-repeat -22px -3px; +} +/* @end */ + +/* @group Active */ +.chzn-container-active .chzn-single { + -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3); + -moz-box-shadow : 0 0 5px rgba(0,0,0,.3); + -o-box-shadow : 0 0 5px rgba(0,0,0,.3); + box-shadow : 0 0 5px rgba(0,0,0,.3); + border: 1px solid #5897fb; +} +.chzn-container-active .chzn-single-with-drop { + border: 1px solid #aaa; + -webkit-box-shadow: 0 1px 0 #fff inset; + -moz-box-shadow : 0 1px 0 #fff inset; + -o-box-shadow : 0 1px 0 #fff inset; + box-shadow : 0 1px 0 #fff inset; + background-color: #eee; + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0 ); + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff)); + background-image: -webkit-linear-gradient(top, #eeeeee 20%, #ffffff 80%); + background-image: -moz-linear-gradient(top, #eeeeee 20%, #ffffff 80%); + background-image: -o-linear-gradient(top, #eeeeee 20%, #ffffff 80%); + background-image: -ms-linear-gradient(top, #eeeeee 20%, #ffffff 80%); + background-image: linear-gradient(top, #eeeeee 20%, #ffffff 80%); + -webkit-border-bottom-left-radius : 0; + -webkit-border-bottom-right-radius: 0; + -moz-border-radius-bottomleft : 0; + -moz-border-radius-bottomright: 0; + border-bottom-left-radius : 0; + border-bottom-right-radius: 0; +} +.chzn-container-active .chzn-single-with-drop div { + background: transparent; + border-left: none; +} +.chzn-container-active .chzn-single-with-drop div b { + background-position: -18px 1px; +} +.chzn-container-active .chzn-choices { + -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3); + -moz-box-shadow : 0 0 5px rgba(0,0,0,.3); + -o-box-shadow : 0 0 5px rgba(0,0,0,.3); + box-shadow : 0 0 5px rgba(0,0,0,.3); + border: 1px solid #5897fb; +} +.chzn-container-active .chzn-choices .search-field input { + color: #111 !important; +} +/* @end */ + +/* @group Disabled Support */ +.chzn-disabled { + cursor: default; + opacity:0.5 !important; +} +.chzn-disabled .chzn-single { + cursor: default; +} +.chzn-disabled .chzn-choices .search-choice .search-choice-close { + cursor: default; +} + +/* @group Right to Left */ +.chzn-rtl { text-align: right; } +.chzn-rtl .chzn-single { padding: 0 8px 0 0; overflow: visible; } +.chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; direction: rtl; } + +.chzn-rtl .chzn-single div { left: 3px; right: auto; } +.chzn-rtl .chzn-single abbr { + left: 26px; + right: auto; +} +.chzn-rtl .chzn-choices .search-field input { direction: rtl; } +.chzn-rtl .chzn-choices li { float: right; } +.chzn-rtl .chzn-choices .search-choice { padding: 3px 5px 3px 19px; margin: 3px 5px 3px 0; } +.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 4px; right: auto; background-position: right top;} +.chzn-rtl.chzn-container-single .chzn-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; } +.chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 15px; } +.chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; } +.chzn-rtl .chzn-search input { + background: #fff url('chosen-sprite.png') no-repeat -38px -22px; + background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff)); + background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%); + background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%); + padding: 4px 5px 4px 20px; + direction: rtl; +} +/* @end */ diff --git a/www/themes/profind/lib/chosen/chosen.jquery.js b/www/protected/extensions/yii-chosen/assets/chosen.jquery.js similarity index 96% rename from www/themes/profind/lib/chosen/chosen.jquery.js rename to www/protected/extensions/yii-chosen/assets/chosen.jquery.js index 9293773..8b28bc0 100644 --- a/www/themes/profind/lib/chosen/chosen.jquery.js +++ b/www/protected/extensions/yii-chosen/assets/chosen.jquery.js @@ -1,994 +1,1003 @@ -// 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 === "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 === "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.search_contains = this.options.search_contains || false; - this.choices = 0; - 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.active_field) { - return setTimeout((function() { - return _this.container_mousedown(); - }), 50); - } - }; - - 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; - - $ = jQuery; - - $.fn.extend({ - chosen: function(options) { - if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) { - 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); - 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 = 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.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); - }); - if (this.is_multiple) { - this.search_choices.click(function(evt) { - return _this.choices_click(evt); - }); - return this.search_field.focus(function(evt) { - return _this.input_focus(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); - if (!this.is_multiple) { - this.selected_item.attr("tabindex", this.search_field.attr("tabindex")); - this.search_field.attr("tabindex", -1); - } - 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() { - if (!this.is_multiple && !this.active_field) { - this.search_field.attr("tabindex", this.selected_item.attr("tabindex")); - this.selected_item.attr("tabindex", -1); - } - 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.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); - if (this.is_multiple) { - return this.search_field.attr("tabindex", ti); - } else { - this.selected_item.attr("tabindex", ti); - return this.search_field.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); - 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; - return this.result_select(evt); - } - }; - - 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, 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; - this.search_container.before('
  • ' + item.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) { - this.choices -= 1; - this.show_search_field_default(); - if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) { - this.results_hide(); - } - this.result_deselect(link.attr("rel")); - 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() { - 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(""); - this.form_field_jq.trigger("change", { - 'selected': this.form_field.options[item.options_index].value - }); - 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]; - 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 - }); - return this.search_field_scale(); - }; - - 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() { - if (this.pending_backstroke) { - this.choice_destroy(this.pending_backstroke.find("a").first()); - return this.clear_backstroke(); - } else { - this.pending_backstroke = this.search_container.siblings("li.search-choice").last(); - 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); +// 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 === "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 === "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.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.active_field) { + return setTimeout((function() { + return _this.container_mousedown(); + }), 50); + } + }; + + 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; + + $ = jQuery; + + $.fn.extend({ + chosen: function(options) { + if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) { + 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 = 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.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); + }); + if (this.is_multiple) { + this.search_choices.click(function(evt) { + return _this.choices_click(evt); + }); + return this.search_field.focus(function(evt) { + return _this.input_focus(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); + if (!this.is_multiple) { + this.selected_item.attr("tabindex", this.search_field.attr("tabindex")); + this.search_field.attr("tabindex", -1); + } + 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() { + if (!this.is_multiple && !this.active_field) { + this.search_field.attr("tabindex", this.selected_item.attr("tabindex")); + this.selected_item.attr("tabindex", -1); + } + 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.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); + if (this.is_multiple) { + return this.search_field.attr("tabindex", ti); + } else { + this.selected_item.attr("tabindex", ti); + return this.search_field.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); + 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; + return this.result_select(evt); + } + }; + + 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, 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; + this.search_container.before('
      • ' + item.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) { + this.choices -= 1; + this.show_search_field_default(); + if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) { + this.results_hide(); + } + this.result_deselect(link.attr("rel")); + 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() { + 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]; + 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 + }); + return this.search_field_scale(); + }; + + 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() { + if (this.pending_backstroke) { + this.choice_destroy(this.pending_backstroke.find("a").first()); + return this.clear_backstroke(); + } else { + this.pending_backstroke = this.search_container.siblings("li.search-choice").last(); + 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/www/protected/extensions/yii-chosen/assets/chosen.jquery.min.js b/www/protected/extensions/yii-chosen/assets/chosen.jquery.min.js new file mode 100644 index 0000000..022d662 --- /dev/null +++ b/www/protected/extensions/yii-chosen/assets/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 a;a=function(){function a(){this.options_index=0,this.parsed=[]}return a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d"+a.html+"")},a.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()},a.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){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:a.preventDefault();if(this.results_showing)return this.result_select(a);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()}},a.prototype.generate_field_id=function(){var a;return a=this.generate_random_id(),this.form_field.id=a,a},a.prototype.generate_random_char=function(){var a,b,c;return a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",c=Math.floor(Math.random()*a.length),b=a.substring(c,c+1)},a}(),b.AbstractChosen=a}.call(this),function(){var a,b,c,d,e=Object.prototype.hasOwnProperty,f=function(a,b){function d(){this.constructor=a}for(var c in b)e.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};d=this,a=jQuery,a.fn.extend({chosen:function(c){return!a.browser.msie||a.browser.version!=="6.0"&&a.browser.version!=="7.0"?this.each(function(d){var e;e=a(this);if(!e.hasClass("chzn-done"))return e.data("chosen",new b(this,c))}):this}}),b=function(b){function e(){e.__super__.constructor.apply(this,arguments)}return f(e,b),e.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_value=this.form_field_jq.val(),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},e.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},e.prototype.set_up_html=function(){var b,d,e,f;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=this.form_field_jq.outerWidth(),b=a("
        ",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.html('
          '):b.html(''+this.default_text+'
            '),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"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(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build(),this.set_tab_index(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},e.prototype.register_observers=function(){var a=this;return this.container.mousedown(function(b){return a.container_mousedown(b)}),this.container.mouseup(function(b){return a.container_mouseup(b)}),this.container.mouseenter(function(b){return a.mouse_enter(b)}),this.container.mouseleave(function(b){return a.mouse_leave(b)}),this.search_results.mouseup(function(b){return a.search_results_mouseup(b)}),this.search_results.mouseover(function(b){return a.search_results_mouseover(b)}),this.search_results.mouseout(function(b){return a.search_results_mouseout(b)}),this.form_field_jq.bind("liszt:updated",function(b){return a.results_update_field(b)}),this.search_field.blur(function(b){return a.input_blur(b)}),this.search_field.keyup(function(b){return a.keyup_checker(b)}),this.search_field.keydown(function(b){return a.keydown_checker(b)}),this.is_multiple?(this.search_choices.click(function(b){return a.choices_click(b)}),this.search_field.focus(function(b){return a.input_focus(b)})):this.container.click(function(a){return a.preventDefault()})},e.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)},e.prototype.container_mousedown=function(b){var c;if(!this.is_disabled)return c=b!=null?a(b.target).hasClass("search-choice-close"):!1,b&&b.type==="mousedown"&&!this.results_showing&&b.stopPropagation(),!this.pending_destroy_click&&!c?(this.active_field?!this.is_multiple&&b&&(a(b.target)[0]===this.selected_item[0]||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},e.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(a)},e.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},e.prototype.close_field=function(){return a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),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()},e.prototype.activate_field=function(){return!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},e.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},e.prototype.results_build=function(){var a,b,c,e,f;this.parsing=!0,this.results_data=d.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.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),a="",f=this.results_data;for(c=0,e=f.length;c'+a("
            ").text(b.label).html()+"")},e.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c'+b.html+''),d=a("#"+c).find("a").first(),d.click(function(a){return e.choice_destroy_link_click(a)}))},e.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),this.is_disabled?b.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy(a(b.target)))},e.prototype.choice_destroy=function(a){return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel")),a.parents("li").first().remove()},e.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()},e.prototype.results_reset_cleanup=function(){return this.selected_item.find("abbr").remove()},e.prototype.result_select=function(a){var b,c,d,e;if(this.result_highlight)return b=this.result_highlight,c=b.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=b,this.selected_item.removeClass("chzn-default")),b.addClass("result-selected"),e=c.substr(c.lastIndexOf("_")+1),d=this.results_data[e],d.selected=!0,this.form_field.options[d.options_index].selected=!0,this.is_multiple?this.choice_build(d):(this.selected_item.find("span").first().text(d.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!a.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[d.options_index].value}),this.current_value=this.form_field_jq.val(),this.search_field_scale()},e.prototype.result_activate=function(a){return a.addClass("active-result")},e.prototype.result_deactivate=function(a){return a.removeClass("active-result")},e.prototype.result_deselect=function(b){var c,d;return d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.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[d.options_index].value}),this.search_field_scale()},e.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('')},e.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;this.no_results_clear(),j=0,k=this.search_field.val()===this.default_text?"":a("
            ").text(a.trim(this.search_field.val())).html(),g=this.search_contains?"":"^",f=new RegExp(g+k.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),n=new RegExp(k.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),s=this.results_data;for(o=0,q=s.length;o=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(p=0,r=e.length;p"+c.html.substr(l+k.length),m=m.substr(0,l)+""+m.substr(l)):m=c.html,h.html(m),this.result_activate(h),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&i===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(h))}}return j<1&&k.length?this.no_results(k):this.winnow_results_set_highlight()},e.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;d'+this.results_none_found+' ""'),c.find("span").first().html(b),this.search_results.append(c)},e.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},e.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},e.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},e.prototype.keydown_backstroke=function(){return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(this.pending_backstroke=this.search_container.siblings("li.search-choice").last(),this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus"))},e.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},e.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},e.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height(),this.dropdown.css({top:b+"px"})}},e.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},e}(AbstractChosen),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}.call(this); \ No newline at end of file diff --git a/www/protected/extensions/yii-chosen/messages/config.php b/www/protected/extensions/yii-chosen/messages/config.php new file mode 100644 index 0000000..5832e90 --- /dev/null +++ b/www/protected/extensions/yii-chosen/messages/config.php @@ -0,0 +1,14 @@ + dirname(__FILE__) . DIRECTORY_SEPARATOR . '..', + 'messagePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'messages', + 'languages' => array('es', 'en'), + 'fileTypes' => array('php'), + 'overwrite' => true, + 'exclude' => array( + '/messages', + '/vendors', + '/assets', + ), +); diff --git a/www/protected/extensions/yii-chosen/messages/en/main.php b/www/protected/extensions/yii-chosen/messages/en/main.php new file mode 100644 index 0000000..3d61554 --- /dev/null +++ b/www/protected/extensions/yii-chosen/messages/en/main.php @@ -0,0 +1,25 @@ + '', + 'Select Some Options' => '', + 'Select an Option' => '', +); diff --git a/www/protected/extensions/yii-chosen/messages/es/main.php b/www/protected/extensions/yii-chosen/messages/es/main.php new file mode 100644 index 0000000..2c02c5c --- /dev/null +++ b/www/protected/extensions/yii-chosen/messages/es/main.php @@ -0,0 +1,25 @@ + 'No hay coincidencias', + 'Select Some Options' => 'Seleccione algunas opciones', + 'Select an Option' => 'Seleccione una opción', +); diff --git a/www/protected/extensions/yii-chosen/readme.md b/www/protected/extensions/yii-chosen/readme.md new file mode 100644 index 0000000..f64a0d3 --- /dev/null +++ b/www/protected/extensions/yii-chosen/readme.md @@ -0,0 +1,28 @@ +Chosen usage instructions +=========================== + +1. Checkout source code to your project, for example to ext.chosen. +2. Use it, as any input widget. + +Example: + + $this->widget('ext.chosen.Chosen',array( + 'name' => 'inputName', // input name + 'value' => '2', // selection + 'data' => array( // list of select options + '1'=>'Option 1', + '2'=>'Option 2', + '3'=>'Option 3', + '4'=>'Option 4', + ), + )); + +Also you can use it like CHtml helper +---------------------------------------- +Before this import ext.chosen.Chosen, you can add it to config/main.php or call Yii::import('ext.chosen.Chosen') before usage. + + Chosen::dropDownList($name, $select, $data, $htmlOptions); + Chosen::activeDropDownList($model, $attribute, $data, $htmlOptions); + Chosen::multiSelect($name, $select, $data, $htmlOptions); + Chosen::activeMultiSelect($model, $attribute, $data, $htmlOptions); + diff --git a/www/protected/extensions/yii-chosen/upgradeAssets.sh b/www/protected/extensions/yii-chosen/upgradeAssets.sh new file mode 100644 index 0000000..7954ad6 --- /dev/null +++ b/www/protected/extensions/yii-chosen/upgradeAssets.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +cp ./vendors/chosen/chosen/chosen-sprite.png ./assets/ +cp ./vendors/chosen/chosen/chosen.jquery.min.js ./assets/ +cp ./vendors/chosen/chosen/chosen.jquery.js ./assets/ +cp ./vendors/chosen/chosen/cchosen.css ./assets/ diff --git a/www/protected/extensions/yii-chosen/vendors.sh b/www/protected/extensions/yii-chosen/vendors.sh new file mode 100644 index 0000000..cebd50e --- /dev/null +++ b/www/protected/extensions/yii-chosen/vendors.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +mkdir vendors +git clone https://github.com/harvesthq/chosen.git ./vendors/chosen/ + diff --git a/www/protected/migrations/m120905_183258_tbl_empresas.php b/www/protected/migrations/m120905_183258_tbl_empresas.php index 1e323ca..bdaea9d 100644 --- a/www/protected/migrations/m120905_183258_tbl_empresas.php +++ b/www/protected/migrations/m120905_183258_tbl_empresas.php @@ -1,23 +1,22 @@ createTable('tbl_empresas', array( - 'id' => 'pk', - 'cif' => 'string', - 'nombre' => 'string', - 'email' => 'string', - 'pagina_web' => 'string', - 'empleados' => 'integer', - 'direccion' => 'string', - 'descripcion' => 'text', - )); - } +class m120905_183258_tbl_empresas extends CDbMigration { + + public function up() { + $this->createTable('tbl_empresas', array( + 'id' => 'pk', + 'cif' => 'string', + 'nombre' => 'string', + 'email' => 'string', + 'pagina_web' => 'string', + 'empleados' => 'integer', + 'direccion' => 'string', + 'descripcion' => 'text', + ), 'ENGINE=InnoDB CHARSET=utf8'); + } + + public function down() { + $this->dropTable('tbl_empresas'); + } - public function down() - { - $this->dropTable('tbl_empresas'); - } } \ No newline at end of file diff --git a/www/protected/migrations/m120905_184758_tbl_usuarios.php b/www/protected/migrations/m120905_184758_tbl_usuarios.php index 1f92ce1..cc7ab8d 100644 --- a/www/protected/migrations/m120905_184758_tbl_usuarios.php +++ b/www/protected/migrations/m120905_184758_tbl_usuarios.php @@ -1,33 +1,31 @@ createTable('tbl_usuarios', array( - 'id' => 'pk', - 'id_empresa' => 'integer', - 'estado' => 'decimal(1,0)', - 'clave_seguridad' => 'string', - 'email' => 'string NOT NULL', - 'nombre' => 'string', - 'apellidos' => 'string', - 'password' => 'string NOT NULL', - 'tipo' => 'string NOT NULL', - 'titulo' => 'string', - 'localidad' => 'string', - 'telefono' => 'string', - 'descripcion' => 'text', - 'last_login_time' => 'datetime', - )); - - $this->addForeignKey('fk_usuarios_1', 'tbl_usuarios', 'id_empresa', 'tbl_empresas', 'id', 'CASCADE', 'CASCADE'); - } +class m120905_184758_tbl_usuarios extends CDbMigration { + + public function safeUp() { + $this->createTable('tbl_usuarios', array( + 'id' => 'pk', + 'id_empresa' => 'integer', + 'estado' => 'decimal(1,0)', + 'clave_seguridad' => 'string', + 'email' => 'string NOT NULL', + 'nombre' => 'string', + 'apellidos' => 'string', + 'password' => 'string NOT NULL', + 'tipo' => 'string NOT NULL', + 'titulo' => 'string', + 'localidad' => 'string', + 'telefono' => 'string', + 'descripcion' => 'text', + 'last_login_time' => 'datetime', + ), 'ENGINE=InnoDB CHARSET=utf8'); + + $this->addForeignKey('fk_usuarios_1', 'tbl_usuarios', 'id_empresa', 'tbl_empresas', 'id', 'CASCADE', 'CASCADE'); + } + + public function safeDown() { + $this->dropForeignKey('fk_usuarios_1', 'tbl_usuarios'); + $this->dropTable('tbl_usuarios'); + } - public function safeDown() - { - $this->dropForeignKey('fk_usuarios_1', 'tbl_usuarios'); - $this->dropTable('tbl_usuarios'); - } - } \ No newline at end of file diff --git a/www/protected/migrations/m120911_174500_tbl_social_connect.php b/www/protected/migrations/m120911_174500_tbl_social_connect.php index 0702b3a..f872830 100644 --- a/www/protected/migrations/m120911_174500_tbl_social_connect.php +++ b/www/protected/migrations/m120911_174500_tbl_social_connect.php @@ -1,28 +1,30 @@ createTable('tbl_social_connect', array( - 'id' => 'pk', - 'userId' => 'integer NOT NULL', - 'provider' => 'string NOT NULL', - 'providerUser' => 'string NOT NULL', - )); - $this->createIndex('idx_provider_provideruser', 'tbl_social_connect', 'provider, providerUser', true); - $this->createIndex('idx_provider', 'tbl_social_connect', 'provider'); - $this->createIndex('idx_provideruser', 'tbl_social_connect', 'providerUser'); - $this->createIndex('idx_userId', 'tbl_social_connect', 'userId'); - } - - public function safeDown() { - $this->dropIndex('idx_provider_provideruser', 'tbl_social_connect'); - $this->dropIndex('idx_provider', 'tbl_social_connect'); - $this->dropIndex('idx_provideruser', 'tbl_social_connect'); - $this->dropIndex('idx_userId', 'tbl_social_connect'); +class m120911_174500_tbl_social_connect extends CDbMigration { + + public function safeUp() { + $this->createTable('tbl_social_connect', array( + 'id' => 'pk', + 'userId' => 'integer NOT NULL', + 'provider' => 'string NOT NULL', + 'providerUser' => 'string NOT NULL', + ), 'ENGINE=InnoDB CHARSET=utf8'); + + $this->createIndex('idx_provider_provideruser', 'tbl_social_connect', 'provider, providerUser', true); + $this->createIndex('idx_provider', 'tbl_social_connect', 'provider'); + $this->createIndex('idx_provideruser', 'tbl_social_connect', 'providerUser'); + $this->createIndex('idx_userId', 'tbl_social_connect', 'userId'); + } + + public function safeDown() { + $this->dropIndex('idx_provider_provideruser', 'tbl_social_connect'); + $this->dropIndex('idx_provider', 'tbl_social_connect'); + $this->dropIndex('idx_provideruser', 'tbl_social_connect'); + $this->dropIndex('idx_userId', 'tbl_social_connect'); + + $this->dropTable('tbl_social_connect'); + } - $this->dropTable('tbl_social_connect'); - } } ?> \ No newline at end of file diff --git a/www/protected/migrations/m120925_162525_create_tbl_poblaciones.php b/www/protected/migrations/m120925_162525_create_tbl_poblaciones.php index 3328457..325c0ef 100644 --- a/www/protected/migrations/m120925_162525_create_tbl_poblaciones.php +++ b/www/protected/migrations/m120925_162525_create_tbl_poblaciones.php @@ -1,17 +1,16 @@ createTable('tbl_poblaciones', array( - 'id' => 'pk', - 'poblacion' => 'string', - )); - } +class m120925_162525_create_tbl_poblaciones extends CDbMigration { + + public function up() { + $this->createTable('tbl_poblaciones', array( + 'id' => 'pk', + 'poblacion' => 'string', + ), 'ENGINE=InnoDB CHARSET=utf8'); + } + + public function down() { + $this->dropTable('tbl_poblaciones'); + } - public function down() - { - $this->dropTable('tbl_poblaciones'); - } } \ No newline at end of file diff --git a/www/protected/migrations/m120926_090957_tbl_empresas.php b/www/protected/migrations/m120926_090957_tbl_empresas.php index ed376c3..cee3ab5 100644 --- a/www/protected/migrations/m120926_090957_tbl_empresas.php +++ b/www/protected/migrations/m120926_090957_tbl_empresas.php @@ -1,16 +1,15 @@ dropColumn('tbl_empresas', 'empleados'); - $this->addColumn('tbl_empresas', 'empleados', 'string'); - } +class m120926_090957_tbl_empresas extends CDbMigration { + + public function up() { + $this->dropColumn('tbl_empresas', 'empleados'); + $this->addColumn('tbl_empresas', 'empleados', 'string'); + } + + public function down() { + $this->dropColumn('tbl_empresas', 'empleados'); + $this->addColumn('tbl_empresas', 'empleados', 'integer'); + } - public function down() - { - $this->dropColumn('tbl_empresas', 'empleados'); - $this->addColumn('tbl_empresas', 'empleados', 'integer'); - } } \ No newline at end of file diff --git a/www/protected/migrations/m120927_143321_tbl_productos.php b/www/protected/migrations/m120927_143321_tbl_productos.php index 7ea827e..811951f 100644 --- a/www/protected/migrations/m120927_143321_tbl_productos.php +++ b/www/protected/migrations/m120927_143321_tbl_productos.php @@ -1,35 +1,36 @@ createTable('tbl_productos', array( - 'id' => 'pk', - 'titulo' => 'string', - 'n_agentes' => 'integer', - 'n_publicaciones' => 'integer', - - )); - - $this->createTable('tbl_subscripciones', array( - 'id' => 'pk', - 'id_usuario' => 'integer NOT NULL', - 'id_producto' => 'integer NOT NULL', - 'estado' => 'string', - 'fecha_inicio' => 'datetime', - 'fecha_fin' => 'datetime', - )); - - $this->addForeignKey('fk_subscripciones_1', 'tbl_subscripciones', 'id_usuario', 'tbl_usuarios', 'id', 'CASCADE', 'CASCADE'); - $this->addForeignKey('fk_subscripciones_2', 'tbl_subscripciones', 'id_producto', 'tbl_productos', 'id', 'CASCADE', 'CASCADE'); - } +class m120927_143321_tbl_productos extends CDbMigration { + + public function safeUp() { + $this->createTable('tbl_productos', array( + 'id' => 'pk', + 'titulo' => 'string', + 'n_agentes' => 'integer', + 'n_publicaciones' => 'integer', + ), 'ENGINE=InnoDB CHARSET=utf8'); + + + $this->createTable('tbl_subscripciones', array( + 'id' => 'pk', + 'id_usuario' => 'integer NOT NULL', + 'id_producto' => 'integer NOT NULL', + 'estado' => 'string', + 'fecha_inicio' => 'datetime', + 'fecha_fin' => 'datetime', + ), 'ENGINE=InnoDB CHARSET=utf8'); + + + $this->addForeignKey('fk_subscripciones_1', 'tbl_subscripciones', 'id_usuario', 'tbl_usuarios', 'id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('fk_subscripciones_2', 'tbl_subscripciones', 'id_producto', 'tbl_productos', 'id', 'CASCADE', 'CASCADE'); + } + + public function safeDown() { + $this->dropForeignKey('fk_subscripciones_2', 'tbl_subscripciones'); + $this->dropForeignKey('fk_subscripciones_1', 'tbl_subscripciones'); + + $this->dropTable('tbl_subscripciones'); + $this->dropTable('tbl_productos'); + } - public function safeDown() - { - $this->dropForeignKey('fk_subscripciones_2', 'tbl_subscripciones'); - $this->dropForeignKey('fk_subscripciones_1', 'tbl_subscripciones'); - - $this->dropTable('tbl_subscripciones'); - $this->dropTable('tbl_productos'); - } } \ No newline at end of file diff --git a/www/protected/migrations/m121014_170834_tbl_estados_candidatos.php b/www/protected/migrations/m121014_170834_tbl_estados_candidatos.php index b70b1cb..d78934a 100644 --- a/www/protected/migrations/m121014_170834_tbl_estados_candidatos.php +++ b/www/protected/migrations/m121014_170834_tbl_estados_candidatos.php @@ -4,7 +4,7 @@ class m121014_170834_tbl_estados_candidatos extends CDbMigration { $this->createTable('tbl_estados_candidatos', array( 'id' => 'pk', 'descripcion' => 'string NOT NULL', - )); + ), 'ENGINE=InnoDB CHARSET=utf8'); } public function safeDown() { diff --git a/www/protected/migrations/m121014_171025_tbl_idiomas_tecnologias_titulaciones.php b/www/protected/migrations/m121014_171025_tbl_idiomas_tecnologias_titulaciones.php index 6c8ea2f..94f45b5 100644 --- a/www/protected/migrations/m121014_171025_tbl_idiomas_tecnologias_titulaciones.php +++ b/www/protected/migrations/m121014_171025_tbl_idiomas_tecnologias_titulaciones.php @@ -5,30 +5,23 @@ class m121014_171025_tbl_idiomas_tecnologias_titulaciones extends CDbMigration { public function safeUp() { $this->createTable('tbl_idiomas', array( 'id' => 'pk', - 'descripcion' => 'string NOT NULL', - )); + 'descripcion' => 'string NOT NULL', + ), 'ENGINE=InnoDB CHARSET=utf8'); $this->createTable('tbl_tecnologias', array( 'id' => 'pk', 'descripcion' => 'string NOT NULL', - )); + ), 'ENGINE=InnoDB CHARSET=utf8'); - $this->createTable('tbl_perfiles_tecnicos', array( + $this->createTable('tbl_titulaciones', array( 'id' => 'pk', 'descripcion' => 'string NOT NULL', - )); - - $this->createTable('tbl_perfiles_funcionales', array( - 'id' => 'pk', - 'descripcion' => 'string NOT NULL', - )); + ), 'ENGINE=InnoDB CHARSET=utf8'); } public function safeDown() { - $this->dropTable('tbl_perfiles_tecnicos'); - - $this->dropTable('tbl_perfiles_funcionales'); - + $this->dropTable('tbl_titulaciones'); + $this->dropTable('tbl_tecnologias'); $this->dropTable('tbl_idiomas'); diff --git a/www/protected/migrations/m121014_171033_tbl_candidatos.php b/www/protected/migrations/m121014_171033_tbl_candidatos.php index 9e63ab4..5532b64 100644 --- a/www/protected/migrations/m121014_171033_tbl_candidatos.php +++ b/www/protected/migrations/m121014_171033_tbl_candidatos.php @@ -43,7 +43,7 @@ class m121014_171033_tbl_candidatos extends CDbMigration { 'disponibilidad_guardias' => 'string', 'disponibilidad_viajar' => 'string', 'disponibilidad_proyectos_internacionales' => 'string', - )); + ), 'ENGINE=InnoDB CHARSET=utf8'); } public function safeDown() { diff --git a/www/protected/migrations/m121014_171456_tbl_candidatos_idiomas.php b/www/protected/migrations/m121014_171456_tbl_candidatos_idiomas.php index 3867b4f..5e9838d 100644 --- a/www/protected/migrations/m121014_171456_tbl_candidatos_idiomas.php +++ b/www/protected/migrations/m121014_171456_tbl_candidatos_idiomas.php @@ -9,7 +9,7 @@ class m121014_171456_tbl_candidatos_idiomas extends CDbMigration { 'idioma' => 'string NOT NULL', 'conversacion' => 'string', 'lectura_traduccion' => 'string', - )); + ), 'ENGINE=InnoDB CHARSET=utf8'); $this->addForeignKey('fk_candidatos_idiomas_1', 'tbl_candidatos_idiomas', 'candidato_id', 'tbl_candidatos', 'id', 'CASCADE', 'CASCADE'); } diff --git a/www/protected/migrations/m121014_171501_tbl_candidatos_titulaciones.php b/www/protected/migrations/m121014_171501_tbl_candidatos_titulaciones.php index 002c33a..d0fe477 100644 --- a/www/protected/migrations/m121014_171501_tbl_candidatos_titulaciones.php +++ b/www/protected/migrations/m121014_171501_tbl_candidatos_titulaciones.php @@ -7,7 +7,7 @@ class m121014_171501_tbl_candidatos_titulaciones extends CDbMigration { 'id' => 'pk', 'candidato_id' => 'integer NOT NULL', 'titulacion' => 'string NOT NULL', - )); + ), 'ENGINE=InnoDB CHARSET=utf8'); $this->addForeignKey('fk_candidatos_titulaciones_1', 'tbl_candidatos_titulaciones', 'candidato_id', 'tbl_candidatos', 'id', 'CASCADE', 'CASCADE'); } diff --git a/www/protected/migrations/m121024_103612_tbl_perfiles.php b/www/protected/migrations/m121024_103612_tbl_perfiles.php new file mode 100644 index 0000000..7e0c6a4 --- /dev/null +++ b/www/protected/migrations/m121024_103612_tbl_perfiles.php @@ -0,0 +1,22 @@ +createTable('tbl_perfiles_tecnicos', array( + 'id' => 'pk', + 'descripcion' => 'string NOT NULL', + ), 'ENGINE=InnoDB CHARSET=utf8'); + + $this->createTable('tbl_perfiles_funcionales', array( + 'id' => 'pk', + 'descripcion' => 'string NOT NULL', + ), 'ENGINE=InnoDB CHARSET=utf8'); + } + + public function safeDown() { + $this->dropTable('tbl_perfiles_tecnicos'); + $this->dropTable('tbl_perfiles_funcionales'); + } + +} \ No newline at end of file diff --git a/www/protected/models/CandidatoTitulacion.php b/www/protected/models/CandidatoTitulacion.php new file mode 100644 index 0000000..d4feb67 --- /dev/null +++ b/www/protected/models/CandidatoTitulacion.php @@ -0,0 +1,90 @@ + true), + array('titulacion', 'length', 'max' => 255), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, candidato_id, titulacion', 'safe', 'on' => 'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + 'candidato' => array(self::BELONGS_TO, 'Candidato', 'candidato_id'), + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() { + return array( + 'id' => 'ID', + 'candidato_id' => 'Candidato', + 'titulacion' => 'Titulación', + ); + } + + /** + * Retrieves a list of models based on the current search/filter conditions. + * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. + */ + public function search() { + // Warning: Please modify the following code to remove attributes that + // should not be searched. + + $criteria = new CDbCriteria; + + $criteria->compare('id', $this->id); + $criteria->compare('candidato_id', $this->candidato_id); + $criteria->compare('titulacion', $this->titulacion, true); + + return new CActiveDataProvider($this, array( + 'criteria' => $criteria, + )); + } + +} \ No newline at end of file diff --git a/www/protected/models/Titulacion.php b/www/protected/models/Titulacion.php index fea475e..9c6e61e 100644 --- a/www/protected/models/Titulacion.php +++ b/www/protected/models/Titulacion.php @@ -45,6 +45,15 @@ class Titulacion extends CActiveRecord { ); } + /** + * @return array Default scope for this model. + */ + public function defaultScope() { + return array( + 'order' => 'descripcion' + ); + } + /** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. diff --git a/www/themes/profind/js/profind-general.js b/www/themes/profind/js/profind-general.js index 399e9d2..2986584 100644 --- a/www/themes/profind/js/profind-general.js +++ b/www/themes/profind/js/profind-general.js @@ -42,10 +42,7 @@ $(document).ready(function() { } //* external links //profind_external_links.init(); - - /* Chosen */ - //profind_chosen.init(); - + //* accordion icons profind_acc_icons.init(); @@ -68,17 +65,6 @@ profind_external_links = { } }; -//* external links -profind_chosen = { - init: function() { - $('.chosen').chosen({ - allow_single_deselect: true, - no_results_text: 'No existe' - }); - } -}; - - profind_sidebar = { init: function() { // sidebar onload state diff --git a/www/themes/profind/js/profind-template.js b/www/themes/profind/js/profind-template.js index 0203a86..f527d63 100644 --- a/www/themes/profind/js/profind-template.js +++ b/www/themes/profind/js/profind-template.js @@ -10,12 +10,15 @@ $(document).ready(function() { profind_template = { init: function() { profind_template.hideHeaderIfEmpty(); + profind_template.onAppend(); $(".add").click(function(){ var template = jQuery.format(jQuery.trim($(this).siblings(".template").val())); var place = $(this).parents(".templateFrame:first").children(".templateTarget"); var i = place.find(".rowIndex").length>0 ? place.find(".rowIndex").max()+1 : 0; $(template(i)).appendTo(place); profind_template.showHeader(this); + profind_template.onAppend(); + return false; }); @@ -41,5 +44,9 @@ profind_template = { var place = $(element).parents(".templateFrame:first"); $(place).children('.templateHead').show(); $(place).addClass('table'); + }, + + onAppend: function() { + } }; diff --git a/www/themes/profind/lib/chosen/LICENSE.md b/www/themes/profind/lib/chosen/LICENSE.md deleted file mode 100644 index 80109bb..0000000 --- a/www/themes/profind/lib/chosen/LICENSE.md +++ /dev/null @@ -1,24 +0,0 @@ -# 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/www/themes/profind/lib/chosen/README.md b/www/themes/profind/lib/chosen/README.md deleted file mode 100644 index a5039ef..0000000 --- a/www/themes/profind/lib/chosen/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# 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/www/themes/profind/lib/chosen/VERSION b/www/themes/profind/lib/chosen/VERSION deleted file mode 100644 index 95a773d..0000000 --- a/www/themes/profind/lib/chosen/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.9.8 diff --git a/www/themes/profind/lib/chosen/chosen.jquery.min.js b/www/themes/profind/lib/chosen/chosen.jquery.min.js deleted file mode 100644 index a891f75..0000000 --- a/www/themes/profind/lib/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 a;a=function(){function a(){this.options_index=0,this.parsed=[]}return a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d"+a.html+"")},a.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()},a.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){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:a.preventDefault();if(this.results_showing)return this.result_select(a);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()}},a.prototype.generate_field_id=function(){var a;return a=this.generate_random_id(),this.form_field.id=a,a},a.prototype.generate_random_char=function(){var a,b,c;return a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",c=Math.floor(Math.random()*a.length),b=a.substring(c,c+1)},a}(),b.AbstractChosen=a}.call(this),function(){var a,b,c,d,e=Object.prototype.hasOwnProperty,f=function(a,b){function d(){this.constructor=a}for(var c in b)e.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};d=this,a=jQuery,a.fn.extend({chosen:function(c){return!a.browser.msie||a.browser.version!=="6.0"&&a.browser.version!=="7.0"?this.each(function(d){var e;e=a(this);if(!e.hasClass("chzn-done"))return e.data("chosen",new b(this,c))}):this}}),b=function(b){function e(){e.__super__.constructor.apply(this,arguments)}return f(e,b),e.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},e.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},e.prototype.set_up_html=function(){var b,d,e,f;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=this.form_field_jq.outerWidth(),b=a("
            ",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.html('
              '):b.html(''+this.default_text+'
                '),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"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(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build(),this.set_tab_index(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},e.prototype.register_observers=function(){var a=this;return this.container.mousedown(function(b){return a.container_mousedown(b)}),this.container.mouseup(function(b){return a.container_mouseup(b)}),this.container.mouseenter(function(b){return a.mouse_enter(b)}),this.container.mouseleave(function(b){return a.mouse_leave(b)}),this.search_results.mouseup(function(b){return a.search_results_mouseup(b)}),this.search_results.mouseover(function(b){return a.search_results_mouseover(b)}),this.search_results.mouseout(function(b){return a.search_results_mouseout(b)}),this.form_field_jq.bind("liszt:updated",function(b){return a.results_update_field(b)}),this.search_field.blur(function(b){return a.input_blur(b)}),this.search_field.keyup(function(b){return a.keyup_checker(b)}),this.search_field.keydown(function(b){return a.keydown_checker(b)}),this.is_multiple?(this.search_choices.click(function(b){return a.choices_click(b)}),this.search_field.focus(function(b){return a.input_focus(b)})):this.container.click(function(a){return a.preventDefault()})},e.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)},e.prototype.container_mousedown=function(b){var c;if(!this.is_disabled)return c=b!=null?a(b.target).hasClass("search-choice-close"):!1,b&&b.type==="mousedown"&&!this.results_showing&&b.stopPropagation(),!this.pending_destroy_click&&!c?(this.active_field?!this.is_multiple&&b&&(a(b.target)[0]===this.selected_item[0]||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},e.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(a)},e.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},e.prototype.close_field=function(){return a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),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()},e.prototype.activate_field=function(){return!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},e.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},e.prototype.results_build=function(){var a,b,c,e,f;this.parsing=!0,this.results_data=d.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.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),a="",f=this.results_data;for(c=0,e=f.length;c'+a("
                ").text(b.label).html()+"")},e.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c'+b.html+''),d=a("#"+c).find("a").first(),d.click(function(a){return e.choice_destroy_link_click(a)}))},e.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),this.is_disabled?b.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy(a(b.target)))},e.prototype.choice_destroy=function(a){return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel")),a.parents("li").first().remove()},e.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()},e.prototype.results_reset_cleanup=function(){return this.selected_item.find("abbr").remove()},e.prototype.result_select=function(a){var b,c,d,e;if(this.result_highlight)return b=this.result_highlight,c=b.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=b,this.selected_item.removeClass("chzn-default")),b.addClass("result-selected"),e=c.substr(c.lastIndexOf("_")+1),d=this.results_data[e],d.selected=!0,this.form_field.options[d.options_index].selected=!0,this.is_multiple?this.choice_build(d):(this.selected_item.find("span").first().text(d.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!a.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change",{selected:this.form_field.options[d.options_index].value}),this.search_field_scale()},e.prototype.result_activate=function(a){return a.addClass("active-result")},e.prototype.result_deactivate=function(a){return a.removeClass("active-result")},e.prototype.result_deselect=function(b){var c,d;return d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.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[d.options_index].value}),this.search_field_scale()},e.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('')},e.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;this.no_results_clear(),j=0,k=this.search_field.val()===this.default_text?"":a("
                ").text(a.trim(this.search_field.val())).html(),g=this.search_contains?"":"^",f=new RegExp(g+k.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),n=new RegExp(k.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),s=this.results_data;for(o=0,q=s.length;o=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(p=0,r=e.length;p"+c.html.substr(l+k.length),m=m.substr(0,l)+""+m.substr(l)):m=c.html,h.html(m),this.result_activate(h),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&i===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(h))}}return j<1&&k.length?this.no_results(k):this.winnow_results_set_highlight()},e.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;d'+this.results_none_found+' ""'),c.find("span").first().html(b),this.search_results.append(c)},e.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},e.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},e.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},e.prototype.keydown_backstroke=function(){return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(this.pending_backstroke=this.search_container.siblings("li.search-choice").last(),this.pending_backstroke.addClass("search-choice-focus"))},e.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},e.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},e.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height(),this.dropdown.css({top:b+"px"})}},e.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},e}(AbstractChosen),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}.call(this); \ No newline at end of file diff --git a/www/themes/profind/lib/chosen/example.jquery.html b/www/themes/profind/lib/chosen/example.jquery.html deleted file mode 100644 index 76a7363..0000000 --- a/www/themes/profind/lib/chosen/example.jquery.html +++ /dev/null @@ -1,1314 +0,0 @@ - - - - - - - -
                -
                -

                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 - -
                -
                - -

                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/www/themes/profind/views/candidato/__idiomas.php b/www/themes/profind/views/candidato/__idiomas.php index 5b7d79a..8b32ef5 100644 --- a/www/themes/profind/views/candidato/__idiomas.php +++ b/www/themes/profind/views/candidato/__idiomas.php @@ -2,87 +2,94 @@ clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.calculation.min.js', CClientScript::POS_END); ?> clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/profind-template.js', CClientScript::POS_END); ?> -
                -
                -
                - -
                - - - - - - - - - - - - idiomas as $i=>$idioma): ?> - - - - - - - - - - - - - -
                - findAll(), 'descripcion', 'descripcion'), - array('class' => 'span12') - ); - ?> - - opcionesNivel, - array('class' => 'span12') - ); - ?> - - opcionesNivel, - array('class' => 'span12') - ); - ?> - - 'pk')); ?> - - 'to_remove')); ?> - - -
                - - -
                -
                +clientScript->registerScript('js_chosen', $js_chosen, CClientScript::POS_END); +?> + +
                +
                + +
                + + + + + + + + + + + + idiomas as $i=>$idioma): ?> + + + + + + + + + + + + + +
                + findAll(), 'descripcion', 'descripcion'), + array('class' => 'span12 chosen') + ); + ?> + + opcionesNivel, + array('class' => 'span12 chosen') + ); + ?> + + opcionesNivel, + array('class' => 'span12 chosen') + ); + ?> + + 'pk')); ?> + + 'to_remove')); ?> + + +
                + + +
                -
                \ No newline at end of file +
                diff --git a/www/themes/profind/views/candidato/__titulaciones.php b/www/themes/profind/views/candidato/__titulaciones.php new file mode 100644 index 0000000..a1b4f65 --- /dev/null +++ b/www/themes/profind/views/candidato/__titulaciones.php @@ -0,0 +1,23 @@ +
                +
                + +
                + findAll(), 'descripcion', 'descripcion'); + $seleccion = ($candidato->titulaciones) ? CHtml::listData($candidato->titulaciones, 'titulacion', 'titulacion') : ''; + + $this->widget('ext.yii-chosen.Chosen', array( + 'name' => 'CandidatoTitulacion[]', + 'value' => $seleccion, + 'data' => $lista, + 'placeholderSingle' => Yii::t('profind', 'Seleccione las titulaciones'), + 'htmlOptions' => array( + 'multiple' => true, + 'empty' => '', + 'class' => 'span12' + ) + )); + ?> +
                +
                +
                diff --git a/www/themes/profind/views/candidato/_form.php b/www/themes/profind/views/candidato/_form.php index 6bee016..b47664b 100644 --- a/www/themes/profind/views/candidato/_form.php +++ b/www/themes/profind/views/candidato/_form.php @@ -1,21 +1,7 @@ clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/bootstrap-inputmask.js', CClientScript::POS_END); ?> clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/bootstrap-fileupload.js', CClientScript::POS_END); ?> -clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/lib/chosen/chosen.jquery.min.js', CClientScript::POS_END); ?> - -clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/lib/chosen/chosen.css'); ?> clientScript->registerScript('js_chosen', $js_chosen, CClientScript::POS_END); $js_quitar_foto = <<clientScript->registerScript('js_quitar_foto', $js_quitar_foto, CCli $js_init = <<beginWidget('CActiveForm', array( labelEx($candidato, 'lugar_nacimiento', array('class' => 'control-label')); ?>
                findAll(), 'id', 'poblacion'); - echo $form->dropDownList($candidato, 'lugar_nacimiento', $lista, array( - 'empty' => '', - 'data-placeholder' => Yii::t('profind', 'Elegir la localidad...'), - 'class' => 'span6 localidad', + $lista = CHtml::listData(Poblacion::model()->findAll(), 'poblacion', 'poblacion'); + $this->widget('ext.yii-chosen.Chosen', array( + 'name' => CHtml::activeName($candidato, 'lugar_nacimiento'), + 'value' => $candidato->lugar_nacimiento, + 'data' => $lista, + 'placeholderSingle' => Yii::t('profind', 'Seleccione una localidad'), + 'htmlOptions' => array( + 'empty' => '', + 'class' => 'span12' + ) )); ?>
                @@ -154,7 +144,7 @@ $form = $this->beginWidget('CActiveForm', array(
                labelEx($candidato, 'email', array('class' => 'control-label')); ?>
                -
                +
                textField($candidato, 'email', array('class' => 'span12')); ?>
                @@ -177,6 +167,12 @@ $form = $this->beginWidget('CActiveForm', array(
                +
                + + renderPartial('__titulaciones', array('candidato' => $candidato)); ?> + renderPartial('__idiomas', array('candidato' => $candidato)); ?> +
                +
                @@ -219,6 +215,7 @@ $form = $this->beginWidget('CActiveForm', array(
                +
                @@ -267,7 +264,6 @@ $form = $this->beginWidget('CActiveForm', array(
                -renderPartial('__idiomas', array('candidato' => $candidato)); ?>
                diff --git a/www/themes/profind/views/usuario/_form.php b/www/themes/profind/views/usuario/_form.php index 042bfae..7dc3caf 100644 --- a/www/themes/profind/views/usuario/_form.php +++ b/www/themes/profind/views/usuario/_form.php @@ -1,8 +1,5 @@ clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/bootstrap-inputmask.js'); ?> clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/bootstrap-fileupload.js'); ?> -clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/lib/chosen/chosen.jquery.min.js'); ?> - -clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/lib/chosen/chosen.css'); ?> clientScript->registerScript( @@ -102,13 +99,17 @@ Yii::app()->clientScript->registerScript( labelEx($model, 'localidad', array('class' => 'control-label')); ?>
                findAll(), 'id', 'poblacion'); - echo $form->dropDownList( - $model, 'localidad', $lista, array( - 'empty' => '', - 'data-placeholder' => Yii::t('profind', 'Elegir la localidad...'), - 'class' => 'chzn_a input-xlarge', - )); + $lista = CHtml::listData(Poblacion::model()->findAll(), 'poblacion', 'poblacion'); + $this->widget('ext.yii-chosen.Chosen', array( + 'name' => CHtml::activeName($model, 'localidad'), + 'value' => $model->localidad, + 'data' => $lista, + 'placeholderSingle' => Yii::t('profind', 'Seleccione una localidad'), + 'htmlOptions' => array( + 'empty' => '', + 'class' => 'input-xlarge' + ) + )); ?>