Krajee

Advanced Usage Example 2

Thankful to Krajee! BUY A COFFEEor to get more out of us.

Display the editor to launch in full screen mode by default. This example uses another button which when clicked shows the full screen editor. The example uses the plugin event normalScreen to monitor when the full screen mode is restored to normal. It automatically hides the editor when restored to normal screen mode. The plugin method toggleFullScreen is called when the button is pressed the second time after the plugin has been already initialized.

Note, the demo example(s) uses:

  • this as the raw input source for the markdown textarea.

  • these assets loaded on the page in the order mentioned.

Tip

Not seeing the updated content on this page! Hard refresh your browser to clean cache for this page (e.g. SHIFT-F5 on Windows Chrome)


Example
Code
<button type='button' class='btn btn-secondary btn-toggle-editor'>Launch Full Screen Editor &raquo;</button>
<span class='cont-example-2' style='display:none'>
<textarea id="editor-a2" name="editor-a2" class="form-control" rows="15">
{RAW MARKDOWN DATA}
</textarea>
</span>

<script type="text/javascript">
var $editor = $('#editor-a2'), // the markdown editor textarea
    $cont = $('.cont-example-2'); // the container enclosing the editor
// detect custom button click
$('.btn-toggle-editor').on('click', function() {
    $cont.show(); // show enveloping container
    if (!$editor.data('markdownEditor')) { // plugin is not initialized
        $editor.markdownEditor({startFullScreen: true}); // launch in full screen mode   
    } else { // plugin already initialized
        $editor.markdownEditor('toggleFullScreen'); // call toggleFullScreen method
    }
});
// when fullscreen mode is restored to normal
$editor.on('normalScreen.markdownEditor', function() { 
    $cont.hide(); // hide enveloping container
});
</script>

Note

You can now visit the Krajee Webtips Q & A forum for searching OR asking questions OR helping programmers with answers on these extensions and plugins. For asking a question click here. Select the appropriate question category (i.e. Krajee Plugins) and choose this current page plugin in the question related to field.

The comments and discussion section below are intended for generic discussions or feedback for this plugin. Developers may not be able to search or lookup here specific questions or tips on usage for this plugin.

 
visitors to Krajee Jquery Plugins since 22-May-2017