Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Behavior #239

Merged
merged 4 commits into from

3 participants

@realityking
Collaborator

A little bit more flexibility for developers.

@ianmacl

Test Results

Total Tests: 1280
Assertions: 2217
Failures: 0
Errors: 0
Test Time: 56.579529

@ianmacl

WARNING! Pull request is not against staging!

Test Results

Total Tests:
Assertions:
Failures:
Errors:
Test Time:

@LouisLandry LouisLandry merged commit 5a0521a into joomla:staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
70 libraries/joomla/html/html/behavior.php
@@ -86,16 +86,23 @@ public static function mootools($debug = null)
/**
* Add unobtrusive javascript support for image captions.
*
+ * @param string $selector The selector for which a caption behaviour is to be applied.
+ *
* @return void
*
* @since 11.1
*/
- public static function caption()
+ public static function caption($selector = 'img.caption')
{
- static $loaded = false;
+ static $caption;
+
+ if (!isset($caption))
+ {
+ $caption = array();
+ }
// Only load once
- if ($loaded)
+ if (isset($caption[$selector]))
{
return;
}
@@ -105,7 +112,16 @@ public static function caption()
$uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
JHtml::_('script', 'system/caption' . $uncompressed . '.js', true, true);
- $loaded = true;
+
+ // Attach caption to document
+ JFactory::getDocument()->addScriptDeclaration("
+ window.addEvent('load', function() {
+ new JCaption('".$selector."');
+ });"
+ );
+
+ // Set static array
+ $tips[$selector] = true;
}
/**
@@ -261,17 +277,14 @@ public static function tooltip($selector = '.hasTip', $params = array())
$opt['showDelay'] = (isset($params['showDelay'])) ? (int) $params['showDelay'] : null;
$opt['hideDelay'] = (isset($params['hideDelay'])) ? (int) $params['hideDelay'] : null;
$opt['className'] = (isset($params['className'])) ? $params['className'] : null;
- $opt['fixed'] = (isset($params['fixed']) && ($params['fixed'])) ? '\\true' : '\\false';
+ $opt['fixed'] = (isset($params['fixed']) && ($params['fixed'])) ? true : false;
$opt['onShow'] = (isset($params['onShow'])) ? '\\' . $params['onShow'] : null;
$opt['onHide'] = (isset($params['onHide'])) ? '\\' . $params['onHide'] : null;
$options = JHtmlBehavior::_getJSObject($opt);
// Attach tooltips to document
- $document = JFactory::getDocument();
- $document
- ->addScriptDeclaration(
- "
+ JFactory::getDocument()->addScriptDeclaration("
window.addEvent('domready', function() {
$$('$selector').each(function(el) {
var title = el.get('title');
@@ -294,7 +307,7 @@ public static function tooltip($selector = '.hasTip', $params = array())
/**
* Add unobtrusive javascript support for modal links.
*
- * @param string $selector The class selector for which a modal behaviour is to be applied.
+ * @param string $selector The selector for which a modal behaviour is to be applied.
* @param array $params An array of parameters for the modal behaviour.
* Options for the modal behaviour can be:
* - ajaxOptions
@@ -388,16 +401,41 @@ public static function modal($selector = 'a.modal', $params = array())
/**
* JavaScript behavior to allow shift select in grids
*
+ * @param string $id The id of the form for which a multiselect behaviour is to be applied.
+ *
* @return void
*
* @since 11.1
*/
- public static function multiselect()
+ public static function multiselect($id = 'adminForm')
{
+ static $multiselect;
+
+ if (!isset($multiselect))
+ {
+ $multiselect = array();
+ }
+
+ // Only load once
+ if (isset($multiselect[$selector]))
+ {
+ return;
+ }
+
// Include MooTools framework
self::framework();
+
JHtml::_('script', 'system/multiselect.js', true, true);
+ // Attach multiselect to document
+ JFactory::getDocument()->addScriptDeclaration("
+ window.addEvent('domready', function() {
+ new Joomla.JMultiSelect('".$id."');
+ });"
+ );
+
+ // Set static array
+ $multiselect[$selector] = true;
return;
}
@@ -478,11 +516,11 @@ public static function uploader($id = 'file-upload', $params = array(), $upload_
$opt['path'] = (isset($params['swf'])) ? $params['swf'] : JURI::root(true) . '/media/system/swf/uploader.swf';
$opt['height'] = (isset($params['height'])) && $params['height'] ? (int) $params['height'] : null;
$opt['width'] = (isset($params['width'])) && $params['width'] ? (int) $params['width'] : null;
- $opt['multiple'] = (isset($params['multiple']) && !($params['multiple'])) ? '\\false' : '\\true';
+ $opt['multiple'] = (isset($params['multiple']) && !($params['multiple'])) ? false : true;
$opt['queued'] = (isset($params['queued']) && !($params['queued'])) ? (int) $params['queued'] : null;
$opt['target'] = (isset($params['target'])) ? $params['target'] : '\\document.id(\'upload-browse\')';
- $opt['instantStart'] = (isset($params['instantStart']) && ($params['instantStart'])) ? '\\true' : '\\false';
- $opt['allowDuplicates'] = (isset($params['allowDuplicates']) && !($params['allowDuplicates'])) ? '\\false' : '\\true';
+ $opt['instantStart'] = (isset($params['instantStart']) && ($params['instantStart'])) ? true : false;
+ $opt['allowDuplicates'] = (isset($params['allowDuplicates']) && !($params['allowDuplicates'])) ? false : true;
// limitSize is the old parameter name. Remove in 1.7
$opt['fileSizeMax'] = (isset($params['limitSize']) && ($params['limitSize'])) ? (int) $params['limitSize'] : null;
// fileSizeMax is the new name. If supplied, it will override the old value specified for limitSize
@@ -602,7 +640,7 @@ public static function tree($id, $params = array(), $root = array())
// Setup options object
$opt['div'] = (array_key_exists('div', $params)) ? $params['div'] : $id . '_tree';
$opt['mode'] = (array_key_exists('mode', $params)) ? $params['mode'] : 'folders';
- $opt['grid'] = (array_key_exists('grid', $params)) ? '\\' . $params['grid'] : '\\true';
+ $opt['grid'] = (array_key_exists('grid', $params)) ? '\\' . $params['grid'] : true;
$opt['theme'] = (array_key_exists('theme', $params)) ? $params['theme'] : JHtml::_('image', 'system/mootree.gif', '', array(), true, true);
// Event handlers
@@ -617,7 +655,7 @@ public static function tree($id, $params = array(), $root = array())
$rt['text'] = (array_key_exists('text', $root)) ? $root['text'] : 'Root';
$rt['id'] = (array_key_exists('id', $root)) ? $root['id'] : null;
$rt['color'] = (array_key_exists('color', $root)) ? $root['color'] : null;
- $rt['open'] = (array_key_exists('open', $root)) ? '\\' . $root['open'] : '\\true';
+ $rt['open'] = (array_key_exists('open', $root)) ? '\\' . $root['open'] : true;
$rt['icon'] = (array_key_exists('icon', $root)) ? $root['icon'] : null;
$rt['openicon'] = (array_key_exists('openicon', $root)) ? $root['openicon'] : null;
$rt['data'] = (array_key_exists('data', $root)) ? $root['data'] : null;
View
7 media/system/js/caption-uncompressed.js
@@ -48,7 +48,7 @@ var JCaption = new Class({
element.parentNode.insertBefore(container, element);
container.appendChild(element);
- if ( element.title != "" ) {
+ if (element.title != "") {
container.appendChild(text);
}
container.className = this.selector.replace('.', '_');
@@ -60,8 +60,3 @@ var JCaption = new Class({
}
});
-document.caption = null;
-window.addEvent('load', function() {
- var caption = new JCaption('img.caption')
- document.caption = caption
-});
View
6 media/system/js/caption.js
@@ -1 +1,5 @@
-var JCaption=new Class({initialize:function(b){this.selector=b;var a=$$(b);a.each(function(c){this.createCaption(c)},this)},createCaption:function(c){var b=document.createTextNode(c.title);var a=document.createElement("div");var e=document.createElement("p");var d=c.getAttribute("width");var f=c.getAttribute("align");if(!d){d=c.width}if(!f){f=c.getStyle("float")}if(!f){f=c.style.styleFloat}if(f==""||!f){f="none"}e.appendChild(b);e.className=this.selector.replace(".","_");c.parentNode.insertBefore(a,c);a.appendChild(c);if(c.title!=""){a.appendChild(e)}a.className=this.selector.replace(".","_");a.className=a.className+" "+f;a.setAttribute("style","float:"+f);a.style.width=d+"px"}});document.caption=null;window.addEvent("load",function(){var a=new JCaption("img.caption");document.caption=a});
+/*
+ GNU General Public License version 2 or later; see LICENSE.txt
+*/
+var JCaption=new Class({initialize:function(a){this.selector=a;$$(a).each(function(a){this.createCaption(a)},this)},createCaption:function(a){var f=document.createTextNode(a.title),c=document.createElement("div"),d=document.createElement("p"),e=a.getAttribute("width"),b=a.getAttribute("align");if(!e)e=a.width;b||(b=a.getStyle("float"));if(!b)b=a.style.styleFloat;if(b==""||!b)b="none";d.appendChild(f);d.className=this.selector.replace(".","_");a.parentNode.insertBefore(c,a);c.appendChild(a);a.title!=
+""&&c.appendChild(d);c.className=this.selector.replace(".","_");c.className=c.className+" "+b;c.setAttribute("style","float:"+b);c.style.width=e+"px"}});
View
18 media/system/js/multiselect.js
@@ -12,11 +12,14 @@
Joomla.JMultiSelect = new Class({
initialize : function(table) {
this.table = document.id(table);
- this.boxes = table.getElements('input[type=checkbox]');
- this.boxes.addEvent('click', function(e){
- this.doselect(e);
- }.bind(this));
+ if (table) {
+ this.boxes = table.getElements('input[type=checkbox]');
+ this.boxes.addEvent('click', function(e){
+ this.doselect(e);
+ }.bind(this));
+ }
},
+
doselect: function(e) {
var current = document.id(e.target);
if (e.shift && typeOf(this.last) !== 'null') {
@@ -32,11 +35,4 @@
this.last = current;
}
});
-
- window.addEvent('domready', function() {
- var adminForm = document.id('adminForm');
- if (adminForm) {
- new Joomla.JMultiSelect(adminForm);
- }
- });
})();
Something went wrong with that request. Please try again.