Permalink
Browse files

Merge branch 'master' into addItems-nullTag

  • Loading branch information...
2 parents 2a41ac5 + 53d4988 commit 24789638ab705631801eca10aeab2a388e030f81 Ben Combee committed Dec 15, 2012
View
@@ -5,17 +5,17 @@
<!-- -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- -->
- <script src="../enyo.js" type="text/javascript"></script>
+ <script src="../../enyo/enyo.js" type="text/javascript"></script>
<script src="../../lib/layout/package.js" type="text/javascript"></script>
<script src="../../lib/onyx/package.js" type="text/javascript"></script>
<!-- -->
<link href="AjaxSample.css" rel="stylesheet">
<script src="AjaxSample.js" type="text/javascript"></script>
<!-- -->
</head>
-<body>
+<body class="onyx">
<script type="text/javascript">
- new enyo.sample.AjaxSample().write();
+ new enyo.sample.AjaxSample().renderInto(document.body);
</script>
</body>
</html>
@@ -5,17 +5,17 @@
<!-- -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- -->
- <script src="../enyo.js" type="text/javascript"></script>
+ <script src="../../enyo/enyo.js" type="text/javascript"></script>
<script src="../../lib/layout/package.js" type="text/javascript"></script>
<script src="../../lib/onyx/package.js" type="text/javascript"></script>
<!-- -->
<link href="GestureSample.css" rel="stylesheet">
<script src="GestureSample.js" type="text/javascript"></script>
<!-- -->
</head>
-<body>
+<body class="onyx">
<script type="text/javascript">
- new enyo.sample.GestureSample().write();
+ new enyo.sample.GestureSample().renderInto(document.body);
</script>
</body>
</html>
View
@@ -5,17 +5,17 @@
<!-- -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- -->
- <script src="../enyo.js" type="text/javascript"></script>
+ <script src="../../enyo/enyo.js" type="text/javascript"></script>
<script src="../../lib/layout/package.js" type="text/javascript"></script>
<script src="../../lib/onyx/package.js" type="text/javascript"></script>
<!-- -->
<link href="JsonpSample.css" rel="stylesheet">
<script src="JsonpSample.js" type="text/javascript"></script>
<!-- -->
</head>
-<body>
+<body class="onyx">
<script type="text/javascript">
- new enyo.sample.JsonpSample().write();
+ new enyo.sample.JsonpSample().renderInto(document.body);
</script>
</body>
</html>
@@ -5,15 +5,15 @@
<!-- -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- -->
- <script src="../enyo.js" type="text/javascript"></script>
+ <script src="../../enyo/enyo.js" type="text/javascript"></script>
<script src="../../lib/layout/package.js" type="text/javascript"></script>
<script src="../../lib/onyx/package.js" type="text/javascript"></script>
<!-- -->
<link href="PlatformSample.css" rel="stylesheet">
<script src="PlatformSample.js" type="text/javascript"></script>
<!-- -->
</head>
-<body>
+<body class="onyx">
<script type="text/javascript">
new enyo.sample.PlatformSample().renderInto(document.body);
</script>
@@ -26,7 +26,7 @@ enyo.kind({
create: function() {
this.inherited(arguments);
this.$.uaString.setContent(navigator.userAgent);
- this.$.enyoPlatformJSON.setContent(JSON.stringify(enyo.platform));
+ this.$.enyoPlatformJSON.setContent(JSON.stringify(enyo.platform, null, 1));
this.updateWindowSize();
},
resizeHandler: function() {
View
@@ -5,7 +5,7 @@
<!-- -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- -->
- <script src="../enyo.js" type="text/javascript"></script>
+ <script src="../../enyo/enyo.js" type="text/javascript"></script>
<script src="../../lib/canvas/package.js" type="text/javascript"></script>
<script src="../../lib/layout/package.js" type="text/javascript"></script>
<script src="../../lib/onyx/package.js" type="text/javascript"></script>
@@ -15,9 +15,9 @@
<script src="Playground.js" type="text/javascript"></script>
<!-- -->
</head>
-<body>
+<body class="onyx">
<script type="text/javascript">
- new enyo.sample.Playground().write();
+ new enyo.sample.Playground().renderInto(document.body);
</script>
</body>
</html>
@@ -5,17 +5,17 @@
<!-- -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- -->
- <script src="../enyo.js" type="text/javascript"></script>
+ <script src="../../enyo/enyo.js" type="text/javascript"></script>
<script src="../../lib/layout/package.js" type="text/javascript"></script>
<script src="../../lib/onyx/package.js" type="text/javascript"></script>
<!-- -->
<link href="RepeaterSample.css" rel="stylesheet">
<script src="RepeaterSample.js" type="text/javascript"></script>
<!-- -->
</head>
-<body>
+<body class="onyx">
<script type="text/javascript">
- new enyo.sample.RepeaterSample().write();
+ new enyo.sample.RepeaterSample().renderInto(document.body);
</script>
</body>
</html>
@@ -5,17 +5,17 @@
<!-- -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- -->
- <script src="../enyo.js" type="text/javascript"></script>
+ <script src="../../enyo/enyo.js" type="text/javascript"></script>
<script src="../../lib/layout/package.js" type="text/javascript"></script>
<script src="../../lib/onyx/package.js" type="text/javascript"></script>
<!-- -->
<link href="ScrollerSample.css" rel="stylesheet">
<script src="ScrollerSample.js" type="text/javascript"></script>
<!-- -->
</head>
-<body>
+<body class="onyx">
<script type="text/javascript">
- new enyo.sample.ScrollerSample().write();
+ new enyo.sample.ScrollerSample().renderInto(document.body);
</script>
</body>
</html>
@@ -5,17 +5,17 @@
<!-- -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- -->
- <script src="../enyo.js" type="text/javascript"></script>
+ <script src="../../enyo/enyo.js" type="text/javascript"></script>
<script src="../../lib/layout/package.js" type="text/javascript"></script>
<script src="../../lib/onyx/package.js" type="text/javascript"></script>
<!-- -->
<link href="WebServiceSample.css" rel="stylesheet">
<script src="WebServiceSample.js" type="text/javascript"></script>
<!-- -->
</head>
-<body>
+<body class="onyx">
<script type="text/javascript">
- new enyo.sample.WebServiceSample().write();
+ new enyo.sample.WebServiceSample().renderInto(document.body);
</script>
</body>
</html>
View
@@ -31,32 +31,24 @@ enyo.kind({
},
//* @public
/**
- Sends the Ajax request with parameters _inParams_. _inParams_ values may be
- either Strings or Objects.
+ Sends the Ajax request with parameters _inParams_. _inParams_ values may be
+ either Strings or Objects.
- _inParams_ as an Object is converted into the url query string. For
- instance, passing <code>{q: "searchTerm"}</code> will result in the addition
- of the string `q="searchTerm"` to the current url query string.
+ _inParams_ as an Object is converted into the url query string. For
+ instance, passing <code>{q: "searchTerm"}</code> will result in the addition
+ of the string `q="searchTerm"` to the current url query string.
- _inParams_ as a String is used as the request body, and triggers various
- behaviors depending on the query method.
+ _inParams_ as a String is used as the query part of the URL directly.
- * The GET method, since it has no body, translates the string into a
- parameter. Thus `'q="searchTerm"'` translates into `q=searchTerm` in the
- url query string.
+ _inParams_ will not be converted into a POST body, it will always be used as
+ part of the URL query string if provided. Use the `postBody` property for
+ specifying a body.
- * The POST method uses the provided string as its body. However, this will
- be overridden by the value of _postBody_, if set.
-
- The use of _inParams_ as a String is discouraged. Instead, set the request
- body content via _postBody_ and use _inParams_ as an Object to set the query
- string.
-
- When the request is completed, the code will set a `xhrResponse` property
- in the `enyo.Ajax` object with the subproperties `status`, `headers`, and
- `body`. These cache the results from the XHR for later use. The keys for
- the `headers` object have been converted to all lower case as HTTP headers
- are case-insensitive.
+ When the request is completed, the code will set a `xhrResponse` property
+ in the `enyo.Ajax` object with the subproperties `status`, `headers`, and
+ `body`. These cache the results from the XHR for later use. The keys for
+ the `headers` object have been converted to all lower case as HTTP headers
+ are case-insensitive.
*/
go: function(inParams) {
this.startTimer();
@@ -69,35 +61,33 @@ enyo.kind({
var uri = parts.shift() || "";
var args = parts.length ? (parts.join("?").split("&")) : [];
//
- var body = null;
- //
- if(enyo.isString(inParams)){
- //If inParams parameter is a string, use it as request body
- body = inParams;
- }
- else{
- //If inParams parameter is not a string, build a query from it
- if(inParams){
- body = enyo.Ajax.objectToQuery(inParams);
- }
- }
- //
- if (this.method == "GET") {
- if (body) {
- args.push(body);
- body = null;
- }
- // don't use cacheBust on file URLs, can cause problems in Android 4
- if (this.cacheBust && !/^file:/i.test(uri)) {
- args.push(Math.random());
+ var query = null;
+ //
+ if(enyo.isString(inParams)){
+ //If inParams parameter is a string, use it as request body
+ query = inParams;
+ }
+ else{
+ //If inParams parameter is not a string, build a query from it
+ if(inParams){
+ query = enyo.Ajax.objectToQuery(inParams);
}
}
//
+ if (query) {
+ args.push(query);
+ query = null;
+ }
+ if (this.cacheBust) {
+ args.push(Math.random());
+ }
+ //
var url = args.length ? [uri, args.join("&")].join("?") : uri;
//
var xhr_headers = {};
- body = this.postBody || body;
+ var body;
if (this.method != "GET") {
+ body = this.postBody;
if (this.method === "POST" && body instanceof enyo.FormData) {
if (body.fake) {
xhr_headers["Content-Type"] = body.getContentType();
@@ -110,6 +100,16 @@ enyo.kind({
}
} else {
xhr_headers["Content-Type"] = this.contentType;
+ if (body instanceof Object) {
+ if (this.contentType === "application/json") {
+ body = JSON.stringify(body);
+ } else if (this.contentType === "application/x-www-form-urlencoded") {
+ body = enyo.Ajax.objectToQuery(body);
+ }
+ else {
+ body = body.toString();
+ }
+ }
}
}
enyo.mixin(xhr_headers, this.headers);
@@ -38,8 +38,14 @@ enyo.AjaxProperties = {
*/
headers: null,
/**
- The content for the request body for POST method. If this is not set, params will be used instead.
- When both params and postBody are set, postBody override any data provided as params thus destroying them.
+ The content for the request body for POST/PUT methods.
+
+ When postBody is a Buffer or a String, it is passed verbatim in the request body.
+ When postBody is an Object, the way it is encoded depends on the contentType:
+
+ * application/json => JSON.stringify
+ * application/x-www-urlencoed => url-encoded parameters
+ * multipart/form-data => passed as fields in enyo.FormData (XHR2 emulation)
*/
postBody: "",
/**
@@ -56,7 +62,7 @@ enyo.AjaxProperties = {
*/
xhrFields: null,
/**
- Optional string to override the MIME-Type.
+ Optional string to override the MIME-Type header.
*/
mimeType: null
};
Oops, something went wrong.

0 comments on commit 2478963

Please sign in to comment.