Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

added ip from dropdown

  • Loading branch information...
luceos committed Jan 19, 2016
1 parent dbebc07 commit a6ba11f21de8012f84f530d81bb934912c316340
Showing with 20 additions and 8 deletions.
  1. +7 −5 js/forum/dist/extension.js
  2. +13 −3 js/forum/src/main.js
@@ -1,28 +1,30 @@
System.register('hyn/guardian/main', ['flarum/extend', 'flarum/components/PostMeta', 'flarum/components/CommentPost', 'flarum/models/Post', 'flarum/Model'], function (_export) {
System.register('hyn/guardian/main', ['flarum/extend', 'flarum/components/CommentPost', 'flarum/models/Post', 'flarum/Model', 'flarum/helpers/icon'], function (_export) {
'use strict';

var extend, PostMeta, CommentPost, Post, Model;
var extend, CommentPost, Post, Model, icon;
return {
setters: [function (_flarumExtend) {
extend = _flarumExtend.extend;
}, function (_flarumComponentsPostMeta) {
PostMeta = _flarumComponentsPostMeta['default'];
}, function (_flarumComponentsCommentPost) {
CommentPost = _flarumComponentsCommentPost['default'];
}, function (_flarumModelsPost) {
Post = _flarumModelsPost['default'];
}, function (_flarumModel) {
Model = _flarumModel['default'];
}, function (_flarumHelpersIcon) {
icon = _flarumHelpersIcon['default'];
}],
execute: function () {

app.initializers.add('hyn-guardian', function (app) {
// extend the Post object to add the user_ip
babelHelpers._extends(Post.prototype, {
user_ip: Model.attribute('user_ip')
});
// extend the CommentPost
extend(CommentPost.prototype, 'headerItems', function (items) {
if (this.props.post.user_ip()) {
items.add('guardian', m('div', { className: 'PostGuardian PostMeta' }, [this.props.post.user_ip()]));
items.add('guardian', m('div', { className: 'PostGuardian PostMeta Dropdown' }, [m('a', { className: 'Dropdown-toggle', 'data-toggle': 'dropdown' }, [icon('user-secret')]), m('div', { className: 'Dropdown-menu dropdown-menu' }, [m('span', [icon('wifi'), this.props.post.user_ip()])])]));
}

return items;
@@ -1,17 +1,27 @@
import { extend } from 'flarum/extend';
import PostMeta from 'flarum/components/PostMeta';
import CommentPost from 'flarum/components/CommentPost';
import Post from 'flarum/models/Post';
import Model from 'flarum/Model';
import icon from 'flarum/helpers/icon';

app.initializers.add('hyn-guardian', app => {
// extend the Post object to add the user_ip
Object.assign(Post.prototype, {
user_ip: Model.attribute('user_ip')
});
// extend the CommentPost
extend(CommentPost.prototype, 'headerItems', function(items) {
if(this.props.post.user_ip()) {
items.add('guardian', m('div', {className: 'PostGuardian PostMeta'}, [
this.props.post.user_ip()
items.add('guardian', m('div', {className: 'PostGuardian PostMeta Dropdown'}, [
m('a', {className: 'Dropdown-toggle', 'data-toggle': 'dropdown'}, [
icon('user-secret')
]),
m('div', {className: 'Dropdown-menu dropdown-menu'}, [
m('span', [
icon('wifi'),
this.props.post.user_ip()
])
])
]));
}

0 comments on commit a6ba11f

Please sign in to comment.
You can’t perform that action at this time.