2015-01-23 13:09:30 +00:00
|
|
|
|
2016-09-26 09:28:47 +00:00
|
|
|
Vn.include ('node_modules/tinymce/tinymce.min');
|
2015-12-10 13:48:43 +00:00
|
|
|
Vn.define (function () {
|
|
|
|
|
2016-09-26 09:28:47 +00:00
|
|
|
Hedera.New = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Hedera.Form
|
2016-10-11 07:26:10 +00:00
|
|
|
|
|
|
|
,editor: null
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,activate: function ()
|
|
|
|
{
|
2015-03-19 19:36:11 +00:00
|
|
|
this.$('model').mode = Db.Model.Mode.ON_DEMAND;
|
|
|
|
this.$('model').setDefault ('user_id', 'news',
|
2016-10-04 15:27:49 +00:00
|
|
|
new Sql.Function ({schema: 'account', name: 'userGetId'}));
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
tinymce.init ({
|
2016-10-11 07:26:10 +00:00
|
|
|
mode : 'exact'
|
|
|
|
,target: this.$('html-editor')
|
2015-02-08 15:38:38 +00:00
|
|
|
,plugins: [
|
2016-10-11 07:26:10 +00:00
|
|
|
"advlist autolink lists link image charmap print preview hr"
|
|
|
|
,"anchor pagebreak searchreplace wordcount visualblocks"
|
|
|
|
,"visualchars code fullscreen insertdatetime media nonbreaking"
|
|
|
|
,"save table contextmenu directionality emoticons template"
|
|
|
|
,"paste textcolor"
|
2015-01-23 13:09:30 +00:00
|
|
|
]
|
2017-03-22 16:57:21 +00:00
|
|
|
,toolbar:
|
|
|
|
" 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"
|
2015-01-23 13:09:30 +00:00
|
|
|
,image_advtab: true
|
2016-10-11 07:26:10 +00:00
|
|
|
,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 ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 07:26:10 +00:00
|
|
|
,setEditorText: function ()
|
|
|
|
{
|
|
|
|
if (!this.editor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var newHtml = this.$('iter').get ('text');
|
|
|
|
|
|
|
|
if (!newHtml)
|
|
|
|
newHtml = '';
|
|
|
|
|
|
|
|
this.editor.setContent (newHtml);
|
|
|
|
}
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
,onStatusChange: function (form)
|
|
|
|
{
|
2017-04-07 11:00:33 +00:00
|
|
|
if (this.hash.get('new') == 0)
|
2015-01-23 13:09:30 +00:00
|
|
|
form.insertRow ();
|
|
|
|
}
|
2015-03-19 19:36:11 +00:00
|
|
|
|
|
|
|
,onOperationsDone: function ()
|
|
|
|
{
|
2015-08-17 18:02:14 +00:00
|
|
|
Htk.Toast.showMessage (_('NewChangedSuccessfully'));
|
2015-03-19 19:36:11 +00:00
|
|
|
this.onReturnClick ();
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,onBodyChange: function ()
|
|
|
|
{
|
2016-10-11 07:26:10 +00:00
|
|
|
this.setEditorText ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,onAcceptClick: function ()
|
|
|
|
{
|
2016-10-11 07:26:10 +00:00
|
|
|
this.$('iter').set ('text', this.editor.getContent ());
|
2015-03-19 19:36:11 +00:00
|
|
|
this.$('iter').performOperations ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2015-03-19 19:36:11 +00:00
|
|
|
|
|
|
|
,onReturnClick: function ()
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2017-04-05 14:06:07 +00:00
|
|
|
this.hash.setAll ({'form': 'news/news'});
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-10 13:48:43 +00:00
|
|
|
});
|