mirror of
https://github.com/flarum/core.git
synced 2025-08-07 08:56:38 +02:00
Upgrade to flarum-gulp 0.2.0 / Babel 6
This commit is contained in:
8
extensions/likes/js/admin/dist/extension.js
vendored
8
extensions/likes/js/admin/dist/extension.js
vendored
@@ -1,14 +1,14 @@
|
|||||||
System.register('flarum/likes/main', ['flarum/extend', 'flarum/app', 'flarum/components/PermissionGrid'], function (_export) {
|
'use strict';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
System.register('flarum/likes/main', ['flarum/extend', 'flarum/app', 'flarum/components/PermissionGrid'], function (_export, _context) {
|
||||||
var extend, app, PermissionGrid;
|
var extend, app, PermissionGrid;
|
||||||
return {
|
return {
|
||||||
setters: [function (_flarumExtend) {
|
setters: [function (_flarumExtend) {
|
||||||
extend = _flarumExtend.extend;
|
extend = _flarumExtend.extend;
|
||||||
}, function (_flarumApp) {
|
}, function (_flarumApp) {
|
||||||
app = _flarumApp['default'];
|
app = _flarumApp.default;
|
||||||
}, function (_flarumComponentsPermissionGrid) {
|
}, function (_flarumComponentsPermissionGrid) {
|
||||||
PermissionGrid = _flarumComponentsPermissionGrid['default'];
|
PermissionGrid = _flarumComponentsPermissionGrid.default;
|
||||||
}],
|
}],
|
||||||
execute: function () {
|
execute: function () {
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^3.8.11",
|
"gulp": "^3.9.1",
|
||||||
"flarum-gulp": "^0.1.0"
|
"flarum-gulp": "^0.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
276
extensions/likes/js/forum/dist/extension.js
vendored
276
extensions/likes/js/forum/dist/extension.js
vendored
@@ -1,149 +1,151 @@
|
|||||||
System.register('flarum/likes/addLikeAction', ['flarum/extend', 'flarum/app', 'flarum/components/Button', 'flarum/components/CommentPost'], function (_export) {
|
'use strict';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
System.register('flarum/likes/addLikeAction', ['flarum/extend', 'flarum/app', 'flarum/components/Button', 'flarum/components/CommentPost'], function (_export, _context) {
|
||||||
var extend, app, Button, CommentPost;
|
var extend, app, Button, CommentPost;
|
||||||
return {
|
|
||||||
setters: [function (_flarumExtend) {
|
|
||||||
extend = _flarumExtend.extend;
|
|
||||||
}, function (_flarumApp) {
|
|
||||||
app = _flarumApp['default'];
|
|
||||||
}, function (_flarumComponentsButton) {
|
|
||||||
Button = _flarumComponentsButton['default'];
|
|
||||||
}, function (_flarumComponentsCommentPost) {
|
|
||||||
CommentPost = _flarumComponentsCommentPost['default'];
|
|
||||||
}],
|
|
||||||
execute: function () {
|
|
||||||
_export('default', function () {
|
|
||||||
extend(CommentPost.prototype, 'actionItems', function (items) {
|
|
||||||
var post = this.props.post;
|
|
||||||
|
|
||||||
if (post.isHidden() || !post.canLike()) return;
|
_export('default', function () {
|
||||||
|
extend(CommentPost.prototype, 'actionItems', function (items) {
|
||||||
|
var post = this.props.post;
|
||||||
|
|
||||||
var isLiked = app.session.user && post.likes().some(function (user) {
|
if (post.isHidden() || !post.canLike()) return;
|
||||||
return user === app.session.user;
|
|
||||||
|
var isLiked = app.session.user && post.likes().some(function (user) {
|
||||||
|
return user === app.session.user;
|
||||||
|
});
|
||||||
|
|
||||||
|
items.add('like', Button.component({
|
||||||
|
children: app.translator.trans(isLiked ? 'flarum-likes.forum.post.unlike_link' : 'flarum-likes.forum.post.like_link'),
|
||||||
|
className: 'Button Button--link',
|
||||||
|
onclick: function onclick() {
|
||||||
|
isLiked = !isLiked;
|
||||||
|
|
||||||
|
post.save({ isLiked: isLiked });
|
||||||
|
|
||||||
|
// We've saved the fact that we do or don't like the post, but in order
|
||||||
|
// to provide instantaneous feedback to the user, we'll need to add or
|
||||||
|
// remove the like from the relationship data manually.
|
||||||
|
var data = post.data.relationships.likes.data;
|
||||||
|
data.some(function (like, i) {
|
||||||
|
if (like.id === app.session.user.id()) {
|
||||||
|
data.splice(i, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
items.add('like', Button.component({
|
if (isLiked) {
|
||||||
children: app.translator.trans(isLiked ? 'flarum-likes.forum.post.unlike_link' : 'flarum-likes.forum.post.like_link'),
|
data.unshift({ type: 'users', id: app.session.user.id() });
|
||||||
className: 'Button Button--link',
|
}
|
||||||
onclick: function onclick() {
|
}
|
||||||
isLiked = !isLiked;
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
post.save({ isLiked: isLiked });
|
|
||||||
|
|
||||||
// We've saved the fact that we do or don't like the post, but in order
|
|
||||||
// to provide instantaneous feedback to the user, we'll need to add or
|
|
||||||
// remove the like from the relationship data manually.
|
|
||||||
var data = post.data.relationships.likes.data;
|
|
||||||
data.some(function (like, i) {
|
|
||||||
if (like.id === app.session.user.id()) {
|
|
||||||
data.splice(i, 1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isLiked) {
|
|
||||||
data.unshift({ type: 'users', id: app.session.user.id() });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});;
|
|
||||||
System.register('flarum/likes/addLikesList', ['flarum/extend', 'flarum/app', 'flarum/components/CommentPost', 'flarum/helpers/punctuateSeries', 'flarum/helpers/username', 'flarum/helpers/icon', 'flarum/likes/components/PostLikesModal'], function (_export) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var extend, app, CommentPost, punctuateSeries, username, icon, PostLikesModal;
|
|
||||||
return {
|
return {
|
||||||
setters: [function (_flarumExtend) {
|
setters: [function (_flarumExtend) {
|
||||||
extend = _flarumExtend.extend;
|
extend = _flarumExtend.extend;
|
||||||
}, function (_flarumApp) {
|
}, function (_flarumApp) {
|
||||||
app = _flarumApp['default'];
|
app = _flarumApp.default;
|
||||||
|
}, function (_flarumComponentsButton) {
|
||||||
|
Button = _flarumComponentsButton.default;
|
||||||
}, function (_flarumComponentsCommentPost) {
|
}, function (_flarumComponentsCommentPost) {
|
||||||
CommentPost = _flarumComponentsCommentPost['default'];
|
CommentPost = _flarumComponentsCommentPost.default;
|
||||||
}, function (_flarumHelpersPunctuateSeries) {
|
|
||||||
punctuateSeries = _flarumHelpersPunctuateSeries['default'];
|
|
||||||
}, function (_flarumHelpersUsername) {
|
|
||||||
username = _flarumHelpersUsername['default'];
|
|
||||||
}, function (_flarumHelpersIcon) {
|
|
||||||
icon = _flarumHelpersIcon['default'];
|
|
||||||
}, function (_flarumLikesComponentsPostLikesModal) {
|
|
||||||
PostLikesModal = _flarumLikesComponentsPostLikesModal['default'];
|
|
||||||
}],
|
}],
|
||||||
execute: function () {
|
execute: function () {}
|
||||||
_export('default', function () {
|
|
||||||
extend(CommentPost.prototype, 'footerItems', function (items) {
|
|
||||||
var post = this.props.post;
|
|
||||||
var likes = post.likes();
|
|
||||||
|
|
||||||
if (likes && likes.length) {
|
|
||||||
var limit = 4;
|
|
||||||
var overLimit = likes.length > limit;
|
|
||||||
|
|
||||||
// Construct a list of names of users who have liked this post. Make sure the
|
|
||||||
// current user is first in the list, and cap a maximum of 4 items.
|
|
||||||
var names = likes.sort(function (a) {
|
|
||||||
return a === app.session.user ? -1 : 1;
|
|
||||||
}).slice(0, overLimit ? limit - 1 : limit).map(function (user) {
|
|
||||||
return m(
|
|
||||||
'a',
|
|
||||||
{ href: app.route.user(user), config: m.route },
|
|
||||||
user === app.session.user ? app.translator.trans('flarum-likes.forum.post.you_text') : username(user)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// If there are more users that we've run out of room to display, add a "x
|
|
||||||
// others" name to the end of the list. Clicking on it will display a modal
|
|
||||||
// with a full list of names.
|
|
||||||
if (overLimit) {
|
|
||||||
var count = likes.length - names.length;
|
|
||||||
|
|
||||||
names.push(m(
|
|
||||||
'a',
|
|
||||||
{ href: '#', onclick: function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
app.modal.show(new PostLikesModal({ post: post }));
|
|
||||||
} },
|
|
||||||
app.translator.transChoice('flarum-likes.forum.post.others_link', count, { count: count })
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
items.add('liked', m(
|
|
||||||
'div',
|
|
||||||
{ className: 'Post-likedBy' },
|
|
||||||
icon('thumbs-o-up'),
|
|
||||||
app.translator.transChoice('flarum-likes.forum.post.liked_by' + (likes[0] === app.session.user ? '_self' : '') + '_text', names.length, {
|
|
||||||
count: names.length,
|
|
||||||
users: punctuateSeries(names)
|
|
||||||
})
|
|
||||||
));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
});;
|
});;
|
||||||
System.register('flarum/likes/components/PostLikedNotification', ['flarum/components/Notification', 'flarum/helpers/username', 'flarum/helpers/punctuateSeries'], function (_export) {
|
'use strict';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
System.register('flarum/likes/addLikesList', ['flarum/extend', 'flarum/app', 'flarum/components/CommentPost', 'flarum/helpers/punctuateSeries', 'flarum/helpers/username', 'flarum/helpers/icon', 'flarum/likes/components/PostLikesModal'], function (_export, _context) {
|
||||||
|
var extend, app, CommentPost, punctuateSeries, username, icon, PostLikesModal;
|
||||||
|
|
||||||
|
_export('default', function () {
|
||||||
|
extend(CommentPost.prototype, 'footerItems', function (items) {
|
||||||
|
var post = this.props.post;
|
||||||
|
var likes = post.likes();
|
||||||
|
|
||||||
|
if (likes && likes.length) {
|
||||||
|
var limit = 4;
|
||||||
|
var overLimit = likes.length > limit;
|
||||||
|
|
||||||
|
// Construct a list of names of users who have liked this post. Make sure the
|
||||||
|
// current user is first in the list, and cap a maximum of 4 items.
|
||||||
|
var names = likes.sort(function (a) {
|
||||||
|
return a === app.session.user ? -1 : 1;
|
||||||
|
}).slice(0, overLimit ? limit - 1 : limit).map(function (user) {
|
||||||
|
return m(
|
||||||
|
'a',
|
||||||
|
{ href: app.route.user(user), config: m.route },
|
||||||
|
user === app.session.user ? app.translator.trans('flarum-likes.forum.post.you_text') : username(user)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// If there are more users that we've run out of room to display, add a "x
|
||||||
|
// others" name to the end of the list. Clicking on it will display a modal
|
||||||
|
// with a full list of names.
|
||||||
|
if (overLimit) {
|
||||||
|
var count = likes.length - names.length;
|
||||||
|
|
||||||
|
names.push(m(
|
||||||
|
'a',
|
||||||
|
{ href: '#', onclick: function onclick(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
app.modal.show(new PostLikesModal({ post: post }));
|
||||||
|
} },
|
||||||
|
app.translator.transChoice('flarum-likes.forum.post.others_link', count, { count: count })
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
items.add('liked', m(
|
||||||
|
'div',
|
||||||
|
{ className: 'Post-likedBy' },
|
||||||
|
icon('thumbs-o-up'),
|
||||||
|
app.translator.transChoice('flarum-likes.forum.post.liked_by' + (likes[0] === app.session.user ? '_self' : '') + '_text', names.length, {
|
||||||
|
count: names.length,
|
||||||
|
users: punctuateSeries(names)
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
setters: [function (_flarumExtend) {
|
||||||
|
extend = _flarumExtend.extend;
|
||||||
|
}, function (_flarumApp) {
|
||||||
|
app = _flarumApp.default;
|
||||||
|
}, function (_flarumComponentsCommentPost) {
|
||||||
|
CommentPost = _flarumComponentsCommentPost.default;
|
||||||
|
}, function (_flarumHelpersPunctuateSeries) {
|
||||||
|
punctuateSeries = _flarumHelpersPunctuateSeries.default;
|
||||||
|
}, function (_flarumHelpersUsername) {
|
||||||
|
username = _flarumHelpersUsername.default;
|
||||||
|
}, function (_flarumHelpersIcon) {
|
||||||
|
icon = _flarumHelpersIcon.default;
|
||||||
|
}, function (_flarumLikesComponentsPostLikesModal) {
|
||||||
|
PostLikesModal = _flarumLikesComponentsPostLikesModal.default;
|
||||||
|
}],
|
||||||
|
execute: function () {}
|
||||||
|
};
|
||||||
|
});;
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
System.register('flarum/likes/components/PostLikedNotification', ['flarum/components/Notification', 'flarum/helpers/username', 'flarum/helpers/punctuateSeries'], function (_export, _context) {
|
||||||
var Notification, username, punctuateSeries, PostLikedNotification;
|
var Notification, username, punctuateSeries, PostLikedNotification;
|
||||||
return {
|
return {
|
||||||
setters: [function (_flarumComponentsNotification) {
|
setters: [function (_flarumComponentsNotification) {
|
||||||
Notification = _flarumComponentsNotification['default'];
|
Notification = _flarumComponentsNotification.default;
|
||||||
}, function (_flarumHelpersUsername) {
|
}, function (_flarumHelpersUsername) {
|
||||||
username = _flarumHelpersUsername['default'];
|
username = _flarumHelpersUsername.default;
|
||||||
}, function (_flarumHelpersPunctuateSeries) {
|
}, function (_flarumHelpersPunctuateSeries) {
|
||||||
punctuateSeries = _flarumHelpersPunctuateSeries['default'];
|
punctuateSeries = _flarumHelpersPunctuateSeries.default;
|
||||||
}],
|
}],
|
||||||
execute: function () {
|
execute: function () {
|
||||||
PostLikedNotification = (function (_Notification) {
|
PostLikedNotification = function (_Notification) {
|
||||||
babelHelpers.inherits(PostLikedNotification, _Notification);
|
babelHelpers.inherits(PostLikedNotification, _Notification);
|
||||||
|
|
||||||
function PostLikedNotification() {
|
function PostLikedNotification() {
|
||||||
babelHelpers.classCallCheck(this, PostLikedNotification);
|
babelHelpers.classCallCheck(this, PostLikedNotification);
|
||||||
babelHelpers.get(Object.getPrototypeOf(PostLikedNotification.prototype), 'constructor', this).apply(this, arguments);
|
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(PostLikedNotification).apply(this, arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
babelHelpers.createClass(PostLikedNotification, [{
|
babelHelpers.createClass(PostLikedNotification, [{
|
||||||
@@ -175,31 +177,31 @@ System.register('flarum/likes/components/PostLikedNotification', ['flarum/compon
|
|||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
return PostLikedNotification;
|
return PostLikedNotification;
|
||||||
})(Notification);
|
}(Notification);
|
||||||
|
|
||||||
_export('default', PostLikedNotification);
|
_export('default', PostLikedNotification);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});;
|
});;
|
||||||
System.register('flarum/likes/components/PostLikesModal', ['flarum/components/Modal', 'flarum/helpers/avatar', 'flarum/helpers/username'], function (_export) {
|
'use strict';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
System.register('flarum/likes/components/PostLikesModal', ['flarum/components/Modal', 'flarum/helpers/avatar', 'flarum/helpers/username'], function (_export, _context) {
|
||||||
var Modal, avatar, username, PostLikesModal;
|
var Modal, avatar, username, PostLikesModal;
|
||||||
return {
|
return {
|
||||||
setters: [function (_flarumComponentsModal) {
|
setters: [function (_flarumComponentsModal) {
|
||||||
Modal = _flarumComponentsModal['default'];
|
Modal = _flarumComponentsModal.default;
|
||||||
}, function (_flarumHelpersAvatar) {
|
}, function (_flarumHelpersAvatar) {
|
||||||
avatar = _flarumHelpersAvatar['default'];
|
avatar = _flarumHelpersAvatar.default;
|
||||||
}, function (_flarumHelpersUsername) {
|
}, function (_flarumHelpersUsername) {
|
||||||
username = _flarumHelpersUsername['default'];
|
username = _flarumHelpersUsername.default;
|
||||||
}],
|
}],
|
||||||
execute: function () {
|
execute: function () {
|
||||||
PostLikesModal = (function (_Modal) {
|
PostLikesModal = function (_Modal) {
|
||||||
babelHelpers.inherits(PostLikesModal, _Modal);
|
babelHelpers.inherits(PostLikesModal, _Modal);
|
||||||
|
|
||||||
function PostLikesModal() {
|
function PostLikesModal() {
|
||||||
babelHelpers.classCallCheck(this, PostLikesModal);
|
babelHelpers.classCallCheck(this, PostLikesModal);
|
||||||
babelHelpers.get(Object.getPrototypeOf(PostLikesModal.prototype), 'constructor', this).apply(this, arguments);
|
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(PostLikesModal).apply(this, arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
babelHelpers.createClass(PostLikesModal, [{
|
babelHelpers.createClass(PostLikesModal, [{
|
||||||
@@ -240,33 +242,33 @@ System.register('flarum/likes/components/PostLikesModal', ['flarum/components/Mo
|
|||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
return PostLikesModal;
|
return PostLikesModal;
|
||||||
})(Modal);
|
}(Modal);
|
||||||
|
|
||||||
_export('default', PostLikesModal);
|
_export('default', PostLikesModal);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});;
|
});;
|
||||||
System.register('flarum/likes/main', ['flarum/extend', 'flarum/app', 'flarum/models/Post', 'flarum/Model', 'flarum/components/NotificationGrid', 'flarum/likes/addLikeAction', 'flarum/likes/addLikesList', 'flarum/likes/components/PostLikedNotification'], function (_export) {
|
'use strict';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
System.register('flarum/likes/main', ['flarum/extend', 'flarum/app', 'flarum/models/Post', 'flarum/Model', 'flarum/components/NotificationGrid', 'flarum/likes/addLikeAction', 'flarum/likes/addLikesList', 'flarum/likes/components/PostLikedNotification'], function (_export, _context) {
|
||||||
var extend, app, Post, Model, NotificationGrid, addLikeAction, addLikesList, PostLikedNotification;
|
var extend, app, Post, Model, NotificationGrid, addLikeAction, addLikesList, PostLikedNotification;
|
||||||
return {
|
return {
|
||||||
setters: [function (_flarumExtend) {
|
setters: [function (_flarumExtend) {
|
||||||
extend = _flarumExtend.extend;
|
extend = _flarumExtend.extend;
|
||||||
}, function (_flarumApp) {
|
}, function (_flarumApp) {
|
||||||
app = _flarumApp['default'];
|
app = _flarumApp.default;
|
||||||
}, function (_flarumModelsPost) {
|
}, function (_flarumModelsPost) {
|
||||||
Post = _flarumModelsPost['default'];
|
Post = _flarumModelsPost.default;
|
||||||
}, function (_flarumModel) {
|
}, function (_flarumModel) {
|
||||||
Model = _flarumModel['default'];
|
Model = _flarumModel.default;
|
||||||
}, function (_flarumComponentsNotificationGrid) {
|
}, function (_flarumComponentsNotificationGrid) {
|
||||||
NotificationGrid = _flarumComponentsNotificationGrid['default'];
|
NotificationGrid = _flarumComponentsNotificationGrid.default;
|
||||||
}, function (_flarumLikesAddLikeAction) {
|
}, function (_flarumLikesAddLikeAction) {
|
||||||
addLikeAction = _flarumLikesAddLikeAction['default'];
|
addLikeAction = _flarumLikesAddLikeAction.default;
|
||||||
}, function (_flarumLikesAddLikesList) {
|
}, function (_flarumLikesAddLikesList) {
|
||||||
addLikesList = _flarumLikesAddLikesList['default'];
|
addLikesList = _flarumLikesAddLikesList.default;
|
||||||
}, function (_flarumLikesComponentsPostLikedNotification) {
|
}, function (_flarumLikesComponentsPostLikedNotification) {
|
||||||
PostLikedNotification = _flarumLikesComponentsPostLikedNotification['default'];
|
PostLikedNotification = _flarumLikesComponentsPostLikedNotification.default;
|
||||||
}],
|
}],
|
||||||
execute: function () {
|
execute: function () {
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^3.8.11",
|
"gulp": "^3.9.1",
|
||||||
"flarum-gulp": "^0.1.0"
|
"flarum-gulp": "^0.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user