source: spip-zone/_plugins_/socialtags/socialtags.js.html @ 28930

Last change on this file since 28930 was 27125, checked in by paladin@…, 12 years ago

si besoin, rendre compatible avec anciennes versions de jQuery (SPIP 192x)

File size: 1.4 KB
Line 
1#HTTP_HEADER{Content-Type: text/javascript}
2// socialtags.js
3
4// 'ajouter un bookmark' ne marche que sous IE
5// les tuyaux trouves pour FF ou Opera sont creves
6;var socialtags_addfavorite = function(u,t){
7        if(document.all)window.external.AddFavorite(u,t);
8};
9(function($) { $(function(){
10var selector = $('[(#CONFIG{socialtags/jsselector})]');
11if (!selector.length) return;
12var socialtags = [(#CONFIG{socialtags/tags}|socialtags_json)];
13var title = $('title').text() ||'';
14// [@attr] style selectors removed in jQuery 1.3 (voir http://docs.jquery.com/Selectors)
15// si besoin, rendre compatible avec anciennes versions de jQuery (SPIP 192x)
16var jqss = (jQuery.fn.jquery <= '1.2.6') ? '@' : '';
17var description = ($('meta['+jqss+'name=description]').attr('content') || '').substr(0,250);
18var cano = $('link['+jqss+'rel=canonical]')[0];
19var url = cano ? cano.href : document.location.href;
20var ul = $('<ul><\/ul>');
21var esc = function(x){return encodeURIComponent(x).replace(/\s/g,' ');};
22
23$.each(socialtags, function(){ if (this.u) {
24        if (this.a == 'bookmark' && !document.all) return;
25
26        $('<a rel="nofollow"><img class="socialtags-hovers" src="'+ this.i +'"\/><\/a>')
27        .attr('href',
28                this.u
29                .replace(/%u/g, esc(url))
30                .replace(/%t/g, esc(title))
31                .replace(/%d/g, esc(description))
32        )
33        .attr('title', this.n)
34        .wrap('<li><\/li>')
35        .parent().appendTo(ul);
36}});
37
38selector.after(ul.wrap('<div class="socialtags"><\/div>').parent());
39
40}); })(jQuery);
Note: See TracBrowser for help on using the repository browser.