# HG changeset patch # User cavaliet # Date 1321356422 -3600 # Node ID 6c87166b819cb05e9969e532dfb8e4c8b52be0cc # Parent 38dcd2db04e4016fb6c741a7f225248369cb240c First step to add context search to a page. Works fine but needs to be improved with several list of selectors. diff -r 38dcd2db04e4 -r 6c87166b819c Controller/WikiTagController.php --- a/Controller/WikiTagController.php Thu Nov 10 12:40:22 2011 +0100 +++ b/Controller/WikiTagController.php Tue Nov 15 12:27:02 2011 +0100 @@ -59,7 +59,20 @@ } // ... so we create is json like {"":""},{"Créateur":"Créateur"},{"Datation":"Datation"},... $categories = json_encode($ar); - return $this->render('WikiTagBundle:WikiTag:javascript.html.twig', array('categories' => $categories,'tags_list' => $tags_list)); + return $this->render('WikiTagBundle:WikiTag:javascript.html.twig', array('categories' => $categories, 'tags_list' => $tags_list)); + } + + /** + * Renders the little html to add the javascript for context search + */ + public function addJavascriptForContextSearchAction($context_name) + { + // WARNING : PREREQUISITE : the request to add a tag needs the external document id, + // which is gotten by the jQuery call $('#wikitag_document_id').val() in the page. + // So the page holding this context search MUST have a input value with this id. + // We add the reactive selectors + $reactive_selectors = $this->container->getParameter("wiki_tag.reactive_selectors"); + return $this->render('WikiTagBundle:WikiTag:javascriptForContextSearch.html.twig', array('reactive_selectors' => $reactive_selectors)); } /** diff -r 38dcd2db04e4 -r 6c87166b819c DependencyInjection/Configuration.php --- a/DependencyInjection/Configuration.php Thu Nov 10 12:40:22 2011 +0100 +++ b/DependencyInjection/Configuration.php Tue Nov 15 12:27:02 2011 +0100 @@ -23,6 +23,7 @@ $rootNode ->children() ->scalarNode('route_for_documents_by_tag')->defaultNull()->end() + ->scalarNode('reactive_selectors')->defaultNull()->end() ->scalarNode('document_class')->isRequired()->end() ->scalarNode('document_id_column')->defaultValue('id')->end() ->end() diff -r 38dcd2db04e4 -r 6c87166b819c DependencyInjection/WikiTagExtension.php --- a/DependencyInjection/WikiTagExtension.php Thu Nov 10 12:40:22 2011 +0100 +++ b/DependencyInjection/WikiTagExtension.php Tue Nov 15 12:27:02 2011 +0100 @@ -45,5 +45,6 @@ $fields['tagsStr'] = array("type"=>"text"); $container->setParameter("wiki_tag.fields_all", $fields); $container->setParameter("wiki_tag.route_for_documents_by_tag", $config['route_for_documents_by_tag']); + $container->setParameter("wiki_tag.reactive_selectors", $config['reactive_selectors']); } } diff -r 38dcd2db04e4 -r 6c87166b819c Resources/public/css/wikiTag.css --- a/Resources/public/css/wikiTag.css Thu Nov 10 12:40:22 2011 +0100 +++ b/Resources/public/css/wikiTag.css Tue Nov 15 12:27:02 2011 +0100 @@ -91,26 +91,10 @@ #wikitag_context_div { width: 260px; border: 2px; - background: lightgreen; + background: #97fefd; display: none; float: none; position: absolute; } - -/* - - -#count_nav_top, -#count_nav_bottom { - text-align: right; -} -#count_nav_bottom p, -#count_nav_top p { - font-size: 12px; - font-weight : bold; -} - - -*/ diff -r 38dcd2db04e4 -r 6c87166b819c Resources/public/js/wikiTag.js --- a/Resources/public/js/wikiTag.js Thu Nov 10 12:40:22 2011 +0100 +++ b/Resources/public/js/wikiTag.js Tue Nov 15 12:27:02 2011 +0100 @@ -243,7 +243,9 @@ } } $(document).ready(function(){ - $(document).bind("mouseup", Kolich.Selector.mouseup); + for(c in reactive_selectors){ + $(reactive_selectors[c]).bind("mouseup", Kolich.Selector.mouseup); + } }); // Function to close the context window diff -r 38dcd2db04e4 -r 6c87166b819c Resources/views/WikiTag/javascript.html.twig --- a/Resources/views/WikiTag/javascript.html.twig Thu Nov 10 12:40:22 2011 +0100 +++ b/Resources/views/WikiTag/javascript.html.twig Tue Nov 15 12:27:02 2011 +0100 @@ -29,10 +29,5 @@ $(document).ready(function(){ wikitag_init_tags_events(); wikitag_init_datasheet_events(); - - {% if tags_list!=true %} - wikitag_init_search_context_events(); - {% endif %} - }); \ No newline at end of file diff -r 38dcd2db04e4 -r 6c87166b819c Resources/views/WikiTag/javascriptForContextSearch.html.twig --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/views/WikiTag/javascriptForContextSearch.html.twig Tue Nov 15 12:27:02 2011 +0100 @@ -0,0 +1,8 @@ +{# partial display to add the needed Javascript for context search #} +{# We suppose the all the JS (jquery and stuffs and wikiTag.js) have already been loaded. See javascript.html.twig #} + \ No newline at end of file