Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
$script .= "\t\t".'}'."\n";
$script .= "\t\t".'}'."\n";

JHtml::_('behavior.core');
JHtml::_('formbehavior.chosen', 'select');

JFactory::getDocument()->addScriptDeclaration($script);
Expand Down
2 changes: 2 additions & 0 deletions layouts/joomla/toolbar/batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

JHtml::_('behavior.core');

$title = $displayData['title'];
$message = JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
?>
Expand Down
2 changes: 2 additions & 0 deletions layouts/joomla/toolbar/confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

JHtml::_('behavior.core');

$doTask = $displayData['doTask'];
$class = $displayData['class'];
$text = $displayData['text'];
Expand Down
2 changes: 2 additions & 0 deletions layouts/joomla/toolbar/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

JHtml::_('behavior.core');

$doTask = $displayData['doTask'];
$text = $displayData['text'];

Expand Down
2 changes: 2 additions & 0 deletions layouts/joomla/toolbar/popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

JHtml::_('behavior.core');

$doTask = $displayData['doTask'];
$class = $displayData['class'];
$text = $displayData['text'];
Expand Down
2 changes: 2 additions & 0 deletions layouts/joomla/toolbar/slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

JHtml::_('behavior.core');

$doTask = $displayData['doTask'];
$class = $displayData['class'];
$text = $displayData['text'];
Expand Down
2 changes: 2 additions & 0 deletions layouts/joomla/toolbar/standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

JHtml::_('behavior.core');

$doTask = $displayData['doTask'];
$class = $displayData['class'];
$text = $displayData['text'];
Expand Down
3 changes: 3 additions & 0 deletions layouts/joomla/toolbar/versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/

defined('_JEXEC') or die;

JHtml::_('behavior.framework');

?>
<a rel="{handler: 'iframe', size: {x: <?php echo $displayData['height']; ?>, y: <?php echo $displayData['width']; ?>}}"
href="index.php?option=com_contenthistory&amp;view=history&amp;layout=modal&amp;tmpl=component&amp;item_id=<?php echo (int) $displayData['itemId']; ?>&amp;type_id=<?php echo $displayData['typeId']; ?>&amp;type_alias=<?php echo $displayData['typeAlias']; ?>&amp;<?php echo JSession::getFormToken(); ?>=1"
Expand Down
55 changes: 40 additions & 15 deletions libraries/cms/html/behavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ public static function caption($selector = 'img.caption')
* @return void
*
* @since 1.5
*
* @Deprecated 3.4 Use formvalidator instead
*/
public static function formvalidation()
{
JLog::add('The use of formvalidation is deprecated use formvalidator instead.', JLog::WARNING, 'deprecated');

// Only load once
if (isset(static::$loaded[__METHOD__]))
{
Expand All @@ -148,8 +152,32 @@ public static function formvalidation()
// Include MooTools framework
static::framework();

// Include jQuery Framework
JHtml::_('jquery.framework');
// Load the new jQuery code
static::formvalidator();
}

/**
* Add unobtrusive JavaScript support for form validation.
*
* To enable form validation the form tag must have class="form-validate".
* Each field that needs to be validated needs to have class="validate".
* Additional handlers can be added to the handler for username, password,
* numeric and email. To use these add class="validate-email" and so on.
*
* @return void
*
* @since 3.4
*/
public static function formvalidator()
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}

// Include core
static::core();

// Add validate.js language strings
JText::script('JLIB_FORM_FIELD_INVALID');
Expand Down Expand Up @@ -209,10 +237,10 @@ public static function combobox()
{
return;
}
// Include MooTools framework
static::framework();
// Include core
static::core();

JHtml::_('script', 'system/combobox.js', true, true);
JHtml::_('script', 'system/combobox.js', false, true);
static::$loaded[__METHOD__] = true;
}

Expand Down Expand Up @@ -400,14 +428,14 @@ public static function multiselect($id = 'adminForm')
}

// Include jQuery
JHtml::_('jquery.framework');
static::core();

JHtml::_('script', 'system/multiselect.js', true, true);
JHtml::_('script', 'system/multiselect.js', false, true);

// Attach multiselect to document
JFactory::getDocument()->addScriptDeclaration(
"window.addEvent('domready', function() {
new Joomla.JMultiSelect('" . $id . "');
"jQuery(document).ready(function() {
Joomla.JMultiSelect('" . $id . "');
});"
);

Expand Down Expand Up @@ -649,9 +677,9 @@ public static function highlighter(array $terms, $start = 'highlighter-start', $
}

// Include jQuery
JHtml::_('jquery.framework');
static::core();

JHtml::_('script', 'system/highlighter.js', true, true);
JHtml::_('script', 'system/highlighter.js', false, true);

$terms = str_replace('"', '\"', $terms);

