Erstellt ein Snippet welches mit %self% auf die Componente als jQuery Objekt zugreifen kann

@return Psc\JS\Snippet
330482
protected function createJooseSnippet($jooseClass, $constructParams = NULL, Array $dependencies = array()) {
    return JooseSnippet::create($jooseClass, $constructParams, $dependencies);
  }
993562
function toHtml(){
        global $PAGE;

        // Enhance the select with javascript.
        $this->_generateId();
        $id = $this->getAttribute('id');

        if (!$this->isFrozen()) {
            $PAGE->requires->js_call_amd('core/form-autocomplete', 'enhance', $params = array('#' . $id, $this->tags, $this->ajax,
                $this->placeholder, $this->casesensitive, $this->showsuggestions, $this->noselectionstring));
        }

        $html = parent::toHTML();

        // Hacky bodge to add in the HTML code to the option tag. There is a nicer
        // version of this code in the new template version (see export_for_template).
        if ($this->valuehtmlcallback) {
            $html = preg_replace_callback('~value="([^"]+)"~', function($matches) {
                $value = html_entity_decode($matches[1]);
                $htmlvalue = call_user_func($this->valuehtmlcallback, $value);
                if ($htmlvalue !== false) {
                    return $matches[0] . ' data-html="' . s($htmlvalue) . '"';
                } else {
                    return $matches[0];
                }
            }, $html);
        }

        return $html;
    }
1060203
protected function getInlineJavaScript()
    {
        $javascript = '';

        foreach ($this->fields as $field) {
            $field_javascript = $field->getRendererInlineJavaScript();
            if ($field_javascript != '') {
                $javascript .= "\n" . $field_javascript;
            }
        }

        foreach ($this->fields as $field) {
            $field_javascript = $field->getInlineJavaScript();
            if ($field_javascript != '') {
                $javascript .= "\n" . $field_javascript;
            }
        }

        return $javascript;
    }
1272441
public function jsRender()
    {
        $pre = '';

        if ($this->preventDefault) {
            $this->fx_args = ['event'];
            $pre .= "\n".$this->indent.'  event.preventDefault();';
        }

        if ($this->stopPropagation) {
            $this->fx_args = ['event'];
            $pre .= "\n".$this->indent.'  event.stopPropagation();';
        }

        $output = 'function('.implode(',', $this->fx_args).') {';
        $output .= $pre;
        foreach ($this->fx_statements as $statement) {
            if (!$statement) {
                // null passed
                continue;
            }

            if ($statement instanceof jsChain && !$statement->_chain) {
                // chain contains no statements, so probably is useless
                continue;
            }

            if ($statement instanceof jsExpressionable) {
                $statement = $statement->jsRender();
            } else {
                throw new Exception(['Incorrect statement for jsFunction.', 'statement' => $statement]);
            }

            $output .= "\n".$this->indent.'  '.$statement.';';
        }

        $output .= "\n".$this->indent.'}';

        return $output;
    }
693104
public function getJavascript()
    {
        if (!empty($this->columns)) {
            $this->setJsInitParam('columns', $this->getColumnsForJs());
        }

        $js = 'var '.$this->tableName.' = $("#'.$this->tableName.'").dataTable('."\n"
                .(!empty($this->jsInitParameters) ? PHPToJS::render((object) $this->jsInitParameters) : '')."\n"
            .');'."\n";

        $js .= $this->getJavascriptSearchPart();

        return $js;
    }
598829
protected function getInlineJavaScript()
    {
        $javascript = sprintf(
            "var %s_obj = new SwatCheckboxEntryList('%s');",
            $this->id,
            $this->id
        );

        // set check-all controller if it is visible
        if ($this->show_check_all && count($this->getOptions()) > 1) {
            $javascript .= sprintf(
                "\n%s_obj.setController(%s_obj);",
                $this->getCompositeWidget('check_all')->id,
                $this->id
            );
        }

        return $javascript;
    }
