Skip to content

Commit

Permalink
Update Providers
Browse files Browse the repository at this point in the history
Vic Shóstak committed Mar 15, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 1969eda commit 149ac2f
Showing 16 changed files with 219 additions and 557 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-goodshare",
"version": "1.2.0",
"version": "1.3.0",
"description": "Vue.js component for social share. A simple way to share a link on the pages of your website in the most popular (and not so) social networks.",
"main": "src/VueGoodshare.vue",
"scripts": {
@@ -13,7 +13,7 @@
"url": "git+https://github.com/koddr/vue-goodshare.git"
},
"dependencies": {
"vue": "^2.6.8"
"vue": "^2.6.9"
},
"devDependencies": {
"css-loader": "^0.28.11",
14 changes: 4 additions & 10 deletions src/providers/GooglePlus.vue
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
<script>
import { clickEvent } from "../helpers/events";
import { documentHref } from "../helpers/href";
import { openPopUpWindow } from "../helpers/popup_window";
export default {
name: "VueGoodshareGooglePlus",
@@ -54,22 +55,15 @@ export default {
showShareWindow: function() {
// Variables
const width = 640;
const height = 640;
let left = screen.width / 2 - width / 2;
let top = screen.height / 2 - height / 2;
const window_config = `width=${width},height=${height},left=${left},top=${top}`;
const height = 480;
const share_url = `https://plus.google.com/share?url=${encodeURIComponent(
this.$props.page_url
)}`;
// onClick event
clickEvent(this, "googlePlus");
clickEvent(this, "googleplus");
return window.open(
share_url,
"Share this",
`${window_config},toolbar=no,menubar=no,scrollbars=no`
);
return openPopUpWindow(share_url, width, height);
}
}
};
12 changes: 3 additions & 9 deletions src/providers/Line.vue
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
<script>
import { clickEvent } from "../helpers/events";
import { documentHref } from "../helpers/href";
import { openPopUpWindow } from "../helpers/popup_window";
export default {
name: "VueGoodshareLine",
@@ -54,22 +55,15 @@ export default {
showShareWindow: function() {
// Variables
const width = 640;
const height = 640;
let left = screen.width / 2 - width / 2;
let top = screen.height / 2 - height / 2;
const window_config = `width=${width},height=${height},left=${left},top=${top}`;
const height = 480;
const share_url = `line://msg/text/${encodeURIComponent(
this.$props.page_url
)}`;
// onClick event
clickEvent(this, "line");
return window.open(
share_url,
"Share this",
`${window_config},toolbar=no,menubar=no,scrollbars=no`
);
return openPopUpWindow(share_url, width, height);
}
}
};
52 changes: 11 additions & 41 deletions src/providers/LinkedIn.vue
Original file line number Diff line number Diff line change
@@ -31,6 +31,9 @@ import { clickEvent } from "../helpers/events";
import { documentHref } from "../helpers/href";
import { documentTitle } from "../helpers/title";
import { metaDescription } from "../helpers/description";
import { getCallbackName } from "../helpers/callback_name";
import { sliceThousandInt } from "../helpers/count_number";
import { openPopUpWindow } from "../helpers/popup_window";
export default {
name: "VueGoodshareLinkedIn",
@@ -68,27 +71,6 @@ export default {
};
},
methods: {
/**
* Get a random integer between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random integer
*/
getRandomInt: (min, max) => {
return Math.floor(Math.random() * (max - min + 1) + min);
},
/**
* Slice thousand integer and add `k` letter.
*
* @param {number} number - thousand integer
* @return {string} a integer with letter
*/
sliceThousandInt: number => {
return (number / 1000).toFixed(1) + "k";
},
/**
* Show share window.
*
@@ -97,24 +79,17 @@ export default {
showShareWindow: function() {
// Variables
const width = 640;
const height = 640;
let left = screen.width / 2 - width / 2;
let top = screen.height / 2 - height / 2;
const window_config = `width=${width},height=${height},left=${left},top=${top}`;
const height = 480;
const share_url = `https://www.linkedin.com/shareArticle?url=${encodeURIComponent(
this.$props.page_url
)}&text=${encodeURIComponent(
this.$props.page_title
)}&summary=${encodeURIComponent(this.$props.page_description)}&mini=true`;
// onClick event
clickEvent(this, "linkedIn");
clickEvent(this, "linkedin");
return window.open(
share_url,
"Share this",
`${window_config},toolbar=no,menubar=no,scrollbars=no`
);
return openPopUpWindow(share_url, width, height);
},
/**
@@ -125,15 +100,12 @@ export default {
getShareCounter: function() {
// Variables
const script = document.createElement("script");
const callback = `vue_goodshare_${this.getRandomInt(1, 2345)}`;
const callback = getCallbackName("vue_goodshare", 9999, 111);
// Create `script` tag with share count URL
script.src =
"https://www.linkedin.com/countserv/count/share?" +
"url=" +
encodeURIComponent(this.$props.page_url) +
"&callback=" +
callback;
script.src = `https://www.linkedin.com/countserv/count/share?url=${encodeURIComponent(
this.$props.page_url
)}&callback=${callback}`;
// Add `script` tag with share count URL
// to end of `body` tag
@@ -143,9 +115,7 @@ export default {
window[callback] = count => {
if (count) {
this.counter_linkedin =
count.count >= 1000
? this.sliceThousandInt(count.count)
: count.count;
count.count >= 1000 ? sliceThousandInt(count.count) : count.count;
}
};
}
36 changes: 10 additions & 26 deletions src/providers/LiveJournal.vue
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import { clickEvent } from "../helpers/events";
import { documentHref } from "../helpers/href";
import { documentTitle } from "../helpers/title";
import { openPopUpWindow } from "../helpers/popup_window";
export default {
name: "VueGoodshareLiveJournal",
@@ -58,34 +59,17 @@ export default {
* @return {object} a pop-up window
*/
showShareWindow: function() {
click(this, "liveJournal");
// Variables
const width = 640;
const height = 640;
let left = screen.width / 2 - width / 2;
let top = screen.height / 2 - height / 2;
const window_config =
"width=" +
width +
",height=" +
height +
",left=" +
left +
",top=" +
top +
",";
const share_url =
"https://livejournal.com/update.bml?" +
"event=" +
encodeURIComponent(this.$props.page_url) +
"&subject=" +
encodeURIComponent(this.$props.page_title);
return window.open(
share_url,
"Share this",
window_config + "toolbar=no,menubar=no,scrollbars=no"
);
const height = 480;
const share_url = `https://livejournal.com/update.bml?event=${encodeURIComponent(
this.$props.page_url
)}&subject=${encodeURIComponent(this.$props.page_title)}`;
// onClick event
clickEvent(this, "livejournal");
return openPopUpWindow(share_url, width, height);
}
}
};
85 changes: 25 additions & 60 deletions src/providers/MoiMir.vue
Original file line number Diff line number Diff line change
@@ -14,15 +14,16 @@
@click.prevent="showShareWindow"
>
<i class="icon-moimir" v-if="this.$props.has_icon"></i>
<span class="title-social" v-if="this.$props.title_social">{{
title_social
}}</span>
<span class="title-social" v-if="this.$props.title_social">
{{ title_social }}
</span>
<span
class="counter-moimir"
v-model="counter_moimir"
v-if="this.$props.has_counter"
>{{ counter_moimir }}</span
>
{{ counter_moimir }}
</span>
</a>
</template>

