77 lines
1.8 KiB
JavaScript
77 lines
1.8 KiB
JavaScript
|
|
Vn.include('node_modules/tinymce/tinymce.min');
|
|
Vn.define(function() {
|
|
Hedera.New = new Class({
|
|
Extends: Hedera.Form
|
|
|
|
,editor: null
|
|
|
|
,activate: function() {
|
|
this.$.model.mode = Db.Model.Mode.ON_DEMAND;
|
|
this.$.model.setDefault('userFk', 'news',
|
|
new Sql.Function({schema: 'account', name: 'myUser_getId'}));
|
|
|
|
tinymce.init({
|
|
mode : 'exact'
|
|
,target: this.$.htmlEditor
|
|
,plugins: [
|
|
"advlist autolink lists link image charmap print preview hr"
|
|
,"anchor pagebreak searchreplace wordcount visualblocks"
|
|
,"visualchars code fullscreen insertdatetime media nonbreaking"
|
|
,"save table directionality emoticons template paste"
|
|
]
|
|
,toolbar1:
|
|
" print preview | link image media emoticons blockquote"
|
|
+" | insertfile undo redo | bold italic"
|
|
+" | alignleft aligncenter alignright alignjustify"
|
|
+" | bullist numlist outdent indent"
|
|
+" | styleselect | fontselect fontsizeselect"
|
|
+" | forecolor backcolor"
|
|
,image_advtab: true
|
|
,init_instance_callback: this._onEditorInit.bind(this)
|
|
});
|
|
},
|
|
|
|
deactivate: function() {
|
|
this.editor.destroy();
|
|
},
|
|
|
|
_onEditorInit: function(editor) {
|
|
this.editor = editor;
|
|
editor.getDoc().body.style.fontSize = '1em';
|
|
this.setEditorText();
|
|
},
|
|
|
|
setEditorText: function() {
|
|
if (!this.editor)
|
|
return;
|
|
|
|
var newHtml = this.$.iter.$.text;
|
|
|
|
if (!newHtml)
|
|
newHtml = '';
|
|
|
|
this.editor.setContent(newHtml);
|
|
},
|
|
|
|
onStatusChange: function() {
|
|
if (this.hash.$.new == 0)
|
|
this.$.iter.insertRow();
|
|
},
|
|
|
|
onOperationsDone: function() {
|
|
Htk.Toast.showMessage(_('NewChangedSuccessfully'));
|
|
this.onReturnClick();
|
|
},
|
|
|
|
onBodyChange: function() {
|
|
this.setEditorText();
|
|
},
|
|
|
|
onAcceptClick: function() {
|
|
this.$.iter.set('text', this.editor.getContent());
|
|
this.$.iter.performOperations();
|
|
}
|
|
});
|
|
});
|