You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/10/03 10:38:11 UTC
[1/2] git commit: Wrap the JS code in an auto-executing function as
all other our scripts. Best practices.
Updated Branches:
refs/heads/master 350f89afb -> 1ca1ecfc9
Wrap the JS code in an auto-executing function as all other our scripts. Best practices.
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/1ca1ecfc
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/1ca1ecfc
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/1ca1ecfc
Branch: refs/heads/master
Commit: 1ca1ecfc909d51dfd99ab0a385a582dedd7e95ef
Parents: a815d40
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Oct 3 11:36:00 2012 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Wed Oct 3 11:36:00 2012 +0300
----------------------------------------------------------------------
.../AjaxFormChoiceComponentUpdatingBehavior.js | 106 +++++++-------
1 files changed, 53 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/1ca1ecfc/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js b/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js
index 53decb6..cc00654 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.js
@@ -14,72 +14,72 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
/*
* Wicket Choice Ajax updates.
*
* @author svenmeier
*/
+;(function (undefined) {
+ "use strict";
-// introduce a namespace
-if (typeof (Wicket.Choice) === "undefined") {
- Wicket.Choice = {};
+ // introduce a namespace
+ if (typeof (Wicket.Choice) === "undefined") {
+ Wicket.Choice = {};
- /**
- * Is a change accepted.
- *
- * @param name input name of choice
- * @param attrs ajax attributes
- */
- Wicket.Choice.acceptInput = function(name, attrs) {
- "use strict";
+ /**
+ * Is a change accepted.
+ *
+ * @param name input name of choice
+ * @param attrs ajax attributes
+ */
+ Wicket.Choice.acceptInput = function(name, attrs) {
- var srcElement = attrs.event.target;
+ var srcElement = attrs.event.target;
- return srcElement.name === name;
- };
+ return srcElement.name === name;
+ };
- /**
- * Get all checked input values.
- *
- * @param markupId markup id of choice
- * @param name input name of choice
- * @param attrs ajax attributes
- */
- Wicket.Choice.getInputValues = function(markupId, name, attrs) {
- "use strict";
- var result = [], srcElement = attrs.event.target;
+ /**
+ * Get all checked input values.
+ *
+ * @param markupId markup id of choice
+ * @param name input name of choice
+ * @param attrs ajax attributes
+ */
+ Wicket.Choice.getInputValues = function(markupId, name, attrs) {
+ var result = [], srcElement = attrs.event.target;
- var inputNodes = Wicket.$(markupId).getElementsByTagName("input");
- for (var i = 0 ; i < inputNodes.length ; i ++) {
- var inputNode = inputNodes[i];
+ var inputNodes = Wicket.$(markupId).getElementsByTagName("input");
+ for (var i = 0 ; i < inputNodes.length ; i ++) {
+ var inputNode = inputNodes[i];
- if (inputNode.name !== name) {
- continue;
- }
- if (!inputNode.checked) {
- continue;
- }
+ if (inputNode.name !== name) {
+ continue;
+ }
+ if (!inputNode.checked) {
+ continue;
+ }
- var value = inputNode.value;
- result.push({ name: name, value: value });
- }
-
- return result;
- };
+ var value = inputNode.value;
+ result.push({ name: name, value: value });
+ }
- /**
- * Attach to a choice.
- *
- * @param markupId markup id of choice
- * @param input name of choice
- * @attrs ajax attributes
- */
- Wicket.Choice.attach = function(markupId, name, attrs) {
- "use strict";
+ return result;
+ };
- attrs.pre = (attrs.pre || []).concat([ function(attributes) { var pre = Wicket.Choice.acceptInput(name, attributes); return pre; } ]);
- attrs.dep = (attrs.dep || []).concat([ function(attributes) { var deps = Wicket.Choice.getInputValues(markupId, name, attributes); return deps; } ]);
- Wicket.Ajax.post(attrs);
- };
-}
+ /**
+ * Attach to a choice.
+ *
+ * @param markupId markup id of choice
+ * @param input name of choice
+ * @attrs ajax attributes
+ */
+ Wicket.Choice.attach = function(markupId, name, attrs) {
+ attrs.pre = (attrs.pre || []).concat([ function(attributes) { var pre = Wicket.Choice.acceptInput(name, attributes); return pre; } ]);
+ attrs.dep = (attrs.dep || []).concat([ function(attributes) { var deps = Wicket.Choice.getInputValues(markupId, name, attributes); return deps; } ]);
+ Wicket.Ajax.post(attrs);
+ };
+ }
+})();