src/js/widgets/tagCloudWidget.js
branchpopcorn-port
changeset 733 a4dda820d9ee
parent 728 9ee6badcb160
child 736 eff5206f6877
equal deleted inserted replaced
732:823fa16807d4 733:a4dda820d9ee
     7 IriSP.TagCloudWidget.prototype.draw = function() {
     7 IriSP.TagCloudWidget.prototype.draw = function() {
     8     
     8     
     9     var _stopwords = [
     9     var _stopwords = [
    10             'aussi', 'and', 'avec', 'aux', 'car', 'cette', 'comme', 'dans', 'donc', 'des', 'elle', 'est',
    10             'aussi', 'and', 'avec', 'aux', 'car', 'cette', 'comme', 'dans', 'donc', 'des', 'elle', 'est',
    11             'être', 'eux', 'fait', 'ici', 'ils', 'les', 'leur', 'leurs', 'mais', 'mes', 'même', 'mon', 'notre',
    11             'être', 'eux', 'fait', 'ici', 'ils', 'les', 'leur', 'leurs', 'mais', 'mes', 'même', 'mon', 'notre',
    12             'nos', 'nous', 'ont', 'par', 'pas', 'peu', 'pour', 'que', 'qui', 'ses' ,'son', 'sont', 'sur',
    12             'non', 'nos', 'nous', 'ont', 'par', 'pas', 'peu', 'pour', 'que', 'qui', 'ses' ,'son', 'sont', 'sur',
    13             'tes', 'très', 'the', 'ton', 'tous', 'tout', 'une', 'votre', 'vos', 'vous'
    13             'tes', 'très', 'the', 'ton', 'tous', 'tout', 'une', 'votre', 'vos', 'vous'
    14         ],
    14         ],
    15         _regexpword = /[^\s\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g,
    15         _regexpword = /[^\s\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g,
    16         _words = {},
    16         _words = {},
    17         _showTitle = !this._config.excludeTitle,
    17         _showTitle = !this._config.excludeTitle,
    46         .first(_tagCount)
    46         .first(_tagCount)
    47         .value();
    47         .value();
    48     var _max = _words[0].count,
    48     var _max = _words[0].count,
    49         _min = Math.min(_words[_words.length - 1].count, _max - 1),
    49         _min = Math.min(_words[_words.length - 1].count, _max - 1),
    50         _scale = 16 / Math.sqrt(_max - _min),
    50         _scale = 16 / Math.sqrt(_max - _min),
       
    51         _this = this,
    51         _html = '<ul>'
    52         _html = '<ul>'
    52             + IriSP._(_words)
    53             + IriSP._(_words)
    53                 .chain()
    54                 .chain()
    54                 .shuffle()
    55                 .shuffle()
    55                 .map(function(_word) {
    56                 .map(function(_word) {
    64                 .join("")
    65                 .join("")
    65             + '</ul>';
    66             + '</ul>';
    66     this.selector
    67     this.selector
    67         .addClass("Ldt-TagCloud")
    68         .addClass("Ldt-TagCloud")
    68         .html(_html);
    69         .html(_html);
    69     
    70     this.selector.find("li").click(function() {
       
    71         var _txt = this.textContent.replace(/(^[\s]+|[\s]+$)/g,'');
       
    72         _this._Popcorn.trigger("IriSP.search", _txt);
       
    73     });
       
    74     this._Popcorn.listen("IriSP.search", IriSP.wrap(this, function(searchString) {
       
    75         var _rgxp = new RegExp("(" + searchString.replace(/(\W)/g,'\\$1') + ")","gi");
       
    76         this.selector.find("li").each(function(_i, _e) {
       
    77             _e.innerHTML = searchString.length ?
       
    78                 _e.textContent.replace(_rgxp,'<span class="Ldt-TagCloud-actif">$1</span>')
       
    79                 : _e.textContent;
       
    80         });
       
    81     }));
       
    82     this._Popcorn.listen("IriSP.search.closed", IriSP.wrap(this, this.searchFieldClosedHandler));
       
    83     this._Popcorn.listen("IriSP.search.cleared", IriSP.wrap(this, this.searchFieldClearedHandler));
    70 }
    84 }
       
    85 
       
    86 IriSP.TagCloudWidget.prototype.endsearch = function() {
       
    87     this.selector.find("li").each(function(_i, _e) {
       
    88         _e.innerHTML = _e.textContent;
       
    89     });
       
    90 }