legacy/src/wysiwyg-editor.js
function()
                {
                    var $toolbar = $('<div/>').addClass( 'wysiwyg-toolbar' ).addClass( toolbar_top ? 'wysiwyg-toolbar-top' : 'wysiwyg-toolbar-bottom' );
                    if( toolbar_focus )
                        $toolbar.hide().addClass( 'wysiwyg-toolbar-focus' );
                    // Add buttons to the toolbar
                    add_buttons_to_toolbar( $toolbar, false,
                        function() {
                            // Open a popup from the toolbar
                            var $popup = $(wysiwygeditor.openPopup());
                            // if wrong popup -> create a new one
                            if( $popup.hasClass('wysiwyg-popup') && $popup.hasClass('wysiwyg-popuphover') )
                                $popup = $(wysiwygeditor.closePopup().openPopup());
                            if( ! $popup.hasClass('wysiwyg-popup') )
                                // add classes + content
                                $popup.addClass( 'wysiwyg-popup' );
                            return $popup;
                        },
                        function( $popup, target, overwrite_offset ) {
                            // Popup position
                            var $button = $(target);
                            var popup_width = $popup.outerWidth();
                            // Point is the top/bottom-center of the button
                            var left = $button.offset().left - $container.offset().left + parseInt($button.width() / 2) - parseInt(popup_width / 2);
                            var top = $button.offset().top - $container.offset().top;
                            if( toolbar_top )
                                top += $button.outerHeight();
                            else
                                top -= $popup.outerHeight();
                            if( overwrite_offset )
                            {
                                left = overwrite_offset.left;
                                top = overwrite_offset.top;
                            }
                            popup_position( $popup, $container, left, top );
                        });
                    if( toolbar_top )
                        $container.prepend( $toolbar );
                    else
                        $container.append( $toolbar );
                }
function()
                {
                    var $toolbar = $('<div/>').addClass( 'wysiwyg-toolbar' ).addClass( toolbar_top ? 'wysiwyg-toolbar-top' : 'wysiwyg-toolbar-bottom' );
                    if( toolbar_focus )
                        $toolbar.hide().addClass( 'wysiwyg-toolbar-focus' );
                    // Add buttons to the toolbar
                    add_buttons_to_toolbar( $toolbar, false,
                        function() {
                            // Open a popup from the toolbar
                            var $popup = $(wysiwygeditor.openPopup());
                            // if wrong popup -> create a new one
                            if( $popup.hasClass('wysiwyg-popup') && $popup.hasClass('wysiwyg-popuphover') )
                                $popup = $(wysiwygeditor.closePopup().openPopup());
                            if( ! $popup.hasClass('wysiwyg-popup') )
                                // add classes + content
                                $popup.addClass( 'wysiwyg-popup' );
                            return $popup;
                        },
                        function( $popup, target, overwrite_offset ) {
                            // Popup position
                            var $button = $(target);
                            var popup_width = $popup.outerWidth();
                            // Point is the top/bottom-center of the button
                            var left = $button.offset().left - $container.offset().left + parseInt($button.width() / 2) - parseInt(popup_width / 2);
                            var top = $button.offset().top - $container.offset().top;
                            if( toolbar_top )
                                top += $button.outerHeight();
                            else
                                top -= $popup.outerHeight();
                            if( overwrite_offset )
                            {
                                left = overwrite_offset.left;
                                top = overwrite_offset.top;
                            }
                            popup_position( $popup, $container, left, top );
                        });
                    if( toolbar_top )
                        $container.prepend( $toolbar );
                    else
                        $container.append( $toolbar );
                }
function ( ) { var $toolbar = $ ( '<div/>' ) . addClass ( 'wysiwyg-toolbar' ) . addClass ( toolbar_top ? 'wysiwyg-toolbar-top' : 'wysiwyg-toolbar-bottom' ) ; if ( toolbar_focus ) $toolbar . hide ( ) . addClass ( 'wysiwyg-toolbar-focus' ) ; // Add buttons to the toolbar add_buttons_to_toolbar ( $toolbar , false , function ( ) { // Open a popup from the toolbar var $popup = $ ( wysiwygeditor . openPopup ( ) ) ; // if wrong popup -> create a new one if ( $popup . hasClass ( 'wysiwyg-popup' ) && $popup . hasClass ( 'wysiwyg-popuphover' ) ) $popup = $ ( wysiwygeditor . closePopup ( ) . openPopup ( ) ) ; if ( ! $popup . hasClass ( 'wysiwyg-popup' ) ) // add classes + content $popup . addClass ( 'wysiwyg-popup' ) ; return $popup ; } , function ( $popup , target , overwrite_offset ) { // Popup position var $button = $ ( target ) ; var popup_width = $popup . outerWidth ( ) ; // Point is the top/bottom-center of the button var left = $button . offset ( ) . left - $container . offset ( ) . left + parseInt ( $button . width ( ) / 2 ) - parseInt ( popup_width / 2 ) ; var top = $button . offset ( ) . top - $container . offset ( ) . top ; if ( toolbar_top ) top += $button . outerHeight ( ) ; else top -= $popup . outerHeight ( ) ; if ( overwrite_offset ) { left = overwrite_offset . left ; top = overwrite_offset . top ; } popup_position ( $popup , $container , left , top ) ; } ) ; if ( toolbar_top ) $container . prepend ( $toolbar ) ; else $container . append ( $toolbar ) ; }
Callback to create toolbar on demand
Callback to create toolbar on demand