From abfc928ee730dd0aa4a2b856da4169c090ea129f Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 4 May 2012 18:21:51 +0000 Subject: [PATCH] Regroupement du script autocompleted.js dans fields.js --- application/controllers/IndexController.php | 5 +- .../themes/default/scripts/autocompleted.js | 128 ----------------- public/themes/default/scripts/fields.js | 129 ++++++++++++++++++ 3 files changed, 131 insertions(+), 131 deletions(-) delete mode 100644 public/themes/default/scripts/autocompleted.js diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 6944e9a0..a4f4a71b 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -6,9 +6,7 @@ Class IndexController extends Zend_Controller_Action { $this->view->headScript() ->appendFile('/themes/default/scripts/jquery.jstree.js', 'text/javascript') - ->appendFile('/themes/default/scripts/fields.js', 'text/javascript') - ->appendFile('/themes/default/scripts/autocompleted.js', 'text/javascript'); - /* Initialize action controller here */ + ->appendFile('/themes/default/scripts/fields.js', 'text/javascript'); } public function indexAction() @@ -25,6 +23,7 @@ Class IndexController extends Zend_Controller_Action $ajax = $this->getRequest()->getParam('ajax'); if($ajax) $this->_helper->layout()->disableLayout(); + require_once 'Scores/SessionCiblage.php'; require_once 'Scores/Field.php'; $session = new SessionCiblage(); diff --git a/public/themes/default/scripts/autocompleted.js b/public/themes/default/scripts/autocompleted.js deleted file mode 100644 index 989b80b8..00000000 --- a/public/themes/default/scripts/autocompleted.js +++ /dev/null @@ -1,128 +0,0 @@ -function split( val ) { - return val.split( /,\s*/ ); -} -function extractLast( term ) { - return split( term ).pop(); -} -$(document).ready(function(){ - - $('textarea.complitedCj').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/juridique/completed', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - $('textarea.complitedCj_ex').autocomplete({ - delay:300, - source: function(request, response) { - $.getJSON('/juridique/completed', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - $('textarea.complitedNaf').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/economique/completed', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - $('#textarea_adr_dept').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/geographique/completed/dep/1', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - $('#textarea_adr_reg').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/geographique/completed/reg/1', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - $('#textarea_adr_dept').val(terms.join( "," )+$('#textarea_adr_dept').val()); - $(this).val(''); - return false; - } - }); - - $('textarea.complitedadr_com').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/geographique/completed/adr_com/1', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - $('textarea.complitedadr_com_ex').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/geographique/completed/adr_com_ex/1', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); -}); \ No newline at end of file diff --git a/public/themes/default/scripts/fields.js b/public/themes/default/scripts/fields.js index 93743c12..98e7bc8d 100644 --- a/public/themes/default/scripts/fields.js +++ b/public/themes/default/scripts/fields.js @@ -203,6 +203,127 @@ $(document).ready(function() set($(this).attr('name'), 0); } }); + + $('textarea.complitedCj').autocomplete({ + delay:600, + source: function(request, response) { + $.getJSON('/juridique/completed', { q: extractLast( request.term ) }, + function(data) { response(data); } + ); + }, + select: function(event, ui){ + var terms = split( this.value ); + terms.pop(); + terms.push( ui.item.value ); + terms.push( "" ); + this.value = terms.join( ", " ); + return false; + } + }); + + $('textarea.complitedCj_ex').autocomplete({ + delay:300, + source: function(request, response) { + $.getJSON('/juridique/completed', { q: extractLast( request.term ) }, + function(data) { response(data); } + ); + }, + select: function(event, ui){ + var terms = split( this.value ); + terms.pop(); + terms.push( ui.item.value ); + terms.push( "" ); + this.value = terms.join( ", " ); + return false; + } + }); + + $('textarea.complitedNaf').autocomplete({ + delay:600, + source: function(request, response) { + $.getJSON('/economique/completed', { q: extractLast( request.term ) }, + function(data) { response(data); } + ); + }, + select: function(event, ui){ + var terms = split( this.value ); + terms.pop(); + terms.push( ui.item.value ); + terms.push( "" ); + this.value = terms.join( ", " ); + return false; + } + }); + + $('#textarea_adr_dept').autocomplete({ + delay:600, + source: function(request, response) { + $.getJSON('/geographique/completed/dep/1', { q: extractLast( request.term ) }, + function(data) { response(data); } + ); + }, + select: function(event, ui){ + var terms = split( this.value ); + terms.pop(); + terms.push( ui.item.value ); + terms.push( "" ); + this.value = terms.join( ", " ); + return false; + } + }); + + $('#textarea_adr_reg').autocomplete({ + delay:600, + source: function(request, response) { + $.getJSON('/geographique/completed/reg/1', { q: extractLast( request.term ) }, + function(data) { response(data); } + ); + }, + select: function(event, ui){ + var terms = split( this.value ); + terms.pop(); + terms.push( ui.item.value ); + terms.push( "" ); + $('#textarea_adr_dept').val(terms.join( "," )+$('#textarea_adr_dept').val()); + $(this).val(''); + return false; + } + }); + + $('textarea.complitedadr_com').autocomplete({ + delay:600, + source: function(request, response) { + $.getJSON('/geographique/completed/adr_com/1', { q: extractLast( request.term ) }, + function(data) { response(data); } + ); + }, + select: function(event, ui){ + var terms = split( this.value ); + terms.pop(); + terms.push( ui.item.value ); + terms.push( "" ); + this.value = terms.join( ", " ); + return false; + } + }); + + $('textarea.complitedadr_com_ex').autocomplete({ + delay:600, + source: function(request, response) { + $.getJSON('/geographique/completed/adr_com_ex/1', { q: extractLast( request.term ) }, + function(data) { response(data); } + ); + }, + select: function(event, ui){ + var terms = split( this.value ); + terms.pop(); + terms.push( ui.item.value ); + terms.push( "" ); + this.value = terms.join( ", " ); + return false; + } + }); + }); function set(key, value) @@ -228,3 +349,11 @@ function set(key, value) }, 'json') .error(function(){ alert('error'); }); } + +function split( val ) { + return val.split( /,\s*/ ); +} + +function extractLast( term ) { + return split( term ).pop(); +} \ No newline at end of file