Skip to content

Commit c06af89

Browse files
author
setare karimi
authored
Merge pull request #1 from Javid-Izadfar/master
Add Pol files
2 parents 49941a2 + 981ad43 commit c06af89

File tree

6 files changed

+236
-1
lines changed

6 files changed

+236
-1
lines changed

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contributing to Pol
2+
Want to make Pol better? These are ways you can contribute:
3+
4+
## Ask for new media
5+
Though Pol is free and open source, we have to follow some certain standards. If you want us to add a new media, please have this things in mind:
6+
* Search [previous icon requests](https://github.com/IKAcc/Pol/search?type=Issues) to see if your wanted media already exists. If it was requested before, +1 it.
7+
* Ask for a single media at a request.
8+
* Make sure that media is notable enough.
9+
* Title your new issue Icon request: `add: media_name` (e.g., Icon request: `add: Twitter`).
10+
11+
## Report a bug
12+
We can’t claim that Pol is bug free. Please be kind and report issues in the following manner:
13+
* Search in existing issues. We don’t want to get hundreds of duplicated reports. There are even chances that we are already working on that issue you’re facing.
14+
* Try to reproduce issue. Make sure that issue is made up by Pol Icons and not with your other components with a [reduced test case](https://css-tricks.com/reduced-test-cases/).
15+
* Include an example. We can fix bugs much faster if we could lay an eye upon it.
16+
17+
## Code CSS
18+
Please follow these standards if you want to change some CSS:
19+
* Multiple-line approach (one property and value per line).
20+
* Always a space after a property's colon (.e.g, `font=size: 2rem;` and not `font-size:2rem;`).
21+
* End all lines with a semi-colon.
22+
* For multiple, comma-separated selectors, place each selector on its own line.
23+
24+
Note: By contributing in codes, you agree to license your contribution under the terms of the [MIT License](https://opensource.org/licenses/mit-license.html).
25+
26+
## Support us
27+
If you like to support us as an sponsor, please contact [email protected]

README.md

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,79 @@
1-
# Pol
1+
# Pol
2+
[![](http://ikacc.ir/github-assets/pol-header-v1.0.png)](https://github.com/IKAcc/Pol)
3+
4+
Pol (Farsi: پل, "Bridge") is a new way for your audience to share contents of your site. You - as a Content Manager (CM) - point out to the most important part of your content, then Pol will transform it to a shareable link using javaScript and CSS so anyone could share it on your targeted social network.
5+
6+
Pol is created by [Javid Izadfar](https://twitter.com/JavidIzadfar "Javid Izadfar at Twitter") and [Setareh Karimi](https://twitter.com/setarekarimi "Setareh Karimi at Twitter") at [IKA Computing Club](http://ikacc.ir/) as a [free and open-source tool](../master/LICENSE); so feel free to use and modify it as you need.
7+
8+
Pol will look great, using [Gorbeh](https://github.com/IKAcc/Gorbeh-Icons) for media icons and [RangeBrand](https://github.com/IKAcc/RangeBrand) for official media colors.
9+
10+
## License
11+
Pol files are licensed under the MIT License:
12+
* https://opensource.org/licenses/mit-license.html
13+
14+
## Contributing
15+
We support and encourage any kind of contribution by anyone. Please read through [contributing guidelines](../master/CONTRIBUTING.md). In these guidelines, directions to asking for a new media, reporting a bug and other notes are fully explained.
16+
17+
## Supporting Media
18+
Pol currently supports the following social networks:
19+
* Telegram
20+
* Twitter
21+
22+
## Usage
23+
To use Pol on your site or blog, follow these steps:
24+
25+
1) Download Pol’s [latest release](../zipball/master).
26+
27+
2) Add Pol folder to your preferred directory on your project.
28+
29+
3) Add Pol.js to your HTML file:
30+
```html
31+
<!-- Pol js -->
32+
<script src="js/pol.js"></script>
33+
```
34+
or
35+
```html
36+
<!-- Pol min.js -->
37+
<script src="js/pol.min.js"></script>
38+
```
39+
40+
4) Add Pol.css to your HTML file (Optional):
41+
```html
42+
<!-- Pol css -->
43+
<link href="css/pol.css" rel="stylesheet">
44+
```
45+
or
46+
```html
47+
<!-- Pol min.css -->
48+
<link href="css/pol.min.css" rel="stylesheet">
49+
```
50+
51+
5) Initiate Pol in your custom js file:
52+
```javascript
53+
$('body').pol()
54+
```
55+
see [Options](#Options) for more initialization options.
56+
57+
6) Implement a Pol, using `data-pol-media` and name your preferred media:
58+
```html
59+
<span data-pol-media="twitter"> .... </span>
60+
```
61+
## Options
62+
| Option | Default value | Functionality |
63+
| ------------- |:----------------------:| :----------------------|
64+
| url | current page's URL | Includes a link to the source |
65+
| target | _blank | How should Pol's link behave when is clicked |
66+
| author | none | Your official account(s) on targeted media. do NOT include "@". Separate accounts using ",". |
67+
| hashtags | none | Hashtags. do NOT include "#". Separate accounts using ",". |
68+
69+
## Creators
70+
* ![](https://avatars3.githubusercontent.com/u/14288838?v=3&s=16) Javid Izadfar
71+
72+
* Twitter: [twitter.com/JavidIzadfar](http://twitter.com/JavidIzadfar)
73+
* Github: [github.com/Javid-Izadfar](http://github.com/Javid-Izadfar)
74+
* ![](https://avatars3.githubusercontent.com/u/13146837?v=3&s=16) Setareh Karimi
75+
76+
* Twitter: [twitter.com/setarekarimi](http://twitter.com/setarekarimi)
77+
* Github: [github.com/setarek](http://github.com/setarek)
78+
79+
[![IKA Computing Club](http://ikacc.ir/github-assets/ika-footer.png)](http://ikacc.ir)

css/pol.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Pol
3+
Created by @JavidIzadfar and @setarekarimi at IKAcc
4+
Last edit on June 11, 2016
5+
*/
6+
7+
a[data-pol-media]{
8+
outline: none;
9+
color: inherit;
10+
text-decoration: none;
11+
-webkit-transition: all 0.2s ease-out;
12+
-moz-transition: all 0.2s ease-out;
13+
-o-transition: all 0.2s ease-out;
14+
transition: all 0.2s ease-out;}
15+
16+
a[data-pol-media="twitter"]:hover{
17+
background-color: rgba(85, 172, 238, .1);
18+
}
19+
20+
a[data-pol-media="telegram"]:hover{
21+
background-color: rgba(0, 136, 204, .1);
22+
}

css/pol.min.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
Pol
3+
Created by @JavidIzadfar and @setarekarimi at IKAcc
4+
Last edit on June 11, 2016
5+
*/
6+
7+
a[data-pol-media]{outline:none;color:inherit;text-decoration:none;-webkit-transition:all .2s ease-out;-moz-transition:all .2s ease-out;-o-transition:all .2s ease-out;transition:all .2s ease-out}a[data-pol-media="twitter"]:hover{background-color:rgba(85,172,238,.1)}a[data-pol-media="telegram"]:hover{background-color:rgba(0,136,204,.1)}

js/pol.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
Pol
3+
Created by @JavidIzadfar and @setarekarimi at IKAcc
4+
Last edit on June 11, 2016
5+
*/
6+
7+
(function( $ ) {
8+
9+
$.fn.pol = function(options) {
10+
11+
var settings = $.extend({ // These are the defaults.
12+
url: $(location).attr('href'), // by default, use current URL
13+
target: '_blank', // by default, link opens in new blank tab
14+
author: '', // by default, no author
15+
hashtags: '', // by default, no author
16+
}, options );
17+
18+
var authorActive = '';
19+
var hashtagsActive = '';
20+
21+
if (settings.author) authorActive = '%40' + settings.author.replace(/, |,/g, "%20%40"); // turn author to an active user(s)
22+
if (settings.hashtags) hashtagsActive = '%23' + settings.hashtags.replace(/, |,/g, "%20%23"); // turn author to an active tags(s)
23+
24+
var media = [
25+
// { // Twitter (Official)
26+
// name: 'twitter',
27+
// baseURL: 'https://twitter.com/intent/tweet?',
28+
// textBinding: '&text=',
29+
// hashtagBinding: '&hashtags=',
30+
// viaBinding: '&via=',
31+
// urlBinding: '&url=',
32+
// requireActive: false
33+
// },
34+
{ // Twitter (Unofficial)
35+
name: 'Twitter',
36+
baseURL: 'https://twitter.com/intent/tweet?',
37+
textBinding: '&text=',
38+
hashtagBinding: '%0A',
39+
viaBinding: '%0A',
40+
urlBinding: '&url=',
41+
requireActive: true
42+
},
43+
{ // Telegram
44+
name: 'Telegram',
45+
baseURL: 'https://telegram.me/share/url?',
46+
textBinding: '&text=',
47+
hashtagBinding: '%0A',
48+
viaBinding: '%0A',
49+
urlBinding: '&url=',
50+
requireActive: true
51+
}
52+
]
53+
54+
$('[data-pol-media]').each(function(){ // get every Pol
55+
56+
var attrs = {
57+
text: $(this).text(), // Pol's content
58+
html: $(this).html(), // Pol's content + HTML
59+
target: settings.target, // Pol's targeting behavior
60+
};
61+
62+
$.each(this.attributes, function() { // get all other attributes
63+
if(this.specified) {
64+
attrs[this.name] = this.value; // and save on attrs object
65+
}
66+
});
67+
68+
for (var i = 0; i < media.length; i++) { // check media array to
69+
if (attrs['data-pol-media'].toLowerCase() == media[i].name.toLowerCase()) { // grab the pol-media object
70+
71+
if (!settings.hashtags) media[i].hashtagBinding = ''; // remove the hashtags's binding if hashtag(s) is not specified
72+
if (!settings.author) media[i].viaBinding = ''; // remove the author's binding if author(s) is not specified
73+
74+
if (media[i].requireActive) { // if media required active links
75+
settings.hashtags = hashtagsActive; // active hashtags(s)
76+
settings.author = authorActive; // active author(s)
77+
}
78+
79+
attrs.title = 'Share on ' + media[i].name; // Pol's title for link
80+
81+
attrs.href = media[i].baseURL + media[i].textBinding + attrs.text + media[i].hashtagBinding + settings.hashtags + media[i].viaBinding + settings.author + media[i].urlBinding + settings.url; // the universal Pol URL
82+
83+
}
84+
}
85+
86+
$(this).replaceWith(function () { // replace span with <a> tag
87+
return $("<a />", attrs); // with its attributes
88+
});
89+
90+
});
91+
92+
};
93+
94+
}( jQuery ));

js/pol.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)