mirror of https://github.com/requarks/wiki
parent
f6c519c5dc
commit
fe0c4ce0c0
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,28 +1,35 @@
|
|||||||
/* global $, _, currentBasePath */
|
'use strict'
|
||||||
|
|
||||||
|
import $ from 'jquery'
|
||||||
|
import _ from 'lodash'
|
||||||
|
import { setInputSelection } from '../helpers/form'
|
||||||
|
import { makeSafePath } from '../helpers/pages'
|
||||||
|
|
||||||
// -> Create New Document
|
// -> Create New Document
|
||||||
|
|
||||||
let suggestedCreatePath = currentBasePath + '/new-page'
|
module.exports = (currentBasePath) => {
|
||||||
|
let suggestedCreatePath = currentBasePath + '/new-page'
|
||||||
|
|
||||||
$('.btn-create-prompt').on('click', (ev) => {
|
$('.btn-create-prompt').on('click', (ev) => {
|
||||||
$('#txt-create-prompt').val(suggestedCreatePath)
|
$('#txt-create-prompt').val(suggestedCreatePath)
|
||||||
$('#modal-create-prompt').toggleClass('is-active')
|
$('#modal-create-prompt').toggleClass('is-active')
|
||||||
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length) // eslint-disable-line no-undef
|
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length)
|
||||||
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden')
|
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden')
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#txt-create-prompt').on('keypress', (ev) => {
|
$('#txt-create-prompt').on('keypress', (ev) => {
|
||||||
if (ev.which === 13) {
|
if (ev.which === 13) {
|
||||||
$('.btn-create-go').trigger('click')
|
$('.btn-create-go').trigger('click')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
$('.btn-create-go').on('click', (ev) => {
|
$('.btn-create-go').on('click', (ev) => {
|
||||||
let newDocPath = makeSafePath($('#txt-create-prompt').val()) // eslint-disable-line no-undef
|
let newDocPath = makeSafePath($('#txt-create-prompt').val())
|
||||||
if (_.isEmpty(newDocPath)) {
|
if (_.isEmpty(newDocPath)) {
|
||||||
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden')
|
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden')
|
||||||
} else {
|
} else {
|
||||||
$('#txt-create-prompt').parent().addClass('is-loading')
|
$('#txt-create-prompt').parent().addClass('is-loading')
|
||||||
window.location.assign('/create/' + newDocPath)
|
window.location.assign('/create/' + newDocPath)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
/* global $ */
|
'use strict'
|
||||||
|
|
||||||
if ($('#page-type-view').length) {
|
import $ from 'jquery'
|
||||||
let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : '' // eslint-disable-line no-unused-vars
|
|
||||||
|
|
||||||
/* eslint-disable spaced-comment */
|
module.exports = (alerts) => {
|
||||||
//=include ../modals/create.js
|
if ($('#page-type-view').length) {
|
||||||
//=include ../modals/move.js
|
let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : ''
|
||||||
/* eslint-enable spaced-comment */
|
|
||||||
|
require('../modals/create.js')(currentBasePath)
|
||||||
|
require('../modals/move.js')(currentBasePath, alerts)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue