Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
66b128f
Base Asset factory classes and datafiles
Fedik Jan 3, 2016
c314d9f
Asset get/set methods and parse json data file
Fedik Jan 4, 2016
d4e8ac6
Resolve dependency for active assets
Fedik Jan 6, 2016
d7c8995
Update joomla.asset.json for JUI
Fedik Jan 6, 2016
fddfe0e
Attach StyleSheet and JavaScript files to the document
Fedik Jan 6, 2016
ee6a280
Trigger the onBeforeHeadAttachHtmlAsset event and Attach the assets. …
Fedik Jan 7, 2016
410d18b
'template.protostar' as example of custom template asset (on fly)
Fedik Jan 7, 2016
5c32779
Use glob() instead of JFolder::files, for avoid uselless deep recursi…
Fedik Jan 7, 2016
b79043c
Asset 'template.isis' for isis template, and html/jquery.php use assets
Fedik Jan 7, 2016
8c36ca7
html/bootstrap.php use asset
Fedik Jan 7, 2016
8d2eb71
Asset for html/behavior.php (partialy), Chosen, Quickicon update check
Fedik Jan 7, 2016
5785c8f
Replace html5fallback.js to asset html5fallback
Fedik Jan 7, 2016
c4add8c
Asset for sortablelist, jquery.searchtools
Fedik Jan 7, 2016
2ca81ef
Allow attach for css/js with a version
Fedik Jan 7, 2016
be08d1e
Backward compatibility hack for alredy added JavaScripts
Fedik Jan 7, 2016
1814703
Move attach() into JHtmlAssetItem
Fedik Jan 9, 2016
fea6f30
Move Trigger the onBeforeHeadAttachHtmlAsset event insid JHtmlAssetFa…
Fedik Jan 9, 2016
ecff41a
Prepare Asset instance
Fedik Jan 9, 2016
026250e
Support for Attributes of JavaScript/StyleSheet files
Fedik Jan 9, 2016
30d20ee
asset for jhtml::calendar
Fedik Jan 9, 2016
6259467
Test for external/relative Path while attach the asset file
Fedik Jan 11, 2016
097d2df
Codestyle
Fedik Jan 11, 2016
ee1421e
Asset data file state constants
Fedik Jan 11, 2016
70ec14f
AssetItem State constants
Fedik Jan 11, 2016
84df1ff
Bower compatible naming
Fedik Jan 12, 2016
5767faf
Improve JHtmlAsset load/unload
Fedik Jan 12, 2016
a9e82c7
Do not add Version to external file
Fedik Jan 12, 2016
e24922d
Update templates asset
Fedik Jan 12, 2016
65540f4
Updtae comments
Fedik Jan 16, 2016
7da2d7f
Merge branch 'master' into assets-factory-sync
Fedik Jan 16, 2016
2b4e51b
Copyright date
Fedik Jan 16, 2016
a9ab1d9
Remove unused joomla.filesystem.file
Fedik Jan 16, 2016
af01e1a
Use JVersion::generateMediaVersion() to calculate version hash
Fedik Jan 16, 2016
bd3e576
PHP 5.3 compatibility
Fedik Jan 17, 2016
f59a175
JHtmlAssetFactory to JAssetFactory and JHtmlAssetItem to JAssetItem
Fedik Jan 17, 2016
41c427b
Codestyle :ghost:
Fedik Jan 18, 2016
06e609b
JAssetFactory getInstance
Fedik Jan 22, 2016
007c9d6
Sync. Merge branch 'master' into assets-factory
Fedik Apr 10, 2016
e964d6e
Add JHtml::_('asset.scriptDeclaration', $content) and JHtml::_('asset…
Fedik Apr 10, 2016
ac5fefd
Support for Placeholders, in the jss/css path
Fedik Apr 10, 2016
4371851
Support `joomla.asset.json` in templates. Add joomla.asset.json in to…
Fedik Apr 10, 2016
62196af
Improve the Calendar asset
Fedik Apr 10, 2016
1d1aa6e
Sync. Merge branch 'master' into assets-factory
Fedik May 21, 2016
f88e650
Sync. Merge branch 'master' into assets-factory-sync
Fedik Sep 11, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions administrator/templates/isis/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,8 @@
// Output as HTML5
$doc->setHtml5(true);

// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');

$doc->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js');

// Add Stylesheets
$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template.css');

// Load optional RTL Bootstrap CSS
JHtml::_('bootstrap.loadCss', false, $this->direction);

// Load specific language related CSS
$file = 'language/' . $lang->getTag() . '/' . $lang->getTag() . '.css';

if (is_file($file))
{
$doc->addStyleSheet($file);
}

// Load custom.css
$file = 'templates/' . $this->template . '/css/custom.css';

if (is_file($file))
{
$doc->addStyleSheetVersion($file);
}
// Load the template asset
JHtml::_('asset.load', $doc->direction == 'rtl' ? 'template.isis.rtl' : 'template.isis.ltr');

// Link color
if ($this->params->get('linkColor'))
Expand Down
25 changes: 2 additions & 23 deletions administrator/templates/isis/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,8 @@
$frontEndUri->setScheme(((int) $app->get('force_ssl', 0) === 2) ? 'https' : 'http');
$mainPageUri = $frontEndUri->toString();

// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');

$doc->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js');

// Add Stylesheets
$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template' . ($this->direction == 'rtl' ? '-rtl' : '') . '.css');

// Load specific language related CSS
$languageCss = 'language/' . $lang->getTag() . '/' . $lang->getTag() . '.css';

if (file_exists($languageCss) && filesize($languageCss) > 0)
{
$doc->addStyleSheetVersion($languageCss);
}

// Load custom.css
$customCss = 'templates/' . $this->template . '/css/custom.css';

if (file_exists($customCss) && filesize($customCss) > 0)
{
$doc->addStyleSheetVersion($customCss);
}
// Load the template asset
JHtml::_('asset.load', $doc->direction == 'rtl' ? 'template.isis.rtl' : 'template.isis.ltr');

// Detecting Active Variables
$option = $input->get('option', '');
Expand Down
43 changes: 43 additions & 0 deletions administrator/templates/isis/joomla.asset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"title" : "Joomla! isis template",
"name" : "template.isis",
"author" : "Joomla! CMS",
"version": "1.0",

"assets": [
{
"name": "template.isis",
"versionAttach": true,
"dependency": [
"bootstrap.js"
],
"js": [
"template.js"
]
},
{
"name": "template.isis.ltr",
"versionAttach": true,
"dependency": [
"template.isis"
],
"css": [
"template.css",
"language/[LANGUAGE_TAG]/[LANGUAGE_TAG].css",
"custom.css"
]
},
{
"name": "template.isis.rtl",
"versionAttach": true,
"dependency": [
"template.isis"
],
"css": [
"template-rtl.css",
"language/[LANGUAGE_TAG]/[LANGUAGE_TAG].css",
"custom.css"
]
}
]
}
27 changes: 2 additions & 25 deletions administrator/templates/isis/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,8 @@
$background_color = $this->params->get('loginBackgroundColor') ? $this->params->get('loginBackgroundColor') : '';
$color_is_light = ($background_color && colorIsLight($background_color));

// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');
JHtml::_('bootstrap.tooltip');

// Add Stylesheets
$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template' . ($this->direction == 'rtl' ? '-rtl' : '') . '.css');

// Load optional RTL Bootstrap CSS
JHtml::_('bootstrap.loadCss', false, $this->direction);

// Load specific language related CSS
$file = 'language/' . $lang->getTag() . '/' . $lang->getTag() . '.css';

if (is_file($file))
{
$doc->addStyleSheet($file);
}

// Load custom.css
$file = 'templates/' . $this->template . '/css/custom.css';

if (is_file($file))
{
$doc->addStyleSheetVersion($file);
}
// Load the template asset
JHtml::_('asset.load', $doc->direction == 'rtl' ? 'template.isis.rtl' : 'template.isis.ltr');

// Detecting Active Variables
$option = $app->input->getCmd('option', '');
Expand Down
1 change: 1 addition & 0 deletions administrator/templates/isis/templateDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<filename>cpanel.php</filename>
<filename>favicon.ico</filename>
<filename>index.php</filename>
<filename>joomla.asset.json</filename>
<filename>login.php</filename>
<filename>templateDetails.xml</filename>
<filename>template_preview.png</filename>
Expand Down
3 changes: 1 addition & 2 deletions layouts/joomla/form/field/checkboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
*/

// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js', false, true);
JHtml::_('asset.load', 'html5fallback');

/**
* The format of the input tag to be filled in using sprintf.
Expand Down
3 changes: 1 addition & 2 deletions layouts/joomla/form/field/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
*/

// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js', false, true);
JHtml::_('asset.load', 'html5fallback');
?>
<input type="file"
name="<?php echo $name; ?>"
Expand Down
3 changes: 1 addition & 2 deletions layouts/joomla/form/field/radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
*/

// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js', false, true);
JHtml::_('asset.load', 'html5fallback');

/**
* The format of the input tag to be filled in using sprintf.
Expand Down
4 changes: 1 addition & 3 deletions layouts/joomla/html/formbehavior/ajaxchosen.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
JText::script('JGLOBAL_KEEP_TYPING');
JText::script('JGLOBAL_LOOKING_FOR');

// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'jui/ajax-chosen.min.js', false, true, false, false, $debug);
JHtml::_('asset.load', 'chosen.ajax');

JFactory::getDocument()->addScriptDeclaration(
"
Expand Down
5 changes: 1 addition & 4 deletions layouts/joomla/html/formbehavior/chosen.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

extract($displayData);

// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'jui/chosen.jquery.min.js', false, true, false, false, $debug);
JHtml::_('stylesheet', 'jui/chosen.css', false, true);
JHtml::_('asset.load', 'chosen');

// Options array to json options string
$options_str = json_encode($options, ($debug && defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : false));
Expand Down
6 changes: 1 addition & 5 deletions layouts/joomla/html/sortablelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@

extract($displayData);

// Depends on jQuery UI
JHtml::_('jquery.ui', array('core', 'sortable'));

JHtml::_('script', 'jui/sortablelist.js', false, true);
JHtml::_('stylesheet', 'jui/sortablelist.css', false, true, false);
JHtml::_('asset.load', 'sortablelist');

// Attach sortable to document
JFactory::getDocument()->addScriptDeclaration(
Expand Down
140 changes: 140 additions & 0 deletions libraries/cms/html/asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_PLATFORM') or die;

/**
* HTML Asset helper.
*
* @since 5.0
*/
class JHtmlAsset
{
/**
* Make the asset active
*
* @param string|JAssetItem $asset Asset instance or name
*
* @return JAssetItem
*/
public static function load($asset)
{
$name = $asset;
$factory = JAssetFactory::getInstance();

if ($asset instanceof JAssetItem)
{
$name = $asset->getName();
$factory->addAsset($asset);
}

$factory->setAssetState($name, JAssetItem::ASSET_STATE_ACTIVE);

return $factory->getAsset($name);
}

/**
* Make the asset inactive
*
* @param string|JAssetItem $asset Asset instance or name
*
* @return JAssetItem
*/
public static function unload($asset)
{
$name = ($asset instanceof JAssetItem) ? $asset->getName() : $asset;
$factory = JAssetFactory::getInstance();

$factory->setAssetState($name, JAssetItem::ASSET_STATE_INACTIVE);

return $factory->getAsset($name);
}

/**
* Add asset to the collection of known assets
*
* @param JAssetItem $asset Asset instance
*
* @return void
*/
public static function add(JAssetItem $asset)
{
JAssetFactory::getInstance()->addAsset($asset);
}

/**
* Adds a script to the page
*
* @param string $content Script
* @param array $deps The script dependancy
* @param string $type Scripting mime (defaults to 'text/javascript')
*
* @return void
*/
public static function scriptDeclaration($content, array $deps = array(), $type = 'text/javascript')
{
static $loaded = array();
$key = md5($content);

// Avoid duplication
if (!empty($loaded[$key]))
{
return;
}

// Load dependancy
if (!empty($deps))
{
foreach($deps as $dep) {
static::load($dep);
}
}

// Attach the script to the Document
$doc = JFactory::getDocument();
$doc->addScriptDeclaration($content, $type);

$loaded[$key] = true;
}

/**
* Adds a stylesheet declaration to the page
*
* @param string $content Style declarations
* @param array $deps The style dependancy
* @param string $type Type of stylesheet (defaults to 'text/css')
*
* @return void
*/
public static function styleDeclaration($content, array $deps = array(), $type = 'text/css')
{
static $loaded = array();
$key = md5($content);

// Avoid duplication
if (!empty($loaded[$key]))
{
return;
}

// Load dependancy
if (!empty($deps))
{
foreach($deps as $dep) {
static::load($dep);
}
}

// Attach the script to the Document
$doc = JFactory::getDocument();
$doc->addStyleDeclaration($content, $type);

$loaded[$key] = true;
}
}
Loading