Annotation of loncom/html/adm/ckeditor/plugins/chem/dialogs/chem.js, revision 1.1

1.1     ! damieng     1: /**
        !             2:  * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
        !             3:  * For licensing, see LICENSE.md or http://ckeditor.com/license
        !             4:  */
        !             5: 
        !             6: 'use strict';
        !             7: 
        !             8: CKEDITOR.dialog.add( 'chem', function( editor ) {
        !             9:     return {
        !            10:         title: editor.lang.chem.title,
        !            11:         minWidth: 300,
        !            12:         minHeight: 150,
        !            13:         contents: [
        !            14:             {
        !            15:                 id: 'info',
        !            16:                 elements: [
        !            17:                     {
        !            18:                         id: 'ta',
        !            19:                         type: 'textarea',
        !            20:                         label: editor.lang.chem.dialogInput,
        !            21: 
        !            22:                         onLoad: function() {
        !            23:                             var that = this;
        !            24: 
        !            25:                             if ( !( CKEDITOR.env.ie && CKEDITOR.env.version == 8 ) ) {
        !            26:                                 this.getInputElement().on( 'keyup', function() {
        !            27:                                     var dlg = that.getDialog();
        !            28:                                     var preview = dlg.getContentElement('info', 'preview');
        !            29:                                     var div = preview.getElement();
        !            30:                                     var span = div.getChild( 0 );
        !            31:                                     var value = that.getInputElement().getValue();
        !            32:                                     if (value)
        !            33:                                         CKEDITOR.plugins.chem.add_html(value, span);
        !            34:                                     else
        !            35:                                         span.setHtml('?');
        !            36:                                 } );
        !            37:                             }
        !            38:                         },
        !            39: 
        !            40:                         setup: function( widget ) {
        !            41:                             this.setValue( widget.data.reaction );
        !            42:                         },
        !            43: 
        !            44:                         commit: function( widget ) {
        !            45:                             widget.setData( 'reaction', this.getValue() );
        !            46:                         }
        !            47:                     },
        !            48:                     {
        !            49:                         id: 'preview',
        !            50:                         type: 'html',
        !            51:                         html:
        !            52:                             '<div style="width:100%;text-align:center;">' +
        !            53:                                 '<span class="chem"></span>' +
        !            54:                             '</div>',
        !            55: 
        !            56:                         onLoad: function() {
        !            57:                         },
        !            58: 
        !            59:                         setup: function( widget ) {
        !            60:                             var span = CKEDITOR.document.getById( this.domId ).getChild( 0 );
        !            61:                             if (widget.data.reaction)
        !            62:                                 CKEDITOR.plugins.chem.add_html( widget.data.reaction, span);
        !            63:                             else
        !            64:                                 span.setHtml('?');
        !            65:                         }
        !            66:                     }
        !            67:                 ]
        !            68:             }
        !            69:         ]
        !            70:     };
        !            71: } );

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>