-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[code-convention] [comment] Update some JS code convention and comments.
- Loading branch information
Showing
7 changed files
with
77 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
// http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax | ||
(function ($) { | ||
$.extend({ | ||
form: function (url, data, method) { | ||
if (method == null) method = 'POST'; | ||
if (data == null) data = {}; | ||
(function ( $ ) { | ||
$.extend( { | ||
form: function ( url, data, method ) { | ||
if ( method == null ) method = 'POST'; | ||
if ( data == null ) data = {}; | ||
|
||
var form = $('<form>').attr({ | ||
var form = $( '<form>' ).attr( { | ||
method: method, | ||
action: url | ||
}).css({ | ||
} ).css( { | ||
display: 'none' | ||
}); | ||
} ); | ||
|
||
var addData = function (name, data) { | ||
if ($.isArray(data)) { | ||
for (var i = 0; i < data.length; i++) { | ||
var value = data[i]; | ||
addData(name + '[]', value); | ||
var addData = function ( name, data ) { | ||
if ( $.isArray( data ) ) { | ||
for ( var i = 0; i < data.length; i++ ) { | ||
var value = data[ i ]; | ||
addData( name + '[]', value ); | ||
} | ||
} else if (typeof data === 'object') { | ||
for (var key in data) { | ||
if (data.hasOwnProperty(key)) { | ||
addData(name + '[' + key + ']', data[key]); | ||
} else if ( typeof data === 'object' ) { | ||
for ( var key in data ) { | ||
if ( data.hasOwnProperty( key ) ) { | ||
addData( name + '[' + key + ']', data[ key ] ); | ||
} | ||
} | ||
} else if (data != null) { | ||
form.append($('<input>').attr({ | ||
} else if ( data != null ) { | ||
form.append( $( '<input>' ).attr( { | ||
type : 'hidden', | ||
name : String(name), | ||
value: String(data) | ||
})); | ||
name : String( name ), | ||
value: String( data ) | ||
} ) ); | ||
} | ||
}; | ||
|
||
for (var key in data) { | ||
if (data.hasOwnProperty(key)) { | ||
addData(key, data[key]); | ||
for ( var key in data ) { | ||
if ( data.hasOwnProperty( key ) ) { | ||
addData( key, data[ key ] ); | ||
} | ||
} | ||
|
||
return form.appendTo('body'); | ||
return form.appendTo( 'body' ); | ||
} | ||
}); | ||
})(jQuery); | ||
} ); | ||
} )( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters