Add custom code into onReady section. Will be executed under $(function(){ .. })

@param jQuery_Chain|string $js

@return $this
195078
public function addOnReady($js)
    {
        if (is_object($js)) {
            $js = $js->getString();
        }
        $this->app->template->appendHTML('document_ready', $js.";\n");

        return $this;
    }
1319473
protected function autoloadJS()
	{
		if (!is_string($this->callback))
		{
			return;
		}

		try
		{
			$this->js = FunctionProvider::get($this->callback);
		}
		catch (InvalidArgumentException $e)
		{
			// Do nothing
		}
	}
439038
public function run(JsUtils $js) {
		if(isset($this->_bsComponent)===false)
			$this->_bsComponent=$js->semantic()->accordion("#".$this->identifier,$this->params);
			$this->addEventsOnRun($js);
			return $this->_bsComponent;
	}
234058
public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
		foreach ( $this->elements as $element ) {
			$element->on($event, $jsCode, $stopPropagation, $preventDefault);
		}
		return $this;
	}
1242053
protected function initialize($js, $options)
	{
		$this->options = array_merge(static::$defaultOptions, $options);
		$js            = str_replace("\r\n", "\n", $js);
		$js            = str_replace('/**/', '', $js);
		$this->input   = str_replace("\r", "\n", $js);

		// We add a newline to the end of the script to make it easier to deal
		// with comments at the bottom of the script- this prevents the unclosed
		// comment error that can otherwise occur.
		$this->input .= PHP_EOL;

		// Populate "a" with a new line, "b" with the first character, before
		// entering the loop
		$this->a = "\n";
		$this->b = $this->getReal();
	}
609397
public function addJS($src,$val='',$priority=100){
		$this->js[]=array(
			'src' => $src,
			'val' => $val,
			'priority'=>$priority,
			'lazy'=>true,//Load after, if it is possible.
			);
		}
1230885
function(src) {
    var _deferred = $q.defer();

    // Instance
    var _loadable = {

      src: src,

      // Loading completion flag
      isComplete: false,

      promise: _deferred.promise,

      // TODO switch to $document
      $element: document.createElement('script')
    };

    // Build DOM element
    _loadable.$element.src = src;
    _loadable.$element.type = 'text/javascript';
    _loadable.$element.async = false;

    _head.insertBefore(_loadable.$element, _head.firstChild);

    // Mark loading in progress
    _loadingList.push(_loadable);

    // Completion
    _loadable.$element.onload = _loadable.$element.onreadystatechange = function() {

      if(!_loadable.isComplete && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
        _loadable.isComplete = true;
        _loadable.$element.onload = _loadable.$element.onreadystatechange = null;
        
        if(_head && _loadable.$element.parentNode) {
          _head.removeChild(_loadable.$element);
        }

        // Mark complete
        var i = _loadingList.indexOf(_loadable);
        if(i !== -1) {
          _loadingList.splice(i, 1);
        }
        _completedList.push(_loadable);

        _deferred.resolve(_loadable);
      }
    };

    return _loadable;
  }
507865
def set_customjs_callback(self, js_callback, handle):
        
        if self.on_events:
            for event in self.on_events:
                handle.js_on_event(event, js_callback)
        if self.on_changes:
            for change in self.on_changes:
                handle.js_on_change(change, js_callback)
        elif hasattr(handle, 'callback'):
            handle.callback = js_callback
440707
public static function parseBlockJs($js)
    {
        $jsBlockPattern = '|^<script[^>]*>(?P<block_content>.+?)</script>$|is';
        if (preg_match($jsBlockPattern, trim($js), $matches)) {
            $js = trim($matches['block_content']);
        }
        return $js;
    }
9098
public function send($js)
    {
        $this->_output_bypass = true;
        $this->sse->send($js);
        $this->_output_bypass = false;

        return $this;
    }
1254325
public function onReady()
    {
        $this->ptr =& $this->result;
        if (!isset($this->password)) {
            if (isset($this->pool->config->select->value)) {
                $this->select($this->pool->config->select->value);
            }
            parent::onReady();
            $this->setWatermark(null, $this->pool->maxAllowedPacket + 2);
            return;
        }
        $this->sendCommand('AUTH', [$this->password], function () {
            if ($this->result !== 'OK') {
                $this->log('Auth. error: ' . json_encode($this->result));
                $this->finish();
            }
            if (isset($this->pool->config->select->value)) {
                $this->select($this->pool->config->select->value);
            }
            parent::onReady();
            $this->setWatermark(null, $this->pool->maxAllowedPacket + 2);
        });
    }
