<commit_before>/**
 * Paragraph dashboard
 * @package zork
 * @subpackage paragraph
 * @author <NAME> <<EMAIL>>
 */
( function ( global, $, js )
{
    "use strict";

    if ( typeof js.paragraph.dashboard.image !== "undefined" )
    {
        return;
    }

    js.require( "js.paragraph.image" );

    /**
     * @class Image dashborad
     * @memberOf global.Zork.Paragraph.prototype.dashboard
     */
    global.Zork.Paragraph.prototype.dashboard.image = function ( form, element )
    {
        form    = $( form );
        element = $( element );
        var img = element.find( "img:first" ),
            link = element.find( "a.image-paragraph-link:first" ),
            caption = element.find( "figcaption:first" ),
            elements = {
                "url"       : form.find( ":input[name='paragraph-image[url]']" ),
                "width"     : form.find( ":input[name='paragraph-image[width]']" ),
                "height"    : form.find( ":input[name='paragraph-image[height]']" ),
                "method"    : form.find( ":input[name='paragraph-image[method]']" ),
                "bgColor"   : form.find( ":input[name='paragraph-image[bgColor]']" ),
                "caption"   : form.find( ":input[name='paragraph-image[caption]']" ),
                "alternate" : form.find( ":input[name='paragraph-image[alternate]']" ),
                "linkTo"    : form.find( ":input[name='paragraph-image[linkTo]']" ),
                "linkTarget": form.find( ":input[name='paragraph-image[linkTarget]']" ),
                "lightBox"  : form.find( ":input[name='paragraph-image[lightBox]']" )
            },
            before = {
                "url"       : img.attr( "src" ),
                "caption"   : element.find( "figcaption" ).html(),
                "alternate" : img.attr( "alt" ),
                "linkTo"    : elements.linkTo.val(),
                "linkTarget": elements.linkTarget.val(),
                "lightBox"  : elements.lightBox.attr( "checked" )
            },
            changeTtl = 2000,
            changeTimeout = null,
            reloadImage = function () {
                var src = parseInt( elements.width.val(), 10 ) &&
                          parseInt( elements.height.val(), 10 )
                            ? js.core.thumbnail( {
                                  "url"     : elements.url.val(),
                                  "width"   : elements.width.val(),
                                  "height"  : elements.height.val(),
                                  "method"  : elements.method.val(),
                                  "bgcolor" : elements.bgColor.val()
                              } )
                            : elements.url.val();

                img.one( "load", function () {
                        $( this ).css( {
                            "width"          : "",
                            "height"         : "",
                            "max-width"      : "",
                            "max-height"     : ""
                        } );
                    } )
                   .attr( "src", src );
            },
            changeImage = function ( evt ) {
                if ( evt )
                {
                    if ( changeTimeout )
                    {
                        clearTimeout( changeTimeout );
                    }

                    if ( parseInt( elements.width.val(), 10 ) &&
                         parseInt( elements.height.val(), 10 ) )
                    {
                        if ( elements.method.val() == "fit" )
                        {
                            img.css( {
                                "max-width"  : parseInt( elements.width.val(), 10 ),
                                "max-height" : parseInt( elements.height.val(), 10 )
                            } );
                        }
                        else
                        {
                            img.css( {
                                "width"  : parseInt( elements.width.val(), 10 ),
                                "height" : parseInt( elements.height.val(), 10 )
                            } );
                        }
                    }

                    changeTimeout = setTimeout( changeImage, changeTtl );
                }
                else
                {
                    changeTimeout = null;
                    reloadImage();
                }
            };

        elements.url.on( "change", reloadImage );
        elements.width.on( "keyup change", changeImage );
        elements.height.on( "keyup change", changeImage );
        elements.method.on( "click change", reloadImage );
        elements.bgColor.on( "keyup change", changeImage );

        elements.caption.on( "keyup change", function () {
            var val = $( this ).val();

            caption.html( val )
                   .toggleClass( "empty", !! val );
        } );

        elements.alternate.on( "keyup change", function () {<commit_msg>image paragraph fixes<commit_after>/**
 * Paragraph dashboard
 * @package zork
 * @subpackage paragraph
 * @author <NAME> <<EMAIL>>
 */
( function ( global, $, js )
{
    "use strict";

    if ( typeof js.paragraph.dashboard.image !== "undefined" )
    {
        return;
    }

    js.require( "js.paragraph.image" );

    /**
     * @class Image dashborad
     * @memberOf global.Zork.Paragraph.prototype.dashboard
     */
    global.Zork.Paragraph.prototype.dashboard.image = function ( form, element )
    {
        form    = $( form );
        element = $( element );
        var img = element.find( "img:first" ),
            link = element.find( "a.image-paragraph-link:first" ),
            caption = element.find( "figcaption:first" ),
            elements = {
                "url"       : form.find( ":input[name='paragraph-image[url]']" ),
                "width"     : form.find( ":input[name='paragraph-image[width]']" ),
                "height"    : form.find( ":input[name='paragraph-image[height]']" ),
                "method"    : form.find( ":input[name='paragraph-image[method]']" ),
                "bgColor"   : form.find( ":input[name='paragraph-image[bgColor]']" ),
                "caption"   : form.find( ":input[name='paragraph-image[caption]']" ),
                "alternate" : form.find( ":input[name='paragraph-image[alternate]']" ),
                "linkTo"    : form.find( ":input[name='paragraph-image[linkTo]']" ),
                "linkTarget": form.find( ":input[name='paragraph-image[linkTarget]']" ),
                "lightBox"  : form.find( ":input[name='paragraph-image[lightBox]']" )
            },
            before = {
                "url"       : img.attr( "src" ),
                "caption"   : element.find( "figcaption" ).html(),
                "alternate" : img.attr( "alt" ),
                "linkTo"    : elements.linkTo.val(),
                "linkTarget": elements.linkTarget.val(),
                "lightBox"  : elements.lightBox.attr( "checked" )
            },
            changeTtl = 2000,
            changeTimeout = null,
            reloadImage = function () {
                var src = parseInt( elements.width.val(), 10 ) ||
                          parseInt( elements.height.val(), 10 )
                            ? js.core.thumbnail( {
                                  "url"     : elements.url.val(),
                                  "width"   : elements.width.val(),
                                  "height"  : elements.height.val(),
                                  "method"  : elements.method.val(),
                                  "bgcolor" : elements.bgColor.val()
                              } )
                            : elements.url.val();

                img.one( "load", function () {
                        $( this ).css( {
                            "width"          : "",
                            "height"         : "",
                            "max-width"      : "",
                            "max-height"     : ""
                        } );
                    } )
                   .attr( "src", src );
            },
            changeImage = function ( evt ) {
                if ( evt )
                {
                    var prefix = elements.method.val() == "fit" ? "max-" : "";

                    if ( changeTimeout )
                    {
                        clearTimeout( changeTimeout );
                    }

                    if ( parseInt( elements.width.val(), 10 ) )
                    {
                        img.css(
                            prefix + "width",
                            parseInt( elements.width.val(), 10 )
                        );
                    }

                    if ( parseInt( elements.height.val(), 10 ) )
                    {
                        img.css(
                            prefix + "height",
                            parseInt( elements.height.val(), 10 )
                        );
                    }

                    changeTimeout = setTimeout( changeImage, changeTtl );
                }
                else
                {
                    changeTimeout = null;
                    reloadImage();
                }
            };

        elements.url.on( "change", reloadImage );
        elements.width.on( "keyup change", changeImage );
        elements.height.on( "keyup change", changeImage );
        elements.method.on( "click change", reloadImage );
        elements.bgColor.on( "keyup change", changeImage );

        elements.caption.on( "keyup change", function () {
            var val = $( this ).val();

            caption.html( val )
                   .toggleClass( "empty", !! val );
        } );

        elements.alternate.on( "keyup change", function () {
{'fraction_non_alphanumeric': 0.13782871175688122, 'fraction_numerical': 0.0036836181315870256, 'mean_word_length': 1.1010318142734308, 'pattern_counts': {'":': 24, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2274636', 'n_tokens_mistral': 2559, 'n_tokens_neox': 2403, 'n_words': 426}