hedera-web/forms/news/new/new.js

94 lines
1.9 KiB
JavaScript
Raw Normal View History

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
({
2016-09-26 09:28:47 +00:00
Extends: Hedera.Form
2016-10-11 07:26:10 +00:00
,editor: null
,activate: function ()
{
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'}));
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"
]
2016-10-11 07:26:10 +00:00
,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
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 ();
}
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);
}
,onStatusChange: function (form)
{
if (this.$('new-id').value == 0)
form.insertRow ();
}
,onOperationsDone: function ()
{
2015-08-17 18:02:14 +00:00
Htk.Toast.showMessage (_('NewChangedSuccessfully'));
this.onReturnClick ();
}
,onBodyChange: function ()
{
2016-10-11 07:26:10 +00:00
this.setEditorText ();
}
,onAcceptClick: function ()
{
2016-10-11 07:26:10 +00:00
this.$('iter').set ('text', this.editor.getContent ());
this.$('iter').performOperations ();
}
,onReturnClick: function ()
{
this.hash.set ({'form': 'news/news'});
}
});
2015-12-10 13:48:43 +00:00
});