PageSourceSearch

https://50wegezumjob.de/library/js/libs/angular-socialshare.js

js 50wegezumjob.de collected 2026-10-07 20:01:21 UTC 5,351 bytes, 172 lines download raw bytes

1// Code goes here
2'use strict';
3
4/*
5 *  * angular-socialshare v0.0.1
6 *   * ♡ CopyHeart 2014 by Dayanand Prabhu http://djds4rce.github.io
7 *    * Copying is an act of love. Please copy.
8 *     */
9
10angular.module('djds4rce.angular-socialshare', [])
11.factory('$FB',['$window',function($window){
12  return {
13    init: function(fbId){
14      if(fbId){
15        this.fbId = fbId;
16        $window.fbAsyncInit = function() {
17          FB.init({ 
18            appId: fbId, 
19            channelUrl: 'app/channel.html', 
20            status: true, 
21            xfbml: true 
22          });
23        };
24        (function(d){
25          var js,           
26          id = 'facebook-jssdk', 
27          ref = d.getElementsByTagName('script')[0];
28          if (d.getElementById(id)) {
29            return;
30          }
31
32          js = d.createElement('script'); 
33          js.id = id; 
34          js.async = true;
35          js.src = "//connect.facebook.net/en_US/all.js";
36
37          ref.parentNode.insertBefore(js, ref);
38
39        }(document));
40      }
41      else{
42        throw("FB App Id Cannot be blank");
43      }
44    }
45  };
46
47}]).directive('facebook', ['$rootScope','$timeout','$http', function($rootScope,$timeout,$http) {
48  return {
49    scope: {
50      shares: '=' 
51    }, 
52    transclude: true,
53    template: '<div ng-transclude></div>',
54    link: function(scope, element, attr) {
55      var triggerRelink = function(){
56        if(attr.shares){
57          $http.get('https://api.facebook.com/method/links.getStats?urls='+attr.url+'&format=json').success(function(res){
58            var x2js = new X2JS();
59            var json = x2js.xml_str2json(res);
60            try {
61              scope.shares = json.links_getStats_response.link_stat.share_count;
62            } catch (e) {
63              scope.shares = res[0].share_count;
64            }
65          }).error(function(){
66            scope.shares = 0;
67          });
68        }
69      }
70
71      $timeout(function(){
72          element.bind('click',function(){
73            FB.ui({
74              method: 'share_open_graph',
75              action_type: 'og.shares',
76              action_properties: JSON.stringify({
77                  object : {
78                    'og:url': attr.url,
79                    'og:title': attr.name,
80                    'og:description': attr.caption,
81                    'og:og:image:width': '403',
82                    'og:image:height': '403',
83                    'og:image': attr.pictureUrl,
84                  }
85              })
86            });
87            // FB.ui(
88            //   {
89            //     method: 'feed',
90            //     name: attr.name,
91            //     link: attr.url,
92            //     picture: attr.pictureUrl,
93            //     caption: attr.caption
94            // });
95          });
96        });
97
98      triggerRelink();
99
100      $rootScope.$on(attr.relinkEvent,triggerRelink);
101    }
102  };
103}]).directive('twitter',['$rootScope','$timeout',function($rootScope,$timeout) {
104  return {
105    link: function(scope, element, attr) {
106      var triggerRelink = function(){
107        angular.element(element).html('');
108        var escapedUrl = encodeURIComponent(attr.url);
109        var escapedCountUrl = encodeURIComponent(attr.counturl);
110        var escapedText = escape(attr.text);
111        var escapedCount = encodeURIComponent(attr.count);
112
113        $timeout(function() {
114          angular.element(element[0]).html('<a href="https://twitter.com/share?url='+escapedUrl+'&text='+escapedText+'&count='+escapedCount+'&lang=en&counturl='+escapedCountUrl+'&dnt=true" target="_blank"><img src="'+attr.imgsrc+'" /></a>');
115        //   twttr.widgets.createShareButton(
116        //     attr.url,
117        //     element[0],
118        //     function() {}, {
119        //       count: attr.count,
120        //       text: attr.text,
121        //       via: attr.via,
122        //       size: attr.size
123        //     }
124        //   );
125        });
126      }
127
128      triggerRelink();
129      $rootScope.$on(attr.relinkEvent,triggerRelink);
130    }
131  };
132}]).directive('linkdin', ['$rootScope','$timeout','$http', '$window',function($rootScope,$timeout,$http,$window) {
133  return {
134    scope: {
135      shares: '='
136    }, 
137    transclude: true,
138    template: '<div ng-transclude></div>',
139    link: function(scope, element, attr) {
140      var triggerRelink = function(){
141          if(attr.shares){
142            $http.jsonp('//www.linkedin.com/countserv/count/share?url='+attr.url+'&callback=JSON_CALLBACK&format=jsonp').success(function(res){
143              scope.shares = res.count;
144            }).error(function(){
145              scope.shares = 0;
146            });
147          }
148      };
149
150      $timeout(function(){
151        element.bind('click',function(){
152          $window.open("//www.linkedin.com/shareArticle?mini=true&url="+attr.url+"&title="+attr.title+"&summary="+attr.summary);
153        });
154      });
155
156      triggerRelink();
157      $rootScope.$on(attr.relinkEvent,triggerRelink);
158    }
159  };
160}]).directive('gplus',[function(){
161  return {
162    link: function(scope,element,attr){
163      if(typeof gapi == "undefined"){
164        (function() {
165          var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
166          po.src = 'https://apis.google.com/js/plusone.js';
167          var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
168        })();
169      }
170    }
171  };
172}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.