Habari\FormControlFacet::pre_out PHP Метод

pre_out() публичный Метод

Return the HTML/script required for this control. Do it only once.
public pre_out ( ) : string
Результат string The HTML/javascript required for this control.
    public function pre_out()
    {
        $out = '';
        if (!self::$outpre) {
            self::$outpre = true;
            $out = <<<CUSTOM_AUTOCOMPLETE_JS
\t\t\t\t<script type="text/javascript">
controls.init(function(){
\t\$('.facet_ui:not(.initok)').each(function(){
\t\tvar self = \$(this);
\t\tself.addClass('initok');
\t\tvar target = \$('#' + self.data('target'));
\t\tvar facet_config = target.data('facet-config');
\t\tself.data('visualsearch', VS.init({
\t\t\tcontainer: self,
\t\t\tquery: target.val(),
\t\t\tshowFacets: false, /* true makes them pop up automatically, but is kind of weird */
\t\t\tcallbacks: {
\t\t\t\tsearch: function(query, searchCollection) {
\t\t\t\t\tif(facet_config.onsearch != undefined) {
\t\t\t\t\t\teval(facet_config.onsearch);
\t\t\t\t\t}
\t\t\t\t},
\t\t\t\tfacetMatches: function(callback) {
\t\t\t\t\tif(facet_config.facetsURL != undefined) {
\t\t\t\t\t\t\$.post(
\t\t\t\t\t\t\tfacet_config.facetsURL,
\t\t\t\t\t\t\t{},
\t\t\t\t\t\t\tfunction(response) {
\t\t\t\t\t\t\t\tcallback(response.data);
\t\t\t\t\t\t\t}
\t\t\t\t\t\t)
\t\t\t\t\t}
\t\t\t\t\telse {
\t\t\t\t\t\tcallback(facet_config.facets)
\t\t\t\t\t}
\t\t\t\t},
\t\t\t\tvalueMatches: function(facet, searchTerm, callback) {
\t\t\t\t\tif(facet_config.valuesURL != undefined) {
\t\t\t\t\t\t\$.post(
\t\t\t\t\t\t\tfacet_config.valuesURL,
\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\tfacet: facet,
\t\t\t\t\t\t\t\tq: searchTerm
\t\t\t\t\t\t\t},
\t\t\t\t\t\t\tfunction(response) {
\t\t\t\t\t\t\t\tcallback(response.data);
\t\t\t\t\t\t\t}
\t\t\t\t\t\t)
\t\t\t\t\t}
\t\t\t\t\telse {
\t\t\t\t\t\tif(facet_config.values[facet]!=undefined){
\t\t\t\t\t\t\tcallback(facet_config.values[facet]);
\t\t\t\t\t\t}
\t\t\t\t\t}
\t\t\t\t}
\t\t\t}
\t\t}))
\t\t.closest('form').on('submit', function(){
\t\t\ttarget.val(self.data('visualsearch').searchBox.value());
\t\t});
\t});

});
\t\t\t\t</script>
CUSTOM_AUTOCOMPLETE_JS;
        }
        return $this->controls_js($out);
    }