Repository navigation
Expand file tree
/
Copy pathask.js
More file actions
109 lines (88 loc) · 3.04 KB
/
Copy pathask.js
File metadata and controls
109 lines (88 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var Ask = (function() {
var init = function() {
var $replyForm = $('#replyForm')
var $id = $('[name=id]')
var $text = $('[name=text]')
var $tmpl = $('.comment-tmpl')
var textEditor
tinymce.init({
selector : '[name=text]'
, content_css : '/css/bootstrap.min.css'
, language : (FE_LOCAL.language || '').replace('-', '_')
, menubar : 'edit insert format table'
, relative_urls : false
, remove_script_host : false
, convert_urls : true
, plugins : [
"advlist autolink lists link image charmap print preview anchor"
, "searchreplace visualblocks code fullscreen"
, "insertdatetime media table paste textcolor colorpicker contextmenu"
]
, image_dimensions : false
, toolbar: "insertfile undo redo | styleselect | bold italic underline strikethrough | fontselect fontsizeselect | "
+ "forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | "
+ "link image code codeSC print"
, setup: function(editor) {
textEditor = editor
editor.addButton('codeSC', {
text: '<pre>',
icon: false,
onclick: function () {
editor.insertContent('<pre>\r\n</pre>');
}
})
editor.on('init', function(e) {
})
/*
https://stackoverflow.com/questions/33185657/why-i-cant-get-a-value-of-textarea-from-tinymce-editor-using-formdata-in-jquery
*/
editor.on('change', function(e) {
//editor.getContent()
editor.save()
})
editor.on('keyup', function(e) {
//editor.getContent()
editor.save()
})
}
})
$replyForm.on('submit', function(e) {
e.preventDefault()
$.post('/ask/json/reply/add?id=' + $id.val(), $text.val(), function(json) {
OnceDoc.Common.onAjaxMsg(json)
if (json.user) {
json.text = $text.val()
var $reply = $tmpl.clone()
$reply.removeClass('hide')
$reply.view(json)
textEditor.setContent('')
$('#comments_list').append($reply)
}
})
})
$('.cmd-confirm').on('click', function(e) {
e.preventDefault()
var $this = $(this)
$.messager.confirm(FE_LOCAL.ARE_YOU_SURE_YOU_WANT_TO_XX.format($this.text()), function() {
$.get($this.attr('href'), function(result) {
try {
result = JSON.parse(result)
} catch(e) {
$.messager.popup(result)
return
}
if (result.error) {
$.messager.popup(result.error)
return
}
if (result.message) {
$.messager.popup(result.message)
return
}
$.messager.popup(FE_LOCAL.ACTION_SUCCESS_NEED_REFRESH)
})
})
})
}
init()
})();