-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #481 from support-project/feature/issue436_interna…
…l_link Feature/issue436 internal link
- Loading branch information
Showing
10 changed files
with
256 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,176 +1,170 @@ | ||
$(document).ready(function() { | ||
$('#emojiPeopleModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiPeopleModal'); | ||
}); | ||
$('#emojiNatureModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiNatureModal'); | ||
}); | ||
$('#emojiObjectsModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiObjectsModal'); | ||
}); | ||
$('#emojiPlacesModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiPlacesModal'); | ||
}); | ||
$('#emojiSymbolsModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiSymbolsModal'); | ||
}); | ||
$('#sampleMarkdownCheck').click(function() { | ||
var text = $('#sampleMarkdownText').val(); | ||
var textarea = $('#comment'); | ||
textarea.val(text); | ||
preview(); | ||
$('#helpMarkdownModal').modal('hide'); | ||
var p = $("#preview").offset().top - 60; | ||
$('html,body').animate({ scrollTop: p }, 'fast'); | ||
}); | ||
var url = _CONTEXT + '/protect.file/upload'; | ||
$('#fileupload').fileupload({ | ||
url : url, | ||
dataType : 'json', | ||
autoUpload: true, | ||
maxFileSize: 5000000, // 5 MB | ||
}).on('fileuploaddone', function (e, data) { | ||
//$('#files').show(); | ||
$.each(data.result.files, function(index, file) { | ||
console.log(file); | ||
var filediv = '<div class="filediv" id="file-' + file.fileNo + '">'; | ||
filediv += '<div class="file-image">'; | ||
filediv += '<img src="' + file.thumbnailUrl + '" />'; | ||
filediv += '</div>'; | ||
filediv += '<div class="file-label">'; | ||
filediv += '<a href="' + file.url + '">'; | ||
filediv += file.name; | ||
filediv += '</a>'; | ||
filediv += '</div>'; | ||
filediv += '<br class="fileLabelBr"/>'; | ||
filediv += '<input type="hidden" name="files" value="' + file.fileNo + '" />'; | ||
filediv += ' '; | ||
filediv += '<button type="button" class="btn btn-success" onclick="setImagePath(\'' + file.url + '\', \'' + file.name + '\')">'; | ||
filediv += '<i class="fa fa-file-image-o"></i> ' + _SET_IMAGE_LABEL; | ||
filediv += '</button>'; | ||
filediv += '<button type="button" class="btn btn-danger" onclick="removeAddedFile(' + file.fileNo + ')">'; | ||
filediv += '<i class="fa fa-remove"></i>'; | ||
filediv += ' ' + _DELETE_LABEL + '</button>'; | ||
filediv += '</div>'; | ||
$('#files').append(filediv); | ||
}); | ||
$.notify(_UPLOADED, 'success'); | ||
setTimeout(function() { | ||
$('#progress').hide(); | ||
}, 5000); | ||
}).on('fileuploadprogressall', function (e, data) { | ||
$('#progress').show(); | ||
var progress = parseInt(data.loaded / data.total * 100, 10); | ||
console.log('' + progress + '%'); | ||
$('.progress .progress-bar').css('width', progress + '%'); | ||
$('.progress .progress-bar').text(progress + '%'); | ||
}).on('fileuploadfail', function (e, data) { | ||
if (data && data.jqXHR && data.jqXHR.responseJSON && data.jqXHR.responseJSON.msg) { | ||
var msg = data.jqXHR.responseJSON.msg; | ||
$.each(data.files, function (index) { | ||
var filediv = '<div class="alert alert-warning alert-dismissible" role="alert">'; | ||
filediv += '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'; | ||
filediv += '<strong>'; | ||
filediv += '<i class="fa fa-remove"></i> '; | ||
filediv += data.files[index].name; | ||
filediv += '</strong> '; | ||
filediv += msg; | ||
filediv += '</div>'; | ||
$('#files').append(filediv); | ||
$.notify(_FAIL_UPLOAD, 'warn'); | ||
}); | ||
} else { | ||
console.log(e); | ||
console.log(data); | ||
$.notify('アップロードに失敗しました', 'warn'); | ||
} | ||
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled'); | ||
$('#emojiPeopleModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiPeopleModal'); | ||
}); | ||
$('#emojiNatureModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiNatureModal'); | ||
}); | ||
$('#emojiObjectsModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiObjectsModal'); | ||
}); | ||
$('#emojiPlacesModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiPlacesModal'); | ||
}); | ||
$('#emojiSymbolsModal').on('loaded.bs.modal', function (event) { | ||
emojiSelect('#emojiSymbolsModal'); | ||
}); | ||
$('#sampleMarkdownCheck').click(function() { | ||
var text = $('#sampleMarkdownText').val(); | ||
var textarea = $('#comment'); | ||
textarea.val(text); | ||
preview(); | ||
$('#helpMarkdownModal').modal('hide'); | ||
var p = $("#preview").offset().top - 60; | ||
$('html,body').animate({ scrollTop: p }, 'fast'); | ||
}); | ||
var url = _CONTEXT + '/protect.file/upload'; | ||
$('#fileupload').fileupload({ | ||
url : url, | ||
dataType : 'json', | ||
autoUpload: true, | ||
maxFileSize: 5000000, // 5 MB | ||
}).on('fileuploaddone', function (e, data) { | ||
//$('#files').show(); | ||
$.each(data.result.files, function(index, file) { | ||
console.log(file); | ||
var filediv = '<div class="filediv" id="file-' + file.fileNo + '">'; | ||
filediv += '<div class="file-image">'; | ||
filediv += '<img src="' + file.thumbnailUrl + '" />'; | ||
filediv += '</div>'; | ||
filediv += '<div class="file-label">'; | ||
filediv += '<a href="' + file.url + '">'; | ||
filediv += file.name; | ||
filediv += '</a>'; | ||
filediv += '</div>'; | ||
filediv += '<br class="fileLabelBr"/>'; | ||
filediv += '<input type="hidden" name="files" value="' + file.fileNo + '" />'; | ||
filediv += ' '; | ||
filediv += '<button type="button" class="btn btn-success" onclick="setImagePath(\'' + file.url + '\', \'' + file.name + '\')">'; | ||
filediv += '<i class="fa fa-file-image-o"></i> ' + _SET_IMAGE_LABEL; | ||
filediv += '</button>'; | ||
filediv += '<button type="button" class="btn btn-danger" onclick="removeAddedFile(' + file.fileNo + ')">'; | ||
filediv += '<i class="fa fa-remove"></i>'; | ||
filediv += ' ' + _DELETE_LABEL + '</button>'; | ||
filediv += '</div>'; | ||
$('#files').append(filediv); | ||
}); | ||
$.notify(_UPLOADED, 'success'); | ||
setTimeout(function() { | ||
$('#progress').hide(); | ||
}, 5000); | ||
}).on('fileuploadprogressall', function (e, data) { | ||
$('#progress').show(); | ||
var progress = parseInt(data.loaded / data.total * 100, 10); | ||
console.log('' + progress + '%'); | ||
$('.progress .progress-bar').css('width', progress + '%'); | ||
$('.progress .progress-bar').text(progress + '%'); | ||
}).on('fileuploadfail', function (e, data) { | ||
if (data && data.jqXHR && data.jqXHR.responseJSON && data.jqXHR.responseJSON.msg) { | ||
var msg = data.jqXHR.responseJSON.msg; | ||
$.each(data.files, function (index) { | ||
var filediv = '<div class="alert alert-warning alert-dismissible" role="alert">'; | ||
filediv += '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'; | ||
filediv += '<strong>'; | ||
filediv += '<i class="fa fa-remove"></i> '; | ||
filediv += data.files[index].name; | ||
filediv += '</strong> '; | ||
filediv += msg; | ||
filediv += '</div>'; | ||
$('#files').append(filediv); | ||
$.notify(_FAIL_UPLOAD, 'warn'); | ||
}); | ||
} else { | ||
console.log(e); | ||
console.log(data); | ||
$.notify('アップロードに失敗しました', 'warn'); | ||
} | ||
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled'); | ||
}); | ||
|
||
var emoji = window.emojiParser; | ||
var preview = function() { | ||
$.post(_CONTEXT + '/open.knowledge/marked', { | ||
title : $('#input_title').val(), | ||
content : $('#comment').val() | ||
}, function(data) { | ||
var html = '<div class="row">'; | ||
html += '<div class="col-sm-12">'; | ||
html += '<div class="thumbnail">'; | ||
html += '<div class="caption">'; | ||
html += '[preview]'; | ||
html += '<h3>'; | ||
html += data.title; | ||
html += '</h3><hr/>'; | ||
html += '<div style="word-break:break-all" id="content">'; | ||
var content = data.content; | ||
html += content; | ||
html += '</div>'; | ||
html += '</div>'; | ||
html += '</div>'; | ||
html += '</div>'; | ||
html += '</div>'; | ||
|
||
var jqObj = $('#preview'); | ||
jqObj.html(html); | ||
jqObj.find('code').addClass('hljs'); | ||
codeHighlight(jqObj) | ||
.then(function() { | ||
var content = emoji(jqObj.html().trim(), _CONTEXT + '/bower/emoji-parser/emoji', {classes: 'emoji-img'}); | ||
jqObj.html(content); | ||
}).then(function () { | ||
jqObj.find('a.oembed').oembed(); | ||
}); | ||
}); | ||
$.post(_CONTEXT + '/open.knowledge/marked', { | ||
title : $('#input_title').val(), | ||
content : $('#comment').val() | ||
}, function(data) { | ||
var html = '<div class="row">'; | ||
html += '<div class="col-sm-12">'; | ||
html += '<div class="thumbnail">'; | ||
html += '<div class="caption">'; | ||
html += '[preview]'; | ||
html += '<h3>'; | ||
html += data.title; | ||
html += '</h3><hr/>'; | ||
html += '<div style="word-break:break-all" id="content">'; | ||
var content = data.content; | ||
html += content; | ||
html += '</div>'; | ||
html += '</div>'; | ||
html += '</div>'; | ||
html += '</div>'; | ||
html += '</div>'; | ||
|
||
var target = '#preview'; | ||
var jqObj = $(target); | ||
jqObj.html(html); | ||
processDecoration(target); | ||
}); | ||
}; | ||
var emojiSelect = function(id) { | ||
$(id).find('.name').each(function(i, block) { | ||
$(this).click(function(event) { | ||
var val = ' :' + $(this).text() + ': '; | ||
var textarea = $('#comment'); | ||
textarea.val(textarea.val() + val); | ||
$(id).modal('hide'); | ||
}); | ||
}); | ||
$(id).find('.name').each(function(i, block) { | ||
$(this).click(function(event) { | ||
var val = ' :' + $(this).text() + ': '; | ||
var textarea = $('#comment'); | ||
textarea.val(textarea.val() + val); | ||
$(id).modal('hide'); | ||
}); | ||
}); | ||
}; | ||
|
||
function deleteComment() { | ||
bootbox.confirm(_CONFIRM, function(result) { | ||
if (result) { | ||
$('#commentForm').attr('action', _CONTEXT + '/protect.knowledge/delete_comment/' + $('#commentNo').val()); | ||
$('#commentForm').attr('method', 'GET'); | ||
$('#commentForm').submit(); | ||
} | ||
}); | ||
bootbox.confirm(_CONFIRM, function(result) { | ||
if (result) { | ||
$('#commentForm').attr('action', _CONTEXT + '/protect.knowledge/delete_comment/' + $('#commentNo').val()); | ||
$('#commentForm').attr('method', 'GET'); | ||
$('#commentForm').submit(); | ||
} | ||
}); | ||
}; | ||
|
||
var removeAddedFile = function(fileNo) { | ||
var url = _CONTEXT + '/protect.file/delete'; | ||
$.ajax({ | ||
type : 'GET', | ||
url : url, | ||
data : 'fileNo=' + fileNo, | ||
success : function(data, dataType) { | ||
$.notify(_REMOVE_FILE, 'info'); | ||
$('#file-' + fileNo).remove(); | ||
}, | ||
error: function(XMLHttpRequest, textStatus, errorThrown){ | ||
//alert("error: " + textStatus); | ||
$.notify(_FAIL_REMOVE_FILE, 'warn'); | ||
} | ||
}); | ||
var url = _CONTEXT + '/protect.file/delete'; | ||
$.ajax({ | ||
type : 'GET', | ||
url : url, | ||
data : 'fileNo=' + fileNo, | ||
success : function(data, dataType) { | ||
$.notify(_REMOVE_FILE, 'info'); | ||
$('#file-' + fileNo).remove(); | ||
}, | ||
error: function(XMLHttpRequest, textStatus, errorThrown){ | ||
//alert("error: " + textStatus); | ||
$.notify(_FAIL_REMOVE_FILE, 'warn'); | ||
} | ||
}); | ||
}; | ||
|
||
var setImagePath = function(url, name) { | ||
var text = '\n![' + name + '](' + url + ')\n'; | ||
var textarea = $('#comment'); | ||
textarea.val(textarea.val() + text); | ||
var text = '\n![' + name + '](' + url + ')\n'; | ||
var textarea = $('#comment'); | ||
textarea.val(textarea.val() + text); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.