Version Description
- 26 September 2016 =
- Changed CSS parsing library. Fixed several issues with the visual editor mode.
- Added address bar to preview window.
- Small CSS fixes.
- Small changes to allow adding more visual editor fields.
Download this release
Release Info
Developer | gpriday |
Plugin | SiteOrigin CSS |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.8 to 1.1
- css/admin.css +37 -3
- js/URI.js +2201 -0
- js/URI.min.js +1 -0
- js/css.js +4344 -555
- js/css.min.js +2 -1
- js/editor.js +146 -76
- js/editor.min.js +1 -1
- js/inspector.js +52 -27
- js/inspector.min.js +1 -1
- readme.txt +8 -2
- so-css.php +14 -5
- tpl/js-templates.php +7 -0
- tpl/page.php +6 -9
css/admin.css
CHANGED
@@ -64,7 +64,8 @@
|
|
64 |
margin: 0;
|
65 |
line-height: 2.2em;
|
66 |
}
|
67 |
-
#so-custom-css-form .custom-css-preview iframe
|
|
|
68 |
display: none;
|
69 |
}
|
70 |
#so-custom-css-form .custom-css-toolbar {
|
@@ -169,13 +170,41 @@
|
|
169 |
#so-custom-css-form.expanded .custom-css-preview {
|
170 |
position: fixed;
|
171 |
display: block;
|
172 |
-
top:
|
173 |
right: 0;
|
174 |
bottom: 0;
|
175 |
left: 340px;
|
176 |
background: #ffffff;
|
177 |
}
|
178 |
-
#so-custom-css-form.expanded .custom-css-preview
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
display: block;
|
180 |
width: 100%;
|
181 |
height: 100%;
|
@@ -302,6 +331,11 @@
|
|
302 |
width: 175px;
|
303 |
box-sizing: border-box;
|
304 |
border-radius: 0;
|
|
|
|
|
|
|
|
|
|
|
305 |
}
|
306 |
#so-custom-css-properties .sections .fields-table .select {
|
307 |
display: block;
|
64 |
margin: 0;
|
65 |
line-height: 2.2em;
|
66 |
}
|
67 |
+
#so-custom-css-form .custom-css-preview iframe,
|
68 |
+
#so-custom-css-form .custom-css-preview #preview-navigator {
|
69 |
display: none;
|
70 |
}
|
71 |
#so-custom-css-form .custom-css-toolbar {
|
170 |
#so-custom-css-form.expanded .custom-css-preview {
|
171 |
position: fixed;
|
172 |
display: block;
|
173 |
+
top: 40px;
|
174 |
right: 0;
|
175 |
bottom: 0;
|
176 |
left: 340px;
|
177 |
background: #ffffff;
|
178 |
}
|
179 |
+
#so-custom-css-form.expanded .custom-css-preview #preview-navigator {
|
180 |
+
display: block;
|
181 |
+
-ms-box-sizing: border-box;
|
182 |
+
-moz-box-sizing: border-box;
|
183 |
+
-webkit-box-sizing: border-box;
|
184 |
+
box-sizing: border-box;
|
185 |
+
padding: 6px 10px;
|
186 |
+
position: absolute;
|
187 |
+
width: 100%;
|
188 |
+
height: 40px;
|
189 |
+
top: -40px;
|
190 |
+
background: #bbb;
|
191 |
+
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #bbb), color-stop(1, #eee));
|
192 |
+
background: -ms-linear-gradient(bottom, #bbb, #eee);
|
193 |
+
background: -moz-linear-gradient(center bottom, #bbb 0%, #eee 100%);
|
194 |
+
background: -o-linear-gradient(#eee, #bbb);
|
195 |
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eee', endColorstr='#bbb', GradientType=0);
|
196 |
+
border-bottom: 1px solid #888;
|
197 |
+
}
|
198 |
+
#so-custom-css-form.expanded .custom-css-preview #preview-navigator input {
|
199 |
+
width: 100%;
|
200 |
+
border: 1px solid #888;
|
201 |
+
border-radius: 2px;
|
202 |
+
color: #444;
|
203 |
+
-webkit-box-shadow: inset 2px 2px 2px rgba( 0,0,0,0.1 );
|
204 |
+
-moz-box-shadow: inset 2px 2px 2px rgba( 0,0,0,0.1 );
|
205 |
+
box-shadow: inset 2px 2px 2px rgba( 0,0,0,0.1 );
|
206 |
+
}
|
207 |
+
#so-custom-css-form.expanded .custom-css-preview #preview-iframe {
|
208 |
display: block;
|
209 |
width: 100%;
|
210 |
height: 100%;
|
331 |
width: 175px;
|
332 |
box-sizing: border-box;
|
333 |
border-radius: 0;
|
334 |
+
font-size: 12px;
|
335 |
+
padding: 5px 8px;
|
336 |
+
}
|
337 |
+
#so-custom-css-properties .sections .fields-table .minicolors input {
|
338 |
+
padding-left: 30px;
|
339 |
}
|
340 |
#so-custom-css-properties .sections .fields-table .select {
|
341 |
display: block;
|
js/URI.js
ADDED
@@ -0,0 +1,2201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* URI.js - Mutating URLs
|
3 |
+
*
|
4 |
+
* Version: 1.18.1
|
5 |
+
*
|
6 |
+
* Author: Rodney Rehm
|
7 |
+
* Web: http://medialize.github.io/URI.js/
|
8 |
+
*
|
9 |
+
* Licensed under
|
10 |
+
* MIT License http://www.opensource.org/licenses/mit-license
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
(function (root, factory) {
|
14 |
+
'use strict';
|
15 |
+
// Browser globals (root is window)
|
16 |
+
root.URI = factory(root.punycode, root.IPv6, root.SecondLevelDomains, root);
|
17 |
+
}(this, function (punycode, IPv6, SLD, root) {
|
18 |
+
'use strict';
|
19 |
+
/*global location, escape, unescape */
|
20 |
+
// FIXME: v2.0.0 renamce non-camelCase properties to uppercase
|
21 |
+
/*jshint camelcase: false */
|
22 |
+
|
23 |
+
// save current URI variable, if any
|
24 |
+
var _URI = root && root.URI;
|
25 |
+
|
26 |
+
function URI(url, base) {
|
27 |
+
var _urlSupplied = arguments.length >= 1;
|
28 |
+
var _baseSupplied = arguments.length >= 2;
|
29 |
+
|
30 |
+
// Allow instantiation without the 'new' keyword
|
31 |
+
if (!(this instanceof URI)) {
|
32 |
+
if (_urlSupplied) {
|
33 |
+
if (_baseSupplied) {
|
34 |
+
return new URI(url, base);
|
35 |
+
}
|
36 |
+
|
37 |
+
return new URI(url);
|
38 |
+
}
|
39 |
+
|
40 |
+
return new URI();
|
41 |
+
}
|
42 |
+
|
43 |
+
if (url === undefined) {
|
44 |
+
if (_urlSupplied) {
|
45 |
+
throw new TypeError('undefined is not a valid argument for URI');
|
46 |
+
}
|
47 |
+
|
48 |
+
if (typeof location !== 'undefined') {
|
49 |
+
url = location.href + '';
|
50 |
+
} else {
|
51 |
+
url = '';
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
this.href(url);
|
56 |
+
|
57 |
+
// resolve to base according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#constructor
|
58 |
+
if (base !== undefined) {
|
59 |
+
return this.absoluteTo(base);
|
60 |
+
}
|
61 |
+
|
62 |
+
return this;
|
63 |
+
}
|
64 |
+
|
65 |
+
URI.version = '1.18.1';
|
66 |
+
|
67 |
+
var p = URI.prototype;
|
68 |
+
var hasOwn = Object.prototype.hasOwnProperty;
|
69 |
+
|
70 |
+
function escapeRegEx(string) {
|
71 |
+
// https://github.com/medialize/URI.js/commit/85ac21783c11f8ccab06106dba9735a31a86924d#commitcomment-821963
|
72 |
+
return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
|
73 |
+
}
|
74 |
+
|
75 |
+
function getType(value) {
|
76 |
+
// IE8 doesn't return [Object Undefined] but [Object Object] for undefined value
|
77 |
+
if (value === undefined) {
|
78 |
+
return 'Undefined';
|
79 |
+
}
|
80 |
+
|
81 |
+
return String(Object.prototype.toString.call(value)).slice(8, -1);
|
82 |
+
}
|
83 |
+
|
84 |
+
function isArray(obj) {
|
85 |
+
return getType(obj) === 'Array';
|
86 |
+
}
|
87 |
+
|
88 |
+
function filterArrayValues(data, value) {
|
89 |
+
var lookup = {};
|
90 |
+
var i, length;
|
91 |
+
|
92 |
+
if (getType(value) === 'RegExp') {
|
93 |
+
lookup = null;
|
94 |
+
} else if (isArray(value)) {
|
95 |
+
for (i = 0, length = value.length; i < length; i++) {
|
96 |
+
lookup[value[i]] = true;
|
97 |
+
}
|
98 |
+
} else {
|
99 |
+
lookup[value] = true;
|
100 |
+
}
|
101 |
+
|
102 |
+
for (i = 0, length = data.length; i < length; i++) {
|
103 |
+
/*jshint laxbreak: true */
|
104 |
+
var _match = lookup && lookup[data[i]] !== undefined
|
105 |
+
|| !lookup && value.test(data[i]);
|
106 |
+
/*jshint laxbreak: false */
|
107 |
+
if (_match) {
|
108 |
+
data.splice(i, 1);
|
109 |
+
length--;
|
110 |
+
i--;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
return data;
|
115 |
+
}
|
116 |
+
|
117 |
+
function arrayContains(list, value) {
|
118 |
+
var i, length;
|
119 |
+
|
120 |
+
// value may be string, number, array, regexp
|
121 |
+
if (isArray(value)) {
|
122 |
+
// Note: this can be optimized to O(n) (instead of current O(m * n))
|
123 |
+
for (i = 0, length = value.length; i < length; i++) {
|
124 |
+
if (!arrayContains(list, value[i])) {
|
125 |
+
return false;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
return true;
|
130 |
+
}
|
131 |
+
|
132 |
+
var _type = getType(value);
|
133 |
+
for (i = 0, length = list.length; i < length; i++) {
|
134 |
+
if (_type === 'RegExp') {
|
135 |
+
if (typeof list[i] === 'string' && list[i].match(value)) {
|
136 |
+
return true;
|
137 |
+
}
|
138 |
+
} else if (list[i] === value) {
|
139 |
+
return true;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
return false;
|
144 |
+
}
|
145 |
+
|
146 |
+
function arraysEqual(one, two) {
|
147 |
+
if (!isArray(one) || !isArray(two)) {
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
|
151 |
+
// arrays can't be equal if they have different amount of content
|
152 |
+
if (one.length !== two.length) {
|
153 |
+
return false;
|
154 |
+
}
|
155 |
+
|
156 |
+
one.sort();
|
157 |
+
two.sort();
|
158 |
+
|
159 |
+
for (var i = 0, l = one.length; i < l; i++) {
|
160 |
+
if (one[i] !== two[i]) {
|
161 |
+
return false;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
return true;
|
166 |
+
}
|
167 |
+
|
168 |
+
function trimSlashes(text) {
|
169 |
+
var trim_expression = /^\/+|\/+$/g;
|
170 |
+
return text.replace(trim_expression, '');
|
171 |
+
}
|
172 |
+
|
173 |
+
URI._parts = function() {
|
174 |
+
return {
|
175 |
+
protocol: null,
|
176 |
+
username: null,
|
177 |
+
password: null,
|
178 |
+
hostname: null,
|
179 |
+
urn: null,
|
180 |
+
port: null,
|
181 |
+
path: null,
|
182 |
+
query: null,
|
183 |
+
fragment: null,
|
184 |
+
// state
|
185 |
+
duplicateQueryParameters: URI.duplicateQueryParameters,
|
186 |
+
escapeQuerySpace: URI.escapeQuerySpace
|
187 |
+
};
|
188 |
+
};
|
189 |
+
// state: allow duplicate query parameters (a=1&a=1)
|
190 |
+
URI.duplicateQueryParameters = false;
|
191 |
+
// state: replaces + with %20 (space in query strings)
|
192 |
+
URI.escapeQuerySpace = true;
|
193 |
+
// static properties
|
194 |
+
URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i;
|
195 |
+
URI.idn_expression = /[^a-z0-9\.-]/i;
|
196 |
+
URI.punycode_expression = /(xn--)/i;
|
197 |
+
// well, 333.444.555.666 matches, but it sure ain't no IPv4 - do we care?
|
198 |
+
URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
199 |
+
// credits to Rich Brown
|
200 |
+
// source: http://forums.intermapper.com/viewtopic.php?p=1096#1096
|
201 |
+
// specification: http://www.ietf.org/rfc/rfc4291.txt
|
202 |
+
URI.ip6_expression = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
|
203 |
+
// expression used is "gruber revised" (@gruber v2) determined to be the
|
204 |
+
// best solution in a regex-golf we did a couple of ages ago at
|
205 |
+
// * http://mathiasbynens.be/demo/url-regex
|
206 |
+
// * http://rodneyrehm.de/t/url-regex.html
|
207 |
+
URI.find_uri_expression = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig;
|
208 |
+
URI.findUri = {
|
209 |
+
// valid "scheme://" or "www."
|
210 |
+
start: /\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,
|
211 |
+
// everything up to the next whitespace
|
212 |
+
end: /[\s\r\n]|$/,
|
213 |
+
// trim trailing punctuation captured by end RegExp
|
214 |
+
trim: /[`!()\[\]{};:'".,<>?«»“”„‘’]+$/
|
215 |
+
};
|
216 |
+
// http://www.iana.org/assignments/uri-schemes.html
|
217 |
+
// http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports
|
218 |
+
URI.defaultPorts = {
|
219 |
+
http: '80',
|
220 |
+
https: '443',
|
221 |
+
ftp: '21',
|
222 |
+
gopher: '70',
|
223 |
+
ws: '80',
|
224 |
+
wss: '443'
|
225 |
+
};
|
226 |
+
// allowed hostname characters according to RFC 3986
|
227 |
+
// ALPHA DIGIT "-" "." "_" "~" "!" "$" "&" "'" "(" ")" "*" "+" "," ";" "=" %encoded
|
228 |
+
// I've never seen a (non-IDN) hostname other than: ALPHA DIGIT . -
|
229 |
+
URI.invalid_hostname_characters = /[^a-zA-Z0-9\.-]/;
|
230 |
+
// map DOM Elements to their URI attribute
|
231 |
+
URI.domAttributes = {
|
232 |
+
'a': 'href',
|
233 |
+
'blockquote': 'cite',
|
234 |
+
'link': 'href',
|
235 |
+
'base': 'href',
|
236 |
+
'script': 'src',
|
237 |
+
'form': 'action',
|
238 |
+
'img': 'src',
|
239 |
+
'area': 'href',
|
240 |
+
'iframe': 'src',
|
241 |
+
'embed': 'src',
|
242 |
+
'source': 'src',
|
243 |
+
'track': 'src',
|
244 |
+
'input': 'src', // but only if type="image"
|
245 |
+
'audio': 'src',
|
246 |
+
'video': 'src'
|
247 |
+
};
|
248 |
+
URI.getDomAttribute = function(node) {
|
249 |
+
if (!node || !node.nodeName) {
|
250 |
+
return undefined;
|
251 |
+
}
|
252 |
+
|
253 |
+
var nodeName = node.nodeName.toLowerCase();
|
254 |
+
// <input> should only expose src for type="image"
|
255 |
+
if (nodeName === 'input' && node.type !== 'image') {
|
256 |
+
return undefined;
|
257 |
+
}
|
258 |
+
|
259 |
+
return URI.domAttributes[nodeName];
|
260 |
+
};
|
261 |
+
|
262 |
+
function escapeForDumbFirefox36(value) {
|
263 |
+
// https://github.com/medialize/URI.js/issues/91
|
264 |
+
return escape(value);
|
265 |
+
}
|
266 |
+
|
267 |
+
// encoding / decoding according to RFC3986
|
268 |
+
function strictEncodeURIComponent(string) {
|
269 |
+
// see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent
|
270 |
+
return encodeURIComponent(string)
|
271 |
+
.replace(/[!'()*]/g, escapeForDumbFirefox36)
|
272 |
+
.replace(/\*/g, '%2A');
|
273 |
+
}
|
274 |
+
URI.encode = strictEncodeURIComponent;
|
275 |
+
URI.decode = decodeURIComponent;
|
276 |
+
URI.iso8859 = function() {
|
277 |
+
URI.encode = escape;
|
278 |
+
URI.decode = unescape;
|
279 |
+
};
|
280 |
+
URI.unicode = function() {
|
281 |
+
URI.encode = strictEncodeURIComponent;
|
282 |
+
URI.decode = decodeURIComponent;
|
283 |
+
};
|
284 |
+
URI.characters = {
|
285 |
+
pathname: {
|
286 |
+
encode: {
|
287 |
+
// RFC3986 2.1: For consistency, URI producers and normalizers should
|
288 |
+
// use uppercase hexadecimal digits for all percent-encodings.
|
289 |
+
expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig,
|
290 |
+
map: {
|
291 |
+
// -._~!'()*
|
292 |
+
'%24': '$',
|
293 |
+
'%26': '&',
|
294 |
+
'%2B': '+',
|
295 |
+
'%2C': ',',
|
296 |
+
'%3B': ';',
|
297 |
+
'%3D': '=',
|
298 |
+
'%3A': ':',
|
299 |
+
'%40': '@'
|
300 |
+
}
|
301 |
+
},
|
302 |
+
decode: {
|
303 |
+
expression: /[\/\?#]/g,
|
304 |
+
map: {
|
305 |
+
'/': '%2F',
|
306 |
+
'?': '%3F',
|
307 |
+
'#': '%23'
|
308 |
+
}
|
309 |
+
}
|
310 |
+
},
|
311 |
+
reserved: {
|
312 |
+
encode: {
|
313 |
+
// RFC3986 2.1: For consistency, URI producers and normalizers should
|
314 |
+
// use uppercase hexadecimal digits for all percent-encodings.
|
315 |
+
expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,
|
316 |
+
map: {
|
317 |
+
// gen-delims
|
318 |
+
'%3A': ':',
|
319 |
+
'%2F': '/',
|
320 |
+
'%3F': '?',
|
321 |
+
'%23': '#',
|
322 |
+
'%5B': '[',
|
323 |
+
'%5D': ']',
|
324 |
+
'%40': '@',
|
325 |
+
// sub-delims
|
326 |
+
'%21': '!',
|
327 |
+
'%24': '$',
|
328 |
+
'%26': '&',
|
329 |
+
'%27': '\'',
|
330 |
+
'%28': '(',
|
331 |
+
'%29': ')',
|
332 |
+
'%2A': '*',
|
333 |
+
'%2B': '+',
|
334 |
+
'%2C': ',',
|
335 |
+
'%3B': ';',
|
336 |
+
'%3D': '='
|
337 |
+
}
|
338 |
+
}
|
339 |
+
},
|
340 |
+
urnpath: {
|
341 |
+
// The characters under `encode` are the characters called out by RFC 2141 as being acceptable
|
342 |
+
// for usage in a URN. RFC2141 also calls out "-", ".", and "_" as acceptable characters, but
|
343 |
+
// these aren't encoded by encodeURIComponent, so we don't have to call them out here. Also
|
344 |
+
// note that the colon character is not featured in the encoding map; this is because URI.js
|
345 |
+
// gives the colons in URNs semantic meaning as the delimiters of path segements, and so it
|
346 |
+
// should not appear unencoded in a segment itself.
|
347 |
+
// See also the note above about RFC3986 and capitalalized hex digits.
|
348 |
+
encode: {
|
349 |
+
expression: /%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,
|
350 |
+
map: {
|
351 |
+
'%21': '!',
|
352 |
+
'%24': '$',
|
353 |
+
'%27': '\'',
|
354 |
+
'%28': '(',
|
355 |
+
'%29': ')',
|
356 |
+
'%2A': '*',
|
357 |
+
'%2B': '+',
|
358 |
+
'%2C': ',',
|
359 |
+
'%3B': ';',
|
360 |
+
'%3D': '=',
|
361 |
+
'%40': '@'
|
362 |
+
}
|
363 |
+
},
|
364 |
+
// These characters are the characters called out by RFC2141 as "reserved" characters that
|
365 |
+
// should never appear in a URN, plus the colon character (see note above).
|
366 |
+
decode: {
|
367 |
+
expression: /[\/\?#:]/g,
|
368 |
+
map: {
|
369 |
+
'/': '%2F',
|
370 |
+
'?': '%3F',
|
371 |
+
'#': '%23',
|
372 |
+
':': '%3A'
|
373 |
+
}
|
374 |
+
}
|
375 |
+
}
|
376 |
+
};
|
377 |
+
URI.encodeQuery = function(string, escapeQuerySpace) {
|
378 |
+
var escaped = URI.encode(string + '');
|
379 |
+
if (escapeQuerySpace === undefined) {
|
380 |
+
escapeQuerySpace = URI.escapeQuerySpace;
|
381 |
+
}
|
382 |
+
|
383 |
+
return escapeQuerySpace ? escaped.replace(/%20/g, '+') : escaped;
|
384 |
+
};
|
385 |
+
URI.decodeQuery = function(string, escapeQuerySpace) {
|
386 |
+
string += '';
|
387 |
+
if (escapeQuerySpace === undefined) {
|
388 |
+
escapeQuerySpace = URI.escapeQuerySpace;
|
389 |
+
}
|
390 |
+
|
391 |
+
try {
|
392 |
+
return URI.decode(escapeQuerySpace ? string.replace(/\+/g, '%20') : string);
|
393 |
+
} catch(e) {
|
394 |
+
// we're not going to mess with weird encodings,
|
395 |
+
// give up and return the undecoded original string
|
396 |
+
// see https://github.com/medialize/URI.js/issues/87
|
397 |
+
// see https://github.com/medialize/URI.js/issues/92
|
398 |
+
return string;
|
399 |
+
}
|
400 |
+
};
|
401 |
+
// generate encode/decode path functions
|
402 |
+
var _parts = {'encode':'encode', 'decode':'decode'};
|
403 |
+
var _part;
|
404 |
+
var generateAccessor = function(_group, _part) {
|
405 |
+
return function(string) {
|
406 |
+
try {
|
407 |
+
return URI[_part](string + '').replace(URI.characters[_group][_part].expression, function(c) {
|
408 |
+
return URI.characters[_group][_part].map[c];
|
409 |
+
});
|
410 |
+
} catch (e) {
|
411 |
+
// we're not going to mess with weird encodings,
|
412 |
+
// give up and return the undecoded original string
|
413 |
+
// see https://github.com/medialize/URI.js/issues/87
|
414 |
+
// see https://github.com/medialize/URI.js/issues/92
|
415 |
+
return string;
|
416 |
+
}
|
417 |
+
};
|
418 |
+
};
|
419 |
+
|
420 |
+
for (_part in _parts) {
|
421 |
+
URI[_part + 'PathSegment'] = generateAccessor('pathname', _parts[_part]);
|
422 |
+
URI[_part + 'UrnPathSegment'] = generateAccessor('urnpath', _parts[_part]);
|
423 |
+
}
|
424 |
+
|
425 |
+
var generateSegmentedPathFunction = function(_sep, _codingFuncName, _innerCodingFuncName) {
|
426 |
+
return function(string) {
|
427 |
+
// Why pass in names of functions, rather than the function objects themselves? The
|
428 |
+
// definitions of some functions (but in particular, URI.decode) will occasionally change due
|
429 |
+
// to URI.js having ISO8859 and Unicode modes. Passing in the name and getting it will ensure
|
430 |
+
// that the functions we use here are "fresh".
|
431 |
+
var actualCodingFunc;
|
432 |
+
if (!_innerCodingFuncName) {
|
433 |
+
actualCodingFunc = URI[_codingFuncName];
|
434 |
+
} else {
|
435 |
+
actualCodingFunc = function(string) {
|
436 |
+
return URI[_codingFuncName](URI[_innerCodingFuncName](string));
|
437 |
+
};
|
438 |
+
}
|
439 |
+
|
440 |
+
var segments = (string + '').split(_sep);
|
441 |
+
|
442 |
+
for (var i = 0, length = segments.length; i < length; i++) {
|
443 |
+
segments[i] = actualCodingFunc(segments[i]);
|
444 |
+
}
|
445 |
+
|
446 |
+
return segments.join(_sep);
|
447 |
+
};
|
448 |
+
};
|
449 |
+
|
450 |
+
// This takes place outside the above loop because we don't want, e.g., encodeUrnPath functions.
|
451 |
+
URI.decodePath = generateSegmentedPathFunction('/', 'decodePathSegment');
|
452 |
+
URI.decodeUrnPath = generateSegmentedPathFunction(':', 'decodeUrnPathSegment');
|
453 |
+
URI.recodePath = generateSegmentedPathFunction('/', 'encodePathSegment', 'decode');
|
454 |
+
URI.recodeUrnPath = generateSegmentedPathFunction(':', 'encodeUrnPathSegment', 'decode');
|
455 |
+
|
456 |
+
URI.encodeReserved = generateAccessor('reserved', 'encode');
|
457 |
+
|
458 |
+
URI.parse = function(string, parts) {
|
459 |
+
var pos;
|
460 |
+
if (!parts) {
|
461 |
+
parts = {};
|
462 |
+
}
|
463 |
+
// [protocol"://"[username[":"password]"@"]hostname[":"port]"/"?][path]["?"querystring]["#"fragment]
|
464 |
+
|
465 |
+
// extract fragment
|
466 |
+
pos = string.indexOf('#');
|
467 |
+
if (pos > -1) {
|
468 |
+
// escaping?
|
469 |
+
parts.fragment = string.substring(pos + 1) || null;
|
470 |
+
string = string.substring(0, pos);
|
471 |
+
}
|
472 |
+
|
473 |
+
// extract query
|
474 |
+
pos = string.indexOf('?');
|
475 |
+
if (pos > -1) {
|
476 |
+
// escaping?
|
477 |
+
parts.query = string.substring(pos + 1) || null;
|
478 |
+
string = string.substring(0, pos);
|
479 |
+
}
|
480 |
+
|
481 |
+
// extract protocol
|
482 |
+
if (string.substring(0, 2) === '//') {
|
483 |
+
// relative-scheme
|
484 |
+
parts.protocol = null;
|
485 |
+
string = string.substring(2);
|
486 |
+
// extract "user:pass@host:port"
|
487 |
+
string = URI.parseAuthority(string, parts);
|
488 |
+
} else {
|
489 |
+
pos = string.indexOf(':');
|
490 |
+
if (pos > -1) {
|
491 |
+
parts.protocol = string.substring(0, pos) || null;
|
492 |
+
if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
|
493 |
+
// : may be within the path
|
494 |
+
parts.protocol = undefined;
|
495 |
+
} else if (string.substring(pos + 1, pos + 3) === '//') {
|
496 |
+
string = string.substring(pos + 3);
|
497 |
+
|
498 |
+
// extract "user:pass@host:port"
|
499 |
+
string = URI.parseAuthority(string, parts);
|
500 |
+
} else {
|
501 |
+
string = string.substring(pos + 1);
|
502 |
+
parts.urn = true;
|
503 |
+
}
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
// what's left must be the path
|
508 |
+
parts.path = string;
|
509 |
+
|
510 |
+
// and we're done
|
511 |
+
return parts;
|
512 |
+
};
|
513 |
+
URI.parseHost = function(string, parts) {
|
514 |
+
// Copy chrome, IE, opera backslash-handling behavior.
|
515 |
+
// Back slashes before the query string get converted to forward slashes
|
516 |
+
// See: https://github.com/joyent/node/blob/386fd24f49b0e9d1a8a076592a404168faeecc34/lib/url.js#L115-L124
|
517 |
+
// See: https://code.google.com/p/chromium/issues/detail?id=25916
|
518 |
+
// https://github.com/medialize/URI.js/pull/233
|
519 |
+
string = string.replace(/\\/g, '/');
|
520 |
+
|
521 |
+
// extract host:port
|
522 |
+
var pos = string.indexOf('/');
|
523 |
+
var bracketPos;
|
524 |
+
var t;
|
525 |
+
|
526 |
+
if (pos === -1) {
|
527 |
+
pos = string.length;
|
528 |
+
}
|
529 |
+
|
530 |
+
if (string.charAt(0) === '[') {
|
531 |
+
// IPv6 host - http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04#section-6
|
532 |
+
// I claim most client software breaks on IPv6 anyways. To simplify things, URI only accepts
|
533 |
+
// IPv6+port in the format [2001:db8::1]:80 (for the time being)
|
534 |
+
bracketPos = string.indexOf(']');
|
535 |
+
parts.hostname = string.substring(1, bracketPos) || null;
|
536 |
+
parts.port = string.substring(bracketPos + 2, pos) || null;
|
537 |
+
if (parts.port === '/') {
|
538 |
+
parts.port = null;
|
539 |
+
}
|
540 |
+
} else {
|
541 |
+
var firstColon = string.indexOf(':');
|
542 |
+
var firstSlash = string.indexOf('/');
|
543 |
+
var nextColon = string.indexOf(':', firstColon + 1);
|
544 |
+
if (nextColon !== -1 && (firstSlash === -1 || nextColon < firstSlash)) {
|
545 |
+
// IPv6 host contains multiple colons - but no port
|
546 |
+
// this notation is actually not allowed by RFC 3986, but we're a liberal parser
|
547 |
+
parts.hostname = string.substring(0, pos) || null;
|
548 |
+
parts.port = null;
|
549 |
+
} else {
|
550 |
+
t = string.substring(0, pos).split(':');
|
551 |
+
parts.hostname = t[0] || null;
|
552 |
+
parts.port = t[1] || null;
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
if (parts.hostname && string.substring(pos).charAt(0) !== '/') {
|
557 |
+
pos++;
|
558 |
+
string = '/' + string;
|
559 |
+
}
|
560 |
+
|
561 |
+
return string.substring(pos) || '/';
|
562 |
+
};
|
563 |
+
URI.parseAuthority = function(string, parts) {
|
564 |
+
string = URI.parseUserinfo(string, parts);
|
565 |
+
return URI.parseHost(string, parts);
|
566 |
+
};
|
567 |
+
URI.parseUserinfo = function(string, parts) {
|
568 |
+
// extract username:password
|
569 |
+
var firstSlash = string.indexOf('/');
|
570 |
+
var pos = string.lastIndexOf('@', firstSlash > -1 ? firstSlash : string.length - 1);
|
571 |
+
var t;
|
572 |
+
|
573 |
+
// authority@ must come before /path
|
574 |
+
if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) {
|
575 |
+
t = string.substring(0, pos).split(':');
|
576 |
+
parts.username = t[0] ? URI.decode(t[0]) : null;
|
577 |
+
t.shift();
|
578 |
+
parts.password = t[0] ? URI.decode(t.join(':')) : null;
|
579 |
+
string = string.substring(pos + 1);
|
580 |
+
} else {
|
581 |
+
parts.username = null;
|
582 |
+
parts.password = null;
|
583 |
+
}
|
584 |
+
|
585 |
+
return string;
|
586 |
+
};
|
587 |
+
URI.parseQuery = function(string, escapeQuerySpace) {
|
588 |
+
if (!string) {
|
589 |
+
return {};
|
590 |
+
}
|
591 |
+
|
592 |
+
// throw out the funky business - "?"[name"="value"&"]+
|
593 |
+
string = string.replace(/&+/g, '&').replace(/^\?*&*|&+$/g, '');
|
594 |
+
|
595 |
+
if (!string) {
|
596 |
+
return {};
|
597 |
+
}
|
598 |
+
|
599 |
+
var items = {};
|
600 |
+
var splits = string.split('&');
|
601 |
+
var length = splits.length;
|
602 |
+
var v, name, value;
|
603 |
+
|
604 |
+
for (var i = 0; i < length; i++) {
|
605 |
+
v = splits[i].split('=');
|
606 |
+
name = URI.decodeQuery(v.shift(), escapeQuerySpace);
|
607 |
+
// no "=" is null according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters
|
608 |
+
value = v.length ? URI.decodeQuery(v.join('='), escapeQuerySpace) : null;
|
609 |
+
|
610 |
+
if (hasOwn.call(items, name)) {
|
611 |
+
if (typeof items[name] === 'string' || items[name] === null) {
|
612 |
+
items[name] = [items[name]];
|
613 |
+
}
|
614 |
+
|
615 |
+
items[name].push(value);
|
616 |
+
} else {
|
617 |
+
items[name] = value;
|
618 |
+
}
|
619 |
+
}
|
620 |
+
|
621 |
+
return items;
|
622 |
+
};
|
623 |
+
|
624 |
+
URI.build = function(parts) {
|
625 |
+
var t = '';
|
626 |
+
|
627 |
+
if (parts.protocol) {
|
628 |
+
t += parts.protocol + ':';
|
629 |
+
}
|
630 |
+
|
631 |
+
if (!parts.urn && (t || parts.hostname)) {
|
632 |
+
t += '//';
|
633 |
+
}
|
634 |
+
|
635 |
+
t += (URI.buildAuthority(parts) || '');
|
636 |
+
|
637 |
+
if (typeof parts.path === 'string') {
|
638 |
+
if (parts.path.charAt(0) !== '/' && typeof parts.hostname === 'string') {
|
639 |
+
t += '/';
|
640 |
+
}
|
641 |
+
|
642 |
+
t += parts.path;
|
643 |
+
}
|
644 |
+
|
645 |
+
if (typeof parts.query === 'string' && parts.query) {
|
646 |
+
t += '?' + parts.query;
|
647 |
+
}
|
648 |
+
|
649 |
+
if (typeof parts.fragment === 'string' && parts.fragment) {
|
650 |
+
t += '#' + parts.fragment;
|
651 |
+
}
|
652 |
+
return t;
|
653 |
+
};
|
654 |
+
URI.buildHost = function(parts) {
|
655 |
+
var t = '';
|
656 |
+
|
657 |
+
if (!parts.hostname) {
|
658 |
+
return '';
|
659 |
+
} else if (URI.ip6_expression.test(parts.hostname)) {
|
660 |
+
t += '[' + parts.hostname + ']';
|
661 |
+
} else {
|
662 |
+
t += parts.hostname;
|
663 |
+
}
|
664 |
+
|
665 |
+
if (parts.port) {
|
666 |
+
t += ':' + parts.port;
|
667 |
+
}
|
668 |
+
|
669 |
+
return t;
|
670 |
+
};
|
671 |
+
URI.buildAuthority = function(parts) {
|
672 |
+
return URI.buildUserinfo(parts) + URI.buildHost(parts);
|
673 |
+
};
|
674 |
+
URI.buildUserinfo = function(parts) {
|
675 |
+
var t = '';
|
676 |
+
|
677 |
+
if (parts.username) {
|
678 |
+
t += URI.encode(parts.username);
|
679 |
+
}
|
680 |
+
|
681 |
+
if (parts.password) {
|
682 |
+
t += ':' + URI.encode(parts.password);
|
683 |
+
}
|
684 |
+
|
685 |
+
if (t) {
|
686 |
+
t += '@';
|
687 |
+
}
|
688 |
+
|
689 |
+
return t;
|
690 |
+
};
|
691 |
+
URI.buildQuery = function(data, duplicateQueryParameters, escapeQuerySpace) {
|
692 |
+
// according to http://tools.ietf.org/html/rfc3986 or http://labs.apache.org/webarch/uri/rfc/rfc3986.html
|
693 |
+
// being »-._~!$&'()*+,;=:@/?« %HEX and alnum are allowed
|
694 |
+
// the RFC explicitly states ?/foo being a valid use case, no mention of parameter syntax!
|
695 |
+
// URI.js treats the query string as being application/x-www-form-urlencoded
|
696 |
+
// see http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type
|
697 |
+
|
698 |
+
var t = '';
|
699 |
+
var unique, key, i, length;
|
700 |
+
for (key in data) {
|
701 |
+
if (hasOwn.call(data, key) && key) {
|
702 |
+
if (isArray(data[key])) {
|
703 |
+
unique = {};
|
704 |
+
for (i = 0, length = data[key].length; i < length; i++) {
|
705 |
+
if (data[key][i] !== undefined && unique[data[key][i] + ''] === undefined) {
|
706 |
+
t += '&' + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace);
|
707 |
+
if (duplicateQueryParameters !== true) {
|
708 |
+
unique[data[key][i] + ''] = true;
|
709 |
+
}
|
710 |
+
}
|
711 |
+
}
|
712 |
+
} else if (data[key] !== undefined) {
|
713 |
+
t += '&' + URI.buildQueryParameter(key, data[key], escapeQuerySpace);
|
714 |
+
}
|
715 |
+
}
|
716 |
+
}
|
717 |
+
|
718 |
+
return t.substring(1);
|
719 |
+
};
|
720 |
+
URI.buildQueryParameter = function(name, value, escapeQuerySpace) {
|
721 |
+
// http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type -- application/x-www-form-urlencoded
|
722 |
+
// don't append "=" for null values, according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#url-parameter-serialization
|
723 |
+
return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? '=' + URI.encodeQuery(value, escapeQuerySpace) : '');
|
724 |
+
};
|
725 |
+
|
726 |
+
URI.addQuery = function(data, name, value) {
|
727 |
+
if (typeof name === 'object') {
|
728 |
+
for (var key in name) {
|
729 |
+
if (hasOwn.call(name, key)) {
|
730 |
+
URI.addQuery(data, key, name[key]);
|
731 |
+
}
|
732 |
+
}
|
733 |
+
} else if (typeof name === 'string') {
|
734 |
+
if (data[name] === undefined) {
|
735 |
+
data[name] = value;
|
736 |
+
return;
|
737 |
+
} else if (typeof data[name] === 'string') {
|
738 |
+
data[name] = [data[name]];
|
739 |
+
}
|
740 |
+
|
741 |
+
if (!isArray(value)) {
|
742 |
+
value = [value];
|
743 |
+
}
|
744 |
+
|
745 |
+
data[name] = (data[name] || []).concat(value);
|
746 |
+
} else {
|
747 |
+
throw new TypeError('URI.addQuery() accepts an object, string as the name parameter');
|
748 |
+
}
|
749 |
+
};
|
750 |
+
URI.removeQuery = function(data, name, value) {
|
751 |
+
var i, length, key;
|
752 |
+
|
753 |
+
if (isArray(name)) {
|
754 |
+
for (i = 0, length = name.length; i < length; i++) {
|
755 |
+
data[name[i]] = undefined;
|
756 |
+
}
|
757 |
+
} else if (getType(name) === 'RegExp') {
|
758 |
+
for (key in data) {
|
759 |
+
if (name.test(key)) {
|
760 |
+
data[key] = undefined;
|
761 |
+
}
|
762 |
+
}
|
763 |
+
} else if (typeof name === 'object') {
|
764 |
+
for (key in name) {
|
765 |
+
if (hasOwn.call(name, key)) {
|
766 |
+
URI.removeQuery(data, key, name[key]);
|
767 |
+
}
|
768 |
+
}
|
769 |
+
} else if (typeof name === 'string') {
|
770 |
+
if (value !== undefined) {
|
771 |
+
if (getType(value) === 'RegExp') {
|
772 |
+
if (!isArray(data[name]) && value.test(data[name])) {
|
773 |
+
data[name] = undefined;
|
774 |
+
} else {
|
775 |
+
data[name] = filterArrayValues(data[name], value);
|
776 |
+
}
|
777 |
+
} else if (data[name] === String(value) && (!isArray(value) || value.length === 1)) {
|
778 |
+
data[name] = undefined;
|
779 |
+
} else if (isArray(data[name])) {
|
780 |
+
data[name] = filterArrayValues(data[name], value);
|
781 |
+
}
|
782 |
+
} else {
|
783 |
+
data[name] = undefined;
|
784 |
+
}
|
785 |
+
} else {
|
786 |
+
throw new TypeError('URI.removeQuery() accepts an object, string, RegExp as the first parameter');
|
787 |
+
}
|
788 |
+
};
|
789 |
+
URI.hasQuery = function(data, name, value, withinArray) {
|
790 |
+
switch (getType(name)) {
|
791 |
+
case 'String':
|
792 |
+
// Nothing to do here
|
793 |
+
break;
|
794 |
+
|
795 |
+
case 'RegExp':
|
796 |
+
for (var key in data) {
|
797 |
+
if (hasOwn.call(data, key)) {
|
798 |
+
if (name.test(key) && (value === undefined || URI.hasQuery(data, key, value))) {
|
799 |
+
return true;
|
800 |
+
}
|
801 |
+
}
|
802 |
+
}
|
803 |
+
|
804 |
+
return false;
|
805 |
+
|
806 |
+
case 'Object':
|
807 |
+
for (var _key in name) {
|
808 |
+
if (hasOwn.call(name, _key)) {
|
809 |
+
if (!URI.hasQuery(data, _key, name[_key])) {
|
810 |
+
return false;
|
811 |
+
}
|
812 |
+
}
|
813 |
+
}
|
814 |
+
|
815 |
+
return true;
|
816 |
+
|
817 |
+
default:
|
818 |
+
throw new TypeError('URI.hasQuery() accepts a string, regular expression or object as the name parameter');
|
819 |
+
}
|
820 |
+
|
821 |
+
switch (getType(value)) {
|
822 |
+
case 'Undefined':
|
823 |
+
// true if exists (but may be empty)
|
824 |
+
return name in data; // data[name] !== undefined;
|
825 |
+
|
826 |
+
case 'Boolean':
|
827 |
+
// true if exists and non-empty
|
828 |
+
var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]);
|
829 |
+
return value === _booly;
|
830 |
+
|
831 |
+
case 'Function':
|
832 |
+
// allow complex comparison
|
833 |
+
return !!value(data[name], name, data);
|
834 |
+
|
835 |
+
case 'Array':
|
836 |
+
if (!isArray(data[name])) {
|
837 |
+
return false;
|
838 |
+
}
|
839 |
+
|
840 |
+
var op = withinArray ? arrayContains : arraysEqual;
|
841 |
+
return op(data[name], value);
|
842 |
+
|
843 |
+
case 'RegExp':
|
844 |
+
if (!isArray(data[name])) {
|
845 |
+
return Boolean(data[name] && data[name].match(value));
|
846 |
+
}
|
847 |
+
|
848 |
+
if (!withinArray) {
|
849 |
+
return false;
|
850 |
+
}
|
851 |
+
|
852 |
+
return arrayContains(data[name], value);
|
853 |
+
|
854 |
+
case 'Number':
|
855 |
+
value = String(value);
|
856 |
+
/* falls through */
|
857 |
+
case 'String':
|
858 |
+
if (!isArray(data[name])) {
|
859 |
+
return data[name] === value;
|
860 |
+
}
|
861 |
+
|
862 |
+
if (!withinArray) {
|
863 |
+
return false;
|
864 |
+
}
|
865 |
+
|
866 |
+
return arrayContains(data[name], value);
|
867 |
+
|
868 |
+
default:
|
869 |
+
throw new TypeError('URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter');
|
870 |
+
}
|
871 |
+
};
|
872 |
+
|
873 |
+
|
874 |
+
URI.joinPaths = function() {
|
875 |
+
var input = [];
|
876 |
+
var segments = [];
|
877 |
+
var nonEmptySegments = 0;
|
878 |
+
|
879 |
+
for (var i = 0; i < arguments.length; i++) {
|
880 |
+
var url = new URI(arguments[i]);
|
881 |
+
input.push(url);
|
882 |
+
var _segments = url.segment();
|
883 |
+
for (var s = 0; s < _segments.length; s++) {
|
884 |
+
if (typeof _segments[s] === 'string') {
|
885 |
+
segments.push(_segments[s]);
|
886 |
+
}
|
887 |
+
|
888 |
+
if (_segments[s]) {
|
889 |
+
nonEmptySegments++;
|
890 |
+
}
|
891 |
+
}
|
892 |
+
}
|
893 |
+
|
894 |
+
if (!segments.length || !nonEmptySegments) {
|
895 |
+
return new URI('');
|
896 |
+
}
|
897 |
+
|
898 |
+
var uri = new URI('').segment(segments);
|
899 |
+
|
900 |
+
if (input[0].path() === '' || input[0].path().slice(0, 1) === '/') {
|
901 |
+
uri.path('/' + uri.path());
|
902 |
+
}
|
903 |
+
|
904 |
+
return uri.normalize();
|
905 |
+
};
|
906 |
+
|
907 |
+
URI.commonPath = function(one, two) {
|
908 |
+
var length = Math.min(one.length, two.length);
|
909 |
+
var pos;
|
910 |
+
|
911 |
+
// find first non-matching character
|
912 |
+
for (pos = 0; pos < length; pos++) {
|
913 |
+
if (one.charAt(pos) !== two.charAt(pos)) {
|
914 |
+
pos--;
|
915 |
+
break;
|
916 |
+
}
|
917 |
+
}
|
918 |
+
|
919 |
+
if (pos < 1) {
|
920 |
+
return one.charAt(0) === two.charAt(0) && one.charAt(0) === '/' ? '/' : '';
|
921 |
+
}
|
922 |
+
|
923 |
+
// revert to last /
|
924 |
+
if (one.charAt(pos) !== '/' || two.charAt(pos) !== '/') {
|
925 |
+
pos = one.substring(0, pos).lastIndexOf('/');
|
926 |
+
}
|
927 |
+
|
928 |
+
return one.substring(0, pos + 1);
|
929 |
+
};
|
930 |
+
|
931 |
+
URI.withinString = function(string, callback, options) {
|
932 |
+
options || (options = {});
|
933 |
+
var _start = options.start || URI.findUri.start;
|
934 |
+
var _end = options.end || URI.findUri.end;
|
935 |
+
var _trim = options.trim || URI.findUri.trim;
|
936 |
+
var _attributeOpen = /[a-z0-9-]=["']?$/i;
|
937 |
+
|
938 |
+
_start.lastIndex = 0;
|
939 |
+
while (true) {
|
940 |
+
var match = _start.exec(string);
|
941 |
+
if (!match) {
|
942 |
+
break;
|
943 |
+
}
|
944 |
+
|
945 |
+
var start = match.index;
|
946 |
+
if (options.ignoreHtml) {
|
947 |
+
// attribut(e=["']?$)
|
948 |
+
var attributeOpen = string.slice(Math.max(start - 3, 0), start);
|
949 |
+
if (attributeOpen && _attributeOpen.test(attributeOpen)) {
|
950 |
+
continue;
|
951 |
+
}
|
952 |
+
}
|
953 |
+
|
954 |
+
var end = start + string.slice(start).search(_end);
|
955 |
+
var slice = string.slice(start, end).replace(_trim, '');
|
956 |
+
if (options.ignore && options.ignore.test(slice)) {
|
957 |
+
continue;
|
958 |
+
}
|
959 |
+
|
960 |
+
end = start + slice.length;
|
961 |
+
var result = callback(slice, start, end, string);
|
962 |
+
string = string.slice(0, start) + result + string.slice(end);
|
963 |
+
_start.lastIndex = start + result.length;
|
964 |
+
}
|
965 |
+
|
966 |
+
_start.lastIndex = 0;
|
967 |
+
return string;
|
968 |
+
};
|
969 |
+
|
970 |
+
URI.ensureValidHostname = function(v) {
|
971 |
+
// Theoretically URIs allow percent-encoding in Hostnames (according to RFC 3986)
|
972 |
+
// they are not part of DNS and therefore ignored by URI.js
|
973 |
+
|
974 |
+
if (v.match(URI.invalid_hostname_characters)) {
|
975 |
+
// test punycode
|
976 |
+
if (!punycode) {
|
977 |
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-] and Punycode.js is not available');
|
978 |
+
}
|
979 |
+
|
980 |
+
if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) {
|
981 |
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
982 |
+
}
|
983 |
+
}
|
984 |
+
};
|
985 |
+
|
986 |
+
// noConflict
|
987 |
+
URI.noConflict = function(removeAll) {
|
988 |
+
if (removeAll) {
|
989 |
+
var unconflicted = {
|
990 |
+
URI: this.noConflict()
|
991 |
+
};
|
992 |
+
|
993 |
+
if (root.URITemplate && typeof root.URITemplate.noConflict === 'function') {
|
994 |
+
unconflicted.URITemplate = root.URITemplate.noConflict();
|
995 |
+
}
|
996 |
+
|
997 |
+
if (root.IPv6 && typeof root.IPv6.noConflict === 'function') {
|
998 |
+
unconflicted.IPv6 = root.IPv6.noConflict();
|
999 |
+
}
|
1000 |
+
|
1001 |
+
if (root.SecondLevelDomains && typeof root.SecondLevelDomains.noConflict === 'function') {
|
1002 |
+
unconflicted.SecondLevelDomains = root.SecondLevelDomains.noConflict();
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
return unconflicted;
|
1006 |
+
} else if (root.URI === this) {
|
1007 |
+
root.URI = _URI;
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
return this;
|
1011 |
+
};
|
1012 |
+
|
1013 |
+
p.build = function(deferBuild) {
|
1014 |
+
if (deferBuild === true) {
|
1015 |
+
this._deferred_build = true;
|
1016 |
+
} else if (deferBuild === undefined || this._deferred_build) {
|
1017 |
+
this._string = URI.build(this._parts);
|
1018 |
+
this._deferred_build = false;
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
return this;
|
1022 |
+
};
|
1023 |
+
|
1024 |
+
p.clone = function() {
|
1025 |
+
return new URI(this);
|
1026 |
+
};
|
1027 |
+
|
1028 |
+
p.valueOf = p.toString = function() {
|
1029 |
+
return this.build(false)._string;
|
1030 |
+
};
|
1031 |
+
|
1032 |
+
|
1033 |
+
function generateSimpleAccessor(_part){
|
1034 |
+
return function(v, build) {
|
1035 |
+
if (v === undefined) {
|
1036 |
+
return this._parts[_part] || '';
|
1037 |
+
} else {
|
1038 |
+
this._parts[_part] = v || null;
|
1039 |
+
this.build(!build);
|
1040 |
+
return this;
|
1041 |
+
}
|
1042 |
+
};
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
function generatePrefixAccessor(_part, _key){
|
1046 |
+
return function(v, build) {
|
1047 |
+
if (v === undefined) {
|
1048 |
+
return this._parts[_part] || '';
|
1049 |
+
} else {
|
1050 |
+
if (v !== null) {
|
1051 |
+
v = v + '';
|
1052 |
+
if (v.charAt(0) === _key) {
|
1053 |
+
v = v.substring(1);
|
1054 |
+
}
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
this._parts[_part] = v;
|
1058 |
+
this.build(!build);
|
1059 |
+
return this;
|
1060 |
+
}
|
1061 |
+
};
|
1062 |
+
}
|
1063 |
+
|
1064 |
+
p.protocol = generateSimpleAccessor('protocol');
|
1065 |
+
p.username = generateSimpleAccessor('username');
|
1066 |
+
p.password = generateSimpleAccessor('password');
|
1067 |
+
p.hostname = generateSimpleAccessor('hostname');
|
1068 |
+
p.port = generateSimpleAccessor('port');
|
1069 |
+
p.query = generatePrefixAccessor('query', '?');
|
1070 |
+
p.fragment = generatePrefixAccessor('fragment', '#');
|
1071 |
+
|
1072 |
+
p.search = function(v, build) {
|
1073 |
+
var t = this.query(v, build);
|
1074 |
+
return typeof t === 'string' && t.length ? ('?' + t) : t;
|
1075 |
+
};
|
1076 |
+
p.hash = function(v, build) {
|
1077 |
+
var t = this.fragment(v, build);
|
1078 |
+
return typeof t === 'string' && t.length ? ('#' + t) : t;
|
1079 |
+
};
|
1080 |
+
|
1081 |
+
p.pathname = function(v, build) {
|
1082 |
+
if (v === undefined || v === true) {
|
1083 |
+
var res = this._parts.path || (this._parts.hostname ? '/' : '');
|
1084 |
+
return v ? (this._parts.urn ? URI.decodeUrnPath : URI.decodePath)(res) : res;
|
1085 |
+
} else {
|
1086 |
+
if (this._parts.urn) {
|
1087 |
+
this._parts.path = v ? URI.recodeUrnPath(v) : '';
|
1088 |
+
} else {
|
1089 |
+
this._parts.path = v ? URI.recodePath(v) : '/';
|
1090 |
+
}
|
1091 |
+
this.build(!build);
|
1092 |
+
return this;
|
1093 |
+
}
|
1094 |
+
};
|
1095 |
+
p.path = p.pathname;
|
1096 |
+
p.href = function(href, build) {
|
1097 |
+
var key;
|
1098 |
+
|
1099 |
+
if (href === undefined) {
|
1100 |
+
return this.toString();
|
1101 |
+
}
|
1102 |
+
|
1103 |
+
this._string = '';
|
1104 |
+
this._parts = URI._parts();
|
1105 |
+
|
1106 |
+
var _URI = href instanceof URI;
|
1107 |
+
var _object = typeof href === 'object' && (href.hostname || href.path || href.pathname);
|
1108 |
+
if (href.nodeName) {
|
1109 |
+
var attribute = URI.getDomAttribute(href);
|
1110 |
+
href = href[attribute] || '';
|
1111 |
+
_object = false;
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
// window.location is reported to be an object, but it's not the sort
|
1115 |
+
// of object we're looking for:
|
1116 |
+
// * location.protocol ends with a colon
|
1117 |
+
// * location.query != object.search
|
1118 |
+
// * location.hash != object.fragment
|
1119 |
+
// simply serializing the unknown object should do the trick
|
1120 |
+
// (for location, not for everything...)
|
1121 |
+
if (!_URI && _object && href.pathname !== undefined) {
|
1122 |
+
href = href.toString();
|
1123 |
+
}
|
1124 |
+
|
1125 |
+
if (typeof href === 'string' || href instanceof String) {
|
1126 |
+
this._parts = URI.parse(String(href), this._parts);
|
1127 |
+
} else if (_URI || _object) {
|
1128 |
+
var src = _URI ? href._parts : href;
|
1129 |
+
for (key in src) {
|
1130 |
+
if (hasOwn.call(this._parts, key)) {
|
1131 |
+
this._parts[key] = src[key];
|
1132 |
+
}
|
1133 |
+
}
|
1134 |
+
} else {
|
1135 |
+
throw new TypeError('invalid input');
|
1136 |
+
}
|
1137 |
+
|
1138 |
+
this.build(!build);
|
1139 |
+
return this;
|
1140 |
+
};
|
1141 |
+
|
1142 |
+
// identification accessors
|
1143 |
+
p.is = function(what) {
|
1144 |
+
var ip = false;
|
1145 |
+
var ip4 = false;
|
1146 |
+
var ip6 = false;
|
1147 |
+
var name = false;
|
1148 |
+
var sld = false;
|
1149 |
+
var idn = false;
|
1150 |
+
var punycode = false;
|
1151 |
+
var relative = !this._parts.urn;
|
1152 |
+
|
1153 |
+
if (this._parts.hostname) {
|
1154 |
+
relative = false;
|
1155 |
+
ip4 = URI.ip4_expression.test(this._parts.hostname);
|
1156 |
+
ip6 = URI.ip6_expression.test(this._parts.hostname);
|
1157 |
+
ip = ip4 || ip6;
|
1158 |
+
name = !ip;
|
1159 |
+
sld = name && SLD && SLD.has(this._parts.hostname);
|
1160 |
+
idn = name && URI.idn_expression.test(this._parts.hostname);
|
1161 |
+
punycode = name && URI.punycode_expression.test(this._parts.hostname);
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
switch (what.toLowerCase()) {
|
1165 |
+
case 'relative':
|
1166 |
+
return relative;
|
1167 |
+
|
1168 |
+
case 'absolute':
|
1169 |
+
return !relative;
|
1170 |
+
|
1171 |
+
// hostname identification
|
1172 |
+
case 'domain':
|
1173 |
+
case 'name':
|
1174 |
+
return name;
|
1175 |
+
|
1176 |
+
case 'sld':
|
1177 |
+
return sld;
|
1178 |
+
|
1179 |
+
case 'ip':
|
1180 |
+
return ip;
|
1181 |
+
|
1182 |
+
case 'ip4':
|
1183 |
+
case 'ipv4':
|
1184 |
+
case 'inet4':
|
1185 |
+
return ip4;
|
1186 |
+
|
1187 |
+
case 'ip6':
|
1188 |
+
case 'ipv6':
|
1189 |
+
case 'inet6':
|
1190 |
+
return ip6;
|
1191 |
+
|
1192 |
+
case 'idn':
|
1193 |
+
return idn;
|
1194 |
+
|
1195 |
+
case 'url':
|
1196 |
+
return !this._parts.urn;
|
1197 |
+
|
1198 |
+
case 'urn':
|
1199 |
+
return !!this._parts.urn;
|
1200 |
+
|
1201 |
+
case 'punycode':
|
1202 |
+
return punycode;
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
return null;
|
1206 |
+
};
|
1207 |
+
|
1208 |
+
// component specific input validation
|
1209 |
+
var _protocol = p.protocol;
|
1210 |
+
var _port = p.port;
|
1211 |
+
var _hostname = p.hostname;
|
1212 |
+
|
1213 |
+
p.protocol = function(v, build) {
|
1214 |
+
if (v !== undefined) {
|
1215 |
+
if (v) {
|
1216 |
+
// accept trailing ://
|
1217 |
+
v = v.replace(/:(\/\/)?$/, '');
|
1218 |
+
|
1219 |
+
if (!v.match(URI.protocol_expression)) {
|
1220 |
+
throw new TypeError('Protocol "' + v + '" contains characters other than [A-Z0-9.+-] or doesn\'t start with [A-Z]');
|
1221 |
+
}
|
1222 |
+
}
|
1223 |
+
}
|
1224 |
+
return _protocol.call(this, v, build);
|
1225 |
+
};
|
1226 |
+
p.scheme = p.protocol;
|
1227 |
+
p.port = function(v, build) {
|
1228 |
+
if (this._parts.urn) {
|
1229 |
+
return v === undefined ? '' : this;
|
1230 |
+
}
|
1231 |
+
|
1232 |
+
if (v !== undefined) {
|
1233 |
+
if (v === 0) {
|
1234 |
+
v = null;
|
1235 |
+
}
|
1236 |
+
|
1237 |
+
if (v) {
|
1238 |
+
v += '';
|
1239 |
+
if (v.charAt(0) === ':') {
|
1240 |
+
v = v.substring(1);
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
if (v.match(/[^0-9]/)) {
|
1244 |
+
throw new TypeError('Port "' + v + '" contains characters other than [0-9]');
|
1245 |
+
}
|
1246 |
+
}
|
1247 |
+
}
|
1248 |
+
return _port.call(this, v, build);
|
1249 |
+
};
|
1250 |
+
p.hostname = function(v, build) {
|
1251 |
+
if (this._parts.urn) {
|
1252 |
+
return v === undefined ? '' : this;
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
if (v !== undefined) {
|
1256 |
+
var x = {};
|
1257 |
+
var res = URI.parseHost(v, x);
|
1258 |
+
if (res !== '/') {
|
1259 |
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
1260 |
+
}
|
1261 |
+
|
1262 |
+
v = x.hostname;
|
1263 |
+
}
|
1264 |
+
return _hostname.call(this, v, build);
|
1265 |
+
};
|
1266 |
+
|
1267 |
+
// compound accessors
|
1268 |
+
p.origin = function(v, build) {
|
1269 |
+
if (this._parts.urn) {
|
1270 |
+
return v === undefined ? '' : this;
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
if (v === undefined) {
|
1274 |
+
var protocol = this.protocol();
|
1275 |
+
var authority = this.authority();
|
1276 |
+
if (!authority) {
|
1277 |
+
return '';
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
return (protocol ? protocol + '://' : '') + this.authority();
|
1281 |
+
} else {
|
1282 |
+
var origin = URI(v);
|
1283 |
+
this
|
1284 |
+
.protocol(origin.protocol())
|
1285 |
+
.authority(origin.authority())
|
1286 |
+
.build(!build);
|
1287 |
+
return this;
|
1288 |
+
}
|
1289 |
+
};
|
1290 |
+
p.host = function(v, build) {
|
1291 |
+
if (this._parts.urn) {
|
1292 |
+
return v === undefined ? '' : this;
|
1293 |
+
}
|
1294 |
+
|
1295 |
+
if (v === undefined) {
|
1296 |
+
return this._parts.hostname ? URI.buildHost(this._parts) : '';
|
1297 |
+
} else {
|
1298 |
+
var res = URI.parseHost(v, this._parts);
|
1299 |
+
if (res !== '/') {
|
1300 |
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
1301 |
+
}
|
1302 |
+
|
1303 |
+
this.build(!build);
|
1304 |
+
return this;
|
1305 |
+
}
|
1306 |
+
};
|
1307 |
+
p.authority = function(v, build) {
|
1308 |
+
if (this._parts.urn) {
|
1309 |
+
return v === undefined ? '' : this;
|
1310 |
+
}
|
1311 |
+
|
1312 |
+
if (v === undefined) {
|
1313 |
+
return this._parts.hostname ? URI.buildAuthority(this._parts) : '';
|
1314 |
+
} else {
|
1315 |
+
var res = URI.parseAuthority(v, this._parts);
|
1316 |
+
if (res !== '/') {
|
1317 |
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
this.build(!build);
|
1321 |
+
return this;
|
1322 |
+
}
|
1323 |
+
};
|
1324 |
+
p.userinfo = function(v, build) {
|
1325 |
+
if (this._parts.urn) {
|
1326 |
+
return v === undefined ? '' : this;
|
1327 |
+
}
|
1328 |
+
|
1329 |
+
if (v === undefined) {
|
1330 |
+
var t = URI.buildUserinfo(this._parts);
|
1331 |
+
return t ? t.substring(0, t.length -1) : t;
|
1332 |
+
} else {
|
1333 |
+
if (v[v.length-1] !== '@') {
|
1334 |
+
v += '@';
|
1335 |
+
}
|
1336 |
+
|
1337 |
+
URI.parseUserinfo(v, this._parts);
|
1338 |
+
this.build(!build);
|
1339 |
+
return this;
|
1340 |
+
}
|
1341 |
+
};
|
1342 |
+
p.resource = function(v, build) {
|
1343 |
+
var parts;
|
1344 |
+
|
1345 |
+
if (v === undefined) {
|
1346 |
+
return this.path() + this.search() + this.hash();
|
1347 |
+
}
|
1348 |
+
|
1349 |
+
parts = URI.parse(v);
|
1350 |
+
this._parts.path = parts.path;
|
1351 |
+
this._parts.query = parts.query;
|
1352 |
+
this._parts.fragment = parts.fragment;
|
1353 |
+
this.build(!build);
|
1354 |
+
return this;
|
1355 |
+
};
|
1356 |
+
|
1357 |
+
// fraction accessors
|
1358 |
+
p.subdomain = function(v, build) {
|
1359 |
+
if (this._parts.urn) {
|
1360 |
+
return v === undefined ? '' : this;
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
// convenience, return "www" from "www.example.org"
|
1364 |
+
if (v === undefined) {
|
1365 |
+
if (!this._parts.hostname || this.is('IP')) {
|
1366 |
+
return '';
|
1367 |
+
}
|
1368 |
+
|
1369 |
+
// grab domain and add another segment
|
1370 |
+
var end = this._parts.hostname.length - this.domain().length - 1;
|
1371 |
+
return this._parts.hostname.substring(0, end) || '';
|
1372 |
+
} else {
|
1373 |
+
var e = this._parts.hostname.length - this.domain().length;
|
1374 |
+
var sub = this._parts.hostname.substring(0, e);
|
1375 |
+
var replace = new RegExp('^' + escapeRegEx(sub));
|
1376 |
+
|
1377 |
+
if (v && v.charAt(v.length - 1) !== '.') {
|
1378 |
+
v += '.';
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
if (v) {
|
1382 |
+
URI.ensureValidHostname(v);
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
1386 |
+
this.build(!build);
|
1387 |
+
return this;
|
1388 |
+
}
|
1389 |
+
};
|
1390 |
+
p.domain = function(v, build) {
|
1391 |
+
if (this._parts.urn) {
|
1392 |
+
return v === undefined ? '' : this;
|
1393 |
+
}
|
1394 |
+
|
1395 |
+
if (typeof v === 'boolean') {
|
1396 |
+
build = v;
|
1397 |
+
v = undefined;
|
1398 |
+
}
|
1399 |
+
|
1400 |
+
// convenience, return "example.org" from "www.example.org"
|
1401 |
+
if (v === undefined) {
|
1402 |
+
if (!this._parts.hostname || this.is('IP')) {
|
1403 |
+
return '';
|
1404 |
+
}
|
1405 |
+
|
1406 |
+
// if hostname consists of 1 or 2 segments, it must be the domain
|
1407 |
+
var t = this._parts.hostname.match(/\./g);
|
1408 |
+
if (t && t.length < 2) {
|
1409 |
+
return this._parts.hostname;
|
1410 |
+
}
|
1411 |
+
|
1412 |
+
// grab tld and add another segment
|
1413 |
+
var end = this._parts.hostname.length - this.tld(build).length - 1;
|
1414 |
+
end = this._parts.hostname.lastIndexOf('.', end -1) + 1;
|
1415 |
+
return this._parts.hostname.substring(end) || '';
|
1416 |
+
} else {
|
1417 |
+
if (!v) {
|
1418 |
+
throw new TypeError('cannot set domain empty');
|
1419 |
+
}
|
1420 |
+
|
1421 |
+
URI.ensureValidHostname(v);
|
1422 |
+
|
1423 |
+
if (!this._parts.hostname || this.is('IP')) {
|
1424 |
+
this._parts.hostname = v;
|
1425 |
+
} else {
|
1426 |
+
var replace = new RegExp(escapeRegEx(this.domain()) + '$');
|
1427 |
+
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
1428 |
+
}
|
1429 |
+
|
1430 |
+
this.build(!build);
|
1431 |
+
return this;
|
1432 |
+
}
|
1433 |
+
};
|
1434 |
+
p.tld = function(v, build) {
|
1435 |
+
if (this._parts.urn) {
|
1436 |
+
return v === undefined ? '' : this;
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
if (typeof v === 'boolean') {
|
1440 |
+
build = v;
|
1441 |
+
v = undefined;
|
1442 |
+
}
|
1443 |
+
|
1444 |
+
// return "org" from "www.example.org"
|
1445 |
+
if (v === undefined) {
|
1446 |
+
if (!this._parts.hostname || this.is('IP')) {
|
1447 |
+
return '';
|
1448 |
+
}
|
1449 |
+
|
1450 |
+
var pos = this._parts.hostname.lastIndexOf('.');
|
1451 |
+
var tld = this._parts.hostname.substring(pos + 1);
|
1452 |
+
|
1453 |
+
if (build !== true && SLD && SLD.list[tld.toLowerCase()]) {
|
1454 |
+
return SLD.get(this._parts.hostname) || tld;
|
1455 |
+
}
|
1456 |
+
|
1457 |
+
return tld;
|
1458 |
+
} else {
|
1459 |
+
var replace;
|
1460 |
+
|
1461 |
+
if (!v) {
|
1462 |
+
throw new TypeError('cannot set TLD empty');
|
1463 |
+
} else if (v.match(/[^a-zA-Z0-9-]/)) {
|
1464 |
+
if (SLD && SLD.is(v)) {
|
1465 |
+
replace = new RegExp(escapeRegEx(this.tld()) + '$');
|
1466 |
+
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
1467 |
+
} else {
|
1468 |
+
throw new TypeError('TLD "' + v + '" contains characters other than [A-Z0-9]');
|
1469 |
+
}
|
1470 |
+
} else if (!this._parts.hostname || this.is('IP')) {
|
1471 |
+
throw new ReferenceError('cannot set TLD on non-domain host');
|
1472 |
+
} else {
|
1473 |
+
replace = new RegExp(escapeRegEx(this.tld()) + '$');
|
1474 |
+
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
1475 |
+
}
|
1476 |
+
|
1477 |
+
this.build(!build);
|
1478 |
+
return this;
|
1479 |
+
}
|
1480 |
+
};
|
1481 |
+
p.directory = function(v, build) {
|
1482 |
+
if (this._parts.urn) {
|
1483 |
+
return v === undefined ? '' : this;
|
1484 |
+
}
|
1485 |
+
|
1486 |
+
if (v === undefined || v === true) {
|
1487 |
+
if (!this._parts.path && !this._parts.hostname) {
|
1488 |
+
return '';
|
1489 |
+
}
|
1490 |
+
|
1491 |
+
if (this._parts.path === '/') {
|
1492 |
+
return '/';
|
1493 |
+
}
|
1494 |
+
|
1495 |
+
var end = this._parts.path.length - this.filename().length - 1;
|
1496 |
+
var res = this._parts.path.substring(0, end) || (this._parts.hostname ? '/' : '');
|
1497 |
+
|
1498 |
+
return v ? URI.decodePath(res) : res;
|
1499 |
+
|
1500 |
+
} else {
|
1501 |
+
var e = this._parts.path.length - this.filename().length;
|
1502 |
+
var directory = this._parts.path.substring(0, e);
|
1503 |
+
var replace = new RegExp('^' + escapeRegEx(directory));
|
1504 |
+
|
1505 |
+
// fully qualifier directories begin with a slash
|
1506 |
+
if (!this.is('relative')) {
|
1507 |
+
if (!v) {
|
1508 |
+
v = '/';
|
1509 |
+
}
|
1510 |
+
|
1511 |
+
if (v.charAt(0) !== '/') {
|
1512 |
+
v = '/' + v;
|
1513 |
+
}
|
1514 |
+
}
|
1515 |
+
|
1516 |
+
// directories always end with a slash
|
1517 |
+
if (v && v.charAt(v.length - 1) !== '/') {
|
1518 |
+
v += '/';
|
1519 |
+
}
|
1520 |
+
|
1521 |
+
v = URI.recodePath(v);
|
1522 |
+
this._parts.path = this._parts.path.replace(replace, v);
|
1523 |
+
this.build(!build);
|
1524 |
+
return this;
|
1525 |
+
}
|
1526 |
+
};
|
1527 |
+
p.filename = function(v, build) {
|
1528 |
+
if (this._parts.urn) {
|
1529 |
+
return v === undefined ? '' : this;
|
1530 |
+
}
|
1531 |
+
|
1532 |
+
if (v === undefined || v === true) {
|
1533 |
+
if (!this._parts.path || this._parts.path === '/') {
|
1534 |
+
return '';
|
1535 |
+
}
|
1536 |
+
|
1537 |
+
var pos = this._parts.path.lastIndexOf('/');
|
1538 |
+
var res = this._parts.path.substring(pos+1);
|
1539 |
+
|
1540 |
+
return v ? URI.decodePathSegment(res) : res;
|
1541 |
+
} else {
|
1542 |
+
var mutatedDirectory = false;
|
1543 |
+
|
1544 |
+
if (v.charAt(0) === '/') {
|
1545 |
+
v = v.substring(1);
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
if (v.match(/\.?\//)) {
|
1549 |
+
mutatedDirectory = true;
|
1550 |
+
}
|
1551 |
+
|
1552 |
+
var replace = new RegExp(escapeRegEx(this.filename()) + '$');
|
1553 |
+
v = URI.recodePath(v);
|
1554 |
+
this._parts.path = this._parts.path.replace(replace, v);
|
1555 |
+
|
1556 |
+
if (mutatedDirectory) {
|
1557 |
+
this.normalizePath(build);
|
1558 |
+
} else {
|
1559 |
+
this.build(!build);
|
1560 |
+
}
|
1561 |
+
|
1562 |
+
return this;
|
1563 |
+
}
|
1564 |
+
};
|
1565 |
+
p.suffix = function(v, build) {
|
1566 |
+
if (this._parts.urn) {
|
1567 |
+
return v === undefined ? '' : this;
|
1568 |
+
}
|
1569 |
+
|
1570 |
+
if (v === undefined || v === true) {
|
1571 |
+
if (!this._parts.path || this._parts.path === '/') {
|
1572 |
+
return '';
|
1573 |
+
}
|
1574 |
+
|
1575 |
+
var filename = this.filename();
|
1576 |
+
var pos = filename.lastIndexOf('.');
|
1577 |
+
var s, res;
|
1578 |
+
|
1579 |
+
if (pos === -1) {
|
1580 |
+
return '';
|
1581 |
+
}
|
1582 |
+
|
1583 |
+
// suffix may only contain alnum characters (yup, I made this up.)
|
1584 |
+
s = filename.substring(pos+1);
|
1585 |
+
res = (/^[a-z0-9%]+$/i).test(s) ? s : '';
|
1586 |
+
return v ? URI.decodePathSegment(res) : res;
|
1587 |
+
} else {
|
1588 |
+
if (v.charAt(0) === '.') {
|
1589 |
+
v = v.substring(1);
|
1590 |
+
}
|
1591 |
+
|
1592 |
+
var suffix = this.suffix();
|
1593 |
+
var replace;
|
1594 |
+
|
1595 |
+
if (!suffix) {
|
1596 |
+
if (!v) {
|
1597 |
+
return this;
|
1598 |
+
}
|
1599 |
+
|
1600 |
+
this._parts.path += '.' + URI.recodePath(v);
|
1601 |
+
} else if (!v) {
|
1602 |
+
replace = new RegExp(escapeRegEx('.' + suffix) + '$');
|
1603 |
+
} else {
|
1604 |
+
replace = new RegExp(escapeRegEx(suffix) + '$');
|
1605 |
+
}
|
1606 |
+
|
1607 |
+
if (replace) {
|
1608 |
+
v = URI.recodePath(v);
|
1609 |
+
this._parts.path = this._parts.path.replace(replace, v);
|
1610 |
+
}
|
1611 |
+
|
1612 |
+
this.build(!build);
|
1613 |
+
return this;
|
1614 |
+
}
|
1615 |
+
};
|
1616 |
+
p.segment = function(segment, v, build) {
|
1617 |
+
var separator = this._parts.urn ? ':' : '/';
|
1618 |
+
var path = this.path();
|
1619 |
+
var absolute = path.substring(0, 1) === '/';
|
1620 |
+
var segments = path.split(separator);
|
1621 |
+
|
1622 |
+
if (segment !== undefined && typeof segment !== 'number') {
|
1623 |
+
build = v;
|
1624 |
+
v = segment;
|
1625 |
+
segment = undefined;
|
1626 |
+
}
|
1627 |
+
|
1628 |
+
if (segment !== undefined && typeof segment !== 'number') {
|
1629 |
+
throw new Error('Bad segment "' + segment + '", must be 0-based integer');
|
1630 |
+
}
|
1631 |
+
|
1632 |
+
if (absolute) {
|
1633 |
+
segments.shift();
|
1634 |
+
}
|
1635 |
+
|
1636 |
+
if (segment < 0) {
|
1637 |
+
// allow negative indexes to address from the end
|
1638 |
+
segment = Math.max(segments.length + segment, 0);
|
1639 |
+
}
|
1640 |
+
|
1641 |
+
if (v === undefined) {
|
1642 |
+
/*jshint laxbreak: true */
|
1643 |
+
return segment === undefined
|
1644 |
+
? segments
|
1645 |
+
: segments[segment];
|
1646 |
+
/*jshint laxbreak: false */
|
1647 |
+
} else if (segment === null || segments[segment] === undefined) {
|
1648 |
+
if (isArray(v)) {
|
1649 |
+
segments = [];
|
1650 |
+
// collapse empty elements within array
|
1651 |
+
for (var i=0, l=v.length; i < l; i++) {
|
1652 |
+
if (!v[i].length && (!segments.length || !segments[segments.length -1].length)) {
|
1653 |
+
continue;
|
1654 |
+
}
|
1655 |
+
|
1656 |
+
if (segments.length && !segments[segments.length -1].length) {
|
1657 |
+
segments.pop();
|
1658 |
+
}
|
1659 |
+
|
1660 |
+
segments.push(trimSlashes(v[i]));
|
1661 |
+
}
|
1662 |
+
} else if (v || typeof v === 'string') {
|
1663 |
+
v = trimSlashes(v);
|
1664 |
+
if (segments[segments.length -1] === '') {
|
1665 |
+
// empty trailing elements have to be overwritten
|
1666 |
+
// to prevent results such as /foo//bar
|
1667 |
+
segments[segments.length -1] = v;
|
1668 |
+
} else {
|
1669 |
+
segments.push(v);
|
1670 |
+
}
|
1671 |
+
}
|
1672 |
+
} else {
|
1673 |
+
if (v) {
|
1674 |
+
segments[segment] = trimSlashes(v);
|
1675 |
+
} else {
|
1676 |
+
segments.splice(segment, 1);
|
1677 |
+
}
|
1678 |
+
}
|
1679 |
+
|
1680 |
+
if (absolute) {
|
1681 |
+
segments.unshift('');
|
1682 |
+
}
|
1683 |
+
|
1684 |
+
return this.path(segments.join(separator), build);
|
1685 |
+
};
|
1686 |
+
p.segmentCoded = function(segment, v, build) {
|
1687 |
+
var segments, i, l;
|
1688 |
+
|
1689 |
+
if (typeof segment !== 'number') {
|
1690 |
+
build = v;
|
1691 |
+
v = segment;
|
1692 |
+
segment = undefined;
|
1693 |
+
}
|
1694 |
+
|
1695 |
+
if (v === undefined) {
|
1696 |
+
segments = this.segment(segment, v, build);
|
1697 |
+
if (!isArray(segments)) {
|
1698 |
+
segments = segments !== undefined ? URI.decode(segments) : undefined;
|
1699 |
+
} else {
|
1700 |
+
for (i = 0, l = segments.length; i < l; i++) {
|
1701 |
+
segments[i] = URI.decode(segments[i]);
|
1702 |
+
}
|
1703 |
+
}
|
1704 |
+
|
1705 |
+
return segments;
|
1706 |
+
}
|
1707 |
+
|
1708 |
+
if (!isArray(v)) {
|
1709 |
+
v = (typeof v === 'string' || v instanceof String) ? URI.encode(v) : v;
|
1710 |
+
} else {
|
1711 |
+
for (i = 0, l = v.length; i < l; i++) {
|
1712 |
+
v[i] = URI.encode(v[i]);
|
1713 |
+
}
|
1714 |
+
}
|
1715 |
+
|
1716 |
+
return this.segment(segment, v, build);
|
1717 |
+
};
|
1718 |
+
|
1719 |
+
// mutating query string
|
1720 |
+
var q = p.query;
|
1721 |
+
p.query = function(v, build) {
|
1722 |
+
if (v === true) {
|
1723 |
+
return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
1724 |
+
} else if (typeof v === 'function') {
|
1725 |
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
1726 |
+
var result = v.call(this, data);
|
1727 |
+
this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
1728 |
+
this.build(!build);
|
1729 |
+
return this;
|
1730 |
+
} else if (v !== undefined && typeof v !== 'string') {
|
1731 |
+
this._parts.query = URI.buildQuery(v, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
1732 |
+
this.build(!build);
|
1733 |
+
return this;
|
1734 |
+
} else {
|
1735 |
+
return q.call(this, v, build);
|
1736 |
+
}
|
1737 |
+
};
|
1738 |
+
p.setQuery = function(name, value, build) {
|
1739 |
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
1740 |
+
|
1741 |
+
if (typeof name === 'string' || name instanceof String) {
|
1742 |
+
data[name] = value !== undefined ? value : null;
|
1743 |
+
} else if (typeof name === 'object') {
|
1744 |
+
for (var key in name) {
|
1745 |
+
if (hasOwn.call(name, key)) {
|
1746 |
+
data[key] = name[key];
|
1747 |
+
}
|
1748 |
+
}
|
1749 |
+
} else {
|
1750 |
+
throw new TypeError('URI.addQuery() accepts an object, string as the name parameter');
|
1751 |
+
}
|
1752 |
+
|
1753 |
+
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
1754 |
+
if (typeof name !== 'string') {
|
1755 |
+
build = value;
|
1756 |
+
}
|
1757 |
+
|
1758 |
+
this.build(!build);
|
1759 |
+
return this;
|
1760 |
+
};
|
1761 |
+
p.addQuery = function(name, value, build) {
|
1762 |
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
1763 |
+
URI.addQuery(data, name, value === undefined ? null : value);
|
1764 |
+
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
1765 |
+
if (typeof name !== 'string') {
|
1766 |
+
build = value;
|
1767 |
+
}
|
1768 |
+
|
1769 |
+
this.build(!build);
|
1770 |
+
return this;
|
1771 |
+
};
|
1772 |
+
p.removeQuery = function(name, value, build) {
|
1773 |
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
1774 |
+
URI.removeQuery(data, name, value);
|
1775 |
+
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
1776 |
+
if (typeof name !== 'string') {
|
1777 |
+
build = value;
|
1778 |
+
}
|
1779 |
+
|
1780 |
+
this.build(!build);
|
1781 |
+
return this;
|
1782 |
+
};
|
1783 |
+
p.hasQuery = function(name, value, withinArray) {
|
1784 |
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
1785 |
+
return URI.hasQuery(data, name, value, withinArray);
|
1786 |
+
};
|
1787 |
+
p.setSearch = p.setQuery;
|
1788 |
+
p.addSearch = p.addQuery;
|
1789 |
+
p.removeSearch = p.removeQuery;
|
1790 |
+
p.hasSearch = p.hasQuery;
|
1791 |
+
|
1792 |
+
// sanitizing URLs
|
1793 |
+
p.normalize = function() {
|
1794 |
+
if (this._parts.urn) {
|
1795 |
+
return this
|
1796 |
+
.normalizeProtocol(false)
|
1797 |
+
.normalizePath(false)
|
1798 |
+
.normalizeQuery(false)
|
1799 |
+
.normalizeFragment(false)
|
1800 |
+
.build();
|
1801 |
+
}
|
1802 |
+
|
1803 |
+
return this
|
1804 |
+
.normalizeProtocol(false)
|
1805 |
+
.normalizeHostname(false)
|
1806 |
+
.normalizePort(false)
|
1807 |
+
.normalizePath(false)
|
1808 |
+
.normalizeQuery(false)
|
1809 |
+
.normalizeFragment(false)
|
1810 |
+
.build();
|
1811 |
+
};
|
1812 |
+
p.normalizeProtocol = function(build) {
|
1813 |
+
if (typeof this._parts.protocol === 'string') {
|
1814 |
+
this._parts.protocol = this._parts.protocol.toLowerCase();
|
1815 |
+
this.build(!build);
|
1816 |
+
}
|
1817 |
+
|
1818 |
+
return this;
|
1819 |
+
};
|
1820 |
+
p.normalizeHostname = function(build) {
|
1821 |
+
if (this._parts.hostname) {
|
1822 |
+
if (this.is('IDN') && punycode) {
|
1823 |
+
this._parts.hostname = punycode.toASCII(this._parts.hostname);
|
1824 |
+
} else if (this.is('IPv6') && IPv6) {
|
1825 |
+
this._parts.hostname = IPv6.best(this._parts.hostname);
|
1826 |
+
}
|
1827 |
+
|
1828 |
+
this._parts.hostname = this._parts.hostname.toLowerCase();
|
1829 |
+
this.build(!build);
|
1830 |
+
}
|
1831 |
+
|
1832 |
+
return this;
|
1833 |
+
};
|
1834 |
+
p.normalizePort = function(build) {
|
1835 |
+
// remove port of it's the protocol's default
|
1836 |
+
if (typeof this._parts.protocol === 'string' && this._parts.port === URI.defaultPorts[this._parts.protocol]) {
|
1837 |
+
this._parts.port = null;
|
1838 |
+
this.build(!build);
|
1839 |
+
}
|
1840 |
+
|
1841 |
+
return this;
|
1842 |
+
};
|
1843 |
+
p.normalizePath = function(build) {
|
1844 |
+
var _path = this._parts.path;
|
1845 |
+
if (!_path) {
|
1846 |
+
return this;
|
1847 |
+
}
|
1848 |
+
|
1849 |
+
if (this._parts.urn) {
|
1850 |
+
this._parts.path = URI.recodeUrnPath(this._parts.path);
|
1851 |
+
this.build(!build);
|
1852 |
+
return this;
|
1853 |
+
}
|
1854 |
+
|
1855 |
+
if (this._parts.path === '/') {
|
1856 |
+
return this;
|
1857 |
+
}
|
1858 |
+
|
1859 |
+
_path = URI.recodePath(_path);
|
1860 |
+
|
1861 |
+
var _was_relative;
|
1862 |
+
var _leadingParents = '';
|
1863 |
+
var _parent, _pos;
|
1864 |
+
|
1865 |
+
// handle relative paths
|
1866 |
+
if (_path.charAt(0) !== '/') {
|
1867 |
+
_was_relative = true;
|
1868 |
+
_path = '/' + _path;
|
1869 |
+
}
|
1870 |
+
|
1871 |
+
// handle relative files (as opposed to directories)
|
1872 |
+
if (_path.slice(-3) === '/..' || _path.slice(-2) === '/.') {
|
1873 |
+
_path += '/';
|
1874 |
+
}
|
1875 |
+
|
1876 |
+
// resolve simples
|
1877 |
+
_path = _path
|
1878 |
+
.replace(/(\/(\.\/)+)|(\/\.$)/g, '/')
|
1879 |
+
.replace(/\/{2,}/g, '/');
|
1880 |
+
|
1881 |
+
// remember leading parents
|
1882 |
+
if (_was_relative) {
|
1883 |
+
_leadingParents = _path.substring(1).match(/^(\.\.\/)+/) || '';
|
1884 |
+
if (_leadingParents) {
|
1885 |
+
_leadingParents = _leadingParents[0];
|
1886 |
+
}
|
1887 |
+
}
|
1888 |
+
|
1889 |
+
// resolve parents
|
1890 |
+
while (true) {
|
1891 |
+
_parent = _path.search(/\/\.\.(\/|$)/);
|
1892 |
+
if (_parent === -1) {
|
1893 |
+
// no more ../ to resolve
|
1894 |
+
break;
|
1895 |
+
} else if (_parent === 0) {
|
1896 |
+
// top level cannot be relative, skip it
|
1897 |
+
_path = _path.substring(3);
|
1898 |
+
continue;
|
1899 |
+
}
|
1900 |
+
|
1901 |
+
_pos = _path.substring(0, _parent).lastIndexOf('/');
|
1902 |
+
if (_pos === -1) {
|
1903 |
+
_pos = _parent;
|
1904 |
+
}
|
1905 |
+
_path = _path.substring(0, _pos) + _path.substring(_parent + 3);
|
1906 |
+
}
|
1907 |
+
|
1908 |
+
// revert to relative
|
1909 |
+
if (_was_relative && this.is('relative')) {
|
1910 |
+
_path = _leadingParents + _path.substring(1);
|
1911 |
+
}
|
1912 |
+
|
1913 |
+
this._parts.path = _path;
|
1914 |
+
this.build(!build);
|
1915 |
+
return this;
|
1916 |
+
};
|
1917 |
+
p.normalizePathname = p.normalizePath;
|
1918 |
+
p.normalizeQuery = function(build) {
|
1919 |
+
if (typeof this._parts.query === 'string') {
|
1920 |
+
if (!this._parts.query.length) {
|
1921 |
+
this._parts.query = null;
|
1922 |
+
} else {
|
1923 |
+
this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace));
|
1924 |
+
}
|
1925 |
+
|
1926 |
+
this.build(!build);
|
1927 |
+
}
|
1928 |
+
|
1929 |
+
return this;
|
1930 |
+
};
|
1931 |
+
p.normalizeFragment = function(build) {
|
1932 |
+
if (!this._parts.fragment) {
|
1933 |
+
this._parts.fragment = null;
|
1934 |
+
this.build(!build);
|
1935 |
+
}
|
1936 |
+
|
1937 |
+
return this;
|
1938 |
+
};
|
1939 |
+
p.normalizeSearch = p.normalizeQuery;
|
1940 |
+
p.normalizeHash = p.normalizeFragment;
|
1941 |
+
|
1942 |
+
p.iso8859 = function() {
|
1943 |
+
// expect unicode input, iso8859 output
|
1944 |
+
var e = URI.encode;
|
1945 |
+
var d = URI.decode;
|
1946 |
+
|
1947 |
+
URI.encode = escape;
|
1948 |
+
URI.decode = decodeURIComponent;
|
1949 |
+
try {
|
1950 |
+
this.normalize();
|
1951 |
+
} finally {
|
1952 |
+
URI.encode = e;
|
1953 |
+
URI.decode = d;
|
1954 |
+
}
|
1955 |
+
return this;
|
1956 |
+
};
|
1957 |
+
|
1958 |
+
p.unicode = function() {
|
1959 |
+
// expect iso8859 input, unicode output
|
1960 |
+
var e = URI.encode;
|
1961 |
+
var d = URI.decode;
|
1962 |
+
|
1963 |
+
URI.encode = strictEncodeURIComponent;
|
1964 |
+
URI.decode = unescape;
|
1965 |
+
try {
|
1966 |
+
this.normalize();
|
1967 |
+
} finally {
|
1968 |
+
URI.encode = e;
|
1969 |
+
URI.decode = d;
|
1970 |
+
}
|
1971 |
+
return this;
|
1972 |
+
};
|
1973 |
+
|
1974 |
+
p.readable = function() {
|
1975 |
+
var uri = this.clone();
|
1976 |
+
// removing username, password, because they shouldn't be displayed according to RFC 3986
|
1977 |
+
uri.username('').password('').normalize();
|
1978 |
+
var t = '';
|
1979 |
+
if (uri._parts.protocol) {
|
1980 |
+
t += uri._parts.protocol + '://';
|
1981 |
+
}
|
1982 |
+
|
1983 |
+
if (uri._parts.hostname) {
|
1984 |
+
if (uri.is('punycode') && punycode) {
|
1985 |
+
t += punycode.toUnicode(uri._parts.hostname);
|
1986 |
+
if (uri._parts.port) {
|
1987 |
+
t += ':' + uri._parts.port;
|
1988 |
+
}
|
1989 |
+
} else {
|
1990 |
+
t += uri.host();
|
1991 |
+
}
|
1992 |
+
}
|
1993 |
+
|
1994 |
+
if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== '/') {
|
1995 |
+
t += '/';
|
1996 |
+
}
|
1997 |
+
|
1998 |
+
t += uri.path(true);
|
1999 |
+
if (uri._parts.query) {
|
2000 |
+
var q = '';
|
2001 |
+
for (var i = 0, qp = uri._parts.query.split('&'), l = qp.length; i < l; i++) {
|
2002 |
+
var kv = (qp[i] || '').split('=');
|
2003 |
+
q += '&' + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace)
|
2004 |
+
.replace(/&/g, '%26');
|
2005 |
+
|
2006 |
+
if (kv[1] !== undefined) {
|
2007 |
+
q += '=' + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace)
|
2008 |
+
.replace(/&/g, '%26');
|
2009 |
+
}
|
2010 |
+
}
|
2011 |
+
t += '?' + q.substring(1);
|
2012 |
+
}
|
2013 |
+
|
2014 |
+
t += URI.decodeQuery(uri.hash(), true);
|
2015 |
+
return t;
|
2016 |
+
};
|
2017 |
+
|
2018 |
+
// resolving relative and absolute URLs
|
2019 |
+
p.absoluteTo = function(base) {
|
2020 |
+
var resolved = this.clone();
|
2021 |
+
var properties = ['protocol', 'username', 'password', 'hostname', 'port'];
|
2022 |
+
var basedir, i, p;
|
2023 |
+
|
2024 |
+
if (this._parts.urn) {
|
2025 |
+
throw new Error('URNs do not have any generally defined hierarchical components');
|
2026 |
+
}
|
2027 |
+
|
2028 |
+
if (!(base instanceof URI)) {
|
2029 |
+
base = new URI(base);
|
2030 |
+
}
|
2031 |
+
|
2032 |
+
if (!resolved._parts.protocol) {
|
2033 |
+
resolved._parts.protocol = base._parts.protocol;
|
2034 |
+
}
|
2035 |
+
|
2036 |
+
if (this._parts.hostname) {
|
2037 |
+
return resolved;
|
2038 |
+
}
|
2039 |
+
|
2040 |
+
for (i = 0; (p = properties[i]); i++) {
|
2041 |
+
resolved._parts[p] = base._parts[p];
|
2042 |
+
}
|
2043 |
+
|
2044 |
+
if (!resolved._parts.path) {
|
2045 |
+
resolved._parts.path = base._parts.path;
|
2046 |
+
if (!resolved._parts.query) {
|
2047 |
+
resolved._parts.query = base._parts.query;
|
2048 |
+
}
|
2049 |
+
} else if (resolved._parts.path.substring(-2) === '..') {
|
2050 |
+
resolved._parts.path += '/';
|
2051 |
+
}
|
2052 |
+
|
2053 |
+
if (resolved.path().charAt(0) !== '/') {
|
2054 |
+
basedir = base.directory();
|
2055 |
+
basedir = basedir ? basedir : base.path().indexOf('/') === 0 ? '/' : '';
|
2056 |
+
resolved._parts.path = (basedir ? (basedir + '/') : '') + resolved._parts.path;
|
2057 |
+
resolved.normalizePath();
|
2058 |
+
}
|
2059 |
+
|
2060 |
+
resolved.build();
|
2061 |
+
return resolved;
|
2062 |
+
};
|
2063 |
+
p.relativeTo = function(base) {
|
2064 |
+
var relative = this.clone().normalize();
|
2065 |
+
var relativeParts, baseParts, common, relativePath, basePath;
|
2066 |
+
|
2067 |
+
if (relative._parts.urn) {
|
2068 |
+
throw new Error('URNs do not have any generally defined hierarchical components');
|
2069 |
+
}
|
2070 |
+
|
2071 |
+
base = new URI(base).normalize();
|
2072 |
+
relativeParts = relative._parts;
|
2073 |
+
baseParts = base._parts;
|
2074 |
+
relativePath = relative.path();
|
2075 |
+
basePath = base.path();
|
2076 |
+
|
2077 |
+
if (relativePath.charAt(0) !== '/') {
|
2078 |
+
throw new Error('URI is already relative');
|
2079 |
+
}
|
2080 |
+
|
2081 |
+
if (basePath.charAt(0) !== '/') {
|
2082 |
+
throw new Error('Cannot calculate a URI relative to another relative URI');
|
2083 |
+
}
|
2084 |
+
|
2085 |
+
if (relativeParts.protocol === baseParts.protocol) {
|
2086 |
+
relativeParts.protocol = null;
|
2087 |
+
}
|
2088 |
+
|
2089 |
+
if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) {
|
2090 |
+
return relative.build();
|
2091 |
+
}
|
2092 |
+
|
2093 |
+
if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) {
|
2094 |
+
return relative.build();
|
2095 |
+
}
|
2096 |
+
|
2097 |
+
if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) {
|
2098 |
+
relativeParts.hostname = null;
|
2099 |
+
relativeParts.port = null;
|
2100 |
+
} else {
|
2101 |
+
return relative.build();
|
2102 |
+
}
|
2103 |
+
|
2104 |
+
if (relativePath === basePath) {
|
2105 |
+
relativeParts.path = '';
|
2106 |
+
return relative.build();
|
2107 |
+
}
|
2108 |
+
|
2109 |
+
// determine common sub path
|
2110 |
+
common = URI.commonPath(relativePath, basePath);
|
2111 |
+
|
2112 |
+
// If the paths have nothing in common, return a relative URL with the absolute path.
|
2113 |
+
if (!common) {
|
2114 |
+
return relative.build();
|
2115 |
+
}
|
2116 |
+
|
2117 |
+
var parents = baseParts.path
|
2118 |
+
.substring(common.length)
|
2119 |
+
.replace(/[^\/]*$/, '')
|
2120 |
+
.replace(/.*?\//g, '../');
|
2121 |
+
|
2122 |
+
relativeParts.path = (parents + relativeParts.path.substring(common.length)) || './';
|
2123 |
+
|
2124 |
+
return relative.build();
|
2125 |
+
};
|
2126 |
+
|
2127 |
+
// comparing URIs
|
2128 |
+
p.equals = function(uri) {
|
2129 |
+
var one = this.clone();
|
2130 |
+
var two = new URI(uri);
|
2131 |
+
var one_map = {};
|
2132 |
+
var two_map = {};
|
2133 |
+
var checked = {};
|
2134 |
+
var one_query, two_query, key;
|
2135 |
+
|
2136 |
+
one.normalize();
|
2137 |
+
two.normalize();
|
2138 |
+
|
2139 |
+
// exact match
|
2140 |
+
if (one.toString() === two.toString()) {
|
2141 |
+
return true;
|
2142 |
+
}
|
2143 |
+
|
2144 |
+
// extract query string
|
2145 |
+
one_query = one.query();
|
2146 |
+
two_query = two.query();
|
2147 |
+
one.query('');
|
2148 |
+
two.query('');
|
2149 |
+
|
2150 |
+
// definitely not equal if not even non-query parts match
|
2151 |
+
if (one.toString() !== two.toString()) {
|
2152 |
+
return false;
|
2153 |
+
}
|
2154 |
+
|
2155 |
+
// query parameters have the same length, even if they're permuted
|
2156 |
+
if (one_query.length !== two_query.length) {
|
2157 |
+
return false;
|
2158 |
+
}
|
2159 |
+
|
2160 |
+
one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace);
|
2161 |
+
two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace);
|
2162 |
+
|
2163 |
+
for (key in one_map) {
|
2164 |
+
if (hasOwn.call(one_map, key)) {
|
2165 |
+
if (!isArray(one_map[key])) {
|
2166 |
+
if (one_map[key] !== two_map[key]) {
|
2167 |
+
return false;
|
2168 |
+
}
|
2169 |
+
} else if (!arraysEqual(one_map[key], two_map[key])) {
|
2170 |
+
return false;
|
2171 |
+
}
|
2172 |
+
|
2173 |
+
checked[key] = true;
|
2174 |
+
}
|
2175 |
+
}
|
2176 |
+
|
2177 |
+
for (key in two_map) {
|
2178 |
+
if (hasOwn.call(two_map, key)) {
|
2179 |
+
if (!checked[key]) {
|
2180 |
+
// two contains a parameter not present in one
|
2181 |
+
return false;
|
2182 |
+
}
|
2183 |
+
}
|
2184 |
+
}
|
2185 |
+
|
2186 |
+
return true;
|
2187 |
+
};
|
2188 |
+
|
2189 |
+
// state
|
2190 |
+
p.duplicateQueryParameters = function(v) {
|
2191 |
+
this._parts.duplicateQueryParameters = !!v;
|
2192 |
+
return this;
|
2193 |
+
};
|
2194 |
+
|
2195 |
+
p.escapeQuerySpace = function(v) {
|
2196 |
+
this._parts.escapeQuerySpace = !!v;
|
2197 |
+
return this;
|
2198 |
+
};
|
2199 |
+
|
2200 |
+
return URI;
|
2201 |
+
}));
|
js/URI.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(t,r){"use strict";t.URI=r(t.punycode,t.IPv6,t.SecondLevelDomains,t)}(this,function(t,r,e,s){"use strict";function n(t,r){var e=arguments.length>=1,s=arguments.length>=2;if(!(this instanceof n))return e?s?new n(t,r):new n(t):new n;if(void 0===t){if(e)throw new TypeError("undefined is not a valid argument for URI");t="undefined"!=typeof location?location.href+"":""}return this.href(t),void 0!==r?this.absoluteTo(r):this}function a(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function i(t){return void 0===t?"Undefined":String(Object.prototype.toString.call(t)).slice(8,-1)}function o(t){return"Array"===i(t)}function h(t,r){var e,s,n={};if("RegExp"===i(r))n=null;else if(o(r))for(e=0,s=r.length;s>e;e++)n[r[e]]=!0;else n[r]=!0;for(e=0,s=t.length;s>e;e++){var a=n&&void 0!==n[t[e]]||!n&&r.test(t[e]);a&&(t.splice(e,1),s--,e--)}return t}function u(t,r){var e,s;if(o(r)){for(e=0,s=r.length;s>e;e++)if(!u(t,r[e]))return!1;return!0}var n=i(r);for(e=0,s=t.length;s>e;e++)if("RegExp"===n){if("string"==typeof t[e]&&t[e].match(r))return!0}else if(t[e]===r)return!0;return!1}function p(t,r){if(!o(t)||!o(r))return!1;if(t.length!==r.length)return!1;t.sort(),r.sort();for(var e=0,s=t.length;s>e;e++)if(t[e]!==r[e])return!1;return!0}function c(t){var r=/^\/+|\/+$/g;return t.replace(r,"")}function l(t){return escape(t)}function d(t){return encodeURIComponent(t).replace(/[!'()*]/g,l).replace(/\*/g,"%2A")}function f(t){return function(r,e){return void 0===r?this._parts[t]||"":(this._parts[t]=r||null,this.build(!e),this)}}function m(t,r){return function(e,s){return void 0===e?this._parts[t]||"":(null!==e&&(e+="",e.charAt(0)===r&&(e=e.substring(1))),this._parts[t]=e,this.build(!s),this)}}var g=s&&s.URI;n.version="1.18.1";var _=n.prototype,y=Object.prototype.hasOwnProperty;n._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:n.duplicateQueryParameters,escapeQuerySpace:n.escapeQuerySpace}},n.duplicateQueryParameters=!1,n.escapeQuerySpace=!0,n.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,n.idn_expression=/[^a-z0-9\.-]/i,n.punycode_expression=/(xn--)/i,n.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,n.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,n.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,n.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/},n.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},n.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,n.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},n.getDomAttribute=function(t){if(t&&t.nodeName){var r=t.nodeName.toLowerCase();if("input"!==r||"image"===t.type)return n.domAttributes[r]}},n.encode=d,n.decode=decodeURIComponent,n.iso8859=function(){n.encode=escape,n.decode=unescape},n.unicode=function(){n.encode=d,n.decode=decodeURIComponent},n.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},n.encodeQuery=function(t,r){var e=n.encode(t+"");return void 0===r&&(r=n.escapeQuerySpace),r?e.replace(/%20/g,"+"):e},n.decodeQuery=function(t,r){t+="",void 0===r&&(r=n.escapeQuerySpace);try{return n.decode(r?t.replace(/\+/g,"%20"):t)}catch(e){return t}};var v,b={encode:"encode",decode:"decode"},w=function(t,r){return function(e){try{return n[r](e+"").replace(n.characters[t][r].expression,function(e){return n.characters[t][r].map[e]})}catch(s){return e}}};for(v in b)n[v+"PathSegment"]=w("pathname",b[v]),n[v+"UrnPathSegment"]=w("urnpath",b[v]);var Q=function(t,r,e){return function(s){var a;a=e?function(t){return n[r](n[e](t))}:n[r];for(var i=(s+"").split(t),o=0,h=i.length;h>o;o++)i[o]=a(i[o]);return i.join(t)}};n.decodePath=Q("/","decodePathSegment"),n.decodeUrnPath=Q(":","decodeUrnPathSegment"),n.recodePath=Q("/","encodePathSegment","decode"),n.recodeUrnPath=Q(":","encodeUrnPathSegment","decode"),n.encodeReserved=w("reserved","encode"),n.parse=function(t,r){var e;return r||(r={}),e=t.indexOf("#"),e>-1&&(r.fragment=t.substring(e+1)||null,t=t.substring(0,e)),e=t.indexOf("?"),e>-1&&(r.query=t.substring(e+1)||null,t=t.substring(0,e)),"//"===t.substring(0,2)?(r.protocol=null,t=t.substring(2),t=n.parseAuthority(t,r)):(e=t.indexOf(":"),e>-1&&(r.protocol=t.substring(0,e)||null,r.protocol&&!r.protocol.match(n.protocol_expression)?r.protocol=void 0:"//"===t.substring(e+1,e+3)?(t=t.substring(e+3),t=n.parseAuthority(t,r)):(t=t.substring(e+1),r.urn=!0))),r.path=t,r},n.parseHost=function(t,r){t=t.replace(/\\/g,"/");var e,s,n=t.indexOf("/");if(-1===n&&(n=t.length),"["===t.charAt(0))e=t.indexOf("]"),r.hostname=t.substring(1,e)||null,r.port=t.substring(e+2,n)||null,"/"===r.port&&(r.port=null);else{var a=t.indexOf(":"),i=t.indexOf("/"),o=t.indexOf(":",a+1);-1!==o&&(-1===i||i>o)?(r.hostname=t.substring(0,n)||null,r.port=null):(s=t.substring(0,n).split(":"),r.hostname=s[0]||null,r.port=s[1]||null)}return r.hostname&&"/"!==t.substring(n).charAt(0)&&(n++,t="/"+t),t.substring(n)||"/"},n.parseAuthority=function(t,r){return t=n.parseUserinfo(t,r),n.parseHost(t,r)},n.parseUserinfo=function(t,r){var e,s=t.indexOf("/"),a=t.lastIndexOf("@",s>-1?s:t.length-1);return a>-1&&(-1===s||s>a)?(e=t.substring(0,a).split(":"),r.username=e[0]?n.decode(e[0]):null,e.shift(),r.password=e[0]?n.decode(e.join(":")):null,t=t.substring(a+1)):(r.username=null,r.password=null),t},n.parseQuery=function(t,r){if(!t)return{};if(t=t.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!t)return{};for(var e,s,a,i={},o=t.split("&"),h=o.length,u=0;h>u;u++)e=o[u].split("="),s=n.decodeQuery(e.shift(),r),a=e.length?n.decodeQuery(e.join("="),r):null,y.call(i,s)?(("string"==typeof i[s]||null===i[s])&&(i[s]=[i[s]]),i[s].push(a)):i[s]=a;return i},n.build=function(t){var r="";return t.protocol&&(r+=t.protocol+":"),t.urn||!r&&!t.hostname||(r+="//"),r+=n.buildAuthority(t)||"","string"==typeof t.path&&("/"!==t.path.charAt(0)&&"string"==typeof t.hostname&&(r+="/"),r+=t.path),"string"==typeof t.query&&t.query&&(r+="?"+t.query),"string"==typeof t.fragment&&t.fragment&&(r+="#"+t.fragment),r},n.buildHost=function(t){var r="";return t.hostname?(r+=n.ip6_expression.test(t.hostname)?"["+t.hostname+"]":t.hostname,t.port&&(r+=":"+t.port),r):""},n.buildAuthority=function(t){return n.buildUserinfo(t)+n.buildHost(t)},n.buildUserinfo=function(t){var r="";return t.username&&(r+=n.encode(t.username)),t.password&&(r+=":"+n.encode(t.password)),r&&(r+="@"),r},n.buildQuery=function(t,r,e){var s,a,i,h,u="";for(a in t)if(y.call(t,a)&&a)if(o(t[a]))for(s={},i=0,h=t[a].length;h>i;i++)void 0!==t[a][i]&&void 0===s[t[a][i]+""]&&(u+="&"+n.buildQueryParameter(a,t[a][i],e),r!==!0&&(s[t[a][i]+""]=!0));else void 0!==t[a]&&(u+="&"+n.buildQueryParameter(a,t[a],e));return u.substring(1)},n.buildQueryParameter=function(t,r,e){return n.encodeQuery(t,e)+(null!==r?"="+n.encodeQuery(r,e):"")},n.addQuery=function(t,r,e){if("object"==typeof r)for(var s in r)y.call(r,s)&&n.addQuery(t,s,r[s]);else{if("string"!=typeof r)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");if(void 0===t[r])return void(t[r]=e);"string"==typeof t[r]&&(t[r]=[t[r]]),o(e)||(e=[e]),t[r]=(t[r]||[]).concat(e)}},n.removeQuery=function(t,r,e){var s,a,u;if(o(r))for(s=0,a=r.length;a>s;s++)t[r[s]]=void 0;else if("RegExp"===i(r))for(u in t)r.test(u)&&(t[u]=void 0);else if("object"==typeof r)for(u in r)y.call(r,u)&&n.removeQuery(t,u,r[u]);else{if("string"!=typeof r)throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");void 0!==e?"RegExp"===i(e)?!o(t[r])&&e.test(t[r])?t[r]=void 0:t[r]=h(t[r],e):t[r]!==String(e)||o(e)&&1!==e.length?o(t[r])&&(t[r]=h(t[r],e)):t[r]=void 0:t[r]=void 0}},n.hasQuery=function(t,r,e,s){switch(i(r)){case"String":break;case"RegExp":for(var a in t)if(y.call(t,a)&&r.test(a)&&(void 0===e||n.hasQuery(t,a,e)))return!0;return!1;case"Object":for(var h in r)if(y.call(r,h)&&!n.hasQuery(t,h,r[h]))return!1;return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter")}switch(i(e)){case"Undefined":return r in t;case"Boolean":var c=Boolean(o(t[r])?t[r].length:t[r]);return e===c;case"Function":return!!e(t[r],r,t);case"Array":if(!o(t[r]))return!1;var l=s?u:p;return l(t[r],e);case"RegExp":return o(t[r])?s?u(t[r],e):!1:Boolean(t[r]&&t[r].match(e));case"Number":e=String(e);case"String":return o(t[r])?s?u(t[r],e):!1:t[r]===e;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}},n.joinPaths=function(){for(var t=[],r=[],e=0,s=0;s<arguments.length;s++){var a=new n(arguments[s]);t.push(a);for(var i=a.segment(),o=0;o<i.length;o++)"string"==typeof i[o]&&r.push(i[o]),i[o]&&e++}if(!r.length||!e)return new n("");var h=new n("").segment(r);return(""===t[0].path()||"/"===t[0].path().slice(0,1))&&h.path("/"+h.path()),h.normalize()},n.commonPath=function(t,r){var e,s=Math.min(t.length,r.length);for(e=0;s>e;e++)if(t.charAt(e)!==r.charAt(e)){e--;break}return 1>e?t.charAt(0)===r.charAt(0)&&"/"===t.charAt(0)?"/":"":(("/"!==t.charAt(e)||"/"!==r.charAt(e))&&(e=t.substring(0,e).lastIndexOf("/")),t.substring(0,e+1))},n.withinString=function(t,r,e){e||(e={});var s=e.start||n.findUri.start,a=e.end||n.findUri.end,i=e.trim||n.findUri.trim,o=/[a-z0-9-]=["']?$/i;for(s.lastIndex=0;;){var h=s.exec(t);if(!h)break;var u=h.index;if(e.ignoreHtml){var p=t.slice(Math.max(u-3,0),u);if(p&&o.test(p))continue}var c=u+t.slice(u).search(a),l=t.slice(u,c).replace(i,"");if(!e.ignore||!e.ignore.test(l)){c=u+l.length;var d=r(l,u,c,t);t=t.slice(0,u)+d+t.slice(c),s.lastIndex=u+d.length}}return s.lastIndex=0,t},n.ensureValidHostname=function(r){if(r.match(n.invalid_hostname_characters)){if(!t)throw new TypeError('Hostname "'+r+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(t.toASCII(r).match(n.invalid_hostname_characters))throw new TypeError('Hostname "'+r+'" contains characters other than [A-Z0-9.-]')}},n.noConflict=function(t){if(t){var r={URI:this.noConflict()};return s.URITemplate&&"function"==typeof s.URITemplate.noConflict&&(r.URITemplate=s.URITemplate.noConflict()),s.IPv6&&"function"==typeof s.IPv6.noConflict&&(r.IPv6=s.IPv6.noConflict()),s.SecondLevelDomains&&"function"==typeof s.SecondLevelDomains.noConflict&&(r.SecondLevelDomains=s.SecondLevelDomains.noConflict()),r}return s.URI===this&&(s.URI=g),this},_.build=function(t){return t===!0?this._deferred_build=!0:(void 0===t||this._deferred_build)&&(this._string=n.build(this._parts),this._deferred_build=!1),this},_.clone=function(){return new n(this)},_.valueOf=_.toString=function(){return this.build(!1)._string},_.protocol=f("protocol"),_.username=f("username"),_.password=f("password"),_.hostname=f("hostname"),_.port=f("port"),_.query=m("query","?"),_.fragment=m("fragment","#"),_.search=function(t,r){var e=this.query(t,r);return"string"==typeof e&&e.length?"?"+e:e},_.hash=function(t,r){var e=this.fragment(t,r);return"string"==typeof e&&e.length?"#"+e:e},_.pathname=function(t,r){if(void 0===t||t===!0){var e=this._parts.path||(this._parts.hostname?"/":"");return t?(this._parts.urn?n.decodeUrnPath:n.decodePath)(e):e}return this._parts.urn?this._parts.path=t?n.recodeUrnPath(t):"":this._parts.path=t?n.recodePath(t):"/",this.build(!r),this},_.path=_.pathname,_.href=function(t,r){var e;if(void 0===t)return this.toString();this._string="",this._parts=n._parts();var s=t instanceof n,a="object"==typeof t&&(t.hostname||t.path||t.pathname);if(t.nodeName){var i=n.getDomAttribute(t);t=t[i]||"",a=!1}if(!s&&a&&void 0!==t.pathname&&(t=t.toString()),"string"==typeof t||t instanceof String)this._parts=n.parse(String(t),this._parts);else{if(!s&&!a)throw new TypeError("invalid input");var o=s?t._parts:t;for(e in o)y.call(this._parts,e)&&(this._parts[e]=o[e])}return this.build(!r),this},_.is=function(t){var r=!1,s=!1,a=!1,i=!1,o=!1,h=!1,u=!1,p=!this._parts.urn;switch(this._parts.hostname&&(p=!1,s=n.ip4_expression.test(this._parts.hostname),a=n.ip6_expression.test(this._parts.hostname),r=s||a,i=!r,o=i&&e&&e.has(this._parts.hostname),h=i&&n.idn_expression.test(this._parts.hostname),u=i&&n.punycode_expression.test(this._parts.hostname)),t.toLowerCase()){case"relative":return p;case"absolute":return!p;case"domain":case"name":return i;case"sld":return o;case"ip":return r;case"ip4":case"ipv4":case"inet4":return s;case"ip6":case"ipv6":case"inet6":return a;case"idn":return h;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return u}return null};var A=_.protocol,P=_.port,x=_.hostname;_.protocol=function(t,r){if(void 0!==t&&t&&(t=t.replace(/:(\/\/)?$/,""),!t.match(n.protocol_expression)))throw new TypeError('Protocol "'+t+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return A.call(this,t,r)},_.scheme=_.protocol,_.port=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t&&(0===t&&(t=null),t&&(t+="",":"===t.charAt(0)&&(t=t.substring(1)),t.match(/[^0-9]/))))throw new TypeError('Port "'+t+'" contains characters other than [0-9]');return P.call(this,t,r)},_.hostname=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t){var e={},s=n.parseHost(t,e);if("/"!==s)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');t=e.hostname}return x.call(this,t,r)},_.origin=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){var e=this.protocol(),s=this.authority();return s?(e?e+"://":"")+this.authority():""}var a=n(t);return this.protocol(a.protocol()).authority(a.authority()).build(!r),this},_.host=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t)return this._parts.hostname?n.buildHost(this._parts):"";var e=n.parseHost(t,this._parts);if("/"!==e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');return this.build(!r),this},_.authority=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t)return this._parts.hostname?n.buildAuthority(this._parts):"";var e=n.parseAuthority(t,this._parts);if("/"!==e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');return this.build(!r),this},_.userinfo=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){var e=n.buildUserinfo(this._parts);return e?e.substring(0,e.length-1):e}return"@"!==t[t.length-1]&&(t+="@"),n.parseUserinfo(t,this._parts),this.build(!r),this},_.resource=function(t,r){var e;return void 0===t?this.path()+this.search()+this.hash():(e=n.parse(t),this._parts.path=e.path,this._parts.query=e.query,this._parts.fragment=e.fragment,this.build(!r),this)},_.subdomain=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,e)||""}var s=this._parts.hostname.length-this.domain().length,i=this._parts.hostname.substring(0,s),o=new RegExp("^"+a(i));return t&&"."!==t.charAt(t.length-1)&&(t+="."),t&&n.ensureValidHostname(t),this._parts.hostname=this._parts.hostname.replace(o,t),this.build(!r),this},_.domain=function(t,r){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(r=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.match(/\./g);if(e&&e.length<2)return this._parts.hostname;var s=this._parts.hostname.length-this.tld(r).length-1;return s=this._parts.hostname.lastIndexOf(".",s-1)+1,this._parts.hostname.substring(s)||""}if(!t)throw new TypeError("cannot set domain empty");if(n.ensureValidHostname(t),!this._parts.hostname||this.is("IP"))this._parts.hostname=t;else{var i=new RegExp(a(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(i,t)}return this.build(!r),this},_.tld=function(t,r){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(r=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var s=this._parts.hostname.lastIndexOf("."),n=this._parts.hostname.substring(s+1);return r!==!0&&e&&e.list[n.toLowerCase()]?e.get(this._parts.hostname)||n:n}var i;if(!t)throw new TypeError("cannot set TLD empty");if(t.match(/[^a-zA-Z0-9-]/)){if(!e||!e.is(t))throw new TypeError('TLD "'+t+'" contains characters other than [A-Z0-9]');i=new RegExp(a(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(i,t)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");i=new RegExp(a(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(i,t)}return this.build(!r),this},_.directory=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var e=this._parts.path.length-this.filename().length-1,s=this._parts.path.substring(0,e)||(this._parts.hostname?"/":"");return t?n.decodePath(s):s}var i=this._parts.path.length-this.filename().length,o=this._parts.path.substring(0,i),h=new RegExp("^"+a(o));return this.is("relative")||(t||(t="/"),"/"!==t.charAt(0)&&(t="/"+t)),t&&"/"!==t.charAt(t.length-1)&&(t+="/"),t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t),this.build(!r),this},_.filename=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var e=this._parts.path.lastIndexOf("/"),s=this._parts.path.substring(e+1);return t?n.decodePathSegment(s):s}var i=!1;"/"===t.charAt(0)&&(t=t.substring(1)),t.match(/\.?\//)&&(i=!0);var o=new RegExp(a(this.filename())+"$");return t=n.recodePath(t),this._parts.path=this._parts.path.replace(o,t),i?this.normalizePath(r):this.build(!r),this},_.suffix=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var e,s,i=this.filename(),o=i.lastIndexOf(".");return-1===o?"":(e=i.substring(o+1),s=/^[a-z0-9%]+$/i.test(e)?e:"",t?n.decodePathSegment(s):s)}"."===t.charAt(0)&&(t=t.substring(1));var h,u=this.suffix();if(u)h=t?new RegExp(a(u)+"$"):new RegExp(a("."+u)+"$");else{if(!t)return this;this._parts.path+="."+n.recodePath(t)}return h&&(t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t)),this.build(!r),this},_.segment=function(t,r,e){var s=this._parts.urn?":":"/",n=this.path(),a="/"===n.substring(0,1),i=n.split(s);if(void 0!==t&&"number"!=typeof t&&(e=r,r=t,t=void 0),void 0!==t&&"number"!=typeof t)throw new Error('Bad segment "'+t+'", must be 0-based integer');if(a&&i.shift(),0>t&&(t=Math.max(i.length+t,0)),void 0===r)return void 0===t?i:i[t];if(null===t||void 0===i[t])if(o(r)){i=[];for(var h=0,u=r.length;u>h;h++)(r[h].length||i.length&&i[i.length-1].length)&&(i.length&&!i[i.length-1].length&&i.pop(),i.push(c(r[h])))}else(r||"string"==typeof r)&&(r=c(r),""===i[i.length-1]?i[i.length-1]=r:i.push(r));else r?i[t]=c(r):i.splice(t,1);return a&&i.unshift(""),this.path(i.join(s),e)},_.segmentCoded=function(t,r,e){var s,a,i;if("number"!=typeof t&&(e=r,r=t,t=void 0),void 0===r){if(s=this.segment(t,r,e),o(s))for(a=0,i=s.length;i>a;a++)s[a]=n.decode(s[a]);else s=void 0!==s?n.decode(s):void 0;return s}if(o(r))for(a=0,i=r.length;i>a;a++)r[a]=n.encode(r[a]);else r="string"==typeof r||r instanceof String?n.encode(r):r;return this.segment(t,r,e)};var S=_.query;return _.query=function(t,r){if(t===!0)return n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof t){var e=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace),s=t.call(this,e);return this._parts.query=n.buildQuery(s||e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!r),this}return void 0!==t&&"string"!=typeof t?(this._parts.query=n.buildQuery(t,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!r),this):S.call(this,t,r)},_.setQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("string"==typeof t||t instanceof String)s[t]=void 0!==r?r:null;else{if("object"!=typeof t)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");for(var a in t)y.call(t,a)&&(s[a]=t[a])}return this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(e=r),this.build(!e),this},_.addQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.addQuery(s,t,void 0===r?null:r),this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(e=r),this.build(!e),this},_.removeQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.removeQuery(s,t,r),this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(e=r),this.build(!e),this},_.hasQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.hasQuery(s,t,r,e)},_.setSearch=_.setQuery,_.addSearch=_.addQuery,_.removeSearch=_.removeQuery,_.hasSearch=_.hasQuery,_.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},_.normalizeProtocol=function(t){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!t)),this},_.normalizeHostname=function(e){return this._parts.hostname&&(this.is("IDN")&&t?this._parts.hostname=t.toASCII(this._parts.hostname):this.is("IPv6")&&r&&(this._parts.hostname=r.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!e)),this},_.normalizePort=function(t){return"string"==typeof this._parts.protocol&&this._parts.port===n.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!t)),this},_.normalizePath=function(t){var r=this._parts.path;if(!r)return this;if(this._parts.urn)return this._parts.path=n.recodeUrnPath(this._parts.path),this.build(!t),this;if("/"===this._parts.path)return this;r=n.recodePath(r);var e,s,a,i="";for("/"!==r.charAt(0)&&(e=!0,r="/"+r),("/.."===r.slice(-3)||"/."===r.slice(-2))&&(r+="/"),r=r.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),e&&(i=r.substring(1).match(/^(\.\.\/)+/)||"",i&&(i=i[0]));;){if(s=r.search(/\/\.\.(\/|$)/),-1===s)break;0!==s?(a=r.substring(0,s).lastIndexOf("/"),-1===a&&(a=s),r=r.substring(0,a)+r.substring(s+3)):r=r.substring(3)}return e&&this.is("relative")&&(r=i+r.substring(1)),this._parts.path=r,this.build(!t),this},_.normalizePathname=_.normalizePath,_.normalizeQuery=function(t){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(n.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!t)),this},_.normalizeFragment=function(t){return this._parts.fragment||(this._parts.fragment=null,this.build(!t)),this},_.normalizeSearch=_.normalizeQuery,_.normalizeHash=_.normalizeFragment,_.iso8859=function(){var t=n.encode,r=n.decode;n.encode=escape,n.decode=decodeURIComponent;try{this.normalize()}finally{n.encode=t,n.decode=r}return this},_.unicode=function(){var t=n.encode,r=n.decode;n.encode=d,n.decode=unescape;try{this.normalize()}finally{n.encode=t,n.decode=r}return this},_.readable=function(){var r=this.clone();r.username("").password("").normalize();var e="";if(r._parts.protocol&&(e+=r._parts.protocol+"://"),r._parts.hostname&&(r.is("punycode")&&t?(e+=t.toUnicode(r._parts.hostname),r._parts.port&&(e+=":"+r._parts.port)):e+=r.host()),r._parts.hostname&&r._parts.path&&"/"!==r._parts.path.charAt(0)&&(e+="/"),e+=r.path(!0),r._parts.query){for(var s="",a=0,i=r._parts.query.split("&"),o=i.length;o>a;a++){var h=(i[a]||"").split("=");s+="&"+n.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"),void 0!==h[1]&&(s+="="+n.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}e+="?"+s.substring(1)}return e+=n.decodeQuery(r.hash(),!0)},_.absoluteTo=function(t){var r,e,s,a=this.clone(),i=["protocol","username","password","hostname","port"];if(this._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t instanceof n||(t=new n(t)),a._parts.protocol||(a._parts.protocol=t._parts.protocol),this._parts.hostname)return a;for(e=0;s=i[e];e++)a._parts[s]=t._parts[s];return a._parts.path?".."===a._parts.path.substring(-2)&&(a._parts.path+="/"):(a._parts.path=t._parts.path,a._parts.query||(a._parts.query=t._parts.query)),"/"!==a.path().charAt(0)&&(r=t.directory(),r=r?r:0===t.path().indexOf("/")?"/":"",a._parts.path=(r?r+"/":"")+a._parts.path,a.normalizePath()),a.build(),a},_.relativeTo=function(t){var r,e,s,a,i,o=this.clone().normalize();if(o._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t=new n(t).normalize(),r=o._parts,e=t._parts,a=o.path(),i=t.path(),"/"!==a.charAt(0))throw new Error("URI is already relative");if("/"!==i.charAt(0))throw new Error("Cannot calculate a URI relative to another relative URI");if(r.protocol===e.protocol&&(r.protocol=null),r.username!==e.username||r.password!==e.password)return o.build();if(null!==r.protocol||null!==r.username||null!==r.password)return o.build();if(r.hostname!==e.hostname||r.port!==e.port)return o.build();if(r.hostname=null,r.port=null,a===i)return r.path="",o.build();if(s=n.commonPath(a,i),!s)return o.build();var h=e.path.substring(s.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");return r.path=h+r.path.substring(s.length)||"./",o.build()},_.equals=function(t){var r,e,s,a=this.clone(),i=new n(t),h={},u={},c={};if(a.normalize(),i.normalize(),a.toString()===i.toString())return!0;if(r=a.query(),e=i.query(),a.query(""),i.query(""),a.toString()!==i.toString())return!1;if(r.length!==e.length)return!1;h=n.parseQuery(r,this._parts.escapeQuerySpace),u=n.parseQuery(e,this._parts.escapeQuerySpace);for(s in h)if(y.call(h,s)){if(o(h[s])){if(!p(h[s],u[s]))return!1}else if(h[s]!==u[s])return!1;c[s]=!0}for(s in u)if(y.call(u,s)&&!c[s])return!1;return!0},_.duplicateQueryParameters=function(t){return this._parts.duplicateQueryParameters=!!t,this},_.escapeQuerySpace=function(t){return this._parts.escapeQuerySpace=!!t,this},n});
|
js/css.js
CHANGED
@@ -1,698 +1,4487 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/*
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
this.cssKeyframeRegex = '((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})';
|
20 |
-
this.combinedCSSRegex = '((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})'; //to match css & media queries together
|
21 |
-
this.cssCommentsRegex = '(\\/\\*[\\s\\S]*?\\*\\/)';
|
22 |
-
this.cssImportStatementRegex = new RegExp('@import .*?;', 'gi');
|
23 |
};
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
|
|
|
|
36 |
};
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
fi.prototype.parseCSS = function (source) {
|
47 |
|
48 |
-
if (
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
|
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
while (true) {
|
74 |
-
arr = keyframesRegex.exec(source);
|
75 |
-
if (arr === null) {
|
76 |
-
break;
|
77 |
-
}
|
78 |
-
css.push({
|
79 |
-
selector: '@keyframes',
|
80 |
-
type: 'keyframes',
|
81 |
-
styles: arr[0]
|
82 |
-
});
|
83 |
}
|
84 |
-
|
85 |
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
var commentsRegex = new RegExp(this.cssCommentsRegex, 'gi');
|
106 |
-
var comments = commentsRegex.exec(selector);
|
107 |
-
if (comments !== null) {
|
108 |
-
selector = selector.replace(commentsRegex, '').trim();
|
109 |
-
}
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
|
|
143 |
|
144 |
-
|
145 |
};
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
and returns an array of objects containing ruleName:ruleValue pairs
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
}
|
196 |
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
};
|
199 |
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
-
|
218 |
};
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
}
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
|
|
240 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
-
|
244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
}
|
246 |
else {
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
}
|
251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
}
|
|
|
|
|
|
|
253 |
};
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
for (var i = 0; i < cssObjectArray.length; i++) {
|
261 |
-
if (cssObjectArray[i].selector !== selector) {
|
262 |
-
ret.push(cssObjectArray[i]);
|
263 |
-
}
|
264 |
}
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
};
|
267 |
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
|
281 |
-
|
282 |
-
|
283 |
-
compressed = compressed.concat(found);
|
284 |
-
done[obj.selector] = true;
|
285 |
-
}
|
286 |
-
}
|
287 |
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
289 |
};
|
290 |
|
291 |
-
|
292 |
-
Received 2 css objects with following structure
|
293 |
-
{
|
294 |
-
rules : [{directive:"", value:""}, {directive:"", value:""}, ...]
|
295 |
-
selector : "SOMESELECTOR"
|
296 |
-
}
|
297 |
|
298 |
-
|
299 |
|
300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
|
302 |
-
|
303 |
-
|
304 |
-
if a css directive exists in css2 but not css1, then it is deleted in css1, it would be included in diff but will be marked as type='DELETED'
|
305 |
|
306 |
-
|
307 |
-
|
|
|
308 |
|
309 |
-
|
310 |
-
|
311 |
-
fi.prototype.cssDiff = function (css1, css2) {
|
312 |
-
if (css1.selector !== css2.selector) {
|
313 |
-
return false;
|
314 |
-
}
|
315 |
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
diff.rules.push(rule2);
|
351 |
-
}
|
352 |
}
|
|
|
353 |
|
|
|
354 |
|
355 |
-
|
356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
}
|
358 |
-
|
359 |
};
|
360 |
|
361 |
-
|
362 |
-
|
363 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
}
|
|
|
374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
|
376 |
-
|
377 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
}
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
};
|
|
|
|
|
387 |
|
388 |
-
|
389 |
-
|
390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
|
402 |
-
|
403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
break;
|
|
|
|
|
|
|
411 |
}
|
412 |
}
|
413 |
}
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
}
|
421 |
}
|
422 |
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
oldRule.type = 'DELETED';
|
436 |
-
}
|
437 |
-
else {
|
438 |
-
//rule found just update value
|
439 |
-
|
440 |
-
oldRule.value = rule.value;
|
441 |
-
}
|
442 |
-
}
|
443 |
-
}
|
444 |
-
else {
|
445 |
-
cssObject.subStyles = cssObject.subStyles.concat(minimalObject.subStyles); //TODO, make this intelligent too
|
446 |
-
}
|
447 |
|
|
|
|
|
|
|
448 |
}
|
449 |
-
};
|
450 |
|
451 |
-
|
452 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
|
454 |
-
|
|
|
455 |
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
}
|
464 |
-
}
|
465 |
-
return newRules;
|
466 |
-
};
|
467 |
-
/*
|
468 |
-
computes string for ace editor using this.css or given cssBase optional parameter
|
469 |
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
depth = 0;
|
475 |
-
}
|
476 |
-
var ret = '';
|
477 |
-
if (cssBase === undefined) {
|
478 |
-
cssBase = this.css;
|
479 |
-
}
|
480 |
-
//append imports
|
481 |
-
for (var i = 0; i < cssBase.length; i++) {
|
482 |
-
if (cssBase[i].type === 'imports') {
|
483 |
-
ret += cssBase[i].styles + '\n\n';
|
484 |
-
}
|
485 |
-
}
|
486 |
-
for (i = 0; i < cssBase.length; i++) {
|
487 |
-
var tmp = cssBase[i];
|
488 |
-
if (tmp.selector === undefined) { //temporarily omit media queries
|
489 |
-
continue;
|
490 |
-
}
|
491 |
-
var comments = "";
|
492 |
-
if (tmp.comments !== undefined) {
|
493 |
-
comments = tmp.comments + '\n';
|
494 |
-
}
|
495 |
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
ret += this.getSpaces(depth) + comments + tmp.selector + ' {\n';
|
503 |
-
ret += this.getCSSOfRules(tmp.rules, depth + 1);
|
504 |
-
ret += this.getSpaces(depth) + '}\n\n';
|
505 |
}
|
506 |
}
|
507 |
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
|
|
512 |
}
|
513 |
-
}
|
514 |
|
515 |
-
return
|
516 |
};
|
517 |
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
if (cssObjectArray[i].type === 'imports') {
|
522 |
-
imps.push(cssObjectArray[i].styles);
|
523 |
-
}
|
524 |
-
}
|
525 |
-
return imps;
|
526 |
};
|
527 |
|
528 |
-
|
529 |
-
|
530 |
-
to be used inside editor
|
531 |
-
*/
|
532 |
-
fi.prototype.getCSSOfRules = function (rules, depth) {
|
533 |
-
var ret = '';
|
534 |
-
for (var i = 0; i < rules.length; i++) {
|
535 |
-
if (rules[i] === undefined) {
|
536 |
-
continue;
|
537 |
-
}
|
538 |
-
if( rules[i].value === '' ) {
|
539 |
-
continue;
|
540 |
-
}
|
541 |
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
547 |
}
|
|
|
548 |
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
}
|
550 |
-
return ret || '\n';
|
551 |
-
};
|
552 |
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
for (var i = 0; i < num * 2; i++) {
|
560 |
-
ret += ' ';
|
561 |
}
|
562 |
-
return ret;
|
563 |
-
};
|
564 |
-
|
565 |
-
/*
|
566 |
-
Given css string or objectArray, parses it and then for every selector,
|
567 |
-
prepends this.cssPreviewNamespace to prevent css collision issues
|
568 |
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
if (forcedNamespace !== undefined) {
|
575 |
-
namespaceClass = forcedNamespace;
|
576 |
}
|
577 |
|
578 |
-
if (
|
579 |
-
|
|
|
|
|
|
|
580 |
}
|
|
|
581 |
|
582 |
-
|
583 |
-
|
|
|
|
|
|
|
584 |
|
585 |
-
|
586 |
-
|
587 |
-
continue;
|
588 |
-
}
|
589 |
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
600 |
}
|
601 |
-
obj.selector = newSelector.join(',');
|
602 |
-
}
|
603 |
-
else {
|
604 |
-
obj.subStyles = this.applyNamespacing(obj.subStyles, forcedNamespace); //handle media queries as well
|
605 |
}
|
606 |
-
}
|
|
|
|
|
|
|
607 |
|
608 |
-
|
609 |
-
};
|
610 |
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
returnObj = false;
|
618 |
-
}
|
619 |
-
var cssObjectArray = css;
|
620 |
-
var namespaceClass = '.' + this.cssPreviewNamespace;
|
621 |
-
if (typeof css === 'string') {
|
622 |
-
cssObjectArray = this.parseCSS(css);
|
623 |
-
}
|
624 |
|
625 |
-
|
626 |
-
|
|
|
|
|
627 |
|
628 |
-
|
629 |
-
var selector = obj.selector.split(',');
|
630 |
-
var newSelector = [];
|
631 |
-
for (var j = 0; j < selector.length; j++) {
|
632 |
-
newSelector.push(selector[j].split(namespaceClass + ' ').join(''));
|
633 |
-
}
|
634 |
-
obj.selector = newSelector.join(',');
|
635 |
-
}
|
636 |
-
else {
|
637 |
-
obj.subStyles = this.clearNamespacing(obj.subStyles, true); //handle media queries as well
|
638 |
}
|
639 |
}
|
640 |
-
if (returnObj === false) {
|
641 |
-
return this.getCSSForEditor(cssObjectArray);
|
642 |
-
}
|
643 |
-
else {
|
644 |
-
return cssObjectArray;
|
645 |
-
}
|
646 |
-
|
647 |
};
|
648 |
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
|
|
|
|
656 |
}
|
657 |
|
658 |
-
if (
|
659 |
-
|
660 |
-
|
661 |
}
|
662 |
|
663 |
-
if (
|
664 |
-
|
665 |
-
}
|
666 |
-
//apply formatting for css
|
667 |
-
if (format === true) {
|
668 |
-
css = this.getCSSForEditor(this.parseCSS(css));
|
669 |
}
|
670 |
|
671 |
-
|
672 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
}
|
|
|
674 |
|
675 |
-
|
676 |
-
|
677 |
-
|
|
|
|
|
|
|
|
|
678 |
}
|
679 |
|
680 |
-
|
681 |
-
|
|
|
|
|
|
|
682 |
|
683 |
-
|
684 |
-
style.type = 'text/css';
|
685 |
|
686 |
-
|
|
|
687 |
|
688 |
-
|
689 |
-
style.styleSheet.cssText = css;
|
690 |
-
}
|
691 |
-
else {
|
692 |
-
style.appendChild(document.createTextNode(css));
|
693 |
-
}
|
694 |
-
};
|
695 |
|
696 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
697 |
|
698 |
-
})
|
1 |
+
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2 |
+
|
3 |
+
},{}],2:[function(require,module,exports){
|
4 |
+
(function (process){
|
5 |
+
// Copyright Joyent, Inc. and other Node contributors.
|
6 |
+
//
|
7 |
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
8 |
+
// copy of this software and associated documentation files (the
|
9 |
+
// "Software"), to deal in the Software without restriction, including
|
10 |
+
// without limitation the rights to use, copy, modify, merge, publish,
|
11 |
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
12 |
+
// persons to whom the Software is furnished to do so, subject to the
|
13 |
+
// following conditions:
|
14 |
+
//
|
15 |
+
// The above copyright notice and this permission notice shall be included
|
16 |
+
// in all copies or substantial portions of the Software.
|
17 |
+
//
|
18 |
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
19 |
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20 |
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
21 |
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
22 |
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
23 |
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
24 |
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
|
26 |
+
// resolves . and .. elements in a path array with directory names there
|
27 |
+
// must be no slashes, empty elements, or device names (c:\) in the array
|
28 |
+
// (so also no leading and trailing slashes - it does not distinguish
|
29 |
+
// relative and absolute paths)
|
30 |
+
function normalizeArray(parts, allowAboveRoot) {
|
31 |
+
// if the path tries to go above the root, `up` ends up > 0
|
32 |
+
var up = 0;
|
33 |
+
for (var i = parts.length - 1; i >= 0; i--) {
|
34 |
+
var last = parts[i];
|
35 |
+
if (last === '.') {
|
36 |
+
parts.splice(i, 1);
|
37 |
+
} else if (last === '..') {
|
38 |
+
parts.splice(i, 1);
|
39 |
+
up++;
|
40 |
+
} else if (up) {
|
41 |
+
parts.splice(i, 1);
|
42 |
+
up--;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
// if the path is allowed to go above the root, restore leading ..s
|
47 |
+
if (allowAboveRoot) {
|
48 |
+
for (; up--; up) {
|
49 |
+
parts.unshift('..');
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
return parts;
|
54 |
+
}
|
55 |
+
|
56 |
+
// Split a filename into [root, dir, basename, ext], unix version
|
57 |
+
// 'root' is just a slash, or nothing.
|
58 |
+
var splitPathRe =
|
59 |
+
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
60 |
+
var splitPath = function(filename) {
|
61 |
+
return splitPathRe.exec(filename).slice(1);
|
62 |
+
};
|
63 |
+
|
64 |
+
// path.resolve([from ...], to)
|
65 |
+
// posix version
|
66 |
+
exports.resolve = function() {
|
67 |
+
var resolvedPath = '',
|
68 |
+
resolvedAbsolute = false;
|
69 |
+
|
70 |
+
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
71 |
+
var path = (i >= 0) ? arguments[i] : process.cwd();
|
72 |
+
|
73 |
+
// Skip empty and invalid entries
|
74 |
+
if (typeof path !== 'string') {
|
75 |
+
throw new TypeError('Arguments to path.resolve must be strings');
|
76 |
+
} else if (!path) {
|
77 |
+
continue;
|
78 |
+
}
|
79 |
+
|
80 |
+
resolvedPath = path + '/' + resolvedPath;
|
81 |
+
resolvedAbsolute = path.charAt(0) === '/';
|
82 |
+
}
|
83 |
+
|
84 |
+
// At this point the path should be resolved to a full absolute path, but
|
85 |
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
86 |
+
|
87 |
+
// Normalize the path
|
88 |
+
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
89 |
+
return !!p;
|
90 |
+
}), !resolvedAbsolute).join('/');
|
91 |
+
|
92 |
+
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
93 |
+
};
|
94 |
+
|
95 |
+
// path.normalize(path)
|
96 |
+
// posix version
|
97 |
+
exports.normalize = function(path) {
|
98 |
+
var isAbsolute = exports.isAbsolute(path),
|
99 |
+
trailingSlash = substr(path, -1) === '/';
|
100 |
+
|
101 |
+
// Normalize the path
|
102 |
+
path = normalizeArray(filter(path.split('/'), function(p) {
|
103 |
+
return !!p;
|
104 |
+
}), !isAbsolute).join('/');
|
105 |
+
|
106 |
+
if (!path && !isAbsolute) {
|
107 |
+
path = '.';
|
108 |
+
}
|
109 |
+
if (path && trailingSlash) {
|
110 |
+
path += '/';
|
111 |
+
}
|
112 |
+
|
113 |
+
return (isAbsolute ? '/' : '') + path;
|
114 |
+
};
|
115 |
+
|
116 |
+
// posix version
|
117 |
+
exports.isAbsolute = function(path) {
|
118 |
+
return path.charAt(0) === '/';
|
119 |
+
};
|
120 |
+
|
121 |
+
// posix version
|
122 |
+
exports.join = function() {
|
123 |
+
var paths = Array.prototype.slice.call(arguments, 0);
|
124 |
+
return exports.normalize(filter(paths, function(p, index) {
|
125 |
+
if (typeof p !== 'string') {
|
126 |
+
throw new TypeError('Arguments to path.join must be strings');
|
127 |
+
}
|
128 |
+
return p;
|
129 |
+
}).join('/'));
|
130 |
+
};
|
131 |
+
|
132 |
+
|
133 |
+
// path.relative(from, to)
|
134 |
+
// posix version
|
135 |
+
exports.relative = function(from, to) {
|
136 |
+
from = exports.resolve(from).substr(1);
|
137 |
+
to = exports.resolve(to).substr(1);
|
138 |
+
|
139 |
+
function trim(arr) {
|
140 |
+
var start = 0;
|
141 |
+
for (; start < arr.length; start++) {
|
142 |
+
if (arr[start] !== '') break;
|
143 |
+
}
|
144 |
+
|
145 |
+
var end = arr.length - 1;
|
146 |
+
for (; end >= 0; end--) {
|
147 |
+
if (arr[end] !== '') break;
|
148 |
+
}
|
149 |
+
|
150 |
+
if (start > end) return [];
|
151 |
+
return arr.slice(start, end - start + 1);
|
152 |
+
}
|
153 |
+
|
154 |
+
var fromParts = trim(from.split('/'));
|
155 |
+
var toParts = trim(to.split('/'));
|
156 |
+
|
157 |
+
var length = Math.min(fromParts.length, toParts.length);
|
158 |
+
var samePartsLength = length;
|
159 |
+
for (var i = 0; i < length; i++) {
|
160 |
+
if (fromParts[i] !== toParts[i]) {
|
161 |
+
samePartsLength = i;
|
162 |
+
break;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
var outputParts = [];
|
167 |
+
for (var i = samePartsLength; i < fromParts.length; i++) {
|
168 |
+
outputParts.push('..');
|
169 |
+
}
|
170 |
+
|
171 |
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
172 |
+
|
173 |
+
return outputParts.join('/');
|
174 |
+
};
|
175 |
+
|
176 |
+
exports.sep = '/';
|
177 |
+
exports.delimiter = ':';
|
178 |
+
|
179 |
+
exports.dirname = function(path) {
|
180 |
+
var result = splitPath(path),
|
181 |
+
root = result[0],
|
182 |
+
dir = result[1];
|
183 |
+
|
184 |
+
if (!root && !dir) {
|
185 |
+
// No dirname whatsoever
|
186 |
+
return '.';
|
187 |
+
}
|
188 |
+
|
189 |
+
if (dir) {
|
190 |
+
// It has a dirname, strip trailing slash
|
191 |
+
dir = dir.substr(0, dir.length - 1);
|
192 |
+
}
|
193 |
+
|
194 |
+
return root + dir;
|
195 |
+
};
|
196 |
+
|
197 |
+
|
198 |
+
exports.basename = function(path, ext) {
|
199 |
+
var f = splitPath(path)[2];
|
200 |
+
// TODO: make this comparison case-insensitive on windows?
|
201 |
+
if (ext && f.substr(-1 * ext.length) === ext) {
|
202 |
+
f = f.substr(0, f.length - ext.length);
|
203 |
+
}
|
204 |
+
return f;
|
205 |
+
};
|
206 |
+
|
207 |
+
|
208 |
+
exports.extname = function(path) {
|
209 |
+
return splitPath(path)[3];
|
210 |
+
};
|
211 |
+
|
212 |
+
function filter (xs, f) {
|
213 |
+
if (xs.filter) return xs.filter(f);
|
214 |
+
var res = [];
|
215 |
+
for (var i = 0; i < xs.length; i++) {
|
216 |
+
if (f(xs[i], i, xs)) res.push(xs[i]);
|
217 |
+
}
|
218 |
+
return res;
|
219 |
+
}
|
220 |
+
|
221 |
+
// String.prototype.substr - negative index don't work in IE8
|
222 |
+
var substr = 'ab'.substr(-1) === 'b'
|
223 |
+
? function (str, start, len) { return str.substr(start, len) }
|
224 |
+
: function (str, start, len) {
|
225 |
+
if (start < 0) start = str.length + start;
|
226 |
+
return str.substr(start, len);
|
227 |
+
}
|
228 |
+
;
|
229 |
+
|
230 |
+
}).call(this,require('_process'))
|
231 |
+
},{"_process":3}],3:[function(require,module,exports){
|
232 |
+
// shim for using process in browser
|
233 |
+
|
234 |
+
var process = module.exports = {};
|
235 |
+
var queue = [];
|
236 |
+
var draining = false;
|
237 |
+
var currentQueue;
|
238 |
+
var queueIndex = -1;
|
239 |
+
|
240 |
+
function cleanUpNextTick() {
|
241 |
+
draining = false;
|
242 |
+
if (currentQueue.length) {
|
243 |
+
queue = currentQueue.concat(queue);
|
244 |
+
} else {
|
245 |
+
queueIndex = -1;
|
246 |
+
}
|
247 |
+
if (queue.length) {
|
248 |
+
drainQueue();
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
function drainQueue() {
|
253 |
+
if (draining) {
|
254 |
+
return;
|
255 |
+
}
|
256 |
+
var timeout = setTimeout(cleanUpNextTick);
|
257 |
+
draining = true;
|
258 |
+
|
259 |
+
var len = queue.length;
|
260 |
+
while(len) {
|
261 |
+
currentQueue = queue;
|
262 |
+
queue = [];
|
263 |
+
while (++queueIndex < len) {
|
264 |
+
if (currentQueue) {
|
265 |
+
currentQueue[queueIndex].run();
|
266 |
+
}
|
267 |
+
}
|
268 |
+
queueIndex = -1;
|
269 |
+
len = queue.length;
|
270 |
+
}
|
271 |
+
currentQueue = null;
|
272 |
+
draining = false;
|
273 |
+
clearTimeout(timeout);
|
274 |
+
}
|
275 |
+
|
276 |
+
process.nextTick = function (fun) {
|
277 |
+
var args = new Array(arguments.length - 1);
|
278 |
+
if (arguments.length > 1) {
|
279 |
+
for (var i = 1; i < arguments.length; i++) {
|
280 |
+
args[i - 1] = arguments[i];
|
281 |
+
}
|
282 |
+
}
|
283 |
+
queue.push(new Item(fun, args));
|
284 |
+
if (queue.length === 1 && !draining) {
|
285 |
+
setTimeout(drainQueue, 0);
|
286 |
+
}
|
287 |
+
};
|
288 |
+
|
289 |
+
// v8 likes predictible objects
|
290 |
+
function Item(fun, array) {
|
291 |
+
this.fun = fun;
|
292 |
+
this.array = array;
|
293 |
+
}
|
294 |
+
Item.prototype.run = function () {
|
295 |
+
this.fun.apply(null, this.array);
|
296 |
+
};
|
297 |
+
process.title = 'browser';
|
298 |
+
process.browser = true;
|
299 |
+
process.env = {};
|
300 |
+
process.argv = [];
|
301 |
+
process.version = ''; // empty string to avoid regexp issues
|
302 |
+
process.versions = {};
|
303 |
+
|
304 |
+
function noop() {}
|
305 |
+
|
306 |
+
process.on = noop;
|
307 |
+
process.addListener = noop;
|
308 |
+
process.once = noop;
|
309 |
+
process.off = noop;
|
310 |
+
process.removeListener = noop;
|
311 |
+
process.removeAllListeners = noop;
|
312 |
+
process.emit = noop;
|
313 |
+
|
314 |
+
process.binding = function (name) {
|
315 |
+
throw new Error('process.binding is not supported');
|
316 |
+
};
|
317 |
+
|
318 |
+
process.cwd = function () { return '/' };
|
319 |
+
process.chdir = function (dir) {
|
320 |
+
throw new Error('process.chdir is not supported');
|
321 |
+
};
|
322 |
+
process.umask = function() { return 0; };
|
323 |
+
|
324 |
+
},{}],4:[function(require,module,exports){
|
325 |
+
//This is for browserify to build the required CSS module into something we can use in the browser.
|
326 |
+
window.css = require('css');
|
327 |
+
|
328 |
+
},{"css":5}],5:[function(require,module,exports){
|
329 |
+
exports.parse = require('./lib/parse');
|
330 |
+
exports.stringify = require('./lib/stringify');
|
331 |
+
|
332 |
+
},{"./lib/parse":6,"./lib/stringify":10}],6:[function(require,module,exports){
|
333 |
+
// http://www.w3.org/TR/CSS21/grammar.html
|
334 |
+
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
335 |
+
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g
|
336 |
+
|
337 |
+
module.exports = function(css, options){
|
338 |
+
options = options || {};
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Positional.
|
342 |
+
*/
|
343 |
+
|
344 |
+
var lineno = 1;
|
345 |
+
var column = 1;
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Update lineno and column based on `str`.
|
349 |
+
*/
|
350 |
+
|
351 |
+
function updatePosition(str) {
|
352 |
+
var lines = str.match(/\n/g);
|
353 |
+
if (lines) lineno += lines.length;
|
354 |
+
var i = str.lastIndexOf('\n');
|
355 |
+
column = ~i ? str.length - i : column + str.length;
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Mark position and patch `node.position`.
|
360 |
+
*/
|
361 |
+
|
362 |
+
function position() {
|
363 |
+
var start = { line: lineno, column: column };
|
364 |
+
return function(node){
|
365 |
+
node.position = new Position(start);
|
366 |
+
whitespace();
|
367 |
+
return node;
|
368 |
+
};
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Store position information for a node
|
373 |
+
*/
|
374 |
+
|
375 |
+
function Position(start) {
|
376 |
+
this.start = start;
|
377 |
+
this.end = { line: lineno, column: column };
|
378 |
+
this.source = options.source;
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Non-enumerable source string
|
383 |
+
*/
|
384 |
+
|
385 |
+
Position.prototype.content = css;
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Error `msg`.
|
389 |
+
*/
|
390 |
+
|
391 |
+
var errorsList = [];
|
392 |
+
|
393 |
+
function error(msg) {
|
394 |
+
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
395 |
+
err.reason = msg;
|
396 |
+
err.filename = options.source;
|
397 |
+
err.line = lineno;
|
398 |
+
err.column = column;
|
399 |
+
err.source = css;
|
400 |
+
|
401 |
+
if (options.silent) {
|
402 |
+
errorsList.push(err);
|
403 |
+
} else {
|
404 |
+
throw err;
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Parse stylesheet.
|
410 |
+
*/
|
411 |
+
|
412 |
+
function stylesheet() {
|
413 |
+
var rulesList = rules();
|
414 |
+
|
415 |
+
return {
|
416 |
+
type: 'stylesheet',
|
417 |
+
stylesheet: {
|
418 |
+
rules: rulesList,
|
419 |
+
parsingErrors: errorsList
|
420 |
+
}
|
421 |
+
};
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Opening brace.
|
426 |
+
*/
|
427 |
+
|
428 |
+
function open() {
|
429 |
+
return match(/^{\s*/);
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* Closing brace.
|
434 |
+
*/
|
435 |
+
|
436 |
+
function close() {
|
437 |
+
return match(/^}/);
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* Parse ruleset.
|
442 |
+
*/
|
443 |
+
|
444 |
+
function rules() {
|
445 |
+
var node;
|
446 |
+
var rules = [];
|
447 |
+
whitespace();
|
448 |
+
comments(rules);
|
449 |
+
while (css.length && css.charAt(0) != '}' && (node = atrule() || rule())) {
|
450 |
+
if (node !== false) {
|
451 |
+
rules.push(node);
|
452 |
+
comments(rules);
|
453 |
+
}
|
454 |
+
}
|
455 |
+
return rules;
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Match `re` and return captures.
|
460 |
+
*/
|
461 |
+
|
462 |
+
function match(re) {
|
463 |
+
var m = re.exec(css);
|
464 |
+
if (!m) return;
|
465 |
+
var str = m[0];
|
466 |
+
updatePosition(str);
|
467 |
+
css = css.slice(str.length);
|
468 |
+
return m;
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Parse whitespace.
|
473 |
+
*/
|
474 |
+
|
475 |
+
function whitespace() {
|
476 |
+
match(/^\s*/);
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Parse comments;
|
481 |
+
*/
|
482 |
+
|
483 |
+
function comments(rules) {
|
484 |
+
var c;
|
485 |
+
rules = rules || [];
|
486 |
+
while (c = comment()) {
|
487 |
+
if (c !== false) {
|
488 |
+
rules.push(c);
|
489 |
+
}
|
490 |
+
}
|
491 |
+
return rules;
|
492 |
+
}
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Parse comment.
|
496 |
+
*/
|
497 |
+
|
498 |
+
function comment() {
|
499 |
+
var pos = position();
|
500 |
+
if ('/' != css.charAt(0) || '*' != css.charAt(1)) return;
|
501 |
+
|
502 |
+
var i = 2;
|
503 |
+
while ("" != css.charAt(i) && ('*' != css.charAt(i) || '/' != css.charAt(i + 1))) ++i;
|
504 |
+
i += 2;
|
505 |
+
|
506 |
+
if ("" === css.charAt(i-1)) {
|
507 |
+
return error('End of comment missing');
|
508 |
+
}
|
509 |
+
|
510 |
+
var str = css.slice(2, i - 2);
|
511 |
+
column += 2;
|
512 |
+
updatePosition(str);
|
513 |
+
css = css.slice(i);
|
514 |
+
column += 2;
|
515 |
+
|
516 |
+
return pos({
|
517 |
+
type: 'comment',
|
518 |
+
comment: str
|
519 |
+
});
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Parse selector.
|
524 |
+
*/
|
525 |
+
|
526 |
+
function selector() {
|
527 |
+
var m = match(/^([^{]+)/);
|
528 |
+
if (!m) return;
|
529 |
+
/* @fix Remove all comments from selectors
|
530 |
+
* http://ostermiller.org/findcomment.html */
|
531 |
+
return trim(m[0])
|
532 |
+
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
533 |
+
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m) {
|
534 |
+
return m.replace(/,/g, '\u200C');
|
535 |
+
})
|
536 |
+
.split(/\s*(?![^(]*\)),\s*/)
|
537 |
+
.map(function(s) {
|
538 |
+
return s.replace(/\u200C/g, ',');
|
539 |
+
});
|
540 |
+
}
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Parse declaration.
|
544 |
+
*/
|
545 |
+
|
546 |
+
function declaration() {
|
547 |
+
var pos = position();
|
548 |
+
|
549 |
+
// prop
|
550 |
+
var prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
551 |
+
if (!prop) return;
|
552 |
+
prop = trim(prop[0]);
|
553 |
+
|
554 |
+
// :
|
555 |
+
if (!match(/^:\s*/)) return error("property missing ':'");
|
556 |
+
|
557 |
+
// val
|
558 |
+
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
559 |
+
|
560 |
+
var ret = pos({
|
561 |
+
type: 'declaration',
|
562 |
+
property: prop.replace(commentre, ''),
|
563 |
+
value: val ? trim(val[0]).replace(commentre, '') : ''
|
564 |
+
});
|
565 |
+
|
566 |
+
// ;
|
567 |
+
match(/^[;\s]*/);
|
568 |
+
|
569 |
+
return ret;
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* Parse declarations.
|
574 |
+
*/
|
575 |
+
|
576 |
+
function declarations() {
|
577 |
+
var decls = [];
|
578 |
+
|
579 |
+
if (!open()) return error("missing '{'");
|
580 |
+
comments(decls);
|
581 |
+
|
582 |
+
// declarations
|
583 |
+
var decl;
|
584 |
+
while (decl = declaration()) {
|
585 |
+
if (decl !== false) {
|
586 |
+
decls.push(decl);
|
587 |
+
comments(decls);
|
588 |
+
}
|
589 |
+
}
|
590 |
+
|
591 |
+
if (!close()) return error("missing '}'");
|
592 |
+
return decls;
|
593 |
+
}
|
594 |
+
|
595 |
+
/**
|
596 |
+
* Parse keyframe.
|
597 |
+
*/
|
598 |
+
|
599 |
+
function keyframe() {
|
600 |
+
var m;
|
601 |
+
var vals = [];
|
602 |
+
var pos = position();
|
603 |
+
|
604 |
+
while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
|
605 |
+
vals.push(m[1]);
|
606 |
+
match(/^,\s*/);
|
607 |
+
}
|
608 |
+
|
609 |
+
if (!vals.length) return;
|
610 |
+
|
611 |
+
return pos({
|
612 |
+
type: 'keyframe',
|
613 |
+
values: vals,
|
614 |
+
declarations: declarations()
|
615 |
+
});
|
616 |
+
}
|
617 |
+
|
618 |
+
/**
|
619 |
+
* Parse keyframes.
|
620 |
+
*/
|
621 |
+
|
622 |
+
function atkeyframes() {
|
623 |
+
var pos = position();
|
624 |
+
var m = match(/^@([-\w]+)?keyframes\s*/);
|
625 |
+
|
626 |
+
if (!m) return;
|
627 |
+
var vendor = m[1];
|
628 |
+
|
629 |
+
// identifier
|
630 |
+
var m = match(/^([-\w]+)\s*/);
|
631 |
+
if (!m) return error("@keyframes missing name");
|
632 |
+
var name = m[1];
|
633 |
+
|
634 |
+
if (!open()) return error("@keyframes missing '{'");
|
635 |
+
|
636 |
+
var frame;
|
637 |
+
var frames = comments();
|
638 |
+
while (frame = keyframe()) {
|
639 |
+
frames.push(frame);
|
640 |
+
frames = frames.concat(comments());
|
641 |
+
}
|
642 |
+
|
643 |
+
if (!close()) return error("@keyframes missing '}'");
|
644 |
+
|
645 |
+
return pos({
|
646 |
+
type: 'keyframes',
|
647 |
+
name: name,
|
648 |
+
vendor: vendor,
|
649 |
+
keyframes: frames
|
650 |
+
});
|
651 |
+
}
|
652 |
+
|
653 |
+
/**
|
654 |
+
* Parse supports.
|
655 |
+
*/
|
656 |
+
|
657 |
+
function atsupports() {
|
658 |
+
var pos = position();
|
659 |
+
var m = match(/^@supports *([^{]+)/);
|
660 |
+
|
661 |
+
if (!m) return;
|
662 |
+
var supports = trim(m[1]);
|
663 |
+
|
664 |
+
if (!open()) return error("@supports missing '{'");
|
665 |
+
|
666 |
+
var style = comments().concat(rules());
|
667 |
+
|
668 |
+
if (!close()) return error("@supports missing '}'");
|
669 |
+
|
670 |
+
return pos({
|
671 |
+
type: 'supports',
|
672 |
+
supports: supports,
|
673 |
+
rules: style
|
674 |
+
});
|
675 |
+
}
|
676 |
+
|
677 |
+
/**
|
678 |
+
* Parse host.
|
679 |
+
*/
|
680 |
+
|
681 |
+
function athost() {
|
682 |
+
var pos = position();
|
683 |
+
var m = match(/^@host\s*/);
|
684 |
+
|
685 |
+
if (!m) return;
|
686 |
+
|
687 |
+
if (!open()) return error("@host missing '{'");
|
688 |
+
|
689 |
+
var style = comments().concat(rules());
|
690 |
+
|
691 |
+
if (!close()) return error("@host missing '}'");
|
692 |
+
|
693 |
+
return pos({
|
694 |
+
type: 'host',
|
695 |
+
rules: style
|
696 |
+
});
|
697 |
+
}
|
698 |
+
|
699 |
+
/**
|
700 |
+
* Parse media.
|
701 |
+
*/
|
702 |
+
|
703 |
+
function atmedia() {
|
704 |
+
var pos = position();
|
705 |
+
var m = match(/^@media *([^{]+)/);
|
706 |
+
|
707 |
+
if (!m) return;
|
708 |
+
var media = trim(m[1]);
|
709 |
+
|
710 |
+
if (!open()) return error("@media missing '{'");
|
711 |
+
|
712 |
+
var style = comments().concat(rules());
|
713 |
+
|
714 |
+
if (!close()) return error("@media missing '}'");
|
715 |
+
|
716 |
+
return pos({
|
717 |
+
type: 'media',
|
718 |
+
media: media,
|
719 |
+
rules: style
|
720 |
+
});
|
721 |
+
}
|
722 |
+
|
723 |
+
|
724 |
+
/**
|
725 |
+
* Parse custom-media.
|
726 |
+
*/
|
727 |
+
|
728 |
+
function atcustommedia() {
|
729 |
+
var pos = position();
|
730 |
+
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
731 |
+
if (!m) return;
|
732 |
+
|
733 |
+
return pos({
|
734 |
+
type: 'custom-media',
|
735 |
+
name: trim(m[1]),
|
736 |
+
media: trim(m[2])
|
737 |
+
});
|
738 |
+
}
|
739 |
+
|
740 |
+
/**
|
741 |
+
* Parse paged media.
|
742 |
+
*/
|
743 |
+
|
744 |
+
function atpage() {
|
745 |
+
var pos = position();
|
746 |
+
var m = match(/^@page */);
|
747 |
+
if (!m) return;
|
748 |
+
|
749 |
+
var sel = selector() || [];
|
750 |
+
|
751 |
+
if (!open()) return error("@page missing '{'");
|
752 |
+
var decls = comments();
|
753 |
+
|
754 |
+
// declarations
|
755 |
+
var decl;
|
756 |
+
while (decl = declaration()) {
|
757 |
+
decls.push(decl);
|
758 |
+
decls = decls.concat(comments());
|
759 |
+
}
|
760 |
+
|
761 |
+
if (!close()) return error("@page missing '}'");
|
762 |
+
|
763 |
+
return pos({
|
764 |
+
type: 'page',
|
765 |
+
selectors: sel,
|
766 |
+
declarations: decls
|
767 |
+
});
|
768 |
+
}
|
769 |
+
|
770 |
+
/**
|
771 |
+
* Parse document.
|
772 |
+
*/
|
773 |
+
|
774 |
+
function atdocument() {
|
775 |
+
var pos = position();
|
776 |
+
var m = match(/^@([-\w]+)?document *([^{]+)/);
|
777 |
+
if (!m) return;
|
778 |
+
|
779 |
+
var vendor = trim(m[1]);
|
780 |
+
var doc = trim(m[2]);
|
781 |
+
|
782 |
+
if (!open()) return error("@document missing '{'");
|
783 |
+
|
784 |
+
var style = comments().concat(rules());
|
785 |
+
|
786 |
+
if (!close()) return error("@document missing '}'");
|
787 |
+
|
788 |
+
return pos({
|
789 |
+
type: 'document',
|
790 |
+
document: doc,
|
791 |
+
vendor: vendor,
|
792 |
+
rules: style
|
793 |
+
});
|
794 |
+
}
|
795 |
+
|
796 |
+
/**
|
797 |
+
* Parse font-face.
|
798 |
+
*/
|
799 |
+
|
800 |
+
function atfontface() {
|
801 |
+
var pos = position();
|
802 |
+
var m = match(/^@font-face\s*/);
|
803 |
+
if (!m) return;
|
804 |
+
|
805 |
+
if (!open()) return error("@font-face missing '{'");
|
806 |
+
var decls = comments();
|
807 |
+
|
808 |
+
// declarations
|
809 |
+
var decl;
|
810 |
+
while (decl = declaration()) {
|
811 |
+
decls.push(decl);
|
812 |
+
decls = decls.concat(comments());
|
813 |
+
}
|
814 |
+
|
815 |
+
if (!close()) return error("@font-face missing '}'");
|
816 |
+
|
817 |
+
return pos({
|
818 |
+
type: 'font-face',
|
819 |
+
declarations: decls
|
820 |
+
});
|
821 |
+
}
|
822 |
+
|
823 |
+
/**
|
824 |
+
* Parse import
|
825 |
+
*/
|
826 |
+
|
827 |
+
var atimport = _compileAtrule('import');
|
828 |
+
|
829 |
+
/**
|
830 |
+
* Parse charset
|
831 |
+
*/
|
832 |
+
|
833 |
+
var atcharset = _compileAtrule('charset');
|
834 |
+
|
835 |
+
/**
|
836 |
+
* Parse namespace
|
837 |
+
*/
|
838 |
+
|
839 |
+
var atnamespace = _compileAtrule('namespace');
|
840 |
+
|
841 |
+
/**
|
842 |
+
* Parse non-block at-rules
|
843 |
+
*/
|
844 |
+
|
845 |
+
|
846 |
+
function _compileAtrule(name) {
|
847 |
+
var re = new RegExp('^@' + name + '\\s*([^;]+);');
|
848 |
+
return function() {
|
849 |
+
var pos = position();
|
850 |
+
var m = match(re);
|
851 |
+
if (!m) return;
|
852 |
+
var ret = { type: name };
|
853 |
+
ret[name] = m[1].trim();
|
854 |
+
return pos(ret);
|
855 |
+
}
|
856 |
+
}
|
857 |
+
|
858 |
+
/**
|
859 |
+
* Parse at rule.
|
860 |
+
*/
|
861 |
+
|
862 |
+
function atrule() {
|
863 |
+
if (css[0] != '@') return;
|
864 |
+
|
865 |
+
return atkeyframes()
|
866 |
+
|| atmedia()
|
867 |
+
|| atcustommedia()
|
868 |
+
|| atsupports()
|
869 |
+
|| atimport()
|
870 |
+
|| atcharset()
|
871 |
+
|| atnamespace()
|
872 |
+
|| atdocument()
|
873 |
+
|| atpage()
|
874 |
+
|| athost()
|
875 |
+
|| atfontface();
|
876 |
+
}
|
877 |
+
|
878 |
+
/**
|
879 |
+
* Parse rule.
|
880 |
+
*/
|
881 |
+
|
882 |
+
function rule() {
|
883 |
+
var pos = position();
|
884 |
+
var sel = selector();
|
885 |
+
|
886 |
+
if (!sel) return error('selector missing');
|
887 |
+
comments();
|
888 |
+
|
889 |
+
return pos({
|
890 |
+
type: 'rule',
|
891 |
+
selectors: sel,
|
892 |
+
declarations: declarations()
|
893 |
+
});
|
894 |
+
}
|
895 |
+
|
896 |
+
return addParent(stylesheet());
|
897 |
+
};
|
898 |
+
|
899 |
+
/**
|
900 |
+
* Trim `str`.
|
901 |
+
*/
|
902 |
+
|
903 |
+
function trim(str) {
|
904 |
+
return str ? str.replace(/^\s+|\s+$/g, '') : '';
|
905 |
+
}
|
906 |
+
|
907 |
+
/**
|
908 |
+
* Adds non-enumerable parent node reference to each node.
|
909 |
+
*/
|
910 |
+
|
911 |
+
function addParent(obj, parent) {
|
912 |
+
var isNode = obj && typeof obj.type === 'string';
|
913 |
+
var childParent = isNode ? obj : parent;
|
914 |
+
|
915 |
+
for (var k in obj) {
|
916 |
+
var value = obj[k];
|
917 |
+
if (Array.isArray(value)) {
|
918 |
+
value.forEach(function(v) { addParent(v, childParent); });
|
919 |
+
} else if (value && typeof value === 'object') {
|
920 |
+
addParent(value, childParent);
|
921 |
+
}
|
922 |
+
}
|
923 |
+
|
924 |
+
if (isNode) {
|
925 |
+
Object.defineProperty(obj, 'parent', {
|
926 |
+
configurable: true,
|
927 |
+
writable: true,
|
928 |
+
enumerable: false,
|
929 |
+
value: parent || null
|
930 |
+
});
|
931 |
+
}
|
932 |
+
|
933 |
+
return obj;
|
934 |
+
}
|
935 |
+
|
936 |
+
},{}],7:[function(require,module,exports){
|
937 |
+
|
938 |
+
/**
|
939 |
+
* Expose `Compiler`.
|
940 |
+
*/
|
941 |
+
|
942 |
+
module.exports = Compiler;
|
943 |
+
|
944 |
+
/**
|
945 |
+
* Initialize a compiler.
|
946 |
+
*
|
947 |
+
* @param {Type} name
|
948 |
+
* @return {Type}
|
949 |
+
* @api public
|
950 |
+
*/
|
951 |
+
|
952 |
+
function Compiler(opts) {
|
953 |
+
this.options = opts || {};
|
954 |
+
}
|
955 |
+
|
956 |
+
/**
|
957 |
+
* Emit `str`
|
958 |
+
*/
|
959 |
+
|
960 |
+
Compiler.prototype.emit = function(str) {
|
961 |
+
return str;
|
962 |
+
};
|
963 |
+
|
964 |
+
/**
|
965 |
+
* Visit `node`.
|
966 |
+
*/
|
967 |
+
|
968 |
+
Compiler.prototype.visit = function(node){
|
969 |
+
return this[node.type](node);
|
970 |
+
};
|
971 |
+
|
972 |
+
/**
|
973 |
+
* Map visit over array of `nodes`, optionally using a `delim`
|
974 |
+
*/
|
975 |
+
|
976 |
+
Compiler.prototype.mapVisit = function(nodes, delim){
|
977 |
+
var buf = '';
|
978 |
+
delim = delim || '';
|
979 |
+
|
980 |
+
for (var i = 0, length = nodes.length; i < length; i++) {
|
981 |
+
buf += this.visit(nodes[i]);
|
982 |
+
if (delim && i < length - 1) buf += this.emit(delim);
|
983 |
+
}
|
984 |
+
|
985 |
+
return buf;
|
986 |
+
};
|
987 |
+
|
988 |
+
},{}],8:[function(require,module,exports){
|
989 |
+
|
990 |
+
/**
|
991 |
+
* Module dependencies.
|
992 |
+
*/
|
993 |
+
|
994 |
+
var Base = require('./compiler');
|
995 |
+
var inherits = require('inherits');
|
996 |
+
|
997 |
+
/**
|
998 |
+
* Expose compiler.
|
999 |
+
*/
|
1000 |
+
|
1001 |
+
module.exports = Compiler;
|
1002 |
+
|
1003 |
+
/**
|
1004 |
+
* Initialize a new `Compiler`.
|
1005 |
+
*/
|
1006 |
+
|
1007 |
+
function Compiler(options) {
|
1008 |
+
Base.call(this, options);
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
/**
|
1012 |
+
* Inherit from `Base.prototype`.
|
1013 |
+
*/
|
1014 |
+
|
1015 |
+
inherits(Compiler, Base);
|
1016 |
+
|
1017 |
+
/**
|
1018 |
+
* Compile `node`.
|
1019 |
+
*/
|
1020 |
+
|
1021 |
+
Compiler.prototype.compile = function(node){
|
1022 |
+
return node.stylesheet
|
1023 |
+
.rules.map(this.visit, this)
|
1024 |
+
.join('');
|
1025 |
+
};
|
1026 |
+
|
1027 |
+
/**
|
1028 |
+
* Visit comment node.
|
1029 |
+
*/
|
1030 |
+
|
1031 |
+
Compiler.prototype.comment = function(node){
|
1032 |
+
return this.emit('', node.position);
|
1033 |
+
};
|
1034 |
+
|
1035 |
+
/**
|
1036 |
+
* Visit import node.
|
1037 |
+
*/
|
1038 |
+
|
1039 |
+
Compiler.prototype.import = function(node){
|
1040 |
+
return this.emit('@import ' + node.import + ';', node.position);
|
1041 |
+
};
|
1042 |
+
|
1043 |
+
/**
|
1044 |
+
* Visit media node.
|
1045 |
+
*/
|
1046 |
+
|
1047 |
+
Compiler.prototype.media = function(node){
|
1048 |
+
return this.emit('@media ' + node.media, node.position)
|
1049 |
+
+ this.emit('{')
|
1050 |
+
+ this.mapVisit(node.rules)
|
1051 |
+
+ this.emit('}');
|
1052 |
+
};
|
1053 |
+
|
1054 |
+
/**
|
1055 |
+
* Visit document node.
|
1056 |
+
*/
|
1057 |
+
|
1058 |
+
Compiler.prototype.document = function(node){
|
1059 |
+
var doc = '@' + (node.vendor || '') + 'document ' + node.document;
|
1060 |
+
|
1061 |
+
return this.emit(doc, node.position)
|
1062 |
+
+ this.emit('{')
|
1063 |
+
+ this.mapVisit(node.rules)
|
1064 |
+
+ this.emit('}');
|
1065 |
+
};
|
1066 |
+
|
1067 |
+
/**
|
1068 |
+
* Visit charset node.
|
1069 |
+
*/
|
1070 |
+
|
1071 |
+
Compiler.prototype.charset = function(node){
|
1072 |
+
return this.emit('@charset ' + node.charset + ';', node.position);
|
1073 |
+
};
|
1074 |
+
|
1075 |
+
/**
|
1076 |
+
* Visit namespace node.
|
1077 |
+
*/
|
1078 |
+
|
1079 |
+
Compiler.prototype.namespace = function(node){
|
1080 |
+
return this.emit('@namespace ' + node.namespace + ';', node.position);
|
1081 |
+
};
|
1082 |
+
|
1083 |
+
/**
|
1084 |
+
* Visit supports node.
|
1085 |
+
*/
|
1086 |
+
|
1087 |
+
Compiler.prototype.supports = function(node){
|
1088 |
+
return this.emit('@supports ' + node.supports, node.position)
|
1089 |
+
+ this.emit('{')
|
1090 |
+
+ this.mapVisit(node.rules)
|
1091 |
+
+ this.emit('}');
|
1092 |
+
};
|
1093 |
+
|
1094 |
+
/**
|
1095 |
+
* Visit keyframes node.
|
1096 |
+
*/
|
1097 |
+
|
1098 |
+
Compiler.prototype.keyframes = function(node){
|
1099 |
+
return this.emit('@'
|
1100 |
+
+ (node.vendor || '')
|
1101 |
+
+ 'keyframes '
|
1102 |
+
+ node.name, node.position)
|
1103 |
+
+ this.emit('{')
|
1104 |
+
+ this.mapVisit(node.keyframes)
|
1105 |
+
+ this.emit('}');
|
1106 |
+
};
|
1107 |
+
|
1108 |
+
/**
|
1109 |
+
* Visit keyframe node.
|
1110 |
+
*/
|
1111 |
+
|
1112 |
+
Compiler.prototype.keyframe = function(node){
|
1113 |
+
var decls = node.declarations;
|
1114 |
+
|
1115 |
+
return this.emit(node.values.join(','), node.position)
|
1116 |
+
+ this.emit('{')
|
1117 |
+
+ this.mapVisit(decls)
|
1118 |
+
+ this.emit('}');
|
1119 |
+
};
|
1120 |
+
|
1121 |
+
/**
|
1122 |
+
* Visit page node.
|
1123 |
+
*/
|
1124 |
+
|
1125 |
+
Compiler.prototype.page = function(node){
|
1126 |
+
var sel = node.selectors.length
|
1127 |
+
? node.selectors.join(', ')
|
1128 |
+
: '';
|
1129 |
+
|
1130 |
+
return this.emit('@page ' + sel, node.position)
|
1131 |
+
+ this.emit('{')
|
1132 |
+
+ this.mapVisit(node.declarations)
|
1133 |
+
+ this.emit('}');
|
1134 |
+
};
|
1135 |
+
|
1136 |
+
/**
|
1137 |
+
* Visit font-face node.
|
1138 |
+
*/
|
1139 |
+
|
1140 |
+
Compiler.prototype['font-face'] = function(node){
|
1141 |
+
return this.emit('@font-face', node.position)
|
1142 |
+
+ this.emit('{')
|
1143 |
+
+ this.mapVisit(node.declarations)
|
1144 |
+
+ this.emit('}');
|
1145 |
+
};
|
1146 |
+
|
1147 |
+
/**
|
1148 |
+
* Visit host node.
|
1149 |
+
*/
|
1150 |
+
|
1151 |
+
Compiler.prototype.host = function(node){
|
1152 |
+
return this.emit('@host', node.position)
|
1153 |
+
+ this.emit('{')
|
1154 |
+
+ this.mapVisit(node.rules)
|
1155 |
+
+ this.emit('}');
|
1156 |
+
};
|
1157 |
+
|
1158 |
+
/**
|
1159 |
+
* Visit custom-media node.
|
1160 |
+
*/
|
1161 |
+
|
1162 |
+
Compiler.prototype['custom-media'] = function(node){
|
1163 |
+
return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
|
1164 |
+
};
|
1165 |
+
|
1166 |
+
/**
|
1167 |
+
* Visit rule node.
|
1168 |
+
*/
|
1169 |
+
|
1170 |
+
Compiler.prototype.rule = function(node){
|
1171 |
+
var decls = node.declarations;
|
1172 |
+
if (!decls.length) return '';
|
1173 |
+
|
1174 |
+
return this.emit(node.selectors.join(','), node.position)
|
1175 |
+
+ this.emit('{')
|
1176 |
+
+ this.mapVisit(decls)
|
1177 |
+
+ this.emit('}');
|
1178 |
+
};
|
1179 |
+
|
1180 |
+
/**
|
1181 |
+
* Visit declaration node.
|
1182 |
+
*/
|
1183 |
+
|
1184 |
+
Compiler.prototype.declaration = function(node){
|
1185 |
+
return this.emit(node.property + ':' + node.value, node.position) + this.emit(';');
|
1186 |
+
};
|
1187 |
+
|
1188 |
+
|
1189 |
+
},{"./compiler":7,"inherits":12}],9:[function(require,module,exports){
|
1190 |
+
|
1191 |
+
/**
|
1192 |
+
* Module dependencies.
|
1193 |
+
*/
|
1194 |
+
|
1195 |
+
var Base = require('./compiler');
|
1196 |
+
var inherits = require('inherits');
|
1197 |
+
|
1198 |
+
/**
|
1199 |
+
* Expose compiler.
|
1200 |
+
*/
|
1201 |
+
|
1202 |
+
module.exports = Compiler;
|
1203 |
+
|
1204 |
+
/**
|
1205 |
+
* Initialize a new `Compiler`.
|
1206 |
+
*/
|
1207 |
+
|
1208 |
+
function Compiler(options) {
|
1209 |
+
options = options || {};
|
1210 |
+
Base.call(this, options);
|
1211 |
+
this.indentation = options.indent;
|
1212 |
+
}
|
1213 |
+
|
1214 |
+
/**
|
1215 |
+
* Inherit from `Base.prototype`.
|
1216 |
+
*/
|
1217 |
+
|
1218 |
+
inherits(Compiler, Base);
|
1219 |
+
|
1220 |
+
/**
|
1221 |
+
* Compile `node`.
|
1222 |
+
*/
|
1223 |
+
|
1224 |
+
Compiler.prototype.compile = function(node){
|
1225 |
+
return this.stylesheet(node);
|
1226 |
+
};
|
1227 |
+
|
1228 |
+
/**
|
1229 |
+
* Visit stylesheet node.
|
1230 |
+
*/
|
1231 |
+
|
1232 |
+
Compiler.prototype.stylesheet = function(node){
|
1233 |
+
return this.mapVisit(node.stylesheet.rules, '\n\n');
|
1234 |
+
};
|
1235 |
+
|
1236 |
+
/**
|
1237 |
+
* Visit comment node.
|
1238 |
+
*/
|
1239 |
+
|
1240 |
+
Compiler.prototype.comment = function(node){
|
1241 |
+
return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);
|
1242 |
+
};
|
1243 |
+
|
1244 |
+
/**
|
1245 |
+
* Visit import node.
|
1246 |
+
*/
|
1247 |
+
|
1248 |
+
Compiler.prototype.import = function(node){
|
1249 |
+
return this.emit('@import ' + node.import + ';', node.position);
|
1250 |
+
};
|
1251 |
+
|
1252 |
+
/**
|
1253 |
+
* Visit media node.
|
1254 |
+
*/
|
1255 |
+
|
1256 |
+
Compiler.prototype.media = function(node){
|
1257 |
+
return this.emit('@media ' + node.media, node.position)
|
1258 |
+
+ this.emit(
|
1259 |
+
' {\n'
|
1260 |
+
+ this.indent(1))
|
1261 |
+
+ this.mapVisit(node.rules, '\n\n')
|
1262 |
+
+ this.emit(
|
1263 |
+
this.indent(-1)
|
1264 |
+
+ '\n}');
|
1265 |
+
};
|
1266 |
+
|
1267 |
+
/**
|
1268 |
+
* Visit document node.
|
1269 |
+
*/
|
1270 |
+
|
1271 |
+
Compiler.prototype.document = function(node){
|
1272 |
+
var doc = '@' + (node.vendor || '') + 'document ' + node.document;
|
1273 |
+
|
1274 |
+
return this.emit(doc, node.position)
|
1275 |
+
+ this.emit(
|
1276 |
+
' '
|
1277 |
+
+ ' {\n'
|
1278 |
+
+ this.indent(1))
|
1279 |
+
+ this.mapVisit(node.rules, '\n\n')
|
1280 |
+
+ this.emit(
|
1281 |
+
this.indent(-1)
|
1282 |
+
+ '\n}');
|
1283 |
+
};
|
1284 |
+
|
1285 |
+
/**
|
1286 |
+
* Visit charset node.
|
1287 |
+
*/
|
1288 |
+
|
1289 |
+
Compiler.prototype.charset = function(node){
|
1290 |
+
return this.emit('@charset ' + node.charset + ';', node.position);
|
1291 |
+
};
|
1292 |
+
|
1293 |
+
/**
|
1294 |
+
* Visit namespace node.
|
1295 |
+
*/
|
1296 |
+
|
1297 |
+
Compiler.prototype.namespace = function(node){
|
1298 |
+
return this.emit('@namespace ' + node.namespace + ';', node.position);
|
1299 |
+
};
|
1300 |
+
|
1301 |
+
/**
|
1302 |
+
* Visit supports node.
|
1303 |
+
*/
|
1304 |
+
|
1305 |
+
Compiler.prototype.supports = function(node){
|
1306 |
+
return this.emit('@supports ' + node.supports, node.position)
|
1307 |
+
+ this.emit(
|
1308 |
+
' {\n'
|
1309 |
+
+ this.indent(1))
|
1310 |
+
+ this.mapVisit(node.rules, '\n\n')
|
1311 |
+
+ this.emit(
|
1312 |
+
this.indent(-1)
|
1313 |
+
+ '\n}');
|
1314 |
+
};
|
1315 |
+
|
1316 |
+
/**
|
1317 |
+
* Visit keyframes node.
|
1318 |
+
*/
|
1319 |
+
|
1320 |
+
Compiler.prototype.keyframes = function(node){
|
1321 |
+
return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position)
|
1322 |
+
+ this.emit(
|
1323 |
+
' {\n'
|
1324 |
+
+ this.indent(1))
|
1325 |
+
+ this.mapVisit(node.keyframes, '\n')
|
1326 |
+
+ this.emit(
|
1327 |
+
this.indent(-1)
|
1328 |
+
+ '}');
|
1329 |
+
};
|
1330 |
+
|
1331 |
+
/**
|
1332 |
+
* Visit keyframe node.
|
1333 |
+
*/
|
1334 |
+
|
1335 |
+
Compiler.prototype.keyframe = function(node){
|
1336 |
+
var decls = node.declarations;
|
1337 |
+
|
1338 |
+
return this.emit(this.indent())
|
1339 |
+
+ this.emit(node.values.join(', '), node.position)
|
1340 |
+
+ this.emit(
|
1341 |
+
' {\n'
|
1342 |
+
+ this.indent(1))
|
1343 |
+
+ this.mapVisit(decls, '\n')
|
1344 |
+
+ this.emit(
|
1345 |
+
this.indent(-1)
|
1346 |
+
+ '\n'
|
1347 |
+
+ this.indent() + '}\n');
|
1348 |
+
};
|
1349 |
+
|
1350 |
+
/**
|
1351 |
+
* Visit page node.
|
1352 |
+
*/
|
1353 |
+
|
1354 |
+
Compiler.prototype.page = function(node){
|
1355 |
+
var sel = node.selectors.length
|
1356 |
+
? node.selectors.join(', ') + ' '
|
1357 |
+
: '';
|
1358 |
+
|
1359 |
+
return this.emit('@page ' + sel, node.position)
|
1360 |
+
+ this.emit('{\n')
|
1361 |
+
+ this.emit(this.indent(1))
|
1362 |
+
+ this.mapVisit(node.declarations, '\n')
|
1363 |
+
+ this.emit(this.indent(-1))
|
1364 |
+
+ this.emit('\n}');
|
1365 |
+
};
|
1366 |
+
|
1367 |
+
/**
|
1368 |
+
* Visit font-face node.
|
1369 |
+
*/
|
1370 |
+
|
1371 |
+
Compiler.prototype['font-face'] = function(node){
|
1372 |
+
return this.emit('@font-face ', node.position)
|
1373 |
+
+ this.emit('{\n')
|
1374 |
+
+ this.emit(this.indent(1))
|
1375 |
+
+ this.mapVisit(node.declarations, '\n')
|
1376 |
+
+ this.emit(this.indent(-1))
|
1377 |
+
+ this.emit('\n}');
|
1378 |
+
};
|
1379 |
+
|
1380 |
+
/**
|
1381 |
+
* Visit host node.
|
1382 |
+
*/
|
1383 |
+
|
1384 |
+
Compiler.prototype.host = function(node){
|
1385 |
+
return this.emit('@host', node.position)
|
1386 |
+
+ this.emit(
|
1387 |
+
' {\n'
|
1388 |
+
+ this.indent(1))
|
1389 |
+
+ this.mapVisit(node.rules, '\n\n')
|
1390 |
+
+ this.emit(
|
1391 |
+
this.indent(-1)
|
1392 |
+
+ '\n}');
|
1393 |
+
};
|
1394 |
+
|
1395 |
+
/**
|
1396 |
+
* Visit custom-media node.
|
1397 |
+
*/
|
1398 |
+
|
1399 |
+
Compiler.prototype['custom-media'] = function(node){
|
1400 |
+
return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
|
1401 |
+
};
|
1402 |
+
|
1403 |
+
/**
|
1404 |
+
* Visit rule node.
|
1405 |
+
*/
|
1406 |
+
|
1407 |
+
Compiler.prototype.rule = function(node){
|
1408 |
+
var indent = this.indent();
|
1409 |
+
var decls = node.declarations;
|
1410 |
+
if (!decls.length) return '';
|
1411 |
+
|
1412 |
+
return this.emit(node.selectors.map(function(s){ return indent + s }).join(',\n'), node.position)
|
1413 |
+
+ this.emit(' {\n')
|
1414 |
+
+ this.emit(this.indent(1))
|
1415 |
+
+ this.mapVisit(decls, '\n')
|
1416 |
+
+ this.emit(this.indent(-1))
|
1417 |
+
+ this.emit('\n' + this.indent() + '}');
|
1418 |
+
};
|
1419 |
+
|
1420 |
+
/**
|
1421 |
+
* Visit declaration node.
|
1422 |
+
*/
|
1423 |
+
|
1424 |
+
Compiler.prototype.declaration = function(node){
|
1425 |
+
return this.emit(this.indent())
|
1426 |
+
+ this.emit(node.property + ': ' + node.value, node.position)
|
1427 |
+
+ this.emit(';');
|
1428 |
+
};
|
1429 |
+
|
1430 |
+
/**
|
1431 |
+
* Increase, decrease or return current indentation.
|
1432 |
+
*/
|
1433 |
+
|
1434 |
+
Compiler.prototype.indent = function(level) {
|
1435 |
+
this.level = this.level || 1;
|
1436 |
+
|
1437 |
+
if (null != level) {
|
1438 |
+
this.level += level;
|
1439 |
+
return '';
|
1440 |
+
}
|
1441 |
+
|
1442 |
+
return Array(this.level).join(this.indentation || ' ');
|
1443 |
+
};
|
1444 |
+
|
1445 |
+
},{"./compiler":7,"inherits":12}],10:[function(require,module,exports){
|
1446 |
+
|
1447 |
+
/**
|
1448 |
+
* Module dependencies.
|
1449 |
+
*/
|
1450 |
+
|
1451 |
+
var Compressed = require('./compress');
|
1452 |
+
var Identity = require('./identity');
|
1453 |
+
|
1454 |
+
/**
|
1455 |
+
* Stringfy the given AST `node`.
|
1456 |
+
*
|
1457 |
+
* Options:
|
1458 |
+
*
|
1459 |
+
* - `compress` space-optimized output
|
1460 |
+
* - `sourcemap` return an object with `.code` and `.map`
|
1461 |
+
*
|
1462 |
+
* @param {Object} node
|
1463 |
+
* @param {Object} [options]
|
1464 |
+
* @return {String}
|
1465 |
+
* @api public
|
1466 |
+
*/
|
1467 |
+
|
1468 |
+
module.exports = function(node, options){
|
1469 |
+
options = options || {};
|
1470 |
+
|
1471 |
+
var compiler = options.compress
|
1472 |
+
? new Compressed(options)
|
1473 |
+
: new Identity(options);
|
1474 |
+
|
1475 |
+
// source maps
|
1476 |
+
if (options.sourcemap) {
|
1477 |
+
var sourcemaps = require('./source-map-support');
|
1478 |
+
sourcemaps(compiler);
|
1479 |
+
|
1480 |
+
var code = compiler.compile(node);
|
1481 |
+
compiler.applySourceMaps();
|
1482 |
+
|
1483 |
+
var map = options.sourcemap === 'generator'
|
1484 |
+
? compiler.map
|
1485 |
+
: compiler.map.toJSON();
|
1486 |
+
|
1487 |
+
return { code: code, map: map };
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
var code = compiler.compile(node);
|
1491 |
+
return code;
|
1492 |
+
};
|
1493 |
+
|
1494 |
+
},{"./compress":8,"./identity":9,"./source-map-support":11}],11:[function(require,module,exports){
|
1495 |
+
|
1496 |
+
/**
|
1497 |
+
* Module dependencies.
|
1498 |
+
*/
|
1499 |
+
|
1500 |
+
var SourceMap = require('source-map').SourceMapGenerator;
|
1501 |
+
var SourceMapConsumer = require('source-map').SourceMapConsumer;
|
1502 |
+
var sourceMapResolve = require('source-map-resolve');
|
1503 |
+
var urix = require('urix');
|
1504 |
+
var fs = require('fs');
|
1505 |
+
var path = require('path');
|
1506 |
+
|
1507 |
+
/**
|
1508 |
+
* Expose `mixin()`.
|
1509 |
+
*/
|
1510 |
+
|
1511 |
+
module.exports = mixin;
|
1512 |
+
|
1513 |
+
/**
|
1514 |
+
* Mixin source map support into `compiler`.
|
1515 |
+
*
|
1516 |
+
* @param {Compiler} compiler
|
1517 |
+
* @api public
|
1518 |
+
*/
|
1519 |
+
|
1520 |
+
function mixin(compiler) {
|
1521 |
+
compiler._comment = compiler.comment;
|
1522 |
+
compiler.map = new SourceMap();
|
1523 |
+
compiler.position = { line: 1, column: 1 };
|
1524 |
+
compiler.files = {};
|
1525 |
+
for (var k in exports) compiler[k] = exports[k];
|
1526 |
+
}
|
1527 |
+
|
1528 |
+
/**
|
1529 |
+
* Update position.
|
1530 |
+
*
|
1531 |
+
* @param {String} str
|
1532 |
+
* @api private
|
1533 |
+
*/
|
1534 |
+
|
1535 |
+
exports.updatePosition = function(str) {
|
1536 |
+
var lines = str.match(/\n/g);
|
1537 |
+
if (lines) this.position.line += lines.length;
|
1538 |
+
var i = str.lastIndexOf('\n');
|
1539 |
+
this.position.column = ~i ? str.length - i : this.position.column + str.length;
|
1540 |
+
};
|
1541 |
+
|
1542 |
+
/**
|
1543 |
+
* Emit `str`.
|
1544 |
+
*
|
1545 |
+
* @param {String} str
|
1546 |
+
* @param {Object} [pos]
|
1547 |
+
* @return {String}
|
1548 |
+
* @api private
|
1549 |
+
*/
|
1550 |
+
|
1551 |
+
exports.emit = function(str, pos) {
|
1552 |
+
if (pos) {
|
1553 |
+
var sourceFile = urix(pos.source || 'source.css');
|
1554 |
+
|
1555 |
+
this.map.addMapping({
|
1556 |
+
source: sourceFile,
|
1557 |
+
generated: {
|
1558 |
+
line: this.position.line,
|
1559 |
+
column: Math.max(this.position.column - 1, 0)
|
1560 |
+
},
|
1561 |
+
original: {
|
1562 |
+
line: pos.start.line,
|
1563 |
+
column: pos.start.column - 1
|
1564 |
+
}
|
1565 |
+
});
|
1566 |
+
|
1567 |
+
this.addFile(sourceFile, pos);
|
1568 |
+
}
|
1569 |
+
|
1570 |
+
this.updatePosition(str);
|
1571 |
+
|
1572 |
+
return str;
|
1573 |
+
};
|
1574 |
+
|
1575 |
+
/**
|
1576 |
+
* Adds a file to the source map output if it has not already been added
|
1577 |
+
* @param {String} file
|
1578 |
+
* @param {Object} pos
|
1579 |
+
*/
|
1580 |
+
|
1581 |
+
exports.addFile = function(file, pos) {
|
1582 |
+
if (typeof pos.content !== 'string') return;
|
1583 |
+
if (Object.prototype.hasOwnProperty.call(this.files, file)) return;
|
1584 |
+
|
1585 |
+
this.files[file] = pos.content;
|
1586 |
+
};
|
1587 |
+
|
1588 |
+
/**
|
1589 |
+
* Applies any original source maps to the output and embeds the source file
|
1590 |
+
* contents in the source map.
|
1591 |
+
*/
|
1592 |
+
|
1593 |
+
exports.applySourceMaps = function() {
|
1594 |
+
Object.keys(this.files).forEach(function(file) {
|
1595 |
+
var content = this.files[file];
|
1596 |
+
this.map.setSourceContent(file, content);
|
1597 |
+
|
1598 |
+
if (this.options.inputSourcemaps !== false) {
|
1599 |
+
var originalMap = sourceMapResolve.resolveSync(
|
1600 |
+
content, file, fs.readFileSync);
|
1601 |
+
if (originalMap) {
|
1602 |
+
var map = new SourceMapConsumer(originalMap.map);
|
1603 |
+
var relativeTo = originalMap.sourcesRelativeTo;
|
1604 |
+
this.map.applySourceMap(map, file, urix(path.dirname(relativeTo)));
|
1605 |
+
}
|
1606 |
+
}
|
1607 |
+
}, this);
|
1608 |
+
};
|
1609 |
+
|
1610 |
+
/**
|
1611 |
+
* Process comments, drops sourceMap comments.
|
1612 |
+
* @param {Object} node
|
1613 |
+
*/
|
1614 |
+
|
1615 |
+
exports.comment = function(node) {
|
1616 |
+
if (/^# sourceMappingURL=/.test(node.comment))
|
1617 |
+
return this.emit('', node.position);
|
1618 |
+
else
|
1619 |
+
return this._comment(node);
|
1620 |
+
};
|
1621 |
+
|
1622 |
+
},{"fs":1,"path":2,"source-map":16,"source-map-resolve":15,"urix":27}],12:[function(require,module,exports){
|
1623 |
+
if (typeof Object.create === 'function') {
|
1624 |
+
// implementation from standard node.js 'util' module
|
1625 |
+
module.exports = function inherits(ctor, superCtor) {
|
1626 |
+
ctor.super_ = superCtor
|
1627 |
+
ctor.prototype = Object.create(superCtor.prototype, {
|
1628 |
+
constructor: {
|
1629 |
+
value: ctor,
|
1630 |
+
enumerable: false,
|
1631 |
+
writable: true,
|
1632 |
+
configurable: true
|
1633 |
+
}
|
1634 |
+
});
|
1635 |
+
};
|
1636 |
+
} else {
|
1637 |
+
// old school shim for old browsers
|
1638 |
+
module.exports = function inherits(ctor, superCtor) {
|
1639 |
+
ctor.super_ = superCtor
|
1640 |
+
var TempCtor = function () {}
|
1641 |
+
TempCtor.prototype = superCtor.prototype
|
1642 |
+
ctor.prototype = new TempCtor()
|
1643 |
+
ctor.prototype.constructor = ctor
|
1644 |
+
}
|
1645 |
+
}
|
1646 |
+
|
1647 |
+
},{}],13:[function(require,module,exports){
|
1648 |
+
// Copyright 2014 Simon Lydell
|
1649 |
+
// X11 (“MIT”) Licensed. (See LICENSE.)
|
1650 |
+
|
1651 |
+
void (function(root, factory) {
|
1652 |
+
if (typeof define === "function" && define.amd) {
|
1653 |
+
define(factory)
|
1654 |
+
} else if (typeof exports === "object") {
|
1655 |
+
module.exports = factory()
|
1656 |
+
} else {
|
1657 |
+
root.resolveUrl = factory()
|
1658 |
+
}
|
1659 |
+
}(this, function() {
|
1660 |
+
|
1661 |
+
function resolveUrl(/* ...urls */) {
|
1662 |
+
var numUrls = arguments.length
|
1663 |
+
|
1664 |
+
if (numUrls === 0) {
|
1665 |
+
throw new Error("resolveUrl requires at least one argument; got none.")
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
var base = document.createElement("base")
|
1669 |
+
base.href = arguments[0]
|
1670 |
+
|
1671 |
+
if (numUrls === 1) {
|
1672 |
+
return base.href
|
1673 |
+
}
|
1674 |
+
|
1675 |
+
var head = document.getElementsByTagName("head")[0]
|
1676 |
+
head.insertBefore(base, head.firstChild)
|
1677 |
+
|
1678 |
+
var a = document.createElement("a")
|
1679 |
+
var resolved
|
1680 |
+
|
1681 |
+
for (var index = 1; index < numUrls; index++) {
|
1682 |
+
a.href = arguments[index]
|
1683 |
+
resolved = a.href
|
1684 |
+
base.href = resolved
|
1685 |
+
}
|
1686 |
+
|
1687 |
+
head.removeChild(base)
|
1688 |
+
|
1689 |
+
return resolved
|
1690 |
+
}
|
1691 |
+
|
1692 |
+
return resolveUrl
|
1693 |
+
|
1694 |
+
}));
|
1695 |
+
|
1696 |
+
},{}],14:[function(require,module,exports){
|
1697 |
+
// Copyright 2014 Simon Lydell
|
1698 |
+
// X11 (“MIT”) Licensed. (See LICENSE.)
|
1699 |
+
|
1700 |
+
void (function(root, factory) {
|
1701 |
+
if (typeof define === "function" && define.amd) {
|
1702 |
+
define(factory)
|
1703 |
+
} else if (typeof exports === "object") {
|
1704 |
+
module.exports = factory()
|
1705 |
+
} else {
|
1706 |
+
root.sourceMappingURL = factory()
|
1707 |
+
}
|
1708 |
+
}(this, function() {
|
1709 |
+
|
1710 |
+
var innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/
|
1711 |
+
|
1712 |
+
var regex = RegExp(
|
1713 |
+
"(?:" +
|
1714 |
+
"/\\*" +
|
1715 |
+
"(?:\\s*\r?\n(?://)?)?" +
|
1716 |
+
"(?:" + innerRegex.source + ")" +
|
1717 |
+
"\\s*" +
|
1718 |
+
"\\*/" +
|
1719 |
+
"|" +
|
1720 |
+
"//(?:" + innerRegex.source + ")" +
|
1721 |
+
")" +
|
1722 |
+
"\\s*$"
|
1723 |
+
)
|
1724 |
+
|
1725 |
+
return {
|
1726 |
+
|
1727 |
+
regex: regex,
|
1728 |
+
_innerRegex: innerRegex,
|
1729 |
+
|
1730 |
+
getFrom: function(code) {
|
1731 |
+
var match = code.match(regex)
|
1732 |
+
return (match ? match[1] || match[2] || "" : null)
|
1733 |
+
},
|
1734 |
+
|
1735 |
+
existsIn: function(code) {
|
1736 |
+
return regex.test(code)
|
1737 |
+
},
|
1738 |
+
|
1739 |
+
removeFrom: function(code) {
|
1740 |
+
return code.replace(regex, "")
|
1741 |
+
},
|
1742 |
+
|
1743 |
+
insertBefore: function(code, string) {
|
1744 |
+
var match = code.match(regex)
|
1745 |
+
if (match) {
|
1746 |
+
return code.slice(0, match.index) + string + code.slice(match.index)
|
1747 |
+
} else {
|
1748 |
+
return code + string
|
1749 |
+
}
|
1750 |
+
}
|
1751 |
+
}
|
1752 |
+
|
1753 |
+
}));
|
1754 |
+
|
1755 |
+
},{}],15:[function(require,module,exports){
|
1756 |
+
// Copyright 2014 Simon Lydell
|
1757 |
+
// X11 (“MIT”) Licensed. (See LICENSE.)
|
1758 |
+
|
1759 |
+
// Note: source-map-resolve.js is generated from source-map-resolve-node.js and
|
1760 |
+
// source-map-resolve-template.js. Only edit the two latter files, _not_
|
1761 |
+
// source-map-resolve.js!
|
1762 |
+
|
1763 |
+
void (function(root, factory) {
|
1764 |
+
if (typeof define === "function" && define.amd) {
|
1765 |
+
define(["source-map-url", "resolve-url"], factory)
|
1766 |
+
} else if (typeof exports === "object") {
|
1767 |
+
var sourceMappingURL = require("source-map-url")
|
1768 |
+
var resolveUrl = require("resolve-url")
|
1769 |
+
module.exports = factory(sourceMappingURL, resolveUrl)
|
1770 |
+
} else {
|
1771 |
+
root.sourceMapResolve = factory(root.sourceMappingURL, root.resolveUrl)
|
1772 |
+
}
|
1773 |
+
}(this, function(sourceMappingURL, resolveUrl) {
|
1774 |
+
|
1775 |
+
function callbackAsync(callback, error, result) {
|
1776 |
+
setImmediate(function() { callback(error, result) })
|
1777 |
+
}
|
1778 |
+
|
1779 |
+
function parseMapToJSON(string) {
|
1780 |
+
return JSON.parse(string.replace(/^\)\]\}'/, ""))
|
1781 |
+
}
|
1782 |
+
|
1783 |
+
|
1784 |
+
|
1785 |
+
function resolveSourceMap(code, codeUrl, read, callback) {
|
1786 |
+
var mapData
|
1787 |
+
try {
|
1788 |
+
mapData = resolveSourceMapHelper(code, codeUrl)
|
1789 |
+
} catch (error) {
|
1790 |
+
return callbackAsync(callback, error)
|
1791 |
+
}
|
1792 |
+
if (!mapData || mapData.map) {
|
1793 |
+
return callbackAsync(callback, null, mapData)
|
1794 |
+
}
|
1795 |
+
read(mapData.url, function(error, result) {
|
1796 |
+
if (error) {
|
1797 |
+
return callback(error)
|
1798 |
+
}
|
1799 |
+
try {
|
1800 |
+
mapData.map = parseMapToJSON(String(result))
|
1801 |
+
} catch (error) {
|
1802 |
+
return callback(error)
|
1803 |
+
}
|
1804 |
+
callback(null, mapData)
|
1805 |
+
})
|
1806 |
+
}
|
1807 |
+
|
1808 |
+
function resolveSourceMapSync(code, codeUrl, read) {
|
1809 |
+
var mapData = resolveSourceMapHelper(code, codeUrl)
|
1810 |
+
if (!mapData || mapData.map) {
|
1811 |
+
return mapData
|
1812 |
+
}
|
1813 |
+
mapData.map = parseMapToJSON(String(read(mapData.url)))
|
1814 |
+
return mapData
|
1815 |
+
}
|
1816 |
+
|
1817 |
+
var dataUriRegex = /^data:([^,;]*)(;[^,;]*)*(?:,(.*))?$/
|
1818 |
+
var jsonMimeTypeRegex = /^(?:application|text)\/json$/
|
1819 |
+
|
1820 |
+
function resolveSourceMapHelper(code, codeUrl) {
|
1821 |
+
var url = sourceMappingURL.getFrom(code)
|
1822 |
+
if (!url) {
|
1823 |
+
return null
|
1824 |
+
}
|
1825 |
+
|
1826 |
+
var dataUri = url.match(dataUriRegex)
|
1827 |
+
if (dataUri) {
|
1828 |
+
var mimeType = dataUri[1]
|
1829 |
+
var lastParameter = dataUri[2]
|
1830 |
+
var encoded = dataUri[3]
|
1831 |
+
if (!jsonMimeTypeRegex.test(mimeType)) {
|
1832 |
+
throw new Error("Unuseful data uri mime type: " + (mimeType || "text/plain"))
|
1833 |
+
}
|
1834 |
+
return {
|
1835 |
+
sourceMappingURL: url,
|
1836 |
+
url: null,
|
1837 |
+
sourcesRelativeTo: codeUrl,
|
1838 |
+
map: parseMapToJSON(lastParameter === ";base64" ? atob(encoded) : decodeURIComponent(encoded))
|
1839 |
+
}
|
1840 |
+
}
|
1841 |
+
|
1842 |
+
var mapUrl = resolveUrl(codeUrl, url)
|
1843 |
+
return {
|
1844 |
+
sourceMappingURL: url,
|
1845 |
+
url: mapUrl,
|
1846 |
+
sourcesRelativeTo: mapUrl,
|
1847 |
+
map: null
|
1848 |
+
}
|
1849 |
+
}
|
1850 |
+
|
1851 |
+
|
1852 |
+
|
1853 |
+
function resolveSources(map, mapUrl, read, options, callback) {
|
1854 |
+
if (typeof options === "function") {
|
1855 |
+
callback = options
|
1856 |
+
options = {}
|
1857 |
+
}
|
1858 |
+
var pending = map.sources.length
|
1859 |
+
var errored = false
|
1860 |
+
var result = {
|
1861 |
+
sourcesResolved: [],
|
1862 |
+
sourcesContent: []
|
1863 |
+
}
|
1864 |
+
|
1865 |
+
var done = function(error) {
|
1866 |
+
if (errored) {
|
1867 |
+
return
|
1868 |
+
}
|
1869 |
+
if (error) {
|
1870 |
+
errored = true
|
1871 |
+
return callback(error)
|
1872 |
+
}
|
1873 |
+
pending--
|
1874 |
+
if (pending === 0) {
|
1875 |
+
callback(null, result)
|
1876 |
+
}
|
1877 |
+
}
|
1878 |
+
|
1879 |
+
resolveSourcesHelper(map, mapUrl, options, function(fullUrl, sourceContent, index) {
|
1880 |
+
result.sourcesResolved[index] = fullUrl
|
1881 |
+
if (typeof sourceContent === "string") {
|
1882 |
+
result.sourcesContent[index] = sourceContent
|
1883 |
+
callbackAsync(done, null)
|
1884 |
+
} else {
|
1885 |
+
read(fullUrl, function(error, source) {
|
1886 |
+
result.sourcesContent[index] = String(source)
|
1887 |
+
done(error)
|
1888 |
+
})
|
1889 |
+
}
|
1890 |
+
})
|
1891 |
+
}
|
1892 |
+
|
1893 |
+
function resolveSourcesSync(map, mapUrl, read, options) {
|
1894 |
+
var result = {
|
1895 |
+
sourcesResolved: [],
|
1896 |
+
sourcesContent: []
|
1897 |
+
}
|
1898 |
+
resolveSourcesHelper(map, mapUrl, options, function(fullUrl, sourceContent, index) {
|
1899 |
+
result.sourcesResolved[index] = fullUrl
|
1900 |
+
if (read !== null) {
|
1901 |
+
if (typeof sourceContent === "string") {
|
1902 |
+
result.sourcesContent[index] = sourceContent
|
1903 |
+
} else {
|
1904 |
+
result.sourcesContent[index] = String(read(fullUrl))
|
1905 |
+
}
|
1906 |
+
}
|
1907 |
+
})
|
1908 |
+
return result
|
1909 |
+
}
|
1910 |
+
|
1911 |
+
var endingSlash = /\/?$/
|
1912 |
+
|
1913 |
+
function resolveSourcesHelper(map, mapUrl, options, fn) {
|
1914 |
+
options = options || {}
|
1915 |
+
var fullUrl
|
1916 |
+
var sourceContent
|
1917 |
+
for (var index = 0, len = map.sources.length; index < len; index++) {
|
1918 |
+
if (map.sourceRoot && !options.ignoreSourceRoot) {
|
1919 |
+
// Make sure that the sourceRoot ends with a slash, so that `/scripts/subdir` becomes
|
1920 |
+
// `/scripts/subdir/<source>`, not `/scripts/<source>`. Pointing to a file as source root
|
1921 |
+
// does not make sense.
|
1922 |
+
fullUrl = resolveUrl(mapUrl, map.sourceRoot.replace(endingSlash, "/"), map.sources[index])
|
1923 |
+
} else {
|
1924 |
+
fullUrl = resolveUrl(mapUrl, map.sources[index])
|
1925 |
+
}
|
1926 |
+
sourceContent = (map.sourcesContent || [])[index]
|
1927 |
+
fn(fullUrl, sourceContent, index)
|
1928 |
+
}
|
1929 |
+
}
|
1930 |
+
|
1931 |
+
|
1932 |
+
|
1933 |
+
function resolve(code, codeUrl, read, options, callback) {
|
1934 |
+
if (typeof options === "function") {
|
1935 |
+
callback = options
|
1936 |
+
options = {}
|
1937 |
+
}
|
1938 |
+
resolveSourceMap(code, codeUrl, read, function(error, mapData) {
|
1939 |
+
if (error) {
|
1940 |
+
return callback(error)
|
1941 |
+
}
|
1942 |
+
if (!mapData) {
|
1943 |
+
return callback(null, null)
|
1944 |
+
}
|
1945 |
+
resolveSources(mapData.map, mapData.sourcesRelativeTo, read, options, function(error, result) {
|
1946 |
+
if (error) {
|
1947 |
+
return callback(error)
|
1948 |
+
}
|
1949 |
+
mapData.sourcesResolved = result.sourcesResolved
|
1950 |
+
mapData.sourcesContent = result.sourcesContent
|
1951 |
+
callback(null, mapData)
|
1952 |
+
})
|
1953 |
+
})
|
1954 |
+
}
|
1955 |
+
|
1956 |
+
function resolveSync(code, codeUrl, read, options) {
|
1957 |
+
var mapData = resolveSourceMapSync(code, codeUrl, read)
|
1958 |
+
if (!mapData) {
|
1959 |
+
return null
|
1960 |
+
}
|
1961 |
+
var result = resolveSourcesSync(mapData.map, mapData.sourcesRelativeTo, read, options)
|
1962 |
+
mapData.sourcesResolved = result.sourcesResolved
|
1963 |
+
mapData.sourcesContent = result.sourcesContent
|
1964 |
+
return mapData
|
1965 |
+
}
|
1966 |
+
|
1967 |
+
|
1968 |
+
|
1969 |
+
return {
|
1970 |
+
resolveSourceMap: resolveSourceMap,
|
1971 |
+
resolveSourceMapSync: resolveSourceMapSync,
|
1972 |
+
resolveSources: resolveSources,
|
1973 |
+
resolveSourcesSync: resolveSourcesSync,
|
1974 |
+
resolve: resolve,
|
1975 |
+
resolveSync: resolveSync
|
1976 |
+
}
|
1977 |
+
|
1978 |
+
}));
|
1979 |
+
|
1980 |
+
},{"resolve-url":13,"source-map-url":14}],16:[function(require,module,exports){
|
1981 |
+
/*
|
1982 |
+
* Copyright 2009-2011 Mozilla Foundation and contributors
|
1983 |
+
* Licensed under the New BSD license. See LICENSE.txt or:
|
1984 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
1985 |
+
*/
|
1986 |
+
exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator;
|
1987 |
+
exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
|
1988 |
+
exports.SourceNode = require('./source-map/source-node').SourceNode;
|
1989 |
+
|
1990 |
+
},{"./source-map/source-map-consumer":22,"./source-map/source-map-generator":23,"./source-map/source-node":24}],17:[function(require,module,exports){
|
1991 |
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
1992 |
+
/*
|
1993 |
+
* Copyright 2011 Mozilla Foundation and contributors
|
1994 |
+
* Licensed under the New BSD license. See LICENSE or:
|
1995 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
1996 |
+
*/
|
1997 |
+
if (typeof define !== 'function') {
|
1998 |
+
var define = require('amdefine')(module, require);
|
1999 |
+
}
|
2000 |
+
define(function (require, exports, module) {
|
2001 |
+
|
2002 |
+
var util = require('./util');
|
2003 |
+
|
2004 |
+
/**
|
2005 |
+
* A data structure which is a combination of an array and a set. Adding a new
|
2006 |
+
* member is O(1), testing for membership is O(1), and finding the index of an
|
2007 |
+
* element is O(1). Removing elements from the set is not supported. Only
|
2008 |
+
* strings are supported for membership.
|
2009 |
+
*/
|
2010 |
+
function ArraySet() {
|
2011 |
+
this._array = [];
|
2012 |
+
this._set = {};
|
2013 |
+
}
|
2014 |
+
|
2015 |
+
/**
|
2016 |
+
* Static method for creating ArraySet instances from an existing array.
|
2017 |
+
*/
|
2018 |
+
ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
2019 |
+
var set = new ArraySet();
|
2020 |
+
for (var i = 0, len = aArray.length; i < len; i++) {
|
2021 |
+
set.add(aArray[i], aAllowDuplicates);
|
2022 |
+
}
|
2023 |
+
return set;
|
2024 |
+
};
|
2025 |
+
|
2026 |
+
/**
|
2027 |
+
* Add the given string to this set.
|
2028 |
+
*
|
2029 |
+
* @param String aStr
|
2030 |
+
*/
|
2031 |
+
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
|
2032 |
+
var isDuplicate = this.has(aStr);
|
2033 |
+
var idx = this._array.length;
|
2034 |
+
if (!isDuplicate || aAllowDuplicates) {
|
2035 |
+
this._array.push(aStr);
|
2036 |
+
}
|
2037 |
+
if (!isDuplicate) {
|
2038 |
+
this._set[util.toSetString(aStr)] = idx;
|
2039 |
+
}
|
2040 |
+
};
|
2041 |
+
|
2042 |
+
/**
|
2043 |
+
* Is the given string a member of this set?
|
2044 |
+
*
|
2045 |
+
* @param String aStr
|
2046 |
+
*/
|
2047 |
+
ArraySet.prototype.has = function ArraySet_has(aStr) {
|
2048 |
+
return Object.prototype.hasOwnProperty.call(this._set,
|
2049 |
+
util.toSetString(aStr));
|
2050 |
+
};
|
2051 |
+
|
2052 |
+
/**
|
2053 |
+
* What is the index of the given string in the array?
|
2054 |
+
*
|
2055 |
+
* @param String aStr
|
2056 |
+
*/
|
2057 |
+
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
2058 |
+
if (this.has(aStr)) {
|
2059 |
+
return this._set[util.toSetString(aStr)];
|
2060 |
+
}
|
2061 |
+
throw new Error('"' + aStr + '" is not in the set.');
|
2062 |
+
};
|
2063 |
+
|
2064 |
+
/**
|
2065 |
+
* What is the element at the given index?
|
2066 |
+
*
|
2067 |
+
* @param Number aIdx
|
2068 |
+
*/
|
2069 |
+
ArraySet.prototype.at = function ArraySet_at(aIdx) {
|
2070 |
+
if (aIdx >= 0 && aIdx < this._array.length) {
|
2071 |
+
return this._array[aIdx];
|
2072 |
+
}
|
2073 |
+
throw new Error('No element indexed by ' + aIdx);
|
2074 |
+
};
|
2075 |
+
|
2076 |
+
/**
|
2077 |
+
* Returns the array representation of this set (which has the proper indices
|
2078 |
+
* indicated by indexOf). Note that this is a copy of the internal array used
|
2079 |
+
* for storing the members so that no one can mess with internal state.
|
2080 |
+
*/
|
2081 |
+
ArraySet.prototype.toArray = function ArraySet_toArray() {
|
2082 |
+
return this._array.slice();
|
2083 |
+
};
|
2084 |
+
|
2085 |
+
exports.ArraySet = ArraySet;
|
2086 |
+
|
2087 |
+
});
|
2088 |
+
|
2089 |
+
},{"./util":25,"amdefine":26}],18:[function(require,module,exports){
|
2090 |
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2091 |
+
/*
|
2092 |
+
* Copyright 2011 Mozilla Foundation and contributors
|
2093 |
+
* Licensed under the New BSD license. See LICENSE or:
|
2094 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
2095 |
+
*
|
2096 |
+
* Based on the Base 64 VLQ implementation in Closure Compiler:
|
2097 |
+
* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
|
2098 |
+
*
|
2099 |
+
* Copyright 2011 The Closure Compiler Authors. All rights reserved.
|
2100 |
+
* Redistribution and use in source and binary forms, with or without
|
2101 |
+
* modification, are permitted provided that the following conditions are
|
2102 |
+
* met:
|
2103 |
+
*
|
2104 |
+
* * Redistributions of source code must retain the above copyright
|
2105 |
+
* notice, this list of conditions and the following disclaimer.
|
2106 |
+
* * Redistributions in binary form must reproduce the above
|
2107 |
+
* copyright notice, this list of conditions and the following
|
2108 |
+
* disclaimer in the documentation and/or other materials provided
|
2109 |
+
* with the distribution.
|
2110 |
+
* * Neither the name of Google Inc. nor the names of its
|
2111 |
+
* contributors may be used to endorse or promote products derived
|
2112 |
+
* from this software without specific prior written permission.
|
2113 |
+
*
|
2114 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
2115 |
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2116 |
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2117 |
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2118 |
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2119 |
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2120 |
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2121 |
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
2122 |
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
2123 |
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2124 |
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2125 |
+
*/
|
2126 |
+
if (typeof define !== 'function') {
|
2127 |
+
var define = require('amdefine')(module, require);
|
2128 |
+
}
|
2129 |
+
define(function (require, exports, module) {
|
2130 |
+
|
2131 |
+
var base64 = require('./base64');
|
2132 |
+
|
2133 |
+
// A single base 64 digit can contain 6 bits of data. For the base 64 variable
|
2134 |
+
// length quantities we use in the source map spec, the first bit is the sign,
|
2135 |
+
// the next four bits are the actual value, and the 6th bit is the
|
2136 |
+
// continuation bit. The continuation bit tells us whether there are more
|
2137 |
+
// digits in this value following this digit.
|
2138 |
+
//
|
2139 |
+
// Continuation
|
2140 |
+
// | Sign
|
2141 |
+
// | |
|
2142 |
+
// V V
|
2143 |
+
// 101011
|
2144 |
+
|
2145 |
+
var VLQ_BASE_SHIFT = 5;
|
2146 |
+
|
2147 |
+
// binary: 100000
|
2148 |
+
var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
2149 |
+
|
2150 |
+
// binary: 011111
|
2151 |
+
var VLQ_BASE_MASK = VLQ_BASE - 1;
|
2152 |
+
|
2153 |
+
// binary: 100000
|
2154 |
+
var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
2155 |
+
|
2156 |
+
/**
|
2157 |
+
* Converts from a two-complement value to a value where the sign bit is
|
2158 |
+
* placed in the least significant bit. For example, as decimals:
|
2159 |
+
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
2160 |
+
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
2161 |
+
*/
|
2162 |
+
function toVLQSigned(aValue) {
|
2163 |
+
return aValue < 0
|
2164 |
+
? ((-aValue) << 1) + 1
|
2165 |
+
: (aValue << 1) + 0;
|
2166 |
+
}
|
2167 |
+
|
2168 |
+
/**
|
2169 |
+
* Converts to a two-complement value from a value where the sign bit is
|
2170 |
+
* placed in the least significant bit. For example, as decimals:
|
2171 |
+
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
2172 |
+
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
2173 |
+
*/
|
2174 |
+
function fromVLQSigned(aValue) {
|
2175 |
+
var isNegative = (aValue & 1) === 1;
|
2176 |
+
var shifted = aValue >> 1;
|
2177 |
+
return isNegative
|
2178 |
+
? -shifted
|
2179 |
+
: shifted;
|
2180 |
+
}
|
2181 |
+
|
2182 |
+
/**
|
2183 |
+
* Returns the base 64 VLQ encoded value.
|
2184 |
+
*/
|
2185 |
+
exports.encode = function base64VLQ_encode(aValue) {
|
2186 |
+
var encoded = "";
|
2187 |
+
var digit;
|
2188 |
+
|
2189 |
+
var vlq = toVLQSigned(aValue);
|
2190 |
+
|
2191 |
+
do {
|
2192 |
+
digit = vlq & VLQ_BASE_MASK;
|
2193 |
+
vlq >>>= VLQ_BASE_SHIFT;
|
2194 |
+
if (vlq > 0) {
|
2195 |
+
// There are still more digits in this value, so we must make sure the
|
2196 |
+
// continuation bit is marked.
|
2197 |
+
digit |= VLQ_CONTINUATION_BIT;
|
2198 |
+
}
|
2199 |
+
encoded += base64.encode(digit);
|
2200 |
+
} while (vlq > 0);
|
2201 |
+
|
2202 |
+
return encoded;
|
2203 |
+
};
|
2204 |
+
|
2205 |
+
/**
|
2206 |
+
* Decodes the next base 64 VLQ value from the given string and returns the
|
2207 |
+
* value and the rest of the string via the out parameter.
|
2208 |
+
*/
|
2209 |
+
exports.decode = function base64VLQ_decode(aStr, aOutParam) {
|
2210 |
+
var i = 0;
|
2211 |
+
var strLen = aStr.length;
|
2212 |
+
var result = 0;
|
2213 |
+
var shift = 0;
|
2214 |
+
var continuation, digit;
|
2215 |
+
|
2216 |
+
do {
|
2217 |
+
if (i >= strLen) {
|
2218 |
+
throw new Error("Expected more digits in base 64 VLQ value.");
|
2219 |
+
}
|
2220 |
+
digit = base64.decode(aStr.charAt(i++));
|
2221 |
+
continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
2222 |
+
digit &= VLQ_BASE_MASK;
|
2223 |
+
result = result + (digit << shift);
|
2224 |
+
shift += VLQ_BASE_SHIFT;
|
2225 |
+
} while (continuation);
|
2226 |
+
|
2227 |
+
aOutParam.value = fromVLQSigned(result);
|
2228 |
+
aOutParam.rest = aStr.slice(i);
|
2229 |
+
};
|
2230 |
+
|
2231 |
+
});
|
2232 |
+
|
2233 |
+
},{"./base64":19,"amdefine":26}],19:[function(require,module,exports){
|
2234 |
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2235 |
+
/*
|
2236 |
+
* Copyright 2011 Mozilla Foundation and contributors
|
2237 |
+
* Licensed under the New BSD license. See LICENSE or:
|
2238 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
2239 |
+
*/
|
2240 |
+
if (typeof define !== 'function') {
|
2241 |
+
var define = require('amdefine')(module, require);
|
2242 |
+
}
|
2243 |
+
define(function (require, exports, module) {
|
2244 |
+
|
2245 |
+
var charToIntMap = {};
|
2246 |
+
var intToCharMap = {};
|
2247 |
+
|
2248 |
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
2249 |
+
.split('')
|
2250 |
+
.forEach(function (ch, index) {
|
2251 |
+
charToIntMap[ch] = index;
|
2252 |
+
intToCharMap[index] = ch;
|
2253 |
+
});
|
2254 |
+
|
2255 |
+
/**
|
2256 |
+
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
2257 |
+
*/
|
2258 |
+
exports.encode = function base64_encode(aNumber) {
|
2259 |
+
if (aNumber in intToCharMap) {
|
2260 |
+
return intToCharMap[aNumber];
|
2261 |
+
}
|
2262 |
+
throw new TypeError("Must be between 0 and 63: " + aNumber);
|
2263 |
+
};
|
2264 |
+
|
2265 |
+
/**
|
2266 |
+
* Decode a single base 64 digit to an integer.
|
2267 |
+
*/
|
2268 |
+
exports.decode = function base64_decode(aChar) {
|
2269 |
+
if (aChar in charToIntMap) {
|
2270 |
+
return charToIntMap[aChar];
|
2271 |
+
}
|
2272 |
+
throw new TypeError("Not a valid base 64 digit: " + aChar);
|
2273 |
+
};
|
2274 |
+
|
2275 |
+
});
|
2276 |
+
|
2277 |
+
},{"amdefine":26}],20:[function(require,module,exports){
|
2278 |
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2279 |
+
/*
|
2280 |
+
* Copyright 2011 Mozilla Foundation and contributors
|
2281 |
+
* Licensed under the New BSD license. See LICENSE or:
|
2282 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
2283 |
+
*/
|
2284 |
+
if (typeof define !== 'function') {
|
2285 |
+
var define = require('amdefine')(module, require);
|
2286 |
+
}
|
2287 |
+
define(function (require, exports, module) {
|
2288 |
+
|
2289 |
+
/**
|
2290 |
+
* Recursive implementation of binary search.
|
2291 |
+
*
|
2292 |
+
* @param aLow Indices here and lower do not contain the needle.
|
2293 |
+
* @param aHigh Indices here and higher do not contain the needle.
|
2294 |
+
* @param aNeedle The element being searched for.
|
2295 |
+
* @param aHaystack The non-empty array being searched.
|
2296 |
+
* @param aCompare Function which takes two elements and returns -1, 0, or 1.
|
2297 |
+
*/
|
2298 |
+
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) {
|
2299 |
+
// This function terminates when one of the following is true:
|
2300 |
+
//
|
2301 |
+
// 1. We find the exact element we are looking for.
|
2302 |
+
//
|
2303 |
+
// 2. We did not find the exact element, but we can return the index of
|
2304 |
+
// the next closest element that is less than that element.
|
2305 |
+
//
|
2306 |
+
// 3. We did not find the exact element, and there is no next-closest
|
2307 |
+
// element which is less than the one we are searching for, so we
|
2308 |
+
// return -1.
|
2309 |
+
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
|
2310 |
+
var cmp = aCompare(aNeedle, aHaystack[mid], true);
|
2311 |
+
if (cmp === 0) {
|
2312 |
+
// Found the element we are looking for.
|
2313 |
+
return mid;
|
2314 |
+
}
|
2315 |
+
else if (cmp > 0) {
|
2316 |
+
// aHaystack[mid] is greater than our needle.
|
2317 |
+
if (aHigh - mid > 1) {
|
2318 |
+
// The element is in the upper half.
|
2319 |
+
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare);
|
2320 |
+
}
|
2321 |
+
// We did not find an exact match, return the next closest one
|
2322 |
+
// (termination case 2).
|
2323 |
+
return mid;
|
2324 |
+
}
|
2325 |
+
else {
|
2326 |
+
// aHaystack[mid] is less than our needle.
|
2327 |
+
if (mid - aLow > 1) {
|
2328 |
+
// The element is in the lower half.
|
2329 |
+
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare);
|
2330 |
+
}
|
2331 |
+
// The exact needle element was not found in this haystack. Determine if
|
2332 |
+
// we are in termination case (2) or (3) and return the appropriate thing.
|
2333 |
+
return aLow < 0 ? -1 : aLow;
|
2334 |
+
}
|
2335 |
+
}
|
2336 |
+
|
2337 |
+
/**
|
2338 |
+
* This is an implementation of binary search which will always try and return
|
2339 |
+
* the index of next lowest value checked if there is no exact hit. This is
|
2340 |
+
* because mappings between original and generated line/col pairs are single
|
2341 |
+
* points, and there is an implicit region between each of them, so a miss
|
2342 |
+
* just means that you aren't on the very start of a region.
|
2343 |
+
*
|
2344 |
+
* @param aNeedle The element you are looking for.
|
2345 |
+
* @param aHaystack The array that is being searched.
|
2346 |
+
* @param aCompare A function which takes the needle and an element in the
|
2347 |
+
* array and returns -1, 0, or 1 depending on whether the needle is less
|
2348 |
+
* than, equal to, or greater than the element, respectively.
|
2349 |
+
*/
|
2350 |
+
exports.search = function search(aNeedle, aHaystack, aCompare) {
|
2351 |
+
if (aHaystack.length === 0) {
|
2352 |
+
return -1;
|
2353 |
+
}
|
2354 |
+
return recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
|
2355 |
+
};
|
2356 |
+
|
2357 |
+
});
|
2358 |
+
|
2359 |
+
},{"amdefine":26}],21:[function(require,module,exports){
|
2360 |
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2361 |
+
/*
|
2362 |
+
* Copyright 2014 Mozilla Foundation and contributors
|
2363 |
+
* Licensed under the New BSD license. See LICENSE or:
|
2364 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
2365 |
+
*/
|
2366 |
+
if (typeof define !== 'function') {
|
2367 |
+
var define = require('amdefine')(module, require);
|
2368 |
+
}
|
2369 |
+
define(function (require, exports, module) {
|
2370 |
+
|
2371 |
+
var util = require('./util');
|
2372 |
+
|
2373 |
+
/**
|
2374 |
+
* Determine whether mappingB is after mappingA with respect to generated
|
2375 |
+
* position.
|
2376 |
+
*/
|
2377 |
+
function generatedPositionAfter(mappingA, mappingB) {
|
2378 |
+
// Optimized for most common case
|
2379 |
+
var lineA = mappingA.generatedLine;
|
2380 |
+
var lineB = mappingB.generatedLine;
|
2381 |
+
var columnA = mappingA.generatedColumn;
|
2382 |
+
var columnB = mappingB.generatedColumn;
|
2383 |
+
return lineB > lineA || lineB == lineA && columnB >= columnA ||
|
2384 |
+
util.compareByGeneratedPositions(mappingA, mappingB) <= 0;
|
2385 |
+
}
|
2386 |
+
|
2387 |
+
/**
|
2388 |
+
* A data structure to provide a sorted view of accumulated mappings in a
|
2389 |
+
* performance conscious manner. It trades a neglibable overhead in general
|
2390 |
+
* case for a large speedup in case of mappings being added in order.
|
2391 |
+
*/
|
2392 |
+
function MappingList() {
|
2393 |
+
this._array = [];
|
2394 |
+
this._sorted = true;
|
2395 |
+
// Serves as infimum
|
2396 |
+
this._last = {generatedLine: -1, generatedColumn: 0};
|
2397 |
+
}
|
2398 |
+
|
2399 |
+
/**
|
2400 |
+
* Iterate through internal items. This method takes the same arguments that
|
2401 |
+
* `Array.prototype.forEach` takes.
|
2402 |
+
*
|
2403 |
+
* NOTE: The order of the mappings is NOT guaranteed.
|
2404 |
+
*/
|
2405 |
+
MappingList.prototype.unsortedForEach =
|
2406 |
+
function MappingList_forEach(aCallback, aThisArg) {
|
2407 |
+
this._array.forEach(aCallback, aThisArg);
|
2408 |
+
};
|
2409 |
+
|
2410 |
+
/**
|
2411 |
+
* Add the given source mapping.
|
2412 |
+
*
|
2413 |
+
* @param Object aMapping
|
2414 |
+
*/
|
2415 |
+
MappingList.prototype.add = function MappingList_add(aMapping) {
|
2416 |
+
var mapping;
|
2417 |
+
if (generatedPositionAfter(this._last, aMapping)) {
|
2418 |
+
this._last = aMapping;
|
2419 |
+
this._array.push(aMapping);
|
2420 |
+
} else {
|
2421 |
+
this._sorted = false;
|
2422 |
+
this._array.push(aMapping);
|
2423 |
+
}
|
2424 |
+
};
|
2425 |
+
|
2426 |
+
/**
|
2427 |
+
* Returns the flat, sorted array of mappings. The mappings are sorted by
|
2428 |
+
* generated position.
|
2429 |
+
*
|
2430 |
+
* WARNING: This method returns internal data without copying, for
|
2431 |
+
* performance. The return value must NOT be mutated, and should be treated as
|
2432 |
+
* an immutable borrow. If you want to take ownership, you must make your own
|
2433 |
+
* copy.
|
2434 |
+
*/
|
2435 |
+
MappingList.prototype.toArray = function MappingList_toArray() {
|
2436 |
+
if (!this._sorted) {
|
2437 |
+
this._array.sort(util.compareByGeneratedPositions);
|
2438 |
+
this._sorted = true;
|
2439 |
+
}
|
2440 |
+
return this._array;
|
2441 |
+
};
|
2442 |
+
|
2443 |
+
exports.MappingList = MappingList;
|
2444 |
+
|
2445 |
+
});
|
2446 |
+
|
2447 |
+
},{"./util":25,"amdefine":26}],22:[function(require,module,exports){
|
2448 |
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2449 |
/*
|
2450 |
+
* Copyright 2011 Mozilla Foundation and contributors
|
2451 |
+
* Licensed under the New BSD license. See LICENSE or:
|
2452 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
2453 |
+
*/
|
2454 |
+
if (typeof define !== 'function') {
|
2455 |
+
var define = require('amdefine')(module, require);
|
2456 |
+
}
|
2457 |
+
define(function (require, exports, module) {
|
2458 |
+
|
2459 |
+
var util = require('./util');
|
2460 |
+
var binarySearch = require('./binary-search');
|
2461 |
+
var ArraySet = require('./array-set').ArraySet;
|
2462 |
+
var base64VLQ = require('./base64-vlq');
|
2463 |
+
|
2464 |
+
/**
|
2465 |
+
* A SourceMapConsumer instance represents a parsed source map which we can
|
2466 |
+
* query for information about the original file positions by giving it a file
|
2467 |
+
* position in the generated source.
|
2468 |
+
*
|
2469 |
+
* The only parameter is the raw source map (either as a JSON string, or
|
2470 |
+
* already parsed to an object). According to the spec, source maps have the
|
2471 |
+
* following attributes:
|
2472 |
+
*
|
2473 |
+
* - version: Which version of the source map spec this map is following.
|
2474 |
+
* - sources: An array of URLs to the original source files.
|
2475 |
+
* - names: An array of identifiers which can be referrenced by individual mappings.
|
2476 |
+
* - sourceRoot: Optional. The URL root from which all sources are relative.
|
2477 |
+
* - sourcesContent: Optional. An array of contents of the original source files.
|
2478 |
+
* - mappings: A string of base64 VLQs which contain the actual mappings.
|
2479 |
+
* - file: Optional. The generated file this source map is associated with.
|
2480 |
+
*
|
2481 |
+
* Here is an example source map, taken from the source map spec[0]:
|
2482 |
+
*
|
2483 |
+
* {
|
2484 |
+
* version : 3,
|
2485 |
+
* file: "out.js",
|
2486 |
+
* sourceRoot : "",
|
2487 |
+
* sources: ["foo.js", "bar.js"],
|
2488 |
+
* names: ["src", "maps", "are", "fun"],
|
2489 |
+
* mappings: "AA,AB;;ABCDE;"
|
2490 |
+
* }
|
2491 |
+
*
|
2492 |
+
* [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
|
2493 |
+
*/
|
2494 |
+
function SourceMapConsumer(aSourceMap) {
|
2495 |
+
var sourceMap = aSourceMap;
|
2496 |
+
if (typeof aSourceMap === 'string') {
|
2497 |
+
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
|
2498 |
+
}
|
2499 |
+
|
2500 |
+
var version = util.getArg(sourceMap, 'version');
|
2501 |
+
var sources = util.getArg(sourceMap, 'sources');
|
2502 |
+
// Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
|
2503 |
+
// requires the array) to play nice here.
|
2504 |
+
var names = util.getArg(sourceMap, 'names', []);
|
2505 |
+
var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
|
2506 |
+
var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
|
2507 |
+
var mappings = util.getArg(sourceMap, 'mappings');
|
2508 |
+
var file = util.getArg(sourceMap, 'file', null);
|
2509 |
+
|
2510 |
+
// Once again, Sass deviates from the spec and supplies the version as a
|
2511 |
+
// string rather than a number, so we use loose equality checking here.
|
2512 |
+
if (version != this._version) {
|
2513 |
+
throw new Error('Unsupported version: ' + version);
|
2514 |
+
}
|
2515 |
+
|
2516 |
+
// Some source maps produce relative source paths like "./foo.js" instead of
|
2517 |
+
// "foo.js". Normalize these first so that future comparisons will succeed.
|
2518 |
+
// See bugzil.la/1090768.
|
2519 |
+
sources = sources.map(util.normalize);
|
2520 |
+
|
2521 |
+
// Pass `true` below to allow duplicate names and sources. While source maps
|
2522 |
+
// are intended to be compressed and deduplicated, the TypeScript compiler
|
2523 |
+
// sometimes generates source maps with duplicates in them. See Github issue
|
2524 |
+
// #72 and bugzil.la/889492.
|
2525 |
+
this._names = ArraySet.fromArray(names, true);
|
2526 |
+
this._sources = ArraySet.fromArray(sources, true);
|
2527 |
+
|
2528 |
+
this.sourceRoot = sourceRoot;
|
2529 |
+
this.sourcesContent = sourcesContent;
|
2530 |
+
this._mappings = mappings;
|
2531 |
+
this.file = file;
|
2532 |
+
}
|
2533 |
+
|
2534 |
+
/**
|
2535 |
+
* Create a SourceMapConsumer from a SourceMapGenerator.
|
2536 |
+
*
|
2537 |
+
* @param SourceMapGenerator aSourceMap
|
2538 |
+
* The source map that will be consumed.
|
2539 |
+
* @returns SourceMapConsumer
|
2540 |
+
*/
|
2541 |
+
SourceMapConsumer.fromSourceMap =
|
2542 |
+
function SourceMapConsumer_fromSourceMap(aSourceMap) {
|
2543 |
+
var smc = Object.create(SourceMapConsumer.prototype);
|
2544 |
+
|
2545 |
+
smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
|
2546 |
+
smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
|
2547 |
+
smc.sourceRoot = aSourceMap._sourceRoot;
|
2548 |
+
smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
|
2549 |
+
smc.sourceRoot);
|
2550 |
+
smc.file = aSourceMap._file;
|
2551 |
+
|
2552 |
+
smc.__generatedMappings = aSourceMap._mappings.toArray().slice();
|
2553 |
+
smc.__originalMappings = aSourceMap._mappings.toArray().slice()
|
2554 |
+
.sort(util.compareByOriginalPositions);
|
2555 |
+
|
2556 |
+
return smc;
|
2557 |
+
};
|
2558 |
+
|
2559 |
+
/**
|
2560 |
+
* The version of the source mapping spec that we are consuming.
|
2561 |
+
*/
|
2562 |
+
SourceMapConsumer.prototype._version = 3;
|
2563 |
+
|
2564 |
+
/**
|
2565 |
+
* The list of original sources.
|
2566 |
+
*/
|
2567 |
+
Object.defineProperty(SourceMapConsumer.prototype, 'sources', {
|
2568 |
+
get: function () {
|
2569 |
+
return this._sources.toArray().map(function (s) {
|
2570 |
+
return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
|
2571 |
+
}, this);
|
2572 |
+
}
|
2573 |
+
});
|
2574 |
+
|
2575 |
+
// `__generatedMappings` and `__originalMappings` are arrays that hold the
|
2576 |
+
// parsed mapping coordinates from the source map's "mappings" attribute. They
|
2577 |
+
// are lazily instantiated, accessed via the `_generatedMappings` and
|
2578 |
+
// `_originalMappings` getters respectively, and we only parse the mappings
|
2579 |
+
// and create these arrays once queried for a source location. We jump through
|
2580 |
+
// these hoops because there can be many thousands of mappings, and parsing
|
2581 |
+
// them is expensive, so we only want to do it if we must.
|
2582 |
+
//
|
2583 |
+
// Each object in the arrays is of the form:
|
2584 |
+
//
|
2585 |
+
// {
|
2586 |
+
// generatedLine: The line number in the generated code,
|
2587 |
+
// generatedColumn: The column number in the generated code,
|
2588 |
+
// source: The path to the original source file that generated this
|
2589 |
+
// chunk of code,
|
2590 |
+
// originalLine: The line number in the original source that
|
2591 |
+
// corresponds to this chunk of generated code,
|
2592 |
+
// originalColumn: The column number in the original source that
|
2593 |
+
// corresponds to this chunk of generated code,
|
2594 |
+
// name: The name of the original symbol which generated this chunk of
|
2595 |
+
// code.
|
2596 |
+
// }
|
2597 |
+
//
|
2598 |
+
// All properties except for `generatedLine` and `generatedColumn` can be
|
2599 |
+
// `null`.
|
2600 |
+
//
|
2601 |
+
// `_generatedMappings` is ordered by the generated positions.
|
2602 |
+
//
|
2603 |
+
// `_originalMappings` is ordered by the original positions.
|
2604 |
+
|
2605 |
+
SourceMapConsumer.prototype.__generatedMappings = null;
|
2606 |
+
Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
|
2607 |
+
get: function () {
|
2608 |
+
if (!this.__generatedMappings) {
|
2609 |
+
this.__generatedMappings = [];
|
2610 |
+
this.__originalMappings = [];
|
2611 |
+
this._parseMappings(this._mappings, this.sourceRoot);
|
2612 |
+
}
|
2613 |
+
|
2614 |
+
return this.__generatedMappings;
|
2615 |
+
}
|
2616 |
+
});
|
2617 |
+
|
2618 |
+
SourceMapConsumer.prototype.__originalMappings = null;
|
2619 |
+
Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
|
2620 |
+
get: function () {
|
2621 |
+
if (!this.__originalMappings) {
|
2622 |
+
this.__generatedMappings = [];
|
2623 |
+
this.__originalMappings = [];
|
2624 |
+
this._parseMappings(this._mappings, this.sourceRoot);
|
2625 |
+
}
|
2626 |
+
|
2627 |
+
return this.__originalMappings;
|
2628 |
+
}
|
2629 |
+
});
|
2630 |
+
|
2631 |
+
SourceMapConsumer.prototype._nextCharIsMappingSeparator =
|
2632 |
+
function SourceMapConsumer_nextCharIsMappingSeparator(aStr) {
|
2633 |
+
var c = aStr.charAt(0);
|
2634 |
+
return c === ";" || c === ",";
|
2635 |
+
};
|
2636 |
+
|
2637 |
+
/**
|
2638 |
+
* Parse the mappings in a string in to a data structure which we can easily
|
2639 |
+
* query (the ordered arrays in the `this.__generatedMappings` and
|
2640 |
+
* `this.__originalMappings` properties).
|
2641 |
+
*/
|
2642 |
+
SourceMapConsumer.prototype._parseMappings =
|
2643 |
+
function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
|
2644 |
+
var generatedLine = 1;
|
2645 |
+
var previousGeneratedColumn = 0;
|
2646 |
+
var previousOriginalLine = 0;
|
2647 |
+
var previousOriginalColumn = 0;
|
2648 |
+
var previousSource = 0;
|
2649 |
+
var previousName = 0;
|
2650 |
+
var str = aStr;
|
2651 |
+
var temp = {};
|
2652 |
+
var mapping;
|
2653 |
+
|
2654 |
+
while (str.length > 0) {
|
2655 |
+
if (str.charAt(0) === ';') {
|
2656 |
+
generatedLine++;
|
2657 |
+
str = str.slice(1);
|
2658 |
+
previousGeneratedColumn = 0;
|
2659 |
+
}
|
2660 |
+
else if (str.charAt(0) === ',') {
|
2661 |
+
str = str.slice(1);
|
2662 |
+
}
|
2663 |
+
else {
|
2664 |
+
mapping = {};
|
2665 |
+
mapping.generatedLine = generatedLine;
|
2666 |
+
|
2667 |
+
// Generated column.
|
2668 |
+
base64VLQ.decode(str, temp);
|
2669 |
+
mapping.generatedColumn = previousGeneratedColumn + temp.value;
|
2670 |
+
previousGeneratedColumn = mapping.generatedColumn;
|
2671 |
+
str = temp.rest;
|
2672 |
+
|
2673 |
+
if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) {
|
2674 |
+
// Original source.
|
2675 |
+
base64VLQ.decode(str, temp);
|
2676 |
+
mapping.source = this._sources.at(previousSource + temp.value);
|
2677 |
+
previousSource += temp.value;
|
2678 |
+
str = temp.rest;
|
2679 |
+
if (str.length === 0 || this._nextCharIsMappingSeparator(str)) {
|
2680 |
+
throw new Error('Found a source, but no line and column');
|
2681 |
+
}
|
2682 |
|
2683 |
+
// Original line.
|
2684 |
+
base64VLQ.decode(str, temp);
|
2685 |
+
mapping.originalLine = previousOriginalLine + temp.value;
|
2686 |
+
previousOriginalLine = mapping.originalLine;
|
2687 |
+
// Lines are stored 0-based
|
2688 |
+
mapping.originalLine += 1;
|
2689 |
+
str = temp.rest;
|
2690 |
+
if (str.length === 0 || this._nextCharIsMappingSeparator(str)) {
|
2691 |
+
throw new Error('Found a source and line, but no column');
|
2692 |
+
}
|
2693 |
|
2694 |
+
// Original column.
|
2695 |
+
base64VLQ.decode(str, temp);
|
2696 |
+
mapping.originalColumn = previousOriginalColumn + temp.value;
|
2697 |
+
previousOriginalColumn = mapping.originalColumn;
|
2698 |
+
str = temp.rest;
|
2699 |
|
2700 |
+
if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) {
|
2701 |
+
// Original name.
|
2702 |
+
base64VLQ.decode(str, temp);
|
2703 |
+
mapping.name = this._names.at(previousName + temp.value);
|
2704 |
+
previousName += temp.value;
|
2705 |
+
str = temp.rest;
|
2706 |
+
}
|
2707 |
+
}
|
2708 |
+
|
2709 |
+
this.__generatedMappings.push(mapping);
|
2710 |
+
if (typeof mapping.originalLine === 'number') {
|
2711 |
+
this.__originalMappings.push(mapping);
|
2712 |
+
}
|
2713 |
+
}
|
2714 |
+
}
|
2715 |
|
2716 |
+
this.__generatedMappings.sort(util.compareByGeneratedPositions);
|
2717 |
+
this.__originalMappings.sort(util.compareByOriginalPositions);
|
|
|
|
|
|
|
|
|
2718 |
};
|
2719 |
|
2720 |
+
/**
|
2721 |
+
* Find the mapping that best matches the hypothetical "needle" mapping that
|
2722 |
+
* we are searching for in the given "haystack" of mappings.
|
2723 |
+
*/
|
2724 |
+
SourceMapConsumer.prototype._findMapping =
|
2725 |
+
function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
|
2726 |
+
aColumnName, aComparator) {
|
2727 |
+
// To return the position we are searching for, we must first find the
|
2728 |
+
// mapping for the given position and then return the opposite position it
|
2729 |
+
// points to. Because the mappings are sorted, we can use binary search to
|
2730 |
+
// find the best mapping.
|
2731 |
|
2732 |
+
if (aNeedle[aLineName] <= 0) {
|
2733 |
+
throw new TypeError('Line must be greater than or equal to 1, got '
|
2734 |
+
+ aNeedle[aLineName]);
|
2735 |
+
}
|
2736 |
+
if (aNeedle[aColumnName] < 0) {
|
2737 |
+
throw new TypeError('Column must be greater than or equal to 0, got '
|
2738 |
+
+ aNeedle[aColumnName]);
|
2739 |
+
}
|
2740 |
|
2741 |
+
return binarySearch.search(aNeedle, aMappings, aComparator);
|
2742 |
+
};
|
2743 |
+
|
2744 |
+
/**
|
2745 |
+
* Compute the last column for each generated mapping. The last column is
|
2746 |
+
* inclusive.
|
2747 |
+
*/
|
2748 |
+
SourceMapConsumer.prototype.computeColumnSpans =
|
2749 |
+
function SourceMapConsumer_computeColumnSpans() {
|
2750 |
+
for (var index = 0; index < this._generatedMappings.length; ++index) {
|
2751 |
+
var mapping = this._generatedMappings[index];
|
2752 |
+
|
2753 |
+
// Mappings do not contain a field for the last generated columnt. We
|
2754 |
+
// can come up with an optimistic estimate, however, by assuming that
|
2755 |
+
// mappings are contiguous (i.e. given two consecutive mappings, the
|
2756 |
+
// first mapping ends where the second one starts).
|
2757 |
+
if (index + 1 < this._generatedMappings.length) {
|
2758 |
+
var nextMapping = this._generatedMappings[index + 1];
|
2759 |
+
|
2760 |
+
if (mapping.generatedLine === nextMapping.generatedLine) {
|
2761 |
+
mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
|
2762 |
+
continue;
|
2763 |
+
}
|
2764 |
+
}
|
2765 |
|
2766 |
+
// The last mapping for each line spans the entire line.
|
2767 |
+
mapping.lastGeneratedColumn = Infinity;
|
2768 |
+
}
|
2769 |
};
|
2770 |
|
2771 |
+
/**
|
2772 |
+
* Returns the original source, line, and column information for the generated
|
2773 |
+
* source's line and column positions provided. The only argument is an object
|
2774 |
+
* with the following properties:
|
2775 |
+
*
|
2776 |
+
* - line: The line number in the generated source.
|
2777 |
+
* - column: The column number in the generated source.
|
2778 |
+
*
|
2779 |
+
* and an object is returned with the following properties:
|
2780 |
+
*
|
2781 |
+
* - source: The original source file, or null.
|
2782 |
+
* - line: The line number in the original source, or null.
|
2783 |
+
* - column: The column number in the original source, or null.
|
2784 |
+
* - name: The original identifier, or null.
|
2785 |
+
*/
|
2786 |
+
SourceMapConsumer.prototype.originalPositionFor =
|
2787 |
+
function SourceMapConsumer_originalPositionFor(aArgs) {
|
2788 |
+
var needle = {
|
2789 |
+
generatedLine: util.getArg(aArgs, 'line'),
|
2790 |
+
generatedColumn: util.getArg(aArgs, 'column')
|
2791 |
+
};
|
2792 |
|
2793 |
+
var index = this._findMapping(needle,
|
2794 |
+
this._generatedMappings,
|
2795 |
+
"generatedLine",
|
2796 |
+
"generatedColumn",
|
2797 |
+
util.compareByGeneratedPositions);
|
2798 |
|
2799 |
+
if (index >= 0) {
|
2800 |
+
var mapping = this._generatedMappings[index];
|
|
|
2801 |
|
2802 |
+
if (mapping.generatedLine === needle.generatedLine) {
|
2803 |
+
var source = util.getArg(mapping, 'source', null);
|
2804 |
+
if (source != null && this.sourceRoot != null) {
|
2805 |
+
source = util.join(this.sourceRoot, source);
|
2806 |
+
}
|
2807 |
+
return {
|
2808 |
+
source: source,
|
2809 |
+
line: util.getArg(mapping, 'originalLine', null),
|
2810 |
+
column: util.getArg(mapping, 'originalColumn', null),
|
2811 |
+
name: util.getArg(mapping, 'name', null)
|
2812 |
+
};
|
2813 |
}
|
2814 |
+
}
|
2815 |
|
2816 |
+
return {
|
2817 |
+
source: null,
|
2818 |
+
line: null,
|
2819 |
+
column: null,
|
2820 |
+
name: null
|
2821 |
+
};
|
2822 |
+
};
|
2823 |
|
2824 |
+
/**
|
2825 |
+
* Returns the original source content. The only argument is the url of the
|
2826 |
+
* original source file. Returns null if no original source content is
|
2827 |
+
* availible.
|
2828 |
+
*/
|
2829 |
+
SourceMapConsumer.prototype.sourceContentFor =
|
2830 |
+
function SourceMapConsumer_sourceContentFor(aSource) {
|
2831 |
+
if (!this.sourcesContent) {
|
2832 |
+
return null;
|
2833 |
+
}
|
2834 |
+
|
2835 |
+
if (this.sourceRoot != null) {
|
2836 |
+
aSource = util.relative(this.sourceRoot, aSource);
|
2837 |
+
}
|
2838 |
+
|
2839 |
+
if (this._sources.has(aSource)) {
|
2840 |
+
return this.sourcesContent[this._sources.indexOf(aSource)];
|
2841 |
+
}
|
2842 |
+
|
2843 |
+
var url;
|
2844 |
+
if (this.sourceRoot != null
|
2845 |
+
&& (url = util.urlParse(this.sourceRoot))) {
|
2846 |
+
// XXX: file:// URIs and absolute paths lead to unexpected behavior for
|
2847 |
+
// many users. We can help them out when they expect file:// URIs to
|
2848 |
+
// behave like it would if they were running a local HTTP server. See
|
2849 |
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
|
2850 |
+
var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
|
2851 |
+
if (url.scheme == "file"
|
2852 |
+
&& this._sources.has(fileUriAbsPath)) {
|
2853 |
+
return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
|
2854 |
}
|
2855 |
+
|
2856 |
+
if ((!url.path || url.path == "/")
|
2857 |
+
&& this._sources.has("/" + aSource)) {
|
2858 |
+
return this.sourcesContent[this._sources.indexOf("/" + aSource)];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2859 |
}
|
2860 |
+
}
|
2861 |
|
2862 |
+
throw new Error('"' + aSource + '" is not in the SourceMap.');
|
2863 |
+
};
|
2864 |
|
2865 |
+
/**
|
2866 |
+
* Returns the generated line and column information for the original source,
|
2867 |
+
* line, and column positions provided. The only argument is an object with
|
2868 |
+
* the following properties:
|
2869 |
+
*
|
2870 |
+
* - source: The filename of the original source.
|
2871 |
+
* - line: The line number in the original source.
|
2872 |
+
* - column: The column number in the original source.
|
2873 |
+
*
|
2874 |
+
* and an object is returned with the following properties:
|
2875 |
+
*
|
2876 |
+
* - line: The line number in the generated source, or null.
|
2877 |
+
* - column: The column number in the generated source, or null.
|
2878 |
+
*/
|
2879 |
+
SourceMapConsumer.prototype.generatedPositionFor =
|
2880 |
+
function SourceMapConsumer_generatedPositionFor(aArgs) {
|
2881 |
+
var needle = {
|
2882 |
+
source: util.getArg(aArgs, 'source'),
|
2883 |
+
originalLine: util.getArg(aArgs, 'line'),
|
2884 |
+
originalColumn: util.getArg(aArgs, 'column')
|
2885 |
+
};
|
2886 |
|
2887 |
+
if (this.sourceRoot != null) {
|
2888 |
+
needle.source = util.relative(this.sourceRoot, needle.source);
|
2889 |
+
}
|
|
|
|
|
|
|
|
|
|
|
2890 |
|
2891 |
+
var index = this._findMapping(needle,
|
2892 |
+
this._originalMappings,
|
2893 |
+
"originalLine",
|
2894 |
+
"originalColumn",
|
2895 |
+
util.compareByOriginalPositions);
|
2896 |
+
|
2897 |
+
if (index >= 0) {
|
2898 |
+
var mapping = this._originalMappings[index];
|
2899 |
+
|
2900 |
+
return {
|
2901 |
+
line: util.getArg(mapping, 'generatedLine', null),
|
2902 |
+
column: util.getArg(mapping, 'generatedColumn', null),
|
2903 |
+
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
|
2904 |
+
};
|
2905 |
+
}
|
2906 |
+
|
2907 |
+
return {
|
2908 |
+
line: null,
|
2909 |
+
column: null,
|
2910 |
+
lastColumn: null
|
2911 |
+
};
|
2912 |
+
};
|
2913 |
+
|
2914 |
+
/**
|
2915 |
+
* Returns all generated line and column information for the original source
|
2916 |
+
* and line provided. The only argument is an object with the following
|
2917 |
+
* properties:
|
2918 |
+
*
|
2919 |
+
* - source: The filename of the original source.
|
2920 |
+
* - line: The line number in the original source.
|
2921 |
+
*
|
2922 |
+
* and an array of objects is returned, each with the following properties:
|
2923 |
+
*
|
2924 |
+
* - line: The line number in the generated source, or null.
|
2925 |
+
* - column: The column number in the generated source, or null.
|
2926 |
+
*/
|
2927 |
+
SourceMapConsumer.prototype.allGeneratedPositionsFor =
|
2928 |
+
function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
|
2929 |
+
// When there is no exact match, SourceMapConsumer.prototype._findMapping
|
2930 |
+
// returns the index of the closest mapping less than the needle. By
|
2931 |
+
// setting needle.originalColumn to Infinity, we thus find the last
|
2932 |
+
// mapping for the given line, provided such a mapping exists.
|
2933 |
+
var needle = {
|
2934 |
+
source: util.getArg(aArgs, 'source'),
|
2935 |
+
originalLine: util.getArg(aArgs, 'line'),
|
2936 |
+
originalColumn: Infinity
|
2937 |
+
};
|
2938 |
+
|
2939 |
+
if (this.sourceRoot != null) {
|
2940 |
+
needle.source = util.relative(this.sourceRoot, needle.source);
|
2941 |
+
}
|
2942 |
+
|
2943 |
+
var mappings = [];
|
2944 |
+
|
2945 |
+
var index = this._findMapping(needle,
|
2946 |
+
this._originalMappings,
|
2947 |
+
"originalLine",
|
2948 |
+
"originalColumn",
|
2949 |
+
util.compareByOriginalPositions);
|
2950 |
+
if (index >= 0) {
|
2951 |
+
var mapping = this._originalMappings[index];
|
2952 |
+
|
2953 |
+
while (mapping && mapping.originalLine === needle.originalLine) {
|
2954 |
+
mappings.push({
|
2955 |
+
line: util.getArg(mapping, 'generatedLine', null),
|
2956 |
+
column: util.getArg(mapping, 'generatedColumn', null),
|
2957 |
+
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
|
2958 |
+
});
|
2959 |
+
|
2960 |
+
mapping = this._originalMappings[--index];
|
2961 |
}
|
2962 |
+
}
|
2963 |
|
2964 |
+
return mappings.reverse();
|
2965 |
};
|
2966 |
|
2967 |
+
SourceMapConsumer.GENERATED_ORDER = 1;
|
2968 |
+
SourceMapConsumer.ORIGINAL_ORDER = 2;
|
|
|
2969 |
|
2970 |
+
/**
|
2971 |
+
* Iterate over each mapping between an original source/line/column and a
|
2972 |
+
* generated line/column in this source map.
|
2973 |
+
*
|
2974 |
+
* @param Function aCallback
|
2975 |
+
* The function that is called with each mapping.
|
2976 |
+
* @param Object aContext
|
2977 |
+
* Optional. If specified, this object will be the value of `this` every
|
2978 |
+
* time that `aCallback` is called.
|
2979 |
+
* @param aOrder
|
2980 |
+
* Either `SourceMapConsumer.GENERATED_ORDER` or
|
2981 |
+
* `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
|
2982 |
+
* iterate over the mappings sorted by the generated file's line/column
|
2983 |
+
* order or the original's source/line/column order, respectively. Defaults to
|
2984 |
+
* `SourceMapConsumer.GENERATED_ORDER`.
|
2985 |
+
*/
|
2986 |
+
SourceMapConsumer.prototype.eachMapping =
|
2987 |
+
function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
|
2988 |
+
var context = aContext || null;
|
2989 |
+
var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
|
2990 |
+
|
2991 |
+
var mappings;
|
2992 |
+
switch (order) {
|
2993 |
+
case SourceMapConsumer.GENERATED_ORDER:
|
2994 |
+
mappings = this._generatedMappings;
|
2995 |
+
break;
|
2996 |
+
case SourceMapConsumer.ORIGINAL_ORDER:
|
2997 |
+
mappings = this._originalMappings;
|
2998 |
+
break;
|
2999 |
+
default:
|
3000 |
+
throw new Error("Unknown order of iteration.");
|
3001 |
+
}
|
3002 |
+
|
3003 |
+
var sourceRoot = this.sourceRoot;
|
3004 |
+
mappings.map(function (mapping) {
|
3005 |
+
var source = mapping.source;
|
3006 |
+
if (source != null && sourceRoot != null) {
|
3007 |
+
source = util.join(sourceRoot, source);
|
3008 |
+
}
|
3009 |
+
return {
|
3010 |
+
source: source,
|
3011 |
+
generatedLine: mapping.generatedLine,
|
3012 |
+
generatedColumn: mapping.generatedColumn,
|
3013 |
+
originalLine: mapping.originalLine,
|
3014 |
+
originalColumn: mapping.originalColumn,
|
3015 |
+
name: mapping.name
|
3016 |
+
};
|
3017 |
+
}).forEach(aCallback, context);
|
3018 |
+
};
|
3019 |
+
|
3020 |
+
exports.SourceMapConsumer = SourceMapConsumer;
|
3021 |
+
|
3022 |
+
});
|
3023 |
+
|
3024 |
+
},{"./array-set":17,"./base64-vlq":18,"./binary-search":20,"./util":25,"amdefine":26}],23:[function(require,module,exports){
|
3025 |
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
3026 |
+
/*
|
3027 |
+
* Copyright 2011 Mozilla Foundation and contributors
|
3028 |
+
* Licensed under the New BSD license. See LICENSE or:
|
3029 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
3030 |
+
*/
|
3031 |
+
if (typeof define !== 'function') {
|
3032 |
+
var define = require('amdefine')(module, require);
|
3033 |
+
}
|
3034 |
+
define(function (require, exports, module) {
|
3035 |
+
|
3036 |
+
var base64VLQ = require('./base64-vlq');
|
3037 |
+
var util = require('./util');
|
3038 |
+
var ArraySet = require('./array-set').ArraySet;
|
3039 |
+
var MappingList = require('./mapping-list').MappingList;
|
3040 |
+
|
3041 |
+
/**
|
3042 |
+
* An instance of the SourceMapGenerator represents a source map which is
|
3043 |
+
* being built incrementally. You may pass an object with the following
|
3044 |
+
* properties:
|
3045 |
+
*
|
3046 |
+
* - file: The filename of the generated source.
|
3047 |
+
* - sourceRoot: A root for all relative URLs in this source map.
|
3048 |
+
*/
|
3049 |
+
function SourceMapGenerator(aArgs) {
|
3050 |
+
if (!aArgs) {
|
3051 |
+
aArgs = {};
|
3052 |
+
}
|
3053 |
+
this._file = util.getArg(aArgs, 'file', null);
|
3054 |
+
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
|
3055 |
+
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
|
3056 |
+
this._sources = new ArraySet();
|
3057 |
+
this._names = new ArraySet();
|
3058 |
+
this._mappings = new MappingList();
|
3059 |
+
this._sourcesContents = null;
|
3060 |
+
}
|
3061 |
+
|
3062 |
+
SourceMapGenerator.prototype._version = 3;
|
3063 |
+
|
3064 |
+
/**
|
3065 |
+
* Creates a new SourceMapGenerator based on a SourceMapConsumer
|
3066 |
+
*
|
3067 |
+
* @param aSourceMapConsumer The SourceMap.
|
3068 |
+
*/
|
3069 |
+
SourceMapGenerator.fromSourceMap =
|
3070 |
+
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
|
3071 |
+
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
3072 |
+
var generator = new SourceMapGenerator({
|
3073 |
+
file: aSourceMapConsumer.file,
|
3074 |
+
sourceRoot: sourceRoot
|
3075 |
+
});
|
3076 |
+
aSourceMapConsumer.eachMapping(function (mapping) {
|
3077 |
+
var newMapping = {
|
3078 |
+
generated: {
|
3079 |
+
line: mapping.generatedLine,
|
3080 |
+
column: mapping.generatedColumn
|
3081 |
+
}
|
3082 |
+
};
|
3083 |
+
|
3084 |
+
if (mapping.source != null) {
|
3085 |
+
newMapping.source = mapping.source;
|
3086 |
+
if (sourceRoot != null) {
|
3087 |
+
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
3088 |
+
}
|
3089 |
+
|
3090 |
+
newMapping.original = {
|
3091 |
+
line: mapping.originalLine,
|
3092 |
+
column: mapping.originalColumn
|
3093 |
+
};
|
3094 |
+
|
3095 |
+
if (mapping.name != null) {
|
3096 |
+
newMapping.name = mapping.name;
|
3097 |
+
}
|
3098 |
}
|
3099 |
|
3100 |
+
generator.addMapping(newMapping);
|
3101 |
+
});
|
3102 |
+
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
3103 |
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
3104 |
+
if (content != null) {
|
3105 |
+
generator.setSourceContent(sourceFile, content);
|
3106 |
+
}
|
3107 |
+
});
|
3108 |
+
return generator;
|
3109 |
};
|
3110 |
|
3111 |
+
/**
|
3112 |
+
* Add a single mapping from original source line and column to the generated
|
3113 |
+
* source's line and column for this source map being created. The mapping
|
3114 |
+
* object should have the following properties:
|
3115 |
+
*
|
3116 |
+
* - generated: An object with the generated line and column positions.
|
3117 |
+
* - original: An object with the original line and column positions.
|
3118 |
+
* - source: The original source file (relative to the sourceRoot).
|
3119 |
+
* - name: An optional original token name for this mapping.
|
3120 |
+
*/
|
3121 |
+
SourceMapGenerator.prototype.addMapping =
|
3122 |
+
function SourceMapGenerator_addMapping(aArgs) {
|
3123 |
+
var generated = util.getArg(aArgs, 'generated');
|
3124 |
+
var original = util.getArg(aArgs, 'original', null);
|
3125 |
+
var source = util.getArg(aArgs, 'source', null);
|
3126 |
+
var name = util.getArg(aArgs, 'name', null);
|
3127 |
+
|
3128 |
+
if (!this._skipValidation) {
|
3129 |
+
this._validateMapping(generated, original, source, name);
|
3130 |
+
}
|
3131 |
+
|
3132 |
+
if (source != null && !this._sources.has(source)) {
|
3133 |
+
this._sources.add(source);
|
3134 |
+
}
|
3135 |
+
|
3136 |
+
if (name != null && !this._names.has(name)) {
|
3137 |
+
this._names.add(name);
|
3138 |
+
}
|
3139 |
+
|
3140 |
+
this._mappings.add({
|
3141 |
+
generatedLine: generated.line,
|
3142 |
+
generatedColumn: generated.column,
|
3143 |
+
originalLine: original != null && original.line,
|
3144 |
+
originalColumn: original != null && original.column,
|
3145 |
+
source: source,
|
3146 |
+
name: name
|
3147 |
+
});
|
3148 |
+
};
|
3149 |
+
|
3150 |
+
/**
|
3151 |
+
* Set the source content for a source file.
|
3152 |
+
*/
|
3153 |
+
SourceMapGenerator.prototype.setSourceContent =
|
3154 |
+
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
|
3155 |
+
var source = aSourceFile;
|
3156 |
+
if (this._sourceRoot != null) {
|
3157 |
+
source = util.relative(this._sourceRoot, source);
|
3158 |
+
}
|
3159 |
+
|
3160 |
+
if (aSourceContent != null) {
|
3161 |
+
// Add the source content to the _sourcesContents map.
|
3162 |
+
// Create a new _sourcesContents map if the property is null.
|
3163 |
+
if (!this._sourcesContents) {
|
3164 |
+
this._sourcesContents = {};
|
3165 |
+
}
|
3166 |
+
this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
3167 |
+
} else if (this._sourcesContents) {
|
3168 |
+
// Remove the source file from the _sourcesContents map.
|
3169 |
+
// If the _sourcesContents map is empty, set the property to null.
|
3170 |
+
delete this._sourcesContents[util.toSetString(source)];
|
3171 |
+
if (Object.keys(this._sourcesContents).length === 0) {
|
3172 |
+
this._sourcesContents = null;
|
3173 |
}
|
3174 |
+
}
|
3175 |
};
|
3176 |
|
3177 |
+
/**
|
3178 |
+
* Applies the mappings of a sub-source-map for a specific source file to the
|
3179 |
+
* source map being generated. Each mapping to the supplied source file is
|
3180 |
+
* rewritten using the supplied source map. Note: The resolution for the
|
3181 |
+
* resulting mappings is the minimium of this map and the supplied map.
|
3182 |
+
*
|
3183 |
+
* @param aSourceMapConsumer The source map to be applied.
|
3184 |
+
* @param aSourceFile Optional. The filename of the source file.
|
3185 |
+
* If omitted, SourceMapConsumer's file property will be used.
|
3186 |
+
* @param aSourceMapPath Optional. The dirname of the path to the source map
|
3187 |
+
* to be applied. If relative, it is relative to the SourceMapConsumer.
|
3188 |
+
* This parameter is needed when the two source maps aren't in the same
|
3189 |
+
* directory, and the source map to be applied contains relative source
|
3190 |
+
* paths. If so, those relative source paths need to be rewritten
|
3191 |
+
* relative to the SourceMapGenerator.
|
3192 |
+
*/
|
3193 |
+
SourceMapGenerator.prototype.applySourceMap =
|
3194 |
+
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
|
3195 |
+
var sourceFile = aSourceFile;
|
3196 |
+
// If aSourceFile is omitted, we will use the file property of the SourceMap
|
3197 |
+
if (aSourceFile == null) {
|
3198 |
+
if (aSourceMapConsumer.file == null) {
|
3199 |
+
throw new Error(
|
3200 |
+
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
|
3201 |
+
'or the source map\'s "file" property. Both were omitted.'
|
3202 |
+
);
|
3203 |
}
|
3204 |
+
sourceFile = aSourceMapConsumer.file;
|
3205 |
+
}
|
3206 |
+
var sourceRoot = this._sourceRoot;
|
3207 |
+
// Make "sourceFile" relative if an absolute Url is passed.
|
3208 |
+
if (sourceRoot != null) {
|
3209 |
+
sourceFile = util.relative(sourceRoot, sourceFile);
|
3210 |
+
}
|
3211 |
+
// Applying the SourceMap can add and remove items from the sources and
|
3212 |
+
// the names array.
|
3213 |
+
var newSources = new ArraySet();
|
3214 |
+
var newNames = new ArraySet();
|
3215 |
|
3216 |
+
// Find mappings for the "sourceFile"
|
3217 |
+
this._mappings.unsortedForEach(function (mapping) {
|
3218 |
+
if (mapping.source === sourceFile && mapping.originalLine != null) {
|
3219 |
+
// Check if it can be mapped by the source map, then update the mapping.
|
3220 |
+
var original = aSourceMapConsumer.originalPositionFor({
|
3221 |
+
line: mapping.originalLine,
|
3222 |
+
column: mapping.originalColumn
|
3223 |
+
});
|
3224 |
+
if (original.source != null) {
|
3225 |
+
// Copy mapping
|
3226 |
+
mapping.source = original.source;
|
3227 |
+
if (aSourceMapPath != null) {
|
3228 |
+
mapping.source = util.join(aSourceMapPath, mapping.source)
|
3229 |
}
|
3230 |
+
if (sourceRoot != null) {
|
3231 |
+
mapping.source = util.relative(sourceRoot, mapping.source);
|
3232 |
+
}
|
3233 |
+
mapping.originalLine = original.line;
|
3234 |
+
mapping.originalColumn = original.column;
|
3235 |
+
if (original.name != null) {
|
3236 |
+
mapping.name = original.name;
|
3237 |
}
|
3238 |
+
}
|
3239 |
+
}
|
3240 |
+
|
3241 |
+
var source = mapping.source;
|
3242 |
+
if (source != null && !newSources.has(source)) {
|
3243 |
+
newSources.add(source);
|
3244 |
+
}
|
3245 |
+
|
3246 |
+
var name = mapping.name;
|
3247 |
+
if (name != null && !newNames.has(name)) {
|
3248 |
+
newNames.add(name);
|
3249 |
+
}
|
3250 |
+
|
3251 |
+
}, this);
|
3252 |
+
this._sources = newSources;
|
3253 |
+
this._names = newNames;
|
3254 |
|
3255 |
+
// Copy sourcesContents of applied map.
|
3256 |
+
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
3257 |
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
3258 |
+
if (content != null) {
|
3259 |
+
if (aSourceMapPath != null) {
|
3260 |
+
sourceFile = util.join(aSourceMapPath, sourceFile);
|
3261 |
+
}
|
3262 |
+
if (sourceRoot != null) {
|
3263 |
+
sourceFile = util.relative(sourceRoot, sourceFile);
|
3264 |
+
}
|
3265 |
+
this.setSourceContent(sourceFile, content);
|
3266 |
}
|
3267 |
+
}, this);
|
3268 |
+
};
|
3269 |
+
|
3270 |
+
/**
|
3271 |
+
* A mapping can have one of the three levels of data:
|
3272 |
+
*
|
3273 |
+
* 1. Just the generated position.
|
3274 |
+
* 2. The Generated position, original position, and original source.
|
3275 |
+
* 3. Generated and original position, original source, as well as a name
|
3276 |
+
* token.
|
3277 |
+
*
|
3278 |
+
* To maintain consistency, we validate that any new mapping being added falls
|
3279 |
+
* in to one of these categories.
|
3280 |
+
*/
|
3281 |
+
SourceMapGenerator.prototype._validateMapping =
|
3282 |
+
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
|
3283 |
+
aName) {
|
3284 |
+
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
3285 |
+
&& aGenerated.line > 0 && aGenerated.column >= 0
|
3286 |
+
&& !aOriginal && !aSource && !aName) {
|
3287 |
+
// Case 1.
|
3288 |
+
return;
|
3289 |
+
}
|
3290 |
+
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
3291 |
+
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
|
3292 |
+
&& aGenerated.line > 0 && aGenerated.column >= 0
|
3293 |
+
&& aOriginal.line > 0 && aOriginal.column >= 0
|
3294 |
+
&& aSource) {
|
3295 |
+
// Cases 2 and 3.
|
3296 |
+
return;
|
3297 |
+
}
|
3298 |
+
else {
|
3299 |
+
throw new Error('Invalid mapping: ' + JSON.stringify({
|
3300 |
+
generated: aGenerated,
|
3301 |
+
source: aSource,
|
3302 |
+
original: aOriginal,
|
3303 |
+
name: aName
|
3304 |
+
}));
|
3305 |
+
}
|
3306 |
+
};
|
3307 |
+
|
3308 |
+
/**
|
3309 |
+
* Serialize the accumulated mappings in to the stream of base 64 VLQs
|
3310 |
+
* specified by the source map format.
|
3311 |
+
*/
|
3312 |
+
SourceMapGenerator.prototype._serializeMappings =
|
3313 |
+
function SourceMapGenerator_serializeMappings() {
|
3314 |
+
var previousGeneratedColumn = 0;
|
3315 |
+
var previousGeneratedLine = 1;
|
3316 |
+
var previousOriginalColumn = 0;
|
3317 |
+
var previousOriginalLine = 0;
|
3318 |
+
var previousName = 0;
|
3319 |
+
var previousSource = 0;
|
3320 |
+
var result = '';
|
3321 |
+
var mapping;
|
3322 |
+
|
3323 |
+
var mappings = this._mappings.toArray();
|
3324 |
+
|
3325 |
+
for (var i = 0, len = mappings.length; i < len; i++) {
|
3326 |
+
mapping = mappings[i];
|
3327 |
+
|
3328 |
+
if (mapping.generatedLine !== previousGeneratedLine) {
|
3329 |
+
previousGeneratedColumn = 0;
|
3330 |
+
while (mapping.generatedLine !== previousGeneratedLine) {
|
3331 |
+
result += ';';
|
3332 |
+
previousGeneratedLine++;
|
3333 |
+
}
|
3334 |
}
|
3335 |
else {
|
3336 |
+
if (i > 0) {
|
3337 |
+
if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) {
|
3338 |
+
continue;
|
3339 |
}
|
3340 |
+
result += ',';
|
3341 |
+
}
|
3342 |
+
}
|
3343 |
+
|
3344 |
+
result += base64VLQ.encode(mapping.generatedColumn
|
3345 |
+
- previousGeneratedColumn);
|
3346 |
+
previousGeneratedColumn = mapping.generatedColumn;
|
3347 |
+
|
3348 |
+
if (mapping.source != null) {
|
3349 |
+
result += base64VLQ.encode(this._sources.indexOf(mapping.source)
|
3350 |
+
- previousSource);
|
3351 |
+
previousSource = this._sources.indexOf(mapping.source);
|
3352 |
+
|
3353 |
+
// lines are stored 0-based in SourceMap spec version 3
|
3354 |
+
result += base64VLQ.encode(mapping.originalLine - 1
|
3355 |
+
- previousOriginalLine);
|
3356 |
+
previousOriginalLine = mapping.originalLine - 1;
|
3357 |
+
|
3358 |
+
result += base64VLQ.encode(mapping.originalColumn
|
3359 |
+
- previousOriginalColumn);
|
3360 |
+
previousOriginalColumn = mapping.originalColumn;
|
3361 |
+
|
3362 |
+
if (mapping.name != null) {
|
3363 |
+
result += base64VLQ.encode(this._names.indexOf(mapping.name)
|
3364 |
+
- previousName);
|
3365 |
+
previousName = this._names.indexOf(mapping.name);
|
3366 |
+
}
|
3367 |
}
|
3368 |
+
}
|
3369 |
+
|
3370 |
+
return result;
|
3371 |
};
|
3372 |
|
3373 |
+
SourceMapGenerator.prototype._generateSourcesContent =
|
3374 |
+
function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
|
3375 |
+
return aSources.map(function (source) {
|
3376 |
+
if (!this._sourcesContents) {
|
3377 |
+
return null;
|
|
|
|
|
|
|
|
|
3378 |
}
|
3379 |
+
if (aSourceRoot != null) {
|
3380 |
+
source = util.relative(aSourceRoot, source);
|
3381 |
+
}
|
3382 |
+
var key = util.toSetString(source);
|
3383 |
+
return Object.prototype.hasOwnProperty.call(this._sourcesContents,
|
3384 |
+
key)
|
3385 |
+
? this._sourcesContents[key]
|
3386 |
+
: null;
|
3387 |
+
}, this);
|
3388 |
};
|
3389 |
|
3390 |
+
/**
|
3391 |
+
* Externalize the source map.
|
3392 |
+
*/
|
3393 |
+
SourceMapGenerator.prototype.toJSON =
|
3394 |
+
function SourceMapGenerator_toJSON() {
|
3395 |
+
var map = {
|
3396 |
+
version: this._version,
|
3397 |
+
sources: this._sources.toArray(),
|
3398 |
+
names: this._names.toArray(),
|
3399 |
+
mappings: this._serializeMappings()
|
3400 |
+
};
|
3401 |
+
if (this._file != null) {
|
3402 |
+
map.file = this._file;
|
3403 |
+
}
|
3404 |
+
if (this._sourceRoot != null) {
|
3405 |
+
map.sourceRoot = this._sourceRoot;
|
3406 |
+
}
|
3407 |
+
if (this._sourcesContents) {
|
3408 |
+
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
|
3409 |
+
}
|
3410 |
|
3411 |
+
return map;
|
3412 |
+
};
|
|
|
|
|
|
|
|
|
3413 |
|
3414 |
+
/**
|
3415 |
+
* Render the source map being generated to a string.
|
3416 |
+
*/
|
3417 |
+
SourceMapGenerator.prototype.toString =
|
3418 |
+
function SourceMapGenerator_toString() {
|
3419 |
+
return JSON.stringify(this);
|
3420 |
};
|
3421 |
|
3422 |
+
exports.SourceMapGenerator = SourceMapGenerator;
|
|
|
|
|
|
|
|
|
|
|
3423 |
|
3424 |
+
});
|
3425 |
|
3426 |
+
},{"./array-set":17,"./base64-vlq":18,"./mapping-list":21,"./util":25,"amdefine":26}],24:[function(require,module,exports){
|
3427 |
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
3428 |
+
/*
|
3429 |
+
* Copyright 2011 Mozilla Foundation and contributors
|
3430 |
+
* Licensed under the New BSD license. See LICENSE or:
|
3431 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
3432 |
+
*/
|
3433 |
+
if (typeof define !== 'function') {
|
3434 |
+
var define = require('amdefine')(module, require);
|
3435 |
+
}
|
3436 |
+
define(function (require, exports, module) {
|
3437 |
|
3438 |
+
var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
|
3439 |
+
var util = require('./util');
|
|
|
3440 |
|
3441 |
+
// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
|
3442 |
+
// operating systems these days (capturing the result).
|
3443 |
+
var REGEX_NEWLINE = /(\r?\n)/;
|
3444 |
|
3445 |
+
// Newline character code for charCodeAt() comparisons
|
3446 |
+
var NEWLINE_CODE = 10;
|
|
|
|
|
|
|
|
|
3447 |
|
3448 |
+
// Private symbol for identifying `SourceNode`s when multiple versions of
|
3449 |
+
// the source-map library are loaded. This MUST NOT CHANGE across
|
3450 |
+
// versions!
|
3451 |
+
var isSourceNode = "$$$isSourceNode$$$";
|
3452 |
|
3453 |
+
/**
|
3454 |
+
* SourceNodes provide a way to abstract over interpolating/concatenating
|
3455 |
+
* snippets of generated JavaScript source code while maintaining the line and
|
3456 |
+
* column information associated with the original source code.
|
3457 |
+
*
|
3458 |
+
* @param aLine The original line number.
|
3459 |
+
* @param aColumn The original column number.
|
3460 |
+
* @param aSource The original source's filename.
|
3461 |
+
* @param aChunks Optional. An array of strings which are snippets of
|
3462 |
+
* generated JS, or other SourceNodes.
|
3463 |
+
* @param aName The original identifier.
|
3464 |
+
*/
|
3465 |
+
function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
|
3466 |
+
this.children = [];
|
3467 |
+
this.sourceContents = {};
|
3468 |
+
this.line = aLine == null ? null : aLine;
|
3469 |
+
this.column = aColumn == null ? null : aColumn;
|
3470 |
+
this.source = aSource == null ? null : aSource;
|
3471 |
+
this.name = aName == null ? null : aName;
|
3472 |
+
this[isSourceNode] = true;
|
3473 |
+
if (aChunks != null) this.add(aChunks);
|
3474 |
+
}
|
3475 |
+
|
3476 |
+
/**
|
3477 |
+
* Creates a SourceNode from generated code and a SourceMapConsumer.
|
3478 |
+
*
|
3479 |
+
* @param aGeneratedCode The generated code
|
3480 |
+
* @param aSourceMapConsumer The SourceMap for the generated code
|
3481 |
+
* @param aRelativePath Optional. The path that relative sources in the
|
3482 |
+
* SourceMapConsumer should be relative to.
|
3483 |
+
*/
|
3484 |
+
SourceNode.fromStringWithSourceMap =
|
3485 |
+
function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
|
3486 |
+
// The SourceNode we want to fill with the generated code
|
3487 |
+
// and the SourceMap
|
3488 |
+
var node = new SourceNode();
|
3489 |
+
|
3490 |
+
// All even indices of this array are one line of the generated code,
|
3491 |
+
// while all odd indices are the newlines between two adjacent lines
|
3492 |
+
// (since `REGEX_NEWLINE` captures its match).
|
3493 |
+
// Processed fragments are removed from this array, by calling `shiftNextLine`.
|
3494 |
+
var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
|
3495 |
+
var shiftNextLine = function() {
|
3496 |
+
var lineContents = remainingLines.shift();
|
3497 |
+
// The last line of a file might not have a newline.
|
3498 |
+
var newLine = remainingLines.shift() || "";
|
3499 |
+
return lineContents + newLine;
|
3500 |
+
};
|
3501 |
+
|
3502 |
+
// We need to remember the position of "remainingLines"
|
3503 |
+
var lastGeneratedLine = 1, lastGeneratedColumn = 0;
|
3504 |
+
|
3505 |
+
// The generate SourceNodes we need a code range.
|
3506 |
+
// To extract it current and last mapping is used.
|
3507 |
+
// Here we store the last mapping.
|
3508 |
+
var lastMapping = null;
|
3509 |
+
|
3510 |
+
aSourceMapConsumer.eachMapping(function (mapping) {
|
3511 |
+
if (lastMapping !== null) {
|
3512 |
+
// We add the code from "lastMapping" to "mapping":
|
3513 |
+
// First check if there is a new line in between.
|
3514 |
+
if (lastGeneratedLine < mapping.generatedLine) {
|
3515 |
+
var code = "";
|
3516 |
+
// Associate first line with "lastMapping"
|
3517 |
+
addMappingWithCode(lastMapping, shiftNextLine());
|
3518 |
+
lastGeneratedLine++;
|
3519 |
+
lastGeneratedColumn = 0;
|
3520 |
+
// The remaining code is added without mapping
|
3521 |
+
} else {
|
3522 |
+
// There is no new line in between.
|
3523 |
+
// Associate the code between "lastGeneratedColumn" and
|
3524 |
+
// "mapping.generatedColumn" with "lastMapping"
|
3525 |
+
var nextLine = remainingLines[0];
|
3526 |
+
var code = nextLine.substr(0, mapping.generatedColumn -
|
3527 |
+
lastGeneratedColumn);
|
3528 |
+
remainingLines[0] = nextLine.substr(mapping.generatedColumn -
|
3529 |
+
lastGeneratedColumn);
|
3530 |
+
lastGeneratedColumn = mapping.generatedColumn;
|
3531 |
+
addMappingWithCode(lastMapping, code);
|
3532 |
+
// No more remaining code, continue
|
3533 |
+
lastMapping = mapping;
|
3534 |
+
return;
|
3535 |
+
}
|
3536 |
}
|
3537 |
+
// We add the generated code until the first mapping
|
3538 |
+
// to the SourceNode without any mapping.
|
3539 |
+
// Each line is added as separate string.
|
3540 |
+
while (lastGeneratedLine < mapping.generatedLine) {
|
3541 |
+
node.add(shiftNextLine());
|
3542 |
+
lastGeneratedLine++;
|
3543 |
+
}
|
3544 |
+
if (lastGeneratedColumn < mapping.generatedColumn) {
|
3545 |
+
var nextLine = remainingLines[0];
|
3546 |
+
node.add(nextLine.substr(0, mapping.generatedColumn));
|
3547 |
+
remainingLines[0] = nextLine.substr(mapping.generatedColumn);
|
3548 |
+
lastGeneratedColumn = mapping.generatedColumn;
|
3549 |
+
}
|
3550 |
+
lastMapping = mapping;
|
3551 |
+
}, this);
|
3552 |
+
// We have processed all mappings.
|
3553 |
+
if (remainingLines.length > 0) {
|
3554 |
+
if (lastMapping) {
|
3555 |
+
// Associate the remaining code in the current line with "lastMapping"
|
3556 |
+
addMappingWithCode(lastMapping, shiftNextLine());
|
3557 |
+
}
|
3558 |
+
// and add the remaining lines without any mapping
|
3559 |
+
node.add(remainingLines.join(""));
|
3560 |
+
}
|
3561 |
|
3562 |
+
// Copy sourcesContent into SourceNode
|
3563 |
+
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
3564 |
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
3565 |
+
if (content != null) {
|
3566 |
+
if (aRelativePath != null) {
|
3567 |
+
sourceFile = util.join(aRelativePath, sourceFile);
|
3568 |
+
}
|
3569 |
+
node.setSourceContent(sourceFile, content);
|
|
|
|
|
3570 |
}
|
3571 |
+
});
|
3572 |
|
3573 |
+
return node;
|
3574 |
|
3575 |
+
function addMappingWithCode(mapping, code) {
|
3576 |
+
if (mapping === null || mapping.source === undefined) {
|
3577 |
+
node.add(code);
|
3578 |
+
} else {
|
3579 |
+
var source = aRelativePath
|
3580 |
+
? util.join(aRelativePath, mapping.source)
|
3581 |
+
: mapping.source;
|
3582 |
+
node.add(new SourceNode(mapping.originalLine,
|
3583 |
+
mapping.originalColumn,
|
3584 |
+
source,
|
3585 |
+
code,
|
3586 |
+
mapping.name));
|
3587 |
}
|
3588 |
+
}
|
3589 |
};
|
3590 |
|
3591 |
+
/**
|
3592 |
+
* Add a chunk of generated JS to this source node.
|
3593 |
+
*
|
3594 |
+
* @param aChunk A string snippet of generated JS code, another instance of
|
3595 |
+
* SourceNode, or an array where each member is one of those things.
|
3596 |
+
*/
|
3597 |
+
SourceNode.prototype.add = function SourceNode_add(aChunk) {
|
3598 |
+
if (Array.isArray(aChunk)) {
|
3599 |
+
aChunk.forEach(function (chunk) {
|
3600 |
+
this.add(chunk);
|
3601 |
+
}, this);
|
3602 |
+
}
|
3603 |
+
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
3604 |
+
if (aChunk) {
|
3605 |
+
this.children.push(aChunk);
|
3606 |
+
}
|
3607 |
+
}
|
3608 |
+
else {
|
3609 |
+
throw new TypeError(
|
3610 |
+
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
3611 |
+
);
|
3612 |
+
}
|
3613 |
+
return this;
|
3614 |
+
};
|
3615 |
|
3616 |
+
/**
|
3617 |
+
* Add a chunk of generated JS to the beginning of this source node.
|
3618 |
+
*
|
3619 |
+
* @param aChunk A string snippet of generated JS code, another instance of
|
3620 |
+
* SourceNode, or an array where each member is one of those things.
|
3621 |
+
*/
|
3622 |
+
SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
|
3623 |
+
if (Array.isArray(aChunk)) {
|
3624 |
+
for (var i = aChunk.length-1; i >= 0; i--) {
|
3625 |
+
this.prepend(aChunk[i]);
|
3626 |
+
}
|
3627 |
+
}
|
3628 |
+
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
3629 |
+
this.children.unshift(aChunk);
|
3630 |
+
}
|
3631 |
+
else {
|
3632 |
+
throw new TypeError(
|
3633 |
+
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
3634 |
+
);
|
3635 |
+
}
|
3636 |
+
return this;
|
3637 |
+
};
|
3638 |
+
|
3639 |
+
/**
|
3640 |
+
* Walk over the tree of JS snippets in this node and its children. The
|
3641 |
+
* walking function is called once for each snippet of JS and is passed that
|
3642 |
+
* snippet and the its original associated source's line/column location.
|
3643 |
+
*
|
3644 |
+
* @param aFn The traversal function.
|
3645 |
+
*/
|
3646 |
+
SourceNode.prototype.walk = function SourceNode_walk(aFn) {
|
3647 |
+
var chunk;
|
3648 |
+
for (var i = 0, len = this.children.length; i < len; i++) {
|
3649 |
+
chunk = this.children[i];
|
3650 |
+
if (chunk[isSourceNode]) {
|
3651 |
+
chunk.walk(aFn);
|
3652 |
+
}
|
3653 |
+
else {
|
3654 |
+
if (chunk !== '') {
|
3655 |
+
aFn(chunk, { source: this.source,
|
3656 |
+
line: this.line,
|
3657 |
+
column: this.column,
|
3658 |
+
name: this.name });
|
3659 |
+
}
|
3660 |
+
}
|
3661 |
+
}
|
3662 |
+
};
|
3663 |
+
|
3664 |
+
/**
|
3665 |
+
* Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
|
3666 |
+
* each of `this.children`.
|
3667 |
+
*
|
3668 |
+
* @param aSep The separator.
|
3669 |
+
*/
|
3670 |
+
SourceNode.prototype.join = function SourceNode_join(aSep) {
|
3671 |
+
var newChildren;
|
3672 |
+
var i;
|
3673 |
+
var len = this.children.length;
|
3674 |
+
if (len > 0) {
|
3675 |
+
newChildren = [];
|
3676 |
+
for (i = 0; i < len-1; i++) {
|
3677 |
+
newChildren.push(this.children[i]);
|
3678 |
+
newChildren.push(aSep);
|
3679 |
+
}
|
3680 |
+
newChildren.push(this.children[i]);
|
3681 |
+
this.children = newChildren;
|
3682 |
+
}
|
3683 |
+
return this;
|
3684 |
+
};
|
3685 |
+
|
3686 |
+
/**
|
3687 |
+
* Call String.prototype.replace on the very right-most source snippet. Useful
|
3688 |
+
* for trimming whitespace from the end of a source node, etc.
|
3689 |
+
*
|
3690 |
+
* @param aPattern The pattern to replace.
|
3691 |
+
* @param aReplacement The thing to replace the pattern with.
|
3692 |
+
*/
|
3693 |
+
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
|
3694 |
+
var lastChild = this.children[this.children.length - 1];
|
3695 |
+
if (lastChild[isSourceNode]) {
|
3696 |
+
lastChild.replaceRight(aPattern, aReplacement);
|
3697 |
+
}
|
3698 |
+
else if (typeof lastChild === 'string') {
|
3699 |
+
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
3700 |
+
}
|
3701 |
+
else {
|
3702 |
+
this.children.push(''.replace(aPattern, aReplacement));
|
3703 |
+
}
|
3704 |
+
return this;
|
3705 |
+
};
|
3706 |
+
|
3707 |
+
/**
|
3708 |
+
* Set the source content for a source file. This will be added to the SourceMapGenerator
|
3709 |
+
* in the sourcesContent field.
|
3710 |
+
*
|
3711 |
+
* @param aSourceFile The filename of the source file
|
3712 |
+
* @param aSourceContent The content of the source file
|
3713 |
+
*/
|
3714 |
+
SourceNode.prototype.setSourceContent =
|
3715 |
+
function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
|
3716 |
+
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
3717 |
+
};
|
3718 |
+
|
3719 |
+
/**
|
3720 |
+
* Walk over the tree of SourceNodes. The walking function is called for each
|
3721 |
+
* source file content and is passed the filename and source content.
|
3722 |
+
*
|
3723 |
+
* @param aFn The traversal function.
|
3724 |
+
*/
|
3725 |
+
SourceNode.prototype.walkSourceContents =
|
3726 |
+
function SourceNode_walkSourceContents(aFn) {
|
3727 |
+
for (var i = 0, len = this.children.length; i < len; i++) {
|
3728 |
+
if (this.children[i][isSourceNode]) {
|
3729 |
+
this.children[i].walkSourceContents(aFn);
|
3730 |
}
|
3731 |
+
}
|
3732 |
|
3733 |
+
var sources = Object.keys(this.sourceContents);
|
3734 |
+
for (var i = 0, len = sources.length; i < len; i++) {
|
3735 |
+
aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
|
3736 |
+
}
|
3737 |
+
};
|
3738 |
+
|
3739 |
+
/**
|
3740 |
+
* Return the string representation of this source node. Walks over the tree
|
3741 |
+
* and concatenates all the various snippets together to one string.
|
3742 |
+
*/
|
3743 |
+
SourceNode.prototype.toString = function SourceNode_toString() {
|
3744 |
+
var str = "";
|
3745 |
+
this.walk(function (chunk) {
|
3746 |
+
str += chunk;
|
3747 |
+
});
|
3748 |
+
return str;
|
3749 |
+
};
|
3750 |
|
3751 |
+
/**
|
3752 |
+
* Returns the string representation of this source node along with a source
|
3753 |
+
* map.
|
3754 |
+
*/
|
3755 |
+
SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
|
3756 |
+
var generated = {
|
3757 |
+
code: "",
|
3758 |
+
line: 1,
|
3759 |
+
column: 0
|
3760 |
+
};
|
3761 |
+
var map = new SourceMapGenerator(aArgs);
|
3762 |
+
var sourceMappingActive = false;
|
3763 |
+
var lastOriginalSource = null;
|
3764 |
+
var lastOriginalLine = null;
|
3765 |
+
var lastOriginalColumn = null;
|
3766 |
+
var lastOriginalName = null;
|
3767 |
+
this.walk(function (chunk, original) {
|
3768 |
+
generated.code += chunk;
|
3769 |
+
if (original.source !== null
|
3770 |
+
&& original.line !== null
|
3771 |
+
&& original.column !== null) {
|
3772 |
+
if(lastOriginalSource !== original.source
|
3773 |
+
|| lastOriginalLine !== original.line
|
3774 |
+
|| lastOriginalColumn !== original.column
|
3775 |
+
|| lastOriginalName !== original.name) {
|
3776 |
+
map.addMapping({
|
3777 |
+
source: original.source,
|
3778 |
+
original: {
|
3779 |
+
line: original.line,
|
3780 |
+
column: original.column
|
3781 |
+
},
|
3782 |
+
generated: {
|
3783 |
+
line: generated.line,
|
3784 |
+
column: generated.column
|
3785 |
+
},
|
3786 |
+
name: original.name
|
3787 |
+
});
|
3788 |
}
|
3789 |
+
lastOriginalSource = original.source;
|
3790 |
+
lastOriginalLine = original.line;
|
3791 |
+
lastOriginalColumn = original.column;
|
3792 |
+
lastOriginalName = original.name;
|
3793 |
+
sourceMappingActive = true;
|
3794 |
+
} else if (sourceMappingActive) {
|
3795 |
+
map.addMapping({
|
3796 |
+
generated: {
|
3797 |
+
line: generated.line,
|
3798 |
+
column: generated.column
|
3799 |
+
}
|
3800 |
+
});
|
3801 |
+
lastOriginalSource = null;
|
3802 |
+
sourceMappingActive = false;
|
3803 |
+
}
|
3804 |
+
for (var idx = 0, length = chunk.length; idx < length; idx++) {
|
3805 |
+
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
|
3806 |
+
generated.line++;
|
3807 |
+
generated.column = 0;
|
3808 |
+
// Mappings end at eol
|
3809 |
+
if (idx + 1 === length) {
|
3810 |
+
lastOriginalSource = null;
|
3811 |
+
sourceMappingActive = false;
|
3812 |
+
} else if (sourceMappingActive) {
|
3813 |
+
map.addMapping({
|
3814 |
+
source: original.source,
|
3815 |
+
original: {
|
3816 |
+
line: original.line,
|
3817 |
+
column: original.column
|
3818 |
+
},
|
3819 |
+
generated: {
|
3820 |
+
line: generated.line,
|
3821 |
+
column: generated.column
|
3822 |
+
},
|
3823 |
+
name: original.name
|
3824 |
+
});
|
3825 |
+
}
|
3826 |
+
} else {
|
3827 |
+
generated.column++;
|
3828 |
}
|
3829 |
+
}
|
3830 |
+
});
|
3831 |
+
this.walkSourceContents(function (sourceFile, sourceContent) {
|
3832 |
+
map.setSourceContent(sourceFile, sourceContent);
|
3833 |
+
});
|
3834 |
+
|
3835 |
+
return { code: generated.code, map: map };
|
3836 |
+
};
|
3837 |
+
|
3838 |
+
exports.SourceNode = SourceNode;
|
3839 |
+
|
3840 |
+
});
|
3841 |
+
|
3842 |
+
},{"./source-map-generator":23,"./util":25,"amdefine":26}],25:[function(require,module,exports){
|
3843 |
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
3844 |
+
/*
|
3845 |
+
* Copyright 2011 Mozilla Foundation and contributors
|
3846 |
+
* Licensed under the New BSD license. See LICENSE or:
|
3847 |
+
* http://opensource.org/licenses/BSD-3-Clause
|
3848 |
+
*/
|
3849 |
+
if (typeof define !== 'function') {
|
3850 |
+
var define = require('amdefine')(module, require);
|
3851 |
+
}
|
3852 |
+
define(function (require, exports, module) {
|
3853 |
+
|
3854 |
+
/**
|
3855 |
+
* This is a helper function for getting values from parameter/options
|
3856 |
+
* objects.
|
3857 |
+
*
|
3858 |
+
* @param args The object we are extracting values from
|
3859 |
+
* @param name The name of the property we are getting.
|
3860 |
+
* @param defaultValue An optional value to return if the property is missing
|
3861 |
+
* from the object. If this is not specified and the property is missing, an
|
3862 |
+
* error will be thrown.
|
3863 |
+
*/
|
3864 |
+
function getArg(aArgs, aName, aDefaultValue) {
|
3865 |
+
if (aName in aArgs) {
|
3866 |
+
return aArgs[aName];
|
3867 |
+
} else if (arguments.length === 3) {
|
3868 |
+
return aDefaultValue;
|
3869 |
+
} else {
|
3870 |
+
throw new Error('"' + aName + '" is a required argument.');
|
3871 |
+
}
|
3872 |
+
}
|
3873 |
+
exports.getArg = getArg;
|
3874 |
+
|
3875 |
+
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
|
3876 |
+
var dataUrlRegexp = /^data:.+\,.+$/;
|
3877 |
+
|
3878 |
+
function urlParse(aUrl) {
|
3879 |
+
var match = aUrl.match(urlRegexp);
|
3880 |
+
if (!match) {
|
3881 |
+
return null;
|
3882 |
+
}
|
3883 |
+
return {
|
3884 |
+
scheme: match[1],
|
3885 |
+
auth: match[2],
|
3886 |
+
host: match[3],
|
3887 |
+
port: match[4],
|
3888 |
+
path: match[5]
|
3889 |
};
|
3890 |
+
}
|
3891 |
+
exports.urlParse = urlParse;
|
3892 |
|
3893 |
+
function urlGenerate(aParsedUrl) {
|
3894 |
+
var url = '';
|
3895 |
+
if (aParsedUrl.scheme) {
|
3896 |
+
url += aParsedUrl.scheme + ':';
|
3897 |
+
}
|
3898 |
+
url += '//';
|
3899 |
+
if (aParsedUrl.auth) {
|
3900 |
+
url += aParsedUrl.auth + '@';
|
3901 |
+
}
|
3902 |
+
if (aParsedUrl.host) {
|
3903 |
+
url += aParsedUrl.host;
|
3904 |
+
}
|
3905 |
+
if (aParsedUrl.port) {
|
3906 |
+
url += ":" + aParsedUrl.port
|
3907 |
+
}
|
3908 |
+
if (aParsedUrl.path) {
|
3909 |
+
url += aParsedUrl.path;
|
3910 |
+
}
|
3911 |
+
return url;
|
3912 |
+
}
|
3913 |
+
exports.urlGenerate = urlGenerate;
|
3914 |
|
3915 |
+
/**
|
3916 |
+
* Normalizes a path, or the path portion of a URL:
|
3917 |
+
*
|
3918 |
+
* - Replaces consequtive slashes with one slash.
|
3919 |
+
* - Removes unnecessary '.' parts.
|
3920 |
+
* - Removes unnecessary '<dir>/..' parts.
|
3921 |
+
*
|
3922 |
+
* Based on code in the Node.js 'path' core module.
|
3923 |
+
*
|
3924 |
+
* @param aPath The path or url to normalize.
|
3925 |
+
*/
|
3926 |
+
function normalize(aPath) {
|
3927 |
+
var path = aPath;
|
3928 |
+
var url = urlParse(aPath);
|
3929 |
+
if (url) {
|
3930 |
+
if (!url.path) {
|
3931 |
+
return aPath;
|
3932 |
+
}
|
3933 |
+
path = url.path;
|
3934 |
+
}
|
3935 |
+
var isAbsolute = (path.charAt(0) === '/');
|
3936 |
|
3937 |
+
var parts = path.split(/\/+/);
|
3938 |
+
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
|
3939 |
+
part = parts[i];
|
3940 |
+
if (part === '.') {
|
3941 |
+
parts.splice(i, 1);
|
3942 |
+
} else if (part === '..') {
|
3943 |
+
up++;
|
3944 |
+
} else if (up > 0) {
|
3945 |
+
if (part === '') {
|
3946 |
+
// The first part is blank if the path is absolute. Trying to go
|
3947 |
+
// above the root is a no-op. Therefore we can remove all '..' parts
|
3948 |
+
// directly after the root.
|
3949 |
+
parts.splice(i + 1, up);
|
3950 |
+
up = 0;
|
3951 |
+
} else {
|
3952 |
+
parts.splice(i, 2);
|
3953 |
+
up--;
|
3954 |
}
|
3955 |
+
}
|
3956 |
+
}
|
3957 |
+
path = parts.join('/');
|
3958 |
+
|
3959 |
+
if (path === '') {
|
3960 |
+
path = isAbsolute ? '/' : '.';
|
3961 |
+
}
|
3962 |
+
|
3963 |
+
if (url) {
|
3964 |
+
url.path = path;
|
3965 |
+
return urlGenerate(url);
|
3966 |
+
}
|
3967 |
+
return path;
|
3968 |
+
}
|
3969 |
+
exports.normalize = normalize;
|
3970 |
+
|
3971 |
+
/**
|
3972 |
+
* Joins two paths/URLs.
|
3973 |
+
*
|
3974 |
+
* @param aRoot The root path or URL.
|
3975 |
+
* @param aPath The path or URL to be joined with the root.
|
3976 |
+
*
|
3977 |
+
* - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
|
3978 |
+
* scheme-relative URL: Then the scheme of aRoot, if any, is prepended
|
3979 |
+
* first.
|
3980 |
+
* - Otherwise aPath is a path. If aRoot is a URL, then its path portion
|
3981 |
+
* is updated with the result and aRoot is returned. Otherwise the result
|
3982 |
+
* is returned.
|
3983 |
+
* - If aPath is absolute, the result is aPath.
|
3984 |
+
* - Otherwise the two paths are joined with a slash.
|
3985 |
+
* - Joining for example 'http://' and 'www.example.com' is also supported.
|
3986 |
+
*/
|
3987 |
+
function join(aRoot, aPath) {
|
3988 |
+
if (aRoot === "") {
|
3989 |
+
aRoot = ".";
|
3990 |
+
}
|
3991 |
+
if (aPath === "") {
|
3992 |
+
aPath = ".";
|
3993 |
+
}
|
3994 |
+
var aPathUrl = urlParse(aPath);
|
3995 |
+
var aRootUrl = urlParse(aRoot);
|
3996 |
+
if (aRootUrl) {
|
3997 |
+
aRoot = aRootUrl.path || '/';
|
3998 |
+
}
|
3999 |
+
|
4000 |
+
// `join(foo, '//www.example.org')`
|
4001 |
+
if (aPathUrl && !aPathUrl.scheme) {
|
4002 |
+
if (aRootUrl) {
|
4003 |
+
aPathUrl.scheme = aRootUrl.scheme;
|
4004 |
+
}
|
4005 |
+
return urlGenerate(aPathUrl);
|
4006 |
+
}
|
4007 |
+
|
4008 |
+
if (aPathUrl || aPath.match(dataUrlRegexp)) {
|
4009 |
+
return aPath;
|
4010 |
+
}
|
4011 |
|
4012 |
+
// `join('http://', 'www.example.com')`
|
4013 |
+
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
|
4014 |
+
aRootUrl.host = aPath;
|
4015 |
+
return urlGenerate(aRootUrl);
|
4016 |
+
}
|
4017 |
+
|
4018 |
+
var joined = aPath.charAt(0) === '/'
|
4019 |
+
? aPath
|
4020 |
+
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
|
4021 |
+
|
4022 |
+
if (aRootUrl) {
|
4023 |
+
aRootUrl.path = joined;
|
4024 |
+
return urlGenerate(aRootUrl);
|
4025 |
+
}
|
4026 |
+
return joined;
|
4027 |
+
}
|
4028 |
+
exports.join = join;
|
4029 |
+
|
4030 |
+
/**
|
4031 |
+
* Make a path relative to a URL or another path.
|
4032 |
+
*
|
4033 |
+
* @param aRoot The root path or URL.
|
4034 |
+
* @param aPath The path or URL to be made relative to aRoot.
|
4035 |
+
*/
|
4036 |
+
function relative(aRoot, aPath) {
|
4037 |
+
if (aRoot === "") {
|
4038 |
+
aRoot = ".";
|
4039 |
+
}
|
4040 |
+
|
4041 |
+
aRoot = aRoot.replace(/\/$/, '');
|
4042 |
+
|
4043 |
+
// XXX: It is possible to remove this block, and the tests still pass!
|
4044 |
+
var url = urlParse(aRoot);
|
4045 |
+
if (aPath.charAt(0) == "/" && url && url.path == "/") {
|
4046 |
+
return aPath.slice(1);
|
4047 |
+
}
|
4048 |
+
|
4049 |
+
return aPath.indexOf(aRoot + '/') === 0
|
4050 |
+
? aPath.substr(aRoot.length + 1)
|
4051 |
+
: aPath;
|
4052 |
+
}
|
4053 |
+
exports.relative = relative;
|
4054 |
+
|
4055 |
+
/**
|
4056 |
+
* Because behavior goes wacky when you set `__proto__` on objects, we
|
4057 |
+
* have to prefix all the strings in our set with an arbitrary character.
|
4058 |
+
*
|
4059 |
+
* See https://github.com/mozilla/source-map/pull/31 and
|
4060 |
+
* https://github.com/mozilla/source-map/issues/30
|
4061 |
+
*
|
4062 |
+
* @param String aStr
|
4063 |
+
*/
|
4064 |
+
function toSetString(aStr) {
|
4065 |
+
return '$' + aStr;
|
4066 |
+
}
|
4067 |
+
exports.toSetString = toSetString;
|
4068 |
+
|
4069 |
+
function fromSetString(aStr) {
|
4070 |
+
return aStr.substr(1);
|
4071 |
+
}
|
4072 |
+
exports.fromSetString = fromSetString;
|
4073 |
+
|
4074 |
+
function strcmp(aStr1, aStr2) {
|
4075 |
+
var s1 = aStr1 || "";
|
4076 |
+
var s2 = aStr2 || "";
|
4077 |
+
return (s1 > s2) - (s1 < s2);
|
4078 |
+
}
|
4079 |
+
|
4080 |
+
/**
|
4081 |
+
* Comparator between two mappings where the original positions are compared.
|
4082 |
+
*
|
4083 |
+
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
4084 |
+
* mappings with the same original source/line/column, but different generated
|
4085 |
+
* line and column the same. Useful when searching for a mapping with a
|
4086 |
+
* stubbed out mapping.
|
4087 |
+
*/
|
4088 |
+
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
4089 |
+
var cmp;
|
4090 |
+
|
4091 |
+
cmp = strcmp(mappingA.source, mappingB.source);
|
4092 |
+
if (cmp) {
|
4093 |
+
return cmp;
|
4094 |
+
}
|
4095 |
+
|
4096 |
+
cmp = mappingA.originalLine - mappingB.originalLine;
|
4097 |
+
if (cmp) {
|
4098 |
+
return cmp;
|
4099 |
+
}
|
4100 |
+
|
4101 |
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
4102 |
+
if (cmp || onlyCompareOriginal) {
|
4103 |
+
return cmp;
|
4104 |
+
}
|
4105 |
+
|
4106 |
+
cmp = strcmp(mappingA.name, mappingB.name);
|
4107 |
+
if (cmp) {
|
4108 |
+
return cmp;
|
4109 |
+
}
|
4110 |
+
|
4111 |
+
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
4112 |
+
if (cmp) {
|
4113 |
+
return cmp;
|
4114 |
+
}
|
4115 |
+
|
4116 |
+
return mappingA.generatedColumn - mappingB.generatedColumn;
|
4117 |
+
};
|
4118 |
+
exports.compareByOriginalPositions = compareByOriginalPositions;
|
4119 |
+
|
4120 |
+
/**
|
4121 |
+
* Comparator between two mappings where the generated positions are
|
4122 |
+
* compared.
|
4123 |
+
*
|
4124 |
+
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
4125 |
+
* mappings with the same generated line and column, but different
|
4126 |
+
* source/name/original line and column the same. Useful when searching for a
|
4127 |
+
* mapping with a stubbed out mapping.
|
4128 |
+
*/
|
4129 |
+
function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
|
4130 |
+
var cmp;
|
4131 |
+
|
4132 |
+
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
4133 |
+
if (cmp) {
|
4134 |
+
return cmp;
|
4135 |
+
}
|
4136 |
+
|
4137 |
+
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
4138 |
+
if (cmp || onlyCompareGenerated) {
|
4139 |
+
return cmp;
|
4140 |
+
}
|
4141 |
+
|
4142 |
+
cmp = strcmp(mappingA.source, mappingB.source);
|
4143 |
+
if (cmp) {
|
4144 |
+
return cmp;
|
4145 |
+
}
|
4146 |
+
|
4147 |
+
cmp = mappingA.originalLine - mappingB.originalLine;
|
4148 |
+
if (cmp) {
|
4149 |
+
return cmp;
|
4150 |
+
}
|
4151 |
+
|
4152 |
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
4153 |
+
if (cmp) {
|
4154 |
+
return cmp;
|
4155 |
+
}
|
4156 |
+
|
4157 |
+
return strcmp(mappingA.name, mappingB.name);
|
4158 |
+
};
|
4159 |
+
exports.compareByGeneratedPositions = compareByGeneratedPositions;
|
4160 |
+
|
4161 |
+
});
|
4162 |
+
|
4163 |
+
},{"amdefine":26}],26:[function(require,module,exports){
|
4164 |
+
(function (process,__filename){
|
4165 |
+
/** vim: et:ts=4:sw=4:sts=4
|
4166 |
+
* @license amdefine 1.0.0 Copyright (c) 2011-2015, The Dojo Foundation All Rights Reserved.
|
4167 |
+
* Available via the MIT or new BSD license.
|
4168 |
+
* see: http://github.com/jrburke/amdefine for details
|
4169 |
+
*/
|
4170 |
+
|
4171 |
+
/*jslint node: true */
|
4172 |
+
/*global module, process */
|
4173 |
+
'use strict';
|
4174 |
+
|
4175 |
+
/**
|
4176 |
+
* Creates a define for node.
|
4177 |
+
* @param {Object} module the "module" object that is defined by Node for the
|
4178 |
+
* current module.
|
4179 |
+
* @param {Function} [requireFn]. Node's require function for the current module.
|
4180 |
+
* It only needs to be passed in Node versions before 0.5, when module.require
|
4181 |
+
* did not exist.
|
4182 |
+
* @returns {Function} a define function that is usable for the current node
|
4183 |
+
* module.
|
4184 |
+
*/
|
4185 |
+
function amdefine(module, requireFn) {
|
4186 |
+
'use strict';
|
4187 |
+
var defineCache = {},
|
4188 |
+
loaderCache = {},
|
4189 |
+
alreadyCalled = false,
|
4190 |
+
path = require('path'),
|
4191 |
+
makeRequire, stringRequire;
|
4192 |
+
|
4193 |
+
/**
|
4194 |
+
* Trims the . and .. from an array of path segments.
|
4195 |
+
* It will keep a leading path segment if a .. will become
|
4196 |
+
* the first path segment, to help with module name lookups,
|
4197 |
+
* which act like paths, but can be remapped. But the end result,
|
4198 |
+
* all paths that use this function should look normalized.
|
4199 |
+
* NOTE: this method MODIFIES the input array.
|
4200 |
+
* @param {Array} ary the array of path segments.
|
4201 |
+
*/
|
4202 |
+
function trimDots(ary) {
|
4203 |
+
var i, part;
|
4204 |
+
for (i = 0; ary[i]; i+= 1) {
|
4205 |
+
part = ary[i];
|
4206 |
+
if (part === '.') {
|
4207 |
+
ary.splice(i, 1);
|
4208 |
+
i -= 1;
|
4209 |
+
} else if (part === '..') {
|
4210 |
+
if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
|
4211 |
+
//End of the line. Keep at least one non-dot
|
4212 |
+
//path segment at the front so it can be mapped
|
4213 |
+
//correctly to disk. Otherwise, there is likely
|
4214 |
+
//no path mapping for a path starting with '..'.
|
4215 |
+
//This can still fail, but catches the most reasonable
|
4216 |
+
//uses of ..
|
4217 |
break;
|
4218 |
+
} else if (i > 0) {
|
4219 |
+
ary.splice(i - 1, 2);
|
4220 |
+
i -= 2;
|
4221 |
}
|
4222 |
}
|
4223 |
}
|
4224 |
+
}
|
4225 |
+
|
4226 |
+
function normalize(name, baseName) {
|
4227 |
+
var baseParts;
|
4228 |
+
|
4229 |
+
//Adjust any relative paths.
|
4230 |
+
if (name && name.charAt(0) === '.') {
|
4231 |
+
//If have a base name, try to normalize against it,
|
4232 |
+
//otherwise, assume it is a top-level require that will
|
4233 |
+
//be relative to baseUrl in the end.
|
4234 |
+
if (baseName) {
|
4235 |
+
baseParts = baseName.split('/');
|
4236 |
+
baseParts = baseParts.slice(0, baseParts.length - 1);
|
4237 |
+
baseParts = baseParts.concat(name.split('/'));
|
4238 |
+
trimDots(baseParts);
|
4239 |
+
name = baseParts.join('/');
|
4240 |
}
|
4241 |
}
|
4242 |
|
4243 |
+
return name;
|
4244 |
+
}
|
4245 |
+
|
4246 |
+
/**
|
4247 |
+
* Create the normalize() function passed to a loader plugin's
|
4248 |
+
* normalize method.
|
4249 |
+
*/
|
4250 |
+
function makeNormalize(relName) {
|
4251 |
+
return function (name) {
|
4252 |
+
return normalize(name, relName);
|
4253 |
+
};
|
4254 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4255 |
|
4256 |
+
function makeLoad(id) {
|
4257 |
+
function load(value) {
|
4258 |
+
loaderCache[id] = value;
|
4259 |
}
|
|
|
4260 |
|
4261 |
+
load.fromText = function (id, text) {
|
4262 |
+
//This one is difficult because the text can/probably uses
|
4263 |
+
//define, and any relative paths and requires should be relative
|
4264 |
+
//to that id was it would be found on disk. But this would require
|
4265 |
+
//bootstrapping a module/require fairly deeply from node core.
|
4266 |
+
//Not sure how best to go about that yet.
|
4267 |
+
throw new Error('amdefine does not implement load.fromText');
|
4268 |
+
};
|
4269 |
|
4270 |
+
return load;
|
4271 |
+
}
|
4272 |
|
4273 |
+
makeRequire = function (systemRequire, exports, module, relId) {
|
4274 |
+
function amdRequire(deps, callback) {
|
4275 |
+
if (typeof deps === 'string') {
|
4276 |
+
//Synchronous, single module require('')
|
4277 |
+
return stringRequire(systemRequire, exports, module, deps, relId);
|
4278 |
+
} else {
|
4279 |
+
//Array of dependencies with a callback.
|
|
|
|
|
|
|
|
|
|
|
|
|
4280 |
|
4281 |
+
//Convert the dependencies to modules.
|
4282 |
+
deps = deps.map(function (depName) {
|
4283 |
+
return stringRequire(systemRequire, exports, module, depName, relId);
|
4284 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4285 |
|
4286 |
+
//Wait for next tick to call back the require call.
|
4287 |
+
if (callback) {
|
4288 |
+
process.nextTick(function () {
|
4289 |
+
callback.apply(null, deps);
|
4290 |
+
});
|
4291 |
+
}
|
|
|
|
|
|
|
4292 |
}
|
4293 |
}
|
4294 |
|
4295 |
+
amdRequire.toUrl = function (filePath) {
|
4296 |
+
if (filePath.indexOf('.') === 0) {
|
4297 |
+
return normalize(filePath, path.dirname(module.filename));
|
4298 |
+
} else {
|
4299 |
+
return filePath;
|
4300 |
}
|
4301 |
+
};
|
4302 |
|
4303 |
+
return amdRequire;
|
4304 |
};
|
4305 |
|
4306 |
+
//Favor explicit value, passed in if the module wants to support Node 0.4.
|
4307 |
+
requireFn = requireFn || function req() {
|
4308 |
+
return module.require.apply(module, arguments);
|
|
|
|
|
|
|
|
|
|
|
4309 |
};
|
4310 |
|
4311 |
+
function runFactory(id, deps, factory) {
|
4312 |
+
var r, e, m, result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4313 |
|
4314 |
+
if (id) {
|
4315 |
+
e = loaderCache[id] = {};
|
4316 |
+
m = {
|
4317 |
+
id: id,
|
4318 |
+
uri: __filename,
|
4319 |
+
exports: e
|
4320 |
+
};
|
4321 |
+
r = makeRequire(requireFn, e, m, id);
|
4322 |
+
} else {
|
4323 |
+
//Only support one define call per file
|
4324 |
+
if (alreadyCalled) {
|
4325 |
+
throw new Error('amdefine with no module ID cannot be called more than once per file.');
|
4326 |
}
|
4327 |
+
alreadyCalled = true;
|
4328 |
|
4329 |
+
//Use the real variables from node
|
4330 |
+
//Use module.exports for exports, since
|
4331 |
+
//the exports in here is amdefine exports.
|
4332 |
+
e = module.exports;
|
4333 |
+
m = module;
|
4334 |
+
r = makeRequire(requireFn, e, m, module.id);
|
4335 |
}
|
|
|
|
|
4336 |
|
4337 |
+
//If there are dependencies, they are strings, so need
|
4338 |
+
//to convert them to dependency values.
|
4339 |
+
if (deps) {
|
4340 |
+
deps = deps.map(function (depName) {
|
4341 |
+
return r(depName);
|
4342 |
+
});
|
|
|
|
|
4343 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
4344 |
|
4345 |
+
//Call the factory with the right dependencies.
|
4346 |
+
if (typeof factory === 'function') {
|
4347 |
+
result = factory.apply(m.exports, deps);
|
4348 |
+
} else {
|
4349 |
+
result = factory;
|
|
|
|
|
4350 |
}
|
4351 |
|
4352 |
+
if (result !== undefined) {
|
4353 |
+
m.exports = result;
|
4354 |
+
if (id) {
|
4355 |
+
loaderCache[id] = m.exports;
|
4356 |
+
}
|
4357 |
}
|
4358 |
+
}
|
4359 |
|
4360 |
+
stringRequire = function (systemRequire, exports, module, id, relId) {
|
4361 |
+
//Split the ID by a ! so that
|
4362 |
+
var index = id.indexOf('!'),
|
4363 |
+
originalId = id,
|
4364 |
+
prefix, plugin;
|
4365 |
|
4366 |
+
if (index === -1) {
|
4367 |
+
id = normalize(id, relId);
|
|
|
|
|
4368 |
|
4369 |
+
//Straight module lookup. If it is one of the special dependencies,
|
4370 |
+
//deal with it, otherwise, delegate to node.
|
4371 |
+
if (id === 'require') {
|
4372 |
+
return makeRequire(systemRequire, exports, module, relId);
|
4373 |
+
} else if (id === 'exports') {
|
4374 |
+
return exports;
|
4375 |
+
} else if (id === 'module') {
|
4376 |
+
return module;
|
4377 |
+
} else if (loaderCache.hasOwnProperty(id)) {
|
4378 |
+
return loaderCache[id];
|
4379 |
+
} else if (defineCache[id]) {
|
4380 |
+
runFactory.apply(null, defineCache[id]);
|
4381 |
+
return loaderCache[id];
|
4382 |
+
} else {
|
4383 |
+
if(systemRequire) {
|
4384 |
+
return systemRequire(originalId);
|
4385 |
+
} else {
|
4386 |
+
throw new Error('No module with ID: ' + id);
|
4387 |
}
|
|
|
|
|
|
|
|
|
4388 |
}
|
4389 |
+
} else {
|
4390 |
+
//There is a plugin in play.
|
4391 |
+
prefix = id.substring(0, index);
|
4392 |
+
id = id.substring(index + 1, id.length);
|
4393 |
|
4394 |
+
plugin = stringRequire(systemRequire, exports, module, prefix, relId);
|
|
|
4395 |
|
4396 |
+
if (plugin.normalize) {
|
4397 |
+
id = plugin.normalize(id, makeNormalize(relId));
|
4398 |
+
} else {
|
4399 |
+
//Normalize the ID normally.
|
4400 |
+
id = normalize(id, relId);
|
4401 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4402 |
|
4403 |
+
if (loaderCache[id]) {
|
4404 |
+
return loaderCache[id];
|
4405 |
+
} else {
|
4406 |
+
plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
|
4407 |
|
4408 |
+
return loaderCache[id];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4409 |
}
|
4410 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4411 |
};
|
4412 |
|
4413 |
+
//Create a define function specific to the module asking for amdefine.
|
4414 |
+
function define(id, deps, factory) {
|
4415 |
+
if (Array.isArray(id)) {
|
4416 |
+
factory = deps;
|
4417 |
+
deps = id;
|
4418 |
+
id = undefined;
|
4419 |
+
} else if (typeof id !== 'string') {
|
4420 |
+
factory = id;
|
4421 |
+
id = deps = undefined;
|
4422 |
}
|
4423 |
|
4424 |
+
if (deps && !Array.isArray(deps)) {
|
4425 |
+
factory = deps;
|
4426 |
+
deps = undefined;
|
4427 |
}
|
4428 |
|
4429 |
+
if (!deps) {
|
4430 |
+
deps = ['require', 'exports', 'module'];
|
|
|
|
|
|
|
|
|
4431 |
}
|
4432 |
|
4433 |
+
//Set up properties for this module. If an ID, then use
|
4434 |
+
//internal cache. If no ID, then use the external variables
|
4435 |
+
//for this node module.
|
4436 |
+
if (id) {
|
4437 |
+
//Put the module in deep freeze until there is a
|
4438 |
+
//require call for it.
|
4439 |
+
defineCache[id] = [id, deps, factory];
|
4440 |
+
} else {
|
4441 |
+
runFactory(id, deps, factory);
|
4442 |
}
|
4443 |
+
}
|
4444 |
|
4445 |
+
//define.require, which has access to all the values in the
|
4446 |
+
//cache. Useful for AMD modules that all have IDs in the file,
|
4447 |
+
//but need to finally export a value to node based on one of those
|
4448 |
+
//IDs.
|
4449 |
+
define.require = function (id) {
|
4450 |
+
if (loaderCache[id]) {
|
4451 |
+
return loaderCache[id];
|
4452 |
}
|
4453 |
|
4454 |
+
if (defineCache[id]) {
|
4455 |
+
runFactory.apply(null, defineCache[id]);
|
4456 |
+
return loaderCache[id];
|
4457 |
+
}
|
4458 |
+
};
|
4459 |
|
4460 |
+
define.amd = {};
|
|
|
4461 |
|
4462 |
+
return define;
|
4463 |
+
}
|
4464 |
|
4465 |
+
module.exports = amdefine;
|
|
|
|
|
|
|
|
|
|
|
|
|
4466 |
|
4467 |
+
}).call(this,require('_process'),"/node_modules/css/node_modules/source-map/node_modules/amdefine/amdefine.js")
|
4468 |
+
},{"_process":3,"path":2}],27:[function(require,module,exports){
|
4469 |
+
// Copyright 2014 Simon Lydell
|
4470 |
+
// X11 (“MIT”) Licensed. (See LICENSE.)
|
4471 |
+
|
4472 |
+
var path = require("path")
|
4473 |
+
|
4474 |
+
"use strict"
|
4475 |
+
|
4476 |
+
function urix(aPath) {
|
4477 |
+
if (path.sep === "\\") {
|
4478 |
+
return aPath
|
4479 |
+
.replace(/\\/g, "/")
|
4480 |
+
.replace(/^[a-z]:\/?/i, "/")
|
4481 |
+
}
|
4482 |
+
return aPath
|
4483 |
+
}
|
4484 |
+
|
4485 |
+
module.exports = urix
|
4486 |
|
4487 |
+
},{"path":2}]},{},[4]);
|
js/css.min.js
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
!function(e){"use strict";var t=function(){this.cssImportStatements=[],this.cssKeyframeStatements=[],this.cssRegex=new RegExp("([\\s\\S]*?){([\\s\\S]*?)}","gi"),this.cssMediaQueryRegex="((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.cssKeyframeRegex="((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.combinedCSSRegex="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",this.cssCommentsRegex="(\\/\\*[\\s\\S]*?\\*\\/)",this.cssImportStatementRegex=new RegExp("@import .*?;","gi")};t.prototype.stripComments=function(e){var t=new RegExp(this.cssCommentsRegex,"gi");return e.replace(t,"")},t.prototype.parseCSS=function(e){if(void 0===e)return[];for(var t=[];;){var s=this.cssImportStatementRegex.exec(e);if(null===s)break;this.cssImportStatements.push(s[0]),t.push({selector:"@imports",type:"imports",styles:s[0]})}e=e.replace(this.cssImportStatementRegex,"");for(var r,i=new RegExp(this.cssKeyframeRegex,"gi");;){if(r=i.exec(e),null===r)break;t.push({selector:"@keyframes",type:"keyframes",styles:r[0]})}e=e.replace(i,"");for(var o=new RegExp(this.combinedCSSRegex,"gi");;){if(r=o.exec(e),null===r)break;var n="";n=void 0===r[2]?r[5].split("\r\n").join("\n").trim():r[2].split("\r\n").join("\n").trim();var l=new RegExp(this.cssCommentsRegex,"gi"),p=l.exec(n);if(null!==p&&(n=n.replace(l,"").trim()),n=n.replace(/\n+/,"\n"),-1!==n.indexOf("@media")){var a={selector:n,type:"media",subStyles:this.parseCSS(r[3]+"\n}")};null!==p&&(a.comments=p[0]),t.push(a)}else{var c=this.parseRules(r[6]),u={selector:n,rules:c};"@font-face"===n&&(u.type="font-face"),null!==p&&(u.comments=p[0]),t.push(u)}}return t},t.prototype.parseRules=function(e){e=e.split("\r\n").join("\n");var t=[];e=e.split(";");for(var s=0;s<e.length;s++){var r=e[s];if(r=r.trim(),-1!==r.indexOf(":")){r=r.split(":");var i=r[0].trim(),o=r.slice(1).join(":").trim();t.push({directive:i,value:o})}else"base64,"===r.trim().substr(0,7)?t[t.length-1].value+=r.trim():r.length>0&&t.push({directive:"",value:r,defective:!0})}return t},t.prototype.findCorrespondingRule=function(e,t,s){void 0===s&&(s=!1);for(var r=!1,i=0;i<e.length&&(e[i].directive!=t||(r=e[i],s!==e[i].value));i++);return r},t.prototype.findBySelector=function(e,t,s){void 0===s&&(s=!1);for(var r=[],i=0;i<e.length;i++)s===!1?e[i].selector===t&&r.push(e[i]):-1!==e[i].selector.indexOf(t)&&r.push(e[i]);if("@imports"===t||r.length<2)return r;var o=r[0];for(i=1;i<r.length;i++)this.intelligentCSSPush([o],r[i]);return[o]},t.prototype.deleteBySelector=function(e,t){for(var s=[],r=0;r<e.length;r++)e[r].selector!==t&&s.push(e[r]);return s},t.prototype.compressCSS=function(e){for(var t=[],s={},r=0;r<e.length;r++){var i=e[r];if(s[i.selector]!==!0){var o=this.findBySelector(e,i.selector);o.length>0&&(t=t.concat(o),s[i.selector]=!0)}}return t},t.prototype.cssDiff=function(e,t){if(e.selector!==t.selector)return!1;if("media"===e.type||"media"===t.type)return!1;for(var s,r,i={selector:e.selector,rules:[]},o=0;o<e.rules.length;o++)s=e.rules[o],r=this.findCorrespondingRule(t.rules,s.directive,s.value),r===!1?i.rules.push(s):s.value!==r.value&&i.rules.push(s);for(var n=0;n<t.rules.length;n++)r=t.rules[n],s=this.findCorrespondingRule(e.rules,r.directive),s===!1&&(r.type="DELETED",i.rules.push(r));return 0===i.rules.length?!1:i},t.prototype.intelligentMerge=function(e,t,s){void 0===s&&(s=!1);for(var r=0;r<t.length;r++)this.intelligentCSSPush(e,t[r],s);for(r=0;r<e.length;r++){var i=e[r];"media"!==i.type&&"keyframes"!==i.type&&(i.rules=this.compactRules(i.rules))}},t.prototype.intelligentCSSPush=function(e,t,s){var r=(t.selector,!1);if(void 0===s&&(s=!1),s===!1){for(var i=0;i<e.length;i++)if(e[i].selector===t.selector){r=e[i];break}}else for(var o=e.length-1;o>-1;o--)if(e[o].selector===t.selector){r=e[o];break}if(r===!1)e.push(t);else if("media"!==t.type)for(var n=0;n<t.rules.length;n++){var l=t.rules[n],p=this.findCorrespondingRule(r.rules,l.directive);p===!1?r.rules.push(l):"DELETED"===l.type?p.type="DELETED":p.value=l.value}else r.subStyles=r.subStyles.concat(t.subStyles)},t.prototype.compactRules=function(e){for(var t=[],s=0;s<e.length;s++)"DELETED"!==e[s].type&&t.push(e[s]);return t},t.prototype.getCSSForEditor=function(e,t){void 0===t&&(t=0);var s="";void 0===e&&(e=this.css);for(var r=0;r<e.length;r++)"imports"===e[r].type&&(s+=e[r].styles+"\n\n");for(r=0;r<e.length;r++){var i=e[r];if(void 0!==i.selector){var o="";void 0!==i.comments&&(o=i.comments+"\n"),"media"===i.type?(s+=o+i.selector+"{\n",s+=this.getCSSForEditor(i.subStyles,t+1),s+="}\n\n"):"keyframes"!==i.type&&"imports"!==i.type&&(s+=this.getSpaces(t)+o+i.selector+" {\n",s+=this.getCSSOfRules(i.rules,t+1),s+=this.getSpaces(t)+"}\n\n")}}for(r=0;r<e.length;r++)"keyframes"===e[r].type&&(s+=e[r].styles+"\n\n");return s},t.prototype.getImports=function(e){for(var t=[],s=0;s<e.length;s++)"imports"===e[s].type&&t.push(e[s].styles);return t},t.prototype.getCSSOfRules=function(e,t){for(var s="",r=0;r<e.length;r++)void 0!==e[r]&&""!==e[r].value&&(s+=void 0===e[r].defective?this.getSpaces(t)+e[r].directive+": "+e[r].value+";\n":this.getSpaces(t)+e[r].value+";\n");return s||"\n"},t.prototype.getSpaces=function(e){for(var t="",s=0;2*e>s;s++)t+=" ";return t},t.prototype.applyNamespacing=function(e,t){var s=e,r="."+this.cssPreviewNamespace;void 0!==t&&(r=t),"string"==typeof e&&(s=this.parseCSS(e));for(var i=0;i<s.length;i++){var o=s[i];if(!(o.selector.indexOf("@font-face")>-1||o.selector.indexOf("keyframes")>-1||o.selector.indexOf("@import")>-1||o.selector.indexOf(".form-all")>-1||o.selector.indexOf("#stage")>-1))if("media"!==o.type){for(var n=o.selector.split(","),l=[],p=0;p<n.length;p++)-1===n[p].indexOf(".supernova")?l.push(r+" "+n[p]):l.push(n[p]);o.selector=l.join(",")}else o.subStyles=this.applyNamespacing(o.subStyles,t)}return s},t.prototype.clearNamespacing=function(e,t){void 0===t&&(t=!1);var s=e,r="."+this.cssPreviewNamespace;"string"==typeof e&&(s=this.parseCSS(e));for(var i=0;i<s.length;i++){var o=s[i];if("media"!==o.type){for(var n=o.selector.split(","),l=[],p=0;p<n.length;p++)l.push(n[p].split(r+" ").join(""));o.selector=l.join(",")}else o.subStyles=this.clearNamespacing(o.subStyles,!0)}return t===!1?this.getCSSForEditor(s):s},t.prototype.createStyleElement=function(e,t,s){if(void 0===s&&(s=!1),this.testMode===!1&&"nonamespace"!==s&&(t=this.applyNamespacing(t)),"string"!=typeof t&&(t=this.getCSSForEditor(t)),s===!0&&(t=this.getCSSForEditor(this.parseCSS(t))),this.testMode!==!1)return this.testMode("create style #"+e,t);var r=document.getElementById(e);r&&r.parentNode.removeChild(r);var i=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.id=e,o.type="text/css",i.appendChild(o),o.styleSheet&&!o.sheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))},window.cssjs=t}();
|
|
1 |
+
!function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n?n:e)},l,l.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){},{}],2:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,o=function(e){return i.exec(e).slice(1)};n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,i="/"===s.charAt(0))}return n=t(r(n.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(e){var i=n.isAbsolute(e),o="/"===s(e,-1);return e=t(r(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&o&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),s=Math.min(i.length,o.length),u=s,a=0;s>a;a++)if(i[a]!==o[a]){u=a;break}for(var c=[],a=u;a<i.length;a++)c.push("..");return c=c.concat(o.slice(u)),c.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){var t=o(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},n.basename=function(e,t){var n=o(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){return o(e)[3]};var s="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return 0>t&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:3}],3:[function(e,t,n){function r(){l=!1,u.length?c=u.concat(c):p=-1,c.length&&i()}function i(){if(!l){var e=setTimeout(r);l=!0;for(var t=c.length;t;){for(u=c,c=[];++p<t;)u&&u[p].run();p=-1,t=c.length}u=null,l=!1,clearTimeout(e)}}function o(e,t){this.fun=e,this.array=t}function s(){}var u,a=t.exports={},c=[],l=!1,p=-1;a.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new o(e,t)),1!==c.length||l||setTimeout(i,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=s,a.addListener=s,a.once=s,a.off=s,a.removeListener=s,a.removeAllListeners=s,a.emit=s,a.binding=function(e){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},{}],4:[function(e,t,n){window.css=e("css")},{css:5}],5:[function(e,t,n){n.parse=e("./lib/parse"),n.stringify=e("./lib/stringify")},{"./lib/parse":6,"./lib/stringify":10}],6:[function(e,t,n){function r(e){return e?e.replace(/^\s+|\s+$/g,""):""}function i(e,t){var n=e&&"string"==typeof e.type,r=n?e:t;for(var o in e){var s=e[o];Array.isArray(s)?s.forEach(function(e){i(e,r)}):s&&"object"==typeof s&&i(s,r)}return n&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var o=/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//g;t.exports=function(e,t){function n(e){var t=e.match(/\n/g);t&&(k+=t.length);var n=e.lastIndexOf("\n");P=~n?e.length-n:P+e.length}function s(){var e={line:k,column:P};return function(t){return t.position=new u(e),m(),t}}function u(e){this.start=e,this.end={line:k,column:P},this.source=t.source}function a(n){var r=new Error(t.source+":"+k+":"+P+": "+n);if(r.reason=n,r.filename=t.source,r.line=k,r.column=P,r.source=e,!t.silent)throw r;G.push(r)}function c(){var e=f();return{type:"stylesheet",stylesheet:{rules:e,parsingErrors:G}}}function l(){return h(/^{\s*/)}function p(){return h(/^}/)}function f(){var t,n=[];for(m(),g(n);e.length&&"}"!=e.charAt(0)&&(t=O()||j());)t!==!1&&(n.push(t),g(n));return n}function h(t){var r=t.exec(e);if(r){var i=r[0];return n(i),e=e.slice(i.length),r}}function m(){h(/^\s*/)}function g(e){var t;for(e=e||[];t=d();)t!==!1&&e.push(t);return e}function d(){var t=s();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return a("End of comment missing");var i=e.slice(2,r-2);return P+=2,n(i),e=e.slice(r),P+=2,t({type:"comment",comment:i})}}function v(){var e=h(/^([^{]+)/);if(e)return r(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function y(){var e=s(),t=h(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){if(t=r(t[0]),!h(/^:\s*/))return a("property missing ':'");var n=h(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),i=e({type:"declaration",property:t.replace(o,""),value:n?r(n[0]).replace(o,""):""});return h(/^[;\s]*/),i}}function _(){var e=[];if(!l())return a("missing '{'");g(e);for(var t;t=y();)t!==!1&&(e.push(t),g(e));return p()?e:a("missing '}'")}function C(){for(var e,t=[],n=s();e=h(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),h(/^,\s*/);return t.length?n({type:"keyframe",values:t,declarations:_()}):void 0}function w(){var e=s(),t=h(/^@([-\w]+)?keyframes\s*/);if(t){var n=t[1],t=h(/^([-\w]+)\s*/);if(!t)return a("@keyframes missing name");var r=t[1];if(!l())return a("@keyframes missing '{'");for(var i,o=g();i=C();)o.push(i),o=o.concat(g());return p()?e({type:"keyframes",name:r,vendor:n,keyframes:o}):a("@keyframes missing '}'")}}function S(){var e=s(),t=h(/^@supports *([^{]+)/);if(t){var n=r(t[1]);if(!l())return a("@supports missing '{'");var i=g().concat(f());return p()?e({type:"supports",supports:n,rules:i}):a("@supports missing '}'")}}function A(){var e=s(),t=h(/^@host\s*/);if(t){if(!l())return a("@host missing '{'");var n=g().concat(f());return p()?e({type:"host",rules:n}):a("@host missing '}'")}}function M(){var e=s(),t=h(/^@media *([^{]+)/);if(t){var n=r(t[1]);if(!l())return a("@media missing '{'");var i=g().concat(f());return p()?e({type:"media",media:n,rules:i}):a("@media missing '}'")}}function b(){var e=s(),t=h(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);return t?e({type:"custom-media",name:r(t[1]),media:r(t[2])}):void 0}function R(){var e=s(),t=h(/^@page */);if(t){var n=v()||[];if(!l())return a("@page missing '{'");for(var r,i=g();r=y();)i.push(r),i=i.concat(g());return p()?e({type:"page",selectors:n,declarations:i}):a("@page missing '}'")}}function x(){var e=s(),t=h(/^@([-\w]+)?document *([^{]+)/);if(t){var n=r(t[1]),i=r(t[2]);if(!l())return a("@document missing '{'");var o=g().concat(f());return p()?e({type:"document",document:i,vendor:n,rules:o}):a("@document missing '}'")}}function L(){var e=s(),t=h(/^@font-face\s*/);if(t){if(!l())return a("@font-face missing '{'");for(var n,r=g();n=y();)r.push(n),r=r.concat(g());return p()?e({type:"font-face",declarations:r}):a("@font-face missing '}'")}}function E(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var n=s(),r=h(t);if(r){var i={type:e};return i[e]=r[1].trim(),n(i)}}}function O(){return"@"==e[0]?w()||M()||b()||S()||N()||T()||V()||x()||R()||A()||L():void 0}function j(){var e=s(),t=v();return t?(g(),e({type:"rule",selectors:t,declarations:_()})):a("selector missing")}t=t||{};var k=1,P=1;u.prototype.content=e;var G=[],N=E("import"),T=E("charset"),V=E("namespace");return i(c())}},{}],7:[function(e,t,n){function r(e){this.options=e||{}}t.exports=r,r.prototype.emit=function(e){return e},r.prototype.visit=function(e){return this[e.type](e)},r.prototype.mapVisit=function(e,t){var n="";t=t||"";for(var r=0,i=e.length;i>r;r++)n+=this.visit(e[r]),t&&i-1>r&&(n+=this.emit(t));return n}},{}],8:[function(e,t,n){function r(e){i.call(this,e)}var i=e("./compiler"),o=e("inherits");t.exports=r,o(r,i),r.prototype.compile=function(e){return e.stylesheet.rules.map(this.visit,this).join("")},r.prototype.comment=function(e){return this.emit("",e.position)},r.prototype["import"]=function(e){return this.emit("@import "+e["import"]+";",e.position)},r.prototype.media=function(e){return this.emit("@media "+e.media,e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype.document=function(e){var t="@"+(e.vendor||"")+"document "+e.document;return this.emit(t,e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype.charset=function(e){return this.emit("@charset "+e.charset+";",e.position)},r.prototype.namespace=function(e){return this.emit("@namespace "+e.namespace+";",e.position)},r.prototype.supports=function(e){return this.emit("@supports "+e.supports,e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype.keyframes=function(e){return this.emit("@"+(e.vendor||"")+"keyframes "+e.name,e.position)+this.emit("{")+this.mapVisit(e.keyframes)+this.emit("}")},r.prototype.keyframe=function(e){var t=e.declarations;return this.emit(e.values.join(","),e.position)+this.emit("{")+this.mapVisit(t)+this.emit("}")},r.prototype.page=function(e){var t=e.selectors.length?e.selectors.join(", "):"";return this.emit("@page "+t,e.position)+this.emit("{")+this.mapVisit(e.declarations)+this.emit("}")},r.prototype["font-face"]=function(e){return this.emit("@font-face",e.position)+this.emit("{")+this.mapVisit(e.declarations)+this.emit("}")},r.prototype.host=function(e){return this.emit("@host",e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype["custom-media"]=function(e){return this.emit("@custom-media "+e.name+" "+e.media+";",e.position)},r.prototype.rule=function(e){var t=e.declarations;return t.length?this.emit(e.selectors.join(","),e.position)+this.emit("{")+this.mapVisit(t)+this.emit("}"):""},r.prototype.declaration=function(e){return this.emit(e.property+":"+e.value,e.position)+this.emit(";")}},{"./compiler":7,inherits:12}],9:[function(e,t,n){function r(e){e=e||{},i.call(this,e),this.indentation=e.indent}var i=e("./compiler"),o=e("inherits");t.exports=r,o(r,i),r.prototype.compile=function(e){return this.stylesheet(e)},r.prototype.stylesheet=function(e){return this.mapVisit(e.stylesheet.rules,"\n\n")},r.prototype.comment=function(e){return this.emit(this.indent()+"/*"+e.comment+"*/",e.position)},r.prototype["import"]=function(e){return this.emit("@import "+e["import"]+";",e.position)},r.prototype.media=function(e){return this.emit("@media "+e.media,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype.document=function(e){var t="@"+(e.vendor||"")+"document "+e.document;return this.emit(t,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype.charset=function(e){return this.emit("@charset "+e.charset+";",e.position)},r.prototype.namespace=function(e){return this.emit("@namespace "+e.namespace+";",e.position)},r.prototype.supports=function(e){return this.emit("@supports "+e.supports,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype.keyframes=function(e){return this.emit("@"+(e.vendor||"")+"keyframes "+e.name,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.keyframes,"\n")+this.emit(this.indent(-1)+"}")},r.prototype.keyframe=function(e){var t=e.declarations;return this.emit(this.indent())+this.emit(e.values.join(", "),e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(t,"\n")+this.emit(this.indent(-1)+"\n"+this.indent()+"}\n")},r.prototype.page=function(e){var t=e.selectors.length?e.selectors.join(", ")+" ":"";return this.emit("@page "+t,e.position)+this.emit("{\n")+this.emit(this.indent(1))+this.mapVisit(e.declarations,"\n")+this.emit(this.indent(-1))+this.emit("\n}")},r.prototype["font-face"]=function(e){return this.emit("@font-face ",e.position)+this.emit("{\n")+this.emit(this.indent(1))+this.mapVisit(e.declarations,"\n")+this.emit(this.indent(-1))+this.emit("\n}")},r.prototype.host=function(e){return this.emit("@host",e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype["custom-media"]=function(e){return this.emit("@custom-media "+e.name+" "+e.media+";",e.position)},r.prototype.rule=function(e){var t=this.indent(),n=e.declarations;return n.length?this.emit(e.selectors.map(function(e){return t+e}).join(",\n"),e.position)+this.emit(" {\n")+this.emit(this.indent(1))+this.mapVisit(n,"\n")+this.emit(this.indent(-1))+this.emit("\n"+this.indent()+"}"):""},r.prototype.declaration=function(e){return this.emit(this.indent())+this.emit(e.property+": "+e.value,e.position)+this.emit(";")},r.prototype.indent=function(e){return this.level=this.level||1,null!=e?(this.level+=e,""):Array(this.level).join(this.indentation||" ")}},{"./compiler":7,inherits:12}],10:[function(e,t,n){var r=e("./compress"),i=e("./identity");t.exports=function(t,n){n=n||{};var o=n.compress?new r(n):new i(n);if(n.sourcemap){var s=e("./source-map-support");s(o);var u=o.compile(t);o.applySourceMaps();var a="generator"===n.sourcemap?o.map:o.map.toJSON();return{code:u,map:a}}var u=o.compile(t);return u}},{"./compress":8,"./identity":9,"./source-map-support":11}],11:[function(e,t,n){function r(e){e._comment=e.comment,e.map=new i,e.position={line:1,column:1},e.files={};for(var t in n)e[t]=n[t]}var i=e("source-map").SourceMapGenerator,o=e("source-map").SourceMapConsumer,s=e("source-map-resolve"),u=e("urix"),a=e("fs"),c=e("path");t.exports=r,n.updatePosition=function(e){var t=e.match(/\n/g);t&&(this.position.line+=t.length);var n=e.lastIndexOf("\n");this.position.column=~n?e.length-n:this.position.column+e.length},n.emit=function(e,t){if(t){var n=u(t.source||"source.css");this.map.addMapping({source:n,generated:{line:this.position.line,column:Math.max(this.position.column-1,0)},original:{line:t.start.line,column:t.start.column-1}}),this.addFile(n,t)}return this.updatePosition(e),e},n.addFile=function(e,t){"string"==typeof t.content&&(Object.prototype.hasOwnProperty.call(this.files,e)||(this.files[e]=t.content))},n.applySourceMaps=function(){Object.keys(this.files).forEach(function(e){var t=this.files[e];if(this.map.setSourceContent(e,t),this.options.inputSourcemaps!==!1){var n=s.resolveSync(t,e,a.readFileSync);if(n){var r=new o(n.map),i=n.sourcesRelativeTo;this.map.applySourceMap(r,e,u(c.dirname(i)))}}},this)},n.comment=function(e){return/^# sourceMappingURL=/.test(e.comment)?this.emit("",e.position):this._comment(e)}},{fs:1,path:2,"source-map":16,"source-map-resolve":15,urix:27}],12:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],13:[function(e,t,n){void function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof n?t.exports=r():e.resolveUrl=r()}(this,function(){function e(){var e=arguments.length;if(0===e)throw new Error("resolveUrl requires at least one argument; got none.");var t=document.createElement("base");if(t.href=arguments[0],1===e)return t.href;var n=document.getElementsByTagName("head")[0];n.insertBefore(t,n.firstChild);for(var r,i=document.createElement("a"),o=1;e>o;o++)i.href=arguments[o],r=i.href,t.href=r;return n.removeChild(t),r}return e})},{}],14:[function(e,t,n){void function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof n?t.exports=r():e.sourceMappingURL=r()}(this,function(){var e=/[#@] sourceMappingURL=([^\s'"]*)/,t=RegExp("(?:/\\*(?:\\s*\r?\n(?://)?)?(?:"+e.source+")\\s*\\*/|//(?:"+e.source+"))\\s*$");return{regex:t,_innerRegex:e,getFrom:function(e){var n=e.match(t);return n?n[1]||n[2]||"":null},existsIn:function(e){return t.test(e)},removeFrom:function(e){return e.replace(t,"")},insertBefore:function(e,n){var r=e.match(t);return r?e.slice(0,r.index)+n+e.slice(r.index):e+n}}})},{}],15:[function(e,t,n){void function(r,i){if("function"==typeof define&&define.amd)define(["source-map-url","resolve-url"],i);else if("object"==typeof n){var o=e("source-map-url"),s=e("resolve-url");t.exports=i(o,s)}else r.sourceMapResolve=i(r.sourceMappingURL,r.resolveUrl)}(this,function(e,t){function n(e,t,n){setImmediate(function(){e(t,n)})}function r(e){return JSON.parse(e.replace(/^\)\]\}'/,""))}function i(e,t,i,o){var u;try{u=s(e,t)}catch(a){return n(o,a)}return!u||u.map?n(o,null,u):void i(u.url,function(e,t){if(e)return o(e);try{u.map=r(String(t))}catch(e){return o(e)}o(null,u)})}function o(e,t,n){var i=s(e,t);return!i||i.map?i:(i.map=r(String(n(i.url))),i)}function s(n,i){var o=e.getFrom(n);if(!o)return null;var s=o.match(f);if(s){var u=s[1],a=s[2],c=s[3];if(!h.test(u))throw new Error("Unuseful data uri mime type: "+(u||"text/plain"));return{sourceMappingURL:o,url:null,sourcesRelativeTo:i,map:r(";base64"===a?atob(c):decodeURIComponent(c))}}var l=t(i,o);return{sourceMappingURL:o,url:l,sourcesRelativeTo:l,map:null}}function u(e,t,r,i,o){"function"==typeof i&&(o=i,i={});var s=e.sources.length,u=!1,a={sourcesResolved:[],sourcesContent:[]},l=function(e){if(!u){if(e)return u=!0,o(e);s--,0===s&&o(null,a)}};c(e,t,i,function(e,t,i){a.sourcesResolved[i]=e,"string"==typeof t?(a.sourcesContent[i]=t,n(l,null)):r(e,function(e,t){a.sourcesContent[i]=String(t),l(e)})})}function a(e,t,n,r){var i={sourcesResolved:[],sourcesContent:[]};return c(e,t,r,function(e,t,r){i.sourcesResolved[r]=e,null!==n&&("string"==typeof t?i.sourcesContent[r]=t:i.sourcesContent[r]=String(n(e)))}),i}function c(e,n,r,i){r=r||{};for(var o,s,u=0,a=e.sources.length;a>u;u++)o=e.sourceRoot&&!r.ignoreSourceRoot?t(n,e.sourceRoot.replace(m,"/"),e.sources[u]):t(n,e.sources[u]),s=(e.sourcesContent||[])[u],i(o,s,u)}function l(e,t,n,r,o){"function"==typeof r&&(o=r,r={}),i(e,t,n,function(e,t){return e?o(e):t?void u(t.map,t.sourcesRelativeTo,n,r,function(e,n){return e?o(e):(t.sourcesResolved=n.sourcesResolved,t.sourcesContent=n.sourcesContent,void o(null,t))}):o(null,null)})}function p(e,t,n,r){var i=o(e,t,n);if(!i)return null;var s=a(i.map,i.sourcesRelativeTo,n,r);return i.sourcesResolved=s.sourcesResolved,i.sourcesContent=s.sourcesContent,i}var f=/^data:([^,;]*)(;[^,;]*)*(?:,(.*))?$/,h=/^(?:application|text)\/json$/,m=/\/?$/;return{resolveSourceMap:i,resolveSourceMapSync:o,resolveSources:u,resolveSourcesSync:a,resolve:l,resolveSync:p}})},{"resolve-url":13,"source-map-url":14}],16:[function(e,t,n){n.SourceMapGenerator=e("./source-map/source-map-generator").SourceMapGenerator,n.SourceMapConsumer=e("./source-map/source-map-consumer").SourceMapConsumer,n.SourceNode=e("./source-map/source-node").SourceNode},{"./source-map/source-map-consumer":22,"./source-map/source-map-generator":23,"./source-map/source-node":24}],17:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(){this._array=[],this._set={}}var i=e("./util");r.fromArray=function(e,t){for(var n=new r,i=0,o=e.length;o>i;i++)n.add(e[i],t);return n},r.prototype.add=function(e,t){var n=this.has(e),r=this._array.length;(!n||t)&&this._array.push(e),n||(this._set[i.toSetString(e)]=r)},r.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this._set,i.toSetString(e))},r.prototype.indexOf=function(e){if(this.has(e))return this._set[i.toSetString(e)];throw new Error('"'+e+'" is not in the set.')},r.prototype.at=function(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},r.prototype.toArray=function(){return this._array.slice()},t.ArraySet=r})},{"./util":25,amdefine:26}],18:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e){return 0>e?(-e<<1)+1:(e<<1)+0}function i(e){var t=1===(1&e),n=e>>1;return t?-n:n}var o=e("./base64"),s=5,u=1<<s,a=u-1,c=u;t.encode=function(e){var t,n="",i=r(e);do t=i&a,i>>>=s,i>0&&(t|=c),n+=o.encode(t);while(i>0);return n},t.decode=function(e,t){var n,r,u=0,l=e.length,p=0,f=0;do{if(u>=l)throw new Error("Expected more digits in base 64 VLQ value.");r=o.decode(e.charAt(u++)),n=!!(r&c),r&=a,p+=r<<f,f+=s}while(n);t.value=i(p),t.rest=e.slice(u)}})},{"./base64":19,amdefine:26}],19:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){var r={},i={};"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").forEach(function(e,t){r[e]=t,i[t]=e}),t.encode=function(e){if(e in i)return i[e];throw new TypeError("Must be between 0 and 63: "+e)},t.decode=function(e){if(e in r)return r[e];throw new TypeError("Not a valid base 64 digit: "+e)}})},{amdefine:26}],20:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t,n,i,o){var s=Math.floor((t-e)/2)+e,u=o(n,i[s],!0);return 0===u?s:u>0?t-s>1?r(s,t,n,i,o):s:s-e>1?r(e,s,n,i,o):0>e?-1:e}t.search=function(e,t,n){return 0===t.length?-1:r(-1,t.length,e,t,n)}})},{amdefine:26}],21:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t){var n=e.generatedLine,r=t.generatedLine,i=e.generatedColumn,s=t.generatedColumn;return r>n||r==n&&s>=i||o.compareByGeneratedPositions(e,t)<=0}function i(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}var o=e("./util");i.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},i.prototype.add=function(e){r(this._last,e)?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},i.prototype.toArray=function(){return this._sorted||(this._array.sort(o.compareByGeneratedPositions),this._sorted=!0),this._array},t.MappingList=i})},{"./util":25,amdefine:26}],22:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e){var t=e;"string"==typeof e&&(t=JSON.parse(e.replace(/^\)\]\}'/,"")));var n=i.getArg(t,"version"),r=i.getArg(t,"sources"),o=i.getArg(t,"names",[]),u=i.getArg(t,"sourceRoot",null),a=i.getArg(t,"sourcesContent",null),c=i.getArg(t,"mappings"),l=i.getArg(t,"file",null);if(n!=this._version)throw new Error("Unsupported version: "+n);r=r.map(i.normalize),this._names=s.fromArray(o,!0),this._sources=s.fromArray(r,!0),this.sourceRoot=u,this.sourcesContent=a,this._mappings=c,this.file=l}var i=e("./util"),o=e("./binary-search"),s=e("./array-set").ArraySet,u=e("./base64-vlq");r.fromSourceMap=function(e){var t=Object.create(r.prototype);return t._names=s.fromArray(e._names.toArray(),!0),t._sources=s.fromArray(e._sources.toArray(),!0),t.sourceRoot=e._sourceRoot,t.sourcesContent=e._generateSourcesContent(t._sources.toArray(),t.sourceRoot),t.file=e._file,t.__generatedMappings=e._mappings.toArray().slice(),t.__originalMappings=e._mappings.toArray().slice().sort(i.compareByOriginalPositions),t},r.prototype._version=3,Object.defineProperty(r.prototype,"sources",{get:function(){return this._sources.toArray().map(function(e){return null!=this.sourceRoot?i.join(this.sourceRoot,e):e},this)}}),r.prototype.__generatedMappings=null,Object.defineProperty(r.prototype,"_generatedMappings",{get:function(){return this.__generatedMappings||(this.__generatedMappings=[],this.__originalMappings=[],this._parseMappings(this._mappings,this.sourceRoot)),this.__generatedMappings}}),r.prototype.__originalMappings=null,Object.defineProperty(r.prototype,"_originalMappings",{get:function(){return this.__originalMappings||(this.__generatedMappings=[],this.__originalMappings=[],this._parseMappings(this._mappings,this.sourceRoot)),this.__originalMappings}}),r.prototype._nextCharIsMappingSeparator=function(e){var t=e.charAt(0);return";"===t||","===t},r.prototype._parseMappings=function(e,t){for(var n,r=1,o=0,s=0,a=0,c=0,l=0,p=e,f={};p.length>0;)if(";"===p.charAt(0))r++,p=p.slice(1),o=0;else if(","===p.charAt(0))p=p.slice(1);else{if(n={},n.generatedLine=r,u.decode(p,f),n.generatedColumn=o+f.value,o=n.generatedColumn,p=f.rest,p.length>0&&!this._nextCharIsMappingSeparator(p)){if(u.decode(p,f),n.source=this._sources.at(c+f.value),c+=f.value,p=f.rest,0===p.length||this._nextCharIsMappingSeparator(p))throw new Error("Found a source, but no line and column");if(u.decode(p,f),n.originalLine=s+f.value,s=n.originalLine,n.originalLine+=1,p=f.rest,0===p.length||this._nextCharIsMappingSeparator(p))throw new Error("Found a source and line, but no column");u.decode(p,f),n.originalColumn=a+f.value,a=n.originalColumn,p=f.rest,p.length>0&&!this._nextCharIsMappingSeparator(p)&&(u.decode(p,f),n.name=this._names.at(l+f.value),l+=f.value,p=f.rest)}this.__generatedMappings.push(n),"number"==typeof n.originalLine&&this.__originalMappings.push(n)}this.__generatedMappings.sort(i.compareByGeneratedPositions),this.__originalMappings.sort(i.compareByOriginalPositions)},r.prototype._findMapping=function(e,t,n,r,i){if(e[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[n]);if(e[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[r]);return o.search(e,t,i)},r.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var t=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var n=this._generatedMappings[e+1];if(t.generatedLine===n.generatedLine){t.lastGeneratedColumn=n.generatedColumn-1;continue}}t.lastGeneratedColumn=1/0}},r.prototype.originalPositionFor=function(e){var t={generatedLine:i.getArg(e,"line"),generatedColumn:i.getArg(e,"column")},n=this._findMapping(t,this._generatedMappings,"generatedLine","generatedColumn",i.compareByGeneratedPositions);if(n>=0){var r=this._generatedMappings[n];if(r.generatedLine===t.generatedLine){var o=i.getArg(r,"source",null);return null!=o&&null!=this.sourceRoot&&(o=i.join(this.sourceRoot,o)),{source:o,line:i.getArg(r,"originalLine",null),column:i.getArg(r,"originalColumn",null),name:i.getArg(r,"name",null)}}}return{source:null,line:null,column:null,name:null}},r.prototype.sourceContentFor=function(e){if(!this.sourcesContent)return null;if(null!=this.sourceRoot&&(e=i.relative(this.sourceRoot,e)),this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];var t;if(null!=this.sourceRoot&&(t=i.urlParse(this.sourceRoot))){var n=e.replace(/^file:\/\//,"");if("file"==t.scheme&&this._sources.has(n))return this.sourcesContent[this._sources.indexOf(n)];if((!t.path||"/"==t.path)&&this._sources.has("/"+e))return this.sourcesContent[this._sources.indexOf("/"+e)]}throw new Error('"'+e+'" is not in the SourceMap.')},r.prototype.generatedPositionFor=function(e){var t={source:i.getArg(e,"source"),originalLine:i.getArg(e,"line"),originalColumn:i.getArg(e,"column")};null!=this.sourceRoot&&(t.source=i.relative(this.sourceRoot,t.source));var n=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions);if(n>=0){var r=this._originalMappings[n];return{line:i.getArg(r,"generatedLine",null),column:i.getArg(r,"generatedColumn",null),lastColumn:i.getArg(r,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},r.prototype.allGeneratedPositionsFor=function(e){var t={source:i.getArg(e,"source"),originalLine:i.getArg(e,"line"),originalColumn:1/0};null!=this.sourceRoot&&(t.source=i.relative(this.sourceRoot,t.source));var n=[],r=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions);if(r>=0)for(var o=this._originalMappings[r];o&&o.originalLine===t.originalLine;)n.push({line:i.getArg(o,"generatedLine",null),column:i.getArg(o,"generatedColumn",null),lastColumn:i.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[--r];return n.reverse()},r.GENERATED_ORDER=1,r.ORIGINAL_ORDER=2,r.prototype.eachMapping=function(e,t,n){var o,s=t||null,u=n||r.GENERATED_ORDER;switch(u){case r.GENERATED_ORDER:o=this._generatedMappings;break;case r.ORIGINAL_ORDER:o=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var a=this.sourceRoot;o.map(function(e){var t=e.source;return null!=t&&null!=a&&(t=i.join(a,t)),{source:t,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name}}).forEach(e,s)},t.SourceMapConsumer=r})},{"./array-set":17,"./base64-vlq":18,"./binary-search":20,"./util":25,amdefine:26}],23:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e){e||(e={}),this._file=o.getArg(e,"file",null),this._sourceRoot=o.getArg(e,"sourceRoot",null),this._skipValidation=o.getArg(e,"skipValidation",!1),this._sources=new s,this._names=new s,this._mappings=new u,this._sourcesContents=null}var i=e("./base64-vlq"),o=e("./util"),s=e("./array-set").ArraySet,u=e("./mapping-list").MappingList;r.prototype._version=3,r.fromSourceMap=function(e){var t=e.sourceRoot,n=new r({file:e.file,sourceRoot:t});return e.eachMapping(function(e){var r={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(r.source=e.source,null!=t&&(r.source=o.relative(t,r.source)),r.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(r.name=e.name)),n.addMapping(r)}),e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&n.setSourceContent(t,r)}),n},r.prototype.addMapping=function(e){var t=o.getArg(e,"generated"),n=o.getArg(e,"original",null),r=o.getArg(e,"source",null),i=o.getArg(e,"name",null);this._skipValidation||this._validateMapping(t,n,r,i),null==r||this._sources.has(r)||this._sources.add(r),null==i||this._names.has(i)||this._names.add(i),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=n&&n.line,originalColumn:null!=n&&n.column,source:r,name:i})},r.prototype.setSourceContent=function(e,t){var n=e;null!=this._sourceRoot&&(n=o.relative(this._sourceRoot,n)),null!=t?(this._sourcesContents||(this._sourcesContents={}),this._sourcesContents[o.toSetString(n)]=t):this._sourcesContents&&(delete this._sourcesContents[o.toSetString(n)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},r.prototype.applySourceMap=function(e,t,n){var r=t;if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');r=e.file}var i=this._sourceRoot;null!=i&&(r=o.relative(i,r));var u=new s,a=new s;this._mappings.unsortedForEach(function(t){if(t.source===r&&null!=t.originalLine){var s=e.originalPositionFor({line:t.originalLine,column:t.originalColumn});null!=s.source&&(t.source=s.source,null!=n&&(t.source=o.join(n,t.source)),null!=i&&(t.source=o.relative(i,t.source)),t.originalLine=s.line,t.originalColumn=s.column,null!=s.name&&(t.name=s.name))}var c=t.source;null==c||u.has(c)||u.add(c);var l=t.name;null==l||a.has(l)||a.add(l)},this),this._sources=u,this._names=a,e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&(null!=n&&(t=o.join(n,t)),null!=i&&(t=o.relative(i,t)),this.setSourceContent(t,r))},this)},r.prototype._validateMapping=function(e,t,n,r){if((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||n||r)&&!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:t,name:r
|
2 |
+
}))},r.prototype._serializeMappings=function(){for(var e,t=0,n=1,r=0,s=0,u=0,a=0,c="",l=this._mappings.toArray(),p=0,f=l.length;f>p;p++){if(e=l[p],e.generatedLine!==n)for(t=0;e.generatedLine!==n;)c+=";",n++;else if(p>0){if(!o.compareByGeneratedPositions(e,l[p-1]))continue;c+=","}c+=i.encode(e.generatedColumn-t),t=e.generatedColumn,null!=e.source&&(c+=i.encode(this._sources.indexOf(e.source)-a),a=this._sources.indexOf(e.source),c+=i.encode(e.originalLine-1-s),s=e.originalLine-1,c+=i.encode(e.originalColumn-r),r=e.originalColumn,null!=e.name&&(c+=i.encode(this._names.indexOf(e.name)-u),u=this._names.indexOf(e.name)))}return c},r.prototype._generateSourcesContent=function(e,t){return e.map(function(e){if(!this._sourcesContents)return null;null!=t&&(e=o.relative(t,e));var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null},this)},r.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},r.prototype.toString=function(){return JSON.stringify(this)},t.SourceMapGenerator=r})},{"./array-set":17,"./base64-vlq":18,"./mapping-list":21,"./util":25,amdefine:26}],24:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t,n,r,i){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==t?null:t,this.source=null==n?null:n,this.name=null==i?null:i,this[a]=!0,null!=r&&this.add(r)}var i=e("./source-map-generator").SourceMapGenerator,o=e("./util"),s=/(\r?\n)/,u=10,a="$$$isSourceNode$$$";r.fromStringWithSourceMap=function(e,t,n){function i(e,t){if(null===e||void 0===e.source)u.add(t);else{var i=n?o.join(n,e.source):e.source;u.add(new r(e.originalLine,e.originalColumn,i,t,e.name))}}var u=new r,a=e.split(s),c=function(){var e=a.shift(),t=a.shift()||"";return e+t},l=1,p=0,f=null;return t.eachMapping(function(e){if(null!==f){if(!(l<e.generatedLine)){var t=a[0],n=t.substr(0,e.generatedColumn-p);return a[0]=t.substr(e.generatedColumn-p),p=e.generatedColumn,i(f,n),void(f=e)}var n="";i(f,c()),l++,p=0}for(;l<e.generatedLine;)u.add(c()),l++;if(p<e.generatedColumn){var t=a[0];u.add(t.substr(0,e.generatedColumn)),a[0]=t.substr(e.generatedColumn),p=e.generatedColumn}f=e},this),a.length>0&&(f&&i(f,c()),u.add(a.join(""))),t.sources.forEach(function(e){var r=t.sourceContentFor(e);null!=r&&(null!=n&&(e=o.join(n,e)),u.setSourceContent(e,r))}),u},r.prototype.add=function(e){if(Array.isArray(e))e.forEach(function(e){this.add(e)},this);else{if(!e[a]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this},r.prototype.prepend=function(e){if(Array.isArray(e))for(var t=e.length-1;t>=0;t--)this.prepend(e[t]);else{if(!e[a]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},r.prototype.walk=function(e){for(var t,n=0,r=this.children.length;r>n;n++)t=this.children[n],t[a]?t.walk(e):""!==t&&e(t,{source:this.source,line:this.line,column:this.column,name:this.name})},r.prototype.join=function(e){var t,n,r=this.children.length;if(r>0){for(t=[],n=0;r-1>n;n++)t.push(this.children[n]),t.push(e);t.push(this.children[n]),this.children=t}return this},r.prototype.replaceRight=function(e,t){var n=this.children[this.children.length-1];return n[a]?n.replaceRight(e,t):"string"==typeof n?this.children[this.children.length-1]=n.replace(e,t):this.children.push("".replace(e,t)),this},r.prototype.setSourceContent=function(e,t){this.sourceContents[o.toSetString(e)]=t},r.prototype.walkSourceContents=function(e){for(var t=0,n=this.children.length;n>t;t++)this.children[t][a]&&this.children[t].walkSourceContents(e);for(var r=Object.keys(this.sourceContents),t=0,n=r.length;n>t;t++)e(o.fromSetString(r[t]),this.sourceContents[r[t]])},r.prototype.toString=function(){var e="";return this.walk(function(t){e+=t}),e},r.prototype.toStringWithSourceMap=function(e){var t={code:"",line:1,column:0},n=new i(e),r=!1,o=null,s=null,a=null,c=null;return this.walk(function(e,i){t.code+=e,null!==i.source&&null!==i.line&&null!==i.column?((o!==i.source||s!==i.line||a!==i.column||c!==i.name)&&n.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name}),o=i.source,s=i.line,a=i.column,c=i.name,r=!0):r&&(n.addMapping({generated:{line:t.line,column:t.column}}),o=null,r=!1);for(var l=0,p=e.length;p>l;l++)e.charCodeAt(l)===u?(t.line++,t.column=0,l+1===p?(o=null,r=!1):r&&n.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name})):t.column++}),this.walkSourceContents(function(e,t){n.setSourceContent(e,t)}),{code:t.code,map:n}},t.SourceNode=r})},{"./source-map-generator":23,"./util":25,amdefine:26}],25:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t,n){if(t in e)return e[t];if(3===arguments.length)return n;throw new Error('"'+t+'" is a required argument.')}function i(e){var t=e.match(m);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}function o(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}function s(e){var t=e,n=i(e);if(n){if(!n.path)return e;t=n.path}for(var r,s="/"===t.charAt(0),u=t.split(/\/+/),a=0,c=u.length-1;c>=0;c--)r=u[c],"."===r?u.splice(c,1):".."===r?a++:a>0&&(""===r?(u.splice(c+1,a),a=0):(u.splice(c,2),a--));return t=u.join("/"),""===t&&(t=s?"/":"."),n?(n.path=t,o(n)):t}function u(e,t){""===e&&(e="."),""===t&&(t=".");var n=i(t),r=i(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),o(n);if(n||t.match(g))return t;if(r&&!r.host&&!r.path)return r.host=t,o(r);var u="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=u,o(r)):u}function a(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");var n=i(e);return"/"==t.charAt(0)&&n&&"/"==n.path?t.slice(1):0===t.indexOf(e+"/")?t.substr(e.length+1):t}function c(e){return"$"+e}function l(e){return e.substr(1)}function p(e,t){var n=e||"",r=t||"";return(n>r)-(r>n)}function f(e,t,n){var r;return(r=p(e.source,t.source))?r:(r=e.originalLine-t.originalLine)?r:(r=e.originalColumn-t.originalColumn,r||n?r:(r=p(e.name,t.name))?r:(r=e.generatedLine-t.generatedLine,r?r:e.generatedColumn-t.generatedColumn))}function h(e,t,n){var r;return(r=e.generatedLine-t.generatedLine)?r:(r=e.generatedColumn-t.generatedColumn,r||n?r:(r=p(e.source,t.source))?r:(r=e.originalLine-t.originalLine)?r:(r=e.originalColumn-t.originalColumn,r?r:p(e.name,t.name)))}t.getArg=r;var m=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/,g=/^data:.+\,.+$/;t.urlParse=i,t.urlGenerate=o,t.normalize=s,t.join=u,t.relative=a,t.toSetString=c,t.fromSetString=l,t.compareByOriginalPositions=f,t.compareByGeneratedPositions=h})},{amdefine:26}],26:[function(e,t,n){(function(n,r){"use strict";function i(t,i){function o(e){var t,n;for(t=0;e[t];t+=1)if(n=e[t],"."===n)e.splice(t,1),t-=1;else if(".."===n){if(1===t&&(".."===e[2]||".."===e[0]))break;t>0&&(e.splice(t-1,2),t-=2)}}function s(e,t){var n;return e&&"."===e.charAt(0)&&t&&(n=t.split("/"),n=n.slice(0,n.length-1),n=n.concat(e.split("/")),o(n),e=n.join("/")),e}function u(e){return function(t){return s(t,e)}}function a(e){function t(t){m[e]=t}return t.fromText=function(e,t){throw new Error("amdefine does not implement load.fromText")},t}function c(e,n,o){var s,u,a,c;if(e)u=m[e]={},a={id:e,uri:r,exports:u},s=p(i,u,a,e);else{if(g)throw new Error("amdefine with no module ID cannot be called more than once per file.");g=!0,u=t.exports,a=t,s=p(i,u,a,t.id)}n&&(n=n.map(function(e){return s(e)})),c="function"==typeof o?o.apply(a.exports,n):o,void 0!==c&&(a.exports=c,e&&(m[e]=a.exports))}function l(e,t,n){Array.isArray(e)?(n=t,t=e,e=void 0):"string"!=typeof e&&(n=e,e=t=void 0),t&&!Array.isArray(t)&&(n=t,t=void 0),t||(t=["require","exports","module"]),e?h[e]=[e,t,n]:c(e,t,n)}var p,f,h={},m={},g=!1,d=e("path");return p=function(e,t,r,i){function o(o,s){return"string"==typeof o?f(e,t,r,o,i):(o=o.map(function(n){return f(e,t,r,n,i)}),void(s&&n.nextTick(function(){s.apply(null,o)})))}return o.toUrl=function(e){return 0===e.indexOf(".")?s(e,d.dirname(r.filename)):e},o},i=i||function(){return t.require.apply(t,arguments)},f=function(e,t,n,r,i){var o,l,g=r.indexOf("!"),d=r;if(-1===g){if(r=s(r,i),"require"===r)return p(e,t,n,i);if("exports"===r)return t;if("module"===r)return n;if(m.hasOwnProperty(r))return m[r];if(h[r])return c.apply(null,h[r]),m[r];if(e)return e(d);throw new Error("No module with ID: "+r)}return o=r.substring(0,g),r=r.substring(g+1,r.length),l=f(e,t,n,o,i),r=l.normalize?l.normalize(r,u(i)):s(r,i),m[r]?m[r]:(l.load(r,p(e,t,n,i),a(r),{}),m[r])},l.require=function(e){return m[e]?m[e]:h[e]?(c.apply(null,h[e]),m[e]):void 0},l.amd={},l}t.exports=i}).call(this,e("_process"),"/node_modules/css/node_modules/source-map/node_modules/amdefine/amdefine.js")},{_process:3,path:2}],27:[function(e,t,n){function r(e){return"\\"===i.sep?e.replace(/\\/g,"/").replace(/^[a-z]:\/?/i,"/"):e}var i=e("path");t.exports=r},{path:2}]},{},[4]);
|
js/editor.js
CHANGED
@@ -115,7 +115,7 @@
|
|
115 |
var initValue = $textArea.val();
|
116 |
// Pad with empty lines so the editor takes up all the white space. To try make sure user gets copy/paste
|
117 |
// options in context menu.
|
118 |
-
var newlineMatches = initValue.match(/\n/gm);
|
119 |
var lineCount = newlineMatches ? newlineMatches.length+1 : 1;
|
120 |
var numPadLines = 15 - lineCount;
|
121 |
var paddedValue = initValue;
|
@@ -422,8 +422,10 @@
|
|
422 |
*/
|
423 |
socss.view.preview = Backbone.View.extend({
|
424 |
|
425 |
-
template: _.template('
|
426 |
editor: null,
|
|
|
|
|
427 |
|
428 |
initialize: function (attr) {
|
429 |
this.editor = attr.editor;
|
@@ -437,12 +439,19 @@
|
|
437 |
render: function () {
|
438 |
var thisView = this;
|
439 |
|
440 |
-
this.$el.html(this.template());
|
441 |
|
442 |
-
this.$('
|
443 |
-
.attr('src', socssOptions.homeURL)
|
444 |
.load(function () {
|
445 |
var $$ = $(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
$$.contents().find('a').each(function () {
|
447 |
var href = $(this).attr('href');
|
448 |
if (href === undefined) {
|
@@ -458,13 +467,44 @@
|
|
458 |
.mouseleave(function () {
|
459 |
thisView.clearHighlight();
|
460 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
},
|
462 |
|
463 |
/**
|
464 |
* Update the preview CSS from the CodeMirror value in the editor
|
465 |
*/
|
466 |
updatePreviewCss: function () {
|
467 |
-
var preview = this.$('
|
468 |
if (preview.length === 0) {
|
469 |
return;
|
470 |
}
|
@@ -660,7 +700,7 @@
|
|
660 |
* Initialize the properties editor with a new model
|
661 |
*/
|
662 |
initialize: function ( attr ) {
|
663 |
-
this.parser =
|
664 |
this.editor = attr.editor;
|
665 |
},
|
666 |
|
@@ -669,7 +709,7 @@
|
|
669 |
*/
|
670 |
render: function () {
|
671 |
var thisView = this;
|
672 |
-
|
673 |
// Clean up for potential re-renders
|
674 |
this.$('.section-tabs').empty();
|
675 |
this.$('.sections').empty();
|
@@ -752,85 +792,127 @@
|
|
752 |
* @param value
|
753 |
*/
|
754 |
setRuleValue: function (rule, value) {
|
755 |
-
if (
|
|
|
|
|
|
|
756 |
return;
|
757 |
}
|
758 |
|
|
|
759 |
var newRule = true;
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
newRule = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
764 |
break;
|
765 |
}
|
766 |
}
|
767 |
|
768 |
-
if (newRule) {
|
769 |
-
|
770 |
-
|
771 |
-
value: value
|
|
|
772 |
});
|
|
|
773 |
}
|
774 |
|
775 |
-
|
|
|
|
|
776 |
},
|
777 |
|
778 |
/**
|
779 |
* Adds the @import rule value if it doesn't already exist.
|
780 |
-
*
|
781 |
-
* @param
|
782 |
-
*
|
783 |
*/
|
784 |
-
addImport: function (
|
785 |
-
|
786 |
// get @import rules
|
787 |
// check if any have the same value
|
788 |
// if not, then add the new @ rule
|
789 |
-
|
790 |
-
var importRules = _.filter( this.parsed, function (
|
791 |
-
return
|
792 |
} );
|
793 |
var exists = _.any( importRules, function ( rule ) {
|
794 |
-
return rule.
|
795 |
} );
|
796 |
-
|
797 |
if ( !exists ) {
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
};
|
803 |
-
// Add it to the top! @import statements must precede other rule types.
|
804 |
-
this.parsed.unshift( newRule );
|
805 |
}
|
806 |
-
|
807 |
-
this.updateMainEditor( false );
|
808 |
},
|
809 |
-
|
810 |
/**
|
811 |
* Find @import which completely or partially contains the specified value.
|
812 |
*
|
813 |
* @param value
|
814 |
*/
|
815 |
findImport: function(value) {
|
816 |
-
|
817 |
-
|
818 |
-
return selector.selector.startsWith('@import') && selector.styles.indexOf(value) > -1;
|
819 |
} );
|
820 |
},
|
821 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
822 |
/**
|
823 |
* Get the rule value for the active selector
|
824 |
* @param rule
|
825 |
*/
|
826 |
getRuleValue: function (rule) {
|
827 |
-
if (typeof this.activeSelector === 'undefined' || typeof this.activeSelector.
|
828 |
return '';
|
829 |
}
|
830 |
|
831 |
-
|
832 |
-
|
833 |
-
|
|
|
834 |
}
|
835 |
}
|
836 |
return '';
|
@@ -840,22 +922,8 @@
|
|
840 |
* Update the main editor with the value of the parsed CSS
|
841 |
*/
|
842 |
updateMainEditor: function ( compress ) {
|
843 |
-
|
844 |
-
|
845 |
-
css = this.parser.compressCSS( this.parsed );
|
846 |
-
// Also remove any empty selectors
|
847 |
-
css = css.filter( function(v){
|
848 |
-
return (
|
849 |
-
typeof v.type !== 'undefined' ||
|
850 |
-
v.rules.length > 0
|
851 |
-
);
|
852 |
-
} );
|
853 |
-
}
|
854 |
-
else {
|
855 |
-
css = this.parsed;
|
856 |
-
}
|
857 |
-
|
858 |
-
this.editor.codeMirror.setValue( this.parser.getCSSForEditor( css ).trim() );
|
859 |
},
|
860 |
|
861 |
/**
|
@@ -895,27 +963,29 @@
|
|
895 |
loadCSS: function (css, activeSelector) {
|
896 |
this.css = css;
|
897 |
|
898 |
-
// Load the CSS
|
899 |
-
this.parsed = this.parser.
|
|
|
900 |
|
901 |
// Add the dropdown menu items
|
902 |
var dropdown = this.$('.toolbar select').empty();
|
903 |
-
for (var i = 0; i <
|
904 |
-
var rule =
|
905 |
-
|
906 |
-
// Exclude @
|
907 |
-
if(
|
908 |
continue;
|
909 |
}
|
910 |
-
|
911 |
-
if( typeof rule.subStyles !== 'undefined' ) {
|
912 |
|
913 |
-
|
914 |
-
|
|
|
|
|
|
|
915 |
dropdown.append(
|
916 |
$('<option>')
|
917 |
-
.html(
|
918 |
-
.attr( 'val',
|
919 |
.data( 'selector', subRule )
|
920 |
);
|
921 |
}
|
@@ -924,8 +994,8 @@
|
|
924 |
else {
|
925 |
dropdown.append(
|
926 |
$('<option>')
|
927 |
-
.html( rule.
|
928 |
-
.attr( 'val', rule.
|
929 |
.data( 'selector', rule )
|
930 |
);
|
931 |
}
|
@@ -1093,7 +1163,7 @@
|
|
1093 |
},
|
1094 |
|
1095 |
getValue: function () {
|
1096 |
-
return this.field.minicolors('value');
|
1097 |
},
|
1098 |
|
1099 |
setValue: function (val, options) {
|
115 |
var initValue = $textArea.val();
|
116 |
// Pad with empty lines so the editor takes up all the white space. To try make sure user gets copy/paste
|
117 |
// options in context menu.
|
118 |
+
var newlineMatches = initValue.match(/\n/gm);
|
119 |
var lineCount = newlineMatches ? newlineMatches.length+1 : 1;
|
120 |
var numPadLines = 15 - lineCount;
|
121 |
var paddedValue = initValue;
|
422 |
*/
|
423 |
socss.view.preview = Backbone.View.extend({
|
424 |
|
425 |
+
template: _.template( $('#template-preview-window').html() ),
|
426 |
editor: null,
|
427 |
+
originalUri: null,
|
428 |
+
currentUri: null,
|
429 |
|
430 |
initialize: function (attr) {
|
431 |
this.editor = attr.editor;
|
439 |
render: function () {
|
440 |
var thisView = this;
|
441 |
|
442 |
+
this.$el.html( this.template() );
|
443 |
|
444 |
+
this.$( '#preview-iframe' )
|
445 |
+
.attr( 'src', socssOptions.homeURL )
|
446 |
.load(function () {
|
447 |
var $$ = $(this);
|
448 |
+
|
449 |
+
// Update the current URI with the iframe URI
|
450 |
+
thisView.currentUri = new URI( $$.contents().get(0).location.href );
|
451 |
+
thisView.currentUri.removeQuery( 'so_css_preview' );
|
452 |
+
thisView.$( '#preview-navigator input' ).val( thisView.currentUri.toString() );
|
453 |
+
thisView.currentUri.addQuery( 'so_css_preview', 1 );
|
454 |
+
|
455 |
$$.contents().find('a').each(function () {
|
456 |
var href = $(this).attr('href');
|
457 |
if (href === undefined) {
|
467 |
.mouseleave(function () {
|
468 |
thisView.clearHighlight();
|
469 |
});
|
470 |
+
|
471 |
+
this.$( '#preview-navigator input' ).keydown( function( e ){
|
472 |
+
var $$ = $(this);
|
473 |
+
|
474 |
+
if( e.keyCode == 13 ) {
|
475 |
+
e.preventDefault();
|
476 |
+
|
477 |
+
var newUri = new URI( $$.val() );
|
478 |
+
|
479 |
+
// Validate the URI
|
480 |
+
if(
|
481 |
+
thisView.originalUri.host() !== newUri.host() ||
|
482 |
+
thisView.originalUri.protocol() !== newUri.protocol()
|
483 |
+
) {
|
484 |
+
$$.blur();
|
485 |
+
alert( $$.data( 'invalid-uri' ) );
|
486 |
+
$$.focus();
|
487 |
+
}
|
488 |
+
else {
|
489 |
+
newUri.addQuery( 'so_css_preview', 1 );
|
490 |
+
thisView.$( '#preview-iframe' ).attr( 'src', newUri.toString() );
|
491 |
+
}
|
492 |
+
}
|
493 |
+
} );
|
494 |
+
|
495 |
+
this.originalUri = new URI( socssOptions.homeURL );
|
496 |
+
this.currentUri = new URI( socssOptions.homeURL );
|
497 |
+
|
498 |
+
this.currentUri.removeQuery( 'so_css_preview' );
|
499 |
+
this.$('#preview-navigator input').val( this.currentUri.toString() );
|
500 |
+
this.currentUri.addQuery( 'so_css_preview', 1 );
|
501 |
},
|
502 |
|
503 |
/**
|
504 |
* Update the preview CSS from the CodeMirror value in the editor
|
505 |
*/
|
506 |
updatePreviewCss: function () {
|
507 |
+
var preview = this.$('#preview-iframe');
|
508 |
if (preview.length === 0) {
|
509 |
return;
|
510 |
}
|
700 |
* Initialize the properties editor with a new model
|
701 |
*/
|
702 |
initialize: function ( attr ) {
|
703 |
+
this.parser = window.css;
|
704 |
this.editor = attr.editor;
|
705 |
},
|
706 |
|
709 |
*/
|
710 |
render: function () {
|
711 |
var thisView = this;
|
712 |
+
|
713 |
// Clean up for potential re-renders
|
714 |
this.$('.section-tabs').empty();
|
715 |
this.$('.sections').empty();
|
792 |
* @param value
|
793 |
*/
|
794 |
setRuleValue: function (rule, value) {
|
795 |
+
if (
|
796 |
+
typeof this.activeSelector === 'undefined' ||
|
797 |
+
typeof this.activeSelector.declarations === 'undefined'
|
798 |
+
) {
|
799 |
return;
|
800 |
}
|
801 |
|
802 |
+
var declarations = this.activeSelector.declarations;
|
803 |
var newRule = true;
|
804 |
+
var valueChanged = false;
|
805 |
+
for (var i = 0; i < declarations.length; i++) {
|
806 |
+
if (declarations[i].property === rule) {
|
807 |
newRule = false;
|
808 |
+
var declaration = declarations[i];
|
809 |
+
if ( declaration.value !== value ) {
|
810 |
+
declaration.value = value;
|
811 |
+
valueChanged = true;
|
812 |
+
}
|
813 |
+
|
814 |
+
// Remove empty declarations
|
815 |
+
if ( _.isEmpty( declaration.value ) ) {
|
816 |
+
declarations.splice( declarations.indexOf( declaration ) );
|
817 |
+
}
|
818 |
break;
|
819 |
}
|
820 |
}
|
821 |
|
822 |
+
if ( newRule && !_.isEmpty( value ) ) {
|
823 |
+
declarations.push({
|
824 |
+
property: rule,
|
825 |
+
value: value,
|
826 |
+
type: 'declaration',
|
827 |
});
|
828 |
+
valueChanged = true;
|
829 |
}
|
830 |
|
831 |
+
if ( valueChanged ) {
|
832 |
+
this.updateMainEditor(false);
|
833 |
+
}
|
834 |
},
|
835 |
|
836 |
/**
|
837 |
* Adds the @import rule value if it doesn't already exist.
|
838 |
+
*
|
839 |
+
* @param newRule
|
840 |
+
*
|
841 |
*/
|
842 |
+
addImport: function (newRule) {
|
843 |
+
|
844 |
// get @import rules
|
845 |
// check if any have the same value
|
846 |
// if not, then add the new @ rule
|
847 |
+
|
848 |
+
var importRules = _.filter( this.parsed.stylesheet.rules, function ( rule) {
|
849 |
+
return rule.type === 'import';
|
850 |
} );
|
851 |
var exists = _.any( importRules, function ( rule ) {
|
852 |
+
return rule.import === newRule.import;
|
853 |
} );
|
854 |
+
|
855 |
if ( !exists ) {
|
856 |
+
// Add it to the top!
|
857 |
+
// @import statements must precede other rule types.
|
858 |
+
this.parsed.stylesheet.rules.unshift( newRule );
|
859 |
+
this.updateMainEditor( false );
|
|
|
|
|
|
|
860 |
}
|
861 |
+
|
|
|
862 |
},
|
863 |
+
|
864 |
/**
|
865 |
* Find @import which completely or partially contains the specified value.
|
866 |
*
|
867 |
* @param value
|
868 |
*/
|
869 |
findImport: function(value) {
|
870 |
+
return _.find( this.parsed.stylesheet.rules, function ( rule ) {
|
871 |
+
return rule.type === 'import' && rule.import.indexOf(value) > -1;
|
|
|
872 |
} );
|
873 |
},
|
874 |
|
875 |
+
/**
|
876 |
+
* Find @import which completely or partially contains the identifier value and update it's import property.
|
877 |
+
*
|
878 |
+
* @param identifier
|
879 |
+
* @param value
|
880 |
+
*/
|
881 |
+
updateImport: function(identifier, value) {
|
882 |
+
var importRule = this.findImport(identifier);
|
883 |
+
if ( importRule.import !== value.import ) {
|
884 |
+
importRule.import = value.import;
|
885 |
+
this.updateMainEditor(false);
|
886 |
+
}
|
887 |
+
},
|
888 |
+
|
889 |
+
/**
|
890 |
+
* Find @import which completely or partially contains the identifier value and remove it.
|
891 |
+
*
|
892 |
+
* @param identifier
|
893 |
+
*/
|
894 |
+
removeImport: function(identifier) {
|
895 |
+
var importIndex = _.findIndex( this.parsed.stylesheet.rules, function ( rule ) {
|
896 |
+
return rule.type === 'import' && rule.import.indexOf(identifier) > -1;
|
897 |
+
} );
|
898 |
+
if ( importIndex > -1 ) {
|
899 |
+
this.parsed.stylesheet.rules.splice(importIndex, 1);
|
900 |
+
}
|
901 |
+
},
|
902 |
+
|
903 |
/**
|
904 |
* Get the rule value for the active selector
|
905 |
* @param rule
|
906 |
*/
|
907 |
getRuleValue: function (rule) {
|
908 |
+
if (typeof this.activeSelector === 'undefined' || typeof this.activeSelector.declarations === 'undefined') {
|
909 |
return '';
|
910 |
}
|
911 |
|
912 |
+
var declarations = this.activeSelector.declarations;
|
913 |
+
for (var i = 0; i < declarations.length; i++) {
|
914 |
+
if (declarations[i].property === rule) {
|
915 |
+
return declarations[i].value;
|
916 |
}
|
917 |
}
|
918 |
return '';
|
922 |
* Update the main editor with the value of the parsed CSS
|
923 |
*/
|
924 |
updateMainEditor: function ( compress ) {
|
925 |
+
//TODO: add back compress option to remove/merge duplicated CSS selectors.
|
926 |
+
this.editor.codeMirror.setValue( this.parser.stringify( this.parsed ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
927 |
},
|
928 |
|
929 |
/**
|
963 |
loadCSS: function (css, activeSelector) {
|
964 |
this.css = css;
|
965 |
|
966 |
+
// Load the CSS
|
967 |
+
this.parsed = this.parser.parse(css, {silent:true});
|
968 |
+
var rules = this.parsed.stylesheet.rules;
|
969 |
|
970 |
// Add the dropdown menu items
|
971 |
var dropdown = this.$('.toolbar select').empty();
|
972 |
+
for (var i = 0; i < rules.length; i++) {
|
973 |
+
var rule = rules[i];
|
974 |
+
|
975 |
+
// Exclude @import statements
|
976 |
+
if ( ! _.contains( [ 'rule', 'media' ], rule.type) ) {
|
977 |
continue;
|
978 |
}
|
|
|
|
|
979 |
|
980 |
+
if( rule.type === 'media' ) {
|
981 |
+
|
982 |
+
for (var j = 0; j < rule.rules.length; j++) {
|
983 |
+
var mediaRule = '@media ' + rule.media;
|
984 |
+
var subRule = rule.rules[j];
|
985 |
dropdown.append(
|
986 |
$('<option>')
|
987 |
+
.html( mediaRule + ': ' + subRule.selectors.join(',') )
|
988 |
+
.attr( 'val', mediaRule + ': ' + subRule.selectors.join(',') )
|
989 |
.data( 'selector', subRule )
|
990 |
);
|
991 |
}
|
994 |
else {
|
995 |
dropdown.append(
|
996 |
$('<option>')
|
997 |
+
.html( rule.selectors.join(',') )
|
998 |
+
.attr( 'val', rule.selectors.join(',') )
|
999 |
.data( 'selector', rule )
|
1000 |
);
|
1001 |
}
|
1163 |
},
|
1164 |
|
1165 |
getValue: function () {
|
1166 |
+
return this.field.minicolors('value').trim();
|
1167 |
},
|
1168 |
|
1169 |
setValue: function (val, options) {
|
js/editor.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(t){this.editor=t.editor;var i=this;this.$(".editor-expand").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_expand")}),this.$(".editor-visual").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_visual")})},addButton:function(t,i){var s=this,r=e(this.button({text:t})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons")).click(function(t){t.preventDefault(),e(this).blur(),s.trigger("click_"+i)});return r}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(e){this.setupEditor()},render:function(){var t=this;this.toolbar=new s.view.toolbar({editor:this,el:this.$(".custom-css-toolbar")}),this.toolbar.editor=this,this.toolbar.render(),this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render(),this.toolbar.on("click_expand",function(){t.toggleExpand()}),this.toolbar.on("click_visual",function(){t.visualProperties.loadCSS(t.codeMirror.getValue().trim()),t.visualProperties.show()}),this.preview=new s.view.preview({editor:this,el:this.$(".custom-css-preview")}),this.preview.render()},setupEditor:function(){var t=this;this.registerCodeMirrorAutocomplete();for(var s=this.$("textarea.css-editor"),r=s.val(),n=r.match(/\n/gm),o=n?n.length+1:1,a=15-o,l=r,c=0;a>c;c++)l+="\n";s.val(l),this.codeMirror=CodeMirror.fromTextArea(s.get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",inputStyle:"contenteditable",gutters:["CodeMirror-lint-markers"],lint:!0}),this.$el.on("submit",function(){r=t.codeMirror.getValue().trim()}),e(window).bind("beforeunload",function(){var e=t.codeMirror.getValue().trim();return e!==r?i.loc.leave:void 0}),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).resize(function(){t.scaleEditor()}),this.setupCodeMirrorExtensions()},registerCodeMirrorAutocomplete:function(){var e=this,t={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(i){function s(e){for(var t in e)c&&0!==t.lastIndexOf(c,0)||p.push(t)}var r=i.getCursor(),n=i.getTokenAt(r),o=CodeMirror.innerMode(i.getMode(),n.state);if("css"===o.mode.name){if("keyword"===n.type&&0==="!important".indexOf(n.string))return{list:["!important"],from:CodeMirror.Pos(r.line,n.start),to:CodeMirror.Pos(r.line,n.end)};var a=n.start,l=r.ch,c=n.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=r.ch);var d=CodeMirror.resolveMode("text/css"),p=[],h=o.state.state;if("top"===h){for(var u=i.getLine(r.line).trim(),f=e.cssSelectors,v=0;v<f.length;v++)-1!==f[v].selector.indexOf(u)&&p.push(f[v].selector);if(p.length)return{list:p,from:CodeMirror.Pos(r.line,0),to:CodeMirror.Pos(r.line,l)}}else if("pseudo"===h||"variable-3"===n.type?s(t):"block"===h||"maybeprop"===h?s(d.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(d.valueKeywords),s(d.colorKeywords)):("media"===h||"media_parens"===h)&&(s(d.mediaTypes),s(d.mediaFeatures)),p.length)return{list:p,from:CodeMirror.Pos(r.line,a),to:CodeMirror.Pos(r.line,l)}}})},setupCodeMirrorExtensions:function(){var e=this;this.codeMirror.on("cursorActivity",function(t){var i=t.getCursor(),s=t.getTokenAt(i);CodeMirror.innerMode(t.getMode(),s.state);if("qualifier"===s.type||"tag"===s.type||"builtin"===s.type){var r=t.getLine(i.line),n=r.substring(0,s.end);e.preview.highlight(n)}else e.preview.clearHighlight()}),this.codeMirror.on("keyup",function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint({completeSingle:!1})})},scaleEditor:function(){this.$el.hasClass("expanded")?this.codeMirror.setSize("100%",e(window).outerHeight()-this.$(".custom-css-toolbar").outerHeight()):this.codeMirror.setSize("100%","auto")},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},setSnippets:function(e){if(!t.isEmpty(e)){var i=this;this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){i.snippets.show()})}},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){var t=this;this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){t.visualProperties.isVisible()?t.visualProperties.addSelector(e):t.addEmptySelector(e)}),e.on("click_property",function(e){t.visualProperties.isVisible()||t.codeMirror.replaceSelection(e+";\n ")}),e.on("set_active_element",function(e,i){t.visualProperties.isVisible()&&i.length&&t.visualProperties.addSelector(i[0].selector)})}}),s.view.preview=Backbone.View.extend({template:t.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),editor:null,initialize:function(e){this.editor=e.editor;var t=this;this.editor.codeMirror.on("change",function(e,i){t.updatePreviewCss()})},render:function(){var t=this;this.$el.html(this.template()),this.$(".preview-iframe").attr("src",i.homeURL).load(function(){var i=e(this);i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=-1===t.indexOf("?")?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()})},updatePreviewCss:function(){var e=this.$(".preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue().trim();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(t){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){var t=this,i=function(i){i.preventDefault();var s=e(this);t.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),t.viewSnippet({name:s.html(),description:s.data("description"),css:s.data("css")})};this.$el.html(this.template());for(var s=0;s<this.snippets.length;s++)e(this.snippet({name:this.snippets[s].Name})).data({description:this.snippets[s].Description,css:this.snippets[s].css}).appendTo(this.$("ul.snippets")).click(i);return t.$(".snippets li.snippet").eq(0).click(),this.attach(),this},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({model:s.model.cssRules,tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide"},initialize:function(e){this.parser=new cssjs,this.editor=e.editor},render:function(){var r=this;this.$(".section-tabs").empty(),this.$(".sections").empty(),this.$(".toolbar select").off(),r.propertyControllers=[];var n=i.propertyControllers;for(var o in n){var a=(e(this.tabTemplate({id:o,icon:n[o].icon,title:n[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(n[o].controllers))for(var l=0;l<n[o].controllers.length;l++){var c,d=e(r.controllerTemplate({title:n[o].controllers[l].title})).appendTo(a.find("tbody")),p=n[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[p.type]?new s.view.propertyController({el:d.find("td"),propertiesView:r,args:"undefined"==typeof p.args?{}:p.args}):new s.view.properties.controllers[p.type]({el:d.find("td"),propertiesView:r,args:"undefined"==typeof p.args?{}:p.args}),r.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=r.$('.sections .section[data-section="'+t.data("section")+'"]');r.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),r.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){r.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,t){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.rules){for(var i=!0,s=0;s<this.activeSelector.rules.length;s++)if(this.activeSelector.rules[s].directive===e){this.activeSelector.rules[s].value=t,i=!1;break}i&&this.activeSelector.rules.push({directive:e,value:t}),this.updateMainEditor(!1)}},addImport:function(e){var i=t.filter(this.parsed,function(e){return e.selector.startsWith("@import")}),s=t.any(i,function(t){return t.styles===e});if(!s){var r={selector:"@imports",styles:e,type:"imports"};this.parsed.unshift(r)}this.updateMainEditor(!1)},findImport:function(e){return t.find(this.parsed,function(t){return t.selector.startsWith("@import")&&t.styles.indexOf(e)>-1})},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.rules)return"";for(var t=0;t<this.activeSelector.rules.length;t++)if(this.activeSelector.rules[t].directive===e)return this.activeSelector.rules[t].value;return""},updateMainEditor:function(e){var t;"undefined"==typeof e||e===!0?(t=this.parser.compressCSS(this.parsed),t=t.filter(function(e){return"undefined"!=typeof e.type||e.rules.length>0})):t=this.parsed,this.editor.codeMirror.setValue(this.parser.getCSSForEditor(t).trim())},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",function(){e(this).hide()}),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(i,s){this.css=i,this.parsed=this.parser.compressCSS(this.parser.parseCSS(i));for(var r=this.$(".toolbar select").empty(),n=0;n<this.parsed.length;n++){var o=this.parsed[n];if("imports"!==o.type)if("undefined"!=typeof o.subStyles)for(var a=0;a<o.subStyles.length;a++){var l=o.subStyles[a];r.append(e("<option>").html(o.selector+": "+l.selector).attr("val",o.selector+": "+l.selector).data("selector",l))}else r.append(e("<option>").html(o.selector).attr("val",o.selector).data("selector",o))}"undefined"==typeof s&&(s=r.find("option").eq(0).attr("val")),t.isEmpty(s)||r.val(s).change()},setActivateSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue().trim(),e)),t.addClass("highlighted"),setTimeout(function(){t.removeClass("highlighted")},2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input")},initChangeEvents:function(){var t=this;this.field.on("change keyup",function(){t.trigger("change",e(this).val())})},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({template:t.template('<input type="text" value="" />'),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),this.field.minicolors({})},initChangeEvents:function(){var e=this;this.field.on("change keyup",function(){e.trigger("change",e.field.minicolors("value"))})},getValue:function(){return this.field.minicolors("value")},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template("<select></select>"),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("select"),this.field.append(e('<option value=""></option>').html(""));for(var t in this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));"undefined"!=typeof this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){var t=this;this.field.hide();var i=e('<div class="select-tabs"></div>').appendTo(this.$el);e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(i);for(var s in this.args.option_icons)e('<div class="select-tab"></div>').appendTo(i).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[s])).attr("data-value",s);i.find(".select-tab").css("width",100/i.find(">div").length+"%").click(function(){var s=e(this);i.find(".select-tab").removeClass("active"),s.addClass("active"),t.field.val(s.data("value")).change()})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var t=this;this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.$(".select").click(function(){t.media.open()}),this.media.on("select",function(){var e=this.state().get("selection").first().attributes,i=t.args.value.replace("{{url}}",e.url);t.field.val(i).change(),t.media.close()},this.media)}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupMeasurementField(this.field,{})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},i=this.units.map(t),s=new RegExp("([0-9\\.\\-]+)("+i.join("|")+")?","i"),r=s.exec(e);return null===r?{value:"",unit:""}:{value:r[1],unit:void 0===r[2]?"":r[2]}},setupMeasurementField:function(i,s){var r=this,n=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),n.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(n),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(n),l=e('<ul class="dropdown"></ul>').appendTo(n),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(n),d=0;d<r.units.length;d++){var p=e("<li></li>").html(r.units[d]).data("unit",r.units[d]);r.units[d]===s.defaultUnit&&p.addClass("active"),l.append(p)}var h=function(){var e=r.parseUnits(o.val());""!==e.unit&&e.unit!==n.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+n.data("unit"))},u=function(e){c.html(e),n.data("unit",e),o.trigger("keydown")};a.click(function(){l.toggle()}),l.find("li").click(function(){l.toggle(),u(e(this).data("unit")),h(),i.trigger("change")}),o.on("keyup keydown",function(t){var i=(e(this),"");"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?i=String.fromCharCode(t.keyCode):189===t.keyCode?i="-":190===t.keyCode&&(i="."));var s=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(o.val()+i).appendTo("body"),r=s.width();r=Math.min(r,63),s.remove(),c.css("left",r+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=r.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;n.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),d=l.width();d=Math.min(d,63),l.remove(),c.css("left",d+12)});var f=e('<div class="socss-diw"></div>').appendTo(n),v=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(f),m=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(f);m.click(function(){var e=r.parseUnits(i.val());if(""===e.value)return!0;var t=Math.ceil(1.05*e.value);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")}),v.click(function(){var e=r.parseUnits(i.val());if(""===e.value)return!0;var t=Math.floor(e.value/1.05);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")})}}),s.view.properties.controllers.number=s.view.propertyController.extend({render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupNumberField(this.field,this.args)},setupNumberField:function(i,s){s=t.extend({change:null,"default":0,increment:1,decrement:-1,max:null,min:null},s);var r=i.parent();r.addClass("socss-field-number");var n=e('<div class="socss-diw"></div>').appendTo(r),o=e('<div class="dec-button socss-button">-</div>').appendTo(n);e('<div class="inc-button socss-button">+</div>').appendTo(n);return n.find("> div").click(function(t){t.preventDefault();var r=s["default"];""!==i.val()&&(r=Number(i.val())),r+=e(this).is(o)?s.decrement:s.increment,r=Math.round(100*r)/100,null!==s.max&&(r=Math.min(s.max,r)),null!==s.min&&(r=Math.max(s.min,r)),i.val(r),i.trigger("change")}),this}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],render:function(){var i=this;this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),i.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(){for(var r=e(this).data("direction"),n=e('<li class="side">').appendTo(i.$(".sides")).hide(),o=0;o<i.args.controllers.length;o++){var a=i.args.controllers[o],l="";l="all"===r?a.args.propertyAll:a.args.property.replace("{dir}",r);var c=t.extend({},a.args,{property:l}),d=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(n),propertiesView:i.propertiesView,args:c});d.render(),d.initChangeEvents(),i.propertiesView.propertyControllers.push(d)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),n.show()})}),this.$(".select-tab").eq(0).click()}})}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socss,i=new t.view.editor({el:e("#so-custom-css-form").get(0)});i.render(),i.setSnippets(socssOptions.snippets),window.socss.mainEditor=i,e("#so-custom-css-getting-started a.hide").click(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})});
|
1 |
+
!function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(t){this.editor=t.editor;var i=this;this.$(".editor-expand").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_expand")}),this.$(".editor-visual").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_visual")})},addButton:function(t,i){var s=this,r=e(this.button({text:t})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons")).click(function(t){t.preventDefault(),e(this).blur(),s.trigger("click_"+i)});return r}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(e){this.setupEditor()},render:function(){var t=this;this.toolbar=new s.view.toolbar({editor:this,el:this.$(".custom-css-toolbar")}),this.toolbar.editor=this,this.toolbar.render(),this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render(),this.toolbar.on("click_expand",function(){t.toggleExpand()}),this.toolbar.on("click_visual",function(){t.visualProperties.loadCSS(t.codeMirror.getValue().trim()),t.visualProperties.show()}),this.preview=new s.view.preview({editor:this,el:this.$(".custom-css-preview")}),this.preview.render()},setupEditor:function(){var t=this;this.registerCodeMirrorAutocomplete();for(var s=this.$("textarea.css-editor"),r=s.val(),n=r.match(/\n/gm),o=n?n.length+1:1,a=15-o,l=r,c=0;a>c;c++)l+="\n";s.val(l),this.codeMirror=CodeMirror.fromTextArea(s.get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",inputStyle:"contenteditable",gutters:["CodeMirror-lint-markers"],lint:!0}),this.$el.on("submit",function(){r=t.codeMirror.getValue().trim()}),e(window).bind("beforeunload",function(){var e=t.codeMirror.getValue().trim();return e!==r?i.loc.leave:void 0}),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).resize(function(){t.scaleEditor()}),this.setupCodeMirrorExtensions()},registerCodeMirrorAutocomplete:function(){var e=this,t={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(i){function s(e){for(var t in e)c&&0!==t.lastIndexOf(c,0)||d.push(t)}var r=i.getCursor(),n=i.getTokenAt(r),o=CodeMirror.innerMode(i.getMode(),n.state);if("css"===o.mode.name){if("keyword"===n.type&&0==="!important".indexOf(n.string))return{list:["!important"],from:CodeMirror.Pos(r.line,n.start),to:CodeMirror.Pos(r.line,n.end)};var a=n.start,l=r.ch,c=n.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=r.ch);var p=CodeMirror.resolveMode("text/css"),d=[],h=o.state.state;if("top"===h){for(var u=i.getLine(r.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)-1!==v[f].selector.indexOf(u)&&d.push(v[f].selector);if(d.length)return{list:d,from:CodeMirror.Pos(r.line,0),to:CodeMirror.Pos(r.line,l)}}else if("pseudo"===h||"variable-3"===n.type?s(t):"block"===h||"maybeprop"===h?s(p.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(p.valueKeywords),s(p.colorKeywords)):("media"===h||"media_parens"===h)&&(s(p.mediaTypes),s(p.mediaFeatures)),d.length)return{list:d,from:CodeMirror.Pos(r.line,a),to:CodeMirror.Pos(r.line,l)}}})},setupCodeMirrorExtensions:function(){var e=this;this.codeMirror.on("cursorActivity",function(t){var i=t.getCursor(),s=t.getTokenAt(i);CodeMirror.innerMode(t.getMode(),s.state);if("qualifier"===s.type||"tag"===s.type||"builtin"===s.type){var r=t.getLine(i.line),n=r.substring(0,s.end);e.preview.highlight(n)}else e.preview.clearHighlight()}),this.codeMirror.on("keyup",function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint({completeSingle:!1})})},scaleEditor:function(){this.$el.hasClass("expanded")?this.codeMirror.setSize("100%",e(window).outerHeight()-this.$(".custom-css-toolbar").outerHeight()):this.codeMirror.setSize("100%","auto")},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},setSnippets:function(e){if(!t.isEmpty(e)){var i=this;this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){i.snippets.show()})}},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){var t=this;this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){t.visualProperties.isVisible()?t.visualProperties.addSelector(e):t.addEmptySelector(e)}),e.on("click_property",function(e){t.visualProperties.isVisible()||t.codeMirror.replaceSelection(e+";\n ")}),e.on("set_active_element",function(e,i){t.visualProperties.isVisible()&&i.length&&t.visualProperties.addSelector(i[0].selector)})}}),s.view.preview=Backbone.View.extend({template:t.template(e("#template-preview-window").html()),editor:null,originalUri:null,currentUri:null,initialize:function(e){this.editor=e.editor;var t=this;this.editor.codeMirror.on("change",function(e,i){t.updatePreviewCss()})},render:function(){var t=this;this.$el.html(this.template()),this.$("#preview-iframe").attr("src",i.homeURL).load(function(){var i=e(this);t.currentUri=new URI(i.contents().get(0).location.href),t.currentUri.removeQuery("so_css_preview"),t.$("#preview-navigator input").val(t.currentUri.toString()),t.currentUri.addQuery("so_css_preview",1),i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=-1===t.indexOf("?")?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()}),this.$("#preview-navigator input").keydown(function(i){var s=e(this);if(13==i.keyCode){i.preventDefault();var r=new URI(s.val());t.originalUri.host()!==r.host()||t.originalUri.protocol()!==r.protocol()?(s.blur(),alert(s.data("invalid-uri")),s.focus()):(r.addQuery("so_css_preview",1),t.$("#preview-iframe").attr("src",r.toString()))}}),this.originalUri=new URI(i.homeURL),this.currentUri=new URI(i.homeURL),this.currentUri.removeQuery("so_css_preview"),this.$("#preview-navigator input").val(this.currentUri.toString()),this.currentUri.addQuery("so_css_preview",1)},updatePreviewCss:function(){var e=this.$("#preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue().trim();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(t){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){var t=this,i=function(i){i.preventDefault();var s=e(this);t.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),t.viewSnippet({name:s.html(),description:s.data("description"),css:s.data("css")})};this.$el.html(this.template());for(var s=0;s<this.snippets.length;s++)e(this.snippet({name:this.snippets[s].Name})).data({description:this.snippets[s].Description,css:this.snippets[s].css}).appendTo(this.$("ul.snippets")).click(i);return t.$(".snippets li.snippet").eq(0).click(),this.attach(),this},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({model:s.model.cssRules,tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide"},initialize:function(e){this.parser=window.css,this.editor=e.editor},render:function(){var r=this;this.$(".section-tabs").empty(),this.$(".sections").empty(),this.$(".toolbar select").off(),r.propertyControllers=[];var n=i.propertyControllers;for(var o in n){var a=(e(this.tabTemplate({id:o,icon:n[o].icon,title:n[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(n[o].controllers))for(var l=0;l<n[o].controllers.length;l++){var c,p=e(r.controllerTemplate({title:n[o].controllers[l].title})).appendTo(a.find("tbody")),d=n[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[d.type]?new s.view.propertyController({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}):new s.view.properties.controllers[d.type]({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}),r.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=r.$('.sections .section[data-section="'+t.data("section")+'"]');r.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),r.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){r.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,i){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.declarations){for(var s=this.activeSelector.declarations,r=!0,n=!1,o=0;o<s.length;o++)if(s[o].property===e){r=!1;var a=s[o];a.value!==i&&(a.value=i,n=!0),t.isEmpty(a.value)&&s.splice(s.indexOf(a));break}r&&!t.isEmpty(i)&&(s.push({property:e,value:i,type:"declaration"}),n=!0),n&&this.updateMainEditor(!1)}},addImport:function(e){var i=t.filter(this.parsed.stylesheet.rules,function(e){return"import"===e.type}),s=t.any(i,function(t){return t["import"]===e["import"]});s||(this.parsed.stylesheet.rules.unshift(e),this.updateMainEditor(!1))},findImport:function(e){return t.find(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t["import"].indexOf(e)>-1})},updateImport:function(e,t){var i=this.findImport(e);i["import"]!==t["import"]&&(i["import"]=t["import"],this.updateMainEditor(!1))},removeImport:function(e){var i=t.findIndex(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t["import"].indexOf(e)>-1});i>-1&&this.parsed.stylesheet.rules.splice(i,1)},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.declarations)return"";for(var t=this.activeSelector.declarations,i=0;i<t.length;i++)if(t[i].property===e)return t[i].value;return""},updateMainEditor:function(e){this.editor.codeMirror.setValue(this.parser.stringify(this.parsed))},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",function(){e(this).hide()}),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(i,s){this.css=i,this.parsed=this.parser.parse(i,{silent:!0});for(var r=this.parsed.stylesheet.rules,n=this.$(".toolbar select").empty(),o=0;o<r.length;o++){var a=r[o];if(t.contains(["rule","media"],a.type))if("media"===a.type)for(var l=0;l<a.rules.length;l++){var c="@media "+a.media,p=a.rules[l];n.append(e("<option>").html(c+": "+p.selectors.join(",")).attr("val",c+": "+p.selectors.join(",")).data("selector",p))}else n.append(e("<option>").html(a.selectors.join(",")).attr("val",a.selectors.join(",")).data("selector",a))}"undefined"==typeof s&&(s=n.find("option").eq(0).attr("val")),t.isEmpty(s)||n.val(s).change()},setActivateSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue().trim(),e)),t.addClass("highlighted"),setTimeout(function(){t.removeClass("highlighted")},2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input")},initChangeEvents:function(){var t=this;this.field.on("change keyup",function(){t.trigger("change",e(this).val())})},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({template:t.template('<input type="text" value="" />'),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),this.field.minicolors({})},initChangeEvents:function(){var e=this;this.field.on("change keyup",function(){e.trigger("change",e.field.minicolors("value"))})},getValue:function(){return this.field.minicolors("value").trim()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template("<select></select>"),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("select"),this.field.append(e('<option value=""></option>').html(""));for(var t in this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));"undefined"!=typeof this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){var t=this;this.field.hide();var i=e('<div class="select-tabs"></div>').appendTo(this.$el);e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(i);for(var s in this.args.option_icons)e('<div class="select-tab"></div>').appendTo(i).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[s])).attr("data-value",s);i.find(".select-tab").css("width",100/i.find(">div").length+"%").click(function(){var s=e(this);i.find(".select-tab").removeClass("active"),s.addClass("active"),t.field.val(s.data("value")).change()})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var t=this;this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.$(".select").click(function(){t.media.open()}),this.media.on("select",function(){var e=this.state().get("selection").first().attributes,i=t.args.value.replace("{{url}}",e.url);t.field.val(i).change(),t.media.close()},this.media)}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupMeasurementField(this.field,{})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},i=this.units.map(t),s=new RegExp("([0-9\\.\\-]+)("+i.join("|")+")?","i"),r=s.exec(e);return null===r?{value:"",unit:""}:{value:r[1],unit:void 0===r[2]?"":r[2]}},setupMeasurementField:function(i,s){var r=this,n=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),n.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(n),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(n),l=e('<ul class="dropdown"></ul>').appendTo(n),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(n),p=0;p<r.units.length;p++){var d=e("<li></li>").html(r.units[p]).data("unit",r.units[p]);r.units[p]===s.defaultUnit&&d.addClass("active"),l.append(d)}var h=function(){var e=r.parseUnits(o.val());""!==e.unit&&e.unit!==n.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+n.data("unit"))},u=function(e){c.html(e),n.data("unit",e),o.trigger("keydown")};a.click(function(){l.toggle()}),l.find("li").click(function(){l.toggle(),u(e(this).data("unit")),h(),i.trigger("change")}),o.on("keyup keydown",function(t){var i=(e(this),"");"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?i=String.fromCharCode(t.keyCode):189===t.keyCode?i="-":190===t.keyCode&&(i="."));var s=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(o.val()+i).appendTo("body"),r=s.width();r=Math.min(r,63),s.remove(),c.css("left",r+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=r.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;n.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),p=l.width();p=Math.min(p,63),l.remove(),c.css("left",p+12)});var v=e('<div class="socss-diw"></div>').appendTo(n),f=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(v),m=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(v);m.click(function(){var e=r.parseUnits(i.val());if(""===e.value)return!0;var t=Math.ceil(1.05*e.value);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")}),f.click(function(){var e=r.parseUnits(i.val());if(""===e.value)return!0;var t=Math.floor(e.value/1.05);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")})}}),s.view.properties.controllers.number=s.view.propertyController.extend({render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupNumberField(this.field,this.args)},setupNumberField:function(i,s){s=t.extend({change:null,"default":0,increment:1,decrement:-1,max:null,min:null},s);var r=i.parent();r.addClass("socss-field-number");var n=e('<div class="socss-diw"></div>').appendTo(r),o=e('<div class="dec-button socss-button">-</div>').appendTo(n);e('<div class="inc-button socss-button">+</div>').appendTo(n);return n.find("> div").click(function(t){t.preventDefault();var r=s["default"];""!==i.val()&&(r=Number(i.val())),r+=e(this).is(o)?s.decrement:s.increment,r=Math.round(100*r)/100,null!==s.max&&(r=Math.min(s.max,r)),null!==s.min&&(r=Math.max(s.min,r)),i.val(r),i.trigger("change")}),this}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],render:function(){var i=this;this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),i.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(){for(var r=e(this).data("direction"),n=e('<li class="side">').appendTo(i.$(".sides")).hide(),o=0;o<i.args.controllers.length;o++){var a=i.args.controllers[o],l="";l="all"===r?a.args.propertyAll:a.args.property.replace("{dir}",r);var c=t.extend({},a.args,{property:l}),p=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(n),propertiesView:i.propertiesView,args:c});p.render(),p.initChangeEvents(),i.propertiesView.propertyControllers.push(p)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),n.show()})}),this.$(".select-tab").eq(0).click()}})}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socss,i=new t.view.editor({el:e("#so-custom-css-form").get(0)});i.render(),i.setSnippets(socssOptions.snippets),window.socss.mainEditor=i,e("#so-custom-css-getting-started a.hide").click(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})});
|
js/inspector.js
CHANGED
@@ -182,9 +182,9 @@
|
|
182 |
|
183 |
var container = this.$('.socss-selectors-window').empty();
|
184 |
|
185 |
-
_.each( selectors, function(selector){
|
186 |
container.append(
|
187 |
-
$( thisView.selectorTemplate(selector) )
|
188 |
.data( selector )
|
189 |
);
|
190 |
} );
|
@@ -307,10 +307,10 @@
|
|
307 |
socss.fn.getParsedCss = function(){
|
308 |
// Load all the parsed CSS
|
309 |
if( Object.keys(socss.parsedCss).length === 0 ) {
|
310 |
-
var parser =
|
311 |
$('.socss-theme-styles').each(function(){
|
312 |
var $$ = $(this);
|
313 |
-
var p = parser.
|
314 |
socss.parsedCss[ $$.attr('id') ] = p;
|
315 |
});
|
316 |
}
|
@@ -325,12 +325,15 @@
|
|
325 |
var parsedCss = socss.fn.getParsedCss();
|
326 |
|
327 |
for( var k in parsedCss ) {
|
328 |
-
|
329 |
-
|
|
|
330 |
continue;
|
331 |
}
|
332 |
-
|
333 |
-
|
|
|
|
|
334 |
}
|
335 |
}
|
336 |
|
@@ -376,34 +379,56 @@
|
|
376 |
return e.split(':').map( trimFunc );
|
377 |
};
|
378 |
|
379 |
-
|
380 |
var parsedCss = socss.fn.getParsedCss();
|
381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
for( var k in parsedCss ) {
|
383 |
-
|
|
|
|
|
384 |
if (
|
385 |
-
typeof
|
386 |
-
typeof parsedCss[k][i].type !== 'undefined' ||
|
387 |
-
parsedCss[k][i].selector[0] === '@'
|
388 |
) {
|
389 |
continue;
|
390 |
}
|
391 |
-
|
392 |
-
var
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
|
|
|
|
|
|
402 |
}
|
403 |
}
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
}
|
408 |
}
|
409 |
|
182 |
|
183 |
var container = this.$('.socss-selectors-window').empty();
|
184 |
|
185 |
+
_.each( selectors, function( selector ){
|
186 |
container.append(
|
187 |
+
$( thisView.selectorTemplate( selector ) )
|
188 |
.data( selector )
|
189 |
);
|
190 |
} );
|
307 |
socss.fn.getParsedCss = function(){
|
308 |
// Load all the parsed CSS
|
309 |
if( Object.keys(socss.parsedCss).length === 0 ) {
|
310 |
+
var parser = window.css;
|
311 |
$('.socss-theme-styles').each(function(){
|
312 |
var $$ = $(this);
|
313 |
+
var p = parser.parse( $$.html() );
|
314 |
socss.parsedCss[ $$.attr('id') ] = p;
|
315 |
});
|
316 |
}
|
325 |
var parsedCss = socss.fn.getParsedCss();
|
326 |
|
327 |
for( var k in parsedCss ) {
|
328 |
+
var rules = parsedCss[k].stylesheet.rules;
|
329 |
+
for( var i = 0; i < rules.length; i++ ) {
|
330 |
+
if (typeof rules[i].selectors === 'undefined') {
|
331 |
continue;
|
332 |
}
|
333 |
+
|
334 |
+
for(var j = 0; j < rules[i].selectors.length; j++) {
|
335 |
+
selectors = selectors.concat( getSelectorSpecificity( rules[i].selectors[j] ) );
|
336 |
+
}
|
337 |
}
|
338 |
}
|
339 |
|
379 |
return e.split(':').map( trimFunc );
|
380 |
};
|
381 |
|
|
|
382 |
var parsedCss = socss.fn.getParsedCss();
|
383 |
|
384 |
+
var isAtRule = function (ruleType) {
|
385 |
+
switch(ruleType) {
|
386 |
+
case 'charset':
|
387 |
+
case 'custom-media':
|
388 |
+
case 'document':
|
389 |
+
case 'font-face':
|
390 |
+
case 'host':
|
391 |
+
case 'import':
|
392 |
+
case 'keyframes':
|
393 |
+
case 'keyframe':
|
394 |
+
case 'media':
|
395 |
+
case 'namespace':
|
396 |
+
case 'page':
|
397 |
+
case 'supports':
|
398 |
+
return true;
|
399 |
+
|
400 |
+
}
|
401 |
+
return false;
|
402 |
+
};
|
403 |
+
|
404 |
for( var k in parsedCss ) {
|
405 |
+
var rules = parsedCss[k].stylesheet.rules;
|
406 |
+
for( var i = 0; i < rules.length; i++ ) {
|
407 |
+
var rule = rules[i];
|
408 |
if (
|
409 |
+
typeof rule.selectors === 'undefined' || isAtRule(rule.type)
|
|
|
|
|
410 |
) {
|
411 |
continue;
|
412 |
}
|
413 |
+
|
414 |
+
for(var j = 0; j < rule.selectors.length; j++) {
|
415 |
+
var ruleSpecificity = SPECIFICITY.calculate( rule.selectors[j] );
|
416 |
+
for (var l = 0; l < ruleSpecificity.length; l++) {
|
417 |
+
try {
|
418 |
+
if ( el.is( ruleSpecificity[l].selector ) ) {
|
419 |
+
var declarations = rule.declarations;
|
420 |
+
for (var l = 0; l < declarations.length; l++) {
|
421 |
+
elProperties.push({
|
422 |
+
'name': declarations[l].property,
|
423 |
+
'value': declarations[l].value,
|
424 |
+
'specificity': parseInt( ruleSpecificity[l].specificity.replace( /,/g, '' ) )
|
425 |
+
});
|
426 |
+
}
|
427 |
}
|
428 |
}
|
429 |
+
catch (e) {
|
430 |
+
// For now, we're just going to ignore rules that trigger errors
|
431 |
+
}
|
432 |
}
|
433 |
}
|
434 |
|
js/inspector.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t,s){var i={model:{},collection:{},view:{},fn:{}},r=function(e,t){for(var s=[],i=SPECIFICITY.calculate(e),o=0;o<i.length;o++){var c=i[o];if(t)for(var
|
1 |
+
!function(e,t,s){var i={model:{},collection:{},view:{},fn:{}},r=function(e,t){for(var s=[],i=SPECIFICITY.calculate(e),o=0;o<i.length;o++){var c=i[o];if(t)for(var a=0;a<c.parts.length;a++){var n=c.parts[a];s=s.concat(r(n.selector))}else s.push({selector:c.selector.trim(),specificity:parseInt(c.specificity.replace(/,/g,""))})}return s};i.view.inspector=Backbone.View.extend({active:!1,hl:!1,hoverEl:!1,pageSelectors:[],selectorTemplate:t.template('<div class="socss-selector"><%= selector %></div>'),initialize:function(){var t=this;this.hl=new i.view.highlighter,this.hl.initialize(),this.pageSelectors=i.fn.pageSelectors(),e("body").on("mouseover","*",function(s){if(!t.active)return!0;var i=e(this);0===i.closest(".socss-element").length&&(s.stopPropagation(),t.setHoverEl(e(this)))}),e("body *").click(function(s){if(!t.active||t.$el.is(":hover"))return!0;s.preventDefault(),s.stopPropagation();var i=e(this);i.blur(),t.setActiveEl(t.hoverEl)}),this.$(".socss-enable-inspector").click(function(){t.toggleActive()}),this.$el.mouseenter(function(){t.hl.clear()});try{parent.socss.mainEditor.setInspector(this)}catch(s){console.log("No editor to register this inspector with")}},setHoverEl:function(e){this.hoverEl=e,this.hl.highlight(e)},activate:function(){this.active=!0,e("body").addClass("socss-active"),e("body").removeClass("socss-inactive")},deactivate:function(){this.active=!1,e("body").addClass("socss-inactive"),e("body").removeClass("socss-active"),this.hl.clear(),this.$(".socss-hierarchy").empty()},toggleActive:function(){this.active?this.deactivate():this.activate()},setActiveEl:function(s){var r=this,o=this.$(".socss-hierarchy");if(o.empty(),"body"!==s.prop("tagName").toLowerCase()){var c=e(s);do e(this.selectorTemplate({selector:i.fn.elSelector(c)})).prependTo(o).data("el",c),c=c.parent();while("body"!==c.prop("tagName").toLowerCase());e(this.selectorTemplate({selector:"body"})).prependTo(o).data("el",e("body")),this.$(".socss-hierarchy .socss-selector").hover(function(){r.hl.highlight(e(this).data("el"))}).click(function(t){t.preventDefault(),t.stopPropagation(),r.setActiveEl(e(this).data("el"))})}o.scrollLeft(99999);var a=this.pageSelectors.filter(function(e){try{return s.is(e.selector)}catch(t){return!1}}),n=this.$(".socss-selectors-window").empty();t.each(a,function(t){n.append(e(r.selectorTemplate(t)).data(t))}),n.find("> div").mouseenter(function(){r.hl.highlight(e(this).data("selector"))}).click(function(t){t.preventDefault(),t.stopPropagation(),r.trigger("click_selector",e(this).data("selector"))});var l=i.fn.elementAttributes(s);n=this.$(".socss-properties-window").empty(),t.each(l,function(t,s){n.append(e(r.selectorTemplate({selector:"<strong>"+s+"</strong>: "+t})).data("property",s+": "+t))}),n.find("> div").click(function(t){t.preventDefault(),t.stopPropagation(),r.trigger("click_property",e(this).data("property"))});var h=s.closest("a[href]"),p=this.$(".socss-link");h.length?p.show().find("a").html(h.attr("href").replace(/[\?&]*so_css_preview=1/,"")).attr("href",h.attr("href")):p.hide(),this.trigger("set_active_element",s,a)}}),i.view.highlighter=Backbone.View.extend({template:t.template(e("#socss-template-hover").html().trim()),highlighted:[],highlight:function(t){this.clear();var s=this;e(t).each(function(t,i){if(i=e(i),!i.is(":visible"))return!0;var r=e(s.template());r.css({top:i.offset().top,left:i.offset().left,width:i.outerWidth(),height:i.outerHeight()}).appendTo("body");var o,c=i.padding();for(var a in c)parseInt(c[a])>0&&(o=r.find(".socss-guide-padding.socss-guide-"+a).show(),"top"===a||"bottom"===a?o.css("height",c[a]):(o.css("width",c[a]),o.css({width:c[a],top:c.top,bottom:c.bottom})));var n=i.margin();for(var a in n)parseInt(n[a])>0&&(o=r.find(".socss-guide-margin.socss-guide-"+a).show(),"top"===a||"bottom"===a?o.css("height",n[a]):o.css("width",n[a]));s.highlighted.push(r)})},clear:function(){for(;this.highlighted.length;)this.highlighted.pop().remove()}}),i.parsedCss={},i.fn.getParsedCss=function(){if(0===Object.keys(i.parsedCss).length){var t=window.css;e(".socss-theme-styles").each(function(){var s=e(this),r=t.parse(s.html());i.parsedCss[s.attr("id")]=r})}return i.parsedCss},i.fn.pageSelectors=function(){var s=[],o=i.fn.getParsedCss();for(var c in o)for(var a=o[c].stylesheet.rules,n=0;n<a.length;n++)if("undefined"!=typeof a[n].selectors)for(var l=0;l<a[n].selectors.length;l++)s=s.concat(r(a[n].selectors[l]));e("body *").each(function(){var t=e(this),o=i.fn.elSelector(t);s=s.concat(r(o))});var h=e("body"),p=i.fn.elSelector(h);return s=s.concat(r(p,!0)),s=t.uniq(s,!1,function(e){return e.selector}),s.sort(function(e,t){return e.specificity>t.specificity?-1:1}),s},i.fn.elementAttributes=function(e){if(!document.styleSheets)return[];var t=[],s=i.fn.getParsedCss(),r=function(e){switch(e){case"charset":case"custom-media":case"document":case"font-face":case"host":case"import":case"keyframes":case"keyframe":case"media":case"namespace":case"page":case"supports":return!0}return!1};for(var o in s)for(var c=s[o].stylesheet.rules,a=0;a<c.length;a++){var n=c[a];if("undefined"!=typeof n.selectors&&!r(n.type))for(var l=0;l<n.selectors.length;l++)for(var h=SPECIFICITY.calculate(n.selectors[l]),p=0;p<h.length;p++)try{if(e.is(h[p].selector))for(var f=n.declarations,p=0;p<f.length;p++)t.push({name:f[p].property,value:f[p].value,specificity:parseInt(h[p].specificity.replace(/,/g,""))})}catch(d){}}t.sort(function(e,t){return e.specificity>t.specificity?1:-1}).reverse();for(var v={},u=0;u<t.length;u++)"undefined"==typeof v[t[u].name]&&(v[t[u].name]=t[u].value);return v},i.fn.elSelector=function(e){var t="";return void 0!==e.attr("id")&&(t+="#"+e.attr("id")),void 0!==e.attr("class")&&(t+="."+e.attr("class").replace(/\s+/g,".")),""===t&&(t=e.prop("tagName").toLowerCase()),t},window.socssInspector=i}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socssInspector,s=new t.view.inspector({el:e("#socss-inspector-interface").get(0)});s.activate(),window.socssInspector.mainInspector=s});
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
Tested up to: 4.6
|
5 |
-
Stable tag: 1.
|
6 |
-
Build time:
|
7 |
License: GPLv2 or later
|
8 |
Contributors: gpriday
|
9 |
|
@@ -62,6 +62,12 @@ We offer free support on the [SiteOrigin support forums](https://siteorigin.com/
|
|
62 |
|
63 |
== Changelog ==
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
= 1.0.8 - 15 August 2016 =
|
66 |
* Fixed action link.
|
67 |
* Support for GlotPress.
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
Tested up to: 4.6
|
5 |
+
Stable tag: 1.1
|
6 |
+
Build time: 2016-09-26T12:54:24+02:00
|
7 |
License: GPLv2 or later
|
8 |
Contributors: gpriday
|
9 |
|
62 |
|
63 |
== Changelog ==
|
64 |
|
65 |
+
= 1.1 - 26 September 2016 =
|
66 |
+
* Changed CSS parsing library. Fixed several issues with the visual editor mode.
|
67 |
+
* Added address bar to preview window.
|
68 |
+
* Small CSS fixes.
|
69 |
+
* Small changes to allow adding more visual editor fields.
|
70 |
+
|
71 |
= 1.0.8 - 15 August 2016 =
|
72 |
* Fixed action link.
|
73 |
* Support for GlotPress.
|
so-css.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin CSS
|
4 |
Description: An advanced CSS editor from SiteOrigin.
|
5 |
-
Version: 1.
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
@@ -14,7 +14,7 @@ Text Domain: so-css
|
|
14 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
15 |
include plugin_dir_path(__FILE__) . '/inc/legacy.php';
|
16 |
|
17 |
-
define('SOCSS_VERSION', '1.
|
18 |
define('SOCSS_JS_SUFFIX', '.min');
|
19 |
|
20 |
/**
|
@@ -170,7 +170,7 @@ class SiteOrigin_CSS {
|
|
170 |
wp_enqueue_style( 'codemirror-show-hint', plugin_dir_url(__FILE__) . 'lib/codemirror/addon/hint/show-hint.css', array( ), '5.2.0' );
|
171 |
|
172 |
// Enqueue the scripts for theme CSS processing
|
173 |
-
wp_enqueue_script( 'siteorigin-
|
174 |
|
175 |
// There are conflicts between CSS linting and the built in WordPress color picker, so use something else
|
176 |
wp_enqueue_style('siteorigin-custom-css-minicolors', plugin_dir_url(__FILE__) . 'lib/minicolors/jquery.minicolors.css', array(), '2.1.7' );
|
@@ -179,8 +179,11 @@ class SiteOrigin_CSS {
|
|
179 |
// We need Font Awesome
|
180 |
wp_enqueue_style( 'siteorigin-custom-css-font-awesome', plugin_dir_url(__FILE__) . 'lib/fontawesome/css/font-awesome.min.css', array( ), SOCSS_VERSION );
|
181 |
|
|
|
|
|
|
|
182 |
// All the custom SiteOrigin CSS stuff
|
183 |
-
wp_enqueue_script( 'siteorigin-custom-css', plugin_dir_url(__FILE__) . 'js/editor' . SOCSS_JS_SUFFIX . '.js', array( 'jquery', 'underscore', 'backbone', 'siteorigin-
|
184 |
wp_enqueue_style( 'siteorigin-custom-css', plugin_dir_url(__FILE__) . 'css/admin.css', array( ), SOCSS_VERSION );
|
185 |
|
186 |
wp_localize_script( 'siteorigin-custom-css', 'socssOptions', array(
|
@@ -249,6 +252,12 @@ class SiteOrigin_CSS {
|
|
249 |
include plugin_dir_path(__FILE__).'/tpl/page.php';
|
250 |
}
|
251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
/**
|
253 |
*
|
254 |
*/
|
@@ -371,7 +380,7 @@ class SiteOrigin_CSS {
|
|
371 |
|
372 |
wp_enqueue_style( 'dashicons' );
|
373 |
|
374 |
-
wp_enqueue_script( 'siteorigin-
|
375 |
|
376 |
wp_enqueue_script('siteorigin-css-sizes', plugin_dir_url(__FILE__) . 'js/jquery.sizes' . SOCSS_JS_SUFFIX . '.js', array( 'jquery' ), '0.33' );
|
377 |
wp_enqueue_script('siteorigin-css-specificity', plugin_dir_url(__FILE__) . 'js/specificity' . SOCSS_JS_SUFFIX . '.js', array( ) );
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin CSS
|
4 |
Description: An advanced CSS editor from SiteOrigin.
|
5 |
+
Version: 1.1
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
14 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
15 |
include plugin_dir_path(__FILE__) . '/inc/legacy.php';
|
16 |
|
17 |
+
define('SOCSS_VERSION', '1.1');
|
18 |
define('SOCSS_JS_SUFFIX', '.min');
|
19 |
|
20 |
/**
|
170 |
wp_enqueue_style( 'codemirror-show-hint', plugin_dir_url(__FILE__) . 'lib/codemirror/addon/hint/show-hint.css', array( ), '5.2.0' );
|
171 |
|
172 |
// Enqueue the scripts for theme CSS processing
|
173 |
+
wp_enqueue_script( 'siteorigin-css-parser-lib', plugin_dir_url(__FILE__) . 'js/css' . SOCSS_JS_SUFFIX . '.js', array( 'jquery' ), SOCSS_VERSION );
|
174 |
|
175 |
// There are conflicts between CSS linting and the built in WordPress color picker, so use something else
|
176 |
wp_enqueue_style('siteorigin-custom-css-minicolors', plugin_dir_url(__FILE__) . 'lib/minicolors/jquery.minicolors.css', array(), '2.1.7' );
|
179 |
// We need Font Awesome
|
180 |
wp_enqueue_style( 'siteorigin-custom-css-font-awesome', plugin_dir_url(__FILE__) . 'lib/fontawesome/css/font-awesome.min.css', array( ), SOCSS_VERSION );
|
181 |
|
182 |
+
// URI parsing for preview navigation
|
183 |
+
wp_enqueue_script( 'siteorigin-uri', plugin_dir_url(__FILE__) . 'js/URI' . SOCSS_JS_SUFFIX . '.js', array( ), SOCSS_VERSION, true );
|
184 |
+
|
185 |
// All the custom SiteOrigin CSS stuff
|
186 |
+
wp_enqueue_script( 'siteorigin-custom-css', plugin_dir_url(__FILE__) . 'js/editor' . SOCSS_JS_SUFFIX . '.js', array( 'jquery', 'underscore', 'backbone', 'siteorigin-css-parser-lib', 'codemirror' ), SOCSS_VERSION, true );
|
187 |
wp_enqueue_style( 'siteorigin-custom-css', plugin_dir_url(__FILE__) . 'css/admin.css', array( ), SOCSS_VERSION );
|
188 |
|
189 |
wp_localize_script( 'siteorigin-custom-css', 'socssOptions', array(
|
252 |
include plugin_dir_path(__FILE__).'/tpl/page.php';
|
253 |
}
|
254 |
|
255 |
+
|
256 |
+
function display_teaser(){
|
257 |
+
return apply_filters( 'siteorigin_premium_upgrade_teaser', true ) &&
|
258 |
+
! defined( 'SITEORIGIN_PREMIUM_VERSION' );
|
259 |
+
}
|
260 |
+
|
261 |
/**
|
262 |
*
|
263 |
*/
|
380 |
|
381 |
wp_enqueue_style( 'dashicons' );
|
382 |
|
383 |
+
wp_enqueue_script( 'siteorigin-css-parser-lib', plugin_dir_url(__FILE__) . 'js/css' . SOCSS_JS_SUFFIX . '.js', array( 'jquery' ), SOCSS_VERSION );
|
384 |
|
385 |
wp_enqueue_script('siteorigin-css-sizes', plugin_dir_url(__FILE__) . 'js/jquery.sizes' . SOCSS_JS_SUFFIX . '.js', array( 'jquery' ), '0.33' );
|
386 |
wp_enqueue_script('siteorigin-css-specificity', plugin_dir_url(__FILE__) . 'js/specificity' . SOCSS_JS_SUFFIX . '.js', array( ) );
|
tpl/js-templates.php
CHANGED
@@ -44,4 +44,11 @@
|
|
44 |
</ul>
|
45 |
|
46 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
</script>
|
44 |
</ul>
|
45 |
|
46 |
</div>
|
47 |
+
</script>
|
48 |
+
|
49 |
+
<script type="text/template" id="template-preview-window">
|
50 |
+
<div id="preview-navigator">
|
51 |
+
<input type="text" data-invalid-uri="<?php esc_attr_e( "Invalid URI. Please make sure you're using a URL from the same site.", 'so-css' ) ?>" />
|
52 |
+
</div>
|
53 |
+
<iframe id="preview-iframe" seamless="seamless"></iframe>
|
54 |
</script>
|
tpl/page.php
CHANGED
@@ -2,7 +2,10 @@
|
|
2 |
/**
|
3 |
* @var $custom_css_revisions array Saved revisions for the current theme.
|
4 |
*/
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
<div class="wrap" id="siteorigin-custom-css">
|
8 |
<h2>
|
@@ -21,14 +24,10 @@ $snippets = SiteOrigin_CSS::single()->get_snippets(); ?>
|
|
21 |
</div>
|
22 |
<?php endif; ?>
|
23 |
|
24 |
-
|
25 |
<div id="poststuff">
|
26 |
<div id="so-custom-css-info">
|
27 |
|
28 |
-
<?php
|
29 |
-
$user = wp_get_current_user();
|
30 |
-
if( !get_user_meta( $user->ID, 'socss_hide_gs' ) ) {
|
31 |
-
?>
|
32 |
<div class="postbox" id="so-custom-css-getting-started">
|
33 |
<h3 class="hndle">
|
34 |
<span><?php _e('Getting Started Video', 'so-css') ?></span>
|
@@ -38,9 +37,7 @@ $snippets = SiteOrigin_CSS::single()->get_snippets(); ?>
|
|
38 |
<a href="https://siteorigin.com/css/getting-started/" target="_blank"><img src="<?php echo plugin_dir_url(__FILE__).'../css/images/video.jpg' ?>" /></a>
|
39 |
</div>
|
40 |
</div>
|
41 |
-
|
42 |
-
}
|
43 |
-
?>
|
44 |
|
45 |
<div class="postbox" id="so-custom-css-revisions">
|
46 |
<h3 class="hndle"><span><?php _e('CSS Revisions', 'so-css') ?></span></h3>
|
2 |
/**
|
3 |
* @var $custom_css_revisions array Saved revisions for the current theme.
|
4 |
*/
|
5 |
+
|
6 |
+
$snippets = SiteOrigin_CSS::single()->get_snippets();
|
7 |
+
$user = wp_get_current_user();
|
8 |
+
?>
|
9 |
|
10 |
<div class="wrap" id="siteorigin-custom-css">
|
11 |
<h2>
|
24 |
</div>
|
25 |
<?php endif; ?>
|
26 |
|
|
|
27 |
<div id="poststuff">
|
28 |
<div id="so-custom-css-info">
|
29 |
|
30 |
+
<?php if( !get_user_meta( $user->ID, 'socss_hide_gs' ) ) : ?>
|
|
|
|
|
|
|
31 |
<div class="postbox" id="so-custom-css-getting-started">
|
32 |
<h3 class="hndle">
|
33 |
<span><?php _e('Getting Started Video', 'so-css') ?></span>
|
37 |
<a href="https://siteorigin.com/css/getting-started/" target="_blank"><img src="<?php echo plugin_dir_url(__FILE__).'../css/images/video.jpg' ?>" /></a>
|
38 |
</div>
|
39 |
</div>
|
40 |
+
<?php endif; ?>
|
|
|
|
|
41 |
|
42 |
<div class="postbox" id="so-custom-css-revisions">
|
43 |
<h3 class="hndle"><span><?php _e('CSS Revisions', 'so-css') ?></span></h3>
|