648770
public function run(JsUtils $js) {
		$this->_bsComponent=$js->bootstrap()->collapse("#".$this->element->getIdentifier());
		$this->addEventsOnRun($js);
		return $this->_bsComponent;
	}
1266161
public function addJs($link) {
        
        if ( ! empty($link)) {
            if ( ! is_array($link)) {
                $link = [$link];
            }
            $this->js = array_merge($this->js, $link);
        }
    }
803394
function( map ) {
					var code;
					if ( map ) {
						if ( completed ) {

							// Execute the appropriate callbacks
							jqXHR.always( map[ jqXHR.status ] );
						} else {

							// Lazy-add the new callbacks in a way that preserves old ones
							for ( code in map ) {
								statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
							}
						}
					}
					return this;
				}
1001168
public function add($tag_content)
    {
        if (!empty($tag_content)) {
            $this->__template->registry->addEntry($tag_content, 'js_entries');
        }
        return $this;
    }
877555
public static function require_js() {
		require_once TINYMCE4_PATH . '/thirdparty/tinymce/tiny_mce_gzip.php';
		$useGzip = Config::inst()->get('CustomHtmlEditorField', 'use_gzip');

		$configs = array();
		$externalPlugins = array();
		$internalPlugins = array();
		$languages = array();

		foreach (self::$configs as $configID => $config) {
			$settings = $config->settings;
			// parse plugins
			$configPlugins = array();
			foreach($config->plugins as $plugin => $path) {
				if(!$path) {
					$configPlugins[] = $plugin;
					$internalPlugins[] = $plugin;
				} else {
					$configPlugins[] = '-' . $plugin;
					if ( !array_key_exists($plugin, $externalPlugins) )
					{
						$externalPlugins[$plugin] = sprintf(
							'tinymce.PluginManager.load("%s", "%s");',
							$plugin,
							$path
						);
					}
				}
			}

			// save config plugins settings
			$settings['plugins'] = implode(',', $configPlugins);

			// buttons
			foreach ($config->buttons as $i=>$buttons) {
				// $settings['theme_advanced_buttons'.$i] = implode(',', $buttons); // tinymce3
				$settings['toolbar'.$i] = implode(',', $buttons); // tinymce4
			}

			// languages
			$languages[] = $config->getOption('language');

			// save this config settings
			$configs[$configID] = $settings;
		}

		// tinyMCE JS requirement
		if ( $useGzip )
		{
			$tag = TinyMCE4_Compressor::renderTag(array(
				'url' => TINYMCE4_DIR . '/thirdparty/tinymce/tiny_mce_gzip.php',
				'plugins' => implode(',', $internalPlugins),
				'themes' => 'advanced',
				'languages' => implode(",", array_filter($languages))
			), true);
			preg_match('/src="([^"]*)"/', $tag, $matches);
			Requirements::javascript(html_entity_decode($matches[1]));
		}
		else{
			Requirements::javascript(TINYMCE4_DIR . '/thirdparty/tinymce/jquery.tinymce.min.js');
		}

		// block old scripts
		Requirements::block(MCE_ROOT . 'tiny_mce_src.js');
		Requirements::block(FRAMEWORK_DIR ."/javascript/HtmlEditorField.js");
		Requirements::block('htmlEditorConfig');

		// load replacements
		Requirements::javascript(TINYMCE4_DIR ."/javascript/HtmlEditorField.js");

		if(Member::currentUser()) {
			CustomHtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
		}

		// prepare external plugins js string
		$externalPlugins = array_values($externalPlugins);
		$externalPlugins = implode("\n	", $externalPlugins);

		// tinyMCE config object and external plugings
		$configsJS = "
if((typeof tinyMCE != 'undefined')) {
	$externalPlugins
	var ssTinyMceConfig = " . Convert::raw2json($configs) . ";
}";
		Requirements::customScript($configsJS, 'customHtmlEditorConfig');
	}
1088350
public function js()
    {
        $renderer = $this->debugbar->getJavascriptRenderer();

        $content = $renderer->dumpAssetsToString('js');

        $response = new Response(
            $content, 200, [
                'Content-Type' => 'text/javascript',
            ]
        );

        return $this->cacheResponse($response);
    }