Skip to content

Commit

Permalink
feat: fbbutton -> fbButton
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Avdeev committed Oct 24, 2017
1 parent 1e7b814 commit 01c6e39
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 80 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ fbFeed({
})
```

### `fbbutton(options)`
### `fbButton(options)`

Share to facebook.com using facebook share button.

```js
fbbutton({
fbButton({
url: string,
})
```
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1><a href="https://github.com/avdeev/vanilla-sharing">vanilla-sharing</a> demo
<ul>
<li class="item" data-social="fbFeed">Share on Facebook (Feed dialog)</li>
<li class="item" data-social="fbShare">Share on Facebook (Share dialog)</li>
<li class="item" data-social="fbbutton">Share on Facebook (Share button)</li>
<li class="item" data-social="fbButton">Share on Facebook (Share button)</li>
<li class="item" data-social="tw">Share on Twitter</li>
<li class="item" data-social="gp">Share on Google</li>
<li class="item" data-social="vk">Share on VK</li>
Expand Down
142 changes: 72 additions & 70 deletions dist/vanilla-sharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = mobileShare;

var _isMobileSafari = __webpack_require__(12);
var _isMobileSafari = __webpack_require__(13);

var _isMobileSafari2 = _interopRequireDefault(_isMobileSafari);

Expand All @@ -137,7 +137,7 @@ function mobileShare(link) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fbbutton = exports.line = exports.messenger = exports.linkedin = exports.whatsapp = exports.vk = exports.getVkUrl = exports.viber = exports.tw = exports.telegram = exports.ok = exports.mail = exports.gp = exports.fbShare = exports.fbFeed = undefined;
exports.line = exports.messenger = exports.linkedin = exports.whatsapp = exports.vk = exports.getVkUrl = exports.viber = exports.tw = exports.telegram = exports.ok = exports.mail = exports.gp = exports.fbButton = exports.fbShare = exports.fbFeed = undefined;

var _fbFeed = __webpack_require__(4);

Expand All @@ -147,56 +147,57 @@ var _fbShare = __webpack_require__(5);

var _fbShare2 = _interopRequireDefault(_fbShare);

var _gp = __webpack_require__(6);
var _fbButton = __webpack_require__(6);

var _fbButton2 = _interopRequireDefault(_fbButton);

var _gp = __webpack_require__(7);

var _gp2 = _interopRequireDefault(_gp);

var _mail = __webpack_require__(7);
var _mail = __webpack_require__(8);

var _mail2 = _interopRequireDefault(_mail);

var _ok = __webpack_require__(8);
var _ok = __webpack_require__(9);

var _ok2 = _interopRequireDefault(_ok);

var _telegram = __webpack_require__(9);
var _telegram = __webpack_require__(10);

var _telegram2 = _interopRequireDefault(_telegram);

var _tw = __webpack_require__(10);
var _tw = __webpack_require__(11);

var _tw2 = _interopRequireDefault(_tw);

var _viber = __webpack_require__(11);
var _viber = __webpack_require__(12);

var _viber2 = _interopRequireDefault(_viber);

var _vk = __webpack_require__(13);
var _vk = __webpack_require__(14);

var _whatsapp = __webpack_require__(14);
var _whatsapp = __webpack_require__(15);

var _whatsapp2 = _interopRequireDefault(_whatsapp);

var _linkedin = __webpack_require__(15);
var _linkedin = __webpack_require__(16);

var _linkedin2 = _interopRequireDefault(_linkedin);

var _messenger = __webpack_require__(16);
var _messenger = __webpack_require__(17);

var _messenger2 = _interopRequireDefault(_messenger);

var _line = __webpack_require__(17);
var _line = __webpack_require__(18);

var _line2 = _interopRequireDefault(_line);

var _fbbutton = __webpack_require__(18);

var _fbbutton2 = _interopRequireDefault(_fbbutton);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.fbFeed = _fbFeed2.default;
exports.fbShare = _fbShare2.default;
exports.fbButton = _fbButton2.default;
exports.gp = _gp2.default;
exports.mail = _mail2.default;
exports.ok = _ok2.default;
Expand All @@ -209,7 +210,8 @@ exports.whatsapp = _whatsapp2.default;
exports.linkedin = _linkedin2.default;
exports.messenger = _messenger2.default;
exports.line = _line2.default;
exports.fbbutton = _fbbutton2.default;

// @FIXME

/***/ }),
/* 4 */
Expand Down Expand Up @@ -310,6 +312,47 @@ function fbShare() {
"use strict";


Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = fbButton;

var _config = __webpack_require__(1);

var _encodeParams = __webpack_require__(0);

var _encodeParams2 = _interopRequireDefault(_encodeParams);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function fbButton() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var url = options.url;


if (!url) {
throw new Error('url is not defined');
}

var params = (0, _encodeParams2.default)({
kid_directed_site: 0,
sdk: 'joey',
u: url,
display: 'popup',
ref: 'plugin',
src: 'share_button'
});

return window.open('https://www.facebook.com/sharer/sharer.php?' + params, '_blank', _config.WIN_PARAMS);
}

/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
value: true
});
Expand All @@ -334,7 +377,7 @@ function gp() {
}

/***/ }),
/* 7 */
/* 8 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -372,7 +415,7 @@ function mail() {
}

/***/ }),
/* 8 */
/* 9 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -407,7 +450,7 @@ function ok() {
}

/***/ }),
/* 9 */
/* 10 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -441,7 +484,7 @@ function telegram() {
}

/***/ }),
/* 10 */
/* 11 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -475,7 +518,7 @@ function tw() {
}

/***/ }),
/* 11 */
/* 12 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -515,7 +558,7 @@ function viber() {
}

/***/ }),
/* 12 */
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand All @@ -530,7 +573,7 @@ function isMobileSafari() {
}

/***/ }),
/* 13 */
/* 14 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -586,7 +629,7 @@ function share() {
}

/***/ }),
/* 14 */
/* 15 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -623,7 +666,7 @@ function whatsapp() {
}

/***/ }),
/* 15 */
/* 16 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -659,7 +702,7 @@ function linkedin() {
}

/***/ }),
/* 16 */
/* 17 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -695,7 +738,7 @@ function messenger() {
}

/***/ }),
/* 17 */
/* 18 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -727,47 +770,6 @@ function line() {
return window.open('https://line.me/R/msg/text/?' + params, '_blank', _config.WIN_PARAMS);
}

/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = fbbutton;

var _config = __webpack_require__(1);

var _encodeParams = __webpack_require__(0);

var _encodeParams2 = _interopRequireDefault(_encodeParams);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function fbbutton() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var url = options.url;


if (!url) {
throw new Error('url is not defined');
}

var params = (0, _encodeParams2.default)({
kid_directed_site: 0,
sdk: 'joey',
u: url,
display: 'popup',
ref: 'plugin',
src: 'share_button'
});

return window.open('https://www.facebook.com/sharer/sharer.php?' + params, '_blank', _config.WIN_PARAMS);
}

/***/ })
/******/ ]);
});
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import fbFeed from 'sharers/fbFeed';
import fbShare from 'sharers/fbShare';
import fbButton from 'sharers/fbButton';
import gp from 'sharers/gp';
import mail from 'sharers/mail';
import ok from 'sharers/ok';
import telegram from 'sharers/telegram';
import tw from 'sharers/tw';
import viber from 'sharers/viber';

// @FIXME
import { getUrl as getVkUrl, share as vk } from 'sharers/vk';

import whatsapp from 'sharers/whatsapp';
import linkedin from 'sharers/linkedin';
import messenger from 'sharers/messenger';
import line from 'sharers/line';
import fbbutton from 'sharers/fbbutton';

export {
fbFeed,
fbShare,
fbButton,
gp,
mail,
ok,
Expand All @@ -28,5 +32,4 @@ export {
linkedin,
messenger,
line,
fbbutton,
};
2 changes: 1 addition & 1 deletion src/sharers/fbbutton.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WIN_PARAMS } from 'config';
import encodeParams from 'utils/encodeParams';

export default function fbbutton(options = {}) {
export default function fbButton(options = {}) {
const { url } = options;

if (!url) {
Expand Down
8 changes: 4 additions & 4 deletions src/sharers/tests/fbbutton.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import faker from 'faker';

import fbbutton from '../fbbutton';
import fbButton from '../fbButton';

describe('fbbutton', () => {
describe('fbButton', () => {
beforeEach(() => {
window.open = jest.fn();
});
Expand All @@ -12,13 +12,13 @@ describe('fbbutton', () => {
});

it('should call without params', () => {
expect(fbbutton).toThrow('url is not defined');
expect(fbButton).toThrow('url is not defined');
});

it('should call with url', () => {
const fixture = faker.internet.url();

fbbutton({ url: fixture });
fbButton({ url: fixture });

expect(window.open.mock.calls[0][0]).toBe(`https://www.facebook.com/sharer/sharer.php?kid_directed_site=0&sdk=joey&u=${encodeURIComponent(fixture)}&display=popup&ref=plugin&src=share_button`);
});
Expand Down

0 comments on commit 01c6e39

Please sign in to comment.