Skip to content

Commit a5e4ced

Browse files
committed
Merge pull request #1 from jaredhoberock/master
Port N3960 from Markdown
2 parents 7ec1429 + 89ebb58 commit a5e4ced

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+12035
-0
lines changed

algorithms.html

Lines changed: 771 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "core-action-icons",
3+
"homepage": "https://github.com/Polymer/core-action-icons",
4+
"version": "0.2.3",
5+
"_release": "0.2.3",
6+
"_resolution": {
7+
"type": "version",
8+
"tag": "0.2.3",
9+
"commit": "2dbce5513e3332498bd8b7838ba5f26b8579db92"
10+
},
11+
"_source": "git://github.com/Polymer/core-action-icons.git",
12+
"_target": "0.2.3",
13+
"_originalSource": "Polymer/core-action-icons"
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
core-action-icons
2+
=================
3+
4+
This is a _resource_ component which contains image assets for the default core icon set.
5+
6+
While HTML, JS, and CSS can be combined for production deployments by tools like Vulcanizer, some assets are easier to deliver as is.
7+
8+
Projects using the default core icon set should include this component in deployments verbatim.
33.3 KB
Loading

bower_components/core-action-icons/action-icons.svg

Lines changed: 1352 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "core-ajax",
3+
"private": true,
4+
"dependencies": {
5+
"polymer": "Polymer/polymer#0.2.3"
6+
},
7+
"version": "0.2.3",
8+
"homepage": "https://github.com/Polymer/core-ajax",
9+
"_release": "0.2.3",
10+
"_resolution": {
11+
"type": "version",
12+
"tag": "0.2.3",
13+
"commit": "86ec30d097037ed3699556567bae6b09b553ce51"
14+
},
15+
"_source": "git://github.com/Polymer/core-ajax.git",
16+
"_target": "0.2.3",
17+
"_originalSource": "Polymer/core-ajax"
18+
}