@@ -32,6 +33,9 @@ import { documentHref } from "../helpers/href";
import { documentTitle } from "../helpers/title";
import { metaDescription } from "../helpers/description";
import { linkAppleTouchIcon } from "../helpers/icon";
import { getCallbackName } from "../helpers/callback_name";
import { sliceThousandInt } from "../helpers/count_number";
import { openPopUpWindow } from "../helpers/popup_window";
export default {
name: "VueGoodshareMoiMir",
@@ -73,64 +77,27 @@ export default {
};
},
methods: {
/**
* Get a random integer between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random integer
*/
getRandomInt: (min, max) => {
return Math.floor(Math.random() * (max - min + 1) + min);
},
/**
* Slice thousand integer and add `k` letter.
*
* @param {number} number - thousand integer
* @return {string} a integer with letter
*/
sliceThousandInt: number => {
return (number / 1000).toFixed(1) + "k";
},
/**
* Show share window.
*
* @return {object} a pop-up window
*/
showShareWindow: function() {
click(this, "moiMir");
// Variables
const width = 640;
const height = 640;
let left = screen.width / 2 - width / 2;
let top = screen.height / 2 - height / 2;
const window_config =
"width=" +
width +
",height=" +
height +
",left=" +
left +
",top=" +
top;
const share_url =
"https://connect.mail.ru/share?" +
"url=" +
encodeURIComponent(this.$props.page_url) +
"&title=" +
encodeURIComponent(this.$props.page_title) +
"&description=" +
encodeURIComponent(this.$props.page_description) +
"&imageurl=" +
encodeURIComponent(this.$props.page_image);
const height = 480;
const share_url = `https://connect.mail.ru/share?url=${encodeURIComponent(
this.$props.page_url
)}&title=${encodeURIComponent(
this.$props.page_title
)}&description=${encodeURIComponent(
this.$props.page_description
)}&imageurl=${encodeURIComponent(this.$props.page_image)}`;
// onClick event
clickEvent(this, "moimir");
return window.open(
share_url,
"Share this",
window_config + ",toolbar=no,menubar=no,scrollbars=no"
);
return openPopUpWindow(share_url, width, height);
},
/**
@@ -141,14 +108,12 @@ export default {
getShareCounter: function() {
// Variables
const script = document.createElement("script");
const callback = "vue_goodshare_" + this.getRandomInt(1, 2345);
const callback = getCallbackName("vue_goodshare", 9999, 111);
// Create `script` tag with share count URL
script.src =
"https://appsmail.ru/share/count/" +
encodeURIComponent(this.$props.page_url.replace(/^.*?:\/\//, "")) +
"?callback=" +
callback;
script.src = `https://appsmail.ru/share/count/${encodeURIComponent(
this.$props.page_url.replace(/^.*?:\/\//, "")
)}?callback=${callback}`;
// Add `script` tag with share count URL
// to end of `body` tag
@@ -159,7 +124,7 @@ export default {
if (count) {
this.counter_moimir =
count.share_mm >= 1000
? this.sliceThousandInt(count.share_mm)
? sliceThousandInt(count.share_mm)
: count.share_mm;
}
};
Loading

0 comments on commit 149ac2f

Please sign in to comment.