markupmirror/static/markupmirror/markupmirror.js
/* when init a textarea with codemirror we also create an iframe */
when init a textarea with codemirror we also create an iframe
when init a textarea with codemirror we also create an iframe
function create_iframe(textarea) {
    var $textarea = $(textarea),
        $iframe = $('<iframe />').attr(
            'src', $textarea.data('mmSettings').base_url),
        $codemirror = $textarea.next('.CodeMirror');
    $iframe
        .addClass('CodeMirror-preview')
        .on({
            'load': function() {
                var $this = $(this);
                $this.data('load', true);
                if( $this.data('replace') !== undefined ) {
                    $this.trigger('_update', {html: $this.data('replace')});
                }
            },
            '_resize': function() {
                $(this).css({
                    'height': $(this).prev().outerHeight()
                });
            },
            '_update': function(e, data) {
                $(this)
                    .contents()
                    .find('body')
                    .html(data.html);
            }
        })
        .trigger('_resize')
        .appendTo($codemirror);
    update_preview($codemirror.get(0).CodeMirror);
}
function create_iframe ( textarea ) { var $textarea = $ ( textarea ) , $iframe = $ ( '<iframe />' ) . attr ( 'src' , $textarea . data ( 'mmSettings' ) . base_url ) , $codemirror = $textarea . next ( '.CodeMirror' ) ; $iframe . addClass ( 'CodeMirror-preview' ) . on ( { 'load' : function ( ) { var $this = $ ( this ) ; $this . data ( 'load' , true ) ; if ( $this . data ( 'replace' ) !== undefined ) { $this . trigger ( '_update' , { html : $this . data ( 'replace' ) } ) ; } } , '_resize' : function ( ) { $ ( this ) . css ( { 'height' : $ ( this ) . prev ( ) . outerHeight ( ) } ) ; } , '_update' : function ( e , data ) { $ ( this ) . contents ( ) . find ( 'body' ) . html ( data . html ) ; } } ) . trigger ( '_resize' ) . appendTo ( $codemirror ) ; update_preview ( $codemirror . get ( 0 ) . CodeMirror ) ; }
when init a textarea with codemirror we also create an iframe
when init a textarea with codemirror we also create an iframe
/* update iframe contents for the first time */