improve tag navigator. put the title of the next film in a tooltip V00.02
authorymh <ymh.work@gmail.com>
Tue, 04 May 2010 13:15:38 +0200
changeset 117 526020c82fc3
parent 116 4a55e2fafdd5
child 118 aad3c6a520ca
improve tag navigator. put the title of the next film in a tooltip
web/thdProject/apps/frontend/modules/reflex/actions/actions.class.php
web/thdProject/apps/frontend/modules/tag/templates/_tagNavigator.php
--- a/web/thdProject/apps/frontend/modules/reflex/actions/actions.class.php	Mon May 03 17:53:28 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/reflex/actions/actions.class.php	Tue May 04 13:15:38 2010 +0200
@@ -110,9 +110,18 @@
     {
       $primaryKeys[] = $res['id'];
     }
+    
+    $films = array();
+    if(!empty($primaryKeys)) {
+      $films_res = Doctrine::getTable('ThdFilm')->findByScoredId($primaryKeys);
+      foreach($films_res as $film) {
+      	$films[] = $film->toArray(false);
+      }
+    }
 
     $this->getResponse()->setHttpHeader('Content-Type','application/json; charset=utf-8');
-    return $this->renderText(json_encode($primaryKeys));
+    return $this->renderText(json_encode($films));
+    
   }
   
   
--- a/web/thdProject/apps/frontend/modules/tag/templates/_tagNavigator.php	Mon May 03 17:53:28 2010 +0200
+++ b/web/thdProject/apps/frontend/modules/tag/templates/_tagNavigator.php	Tue May 04 13:15:38 2010 +0200
@@ -11,6 +11,18 @@
 	</li>
 	<script type="text/javascript" charset="utf-8">
 	  //scale: ['-100%', '|', -50, '|', '0', '|', 50, '|', '100%'
+	    function updatelink(json_res, linkid) {
+            color =  json_res.length==0?"#990000":"#32cd32";
+            if(json_res.length == 0) {
+                $(linkid).parent().hide("fast");
+            }
+            else {
+                $(linkid).parent().show("fast");
+                $(linkid).attr("title", json_res[0]["title"]);
+            }
+                          
+            $(linkid).parent().css("background",color);
+	    }
       $(document).ready(function() {
     	    var url_<?php echo $i; ?> = "<?php echo url_for('@searchReflex?distance={0}&film_uniqueid='.$film->uniqueid.'&tag='.$tag); ?>";
     	    var urlTest_<?php echo $i; ?> = "<?php echo url_for('@testReflex?distance={0}&film_uniqueid='.$film->uniqueid.'&tag='.$tag); ?>";
@@ -25,30 +37,15 @@
 	                  limits: false,
 	                  callback: function(value) {
 	                      $("#tag_link_<?php echo $i; ?>").attr("href",url_<?php echo $i; ?>.replace("%7B0%7D", value.toString())); 
-	                      $.getJSON(urlTest_<?php echo $i; ?>.replace("%7B0%7D", value.toString()), function(json){
-	                           color =  json.length==0?"#990000":"#32cd32";
-	                           if(json.length == 0) {
-	                               $("#tag_link_<?php echo $i; ?>").parent().hide("fast");
-	                           }
-	                           else {
-	                               $("#tag_link_<?php echo $i; ?>").parent().show("fast");
-	                           }
-	            	                           
-	                           $("#tag_link_<?php echo $i; ?>").parent().css("background",color);
+	                      $.getJSON(urlTest_<?php echo $i; ?>.replace("%7B0%7D", value.toString()), function(json_res){
+	                    	  updatelink(json_res, "#tag_link_<?php echo $i; ?>");
 	                      });
 	                  },
 	                  });    	          
     	  value = $("#Slider_<?php echo $i; ?>").val();
           $("#tag_link_<?php echo $i; ?>").attr("href",url_<?php echo $i; ?>.replace("%7B0%7D", value.toString())); 
-          $.getJSON(urlTest_<?php echo $i; ?>.replace("%7B0%7D", value.toString()), function(json){
-               color = json.length==0?"#990000":"#32cd32";
-               if(json.length == 0) {
-                   $("#tag_link_<?php echo $i; ?>").parent().hide("fast");
-               }
-               else {
-            	   $("#tag_link_<?php echo $i; ?>").parent().show("fast");
-               }
-               $("#tag_link_<?php echo $i; ?>").parent().css("background",color);
+          $.getJSON(urlTest_<?php echo $i; ?>.replace("%7B0%7D", value.toString()), function(json_res){
+        	    updatelink(json_res, "#tag_link_<?php echo $i; ?>");
           });    	  
       });
     </script>