Permalink
Browse files

Move Repeat's JS to proper qf.elements.Repeat namespace

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_QuickForm2/trunk@325694 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
sad-spirit committed May 15, 2012
1 parent f1ab56a commit 9baf1a3f29153c9d25bf767ec6e255fd96c25e1d
Showing with 37 additions and 23 deletions.
  1. +2 −2 HTML/QuickForm2/Container/Repeat.php
  2. +5 −5 data/js/min/quickform-repeat.js
  3. +15 −8 data/js/quickform-repeat.js
  4. +15 −8 js/src/repeat.js
@@ -661,8 +661,8 @@ private function _generateInitScript(
);
list ($rules, $scripts) = $evalBuilder->getFormJavascriptAsStrings();
- return "new qf.Repeat(document.getElementById({$myId}), {$protoId}, {$triggers},\n"
- . $rules . ",\n" . $scripts . "\n);";
+ return "new qf.elements.Repeat(document.getElementById({$myId}), {$protoId}, "
+ . "{$triggers},\n{$rules},\n{$scripts}\n);";
}
/**

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -20,7 +20,7 @@
* @param {String} scriptsTpl
* @constructor
*/
-qf.Repeat = function(container, itemId, triggers, rulesTpl, scriptsTpl)
+qf.elements.Repeat = function(container, itemId, triggers, rulesTpl, scriptsTpl)
{
container.repeat = this;
@@ -69,12 +69,12 @@ qf.Repeat = function(container, itemId, triggers, rulesTpl, scriptsTpl)
// find all elements with class repeatAdd inside container...
var adders = this.getElementsByClass('repeatAdd', container);
for (var i = 0, element; element = adders[i]; i++) {
- qf.events.addListener(element, 'click', qf.Repeat.addHandler);
+ qf.events.addListener(element, 'click', qf.elements.Repeat.addHandler);
}
// find all elements with class repeatRemove inside container...
var removers = this.getElementsByClass('repeatRemove', container);
for (i = 0; element = removers[i]; i++) {
- qf.events.addListener(element, 'click', qf.Repeat.removeHandler);
+ qf.events.addListener(element, 'click', qf.elements.Repeat.removeHandler);
}
};
@@ -83,7 +83,7 @@ qf.Repeat = function(container, itemId, triggers, rulesTpl, scriptsTpl)
*
* @param {Event} event
*/
-qf.Repeat.addHandler = function(event)
+qf.elements.Repeat.addHandler = function(event)
{
event = qf.events.fixEvent(event);
@@ -102,7 +102,7 @@ qf.Repeat.addHandler = function(event)
*
* @param {Event} event
*/
-qf.Repeat.removeHandler = function(event)
+qf.elements.Repeat.removeHandler = function(event)
{
event = qf.events.fixEvent(event);
@@ -120,7 +120,7 @@ qf.Repeat.removeHandler = function(event)
event.preventDefault();
};
-qf.Repeat.prototype = {
+qf.elements.Repeat.prototype = {
/**
* Finds elements by CSS class name
*
@@ -259,10 +259,10 @@ qf.Repeat.prototype = {
eval(element.innerHTML.replace(/:idx:/g, index));
}
if (qf.classes.has(element, 'repeatAdd')) {
- qf.events.addListener(element, 'click', qf.Repeat.addHandler);
+ qf.events.addListener(element, 'click', qf.elements.Repeat.addHandler);
}
if (qf.classes.has(element, 'repeatRemove')) {
- qf.events.addListener(element, 'click', qf.Repeat.removeHandler);
+ qf.events.addListener(element, 'click', qf.elements.Repeat.removeHandler);
}
}
@@ -355,3 +355,10 @@ qf.Repeat.prototype = {
{
}
};
+
+/**
+ * Alias for qf.elements.Repeat, in case someone managed to rely on that name
+ * @deprecated will be removed in the next release
+ * @type {Function}
+ */
+qf.Repeat = qf.elements.Repeat;
View
@@ -20,7 +20,7 @@
* @param {String} scriptsTpl
* @constructor
*/
-qf.Repeat = function(container, itemId, triggers, rulesTpl, scriptsTpl)
+qf.elements.Repeat = function(container, itemId, triggers, rulesTpl, scriptsTpl)
{
container.repeat = this;
@@ -69,12 +69,12 @@ qf.Repeat = function(container, itemId, triggers, rulesTpl, scriptsTpl)
// find all elements with class repeatAdd inside container...
var adders = this.getElementsByClass('repeatAdd', container);
for (var i = 0, element; element = adders[i]; i++) {
- qf.events.addListener(element, 'click', qf.Repeat.addHandler);
+ qf.events.addListener(element, 'click', qf.elements.Repeat.addHandler);
}
// find all elements with class repeatRemove inside container...
var removers = this.getElementsByClass('repeatRemove', container);
for (i = 0; element = removers[i]; i++) {
- qf.events.addListener(element, 'click', qf.Repeat.removeHandler);
+ qf.events.addListener(element, 'click', qf.elements.Repeat.removeHandler);
}
};
@@ -83,7 +83,7 @@ qf.Repeat = function(container, itemId, triggers, rulesTpl, scriptsTpl)
*
* @param {Event} event
*/
-qf.Repeat.addHandler = function(event)
+qf.elements.Repeat.addHandler = function(event)
{
event = qf.events.fixEvent(event);
@@ -102,7 +102,7 @@ qf.Repeat.addHandler = function(event)
*
* @param {Event} event
*/
-qf.Repeat.removeHandler = function(event)
+qf.elements.Repeat.removeHandler = function(event)
{
event = qf.events.fixEvent(event);
@@ -120,7 +120,7 @@ qf.Repeat.removeHandler = function(event)
event.preventDefault();
};
-qf.Repeat.prototype = {
+qf.elements.Repeat.prototype = {
/**
* Finds elements by CSS class name
*
@@ -259,10 +259,10 @@ qf.Repeat.prototype = {
eval(element.innerHTML.replace(/:idx:/g, index));
}
if (qf.classes.has(element, 'repeatAdd')) {
- qf.events.addListener(element, 'click', qf.Repeat.addHandler);
+ qf.events.addListener(element, 'click', qf.elements.Repeat.addHandler);
}
if (qf.classes.has(element, 'repeatRemove')) {
- qf.events.addListener(element, 'click', qf.Repeat.removeHandler);
+ qf.events.addListener(element, 'click', qf.elements.Repeat.removeHandler);
}
}
@@ -355,3 +355,10 @@ qf.Repeat.prototype = {
{
}
};
+
+/**
+ * Alias for qf.elements.Repeat, in case someone managed to rely on that name
+ * @deprecated will be removed in the next release
+ * @type {Function}
+ */
+qf.Repeat = qf.elements.Repeat;

0 comments on commit 9baf1a3

Please sign in to comment.