/** * Add jQuery highlight plugin. * * @param string $selector The selector to make highlight. * @param string $text The text to mark. * @param array $options The options of this script. * * @see http://bartaz.github.io/sandbox.js/jquery.highlight.html * * @return void */ public static function highlight($selector = '.hasHighlight', $text = null, $options = array()) { $asset = static::getAsset(); if (!static::inited(__METHOD__)) { JQueryScript::core(); $asset->addJS('jquery/jquery.highlight.js'); } if (!static::inited(__METHOD__, func_get_args()) && $selector && $text) { if (is_array($text)) { $text = implode(' ', $text); } $defaultOptions = array('element' => 'mark', 'className' => 'windwalker-highlight'); $options = $asset::getJSObject(ArrayHelper::merge($defaultOptions, $options)); $js = <<<JS // Highlight Text jQuery(document).ready(function(\$) { \t\$('{$selector}').highlight('{$text}', {$options}); }); JS; $asset->internalJS($js); } }