<commit_before>(function($){

    $.widget('mapbender.mbSearchRouter', {
        options: {
            asDialog: true,     // Display as jQuery UI dialog
            timeoutFactor: 2    // use delay * timeoutFactor before showing
                                // autocomplete again after a search has been
                                // started
        },

        callbackUrl: null,
        selected: null,
        highlightLayer: null,
        lastSearch: new Date(),
        resultCallbackEvent: null,
        resultCallbackProxy: null,
        searchModel: null,
        autocompleteModel: null,
        popup: null,

        /**
         * Widget creator
         */
        _create: function(){
            if(!Mapbender.checkTarget("mbSearchRouter", this.options.target)){
                return;
            }
            var self = this;
            Mapbender.elementRegistry.onElementReady(this.options.target, $.proxy(self._setup, self));
        },

        _setup: function(){
            var self = this;

            // Prepare callback URL and Search Model
            this.callbackUrl = Mapbender.configuration.application.urls.element +
                '/' + this.element.attr('id') + '/';
            this.searchModel = new Mapbender.SearchModel(null, null, this);

            // bind form reset to reset search model
            this.element.delegate('.search-forms form', 'reset', function(){
                self.searchModel.reset();
            });
            // bind form submit to send search model
            this.element.delegate('.search-forms form', 'submit', function(evt){
                self.searchModel.submit(evt);
            });
            // bind result to result list and map view
            this.searchModel.on('change:results', this._searchResults, this);

            this.searchModel.on('request', this._setActive, this);
            this.searchModel.on('error sync', this._setInactive, this);

            this.resultCallbackProxy = $.proxy(this._resultCallback, this);

            // Prepare autocompletes
            $('form input[data-autocomplete="on"]', this.element).each(
                $.proxy(this._setupAutocomplete, this));
            $('form input[data-autocomplete^="custom:"]', this.element).each(
                $.proxy(this._setupCustomAutocomplete, this));

            // Prepare search button (trigger form submit)
            $('a[role="search_router_search"]')
                .button()
                .click(function(){
                $('form[name="' + self.selected + '"]', self.element).submit();
            });

            // Prevent map getting cursors keys
            this.element.bind('keydown', function(event){
                event.stopPropagation();
            });

            // Listen to changes of search select (switching and forms resetting)
            var routeSelect = $('select#search_routes_route', this.element);
            routeSelect.change($.proxy(this._selectSearch, this));
            Mapbender.elementRegistry.onElementReady(this.options.target, function(){
                routeSelect.change();
                self._trigger('ready');
            });
            // But if there's only one search, we actually don't need the select
            var routeCount = 0;
            for(route in this.options.routes){
                if(this.options.routes.hasOwnProperty(route)){
                    routeCount++;
                }
            }
            if(routeCount === 1){
                $('#search_routes_route_control_group').hide()
                    .next('hr').hide();
            }
            this._trigger('ready');
            this._ready();

            if(this.options.autoOpen) {
                this.open();
            }
        },

        defaultAction: function(callback){
            this.open(callback);
        },

        /**
         * Open method stub. Calls dialog's open method if widget is configured as
         * an dialog (asDialog: true), otherwise just goes on and does nothing.
         */
        open: function(callback){
            this.callback = callback ? callback : null;
            if(true === this.options.asDialog) {
                if(!this.popup || !this.popup.$element){
                    this.popup = new Mapbender.Popup2({
                        title: this.element.attr('title'),
                        draggable: true,
                        modal: false,
                        closeButton: false,
                        closeOnPopupCloseClick: false,
                        closeOnESC: false,
                        content: this.element,
                        width: 450,
                        buttons: {
                            'cancel': {<commit_msg>SearchRouter - resizable frontend popup<commit_after>(function($){

    $.widget('mapbender.mbSearchRouter', {
        options: {
            asDialog: true,     // Display as jQuery UI dialog
            timeoutFactor: 2    // use delay * timeoutFactor before showing
                                // autocomplete again after a search has been
                                // started
        },

        callbackUrl: null,
        selected: null,
        highlightLayer: null,
        lastSearch: new Date(),
        resultCallbackEvent: null,
        resultCallbackProxy: null,
        searchModel: null,
        autocompleteModel: null,
        popup: null,

        /**
         * Widget creator
         */
        _create: function(){
            if(!Mapbender.checkTarget("mbSearchRouter", this.options.target)){
                return;
            }
            var self = this;
            Mapbender.elementRegistry.onElementReady(this.options.target, $.proxy(self._setup, self));
        },

        _setup: function(){
            var self = this;

            // Prepare callback URL and Search Model
            this.callbackUrl = Mapbender.configuration.application.urls.element +
                '/' + this.element.attr('id') + '/';
            this.searchModel = new Mapbender.SearchModel(null, null, this);

            // bind form reset to reset search model
            this.element.delegate('.search-forms form', 'reset', function(){
                self.searchModel.reset();
            });
            // bind form submit to send search model
            this.element.delegate('.search-forms form', 'submit', function(evt){
                self.searchModel.submit(evt);
            });
            // bind result to result list and map view
            this.searchModel.on('change:results', this._searchResults, this);

            this.searchModel.on('request', this._setActive, this);
            this.searchModel.on('error sync', this._setInactive, this);

            this.resultCallbackProxy = $.proxy(this._resultCallback, this);

            // Prepare autocompletes
            $('form input[data-autocomplete="on"]', this.element).each(
                $.proxy(this._setupAutocomplete, this));
            $('form input[data-autocomplete^="custom:"]', this.element).each(
                $.proxy(this._setupCustomAutocomplete, this));

            // Prepare search button (trigger form submit)
            $('a[role="search_router_search"]')
                .button()
                .click(function(){
                $('form[name="' + self.selected + '"]', self.element).submit();
            });

            // Prevent map getting cursors keys
            this.element.bind('keydown', function(event){
                event.stopPropagation();
            });

            // Listen to changes of search select (switching and forms resetting)
            var routeSelect = $('select#search_routes_route', this.element);
            routeSelect.change($.proxy(this._selectSearch, this));
            Mapbender.elementRegistry.onElementReady(this.options.target, function(){
                routeSelect.change();
                self._trigger('ready');
            });
            // But if there's only one search, we actually don't need the select
            var routeCount = 0;
            for(route in this.options.routes){
                if(this.options.routes.hasOwnProperty(route)){
                    routeCount++;
                }
            }
            if(routeCount === 1){
                $('#search_routes_route_control_group').hide()
                    .next('hr').hide();
            }
            this._trigger('ready');
            this._ready();

            if(this.options.autoOpen) {
                this.open();
            }
        },

        defaultAction: function(callback){
            this.open(callback);
        },

        /**
         * Open method stub. Calls dialog's open method if widget is configured as
         * an dialog (asDialog: true), otherwise just goes on and does nothing.
         */
        open: function(callback){
            this.callback = callback ? callback : null;
            if(true === this.options.asDialog) {
                if(!this.popup || !this.popup.$element){
                    this.popup = new Mapbender.Popup2({
                        title: this.element.attr('title'),
                        draggable: true,
                        modal: false,
                        closeButton: false,
                        closeOnPopupCloseClick: false,
                        closeOnESC: false,
                        content: this.element,
                        width: 450,
                        resizable: true,
                        height: 350,
                        buttons: {
                            'cancel': {
{'fraction_non_alphanumeric': 0.11309151553053992, 'fraction_numerical': 0.0017719407963310402, 'mean_word_length': 1.4896211728074729, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1118504', 'n_tokens_mistral': 2343, 'n_tokens_neox': 2230, 'n_words': 523}