bower_components/core-ajax/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
core-ajax
2+
=========
3+
4+
See the [component page](http://polymer.github.io/core-ajax) for more information.

bower_components/core-ajax/bower.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "core-ajax",
3+
"private": true,
4+
"dependencies": {
5+
"polymer": "Polymer/polymer#0.2.3"
6+
},
7+
"version": "0.2.3"
8+
}
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
<!--
2+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6+
Code distributed by Google as part of the polymer project is also
7+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8+
-->
9+
10+
<!--
11+
@group Polymer Core Elements
12+
13+
The `core-ajax` element exposes `XMLHttpRequest` functionality.
14+
15+
<core-ajax
16+
auto
17+
url="http://gdata.youtube.com/feeds/api/videos/"
18+
params='{"alt":"json", "q":"chrome"}'
19+
handleAs="json"
20+
on-core-response="{{handleResponse}}"></core-ajax>
21+
22+
With `auto` set to `true`, the element performs a request whenever
23+
its `url` or `params` properties are changed.
24+
25+
Note: The `params` attribute must be double quoted JSON.
26+
27+
You can trigger a request explicitly by calling `go` on the
28+
element.
29+
30+
@element core-ajax
31+
@status beta
32+
@homepage github.io
33+
-->
34+
35+
<link rel="import" href="core-xhr.html">
36+
37+
<polymer-element name="core-ajax" attributes="url handleAs auto params response method headers body contentType withCredentials">
38+
39+
<script>
40+
41+
Polymer('core-ajax', {
42+
/**
43+
* Fired when a response is received.
44+
*
45+
* @event core-response
46+
*/
47+
48+
/**
49+
* Fired when an error is received.
50+
*
51+
* @event core-error
52+
*/
53+
54+
/**
55+
* Fired whenever a response or an error is received.
56+
*
57+
* @event core-complete
58+
*/
59+
60+
/**
61+
* The URL target of the request.
62+
*
63+
* @attribute url
64+
* @type string
65+
* @default ''
66+
*/
67+
url: '',
68+
69+
/**
70+
* Specifies what data to store in the `response` property, and
71+
* to deliver as `event.response` in `response` events.
72+
*
73+
* One of:
74+
*
75+
* `text`: uses `XHR.responseText`.
76+
*
77+
* `xml`: uses `XHR.responseXML`.
78+
*
79+
* `json`: uses `XHR.responseText` parsed as JSON.
80+
*
81+
* @attribute handleAs
82+
* @type string
83+
* @default 'text'
84+
*/
85+
handleAs: '',
86+
87+
/**
88+
* If true, automatically performs an Ajax request when either `url` or `params` changes.
89+
*
90+
* @attribute auto
91+
* @type boolean
92+
* @default false
93+
*/
94+
auto: false,
95+
96+
/**
97+
* Parameters to send to the specified URL, as JSON.
98+
*
99+
* @attribute params
100+
* @type string (JSON)
101+
* @default ''
102+
*/
103+
params: '',
104+
105+
/**
106+
* Returns the response object.
107+
*
108+
* @attribute response
109+
* @type Object
110+
* @default null
111+
*/
112+
response: null,
113+
114+
/**
115+
* The HTTP method to use such as 'GET', 'POST', 'PUT', or 'DELETE'.
116+
* Default is 'GET'.
117+
*
118+
* @attribute method
119+
* @type string
120+
* @default ''
121+
*/
122+
method: '',
123+
124+
/**
125+
* HTTP request headers to send.
126+
*
127+
* Example:
128+
*
129+
* <core-ajax
130+
* auto
131+
* url="http://somesite.com"
132+
* headers='{"X-Requested-With": "XMLHttpRequest"}'
133+
* handleAs="json"
134+
* on-core-response="{{handleResponse}}"></core-ajax>
135+
*
136+
* @attribute headers
137+
* @type Object
138+
* @default null
139+
*/
140+
headers: null,
141+
142+
/**
143+
* Optional raw body content to send when method === "POST".
144+
*
145+
* Example:
146+
*
147+
* <core-ajax method="POST" auto url="http://somesite.com"
148+
* body='{"foo":1, "bar":2}'>
149+
* </core-ajax>
150+
*
151+
* @attribute body
152+
* @type Object
153+
* @default null
154+
*/
155+
body: null,
156+
157+
/**
158+
* Content type to use when sending data.
159+
*
160+
* @attribute contentType
161+
* @type string
162+
* @default 'application/x-www-form-urlencoded'
163+
*/
164+
contentType: 'application/x-www-form-urlencoded',
165+
166+
/**
167+
* Set the withCredentials flag on the request.
168+
*
169+
* @attribute withCredentials
170+
* @type boolean
171+
* @default false
172+
*/
173+
withCredentials: false,
174+
175+
ready: function() {
176+
this.xhr = document.createElement('core-xhr');
177+
},
178+
179+
receive: function(response, xhr) {
180+
if (this.isSuccess(xhr)) {
181+
this.processResponse(xhr);
182+
} else {
183+
this.error(xhr);
184+
}
185+
this.complete(xhr);
186+
},
187+
188+
isSuccess: function(xhr) {
189+
var status = xhr.status || 0;
190+
return !status || (status >= 200 && status < 300);
191+
},
192+
193+
processResponse: function(xhr) {
194+
var response = this.evalResponse(xhr);
195+
this.response = response;
196+
this.fire('core-response', {response: response, xhr: xhr});
197+
},
198+
199+
error: function(xhr) {
200+
var response = xhr.status + ': ' + xhr.responseText;
201+
this.fire('core-error', {response: response, xhr: xhr});
202+
},
203+
204+
complete: function(xhr) {
205+
this.fire('core-complete', {response: xhr.status, xhr: xhr});
206+
},
207+
208+
evalResponse: function(xhr) {
209+
return this[(this.handleAs || 'text') + 'Handler'](xhr);
210+
},
211+
212+
xmlHandler: function(xhr) {
213+
return xhr.responseXML;
214+
},
215+
216+
textHandler: function(xhr) {
217+
return xhr.responseText;
218+
},
219+
220+
jsonHandler: function(xhr) {
221+
var r = xhr.responseText;
222+
try {
223+
return JSON.parse(r);
224+
} catch (x) {
225+
return r;
226+
}
227+
},
228+
229+
urlChanged: function() {
230+
if (!this.handleAs) {
231+
var ext = String(this.url).split('.').pop();
232+
switch (ext) {
233+
case 'json':
234+
this.handleAs = 'json';
235+
break;
236+
}
237+
}
238+
this.autoGo();
239+
},
240+
241+
paramsChanged: function() {
242+
this.autoGo();
243+
},
244+
245+
autoChanged: function() {
246+
this.autoGo();
247+
},
248+
249+
// TODO(sorvell): multiple side-effects could call autoGo
250+
// during one micro-task, use a job to have only one action
251+
// occur
252+
autoGo: function() {
253+
if (this.auto) {
254+
this.goJob = this.job(this.goJob, this.go, 0);
255+
}
256+
},
257+
258+
/**
259+
* Performs an Ajax request to the specified URL.
260+
*
261+
* @method go
262+
*/
263+
go: function() {
264+
var args = this.xhrArgs || {};
265+
// TODO(sjmiles): alternatively, we could force POST if body is set
266+
if (this.method === 'POST') {
267+
args.body = this.body || args.body;
268+
}
269+
args.params = this.params || args.params;
270+
if (args.params && typeof(args.params) == 'string') {
271+
args.params = JSON.parse(args.params);
272+
}
273+
args.headers = this.headers || args.headers || {};
274+
if (args.headers && typeof(args.headers) == 'string') {
275+
args.headers = JSON.parse(args.headers);
276+
}
277+
if (this.contentType) {
278+
args.headers['content-type'] = this.contentType;
279+
}
280+
281+
args.withCredentials = this.withCredentials;
282+
args.callback = this.receive.bind(this);
283+
args.url = this.url;
284+
args.method = this.method;
285+
return args.url && this.xhr.request(args);
286+
}
287+
288+
});
289+
290+
</script>
291+
292+
</polymer-element>

0 commit comments

Comments
 (0)