Load Bootstrap JavaScript files, from Joomla if possible

@param array|KObjectConfig $config
@return string
357055
public function javascript($config = array())
    {
        return $this->getTemplate()->helper('behavior.bootstrap', array(
            'debug' => JFactory::getApplication()->getCfg('debug'),
            'css' => false,
            'javascript' => true
        ));
    }
1245645
public function autocomplete($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'element'  => null,
            'options_callback' => null, // wraps the call to select2 options in JavaScript, can be used to add JS code
            'options'  => array(
                'minimumInputLength' => 2,
                'validate'      => false, //Toggle if the forms validation helper is loaded
                'queryVarName'  => 'search',
                'width'         => 'resolve',
                'model'		    => $config->model,
                'placeholder'   => $config->prompt,
                'allowClear'    => $config->deselect,
                'value'         => $config->value,
                'text'          => $config->text,
                'selected'      => $config->selected,
                'url'           => $config->url,
                'multiple'      => false
            )
        ))->append(array(
            'options' => array(
                'label' => $config->text
            )
        ));

        $html ='';

        if (!$config->options->url instanceof KHttpUrl) {
            $config->options->url = $this->getObject('lib:http.url', array('url' => $config->options->url));
        }

        $config->options->url->setQuery(array('fields' => $config->value.','.$config->text), true);

        $config->options->url = (string)$config->options->url;

        $options   = $config->options;
        $signature = md5('autocomplete-'.$config->element.$config->options_callback.$options);

        if($config->element && !static::isLoaded($signature))
        {
            $options = (string) $options;

            if ($config->options_callback) {
                $options = $config->options_callback.'('.$options.')';
            }

            $html .= $this->select2(array('element' => false));

            if (!static::isLoaded('koowa-select2-autocomplete')) {
                $html .= '<script>
                if(!Koowa) {
                    var Koowa = {};
                }
                
                Koowa.getSelect2Options = function(options) {
                    var defaults = {
                        width: "resolve",
                        minimumInputLength: 2,
                        theme: "bootstrap",
                        ajax: {
                            url: options.url,
                            delay: 100,
                            data: function (params) {
                                var page  = params.page || 1,  // page is the one-based page number tracked by Select2
                                    query = {
                                        limit: 10, // page size
                                        offset: (page-1)*10
                                    };
                                query[options.queryVarName] = params.term;
            
                                return query;
                            },
                            processResults: function (data, page) {
                                var results = [],
                                    more = (page * 10) < data.meta.total; // whether or not there are more results available
            
                                kQuery.each(data.entities, function(i, item) {
                                    // Change format to what select2 expects
                                    item.id   = item[options.value];
                                    item.text = item[options.text];
            
                                    results.push(item);
                                });
            
                                // notice we return the value of more so Select2 knows if more results can be loaded
                                return {results: results, more: more};
                            }
                        }
                    };
                    
                    var settings = kQuery.extend( {}, defaults, options);
                    
                    return settings;
                };
                </script>';

                static::setLoaded('koowa-select2-autocomplete');
            }

            $html .= '<script>
            kQuery(function($){
                $("'.$config->element.'").select2(Koowa.getSelect2Options('.$options.'));
            });</script>';

            static::setLoaded($signature);
        }

        return $html;
    }
230993
protected function _initialize(KObjectConfig $config)
    {
        $config->append(array(
            'locale'  => JFactory::getConfig()->get('language'),
        ));

        parent::_initialize($config);
    }
441343
public function loadConfig($config = null)
    {
        $config =
            !is_null($config) || !file_exists($this->configFile)
                ? $this->setConfigFile($this->getConfigFile($config))
                : $this->configFile;

        return $this->loadToLaravelConfig($config);
    }
1255526
public function render($config = array())
    {
        // Load the language strings for toolbar button labels
        JFactory::getLanguage()->load('joomla', JPATH_ADMINISTRATOR);

        $html = parent::render($config);

        return $html;
    }
1110482
public function load(array $config)
    {
        $config = $this->getParsedConfig(
            $config,
            $this->config,
            $this->yamlConfigMap,
            $this->required
        );
        $this->setParsedConfig($config);

        return $this;
    }
524586
protected function buildJquery(array $config)
    {
        if (isset($config['jquery_path'])) {
            return array(
                'inputs' => array($config['jquery_path']),
                'output' => $this->normalizePath(isset($config['output_dir']) ? array($config['output_dir'], 'js/jquery.js') : 'js/jquery.js')
            );
        } else {
            return array(
                'inputs' => array(
                    $this->normalizePath($config['bootswatch']['path'], 'bower_components/jquery/dist/jquery.js'),
                ),
                'output' => $this->normalizePath(isset($config['output_dir']) ? array($config['output_dir'], 'js/jquery.js') : 'js/jquery.js')
            );
        }
    }
347525
public function render($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'toolbar' => null,
            'title'   => null,
        ))->append(array(
            'icon' => $config->toolbar->getName()
        ));

        //Set a custom title
        if($config->title || $config->icon)
        {
            if($config->toolbar->hasCommand('title'))
            {
                $command = $config->toolbar->getCommand('title');

                if ($config->title) {
                    $command->set('title', $config->title);
                }

                if ($config->icon) {
                    $command->set('icon', $config->icon);
                }
            }
            else $config->toolbar->addTitle($config->title, $config->icon);
        }

        $html     = '';
        $commands = $config->toolbar->getCommands();

        foreach ($commands as $command)
        {
            if ($command->getName() === 'title')
            {
                $config->command = $command;

                $html .= $this->title($config);
            }
        }

        return $html;
    }
