forked from AkkomaGang/akkoma-fe
Merge remote-tracking branch 'upstream/develop' into emoji-selector-update
* upstream/develop: (469 commits) Feature/add sticker picker guard more secure routes guard secure routes by redirecting to root closest can returns itself as well find inside status-content div only try to use the closest a tag as target Update es.json Also apply keyword filter to subjects Remove files I accidentally pushed in fix issues caused by merges in usersearch on @ Add user search at fix eslint warnings remove vue-popperjs fix moderation menu partially hidden by usercard boundary migrate popper css rewrite ModerationTools using v-tooltip make popover position for status action dropdow relative to parent node rewrite ExtraButtons using v-tooltip install v-tooltip i18n/Update pedantic Japanese translation ...
This commit is contained in:
commit
b3aff9bbae
257 changed files with 15939 additions and 5477 deletions
12
.eslintrc.js
12
.eslintrc.js
|
@ -1,14 +1,17 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
root: true,
|
||||||
parser: 'babel-eslint',
|
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
|
parser: 'babel-eslint',
|
||||||
sourceType: 'module'
|
sourceType: 'module'
|
||||||
},
|
},
|
||||||
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
|
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
|
||||||
extends: 'standard',
|
extends: [
|
||||||
|
'standard',
|
||||||
|
'plugin:vue/recommended'
|
||||||
|
],
|
||||||
// required to lint *.vue files
|
// required to lint *.vue files
|
||||||
plugins: [
|
plugins: [
|
||||||
'html'
|
'vue'
|
||||||
],
|
],
|
||||||
// add your custom rules here
|
// add your custom rules here
|
||||||
rules: {
|
rules: {
|
||||||
|
@ -17,6 +20,7 @@ module.exports = {
|
||||||
// allow async-await
|
// allow async-await
|
||||||
'generator-star-spacing': 0,
|
'generator-star-spacing': 0,
|
||||||
// allow debugger during development
|
// allow debugger during development
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
|
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
|
||||||
|
'vue/require-prop-types': 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# This file is a template, and might need editing before it works on your project.
|
# This file is a template, and might need editing before it works on your project.
|
||||||
# Official framework image. Look for the different tagged releases at:
|
# Official framework image. Look for the different tagged releases at:
|
||||||
# https://hub.docker.com/r/library/node/tags/
|
# https://hub.docker.com/r/library/node/tags/
|
||||||
image: node:7
|
image: node:8
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- lint
|
- lint
|
||||||
|
@ -16,7 +16,12 @@ lint:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
|
variables:
|
||||||
|
APT_CACHE_DIR: apt-cache
|
||||||
script:
|
script:
|
||||||
|
- mkdir -pv $APT_CACHE_DIR && apt-get -qq update
|
||||||
|
- apt install firefox-esr -y --no-install-recommends
|
||||||
|
- firefox --version
|
||||||
- yarn
|
- yarn
|
||||||
- npm run unit
|
- npm run unit
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# v1.0
|
# v1.0
|
||||||
## Removed features/radically changed behavior
|
## Removed features/radically changed behavior
|
||||||
|
### formattingOptionsEnabled
|
||||||
|
as of !833 `formattingOptionsEnabled` is no longer available and instead FE check for available post formatting options and enables formatting control if there's more than one option.
|
||||||
|
|
||||||
### minimalScopesMode
|
### minimalScopesMode
|
||||||
As of !633, `scopeOptions` is no longer available and instead is changed for `minimalScopesMode` (default: `false`)
|
As of !633, `scopeOptions` is no longer available and instead is changed for `minimalScopesMode` (default: `false`)
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,13 @@ var hotMiddleware = require('webpack-hot-middleware')(compiler)
|
||||||
// force page reload when html-webpack-plugin template changes
|
// force page reload when html-webpack-plugin template changes
|
||||||
compiler.plugin('compilation', function (compilation) {
|
compiler.plugin('compilation', function (compilation) {
|
||||||
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
|
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
|
||||||
hotMiddleware.publish({ action: 'reload' })
|
// FIXME: This supposed to reload whole page when index.html is changed,
|
||||||
cb()
|
// however now it reloads entire page on every breath, i suppose the order
|
||||||
|
// of plugins changed or something. It's a minor thing and douesn't hurt
|
||||||
|
// disabling it, constant reloads hurt much more
|
||||||
|
|
||||||
|
// hotMiddleware.publish({ action: 'reload' })
|
||||||
|
// cb()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
var path = require('path')
|
var path = require('path')
|
||||||
var config = require('../config')
|
var config = require('../config')
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
var sass = require('sass')
|
||||||
|
var MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||||
|
|
||||||
exports.assetsPath = function (_path) {
|
exports.assetsPath = function (_path) {
|
||||||
var assetsSubDirectory = process.env.NODE_ENV === 'production'
|
var assetsSubDirectory = process.env.NODE_ENV === 'production'
|
||||||
|
@ -11,51 +12,51 @@ exports.assetsPath = function (_path) {
|
||||||
|
|
||||||
exports.cssLoaders = function (options) {
|
exports.cssLoaders = function (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
// generate loader string to be used with extract text plugin
|
|
||||||
function generateLoaders (loaders) {
|
|
||||||
var sourceLoader = loaders.map(function (loader) {
|
|
||||||
var extraParamChar
|
|
||||||
if (/\?/.test(loader)) {
|
|
||||||
loader = loader.replace(/\?/, '-loader?')
|
|
||||||
extraParamChar = '&'
|
|
||||||
} else {
|
|
||||||
loader = loader + '-loader'
|
|
||||||
extraParamChar = '?'
|
|
||||||
}
|
|
||||||
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
|
|
||||||
}).join('!')
|
|
||||||
|
|
||||||
|
function generateLoaders (loaders) {
|
||||||
// Extract CSS when that option is specified
|
// Extract CSS when that option is specified
|
||||||
// (which is the case during production build)
|
// (which is the case during production build)
|
||||||
if (options.extract) {
|
if (options.extract) {
|
||||||
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
|
return [MiniCssExtractPlugin.loader].concat(loaders)
|
||||||
} else {
|
} else {
|
||||||
return ['vue-style-loader', sourceLoader].join('!')
|
return ['vue-style-loader'].concat(loaders)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://vuejs.github.io/vue-loader/configurations/extract-css.html
|
// http://vuejs.github.io/vue-loader/configurations/extract-css.html
|
||||||
return {
|
return [
|
||||||
css: generateLoaders(['css']),
|
{
|
||||||
postcss: generateLoaders(['css']),
|
test: /\.(post)?css$/,
|
||||||
less: generateLoaders(['css', 'less']),
|
use: generateLoaders(['css-loader']),
|
||||||
sass: generateLoaders(['css', 'sass?indentedSyntax']),
|
},
|
||||||
scss: generateLoaders(['css', 'sass']),
|
{
|
||||||
stylus: generateLoaders(['css', 'stylus']),
|
test: /\.less$/,
|
||||||
styl: generateLoaders(['css', 'stylus'])
|
use: generateLoaders(['css-loader', 'less-loader']),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.sass$/,
|
||||||
|
use: generateLoaders([
|
||||||
|
'css-loader',
|
||||||
|
{
|
||||||
|
loader: 'sass-loader',
|
||||||
|
options: {
|
||||||
|
indentedSyntax: true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
])
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
use: generateLoaders(['css-loader', 'sass-loader'])
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.styl(us)?$/,
|
||||||
|
use: generateLoaders(['css-loader', 'stylus-loader']),
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate loaders for standalone style files (outside of .vue)
|
// Generate loaders for standalone style files (outside of .vue)
|
||||||
exports.styleLoaders = function (options) {
|
exports.styleLoaders = function (options) {
|
||||||
var output = []
|
return exports.cssLoaders(options)
|
||||||
var loaders = exports.cssLoaders(options)
|
|
||||||
for (var extension in loaders) {
|
|
||||||
var loader = loaders[extension]
|
|
||||||
output.push({
|
|
||||||
test: new RegExp('\\.' + extension + '$'),
|
|
||||||
loader: loader
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return output
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,16 @@ module.exports = {
|
||||||
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
|
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
|
||||||
filename: '[name].js'
|
filename: '[name].js'
|
||||||
},
|
},
|
||||||
|
optimization: {
|
||||||
|
splitChunks: {
|
||||||
|
chunks: 'all'
|
||||||
|
}
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['', '.js', '.vue'],
|
extensions: ['.js', '.vue'],
|
||||||
fallback: [path.join(__dirname, '../node_modules')],
|
modules: [
|
||||||
|
path.join(__dirname, '../node_modules')
|
||||||
|
],
|
||||||
alias: {
|
alias: {
|
||||||
'vue$': 'vue/dist/vue.runtime.common',
|
'vue$': 'vue/dist/vue.runtime.common',
|
||||||
'src': path.resolve(__dirname, '../src'),
|
'src': path.resolve(__dirname, '../src'),
|
||||||
|
@ -30,67 +37,53 @@ module.exports = {
|
||||||
'components': path.resolve(__dirname, '../src/components')
|
'components': path.resolve(__dirname, '../src/components')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
resolveLoader: {
|
|
||||||
fallback: [path.join(__dirname, '../node_modules')]
|
|
||||||
},
|
|
||||||
module: {
|
module: {
|
||||||
noParse: /node_modules\/localforage\/dist\/localforage.js/,
|
noParse: /node_modules\/localforage\/dist\/localforage.js/,
|
||||||
preLoaders: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.vue$/,
|
enforce: 'pre',
|
||||||
loader: 'eslint',
|
test: /\.(js|vue)$/,
|
||||||
include: projectRoot,
|
include: projectRoot,
|
||||||
exclude: /node_modules/
|
exclude: /node_modules/,
|
||||||
|
use: {
|
||||||
|
loader: 'eslint-loader',
|
||||||
|
options: {
|
||||||
|
formatter: require('eslint-friendly-formatter'),
|
||||||
|
sourceMap: config.build.productionSourceMap,
|
||||||
|
extract: true
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
loader: 'eslint',
|
|
||||||
include: projectRoot,
|
|
||||||
exclude: /node_modules/
|
|
||||||
}
|
|
||||||
],
|
|
||||||
loaders: [
|
|
||||||
{
|
{
|
||||||
test: /\.vue$/,
|
test: /\.vue$/,
|
||||||
loader: 'vue'
|
use: 'vue-loader'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.jsx?$/,
|
test: /\.jsx?$/,
|
||||||
loader: 'babel',
|
|
||||||
include: projectRoot,
|
include: projectRoot,
|
||||||
exclude: /node_modules\/(?!tributejs)/
|
exclude: /node_modules\/(?!tributejs)/,
|
||||||
},
|
use: 'babel-loader'
|
||||||
{
|
|
||||||
test: /\.json$/,
|
|
||||||
loader: 'json'
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
||||||
loader: 'url',
|
use: {
|
||||||
query: {
|
loader: 'url-loader',
|
||||||
|
options: {
|
||||||
limit: 10000,
|
limit: 10000,
|
||||||
name: utils.assetsPath('img/[name].[hash:7].[ext]')
|
name: utils.assetsPath('img/[name].[hash:7].[ext]')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
||||||
loader: 'url',
|
use: {
|
||||||
query: {
|
loader: 'url-loader',
|
||||||
|
options: {
|
||||||
limit: 10000,
|
limit: 10000,
|
||||||
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
|
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
},
|
},
|
||||||
eslint: {
|
|
||||||
formatter: require('eslint-friendly-formatter')
|
|
||||||
},
|
|
||||||
vue: {
|
|
||||||
loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
|
|
||||||
postcss: [
|
|
||||||
require('autoprefixer')({
|
|
||||||
browsers: ['last 2 versions']
|
|
||||||
})
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|
|
@ -12,8 +12,9 @@ Object.keys(baseWebpackConfig.entry).forEach(function (name) {
|
||||||
|
|
||||||
module.exports = merge(baseWebpackConfig, {
|
module.exports = merge(baseWebpackConfig, {
|
||||||
module: {
|
module: {
|
||||||
loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
|
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
|
||||||
},
|
},
|
||||||
|
mode: 'development',
|
||||||
// eval-source-map is faster for development
|
// eval-source-map is faster for development
|
||||||
devtool: '#eval-source-map',
|
devtool: '#eval-source-map',
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -23,9 +24,7 @@ module.exports = merge(baseWebpackConfig, {
|
||||||
'DEV_OVERRIDES': JSON.stringify(config.dev.settings)
|
'DEV_OVERRIDES': JSON.stringify(config.dev.settings)
|
||||||
}),
|
}),
|
||||||
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
|
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
|
||||||
new webpack.optimize.OccurenceOrderPlugin(),
|
|
||||||
new webpack.HotModuleReplacementPlugin(),
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
new webpack.NoErrorsPlugin(),
|
|
||||||
// https://github.com/ampedandwired/html-webpack-plugin
|
// https://github.com/ampedandwired/html-webpack-plugin
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
filename: 'index.html',
|
filename: 'index.html',
|
||||||
|
|
|
@ -4,7 +4,7 @@ var utils = require('./utils')
|
||||||
var webpack = require('webpack')
|
var webpack = require('webpack')
|
||||||
var merge = require('webpack-merge')
|
var merge = require('webpack-merge')
|
||||||
var baseWebpackConfig = require('./webpack.base.conf')
|
var baseWebpackConfig = require('./webpack.base.conf')
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
var MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||||
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
var env = process.env.NODE_ENV === 'testing'
|
var env = process.env.NODE_ENV === 'testing'
|
||||||
? require('../config/test.env')
|
? require('../config/test.env')
|
||||||
|
@ -13,23 +13,23 @@ var env = process.env.NODE_ENV === 'testing'
|
||||||
let commitHash = require('child_process')
|
let commitHash = require('child_process')
|
||||||
.execSync('git rev-parse --short HEAD')
|
.execSync('git rev-parse --short HEAD')
|
||||||
.toString();
|
.toString();
|
||||||
console.log(commitHash)
|
|
||||||
|
|
||||||
var webpackConfig = merge(baseWebpackConfig, {
|
var webpackConfig = merge(baseWebpackConfig, {
|
||||||
|
mode: 'production',
|
||||||
module: {
|
module: {
|
||||||
loaders: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true })
|
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, extract: true })
|
||||||
},
|
},
|
||||||
devtool: config.build.productionSourceMap ? '#source-map' : false,
|
devtool: config.build.productionSourceMap ? '#source-map' : false,
|
||||||
|
optimization: {
|
||||||
|
minimize: true,
|
||||||
|
splitChunks: {
|
||||||
|
chunks: 'all'
|
||||||
|
}
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
path: config.build.assetsRoot,
|
path: config.build.assetsRoot,
|
||||||
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
||||||
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
chunkFilename: utils.assetsPath('js/[name].[chunkhash].js')
|
||||||
},
|
|
||||||
vue: {
|
|
||||||
loaders: utils.cssLoaders({
|
|
||||||
sourceMap: config.build.productionSourceMap,
|
|
||||||
extract: true
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
// http://vuejs.github.io/vue-loader/workflow/production.html
|
// http://vuejs.github.io/vue-loader/workflow/production.html
|
||||||
|
@ -38,14 +38,10 @@ var webpackConfig = merge(baseWebpackConfig, {
|
||||||
'COMMIT_HASH': JSON.stringify(commitHash),
|
'COMMIT_HASH': JSON.stringify(commitHash),
|
||||||
'DEV_OVERRIDES': JSON.stringify(undefined)
|
'DEV_OVERRIDES': JSON.stringify(undefined)
|
||||||
}),
|
}),
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
|
||||||
compress: {
|
|
||||||
warnings: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
new webpack.optimize.OccurenceOrderPlugin(),
|
|
||||||
// extract css into its own file
|
// extract css into its own file
|
||||||
new ExtractTextPlugin(utils.assetsPath('css/[name].[contenthash].css')),
|
new MiniCssExtractPlugin({
|
||||||
|
filename: utils.assetsPath('css/[name].[contenthash].css')
|
||||||
|
}),
|
||||||
// generate dist index.html with correct asset hash for caching.
|
// generate dist index.html with correct asset hash for caching.
|
||||||
// you can customize output by editing /index.html
|
// you can customize output by editing /index.html
|
||||||
// see https://github.com/ampedandwired/html-webpack-plugin
|
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||||
|
@ -67,25 +63,11 @@ var webpackConfig = merge(baseWebpackConfig, {
|
||||||
chunksSortMode: 'dependency'
|
chunksSortMode: 'dependency'
|
||||||
}),
|
}),
|
||||||
// split vendor js into its own file
|
// split vendor js into its own file
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
|
||||||
name: 'vendor',
|
|
||||||
minChunks: function (module, count) {
|
|
||||||
// any required modules inside node_modules are extracted to vendor
|
|
||||||
return (
|
|
||||||
module.resource &&
|
|
||||||
/\.js$/.test(module.resource) &&
|
|
||||||
module.resource.indexOf(
|
|
||||||
path.join(__dirname, '../node_modules')
|
|
||||||
) === 0
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
// extract webpack runtime and module manifest to its own file in order to
|
// extract webpack runtime and module manifest to its own file in order to
|
||||||
// prevent vendor hash from being updated whenever app bundle is updated
|
// prevent vendor hash from being updated whenever app bundle is updated
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
// new webpack.optimize.SplitChunksPlugin({
|
||||||
name: 'manifest',
|
// name: ['app', 'vendor']
|
||||||
chunks: ['vendor']
|
// }),
|
||||||
})
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,11 @@ module.exports = {
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
cookieDomainRewrite: 'localhost',
|
cookieDomainRewrite: 'localhost',
|
||||||
ws: true
|
ws: true
|
||||||
|
},
|
||||||
|
'/oauth/revoke': {
|
||||||
|
target,
|
||||||
|
changeOrigin: true,
|
||||||
|
cookieDomainRewrite: 'localhost'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// CSS Sourcemaps off by default because relative paths are "buggy"
|
// CSS Sourcemaps off by default because relative paths are "buggy"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
|
||||||
<title>Pleroma</title>
|
<title>Pleroma</title>
|
||||||
<!--server-generated-meta-->
|
<!--server-generated-meta-->
|
||||||
<link rel="icon" type="image/png" href="/favicon.png">
|
<link rel="icon" type="image/png" href="/favicon.png">
|
||||||
|
|
60
package.json
60
package.json
|
@ -11,9 +11,11 @@
|
||||||
"unit:watch": "karma start test/unit/karma.conf.js --single-run=false",
|
"unit:watch": "karma start test/unit/karma.conf.js --single-run=false",
|
||||||
"e2e": "node test/e2e/runner.js",
|
"e2e": "node test/e2e/runner.js",
|
||||||
"test": "npm run unit && npm run e2e",
|
"test": "npm run unit && npm run e2e",
|
||||||
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
|
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
|
||||||
|
"lint-fix": "eslint --fix --ext .js,.vue src test/unit/specs test/e2e/specs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@chenfengyuan/vue-qrcode": "^1.0.0",
|
||||||
"babel-plugin-add-module-exports": "^0.2.1",
|
"babel-plugin-add-module-exports": "^0.2.1",
|
||||||
"babel-plugin-lodash": "^3.2.11",
|
"babel-plugin-lodash": "^3.2.11",
|
||||||
"chromatism": "^3.0.0",
|
"chromatism": "^3.0.0",
|
||||||
|
@ -21,18 +23,17 @@
|
||||||
"diff": "^3.0.1",
|
"diff": "^3.0.1",
|
||||||
"karma-mocha-reporter": "^2.2.1",
|
"karma-mocha-reporter": "^2.2.1",
|
||||||
"localforage": "^1.5.0",
|
"localforage": "^1.5.0",
|
||||||
"node-sass": "^3.10.1",
|
|
||||||
"object-path": "^0.11.3",
|
"object-path": "^0.11.3",
|
||||||
"phoenix": "^1.3.0",
|
"phoenix": "^1.3.0",
|
||||||
|
"portal-vue": "^2.1.4",
|
||||||
"sanitize-html": "^1.13.0",
|
"sanitize-html": "^1.13.0",
|
||||||
"sass-loader": "^4.0.2",
|
"v-click-outside": "^2.1.1",
|
||||||
|
"v-tooltip": "^2.0.2",
|
||||||
"vue": "^2.5.13",
|
"vue": "^2.5.13",
|
||||||
"vue-chat-scroll": "^1.2.1",
|
"vue-chat-scroll": "^1.2.1",
|
||||||
"vue-compose": "^0.7.1",
|
|
||||||
"vue-i18n": "^7.3.2",
|
"vue-i18n": "^7.3.2",
|
||||||
"vue-router": "^3.0.1",
|
"vue-router": "^3.0.1",
|
||||||
"vue-template-compiler": "^2.3.4",
|
"vue-template-compiler": "^2.3.4",
|
||||||
"vue-timeago": "^3.1.2",
|
|
||||||
"vuelidate": "^0.7.4",
|
"vuelidate": "^0.7.4",
|
||||||
"vuex": "^3.0.1",
|
"vuex": "^3.0.1",
|
||||||
"whatwg-fetch": "^2.0.3"
|
"whatwg-fetch": "^2.0.3"
|
||||||
|
@ -44,7 +45,7 @@
|
||||||
"babel-core": "^6.0.0",
|
"babel-core": "^6.0.0",
|
||||||
"babel-eslint": "^7.0.0",
|
"babel-eslint": "^7.0.0",
|
||||||
"babel-helper-vue-jsx-merge-props": "^2.0.3",
|
"babel-helper-vue-jsx-merge-props": "^2.0.3",
|
||||||
"babel-loader": "^6.0.0",
|
"babel-loader": "^7.0.0",
|
||||||
"babel-plugin-syntax-jsx": "^6.18.0",
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
||||||
"babel-plugin-transform-runtime": "^6.0.0",
|
"babel-plugin-transform-runtime": "^6.0.0",
|
||||||
"babel-plugin-transform-vue-jsx": "3",
|
"babel-plugin-transform-vue-jsx": "3",
|
||||||
|
@ -57,52 +58,55 @@
|
||||||
"chromedriver": "^2.21.2",
|
"chromedriver": "^2.21.2",
|
||||||
"connect-history-api-fallback": "^1.1.0",
|
"connect-history-api-fallback": "^1.1.0",
|
||||||
"cross-spawn": "^4.0.2",
|
"cross-spawn": "^4.0.2",
|
||||||
"css-loader": "^0.25.0",
|
"css-loader": "^0.28.0",
|
||||||
"eslint": "^3.7.1",
|
"eslint": "^5.16.0",
|
||||||
"eslint-config-standard": "^6.1.0",
|
"eslint-config-standard": "^12.0.0",
|
||||||
"eslint-friendly-formatter": "^2.0.5",
|
"eslint-friendly-formatter": "^2.0.5",
|
||||||
"eslint-loader": "^1.5.0",
|
"eslint-loader": "^2.1.0",
|
||||||
"eslint-plugin-html": "^1.5.5",
|
"eslint-plugin-import": "^2.13.0",
|
||||||
"eslint-plugin-promise": "^2.0.1",
|
"eslint-plugin-node": "^7.0.0",
|
||||||
"eslint-plugin-standard": "^2.0.1",
|
"eslint-plugin-promise": "^4.0.0",
|
||||||
|
"eslint-plugin-standard": "^4.0.0",
|
||||||
|
"eslint-plugin-vue": "^5.2.2",
|
||||||
"eventsource-polyfill": "^0.9.6",
|
"eventsource-polyfill": "^0.9.6",
|
||||||
"express": "^4.13.3",
|
"express": "^4.13.3",
|
||||||
"extract-text-webpack-plugin": "^1.0.1",
|
"file-loader": "^3.0.1",
|
||||||
"file-loader": "^0.9.0",
|
|
||||||
"function-bind": "^1.0.2",
|
"function-bind": "^1.0.2",
|
||||||
"html-webpack-plugin": "^2.8.1",
|
"html-webpack-plugin": "^3.0.0",
|
||||||
"http-proxy-middleware": "^0.17.2",
|
"http-proxy-middleware": "^0.17.2",
|
||||||
"inject-loader": "^2.0.1",
|
"inject-loader": "^2.0.1",
|
||||||
"iso-639-1": "^2.0.3",
|
"iso-639-1": "^2.0.3",
|
||||||
"isparta-loader": "^2.0.0",
|
"isparta-loader": "^2.0.0",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"karma": "^1.3.0",
|
"karma": "^3.0.0",
|
||||||
"karma-coverage": "^1.1.1",
|
"karma-coverage": "^1.1.1",
|
||||||
|
"karma-firefox-launcher": "^1.1.0",
|
||||||
"karma-mocha": "^1.2.0",
|
"karma-mocha": "^1.2.0",
|
||||||
"karma-phantomjs-launcher": "^1.0.0",
|
"karma-sinon-chai": "^2.0.2",
|
||||||
"karma-sinon-chai": "^1.2.0",
|
|
||||||
"karma-sourcemap-loader": "^0.3.7",
|
"karma-sourcemap-loader": "^0.3.7",
|
||||||
"karma-spec-reporter": "0.0.26",
|
"karma-spec-reporter": "0.0.26",
|
||||||
"karma-webpack": "^1.7.0",
|
"karma-webpack": "^4.0.0-rc.3",
|
||||||
"lodash": "^4.16.4",
|
"lodash": "^4.16.4",
|
||||||
"lolex": "^1.4.0",
|
"lolex": "^1.4.0",
|
||||||
|
"mini-css-extract-plugin": "^0.5.0",
|
||||||
"mocha": "^3.1.0",
|
"mocha": "^3.1.0",
|
||||||
"nightwatch": "^0.9.8",
|
"nightwatch": "^0.9.8",
|
||||||
"opn": "^4.0.2",
|
"opn": "^4.0.2",
|
||||||
"ora": "^0.3.0",
|
"ora": "^0.3.0",
|
||||||
"phantomjs-prebuilt": "^2.1.3",
|
|
||||||
"raw-loader": "^0.5.1",
|
"raw-loader": "^0.5.1",
|
||||||
|
"sass": "^1.17.3",
|
||||||
|
"sass-loader": "git://github.com/webpack-contrib/sass-loader",
|
||||||
"selenium-server": "2.53.1",
|
"selenium-server": "2.53.1",
|
||||||
"semver": "^5.3.0",
|
"semver": "^5.3.0",
|
||||||
"serviceworker-webpack-plugin": "0.2.3",
|
"serviceworker-webpack-plugin": "^1.0.0",
|
||||||
"shelljs": "^0.7.4",
|
"shelljs": "^0.7.4",
|
||||||
"sinon": "^1.17.3",
|
"sinon": "^2.1.0",
|
||||||
"sinon-chai": "^2.8.0",
|
"sinon-chai": "^2.8.0",
|
||||||
"url-loader": "^0.5.7",
|
"url-loader": "^1.1.2",
|
||||||
"vue-loader": "^11.1.0",
|
"vue-loader": "^14.0.0",
|
||||||
"vue-style-loader": "^2.0.0",
|
"vue-style-loader": "^4.0.0",
|
||||||
"webpack": "^1.13.2",
|
"webpack": "^4.0.0",
|
||||||
"webpack-dev-middleware": "^1.8.3",
|
"webpack-dev-middleware": "^3.6.0",
|
||||||
"webpack-hot-middleware": "^2.12.2",
|
"webpack-hot-middleware": "^2.12.2",
|
||||||
"webpack-merge": "^0.14.1"
|
"webpack-merge": "^0.14.1"
|
||||||
},
|
},
|
||||||
|
|
16
src/App.js
16
src/App.js
|
@ -1,7 +1,7 @@
|
||||||
import UserPanel from './components/user_panel/user_panel.vue'
|
import UserPanel from './components/user_panel/user_panel.vue'
|
||||||
import NavPanel from './components/nav_panel/nav_panel.vue'
|
import NavPanel from './components/nav_panel/nav_panel.vue'
|
||||||
import Notifications from './components/notifications/notifications.vue'
|
import Notifications from './components/notifications/notifications.vue'
|
||||||
import UserFinder from './components/user_finder/user_finder.vue'
|
import SearchBar from './components/search_bar/search_bar.vue'
|
||||||
import InstanceSpecificPanel from './components/instance_specific_panel/instance_specific_panel.vue'
|
import InstanceSpecificPanel from './components/instance_specific_panel/instance_specific_panel.vue'
|
||||||
import FeaturesPanel from './components/features_panel/features_panel.vue'
|
import FeaturesPanel from './components/features_panel/features_panel.vue'
|
||||||
import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_panel.vue'
|
import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_panel.vue'
|
||||||
|
@ -10,6 +10,7 @@ import MediaModal from './components/media_modal/media_modal.vue'
|
||||||
import SideDrawer from './components/side_drawer/side_drawer.vue'
|
import SideDrawer from './components/side_drawer/side_drawer.vue'
|
||||||
import MobilePostStatusModal from './components/mobile_post_status_modal/mobile_post_status_modal.vue'
|
import MobilePostStatusModal from './components/mobile_post_status_modal/mobile_post_status_modal.vue'
|
||||||
import MobileNav from './components/mobile_nav/mobile_nav.vue'
|
import MobileNav from './components/mobile_nav/mobile_nav.vue'
|
||||||
|
import UserReportingModal from './components/user_reporting_modal/user_reporting_modal.vue'
|
||||||
import { windowWidth } from './services/window_utils/window_utils'
|
import { windowWidth } from './services/window_utils/window_utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -18,7 +19,7 @@ export default {
|
||||||
UserPanel,
|
UserPanel,
|
||||||
NavPanel,
|
NavPanel,
|
||||||
Notifications,
|
Notifications,
|
||||||
UserFinder,
|
SearchBar,
|
||||||
InstanceSpecificPanel,
|
InstanceSpecificPanel,
|
||||||
FeaturesPanel,
|
FeaturesPanel,
|
||||||
WhoToFollowPanel,
|
WhoToFollowPanel,
|
||||||
|
@ -26,11 +27,12 @@ export default {
|
||||||
MediaModal,
|
MediaModal,
|
||||||
SideDrawer,
|
SideDrawer,
|
||||||
MobilePostStatusModal,
|
MobilePostStatusModal,
|
||||||
MobileNav
|
MobileNav,
|
||||||
|
UserReportingModal
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
mobileActivePanel: 'timeline',
|
mobileActivePanel: 'timeline',
|
||||||
finderHidden: true,
|
searchBarHidden: true,
|
||||||
supportsMask: window.CSS && window.CSS.supports && (
|
supportsMask: window.CSS && window.CSS.supports && (
|
||||||
window.CSS.supports('mask-size', 'contain') ||
|
window.CSS.supports('mask-size', 'contain') ||
|
||||||
window.CSS.supports('-webkit-mask-size', 'contain') ||
|
window.CSS.supports('-webkit-mask-size', 'contain') ||
|
||||||
|
@ -68,7 +70,7 @@ export default {
|
||||||
logoBgStyle () {
|
logoBgStyle () {
|
||||||
return Object.assign({
|
return Object.assign({
|
||||||
'margin': `${this.$store.state.instance.logoMargin} 0`,
|
'margin': `${this.$store.state.instance.logoMargin} 0`,
|
||||||
opacity: this.finderHidden ? 1 : 0
|
opacity: this.searchBarHidden ? 1 : 0
|
||||||
}, this.enableMask ? {} : {
|
}, this.enableMask ? {} : {
|
||||||
'background-color': this.enableMask ? '' : 'transparent'
|
'background-color': this.enableMask ? '' : 'transparent'
|
||||||
})
|
})
|
||||||
|
@ -99,8 +101,8 @@ export default {
|
||||||
this.$router.replace('/main/public')
|
this.$router.replace('/main/public')
|
||||||
this.$store.dispatch('logout')
|
this.$store.dispatch('logout')
|
||||||
},
|
},
|
||||||
onFinderToggled (hidden) {
|
onSearchBarToggled (hidden) {
|
||||||
this.finderHidden = hidden
|
this.searchBarHidden = hidden
|
||||||
},
|
},
|
||||||
updateMobileState () {
|
updateMobileState () {
|
||||||
const mobileLayout = windowWidth() <= 800
|
const mobileLayout = windowWidth() <= 800
|
||||||
|
|
229
src/App.scss
229
src/App.scss
|
@ -47,6 +47,8 @@ body {
|
||||||
color: var(--text, $fallback--text);
|
color: var(--text, $fallback--text);
|
||||||
max-width: 100vw;
|
max-width: 100vw;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
@ -101,6 +103,14 @@ button {
|
||||||
background-color: $fallback--bg;
|
background-color: $fallback--bg;
|
||||||
background-color: var(--bg, $fallback--bg)
|
background-color: var(--bg, $fallback--bg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.danger {
|
||||||
|
// TODO: add better color variable
|
||||||
|
color: $fallback--text;
|
||||||
|
color: var(--alertErrorPanelText, $fallback--text);
|
||||||
|
background-color: $fallback--alertError;
|
||||||
|
background-color: var(--alertError, $fallback--alertError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
label.select {
|
label.select {
|
||||||
|
@ -121,6 +131,7 @@ input, textarea, .select {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
font-family: var(--inputFont, sans-serif);
|
font-family: var(--inputFont, sans-serif);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
margin: 0;
|
||||||
padding: 8px .5em;
|
padding: 8px .5em;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -174,7 +185,44 @@ input, textarea, .select {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
&[type=radio],
|
&[type=radio] {
|
||||||
|
display: none;
|
||||||
|
&:checked + label::before {
|
||||||
|
box-shadow: 0px 0px 2px black inset, 0px 0px 0px 4px $fallback--fg inset;
|
||||||
|
box-shadow: var(--inputShadow), 0px 0px 0px 4px var(--fg, $fallback--fg) inset;
|
||||||
|
background-color: var(--link, $fallback--link);
|
||||||
|
}
|
||||||
|
&:disabled {
|
||||||
|
&,
|
||||||
|
& + label,
|
||||||
|
& + label::before {
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ label::before {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: inline-block;
|
||||||
|
content: '';
|
||||||
|
transition: box-shadow 200ms;
|
||||||
|
width: 1.1em;
|
||||||
|
height: 1.1em;
|
||||||
|
border-radius: 100%; // Radio buttons should always be circle
|
||||||
|
box-shadow: 0px 0px 2px black inset;
|
||||||
|
box-shadow: var(--inputShadow);
|
||||||
|
margin-right: .5em;
|
||||||
|
background-color: $fallback--fg;
|
||||||
|
background-color: var(--input, $fallback--fg);
|
||||||
|
vertical-align: top;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1.1em;
|
||||||
|
font-size: 1.1em;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: transparent;
|
||||||
|
overflow: hidden;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&[type=checkbox] {
|
&[type=checkbox] {
|
||||||
display: none;
|
display: none;
|
||||||
&:checked + label::before {
|
&:checked + label::before {
|
||||||
|
@ -189,6 +237,7 @@ input, textarea, .select {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+ label::before {
|
+ label::before {
|
||||||
|
flex-shrink: 0;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
content: '✔';
|
content: '✔';
|
||||||
transition: color 200ms;
|
transition: color 200ms;
|
||||||
|
@ -220,11 +269,45 @@ option {
|
||||||
background-color: var(--bg, $fallback--bg);
|
background-color: var(--bg, $fallback--bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hide-number-spinner {
|
||||||
|
-moz-appearance: textfield;
|
||||||
|
&[type=number]::-webkit-inner-spin-button,
|
||||||
|
&[type=number]::-webkit-outer-spin-button {
|
||||||
|
opacity: 0;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
i[class*=icon-] {
|
i[class*=icon-] {
|
||||||
color: $fallback--icon;
|
color: $fallback--icon;
|
||||||
color: var(--icon, $fallback--icon)
|
color: var(--icon, $fallback--icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-block {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-group {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
vertical-align: middle;
|
||||||
|
|
||||||
|
button {
|
||||||
|
position: relative;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
|
||||||
|
&:not(:last-child) {
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:not(:first-child) {
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -371,6 +454,7 @@ main-router {
|
||||||
|
|
||||||
.panel-heading {
|
.panel-heading {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex: none;
|
||||||
border-radius: $fallback--panelRadius $fallback--panelRadius 0 0;
|
border-radius: $fallback--panelRadius $fallback--panelRadius 0 0;
|
||||||
border-radius: var(--panelRadius, $fallback--panelRadius) var(--panelRadius, $fallback--panelRadius) 0 0;
|
border-radius: var(--panelRadius, $fallback--panelRadius) var(--panelRadius, $fallback--panelRadius) 0 0;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
@ -616,21 +700,6 @@ nav {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.visibility-tray {
|
|
||||||
font-size: 1.2em;
|
|
||||||
padding: 3px;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
.selected {
|
|
||||||
color: $fallback--lightText;
|
|
||||||
color: var(--lightText, $fallback--lightText);
|
|
||||||
}
|
|
||||||
|
|
||||||
div {
|
|
||||||
padding-top: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.visibility-notice {
|
.visibility-notice {
|
||||||
padding: .5em;
|
padding: .5em;
|
||||||
border: 1px solid $fallback--faint;
|
border: 1px solid $fallback--faint;
|
||||||
|
@ -639,6 +708,19 @@ nav {
|
||||||
border-radius: var(--inputRadius, $fallback--inputRadius);
|
border-radius: var(--inputRadius, $fallback--inputRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notice-dismissible {
|
||||||
|
padding-right: 4rem;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.dismiss {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
padding: .5em;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes modal-background-fadein {
|
@keyframes modal-background-fadein {
|
||||||
from {
|
from {
|
||||||
background-color: rgba(0, 0, 0, 0);
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
@ -718,6 +800,70 @@ nav {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.setting-item {
|
||||||
|
border-bottom: 2px solid var(--fg, $fallback--fg);
|
||||||
|
margin: 1em 1em 1.4em;
|
||||||
|
padding-bottom: 1.4em;
|
||||||
|
|
||||||
|
> div {
|
||||||
|
margin-bottom: .5em;
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
padding-bottom: 0;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
min-width: 10em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unavailable,
|
||||||
|
.unavailable i {
|
||||||
|
color: var(--cRed, $fallback--cRed);
|
||||||
|
color: $fallback--cRed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
min-height: 28px;
|
||||||
|
min-width: 10em;
|
||||||
|
padding: 0 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number-input {
|
||||||
|
max-width: 6em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.select-multiple {
|
||||||
|
display: flex;
|
||||||
|
.option-list {
|
||||||
|
margin: 0;
|
||||||
|
padding-left: .5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.setting-list,
|
||||||
|
.option-list{
|
||||||
|
list-style-type: none;
|
||||||
|
padding-left: 2em;
|
||||||
|
li {
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
.suboptions {
|
||||||
|
margin-top: 0.3em
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.login-hint {
|
.login-hint {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
|
@ -735,54 +881,3 @@ nav {
|
||||||
.btn.btn-default {
|
.btn.btn-default {
|
||||||
min-height: 28px;
|
min-height: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.autocomplete {
|
|
||||||
&-panel {
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
&-body {
|
|
||||||
margin: 0 0.5em 0 0.5em;
|
|
||||||
border-radius: $fallback--tooltipRadius;
|
|
||||||
border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
|
|
||||||
position: absolute;
|
|
||||||
z-index: 1;
|
|
||||||
box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.5);
|
|
||||||
// this doesn't match original but i don't care, making it uniform.
|
|
||||||
box-shadow: var(--popupShadow);
|
|
||||||
min-width: 75%;
|
|
||||||
background: $fallback--bg;
|
|
||||||
background: var(--bg, $fallback--bg);
|
|
||||||
color: $fallback--lightText;
|
|
||||||
color: var(--lightText, $fallback--lightText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-item {
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 0.2em 0.4em 0.2em 0.4em;
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.4);
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
img {
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
object-fit: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
line-height: 24px;
|
|
||||||
margin: 0 0.1em 0 0.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
small {
|
|
||||||
margin-left: .5em;
|
|
||||||
color: $fallback--faint;
|
|
||||||
color: var(--faint, $fallback--faint);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.highlighted {
|
|
||||||
background-color: $fallback--fg;
|
|
||||||
background-color: var(--lightBg, $fallback--fg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
114
src/App.vue
114
src/App.vue
|
@ -1,51 +1,113 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="app" v-bind:style="bgAppStyle">
|
<div
|
||||||
<div class="app-bg-wrapper" v-bind:style="bgStyle"></div>
|
id="app"
|
||||||
|
:style="bgAppStyle"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="app-bg-wrapper"
|
||||||
|
:style="bgStyle"
|
||||||
|
/>
|
||||||
<MobileNav v-if="isMobileLayout" />
|
<MobileNav v-if="isMobileLayout" />
|
||||||
<nav v-else class='nav-bar container' @click="scrollToTop()" id="nav">
|
<nav
|
||||||
<div class='logo' :style='logoBgStyle'>
|
v-else
|
||||||
<div class='mask' :style='logoMaskStyle'></div>
|
id="nav"
|
||||||
<img :src='logo' :style='logoStyle'>
|
class="nav-bar container"
|
||||||
|
@click="scrollToTop()"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="logo"
|
||||||
|
:style="logoBgStyle"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="mask"
|
||||||
|
:style="logoMaskStyle"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
:src="logo"
|
||||||
|
:style="logoStyle"
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class='inner-nav'>
|
<div class="inner-nav">
|
||||||
<div class='item'>
|
<div class="item">
|
||||||
<router-link class="site-name" :to="{ name: 'root' }" active-class="home">{{sitename}}</router-link>
|
<router-link
|
||||||
|
class="site-name"
|
||||||
|
:to="{ name: 'root' }"
|
||||||
|
active-class="home"
|
||||||
|
>
|
||||||
|
{{ sitename }}
|
||||||
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div class='item right'>
|
<div class="item right">
|
||||||
<user-finder class="button-icon nav-icon mobile-hidden" @toggled="onFinderToggled"></user-finder>
|
<search-bar
|
||||||
<router-link class="mobile-hidden" :to="{ name: 'settings'}"><i class="button-icon icon-cog nav-icon" :title="$t('nav.preferences')"></i></router-link>
|
class="nav-icon mobile-hidden"
|
||||||
<a href="#" class="mobile-hidden" v-if="currentUser" @click.prevent="logout"><i class="button-icon icon-logout nav-icon" :title="$t('login.logout')"></i></a>
|
@toggled="onSearchBarToggled"
|
||||||
|
/>
|
||||||
|
<router-link
|
||||||
|
class="mobile-hidden"
|
||||||
|
:to="{ name: 'settings'}"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
class="button-icon icon-cog nav-icon"
|
||||||
|
:title="$t('nav.preferences')"
|
||||||
|
/>
|
||||||
|
</router-link>
|
||||||
|
<a
|
||||||
|
v-if="currentUser"
|
||||||
|
href="#"
|
||||||
|
class="mobile-hidden"
|
||||||
|
@click.prevent="logout"
|
||||||
|
><i
|
||||||
|
class="button-icon icon-logout nav-icon"
|
||||||
|
:title="$t('login.logout')"
|
||||||
|
/></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<div v-if="" class="container" id="content">
|
<div
|
||||||
<div class="sidebar-flexer mobile-hidden" v-if="!isMobileLayout">
|
id="content"
|
||||||
|
class="container"
|
||||||
|
>
|
||||||
|
<div class="sidebar-flexer mobile-hidden">
|
||||||
<div class="sidebar-bounds">
|
<div class="sidebar-bounds">
|
||||||
<div class="sidebar-scroller">
|
<div class="sidebar-scroller">
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<user-panel></user-panel>
|
<user-panel />
|
||||||
<nav-panel></nav-panel>
|
<div v-if="!isMobileLayout">
|
||||||
<instance-specific-panel v-if="showInstanceSpecificPanel"></instance-specific-panel>
|
<nav-panel />
|
||||||
<features-panel v-if="!currentUser && showFeaturesPanel"></features-panel>
|
<instance-specific-panel v-if="showInstanceSpecificPanel" />
|
||||||
<who-to-follow-panel v-if="currentUser && suggestionsEnabled"></who-to-follow-panel>
|
<features-panel v-if="!currentUser && showFeaturesPanel" />
|
||||||
<notifications v-if="currentUser"></notifications>
|
<who-to-follow-panel v-if="currentUser && suggestionsEnabled" />
|
||||||
|
<notifications v-if="currentUser" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div v-if="!currentUser" class="login-hint panel panel-default">
|
<div
|
||||||
<router-link :to="{ name: 'login' }" class="panel-body">
|
v-if="!currentUser"
|
||||||
|
class="login-hint panel panel-default"
|
||||||
|
>
|
||||||
|
<router-link
|
||||||
|
:to="{ name: 'login' }"
|
||||||
|
class="panel-body"
|
||||||
|
>
|
||||||
{{ $t("login.hint") }}
|
{{ $t("login.hint") }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<transition name="fade">
|
<transition name="fade">
|
||||||
<router-view></router-view>
|
<router-view />
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
<media-modal></media-modal>
|
<media-modal />
|
||||||
</div>
|
</div>
|
||||||
<chat-panel :floating="true" v-if="currentUser && chat" class="floating-chat mobile-hidden"></chat-panel>
|
<chat-panel
|
||||||
|
v-if="currentUser && chat"
|
||||||
|
:floating="true"
|
||||||
|
class="floating-chat mobile-hidden"
|
||||||
|
/>
|
||||||
|
<UserReportingModal />
|
||||||
|
<portal-target name="modal" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ import VueRouter from 'vue-router'
|
||||||
import routes from './routes'
|
import routes from './routes'
|
||||||
import App from '../App.vue'
|
import App from '../App.vue'
|
||||||
import { windowWidth } from '../services/window_utils/window_utils'
|
import { windowWidth } from '../services/window_utils/window_utils'
|
||||||
|
import { getOrCreateApp, getClientToken } from '../services/new_api/oauth.js'
|
||||||
|
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
|
||||||
|
|
||||||
const getStatusnetConfig = async ({ store }) => {
|
const getStatusnetConfig = async ({ store }) => {
|
||||||
try {
|
try {
|
||||||
|
@ -92,15 +94,14 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
|
||||||
? 0
|
? 0
|
||||||
: config.logoMargin
|
: config.logoMargin
|
||||||
})
|
})
|
||||||
|
store.commit('authFlow/setInitialStrategy', config.loginMethod)
|
||||||
|
|
||||||
copyInstanceOption('redirectRootNoLogin')
|
copyInstanceOption('redirectRootNoLogin')
|
||||||
copyInstanceOption('redirectRootLogin')
|
copyInstanceOption('redirectRootLogin')
|
||||||
copyInstanceOption('showInstanceSpecificPanel')
|
copyInstanceOption('showInstanceSpecificPanel')
|
||||||
copyInstanceOption('minimalScopesMode')
|
copyInstanceOption('minimalScopesMode')
|
||||||
copyInstanceOption('formattingOptionsEnabled')
|
|
||||||
copyInstanceOption('hideMutedPosts')
|
copyInstanceOption('hideMutedPosts')
|
||||||
copyInstanceOption('collapseMessageWithSubject')
|
copyInstanceOption('collapseMessageWithSubject')
|
||||||
copyInstanceOption('loginMethod')
|
|
||||||
copyInstanceOption('scopeCopy')
|
copyInstanceOption('scopeCopy')
|
||||||
copyInstanceOption('subjectLineBehavior')
|
copyInstanceOption('subjectLineBehavior')
|
||||||
copyInstanceOption('postContentType')
|
copyInstanceOption('postContentType')
|
||||||
|
@ -147,13 +148,48 @@ const getInstancePanel = async ({ store }) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getStickers = async ({ store }) => {
|
||||||
|
try {
|
||||||
|
const res = await window.fetch('/static/stickers.json')
|
||||||
|
if (res.ok) {
|
||||||
|
const values = await res.json()
|
||||||
|
const stickers = (await Promise.all(
|
||||||
|
Object.entries(values).map(async ([name, path]) => {
|
||||||
|
const resPack = await window.fetch(path + 'pack.json')
|
||||||
|
var meta = {}
|
||||||
|
if (resPack.ok) {
|
||||||
|
meta = await resPack.json()
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
pack: name,
|
||||||
|
path,
|
||||||
|
meta
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)).sort((a, b) => {
|
||||||
|
return a.meta.title.localeCompare(b.meta.title)
|
||||||
|
})
|
||||||
|
store.dispatch('setInstanceOption', { name: 'stickers', value: stickers })
|
||||||
|
} else {
|
||||||
|
throw (res)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("Can't load stickers")
|
||||||
|
console.warn(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const getStaticEmoji = async ({ store }) => {
|
const getStaticEmoji = async ({ store }) => {
|
||||||
try {
|
try {
|
||||||
const res = await window.fetch('/static/emoji.json')
|
const res = await window.fetch('/static/emoji.json')
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const values = await res.json()
|
const values = await res.json()
|
||||||
const emoji = Object.keys(values).map((key) => {
|
const emoji = Object.keys(values).map((key) => {
|
||||||
return { shortcode: key, image_url: false, 'utf': values[key] }
|
return {
|
||||||
|
displayText: key,
|
||||||
|
imageUrl: false,
|
||||||
|
replacement: values[key]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
store.dispatch('setInstanceOption', { name: 'emoji', value: emoji })
|
store.dispatch('setInstanceOption', { name: 'emoji', value: emoji })
|
||||||
} else {
|
} else {
|
||||||
|
@ -171,9 +207,15 @@ const getCustomEmoji = async ({ store }) => {
|
||||||
try {
|
try {
|
||||||
const res = await window.fetch('/api/pleroma/emoji.json')
|
const res = await window.fetch('/api/pleroma/emoji.json')
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const values = await res.json()
|
const result = await res.json()
|
||||||
|
const values = Array.isArray(result) ? Object.assign({}, ...result) : result
|
||||||
const emoji = Object.keys(values).map((key) => {
|
const emoji = Object.keys(values).map((key) => {
|
||||||
return { shortcode: key, image_url: values[key] }
|
const imageUrl = values[key].image_url
|
||||||
|
return {
|
||||||
|
displayText: key,
|
||||||
|
imageUrl: imageUrl ? store.state.instance.server + imageUrl : values[key],
|
||||||
|
replacement: `:${key}: `
|
||||||
|
}
|
||||||
})
|
})
|
||||||
store.dispatch('setInstanceOption', { name: 'customEmoji', value: emoji })
|
store.dispatch('setInstanceOption', { name: 'customEmoji', value: emoji })
|
||||||
store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: true })
|
store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: true })
|
||||||
|
@ -187,17 +229,29 @@ const getCustomEmoji = async ({ store }) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getAppSecret = async ({ store }) => {
|
||||||
|
const { state, commit } = store
|
||||||
|
const { oauth, instance } = state
|
||||||
|
return getOrCreateApp({ ...oauth, instance: instance.server, commit })
|
||||||
|
.then((app) => getClientToken({ ...app, instance: instance.server }))
|
||||||
|
.then((token) => {
|
||||||
|
commit('setAppToken', token.access_token)
|
||||||
|
commit('setBackendInteractor', backendInteractorService(store.getters.getToken()))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const getNodeInfo = async ({ store }) => {
|
const getNodeInfo = async ({ store }) => {
|
||||||
try {
|
try {
|
||||||
const res = await window.fetch('/nodeinfo/2.0.json')
|
const res = await window.fetch('/nodeinfo/2.0.json')
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
const metadata = data.metadata
|
const metadata = data.metadata
|
||||||
|
|
||||||
const features = metadata.features
|
const features = metadata.features
|
||||||
store.dispatch('setInstanceOption', { name: 'mediaProxyAvailable', value: features.includes('media_proxy') })
|
store.dispatch('setInstanceOption', { name: 'mediaProxyAvailable', value: features.includes('media_proxy') })
|
||||||
store.dispatch('setInstanceOption', { name: 'chatAvailable', value: features.includes('chat') })
|
store.dispatch('setInstanceOption', { name: 'chatAvailable', value: features.includes('chat') })
|
||||||
store.dispatch('setInstanceOption', { name: 'gopherAvailable', value: features.includes('gopher') })
|
store.dispatch('setInstanceOption', { name: 'gopherAvailable', value: features.includes('gopher') })
|
||||||
|
store.dispatch('setInstanceOption', { name: 'pollsAvailable', value: features.includes('polls') })
|
||||||
|
store.dispatch('setInstanceOption', { name: 'pollLimits', value: metadata.pollLimits })
|
||||||
|
|
||||||
store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: metadata.restrictedNicknames })
|
store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: metadata.restrictedNicknames })
|
||||||
store.dispatch('setInstanceOption', { name: 'postFormats', value: metadata.postFormats })
|
store.dispatch('setInstanceOption', { name: 'postFormats', value: metadata.postFormats })
|
||||||
|
@ -211,6 +265,7 @@ const getNodeInfo = async ({ store }) => {
|
||||||
|
|
||||||
const frontendVersion = window.___pleromafe_commit_hash
|
const frontendVersion = window.___pleromafe_commit_hash
|
||||||
store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion })
|
store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion })
|
||||||
|
store.dispatch('setInstanceOption', { name: 'tagPolicyAvailable', value: metadata.federation.mrf_policies.includes('TagPolicy') })
|
||||||
} else {
|
} else {
|
||||||
throw (res)
|
throw (res)
|
||||||
}
|
}
|
||||||
|
@ -226,14 +281,14 @@ const setConfig = async ({ store }) => {
|
||||||
const apiConfig = configInfos[0]
|
const apiConfig = configInfos[0]
|
||||||
const staticConfig = configInfos[1]
|
const staticConfig = configInfos[1]
|
||||||
|
|
||||||
await setSettings({ store, apiConfig, staticConfig })
|
await setSettings({ store, apiConfig, staticConfig }).then(getAppSecret({ store }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkOAuthToken = async ({ store }) => {
|
const checkOAuthToken = async ({ store }) => {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
if (store.state.oauth.token) {
|
if (store.getters.getUserToken()) {
|
||||||
try {
|
try {
|
||||||
await store.dispatch('loginUser', store.state.oauth.token)
|
await store.dispatch('loginUser', store.getters.getUserToken())
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
@ -262,6 +317,7 @@ const afterStoreSetup = async ({ store, i18n }) => {
|
||||||
setConfig({ store }),
|
setConfig({ store }),
|
||||||
getTOS({ store }),
|
getTOS({ store }),
|
||||||
getInstancePanel({ store }),
|
getInstancePanel({ store }),
|
||||||
|
getStickers({ store }),
|
||||||
getStaticEmoji({ store }),
|
getStaticEmoji({ store }),
|
||||||
getCustomEmoji({ store }),
|
getCustomEmoji({ store }),
|
||||||
getNodeInfo({ store })
|
getNodeInfo({ store })
|
||||||
|
|
|
@ -3,22 +3,30 @@ import PublicAndExternalTimeline from 'components/public_and_external_timeline/p
|
||||||
import FriendsTimeline from 'components/friends_timeline/friends_timeline.vue'
|
import FriendsTimeline from 'components/friends_timeline/friends_timeline.vue'
|
||||||
import TagTimeline from 'components/tag_timeline/tag_timeline.vue'
|
import TagTimeline from 'components/tag_timeline/tag_timeline.vue'
|
||||||
import ConversationPage from 'components/conversation-page/conversation-page.vue'
|
import ConversationPage from 'components/conversation-page/conversation-page.vue'
|
||||||
import Mentions from 'components/mentions/mentions.vue'
|
import Interactions from 'components/interactions/interactions.vue'
|
||||||
import DMs from 'components/dm_timeline/dm_timeline.vue'
|
import DMs from 'components/dm_timeline/dm_timeline.vue'
|
||||||
import UserProfile from 'components/user_profile/user_profile.vue'
|
import UserProfile from 'components/user_profile/user_profile.vue'
|
||||||
|
import Search from 'components/search/search.vue'
|
||||||
import Settings from 'components/settings/settings.vue'
|
import Settings from 'components/settings/settings.vue'
|
||||||
import Registration from 'components/registration/registration.vue'
|
import Registration from 'components/registration/registration.vue'
|
||||||
import UserSettings from 'components/user_settings/user_settings.vue'
|
import UserSettings from 'components/user_settings/user_settings.vue'
|
||||||
import FollowRequests from 'components/follow_requests/follow_requests.vue'
|
import FollowRequests from 'components/follow_requests/follow_requests.vue'
|
||||||
import OAuthCallback from 'components/oauth_callback/oauth_callback.vue'
|
import OAuthCallback from 'components/oauth_callback/oauth_callback.vue'
|
||||||
import UserSearch from 'components/user_search/user_search.vue'
|
|
||||||
import Notifications from 'components/notifications/notifications.vue'
|
import Notifications from 'components/notifications/notifications.vue'
|
||||||
import LoginForm from 'components/login_form/login_form.vue'
|
import AuthForm from 'components/auth_form/auth_form.js'
|
||||||
import ChatPanel from 'components/chat_panel/chat_panel.vue'
|
import ChatPanel from 'components/chat_panel/chat_panel.vue'
|
||||||
import WhoToFollow from 'components/who_to_follow/who_to_follow.vue'
|
import WhoToFollow from 'components/who_to_follow/who_to_follow.vue'
|
||||||
import About from 'components/about/about.vue'
|
import About from 'components/about/about.vue'
|
||||||
|
|
||||||
export default (store) => {
|
export default (store) => {
|
||||||
|
const validateAuthenticatedRoute = (to, from, next) => {
|
||||||
|
if (store.state.users.currentUser) {
|
||||||
|
next()
|
||||||
|
} else {
|
||||||
|
next(store.state.instance.redirectRootNoLogin || '/main/all')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{ name: 'root',
|
{ name: 'root',
|
||||||
path: '/',
|
path: '/',
|
||||||
|
@ -30,23 +38,23 @@ export default (store) => {
|
||||||
},
|
},
|
||||||
{ name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline },
|
{ name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline },
|
||||||
{ name: 'public-timeline', path: '/main/public', component: PublicTimeline },
|
{ name: 'public-timeline', path: '/main/public', component: PublicTimeline },
|
||||||
{ name: 'friends', path: '/main/friends', component: FriendsTimeline },
|
{ name: 'friends', path: '/main/friends', component: FriendsTimeline, beforeEnter: validateAuthenticatedRoute },
|
||||||
{ name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline },
|
{ name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline },
|
||||||
{ name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
|
{ name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
|
||||||
{ name: 'external-user-profile', path: '/users/:id', component: UserProfile },
|
{ name: 'external-user-profile', path: '/users/:id', component: UserProfile },
|
||||||
{ name: 'mentions', path: '/users/:username/mentions', component: Mentions },
|
{ name: 'interactions', path: '/users/:username/interactions', component: Interactions, beforeEnter: validateAuthenticatedRoute },
|
||||||
{ name: 'dms', path: '/users/:username/dms', component: DMs },
|
{ name: 'dms', path: '/users/:username/dms', component: DMs, beforeEnter: validateAuthenticatedRoute },
|
||||||
{ name: 'settings', path: '/settings', component: Settings },
|
{ name: 'settings', path: '/settings', component: Settings },
|
||||||
{ name: 'registration', path: '/registration', component: Registration },
|
{ name: 'registration', path: '/registration', component: Registration },
|
||||||
{ name: 'registration-token', path: '/registration/:token', component: Registration },
|
{ name: 'registration-token', path: '/registration/:token', component: Registration },
|
||||||
{ name: 'friend-requests', path: '/friend-requests', component: FollowRequests },
|
{ name: 'friend-requests', path: '/friend-requests', component: FollowRequests, beforeEnter: validateAuthenticatedRoute },
|
||||||
{ name: 'user-settings', path: '/user-settings', component: UserSettings },
|
{ name: 'user-settings', path: '/user-settings', component: UserSettings, beforeEnter: validateAuthenticatedRoute },
|
||||||
{ name: 'notifications', path: '/:username/notifications', component: Notifications },
|
{ name: 'notifications', path: '/:username/notifications', component: Notifications, beforeEnter: validateAuthenticatedRoute },
|
||||||
{ name: 'login', path: '/login', component: LoginForm },
|
{ name: 'login', path: '/login', component: AuthForm },
|
||||||
{ name: 'chat', path: '/chat', component: ChatPanel, props: () => ({ floating: false }) },
|
{ name: 'chat', path: '/chat', component: ChatPanel, props: () => ({ floating: false }) },
|
||||||
{ name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) },
|
{ name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) },
|
||||||
{ name: 'user-search', path: '/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) },
|
{ name: 'search', path: '/search', component: Search, props: (route) => ({ query: route.query.query }) },
|
||||||
{ name: 'who-to-follow', path: '/who-to-follow', component: WhoToFollow },
|
{ name: 'who-to-follow', path: '/who-to-follow', component: WhoToFollow, beforeEnter: validateAuthenticatedRoute },
|
||||||
{ name: 'about', path: '/about', component: About },
|
{ name: 'about', path: '/about', component: About },
|
||||||
{ name: 'user-profile', path: '/(users/)?:name', component: UserProfile }
|
{ name: 'user-profile', path: '/(users/)?:name', component: UserProfile }
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<instance-specific-panel></instance-specific-panel>
|
<instance-specific-panel />
|
||||||
<features-panel v-if="showFeaturesPanel"></features-panel>
|
<features-panel v-if="showFeaturesPanel" />
|
||||||
<terms-of-service-panel></terms-of-service-panel>
|
<terms-of-service-panel />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ const Attachment = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
linkClicked ({target}) {
|
linkClicked ({ target }) {
|
||||||
if (target.tagName === 'A') {
|
if (target.tagName === 'A') {
|
||||||
window.open(target.href, '_blank')
|
window.open(target.href, '_blank')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +1,106 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="usePlaceHolder" @click="openModal">
|
<div
|
||||||
<a class="placeholder"
|
v-if="usePlaceHolder"
|
||||||
v-if="type !== 'html'"
|
@click="openModal"
|
||||||
target="_blank" :href="attachment.url"
|
|
||||||
>
|
>
|
||||||
[{{nsfw ? "NSFW/" : ""}}{{type.toUpperCase()}}]
|
<a
|
||||||
|
v-if="type !== 'html'"
|
||||||
|
class="placeholder"
|
||||||
|
target="_blank"
|
||||||
|
:href="attachment.url"
|
||||||
|
>
|
||||||
|
[{{ nsfw ? "NSFW/" : "" }}{{ type.toUpperCase() }}]
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-else class="attachment"
|
v-else
|
||||||
:class="{[type]: true, loading, 'fullwidth': fullwidth, 'nsfw-placeholder': hidden}"
|
|
||||||
v-show="!isEmpty"
|
v-show="!isEmpty"
|
||||||
|
class="attachment"
|
||||||
|
:class="{[type]: true, loading, 'fullwidth': fullwidth, 'nsfw-placeholder': hidden}"
|
||||||
>
|
>
|
||||||
<a class="image-attachment" v-if="hidden" :href="attachment.url" @click.prevent="toggleHidden">
|
<a
|
||||||
<img class="nsfw" :key="nsfwImage" :src="nsfwImage" :class="{'small': isSmall}"/>
|
v-if="hidden"
|
||||||
<i v-if="type === 'video'" class="play-icon icon-play-circled"></i>
|
class="image-attachment"
|
||||||
|
:href="attachment.url"
|
||||||
|
@click.prevent="toggleHidden"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:key="nsfwImage"
|
||||||
|
class="nsfw"
|
||||||
|
:src="nsfwImage"
|
||||||
|
:class="{'small': isSmall}"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
v-if="type === 'video'"
|
||||||
|
class="play-icon icon-play-circled"
|
||||||
|
/>
|
||||||
</a>
|
</a>
|
||||||
<div class="hider" v-if="nsfw && hideNsfwLocal && !hidden">
|
<div
|
||||||
<a href="#" @click.prevent="toggleHidden">Hide</a>
|
v-if="nsfw && hideNsfwLocal && !hidden"
|
||||||
|
class="hider"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
@click.prevent="toggleHidden"
|
||||||
|
>Hide</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a v-if="type === 'image' && (!hidden || preloadImage)"
|
<a
|
||||||
@click="openModal"
|
v-if="type === 'image' && (!hidden || preloadImage)"
|
||||||
class="image-attachment"
|
class="image-attachment"
|
||||||
:class="{'hidden': hidden && preloadImage }"
|
:class="{'hidden': hidden && preloadImage }"
|
||||||
:href="attachment.url" target="_blank"
|
:href="attachment.url"
|
||||||
|
target="_blank"
|
||||||
:title="attachment.description"
|
:title="attachment.description"
|
||||||
|
@click="openModal"
|
||||||
>
|
>
|
||||||
<StillImage :referrerpolicy="referrerpolicy" :mimetype="attachment.mimetype" :src="attachment.large_thumb_url || attachment.url"/>
|
<StillImage
|
||||||
|
:referrerpolicy="referrerpolicy"
|
||||||
|
:mimetype="attachment.mimetype"
|
||||||
|
:src="attachment.large_thumb_url || attachment.url"
|
||||||
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="video-container"
|
<a
|
||||||
@click="openModal"
|
|
||||||
v-if="type === 'video' && !hidden"
|
v-if="type === 'video' && !hidden"
|
||||||
|
class="video-container"
|
||||||
:class="{'small': isSmall}"
|
:class="{'small': isSmall}"
|
||||||
:href="allowPlay ? undefined : attachment.url"
|
:href="allowPlay ? undefined : attachment.url"
|
||||||
|
@click="openModal"
|
||||||
>
|
>
|
||||||
<VideoAttachment class="video" :attachment="attachment" :controls="allowPlay" />
|
<VideoAttachment
|
||||||
<i v-if="!allowPlay" class="play-icon icon-play-circled"></i>
|
class="video"
|
||||||
|
:attachment="attachment"
|
||||||
|
:controls="allowPlay"
|
||||||
|
/>
|
||||||
|
<i
|
||||||
|
v-if="!allowPlay"
|
||||||
|
class="play-icon icon-play-circled"
|
||||||
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<audio v-if="type === 'audio'" :src="attachment.url" controls></audio>
|
<audio
|
||||||
|
v-if="type === 'audio'"
|
||||||
|
:src="attachment.url"
|
||||||
|
controls
|
||||||
|
/>
|
||||||
|
|
||||||
<div @click.prevent="linkClicked" v-if="type === 'html' && attachment.oembed" class="oembed">
|
<div
|
||||||
<div v-if="attachment.thumb_url" class="image">
|
v-if="type === 'html' && attachment.oembed"
|
||||||
<img :src="attachment.thumb_url"/>
|
class="oembed"
|
||||||
|
@click.prevent="linkClicked"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="attachment.thumb_url"
|
||||||
|
class="image"
|
||||||
|
>
|
||||||
|
<img :src="attachment.thumb_url">
|
||||||
</div>
|
</div>
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<h1><a :href="attachment.url">{{attachment.oembed.title}}</a></h1>
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
<div v-html="attachment.oembed.oembedHTML"></div>
|
<h1><a :href="attachment.url">{{ attachment.oembed.title }}</a></h1>
|
||||||
|
<div v-html="attachment.oembed.oembedHTML" />
|
||||||
|
<!-- eslint-enable vue/no-v-html -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -68,6 +120,7 @@
|
||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
video {
|
video {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
26
src/components/auth_form/auth_form.js
Normal file
26
src/components/auth_form/auth_form.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import LoginForm from '../login_form/login_form.vue'
|
||||||
|
import MFARecoveryForm from '../mfa_form/recovery_form.vue'
|
||||||
|
import MFATOTPForm from '../mfa_form/totp_form.vue'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
|
const AuthForm = {
|
||||||
|
name: 'AuthForm',
|
||||||
|
render (createElement) {
|
||||||
|
return createElement('component', { is: this.authForm })
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
authForm () {
|
||||||
|
if (this.requiredTOTP) { return 'MFATOTPForm' }
|
||||||
|
if (this.requiredRecovery) { return 'MFARecoveryForm' }
|
||||||
|
return 'LoginForm'
|
||||||
|
},
|
||||||
|
...mapGetters('authFlow', ['requiredTOTP', 'requiredRecovery'])
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
MFARecoveryForm,
|
||||||
|
MFATOTPForm,
|
||||||
|
LoginForm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AuthForm
|
52
src/components/autosuggest/autosuggest.js
Normal file
52
src/components/autosuggest/autosuggest.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
const debounceMilliseconds = 500
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
query: { // function to query results and return a promise
|
||||||
|
type: Function,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
filter: { // function to filter results in real time
|
||||||
|
type: Function
|
||||||
|
},
|
||||||
|
placeholder: {
|
||||||
|
type: String,
|
||||||
|
default: 'Search...'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
term: '',
|
||||||
|
timeout: null,
|
||||||
|
results: [],
|
||||||
|
resultsVisible: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
filtered () {
|
||||||
|
return this.filter ? this.filter(this.results) : this.results
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
term (val) {
|
||||||
|
this.fetchResults(val)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchResults (term) {
|
||||||
|
clearTimeout(this.timeout)
|
||||||
|
this.timeout = setTimeout(() => {
|
||||||
|
this.results = []
|
||||||
|
if (term) {
|
||||||
|
this.query(term).then((results) => { this.results = results })
|
||||||
|
}
|
||||||
|
}, debounceMilliseconds)
|
||||||
|
},
|
||||||
|
onInputClick () {
|
||||||
|
this.resultsVisible = true
|
||||||
|
},
|
||||||
|
onClickOutside () {
|
||||||
|
this.resultsVisible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
59
src/components/autosuggest/autosuggest.vue
Normal file
59
src/components/autosuggest/autosuggest.vue
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-click-outside="onClickOutside"
|
||||||
|
class="autosuggest"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="term"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
class="autosuggest-input"
|
||||||
|
@click="onInputClick"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="resultsVisible && filtered.length > 0"
|
||||||
|
class="autosuggest-results"
|
||||||
|
>
|
||||||
|
<slot
|
||||||
|
v-for="item in filtered"
|
||||||
|
:item="item"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./autosuggest.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.autosuggest {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&-input {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-results {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 100%;
|
||||||
|
right: 0;
|
||||||
|
max-height: 400px;
|
||||||
|
background-color: $fallback--lightBg;
|
||||||
|
background-color: var(--lightBg, $fallback--lightBg);
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-color: $fallback--border;
|
||||||
|
border-color: var(--border, $fallback--border);
|
||||||
|
border-radius: $fallback--inputRadius;
|
||||||
|
border-radius: var(--inputRadius, $fallback--inputRadius);
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
|
||||||
|
box-shadow: var(--panelShadow);
|
||||||
|
overflow-y: auto;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
21
src/components/avatar_list/avatar_list.js
Normal file
21
src/components/avatar_list/avatar_list.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import UserAvatar from '../user_avatar/user_avatar.vue'
|
||||||
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||||
|
|
||||||
|
const AvatarList = {
|
||||||
|
props: ['users'],
|
||||||
|
computed: {
|
||||||
|
slicedUsers () {
|
||||||
|
return this.users ? this.users.slice(0, 15) : []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
UserAvatar
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
userProfileLink (user) {
|
||||||
|
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AvatarList
|
46
src/components/avatar_list/avatar_list.vue
Normal file
46
src/components/avatar_list/avatar_list.vue
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<template>
|
||||||
|
<div class="avatars">
|
||||||
|
<router-link
|
||||||
|
v-for="user in slicedUsers"
|
||||||
|
:key="user.id"
|
||||||
|
:to="userProfileLink(user)"
|
||||||
|
class="avatars-item"
|
||||||
|
>
|
||||||
|
<UserAvatar
|
||||||
|
:user="user"
|
||||||
|
class="avatar-small"
|
||||||
|
/>
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./avatar_list.js" ></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.avatars {
|
||||||
|
display: flex;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
// For hiding overflowing elements
|
||||||
|
flex-wrap: wrap;
|
||||||
|
height: 24px;
|
||||||
|
|
||||||
|
.avatars-item {
|
||||||
|
margin: 0 0 5px 5px;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-small {
|
||||||
|
border-radius: $fallback--avatarAltRadius;
|
||||||
|
border-radius: var(--avatarAltRadius, $fallback--avatarAltRadius);
|
||||||
|
height: 24px;
|
||||||
|
width: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,22 +1,51 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="basic-user-card">
|
<div class="basic-user-card">
|
||||||
<router-link :to="userProfileLink(user)">
|
<router-link :to="userProfileLink(user)">
|
||||||
<UserAvatar class="avatar" @click.prevent.native="toggleUserExpanded" :src="user.profile_image_url"/>
|
<UserAvatar
|
||||||
|
class="avatar"
|
||||||
|
:user="user"
|
||||||
|
@click.prevent.native="toggleUserExpanded"
|
||||||
|
/>
|
||||||
</router-link>
|
</router-link>
|
||||||
<div class="basic-user-card-expanded-content" v-if="userExpanded">
|
<div
|
||||||
<UserCard :user="user" :rounded="true" :bordered="true"/>
|
v-if="userExpanded"
|
||||||
|
class="basic-user-card-expanded-content"
|
||||||
|
>
|
||||||
|
<UserCard
|
||||||
|
:user="user"
|
||||||
|
:rounded="true"
|
||||||
|
:bordered="true"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="basic-user-card-collapsed-content" v-else>
|
<div
|
||||||
<div :title="user.name" class="basic-user-card-user-name">
|
v-else
|
||||||
<span v-if="user.name_html" class="basic-user-card-user-name-value" v-html="user.name_html"></span>
|
class="basic-user-card-collapsed-content"
|
||||||
<span v-else class="basic-user-card-user-name-value">{{ user.name }}</span>
|
>
|
||||||
|
<div
|
||||||
|
:title="user.name"
|
||||||
|
class="basic-user-card-user-name"
|
||||||
|
>
|
||||||
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
|
<span
|
||||||
|
v-if="user.name_html"
|
||||||
|
class="basic-user-card-user-name-value"
|
||||||
|
v-html="user.name_html"
|
||||||
|
/>
|
||||||
|
<!-- eslint-enable vue/no-v-html -->
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="basic-user-card-user-name-value"
|
||||||
|
>{{ user.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<router-link class="basic-user-card-screen-name" :to="userProfileLink(user)">
|
<router-link
|
||||||
@{{user.screen_name}}
|
class="basic-user-card-screen-name"
|
||||||
|
:to="userProfileLink(user)"
|
||||||
|
>
|
||||||
|
@{{ user.screen_name }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<slot></slot>
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -24,19 +53,11 @@
|
||||||
<script src="./basic_user_card.js"></script>
|
<script src="./basic_user_card.js"></script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import '../../_variables.scss';
|
|
||||||
|
|
||||||
.basic-user-card {
|
.basic-user-card {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1 0;
|
flex: 1 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding-top: 0.6em;
|
padding: 0.6em 1em;
|
||||||
padding-right: 1em;
|
|
||||||
padding-bottom: 0.6em;
|
|
||||||
padding-left: 1em;
|
|
||||||
border-bottom: 1px solid;
|
|
||||||
border-bottom-color: $fallback--border;
|
|
||||||
border-bottom-color: var(--border, $fallback--border);
|
|
||||||
|
|
||||||
&-collapsed-content {
|
&-collapsed-content {
|
||||||
margin-left: 0.7em;
|
margin-left: 0.7em;
|
||||||
|
@ -52,15 +73,16 @@
|
||||||
width: 16px;
|
width: 16px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&-value {
|
&-user-name-value,
|
||||||
|
&-screen-name {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
&-expanded-content {
|
&-expanded-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<basic-user-card :user="user">
|
<basic-user-card :user="user">
|
||||||
<div class="block-card-content-container">
|
<div class="block-card-content-container">
|
||||||
<button class="btn btn-default" @click="unblockUser" :disabled="progress" v-if="blocked">
|
<button
|
||||||
|
v-if="blocked"
|
||||||
|
class="btn btn-default"
|
||||||
|
:disabled="progress"
|
||||||
|
@click="unblockUser"
|
||||||
|
>
|
||||||
<template v-if="progress">
|
<template v-if="progress">
|
||||||
{{ $t('user_card.unblock_progress') }}
|
{{ $t('user_card.unblock_progress') }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -9,7 +14,12 @@
|
||||||
{{ $t('user_card.unblock') }}
|
{{ $t('user_card.unblock') }}
|
||||||
</template>
|
</template>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-default" @click="blockUser" :disabled="progress" v-else>
|
<button
|
||||||
|
v-else
|
||||||
|
class="btn btn-default"
|
||||||
|
:disabled="progress"
|
||||||
|
@click="blockUser"
|
||||||
|
>
|
||||||
<template v-if="progress">
|
<template v-if="progress">
|
||||||
{{ $t('user_card.block_progress') }}
|
{{ $t('user_card.block_progress') }}
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -16,7 +16,7 @@ const chatPanel = {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit (message) {
|
submit (message) {
|
||||||
this.$store.state.chat.channel.push('new_msg', {text: message}, 10000)
|
this.$store.state.chat.channel.push('new_msg', { text: message }, 10000)
|
||||||
this.currentMessage = ''
|
this.currentMessage = ''
|
||||||
},
|
},
|
||||||
togglePanel () {
|
togglePanel () {
|
||||||
|
|
|
@ -1,41 +1,70 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="chat-panel" v-if="!this.collapsed || !this.floating">
|
<div
|
||||||
|
v-if="!collapsed || !floating"
|
||||||
|
class="chat-panel"
|
||||||
|
>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading timeline-heading" :class="{ 'chat-heading': floating }" @click.stop.prevent="togglePanel">
|
<div
|
||||||
|
class="panel-heading timeline-heading"
|
||||||
|
:class="{ 'chat-heading': floating }"
|
||||||
|
@click.stop.prevent="togglePanel"
|
||||||
|
>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<span>{{$t('chat.title')}}</span>
|
<span>{{ $t('chat.title') }}</span>
|
||||||
<i class="icon-cancel" v-if="floating"></i>
|
<i
|
||||||
|
v-if="floating"
|
||||||
|
class="icon-cancel"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="chat-window" v-chat-scroll>
|
<div
|
||||||
<div class="chat-message" v-for="message in messages" :key="message.id">
|
v-chat-scroll
|
||||||
|
class="chat-window"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="message in messages"
|
||||||
|
:key="message.id"
|
||||||
|
class="chat-message"
|
||||||
|
>
|
||||||
<span class="chat-avatar">
|
<span class="chat-avatar">
|
||||||
<img :src="message.author.avatar" />
|
<img :src="message.author.avatar">
|
||||||
</span>
|
</span>
|
||||||
<div class="chat-content">
|
<div class="chat-content">
|
||||||
<router-link
|
<router-link
|
||||||
class="chat-name"
|
class="chat-name"
|
||||||
:to="userProfileLink(message.author)">
|
:to="userProfileLink(message.author)"
|
||||||
{{message.author.username}}
|
>
|
||||||
|
{{ message.author.username }}
|
||||||
</router-link>
|
</router-link>
|
||||||
<br>
|
<br>
|
||||||
<span class="chat-text">
|
<span class="chat-text">
|
||||||
{{message.text}}
|
{{ message.text }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="chat-input">
|
<div class="chat-input">
|
||||||
<textarea @keyup.enter="submit(currentMessage)" v-model="currentMessage" class="chat-input-textarea" rows="1"></textarea>
|
<textarea
|
||||||
|
v-model="currentMessage"
|
||||||
|
class="chat-input-textarea"
|
||||||
|
rows="1"
|
||||||
|
@keyup.enter="submit(currentMessage)"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="chat-panel">
|
<div
|
||||||
|
v-else
|
||||||
|
class="chat-panel"
|
||||||
|
>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading stub timeline-heading chat-heading" @click.stop.prevent="togglePanel">
|
<div
|
||||||
|
class="panel-heading stub timeline-heading chat-heading"
|
||||||
|
@click.stop.prevent="togglePanel"
|
||||||
|
>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<i class="icon-comment-empty"></i>
|
<i class="icon-comment-empty" />
|
||||||
{{$t('chat.title')}}
|
{{ $t('chat.title') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
80
src/components/checkbox/checkbox.vue
Normal file
80
src/components/checkbox/checkbox.vue
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
<template>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
:checked="checked"
|
||||||
|
:indeterminate.prop="indeterminate"
|
||||||
|
@change="$emit('change', $event.target.checked)"
|
||||||
|
>
|
||||||
|
<i class="checkbox-indicator" />
|
||||||
|
<span v-if="!!$slots.default"><slot /></span>
|
||||||
|
</label>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
model: {
|
||||||
|
prop: 'checked',
|
||||||
|
event: 'change'
|
||||||
|
},
|
||||||
|
props: ['checked', 'indeterminate']
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.checkbox {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
padding-left: 1.2em;
|
||||||
|
min-height: 1.2em;
|
||||||
|
|
||||||
|
&-indicator::before {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
display: block;
|
||||||
|
content: '✔';
|
||||||
|
transition: color 200ms;
|
||||||
|
width: 1.1em;
|
||||||
|
height: 1.1em;
|
||||||
|
border-radius: $fallback--checkboxRadius;
|
||||||
|
border-radius: var(--checkboxRadius, $fallback--checkboxRadius);
|
||||||
|
box-shadow: 0px 0px 2px black inset;
|
||||||
|
box-shadow: var(--inputShadow);
|
||||||
|
background-color: $fallback--fg;
|
||||||
|
background-color: var(--input, $fallback--fg);
|
||||||
|
vertical-align: top;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1.1em;
|
||||||
|
font-size: 1.1em;
|
||||||
|
color: transparent;
|
||||||
|
overflow: hidden;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=checkbox] {
|
||||||
|
display: none;
|
||||||
|
|
||||||
|
&:checked + .checkbox-indicator::before {
|
||||||
|
color: $fallback--text;
|
||||||
|
color: var(--text, $fallback--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:indeterminate + .checkbox-indicator::before {
|
||||||
|
content: '–';
|
||||||
|
color: $fallback--text;
|
||||||
|
color: var(--text, $fallback--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:disabled + .checkbox-indicator::before {
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& > span {
|
||||||
|
margin-left: .5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,16 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="color-control style-control" :class="{ disabled: !present || disabled }">
|
<div
|
||||||
<label :for="name" class="label">
|
class="color-control style-control"
|
||||||
{{label}}
|
:class="{ disabled: !present || disabled }"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
:for="name"
|
||||||
|
class="label"
|
||||||
|
>
|
||||||
|
{{ label }}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
v-if="typeof fallback !== 'undefined'"
|
v-if="typeof fallback !== 'undefined'"
|
||||||
class="opt exlcude-disabled"
|
|
||||||
:id="name + '-o'"
|
:id="name + '-o'"
|
||||||
|
class="opt exlcude-disabled"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
:checked="present"
|
:checked="present"
|
||||||
@input="$emit('input', typeof value === 'undefined' ? fallback : undefined)">
|
@input="$emit('input', typeof value === 'undefined' ? fallback : undefined)"
|
||||||
<label v-if="typeof fallback !== 'undefined'" class="opt-l" :for="name + '-o'"></label>
|
>
|
||||||
|
<label
|
||||||
|
v-if="typeof fallback !== 'undefined'"
|
||||||
|
class="opt-l"
|
||||||
|
:for="name + '-o'"
|
||||||
|
/>
|
||||||
<input
|
<input
|
||||||
:id="name"
|
:id="name"
|
||||||
class="color-input"
|
class="color-input"
|
||||||
|
@ -27,7 +38,7 @@
|
||||||
:disabled="!present || disabled"
|
:disabled="!present || disabled"
|
||||||
@input="$emit('input', $event.target.value)"
|
@input="$emit('input', $event.target.value)"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -1,28 +1,38 @@
|
||||||
<template>
|
<template>
|
||||||
<span v-if="contrast" class="contrast-ratio">
|
<span
|
||||||
<span :title="hint" class="rating">
|
v-if="contrast"
|
||||||
|
class="contrast-ratio"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
:title="hint"
|
||||||
|
class="rating"
|
||||||
|
>
|
||||||
<span v-if="contrast.aaa">
|
<span v-if="contrast.aaa">
|
||||||
<i class="icon-thumbs-up-alt"/>
|
<i class="icon-thumbs-up-alt" />
|
||||||
</span>
|
</span>
|
||||||
<span v-if="!contrast.aaa && contrast.aa">
|
<span v-if="!contrast.aaa && contrast.aa">
|
||||||
<i class="icon-adjust"/>
|
<i class="icon-adjust" />
|
||||||
</span>
|
</span>
|
||||||
<span v-if="!contrast.aaa && !contrast.aa">
|
<span v-if="!contrast.aaa && !contrast.aa">
|
||||||
<i class="icon-attention"/>
|
<i class="icon-attention" />
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span class="rating" v-if="contrast && large" :title="hint_18pt">
|
<span
|
||||||
|
v-if="contrast && large"
|
||||||
|
class="rating"
|
||||||
|
:title="hint_18pt"
|
||||||
|
>
|
||||||
<span v-if="contrast.laaa">
|
<span v-if="contrast.laaa">
|
||||||
<i class="icon-thumbs-up-alt"/>
|
<i class="icon-thumbs-up-alt" />
|
||||||
</span>
|
</span>
|
||||||
<span v-if="!contrast.laaa && contrast.laa">
|
<span v-if="!contrast.laaa && contrast.laa">
|
||||||
<i class="icon-adjust"/>
|
<i class="icon-adjust" />
|
||||||
</span>
|
</span>
|
||||||
<span v-if="!contrast.laaa && !contrast.laa">
|
<span v-if="!contrast.laaa && !contrast.laa">
|
||||||
<i class="icon-attention"/>
|
<i class="icon-attention" />
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<conversation
|
<conversation
|
||||||
:collapsable="false"
|
:collapsable="false"
|
||||||
isPage="true"
|
is-page="true"
|
||||||
:statusoid="statusoid"
|
:statusoid="statusoid"
|
||||||
></conversation>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./conversation-page.js"></script>
|
<script src="./conversation-page.js"></script>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { reduce, filter, findIndex } from 'lodash'
|
import { reduce, filter, findIndex, clone } from 'lodash'
|
||||||
import { set } from 'vue'
|
|
||||||
import Status from '../status/status.vue'
|
import Status from '../status/status.vue'
|
||||||
|
|
||||||
const sortById = (a, b) => {
|
const sortById = (a, b) => {
|
||||||
|
@ -36,14 +35,14 @@ const conversation = {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
highlight: null,
|
highlight: null,
|
||||||
expanded: false,
|
expanded: false
|
||||||
converationStatusIds: []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: [
|
props: [
|
||||||
'statusoid',
|
'statusoid',
|
||||||
'collapsable',
|
'collapsable',
|
||||||
'isPage'
|
'isPage',
|
||||||
|
'showPinned'
|
||||||
],
|
],
|
||||||
created () {
|
created () {
|
||||||
if (this.isPage) {
|
if (this.isPage) {
|
||||||
|
@ -54,15 +53,6 @@ const conversation = {
|
||||||
status () {
|
status () {
|
||||||
return this.statusoid
|
return this.statusoid
|
||||||
},
|
},
|
||||||
idsToShow () {
|
|
||||||
if (this.converationStatusIds.length > 0) {
|
|
||||||
return this.converationStatusIds
|
|
||||||
} else if (this.statusId) {
|
|
||||||
return [this.statusId]
|
|
||||||
} else {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
statusId () {
|
statusId () {
|
||||||
if (this.statusoid.retweeted_status) {
|
if (this.statusoid.retweeted_status) {
|
||||||
return this.statusoid.retweeted_status.id
|
return this.statusoid.retweeted_status.id
|
||||||
|
@ -70,6 +60,13 @@ const conversation = {
|
||||||
return this.statusoid.id
|
return this.statusoid.id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
conversationId () {
|
||||||
|
if (this.statusoid.retweeted_status) {
|
||||||
|
return this.statusoid.retweeted_status.statusnet_conversation_id
|
||||||
|
} else {
|
||||||
|
return this.statusoid.statusnet_conversation_id
|
||||||
|
}
|
||||||
|
},
|
||||||
conversation () {
|
conversation () {
|
||||||
if (!this.status) {
|
if (!this.status) {
|
||||||
return []
|
return []
|
||||||
|
@ -79,12 +76,7 @@ const conversation = {
|
||||||
return [this.status]
|
return [this.status]
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusesObject = this.$store.state.statuses.allStatusesObject
|
const conversation = clone(this.$store.state.statuses.conversationsObject[this.conversationId])
|
||||||
const conversation = this.idsToShow.reduce((acc, id) => {
|
|
||||||
acc.push(statusesObject[id])
|
|
||||||
return acc
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const statusIndex = findIndex(conversation, { id: this.statusId })
|
const statusIndex = findIndex(conversation, { id: this.statusId })
|
||||||
if (statusIndex !== -1) {
|
if (statusIndex !== -1) {
|
||||||
conversation[statusIndex] = this.status
|
conversation[statusIndex] = this.status
|
||||||
|
@ -94,7 +86,8 @@ const conversation = {
|
||||||
},
|
},
|
||||||
replies () {
|
replies () {
|
||||||
let i = 1
|
let i = 1
|
||||||
return reduce(this.conversation, (result, {id, in_reply_to_status_id}) => {
|
// eslint-disable-next-line camelcase
|
||||||
|
return reduce(this.conversation, (result, { id, in_reply_to_status_id }) => {
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
const irid = in_reply_to_status_id
|
const irid = in_reply_to_status_id
|
||||||
/* eslint-enable camelcase */
|
/* eslint-enable camelcase */
|
||||||
|
@ -127,19 +120,15 @@ const conversation = {
|
||||||
methods: {
|
methods: {
|
||||||
fetchConversation () {
|
fetchConversation () {
|
||||||
if (this.status) {
|
if (this.status) {
|
||||||
this.$store.state.api.backendInteractor.fetchConversation({id: this.status.id})
|
this.$store.state.api.backendInteractor.fetchConversation({ id: this.status.id })
|
||||||
.then(({ancestors, descendants}) => {
|
.then(({ ancestors, descendants }) => {
|
||||||
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
|
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
|
||||||
this.$store.dispatch('addNewStatuses', { statuses: descendants })
|
this.$store.dispatch('addNewStatuses', { statuses: descendants })
|
||||||
set(this, 'converationStatusIds', [].concat(
|
|
||||||
ancestors.map(_ => _.id).filter(_ => _ !== this.statusId),
|
|
||||||
this.statusId,
|
|
||||||
descendants.map(_ => _.id).filter(_ => _ !== this.statusId)))
|
|
||||||
})
|
})
|
||||||
.then(() => this.setHighlight(this.statusId))
|
.then(() => this.setHighlight(this.statusId))
|
||||||
} else {
|
} else {
|
||||||
const id = this.$route.params.id
|
const id = this.$route.params.id
|
||||||
this.$store.state.api.backendInteractor.fetchStatus({id})
|
this.$store.state.api.backendInteractor.fetchStatus({ id })
|
||||||
.then((status) => this.$store.dispatch('addNewStatuses', { statuses: [status] }))
|
.then((status) => this.$store.dispatch('addNewStatuses', { statuses: [status] }))
|
||||||
.then(() => this.fetchConversation())
|
.then(() => this.fetchConversation())
|
||||||
}
|
}
|
||||||
|
@ -151,7 +140,9 @@ const conversation = {
|
||||||
return (this.isExpanded) && id === this.status.id
|
return (this.isExpanded) && id === this.status.id
|
||||||
},
|
},
|
||||||
setHighlight (id) {
|
setHighlight (id) {
|
||||||
|
if (!id) return
|
||||||
this.highlight = id
|
this.highlight = id
|
||||||
|
this.$store.dispatch('fetchFavsAndRepeats', id)
|
||||||
},
|
},
|
||||||
getHighlight () {
|
getHighlight () {
|
||||||
return this.isExpanded ? this.highlight : null
|
return this.isExpanded ? this.highlight : null
|
||||||
|
|
|
@ -1,24 +1,34 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="timeline panel-default" :class="[isExpanded ? 'panel' : 'panel-disabled']">
|
<div
|
||||||
<div v-if="isExpanded" class="panel-heading conversation-heading">
|
class="timeline panel-default"
|
||||||
|
:class="[isExpanded ? 'panel' : 'panel-disabled']"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="isExpanded"
|
||||||
|
class="panel-heading conversation-heading"
|
||||||
|
>
|
||||||
<span class="title"> {{ $t('timeline.conversation') }} </span>
|
<span class="title"> {{ $t('timeline.conversation') }} </span>
|
||||||
<span v-if="collapsable">
|
<span v-if="collapsable">
|
||||||
<a href="#" @click.prevent="toggleExpanded">{{ $t('timeline.collapse') }}</a>
|
<a
|
||||||
|
href="#"
|
||||||
|
@click.prevent="toggleExpanded"
|
||||||
|
>{{ $t('timeline.collapse') }}</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<status
|
<status
|
||||||
v-for="status in conversation"
|
v-for="status in conversation"
|
||||||
@goto="setHighlight"
|
|
||||||
@toggleExpanded="toggleExpanded"
|
|
||||||
:key="status.id"
|
:key="status.id"
|
||||||
:inlineExpanded="collapsable"
|
:inline-expanded="collapsable && isExpanded"
|
||||||
:statusoid="status"
|
:statusoid="status"
|
||||||
:expandable='!expanded'
|
:expandable="!isExpanded"
|
||||||
|
:show-pinned="showPinned"
|
||||||
:focused="focused(status.id)"
|
:focused="focused(status.id)"
|
||||||
:inConversation="isExpanded"
|
:in-conversation="isExpanded"
|
||||||
:highlight="getHighlight()"
|
:highlight="getHighlight()"
|
||||||
:replies="getReplies(status.id)"
|
:replies="getReplies(status.id)"
|
||||||
class="status-fadein panel-body"
|
class="status-fadein panel-body"
|
||||||
|
@goto="setHighlight"
|
||||||
|
@toggleExpanded="toggleExpanded"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
const DeleteButton = {
|
|
||||||
props: [ 'status' ],
|
|
||||||
methods: {
|
|
||||||
deleteStatus () {
|
|
||||||
const confirmed = window.confirm('Do you really want to delete this status?')
|
|
||||||
if (confirmed) {
|
|
||||||
this.$store.dispatch('deleteStatus', { id: this.status.id })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
currentUser () { return this.$store.state.users.currentUser },
|
|
||||||
canDelete () { return this.currentUser && this.currentUser.rights.delete_others_notice || this.status.user.id === this.currentUser.id }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default DeleteButton
|
|
|
@ -1,21 +0,0 @@
|
||||||
<template>
|
|
||||||
<div v-if="canDelete">
|
|
||||||
<a href="#" v-on:click.prevent="deleteStatus()">
|
|
||||||
<i class='button-icon icon-cancel delete-status'></i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script src="./delete_button.js" ></script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
@import '../../_variables.scss';
|
|
||||||
|
|
||||||
.icon-cancel,.delete-status {
|
|
||||||
cursor: pointer;
|
|
||||||
&:hover {
|
|
||||||
color: $fallback--cRed;
|
|
||||||
color: var(--cRed, $fallback--cRed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
14
src/components/dialog_modal/dialog_modal.js
Normal file
14
src/components/dialog_modal/dialog_modal.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
const DialogModal = {
|
||||||
|
props: {
|
||||||
|
darkOverlay: {
|
||||||
|
default: true,
|
||||||
|
type: Boolean
|
||||||
|
},
|
||||||
|
onCancel: {
|
||||||
|
default: () => {},
|
||||||
|
type: Function
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DialogModal
|
100
src/components/dialog_modal/dialog_modal.vue
Normal file
100
src/components/dialog_modal/dialog_modal.vue
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
<template>
|
||||||
|
<span
|
||||||
|
:class="{ 'dark-overlay': darkOverlay }"
|
||||||
|
@click.self.stop="onCancel()"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="dialog-modal panel panel-default"
|
||||||
|
@click.stop=""
|
||||||
|
>
|
||||||
|
<div class="panel-heading dialog-modal-heading">
|
||||||
|
<div class="title">
|
||||||
|
<slot name="header" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="dialog-modal-content">
|
||||||
|
<slot name="default" />
|
||||||
|
</div>
|
||||||
|
<div class="dialog-modal-footer user-interactions panel-footer">
|
||||||
|
<slot name="footer" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./dialog_modal.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
// TODO: unify with other modals.
|
||||||
|
.dark-overlay {
|
||||||
|
&::before {
|
||||||
|
bottom: 0;
|
||||||
|
content: " ";
|
||||||
|
display: block;
|
||||||
|
cursor: default;
|
||||||
|
left: 0;
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
background: rgba(27,31,35,.5);
|
||||||
|
z-index: 99;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-modal.panel {
|
||||||
|
top: 0;
|
||||||
|
left: 50%;
|
||||||
|
max-height: 80vh;
|
||||||
|
max-width: 90vw;
|
||||||
|
margin: 15vh auto;
|
||||||
|
position: fixed;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
z-index: 999;
|
||||||
|
cursor: default;
|
||||||
|
display: block;
|
||||||
|
background-color: $fallback--bg;
|
||||||
|
background-color: var(--bg, $fallback--bg);
|
||||||
|
|
||||||
|
.dialog-modal-heading {
|
||||||
|
padding: .5em .5em;
|
||||||
|
margin-right: auto;
|
||||||
|
margin-bottom: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
color: var(--panelText);
|
||||||
|
background-color: $fallback--fg;
|
||||||
|
background-color: var(--panel, $fallback--fg);
|
||||||
|
|
||||||
|
.title {
|
||||||
|
margin-bottom: 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-modal-content {
|
||||||
|
margin: 0;
|
||||||
|
padding: 1rem 1rem;
|
||||||
|
background-color: $fallback--lightBg;
|
||||||
|
background-color: var(--lightBg, $fallback--lightBg);
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-modal-footer {
|
||||||
|
margin: 0;
|
||||||
|
padding: .5em .5em;
|
||||||
|
background-color: $fallback--lightBg;
|
||||||
|
background-color: var(--lightBg, $fallback--lightBg);
|
||||||
|
border-top: 1px solid $fallback--bg;
|
||||||
|
border-top: 1px solid var(--bg, $fallback--bg);
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: auto;
|
||||||
|
margin-left: .5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -1,5 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<Timeline :title="$t('nav.dms')" v-bind:timeline="timeline" v-bind:timeline-name="'dms'"/>
|
<Timeline
|
||||||
|
:title="$t('nav.dms')"
|
||||||
|
:timeline="timeline"
|
||||||
|
:timeline-name="'dms'"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./dm_timeline.js"></script>
|
<script src="./dm_timeline.js"></script>
|
||||||
|
|
|
@ -1,19 +1,66 @@
|
||||||
import Completion from '../../services/completion/completion.js'
|
import Completion from '../../services/completion/completion.js'
|
||||||
import EmojiSelector from '../emoji-selector/emoji-selector.vue'
|
import { take } from 'lodash'
|
||||||
|
|
||||||
import { take, filter, map } from 'lodash'
|
/**
|
||||||
|
* EmojiInput - augmented inputs for emoji and autocomplete support in inputs
|
||||||
|
* without having to give up the comfort of <input/> and <textarea/> elements
|
||||||
|
*
|
||||||
|
* Intended usage is:
|
||||||
|
* <EmojiInput v-model="something">
|
||||||
|
* <input v-model="something"/>
|
||||||
|
* </EmojiInput>
|
||||||
|
*
|
||||||
|
* Works only with <input> and <textarea>. Intended to use with only one nested
|
||||||
|
* input. It will find first input or textarea and work with that, multiple
|
||||||
|
* nested children not tested. You HAVE TO duplicate v-model for both
|
||||||
|
* <emoji-input> and <input>/<textarea> otherwise it will not work.
|
||||||
|
*
|
||||||
|
* Be prepared for CSS troubles though because it still wraps component in a div
|
||||||
|
* while TRYING to make it look like nothing happened, but it could break stuff.
|
||||||
|
*/
|
||||||
|
|
||||||
const EmojiInput = {
|
const EmojiInput = {
|
||||||
props: [
|
props: {
|
||||||
'value',
|
suggest: {
|
||||||
'placeholder',
|
/**
|
||||||
'type',
|
* suggest: function (input: String) => Suggestion[]
|
||||||
'classname'
|
*
|
||||||
],
|
* Function that takes input string which takes string (textAtCaret)
|
||||||
|
* and returns an array of Suggestions
|
||||||
|
*
|
||||||
|
* Suggestion is an object containing following properties:
|
||||||
|
* displayText: string. Main display text, what actual suggestion
|
||||||
|
* represents (user's screen name/emoji shortcode)
|
||||||
|
* replacement: string. Text that should replace the textAtCaret
|
||||||
|
* detailText: string, optional. Subtitle text, providing additional info
|
||||||
|
* if present (user's nickname)
|
||||||
|
* imageUrl: string, optional. Image to display alongside with suggestion,
|
||||||
|
* currently if no image is provided, replacement will be used (for
|
||||||
|
* unicode emojis)
|
||||||
|
*
|
||||||
|
* TODO: make it asynchronous when adding proper server-provided user
|
||||||
|
* suggestions
|
||||||
|
*
|
||||||
|
* For commonly used suggestors (emoji, users, both) use suggestor.js
|
||||||
|
*/
|
||||||
|
required: true,
|
||||||
|
type: Function
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
/**
|
||||||
|
* Used for v-model
|
||||||
|
*/
|
||||||
|
required: true,
|
||||||
|
type: String
|
||||||
|
}
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
input: undefined,
|
||||||
highlighted: 0,
|
highlighted: 0,
|
||||||
caret: 0
|
caret: 0,
|
||||||
|
focused: false,
|
||||||
|
blurTimeout: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -22,35 +69,57 @@ const EmojiInput = {
|
||||||
computed: {
|
computed: {
|
||||||
suggestions () {
|
suggestions () {
|
||||||
const firstchar = this.textAtCaret.charAt(0)
|
const firstchar = this.textAtCaret.charAt(0)
|
||||||
if (firstchar === ':') {
|
if (this.textAtCaret === firstchar) { return [] }
|
||||||
if (this.textAtCaret === ':') { return }
|
const matchedSuggestions = this.suggest(this.textAtCaret)
|
||||||
const matchedEmoji = filter(this.emoji.concat(this.customEmoji), (emoji) => emoji.shortcode.startsWith(this.textAtCaret.slice(1)))
|
if (matchedSuggestions.length <= 0) {
|
||||||
if (matchedEmoji.length <= 0) {
|
return []
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
return map(take(matchedEmoji, 5), ({shortcode, image_url, utf}, index) => ({
|
return take(matchedSuggestions, 5)
|
||||||
shortcode: `:${shortcode}:`,
|
.map(({ imageUrl, ...rest }, index) => ({
|
||||||
utf: utf || '',
|
...rest,
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
img: utf ? '' : this.$store.state.instance.server + image_url,
|
img: imageUrl || '',
|
||||||
highlighted: index === this.highlighted
|
highlighted: index === this.highlighted
|
||||||
}))
|
}))
|
||||||
} else {
|
},
|
||||||
return false
|
showPopup () {
|
||||||
}
|
return this.focused && this.suggestions && this.suggestions.length > 0
|
||||||
},
|
},
|
||||||
textAtCaret () {
|
textAtCaret () {
|
||||||
return (this.wordAtCaret || {}).word || ''
|
return (this.wordAtCaret || {}).word || ''
|
||||||
},
|
},
|
||||||
wordAtCaret () {
|
wordAtCaret () {
|
||||||
|
if (this.value && this.caret) {
|
||||||
const word = Completion.wordAtPosition(this.value, this.caret - 1) || {}
|
const word = Completion.wordAtPosition(this.value, this.caret - 1) || {}
|
||||||
return word
|
return word
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
emoji () {
|
mounted () {
|
||||||
return this.$store.state.instance.emoji || []
|
const slots = this.$slots.default
|
||||||
|
if (!slots || slots.length === 0) return
|
||||||
|
const input = slots.find(slot => ['input', 'textarea'].includes(slot.tag))
|
||||||
|
if (!input) return
|
||||||
|
this.input = input
|
||||||
|
this.resize()
|
||||||
|
input.elm.addEventListener('blur', this.onBlur)
|
||||||
|
input.elm.addEventListener('focus', this.onFocus)
|
||||||
|
input.elm.addEventListener('paste', this.onPaste)
|
||||||
|
input.elm.addEventListener('keyup', this.onKeyUp)
|
||||||
|
input.elm.addEventListener('keydown', this.onKeyDown)
|
||||||
|
input.elm.addEventListener('transitionend', this.onTransition)
|
||||||
|
input.elm.addEventListener('compositionupdate', this.onCompositionUpdate)
|
||||||
},
|
},
|
||||||
customEmoji () {
|
unmounted () {
|
||||||
return this.$store.state.instance.customEmoji || []
|
const { input } = this
|
||||||
|
if (input) {
|
||||||
|
input.elm.removeEventListener('blur', this.onBlur)
|
||||||
|
input.elm.removeEventListener('focus', this.onFocus)
|
||||||
|
input.elm.removeEventListener('paste', this.onPaste)
|
||||||
|
input.elm.removeEventListener('keyup', this.onKeyUp)
|
||||||
|
input.elm.removeEventListener('keydown', this.onKeyDown)
|
||||||
|
input.elm.removeEventListener('transitionend', this.onTransition)
|
||||||
|
input.elm.removeEventListener('compositionupdate', this.onCompositionUpdate)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -59,27 +128,35 @@ const EmojiInput = {
|
||||||
this.$emit('input', newValue)
|
this.$emit('input', newValue)
|
||||||
this.caret = 0
|
this.caret = 0
|
||||||
},
|
},
|
||||||
replaceEmoji (e) {
|
replaceText (e, suggestion) {
|
||||||
const len = this.suggestions.length || 0
|
const len = this.suggestions.length || 0
|
||||||
if (this.textAtCaret === ':' || e.ctrlKey) { return }
|
if (this.textAtCaret.length === 1) { return }
|
||||||
if (len > 0) {
|
if (len > 0 || suggestion) {
|
||||||
e.preventDefault()
|
const chosenSuggestion = suggestion || this.suggestions[this.highlighted]
|
||||||
const emoji = this.suggestions[this.highlighted]
|
const replacement = chosenSuggestion.replacement
|
||||||
const replacement = emoji.utf || (emoji.shortcode + ' ')
|
|
||||||
const newValue = Completion.replaceWord(this.value, this.wordAtCaret, replacement)
|
const newValue = Completion.replaceWord(this.value, this.wordAtCaret, replacement)
|
||||||
this.$emit('input', newValue)
|
this.$emit('input', newValue)
|
||||||
this.caret = 0
|
|
||||||
this.highlighted = 0
|
this.highlighted = 0
|
||||||
|
const position = this.wordAtCaret.start + replacement.length
|
||||||
|
|
||||||
|
this.$nextTick(function () {
|
||||||
|
// Re-focus inputbox after clicking suggestion
|
||||||
|
this.input.elm.focus()
|
||||||
|
// Set selection right after the replacement instead of the very end
|
||||||
|
this.input.elm.setSelectionRange(position, position)
|
||||||
|
this.caret = position
|
||||||
|
})
|
||||||
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cycleBackward (e) {
|
cycleBackward (e) {
|
||||||
const len = this.suggestions.length || 0
|
const len = this.suggestions.length || 0
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
e.preventDefault()
|
|
||||||
this.highlighted -= 1
|
this.highlighted -= 1
|
||||||
if (this.highlighted < 0) {
|
if (this.highlighted < 0) {
|
||||||
this.highlighted = this.suggestions.length - 1
|
this.highlighted = this.suggestions.length - 1
|
||||||
}
|
}
|
||||||
|
e.preventDefault()
|
||||||
} else {
|
} else {
|
||||||
this.highlighted = 0
|
this.highlighted = 0
|
||||||
}
|
}
|
||||||
|
@ -87,47 +164,88 @@ const EmojiInput = {
|
||||||
cycleForward (e) {
|
cycleForward (e) {
|
||||||
const len = this.suggestions.length || 0
|
const len = this.suggestions.length || 0
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
if (e.shiftKey) { return }
|
|
||||||
e.preventDefault()
|
|
||||||
this.highlighted += 1
|
this.highlighted += 1
|
||||||
if (this.highlighted >= len) {
|
if (this.highlighted >= len) {
|
||||||
this.highlighted = 0
|
this.highlighted = 0
|
||||||
}
|
}
|
||||||
|
e.preventDefault()
|
||||||
} else {
|
} else {
|
||||||
this.highlighted = 0
|
this.highlighted = 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onKeydown (e) {
|
onTransition (e) {
|
||||||
e.stopPropagation()
|
this.resize()
|
||||||
|
},
|
||||||
|
onBlur (e) {
|
||||||
|
// Clicking on any suggestion removes focus from autocomplete,
|
||||||
|
// preventing click handler ever executing.
|
||||||
|
this.blurTimeout = setTimeout(() => {
|
||||||
|
this.focused = false
|
||||||
|
this.setCaret(e)
|
||||||
|
this.resize()
|
||||||
|
}, 200)
|
||||||
|
},
|
||||||
|
onClick (e, suggestion) {
|
||||||
|
this.replaceText(e, suggestion)
|
||||||
|
},
|
||||||
|
onFocus (e) {
|
||||||
|
if (this.blurTimeout) {
|
||||||
|
clearTimeout(this.blurTimeout)
|
||||||
|
this.blurTimeout = null
|
||||||
|
}
|
||||||
|
|
||||||
|
this.focused = true
|
||||||
|
this.setCaret(e)
|
||||||
|
this.resize()
|
||||||
|
},
|
||||||
|
onKeyUp (e) {
|
||||||
|
this.setCaret(e)
|
||||||
|
this.resize()
|
||||||
|
},
|
||||||
|
onPaste (e) {
|
||||||
|
this.setCaret(e)
|
||||||
|
this.resize()
|
||||||
|
},
|
||||||
|
onKeyDown (e) {
|
||||||
|
this.setCaret(e)
|
||||||
|
this.resize()
|
||||||
|
|
||||||
|
const { ctrlKey, shiftKey, key } = e
|
||||||
|
if (key === 'Tab') {
|
||||||
|
if (shiftKey) {
|
||||||
|
this.cycleBackward(e)
|
||||||
|
} else {
|
||||||
|
this.cycleForward(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (key === 'ArrowUp') {
|
||||||
|
this.cycleBackward(e)
|
||||||
|
} else if (key === 'ArrowDown') {
|
||||||
|
this.cycleForward(e)
|
||||||
|
}
|
||||||
|
if (key === 'Enter') {
|
||||||
|
if (!ctrlKey) {
|
||||||
|
this.replaceText(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onInput (e) {
|
onInput (e) {
|
||||||
|
this.setCaret(e)
|
||||||
this.$emit('input', e.target.value)
|
this.$emit('input', e.target.value)
|
||||||
},
|
},
|
||||||
setCaret ({target: {selectionStart}}) {
|
onCompositionUpdate (e) {
|
||||||
|
this.setCaret(e)
|
||||||
|
this.resize()
|
||||||
|
this.$emit('input', e.target.value)
|
||||||
|
},
|
||||||
|
setCaret ({ target: { selectionStart } }) {
|
||||||
this.caret = selectionStart
|
this.caret = selectionStart
|
||||||
},
|
},
|
||||||
onEmoji (emoji) {
|
resize () {
|
||||||
const newValue = this.value.substr(0, this.caret) + emoji + this.value.substr(this.caret)
|
const { panel } = this.$refs
|
||||||
this.$emit('input', newValue)
|
if (!panel) return
|
||||||
this.caret += emoji.length
|
const { offsetHeight, offsetTop } = this.input.elm
|
||||||
setTimeout(() => {
|
this.$refs.panel.style.top = (offsetTop + offsetHeight) + 'px'
|
||||||
this.updateCaretPos()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
updateCaretPos () {
|
|
||||||
const elem = this.$refs.input
|
|
||||||
if (elem.createTextRange) {
|
|
||||||
const range = elem.createTextRange()
|
|
||||||
range.move('character', this.caret)
|
|
||||||
range.select()
|
|
||||||
} else {
|
|
||||||
if (elem.selectionStart) {
|
|
||||||
elem.focus()
|
|
||||||
elem.setSelectionRange(this.caret, this.caret)
|
|
||||||
} else {
|
|
||||||
elem.focus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +1,30 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="emoji-input">
|
<div class="emoji-input">
|
||||||
<input
|
<slot />
|
||||||
v-if="type !== 'textarea'"
|
<div
|
||||||
:class="classname"
|
ref="panel"
|
||||||
:type="type"
|
class="autocomplete-panel"
|
||||||
:value="value"
|
:class="{ hide: !showPopup }"
|
||||||
:placeholder="placeholder"
|
>
|
||||||
@input="onInput"
|
|
||||||
@click="setCaret"
|
|
||||||
@keyup="setCaret"
|
|
||||||
@keydown="onKeydown"
|
|
||||||
@keydown.down="cycleForward"
|
|
||||||
@keydown.up="cycleBackward"
|
|
||||||
@keydown.shift.tab="cycleBackward"
|
|
||||||
@keydown.tab="cycleForward"
|
|
||||||
@keydown.enter="replaceEmoji"
|
|
||||||
ref="input"
|
|
||||||
/>
|
|
||||||
<textarea
|
|
||||||
v-else
|
|
||||||
:class="classname"
|
|
||||||
:value="value"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
@input="onInput"
|
|
||||||
@click="setCaret"
|
|
||||||
@keyup="setCaret"
|
|
||||||
@keydown="onKeydown"
|
|
||||||
@keydown.down="cycleForward"
|
|
||||||
@keydown.up="cycleBackward"
|
|
||||||
@keydown.shift.tab="cycleBackward"
|
|
||||||
@keydown.tab="cycleForward"
|
|
||||||
@keydown.enter="replaceEmoji"
|
|
||||||
ref="input"
|
|
||||||
></textarea>
|
|
||||||
<EmojiSelector @emoji="onEmoji" />
|
|
||||||
<div class="autocomplete-panel" v-if="suggestions">
|
|
||||||
<div class="autocomplete-panel-body">
|
<div class="autocomplete-panel-body">
|
||||||
<div
|
<div
|
||||||
v-for="(emoji, index) in suggestions"
|
v-for="(suggestion, index) in suggestions"
|
||||||
:key="index"
|
:key="index"
|
||||||
@click="replace(emoji.utf || (emoji.shortcode + ' '))"
|
|
||||||
class="autocomplete-item"
|
class="autocomplete-item"
|
||||||
:class="{ highlighted: emoji.highlighted }"
|
:class="{ highlighted: suggestion.highlighted }"
|
||||||
|
@click.stop.prevent="onClick($event, suggestion)"
|
||||||
>
|
>
|
||||||
<span v-if="emoji.img">
|
<span class="image">
|
||||||
<img :src="emoji.img" />
|
<img
|
||||||
|
v-if="suggestion.img"
|
||||||
|
:src="suggestion.img"
|
||||||
|
>
|
||||||
|
<span v-else>{{ suggestion.replacement }}</span>
|
||||||
</span>
|
</span>
|
||||||
<span v-else>{{emoji.utf}}</span>
|
<div class="label">
|
||||||
<span>{{emoji.shortcode}}</span>
|
<span class="displayText">{{ suggestion.displayText }}</span>
|
||||||
|
<span class="detailText">{{ suggestion.detailText }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,10 +37,81 @@
|
||||||
@import '../../_variables.scss';
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
.emoji-input {
|
.emoji-input {
|
||||||
position: relative;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
.form-control {
|
.autocomplete {
|
||||||
width: 100%;
|
&-panel {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 9;
|
||||||
|
margin-top: 2px;
|
||||||
|
|
||||||
|
&.hide {
|
||||||
|
display: none
|
||||||
|
}
|
||||||
|
|
||||||
|
&-body {
|
||||||
|
margin: 0 0.5em 0 0.5em;
|
||||||
|
border-radius: $fallback--tooltipRadius;
|
||||||
|
border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
|
||||||
|
box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.5);
|
||||||
|
box-shadow: var(--popupShadow);
|
||||||
|
min-width: 75%;
|
||||||
|
background: $fallback--bg;
|
||||||
|
background: var(--bg, $fallback--bg);
|
||||||
|
color: $fallback--lightText;
|
||||||
|
color: var(--lightText, $fallback--lightText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-item {
|
||||||
|
display: flex;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 0.2em 0.4em;
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.4);
|
||||||
|
height: 32px;
|
||||||
|
|
||||||
|
.image {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32px;
|
||||||
|
|
||||||
|
margin-right: 4px;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 0 0.1em 0 0.2em;
|
||||||
|
|
||||||
|
.displayText {
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detailText {
|
||||||
|
font-size: 9px;
|
||||||
|
line-height: 9px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.highlighted {
|
||||||
|
background-color: $fallback--fg;
|
||||||
|
background-color: var(--lightBg, $fallback--fg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
input, textarea {
|
||||||
|
flex: 1 0 auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
94
src/components/emoji-input/suggestor.js
Normal file
94
src/components/emoji-input/suggestor.js
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
import { debounce } from 'lodash'
|
||||||
|
/**
|
||||||
|
* suggest - generates a suggestor function to be used by emoji-input
|
||||||
|
* data: object providing source information for specific types of suggestions:
|
||||||
|
* data.emoji - optional, an array of all emoji available i.e.
|
||||||
|
* (state.instance.emoji + state.instance.customEmoji)
|
||||||
|
* data.users - optional, an array of all known users
|
||||||
|
* updateUsersList - optional, a function to search and append to users
|
||||||
|
*
|
||||||
|
* Depending on data present one or both (or none) can be present, so if field
|
||||||
|
* doesn't support user linking you can just provide only emoji.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const debounceUserSearch = debounce((data, input) => {
|
||||||
|
data.updateUsersList(input)
|
||||||
|
}, 500, { leading: true, trailing: false })
|
||||||
|
|
||||||
|
export default data => input => {
|
||||||
|
const firstChar = input[0]
|
||||||
|
if (firstChar === ':' && data.emoji) {
|
||||||
|
return suggestEmoji(data.emoji)(input)
|
||||||
|
}
|
||||||
|
if (firstChar === '@' && data.users) {
|
||||||
|
return suggestUsers(data)(input)
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
export const suggestEmoji = emojis => input => {
|
||||||
|
const noPrefix = input.toLowerCase().substr(1)
|
||||||
|
return emojis
|
||||||
|
.filter(({ displayText }) => displayText.toLowerCase().startsWith(noPrefix))
|
||||||
|
.sort((a, b) => {
|
||||||
|
let aScore = 0
|
||||||
|
let bScore = 0
|
||||||
|
|
||||||
|
// Make custom emojis a priority
|
||||||
|
aScore += a.imageUrl ? 10 : 0
|
||||||
|
bScore += b.imageUrl ? 10 : 0
|
||||||
|
|
||||||
|
// Sort alphabetically
|
||||||
|
const alphabetically = a.displayText > b.displayText ? 1 : -1
|
||||||
|
|
||||||
|
return bScore - aScore + alphabetically
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const suggestUsers = data => input => {
|
||||||
|
const noPrefix = input.toLowerCase().substr(1)
|
||||||
|
const users = data.users
|
||||||
|
|
||||||
|
const newUsers = users.filter(
|
||||||
|
user =>
|
||||||
|
user.screen_name.toLowerCase().startsWith(noPrefix) ||
|
||||||
|
user.name.toLowerCase().startsWith(noPrefix)
|
||||||
|
|
||||||
|
/* taking only 20 results so that sorting is a bit cheaper, we display
|
||||||
|
* only 5 anyway. could be inaccurate, but we ideally we should query
|
||||||
|
* backend anyway
|
||||||
|
*/
|
||||||
|
).slice(0, 20).sort((a, b) => {
|
||||||
|
let aScore = 0
|
||||||
|
let bScore = 0
|
||||||
|
|
||||||
|
// Matches on screen name (i.e. user@instance) makes a priority
|
||||||
|
aScore += a.screen_name.toLowerCase().startsWith(noPrefix) ? 2 : 0
|
||||||
|
bScore += b.screen_name.toLowerCase().startsWith(noPrefix) ? 2 : 0
|
||||||
|
|
||||||
|
// Matches on name takes second priority
|
||||||
|
aScore += a.name.toLowerCase().startsWith(noPrefix) ? 1 : 0
|
||||||
|
bScore += b.name.toLowerCase().startsWith(noPrefix) ? 1 : 0
|
||||||
|
|
||||||
|
const diff = (bScore - aScore) * 10
|
||||||
|
|
||||||
|
// Then sort alphabetically
|
||||||
|
const nameAlphabetically = a.name > b.name ? 1 : -1
|
||||||
|
const screenNameAlphabetically = a.screen_name > b.screen_name ? 1 : -1
|
||||||
|
|
||||||
|
return diff + nameAlphabetically + screenNameAlphabetically
|
||||||
|
/* eslint-disable camelcase */
|
||||||
|
}).map(({ screen_name, name, profile_image_url_original }) => ({
|
||||||
|
displayText: screen_name,
|
||||||
|
detailText: name,
|
||||||
|
imageUrl: profile_image_url_original,
|
||||||
|
replacement: '@' + screen_name + ' '
|
||||||
|
}))
|
||||||
|
|
||||||
|
// BE search users if there are no matches
|
||||||
|
if (newUsers.length === 0 && data.updateUsersList) {
|
||||||
|
debounceUserSearch(data, noPrefix)
|
||||||
|
}
|
||||||
|
return newUsers
|
||||||
|
/* eslint-enable camelcase */
|
||||||
|
}
|
|
@ -1,12 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="import-export-container">
|
<div class="import-export-container">
|
||||||
<slot name="before"/>
|
<slot name="before" />
|
||||||
<button class="btn" @click="exportData">{{ exportLabel }}</button>
|
<button
|
||||||
<button class="btn" @click="importData">{{ importLabel }}</button>
|
class="btn"
|
||||||
<slot name="afterButtons"/>
|
@click="exportData"
|
||||||
<p v-if="importFailed" class="alert error">{{ importFailedText }}</p>
|
>
|
||||||
<slot name="afterError"/>
|
{{ exportLabel }}
|
||||||
</div>
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn"
|
||||||
|
@click="importData"
|
||||||
|
>
|
||||||
|
{{ importLabel }}
|
||||||
|
</button>
|
||||||
|
<slot name="afterButtons" />
|
||||||
|
<p
|
||||||
|
v-if="importFailed"
|
||||||
|
class="alert error"
|
||||||
|
>
|
||||||
|
{{ importFailedText }}
|
||||||
|
</p>
|
||||||
|
<slot name="afterError" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -49,7 +64,7 @@ export default {
|
||||||
if (event.target.files[0]) {
|
if (event.target.files[0]) {
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.onload = ({target}) => {
|
reader.onload = ({ target }) => {
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(target.result)
|
const parsed = JSON.parse(target.result)
|
||||||
const valid = this.validator(parsed)
|
const valid = this.validator(parsed)
|
||||||
|
|
48
src/components/exporter/exporter.js
Normal file
48
src/components/exporter/exporter.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
const Exporter = {
|
||||||
|
props: {
|
||||||
|
getContent: {
|
||||||
|
type: Function,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
filename: {
|
||||||
|
type: String,
|
||||||
|
default: 'export.csv'
|
||||||
|
},
|
||||||
|
exportButtonLabel: {
|
||||||
|
type: String,
|
||||||
|
default () {
|
||||||
|
return this.$t('exporter.export')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
processingMessage: {
|
||||||
|
type: String,
|
||||||
|
default () {
|
||||||
|
return this.$t('exporter.processing')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
processing: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
process () {
|
||||||
|
this.processing = true
|
||||||
|
this.getContent()
|
||||||
|
.then((content) => {
|
||||||
|
const fileToDownload = document.createElement('a')
|
||||||
|
fileToDownload.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(content))
|
||||||
|
fileToDownload.setAttribute('download', this.filename)
|
||||||
|
fileToDownload.style.display = 'none'
|
||||||
|
document.body.appendChild(fileToDownload)
|
||||||
|
fileToDownload.click()
|
||||||
|
document.body.removeChild(fileToDownload)
|
||||||
|
// Add delay before hiding processing state since browser takes some time to handle file download
|
||||||
|
setTimeout(() => { this.processing = false }, 2000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Exporter
|
26
src/components/exporter/exporter.vue
Normal file
26
src/components/exporter/exporter.vue
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<template>
|
||||||
|
<div class="exporter">
|
||||||
|
<div v-if="processing">
|
||||||
|
<i class="icon-spin4 animate-spin exporter-processing" />
|
||||||
|
<span>{{ processingMessage }}</span>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
v-else
|
||||||
|
class="btn btn-default"
|
||||||
|
@click="process"
|
||||||
|
>
|
||||||
|
{{ exportButtonLabel }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./exporter.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.exporter {
|
||||||
|
&-processing {
|
||||||
|
font-size: 1.5em;
|
||||||
|
margin: 0.25em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
40
src/components/extra_buttons/extra_buttons.js
Normal file
40
src/components/extra_buttons/extra_buttons.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
const ExtraButtons = {
|
||||||
|
props: [ 'status' ],
|
||||||
|
methods: {
|
||||||
|
deleteStatus () {
|
||||||
|
const confirmed = window.confirm(this.$t('status.delete_confirm'))
|
||||||
|
if (confirmed) {
|
||||||
|
this.$store.dispatch('deleteStatus', { id: this.status.id })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pinStatus () {
|
||||||
|
this.$store.dispatch('pinStatus', this.status.id)
|
||||||
|
.then(() => this.$emit('onSuccess'))
|
||||||
|
.catch(err => this.$emit('onError', err.error.error))
|
||||||
|
},
|
||||||
|
unpinStatus () {
|
||||||
|
this.$store.dispatch('unpinStatus', this.status.id)
|
||||||
|
.then(() => this.$emit('onSuccess'))
|
||||||
|
.catch(err => this.$emit('onError', err.error.error))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
currentUser () { return this.$store.state.users.currentUser },
|
||||||
|
canDelete () {
|
||||||
|
if (!this.currentUser) { return }
|
||||||
|
const superuser = this.currentUser.rights.moderator || this.currentUser.rights.admin
|
||||||
|
return superuser || this.status.user.id === this.currentUser.id
|
||||||
|
},
|
||||||
|
ownStatus () {
|
||||||
|
return this.status.user.id === this.currentUser.id
|
||||||
|
},
|
||||||
|
canPin () {
|
||||||
|
return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted')
|
||||||
|
},
|
||||||
|
enabled () {
|
||||||
|
return this.canPin || this.canDelete
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ExtraButtons
|
59
src/components/extra_buttons/extra_buttons.vue
Normal file
59
src/components/extra_buttons/extra_buttons.vue
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<template>
|
||||||
|
<v-popover
|
||||||
|
v-if="enabled"
|
||||||
|
trigger="click"
|
||||||
|
placement="top"
|
||||||
|
class="extra-button-popover"
|
||||||
|
:offset="5"
|
||||||
|
:container="false"
|
||||||
|
>
|
||||||
|
<div slot="popover">
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<button
|
||||||
|
v-if="!status.pinned && canPin"
|
||||||
|
v-close-popover
|
||||||
|
class="dropdown-item dropdown-item-icon"
|
||||||
|
@click.prevent="pinStatus"
|
||||||
|
>
|
||||||
|
<i class="icon-pin" /><span>{{ $t("status.pin") }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="status.pinned && canPin"
|
||||||
|
v-close-popover
|
||||||
|
class="dropdown-item dropdown-item-icon"
|
||||||
|
@click.prevent="unpinStatus"
|
||||||
|
>
|
||||||
|
<i class="icon-pin" /><span>{{ $t("status.unpin") }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="canDelete"
|
||||||
|
v-close-popover
|
||||||
|
class="dropdown-item dropdown-item-icon"
|
||||||
|
@click.prevent="deleteStatus"
|
||||||
|
>
|
||||||
|
<i class="icon-cancel" /><span>{{ $t("status.delete") }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="button-icon">
|
||||||
|
<i class="icon-ellipsis" />
|
||||||
|
</div>
|
||||||
|
</v-popover>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./extra_buttons.js" ></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
@import '../popper/popper.scss';
|
||||||
|
|
||||||
|
.icon-ellipsis {
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
.extra-button-popover.open & {
|
||||||
|
color: $fallback--text;
|
||||||
|
color: var(--text, $fallback--text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -11,9 +11,9 @@ const FavoriteButton = {
|
||||||
methods: {
|
methods: {
|
||||||
favorite () {
|
favorite () {
|
||||||
if (!this.status.favorited) {
|
if (!this.status.favorited) {
|
||||||
this.$store.dispatch('favorite', {id: this.status.id})
|
this.$store.dispatch('favorite', { id: this.status.id })
|
||||||
} else {
|
} else {
|
||||||
this.$store.dispatch('unfavorite', {id: this.status.id})
|
this.$store.dispatch('unfavorite', { id: this.status.id })
|
||||||
}
|
}
|
||||||
this.animated = true
|
this.animated = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="loggedIn">
|
<div v-if="loggedIn">
|
||||||
<i :class='classes' class='button-icon favorite-button fav-active' @click.prevent='favorite()' :title="$t('tool_tip.favorite')"/>
|
<i
|
||||||
<span v-if='!hidePostStatsLocal && status.fave_num > 0'>{{status.fave_num}}</span>
|
:class="classes"
|
||||||
|
class="button-icon favorite-button fav-active"
|
||||||
|
:title="$t('tool_tip.favorite')"
|
||||||
|
@click.prevent="favorite()"
|
||||||
|
/>
|
||||||
|
<span v-if="!hidePostStatsLocal && status.fave_num > 0">{{ status.fave_num }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<i :class='classes' class='button-icon favorite-button' :title="$t('tool_tip.favorite')"/>
|
<i
|
||||||
<span v-if='!hidePostStatsLocal && status.fave_num > 0'>{{status.fave_num}}</span>
|
:class="classes"
|
||||||
|
class="button-icon favorite-button"
|
||||||
|
:title="$t('tool_tip.favorite')"
|
||||||
|
/>
|
||||||
|
<span v-if="!hidePostStatsLocal && status.fave_num > 0">{{ status.fave_num }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,25 @@
|
||||||
<div class="panel panel-default base01-background">
|
<div class="panel panel-default base01-background">
|
||||||
<div class="panel-heading timeline-heading base02-background base04">
|
<div class="panel-heading timeline-heading base02-background base04">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
{{$t('features_panel.title')}}
|
{{ $t('features_panel.title') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body features-panel">
|
<div class="panel-body features-panel">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-if="chat">{{$t('features_panel.chat')}}</li>
|
<li v-if="chat">
|
||||||
<li v-if="gopher">{{$t('features_panel.gopher')}}</li>
|
{{ $t('features_panel.chat') }}
|
||||||
<li v-if="whoToFollow">{{$t('features_panel.who_to_follow')}}</li>
|
</li>
|
||||||
<li v-if="mediaProxy">{{$t('features_panel.media_proxy')}}</li>
|
<li v-if="gopher">
|
||||||
<li>{{$t('features_panel.scope_options')}}</li>
|
{{ $t('features_panel.gopher') }}
|
||||||
<li>{{$t('features_panel.text_limit')}} = {{textlimit}}</li>
|
</li>
|
||||||
|
<li v-if="whoToFollow">
|
||||||
|
{{ $t('features_panel.who_to_follow') }}
|
||||||
|
</li>
|
||||||
|
<li v-if="mediaProxy">
|
||||||
|
{{ $t('features_panel.media_proxy') }}
|
||||||
|
</li>
|
||||||
|
<li>{{ $t('features_panel.scope_options') }}</li>
|
||||||
|
<li>{{ $t('features_panel.text_limit') }} = {{ textlimit }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,8 +10,7 @@ const FollowCard = {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
inProgress: false,
|
inProgress: false,
|
||||||
requestSent: false,
|
requestSent: false
|
||||||
updated: false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -19,10 +18,8 @@ const FollowCard = {
|
||||||
RemoteFollow
|
RemoteFollow
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isMe () { return this.$store.state.users.currentUser.id === this.user.id },
|
isMe () {
|
||||||
following () { return this.updated ? this.updated.following : this.user.following },
|
return this.$store.state.users.currentUser.id === this.user.id
|
||||||
showFollow () {
|
|
||||||
return !this.following || this.updated && !this.updated.following
|
|
||||||
},
|
},
|
||||||
loggedIn () {
|
loggedIn () {
|
||||||
return this.$store.state.users.currentUser
|
return this.$store.state.users.currentUser
|
||||||
|
@ -31,17 +28,15 @@ const FollowCard = {
|
||||||
methods: {
|
methods: {
|
||||||
followUser () {
|
followUser () {
|
||||||
this.inProgress = true
|
this.inProgress = true
|
||||||
requestFollow(this.user, this.$store).then(({ sent, updated }) => {
|
requestFollow(this.user, this.$store).then(({ sent }) => {
|
||||||
this.inProgress = false
|
this.inProgress = false
|
||||||
this.requestSent = sent
|
this.requestSent = sent
|
||||||
this.updated = updated
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
unfollowUser () {
|
unfollowUser () {
|
||||||
this.inProgress = true
|
this.inProgress = true
|
||||||
requestUnfollow(this.user, this.$store).then(({ updated }) => {
|
requestUnfollow(this.user, this.$store).then(() => {
|
||||||
this.inProgress = false
|
this.inProgress = false
|
||||||
this.updated = updated
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<basic-user-card :user="user">
|
<basic-user-card :user="user">
|
||||||
<div class="follow-card-content-container">
|
<div class="follow-card-content-container">
|
||||||
<span class="faint" v-if="!noFollowsYou && user.follows_you">
|
<span
|
||||||
|
v-if="!noFollowsYou && user.follows_you"
|
||||||
|
class="faint"
|
||||||
|
>
|
||||||
{{ isMe ? $t('user_card.its_you') : $t('user_card.follows_you') }}
|
{{ isMe ? $t('user_card.its_you') : $t('user_card.follows_you') }}
|
||||||
</span>
|
</span>
|
||||||
<div class="follow-card-follow-button" v-if="showFollow && !loggedIn">
|
<template v-if="!loggedIn">
|
||||||
|
<div
|
||||||
|
v-if="!user.following"
|
||||||
|
class="follow-card-follow-button"
|
||||||
|
>
|
||||||
<RemoteFollow :user="user" />
|
<RemoteFollow :user="user" />
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
<button
|
<button
|
||||||
v-if="showFollow && loggedIn"
|
v-if="!user.following"
|
||||||
class="btn btn-default follow-card-follow-button"
|
class="btn btn-default follow-card-follow-button"
|
||||||
@click="followUser"
|
|
||||||
:disabled="inProgress"
|
:disabled="inProgress"
|
||||||
:title="requestSent ? $t('user_card.follow_again') : ''"
|
:title="requestSent ? $t('user_card.follow_again') : ''"
|
||||||
|
@click="followUser"
|
||||||
>
|
>
|
||||||
<template v-if="inProgress">
|
<template v-if="inProgress">
|
||||||
{{ $t('user_card.follow_progress') }}
|
{{ $t('user_card.follow_progress') }}
|
||||||
|
@ -24,7 +33,12 @@
|
||||||
{{ $t('user_card.follow') }}
|
{{ $t('user_card.follow') }}
|
||||||
</template>
|
</template>
|
||||||
</button>
|
</button>
|
||||||
<button v-if="following" class="btn btn-default follow-card-follow-button pressed" @click="unfollowUser" :disabled="inProgress">
|
<button
|
||||||
|
v-else
|
||||||
|
class="btn btn-default follow-card-follow-button pressed"
|
||||||
|
:disabled="inProgress"
|
||||||
|
@click="unfollowUser"
|
||||||
|
>
|
||||||
<template v-if="inProgress">
|
<template v-if="inProgress">
|
||||||
{{ $t('user_card.follow_progress') }}
|
{{ $t('user_card.follow_progress') }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -32,6 +46,7 @@
|
||||||
{{ $t('user_card.follow_unfollow') }}
|
{{ $t('user_card.follow_unfollow') }}
|
||||||
</template>
|
</template>
|
||||||
</button>
|
</button>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</basic-user-card>
|
</basic-user-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<basic-user-card :user="user">
|
<basic-user-card :user="user">
|
||||||
<div class="follow-request-card-content-container">
|
<div class="follow-request-card-content-container">
|
||||||
<button class="btn btn-default" @click="approveUser">{{ $t('user_card.approve') }}</button>
|
<button
|
||||||
<button class="btn btn-default" @click="denyUser">{{ $t('user_card.deny') }}</button>
|
class="btn btn-default"
|
||||||
|
@click="approveUser"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.approve') }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn btn-default"
|
||||||
|
@click="denyUser"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.deny') }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</basic-user-card>
|
</basic-user-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="settings panel panel-default">
|
<div class="settings panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
{{$t('nav.friend_requests')}}
|
{{ $t('nav.friend_requests') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<FollowRequestCard v-for="request in requests" :key="request.id" :user="request"/>
|
<FollowRequestCard
|
||||||
|
v-for="request in requests"
|
||||||
|
:key="request.id"
|
||||||
|
:user="request"
|
||||||
|
class="list-item"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,35 +1,56 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="font-control style-control" :class="{ custom: isCustom }">
|
<div
|
||||||
<label :for="preset === 'custom' ? name : name + '-font-switcher'" class="label">
|
class="font-control style-control"
|
||||||
{{label}}
|
:class="{ custom: isCustom }"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
:for="preset === 'custom' ? name : name + '-font-switcher'"
|
||||||
|
class="label"
|
||||||
|
>
|
||||||
|
{{ label }}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
v-if="typeof fallback !== 'undefined'"
|
v-if="typeof fallback !== 'undefined'"
|
||||||
|
:id="name + '-o'"
|
||||||
class="opt exlcude-disabled"
|
class="opt exlcude-disabled"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
:id="name + '-o'"
|
|
||||||
:checked="present"
|
:checked="present"
|
||||||
@input="$emit('input', typeof value === 'undefined' ? fallback : undefined)">
|
@input="$emit('input', typeof value === 'undefined' ? fallback : undefined)"
|
||||||
<label v-if="typeof fallback !== 'undefined'" class="opt-l" :for="name + '-o'"></label>
|
>
|
||||||
<label :for="name + '-font-switcher'" class="select" :disabled="!present">
|
<label
|
||||||
<select
|
v-if="typeof fallback !== 'undefined'"
|
||||||
|
class="opt-l"
|
||||||
|
:for="name + '-o'"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
:for="name + '-font-switcher'"
|
||||||
|
class="select"
|
||||||
:disabled="!present"
|
:disabled="!present"
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
:id="name + '-font-switcher'"
|
||||||
v-model="preset"
|
v-model="preset"
|
||||||
|
:disabled="!present"
|
||||||
class="font-switcher"
|
class="font-switcher"
|
||||||
:id="name + '-font-switcher'">
|
>
|
||||||
<option v-for="option in availableOptions" :value="option">
|
<option
|
||||||
|
v-for="option in availableOptions"
|
||||||
|
:key="option"
|
||||||
|
:value="option"
|
||||||
|
>
|
||||||
{{ option === 'custom' ? $t('settings.style.fonts.custom') : option }}
|
{{ option === 'custom' ? $t('settings.style.fonts.custom') : option }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<i class="icon-down-open"/>
|
<i class="icon-down-open" />
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
v-if="isCustom"
|
v-if="isCustom"
|
||||||
|
:id="name"
|
||||||
|
v-model="family"
|
||||||
class="custom-font"
|
class="custom-font"
|
||||||
type="text"
|
type="text"
|
||||||
:id="name"
|
>
|
||||||
v-model="family">
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./font_control.js" ></script>
|
<script src="./font_control.js" ></script>
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<Timeline :title="$t('nav.timeline')" v-bind:timeline="timeline" v-bind:timeline-name="'friends'"/>
|
<Timeline
|
||||||
|
:title="$t('nav.timeline')"
|
||||||
|
:timeline="timeline"
|
||||||
|
:timeline-name="'friends'"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./friends_timeline.js"></script>
|
<script src="./friends_timeline.js"></script>
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
<template>
|
<template>
|
||||||
<div ref="galleryContainer" style="width: 100%;">
|
<div
|
||||||
<div class="gallery-row" v-for="row in rows" :style="rowHeight(row.length)" :class="{ 'contain-fit': useContainFit, 'cover-fit': !useContainFit }">
|
ref="galleryContainer"
|
||||||
|
style="width: 100%;"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(row, index) in rows"
|
||||||
|
:key="index"
|
||||||
|
class="gallery-row"
|
||||||
|
:style="rowHeight(row.length)"
|
||||||
|
:class="{ 'contain-fit': useContainFit, 'cover-fit': !useContainFit }"
|
||||||
|
>
|
||||||
<attachment
|
<attachment
|
||||||
v-for="attachment in row"
|
v-for="attachment in row"
|
||||||
:setMedia="setMedia"
|
:key="attachment.id"
|
||||||
|
:set-media="setMedia"
|
||||||
:nsfw="nsfw"
|
:nsfw="nsfw"
|
||||||
:attachment="attachment"
|
:attachment="attachment"
|
||||||
:allowPlay="false"
|
:allow-play="false"
|
||||||
:key="attachment.id"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,7 +37,9 @@
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
|
|
||||||
.attachments, .attachment {
|
// FIXME: specificity problem with this and .attachments.attachment
|
||||||
|
// we shouldn't have the need for .image here
|
||||||
|
.attachment.image {
|
||||||
margin: 0 0.5em 0 0;
|
margin: 0 0.5em 0 0;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
|
@ -70,22 +70,10 @@ const ImageCropper = {
|
||||||
this.dataUrl = undefined
|
this.dataUrl = undefined
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
},
|
},
|
||||||
submit () {
|
submit (cropping = true) {
|
||||||
this.submitting = true
|
this.submitting = true
|
||||||
this.avatarUploadError = null
|
this.avatarUploadError = null
|
||||||
this.submitHandler(this.cropper, this.file)
|
this.submitHandler(cropping && this.cropper, this.file)
|
||||||
.then(() => this.destroy())
|
|
||||||
.catch((err) => {
|
|
||||||
this.submitError = err
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.submitting = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
submitWithoutCropping () {
|
|
||||||
this.submitting = true
|
|
||||||
this.avatarUploadError = null
|
|
||||||
this.submitHandler(false, this.dataUrl)
|
|
||||||
.then(() => this.destroy())
|
.then(() => this.destroy())
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.submitError = err
|
this.submitError = err
|
||||||
|
|
|
@ -2,20 +2,57 @@
|
||||||
<div class="image-cropper">
|
<div class="image-cropper">
|
||||||
<div v-if="dataUrl">
|
<div v-if="dataUrl">
|
||||||
<div class="image-cropper-image-container">
|
<div class="image-cropper-image-container">
|
||||||
<img ref="img" :src="dataUrl" alt="" @load.stop="createCropper" />
|
<img
|
||||||
|
ref="img"
|
||||||
|
:src="dataUrl"
|
||||||
|
alt=""
|
||||||
|
@load.stop="createCropper"
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="image-cropper-buttons-wrapper">
|
<div class="image-cropper-buttons-wrapper">
|
||||||
<button class="btn" type="button" :disabled="submitting" @click="submit" v-text="saveText"></button>
|
<button
|
||||||
<button class="btn" type="button" :disabled="submitting" @click="destroy" v-text="cancelText"></button>
|
class="btn"
|
||||||
<button class="btn" type="button" :disabled="submitting" @click="submitWithoutCropping" v-text="saveWithoutCroppingText"></button>
|
type="button"
|
||||||
<i class="icon-spin4 animate-spin" v-if="submitting"></i>
|
:disabled="submitting"
|
||||||
|
@click="submit()"
|
||||||
|
v-text="saveText"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
class="btn"
|
||||||
|
type="button"
|
||||||
|
:disabled="submitting"
|
||||||
|
@click="destroy"
|
||||||
|
v-text="cancelText"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
class="btn"
|
||||||
|
type="button"
|
||||||
|
:disabled="submitting"
|
||||||
|
@click="submit(false)"
|
||||||
|
v-text="saveWithoutCroppingText"
|
||||||
|
/>
|
||||||
|
<i
|
||||||
|
v-if="submitting"
|
||||||
|
class="icon-spin4 animate-spin"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="alert error" v-if="submitError">
|
<div
|
||||||
{{submitErrorMsg}}
|
v-if="submitError"
|
||||||
<i class="button-icon icon-cancel" @click="clearError"></i>
|
class="alert error"
|
||||||
|
>
|
||||||
|
{{ submitErrorMsg }}
|
||||||
|
<i
|
||||||
|
class="button-icon icon-cancel"
|
||||||
|
@click="clearError"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input ref="input" type="file" class="image-cropper-img-input" :accept="mimes">
|
<input
|
||||||
|
ref="input"
|
||||||
|
type="file"
|
||||||
|
class="image-cropper-img-input"
|
||||||
|
:accept="mimes"
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
53
src/components/importer/importer.js
Normal file
53
src/components/importer/importer.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
const Importer = {
|
||||||
|
props: {
|
||||||
|
submitHandler: {
|
||||||
|
type: Function,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
submitButtonLabel: {
|
||||||
|
type: String,
|
||||||
|
default () {
|
||||||
|
return this.$t('importer.submit')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
successMessage: {
|
||||||
|
type: String,
|
||||||
|
default () {
|
||||||
|
return this.$t('importer.success')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errorMessage: {
|
||||||
|
type: String,
|
||||||
|
default () {
|
||||||
|
return this.$t('importer.error')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
file: null,
|
||||||
|
error: false,
|
||||||
|
success: false,
|
||||||
|
submitting: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
change () {
|
||||||
|
this.file = this.$refs.input.files[0]
|
||||||
|
},
|
||||||
|
submit () {
|
||||||
|
this.dismiss()
|
||||||
|
this.submitting = true
|
||||||
|
this.submitHandler(this.file)
|
||||||
|
.then(() => { this.success = true })
|
||||||
|
.catch(() => { this.error = true })
|
||||||
|
.finally(() => { this.submitting = false })
|
||||||
|
},
|
||||||
|
dismiss () {
|
||||||
|
this.success = false
|
||||||
|
this.error = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Importer
|
47
src/components/importer/importer.vue
Normal file
47
src/components/importer/importer.vue
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<template>
|
||||||
|
<div class="importer">
|
||||||
|
<form>
|
||||||
|
<input
|
||||||
|
ref="input"
|
||||||
|
type="file"
|
||||||
|
@change="change"
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
<i
|
||||||
|
v-if="submitting"
|
||||||
|
class="icon-spin4 animate-spin importer-uploading"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
v-else
|
||||||
|
class="btn btn-default"
|
||||||
|
@click="submit"
|
||||||
|
>
|
||||||
|
{{ submitButtonLabel }}
|
||||||
|
</button>
|
||||||
|
<div v-if="success">
|
||||||
|
<i
|
||||||
|
class="icon-cross"
|
||||||
|
@click="dismiss"
|
||||||
|
/>
|
||||||
|
<p>{{ successMessage }}</p>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="error">
|
||||||
|
<i
|
||||||
|
class="icon-cross"
|
||||||
|
@click="dismiss"
|
||||||
|
/>
|
||||||
|
<p>{{ errorMessage }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./importer.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.importer {
|
||||||
|
&-uploading {
|
||||||
|
font-size: 1.5em;
|
||||||
|
margin: 0.25em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,9 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="show" class="instance-specific-panel">
|
<div
|
||||||
|
v-if="show"
|
||||||
|
class="instance-specific-panel"
|
||||||
|
>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div v-html="instanceSpecificPanelContent">
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
</div>
|
<div v-html="instanceSpecificPanelContent" />
|
||||||
|
<!-- eslint-enable vue/no-v-html -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
25
src/components/interactions/interactions.js
Normal file
25
src/components/interactions/interactions.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import Notifications from '../notifications/notifications.vue'
|
||||||
|
|
||||||
|
const tabModeDict = {
|
||||||
|
mentions: ['mention'],
|
||||||
|
'likes+repeats': ['repeat', 'like'],
|
||||||
|
follows: ['follow']
|
||||||
|
}
|
||||||
|
|
||||||
|
const Interactions = {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
filterMode: tabModeDict['mentions']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onModeSwitch (index, dataset) {
|
||||||
|
this.filterMode = tabModeDict[dataset.filter]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
Notifications
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Interactions
|
37
src/components/interactions/interactions.vue
Normal file
37
src/components/interactions/interactions.vue
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<template>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<div class="title">
|
||||||
|
{{ $t("nav.interactions") }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<tab-switcher
|
||||||
|
ref="tabSwitcher"
|
||||||
|
:on-switch="onModeSwitch"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
data-tab-dummy
|
||||||
|
data-filter="mentions"
|
||||||
|
:label="$t('nav.mentions')"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
data-tab-dummy
|
||||||
|
data-filter="likes+repeats"
|
||||||
|
:label="$t('interactions.favs_repeats')"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
data-tab-dummy
|
||||||
|
data-filter="follows"
|
||||||
|
:label="$t('interactions.follows')"
|
||||||
|
/>
|
||||||
|
</tab-switcher>
|
||||||
|
<Notifications
|
||||||
|
ref="notifications"
|
||||||
|
:no-heading="true"
|
||||||
|
:minimal-mode="true"
|
||||||
|
:filter-mode="filterMode"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./interactions.js"></script>
|
|
@ -3,30 +3,40 @@
|
||||||
<label for="interface-language-switcher">
|
<label for="interface-language-switcher">
|
||||||
{{ $t('settings.interfaceLanguage') }}
|
{{ $t('settings.interfaceLanguage') }}
|
||||||
</label>
|
</label>
|
||||||
<label for="interface-language-switcher" class='select'>
|
<label
|
||||||
<select id="interface-language-switcher" v-model="language">
|
for="interface-language-switcher"
|
||||||
<option v-for="(langCode, i) in languageCodes" :value="langCode">
|
class="select"
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
id="interface-language-switcher"
|
||||||
|
v-model="language"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="(langCode, i) in languageCodes"
|
||||||
|
:key="langCode"
|
||||||
|
:value="langCode"
|
||||||
|
>
|
||||||
{{ languageNames[i] }}
|
{{ languageNames[i] }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<i class="icon-down-open"/>
|
<i class="icon-down-open" />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import languagesObject from '../../i18n/messages'
|
import languagesObject from '../../i18n/messages'
|
||||||
import ISO6391 from 'iso-639-1'
|
import ISO6391 from 'iso-639-1'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
languageCodes () {
|
languageCodes () {
|
||||||
return Object.keys(languagesObject)
|
return Object.keys(languagesObject)
|
||||||
},
|
},
|
||||||
|
|
||||||
languageNames () {
|
languageNames () {
|
||||||
return _.map(this.languageCodes, ISO6391.getName)
|
return _.map(this.languageCodes, this.getLanguageName)
|
||||||
},
|
},
|
||||||
|
|
||||||
language: {
|
language: {
|
||||||
|
@ -36,6 +46,17 @@
|
||||||
this.$i18n.locale = val
|
this.$i18n.locale = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
getLanguageName (code) {
|
||||||
|
const specialLanguageNames = {
|
||||||
|
'ja': 'Japanese (やさしいにほんご)',
|
||||||
|
'ja_pedantic': 'Japanese (日本語)',
|
||||||
|
'zh': 'Chinese (简体中文)'
|
||||||
|
}
|
||||||
|
return specialLanguageNames[code] || ISO6391.getName(code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,13 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<a class="link-preview-card" :href="card.url" target="_blank" rel="noopener">
|
<a
|
||||||
<div class="card-image" :class="{ 'small-image': size === 'small' }" v-if="useImage">
|
class="link-preview-card"
|
||||||
<img :src="card.image"></img>
|
:href="card.url"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="useImage"
|
||||||
|
class="card-image"
|
||||||
|
:class="{ 'small-image': size === 'small' }"
|
||||||
|
>
|
||||||
|
<img :src="card.image">
|
||||||
</div>
|
</div>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-host faint">{{ card.provider_name }}</span>
|
<span class="card-host faint">{{ card.provider_name }}</span>
|
||||||
<h4 class="card-title">{{ card.title }}</h4>
|
<h4 class="card-title">{{ card.title }}</h4>
|
||||||
<p class="card-description" v-if="useDescription">{{ card.description }}</p>
|
<p
|
||||||
|
v-if="useDescription"
|
||||||
|
class="card-description"
|
||||||
|
>{{ card.description }}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
52
src/components/list/list.vue
Normal file
52
src/components/list/list.vue
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<template>
|
||||||
|
<div class="list">
|
||||||
|
<div
|
||||||
|
v-for="item in items"
|
||||||
|
:key="getKey(item)"
|
||||||
|
class="list-item"
|
||||||
|
>
|
||||||
|
<slot
|
||||||
|
name="item"
|
||||||
|
:item="item"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="items.length === 0 && !!$slots.empty"
|
||||||
|
class="list-empty-content faint"
|
||||||
|
>
|
||||||
|
<slot name="empty" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
items: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
getKey: {
|
||||||
|
type: Function,
|
||||||
|
default: item => item.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.list {
|
||||||
|
&-item:not(:last-child) {
|
||||||
|
border-bottom: 1px solid;
|
||||||
|
border-bottom-color: $fallback--border;
|
||||||
|
border-bottom-color: var(--border, $fallback--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
&-empty-content {
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,50 +1,81 @@
|
||||||
|
import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
|
||||||
import oauthApi from '../../services/new_api/oauth.js'
|
import oauthApi from '../../services/new_api/oauth.js'
|
||||||
|
|
||||||
const LoginForm = {
|
const LoginForm = {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
user: {},
|
user: {},
|
||||||
authError: false
|
error: false
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
loginMethod () { return this.$store.state.instance.loginMethod },
|
isPasswordAuth () { return this.requiredPassword },
|
||||||
loggingIn () { return this.$store.state.users.loggingIn },
|
isTokenAuth () { return this.requiredToken },
|
||||||
registrationOpen () { return this.$store.state.instance.registrationOpen }
|
...mapState({
|
||||||
|
registrationOpen: state => state.instance.registrationOpen,
|
||||||
|
instance: state => state.instance,
|
||||||
|
loggingIn: state => state.users.loggingIn,
|
||||||
|
oauth: state => state.oauth
|
||||||
|
}),
|
||||||
|
...mapGetters(
|
||||||
|
'authFlow', ['requiredPassword', 'requiredToken', 'requiredMFA']
|
||||||
|
)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
oAuthLogin () {
|
...mapMutations('authFlow', ['requireMFA']),
|
||||||
oauthApi.login({
|
...mapActions({ login: 'authFlow/login' }),
|
||||||
oauth: this.$store.state.oauth,
|
|
||||||
instance: this.$store.state.instance.server,
|
|
||||||
commit: this.$store.commit
|
|
||||||
})
|
|
||||||
},
|
|
||||||
submit () {
|
submit () {
|
||||||
|
this.isTokenAuth ? this.submitToken() : this.submitPassword()
|
||||||
|
},
|
||||||
|
submitToken () {
|
||||||
|
const { clientId, clientSecret } = this.oauth
|
||||||
const data = {
|
const data = {
|
||||||
oauth: this.$store.state.oauth,
|
clientId,
|
||||||
instance: this.$store.state.instance.server
|
clientSecret,
|
||||||
|
instance: this.instance.server,
|
||||||
|
commit: this.$store.commit
|
||||||
}
|
}
|
||||||
this.clearError()
|
|
||||||
|
oauthApi.getOrCreateApp(data)
|
||||||
|
.then((app) => { oauthApi.login({ ...app, ...data }) })
|
||||||
|
},
|
||||||
|
submitPassword () {
|
||||||
|
const { clientId } = this.oauth
|
||||||
|
const data = {
|
||||||
|
clientId,
|
||||||
|
oauth: this.oauth,
|
||||||
|
instance: this.instance.server,
|
||||||
|
commit: this.$store.commit
|
||||||
|
}
|
||||||
|
this.error = false
|
||||||
|
|
||||||
oauthApi.getOrCreateApp(data).then((app) => {
|
oauthApi.getOrCreateApp(data).then((app) => {
|
||||||
oauthApi.getTokenWithCredentials(
|
oauthApi.getTokenWithCredentials(
|
||||||
{
|
{
|
||||||
app,
|
...app,
|
||||||
instance: data.instance,
|
instance: data.instance,
|
||||||
username: this.user.username,
|
username: this.user.username,
|
||||||
password: this.user.password
|
password: this.user.password
|
||||||
}
|
}
|
||||||
).then((result) => {
|
).then((result) => {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
this.authError = result.error
|
if (result.error === 'mfa_required') {
|
||||||
this.user.password = ''
|
this.requireMFA({ app: app, settings: result })
|
||||||
|
} else {
|
||||||
|
this.error = result.error
|
||||||
|
this.focusOnPasswordInput()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$store.commit('setToken', result.access_token)
|
this.login(result).then(() => {
|
||||||
this.$store.dispatch('loginUser', result.access_token)
|
this.$router.push({ name: 'friends' })
|
||||||
this.$router.push({name: 'friends'})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
clearError () {
|
clearError () { this.error = false },
|
||||||
this.authError = false
|
focusOnPasswordInput () {
|
||||||
|
let passwordInput = this.$refs.passwordInput
|
||||||
|
passwordInput.focus()
|
||||||
|
passwordInput.setSelectionRange(0, passwordInput.value.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,80 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="login panel panel-default">
|
<div class="login panel panel-default">
|
||||||
<!-- Default panel contents -->
|
<!-- Default panel contents -->
|
||||||
|
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
{{$t('login.login')}}
|
{{ $t('login.login') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form v-if="loginMethod == 'password'" v-on:submit.prevent='submit(user)' class='login-form'>
|
<form
|
||||||
<div class='form-group'>
|
class="login-form"
|
||||||
<label for='username'>{{$t('login.username')}}</label>
|
@submit.prevent="submit"
|
||||||
<input :disabled="loggingIn" v-model='user.username' class='form-control' id='username' v-bind:placeholder="$t('login.placeholder')">
|
>
|
||||||
</div>
|
<template v-if="isPasswordAuth">
|
||||||
<div class='form-group'>
|
|
||||||
<label for='password'>{{$t('login.password')}}</label>
|
|
||||||
<input :disabled="loggingIn" v-model='user.password' class='form-control' id='password' type='password'>
|
|
||||||
</div>
|
|
||||||
<div class='form-group'>
|
|
||||||
<div class='login-bottom'>
|
|
||||||
<div><router-link :to="{name: 'registration'}" v-if='registrationOpen' class='register'>{{$t('login.register')}}</router-link></div>
|
|
||||||
<button :disabled="loggingIn" type='submit' class='btn btn-default'>{{$t('login.login')}}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form v-if="loginMethod == 'token'" v-on:submit.prevent='oAuthLogin' class="login-form">
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<p>{{$t('login.description')}}</p>
|
<label for="username">{{ $t('login.username') }}</label>
|
||||||
|
<input
|
||||||
|
id="username"
|
||||||
|
v-model="user.username"
|
||||||
|
:disabled="loggingIn"
|
||||||
|
class="form-control"
|
||||||
|
:placeholder="$t('login.placeholder')"
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class='form-group'>
|
<div class="form-group">
|
||||||
<div class='login-bottom'>
|
<label for="password">{{ $t('login.password') }}</label>
|
||||||
<div><router-link :to="{name: 'registration'}" v-if='registrationOpen' class='register'>{{$t('login.register')}}</router-link></div>
|
<input
|
||||||
<button :disabled="loggingIn" type='submit' class='btn btn-default'>{{$t('login.login')}}</button>
|
id="password"
|
||||||
|
ref="passwordInput"
|
||||||
|
v-model="user.password"
|
||||||
|
:disabled="loggingIn"
|
||||||
|
class="form-control"
|
||||||
|
type="password"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="isTokenAuth"
|
||||||
|
class="form-group"
|
||||||
|
>
|
||||||
|
<p>{{ $t('login.description') }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="login-bottom">
|
||||||
|
<div>
|
||||||
|
<router-link
|
||||||
|
v-if="registrationOpen"
|
||||||
|
:to="{name: 'registration'}"
|
||||||
|
class="register"
|
||||||
|
>
|
||||||
|
{{ $t('login.register') }}
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
:disabled="loggingIn"
|
||||||
|
type="submit"
|
||||||
|
class="btn btn-default"
|
||||||
|
>
|
||||||
|
{{ $t('login.login') }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div v-if="authError" class='form-group'>
|
|
||||||
<div class='alert error'>
|
|
||||||
{{authError}}
|
|
||||||
<i class="button-icon icon-cancel" @click="clearError"></i>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="error"
|
||||||
|
class="form-group"
|
||||||
|
>
|
||||||
|
<div class="alert error">
|
||||||
|
{{ error }}
|
||||||
|
<i
|
||||||
|
class="button-icon icon-cancel"
|
||||||
|
@click="clearError"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -50,6 +86,10 @@
|
||||||
@import '../../_variables.scss';
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
.login-form {
|
.login-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 0.6em;
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
min-height: 28px;
|
min-height: 28px;
|
||||||
width: 10em;
|
width: 10em;
|
||||||
|
@ -66,9 +106,30 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.login {
|
.form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 0.3em 0.5em 0.6em;
|
||||||
|
line-height:24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-bottom {
|
||||||
|
display: flex;
|
||||||
|
padding: 0.5em;
|
||||||
|
height: 32px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 10em;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 0.35em;
|
||||||
|
padding: 0.35em;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,33 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="modal-view media-modal-view" v-if="showing" @click.prevent="hide">
|
<div
|
||||||
<img class="modal-image" v-if="type === 'image'" :src="currentMedia.url"></img>
|
v-if="showing"
|
||||||
<VideoAttachment
|
class="modal-view media-modal-view"
|
||||||
|
@click.prevent="hide"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="type === 'image'"
|
||||||
class="modal-image"
|
class="modal-image"
|
||||||
|
:src="currentMedia.url"
|
||||||
|
>
|
||||||
|
<VideoAttachment
|
||||||
v-if="type === 'video'"
|
v-if="type === 'video'"
|
||||||
|
class="modal-image"
|
||||||
:attachment="currentMedia"
|
:attachment="currentMedia"
|
||||||
:controls="true"
|
:controls="true"
|
||||||
@click.stop.native="">
|
@click.stop.native=""
|
||||||
</VideoAttachment>
|
/>
|
||||||
<button
|
<button
|
||||||
|
v-if="canNavigate"
|
||||||
:title="$t('media_modal.previous')"
|
:title="$t('media_modal.previous')"
|
||||||
class="modal-view-button-arrow modal-view-button-arrow--prev"
|
class="modal-view-button-arrow modal-view-button-arrow--prev"
|
||||||
v-if="canNavigate"
|
|
||||||
@click.stop.prevent="goPrev"
|
@click.stop.prevent="goPrev"
|
||||||
>
|
>
|
||||||
<i class="icon-left-open arrow-icon" />
|
<i class="icon-left-open arrow-icon" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
v-if="canNavigate"
|
||||||
:title="$t('media_modal.next')"
|
:title="$t('media_modal.next')"
|
||||||
class="modal-view-button-arrow modal-view-button-arrow--next"
|
class="modal-view-button-arrow modal-view-button-arrow--next"
|
||||||
v-if="canNavigate"
|
|
||||||
@click.stop.prevent="goNext"
|
@click.stop.prevent="goNext"
|
||||||
>
|
>
|
||||||
<i class="icon-right-open arrow-icon" />
|
<i class="icon-right-open arrow-icon" />
|
||||||
|
@ -33,6 +41,8 @@
|
||||||
@import '../../_variables.scss';
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
.media-modal-view {
|
.media-modal-view {
|
||||||
|
z-index: 1001;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.modal-view-button-arrow {
|
.modal-view-button-arrow {
|
||||||
opacity: 0.75;
|
opacity: 0.75;
|
||||||
|
|
|
@ -16,7 +16,7 @@ const mediaUpload = {
|
||||||
if (file.size > store.state.instance.uploadlimit) {
|
if (file.size > store.state.instance.uploadlimit) {
|
||||||
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
|
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
|
||||||
const allowedsize = fileSizeFormatService.fileSizeFormat(store.state.instance.uploadlimit)
|
const allowedsize = fileSizeFormatService.fileSizeFormat(store.state.instance.uploadlimit)
|
||||||
self.$emit('upload-failed', 'file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit})
|
self.$emit('upload-failed', 'file_too_big', { filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
|
@ -54,7 +54,7 @@ const mediaUpload = {
|
||||||
this.uploadReady = true
|
this.uploadReady = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
change ({target}) {
|
change ({ target }) {
|
||||||
for (var i = 0; i < target.files.length; i++) {
|
for (var i = 0; i < target.files.length; i++) {
|
||||||
let file = target.files[i]
|
let file = target.files[i]
|
||||||
this.uploadFile(file)
|
this.uploadFile(file)
|
||||||
|
|
|
@ -1,9 +1,29 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="media-upload" @drop.prevent @dragover.prevent="fileDrag" @drop="fileDrop">
|
<div
|
||||||
<label class="btn btn-default" :title="$t('tool_tip.media_upload')">
|
class="media-upload"
|
||||||
<i class="icon-spin4 animate-spin" v-if="uploading"></i>
|
@drop.prevent
|
||||||
<i class="icon-upload" v-if="!uploading"></i>
|
@dragover.prevent="fileDrag"
|
||||||
<input type="file" v-if="uploadReady" @change="change" style="position: fixed; top: -100em" multiple="true"></input>
|
@drop="fileDrop"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
class="btn btn-default"
|
||||||
|
:title="$t('tool_tip.media_upload')"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
v-if="uploading"
|
||||||
|
class="icon-spin4 animate-spin"
|
||||||
|
/>
|
||||||
|
<i
|
||||||
|
v-if="!uploading"
|
||||||
|
class="icon-upload"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
v-if="uploadReady"
|
||||||
|
type="file"
|
||||||
|
style="position: fixed; top: -100em"
|
||||||
|
multiple="true"
|
||||||
|
@change="change"
|
||||||
|
>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -13,7 +33,7 @@
|
||||||
<style>
|
<style>
|
||||||
.media-upload {
|
.media-upload {
|
||||||
font-size: 26px;
|
font-size: 26px;
|
||||||
flex: 1;
|
min-width: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-upload {
|
.icon-upload {
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<Timeline :title="$t('nav.mentions')" v-bind:timeline="timeline" v-bind:timeline-name="'mentions'"/>
|
<Timeline
|
||||||
|
:title="$t('nav.interactions')"
|
||||||
|
:timeline="timeline"
|
||||||
|
:timeline-name="'mentions'"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./mentions.js"></script>
|
<script src="./mentions.js"></script>
|
||||||
|
|
41
src/components/mfa_form/recovery_form.js
Normal file
41
src/components/mfa_form/recovery_form.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import mfaApi from '../../services/new_api/mfa.js'
|
||||||
|
import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data: () => ({
|
||||||
|
code: null,
|
||||||
|
error: false
|
||||||
|
}),
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
authApp: 'authFlow/app',
|
||||||
|
authSettings: 'authFlow/settings'
|
||||||
|
}),
|
||||||
|
...mapState({ instance: 'instance' })
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapMutations('authFlow', ['requireTOTP', 'abortMFA']),
|
||||||
|
...mapActions({ login: 'authFlow/login' }),
|
||||||
|
clearError () { this.error = false },
|
||||||
|
submit () {
|
||||||
|
const data = {
|
||||||
|
app: this.authApp,
|
||||||
|
instance: this.instance.server,
|
||||||
|
mfaToken: this.authSettings.mfa_token,
|
||||||
|
code: this.code
|
||||||
|
}
|
||||||
|
|
||||||
|
mfaApi.verifyRecoveryCode(data).then((result) => {
|
||||||
|
if (result.error) {
|
||||||
|
this.error = result.error
|
||||||
|
this.code = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.login(result).then(() => {
|
||||||
|
this.$router.push({ name: 'friends' })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
65
src/components/mfa_form/recovery_form.vue
Normal file
65
src/components/mfa_form/recovery_form.vue
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<template>
|
||||||
|
<div class="login panel panel-default">
|
||||||
|
<!-- Default panel contents -->
|
||||||
|
|
||||||
|
<div class="panel-heading">
|
||||||
|
{{ $t('login.heading.recovery') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<form
|
||||||
|
class="login-form"
|
||||||
|
@submit.prevent="submit"
|
||||||
|
>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="code">{{ $t('login.recovery_code') }}</label>
|
||||||
|
<input
|
||||||
|
id="code"
|
||||||
|
v-model="code"
|
||||||
|
class="form-control"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="login-bottom">
|
||||||
|
<div>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
@click.prevent="requireTOTP"
|
||||||
|
>
|
||||||
|
{{ $t('login.enter_two_factor_code') }}
|
||||||
|
</a>
|
||||||
|
<br>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
@click.prevent="abortMFA"
|
||||||
|
>
|
||||||
|
{{ $t('general.cancel') }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="btn btn-default"
|
||||||
|
>
|
||||||
|
{{ $t('general.verify') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="error"
|
||||||
|
class="form-group"
|
||||||
|
>
|
||||||
|
<div class="alert error">
|
||||||
|
{{ error }}
|
||||||
|
<i
|
||||||
|
class="button-icon icon-cancel"
|
||||||
|
@click="clearError"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script src="./recovery_form.js" ></script>
|
40
src/components/mfa_form/totp_form.js
Normal file
40
src/components/mfa_form/totp_form.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import mfaApi from '../../services/new_api/mfa.js'
|
||||||
|
import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
|
||||||
|
export default {
|
||||||
|
data: () => ({
|
||||||
|
code: null,
|
||||||
|
error: false
|
||||||
|
}),
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
authApp: 'authFlow/app',
|
||||||
|
authSettings: 'authFlow/settings'
|
||||||
|
}),
|
||||||
|
...mapState({ instance: 'instance' })
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapMutations('authFlow', ['requireRecovery', 'abortMFA']),
|
||||||
|
...mapActions({ login: 'authFlow/login' }),
|
||||||
|
clearError () { this.error = false },
|
||||||
|
submit () {
|
||||||
|
const data = {
|
||||||
|
app: this.authApp,
|
||||||
|
instance: this.instance.server,
|
||||||
|
mfaToken: this.authSettings.mfa_token,
|
||||||
|
code: this.code
|
||||||
|
}
|
||||||
|
|
||||||
|
mfaApi.verifyOTPCode(data).then((result) => {
|
||||||
|
if (result.error) {
|
||||||
|
this.error = result.error
|
||||||
|
this.code = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.login(result).then(() => {
|
||||||
|
this.$router.push({ name: 'friends' })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
67
src/components/mfa_form/totp_form.vue
Normal file
67
src/components/mfa_form/totp_form.vue
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<template>
|
||||||
|
<div class="login panel panel-default">
|
||||||
|
<!-- Default panel contents -->
|
||||||
|
|
||||||
|
<div class="panel-heading">
|
||||||
|
{{ $t('login.heading.totp') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<form
|
||||||
|
class="login-form"
|
||||||
|
@submit.prevent="submit"
|
||||||
|
>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="code">
|
||||||
|
{{ $t('login.authentication_code') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="code"
|
||||||
|
v-model="code"
|
||||||
|
class="form-control"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="login-bottom">
|
||||||
|
<div>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
@click.prevent="requireRecovery"
|
||||||
|
>
|
||||||
|
{{ $t('login.enter_recovery_code') }}
|
||||||
|
</a>
|
||||||
|
<br>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
@click.prevent="abortMFA"
|
||||||
|
>
|
||||||
|
{{ $t('general.cancel') }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="btn btn-default"
|
||||||
|
>
|
||||||
|
{{ $t('general.verify') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="error"
|
||||||
|
class="form-group"
|
||||||
|
>
|
||||||
|
<div class="alert error">
|
||||||
|
{{ error }}
|
||||||
|
<i
|
||||||
|
class="button-icon icon-cancel"
|
||||||
|
@click="clearError"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script src="./totp_form.js"></script>
|
|
@ -63,6 +63,11 @@ const MobileNav = {
|
||||||
},
|
},
|
||||||
markNotificationsAsSeen () {
|
markNotificationsAsSeen () {
|
||||||
this.$refs.notifications.markAsSeen()
|
this.$refs.notifications.markAsSeen()
|
||||||
|
},
|
||||||
|
onScroll ({ target: { scrollTop, clientHeight, scrollHeight } }) {
|
||||||
|
if (this.$store.state.config.autoLoad && scrollTop + clientHeight >= scrollHeight) {
|
||||||
|
this.$refs.notifications.fetchOlderNotifications()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -1,38 +1,77 @@
|
||||||
<template>
|
<template>
|
||||||
<nav class='nav-bar container' id="nav">
|
<div>
|
||||||
<div class='mobile-inner-nav' @click="scrollToTop()">
|
<nav
|
||||||
<div class='item'>
|
id="nav"
|
||||||
<a href="#" class="mobile-nav-button" @click.stop.prevent="toggleMobileSidebar()">
|
class="nav-bar container"
|
||||||
<i class="button-icon icon-menu"></i>
|
>
|
||||||
|
<div
|
||||||
|
class="mobile-inner-nav"
|
||||||
|
@click="scrollToTop()"
|
||||||
|
>
|
||||||
|
<div class="item">
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
class="mobile-nav-button"
|
||||||
|
@click.stop.prevent="toggleMobileSidebar()"
|
||||||
|
>
|
||||||
|
<i class="button-icon icon-menu" />
|
||||||
</a>
|
</a>
|
||||||
<router-link class="site-name" :to="{ name: 'root' }" active-class="home">{{sitename}}</router-link>
|
<router-link
|
||||||
|
class="site-name"
|
||||||
|
:to="{ name: 'root' }"
|
||||||
|
active-class="home"
|
||||||
|
>
|
||||||
|
{{ sitename }}
|
||||||
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div class='item right'>
|
<div class="item right">
|
||||||
<a class="mobile-nav-button" v-if="currentUser" href="#" @click.stop.prevent="openMobileNotifications()">
|
<a
|
||||||
<i class="button-icon icon-bell-alt"></i>
|
v-if="currentUser"
|
||||||
<div class="alert-dot" v-if="unseenNotificationsCount"></div>
|
class="mobile-nav-button"
|
||||||
|
href="#"
|
||||||
|
@click.stop.prevent="openMobileNotifications()"
|
||||||
|
>
|
||||||
|
<i class="button-icon icon-bell-alt" />
|
||||||
|
<div
|
||||||
|
v-if="unseenNotificationsCount"
|
||||||
|
class="alert-dot"
|
||||||
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<SideDrawer ref="sideDrawer" :logout="logout"/>
|
</nav>
|
||||||
<div v-if="currentUser"
|
<div
|
||||||
|
v-if="currentUser"
|
||||||
class="mobile-notifications-drawer"
|
class="mobile-notifications-drawer"
|
||||||
:class="{ 'closed': !notificationsOpen }"
|
:class="{ 'closed': !notificationsOpen }"
|
||||||
@touchstart="notificationsTouchStart"
|
@touchstart.stop="notificationsTouchStart"
|
||||||
@touchmove="notificationsTouchMove"
|
@touchmove.stop="notificationsTouchMove"
|
||||||
>
|
>
|
||||||
<div class="mobile-notifications-header">
|
<div class="mobile-notifications-header">
|
||||||
<span class="title">{{$t('notifications.notifications')}}</span>
|
<span class="title">{{ $t('notifications.notifications') }}</span>
|
||||||
<a class="mobile-nav-button" @click.stop.prevent="closeMobileNotifications()">
|
<a
|
||||||
<i class="button-icon icon-cancel"/>
|
class="mobile-nav-button"
|
||||||
|
@click.stop.prevent="closeMobileNotifications()"
|
||||||
|
>
|
||||||
|
<i class="button-icon icon-cancel" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="currentUser" class="mobile-notifications">
|
<div
|
||||||
<Notifications ref="notifications" noHeading="true"/>
|
class="mobile-notifications"
|
||||||
|
@scroll="onScroll"
|
||||||
|
>
|
||||||
|
<Notifications
|
||||||
|
ref="notifications"
|
||||||
|
:no-heading="true"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<SideDrawer
|
||||||
|
ref="sideDrawer"
|
||||||
|
:logout="logout"
|
||||||
|
/>
|
||||||
<MobilePostStatusModal />
|
<MobilePostStatusModal />
|
||||||
</nav>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./mobile_nav.js"></script>
|
<script src="./mobile_nav.js"></script>
|
||||||
|
@ -79,6 +118,8 @@
|
||||||
transition-property: transform;
|
transition-property: transform;
|
||||||
transition-duration: 0.25s;
|
transition-duration: 0.25s;
|
||||||
transform: translateX(0);
|
transform: translateX(0);
|
||||||
|
z-index: 1001;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
||||||
&.closed {
|
&.closed {
|
||||||
transform: translateX(100%);
|
transform: translateX(100%);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import PostStatusForm from '../post_status_form/post_status_form.vue'
|
import PostStatusForm from '../post_status_form/post_status_form.vue'
|
||||||
import { throttle } from 'lodash'
|
import { debounce } from 'lodash'
|
||||||
|
|
||||||
const MobilePostStatusModal = {
|
const MobilePostStatusModal = {
|
||||||
components: {
|
components: {
|
||||||
|
@ -16,11 +16,15 @@ const MobilePostStatusModal = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
window.addEventListener('scroll', this.handleScroll)
|
if (this.autohideFloatingPostButton) {
|
||||||
|
this.activateFloatingPostButtonAutohide()
|
||||||
|
}
|
||||||
window.addEventListener('resize', this.handleOSK)
|
window.addEventListener('resize', this.handleOSK)
|
||||||
},
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
window.removeEventListener('scroll', this.handleScroll)
|
if (this.autohideFloatingPostButton) {
|
||||||
|
this.deactivateFloatingPostButtonAutohide()
|
||||||
|
}
|
||||||
window.removeEventListener('resize', this.handleOSK)
|
window.removeEventListener('resize', this.handleOSK)
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -28,10 +32,30 @@ const MobilePostStatusModal = {
|
||||||
return this.$store.state.users.currentUser
|
return this.$store.state.users.currentUser
|
||||||
},
|
},
|
||||||
isHidden () {
|
isHidden () {
|
||||||
return this.hidden || this.inputActive
|
return this.autohideFloatingPostButton && (this.hidden || this.inputActive)
|
||||||
|
},
|
||||||
|
autohideFloatingPostButton () {
|
||||||
|
return !!this.$store.state.config.autohideFloatingPostButton
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
autohideFloatingPostButton: function (isEnabled) {
|
||||||
|
if (isEnabled) {
|
||||||
|
this.activateFloatingPostButtonAutohide()
|
||||||
|
} else {
|
||||||
|
this.deactivateFloatingPostButtonAutohide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
activateFloatingPostButtonAutohide () {
|
||||||
|
window.addEventListener('scroll', this.handleScrollStart)
|
||||||
|
window.addEventListener('scroll', this.handleScrollEnd)
|
||||||
|
},
|
||||||
|
deactivateFloatingPostButtonAutohide () {
|
||||||
|
window.removeEventListener('scroll', this.handleScrollStart)
|
||||||
|
window.removeEventListener('scroll', this.handleScrollEnd)
|
||||||
|
},
|
||||||
openPostForm () {
|
openPostForm () {
|
||||||
this.postFormOpen = true
|
this.postFormOpen = true
|
||||||
this.hidden = true
|
this.hidden = true
|
||||||
|
@ -65,26 +89,19 @@ const MobilePostStatusModal = {
|
||||||
this.inputActive = false
|
this.inputActive = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleScroll: throttle(function () {
|
handleScrollStart: debounce(function () {
|
||||||
const scrollAmount = window.scrollY - this.oldScrollPos
|
if (window.scrollY > this.oldScrollPos) {
|
||||||
const scrollingDown = scrollAmount > 0
|
this.hidden = true
|
||||||
|
} else {
|
||||||
if (scrollingDown !== this.scrollingDown) {
|
|
||||||
this.amountScrolled = 0
|
|
||||||
this.scrollingDown = scrollingDown
|
|
||||||
if (!scrollingDown) {
|
|
||||||
this.hidden = false
|
this.hidden = false
|
||||||
}
|
}
|
||||||
} else if (scrollingDown) {
|
|
||||||
this.amountScrolled += scrollAmount
|
|
||||||
if (this.amountScrolled > 100 && !this.hidden) {
|
|
||||||
this.hidden = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.oldScrollPos = window.scrollY
|
this.oldScrollPos = window.scrollY
|
||||||
this.scrollingDown = scrollingDown
|
}, 100, { leading: true, trailing: false }),
|
||||||
}, 100)
|
|
||||||
|
handleScrollEnd: debounce(function () {
|
||||||
|
this.hidden = false
|
||||||
|
this.oldScrollPos = window.scrollY
|
||||||
|
}, 100, { leading: false, trailing: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="currentUser">
|
<div v-if="currentUser">
|
||||||
<div
|
<div
|
||||||
class="post-form-modal-view modal-view"
|
|
||||||
v-show="postFormOpen"
|
v-show="postFormOpen"
|
||||||
|
class="post-form-modal-view modal-view"
|
||||||
@click="closePostForm"
|
@click="closePostForm"
|
||||||
>
|
>
|
||||||
<div class="post-form-modal-panel panel" @click.stop="">
|
<div
|
||||||
<div class="panel-heading">{{$t('post_status.new_status')}}</div>
|
class="post-form-modal-panel panel"
|
||||||
<PostStatusForm class="panel-body" @posted="closePostForm"/>
|
@click.stop=""
|
||||||
|
>
|
||||||
|
<div class="panel-heading">
|
||||||
|
{{ $t('post_status.new_status') }}
|
||||||
|
</div>
|
||||||
|
<PostStatusForm
|
||||||
|
class="panel-body"
|
||||||
|
@posted="closePostForm"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
@ -17,7 +25,7 @@
|
||||||
>
|
>
|
||||||
<i class="icon-edit" />
|
<i class="icon-edit" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./mobile_post_status_modal.js"></script>
|
<script src="./mobile_post_status_modal.js"></script>
|
||||||
|
|
101
src/components/moderation_tools/moderation_tools.js
Normal file
101
src/components/moderation_tools/moderation_tools.js
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
import DialogModal from '../dialog_modal/dialog_modal.vue'
|
||||||
|
|
||||||
|
const FORCE_NSFW = 'mrf_tag:media-force-nsfw'
|
||||||
|
const STRIP_MEDIA = 'mrf_tag:media-strip'
|
||||||
|
const FORCE_UNLISTED = 'mrf_tag:force-unlisted'
|
||||||
|
const DISABLE_REMOTE_SUBSCRIPTION = 'mrf_tag:disable-remote-subscription'
|
||||||
|
const DISABLE_ANY_SUBSCRIPTION = 'mrf_tag:disable-any-subscription'
|
||||||
|
const SANDBOX = 'mrf_tag:sandbox'
|
||||||
|
const QUARANTINE = 'mrf_tag:quarantine'
|
||||||
|
|
||||||
|
const ModerationTools = {
|
||||||
|
props: [
|
||||||
|
'user'
|
||||||
|
],
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
showDropDown: false,
|
||||||
|
tags: {
|
||||||
|
FORCE_NSFW,
|
||||||
|
STRIP_MEDIA,
|
||||||
|
FORCE_UNLISTED,
|
||||||
|
DISABLE_REMOTE_SUBSCRIPTION,
|
||||||
|
DISABLE_ANY_SUBSCRIPTION,
|
||||||
|
SANDBOX,
|
||||||
|
QUARANTINE
|
||||||
|
},
|
||||||
|
showDeleteUserDialog: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
DialogModal
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
tagsSet () {
|
||||||
|
return new Set(this.user.tags)
|
||||||
|
},
|
||||||
|
hasTagPolicy () {
|
||||||
|
return this.$store.state.instance.tagPolicyAvailable
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
hasTag (tagName) {
|
||||||
|
return this.tagsSet.has(tagName)
|
||||||
|
},
|
||||||
|
toggleTag (tag) {
|
||||||
|
const store = this.$store
|
||||||
|
if (this.tagsSet.has(tag)) {
|
||||||
|
store.state.api.backendInteractor.untagUser(this.user, tag).then(response => {
|
||||||
|
if (!response.ok) { return }
|
||||||
|
store.commit('untagUser', { user: this.user, tag })
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
store.state.api.backendInteractor.tagUser(this.user, tag).then(response => {
|
||||||
|
if (!response.ok) { return }
|
||||||
|
store.commit('tagUser', { user: this.user, tag })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleRight (right) {
|
||||||
|
const store = this.$store
|
||||||
|
if (this.user.rights[right]) {
|
||||||
|
store.state.api.backendInteractor.deleteRight(this.user, right).then(response => {
|
||||||
|
if (!response.ok) { return }
|
||||||
|
store.commit('updateRight', { user: this.user, right: right, value: false })
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
store.state.api.backendInteractor.addRight(this.user, right).then(response => {
|
||||||
|
if (!response.ok) { return }
|
||||||
|
store.commit('updateRight', { user: this.user, right: right, value: true })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleActivationStatus () {
|
||||||
|
const store = this.$store
|
||||||
|
const status = !!this.user.deactivated
|
||||||
|
store.state.api.backendInteractor.setActivationStatus(this.user, status).then(response => {
|
||||||
|
if (!response.ok) { return }
|
||||||
|
store.commit('updateActivationStatus', { user: this.user, status: status })
|
||||||
|
})
|
||||||
|
},
|
||||||
|
deleteUserDialog (show) {
|
||||||
|
this.showDeleteUserDialog = show
|
||||||
|
},
|
||||||
|
deleteUser () {
|
||||||
|
const store = this.$store
|
||||||
|
const user = this.user
|
||||||
|
const { id, name } = user
|
||||||
|
store.state.api.backendInteractor.deleteUser(user)
|
||||||
|
.then(e => {
|
||||||
|
this.$store.dispatch('markStatusesAsDeleted', status => user.id === status.user.id)
|
||||||
|
const isProfile = this.$route.name === 'external-user-profile' || this.$route.name === 'user-profile'
|
||||||
|
const isTargetUser = this.$route.params.name === name || this.$route.params.id === id
|
||||||
|
if (isProfile && isTargetUser) {
|
||||||
|
window.history.back()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ModerationTools
|
193
src/components/moderation_tools/moderation_tools.vue
Normal file
193
src/components/moderation_tools/moderation_tools.vue
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<v-popover
|
||||||
|
trigger="click"
|
||||||
|
class="moderation-tools-popover"
|
||||||
|
:container="false"
|
||||||
|
placement="bottom-end"
|
||||||
|
:offset="5"
|
||||||
|
@show="showDropDown = true"
|
||||||
|
@hide="showDropDown = false"
|
||||||
|
>
|
||||||
|
<div slot="popover">
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<span v-if="user.is_local">
|
||||||
|
<button
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleRight("admin")"
|
||||||
|
>
|
||||||
|
{{ $t(!!user.rights.admin ? 'user_card.admin_menu.revoke_admin' : 'user_card.admin_menu.grant_admin') }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleRight("moderator")"
|
||||||
|
>
|
||||||
|
{{ $t(!!user.rights.moderator ? 'user_card.admin_menu.revoke_moderator' : 'user_card.admin_menu.grant_moderator') }}
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
role="separator"
|
||||||
|
class="dropdown-divider"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleActivationStatus()"
|
||||||
|
>
|
||||||
|
{{ $t(!!user.deactivated ? 'user_card.admin_menu.activate_account' : 'user_card.admin_menu.deactivate_account') }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="deleteUserDialog(true)"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.delete_account') }}
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
v-if="hasTagPolicy"
|
||||||
|
role="separator"
|
||||||
|
class="dropdown-divider"
|
||||||
|
/>
|
||||||
|
<span v-if="hasTagPolicy">
|
||||||
|
<button
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleTag(tags.FORCE_NSFW)"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.force_nsfw') }}
|
||||||
|
<span
|
||||||
|
class="menu-checkbox"
|
||||||
|
:class="{ 'menu-checkbox-checked': hasTag(tags.FORCE_NSFW) }"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleTag(tags.STRIP_MEDIA)"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.strip_media') }}
|
||||||
|
<span
|
||||||
|
class="menu-checkbox"
|
||||||
|
:class="{ 'menu-checkbox-checked': hasTag(tags.STRIP_MEDIA) }"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleTag(tags.FORCE_UNLISTED)"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.force_unlisted') }}
|
||||||
|
<span
|
||||||
|
class="menu-checkbox"
|
||||||
|
:class="{ 'menu-checkbox-checked': hasTag(tags.FORCE_UNLISTED) }"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleTag(tags.SANDBOX)"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.sandbox') }}
|
||||||
|
<span
|
||||||
|
class="menu-checkbox"
|
||||||
|
:class="{ 'menu-checkbox-checked': hasTag(tags.SANDBOX) }"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="user.is_local"
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleTag(tags.DISABLE_REMOTE_SUBSCRIPTION)"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.disable_remote_subscription') }}
|
||||||
|
<span
|
||||||
|
class="menu-checkbox"
|
||||||
|
:class="{ 'menu-checkbox-checked': hasTag(tags.DISABLE_REMOTE_SUBSCRIPTION) }"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="user.is_local"
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleTag(tags.DISABLE_ANY_SUBSCRIPTION)"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.disable_any_subscription') }}
|
||||||
|
<span
|
||||||
|
class="menu-checkbox"
|
||||||
|
:class="{ 'menu-checkbox-checked': hasTag(tags.DISABLE_ANY_SUBSCRIPTION) }"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="user.is_local"
|
||||||
|
class="dropdown-item"
|
||||||
|
@click="toggleTag(tags.QUARANTINE)"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.quarantine') }}
|
||||||
|
<span
|
||||||
|
class="menu-checkbox"
|
||||||
|
:class="{ 'menu-checkbox-checked': hasTag(tags.QUARANTINE) }"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
class="btn btn-default btn-block"
|
||||||
|
:class="{ pressed: showDropDown }"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.moderation') }}
|
||||||
|
</button>
|
||||||
|
</v-popover>
|
||||||
|
<portal to="modal">
|
||||||
|
<DialogModal
|
||||||
|
v-if="showDeleteUserDialog"
|
||||||
|
:on-cancel="deleteUserDialog.bind(this, false)"
|
||||||
|
>
|
||||||
|
<template slot="header">
|
||||||
|
{{ $t('user_card.admin_menu.delete_user') }}
|
||||||
|
</template>
|
||||||
|
<p>{{ $t('user_card.admin_menu.delete_user_confirmation') }}</p>
|
||||||
|
<template slot="footer">
|
||||||
|
<button
|
||||||
|
class="btn btn-default"
|
||||||
|
@click="deleteUserDialog(false)"
|
||||||
|
>
|
||||||
|
{{ $t('general.cancel') }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn btn-default danger"
|
||||||
|
@click="deleteUser()"
|
||||||
|
>
|
||||||
|
{{ $t('user_card.admin_menu.delete_user') }}
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</DialogModal>
|
||||||
|
</portal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./moderation_tools.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
@import '../popper/popper.scss';
|
||||||
|
|
||||||
|
.menu-checkbox {
|
||||||
|
float: right;
|
||||||
|
min-width: 22px;
|
||||||
|
max-width: 22px;
|
||||||
|
min-height: 22px;
|
||||||
|
max-height: 22px;
|
||||||
|
line-height: 22px;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 0px;
|
||||||
|
background-color: $fallback--fg;
|
||||||
|
background-color: var(--input, $fallback--fg);
|
||||||
|
box-shadow: 0px 0px 2px black inset;
|
||||||
|
box-shadow: var(--inputShadow);
|
||||||
|
|
||||||
|
&.menu-checkbox-checked::after {
|
||||||
|
content: '✔';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.moderation-tools-popover {
|
||||||
|
height: 100%;
|
||||||
|
.trigger {
|
||||||
|
display: flex !important;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,7 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<basic-user-card :user="user">
|
<basic-user-card :user="user">
|
||||||
<div class="mute-card-content-container">
|
<div class="mute-card-content-container">
|
||||||
<button class="btn btn-default" @click="unmuteUser" :disabled="progress" v-if="muted">
|
<button
|
||||||
|
v-if="muted"
|
||||||
|
class="btn btn-default"
|
||||||
|
:disabled="progress"
|
||||||
|
@click="unmuteUser"
|
||||||
|
>
|
||||||
<template v-if="progress">
|
<template v-if="progress">
|
||||||
{{ $t('user_card.unmute_progress') }}
|
{{ $t('user_card.unmute_progress') }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -9,7 +14,12 @@
|
||||||
{{ $t('user_card.unmute') }}
|
{{ $t('user_card.unmute') }}
|
||||||
</template>
|
</template>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-default" @click="muteUser" :disabled="progress" v-else>
|
<button
|
||||||
|
v-else
|
||||||
|
class="btn btn-default"
|
||||||
|
:disabled="progress"
|
||||||
|
@click="muteUser"
|
||||||
|
>
|
||||||
<template v-if="progress">
|
<template v-if="progress">
|
||||||
{{ $t('user_card.mute_progress') }}
|
{{ $t('user_card.mute_progress') }}
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -2,26 +2,29 @@
|
||||||
<div class="nav-panel">
|
<div class="nav-panel">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-if='currentUser'>
|
<li v-if="currentUser">
|
||||||
<router-link :to="{ name: 'friends' }">
|
<router-link :to="{ name: 'friends' }">
|
||||||
{{ $t("nav.timeline") }}
|
{{ $t("nav.timeline") }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</li>
|
</li>
|
||||||
<li v-if='currentUser'>
|
<li v-if="currentUser">
|
||||||
<router-link :to="{ name: 'mentions', params: { username: currentUser.screen_name } }">
|
<router-link :to="{ name: 'interactions', params: { username: currentUser.screen_name } }">
|
||||||
{{ $t("nav.mentions") }}
|
{{ $t("nav.interactions") }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</li>
|
</li>
|
||||||
<li v-if='currentUser'>
|
<li v-if="currentUser">
|
||||||
<router-link :to="{ name: 'dms', params: { username: currentUser.screen_name } }">
|
<router-link :to="{ name: 'dms', params: { username: currentUser.screen_name } }">
|
||||||
{{ $t("nav.dms") }}
|
{{ $t("nav.dms") }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</li>
|
</li>
|
||||||
<li v-if='currentUser && currentUser.locked'>
|
<li v-if="currentUser && currentUser.locked">
|
||||||
<router-link :to="{ name: 'friend-requests' }">
|
<router-link :to="{ name: 'friend-requests' }">
|
||||||
{{ $t("nav.friend_requests")}}
|
{{ $t("nav.friend_requests") }}
|
||||||
<span v-if='followRequestCount > 0' class="badge follow-request-count">
|
<span
|
||||||
{{followRequestCount}}
|
v-if="followRequestCount > 0"
|
||||||
|
class="badge follow-request-count"
|
||||||
|
>
|
||||||
|
{{ followRequestCount }}
|
||||||
</span>
|
</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Status from '../status/status.vue'
|
import Status from '../status/status.vue'
|
||||||
import UserAvatar from '../user_avatar/user_avatar.vue'
|
import UserAvatar from '../user_avatar/user_avatar.vue'
|
||||||
import UserCard from '../user_card/user_card.vue'
|
import UserCard from '../user_card/user_card.vue'
|
||||||
|
import Timeago from '../timeago/timeago.vue'
|
||||||
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
|
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
|
||||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||||
|
|
||||||
|
@ -13,7 +14,10 @@ const Notification = {
|
||||||
},
|
},
|
||||||
props: [ 'notification' ],
|
props: [ 'notification' ],
|
||||||
components: {
|
components: {
|
||||||
Status, UserAvatar, UserCard
|
Status,
|
||||||
|
UserAvatar,
|
||||||
|
UserCard,
|
||||||
|
Timeago
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleUserExpanded () {
|
toggleUserExpanded () {
|
||||||
|
@ -21,25 +25,28 @@ const Notification = {
|
||||||
},
|
},
|
||||||
userProfileLink (user) {
|
userProfileLink (user) {
|
||||||
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
||||||
|
},
|
||||||
|
getUser (notification) {
|
||||||
|
return this.$store.state.users.usersObject[notification.from_profile.id]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
userClass () {
|
userClass () {
|
||||||
return highlightClass(this.notification.action.user)
|
return highlightClass(this.notification.from_profile)
|
||||||
},
|
},
|
||||||
userStyle () {
|
userStyle () {
|
||||||
const highlight = this.$store.state.config.highlight
|
const highlight = this.$store.state.config.highlight
|
||||||
const user = this.notification.action.user
|
const user = this.notification.from_profile
|
||||||
return highlightStyle(highlight[user.screen_name])
|
return highlightStyle(highlight[user.screen_name])
|
||||||
},
|
},
|
||||||
userInStore () {
|
userInStore () {
|
||||||
return this.$store.getters.findUser(this.notification.action.user.id)
|
return this.$store.getters.findUser(this.notification.from_profile.id)
|
||||||
},
|
},
|
||||||
user () {
|
user () {
|
||||||
if (this.userInStore) {
|
if (this.userInStore) {
|
||||||
return this.userInStore
|
return this.userInStore
|
||||||
}
|
}
|
||||||
return {}
|
return this.notification.from_profile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,106 @@
|
||||||
<template>
|
<template>
|
||||||
<status v-if="notification.type === 'mention'" :compact="true" :statusoid="notification.status"></status>
|
<status
|
||||||
<div class="non-mention" :class="[userClass, { highlighted: userStyle }]" :style="[ userStyle ]" v-else>
|
v-if="notification.type === 'mention'"
|
||||||
<a class='avatar-container' :href="notification.action.user.statusnet_profile_url" @click.stop.prevent.capture="toggleUserExpanded">
|
:compact="true"
|
||||||
<UserAvatar :compact="true" :betterShadow="betterShadow" :src="notification.action.user.profile_image_url_original"/>
|
:statusoid="notification.status"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="non-mention"
|
||||||
|
:class="[userClass, { highlighted: userStyle }]"
|
||||||
|
:style="[ userStyle ]"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
class="avatar-container"
|
||||||
|
:href="notification.from_profile.statusnet_profile_url"
|
||||||
|
@click.stop.prevent.capture="toggleUserExpanded"
|
||||||
|
>
|
||||||
|
<UserAvatar
|
||||||
|
:compact="true"
|
||||||
|
:better-shadow="betterShadow"
|
||||||
|
:user="notification.from_profile"
|
||||||
|
/>
|
||||||
</a>
|
</a>
|
||||||
<div class='notification-right'>
|
<div class="notification-right">
|
||||||
<UserCard :user="user" :rounded="true" :bordered="true" v-if="userExpanded"/>
|
<UserCard
|
||||||
|
v-if="userExpanded"
|
||||||
|
:user="getUser(notification)"
|
||||||
|
:rounded="true"
|
||||||
|
:bordered="true"
|
||||||
|
/>
|
||||||
<span class="notification-details">
|
<span class="notification-details">
|
||||||
<div class="name-and-action">
|
<div class="name-and-action">
|
||||||
<span class="username" v-if="!!notification.action.user.name_html" :title="'@'+notification.action.user.screen_name" v-html="notification.action.user.name_html"></span>
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
<span class="username" v-else :title="'@'+notification.action.user.screen_name">{{ notification.action.user.name }}</span>
|
<span
|
||||||
|
v-if="!!notification.from_profile.name_html"
|
||||||
|
class="username"
|
||||||
|
:title="'@'+notification.from_profile.screen_name"
|
||||||
|
v-html="notification.from_profile.name_html"
|
||||||
|
/>
|
||||||
|
<!-- eslint-enable vue/no-v-html -->
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="username"
|
||||||
|
:title="'@'+notification.from_profile.screen_name"
|
||||||
|
>{{ notification.from_profile.name }}</span>
|
||||||
<span v-if="notification.type === 'like'">
|
<span v-if="notification.type === 'like'">
|
||||||
<i class="fa icon-star lit"></i>
|
<i class="fa icon-star lit" />
|
||||||
<small>{{$t('notifications.favorited_you')}}</small>
|
<small>{{ $t('notifications.favorited_you') }}</small>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="notification.type === 'repeat'">
|
<span v-if="notification.type === 'repeat'">
|
||||||
<i class="fa icon-retweet lit" :title="$t('tool_tip.repeat')"></i>
|
<i
|
||||||
<small>{{$t('notifications.repeated_you')}}</small>
|
class="fa icon-retweet lit"
|
||||||
|
:title="$t('tool_tip.repeat')"
|
||||||
|
/>
|
||||||
|
<small>{{ $t('notifications.repeated_you') }}</small>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="notification.type === 'follow'">
|
<span v-if="notification.type === 'follow'">
|
||||||
<i class="fa icon-user-plus lit"></i>
|
<i class="fa icon-user-plus lit" />
|
||||||
<small>{{$t('notifications.followed_you')}}</small>
|
<small>{{ $t('notifications.followed_you') }}</small>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="timeago">
|
<div
|
||||||
<router-link v-if="notification.status" :to="{ name: 'conversation', params: { id: notification.status.id } }" class="faint-link">
|
v-if="notification.type === 'follow'"
|
||||||
<timeago :since="notification.action.created_at" :auto-update="240"></timeago>
|
class="timeago"
|
||||||
|
>
|
||||||
|
<span class="faint">
|
||||||
|
<Timeago
|
||||||
|
:time="notification.created_at"
|
||||||
|
:auto-update="240"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="timeago"
|
||||||
|
>
|
||||||
|
<router-link
|
||||||
|
v-if="notification.status"
|
||||||
|
:to="{ name: 'conversation', params: { id: notification.status.id } }"
|
||||||
|
class="faint-link"
|
||||||
|
>
|
||||||
|
<Timeago
|
||||||
|
:time="notification.created_at"
|
||||||
|
:auto-update="240"
|
||||||
|
/>
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
<div class="follow-text" v-if="notification.type === 'follow'">
|
<div
|
||||||
<router-link :to="userProfileLink(notification.action.user)">
|
v-if="notification.type === 'follow'"
|
||||||
@{{notification.action.user.screen_name}}
|
class="follow-text"
|
||||||
|
>
|
||||||
|
<router-link :to="userProfileLink(notification.from_profile)">
|
||||||
|
@{{ notification.from_profile.screen_name }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<status class="faint" :compact="true" :statusoid="notification.status" :noHeading="true"></status>
|
<status
|
||||||
|
class="faint"
|
||||||
|
:compact="true"
|
||||||
|
:statusoid="notification.action"
|
||||||
|
:no-heading="true"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,15 +7,14 @@ import {
|
||||||
} from '../../services/notification_utils/notification_utils.js'
|
} from '../../services/notification_utils/notification_utils.js'
|
||||||
|
|
||||||
const Notifications = {
|
const Notifications = {
|
||||||
props: [
|
props: {
|
||||||
'noHeading'
|
// Disables display of panel header
|
||||||
],
|
noHeading: Boolean,
|
||||||
created () {
|
// Disables panel styles, unread mark, potentially other notification-related actions
|
||||||
const store = this.$store
|
// meant for "Interactions" timeline
|
||||||
const credentials = store.state.users.currentUser.credentials
|
minimalMode: Boolean,
|
||||||
|
// Custom filter mode, an array of strings, possible values 'mention', 'repeat', 'like', 'follow', used to override global filter for use in "Interactions" timeline
|
||||||
const fetcherId = notificationsFetcher.startFetching({ store, credentials })
|
filterMode: Array
|
||||||
this.$store.commit('setNotificationFetcher', { fetcherId })
|
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -23,6 +22,9 @@ const Notifications = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
mainClass () {
|
||||||
|
return this.minimalMode ? '' : 'panel panel-default'
|
||||||
|
},
|
||||||
notifications () {
|
notifications () {
|
||||||
return notificationsFromStore(this.$store)
|
return notificationsFromStore(this.$store)
|
||||||
},
|
},
|
||||||
|
@ -33,7 +35,7 @@ const Notifications = {
|
||||||
return unseenNotificationsFromStore(this.$store)
|
return unseenNotificationsFromStore(this.$store)
|
||||||
},
|
},
|
||||||
visibleNotifications () {
|
visibleNotifications () {
|
||||||
return visibleNotificationsFromStore(this.$store)
|
return visibleNotificationsFromStore(this.$store, this.filterMode)
|
||||||
},
|
},
|
||||||
unseenCount () {
|
unseenCount () {
|
||||||
return this.unseenNotifications.length
|
return this.unseenNotifications.length
|
||||||
|
@ -56,9 +58,13 @@ const Notifications = {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
markAsSeen () {
|
markAsSeen () {
|
||||||
this.$store.dispatch('markNotificationsAsSeen', this.visibleNotifications)
|
this.$store.dispatch('markNotificationsAsSeen')
|
||||||
},
|
},
|
||||||
fetchOlderNotifications () {
|
fetchOlderNotifications () {
|
||||||
|
if (this.loading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = store.state.users.currentUser.credentials
|
||||||
store.commit('setNotificationsLoading', { value: true })
|
store.commit('setNotificationsLoading', { value: true })
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
@import '../../_variables.scss';
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
.notifications {
|
.notifications {
|
||||||
|
&:not(.minimal) {
|
||||||
// a bit of a hack to allow scrolling below notifications
|
// a bit of a hack to allow scrolling below notifications
|
||||||
padding-bottom: 15em;
|
padding-bottom: 15em;
|
||||||
|
}
|
||||||
|
|
||||||
.loadmore-error {
|
.loadmore-error {
|
||||||
color: $fallback--text;
|
color: $fallback--text;
|
||||||
|
|
|
@ -1,31 +1,67 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="notifications">
|
<div
|
||||||
<div class="panel panel-default">
|
:class="{ minimal: minimalMode }"
|
||||||
<div v-if="!noHeading" class="panel-heading">
|
class="notifications"
|
||||||
|
>
|
||||||
|
<div :class="mainClass">
|
||||||
|
<div
|
||||||
|
v-if="!noHeading"
|
||||||
|
class="panel-heading"
|
||||||
|
>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
{{$t('notifications.notifications')}}
|
{{ $t('notifications.notifications') }}
|
||||||
<span class="badge badge-notification unseen-count" v-if="unseenCount">{{unseenCount}}</span>
|
<span
|
||||||
|
v-if="unseenCount"
|
||||||
|
class="badge badge-notification unseen-count"
|
||||||
|
>{{ unseenCount }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div @click.prevent class="loadmore-error alert error" v-if="error">
|
<div
|
||||||
{{$t('timeline.error_fetching')}}
|
v-if="error"
|
||||||
|
class="loadmore-error alert error"
|
||||||
|
@click.prevent
|
||||||
|
>
|
||||||
|
{{ $t('timeline.error_fetching') }}
|
||||||
</div>
|
</div>
|
||||||
<button v-if="unseenCount" @click.prevent="markAsSeen" class="read-button">{{$t('notifications.read')}}</button>
|
<button
|
||||||
|
v-if="unseenCount"
|
||||||
|
class="read-button"
|
||||||
|
@click.prevent="markAsSeen"
|
||||||
|
>
|
||||||
|
{{ $t('notifications.read') }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div v-for="notification in visibleNotifications" :key="notification.action.id" class="notification" :class='{"unseen": !notification.seen}'>
|
<div
|
||||||
<div class="notification-overlay"></div>
|
v-for="notification in visibleNotifications"
|
||||||
<notification :notification="notification"></notification>
|
:key="notification.id"
|
||||||
|
class="notification"
|
||||||
|
:class="{"unseen": !minimalMode && !notification.seen}"
|
||||||
|
>
|
||||||
|
<div class="notification-overlay" />
|
||||||
|
<notification :notification="notification" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<div v-if="bottomedOut" class="new-status-notification text-center panel-footer faint">
|
<div
|
||||||
{{$t('notifications.no_more_notifications')}}
|
v-if="bottomedOut"
|
||||||
|
class="new-status-notification text-center panel-footer faint"
|
||||||
|
>
|
||||||
|
{{ $t('notifications.no_more_notifications') }}
|
||||||
|
</div>
|
||||||
|
<a
|
||||||
|
v-else-if="!loading"
|
||||||
|
href="#"
|
||||||
|
@click.prevent="fetchOlderNotifications()"
|
||||||
|
>
|
||||||
|
<div class="new-status-notification text-center panel-footer">
|
||||||
|
{{ minimalMode ? $t('interactions.load_older') : $t('notifications.load_older') }}
|
||||||
</div>
|
</div>
|
||||||
<a v-else-if="!loading" href="#" v-on:click.prevent="fetchOlderNotifications()">
|
|
||||||
<div class="new-status-notification text-center panel-footer">{{$t('notifications.load_older')}}</div>
|
|
||||||
</a>
|
</a>
|
||||||
<div v-else class="new-status-notification text-center panel-footer">
|
<div
|
||||||
<i class="icon-spin3 animate-spin"/>
|
v-else
|
||||||
|
class="new-status-notification text-center panel-footer"
|
||||||
|
>
|
||||||
|
<i class="icon-spin3 animate-spin" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,14 +4,17 @@ const oac = {
|
||||||
props: ['code'],
|
props: ['code'],
|
||||||
mounted () {
|
mounted () {
|
||||||
if (this.code) {
|
if (this.code) {
|
||||||
|
const { clientId, clientSecret } = this.$store.state.oauth
|
||||||
|
|
||||||
oauth.getToken({
|
oauth.getToken({
|
||||||
app: this.$store.state.oauth,
|
clientId,
|
||||||
|
clientSecret,
|
||||||
instance: this.$store.state.instance.server,
|
instance: this.$store.state.instance.server,
|
||||||
code: this.code
|
code: this.code
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
this.$store.commit('setToken', result.access_token)
|
this.$store.commit('setToken', result.access_token)
|
||||||
this.$store.dispatch('loginUser', result.access_token)
|
this.$store.dispatch('loginUser', result.access_token)
|
||||||
this.$router.push({name: 'friends'})
|
this.$router.push({ name: 'friends' })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,39 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="opacity-control style-control" :class="{ disabled: !present || disabled }">
|
<div
|
||||||
<label :for="name" class="label">
|
class="opacity-control style-control"
|
||||||
{{$t('settings.style.common.opacity')}}
|
:class="{ disabled: !present || disabled }"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
:for="name"
|
||||||
|
class="label"
|
||||||
|
>
|
||||||
|
{{ $t('settings.style.common.opacity') }}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
v-if="typeof fallback !== 'undefined'"
|
v-if="typeof fallback !== 'undefined'"
|
||||||
class="opt exclude-disabled"
|
|
||||||
:id="name + '-o'"
|
:id="name + '-o'"
|
||||||
|
class="opt exclude-disabled"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
:checked="present"
|
:checked="present"
|
||||||
@input="$emit('input', !present ? fallback : undefined)">
|
@input="$emit('input', !present ? fallback : undefined)"
|
||||||
<label v-if="typeof fallback !== 'undefined'" class="opt-l" :for="name + '-o'"></label>
|
>
|
||||||
|
<label
|
||||||
|
v-if="typeof fallback !== 'undefined'"
|
||||||
|
class="opt-l"
|
||||||
|
:for="name + '-o'"
|
||||||
|
/>
|
||||||
<input
|
<input
|
||||||
:id="name"
|
:id="name"
|
||||||
class="input-number"
|
class="input-number"
|
||||||
type="number"
|
type="number"
|
||||||
:value="value || fallback"
|
:value="value || fallback"
|
||||||
:disabled="!present || disabled"
|
:disabled="!present || disabled"
|
||||||
@input="$emit('input', $event.target.value)"
|
|
||||||
max="1"
|
max="1"
|
||||||
min="0"
|
min="0"
|
||||||
step=".05">
|
step=".05"
|
||||||
</div>
|
@input="$emit('input', $event.target.value)"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
112
src/components/poll/poll.js
Normal file
112
src/components/poll/poll.js
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
import Timeago from '../timeago/timeago.vue'
|
||||||
|
import { forEach, map } from 'lodash'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Poll',
|
||||||
|
props: ['basePoll'],
|
||||||
|
components: { Timeago },
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
choices: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
if (!this.$store.state.polls.pollsObject[this.pollId]) {
|
||||||
|
this.$store.dispatch('mergeOrAddPoll', this.basePoll)
|
||||||
|
}
|
||||||
|
this.$store.dispatch('trackPoll', this.pollId)
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
this.$store.dispatch('untrackPoll', this.pollId)
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
pollId () {
|
||||||
|
return this.basePoll.id
|
||||||
|
},
|
||||||
|
poll () {
|
||||||
|
const storePoll = this.$store.state.polls.pollsObject[this.pollId]
|
||||||
|
return storePoll || {}
|
||||||
|
},
|
||||||
|
options () {
|
||||||
|
return (this.poll && this.poll.options) || []
|
||||||
|
},
|
||||||
|
expiresAt () {
|
||||||
|
return (this.poll && this.poll.expires_at) || 0
|
||||||
|
},
|
||||||
|
expired () {
|
||||||
|
return (this.poll && this.poll.expired) || false
|
||||||
|
},
|
||||||
|
loggedIn () {
|
||||||
|
return this.$store.state.users.currentUser
|
||||||
|
},
|
||||||
|
showResults () {
|
||||||
|
return this.poll.voted || this.expired || !this.loggedIn
|
||||||
|
},
|
||||||
|
totalVotesCount () {
|
||||||
|
return this.poll.votes_count
|
||||||
|
},
|
||||||
|
containerClass () {
|
||||||
|
return {
|
||||||
|
loading: this.loading
|
||||||
|
}
|
||||||
|
},
|
||||||
|
choiceIndices () {
|
||||||
|
// Convert array of booleans into an array of indices of the
|
||||||
|
// items that were 'true', so [true, false, false, true] becomes
|
||||||
|
// [0, 3].
|
||||||
|
return this.choices
|
||||||
|
.map((entry, index) => entry && index)
|
||||||
|
.filter(value => typeof value === 'number')
|
||||||
|
},
|
||||||
|
isDisabled () {
|
||||||
|
const noChoice = this.choiceIndices.length === 0
|
||||||
|
return this.loading || noChoice
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
percentageForOption (count) {
|
||||||
|
return this.totalVotesCount === 0 ? 0 : Math.round(count / this.totalVotesCount * 100)
|
||||||
|
},
|
||||||
|
resultTitle (option) {
|
||||||
|
return `${option.votes_count}/${this.totalVotesCount} ${this.$t('polls.votes')}`
|
||||||
|
},
|
||||||
|
fetchPoll () {
|
||||||
|
this.$store.dispatch('refreshPoll', { id: this.statusId, pollId: this.poll.id })
|
||||||
|
},
|
||||||
|
activateOption (index) {
|
||||||
|
// forgive me father: doing checking the radio/checkboxes
|
||||||
|
// in code because of customized input elements need either
|
||||||
|
// a) an extra element for the actual graphic, or b) use a
|
||||||
|
// pseudo element for the label. We use b) which mandates
|
||||||
|
// using "for" and "id" matching which isn't nice when the
|
||||||
|
// same poll appears multiple times on the site (notifs and
|
||||||
|
// timeline for example). With code we can make sure it just
|
||||||
|
// works without altering the pseudo element implementation.
|
||||||
|
const allElements = this.$el.querySelectorAll('input')
|
||||||
|
const clickedElement = this.$el.querySelector(`input[value="${index}"]`)
|
||||||
|
if (this.poll.multiple) {
|
||||||
|
// Checkboxes, toggle only the clicked one
|
||||||
|
clickedElement.checked = !clickedElement.checked
|
||||||
|
} else {
|
||||||
|
// Radio button, uncheck everything and check the clicked one
|
||||||
|
forEach(allElements, element => { element.checked = false })
|
||||||
|
clickedElement.checked = true
|
||||||
|
}
|
||||||
|
this.choices = map(allElements, e => e.checked)
|
||||||
|
},
|
||||||
|
optionId (index) {
|
||||||
|
return `poll${this.poll.id}-${index}`
|
||||||
|
},
|
||||||
|
vote () {
|
||||||
|
if (this.choiceIndices.length === 0) return
|
||||||
|
this.loading = true
|
||||||
|
this.$store.dispatch(
|
||||||
|
'votePoll',
|
||||||
|
{ id: this.statusId, pollId: this.poll.id, choices: this.choiceIndices }
|
||||||
|
).then(poll => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
134
src/components/poll/poll.vue
Normal file
134
src/components/poll/poll.vue
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="poll"
|
||||||
|
:class="containerClass"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(option, index) in options"
|
||||||
|
:key="index"
|
||||||
|
class="poll-option"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="showResults"
|
||||||
|
:title="resultTitle(option)"
|
||||||
|
class="option-result"
|
||||||
|
>
|
||||||
|
<div class="option-result-label">
|
||||||
|
<span class="result-percentage">
|
||||||
|
{{ percentageForOption(option.votes_count) }}%
|
||||||
|
</span>
|
||||||
|
<span>{{ option.title }}</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="result-fill"
|
||||||
|
:style="{ 'width': `${percentageForOption(option.votes_count)}%` }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
@click="activateOption(index)"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-if="poll.multiple"
|
||||||
|
type="checkbox"
|
||||||
|
:disabled="loading"
|
||||||
|
:value="index"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-else
|
||||||
|
type="radio"
|
||||||
|
:disabled="loading"
|
||||||
|
:value="index"
|
||||||
|
>
|
||||||
|
<label class="option-vote">
|
||||||
|
<div>{{ option.title }}</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="footer faint">
|
||||||
|
<button
|
||||||
|
v-if="!showResults"
|
||||||
|
class="btn btn-default poll-vote-button"
|
||||||
|
type="button"
|
||||||
|
:disabled="isDisabled"
|
||||||
|
@click="vote"
|
||||||
|
>
|
||||||
|
{{ $t('polls.vote') }}
|
||||||
|
</button>
|
||||||
|
<div class="total">
|
||||||
|
{{ totalVotesCount }} {{ $t("polls.votes") }} ·
|
||||||
|
</div>
|
||||||
|
<i18n :path="expired ? 'polls.expired' : 'polls.expires_in'">
|
||||||
|
<Timeago
|
||||||
|
:time="expiresAt"
|
||||||
|
:auto-update="60"
|
||||||
|
:now-threshold="0"
|
||||||
|
/>
|
||||||
|
</i18n>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./poll.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.poll {
|
||||||
|
.votes {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 0 0 0.5em;
|
||||||
|
}
|
||||||
|
.poll-option {
|
||||||
|
margin: 0.75em 0.5em;
|
||||||
|
}
|
||||||
|
.option-result {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
position: relative;
|
||||||
|
color: $fallback--lightText;
|
||||||
|
color: var(--lightText, $fallback--lightText);
|
||||||
|
}
|
||||||
|
.option-result-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0.1em 0.25em;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
.result-percentage {
|
||||||
|
width: 3.5em;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.result-fill {
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
background-color: $fallback--lightBg;
|
||||||
|
background-color: var(--linkBg, $fallback--lightBg);
|
||||||
|
border-radius: $fallback--panelRadius;
|
||||||
|
border-radius: var(--panelRadius, $fallback--panelRadius);
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
transition: width 0.5s;
|
||||||
|
}
|
||||||
|
.option-vote {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
input {
|
||||||
|
width: 3.5em;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
&.loading * {
|
||||||
|
cursor: progress;
|
||||||
|
}
|
||||||
|
.poll-vote-button {
|
||||||
|
padding: 0 0.5em;
|
||||||
|
margin-right: 0.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
121
src/components/poll/poll_form.js
Normal file
121
src/components/poll/poll_form.js
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
import * as DateUtils from 'src/services/date_utils/date_utils.js'
|
||||||
|
import { uniq } from 'lodash'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'PollForm',
|
||||||
|
props: ['visible'],
|
||||||
|
data: () => ({
|
||||||
|
pollType: 'single',
|
||||||
|
options: ['', ''],
|
||||||
|
expiryAmount: 10,
|
||||||
|
expiryUnit: 'minutes'
|
||||||
|
}),
|
||||||
|
computed: {
|
||||||
|
pollLimits () {
|
||||||
|
return this.$store.state.instance.pollLimits
|
||||||
|
},
|
||||||
|
maxOptions () {
|
||||||
|
return this.pollLimits.max_options
|
||||||
|
},
|
||||||
|
maxLength () {
|
||||||
|
return this.pollLimits.max_option_chars
|
||||||
|
},
|
||||||
|
expiryUnits () {
|
||||||
|
const allUnits = ['minutes', 'hours', 'days']
|
||||||
|
const expiry = this.convertExpiryFromUnit
|
||||||
|
return allUnits.filter(
|
||||||
|
unit => this.pollLimits.max_expiration >= expiry(unit, 1)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
minExpirationInCurrentUnit () {
|
||||||
|
return Math.ceil(
|
||||||
|
this.convertExpiryToUnit(
|
||||||
|
this.expiryUnit,
|
||||||
|
this.pollLimits.min_expiration
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
maxExpirationInCurrentUnit () {
|
||||||
|
return Math.floor(
|
||||||
|
this.convertExpiryToUnit(
|
||||||
|
this.expiryUnit,
|
||||||
|
this.pollLimits.max_expiration
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
clear () {
|
||||||
|
this.pollType = 'single'
|
||||||
|
this.options = ['', '']
|
||||||
|
this.expiryAmount = 10
|
||||||
|
this.expiryUnit = 'minutes'
|
||||||
|
},
|
||||||
|
nextOption (index) {
|
||||||
|
const element = this.$el.querySelector(`#poll-${index + 1}`)
|
||||||
|
if (element) {
|
||||||
|
element.focus()
|
||||||
|
} else {
|
||||||
|
// Try adding an option and try focusing on it
|
||||||
|
const addedOption = this.addOption()
|
||||||
|
if (addedOption) {
|
||||||
|
this.$nextTick(function () {
|
||||||
|
this.nextOption(index)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
addOption () {
|
||||||
|
if (this.options.length < this.maxOptions) {
|
||||||
|
this.options.push('')
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
deleteOption (index, event) {
|
||||||
|
if (this.options.length > 2) {
|
||||||
|
this.options.splice(index, 1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
convertExpiryToUnit (unit, amount) {
|
||||||
|
// Note: we want seconds and not milliseconds
|
||||||
|
switch (unit) {
|
||||||
|
case 'minutes': return (1000 * amount) / DateUtils.MINUTE
|
||||||
|
case 'hours': return (1000 * amount) / DateUtils.HOUR
|
||||||
|
case 'days': return (1000 * amount) / DateUtils.DAY
|
||||||
|
}
|
||||||
|
},
|
||||||
|
convertExpiryFromUnit (unit, amount) {
|
||||||
|
// Note: we want seconds and not milliseconds
|
||||||
|
switch (unit) {
|
||||||
|
case 'minutes': return 0.001 * amount * DateUtils.MINUTE
|
||||||
|
case 'hours': return 0.001 * amount * DateUtils.HOUR
|
||||||
|
case 'days': return 0.001 * amount * DateUtils.DAY
|
||||||
|
}
|
||||||
|
},
|
||||||
|
expiryAmountChange () {
|
||||||
|
this.expiryAmount =
|
||||||
|
Math.max(this.minExpirationInCurrentUnit, this.expiryAmount)
|
||||||
|
this.expiryAmount =
|
||||||
|
Math.min(this.maxExpirationInCurrentUnit, this.expiryAmount)
|
||||||
|
this.updatePollToParent()
|
||||||
|
},
|
||||||
|
updatePollToParent () {
|
||||||
|
const expiresIn = this.convertExpiryFromUnit(
|
||||||
|
this.expiryUnit,
|
||||||
|
this.expiryAmount
|
||||||
|
)
|
||||||
|
|
||||||
|
const options = uniq(this.options.filter(option => option !== ''))
|
||||||
|
if (options.length < 2) {
|
||||||
|
this.$emit('update-poll', { error: this.$t('polls.not_enough_options') })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$emit('update-poll', {
|
||||||
|
options,
|
||||||
|
multiple: this.pollType === 'multiple',
|
||||||
|
expiresIn
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
163
src/components/poll/poll_form.vue
Normal file
163
src/components/poll/poll_form.vue
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="visible"
|
||||||
|
class="poll-form"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(option, index) in options"
|
||||||
|
:key="index"
|
||||||
|
class="poll-option"
|
||||||
|
>
|
||||||
|
<div class="input-container">
|
||||||
|
<input
|
||||||
|
:id="`poll-${index}`"
|
||||||
|
v-model="options[index]"
|
||||||
|
class="poll-option-input"
|
||||||
|
type="text"
|
||||||
|
:placeholder="$t('polls.option')"
|
||||||
|
:maxlength="maxLength"
|
||||||
|
@change="updatePollToParent"
|
||||||
|
@keydown.enter.stop.prevent="nextOption(index)"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="options.length > 2"
|
||||||
|
class="icon-container"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
class="icon-cancel"
|
||||||
|
@click="deleteOption(index)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a
|
||||||
|
v-if="options.length < maxOptions"
|
||||||
|
class="add-option faint"
|
||||||
|
@click="addOption"
|
||||||
|
>
|
||||||
|
<i class="icon-plus" />
|
||||||
|
{{ $t("polls.add_option") }}
|
||||||
|
</a>
|
||||||
|
<div class="poll-type-expiry">
|
||||||
|
<div
|
||||||
|
class="poll-type"
|
||||||
|
:title="$t('polls.type')"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
for="poll-type-selector"
|
||||||
|
class="select"
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
v-model="pollType"
|
||||||
|
class="select"
|
||||||
|
@change="updatePollToParent"
|
||||||
|
>
|
||||||
|
<option value="single">{{ $t('polls.single_choice') }}</option>
|
||||||
|
<option value="multiple">{{ $t('polls.multiple_choices') }}</option>
|
||||||
|
</select>
|
||||||
|
<i class="icon-down-open" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="poll-expiry"
|
||||||
|
:title="$t('polls.expiry')"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="expiryAmount"
|
||||||
|
type="number"
|
||||||
|
class="expiry-amount hide-number-spinner"
|
||||||
|
:min="minExpirationInCurrentUnit"
|
||||||
|
:max="maxExpirationInCurrentUnit"
|
||||||
|
@change="expiryAmountChange"
|
||||||
|
>
|
||||||
|
<label class="expiry-unit select">
|
||||||
|
<select
|
||||||
|
v-model="expiryUnit"
|
||||||
|
@change="expiryAmountChange"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="unit in expiryUnits"
|
||||||
|
:key="unit"
|
||||||
|
:value="unit"
|
||||||
|
>
|
||||||
|
{{ $t(`time.${unit}_short`, ['']) }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<i class="icon-down-open" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./poll_form.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.poll-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 0 0.5em 0.5em;
|
||||||
|
|
||||||
|
.add-option {
|
||||||
|
align-self: flex-start;
|
||||||
|
padding-top: 0.25em;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.poll-option {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-container {
|
||||||
|
width: 100%;
|
||||||
|
input {
|
||||||
|
// Hack: dodge the floating X icon
|
||||||
|
padding-right: 2.5em;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-container {
|
||||||
|
// Hack: Move the icon over the input box
|
||||||
|
width: 2em;
|
||||||
|
margin-left: -2em;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.poll-type-expiry {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.poll-type {
|
||||||
|
margin-right: 0.75em;
|
||||||
|
flex: 1 1 60%;
|
||||||
|
.select {
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.poll-expiry {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.expiry-amount {
|
||||||
|
width: 3em;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expiry-unit {
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
148
src/components/popper/popper.scss
Normal file
148
src/components/popper/popper.scss
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.tooltip.popover {
|
||||||
|
z-index: 8;
|
||||||
|
|
||||||
|
.popover-inner {
|
||||||
|
box-shadow: 1px 1px 4px rgba(0,0,0,.6);
|
||||||
|
box-shadow: var(--panelShadow);
|
||||||
|
border-radius: $fallback--btnRadius;
|
||||||
|
border-radius: var(--btnRadius, $fallback--btnRadius);
|
||||||
|
background-color: $fallback--bg;
|
||||||
|
background-color: var(--bg, $fallback--bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.popover-arrow {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-style: solid;
|
||||||
|
position: absolute;
|
||||||
|
margin: 5px;
|
||||||
|
border-color: $fallback--bg;
|
||||||
|
border-color: var(--bg, $fallback--bg);
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&[x-placement^="top"] {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
|
||||||
|
.popover-arrow {
|
||||||
|
border-width: 5px 5px 0 5px;
|
||||||
|
border-left-color: transparent !important;
|
||||||
|
border-right-color: transparent !important;
|
||||||
|
border-bottom-color: transparent !important;
|
||||||
|
bottom: -5px;
|
||||||
|
left: calc(50% - 5px);
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[x-placement^="bottom"] {
|
||||||
|
margin-top: 5px;
|
||||||
|
|
||||||
|
.popover-arrow {
|
||||||
|
border-width: 0 5px 5px 5px;
|
||||||
|
border-left-color: transparent !important;
|
||||||
|
border-right-color: transparent !important;
|
||||||
|
border-top-color: transparent !important;
|
||||||
|
top: -5px;
|
||||||
|
left: calc(50% - 5px);
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[x-placement^="right"] {
|
||||||
|
margin-left: 5px;
|
||||||
|
|
||||||
|
.popover-arrow {
|
||||||
|
border-width: 5px 5px 5px 0;
|
||||||
|
border-left-color: transparent !important;
|
||||||
|
border-top-color: transparent !important;
|
||||||
|
border-bottom-color: transparent !important;
|
||||||
|
left: -5px;
|
||||||
|
top: calc(50% - 5px);
|
||||||
|
margin-left: 0;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[x-placement^="left"] {
|
||||||
|
margin-right: 5px;
|
||||||
|
|
||||||
|
.popover-arrow {
|
||||||
|
border-width: 5px 0 5px 5px;
|
||||||
|
border-top-color: transparent !important;
|
||||||
|
border-right-color: transparent !important;
|
||||||
|
border-bottom-color: transparent !important;
|
||||||
|
right: -5px;
|
||||||
|
top: calc(50% - 5px);
|
||||||
|
margin-left: 0;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[aria-hidden='true'] {
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity .15s, visibility .15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
&[aria-hidden='false'] {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity .15s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu {
|
||||||
|
display: block;
|
||||||
|
padding: .5rem 0;
|
||||||
|
font-size: 1rem;
|
||||||
|
text-align: left;
|
||||||
|
list-style: none;
|
||||||
|
max-width: 100vw;
|
||||||
|
z-index: 10;
|
||||||
|
|
||||||
|
.dropdown-divider {
|
||||||
|
height: 0;
|
||||||
|
margin: .5rem 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border-top: 1px solid $fallback--border;
|
||||||
|
border-top: 1px solid var(--border, $fallback--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item {
|
||||||
|
line-height: 21px;
|
||||||
|
margin-right: 5px;
|
||||||
|
overflow: auto;
|
||||||
|
display: block;
|
||||||
|
padding: .25rem 1.0rem .25rem 1.5rem;
|
||||||
|
clear: both;
|
||||||
|
font-weight: 400;
|
||||||
|
text-align: inherit;
|
||||||
|
white-space: normal;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0px;
|
||||||
|
background-color: transparent;
|
||||||
|
box-shadow: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
&-icon {
|
||||||
|
padding-left: 0.5rem;
|
||||||
|
|
||||||
|
i {
|
||||||
|
margin-right: 0.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
// TODO: improve the look on breeze themes
|
||||||
|
background-color: $fallback--fg;
|
||||||
|
background-color: var(--btn, $fallback--fg);
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,17 +3,19 @@ import MediaUpload from '../media_upload/media_upload.vue'
|
||||||
import ScopeSelector from '../scope_selector/scope_selector.vue'
|
import ScopeSelector from '../scope_selector/scope_selector.vue'
|
||||||
import EmojiInput from '../emoji-input/emoji-input.vue'
|
import EmojiInput from '../emoji-input/emoji-input.vue'
|
||||||
import EmojiSelector from '../emoji-selector/emoji-selector.vue'
|
import EmojiSelector from '../emoji-selector/emoji-selector.vue'
|
||||||
|
import PollForm from '../poll/poll_form.vue'
|
||||||
|
import StickerPicker from '../sticker_picker/sticker_picker.vue'
|
||||||
import fileTypeService from '../../services/file_type/file_type.service.js'
|
import fileTypeService from '../../services/file_type/file_type.service.js'
|
||||||
import Completion from '../../services/completion/completion.js'
|
import { reject, map, uniqBy } from 'lodash'
|
||||||
import { take, filter, reject, map, uniqBy } from 'lodash'
|
import suggestor from '../emoji-input/suggestor.js'
|
||||||
|
|
||||||
const buildMentionsString = ({user, attentions}, currentUser) => {
|
const buildMentionsString = ({ user, attentions }, currentUser) => {
|
||||||
let allAttentions = [...attentions]
|
let allAttentions = [...attentions]
|
||||||
|
|
||||||
allAttentions.unshift(user)
|
allAttentions.unshift(user)
|
||||||
|
|
||||||
allAttentions = uniqBy(allAttentions, 'id')
|
allAttentions = uniqBy(allAttentions, 'id')
|
||||||
allAttentions = reject(allAttentions, {id: currentUser.id})
|
allAttentions = reject(allAttentions, { id: currentUser.id })
|
||||||
|
|
||||||
let mentions = map(allAttentions, (attention) => {
|
let mentions = map(allAttentions, (attention) => {
|
||||||
return `@${attention.screen_name}`
|
return `@${attention.screen_name}`
|
||||||
|
@ -32,9 +34,11 @@ const PostStatusForm = {
|
||||||
],
|
],
|
||||||
components: {
|
components: {
|
||||||
MediaUpload,
|
MediaUpload,
|
||||||
ScopeSelector,
|
|
||||||
EmojiInput,
|
EmojiInput,
|
||||||
EmojiSelector
|
PollForm,
|
||||||
|
StickerPicker,
|
||||||
|
EmojiSelector,
|
||||||
|
ScopeSelector
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.resize(this.$refs.textarea)
|
this.resize(this.$refs.textarea)
|
||||||
|
@ -58,7 +62,7 @@ const PostStatusForm = {
|
||||||
statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser)
|
statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
const scope = (this.copyMessageScope && scopeCopy || this.copyMessageScope === 'direct')
|
const scope = ((this.copyMessageScope && scopeCopy) || this.copyMessageScope === 'direct')
|
||||||
? this.copyMessageScope
|
? this.copyMessageScope
|
||||||
: this.$store.state.users.currentUser.default_scope
|
: this.$store.state.users.currentUser.default_scope
|
||||||
|
|
||||||
|
@ -77,57 +81,16 @@ const PostStatusForm = {
|
||||||
status: statusText,
|
status: statusText,
|
||||||
nsfw: false,
|
nsfw: false,
|
||||||
files: [],
|
files: [],
|
||||||
|
poll: {},
|
||||||
visibility: scope,
|
visibility: scope,
|
||||||
contentType
|
contentType
|
||||||
},
|
},
|
||||||
caret: 0
|
caret: 0,
|
||||||
|
pollFormVisible: false,
|
||||||
|
stickerPickerVisible: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
candidates () {
|
|
||||||
const firstchar = this.textAtCaret.charAt(0)
|
|
||||||
if (firstchar === '@') {
|
|
||||||
const query = this.textAtCaret.slice(1).toUpperCase()
|
|
||||||
const matchedUsers = filter(this.users, (user) => {
|
|
||||||
return user.screen_name.toUpperCase().startsWith(query) ||
|
|
||||||
user.name && user.name.toUpperCase().startsWith(query)
|
|
||||||
})
|
|
||||||
if (matchedUsers.length <= 0) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
return map(take(matchedUsers, 5), ({screen_name, name, profile_image_url_original}, index) => ({
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
screen_name: `@${screen_name}`,
|
|
||||||
name: name,
|
|
||||||
img: profile_image_url_original,
|
|
||||||
highlighted: index === this.highlighted
|
|
||||||
}))
|
|
||||||
} else if (firstchar === ':') {
|
|
||||||
if (this.textAtCaret === ':') { return }
|
|
||||||
const matchedEmoji = filter(this.emoji.concat(this.customEmoji), (emoji) => emoji.shortcode.startsWith(this.textAtCaret.slice(1)))
|
|
||||||
if (matchedEmoji.length <= 0) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return map(take(matchedEmoji, 5), ({shortcode, image_url, utf}, index) => ({
|
|
||||||
screen_name: `:${shortcode}:`,
|
|
||||||
name: '',
|
|
||||||
utf: utf || '',
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
img: utf ? '' : this.$store.state.instance.server + image_url,
|
|
||||||
highlighted: index === this.highlighted
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
textAtCaret () {
|
|
||||||
return (this.wordAtCaret || {}).word || ''
|
|
||||||
},
|
|
||||||
wordAtCaret () {
|
|
||||||
const word = Completion.wordAtPosition(this.newStatus.status, this.caret - 1) || {}
|
|
||||||
return word
|
|
||||||
},
|
|
||||||
users () {
|
users () {
|
||||||
return this.$store.state.users.users
|
return this.$store.state.users.users
|
||||||
},
|
},
|
||||||
|
@ -140,6 +103,24 @@ const PostStatusForm = {
|
||||||
: this.$store.state.config.minimalScopesMode
|
: this.$store.state.config.minimalScopesMode
|
||||||
return !minimalScopesMode
|
return !minimalScopesMode
|
||||||
},
|
},
|
||||||
|
emojiUserSuggestor () {
|
||||||
|
return suggestor({
|
||||||
|
emoji: [
|
||||||
|
...this.$store.state.instance.emoji,
|
||||||
|
...this.$store.state.instance.customEmoji
|
||||||
|
],
|
||||||
|
users: this.$store.state.users.users,
|
||||||
|
updateUsersList: (input) => this.$store.dispatch('searchUsers', input)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
emojiSuggestor () {
|
||||||
|
return suggestor({
|
||||||
|
emoji: [
|
||||||
|
...this.$store.state.instance.emoji,
|
||||||
|
...this.$store.state.instance.customEmoji
|
||||||
|
]
|
||||||
|
})
|
||||||
|
},
|
||||||
emoji () {
|
emoji () {
|
||||||
return this.$store.state.instance.emoji || []
|
return this.$store.state.instance.emoji || []
|
||||||
},
|
},
|
||||||
|
@ -176,91 +157,32 @@ const PostStatusForm = {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formattingOptionsEnabled () {
|
|
||||||
return this.$store.state.instance.formattingOptionsEnabled
|
|
||||||
},
|
|
||||||
postFormats () {
|
postFormats () {
|
||||||
return this.$store.state.instance.postFormats || []
|
return this.$store.state.instance.postFormats || []
|
||||||
},
|
},
|
||||||
safeDMEnabled () {
|
safeDMEnabled () {
|
||||||
return this.$store.state.instance.safeDM
|
return this.$store.state.instance.safeDM
|
||||||
|
},
|
||||||
|
stickersAvailable () {
|
||||||
|
if (this.$store.state.instance.stickers) {
|
||||||
|
return this.$store.state.instance.stickers.length > 0
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
},
|
||||||
|
pollsAvailable () {
|
||||||
|
return this.$store.state.instance.pollsAvailable &&
|
||||||
|
this.$store.state.instance.pollLimits.max_options >= 2
|
||||||
|
},
|
||||||
|
hideScopeNotice () {
|
||||||
|
return this.$store.state.config.hideScopeNotice
|
||||||
|
},
|
||||||
|
pollContentError () {
|
||||||
|
return this.pollFormVisible &&
|
||||||
|
this.newStatus.poll &&
|
||||||
|
this.newStatus.poll.error
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
replace (replacement) {
|
|
||||||
this.newStatus.status = Completion.replaceWord(this.newStatus.status, this.wordAtCaret, replacement)
|
|
||||||
const el = this.$el.querySelector('textarea')
|
|
||||||
el.focus()
|
|
||||||
this.caret = 0
|
|
||||||
},
|
|
||||||
replaceCandidate (e) {
|
|
||||||
const len = this.candidates.length || 0
|
|
||||||
if (this.textAtCaret === ':' || e.ctrlKey) { return }
|
|
||||||
if (len > 0) {
|
|
||||||
e.preventDefault()
|
|
||||||
const candidate = this.candidates[this.highlighted]
|
|
||||||
const replacement = candidate.utf || (candidate.screen_name + ' ')
|
|
||||||
this.newStatus.status = Completion.replaceWord(this.newStatus.status, this.wordAtCaret, replacement)
|
|
||||||
const el = this.$el.querySelector('textarea')
|
|
||||||
el.focus()
|
|
||||||
this.caret = 0
|
|
||||||
this.highlighted = 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cycleBackward (e) {
|
|
||||||
const len = this.candidates.length || 0
|
|
||||||
if (len > 0) {
|
|
||||||
e.preventDefault()
|
|
||||||
this.highlighted -= 1
|
|
||||||
if (this.highlighted < 0) {
|
|
||||||
this.highlighted = this.candidates.length - 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.highlighted = 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cycleForward (e) {
|
|
||||||
const len = this.candidates.length || 0
|
|
||||||
if (len > 0) {
|
|
||||||
if (e.shiftKey) { return }
|
|
||||||
e.preventDefault()
|
|
||||||
this.highlighted += 1
|
|
||||||
if (this.highlighted >= len) {
|
|
||||||
this.highlighted = 0
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.highlighted = 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onKeydown (e) {
|
|
||||||
e.stopPropagation()
|
|
||||||
},
|
|
||||||
onEmoji (emoji) {
|
|
||||||
const newValue = this.newStatus.status.substr(0, this.caret) + emoji + this.newStatus.status.substr(this.caret)
|
|
||||||
this.newStatus.status = newValue
|
|
||||||
this.caret += emoji.length
|
|
||||||
setTimeout(() => {
|
|
||||||
this.updateCaretPos()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
updateCaretPos () {
|
|
||||||
const elem = this.$refs.textarea
|
|
||||||
if (elem.createTextRange) {
|
|
||||||
const range = elem.createTextRange()
|
|
||||||
range.move('character', this.caret)
|
|
||||||
range.select()
|
|
||||||
} else {
|
|
||||||
if (elem.selectionStart) {
|
|
||||||
elem.focus()
|
|
||||||
elem.setSelectionRange(this.caret, this.caret)
|
|
||||||
} else {
|
|
||||||
elem.focus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setCaret ({target: {selectionStart}}) {
|
|
||||||
this.caret = selectionStart
|
|
||||||
},
|
|
||||||
postStatus (newStatus) {
|
postStatus (newStatus) {
|
||||||
if (this.posting) { return }
|
if (this.posting) { return }
|
||||||
if (this.submitDisabled) { return }
|
if (this.submitDisabled) { return }
|
||||||
|
@ -274,6 +196,12 @@ const PostStatusForm = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const poll = this.pollFormVisible ? this.newStatus.poll : {}
|
||||||
|
if (this.pollContentError) {
|
||||||
|
this.error = this.pollContentError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.posting = true
|
this.posting = true
|
||||||
statusPoster.postStatus({
|
statusPoster.postStatus({
|
||||||
status: newStatus.status,
|
status: newStatus.status,
|
||||||
|
@ -283,7 +211,8 @@ const PostStatusForm = {
|
||||||
media: newStatus.files,
|
media: newStatus.files,
|
||||||
store: this.$store,
|
store: this.$store,
|
||||||
inReplyToStatusId: this.replyTo,
|
inReplyToStatusId: this.replyTo,
|
||||||
contentType: newStatus.contentType
|
contentType: newStatus.contentType,
|
||||||
|
poll
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
if (!data.error) {
|
if (!data.error) {
|
||||||
this.newStatus = {
|
this.newStatus = {
|
||||||
|
@ -291,9 +220,13 @@ const PostStatusForm = {
|
||||||
spoilerText: '',
|
spoilerText: '',
|
||||||
files: [],
|
files: [],
|
||||||
visibility: newStatus.visibility,
|
visibility: newStatus.visibility,
|
||||||
contentType: newStatus.contentType
|
contentType: newStatus.contentType,
|
||||||
|
poll: {}
|
||||||
}
|
}
|
||||||
|
this.pollFormVisible = false
|
||||||
|
this.stickerPickerVisible = false
|
||||||
this.$refs.mediaUpload.clearFile()
|
this.$refs.mediaUpload.clearFile()
|
||||||
|
this.clearPollForm()
|
||||||
this.$emit('posted')
|
this.$emit('posted')
|
||||||
let el = this.$el.querySelector('textarea')
|
let el = this.$el.querySelector('textarea')
|
||||||
el.style.height = 'auto'
|
el.style.height = 'auto'
|
||||||
|
@ -308,6 +241,7 @@ const PostStatusForm = {
|
||||||
addMediaFile (fileInfo) {
|
addMediaFile (fileInfo) {
|
||||||
this.newStatus.files.push(fileInfo)
|
this.newStatus.files.push(fileInfo)
|
||||||
this.enableSubmit()
|
this.enableSubmit()
|
||||||
|
this.stickerPickerVisible = false
|
||||||
},
|
},
|
||||||
removeMediaFile (fileInfo) {
|
removeMediaFile (fileInfo) {
|
||||||
let index = this.newStatus.files.indexOf(fileInfo)
|
let index = this.newStatus.files.indexOf(fileInfo)
|
||||||
|
@ -349,8 +283,11 @@ const PostStatusForm = {
|
||||||
resize (e) {
|
resize (e) {
|
||||||
const target = e.target || e
|
const target = e.target || e
|
||||||
if (!(target instanceof window.Element)) { return }
|
if (!(target instanceof window.Element)) { return }
|
||||||
const vertPadding = Number(window.getComputedStyle(target)['padding-top'].substr(0, 1)) +
|
const topPaddingStr = window.getComputedStyle(target)['padding-top']
|
||||||
Number(window.getComputedStyle(target)['padding-bottom'].substr(0, 1))
|
const bottomPaddingStr = window.getComputedStyle(target)['padding-bottom']
|
||||||
|
// Remove "px" at the end of the values
|
||||||
|
const vertPadding = Number(topPaddingStr.substr(0, topPaddingStr.length - 2)) +
|
||||||
|
Number(bottomPaddingStr.substr(0, bottomPaddingStr.length - 2))
|
||||||
// Auto is needed to make textbox shrink when removing lines
|
// Auto is needed to make textbox shrink when removing lines
|
||||||
target.style.height = 'auto'
|
target.style.height = 'auto'
|
||||||
target.style.height = `${target.scrollHeight - vertPadding}px`
|
target.style.height = `${target.scrollHeight - vertPadding}px`
|
||||||
|
@ -363,6 +300,28 @@ const PostStatusForm = {
|
||||||
},
|
},
|
||||||
changeVis (visibility) {
|
changeVis (visibility) {
|
||||||
this.newStatus.visibility = visibility
|
this.newStatus.visibility = visibility
|
||||||
|
},
|
||||||
|
toggleStickerPicker () {
|
||||||
|
this.stickerPickerVisible = !this.stickerPickerVisible
|
||||||
|
},
|
||||||
|
clearStickerPicker () {
|
||||||
|
if (this.$refs.stickerPicker) {
|
||||||
|
this.$refs.stickerPicker.clear()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
togglePollForm () {
|
||||||
|
this.pollFormVisible = !this.pollFormVisible
|
||||||
|
},
|
||||||
|
setPoll (poll) {
|
||||||
|
this.newStatus.poll = poll
|
||||||
|
},
|
||||||
|
clearPollForm () {
|
||||||
|
if (this.$refs.pollForm) {
|
||||||
|
this.$refs.pollForm.clear()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissScopeNotice () {
|
||||||
|
this.$store.dispatch('setOption', { name: 'hideScopeNotice', value: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,112 +1,268 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="post-status-form">
|
<div class="post-status-form">
|
||||||
<form @submit.prevent="postStatus(newStatus)">
|
<form
|
||||||
<div class="form-group" >
|
autocomplete="off"
|
||||||
|
@submit.prevent="postStatus(newStatus)"
|
||||||
|
>
|
||||||
|
<div class="form-group">
|
||||||
<i18n
|
<i18n
|
||||||
v-if="!$store.state.users.currentUser.locked && newStatus.visibility == 'private'"
|
v-if="!$store.state.users.currentUser.locked && newStatus.visibility == 'private'"
|
||||||
path="post_status.account_not_locked_warning"
|
path="post_status.account_not_locked_warning"
|
||||||
tag="p"
|
tag="p"
|
||||||
class="visibility-notice">
|
class="visibility-notice"
|
||||||
<router-link :to="{ name: 'user-settings' }">{{ $t('post_status.account_not_locked_warning_link') }}</router-link>
|
>
|
||||||
|
<router-link :to="{ name: 'user-settings' }">
|
||||||
|
{{ $t('post_status.account_not_locked_warning_link') }}
|
||||||
|
</router-link>
|
||||||
</i18n>
|
</i18n>
|
||||||
<p v-if="newStatus.visibility === 'direct'" class="visibility-notice">
|
<p
|
||||||
|
v-if="!hideScopeNotice && newStatus.visibility === 'public'"
|
||||||
|
class="visibility-notice notice-dismissible"
|
||||||
|
>
|
||||||
|
<span>{{ $t('post_status.scope_notice.public') }}</span>
|
||||||
|
<a
|
||||||
|
class="button-icon dismiss"
|
||||||
|
@click.prevent="dismissScopeNotice()"
|
||||||
|
>
|
||||||
|
<i class="icon-cancel" />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-else-if="!hideScopeNotice && newStatus.visibility === 'unlisted'"
|
||||||
|
class="visibility-notice notice-dismissible"
|
||||||
|
>
|
||||||
|
<span>{{ $t('post_status.scope_notice.unlisted') }}</span>
|
||||||
|
<a
|
||||||
|
class="button-icon dismiss"
|
||||||
|
@click.prevent="dismissScopeNotice()"
|
||||||
|
>
|
||||||
|
<i class="icon-cancel" />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-else-if="!hideScopeNotice && newStatus.visibility === 'private' && $store.state.users.currentUser.locked"
|
||||||
|
class="visibility-notice notice-dismissible"
|
||||||
|
>
|
||||||
|
<span>{{ $t('post_status.scope_notice.private') }}</span>
|
||||||
|
<a
|
||||||
|
class="button-icon dismiss"
|
||||||
|
@click.prevent="dismissScopeNotice()"
|
||||||
|
>
|
||||||
|
<i class="icon-cancel" />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-else-if="newStatus.visibility === 'direct'"
|
||||||
|
class="visibility-notice"
|
||||||
|
>
|
||||||
<span v-if="safeDMEnabled">{{ $t('post_status.direct_warning_to_first_only') }}</span>
|
<span v-if="safeDMEnabled">{{ $t('post_status.direct_warning_to_first_only') }}</span>
|
||||||
<span v-else>{{ $t('post_status.direct_warning_to_all') }}</span>
|
<span v-else>{{ $t('post_status.direct_warning_to_all') }}</span>
|
||||||
</p>
|
</p>
|
||||||
<EmojiInput
|
<EmojiInput
|
||||||
v-if="newStatus.spoilerText || alwaysShowSubject"
|
v-if="newStatus.spoilerText || alwaysShowSubject"
|
||||||
|
v-model="newStatus.spoilerText"
|
||||||
|
:suggest="emojiSuggestor"
|
||||||
|
class="form-control"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
|
||||||
|
v-model="newStatus.spoilerText"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="$t('post_status.content_warning')"
|
:placeholder="$t('post_status.content_warning')"
|
||||||
v-model="newStatus.spoilerText"
|
class="form-post-subject"
|
||||||
classname="form-control"
|
>
|
||||||
/>
|
</EmojiInput>
|
||||||
<div class="status-input-wrapper">
|
<EmojiInput
|
||||||
|
v-model="newStatus.status"
|
||||||
|
:suggest="emojiUserSuggestor"
|
||||||
|
class="form-control main-input"
|
||||||
|
>
|
||||||
<textarea
|
<textarea
|
||||||
ref="textarea"
|
ref="textarea"
|
||||||
@click="setCaret"
|
v-model="newStatus.status"
|
||||||
@keyup="setCaret" v-model="newStatus.status" :placeholder="$t('post_status.default')" rows="1" class="form-control"
|
:placeholder="$t('post_status.default')"
|
||||||
@keydown="onKeydown"
|
rows="1"
|
||||||
@keydown.down="cycleForward"
|
:disabled="posting"
|
||||||
@keydown.up="cycleBackward"
|
class="form-post-body"
|
||||||
@keydown.shift.tab="cycleBackward"
|
|
||||||
@keydown.tab="cycleForward"
|
|
||||||
@keydown.enter="replaceCandidate"
|
|
||||||
@keydown.meta.enter="postStatus(newStatus)"
|
@keydown.meta.enter="postStatus(newStatus)"
|
||||||
@keyup.ctrl.enter="postStatus(newStatus)"
|
@keyup.ctrl.enter="postStatus(newStatus)"
|
||||||
@drop="fileDrop"
|
@drop="fileDrop"
|
||||||
@dragover.prevent="fileDrag"
|
@dragover.prevent="fileDrag"
|
||||||
@input="resize"
|
@input="resize"
|
||||||
@paste="paste"
|
@paste="paste"
|
||||||
:disabled="posting"
|
/>
|
||||||
|
<p
|
||||||
|
v-if="hasStatusLengthLimit"
|
||||||
|
class="character-counter faint"
|
||||||
|
:class="{ error: isOverLengthLimit }"
|
||||||
>
|
>
|
||||||
</textarea>
|
{{ charactersLeft }}
|
||||||
<EmojiSelector @emoji="onEmoji" />
|
</p>
|
||||||
</div>
|
</EmojiInput>
|
||||||
<div class="visibility-tray">
|
<div class="visibility-tray">
|
||||||
<span class="text-format" v-if="formattingOptionsEnabled">
|
<scope-selector
|
||||||
<label for="post-content-type" class="select">
|
:show-all="showAllScopes"
|
||||||
<select id="post-content-type" v-model="newStatus.contentType" class="form-control">
|
:user-default="userDefaultScope"
|
||||||
<option v-for="postFormat in postFormats" :key="postFormat" :value="postFormat">
|
:original-scope="copyMessageScope"
|
||||||
{{$t(`post_status.content_type["${postFormat}"]`)}}
|
:initial-scope="newStatus.visibility"
|
||||||
|
:on-scope-change="changeVis"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="postFormats.length > 1"
|
||||||
|
class="text-format"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
for="post-content-type"
|
||||||
|
class="select"
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
id="post-content-type"
|
||||||
|
v-model="newStatus.contentType"
|
||||||
|
class="form-control"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="postFormat in postFormats"
|
||||||
|
:key="postFormat"
|
||||||
|
:value="postFormat"
|
||||||
|
>
|
||||||
|
{{ $t(`post_status.content_type["${postFormat}"]`) }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<i class="icon-down-open"></i>
|
<i class="icon-down-open" />
|
||||||
</label>
|
</label>
|
||||||
</span>
|
|
||||||
|
|
||||||
<scope-selector
|
|
||||||
:showAll="showAllScopes"
|
|
||||||
:userDefault="userDefaultScope"
|
|
||||||
:originalScope="copyMessageScope"
|
|
||||||
:initialScope="newStatus.visibility"
|
|
||||||
:onScopeChange="changeVis"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="autocomplete-panel" v-if="candidates">
|
|
||||||
<div class="autocomplete-panel-body">
|
|
||||||
<div
|
<div
|
||||||
v-for="(candidate, index) in candidates"
|
v-if="postFormats.length === 1 && postFormats[0] !== 'text/plain'"
|
||||||
:key="index"
|
class="text-format"
|
||||||
@click="replace(candidate.utf || (candidate.screen_name + ' '))"
|
|
||||||
class="autocomplete-item"
|
|
||||||
:class="{ highlighted: candidate.highlighted }"
|
|
||||||
>
|
>
|
||||||
<span v-if="candidate.img"><img :src="candidate.img" /></span>
|
<span class="only-format">
|
||||||
<span v-else>{{candidate.utf}}</span>
|
{{ $t(`post_status.content_type["${postFormats[0]}"]`) }}
|
||||||
<span>{{candidate.screen_name}}<small>{{candidate.name}}</small></span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='form-bottom'>
|
<poll-form
|
||||||
<media-upload ref="mediaUpload" @uploading="disableSubmit" @uploaded="addMediaFile" @upload-failed="uploadFailed" :drop-files="dropFiles"></media-upload>
|
v-if="pollsAvailable"
|
||||||
|
ref="pollForm"
|
||||||
<p v-if="isOverLengthLimit" class="error">{{ charactersLeft }}</p>
|
:visible="pollFormVisible"
|
||||||
<p class="faint" v-else-if="hasStatusLengthLimit">{{ charactersLeft }}</p>
|
@update-poll="setPoll"
|
||||||
|
/>
|
||||||
<button v-if="posting" disabled class="btn btn-default">{{$t('post_status.posting')}}</button>
|
<div class="form-bottom">
|
||||||
<button v-else-if="isOverLengthLimit" disabled class="btn btn-default">{{$t('general.submit')}}</button>
|
<div class="form-bottom-left">
|
||||||
<button v-else :disabled="submitDisabled" type="submit" class="btn btn-default">{{$t('general.submit')}}</button>
|
<media-upload
|
||||||
|
ref="mediaUpload"
|
||||||
|
:drop-files="dropFiles"
|
||||||
|
@uploading="disableSubmit"
|
||||||
|
@uploaded="addMediaFile"
|
||||||
|
@upload-failed="uploadFailed"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-if="stickersAvailable"
|
||||||
|
class="sticker-icon"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
:title="$t('stickers.add_sticker')"
|
||||||
|
class="icon-picture btn btn-default"
|
||||||
|
:class="{ selected: stickerPickerVisible }"
|
||||||
|
@click="toggleStickerPicker"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class='alert error' v-if="error">
|
<div
|
||||||
|
v-if="pollsAvailable"
|
||||||
|
class="poll-icon"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
:title="$t('polls.add_poll')"
|
||||||
|
class="icon-chart-bar btn btn-default"
|
||||||
|
:class="pollFormVisible && 'selected'"
|
||||||
|
@click="togglePollForm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
v-if="posting"
|
||||||
|
disabled
|
||||||
|
class="btn btn-default"
|
||||||
|
>
|
||||||
|
{{ $t('post_status.posting') }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-else-if="isOverLengthLimit"
|
||||||
|
disabled
|
||||||
|
class="btn btn-default"
|
||||||
|
>
|
||||||
|
{{ $t('general.submit') }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-else
|
||||||
|
:disabled="submitDisabled"
|
||||||
|
type="submit"
|
||||||
|
class="btn btn-default"
|
||||||
|
>
|
||||||
|
{{ $t('general.submit') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="error"
|
||||||
|
class="alert error"
|
||||||
|
>
|
||||||
Error: {{ error }}
|
Error: {{ error }}
|
||||||
<i class="button-icon icon-cancel" @click="clearError"></i>
|
<i
|
||||||
|
class="button-icon icon-cancel"
|
||||||
|
@click="clearError"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="attachments">
|
<div class="attachments">
|
||||||
<div class="media-upload-wrapper" v-for="file in newStatus.files">
|
<div
|
||||||
<i class="fa button-icon icon-cancel" @click="removeMediaFile(file)"></i>
|
v-for="file in newStatus.files"
|
||||||
|
:key="file.url"
|
||||||
|
class="media-upload-wrapper"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
class="fa button-icon icon-cancel"
|
||||||
|
@click="removeMediaFile(file)"
|
||||||
|
/>
|
||||||
<div class="media-upload-container attachment">
|
<div class="media-upload-container attachment">
|
||||||
<img class="thumbnail media-upload" :src="file.url" v-if="type(file) === 'image'"></img>
|
<img
|
||||||
<video v-if="type(file) === 'video'" :src="file.url" controls></video>
|
v-if="type(file) === 'image'"
|
||||||
<audio v-if="type(file) === 'audio'" :src="file.url" controls></audio>
|
class="thumbnail media-upload"
|
||||||
<a v-if="type(file) === 'unknown'" :href="file.url">{{file.url}}</a>
|
:src="file.url"
|
||||||
|
>
|
||||||
|
<video
|
||||||
|
v-if="type(file) === 'video'"
|
||||||
|
:src="file.url"
|
||||||
|
controls
|
||||||
|
/>
|
||||||
|
<audio
|
||||||
|
v-if="type(file) === 'audio'"
|
||||||
|
:src="file.url"
|
||||||
|
controls
|
||||||
|
/>
|
||||||
|
<a
|
||||||
|
v-if="type(file) === 'unknown'"
|
||||||
|
:href="file.url"
|
||||||
|
>{{ file.url }}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="upload_settings" v-if="newStatus.files.length > 0">
|
<div
|
||||||
<input type="checkbox" id="filesSensitive" v-model="newStatus.nsfw">
|
v-if="newStatus.files.length > 0"
|
||||||
<label for="filesSensitive">{{$t('post_status.attachments_sensitive')}}</label>
|
class="upload_settings"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
id="filesSensitive"
|
||||||
|
v-model="newStatus.nsfw"
|
||||||
|
type="checkbox"
|
||||||
|
>
|
||||||
|
<label for="filesSensitive">{{ $t('post_status.attachments_sensitive') }}</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<sticker-picker
|
||||||
|
v-if="stickerPickerVisible"
|
||||||
|
ref="stickerPicker"
|
||||||
|
@uploaded="addMediaFile"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -136,11 +292,11 @@
|
||||||
.visibility-tray {
|
.visibility-tray {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
flex-direction: row-reverse;
|
padding-top: 5px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-status-form, .login {
|
.post-status-form {
|
||||||
.form-bottom {
|
.form-bottom {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
|
@ -157,6 +313,37 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-bottom-left {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-format {
|
||||||
|
.only-format {
|
||||||
|
color: $fallback--faint;
|
||||||
|
color: var(--faint, $fallback--faint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.poll-icon, .sticker-icon {
|
||||||
|
font-size: 26px;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
.selected {
|
||||||
|
color: $fallback--lightText;
|
||||||
|
color: var(--lightText, $fallback--lightText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sticker-icon {
|
||||||
|
flex: 0;
|
||||||
|
min-width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-chart-bar {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +411,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +428,7 @@
|
||||||
.form-group {
|
.form-group {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 0.3em 0.5em 0.6em;
|
padding: 0.25em 0.5em 0.5em;
|
||||||
line-height:24px;
|
line-height:24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,19 +440,38 @@
|
||||||
min-height: 1px;
|
min-height: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
form textarea.form-control {
|
.form-post-body {
|
||||||
line-height:16px;
|
height: 16px; // Only affects the empty-height
|
||||||
|
line-height: 16px;
|
||||||
resize: none;
|
resize: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
transition: min-height 200ms 100ms;
|
transition: min-height 200ms 100ms;
|
||||||
|
padding-bottom: 1.75em;
|
||||||
min-height: 1px;
|
min-height: 1px;
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
form textarea.form-control:focus {
|
.form-post-body:focus {
|
||||||
min-height: 48px;
|
min-height: 48px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.main-input {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.character-counter {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0 0.5em;
|
||||||
|
|
||||||
|
&.error {
|
||||||
|
color: $fallback--cRed;
|
||||||
|
color: var(--cRed, $fallback--cRed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
38
src/components/progress_button/progress_button.vue
Normal file
38
src/components/progress_button/progress_button.vue
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<template>
|
||||||
|
<button
|
||||||
|
:disabled="progress || disabled"
|
||||||
|
@click="onClick"
|
||||||
|
>
|
||||||
|
<template v-if="progress && $slots.progress">
|
||||||
|
<slot name="progress" />
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<slot />
|
||||||
|
</template>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
disabled: {
|
||||||
|
type: Boolean
|
||||||
|
},
|
||||||
|
click: { // click event handler. Must return a promise
|
||||||
|
type: Function,
|
||||||
|
default: () => Promise.resolve()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
progress: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onClick () {
|
||||||
|
this.progress = true
|
||||||
|
this.click().then(() => { this.progress = false })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue