<commit_before>/* FTUI Plugin
 * Copyright (c) 2015-2016 <NAME> <<EMAIL>>
 * Under MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

/* global ftui:true, Modul_widget:true */

"use strict";

function depends_popup() {
    if (!$.fn.draggable)
        return [ftui.config.basedir + "lib/jquery-ui.min.js"];
}

var Modul_popup = function () {

    function hide(dialog, mode) {
        switch (mode) {
        case 'animate':
            dialog.animate({
                height: 0,
                width: 0,
                top: dialog.options.start_top,
                left: dialog.options.start_left,
                opacity: 0
            }, 500, "swing", function () {
                ftui.showModal(false);
                dialog.trigger('fadeout');
            });
            break;
        default:

            dialog.fadeOut(500, function () {
                ftui.showModal(false);
                dialog.trigger('fadeout');
            });
        }
    }

    function show(dialog, mode) {
        dialog.detach();
        $('body').append(dialog);
        if (dialog.options.shade) {
            ftui.showModal(true);
        }
        switch (mode) {
        case 'animate':
            dialog.show();
            dialog.animate({
                height: dialog.options.height,
                width: dialog.options.width,
                top: dialog.options.end_top,
                left: dialog.options.end_left,
                opacity: 1
            }, 500, "swing", function () {
                dialog.trigger('fadein');
            });
            break;
        default:
            dialog.css({
                height: dialog.options.height,
                width: dialog.options.width,
                top: dialog.options.end_top,
                left: dialog.options.end_left,
            });
            dialog.fadeIn(500);
            dialog.trigger('fadein');
        }
    }

    function init_attr(elem) {
        elem.initData('get', 'STATE');
        elem.initData('get-on', 'on');
        elem.initData('get-off', 'off');
        elem.initData('height', '300px');
        elem.initData('width', '400px');
        elem.initData('mode', 'animate');
        elem.initData('starter', null);
        elem.initData('draggable', true);

        me.addReading(elem, 'get');
    }

    function init() {

        me.elements = $('div[data-type="' + me.widgetname + '"]', me.area);
        me.elements.each(function (index) {
            var elem = $(this);
            me.init_attr(elem);

            var id = [me.widgetname, me.area, index].join('_');
            var dialog = elem.find('.dialog');
            var starter = (elem.data('starter')) ? $(document).find(elem.data('starter')) : elem.children(":first");
            if (starter.hasClass('dialog')) {
                starter = $('<div/>', {
                    class: 'dialog-starter'
                }).prependTo(elem);
            } else
                starter.addClass('dialog-starter');

            var close = $('<div/>', {
                class: 'dialog-close'
            }).html('x').appendTo(dialog);

            if (dialog && close && starter) {
                elem.attr('data-id', id);
                dialog.attr('data-id', id);
                starter.attr('data-id', id);
                close.attr('data-id', id);

                if (elem.data('draggable')) {
                    if ($.fn.draggable)
                        dialog.draggable();
                    else {
                        console.log("widget_popup tries to load jquery ui. insert correct script tag into html header to avoid error (and this warning)");
                        console.log('e.g.: <script type="text/javascript" src="lib/jquery-ui.min.js"></script>');
                    }
                }<commit_msg>Improved selector for close element of Popup<commit_after>/* FTUI Plugin
 * Copyright (c) 2015-2016 <NAME> <<EMAIL>>
 * Under MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

/* global ftui:true, Modul_widget:true */

"use strict";

function depends_popup() {
    if (!$.fn.draggable)
        return [ftui.config.basedir + "lib/jquery-ui.min.js"];
}

var Modul_popup = function () {

    function hide(dialog, mode) {
        switch (mode) {
        case 'animate':
            dialog.animate({
                height: 0,
                width: 0,
                top: dialog.options.start_top,
                left: dialog.options.start_left,
                opacity: 0
            }, 500, "swing", function () {
                ftui.showModal(false);
                dialog.trigger('fadeout');
            });
            break;
        default:

            dialog.fadeOut(500, function () {
                ftui.showModal(false);
                dialog.trigger('fadeout');
            });
        }
    }

    function show(dialog, mode) {
        dialog.detach();
        $('body').append(dialog);
        if (dialog.options.shade) {
            ftui.showModal(true);
        }
        switch (mode) {
        case 'animate':
            dialog.show();
            dialog.animate({
                height: dialog.options.height,
                width: dialog.options.width,
                top: dialog.options.end_top,
                left: dialog.options.end_left,
                opacity: 1
            }, 500, "swing", function () {
                dialog.trigger('fadein');
            });
            break;
        default:
            dialog.css({
                height: dialog.options.height,
                width: dialog.options.width,
                top: dialog.options.end_top,
                left: dialog.options.end_left,
            });
            dialog.fadeIn(500);
            dialog.trigger('fadein');
        }
    }

    function init_attr(elem) {
        elem.initData('get', 'STATE');
        elem.initData('get-on', 'on');
        elem.initData('get-off', 'off');
        elem.initData('height', '300px');
        elem.initData('width', '400px');
        elem.initData('mode', 'animate');
        elem.initData('starter', null);
        elem.initData('draggable', true);

        me.addReading(elem, 'get');
    }

    function init() {

        me.elements = $('div[data-type="' + me.widgetname + '"]', me.area);
        me.elements.each(function (index) {
            var elem = $(this);
            me.init_attr(elem);

            var id = [me.widgetname, me.area, index].join('_');
            var dialog = elem.find('.dialog');
            var starter = (elem.data('starter')) ? $(document).find(elem.data('starter')) : elem.children(":first");
            if (starter.hasClass('dialog')) {
                starter = $('<div/>', {
                    class: 'dialog-starter'
                }).prependTo(elem);
            } else
                starter.addClass('dialog-starter');

            var close = $('<div/>', {
                class: 'dialog-close',
                id: elem.attr('id')
            }).html('x').appendTo(dialog);

            if (dialog && close && starter) {
                elem.attr('data-id', id);
                dialog.attr('data-id', id);
                starter.attr('data-id', id);
                close.attr('data-id', id);

                if (elem.data('draggable')) {
                    if ($.fn.draggable)
                        dialog.draggable();
                    else {
                        console.log("widget_popup tries to load jquery ui. insert correct script tag into html header to avoid error (and this warning)");
                        console.log('e.g.: <script type="text/javascript" src="lib/jquery-ui.min.js"></script>');
                    }
                }
{'fraction_non_alphanumeric': 0.14888369678089305, 'fraction_numerical': 0.00778816199376947, 'mean_word_length': 1.4727214377406932, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '98862', 'n_tokens_mistral': 2257, 'n_tokens_neox': 2057, 'n_words': 404}