934687
public function vue($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append([
            'debug' => false,
            'vuex' => true,
            'entity' => null
        ]);

        $html = '';

        if (!static::isLoaded('vue'))
        {
            $html .= '<ktml:script src="assets://js/'.($config->debug ? 'build/' : 'min/').'vue.js" />';

            static::setLoaded('vue');
        }

        if ($config->vuex && !static::isLoaded('vuex'))
        {
            $html .= '<ktml:script src="assets://js/polyfill.promise.js" />';
            $html .= '<ktml:script src="assets://js/'.($config->debug ? 'build/' : 'min/').'vuex.js" />';

            static::setLoaded('vuex');
        }

        if ($config->entity instanceof KModelEntityInterface)
        {
            $entity = $config->entity->toArray();
            $entity = is_numeric(key($entity)) ? current($entity) : $entity;
            $entity['_isNew'] = $config->entity->isNew();
            $entity['_name']  = KStringInflector::singularize($config->entity->getIdentifier()->name);

            $html .= $this->koowa($config);
            $html .= "
            <ktml:script src=\"assets://js/koowa.vue.js\" />
            <script>
                kQuery(function($) {
                    var form = $('.k-js-form-controller');
                    
                    if (form.length) {
                        form.data('controller').store = Koowa.EntityStore.create({
                            form: form,
                            entity: ".json_encode($entity)."
                        });
                    }
                });
            </script>
";
        }

        return $html;
    }
16063
public function display($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'editor'    => null,
            'name'      => 'description',
            'value'     => '',
            'width'     => '100%',
            'height'    => '500',
            'cols'      => '75',
            'rows'      => '20',
            'buttons'   => true,
            'options'   => array()
        ));

        // Add editor styles and scripts in JDocument to page when rendering
        $this->getIdentifier('com:koowa.view.page.html')->getConfig()->append(['template_filters' => ['document']]);

        $editor  = JFactory::getEditor($config->editor);
        $options = KObjectConfig::unbox($config->options);

        $result = $editor->display($config->name, $config->value, $config->width, $config->height, $config->cols, $config->rows, KObjectConfig::unbox($config->buttons), $config->name, null, null, $options);
        
        // Some editors like CKEditor return inline JS. 
        $result = str_replace('<script', '<script data-inline', $result);

        return $result;
    }
456199
public function users($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'model'        => 'users',
            'name'         => 'user',
            'value'        => 'id',
            'label'        => 'name',
            'sort'         => 'name',
            'validate'     => false
        ));

        return $this->_autocomplete($config);
    }
756021
protected function buildCssWithSass(array $config)
    {
        $bootstrapFile = $config['assets_dir'].'/stylesheets/_bootstrap.scss';
        if (true === isset($config['customize']['variables_file']) &&
            null !== $config['customize']['variables_file']) {
            $bootstrapFile = $config['customize']['bootstrap_output'];
        }

        $inputs = array(
            $bootstrapFile,
            __DIR__.'/../Resources/sass/form.scss'
        );
        if ('fa' === $config['icon_prefix']) {
            $inputs[] = $config['fontawesome_dir'].'/scss/font-awesome.scss';
        }

        return array(
            'inputs'  => $inputs,
            'filters' => array($config['css_preprocessor']),
            'output'  => $config['output_dir'].'css/bootstrap.css'
        );
    }
1346023
protected function loadInstalledComponentsConfig(array $config = []) : array
    {
        $env    = $this->env === self::WEB ? 'web' : 'console';
        $config = FileHelper::loadExtensionsFiles('config/main.php',   $config);
        $config = FileHelper::loadExtensionsFiles("config/{$env}.php", $config);
        return $config;
    }
701823
protected function _initialize(KObjectConfig $config)
    {
        $config->append(array(
            'options' => array(
                'action'       => JFactory::getApplication()->isSite() ? 'core.login.site' : 'core.login.admin',
                'autoregister' => false,
                'type'         => 'basic'
            ),
        ));

        parent::_initialize($config);
    }
262265
protected function _initialize(KObjectConfig $config)
    {
        $config->append(array(
            'behaviors'         => array('decoratable'),
            'response'          => 'com:koowa.dispatcher.response',
            'request'           => 'com:koowa.dispatcher.request',
            'event_subscribers' => array('unauthorized'),
            'user'              => 'com:koowa.user',
            'limit'             => array(
                'default' => JFactory::getApplication()->getCfg('list_limit'),
                'max'     => 100
            ),
        ));

        parent::_initialize($config);
    }
216206
protected function _initialize(KObjectConfig $config)
    {
        $config->append(array(
            'layout'           => 'joomla',
            'template_filters' => ['module', 'style', 'link', 'meta', 'script', 'title', 'message'],
        ))->append(array(
            'decorator' => $config->layout
        ));

        parent::_initialize($config);
    }
1156247
public function dialog($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'command' => NULL
        ));

        $html = $this->command($config);

        return $html;
    }