Skip to content

Commit c13ed52

Browse files
committed
init
0 parents  commit c13ed52

12 files changed

+7255
-0
lines changed

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DS_Store
2+
*.DS_Store
3+
!.gitignore
4+
!.htaccess
5+
!web.config
6+
node_modules
7+
bower_components
8+
Thumbs.db
9+
wiki-common
10+
wiki-images files
11+
wiki-wishlist
12+
*.sublime-project
13+
*.sublime-workspace
14+
.editorconfig
15+
.idea
16+
lib
17+
/plugins

.npmignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
src/
2+
entry.js
3+
webpack.config.js
4+
.idea
5+
prettier.config.js

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Georgy Marchuk
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

dist/SwupGaPlugin.js

+212
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
(function webpackUniversalModuleDefinition(root, factory) {
2+
if(typeof exports === 'object' && typeof module === 'object')
3+
module.exports = factory();
4+
else if(typeof define === 'function' && define.amd)
5+
define([], factory);
6+
else if(typeof exports === 'object')
7+
exports["SwupGaPlugin"] = factory();
8+
else
9+
root["SwupGaPlugin"] = factory();
10+
})(window, function() {
11+
return /******/ (function(modules) { // webpackBootstrap
12+
/******/ // The module cache
13+
/******/ var installedModules = {};
14+
/******/
15+
/******/ // The require function
16+
/******/ function __webpack_require__(moduleId) {
17+
/******/
18+
/******/ // Check if module is in cache
19+
/******/ if(installedModules[moduleId]) {
20+
/******/ return installedModules[moduleId].exports;
21+
/******/ }
22+
/******/ // Create a new module (and put it into the cache)
23+
/******/ var module = installedModules[moduleId] = {
24+
/******/ i: moduleId,
25+
/******/ l: false,
26+
/******/ exports: {}
27+
/******/ };
28+
/******/
29+
/******/ // Execute the module function
30+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31+
/******/
32+
/******/ // Flag the module as loaded
33+
/******/ module.l = true;
34+
/******/
35+
/******/ // Return the exports of the module
36+
/******/ return module.exports;
37+
/******/ }
38+
/******/
39+
/******/
40+
/******/ // expose the modules object (__webpack_modules__)
41+
/******/ __webpack_require__.m = modules;
42+
/******/
43+
/******/ // expose the module cache
44+
/******/ __webpack_require__.c = installedModules;
45+
/******/
46+
/******/ // define getter function for harmony exports
47+
/******/ __webpack_require__.d = function(exports, name, getter) {
48+
/******/ if(!__webpack_require__.o(exports, name)) {
49+
/******/ Object.defineProperty(exports, name, {
50+
/******/ configurable: false,
51+
/******/ enumerable: true,
52+
/******/ get: getter
53+
/******/ });
54+
/******/ }
55+
/******/ };
56+
/******/
57+
/******/ // define __esModule on exports
58+
/******/ __webpack_require__.r = function(exports) {
59+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
60+
/******/ };
61+
/******/
62+
/******/ // getDefaultExport function for compatibility with non-harmony modules
63+
/******/ __webpack_require__.n = function(module) {
64+
/******/ var getter = module && module.__esModule ?
65+
/******/ function getDefault() { return module['default']; } :
66+
/******/ function getModuleExports() { return module; };
67+
/******/ __webpack_require__.d(getter, 'a', getter);
68+
/******/ return getter;
69+
/******/ };
70+
/******/
71+
/******/ // Object.prototype.hasOwnProperty.call
72+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
73+
/******/
74+
/******/ // __webpack_public_path__
75+
/******/ __webpack_require__.p = "";
76+
/******/
77+
/******/
78+
/******/ // Load entry module and return exports
79+
/******/ return __webpack_require__(__webpack_require__.s = 2);
80+
/******/ })
81+
/************************************************************************/
82+
/******/ ([
83+
/* 0 */
84+
/***/ (function(module, exports, __webpack_require__) {
85+
86+
"use strict";
87+
88+
89+
Object.defineProperty(exports, "__esModule", {
90+
value: true
91+
});
92+
93+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
94+
95+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
96+
97+
var Plugin = function () {
98+
function Plugin() {
99+
_classCallCheck(this, Plugin);
100+
101+
this.isSwupPlugin = true;
102+
}
103+
104+
_createClass(Plugin, [{
105+
key: "mount",
106+
value: function mount() {
107+
// this is mount method rewritten by class extending
108+
// and is executed when swup is enabled with plugin
109+
}
110+
}, {
111+
key: "unmount",
112+
value: function unmount() {}
113+
// this is unmount method rewritten by class extending
114+
// and is executed when swup with plugin is disabled
115+
116+
117+
// this is here so we can tell if plugin was created by extending this class
118+
119+
}]);
120+
121+
return Plugin;
122+
}();
123+
124+
exports.default = Plugin;
125+
126+
/***/ }),
127+
/* 1 */
128+
/***/ (function(module, exports, __webpack_require__) {
129+
130+
"use strict";
131+
132+
133+
Object.defineProperty(exports, "__esModule", {
134+
value: true
135+
});
136+
137+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
138+
139+
var _plugin = __webpack_require__(0);
140+
141+
var _plugin2 = _interopRequireDefault(_plugin);
142+
143+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
144+
145+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
146+
147+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
148+
149+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
150+
151+
var GaPlugin = function (_Plugin) {
152+
_inherits(GaPlugin, _Plugin);
153+
154+
function GaPlugin() {
155+
var _ref;
156+
157+
var _temp, _this, _ret;
158+
159+
_classCallCheck(this, GaPlugin);
160+
161+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
162+
args[_key] = arguments[_key];
163+
}
164+
165+
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = GaPlugin.__proto__ || Object.getPrototypeOf(GaPlugin)).call.apply(_ref, [this].concat(args))), _this), _this.name = "SwupGaPlugin", _temp), _possibleConstructorReturn(_this, _ret);
166+
}
167+
168+
_createClass(GaPlugin, [{
169+
key: 'mount',
170+
value: function mount() {
171+
var _this2 = this;
172+
173+
this.swup.on('contentReplaced', function (event) {
174+
if (typeof window.ga === 'function') {
175+
var title = document.title;
176+
var url = window.location.pathname + window.location.search;
177+
178+
window.ga('set', 'title', title);
179+
window.ga('set', 'page', url);
180+
window.ga('send', 'pageview');
181+
182+
_this2.swup.log('GA pageview (url \'' + url + '\').');
183+
} else {
184+
console.warn('GA is not loaded.');
185+
}
186+
});
187+
}
188+
}]);
189+
190+
return GaPlugin;
191+
}(_plugin2.default);
192+
193+
exports.default = GaPlugin;
194+
195+
/***/ }),
196+
/* 2 */
197+
/***/ (function(module, exports, __webpack_require__) {
198+
199+
"use strict";
200+
201+
202+
var _index = __webpack_require__(1);
203+
204+
var _index2 = _interopRequireDefault(_index);
205+
206+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
207+
208+
module.exports = _index2.default; // this is here for webpack to expose SwupPlugin as window.SwupPlugin
209+
210+
/***/ })
211+
/******/ ]);
212+
});

dist/SwupGaPlugin.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

entry.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// this is here for webpack to expose SwupPlugin as window.SwupPlugin
2+
import SwupPlugin from './src/index.js';
3+
module.exports = SwupPlugin;

0 commit comments

Comments
 (0)