public function scripts() { $scripts = ''; foreach ($this->config['scripts'] as $src) { $scripts .= HTML::script($src); } return $scripts; }
public function script() { $nret = ''; foreach ($this->script as $script) { $nret .= HTML::script($script); } return $nret; }
public static function scripts() { $buffer = "\n"; //js links foreach (self::$js as $item) { $buffer .= HTML::script($item); } //inline scripts if (count(self::$scripts)) { $buffer .= sprintf("\n<script language=\"javascript\" type=\"text/javascript\">\n\$(document).ready(function () {\n\n %s \n\n});\n\n</script>\n", implode("\n", self::$scripts)); } return $buffer; }
public static function head() { $buffer = "\n"; //css links foreach (self::$css as $item) { $buffer .= HTML::style($item); } //js links foreach (self::$js as $item) { $buffer .= HTML::script($item); } return $buffer; }
/** * PUblish a single asset * * @param array $asset The asset data * @param string $type The asset type * @return string The link to the asset resource */ protected function publishAsset($asset, $type) { $output = ''; // prepare target directory if (!file_exists(dirname($asset['full']))) { File::makeDirectory(dirname($asset['full']), 0777, true); } // create the asset file File::put($asset['full'], $asset['contents']); // add the element $link = $asset['link'] . '?' . str_random(10); if ($type === 'styles') { $output .= HTML::style($link); } elseif ($type === 'scripts') { $output .= HTML::script($link); } return $output; }
/** * Process given JS path. * * @return string */ public function js($path, $attrs = [], $timestamp = null, $secure = null) { return HTML::script($this->process($path, '.js', $timestamp), $attrs, $secure); }
/** * Prepare the given assets to be rendered to call the Casset controller * and return the HTML link to that resource. * * @param array $assets * @param string $type * * @return string */ public function prepareForController($assets, $type) { $controller_url = $this->cdn ? $this->cdn . '/' : '/'; $controller_url .= $this->route . '/' . $type; $controller_url .= '?c=' . urlencode($this->name); $links = array(); foreach ($assets as &$asset) { $attributes = $asset['attributes']; unset($asset['attributes']); unset($asset['ext']); if (empty($asset['dependencies'])) { unset($asset['dependencies']); } if (!$this->combine) { $url = $controller_url . '&files=' . base64_encode(json_encode(array($asset))); $url .= $this->version ? '&v=' . $this->version : ''; if ('style' == $type) { $links[] = HTML::style($url, $attributes); } else { $links[] = HTML::script($url, $attributes); } } } if ($this->combine) { $url = $controller_url . '&files=' . base64_encode(json_encode($assets)); $url .= $this->version ? '&v=' . $this->version : ''; if ('style' == $type) { $links[] = HTML::style($url); } else { $links[] = HTML::script($url); } } return implode('', $links); }
/** * render the html code for the given position * @param string $position to render * @return html the rendered html code */ protected function render($position = 'head') { $html = null; if ($position == 'head') { $html[] = '<meta charset="' . $this->charset . '">'; $html[] = '<title>' . e($this->getTitle()) . '</title>'; if ($this->html5Ie) { $html[] = '<!--[if lt IE 9]>' . PHP_EOL . HTML::script('//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js') . '<![endif]-->'; } if (!is_null($this->cssFiles)) { ksort($this->cssFiles, SORT_NUMERIC); foreach ($this->cssFiles as $index => $items) { foreach ($items as $item) { $html[] = HTML::style($item[0]); } } } if (!is_null($this->css)) { $html[] = '<style type="text/css">' . implode($this->css) . '</style>'; } if (!is_null($this->favicon)) { $html[] = $this->getLinkTag('shortcut icon', $this->favicon, 'image/x-icon'); } if (!is_null($this->appleTouchIcon)) { $html[] = $this->getLinkTag('apple-touch-icon', $this->appleTouchIcon); } if (!is_null($this->canonical)) { $html[] = $this->getLinkTag('canonical', $this->canonical); } $meta = $this->getMetaProperties(); if (!is_null($meta)) { $html[] = $meta; } $og_tags = $this->renderOgTags(); if (!is_null($og_tags)) { $html[] = $og_tags; } } if ($position == 'footer') { if (!is_null($this->facebook_sdk)) { $html[] = '<div id="fb-root"></div>'; $this->js($this->getFacebookSdkCode(), 'footer', array('jquery' => false)); } if (!is_null($this->twitter_sdk)) { $this->js($this->getTwitterSdkCode(), 'footer', array('jquery' => false)); } if (!is_null($this->youtube_sdk) or !is_null($this->google_plus_sdk)) { $this->js($this->getGoogleSdkCode(), 'footer', array('jquery' => false)); } } if (!is_null($this->jsFiles[$position])) { ksort($this->jsFiles[$position], SORT_NUMERIC); foreach ($this->jsFiles[$position] as $index => $items) { foreach ($items as $item) { if (!in_array($item[0], $this->jsFilesLoaded)) { $html[] = HTML::script($item[0]); $this->jsFilesLoaded[] = $item[0]; } } } } if (!is_null($this->js[$position])) { ksort($this->js[$position]); foreach ($this->js[$position] as $index => $items) { foreach ($items as $item) { if (isset($item[1]['jquery']) and $item[1]['jquery'] === true) { $jquery_code[] = $item[0]; } else { $js_code[] = $item[0]; } } } if (isset($jquery_code)) { $js_code[] = 'jQuery(document).ready(function($){ ' . implode($jquery_code) . ' });'; } $html[] = '<script>' . implode($js_code) . '</script>'; } return !is_null($html) ? implode($html) : null; }
/** * Get the links to all of the registered JavaScript assets. * * @param array $attributes * @param bool $freeze * @return string */ public function scripts($attributes = array(), $freeze = false) { $this->assetCapture = Config::get('theme::assetCapture'); if ($script = $this->group('script')) { // This line fixing config path. $script = $this->configAssetUrl($script); return HTML::script($script, $attributes); } }