151872
public function renderBegin()
	{
		foreach ($this->form->getControls() as $control) {
			$control->setOption(RendererOptions::_rendered, FALSE);
		}

		$prototype = $this->form->getElementPrototype();
		$prototype = $this->configElem('form', $prototype);

		if ($this->form->isMethod('get')) {
			$el = $prototype;
			/** @noinspection PhpUndefinedFieldInspection */
			$query = parse_url($el->action, PHP_URL_QUERY);
			/** @noinspection PhpUndefinedFieldInspection */
			$el->action = str_replace("?$query", '', $el->action);
			$s = '';
			foreach (preg_split('#[;&]#', $query, NULL, PREG_SPLIT_NO_EMPTY) as $param) {
				$parts = explode('=', $param, 2);
				$name = urldecode($parts[0]);
				if (!isset($this->form[ $name ])) {
					$s .= Html::el('input', ['type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])]);
				}
			}

			return $el->startTag() . "\n$s";
		} else {
			return $prototype->startTag();
		}
	}
1112409
public function getInput() {
        $options = $this->htmlOptions;
        $options['class'] = (isset($options['class']) ? $options['class'] . ' ' : '') . 'input autocomplete';
        $options['autc_ajax'] = ($this->ajaxUpdate?'1':'0');
        $options['autc_url'] = $this->ajaxURL;
        $options['autc_for'] = str_replace(['[', ']'], '__', $this->getName());
        $options['autc_minletters'] = $this->minLettersToSearch;
        $options['autc_insert'] = ($this->allowNewValues?'1':'0');
        $this->ajaxExtraParams[WebApp::get()->request()->getCsrfKey()] = WebApp::get()->request()->getCsrfValue();
        $options['autc_extraparams'] = json_encode($this->ajaxExtraParams);
        $opts = [];
        foreach ($this->options as $word){
            $opts[] = "<li>$word</li>";
        }
        $opts = implode("", $opts);
        return Form::get()->hiddenInput($this->getName(), $this->getValue(), ['id' => str_replace(['[', ']'], '__', $this->getName())])
            . Form::get()->input("", "text", $this->getValue(), $options)
            . Html::get()->tag("div", "<ul>$opts</ul>", ['id' => 'options-for-' . $options['autc_for'], 'class' => 'form-autocomplete-list'])
            . Html::get()->scriptFile($this->form->getAssetsURL()  . 'autocomplete.js');
    }
1317754
protected function getInlineJavaScript()
    {
        switch ($this->tab_position) {
            case self::POSITION_RIGHT:
                $position = 'right';
                break;
            case self::POSITION_LEFT:
                $position = 'left';
                break;
            case self::POSITION_BOTTOM:
                $position = 'bottom';
                break;
            case self::POSITION_TOP:
            default:
                $position = 'top';
                break;
        }

        return sprintf(
            "var %s_obj = new YAHOO.widget.TabView(" .
                "'%s', {orientation: '%s'});",
            $this->id,
            $this->id,
            $position
        );
    }
887165
public function buildCode()
    {
        $res = '';
        foreach ($this->styles as $href => $val) {
            $res .= '<link href="' . $href . '" rel="stylesheet" type="text/css" />' . "\r\n";
        }

        return $res;
    }
1242337
private function getCode()
    {
        $_paq = '';

        foreach ($this->options as $option) {
            $option[0] = "'".$option[0]."'";
            $_paq .= sprintf('_paq.push([%s]);', implode(',', $option));
        }

        return <<<PWK
<script>
    var _paq = _paq || [];
    {$_paq}
    (function() {
        var u="{$this->piwikUrl}";
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', {$this->siteId}]);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
    })();
</script>
<noscript><p><img src="{$this->piwikUrl}piwik.php?idsite={$this->siteId}" style="border:0;" alt="" /></p></noscript>
PWK;
    }
549368
public function getInlineJavaScript()
    {
        if (count($this->view->model) < 2) {
            return '';
        }

        // set the controller of the check-all widget
        return sprintf(
            "%s_obj.setController(%s);",
            $this->check_all->id,
            $this->list_id
        );
    }
313442
public function compare() {
        $compareContent=false;
        
        
        //Get the Main Revision
        $snippet1=Snippet::get()->byID(intval($this->urlParams['ID']));
        if(empty($snippet1) || $snippet1===false || $snippet1->ID==0) {
            $snippet1=false;
        }
        
        if($snippet1!==false) {
            //Get the Comparision Revision
            $snippet2=$snippet1->Version(intval($this->urlParams['OtherID']));
            if(empty($snippet2) || $snippet1===false || $snippet2->ID==0) {
                $snippet2=false;
            }
            
            if($snippet2!==false) {
                $snippet1Text=preg_replace('/\r\n|\n|\r/', "\n", $snippet1->SnippetText);
                $snippet2Text=preg_replace('/\r\n|\n|\r/', "\n", $snippet2->Text);
                
                //Generate the diff file
                $diff=new Text_Diff('auto', array(preg_split('/\n/', $snippet1Text), preg_split('/\n/', $snippet2Text)));
                $renderer=new WP_Text_Diff_Renderer_Table();
                
                $renderedDiff=$renderer->render($diff);
                if(!empty($renderedDiff)) {
                    $lTable='<table cellspacing="0" cellpadding="0" border="0" class="diff">'.
                                '<colgroup>'.
                                    '<col class="ltype"/>'.
                                    '<col class="content"/>'.
                                '</colgroup>'.
                                '<tbody>';
                    $rTable=$lTable;
                    
                    header('content-type: text/plain');
                    $xml=simplexml_load_string('<tbody>'.str_replace('&nbsp;', ' ', $renderedDiff).'</tbody>');
                    foreach($xml->children() as $row) {
                        $i=0;
                        $lTable.='<tr>';
                        $rTable.='<tr>';
                        
                        foreach($row->children() as $td) {
                            $attr=$td->attributes();
                            
                            if($i==0) {
                                $lTable.=$td->asXML();
                            }else {
                                $rTable.=$td->asXML();
                            }
                            
                            $i++;
                        }
                        
                        $lTable.='</tr>';
                        $rTable.='</tr>';
                    }
                    
                    $lTable.='</tbody></table>';
                    $rTable.='</tbody></table>';
                    
                    $compareContent='<div class="compare leftSide">'.$lTable.'</div>'.
                                    '<div class="compare rightSide">'.$rTable.'</div>';
                }
            }
        }
        
        
        Requirements::css(CB_DIR.'/css/CompareView.css');
        Requirements::javascript(CB_DIR.'/javascript/CodeBank.CompareView.js');
        
        
        return $this->renderWith('CodeBank_CompareView', array(
                                                                'CompareContent'=>$compareContent
                                                            ));
    }
982362
protected function getInlineJavaScript()
    {
        static $shown = false;

        if (!$shown) {
            $javascript = $this->getInlineJavaScriptTranslations();
            $shown = true;
        } else {
            $javascript = '';
        }

        $javascript .= sprintf(
            "var %s = new %s(\n" . "%s, %s, %s, %s, %s, %s);\n",
            $this->id,
            $this->getJavaScriptClass(),
            SwatString::quoteJavaScriptString($this->id),
            SwatString::quoteJavaScriptString($this->preview_image),
            intval($this->preview_width),
            intval($this->preview_height),
            $this->show_title ? 'true' : 'false',
            SwatString::quoteJavaScriptString($this->preview_title)
        );

        if ($this->container_width !== null) {
            $javascript .= sprintf(
                "%s.width = %s;",
                $this->id,
                (int) $this->container_width
            );
        }

        if ($this->container_height !== null) {
            $javascript .= sprintf(
                "%s.height = %s;",
                $this->id,
                (int) $this->container_height
            );
        }

        return $javascript;
    }
256008
protected function getAppend()
	{
		if ($this->hasAddOn())
		{
			$htmlOptions = $this->appendOptions;

			if (isset($htmlOptions['class']))
				$htmlOptions['class'] .= ' add-on';
			else
				$htmlOptions['class'] = 'add-on';

			ob_start();
			if (isset($this->appendText))
				echo CHtml::tag('span', $htmlOptions, $this->appendText);

			echo '</div>';
			return ob_get_clean();
		} else
			return '';
	}
1257650
function get_content() {
        global $CFG;
        // First check if we have already generated, don't waste cycles
        if ($this->contentgenerated === true) {
            return $this->content;
        }
        // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
        // $this->page->requires->js('/lib/javascript-navigation.js');
        // Navcount is used to allow us to have multiple trees although I dont' know why
        // you would want two trees the same

        block_navigation::$navcount++;

        // Check if this block has been docked
        if ($this->docked === null) {
            $this->docked = get_user_preferences('nav_in_tab_panel_globalnav'.block_navigation::$navcount, 0);
        }

        // Check if there is a param to change the docked state
        if ($this->docked && optional_param('undock', null, PARAM_INT)==$this->instance->id) {
            unset_user_preference('nav_in_tab_panel_globalnav'.block_navigation::$navcount);
            $url = $this->page->url;
            $url->remove_params(array('undock'));
            redirect($url);
        } else if (!$this->docked && optional_param('dock', null, PARAM_INT)==$this->instance->id) {
            set_user_preferences(array('nav_in_tab_panel_globalnav'.block_navigation::$navcount=>1));
            $url = $this->page->url;
            $url->remove_params(array('dock'));
            redirect($url);
        }

        $trimmode = self::TRIM_RIGHT;
        $trimlength = 50;

        if (!empty($this->config->trimmode)) {
            $trimmode = (int)$this->config->trimmode;
        }

        if (!empty($this->config->trimlength)) {
            $trimlength = (int)$this->config->trimlength;
        }

        // Get the navigation object or don't display the block if none provided.
        if (!$navigation = $this->get_navigation()) {
            return null;
        }
        $expansionlimit = null;
        if (!empty($this->config->expansionlimit)) {
            $expansionlimit = $this->config->expansionlimit;
            $navigation->set_expansion_limit($this->config->expansionlimit);
        }
        $this->trim($navigation, $trimmode, $trimlength, ceil($trimlength/2));

        // Get the expandable items so we can pass them to JS
        $expandable = array();
        $navigation->find_expandable($expandable);
        if ($expansionlimit) {
            foreach ($expandable as $key=>$node) {
                if ($node['type'] > $expansionlimit && !($expansionlimit == navigation_node::TYPE_COURSE && $node['type'] == $expansionlimit && $node['branchid'] == SITEID)) {
                    unset($expandable[$key]);
                }
            }
        }

        $limit = 20;
        if (!empty($CFG->navcourselimit)) {
            $limit = $CFG->navcourselimit;
        }
        $expansionlimit = 0;
        if (!empty($this->config->expansionlimit)) {
            $expansionlimit = $this->config->expansionlimit;
        }

        $options = array();
        $options['linkcategories'] = (!empty($this->config->linkcategories) && $this->config->linkcategories == 'yes');

        // Grab the items to display
        $renderer = $this->page->get_renderer($this->blockname);
        $this->content = new stdClass();
        $this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options);

        // Set content generated to true so that we know it has been done
        $this->contentgenerated = true;

        return $this->content;
    }
294486
public function createPreviewTextElement() {
        $options['label']    = $this->translate->_('Preview Text');
        $options['nohidden'] = true;

        return $this->_form->createElement('Html', 'preview_text', $options);
    }