better polemic mdp config
authorcavaliet
Tue, 04 Nov 2014 18:03:34 +0100
changeset 1332 600dbe94e74c
parent 1330 b50d5f579462
child 1333 c59a51cf2dda
better polemic mdp config
src/ldt/ldt/static/ldt/metadataplayer/Polemic.js
--- a/src/ldt/ldt/static/ldt/metadataplayer/Polemic.js	Thu Oct 16 16:18:20 2014 +0200
+++ b/src/ldt/ldt/static/ldt/metadataplayer/Polemic.js	Tue Nov 04 18:03:34 2014 +0100
@@ -24,6 +24,7 @@
     annotation_type : "tweet",
     defaultcolor : "#585858",
     foundcolor : "#fc00ff",
+    search_by_default: true,
     polemics : [
         {
             "name" : "OK",
@@ -87,9 +88,9 @@
                 }),
                 polemicStacks : []
             };
-            
+        
         for (var _j = 0; _j < this.polemics.length; _j++) {
-            var _polemic = _res.annotations.searchByDescription(this.polemics[_j].keywords);
+            var _polemic = this.search_by_default ? _res.annotations.searchByDescription(this.polemics[_j].keywords) : _res.annotations.searchByTextFields(this.polemics[_j].keywords);
             _count += _polemic.length;
             _res.polemicStacks.push(_polemic);
         }
@@ -107,7 +108,7 @@
             this.height = (2 + _max) * this.element_height;
             this.$zone.css({
                 width: this.width + "px",
-                height: this.height + "px",
+                height: (this.height+2) + "px",
                 position: "relative"
             });
             
@@ -139,21 +140,22 @@
                     return false;
                 });
                 IriSP.attachDndData(_el, {
-                	title: _annotation.title,
-                	description: _annotation.description,
-                	image: _annotation.thumbnail,
-                	uri: (typeof _annotation.url !== "undefined" 
-		                ? _annotation.url
-		                : (document.location.href.replace(/#.*$/,'') + '#id='  + _annotation.id))
+                    title: _annotation.title,
+                    description: _annotation.description,
+                    image: _annotation.thumbnail,
+                    uri: (typeof _annotation.url !== "undefined" 
+                        ? _annotation.url
+                        : (document.location.href.replace(/#.*$/,'') + '#id='  + _annotation.id))
                 });
-            	// test if annotation has several colors.
-            	var colAr = [];
-            	for (var _j = 0; _j < _this.polemics.length; _j++) {
-            		if( IriSP.Model.regexpFromTextOrArray( _this.polemics[_j].keywords ).test( _annotation.title ) ){
-            			colAr.push(_this.polemics[_j].color);
-            		}
+                // test if annotation has several colors.
+                var colAr = [];
+                for (var _j = 0; _j < _this.polemics.length; _j++) {
+                    if( IriSP.Model.regexpFromTextOrArray( _this.polemics[_j].keywords ).test( this.search_by_default ? _annotation.title : _annotation.getTagTexts()) ){
+                        colAr.push(_this.polemics[_j].color);
+                    }
                 }
-            	// display annotation
+                
+                // display annotation
                 _annotation.on("select", function() {
                     if (_this.tooltip) {
                         _this.tooltip.show(
@@ -232,7 +234,7 @@
         this.height = (2 + this.max_elements) * this.element_height;
         this.$zone.css({
             width: this.width + "px",
-            height: this.height + "px",
+            height: (this.height+2) + "px",
             position: "relative"
         });