Expand Down Expand Up @@ -695,11 +723,8 @@ public static function noframes()
return;
}

// Include MooTools framework
static::framework();

// Include jQuery
JHtml::_('jquery.framework');
static::core();

$js = "jQuery(function () {if (top == self) {document.documentElement.style.display = 'block'; }" .
" else {top.location = self.location; }});";
Expand Down
1 change: 0 additions & 1 deletion libraries/cms/toolbar/button/confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function fetchId($type = 'Confirm', $msg = '', $name = '', $text = '', $t
*/
protected function _getCommand($msg, $name, $task, $list)
{
JHtml::_('behavior.framework');
$message = JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
$message = addslashes($message);

Expand Down
2 changes: 0 additions & 2 deletions libraries/cms/toolbar/button/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ public function fetchId()
*/
protected function _getCommand($ref, $com, $override, $component)
{
JHtml::_('behavior.framework');

// Get Help URL
$url = JHelp::createURL($ref, $com, $override, $component);
$url = htmlspecialchars($url, ENT_QUOTES);
Expand Down
1 change: 0 additions & 1 deletion libraries/cms/toolbar/button/standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public function fetchId($type = 'Standard', $name = '', $text = '', $task = '',
*/
protected function _getCommand($name, $task, $list)
{
JHtml::_('behavior.framework');
$message = JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
$message = addslashes($message);

Expand Down
2 changes: 1 addition & 1 deletion media/system/js/multiselect-uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
(function($) {

Joomla = Joomla || {};
Joomla = window.Joomla || {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch 👍

var $boxes;
Joomla.JMultiSelect = function(table) {
var $last,
Expand Down
2 changes: 1 addition & 1 deletion media/system/js/multiselect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
GNU General Public License version 2 or later; see LICENSE.txt
*/
(function(b){Joomla=Joomla||{};var a;Joomla.JMultiSelect=function(f){var e,c=function(g){a=b("#"+g).find("input[type=checkbox]");a.on("click",function(h){d(h)})},d=function(j){var h=b(j.target),l,k,g,i;if(j.shiftKey&&e.length){l=h.is(":checked");k=a.index(e);g=a.index(h);if(g<k){i=k;k=g;g=i}a.slice(k,g+1).attr("checked",l)}e=h};c(f)}})(jQuery);
(function(b){Joomla=window.Joomla||{};var a;Joomla.JMultiSelect=function(f){var e,c=function(g){a=b("#"+g).find("input[type=checkbox]");a.on("click",function(h){d(h)})},d=function(j){var h=b(j.target),l,k,g,i;if(j.shiftKey&&e.length){l=h.is(":checked");k=a.index(e);g=a.index(h);if(g<k){i=k;k=g;g=i}a.slice(k,g+1).attr("checked",l)}e=h};c(f)}})(jQuery);
8 changes: 3 additions & 5 deletions tests/unit/suites/libraries/cms/html/JHtmlBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function testFormvalidation()

JHtmlBehaviorInspector::formvalidation();
$this->assertEquals(
array('JHtmlBehavior::core' => true, 'JHtmlBehavior::framework' => array('core' => true), 'JHtmlBehavior::formvalidation' => true),
array('JHtmlBehavior::core' => true, 'JHtmlBehavior::framework' => array('core' => true), 'JHtmlBehavior::formvalidator' => true),
JHtmlBehaviorInspector::getLoaded()
);
}
Expand Down Expand Up @@ -266,7 +266,7 @@ public function testCombobox()

JHtmlBehaviorInspector::combobox();
$this->assertEquals(
array('JHtmlBehavior::core' => true, 'JHtmlBehavior::framework' => array('core' => true), 'JHtmlBehavior::combobox' => true),
array('JHtmlBehavior::core' => true, 'JHtmlBehavior::combobox' => true),
JHtmlBehaviorInspector::getLoaded()
);
}
Expand Down Expand Up @@ -446,14 +446,12 @@ public function getMultiselectData()
array(
array(
'JHtmlBehavior::core' => true,
'JHtmlBehavior::framework' => array('core' => true),
'JHtmlBehavior::multiselect' => array('adminForm' => true),
)
),
array(
array(
'JHtmlBehavior::core' => true,
'JHtmlBehavior::framework' => array('core' => true),
'JHtmlBehavior::multiselect' => array('adminForm2' => true),
),
'adminForm2'
Expand Down Expand Up @@ -677,7 +675,7 @@ public function testNoFrames()

JHtmlBehaviorInspector::noframes();
$this->assertEquals(
array('JHtmlBehavior::core' => true, 'JHtmlBehavior::noframes' => true, 'JHtmlBehavior::framework' => array('core' => true)),
array('JHtmlBehavior::core' => true, 'JHtmlBehavior::noframes' => true),
JHtmlBehaviorInspector::getLoaded()
);
}
Expand Down