[Jifty-commit] jifty branch, master, updated. 2b369bdb30097b3451cec08c6edc5f3a0b4c35e3
Jifty commits
jifty-commit at lists.jifty.org
Wed Dec 23 14:11:06 EST 2009
The branch, master has been updated
via 2b369bdb30097b3451cec08c6edc5f3a0b4c35e3 (commit)
via 5c1d1eadf1ff691f185a3cffb756f5a356636e62 (commit)
from dad95d72050869243f6965fa2b0287b1d4ff35d3 (commit)
Summary of changes:
share/web/static/js/jifty.js | 137 ++++++++++++++++++++++--------------------
1 files changed, 71 insertions(+), 66 deletions(-)
- Log -----------------------------------------------------------------
commit 5c1d1eadf1ff691f185a3cffb756f5a356636e62
Author: c9s <cornelius.howl at gmail.com>
Date: Wed Dec 23 16:26:10 2009 +0800
run jslint on jifty.js. fix syntatic errors. most are semicolon fixs.
diff --git a/share/web/static/js/jifty.js b/share/web/static/js/jifty.js
index 13b044c..225271f 100644
--- a/share/web/static/js/jifty.js
+++ b/share/web/static/js/jifty.js
@@ -38,24 +38,22 @@ Jifty.Update = {
Jifty.$ = function(id) {
if (typeof id == 'string')
- return document.getElementById(id)
+ return document.getElementById(id);
return id;
-}
+};
Jifty.hasAjaxTransport = function() {
var r = false;
- jQuery.each(
- [
- function() {return new XMLHttpRequest()},
- function() {return new ActiveXObject('Msxml2.XMLHTTP')},
- function() {return new ActiveXObject('Microsoft.XMLHTTP')}
- ],
- function(i, v) {
+ jQuery.each( [
+ function() {return new XMLHttpRequest();},
+ function() {return new ActiveXObject('Msxml2.XMLHTTP');},
+ function() {return new ActiveXObject('Microsoft.XMLHTTP');}
+ ], function(i, v) {
try {
r = v();
if (r) return false;
} catch(e) {}
- })
+ });
return r ? true : false;
}();
@@ -70,12 +68,18 @@ Jifty.Web.current_actions = [];
function register_action(a) {
outs(div(function() {
- attr(function() { return ['class', 'hidden'] });
- return input(function() { attr(function() {
- return ['type', 'hidden',
+ attr(function() {
+ return ['class', 'hidden'];
+ });
+ return input(function() {
+ attr(function() {
+ return ['type', 'hidden',
'name', a.register_name(),
'id', a.register_name(),
- 'value', a.actionClass] }) } ) } ));
+ 'value', a.actionClass];
+ });
+ });
+ }));
/* XXX: fallback values */
}
@@ -102,13 +106,12 @@ Action.prototype = {
var elements = [];
// We need to go looking -- this also goes looking through this.extras, from above
- var add_to_elements = function(){ elements.push(this) };
+ var add_to_elements = function(){ elements.push(this); };
jQuery('input').each(add_to_elements);
jQuery.each(this.extras, add_to_elements);
for (var i = 0, l = elements.length; i < l; i++) {
- if ((Jifty.Form.Element.getMoniker(elements[i]) == this.moniker)
- && (Jifty.Form.Element.getType(elements[i]) == "registration")) {
+ if ((Jifty.Form.Element.getMoniker(elements[i]) == this.moniker) && (Jifty.Form.Element.getType(elements[i]) == "registration")) {
this.register = elements[i];
break;
}
@@ -148,7 +151,7 @@ Action.prototype = {
//If the button has no actions explicitly associated
//with it, it's associated with all the actions in the
//form
- if( actions.length == 0
+ if( actions.length === 0
|| actions.indexOf(this.moniker) >= 0) {
elements.push(possible[i]);
}
@@ -200,26 +203,26 @@ Action.prototype = {
a['order'] = tmp[1];
}
- a['fields'] = {};
+ a.fields = {};
var fields = this.fields();
for (var i = 0; i < fields.length; i++) {
var f = fields[i];
if ( (Jifty.Form.Element.getType(f) != "registration")
- && (Jifty.Form.Element.getValue(f) != null)
+ && (Jifty.Form.Element.getValue(f) !== null)
&& (!Jifty.Placeholder.hasPlaceholder(f)))
{
- if (! a['fields'][Jifty.Form.Element.getField(f)])
- a['fields'][Jifty.Form.Element.getField(f)] = {};
+ if (! a.fields[Jifty.Form.Element.getField(f)])
+ a.fields[Jifty.Form.Element.getField(f)] = {};
var field = Jifty.Form.Element.getField(f);
var type = Jifty.Form.Element.getType(f);
// XXX: fallback value being an array makes server
// upset, we don't think that should happen anyway
- if (type == 'fallback' && a['fields'][field][type])
+ if (type == 'fallback' && a.fields[field][type])
continue;
- a['fields'][field][type] = this._mergeValues(a['fields'][field][type],
+ a.fields[field][type] = this._mergeValues(a.fields[field][type],
Jifty.Form.Element.getValue(f));
}
@@ -256,32 +259,32 @@ Action.prototype = {
data: data,
complete: function (request, status) {
var response = request.responseXML.documentElement;
- for (var action = response.firstChild; action != null; action = action.nextSibling) {
+ for (var action = response.firstChild; action !== null; action = action.nextSibling) {
if ((action.nodeName == 'validationaction') && (action.getAttribute("id") == id)) {
- for (var field = action.firstChild; field != null; field = field.nextSibling) {
+ for (var field = action.firstChild; field !== null; field = field.nextSibling) {
// Possibilities for field.nodeName: it could be #text (whitespace),
// or 'blank' (the field was blank, don't mess with the error div), or 'ok'
// (clear the error and warning div!) or 'error' (fill in the error div, clear
// the warning div!) or 'warning' (fill in the warning div and clear the error div!)
if (field.nodeName == 'error' || field.nodeName == 'warning') {
var err_div = document.getElementById(field.getAttribute("id"));
- if (err_div != null) {
+ if (err_div !== null) {
jQuery(err_div).show().html(field.firstChild.data);
}
} else if (field.nodeName == 'ok') {
var err_div = document.getElementById(field.getAttribute("id"));
- if (err_div != null) {
+ if (err_div !== null) {
jQuery(err_div).hide().html('');
}
}
}
} else if ((action.nodeName == 'canonicalizeaction') && (action.getAttribute("id") == id)) {
- for (var field = action.firstChild; field != null; field = field.nextSibling) {
+ for (var field = action.firstChild; field !== null; field = field.nextSibling) {
// Possibilities for field.nodeName: it could be 'ignored', 'blank' , 'update', or 'info'
// info is a separate action from the update
if (field.nodeName == 'canonicalization_note') {
var note_div= document.getElementById(field.getAttribute("id"));
- if (note_div != null) {
+ if (note_div !== null) {
jQuery(note_div).show().html(field.firstChild.data);
}
}
@@ -358,7 +361,7 @@ Action.prototype = {
var f = new ActionField(field, a_s[field], this);
return f.render();
},
- register_name: function() { return this.register.id }
+ register_name: function() { return this.register.id; }
};
@@ -384,12 +387,13 @@ ActionField.prototype = {
},
render: function() {
- if (this.render_mode == 'read')
+ if (this.render_mode == 'read') {
return this.render_wrapper(
this.render_preamble,
this.render_label,
this.render_value);
- else
+ }
+ else {
return this.render_wrapper(
this.render_preamble,
this.render_label,
@@ -400,6 +404,7 @@ ActionField.prototype = {
this.render_errors,
this.render_warnings,
this.render_canonicalization_notes);
+ }
},
render_wrapper: function () {
var classes = ['form_field'];
@@ -419,13 +424,13 @@ ActionField.prototype = {
render_preamble: function() {
var tthis = this;
return span(function(){attr(function(){return ['class', "preamble"]});
- return tthis.preamble });
+ return tthis.preamble; });
},
render_label: function() {
var tthis = this;
if(this.render_mode == 'update')
- return label(function(){attr(function(){return['class', "label", 'for', tthis.element_id()]});
+ return label(function(){attr(function(){return['class', "label", 'for', tthis.element_id()];});
return tthis.label });
else
return span(function(){attr(function(){return['class', "label" ]});
commit 2b369bdb30097b3451cec08c6edc5f3a0b4c35e3
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 23 14:10:49 2009 -0500
Remove EOL whitespace in jifty.js
diff --git a/share/web/static/js/jifty.js b/share/web/static/js/jifty.js
index 225271f..d14a4f3 100644
--- a/share/web/static/js/jifty.js
+++ b/share/web/static/js/jifty.js
@@ -2,8 +2,8 @@
var Jifty = {};
// NOTICE: line break should be in a proper place.
-// something like
-// return
+// something like
+// return
// {
// a : 123
// };
@@ -69,16 +69,16 @@ Jifty.Web.current_actions = [];
function register_action(a) {
outs(div(function() {
attr(function() {
- return ['class', 'hidden'];
+ return ['class', 'hidden'];
});
- return input(function() {
+ return input(function() {
attr(function() {
return ['type', 'hidden',
'name', a.register_name(),
'id', a.register_name(),
'value', a.actionClass];
- });
- });
+ });
+ });
}));
/* XXX: fallback values */
}
@@ -302,9 +302,9 @@ Action.prototype = {
}
}
return true;
- }
+ }
});
-
+
hide_wait_message();
return false;
},
@@ -392,7 +392,7 @@ ActionField.prototype = {
this.render_preamble,
this.render_label,
this.render_value);
- }
+ }
else {
return this.render_wrapper(
this.render_preamble,
@@ -531,7 +531,7 @@ jQuery.extend(Jifty.Form.Element, {
// Takes an element or an element id
getMoniker: function (element) {
element = Jifty.$(element);
-
+
if (/^J:A(:F)+-[^-]+-.+$/.test(element.name)) {
var bits = element.name.match(/^J:A(?::F)+-[^-]+-(.+)$/);
return bits[1];
@@ -739,7 +739,7 @@ Behaviour.register({
button.setAttribute('type', 'button');
jQuery(button).insertAfter(e);
jQuery(button).timepickr({val: 'Pick time'});
- jQuery(button).blur( function() {
+ jQuery(button).blur( function() {
var old_value = jQuery(this).prev().val();
if ( Jifty.Calendar.dateRegex.test(old_value) ) {
var bits = old_value.match(Jifty.Calendar.dateRegex);
@@ -751,7 +751,7 @@ Behaviour.register({
// Trigger an onchange event for any listeners
jQuery(e).change();
jQuery(button).val('');
- }
+ }
);
jQuery(e).addClass('has_datetime_link');
}
@@ -846,7 +846,7 @@ Region.prototype = {
var parsed = k.match(/^(.*?)\.(.*)/);
if ((parsed != null) && (parsed.length == 3) && (parsed[1] == this.name)) {
current_args[k] = null;
- }
+ }
});
}
@@ -1095,7 +1095,7 @@ var apply_fragment_updates = function(fragment, f) {
f['effect_args'],
{
before: function() {
- if(f['is_new'])
+ if(f['is_new'])
jQuery(this).hide();
}
}
@@ -1156,7 +1156,7 @@ Jifty.update = function () {
// If the action is null, take all actions
if (named_args['actions'] == null) {
named_args['actions'] = {};
-
+
// Add all the actions into the list to submit
if (form) {
jQuery.each(Jifty.Form.getActions(form), function(){
@@ -1172,13 +1172,13 @@ Jifty.update = function () {
// SPA Update __page when the form calls a continuation
if (form && form['J:CALL']) {
- optional_fragments = [
+ optional_fragments = [
prepare_element_for_update({
'mode': 'Replace',
'args': {},
'region': '__page',
'path': null
- })
+ })
];
}
@@ -1209,13 +1209,13 @@ Jifty.update = function () {
(function() {
var fields = a.fields();
var path = fields[fields.length - 1];
- optional_fragments = [
+ optional_fragments = [
prepare_element_for_update({
'mode': 'Replace',
'args': {},
'region': '__page',
'path': path
- })
+ })
];
})()
}
@@ -1355,7 +1355,7 @@ Jifty.update = function () {
<fragment id="__page-region-name">
<argument name="argument1">value1</argument>
<argument name="argument2">value2</argument>
- <content>
+ <content>
...
</content>
</fragment>
@@ -1370,10 +1370,10 @@ Jifty.update = function () {
*/
// Look through the action results looking for field validation errors
- walk_node(response, {
+ walk_node(response, {
result: function(result) {
var moniker = result.getAttribute("moniker");
- walk_node(result, {
+ walk_node(result, {
field: function(field) {
var error = field.getElementsByTagName('error')[0];
@@ -1394,16 +1394,16 @@ Jifty.update = function () {
disabled_elements[i].disabled = false;
}
- // empty known action.
+ // empty known action.
// XXX: we should only need to discard actions being submitted
// SPA We only care about __page sometimes
- var expected_fragments = optional_fragments ? optional_fragments
+ var expected_fragments = optional_fragments ? optional_fragments
: named_args['fragments'];
// Loop through the response looking for fragments we requested
for (var response_fragment = response.firstChild;
- response_fragment != null &&
+ response_fragment != null &&
response_fragment.nodeName == 'fragment';
response_fragment = response_fragment.nextSibling) {
@@ -1431,7 +1431,7 @@ Jifty.update = function () {
} catch (e) { alert(e) }
// f
- jQuery.each(Jifty.Update.response_hooks, function(i) {
+ jQuery.each(Jifty.Update.response_hooks, function(i) {
this(response_fragment, f);
});
@@ -1443,7 +1443,7 @@ Jifty.update = function () {
// Look through the response again
- walk_node(response, {
+ walk_node(response, {
// Report all the action results we have
result: function(result) {
@@ -1712,7 +1712,7 @@ function show_action_result() {
}
/* This is a workaround for Safari, which does not support textContent */
- var text = result.textContent
+ var text = result.textContent
? result.textContent
: (result.firstChild ? result.firstChild.nodeValue : '');
@@ -1745,7 +1745,7 @@ jQuery.extend(Jifty.Autocompleter.prototype, {
Jifty.current_autocompleter_object = self;
autocomplete_div.append(jQuery('#autocompleteHelper')).show();
}).blur(function() { autocomplete_div.hide() });
-
+
jQuery(this.field).Autocomplete({
source: this.url,
minchars: -1,
@@ -1881,15 +1881,15 @@ if( !Object.prototype.hasOwnProperty ) {
/*
* Jifty.Effect Usage:
- *
+ *
* Jifty.Effect(element, "Fade", { duration: 2.0 });
- *
+ *
* When called, instantly pefrom a js effect on give element.
*
* The last arg "option" is a hash. Currently it's only used for
* specificing callbacks. There are two possible callbacks, before
* and after. You may specify them like this:
- *
+ *
* Jifty.Effect(element, "Fade", { duration: 2.0 }, {
* before: function() { ... },
* after: function() { ... }
@@ -1928,12 +1928,12 @@ Jifty.Effect = function(el, name, args, options) {
name;
if ( jQuery.isFunction( jQuery(el)[ effect ] ) ) {
- if ( jQuery.isFunction(options["before"]) )
+ if ( jQuery.isFunction(options["before"]) )
options["before"].call( el );
( jQuery(el)[ effect ] )(args);
- if ( jQuery.isFunction(options["after"]) )
+ if ( jQuery.isFunction(options["after"]) )
options["after"].call( el );
}
};
@@ -1999,7 +1999,7 @@ jQuery.extend(Form.Element, {
return Jifty.Form.Element.disableValidation(element);
},
- //Reenable validation
+ //Reenable validation
enableValidation: function(element) {
// DEPRECATED: use Jifty.Form.Element.enableValidation instead
return Jifty.Form.Element.enableValidation(element);
@@ -2023,7 +2023,7 @@ jQuery.extend(Form.Element, {
buttonActions: function(element) {
// DEPRECATED: use Jifty.Form.Element.buttonActions instead
return Jifty.Form.Element.buttonActions(element);
- },
+ },
buttonFormElements: function(element) {
// DEPRECATED: use Jifty.Form.Element.buttonFormElements instead
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list