Version Description
- Initial release.
Download this release
Release Info
Developer | gpriday |
Plugin | SiteOrigin CSS |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- .gitmodules +0 -0
- LICENSE +340 -0
- css/admin.css +608 -0
- css/admin.less +754 -0
- css/images/icon.png +0 -0
- css/images/separator.png +0 -0
- css/images/video.jpg +0 -0
- css/inspector.css +199 -0
- css/inspector.less +236 -0
- css/mixins.css +0 -0
- css/mixins.less +189 -0
- inc/controller-config.php +504 -0
- js/css.js +698 -0
- js/css.min.js +79 -0
- js/csslint.js +9259 -0
- js/csslint.min.js +277 -0
- js/editor.js +1527 -0
- js/editor.min.js +63 -0
- js/inspector.js +432 -0
- js/inspector.min.js +24 -0
- js/jquery.sizes.js +76 -0
- js/jquery.sizes.min.js +8 -0
- js/specificity.js +141 -0
- js/specificity.min.js +3 -0
- lib/codemirror/LICENSE +19 -0
- lib/codemirror/addon/fold/brace-fold.js +105 -0
- lib/codemirror/addon/fold/brace-fold.min.js +15 -0
- lib/codemirror/addon/fold/comment-fold.js +57 -0
- lib/codemirror/addon/fold/comment-fold.min.js +10 -0
- lib/codemirror/addon/fold/foldcode.js +149 -0
- lib/codemirror/addon/fold/foldcode.min.js +18 -0
- lib/codemirror/addon/fold/foldgutter.css +20 -0
- lib/codemirror/addon/fold/foldgutter.js +146 -0
- lib/codemirror/addon/fold/foldgutter.min.js +20 -0
- lib/codemirror/addon/fold/indent-fold.js +44 -0
- lib/codemirror/addon/fold/indent-fold.min.js +6 -0
- lib/codemirror/addon/fold/markdown-fold.js +49 -0
- lib/codemirror/addon/fold/markdown-fold.min.js +8 -0
- lib/codemirror/addon/fold/xml-fold.js +182 -0
- lib/codemirror/addon/fold/xml-fold.min.js +27 -0
- lib/codemirror/addon/hint/anyword-hint.js +41 -0
- lib/codemirror/addon/hint/anyword-hint.min.js +6 -0
- lib/codemirror/addon/hint/css-hint.js +60 -0
- lib/codemirror/addon/hint/css-hint.min.js +11 -0
- lib/codemirror/addon/hint/html-hint.js +348 -0
- lib/codemirror/addon/hint/html-hint.min.js +9 -0
- lib/codemirror/addon/hint/javascript-hint.js +146 -0
- lib/codemirror/addon/hint/javascript-hint.min.js +26 -0
- lib/codemirror/addon/hint/show-hint.css +38 -0
- lib/codemirror/addon/hint/show-hint.js +392 -0
- lib/codemirror/addon/hint/show-hint.min.js +35 -0
- lib/codemirror/addon/hint/sql-hint.js +245 -0
- lib/codemirror/addon/hint/sql-hint.min.js +38 -0
- lib/codemirror/addon/hint/xml-hint.js +110 -0
- lib/codemirror/addon/hint/xml-hint.min.js +22 -0
- lib/codemirror/addon/lint/coffeescript-lint.js +41 -0
- lib/codemirror/addon/lint/coffeescript-lint.min.js +6 -0
- lib/codemirror/addon/lint/css-lint.js +43 -0
- lib/codemirror/addon/lint/css-lint.min.js +6 -0
- lib/codemirror/addon/lint/javascript-lint.js +136 -0
- lib/codemirror/addon/lint/javascript-lint.min.js +15 -0
- lib/codemirror/addon/lint/json-lint.js +31 -0
- lib/codemirror/addon/lint/json-lint.min.js +7 -0
- lib/codemirror/addon/lint/lint.css +73 -0
- lib/codemirror/addon/lint/lint.js +207 -0
- lib/codemirror/addon/lint/lint.min.js +34 -0
- lib/codemirror/addon/lint/yaml-lint.js +28 -0
- lib/codemirror/addon/lint/yaml-lint.min.js +7 -0
- lib/codemirror/addon/merge/merge.css +112 -0
- lib/codemirror/addon/merge/merge.js +775 -0
- lib/codemirror/addon/merge/merge.min.js +109 -0
- lib/codemirror/lib/codemirror.css +325 -0
- lib/codemirror/lib/codemirror.js +3981 -0
.gitmodules
ADDED
File without changes
|
LICENSE
ADDED
@@ -0,0 +1,340 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
{description}
|
294 |
+
Copyright (C) {year} {fullname}
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
{signature of Ty Coon}, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License.
|
340 |
+
|
css/admin.css
ADDED
@@ -0,0 +1,608 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
#siteorigin-custom-css {
|
2 |
+
margin: 0 0 0 -20px;
|
3 |
+
}
|
4 |
+
#siteorigin-custom-css h2 {
|
5 |
+
background: #f8f8f8;
|
6 |
+
padding: 20px;
|
7 |
+
border-bottom: 1px solid #d0d0d0;
|
8 |
+
margin-bottom: 20px;
|
9 |
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.035);
|
10 |
+
}
|
11 |
+
#siteorigin-custom-css h2 .icon {
|
12 |
+
width: 40px;
|
13 |
+
height: auto;
|
14 |
+
margin: -8px 10px -8px 0;
|
15 |
+
}
|
16 |
+
#siteorigin-custom-css .updated {
|
17 |
+
margin: 0 20px 20px 20px ;
|
18 |
+
}
|
19 |
+
#siteorigin-custom-css #poststuff {
|
20 |
+
padding: 0 20px;
|
21 |
+
}
|
22 |
+
#siteorigin-custom-css #poststuff .postbox {
|
23 |
+
border: 1px solid #D0D0D0;
|
24 |
+
}
|
25 |
+
#siteorigin-custom-css #poststuff .postbox h3.hndle {
|
26 |
+
cursor: default;
|
27 |
+
border-bottom: 1px solid #D0D0D0;
|
28 |
+
background: #efefef;
|
29 |
+
position: relative;
|
30 |
+
}
|
31 |
+
#siteorigin-custom-css #poststuff .postbox h3.hndle .hide {
|
32 |
+
position: absolute;
|
33 |
+
top: 50%;
|
34 |
+
line-height: 1em;
|
35 |
+
margin-top: -0.5em;
|
36 |
+
right: 12px;
|
37 |
+
}
|
38 |
+
#siteorigin-custom-css #poststuff #so-custom-css-getting-started .inside {
|
39 |
+
padding: 0 6px 6px 6px;
|
40 |
+
}
|
41 |
+
#siteorigin-custom-css #poststuff #so-custom-css-getting-started .inside img {
|
42 |
+
display: block;
|
43 |
+
width: 100%;
|
44 |
+
height: auto;
|
45 |
+
}
|
46 |
+
#so-custom-css-form {
|
47 |
+
margin-right: 340px;
|
48 |
+
}
|
49 |
+
#so-custom-css-info {
|
50 |
+
width: 315px;
|
51 |
+
float: right;
|
52 |
+
}
|
53 |
+
#so-custom-css-info *:first-child {
|
54 |
+
margin-top: 0;
|
55 |
+
}
|
56 |
+
#so-custom-css-info *:last-child {
|
57 |
+
margin-bottom: 0;
|
58 |
+
}
|
59 |
+
#so-custom-css-revisions ol {
|
60 |
+
list-style: none;
|
61 |
+
margin: 0;
|
62 |
+
}
|
63 |
+
#so-custom-css-revisions ol li {
|
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 {
|
71 |
+
border: 1px solid #D0D0D0;
|
72 |
+
border-bottom: none;
|
73 |
+
background: #efefef;
|
74 |
+
padding: 8px 10px;
|
75 |
+
overflow: auto;
|
76 |
+
}
|
77 |
+
#so-custom-css-form .custom-css-toolbar .toolbar-function-buttons {
|
78 |
+
float: left;
|
79 |
+
}
|
80 |
+
#so-custom-css-form .custom-css-toolbar .toolbar-function-buttons .toolbar-functions-dropdown {
|
81 |
+
display: none;
|
82 |
+
}
|
83 |
+
#so-custom-css-form .custom-css-toolbar .toolbar-function-buttons ul.toolbar-buttons {
|
84 |
+
margin: 0;
|
85 |
+
}
|
86 |
+
#so-custom-css-form .custom-css-toolbar .toolbar-function-buttons ul.toolbar-buttons li {
|
87 |
+
display: inline-block;
|
88 |
+
margin: 0;
|
89 |
+
padding: 0;
|
90 |
+
}
|
91 |
+
#so-custom-css-form .custom-css-toolbar .toolbar-action-buttons {
|
92 |
+
float: right;
|
93 |
+
}
|
94 |
+
#so-custom-css-form .custom-css-toolbar .toolbar-action-buttons a.active {
|
95 |
+
border-color: #b4c4cf;
|
96 |
+
background-color: #e9f9ff;
|
97 |
+
color: #596872;
|
98 |
+
}
|
99 |
+
#so-custom-css-form .custom-css-toolbar .toolbar-action-buttons .editor-expand {
|
100 |
+
float: right;
|
101 |
+
text-decoration: none;
|
102 |
+
color: #666;
|
103 |
+
}
|
104 |
+
#so-custom-css-form .custom-css-toolbar .toolbar-action-buttons .editor-expand .fa-compress {
|
105 |
+
display: none;
|
106 |
+
}
|
107 |
+
#so-custom-css-form .custom-css-toolbar .fa {
|
108 |
+
font-size: 14px;
|
109 |
+
}
|
110 |
+
#so-custom-css-form .custom-css-container {
|
111 |
+
border: 1px solid #D0D0D0;
|
112 |
+
background: #f7f7f7;
|
113 |
+
cursor: text;
|
114 |
+
overflow: hidden;
|
115 |
+
}
|
116 |
+
#so-custom-css-form .custom-css-container .CodeMirror {
|
117 |
+
height: auto;
|
118 |
+
}
|
119 |
+
#so-custom-css-form .custom-css-container .CodeMirror-scroll {
|
120 |
+
min-height: 300px;
|
121 |
+
}
|
122 |
+
#so-custom-css-form .custom-css-container .CodeMirror-lines {
|
123 |
+
padding: 8px 0 8px 0;
|
124 |
+
}
|
125 |
+
#so-custom-css-form .custom-css-container textarea {
|
126 |
+
border: 0;
|
127 |
+
padding: 8px 0 8px 4px;
|
128 |
+
width: 100%;
|
129 |
+
min-height: 300px;
|
130 |
+
display: block;
|
131 |
+
font-family: monospace;
|
132 |
+
font-size: 13px;
|
133 |
+
line-height: 1.4em;
|
134 |
+
border-left: 1px solid #ddd;
|
135 |
+
margin-left: 16px;
|
136 |
+
}
|
137 |
+
#so-custom-css-form .decoration {
|
138 |
+
display: none;
|
139 |
+
}
|
140 |
+
#so-custom-css-form.expanded {
|
141 |
+
z-index: 100000;
|
142 |
+
position: fixed;
|
143 |
+
top: 0;
|
144 |
+
left: 0;
|
145 |
+
bottom: 0;
|
146 |
+
width: 340px;
|
147 |
+
}
|
148 |
+
#so-custom-css-form.expanded .custom-css-toolbar .editor-expand .fa-expand {
|
149 |
+
display: none;
|
150 |
+
}
|
151 |
+
#so-custom-css-form.expanded .custom-css-toolbar .editor-expand .fa-compress {
|
152 |
+
display: inline-block;
|
153 |
+
}
|
154 |
+
#so-custom-css-form.expanded .decoration {
|
155 |
+
display: block;
|
156 |
+
position: absolute;
|
157 |
+
top: 0;
|
158 |
+
bottom: 0;
|
159 |
+
left: 339px;
|
160 |
+
width: 2px;
|
161 |
+
background: rgba(0, 0, 0, 0.1);
|
162 |
+
}
|
163 |
+
#so-custom-css-form.expanded .description {
|
164 |
+
display: none;
|
165 |
+
}
|
166 |
+
#so-custom-css-form.expanded .submit {
|
167 |
+
display: none;
|
168 |
+
}
|
169 |
+
#so-custom-css-form.expanded .custom-css-preview {
|
170 |
+
position: fixed;
|
171 |
+
display: block;
|
172 |
+
top: 0;
|
173 |
+
right: 0;
|
174 |
+
bottom: 0;
|
175 |
+
left: 340px;
|
176 |
+
background: #ffffff;
|
177 |
+
}
|
178 |
+
#so-custom-css-form.expanded .custom-css-preview iframe {
|
179 |
+
display: block;
|
180 |
+
width: 100%;
|
181 |
+
height: 100%;
|
182 |
+
overflow-x: hidden;
|
183 |
+
}
|
184 |
+
#so-custom-css-properties {
|
185 |
+
display: none;
|
186 |
+
position: fixed;
|
187 |
+
top: 0;
|
188 |
+
left: -338px;
|
189 |
+
bottom: 0;
|
190 |
+
width: 338px;
|
191 |
+
background: #ffffff;
|
192 |
+
border: 1px solid #D0D0D0;
|
193 |
+
overflow-y: auto;
|
194 |
+
z-index: 100000;
|
195 |
+
}
|
196 |
+
#so-custom-css-properties .toolbar {
|
197 |
+
display: block;
|
198 |
+
padding: 7px 10px;
|
199 |
+
border-bottom: 1px solid #aaa;
|
200 |
+
background: #F6F6F6;
|
201 |
+
text-align: left;
|
202 |
+
}
|
203 |
+
#so-custom-css-properties .toolbar select {
|
204 |
+
line-height: 1;
|
205 |
+
font-size: 13px;
|
206 |
+
max-width: 265px;
|
207 |
+
-webkit-transition: all 0.5s ease;
|
208 |
+
-moz-transition: all 0.5s ease;
|
209 |
+
-o-transition: all 0.5s ease;
|
210 |
+
transition: all 0.5s ease;
|
211 |
+
}
|
212 |
+
#so-custom-css-properties .toolbar select.highlighted {
|
213 |
+
background: #daeaf7;
|
214 |
+
}
|
215 |
+
#so-custom-css-properties .toolbar .close {
|
216 |
+
float: right;
|
217 |
+
margin: 2px 4px 0 0;
|
218 |
+
}
|
219 |
+
#so-custom-css-properties .section-tabs {
|
220 |
+
list-style: none;
|
221 |
+
height: auto;
|
222 |
+
margin: 0;
|
223 |
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
|
224 |
+
}
|
225 |
+
#so-custom-css-properties .section-tabs li {
|
226 |
+
box-sizing: border-box;
|
227 |
+
float: left;
|
228 |
+
width: 33.333%;
|
229 |
+
padding: 10px 7px;
|
230 |
+
border: 1px solid #aaa;
|
231 |
+
background: #F6F6F6;
|
232 |
+
font-weight: bold;
|
233 |
+
border-top: 0;
|
234 |
+
border-left: 0;
|
235 |
+
font-size: 13px;
|
236 |
+
line-height: 1em;
|
237 |
+
cursor: pointer;
|
238 |
+
white-space: nowrap;
|
239 |
+
overflow: hidden;
|
240 |
+
color: #666;
|
241 |
+
}
|
242 |
+
#so-custom-css-properties .section-tabs li:hover {
|
243 |
+
background: #fff;
|
244 |
+
}
|
245 |
+
#so-custom-css-properties .section-tabs li .fa {
|
246 |
+
float: left;
|
247 |
+
display: block;
|
248 |
+
margin: -1px 6px -1px 0;
|
249 |
+
font-size: 15px;
|
250 |
+
color: #666;
|
251 |
+
}
|
252 |
+
#so-custom-css-properties .section-tabs li:last-child {
|
253 |
+
border-right: 0;
|
254 |
+
}
|
255 |
+
#so-custom-css-properties .section-tabs li.active {
|
256 |
+
color: #444;
|
257 |
+
background: #e8e8e8;
|
258 |
+
}
|
259 |
+
#so-custom-css-properties .section-tabs li.active .fa {
|
260 |
+
color: #333;
|
261 |
+
}
|
262 |
+
#so-custom-css-properties .sections .section {
|
263 |
+
display: none;
|
264 |
+
padding: 10px;
|
265 |
+
}
|
266 |
+
#so-custom-css-properties .sections .fields-table {
|
267 |
+
width: 100%;
|
268 |
+
padding-top: 5px;
|
269 |
+
}
|
270 |
+
#so-custom-css-properties .sections .fields-table th,
|
271 |
+
#so-custom-css-properties .sections .fields-table td {
|
272 |
+
position: relative;
|
273 |
+
zoom: 1;
|
274 |
+
}
|
275 |
+
#so-custom-css-properties .sections .fields-table th:before,
|
276 |
+
#so-custom-css-properties .sections .fields-table td:before {
|
277 |
+
content: '';
|
278 |
+
display: block;
|
279 |
+
}
|
280 |
+
#so-custom-css-properties .sections .fields-table th:after,
|
281 |
+
#so-custom-css-properties .sections .fields-table td:after {
|
282 |
+
content: '';
|
283 |
+
display: table;
|
284 |
+
clear: both;
|
285 |
+
}
|
286 |
+
#so-custom-css-properties .sections .fields-table th[scope="row"] {
|
287 |
+
font-weight: bold;
|
288 |
+
font-size: 12px;
|
289 |
+
padding-right: 10px;
|
290 |
+
text-align: left;
|
291 |
+
width: 36%;
|
292 |
+
vertical-align: top;
|
293 |
+
}
|
294 |
+
#so-custom-css-properties .sections .fields-table td {
|
295 |
+
padding: 0 0 12px 0 ;
|
296 |
+
}
|
297 |
+
#so-custom-css-properties .sections .fields-table input,
|
298 |
+
#so-custom-css-properties .sections .fields-table select {
|
299 |
+
display: block;
|
300 |
+
margin: 0 25px 0 0;
|
301 |
+
border: 1px solid #c0c0c0;
|
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;
|
308 |
+
position: absolute;
|
309 |
+
top: 0px;
|
310 |
+
right: 1px;
|
311 |
+
padding: 5px;
|
312 |
+
cursor: pointer;
|
313 |
+
font-size: 15px;
|
314 |
+
}
|
315 |
+
#so-custom-css-properties .sections .fields-table .select-tabs {
|
316 |
+
margin: 0;
|
317 |
+
height: 40px;
|
318 |
+
}
|
319 |
+
#so-custom-css-properties .sections .fields-table .select-tabs .select-tab {
|
320 |
+
cursor: pointer;
|
321 |
+
float: left;
|
322 |
+
-webkit-box-sizing: border-box;
|
323 |
+
-moz-box-sizing: border-box;
|
324 |
+
box-sizing: border-box;
|
325 |
+
text-align: center;
|
326 |
+
border: 1px solid #c0c0c0;
|
327 |
+
padding: 4px 2px;
|
328 |
+
border-right-width: 0;
|
329 |
+
background: #f7f7f7;
|
330 |
+
}
|
331 |
+
#so-custom-css-properties .sections .fields-table .select-tabs .select-tab .fa {
|
332 |
+
line-height: 14px;
|
333 |
+
font-size: 14px;
|
334 |
+
color: #777;
|
335 |
+
}
|
336 |
+
#so-custom-css-properties .sections .fields-table .select-tabs .select-tab:last-child {
|
337 |
+
border-right-width: 1px;
|
338 |
+
}
|
339 |
+
#so-custom-css-properties .sections .fields-table .select-tabs .select-tab:hover,
|
340 |
+
#so-custom-css-properties .sections .fields-table .select-tabs .select-tab.active {
|
341 |
+
background: #e9e9e9;
|
342 |
+
}
|
343 |
+
#so-custom-css-properties .sections .fields-table .select-tabs .select-tab:hover .fa,
|
344 |
+
#so-custom-css-properties .sections .fields-table .select-tabs .select-tab.active .fa {
|
345 |
+
color: #333;
|
346 |
+
}
|
347 |
+
#so-custom-css-properties .sections .fields-table .side-tabs {
|
348 |
+
height: 26px;
|
349 |
+
}
|
350 |
+
#so-custom-css-properties .sections .fields-table .side-tabs .side-tab {
|
351 |
+
width: 20%;
|
352 |
+
text-align: center;
|
353 |
+
padding: 5px;
|
354 |
+
line-height: 0;
|
355 |
+
}
|
356 |
+
#so-custom-css-properties .sections .fields-table .side-tabs .side-tab div {
|
357 |
+
display: inline-block;
|
358 |
+
width: 10px;
|
359 |
+
height: 10px;
|
360 |
+
border: 2px solid #aaa;
|
361 |
+
}
|
362 |
+
#so-custom-css-properties .sections .fields-table .side-tabs .side-tab .spacing-all {
|
363 |
+
border-color: #12609b;
|
364 |
+
}
|
365 |
+
#so-custom-css-properties .sections .fields-table .side-tabs .side-tab .spacing-top {
|
366 |
+
border-top-color: #12609b;
|
367 |
+
}
|
368 |
+
#so-custom-css-properties .sections .fields-table .side-tabs .side-tab .spacing-left {
|
369 |
+
border-left-color: #12609b;
|
370 |
+
}
|
371 |
+
#so-custom-css-properties .sections .fields-table .side-tabs .side-tab .spacing-bottom {
|
372 |
+
border-bottom-color: #12609b;
|
373 |
+
}
|
374 |
+
#so-custom-css-properties .sections .fields-table .side-tabs .side-tab .spacing-right {
|
375 |
+
border-right-color: #12609b;
|
376 |
+
}
|
377 |
+
#so-custom-css-properties .sections .fields-table .sides .side > div {
|
378 |
+
margin-bottom: 5px;
|
379 |
+
}
|
380 |
+
#so-custom-css-properties .sections .fields-table .sides .side > div:last-child {
|
381 |
+
margin-bottom: 0;
|
382 |
+
}
|
383 |
+
.css-editor-snippet-browser {
|
384 |
+
display: none;
|
385 |
+
}
|
386 |
+
.css-editor-snippet-browser .snippet-browser-overlay {
|
387 |
+
position: fixed;
|
388 |
+
z-index: 100000;
|
389 |
+
top: 0;
|
390 |
+
left: 0;
|
391 |
+
right: 0;
|
392 |
+
bottom: 0;
|
393 |
+
background: rgba(0, 0, 0, 0.8);
|
394 |
+
}
|
395 |
+
.css-editor-snippet-browser .snippet-browser-dialog > div {
|
396 |
+
position: fixed;
|
397 |
+
z-index: 100001;
|
398 |
+
background: #fff;
|
399 |
+
box-sizing: border-box;
|
400 |
+
}
|
401 |
+
.css-editor-snippet-browser .snippet-browser-dialog .toolbar {
|
402 |
+
top: 40px;
|
403 |
+
left: 40px;
|
404 |
+
right: 40px;
|
405 |
+
height: 50px;
|
406 |
+
background: #FCFCFC;
|
407 |
+
border-bottom: 1px solid #dddddd;
|
408 |
+
overflow: hidden;
|
409 |
+
}
|
410 |
+
.css-editor-snippet-browser .snippet-browser-dialog .toolbar h1 {
|
411 |
+
padding: 0 16px;
|
412 |
+
font-size: 22px;
|
413 |
+
line-height: 50px;
|
414 |
+
margin: 0;
|
415 |
+
color: #444;
|
416 |
+
}
|
417 |
+
.css-editor-snippet-browser .snippet-browser-dialog .toolbar .close {
|
418 |
+
cursor: pointer;
|
419 |
+
color: #777;
|
420 |
+
background-color: transparent;
|
421 |
+
height: 50px;
|
422 |
+
width: 50px;
|
423 |
+
padding: 15px 0 0 0;
|
424 |
+
position: absolute;
|
425 |
+
text-align: center;
|
426 |
+
border: 0;
|
427 |
+
border-left: 1px solid #ddd;
|
428 |
+
top: 0;
|
429 |
+
right: 0;
|
430 |
+
text-decoration: none;
|
431 |
+
box-sizing: border-box;
|
432 |
+
}
|
433 |
+
.css-editor-snippet-browser .snippet-browser-dialog .toolbar .close:hover {
|
434 |
+
background: #dddddd;
|
435 |
+
}
|
436 |
+
.css-editor-snippet-browser .snippet-browser-dialog .toolbar .close .icon:before {
|
437 |
+
content: '\f158';
|
438 |
+
font: normal 20px/1 'dashicons';
|
439 |
+
vertical-align: middle;
|
440 |
+
-webkit-font-smoothing: antialiased;
|
441 |
+
-moz-osx-font-smoothing: grayscale;
|
442 |
+
color: #666;
|
443 |
+
}
|
444 |
+
.css-editor-snippet-browser .snippet-browser-dialog .sidebar {
|
445 |
+
top: 90px;
|
446 |
+
left: 40px;
|
447 |
+
bottom: 90px;
|
448 |
+
width: 300px;
|
449 |
+
background: #f3f3f3;
|
450 |
+
border-right: 1px solid #dddddd;
|
451 |
+
padding: 16px;
|
452 |
+
overflow: auto;
|
453 |
+
}
|
454 |
+
.css-editor-snippet-browser .snippet-browser-dialog .sidebar .snippet-search {
|
455 |
+
width: 100%;
|
456 |
+
margin-bottom: 20px;
|
457 |
+
padding: 8px;
|
458 |
+
}
|
459 |
+
.css-editor-snippet-browser .snippet-browser-dialog .sidebar .snippets {
|
460 |
+
margin: 0;
|
461 |
+
}
|
462 |
+
.css-editor-snippet-browser .snippet-browser-dialog .sidebar .snippets .snippet {
|
463 |
+
cursor: pointer;
|
464 |
+
font-size: 1.1em;
|
465 |
+
line-height: 1.35em;
|
466 |
+
margin-bottom: 20px;
|
467 |
+
}
|
468 |
+
.css-editor-snippet-browser .snippet-browser-dialog .sidebar .snippets .snippet.active {
|
469 |
+
font-weight: bold;
|
470 |
+
}
|
471 |
+
.css-editor-snippet-browser .snippet-browser-dialog .main {
|
472 |
+
top: 90px;
|
473 |
+
left: 340px;
|
474 |
+
right: 40px;
|
475 |
+
bottom: 90px;
|
476 |
+
background: #fff;
|
477 |
+
overflow: auto;
|
478 |
+
}
|
479 |
+
.css-editor-snippet-browser .snippet-browser-dialog .main .snippet-view {
|
480 |
+
padding: 20px;
|
481 |
+
}
|
482 |
+
.css-editor-snippet-browser .snippet-browser-dialog .main .snippet-view .snippet-title {
|
483 |
+
margin: 0 0 0.75em 0;
|
484 |
+
padding: 0;
|
485 |
+
}
|
486 |
+
.css-editor-snippet-browser .snippet-browser-dialog .main .snippet-view .snippet-description {
|
487 |
+
font-size: 1.1em;
|
488 |
+
color: #666;
|
489 |
+
margin-bottom: 2em;
|
490 |
+
}
|
491 |
+
.css-editor-snippet-browser .snippet-browser-dialog .main .snippet-view .snippet-code {
|
492 |
+
padding: 20px;
|
493 |
+
border: 1px solid #d0d0d0;
|
494 |
+
background: #f8f8f8;
|
495 |
+
}
|
496 |
+
.css-editor-snippet-browser .snippet-browser-dialog .buttons {
|
497 |
+
bottom: 40px;
|
498 |
+
left: 40px;
|
499 |
+
right: 40px;
|
500 |
+
height: 50px;
|
501 |
+
background: #FCFCFC;
|
502 |
+
border-top: 1px solid #dddddd;
|
503 |
+
text-align: right;
|
504 |
+
padding: 10px 20px;
|
505 |
+
overflow: hidden;
|
506 |
+
}
|
507 |
+
.socss-field-measurement {
|
508 |
+
position: relative;
|
509 |
+
}
|
510 |
+
.socss-field-measurement input.socss-field-input {
|
511 |
+
min-height: 1.5em;
|
512 |
+
padding-right: 50px;
|
513 |
+
width: 120px !important;
|
514 |
+
box-sizing: border-box;
|
515 |
+
}
|
516 |
+
.socss-field-measurement .dashicons-arrow-down {
|
517 |
+
position: absolute;
|
518 |
+
top: 4px;
|
519 |
+
left: 97px;
|
520 |
+
cursor: pointer;
|
521 |
+
}
|
522 |
+
.socss-field-measurement .dropdown {
|
523 |
+
display: none;
|
524 |
+
background: #F5F5F5;
|
525 |
+
border: 1px solid #c0c0c0;
|
526 |
+
position: absolute;
|
527 |
+
top: 27px;
|
528 |
+
left: 71px;
|
529 |
+
width: 50px;
|
530 |
+
z-index: 2;
|
531 |
+
margin: 0;
|
532 |
+
box-sizing: border-box;
|
533 |
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
|
534 |
+
}
|
535 |
+
.socss-field-measurement .dropdown li {
|
536 |
+
padding: 5px 0;
|
537 |
+
text-align: center;
|
538 |
+
line-height: 1.1em;
|
539 |
+
font-size: 11px;
|
540 |
+
margin: 0;
|
541 |
+
}
|
542 |
+
.socss-field-measurement .dropdown li:hover,
|
543 |
+
.socss-field-measurement .dropdown li.active {
|
544 |
+
background: #e8e8e8;
|
545 |
+
cursor: pointer;
|
546 |
+
}
|
547 |
+
.socss-field-measurement .units {
|
548 |
+
position: absolute;
|
549 |
+
top: 5px;
|
550 |
+
left: 12px;
|
551 |
+
color: #bbb;
|
552 |
+
pointer-events: none;
|
553 |
+
}
|
554 |
+
.socss-diw {
|
555 |
+
position: absolute;
|
556 |
+
top: 0px;
|
557 |
+
left: 124px;
|
558 |
+
}
|
559 |
+
.socss-diw .inc-button,
|
560 |
+
.socss-diw .dec-button {
|
561 |
+
cursor: pointer;
|
562 |
+
box-sizing: border-box;
|
563 |
+
float: left;
|
564 |
+
padding: 8px;
|
565 |
+
user-select: none;
|
566 |
+
text-align: center;
|
567 |
+
margin: 0;
|
568 |
+
width: 27px;
|
569 |
+
height: 27px;
|
570 |
+
font-size: 10px;
|
571 |
+
}
|
572 |
+
.socss-diw .inc-button {
|
573 |
+
border-left: 0;
|
574 |
+
}
|
575 |
+
.socss-button {
|
576 |
+
cursor: pointer;
|
577 |
+
line-height: 1em;
|
578 |
+
display: inline-block;
|
579 |
+
border: 1px solid #c0c0c0;
|
580 |
+
background: #f7f7f7;
|
581 |
+
text-decoration: none;
|
582 |
+
padding: 6px;
|
583 |
+
font-weight: bold;
|
584 |
+
color: #555;
|
585 |
+
font-size: 0.95em;
|
586 |
+
margin-left: 5px;
|
587 |
+
-webkit-user-select: none;
|
588 |
+
-moz-user-select: none;
|
589 |
+
-ms-user-select: none;
|
590 |
+
-o-user-select: none;
|
591 |
+
user-select: none;
|
592 |
+
}
|
593 |
+
.socss-button:hover {
|
594 |
+
border-color: #b0b0b0;
|
595 |
+
background: #fff;
|
596 |
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
597 |
+
}
|
598 |
+
.socss-button:hover .fa {
|
599 |
+
color: #333;
|
600 |
+
}
|
601 |
+
.socss-button .fa {
|
602 |
+
color: #555;
|
603 |
+
}
|
604 |
+
.CodeMirror-lint-tooltip,
|
605 |
+
.CodeMirror-hints {
|
606 |
+
/* This is above the editor in full-screen mode */
|
607 |
+
z-index: 100002;
|
608 |
+
}
|
css/admin.less
ADDED
@@ -0,0 +1,754 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
@import "mixins";
|
2 |
+
|
3 |
+
#siteorigin-custom-css {
|
4 |
+
margin: 0 0 0 -20px;
|
5 |
+
|
6 |
+
h2 {
|
7 |
+
background: #f8f8f8;
|
8 |
+
padding: 20px;
|
9 |
+
border-bottom: 1px solid #d0d0d0;
|
10 |
+
margin-bottom: 20px;
|
11 |
+
|
12 |
+
.icon {
|
13 |
+
width: 40px;
|
14 |
+
height: auto;
|
15 |
+
margin: -8px 10px -8px 0;
|
16 |
+
}
|
17 |
+
|
18 |
+
box-shadow: 0 1px 1px rgba(0,0,0,0.035);
|
19 |
+
}
|
20 |
+
|
21 |
+
.updated {
|
22 |
+
margin: 0 20px 20px 20px ;
|
23 |
+
}
|
24 |
+
|
25 |
+
#poststuff {
|
26 |
+
padding: 0 20px;
|
27 |
+
|
28 |
+
.postbox {
|
29 |
+
border: 1px solid #D0D0D0;
|
30 |
+
|
31 |
+
h3.hndle {
|
32 |
+
cursor: default;
|
33 |
+
border-bottom: 1px solid #D0D0D0;
|
34 |
+
background: #efefef;
|
35 |
+
position: relative;
|
36 |
+
|
37 |
+
.hide {
|
38 |
+
position: absolute;
|
39 |
+
top: 50%;
|
40 |
+
line-height: 1em;
|
41 |
+
margin-top: -0.5em;
|
42 |
+
right: 12px;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
#so-custom-css-getting-started {
|
48 |
+
.inside {
|
49 |
+
padding: 0 6px 6px 6px;
|
50 |
+
|
51 |
+
img {
|
52 |
+
display: block;
|
53 |
+
width: 100%;
|
54 |
+
height: auto;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
#so-custom-css-form {
|
62 |
+
margin-right: 340px;
|
63 |
+
}
|
64 |
+
|
65 |
+
#so-custom-css-info{
|
66 |
+
width: 315px;
|
67 |
+
float: right;
|
68 |
+
|
69 |
+
*:first-child {
|
70 |
+
margin-top: 0;
|
71 |
+
}
|
72 |
+
|
73 |
+
*:last-child {
|
74 |
+
margin-bottom: 0;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
#so-custom-css-revisions {
|
79 |
+
ol {
|
80 |
+
list-style: none;
|
81 |
+
margin: 0;
|
82 |
+
|
83 |
+
li{
|
84 |
+
margin: 0;
|
85 |
+
line-height: 2.2em;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
#so-custom-css-form {
|
91 |
+
|
92 |
+
.custom-css-preview {
|
93 |
+
iframe {
|
94 |
+
display: none;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
.custom-css-toolbar {
|
99 |
+
border:1px solid #D0D0D0;
|
100 |
+
border-bottom: none;
|
101 |
+
background: #efefef;
|
102 |
+
padding: 8px 10px;
|
103 |
+
overflow: auto;
|
104 |
+
|
105 |
+
.toolbar-function-buttons{
|
106 |
+
float: left;
|
107 |
+
|
108 |
+
.toolbar-functions-dropdown {
|
109 |
+
display: none;
|
110 |
+
}
|
111 |
+
|
112 |
+
ul.toolbar-buttons {
|
113 |
+
margin: 0;
|
114 |
+
|
115 |
+
li {
|
116 |
+
display: inline-block;
|
117 |
+
margin: 0;
|
118 |
+
padding: 0;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
.toolbar-action-buttons {
|
124 |
+
float: right;
|
125 |
+
|
126 |
+
a {
|
127 |
+
&.active {
|
128 |
+
border-color: #b4c4cf;
|
129 |
+
background-color: #e9f9ff;
|
130 |
+
color: #596872;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
.editor-expand {
|
135 |
+
float: right;
|
136 |
+
text-decoration: none;
|
137 |
+
color: #666;
|
138 |
+
|
139 |
+
.fa-compress {
|
140 |
+
display: none;
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
.fa {
|
146 |
+
font-size: 14px;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
.custom-css-container {
|
151 |
+
border:1px solid #D0D0D0;
|
152 |
+
background: #f7f7f7;
|
153 |
+
cursor: text;
|
154 |
+
overflow: hidden;
|
155 |
+
|
156 |
+
.CodeMirror {
|
157 |
+
height: auto;
|
158 |
+
}
|
159 |
+
|
160 |
+
.CodeMirror-scroll {
|
161 |
+
min-height: 300px;
|
162 |
+
}
|
163 |
+
|
164 |
+
.CodeMirror-lines {
|
165 |
+
padding: 8px 0 8px 0;
|
166 |
+
}
|
167 |
+
|
168 |
+
textarea {
|
169 |
+
border: 0;
|
170 |
+
padding: 8px 0 8px 4px;
|
171 |
+
width: 100%;
|
172 |
+
min-height: 300px;
|
173 |
+
display: block;
|
174 |
+
font-family: monospace;
|
175 |
+
font-size: 13px;
|
176 |
+
line-height: 1.4em;
|
177 |
+
border-left: 1px solid #ddd;
|
178 |
+
margin-left: 16px;
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
.decoration {
|
183 |
+
display: none;
|
184 |
+
}
|
185 |
+
|
186 |
+
&.expanded {
|
187 |
+
@expanded_form_width: 340px;
|
188 |
+
|
189 |
+
z-index: 100000;
|
190 |
+
position: fixed;
|
191 |
+
top: 0;
|
192 |
+
left: 0;
|
193 |
+
bottom: 0;
|
194 |
+
width: @expanded_form_width;
|
195 |
+
|
196 |
+
.custom-css-toolbar {
|
197 |
+
|
198 |
+
.editor-expand {
|
199 |
+
|
200 |
+
.fa-expand {
|
201 |
+
display: none;
|
202 |
+
}
|
203 |
+
.fa-compress {
|
204 |
+
display: inline-block;
|
205 |
+
}
|
206 |
+
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
.decoration {
|
211 |
+
display: block;
|
212 |
+
position: absolute;
|
213 |
+
top: 0;
|
214 |
+
bottom: 0;
|
215 |
+
left: @expanded_form_width - 1px;
|
216 |
+
width: 2px;
|
217 |
+
background: rgba(0,0,0,0.1);
|
218 |
+
}
|
219 |
+
|
220 |
+
.description {
|
221 |
+
display: none;
|
222 |
+
}
|
223 |
+
|
224 |
+
.submit {
|
225 |
+
display: none;
|
226 |
+
}
|
227 |
+
|
228 |
+
.custom-css-preview {
|
229 |
+
position: fixed;
|
230 |
+
display: block;
|
231 |
+
top: 0;
|
232 |
+
right: 0;
|
233 |
+
bottom: 0;
|
234 |
+
left: @expanded_form_width;
|
235 |
+
background: #ffffff;
|
236 |
+
|
237 |
+
iframe {
|
238 |
+
display: block;
|
239 |
+
width: 100%;
|
240 |
+
height: 100%;
|
241 |
+
overflow-x: hidden;
|
242 |
+
}
|
243 |
+
|
244 |
+
}
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
#so-custom-css-properties {
|
249 |
+
|
250 |
+
display: none;
|
251 |
+
|
252 |
+
position: fixed;
|
253 |
+
top: 0;
|
254 |
+
left: -338px;
|
255 |
+
bottom: 0;
|
256 |
+
width: 338px;
|
257 |
+
background: #ffffff;
|
258 |
+
border:1px solid #D0D0D0;
|
259 |
+
overflow-y: auto;
|
260 |
+
|
261 |
+
z-index: 100000;
|
262 |
+
|
263 |
+
.toolbar {
|
264 |
+
display: block;
|
265 |
+
padding: 7px 10px;
|
266 |
+
border-bottom: 1px solid #aaa;
|
267 |
+
background: #F6F6F6;
|
268 |
+
text-align: left;
|
269 |
+
|
270 |
+
select {
|
271 |
+
line-height: 1;
|
272 |
+
font-size: 13px;
|
273 |
+
max-width: 265px;
|
274 |
+
.transition(0.5s);
|
275 |
+
|
276 |
+
&.highlighted {
|
277 |
+
background: #daeaf7;
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
.close {
|
282 |
+
float: right;
|
283 |
+
margin: 2px 4px 0 0;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
.section-tabs {
|
288 |
+
list-style: none;
|
289 |
+
height: auto;
|
290 |
+
margin: 0;
|
291 |
+
box-shadow: 0 1px 1px rgba(0,0,0,0.1);
|
292 |
+
|
293 |
+
li {
|
294 |
+
box-sizing: border-box;
|
295 |
+
float: left;
|
296 |
+
width: 33.333%;
|
297 |
+
padding: 10px 7px;
|
298 |
+
border: 1px solid #aaa;
|
299 |
+
background: #F6F6F6;
|
300 |
+
font-weight: bold;
|
301 |
+
|
302 |
+
border-top: 0;
|
303 |
+
border-left: 0;
|
304 |
+
font-size: 13px;
|
305 |
+
line-height: 1em;
|
306 |
+
|
307 |
+
cursor: pointer;
|
308 |
+
white-space: nowrap;
|
309 |
+
overflow: hidden;
|
310 |
+
|
311 |
+
color: #666;
|
312 |
+
|
313 |
+
&:hover {
|
314 |
+
background: #fff;
|
315 |
+
}
|
316 |
+
|
317 |
+
.fa {
|
318 |
+
float: left;
|
319 |
+
display: block;
|
320 |
+
margin: -1px 6px -1px 0;
|
321 |
+
font-size: 15px;
|
322 |
+
color: #666;
|
323 |
+
}
|
324 |
+
|
325 |
+
&:last-child {
|
326 |
+
border-right: 0;
|
327 |
+
}
|
328 |
+
|
329 |
+
&.active {
|
330 |
+
color: #444;
|
331 |
+
background: #e8e8e8;
|
332 |
+
|
333 |
+
.fa {
|
334 |
+
color: #333;
|
335 |
+
}
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
.sections {
|
341 |
+
|
342 |
+
.section {
|
343 |
+
display: none;
|
344 |
+
padding: 10px;
|
345 |
+
}
|
346 |
+
|
347 |
+
.fields-table {
|
348 |
+
width: 100%;
|
349 |
+
padding-top: 5px;
|
350 |
+
|
351 |
+
th, td {
|
352 |
+
position: relative;
|
353 |
+
.clearfix();
|
354 |
+
}
|
355 |
+
|
356 |
+
th[scope="row"] {
|
357 |
+
font-weight: bold;
|
358 |
+
font-size: 12px;
|
359 |
+
padding-right: 10px;
|
360 |
+
text-align: left;
|
361 |
+
width: 36%;
|
362 |
+
vertical-align: top;
|
363 |
+
}
|
364 |
+
|
365 |
+
td {
|
366 |
+
padding: 0 0 12px 0 ;
|
367 |
+
}
|
368 |
+
|
369 |
+
input, select {
|
370 |
+
display: block;
|
371 |
+
margin: 0 25px 0 0;
|
372 |
+
border: 1px solid #c0c0c0;
|
373 |
+
width: 175px;
|
374 |
+
|
375 |
+
box-sizing: border-box;
|
376 |
+
border-radius: 0;
|
377 |
+
}
|
378 |
+
|
379 |
+
.select {
|
380 |
+
display: block;
|
381 |
+
position: absolute;
|
382 |
+
top: 0px;
|
383 |
+
right: 1px;
|
384 |
+
|
385 |
+
padding: 5px;
|
386 |
+
cursor: pointer;
|
387 |
+
font-size: 15px;
|
388 |
+
}
|
389 |
+
|
390 |
+
.select-tabs {
|
391 |
+
margin: 0;
|
392 |
+
height: 40px;
|
393 |
+
|
394 |
+
.select-tab {
|
395 |
+
cursor: pointer;
|
396 |
+
float: left;
|
397 |
+
|
398 |
+
-webkit-box-sizing: border-box;
|
399 |
+
-moz-box-sizing: border-box;
|
400 |
+
box-sizing: border-box;
|
401 |
+
|
402 |
+
text-align: center;
|
403 |
+
border: 1px solid #c0c0c0;
|
404 |
+
padding: 4px 2px;
|
405 |
+
border-right-width: 0;
|
406 |
+
background: #f7f7f7;
|
407 |
+
|
408 |
+
.fa {
|
409 |
+
line-height: 14px;
|
410 |
+
font-size: 14px;
|
411 |
+
color: #777;
|
412 |
+
}
|
413 |
+
|
414 |
+
&:last-child {
|
415 |
+
border-right-width: 1px;
|
416 |
+
}
|
417 |
+
|
418 |
+
&:hover, &.active {
|
419 |
+
background: #e9e9e9;
|
420 |
+
|
421 |
+
.fa {
|
422 |
+
color: #333;
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
}
|
427 |
+
|
428 |
+
}
|
429 |
+
|
430 |
+
.side-tabs {
|
431 |
+
height: 26px;
|
432 |
+
|
433 |
+
.side-tab {
|
434 |
+
width: 20%;
|
435 |
+
text-align: center;
|
436 |
+
padding: 5px;
|
437 |
+
line-height: 0;
|
438 |
+
|
439 |
+
div {
|
440 |
+
display: inline-block;
|
441 |
+
width: 10px;
|
442 |
+
height: 10px;
|
443 |
+
border: 2px solid #aaa;
|
444 |
+
}
|
445 |
+
|
446 |
+
@border_color: #12609b;
|
447 |
+
|
448 |
+
.spacing-all {
|
449 |
+
border-color: @border_color;
|
450 |
+
}
|
451 |
+
|
452 |
+
.spacing-top {
|
453 |
+
border-top-color: @border_color;
|
454 |
+
}
|
455 |
+
|
456 |
+
.spacing-left {
|
457 |
+
border-left-color: @border_color;
|
458 |
+
}
|
459 |
+
|
460 |
+
.spacing-bottom {
|
461 |
+
border-bottom-color: @border_color;
|
462 |
+
}
|
463 |
+
|
464 |
+
.spacing-right {
|
465 |
+
border-right-color: @border_color;
|
466 |
+
}
|
467 |
+
}
|
468 |
+
}
|
469 |
+
|
470 |
+
.sides {
|
471 |
+
.side > div {
|
472 |
+
margin-bottom: 5px;
|
473 |
+
|
474 |
+
&:last-child {
|
475 |
+
margin-bottom: 0;
|
476 |
+
}
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
}
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
.css-editor-snippet-browser {
|
485 |
+
display: none;
|
486 |
+
|
487 |
+
.snippet-browser-overlay {
|
488 |
+
position: fixed;
|
489 |
+
z-index: 100000;
|
490 |
+
top: 0;
|
491 |
+
left: 0;
|
492 |
+
right: 0;
|
493 |
+
bottom: 0;
|
494 |
+
background: rgba(0,0,0,0.8);
|
495 |
+
}
|
496 |
+
|
497 |
+
.snippet-browser-dialog {
|
498 |
+
|
499 |
+
@dialog_side_space: 40px;
|
500 |
+
|
501 |
+
> div {
|
502 |
+
position: fixed;
|
503 |
+
z-index: 100001;
|
504 |
+
background: #fff;
|
505 |
+
box-sizing: border-box;
|
506 |
+
}
|
507 |
+
|
508 |
+
.toolbar {
|
509 |
+
top: @dialog_side_space;
|
510 |
+
left: @dialog_side_space;
|
511 |
+
right: @dialog_side_space;
|
512 |
+
height: 50px;
|
513 |
+
background: #FCFCFC;
|
514 |
+
border-bottom: 1px solid #dddddd;
|
515 |
+
overflow: hidden;
|
516 |
+
|
517 |
+
h1 {
|
518 |
+
padding: 0 16px;
|
519 |
+
font-size: 22px;
|
520 |
+
line-height: 50px;
|
521 |
+
margin: 0;
|
522 |
+
color: #444;
|
523 |
+
}
|
524 |
+
|
525 |
+
.close {
|
526 |
+
cursor: pointer;
|
527 |
+
color: #777;
|
528 |
+
background-color: transparent;
|
529 |
+
height: 50px;
|
530 |
+
width: 50px;
|
531 |
+
padding: 15px 0 0 0;
|
532 |
+
position: absolute;
|
533 |
+
text-align: center;
|
534 |
+
border: 0;
|
535 |
+
border-left: 1px solid #ddd;
|
536 |
+
top: 0;
|
537 |
+
right: 0;
|
538 |
+
text-decoration: none;
|
539 |
+
box-sizing: border-box;
|
540 |
+
|
541 |
+
&:hover {
|
542 |
+
background: #dddddd;
|
543 |
+
}
|
544 |
+
|
545 |
+
.icon {
|
546 |
+
&:before {
|
547 |
+
content: '\f158';
|
548 |
+
font: normal 20px/1 'dashicons';
|
549 |
+
vertical-align: middle;
|
550 |
+
-webkit-font-smoothing: antialiased;
|
551 |
+
-moz-osx-font-smoothing: grayscale;
|
552 |
+
color: #666;
|
553 |
+
}
|
554 |
+
}
|
555 |
+
}
|
556 |
+
}
|
557 |
+
|
558 |
+
.sidebar {
|
559 |
+
top: @dialog_side_space + 50px;
|
560 |
+
left: @dialog_side_space;
|
561 |
+
bottom: @dialog_side_space + 50px;
|
562 |
+
width: 300px;
|
563 |
+
background: #f3f3f3;
|
564 |
+
border-right: 1px solid #dddddd;
|
565 |
+
padding: 16px;
|
566 |
+
overflow: auto;
|
567 |
+
|
568 |
+
.snippet-search {
|
569 |
+
width: 100%;
|
570 |
+
margin-bottom: 20px;
|
571 |
+
padding: 8px;
|
572 |
+
}
|
573 |
+
|
574 |
+
.snippets {
|
575 |
+
margin: 0;
|
576 |
+
|
577 |
+
.snippet {
|
578 |
+
cursor: pointer;
|
579 |
+
font-size: 1.1em;
|
580 |
+
line-height: 1.35em;
|
581 |
+
margin-bottom: 20px;
|
582 |
+
|
583 |
+
&.active {
|
584 |
+
font-weight: bold;
|
585 |
+
}
|
586 |
+
}
|
587 |
+
}
|
588 |
+
}
|
589 |
+
|
590 |
+
.main {
|
591 |
+
top: @dialog_side_space + 50px;
|
592 |
+
left: @dialog_side_space + 300px;
|
593 |
+
right: @dialog_side_space;
|
594 |
+
bottom: @dialog_side_space + 50px;
|
595 |
+
background: #fff;
|
596 |
+
overflow: auto;
|
597 |
+
|
598 |
+
.snippet-view {
|
599 |
+
padding: 20px;
|
600 |
+
|
601 |
+
.snippet-title {
|
602 |
+
margin: 0 0 0.75em 0;
|
603 |
+
padding: 0;
|
604 |
+
}
|
605 |
+
|
606 |
+
.snippet-description {
|
607 |
+
font-size: 1.1em;
|
608 |
+
color: #666;
|
609 |
+
margin-bottom: 2em;
|
610 |
+
}
|
611 |
+
|
612 |
+
.snippet-code {
|
613 |
+
padding: 20px;
|
614 |
+
border: 1px solid #d0d0d0;
|
615 |
+
background: #f8f8f8;
|
616 |
+
}
|
617 |
+
}
|
618 |
+
}
|
619 |
+
|
620 |
+
.buttons {
|
621 |
+
bottom: @dialog_side_space;
|
622 |
+
left: @dialog_side_space;
|
623 |
+
right: @dialog_side_space;
|
624 |
+
height: 50px;
|
625 |
+
background: #FCFCFC;
|
626 |
+
border-top: 1px solid #dddddd;
|
627 |
+
text-align: right;
|
628 |
+
padding: 10px 20px;
|
629 |
+
overflow: hidden;
|
630 |
+
}
|
631 |
+
|
632 |
+
|
633 |
+
}
|
634 |
+
}
|
635 |
+
|
636 |
+
.socss-field-measurement {
|
637 |
+
|
638 |
+
position: relative;
|
639 |
+
|
640 |
+
input.socss-field-input {
|
641 |
+
min-height: 1.5em;
|
642 |
+
padding-right: 50px;
|
643 |
+
width: 120px !important;
|
644 |
+
box-sizing: border-box;
|
645 |
+
}
|
646 |
+
|
647 |
+
.dashicons-arrow-down {
|
648 |
+
position: absolute;
|
649 |
+
top: 4px;
|
650 |
+
left: 97px;
|
651 |
+
cursor: pointer;
|
652 |
+
}
|
653 |
+
|
654 |
+
.dropdown {
|
655 |
+
display: none;
|
656 |
+
background: #F5F5F5;
|
657 |
+
border: 1px solid #c0c0c0;
|
658 |
+
position: absolute;
|
659 |
+
top: 27px;
|
660 |
+
left: 120px - 50px + 1px;
|
661 |
+
width: 50px;
|
662 |
+
z-index: 2;
|
663 |
+
margin: 0;
|
664 |
+
|
665 |
+
box-sizing: border-box;
|
666 |
+
box-shadow: 0 1px 1px rgba(0,0,0,0.15);
|
667 |
+
|
668 |
+
li {
|
669 |
+
padding: 5px 0;
|
670 |
+
text-align: center;
|
671 |
+
line-height: 1.1em;
|
672 |
+
font-size: 11px;
|
673 |
+
margin: 0;
|
674 |
+
|
675 |
+
&:hover, &.active {
|
676 |
+
background: #e8e8e8;
|
677 |
+
cursor: pointer;
|
678 |
+
}
|
679 |
+
}
|
680 |
+
}
|
681 |
+
|
682 |
+
.units {
|
683 |
+
position: absolute;
|
684 |
+
top: 5px;
|
685 |
+
left: 12px;
|
686 |
+
color: #bbb;
|
687 |
+
pointer-events: none;
|
688 |
+
}
|
689 |
+
}
|
690 |
+
|
691 |
+
.socss-diw {
|
692 |
+
position: absolute;
|
693 |
+
top: 0px;
|
694 |
+
left: 124px;
|
695 |
+
|
696 |
+
.inc-button,
|
697 |
+
.dec-button{
|
698 |
+
cursor: pointer;
|
699 |
+
box-sizing: border-box;
|
700 |
+
float: left;
|
701 |
+
padding: 8px;
|
702 |
+
user-select: none;
|
703 |
+
text-align: center;
|
704 |
+
margin: 0;
|
705 |
+
width: 27px;
|
706 |
+
height: 27px;
|
707 |
+
font-size: 10px;
|
708 |
+
}
|
709 |
+
|
710 |
+
.inc-button {
|
711 |
+
border-left: 0;
|
712 |
+
}
|
713 |
+
}
|
714 |
+
|
715 |
+
.socss-button {
|
716 |
+
cursor: pointer;
|
717 |
+
|
718 |
+
line-height: 1em;
|
719 |
+
display: inline-block;
|
720 |
+
border: 1px solid #c0c0c0;
|
721 |
+
background: #f7f7f7;
|
722 |
+
text-decoration: none;
|
723 |
+
padding: 6px;
|
724 |
+
font-weight: bold;
|
725 |
+
color: #555;
|
726 |
+
font-size: 0.95em;
|
727 |
+
margin-left: 5px;
|
728 |
+
|
729 |
+
-webkit-user-select: none;
|
730 |
+
-moz-user-select: none;
|
731 |
+
-ms-user-select: none;
|
732 |
+
-o-user-select: none;
|
733 |
+
user-select: none;
|
734 |
+
|
735 |
+
&:hover {
|
736 |
+
border-color:#b0b0b0;
|
737 |
+
background: #fff;
|
738 |
+
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
739 |
+
|
740 |
+
.fa {
|
741 |
+
color: #333;
|
742 |
+
}
|
743 |
+
}
|
744 |
+
|
745 |
+
.fa {
|
746 |
+
color: #555;
|
747 |
+
}
|
748 |
+
}
|
749 |
+
|
750 |
+
.CodeMirror-lint-tooltip,
|
751 |
+
.CodeMirror-hints {
|
752 |
+
/* This is above the editor in full-screen mode */
|
753 |
+
z-index: 100002;
|
754 |
+
}
|
css/images/icon.png
ADDED
Binary file
|
css/images/separator.png
ADDED
Binary file
|
css/images/video.jpg
ADDED
Binary file
|
css/inspector.css
ADDED
@@ -0,0 +1,199 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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left: 0;
|
6 |
+
right: 0;
|
7 |
+
height: 220px;
|
8 |
+
background: #ffffff;
|
9 |
+
box-shadow: 0 -2px 2px rgba(0, 0, 0, 0.05);
|
10 |
+
z-index: 100000;
|
11 |
+
font-family: "Arial", sans-serif;
|
12 |
+
font-size: 14px;
|
13 |
+
border-top: 1px solid #a3a3a3;
|
14 |
+
}
|
15 |
+
#socss-inspector-interface .socss-toolbar {
|
16 |
+
box-sizing: border-box;
|
17 |
+
background: #e6e6e6;
|
18 |
+
padding: 0 4px;
|
19 |
+
user-select: none;
|
20 |
+
position: absolute;
|
21 |
+
top: 0;
|
22 |
+
left: 0;
|
23 |
+
right: 0;
|
24 |
+
height: 30px;
|
25 |
+
overflow: hidden;
|
26 |
+
}
|
27 |
+
#socss-inspector-interface .socss-toolbar .socss-enable-inspector {
|
28 |
+
font-size: 20px;
|
29 |
+
display: inline-block;
|
30 |
+
padding: 5px;
|
31 |
+
color: #777;
|
32 |
+
border-left: 1px solid transparent;
|
33 |
+
border-right: 1px solid transparent;
|
34 |
+
position: absolute;
|
35 |
+
top: 0;
|
36 |
+
left: 5px;
|
37 |
+
bottom: 0;
|
38 |
+
height: 30px;
|
39 |
+
width: 30px;
|
40 |
+
box-sizing: border-box;
|
41 |
+
}
|
42 |
+
#socss-inspector-interface .socss-toolbar .socss-enable-inspector:hover {
|
43 |
+
cursor: pointer;
|
44 |
+
background-color: #f3f3f3;
|
45 |
+
color: #596872;
|
46 |
+
}
|
47 |
+
#socss-inspector-interface .socss-toolbar .socss-hierarchy {
|
48 |
+
position: absolute;
|
49 |
+
top: 0;
|
50 |
+
right: 20px;
|
51 |
+
left: 40px;
|
52 |
+
bottom: 0;
|
53 |
+
display: block;
|
54 |
+
padding-left: 10px;
|
55 |
+
overflow: hidden;
|
56 |
+
white-space: nowrap;
|
57 |
+
background: #e6e6e6;
|
58 |
+
}
|
59 |
+
#socss-inspector-interface .socss-toolbar .socss-hierarchy .socss-selector {
|
60 |
+
font-size: 12px;
|
61 |
+
line-height: 1em;
|
62 |
+
padding: 9px 20px 9px 9px;
|
63 |
+
display: inline-block;
|
64 |
+
background: url(images/separator.png) top right no-repeat;
|
65 |
+
background-size: contain;
|
66 |
+
cursor: pointer;
|
67 |
+
}
|
68 |
+
#socss-inspector-interface .socss-toolbar .socss-hierarchy .socss-selector:last-child {
|
69 |
+
background: none;
|
70 |
+
padding-right: 9px;
|
71 |
+
}
|
72 |
+
#socss-inspector-interface .socss-selectors-window,
|
73 |
+
#socss-inspector-interface .socss-properties-window {
|
74 |
+
overflow-y: scroll;
|
75 |
+
font-family: "Courier New", "Lucida Console", Courier, monospace;
|
76 |
+
font-size: 13px;
|
77 |
+
border-top: 1px solid #a3a3a3;
|
78 |
+
}
|
79 |
+
#socss-inspector-interface .socss-selectors-window > div,
|
80 |
+
#socss-inspector-interface .socss-properties-window > div {
|
81 |
+
line-height: 1.2em;
|
82 |
+
padding: 4px 10px;
|
83 |
+
white-space: nowrap;
|
84 |
+
}
|
85 |
+
#socss-inspector-interface .socss-selectors-window > div:hover,
|
86 |
+
#socss-inspector-interface .socss-properties-window > div:hover {
|
87 |
+
background: #f6f6f6;
|
88 |
+
cursor: pointer;
|
89 |
+
}
|
90 |
+
#socss-inspector-interface .socss-selectors-window strong,
|
91 |
+
#socss-inspector-interface .socss-properties-window strong {
|
92 |
+
font-weight: bold;
|
93 |
+
}
|
94 |
+
#socss-inspector-interface .socss-selectors-window {
|
95 |
+
position: absolute;
|
96 |
+
top: 29px;
|
97 |
+
left: 0;
|
98 |
+
right: 50%;
|
99 |
+
bottom: 0;
|
100 |
+
background: #fff;
|
101 |
+
border-right: 1px solid #aaa;
|
102 |
+
}
|
103 |
+
#socss-inspector-interface .socss-properties-window {
|
104 |
+
position: absolute;
|
105 |
+
top: 29px;
|
106 |
+
right: 0;
|
107 |
+
left: 50%;
|
108 |
+
bottom: 0;
|
109 |
+
background: #fff;
|
110 |
+
}
|
111 |
+
body.socss-active {
|
112 |
+
padding-bottom: 200px !important;
|
113 |
+
}
|
114 |
+
body.socss-active #socss-inspector-interface {
|
115 |
+
display: block;
|
116 |
+
height: 200px;
|
117 |
+
}
|
118 |
+
body.socss-active #socss-inspector-interface .socss-toolbar .socss-enable-inspector {
|
119 |
+
border-left: 1px solid #aaa;
|
120 |
+
border-right: 1px solid #aaa;
|
121 |
+
background-color: #f3f3f3;
|
122 |
+
color: #005a67;
|
123 |
+
}
|
124 |
+
body.socss-inactive {
|
125 |
+
padding-bottom: 29px !important;
|
126 |
+
}
|
127 |
+
body.socss-inactive #socss-inspector-interface {
|
128 |
+
display: block;
|
129 |
+
height: 29px;
|
130 |
+
}
|
131 |
+
body.socss-inactive #socss-inspector-interface .socss-selectors-window,
|
132 |
+
body.socss-inactive #socss-inspector-interface .socss-attributes-window {
|
133 |
+
display: none;
|
134 |
+
}
|
135 |
+
.socss-inspector-hover {
|
136 |
+
pointer-events: none;
|
137 |
+
position: absolute;
|
138 |
+
/* Same index as the admin bar */
|
139 |
+
z-index: 99999;
|
140 |
+
border: 1px dashed #0075cb;
|
141 |
+
background: rgba(0, 117, 203, 0.15);
|
142 |
+
box-sizing: border-box;
|
143 |
+
}
|
144 |
+
.socss-inspector-hover .socss-guide {
|
145 |
+
display: none;
|
146 |
+
}
|
147 |
+
.socss-inspector-hover .socss-guide-margin,
|
148 |
+
.socss-inspector-hover .socss-guide-padding {
|
149 |
+
position: absolute;
|
150 |
+
}
|
151 |
+
.socss-inspector-hover .socss-guide-margin.socss-guide-top,
|
152 |
+
.socss-inspector-hover .socss-guide-padding.socss-guide-top,
|
153 |
+
.socss-inspector-hover .socss-guide-margin.socss-guide-bottom,
|
154 |
+
.socss-inspector-hover .socss-guide-padding.socss-guide-bottom {
|
155 |
+
right: 0;
|
156 |
+
left: 0;
|
157 |
+
}
|
158 |
+
.socss-inspector-hover .socss-guide-margin.socss-guide-left,
|
159 |
+
.socss-inspector-hover .socss-guide-padding.socss-guide-left,
|
160 |
+
.socss-inspector-hover .socss-guide-margin.socss-guide-right,
|
161 |
+
.socss-inspector-hover .socss-guide-padding.socss-guide-right {
|
162 |
+
top: 0;
|
163 |
+
bottom: 0;
|
164 |
+
}
|
165 |
+
.socss-inspector-hover .socss-guide-margin {
|
166 |
+
background: rgba(20, 126, 74, 0.25);
|
167 |
+
}
|
168 |
+
.socss-inspector-hover .socss-guide-margin.socss-guide-top {
|
169 |
+
bottom: 100%;
|
170 |
+
}
|
171 |
+
.socss-inspector-hover .socss-guide-margin.socss-guide-bottom {
|
172 |
+
top: 100%;
|
173 |
+
}
|
174 |
+
.socss-inspector-hover .socss-guide-margin.socss-guide-left {
|
175 |
+
right: 100%;
|
176 |
+
}
|
177 |
+
.socss-inspector-hover .socss-guide-margin.socss-guide-right {
|
178 |
+
left: 100%;
|
179 |
+
}
|
180 |
+
.socss-inspector-hover .socss-guide-padding {
|
181 |
+
background: rgba(0, 117, 203, 0.25);
|
182 |
+
}
|
183 |
+
.socss-inspector-hover .socss-guide-padding.socss-guide-top {
|
184 |
+
top: 0;
|
185 |
+
}
|
186 |
+
.socss-inspector-hover .socss-guide-padding.socss-guide-bottom {
|
187 |
+
bottom: 0;
|
188 |
+
}
|
189 |
+
.socss-inspector-hover .socss-guide-padding.socss-guide-left {
|
190 |
+
left: 0;
|
191 |
+
}
|
192 |
+
.socss-inspector-hover .socss-guide-padding.socss-guide-right {
|
193 |
+
right: 0;
|
194 |
+
}
|
195 |
+
body,
|
196 |
+
html {
|
197 |
+
max-width: 100% !important;
|
198 |
+
overflow-x: hidden !important;
|
199 |
+
}
|
css/inspector.less
ADDED
@@ -0,0 +1,236 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
#socss-inspector-interface {
|
2 |
+
display: none;
|
3 |
+
position: fixed;
|
4 |
+
bottom: 0;
|
5 |
+
left: 0;
|
6 |
+
right: 0;
|
7 |
+
height: 220px;
|
8 |
+
background: #ffffff;
|
9 |
+
box-shadow: 0 -2px 2px rgba(0,0,0,0.05);
|
10 |
+
z-index: 99999 + 1;
|
11 |
+
|
12 |
+
font-family: "Arial", sans-serif;
|
13 |
+
font-size: 14px;
|
14 |
+
border-top: 1px solid #a3a3a3;
|
15 |
+
|
16 |
+
.socss-toolbar {
|
17 |
+
box-sizing: border-box;
|
18 |
+
background: #e6e6e6;
|
19 |
+
padding: 0 4px;
|
20 |
+
user-select: none;
|
21 |
+
position: absolute;
|
22 |
+
top: 0;
|
23 |
+
left: 0;
|
24 |
+
right: 0;
|
25 |
+
height: 30px;
|
26 |
+
overflow: hidden;
|
27 |
+
|
28 |
+
.socss-enable-inspector {
|
29 |
+
font-size: 20px;
|
30 |
+
display: inline-block;
|
31 |
+
padding: 5px;
|
32 |
+
color: #777;
|
33 |
+
border-left: 1px solid transparent;
|
34 |
+
border-right: 1px solid transparent;
|
35 |
+
position: absolute;
|
36 |
+
top: 0;
|
37 |
+
left: 5px;
|
38 |
+
bottom: 0;
|
39 |
+
|
40 |
+
height: 30px;
|
41 |
+
width: 30px;
|
42 |
+
|
43 |
+
box-sizing: border-box;
|
44 |
+
|
45 |
+
&:hover {
|
46 |
+
cursor: pointer;
|
47 |
+
background-color: #f3f3f3;
|
48 |
+
color: #596872;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
.socss-hierarchy {
|
53 |
+
position: absolute;
|
54 |
+
top: 0;
|
55 |
+
right: 20px;
|
56 |
+
left: 40px;
|
57 |
+
bottom: 0;
|
58 |
+
display: block;
|
59 |
+
padding-left: 10px;
|
60 |
+
overflow: hidden;
|
61 |
+
white-space: nowrap;
|
62 |
+
background: #e6e6e6;
|
63 |
+
|
64 |
+
.socss-selector {
|
65 |
+
font-size: 12px;
|
66 |
+
line-height: 1em;
|
67 |
+
padding: 9px 20px 9px 9px;
|
68 |
+
display: inline-block;
|
69 |
+
background: url(./images/separator.png) top right no-repeat;
|
70 |
+
background-size: contain;
|
71 |
+
cursor: pointer;
|
72 |
+
|
73 |
+
&:last-child {
|
74 |
+
background: none;
|
75 |
+
padding-right: 9px;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
.socss-selectors-window,
|
83 |
+
.socss-properties-window {
|
84 |
+
overflow-y: scroll;
|
85 |
+
font-family: "Courier New", "Lucida Console", Courier, monospace;
|
86 |
+
font-size: 13px;
|
87 |
+
border-top: 1px solid #a3a3a3;
|
88 |
+
|
89 |
+
> div {
|
90 |
+
line-height: 1.2em;
|
91 |
+
padding: 4px 10px;
|
92 |
+
white-space: nowrap;
|
93 |
+
|
94 |
+
&:hover {
|
95 |
+
background: #f6f6f6;
|
96 |
+
cursor: pointer;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
strong{
|
101 |
+
font-weight: bold;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
.socss-selectors-window {
|
106 |
+
position: absolute;
|
107 |
+
top: 29px;
|
108 |
+
left: 0;
|
109 |
+
right: 50%;
|
110 |
+
bottom: 0;
|
111 |
+
|
112 |
+
background: #fff;
|
113 |
+
border-right: 1px solid #aaa;
|
114 |
+
}
|
115 |
+
|
116 |
+
.socss-properties-window {
|
117 |
+
position: absolute;
|
118 |
+
top: 29px;
|
119 |
+
right: 0;
|
120 |
+
left: 50%;
|
121 |
+
bottom: 0;
|
122 |
+
|
123 |
+
background: #fff;
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
body.socss-active {
|
128 |
+
padding-bottom: 200px !important;
|
129 |
+
|
130 |
+
#socss-inspector-interface {
|
131 |
+
display: block;
|
132 |
+
height: 200px;
|
133 |
+
|
134 |
+
.socss-toolbar .socss-enable-inspector {
|
135 |
+
border-left: 1px solid #aaa;
|
136 |
+
border-right: 1px solid #aaa;
|
137 |
+
background-color: #f3f3f3;
|
138 |
+
color: #005a67;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
body.socss-inactive {
|
144 |
+
padding-bottom: 29px !important;
|
145 |
+
|
146 |
+
#socss-inspector-interface {
|
147 |
+
display: block;
|
148 |
+
height: 29px;
|
149 |
+
|
150 |
+
.socss-selectors-window,
|
151 |
+
.socss-attributes-window {
|
152 |
+
display: none;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
.socss-inspector-hover {
|
158 |
+
pointer-events: none;
|
159 |
+
position: absolute;
|
160 |
+
|
161 |
+
/* Same index as the admin bar */
|
162 |
+
z-index: 99999;
|
163 |
+
|
164 |
+
border: 1px dashed rgba(0,117,203,1);
|
165 |
+
background: rgba(0,117,203,0.15);
|
166 |
+
|
167 |
+
box-sizing: border-box;
|
168 |
+
|
169 |
+
.socss-guide {
|
170 |
+
display: none;
|
171 |
+
}
|
172 |
+
|
173 |
+
.socss-guide-margin,
|
174 |
+
.socss-guide-padding {
|
175 |
+
position: absolute;
|
176 |
+
|
177 |
+
&.socss-guide-top,
|
178 |
+
&.socss-guide-bottom {
|
179 |
+
right: 0;
|
180 |
+
left: 0;
|
181 |
+
}
|
182 |
+
|
183 |
+
&.socss-guide-left,
|
184 |
+
&.socss-guide-right {
|
185 |
+
top: 0;
|
186 |
+
bottom: 0;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
.socss-guide-margin {
|
191 |
+
|
192 |
+
background: rgba(20,126,74,0.25);
|
193 |
+
|
194 |
+
&.socss-guide-top {
|
195 |
+
bottom: 100%;
|
196 |
+
}
|
197 |
+
|
198 |
+
&.socss-guide-bottom {
|
199 |
+
top: 100%;
|
200 |
+
}
|
201 |
+
|
202 |
+
&.socss-guide-left {
|
203 |
+
right: 100%;
|
204 |
+
}
|
205 |
+
|
206 |
+
&.socss-guide-right {
|
207 |
+
left: 100%;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
.socss-guide-padding {
|
212 |
+
|
213 |
+
background: rgba(0,117,203,0.25);
|
214 |
+
|
215 |
+
&.socss-guide-top {
|
216 |
+
top: 0;
|
217 |
+
}
|
218 |
+
|
219 |
+
&.socss-guide-bottom {
|
220 |
+
bottom: 0;
|
221 |
+
}
|
222 |
+
|
223 |
+
&.socss-guide-left {
|
224 |
+
left: 0;
|
225 |
+
}
|
226 |
+
|
227 |
+
&.socss-guide-right {
|
228 |
+
right: 0;
|
229 |
+
}
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
body, html {
|
234 |
+
max-width: 100% !important;
|
235 |
+
overflow-x: hidden !important;
|
236 |
+
}
|
css/mixins.css
ADDED
File without changes
|
css/mixins.less
ADDED
@@ -0,0 +1,189 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
.gradient(@color: #F5F5F5, @start: #EEE, @stop: #FFF) {
|
2 |
+
background: @color;
|
3 |
+
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, @start), color-stop(1, @stop));
|
4 |
+
background: -ms-linear-gradient(bottom,@start,@stop);
|
5 |
+
background: -moz-linear-gradient(center bottom,@start 0%,@stop 100%);
|
6 |
+
background: -o-linear-gradient(@stop,@start);
|
7 |
+
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)", @stop, @start));
|
8 |
+
}
|
9 |
+
|
10 |
+
.bw-gradient(@color: #F5F5F5, @start: 0, @stop: 255) {
|
11 |
+
background: @color;
|
12 |
+
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, rgb(@start,@start,@start)), color-stop(1, rgb(@stop,@stop,@stop)));
|
13 |
+
background: -ms-linear-gradient(bottom, rgb(@start,@start,@start) 0%, rgb(@stop,@stop,@stop) 100%);
|
14 |
+
background: -moz-linear-gradient(center bottom, rgb(@start,@start,@start) 0%, rgb(@stop,@stop,@stop) 100%);
|
15 |
+
background: -o-linear-gradient(rgb(@stop,@stop,@stop), rgb(@start,@start,@start));
|
16 |
+
background: linear-gradient(rgb(@stop,@stop,@stop), rgb(@start,@start,@start));
|
17 |
+
|
18 |
+
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",rgb(@stop,@stop,@stop), rgb(@start,@start,@start)));
|
19 |
+
}
|
20 |
+
|
21 |
+
.linear-gradient(@color, @gradient) {
|
22 |
+
background: @color;
|
23 |
+
background: -moz-linear-gradient(@gradient);
|
24 |
+
background: -webkit-linear-gradient(@gradient);
|
25 |
+
background: -o-linear-gradient(@gradient);
|
26 |
+
background: -ms-linear-gradient(@gradient);
|
27 |
+
background: linear-gradient(@gradient);
|
28 |
+
}
|
29 |
+
|
30 |
+
.bordered(@top-color: #EEE, @right-color: #EEE, @bottom-color: #EEE, @left-color: #EEE) {
|
31 |
+
border-top: solid 1px @top-color;
|
32 |
+
border-left: solid 1px @left-color;
|
33 |
+
border-right: solid 1px @right-color;
|
34 |
+
border-bottom: solid 1px @bottom-color;
|
35 |
+
}
|
36 |
+
|
37 |
+
.drop-shadow(@x-axis: 0, @y-axis: 1px, @blur: 2px, @alpha: 0.1) {
|
38 |
+
-webkit-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
|
39 |
+
-moz-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
|
40 |
+
box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
|
41 |
+
}
|
42 |
+
|
43 |
+
.box-shadow(@shadow) {
|
44 |
+
-webkit-box-shadow: @shadow;
|
45 |
+
-moz-box-shadow: @shadow;
|
46 |
+
box-shadow: @shadow;
|
47 |
+
}
|
48 |
+
|
49 |
+
.rounded(@radius: 2px) {
|
50 |
+
-webkit-border-radius: @radius;
|
51 |
+
-moz-border-radius: @radius;
|
52 |
+
border-radius: @radius;
|
53 |
+
}
|
54 |
+
|
55 |
+
.border-radius(@topright: 0, @bottomright: 0, @bottomleft: 0, @topleft: 0) {
|
56 |
+
-webkit-border-top-right-radius: @topright;
|
57 |
+
-webkit-border-bottom-right-radius: @bottomright;
|
58 |
+
-webkit-border-bottom-left-radius: @bottomleft;
|
59 |
+
-webkit-border-top-left-radius: @topleft;
|
60 |
+
-moz-border-radius-topright: @topright;
|
61 |
+
-moz-border-radius-bottomright: @bottomright;
|
62 |
+
-moz-border-radius-bottomleft: @bottomleft;
|
63 |
+
-moz-border-radius-topleft: @topleft;
|
64 |
+
border-top-right-radius: @topright;
|
65 |
+
border-bottom-right-radius: @bottomright;
|
66 |
+
border-bottom-left-radius: @bottomleft;
|
67 |
+
border-top-left-radius: @topleft;
|
68 |
+
.background-clip(padding-box);
|
69 |
+
}
|
70 |
+
|
71 |
+
.opacity(@opacity: 0.5) {
|
72 |
+
-moz-opacity: @opacity;
|
73 |
+
-khtml-opacity: @opacity;
|
74 |
+
-webkit-opacity: @opacity;
|
75 |
+
opacity: @opacity;
|
76 |
+
@opperc: @opacity * 100;
|
77 |
+
-ms-filter: ~"progid:DXImageTransform.Microsoft.Alpha(opacity=@{opperc})";
|
78 |
+
filter: ~"alpha(opacity=@{opperc})";
|
79 |
+
}
|
80 |
+
|
81 |
+
.transition-duration(@duration: 0.2s) {
|
82 |
+
-moz-transition-duration: @duration;
|
83 |
+
-webkit-transition-duration: @duration;
|
84 |
+
-o-transition-duration: @duration;
|
85 |
+
transition-duration: @duration;
|
86 |
+
}
|
87 |
+
|
88 |
+
.transform(...) {
|
89 |
+
-webkit-transform: @arguments;
|
90 |
+
-moz-transform: @arguments;
|
91 |
+
-o-transform: @arguments;
|
92 |
+
-ms-transform: @arguments;
|
93 |
+
transform: @arguments;
|
94 |
+
}
|
95 |
+
|
96 |
+
.rotation(@deg:5deg) {
|
97 |
+
.transform(rotate(@deg));
|
98 |
+
}
|
99 |
+
|
100 |
+
.scale(@ratio:1.5) {
|
101 |
+
.transform(scale(@ratio));
|
102 |
+
}
|
103 |
+
|
104 |
+
.transition(@duration:0.2s, @on: all, @ease:ease) {
|
105 |
+
-webkit-transition: @on @duration @ease;
|
106 |
+
-moz-transition: @on @duration @ease;
|
107 |
+
-o-transition: @on @duration @ease;
|
108 |
+
transition: @on @duration @ease;
|
109 |
+
}
|
110 |
+
|
111 |
+
.inner-shadow(@horizontal:0, @vertical:1px, @blur:2px, @alpha: 0.4) {
|
112 |
+
-webkit-box-shadow: inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);
|
113 |
+
-moz-box-shadow: inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);
|
114 |
+
box-shadow: inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);
|
115 |
+
}
|
116 |
+
|
117 |
+
.box-sizing(@sizing: border-box) {
|
118 |
+
-ms-box-sizing: @sizing;
|
119 |
+
-moz-box-sizing: @sizing;
|
120 |
+
-webkit-box-sizing: @sizing;
|
121 |
+
box-sizing: @sizing;
|
122 |
+
}
|
123 |
+
|
124 |
+
.user-select(@argument: none) {
|
125 |
+
-webkit-user-select: @argument;
|
126 |
+
-moz-user-select: @argument;
|
127 |
+
-ms-user-select: @argument;
|
128 |
+
user-select: @argument;
|
129 |
+
}
|
130 |
+
|
131 |
+
.columns(@colwidth: 250px, @colcount: 0, @colgap: 50px, @columnRuleColor: #EEE, @columnRuleStyle: solid, @columnRuleWidth: 1px) {
|
132 |
+
-moz-column-width: @colwidth;
|
133 |
+
-moz-column-count: @colcount;
|
134 |
+
-moz-column-gap: @colgap;
|
135 |
+
-moz-column-rule-color: @columnRuleColor;
|
136 |
+
-moz-column-rule-style: @columnRuleStyle;
|
137 |
+
-moz-column-rule-width: @columnRuleWidth;
|
138 |
+
-webkit-column-width: @colwidth;
|
139 |
+
-webkit-column-count: @colcount;
|
140 |
+
-webkit-column-gap: @colgap;
|
141 |
+
-webkit-column-rule-color: @columnRuleColor;
|
142 |
+
-webkit-column-rule-style: @columnRuleStyle;
|
143 |
+
-webkit-column-rule-width: @columnRuleWidth;
|
144 |
+
column-width: @colwidth;
|
145 |
+
column-count: @colcount;
|
146 |
+
column-gap: @colgap;
|
147 |
+
column-rule-color: @columnRuleColor;
|
148 |
+
column-rule-style: @columnRuleStyle;
|
149 |
+
column-rule-width: @columnRuleWidth;
|
150 |
+
}
|
151 |
+
|
152 |
+
.translate(@x:0, @y:0) {
|
153 |
+
.transform(translate(@x, @y));
|
154 |
+
}
|
155 |
+
|
156 |
+
.background-clip(@argument: padding-box) {
|
157 |
+
-moz-background-clip: @argument;
|
158 |
+
-webkit-background-clip: @argument;
|
159 |
+
background-clip: @argument;
|
160 |
+
}
|
161 |
+
|
162 |
+
.clearfix() {
|
163 |
+
zoom: 1;
|
164 |
+
&:before {
|
165 |
+
content: '';
|
166 |
+
display: block;
|
167 |
+
}
|
168 |
+
&:after {
|
169 |
+
content: '';
|
170 |
+
display: table;
|
171 |
+
clear: both;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
.button-style(@base_color, @bg_var: 3.5%, @border_darken: 18%, @border_var: 4%) {
|
176 |
+
@gradient_start: darken(@base_color, @bg_var);
|
177 |
+
@gradient_end: lighten(@base_color, @bg_var);
|
178 |
+
|
179 |
+
@border_color: darken(@base_color, @border_darken);
|
180 |
+
|
181 |
+
@border_top: lighten(@border_color, @border_var );
|
182 |
+
@border_bottom: darken(@border_color, @border_var );
|
183 |
+
|
184 |
+
.gradient(@base_color, @gradient_start, @gradient_end);
|
185 |
+
.bordered(@border_top, @border_color, @border_bottom, @border_color);
|
186 |
+
}
|
187 |
+
|
188 |
+
//this is to remove annoying IDE warnings for not being able to resolve .widget-function() calls
|
189 |
+
.widget-function(...){}
|
inc/controller-config.php
ADDED
@@ -0,0 +1,504 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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+
<?php
|
2 |
+
|
3 |
+
return array (
|
4 |
+
'text' => array(
|
5 |
+
'title' => __('Text', 'so-css'),
|
6 |
+
'icon' => 'align-left',
|
7 |
+
'controllers' => array(
|
8 |
+
array(
|
9 |
+
'title' => __('Text Color', 'so-css'),
|
10 |
+
'type' => 'color',
|
11 |
+
'args' => array(
|
12 |
+
'property' => 'color'
|
13 |
+
)
|
14 |
+
),
|
15 |
+
array(
|
16 |
+
'title' => __('Font Size', 'so-css'),
|
17 |
+
'type' => 'measurement',
|
18 |
+
'args' => array(
|
19 |
+
'property' => 'font-size',
|
20 |
+
'defaultUnit' => 'px',
|
21 |
+
)
|
22 |
+
),
|
23 |
+
array(
|
24 |
+
'title' => __('Line Height', 'so-css'),
|
25 |
+
'type' => 'measurement',
|
26 |
+
'args' => array(
|
27 |
+
'property' => 'line-height',
|
28 |
+
'defaultUnit' => 'em',
|
29 |
+
)
|
30 |
+
),
|
31 |
+
array(
|
32 |
+
'title' => __('Font Weight', 'so-css'),
|
33 |
+
'type' => 'select',
|
34 |
+
'args' => array(
|
35 |
+
'property' => 'font-weight',
|
36 |
+
'options' => array(
|
37 |
+
'normal' => __('Normal', 'so-css'),
|
38 |
+
'bold' => __('Bold', 'so-css'),
|
39 |
+
'bolder' => __('Bolder', 'so-css'),
|
40 |
+
'lighter' => __('Lighter', 'so-css'),
|
41 |
+
'100' => '100',
|
42 |
+
'200' => '200',
|
43 |
+
'300' => '300',
|
44 |
+
'400' => '400',
|
45 |
+
'500' => '500',
|
46 |
+
'600' => '600',
|
47 |
+
'700' => '700',
|
48 |
+
'800' => '800',
|
49 |
+
'900' => '900',
|
50 |
+
)
|
51 |
+
)
|
52 |
+
),
|
53 |
+
array(
|
54 |
+
'title' => __('Font Style', 'so-css'),
|
55 |
+
'type' => 'select',
|
56 |
+
'args' => array(
|
57 |
+
'property' => 'font-style',
|
58 |
+
'options' => array(
|
59 |
+
'none' => __('None', 'so-css'),
|
60 |
+
'normal' => __('Normal', 'so-css'),
|
61 |
+
'italic' => __('Italic', 'so-css'),
|
62 |
+
),
|
63 |
+
'option_icons' => array(
|
64 |
+
'normal' => 'font',
|
65 |
+
'italic' => 'italic',
|
66 |
+
)
|
67 |
+
)
|
68 |
+
),
|
69 |
+
array(
|
70 |
+
'title' => __('Text Decoration', 'so-css'),
|
71 |
+
'type' => 'select',
|
72 |
+
'args' => array(
|
73 |
+
'property' => 'text-decoration',
|
74 |
+
'options' => array(
|
75 |
+
'none' => __('None', 'so-css'),
|
76 |
+
'underline' => __('Underline', 'so-css'),
|
77 |
+
'overline' => __('Overline', 'so-css'),
|
78 |
+
'line-through' => __('Line Through', 'so-css'),
|
79 |
+
),
|
80 |
+
'option_icons' => array(
|
81 |
+
'none' => 'font',
|
82 |
+
'underline' => 'underline',
|
83 |
+
'line-through' => 'strikethrough',
|
84 |
+
)
|
85 |
+
)
|
86 |
+
),
|
87 |
+
array(
|
88 |
+
'title' => __('Font Variant', 'so-css'),
|
89 |
+
'type' => 'select',
|
90 |
+
'args' => array(
|
91 |
+
'property' => 'font-variant',
|
92 |
+
'options' => array(
|
93 |
+
'normal' => __('Normal', 'so-css'),
|
94 |
+
'small-caps' => __('Small Caps', 'so-css'),
|
95 |
+
)
|
96 |
+
)
|
97 |
+
),
|
98 |
+
array(
|
99 |
+
'title' => __('Text Transform', 'so-css'),
|
100 |
+
'type' => 'select',
|
101 |
+
'args' => array(
|
102 |
+
'property' => 'text-transform',
|
103 |
+
'options' => array(
|
104 |
+
'none' => __('None', 'so-css'),
|
105 |
+
'capitalize' => __('Capitalize', 'so-css'),
|
106 |
+
'uppercase' => __('Uppercase', 'so-css'),
|
107 |
+
'lowercase' => __('Lowercase', 'so-css'),
|
108 |
+
)
|
109 |
+
)
|
110 |
+
),
|
111 |
+
array(
|
112 |
+
'title' => __('Font Family', 'so-css'),
|
113 |
+
'type' => 'font-select',
|
114 |
+
'args' => array(
|
115 |
+
'property' => 'font-family',
|
116 |
+
)
|
117 |
+
),
|
118 |
+
array(
|
119 |
+
'title' => __('Text Align', 'so-css'),
|
120 |
+
'type' => 'select',
|
121 |
+
'args' => array(
|
122 |
+
'property' => 'text-align',
|
123 |
+
'options' => array(
|
124 |
+
'left' => __('Left', 'so-css'),
|
125 |
+
'right' => __('Right', 'so-css'),
|
126 |
+
'center' => __('Center', 'so-css'),
|
127 |
+
'justify' => __('Justify', 'so-css'),
|
128 |
+
),
|
129 |
+
'option_icons' => array(
|
130 |
+
'left' => 'align-left',
|
131 |
+
'right' => 'align-right',
|
132 |
+
'center' => 'align-center',
|
133 |
+
'justify' => 'align-justify',
|
134 |
+
)
|
135 |
+
)
|
136 |
+
),
|
137 |
+
array(
|
138 |
+
'title' => __('Text Indent', 'so-css'),
|
139 |
+
'type' => 'measurement',
|
140 |
+
'args' => array(
|
141 |
+
'property' => 'text-indent'
|
142 |
+
)
|
143 |
+
),
|
144 |
+
array(
|
145 |
+
'title' => __('Letter Spacing', 'so-css'),
|
146 |
+
'type' => 'measurement',
|
147 |
+
'args' => array(
|
148 |
+
'property' => 'letter-spacing'
|
149 |
+
)
|
150 |
+
),
|
151 |
+
array(
|
152 |
+
'title' => __('Word Spacing', 'so-css'),
|
153 |
+
'type' => 'measurement',
|
154 |
+
'args' => array(
|
155 |
+
'property' => 'word-spacing'
|
156 |
+
)
|
157 |
+
),
|
158 |
+
array(
|
159 |
+
'title' => __('White Space', 'so-css'),
|
160 |
+
'type' => 'select',
|
161 |
+
'args' => array(
|
162 |
+
'property' => 'white-space',
|
163 |
+
'options' => array(
|
164 |
+
'normal' => __('Normal', 'so-css'),
|
165 |
+
'encountered' => __('Encountered', 'so-css'),
|
166 |
+
'pre' => __('Pre', 'so-css'),
|
167 |
+
'pre-line' => __('Pre Line', 'so-css'),
|
168 |
+
'pre-wrap' => __('Pre Wrap', 'so-css'),
|
169 |
+
)
|
170 |
+
)
|
171 |
+
),
|
172 |
+
array(
|
173 |
+
'title' => __('Text Shadow', 'so-css'),
|
174 |
+
'type' => 'shadow',
|
175 |
+
'args' => array(
|
176 |
+
'property' => 'text-shadow',
|
177 |
+
)
|
178 |
+
),
|
179 |
+
)
|
180 |
+
),
|
181 |
+
|
182 |
+
//////////////////////////////////////////////////////////////////////
|
183 |
+
|
184 |
+
'decoration' => array(
|
185 |
+
'title' => __('Decoration', 'so-css'),
|
186 |
+
'icon' => 'eyedropper',
|
187 |
+
'controllers' => array(
|
188 |
+
array(
|
189 |
+
'title' => __('Background Color', 'so-css'),
|
190 |
+
'type' => 'color',
|
191 |
+
'args' => array(
|
192 |
+
'property' => 'background-color'
|
193 |
+
)
|
194 |
+
),
|
195 |
+
array(
|
196 |
+
'title' => __('Background image', 'so-css'),
|
197 |
+
'type' => 'image',
|
198 |
+
'args' => array(
|
199 |
+
'property' => 'background-image',
|
200 |
+
'value' => 'url("{{url}}")',
|
201 |
+
)
|
202 |
+
),
|
203 |
+
array(
|
204 |
+
'title' => __('Background Position', 'so-css'),
|
205 |
+
'type' => 'position',
|
206 |
+
'args' => array(
|
207 |
+
'property' => 'background-position'
|
208 |
+
)
|
209 |
+
),
|
210 |
+
array(
|
211 |
+
'title' => __('Background Repeat', 'so-css'),
|
212 |
+
'type' => 'select',
|
213 |
+
'args' => array(
|
214 |
+
'property' => 'background-repeat',
|
215 |
+
'options' => array(
|
216 |
+
'repeat' => __( 'repeat', 'so-css' ),
|
217 |
+
'repeat-x' => __( 'repeat-x', 'so-css' ),
|
218 |
+
'repeat-y' => __( 'repeat-y', 'so-css' ),
|
219 |
+
'no-repeat' => __( 'no-repeat', 'so-css' ),
|
220 |
+
)
|
221 |
+
)
|
222 |
+
),
|
223 |
+
array(
|
224 |
+
'title' => __('Background Size', 'so-css'),
|
225 |
+
'type' => 'select',
|
226 |
+
'args' => array(
|
227 |
+
'property' => 'background-size',
|
228 |
+
'options' => array(
|
229 |
+
'auto' => __( 'auto', 'so-css' ),
|
230 |
+
'length' => __( 'length', 'so-css' ),
|
231 |
+
'percentage' => __( 'percentage', 'so-css' ),
|
232 |
+
'cover' => __( 'cover', 'so-css' ),
|
233 |
+
'contain' => __( 'contain', 'so-css' ),
|
234 |
+
)
|
235 |
+
)
|
236 |
+
),
|
237 |
+
|
238 |
+
array(
|
239 |
+
'title' => __('Box Shadow', 'so-css'),
|
240 |
+
'type' => 'shadow',
|
241 |
+
'args' => array(
|
242 |
+
'property' => 'box-shadow',
|
243 |
+
)
|
244 |
+
),
|
245 |
+
|
246 |
+
array(
|
247 |
+
'title' => __('Opacity', 'so-css'),
|
248 |
+
'type' => 'number',
|
249 |
+
'args' => array(
|
250 |
+
'property' => 'opacity',
|
251 |
+
'default' => 1,
|
252 |
+
'min' => 0,
|
253 |
+
'max' => 1,
|
254 |
+
'increment' => 0.05,
|
255 |
+
'decrement' => -0.05,
|
256 |
+
)
|
257 |
+
),
|
258 |
+
|
259 |
+
array(
|
260 |
+
'title' => __('Borders', 'so-css'),
|
261 |
+
'type' => 'sides',
|
262 |
+
'args' => array(
|
263 |
+
'controllers' => array(
|
264 |
+
array(
|
265 |
+
'type' => 'measurement',
|
266 |
+
'args' => array(
|
267 |
+
'property' => 'border-{dir}-width',
|
268 |
+
'propertyAll' => 'border-width',
|
269 |
+
'defaultUnit' => 'px'
|
270 |
+
)
|
271 |
+
),
|
272 |
+
array(
|
273 |
+
'type' => 'select',
|
274 |
+
'args' => array(
|
275 |
+
'property' => 'border-{dir}-style',
|
276 |
+
'propertyAll' => 'border-style',
|
277 |
+
'options' => array(
|
278 |
+
'hidden' => 'Hidden',
|
279 |
+
'dotted' => 'Dotted',
|
280 |
+
'dashed' => 'Dashed',
|
281 |
+
'solid' => 'Solid',
|
282 |
+
'double' => 'Double',
|
283 |
+
'groove' => 'Groove',
|
284 |
+
'ridge' => 'Ridge',
|
285 |
+
'inset' => 'Inset',
|
286 |
+
'outset' => 'Outset',
|
287 |
+
)
|
288 |
+
)
|
289 |
+
),
|
290 |
+
array(
|
291 |
+
'type' => 'color',
|
292 |
+
'args' => array(
|
293 |
+
'property' => 'border-{dir}-color',
|
294 |
+
'propertyAll' => 'border-color',
|
295 |
+
)
|
296 |
+
),
|
297 |
+
),
|
298 |
+
'hasAll' => true
|
299 |
+
)
|
300 |
+
),
|
301 |
+
|
302 |
+
)
|
303 |
+
),
|
304 |
+
|
305 |
+
//////////////////////////////////////////////////////////////////////
|
306 |
+
|
307 |
+
'layout' => array(
|
308 |
+
'title' => __('Layout', 'so-css'),
|
309 |
+
'icon' => 'columns',
|
310 |
+
'controllers' => array(
|
311 |
+
array(
|
312 |
+
'title' => __('Margin', 'so-css'),
|
313 |
+
'type' => 'sides',
|
314 |
+
'args' => array(
|
315 |
+
'controllers' => array(
|
316 |
+
array(
|
317 |
+
'type' => 'measurement',
|
318 |
+
'args' => array(
|
319 |
+
'property' => 'margin-{dir}',
|
320 |
+
'propertyAll' => 'margin',
|
321 |
+
'defaultUnit' => 'px'
|
322 |
+
)
|
323 |
+
)
|
324 |
+
),
|
325 |
+
'hasAll' => true
|
326 |
+
)
|
327 |
+
),
|
328 |
+
array(
|
329 |
+
'title' => __('Padding', 'so-css'),
|
330 |
+
'type' => 'sides',
|
331 |
+
'args' => array(
|
332 |
+
'controllers' => array(
|
333 |
+
array(
|
334 |
+
'type' => 'measurement',
|
335 |
+
'args' => array(
|
336 |
+
'property' => 'padding-{dir}',
|
337 |
+
'propertyAll' => 'padding',
|
338 |
+
'defaultUnit' => 'px'
|
339 |
+
)
|
340 |
+
)
|
341 |
+
),
|
342 |
+
'hasAll' => true
|
343 |
+
)
|
344 |
+
),
|
345 |
+
array(
|
346 |
+
'title' => __('Position', 'so-css'),
|
347 |
+
'type' => 'select',
|
348 |
+
'args' => array(
|
349 |
+
'property' => 'position',
|
350 |
+
'options' => array(
|
351 |
+
'absolute' => __( 'Absolute', 'so-css' ),
|
352 |
+
'fixed' => __( 'Fixed', 'so-css' ),
|
353 |
+
'relative' => __( 'Relative', 'so-css' ),
|
354 |
+
'static' => __( 'Static', 'so-css' ),
|
355 |
+
'inherit' => __( 'Inherit', 'so-css' ),
|
356 |
+
)
|
357 |
+
)
|
358 |
+
),
|
359 |
+
array(
|
360 |
+
'title' => __('Absolute Position', 'so-css'),
|
361 |
+
'type' => 'sides',
|
362 |
+
'args' => array(
|
363 |
+
'controllers' => array(
|
364 |
+
array(
|
365 |
+
'type' => 'measurement',
|
366 |
+
'args' => array(
|
367 |
+
'property' => '{dir}',
|
368 |
+
'defaultUnit' => 'px'
|
369 |
+
)
|
370 |
+
)
|
371 |
+
),
|
372 |
+
'hasAll' => false
|
373 |
+
)
|
374 |
+
),
|
375 |
+
array(
|
376 |
+
'title' => __('Width', 'so-css'),
|
377 |
+
'type' => 'measurement',
|
378 |
+
'args' => array(
|
379 |
+
'property' => 'width',
|
380 |
+
'defaultUnit' => 'px',
|
381 |
+
)
|
382 |
+
),
|
383 |
+
array(
|
384 |
+
'title' => __('Height', 'so-css'),
|
385 |
+
'type' => 'measurement',
|
386 |
+
'args' => array(
|
387 |
+
'property' => 'height',
|
388 |
+
'defaultUnit' => '%',
|
389 |
+
)
|
390 |
+
),
|
391 |
+
array(
|
392 |
+
'title' => __('Display', 'so-css'),
|
393 |
+
'type' => 'select',
|
394 |
+
'args' => array(
|
395 |
+
'property' => 'display',
|
396 |
+
'options' => array(
|
397 |
+
'none' => __( 'None', 'so-css'),
|
398 |
+
'inline' => __( 'Inline', 'so-css'),
|
399 |
+
'block' => __( 'Block', 'so-css'),
|
400 |
+
'flex' => __( 'Flex', 'so-css'),
|
401 |
+
'inline-block' => __( 'Inline Block', 'so-css'),
|
402 |
+
'inline-flex' => __( 'Inline Flex', 'so-css'),
|
403 |
+
'inline-table' => __( 'Inline Table', 'so-css'),
|
404 |
+
'list-item' => __( 'List Item', 'so-css'),
|
405 |
+
'run-in' => __( 'Run In', 'so-css'),
|
406 |
+
'table' => __( 'Table', 'so-css'),
|
407 |
+
'table-caption' => __( 'Table Caption', 'so-css'),
|
408 |
+
'table-column-group' => __( 'Table Column Group', 'so-css'),
|
409 |
+
'table-header-group' => __( 'Table Header Group', 'so-css'),
|
410 |
+
'table-footer-group' => __( 'Table Footer Group', 'so-css'),
|
411 |
+
'table-row-group' => __( 'Table Row Group', 'so-css'),
|
412 |
+
'table-cell' => __( 'Table Cell', 'so-css'),
|
413 |
+
'table-column' => __( 'Table Column', 'so-css'),
|
414 |
+
'table-row' => __( 'Table Row', 'so-css'),
|
415 |
+
)
|
416 |
+
)
|
417 |
+
),
|
418 |
+
array(
|
419 |
+
'title' => __('Float', 'so-css'),
|
420 |
+
'type' => 'select',
|
421 |
+
'args' => array(
|
422 |
+
'property' => 'float',
|
423 |
+
'options' => array(
|
424 |
+
'none' => __( 'None', 'so-css'),
|
425 |
+
'left' => __( 'Left', 'so-css'),
|
426 |
+
'right' => __( 'Right', 'so-css'),
|
427 |
+
)
|
428 |
+
)
|
429 |
+
),
|
430 |
+
array(
|
431 |
+
'title' => __('Clear', 'so-css'),
|
432 |
+
'type' => 'select',
|
433 |
+
'args' => array(
|
434 |
+
'property' => 'clear',
|
435 |
+
'options' => array(
|
436 |
+
'none' => __( 'None', 'so-css'),
|
437 |
+
'left' => __( 'Left', 'so-css'),
|
438 |
+
'right' => __( 'Right', 'so-css'),
|
439 |
+
'both' => __( 'Both', 'so-css'),
|
440 |
+
)
|
441 |
+
)
|
442 |
+
),
|
443 |
+
array(
|
444 |
+
'title' => __('Visibility', 'so-css'),
|
445 |
+
'type' => 'select',
|
446 |
+
'args' => array(
|
447 |
+
'property' => 'visibility',
|
448 |
+
'options' => array(
|
449 |
+
'visible' => __( 'Visible', 'so-css'),
|
450 |
+
'hidden' => __( 'Hidden', 'so-css'),
|
451 |
+
'collapse' => __( 'Collapse', 'so-css'),
|
452 |
+
)
|
453 |
+
)
|
454 |
+
),
|
455 |
+
array(
|
456 |
+
'title' => __('Overflow', 'so-css'),
|
457 |
+
'type' => 'select',
|
458 |
+
'args' => array(
|
459 |
+
'property' => 'overflow',
|
460 |
+
'options' => array(
|
461 |
+
'visible' => __( 'Visible', 'so-css'),
|
462 |
+
'hidden' => __( 'Hidden', 'so-css'),
|
463 |
+
'scroll' => __( 'Scroll', 'so-css'),
|
464 |
+
'auto' => __( 'Auto', 'so-css'),
|
465 |
+
)
|
466 |
+
)
|
467 |
+
),
|
468 |
+
array(
|
469 |
+
'title' => __('Overflow X', 'so-css'),
|
470 |
+
'type' => 'select',
|
471 |
+
'args' => array(
|
472 |
+
'property' => 'overflow-x',
|
473 |
+
'options' => array(
|
474 |
+
'visible' => __( 'Visible', 'so-css'),
|
475 |
+
'hidden' => __( 'Hidden', 'so-css'),
|
476 |
+
'scroll' => __( 'Scroll', 'so-css'),
|
477 |
+
'auto' => __( 'Auto', 'so-css'),
|
478 |
+
)
|
479 |
+
)
|
480 |
+
),
|
481 |
+
array(
|
482 |
+
'title' => __('Overflow Y', 'so-css'),
|
483 |
+
'type' => 'select',
|
484 |
+
'args' => array(
|
485 |
+
'property' => 'overflow-y',
|
486 |
+
'options' => array(
|
487 |
+
'visible' => __( 'Visible', 'so-css'),
|
488 |
+
'hidden' => __( 'Hidden', 'so-css'),
|
489 |
+
'scroll' => __( 'Scroll', 'so-css'),
|
490 |
+
'auto' => __( 'Auto', 'so-css'),
|
491 |
+
)
|
492 |
+
)
|
493 |
+
),
|
494 |
+
array(
|
495 |
+
'title' => __('Z-Index', 'so-css'),
|
496 |
+
'type' => 'number',
|
497 |
+
'args' => array(
|
498 |
+
'property' => 'z-index',
|
499 |
+
)
|
500 |
+
),
|
501 |
+
)
|
502 |
+
),
|
503 |
+
|
504 |
+
);
|
js/css.js
ADDED
@@ -0,0 +1,698 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
/*
|
2 |
+
The MIT License (MIT)
|
3 |
+
Copyright (c) 2015 JotForm
|
4 |
+
|
5 |
+
Modifications made by SiteOrigin
|
6 |
+
*/
|
7 |
+
|
8 |
+
/* jshint unused:false */
|
9 |
+
/* global base64_decode, CSSWizardView, window, console, jQuery */
|
10 |
+
(function ($) {
|
11 |
+
'use strict';
|
12 |
+
var fi = function () {
|
13 |
+
|
14 |
+
this.cssImportStatements = [];
|
15 |
+
this.cssKeyframeStatements = [];
|
16 |
+
|
17 |
+
this.cssRegex = new RegExp('([\\s\\S]*?){([\\s\\S]*?)}', 'gi');
|
18 |
+
this.cssMediaQueryRegex = '((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})';
|
19 |
+
this.cssKeyframeRegex = '((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})';
|
20 |
+
this.combinedCSSRegex = '((\\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 |
+
Strip outs css comments and returns cleaned css string
|
27 |
+
|
28 |
+
@param css, the original css string to be stipped out of comments
|
29 |
+
|
30 |
+
@return cleanedCSS contains no css comments
|
31 |
+
*/
|
32 |
+
fi.prototype.stripComments = function (cssString) {
|
33 |
+
var regex = new RegExp(this.cssCommentsRegex, 'gi');
|
34 |
+
|
35 |
+
return cssString.replace(regex, '');
|
36 |
+
};
|
37 |
+
|
38 |
+
/*
|
39 |
+
Parses given css string, and returns css object
|
40 |
+
keys as selectors and values are css rules
|
41 |
+
|
42 |
+
@param source css string to be parsed
|
43 |
+
|
44 |
+
@return object css
|
45 |
+
*/
|
46 |
+
fi.prototype.parseCSS = function (source) {
|
47 |
+
|
48 |
+
if (source === undefined) {
|
49 |
+
return [];
|
50 |
+
}
|
51 |
+
|
52 |
+
var css = [];
|
53 |
+
|
54 |
+
//get import statements
|
55 |
+
while (true) {
|
56 |
+
var imports = this.cssImportStatementRegex.exec(source);
|
57 |
+
if (imports !== null) {
|
58 |
+
this.cssImportStatements.push(imports[0]);
|
59 |
+
css.push({
|
60 |
+
selector: '@imports',
|
61 |
+
type: 'imports',
|
62 |
+
styles: imports[0]
|
63 |
+
});
|
64 |
+
}
|
65 |
+
else {
|
66 |
+
break;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
source = source.replace(this.cssImportStatementRegex, '');
|
70 |
+
//get keyframe statements
|
71 |
+
var keyframesRegex = new RegExp(this.cssKeyframeRegex, 'gi');
|
72 |
+
var arr;
|
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 |
+
source = source.replace(keyframesRegex, '');
|
85 |
+
|
86 |
+
//unified regex
|
87 |
+
var unified = new RegExp(this.combinedCSSRegex, 'gi');
|
88 |
+
|
89 |
+
while (true) {
|
90 |
+
arr = unified.exec(source);
|
91 |
+
if (arr === null) {
|
92 |
+
break;
|
93 |
+
}
|
94 |
+
var selector = '';
|
95 |
+
if (arr[2] === undefined) {
|
96 |
+
selector = arr[5].split('\r\n').join('\n').trim();
|
97 |
+
}
|
98 |
+
else {
|
99 |
+
selector = arr[2].split('\r\n').join('\n').trim();
|
100 |
+
}
|
101 |
+
|
102 |
+
/*
|
103 |
+
fetch comments and associate it with current selector
|
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 |
+
// Never have more than a single line break in a row
|
112 |
+
selector = selector.replace(/\n+/, "\n");
|
113 |
+
|
114 |
+
//determine the type
|
115 |
+
if (selector.indexOf('@media') !== -1) {
|
116 |
+
//we have a media query
|
117 |
+
var cssObject = {
|
118 |
+
selector: selector,
|
119 |
+
type: 'media',
|
120 |
+
subStyles: this.parseCSS(arr[3] + '\n}') //recursively parse media query inner css
|
121 |
+
};
|
122 |
+
if (comments !== null) {
|
123 |
+
cssObject.comments = comments[0];
|
124 |
+
}
|
125 |
+
css.push(cssObject);
|
126 |
+
}
|
127 |
+
else {
|
128 |
+
//we have standard css
|
129 |
+
var rules = this.parseRules(arr[6]);
|
130 |
+
var style = {
|
131 |
+
selector: selector,
|
132 |
+
rules: rules
|
133 |
+
};
|
134 |
+
if (selector === '@font-face') {
|
135 |
+
style.type = 'font-face';
|
136 |
+
}
|
137 |
+
if (comments !== null) {
|
138 |
+
style.comments = comments[0];
|
139 |
+
}
|
140 |
+
css.push(style);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
return css;
|
145 |
+
};
|
146 |
+
|
147 |
+
/*
|
148 |
+
parses given string containing css directives
|
149 |
+
and returns an array of objects containing ruleName:ruleValue pairs
|
150 |
+
|
151 |
+
@param rules, css directive string example
|
152 |
+
\n\ncolor:white;\n font-size:18px;\n
|
153 |
+
*/
|
154 |
+
fi.prototype.parseRules = function (rules) {
|
155 |
+
//convert all windows style line endings to unix style line endings
|
156 |
+
rules = rules.split('\r\n').join('\n');
|
157 |
+
var ret = [];
|
158 |
+
|
159 |
+
rules = rules.split(';');
|
160 |
+
|
161 |
+
//proccess rules line by line
|
162 |
+
for (var i = 0; i < rules.length; i++) {
|
163 |
+
var line = rules[i];
|
164 |
+
|
165 |
+
//determine if line is a valid css directive, ie color:white;
|
166 |
+
line = line.trim();
|
167 |
+
if (line.indexOf(':') !== -1) {
|
168 |
+
//line contains :
|
169 |
+
line = line.split(':');
|
170 |
+
var cssDirective = line[0].trim();
|
171 |
+
var cssValue = line.slice(1).join(':').trim();
|
172 |
+
|
173 |
+
//push rule
|
174 |
+
ret.push({
|
175 |
+
directive: cssDirective,
|
176 |
+
value: cssValue
|
177 |
+
});
|
178 |
+
}
|
179 |
+
else {
|
180 |
+
//if there is no ':', but what if it was mis splitted value which starts with base64
|
181 |
+
if (line.trim().substr(0, 7) === 'base64,') { //hack :)
|
182 |
+
ret[ret.length - 1].value += line.trim();
|
183 |
+
}
|
184 |
+
else {
|
185 |
+
//add rule, even if it is defective
|
186 |
+
if (line.length > 0) {
|
187 |
+
ret.push({
|
188 |
+
directive: '',
|
189 |
+
value: line,
|
190 |
+
defective: true
|
191 |
+
});
|
192 |
+
}
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
return ret; //we are done!
|
198 |
+
};
|
199 |
+
|
200 |
+
/*
|
201 |
+
just returns the rule having given directive
|
202 |
+
if not found returns false;
|
203 |
+
*/
|
204 |
+
fi.prototype.findCorrespondingRule = function (rules, directive, value) {
|
205 |
+
if (value === undefined) {
|
206 |
+
value = false;
|
207 |
+
}
|
208 |
+
var ret = false;
|
209 |
+
for (var i = 0; i < rules.length; i++) {
|
210 |
+
if (rules[i].directive == directive) {
|
211 |
+
ret = rules[i];
|
212 |
+
if (value === rules[i].value) {
|
213 |
+
break;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
return ret;
|
218 |
+
};
|
219 |
+
|
220 |
+
/*
|
221 |
+
Finds styles that have given selector, compress them,
|
222 |
+
and returns them
|
223 |
+
*/
|
224 |
+
fi.prototype.findBySelector = function (cssObjectArray, selector, contains) {
|
225 |
+
if (contains === undefined) {
|
226 |
+
contains = false;
|
227 |
+
}
|
228 |
+
|
229 |
+
var found = [];
|
230 |
+
for (var i = 0; i < cssObjectArray.length; i++) {
|
231 |
+
if (contains === false) {
|
232 |
+
if (cssObjectArray[i].selector === selector) {
|
233 |
+
found.push(cssObjectArray[i]);
|
234 |
+
}
|
235 |
+
}
|
236 |
+
else {
|
237 |
+
if (cssObjectArray[i].selector.indexOf(selector) !== -1) {
|
238 |
+
found.push(cssObjectArray[i]);
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
}
|
243 |
+
if (found.length < 2) {
|
244 |
+
return found;
|
245 |
+
}
|
246 |
+
else {
|
247 |
+
var base = found[0];
|
248 |
+
for (i = 1; i < found.length; i++) {
|
249 |
+
this.intelligentCSSPush([base], found[i]);
|
250 |
+
}
|
251 |
+
return [base]; //we are done!! all properties merged into base!
|
252 |
+
}
|
253 |
+
};
|
254 |
+
|
255 |
+
/*
|
256 |
+
deletes cssObjects having given selector, and returns new array
|
257 |
+
*/
|
258 |
+
fi.prototype.deleteBySelector = function (cssObjectArray, selector) {
|
259 |
+
var ret = [];
|
260 |
+
for (var i = 0; i < cssObjectArray.length; i++) {
|
261 |
+
if (cssObjectArray[i].selector !== selector) {
|
262 |
+
ret.push(cssObjectArray[i]);
|
263 |
+
}
|
264 |
+
}
|
265 |
+
return ret;
|
266 |
+
};
|
267 |
+
|
268 |
+
/*
|
269 |
+
Compresses given cssObjectArray and tries to minimize
|
270 |
+
selector redundence.
|
271 |
+
*/
|
272 |
+
fi.prototype.compressCSS = function (cssObjectArray) {
|
273 |
+
var compressed = [];
|
274 |
+
var done = {};
|
275 |
+
for (var i = 0; i < cssObjectArray.length; i++) {
|
276 |
+
var obj = cssObjectArray[i];
|
277 |
+
if (done[obj.selector] === true) {
|
278 |
+
continue;
|
279 |
+
}
|
280 |
+
|
281 |
+
var found = this.findBySelector(cssObjectArray, obj.selector); //found compressed
|
282 |
+
if ( found.length !== 0 ) {
|
283 |
+
compressed.push(found[0]);
|
284 |
+
done[obj.selector] = true;
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
return compressed;
|
289 |
+
};
|
290 |
+
|
291 |
+
/*
|
292 |
+
Received 2 css objects with following structure
|
293 |
+
{
|
294 |
+
rules : [{directive:"", value:""}, {directive:"", value:""}, ...]
|
295 |
+
selector : "SOMESELECTOR"
|
296 |
+
}
|
297 |
+
|
298 |
+
returns the changed(new,removed,updated) values on css1 parameter, on same structure
|
299 |
+
|
300 |
+
if two css objects are the same, then returns false
|
301 |
+
|
302 |
+
if a css directive exists in css1 and css2, and its value is different, it is included in diff
|
303 |
+
if a css directive exists in css1 and not css2, it is then included in diff
|
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 |
+
@object css1 css object
|
307 |
+
@object css2 css object
|
308 |
+
|
309 |
+
@return diff css object contains changed values in css1 in regards to css2 see test input output in /test/data/css.js
|
310 |
+
*/
|
311 |
+
fi.prototype.cssDiff = function (css1, css2) {
|
312 |
+
if (css1.selector !== css2.selector) {
|
313 |
+
return false;
|
314 |
+
}
|
315 |
+
|
316 |
+
//if one of them is media query return false, because diff function can not operate on media queries
|
317 |
+
if ((css1.type === 'media' || css2.type === 'media')) {
|
318 |
+
return false;
|
319 |
+
}
|
320 |
+
|
321 |
+
var diff = {
|
322 |
+
selector: css1.selector,
|
323 |
+
rules: []
|
324 |
+
};
|
325 |
+
var rule1, rule2;
|
326 |
+
for (var i = 0; i < css1.rules.length; i++) {
|
327 |
+
rule1 = css1.rules[i];
|
328 |
+
//find rule2 which has the same directive as rule1
|
329 |
+
rule2 = this.findCorrespondingRule(css2.rules, rule1.directive, rule1.value);
|
330 |
+
if (rule2 === false) {
|
331 |
+
//rule1 is a new rule in css1
|
332 |
+
diff.rules.push(rule1);
|
333 |
+
}
|
334 |
+
else {
|
335 |
+
//rule2 was found only push if its value is different too
|
336 |
+
if (rule1.value !== rule2.value) {
|
337 |
+
diff.rules.push(rule1);
|
338 |
+
}
|
339 |
+
}
|
340 |
+
}
|
341 |
+
|
342 |
+
//now for rules exists in css2 but not in css1, which means deleted rules
|
343 |
+
for (var ii = 0; ii < css2.rules.length; ii++) {
|
344 |
+
rule2 = css2.rules[ii];
|
345 |
+
//find rule2 which has the same directive as rule1
|
346 |
+
rule1 = this.findCorrespondingRule(css1.rules, rule2.directive);
|
347 |
+
if (rule1 === false) {
|
348 |
+
//rule1 is a new rule
|
349 |
+
rule2.type = 'DELETED'; //mark it as a deleted rule, so that other merge operations could be true
|
350 |
+
diff.rules.push(rule2);
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
|
355 |
+
if (diff.rules.length === 0) {
|
356 |
+
return false;
|
357 |
+
}
|
358 |
+
return diff;
|
359 |
+
};
|
360 |
+
|
361 |
+
/*
|
362 |
+
Merges 2 different css objects together
|
363 |
+
using intelligentCSSPush,
|
364 |
+
|
365 |
+
@param cssObjectArray, target css object array
|
366 |
+
@param newArray, source array that will be pushed into cssObjectArray parameter
|
367 |
+
@param reverse, [optional], if given true, first parameter will be traversed on reversed order
|
368 |
+
effectively giving priority to the styles in newArray
|
369 |
+
*/
|
370 |
+
fi.prototype.intelligentMerge = function (cssObjectArray, newArray, reverse) {
|
371 |
+
if (reverse === undefined) {
|
372 |
+
reverse = false;
|
373 |
+
}
|
374 |
+
|
375 |
+
|
376 |
+
for (var i = 0; i < newArray.length; i++) {
|
377 |
+
this.intelligentCSSPush(cssObjectArray, newArray[i], reverse);
|
378 |
+
}
|
379 |
+
for (i = 0; i < cssObjectArray.length; i++) {
|
380 |
+
var cobj = cssObjectArray[i];
|
381 |
+
if (cobj.type === 'media' || (cobj.type === 'keyframes')) {
|
382 |
+
continue;
|
383 |
+
}
|
384 |
+
cobj.rules = this.compactRules(cobj.rules);
|
385 |
+
}
|
386 |
+
};
|
387 |
+
|
388 |
+
/*
|
389 |
+
inserts new css objects into a bigger css object
|
390 |
+
with same selectors grouped together
|
391 |
+
|
392 |
+
@param cssObjectArray, array of bigger css object to be pushed into
|
393 |
+
@param minimalObject, single css object
|
394 |
+
@param reverse [optional] default is false, if given, cssObjectArray will be reverse traversed
|
395 |
+
resulting more priority in minimalObject's styles
|
396 |
+
*/
|
397 |
+
fi.prototype.intelligentCSSPush = function (cssObjectArray, minimalObject, reverse) {
|
398 |
+
var pushSelector = minimalObject.selector;
|
399 |
+
//find correct selector if not found just push minimalObject into cssObject
|
400 |
+
var cssObject = false;
|
401 |
+
|
402 |
+
if (reverse === undefined) {
|
403 |
+
reverse = false;
|
404 |
+
}
|
405 |
+
|
406 |
+
if (reverse === false) {
|
407 |
+
for (var i = 0; i < cssObjectArray.length; i++) {
|
408 |
+
if (cssObjectArray[i].selector === minimalObject.selector) {
|
409 |
+
cssObject = cssObjectArray[i];
|
410 |
+
break;
|
411 |
+
}
|
412 |
+
}
|
413 |
+
}
|
414 |
+
else {
|
415 |
+
for (var j = cssObjectArray.length - 1; j > -1; j--) {
|
416 |
+
if (cssObjectArray[j].selector === minimalObject.selector) {
|
417 |
+
cssObject = cssObjectArray[j];
|
418 |
+
break;
|
419 |
+
}
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
if (cssObject === false) {
|
424 |
+
cssObjectArray.push(minimalObject); //just push, because cssSelector is new
|
425 |
+
}
|
426 |
+
else {
|
427 |
+
if (minimalObject.type !== 'media') {
|
428 |
+
for (var ii = 0; ii < minimalObject.rules.length; ii++) {
|
429 |
+
var rule = minimalObject.rules[ii];
|
430 |
+
//find rule inside cssObject
|
431 |
+
var oldRule = this.findCorrespondingRule(cssObject.rules, rule.directive);
|
432 |
+
if (oldRule === false) {
|
433 |
+
cssObject.rules.push(rule);
|
434 |
+
} else if (rule.type === 'DELETED') {
|
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 = minimalObject.subStyles; //TODO, make this intelligent too
|
446 |
+
}
|
447 |
+
|
448 |
+
}
|
449 |
+
};
|
450 |
+
|
451 |
+
/*
|
452 |
+
filter outs rule objects whose type param equal to DELETED
|
453 |
+
|
454 |
+
@param rules, array of rules
|
455 |
+
|
456 |
+
@returns rules array, compacted by deleting all unnecessary rules
|
457 |
+
*/
|
458 |
+
fi.prototype.compactRules = function (rules) {
|
459 |
+
var newRules = [];
|
460 |
+
for (var i = 0; i < rules.length; i++) {
|
461 |
+
if (rules[i].type !== 'DELETED') {
|
462 |
+
newRules.push(rules[i]);
|
463 |
+
}
|
464 |
+
}
|
465 |
+
return newRules;
|
466 |
+
};
|
467 |
+
/*
|
468 |
+
computes string for ace editor using this.css or given cssBase optional parameter
|
469 |
+
|
470 |
+
@param [optional] cssBase, if given computes cssString from cssObject array
|
471 |
+
*/
|
472 |
+
fi.prototype.getCSSForEditor = function (cssBase, depth) {
|
473 |
+
if (depth === undefined) {
|
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 |
+
if (tmp.type === 'media') { //also put media queries to output
|
497 |
+
ret += comments + tmp.selector + '{\n';
|
498 |
+
ret += this.getCSSForEditor(tmp.subStyles, depth + 1);
|
499 |
+
ret += '}\n\n';
|
500 |
+
}
|
501 |
+
else if (tmp.type !== 'keyframes' && tmp.type !== 'imports') {
|
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 |
+
//append keyFrames
|
509 |
+
for (i = 0; i < cssBase.length; i++) {
|
510 |
+
if (cssBase[i].type === 'keyframes') {
|
511 |
+
ret += cssBase[i].styles + '\n\n';
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
return ret;
|
516 |
+
};
|
517 |
+
|
518 |
+
fi.prototype.getImports = function (cssObjectArray) {
|
519 |
+
var imps = [];
|
520 |
+
for (var i = 0; i < cssObjectArray.length; i++) {
|
521 |
+
if (cssObjectArray[i].type === 'imports') {
|
522 |
+
imps.push(cssObjectArray[i].styles);
|
523 |
+
}
|
524 |
+
}
|
525 |
+
return imps;
|
526 |
+
};
|
527 |
+
|
528 |
+
/*
|
529 |
+
given rules array, returns visually formatted css string
|
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 |
+
if (rules[i].defective === undefined) {
|
543 |
+
ret += this.getSpaces(depth) + rules[i].directive + ': ' + rules[i].value + ';\n';
|
544 |
+
}
|
545 |
+
else {
|
546 |
+
ret += this.getSpaces(depth) + rules[i].value + ';\n';
|
547 |
+
}
|
548 |
+
|
549 |
+
}
|
550 |
+
return ret || '\n';
|
551 |
+
};
|
552 |
+
|
553 |
+
/*
|
554 |
+
A very simple helper function returns number of spaces appended in a single string,
|
555 |
+
the number depends input parameter, namely input*2
|
556 |
+
*/
|
557 |
+
fi.prototype.getSpaces = function (num) {
|
558 |
+
var ret = '';
|
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 |
+
@returns css string in which this.cssPreviewNamespace prepended
|
570 |
+
*/
|
571 |
+
fi.prototype.applyNamespacing = function (css, forcedNamespace) {
|
572 |
+
var cssObjectArray = css;
|
573 |
+
var namespaceClass = '.' + this.cssPreviewNamespace;
|
574 |
+
if (forcedNamespace !== undefined) {
|
575 |
+
namespaceClass = forcedNamespace;
|
576 |
+
}
|
577 |
+
|
578 |
+
if (typeof css === 'string') {
|
579 |
+
cssObjectArray = this.parseCSS(css);
|
580 |
+
}
|
581 |
+
|
582 |
+
for (var i = 0; i < cssObjectArray.length; i++) {
|
583 |
+
var obj = cssObjectArray[i];
|
584 |
+
|
585 |
+
//bypass namespacing for @font-face @keyframes @import
|
586 |
+
if (obj.selector.indexOf('@font-face') > -1 || obj.selector.indexOf('keyframes') > -1 || obj.selector.indexOf('@import') > -1 || obj.selector.indexOf('.form-all') > -1 || obj.selector.indexOf('#stage') > -1) {
|
587 |
+
continue;
|
588 |
+
}
|
589 |
+
|
590 |
+
if (obj.type !== 'media') {
|
591 |
+
var selector = obj.selector.split(',');
|
592 |
+
var newSelector = [];
|
593 |
+
for (var j = 0; j < selector.length; j++) {
|
594 |
+
if (selector[j].indexOf('.supernova') === -1) { //do not apply namespacing to selectors including supernova
|
595 |
+
newSelector.push(namespaceClass + ' ' + selector[j]);
|
596 |
+
}
|
597 |
+
else {
|
598 |
+
newSelector.push(selector[j]);
|
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 |
+
return cssObjectArray;
|
609 |
+
};
|
610 |
+
|
611 |
+
/*
|
612 |
+
given css string or object array, clears possible namespacing from
|
613 |
+
all of the selectors inside the css
|
614 |
+
*/
|
615 |
+
fi.prototype.clearNamespacing = function (css, returnObj) {
|
616 |
+
if (returnObj === undefined) {
|
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 |
+
for (var i = 0; i < cssObjectArray.length; i++) {
|
626 |
+
var obj = cssObjectArray[i];
|
627 |
+
|
628 |
+
if (obj.type !== 'media') {
|
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 |
+
creates a new style tag (also destroys the previous one)
|
651 |
+
and injects given css string into that css tag
|
652 |
+
*/
|
653 |
+
fi.prototype.createStyleElement = function (id, css, format) {
|
654 |
+
if (format === undefined) {
|
655 |
+
format = false;
|
656 |
+
}
|
657 |
+
|
658 |
+
if (this.testMode === false && format !== 'nonamespace') {
|
659 |
+
//apply namespacing classes
|
660 |
+
css = this.applyNamespacing(css);
|
661 |
+
}
|
662 |
+
|
663 |
+
if (typeof css !== 'string') {
|
664 |
+
css = this.getCSSForEditor(css);
|
665 |
+
}
|
666 |
+
//apply formatting for css
|
667 |
+
if (format === true) {
|
668 |
+
css = this.getCSSForEditor(this.parseCSS(css));
|
669 |
+
}
|
670 |
+
|
671 |
+
if (this.testMode !== false) {
|
672 |
+
return this.testMode('create style #' + id, css); //if test mode, just pass result to callback
|
673 |
+
}
|
674 |
+
|
675 |
+
var __el = document.getElementById(id);
|
676 |
+
if (__el) {
|
677 |
+
__el.parentNode.removeChild(__el);
|
678 |
+
}
|
679 |
+
|
680 |
+
var head = document.head || document.getElementsByTagName('head')[0],
|
681 |
+
style = document.createElement('style');
|
682 |
+
|
683 |
+
style.id = id;
|
684 |
+
style.type = 'text/css';
|
685 |
+
|
686 |
+
head.appendChild(style);
|
687 |
+
|
688 |
+
if (style.styleSheet && !style.sheet) {
|
689 |
+
style.styleSheet.cssText = css;
|
690 |
+
}
|
691 |
+
else {
|
692 |
+
style.appendChild(document.createTextNode(css));
|
693 |
+
}
|
694 |
+
};
|
695 |
+
|
696 |
+
window.cssjs = fi;
|
697 |
+
|
698 |
+
})();
|
js/css.min.js
ADDED
@@ -0,0 +1,79 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function($){'use strict';var fi=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*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})';this.cssCommentsRegex='(\\/\\*[\\s\\S]*?\\*\\/)';this.cssImportStatementRegex=new RegExp('@import .*?;','gi');};fi.prototype.stripComments=function(cssString){var regex=new RegExp(this.cssCommentsRegex,'gi');return cssString.replace(regex,'');};fi.prototype.parseCSS=function(source){if(source===undefined){return[];}
|
3 |
+
var css=[];while(true){var imports=this.cssImportStatementRegex.exec(source);if(imports!==null){this.cssImportStatements.push(imports[0]);css.push({selector:'@imports',type:'imports',styles:imports[0]});}
|
4 |
+
else{break;}}
|
5 |
+
source=source.replace(this.cssImportStatementRegex,'');var keyframesRegex=new RegExp(this.cssKeyframeRegex,'gi');var arr;while(true){arr=keyframesRegex.exec(source);if(arr===null){break;}
|
6 |
+
css.push({selector:'@keyframes',type:'keyframes',styles:arr[0]});}
|
7 |
+
source=source.replace(keyframesRegex,'');var unified=new RegExp(this.combinedCSSRegex,'gi');while(true){arr=unified.exec(source);if(arr===null){break;}
|
8 |
+
var selector='';if(arr[2]===undefined){selector=arr[5].split('\r\n').join('\n').trim();}
|
9 |
+
else{selector=arr[2].split('\r\n').join('\n').trim();}
|
10 |
+
var commentsRegex=new RegExp(this.cssCommentsRegex,'gi');var comments=commentsRegex.exec(selector);if(comments!==null){selector=selector.replace(commentsRegex,'').trim();}
|
11 |
+
selector=selector.replace(/\n+/,"\n");if(selector.indexOf('@media')!==-1){var cssObject={selector:selector,type:'media',subStyles:this.parseCSS(arr[3]+'\n}')};if(comments!==null){cssObject.comments=comments[0];}
|
12 |
+
css.push(cssObject);}
|
13 |
+
else{var rules=this.parseRules(arr[6]);var style={selector:selector,rules:rules};if(selector==='@font-face'){style.type='font-face';}
|
14 |
+
if(comments!==null){style.comments=comments[0];}
|
15 |
+
css.push(style);}}
|
16 |
+
return css;};fi.prototype.parseRules=function(rules){rules=rules.split('\r\n').join('\n');var ret=[];rules=rules.split(';');for(var i=0;i<rules.length;i++){var line=rules[i];line=line.trim();if(line.indexOf(':')!==-1){line=line.split(':');var cssDirective=line[0].trim();var cssValue=line.slice(1).join(':').trim();ret.push({directive:cssDirective,value:cssValue});}
|
17 |
+
else{if(line.trim().substr(0,7)==='base64,'){ret[ret.length-1].value+=line.trim();}
|
18 |
+
else{if(line.length>0){ret.push({directive:'',value:line,defective:true});}}}}
|
19 |
+
return ret;};fi.prototype.findCorrespondingRule=function(rules,directive,value){if(value===undefined){value=false;}
|
20 |
+
var ret=false;for(var i=0;i<rules.length;i++){if(rules[i].directive==directive){ret=rules[i];if(value===rules[i].value){break;}}}
|
21 |
+
return ret;};fi.prototype.findBySelector=function(cssObjectArray,selector,contains){if(contains===undefined){contains=false;}
|
22 |
+
var found=[];for(var i=0;i<cssObjectArray.length;i++){if(contains===false){if(cssObjectArray[i].selector===selector){found.push(cssObjectArray[i]);}}
|
23 |
+
else{if(cssObjectArray[i].selector.indexOf(selector)!==-1){found.push(cssObjectArray[i]);}}}
|
24 |
+
if(found.length<2){return found;}
|
25 |
+
else{var base=found[0];for(i=1;i<found.length;i++){this.intelligentCSSPush([base],found[i]);}
|
26 |
+
return[base];}};fi.prototype.deleteBySelector=function(cssObjectArray,selector){var ret=[];for(var i=0;i<cssObjectArray.length;i++){if(cssObjectArray[i].selector!==selector){ret.push(cssObjectArray[i]);}}
|
27 |
+
return ret;};fi.prototype.compressCSS=function(cssObjectArray){var compressed=[];var done={};for(var i=0;i<cssObjectArray.length;i++){var obj=cssObjectArray[i];if(done[obj.selector]===true){continue;}
|
28 |
+
var found=this.findBySelector(cssObjectArray,obj.selector);if(found.length!==0){compressed.push(found[0]);done[obj.selector]=true;}}
|
29 |
+
return compressed;};fi.prototype.cssDiff=function(css1,css2){if(css1.selector!==css2.selector){return false;}
|
30 |
+
if((css1.type==='media'||css2.type==='media')){return false;}
|
31 |
+
var diff={selector:css1.selector,rules:[]};var rule1,rule2;for(var i=0;i<css1.rules.length;i++){rule1=css1.rules[i];rule2=this.findCorrespondingRule(css2.rules,rule1.directive,rule1.value);if(rule2===false){diff.rules.push(rule1);}
|
32 |
+
else{if(rule1.value!==rule2.value){diff.rules.push(rule1);}}}
|
33 |
+
for(var ii=0;ii<css2.rules.length;ii++){rule2=css2.rules[ii];rule1=this.findCorrespondingRule(css1.rules,rule2.directive);if(rule1===false){rule2.type='DELETED';diff.rules.push(rule2);}}
|
34 |
+
if(diff.rules.length===0){return false;}
|
35 |
+
return diff;};fi.prototype.intelligentMerge=function(cssObjectArray,newArray,reverse){if(reverse===undefined){reverse=false;}
|
36 |
+
for(var i=0;i<newArray.length;i++){this.intelligentCSSPush(cssObjectArray,newArray[i],reverse);}
|
37 |
+
for(i=0;i<cssObjectArray.length;i++){var cobj=cssObjectArray[i];if(cobj.type==='media'||(cobj.type==='keyframes')){continue;}
|
38 |
+
cobj.rules=this.compactRules(cobj.rules);}};fi.prototype.intelligentCSSPush=function(cssObjectArray,minimalObject,reverse){var pushSelector=minimalObject.selector;var cssObject=false;if(reverse===undefined){reverse=false;}
|
39 |
+
if(reverse===false){for(var i=0;i<cssObjectArray.length;i++){if(cssObjectArray[i].selector===minimalObject.selector){cssObject=cssObjectArray[i];break;}}}
|
40 |
+
else{for(var j=cssObjectArray.length-1;j>-1;j--){if(cssObjectArray[j].selector===minimalObject.selector){cssObject=cssObjectArray[j];break;}}}
|
41 |
+
if(cssObject===false){cssObjectArray.push(minimalObject);}
|
42 |
+
else{if(minimalObject.type!=='media'){for(var ii=0;ii<minimalObject.rules.length;ii++){var rule=minimalObject.rules[ii];var oldRule=this.findCorrespondingRule(cssObject.rules,rule.directive);if(oldRule===false){cssObject.rules.push(rule);}else if(rule.type==='DELETED'){oldRule.type='DELETED';}
|
43 |
+
else{oldRule.value=rule.value;}}}
|
44 |
+
else{cssObject.subStyles=minimalObject.subStyles;}}};fi.prototype.compactRules=function(rules){var newRules=[];for(var i=0;i<rules.length;i++){if(rules[i].type!=='DELETED'){newRules.push(rules[i]);}}
|
45 |
+
return newRules;};fi.prototype.getCSSForEditor=function(cssBase,depth){if(depth===undefined){depth=0;}
|
46 |
+
var ret='';if(cssBase===undefined){cssBase=this.css;}
|
47 |
+
for(var i=0;i<cssBase.length;i++){if(cssBase[i].type==='imports'){ret+=cssBase[i].styles+'\n\n';}}
|
48 |
+
for(i=0;i<cssBase.length;i++){var tmp=cssBase[i];if(tmp.selector===undefined){continue;}
|
49 |
+
var comments="";if(tmp.comments!==undefined){comments=tmp.comments+'\n';}
|
50 |
+
if(tmp.type==='media'){ret+=comments+tmp.selector+'{\n';ret+=this.getCSSForEditor(tmp.subStyles,depth+1);ret+='}\n\n';}
|
51 |
+
else if(tmp.type!=='keyframes'&&tmp.type!=='imports'){ret+=this.getSpaces(depth)+comments+tmp.selector+' {\n';ret+=this.getCSSOfRules(tmp.rules,depth+1);ret+=this.getSpaces(depth)+'}\n\n';}}
|
52 |
+
for(i=0;i<cssBase.length;i++){if(cssBase[i].type==='keyframes'){ret+=cssBase[i].styles+'\n\n';}}
|
53 |
+
return ret;};fi.prototype.getImports=function(cssObjectArray){var imps=[];for(var i=0;i<cssObjectArray.length;i++){if(cssObjectArray[i].type==='imports'){imps.push(cssObjectArray[i].styles);}}
|
54 |
+
return imps;};fi.prototype.getCSSOfRules=function(rules,depth){var ret='';for(var i=0;i<rules.length;i++){if(rules[i]===undefined){continue;}
|
55 |
+
if(rules[i].value===''){continue;}
|
56 |
+
if(rules[i].defective===undefined){ret+=this.getSpaces(depth)+rules[i].directive+': '+rules[i].value+';\n';}
|
57 |
+
else{ret+=this.getSpaces(depth)+rules[i].value+';\n';}}
|
58 |
+
return ret||'\n';};fi.prototype.getSpaces=function(num){var ret='';for(var i=0;i<num*2;i++){ret+=' ';}
|
59 |
+
return ret;};fi.prototype.applyNamespacing=function(css,forcedNamespace){var cssObjectArray=css;var namespaceClass='.'+this.cssPreviewNamespace;if(forcedNamespace!==undefined){namespaceClass=forcedNamespace;}
|
60 |
+
if(typeof css==='string'){cssObjectArray=this.parseCSS(css);}
|
61 |
+
for(var i=0;i<cssObjectArray.length;i++){var obj=cssObjectArray[i];if(obj.selector.indexOf('@font-face')>-1||obj.selector.indexOf('keyframes')>-1||obj.selector.indexOf('@import')>-1||obj.selector.indexOf('.form-all')>-1||obj.selector.indexOf('#stage')>-1){continue;}
|
62 |
+
if(obj.type!=='media'){var selector=obj.selector.split(',');var newSelector=[];for(var j=0;j<selector.length;j++){if(selector[j].indexOf('.supernova')===-1){newSelector.push(namespaceClass+' '+selector[j]);}
|
63 |
+
else{newSelector.push(selector[j]);}}
|
64 |
+
obj.selector=newSelector.join(',');}
|
65 |
+
else{obj.subStyles=this.applyNamespacing(obj.subStyles,forcedNamespace);}}
|
66 |
+
return cssObjectArray;};fi.prototype.clearNamespacing=function(css,returnObj){if(returnObj===undefined){returnObj=false;}
|
67 |
+
var cssObjectArray=css;var namespaceClass='.'+this.cssPreviewNamespace;if(typeof css==='string'){cssObjectArray=this.parseCSS(css);}
|
68 |
+
for(var i=0;i<cssObjectArray.length;i++){var obj=cssObjectArray[i];if(obj.type!=='media'){var selector=obj.selector.split(',');var newSelector=[];for(var j=0;j<selector.length;j++){newSelector.push(selector[j].split(namespaceClass+' ').join(''));}
|
69 |
+
obj.selector=newSelector.join(',');}
|
70 |
+
else{obj.subStyles=this.clearNamespacing(obj.subStyles,true);}}
|
71 |
+
if(returnObj===false){return this.getCSSForEditor(cssObjectArray);}
|
72 |
+
else{return cssObjectArray;}};fi.prototype.createStyleElement=function(id,css,format){if(format===undefined){format=false;}
|
73 |
+
if(this.testMode===false&&format!=='nonamespace'){css=this.applyNamespacing(css);}
|
74 |
+
if(typeof css!=='string'){css=this.getCSSForEditor(css);}
|
75 |
+
if(format===true){css=this.getCSSForEditor(this.parseCSS(css));}
|
76 |
+
if(this.testMode!==false){return this.testMode('create style #'+id,css);}
|
77 |
+
var __el=document.getElementById(id);if(__el){__el.parentNode.removeChild(__el);}
|
78 |
+
var head=document.head||document.getElementsByTagName('head')[0],style=document.createElement('style');style.id=id;style.type='text/css';head.appendChild(style);if(style.styleSheet&&!style.sheet){style.styleSheet.cssText=css;}
|
79 |
+
else{style.appendChild(document.createTextNode(css));}};window.cssjs=fi;})();
|
js/csslint.js
ADDED
@@ -0,0 +1,9259 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
/*!
|
2 |
+
CSSLint
|
3 |
+
Copyright (c) 2013 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in
|
13 |
+
all copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
THE SOFTWARE.
|
22 |
+
|
23 |
+
*/
|
24 |
+
/* Build: v0.10.0 15-August-2013 01:07:22 */
|
25 |
+
var exports = exports || {};
|
26 |
+
var CSSLint = (function(){
|
27 |
+
/*!
|
28 |
+
Parser-Lib
|
29 |
+
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
|
30 |
+
|
31 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
32 |
+
of this software and associated documentation files (the "Software"), to deal
|
33 |
+
in the Software without restriction, including without limitation the rights
|
34 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
35 |
+
copies of the Software, and to permit persons to whom the Software is
|
36 |
+
furnished to do so, subject to the following conditions:
|
37 |
+
|
38 |
+
The above copyright notice and this permission notice shall be included in
|
39 |
+
all copies or substantial portions of the Software.
|
40 |
+
|
41 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
42 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
43 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
44 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
45 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
46 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
47 |
+
THE SOFTWARE.
|
48 |
+
|
49 |
+
*/
|
50 |
+
/* Version v0.2.3, Build time: 19-June-2013 11:16:15 */
|
51 |
+
var parserlib = {};
|
52 |
+
(function(){
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* A generic base to inherit from for any object
|
57 |
+
* that needs event handling.
|
58 |
+
* @class EventTarget
|
59 |
+
* @constructor
|
60 |
+
*/
|
61 |
+
function EventTarget(){
|
62 |
+
|
63 |
+
/**
|
64 |
+
* The array of listeners for various events.
|
65 |
+
* @type Object
|
66 |
+
* @property _listeners
|
67 |
+
* @private
|
68 |
+
*/
|
69 |
+
this._listeners = {};
|
70 |
+
}
|
71 |
+
|
72 |
+
EventTarget.prototype = {
|
73 |
+
|
74 |
+
//restore constructor
|
75 |
+
constructor: EventTarget,
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Adds a listener for a given event type.
|
79 |
+
* @param {String} type The type of event to add a listener for.
|
80 |
+
* @param {Function} listener The function to call when the event occurs.
|
81 |
+
* @return {void}
|
82 |
+
* @method addListener
|
83 |
+
*/
|
84 |
+
addListener: function(type, listener){
|
85 |
+
if (!this._listeners[type]){
|
86 |
+
this._listeners[type] = [];
|
87 |
+
}
|
88 |
+
|
89 |
+
this._listeners[type].push(listener);
|
90 |
+
},
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Fires an event based on the passed-in object.
|
94 |
+
* @param {Object|String} event An object with at least a 'type' attribute
|
95 |
+
* or a string indicating the event name.
|
96 |
+
* @return {void}
|
97 |
+
* @method fire
|
98 |
+
*/
|
99 |
+
fire: function(event){
|
100 |
+
if (typeof event == "string"){
|
101 |
+
event = { type: event };
|
102 |
+
}
|
103 |
+
if (typeof event.target != "undefined"){
|
104 |
+
event.target = this;
|
105 |
+
}
|
106 |
+
|
107 |
+
if (typeof event.type == "undefined"){
|
108 |
+
throw new Error("Event object missing 'type' property.");
|
109 |
+
}
|
110 |
+
|
111 |
+
if (this._listeners[event.type]){
|
112 |
+
|
113 |
+
//create a copy of the array and use that so listeners can't chane
|
114 |
+
var listeners = this._listeners[event.type].concat();
|
115 |
+
for (var i=0, len=listeners.length; i < len; i++){
|
116 |
+
listeners[i].call(this, event);
|
117 |
+
}
|
118 |
+
}
|
119 |
+
},
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Removes a listener for a given event type.
|
123 |
+
* @param {String} type The type of event to remove a listener from.
|
124 |
+
* @param {Function} listener The function to remove from the event.
|
125 |
+
* @return {void}
|
126 |
+
* @method removeListener
|
127 |
+
*/
|
128 |
+
removeListener: function(type, listener){
|
129 |
+
if (this._listeners[type]){
|
130 |
+
var listeners = this._listeners[type];
|
131 |
+
for (var i=0, len=listeners.length; i < len; i++){
|
132 |
+
if (listeners[i] === listener){
|
133 |
+
listeners.splice(i, 1);
|
134 |
+
break;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
+
}
|
140 |
+
}
|
141 |
+
};
|
142 |
+
/**
|
143 |
+
* Convenient way to read through strings.
|
144 |
+
* @namespace parserlib.util
|
145 |
+
* @class StringReader
|
146 |
+
* @constructor
|
147 |
+
* @param {String} text The text to read.
|
148 |
+
*/
|
149 |
+
function StringReader(text){
|
150 |
+
|
151 |
+
/**
|
152 |
+
* The input text with line endings normalized.
|
153 |
+
* @property _input
|
154 |
+
* @type String
|
155 |
+
* @private
|
156 |
+
*/
|
157 |
+
this._input = text.replace(/\n\r?/g, "\n");
|
158 |
+
|
159 |
+
|
160 |
+
/**
|
161 |
+
* The row for the character to be read next.
|
162 |
+
* @property _line
|
163 |
+
* @type int
|
164 |
+
* @private
|
165 |
+
*/
|
166 |
+
this._line = 1;
|
167 |
+
|
168 |
+
|
169 |
+
/**
|
170 |
+
* The column for the character to be read next.
|
171 |
+
* @property _col
|
172 |
+
* @type int
|
173 |
+
* @private
|
174 |
+
*/
|
175 |
+
this._col = 1;
|
176 |
+
|
177 |
+
/**
|
178 |
+
* The index of the character in the input to be read next.
|
179 |
+
* @property _cursor
|
180 |
+
* @type int
|
181 |
+
* @private
|
182 |
+
*/
|
183 |
+
this._cursor = 0;
|
184 |
+
}
|
185 |
+
|
186 |
+
StringReader.prototype = {
|
187 |
+
|
188 |
+
//restore constructor
|
189 |
+
constructor: StringReader,
|
190 |
+
|
191 |
+
//-------------------------------------------------------------------------
|
192 |
+
// Position info
|
193 |
+
//-------------------------------------------------------------------------
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Returns the column of the character to be read next.
|
197 |
+
* @return {int} The column of the character to be read next.
|
198 |
+
* @method getCol
|
199 |
+
*/
|
200 |
+
getCol: function(){
|
201 |
+
return this._col;
|
202 |
+
},
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Returns the row of the character to be read next.
|
206 |
+
* @return {int} The row of the character to be read next.
|
207 |
+
* @method getLine
|
208 |
+
*/
|
209 |
+
getLine: function(){
|
210 |
+
return this._line ;
|
211 |
+
},
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Determines if you're at the end of the input.
|
215 |
+
* @return {Boolean} True if there's no more input, false otherwise.
|
216 |
+
* @method eof
|
217 |
+
*/
|
218 |
+
eof: function(){
|
219 |
+
return (this._cursor == this._input.length);
|
220 |
+
},
|
221 |
+
|
222 |
+
//-------------------------------------------------------------------------
|
223 |
+
// Basic reading
|
224 |
+
//-------------------------------------------------------------------------
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Reads the next character without advancing the cursor.
|
228 |
+
* @param {int} count How many characters to look ahead (default is 1).
|
229 |
+
* @return {String} The next character or null if there is no next character.
|
230 |
+
* @method peek
|
231 |
+
*/
|
232 |
+
peek: function(count){
|
233 |
+
var c = null;
|
234 |
+
count = (typeof count == "undefined" ? 1 : count);
|
235 |
+
|
236 |
+
//if we're not at the end of the input...
|
237 |
+
if (this._cursor < this._input.length){
|
238 |
+
|
239 |
+
//get character and increment cursor and column
|
240 |
+
c = this._input.charAt(this._cursor + count - 1);
|
241 |
+
}
|
242 |
+
|
243 |
+
return c;
|
244 |
+
},
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Reads the next character from the input and adjusts the row and column
|
248 |
+
* accordingly.
|
249 |
+
* @return {String} The next character or null if there is no next character.
|
250 |
+
* @method read
|
251 |
+
*/
|
252 |
+
read: function(){
|
253 |
+
var c = null;
|
254 |
+
|
255 |
+
//if we're not at the end of the input...
|
256 |
+
if (this._cursor < this._input.length){
|
257 |
+
|
258 |
+
//if the last character was a newline, increment row count
|
259 |
+
//and reset column count
|
260 |
+
if (this._input.charAt(this._cursor) == "\n"){
|
261 |
+
this._line++;
|
262 |
+
this._col=1;
|
263 |
+
} else {
|
264 |
+
this._col++;
|
265 |
+
}
|
266 |
+
|
267 |
+
//get character and increment cursor and column
|
268 |
+
c = this._input.charAt(this._cursor++);
|
269 |
+
}
|
270 |
+
|
271 |
+
return c;
|
272 |
+
},
|
273 |
+
|
274 |
+
//-------------------------------------------------------------------------
|
275 |
+
// Misc
|
276 |
+
//-------------------------------------------------------------------------
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Saves the current location so it can be returned to later.
|
280 |
+
* @method mark
|
281 |
+
* @return {void}
|
282 |
+
*/
|
283 |
+
mark: function(){
|
284 |
+
this._bookmark = {
|
285 |
+
cursor: this._cursor,
|
286 |
+
line: this._line,
|
287 |
+
col: this._col
|
288 |
+
};
|
289 |
+
},
|
290 |
+
|
291 |
+
reset: function(){
|
292 |
+
if (this._bookmark){
|
293 |
+
this._cursor = this._bookmark.cursor;
|
294 |
+
this._line = this._bookmark.line;
|
295 |
+
this._col = this._bookmark.col;
|
296 |
+
delete this._bookmark;
|
297 |
+
}
|
298 |
+
},
|
299 |
+
|
300 |
+
//-------------------------------------------------------------------------
|
301 |
+
// Advanced reading
|
302 |
+
//-------------------------------------------------------------------------
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Reads up to and including the given string. Throws an error if that
|
306 |
+
* string is not found.
|
307 |
+
* @param {String} pattern The string to read.
|
308 |
+
* @return {String} The string when it is found.
|
309 |
+
* @throws Error when the string pattern is not found.
|
310 |
+
* @method readTo
|
311 |
+
*/
|
312 |
+
readTo: function(pattern){
|
313 |
+
|
314 |
+
var buffer = "",
|
315 |
+
c;
|
316 |
+
|
317 |
+
/*
|
318 |
+
* First, buffer must be the same length as the pattern.
|
319 |
+
* Then, buffer must end with the pattern or else reach the
|
320 |
+
* end of the input.
|
321 |
+
*/
|
322 |
+
while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) != buffer.length - pattern.length){
|
323 |
+
c = this.read();
|
324 |
+
if (c){
|
325 |
+
buffer += c;
|
326 |
+
} else {
|
327 |
+
throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
|
328 |
+
}
|
329 |
+
}
|
330 |
+
|
331 |
+
return buffer;
|
332 |
+
|
333 |
+
},
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Reads characters while each character causes the given
|
337 |
+
* filter function to return true. The function is passed
|
338 |
+
* in each character and either returns true to continue
|
339 |
+
* reading or false to stop.
|
340 |
+
* @param {Function} filter The function to read on each character.
|
341 |
+
* @return {String} The string made up of all characters that passed the
|
342 |
+
* filter check.
|
343 |
+
* @method readWhile
|
344 |
+
*/
|
345 |
+
readWhile: function(filter){
|
346 |
+
|
347 |
+
var buffer = "",
|
348 |
+
c = this.read();
|
349 |
+
|
350 |
+
while(c !== null && filter(c)){
|
351 |
+
buffer += c;
|
352 |
+
c = this.read();
|
353 |
+
}
|
354 |
+
|
355 |
+
return buffer;
|
356 |
+
|
357 |
+
},
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Reads characters that match either text or a regular expression and
|
361 |
+
* returns those characters. If a match is found, the row and column
|
362 |
+
* are adjusted; if no match is found, the reader's state is unchanged.
|
363 |
+
* reading or false to stop.
|
364 |
+
* @param {String|RegExp} matchter If a string, then the literal string
|
365 |
+
* value is searched for. If a regular expression, then any string
|
366 |
+
* matching the pattern is search for.
|
367 |
+
* @return {String} The string made up of all characters that matched or
|
368 |
+
* null if there was no match.
|
369 |
+
* @method readMatch
|
370 |
+
*/
|
371 |
+
readMatch: function(matcher){
|
372 |
+
|
373 |
+
var source = this._input.substring(this._cursor),
|
374 |
+
value = null;
|
375 |
+
|
376 |
+
//if it's a string, just do a straight match
|
377 |
+
if (typeof matcher == "string"){
|
378 |
+
if (source.indexOf(matcher) === 0){
|
379 |
+
value = this.readCount(matcher.length);
|
380 |
+
}
|
381 |
+
} else if (matcher instanceof RegExp){
|
382 |
+
if (matcher.test(source)){
|
383 |
+
value = this.readCount(RegExp.lastMatch.length);
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
return value;
|
388 |
+
},
|
389 |
+
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Reads a given number of characters. If the end of the input is reached,
|
393 |
+
* it reads only the remaining characters and does not throw an error.
|
394 |
+
* @param {int} count The number of characters to read.
|
395 |
+
* @return {String} The string made up the read characters.
|
396 |
+
* @method readCount
|
397 |
+
*/
|
398 |
+
readCount: function(count){
|
399 |
+
var buffer = "";
|
400 |
+
|
401 |
+
while(count--){
|
402 |
+
buffer += this.read();
|
403 |
+
}
|
404 |
+
|
405 |
+
return buffer;
|
406 |
+
}
|
407 |
+
|
408 |
+
};
|
409 |
+
/**
|
410 |
+
* Type to use when a syntax error occurs.
|
411 |
+
* @class SyntaxError
|
412 |
+
* @namespace parserlib.util
|
413 |
+
* @constructor
|
414 |
+
* @param {String} message The error message.
|
415 |
+
* @param {int} line The line at which the error occurred.
|
416 |
+
* @param {int} col The column at which the error occurred.
|
417 |
+
*/
|
418 |
+
function SyntaxError(message, line, col){
|
419 |
+
|
420 |
+
/**
|
421 |
+
* The column at which the error occurred.
|
422 |
+
* @type int
|
423 |
+
* @property col
|
424 |
+
*/
|
425 |
+
this.col = col;
|
426 |
+
|
427 |
+
/**
|
428 |
+
* The line at which the error occurred.
|
429 |
+
* @type int
|
430 |
+
* @property line
|
431 |
+
*/
|
432 |
+
this.line = line;
|
433 |
+
|
434 |
+
/**
|
435 |
+
* The text representation of the unit.
|
436 |
+
* @type String
|
437 |
+
* @property text
|
438 |
+
*/
|
439 |
+
this.message = message;
|
440 |
+
|
441 |
+
}
|
442 |
+
|
443 |
+
//inherit from Error
|
444 |
+
SyntaxError.prototype = new Error();
|
445 |
+
/**
|
446 |
+
* Base type to represent a single syntactic unit.
|
447 |
+
* @class SyntaxUnit
|
448 |
+
* @namespace parserlib.util
|
449 |
+
* @constructor
|
450 |
+
* @param {String} text The text of the unit.
|
451 |
+
* @param {int} line The line of text on which the unit resides.
|
452 |
+
* @param {int} col The column of text on which the unit resides.
|
453 |
+
*/
|
454 |
+
function SyntaxUnit(text, line, col, type){
|
455 |
+
|
456 |
+
|
457 |
+
/**
|
458 |
+
* The column of text on which the unit resides.
|
459 |
+
* @type int
|
460 |
+
* @property col
|
461 |
+
*/
|
462 |
+
this.col = col;
|
463 |
+
|
464 |
+
/**
|
465 |
+
* The line of text on which the unit resides.
|
466 |
+
* @type int
|
467 |
+
* @property line
|
468 |
+
*/
|
469 |
+
this.line = line;
|
470 |
+
|
471 |
+
/**
|
472 |
+
* The text representation of the unit.
|
473 |
+
* @type String
|
474 |
+
* @property text
|
475 |
+
*/
|
476 |
+
this.text = text;
|
477 |
+
|
478 |
+
/**
|
479 |
+
* The type of syntax unit.
|
480 |
+
* @type int
|
481 |
+
* @property type
|
482 |
+
*/
|
483 |
+
this.type = type;
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Create a new syntax unit based solely on the given token.
|
488 |
+
* Convenience method for creating a new syntax unit when
|
489 |
+
* it represents a single token instead of multiple.
|
490 |
+
* @param {Object} token The token object to represent.
|
491 |
+
* @return {parserlib.util.SyntaxUnit} The object representing the token.
|
492 |
+
* @static
|
493 |
+
* @method fromToken
|
494 |
+
*/
|
495 |
+
SyntaxUnit.fromToken = function(token){
|
496 |
+
return new SyntaxUnit(token.value, token.startLine, token.startCol);
|
497 |
+
};
|
498 |
+
|
499 |
+
SyntaxUnit.prototype = {
|
500 |
+
|
501 |
+
//restore constructor
|
502 |
+
constructor: SyntaxUnit,
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Returns the text representation of the unit.
|
506 |
+
* @return {String} The text representation of the unit.
|
507 |
+
* @method valueOf
|
508 |
+
*/
|
509 |
+
valueOf: function(){
|
510 |
+
return this.toString();
|
511 |
+
},
|
512 |
+
|
513 |
+
/**
|
514 |
+
* Returns the text representation of the unit.
|
515 |
+
* @return {String} The text representation of the unit.
|
516 |
+
* @method toString
|
517 |
+
*/
|
518 |
+
toString: function(){
|
519 |
+
return this.text;
|
520 |
+
}
|
521 |
+
|
522 |
+
};
|
523 |
+
/*global StringReader, SyntaxError*/
|
524 |
+
|
525 |
+
/**
|
526 |
+
* Generic TokenStream providing base functionality.
|
527 |
+
* @class TokenStreamBase
|
528 |
+
* @namespace parserlib.util
|
529 |
+
* @constructor
|
530 |
+
* @param {String|StringReader} input The text to tokenize or a reader from
|
531 |
+
* which to read the input.
|
532 |
+
*/
|
533 |
+
function TokenStreamBase(input, tokenData){
|
534 |
+
|
535 |
+
/**
|
536 |
+
* The string reader for easy access to the text.
|
537 |
+
* @type StringReader
|
538 |
+
* @property _reader
|
539 |
+
* @private
|
540 |
+
*/
|
541 |
+
this._reader = input ? new StringReader(input.toString()) : null;
|
542 |
+
|
543 |
+
/**
|
544 |
+
* Token object for the last consumed token.
|
545 |
+
* @type Token
|
546 |
+
* @property _token
|
547 |
+
* @private
|
548 |
+
*/
|
549 |
+
this._token = null;
|
550 |
+
|
551 |
+
/**
|
552 |
+
* The array of token information.
|
553 |
+
* @type Array
|
554 |
+
* @property _tokenData
|
555 |
+
* @private
|
556 |
+
*/
|
557 |
+
this._tokenData = tokenData;
|
558 |
+
|
559 |
+
/**
|
560 |
+
* Lookahead token buffer.
|
561 |
+
* @type Array
|
562 |
+
* @property _lt
|
563 |
+
* @private
|
564 |
+
*/
|
565 |
+
this._lt = [];
|
566 |
+
|
567 |
+
/**
|
568 |
+
* Lookahead token buffer index.
|
569 |
+
* @type int
|
570 |
+
* @property _ltIndex
|
571 |
+
* @private
|
572 |
+
*/
|
573 |
+
this._ltIndex = 0;
|
574 |
+
|
575 |
+
this._ltIndexCache = [];
|
576 |
+
}
|
577 |
+
|
578 |
+
/**
|
579 |
+
* Accepts an array of token information and outputs
|
580 |
+
* an array of token data containing key-value mappings
|
581 |
+
* and matching functions that the TokenStream needs.
|
582 |
+
* @param {Array} tokens An array of token descriptors.
|
583 |
+
* @return {Array} An array of processed token data.
|
584 |
+
* @method createTokenData
|
585 |
+
* @static
|
586 |
+
*/
|
587 |
+
TokenStreamBase.createTokenData = function(tokens){
|
588 |
+
|
589 |
+
var nameMap = [],
|
590 |
+
typeMap = {},
|
591 |
+
tokenData = tokens.concat([]),
|
592 |
+
i = 0,
|
593 |
+
len = tokenData.length+1;
|
594 |
+
|
595 |
+
tokenData.UNKNOWN = -1;
|
596 |
+
tokenData.unshift({name:"EOF"});
|
597 |
+
|
598 |
+
for (; i < len; i++){
|
599 |
+
nameMap.push(tokenData[i].name);
|
600 |
+
tokenData[tokenData[i].name] = i;
|
601 |
+
if (tokenData[i].text){
|
602 |
+
typeMap[tokenData[i].text] = i;
|
603 |
+
}
|
604 |
+
}
|
605 |
+
|
606 |
+
tokenData.name = function(tt){
|
607 |
+
return nameMap[tt];
|
608 |
+
};
|
609 |
+
|
610 |
+
tokenData.type = function(c){
|
611 |
+
return typeMap[c];
|
612 |
+
};
|
613 |
+
|
614 |
+
return tokenData;
|
615 |
+
};
|
616 |
+
|
617 |
+
TokenStreamBase.prototype = {
|
618 |
+
|
619 |
+
//restore constructor
|
620 |
+
constructor: TokenStreamBase,
|
621 |
+
|
622 |
+
//-------------------------------------------------------------------------
|
623 |
+
// Matching methods
|
624 |
+
//-------------------------------------------------------------------------
|
625 |
+
|
626 |
+
/**
|
627 |
+
* Determines if the next token matches the given token type.
|
628 |
+
* If so, that token is consumed; if not, the token is placed
|
629 |
+
* back onto the token stream. You can pass in any number of
|
630 |
+
* token types and this will return true if any of the token
|
631 |
+
* types is found.
|
632 |
+
* @param {int|int[]} tokenTypes Either a single token type or an array of
|
633 |
+
* token types that the next token might be. If an array is passed,
|
634 |
+
* it's assumed that the token can be any of these.
|
635 |
+
* @param {variant} channel (Optional) The channel to read from. If not
|
636 |
+
* provided, reads from the default (unnamed) channel.
|
637 |
+
* @return {Boolean} True if the token type matches, false if not.
|
638 |
+
* @method match
|
639 |
+
*/
|
640 |
+
match: function(tokenTypes, channel){
|
641 |
+
|
642 |
+
//always convert to an array, makes things easier
|
643 |
+
if (!(tokenTypes instanceof Array)){
|
644 |
+
tokenTypes = [tokenTypes];
|
645 |
+
}
|
646 |
+
|
647 |
+
var tt = this.get(channel),
|
648 |
+
i = 0,
|
649 |
+
len = tokenTypes.length;
|
650 |
+
|
651 |
+
while(i < len){
|
652 |
+
if (tt == tokenTypes[i++]){
|
653 |
+
return true;
|
654 |
+
}
|
655 |
+
}
|
656 |
+
|
657 |
+
//no match found, put the token back
|
658 |
+
this.unget();
|
659 |
+
return false;
|
660 |
+
},
|
661 |
+
|
662 |
+
/**
|
663 |
+
* Determines if the next token matches the given token type.
|
664 |
+
* If so, that token is consumed; if not, an error is thrown.
|
665 |
+
* @param {int|int[]} tokenTypes Either a single token type or an array of
|
666 |
+
* token types that the next token should be. If an array is passed,
|
667 |
+
* it's assumed that the token must be one of these.
|
668 |
+
* @param {variant} channel (Optional) The channel to read from. If not
|
669 |
+
* provided, reads from the default (unnamed) channel.
|
670 |
+
* @return {void}
|
671 |
+
* @method mustMatch
|
672 |
+
*/
|
673 |
+
mustMatch: function(tokenTypes, channel){
|
674 |
+
|
675 |
+
var token;
|
676 |
+
|
677 |
+
//always convert to an array, makes things easier
|
678 |
+
if (!(tokenTypes instanceof Array)){
|
679 |
+
tokenTypes = [tokenTypes];
|
680 |
+
}
|
681 |
+
|
682 |
+
if (!this.match.apply(this, arguments)){
|
683 |
+
token = this.LT(1);
|
684 |
+
throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
|
685 |
+
" at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
|
686 |
+
}
|
687 |
+
},
|
688 |
+
|
689 |
+
//-------------------------------------------------------------------------
|
690 |
+
// Consuming methods
|
691 |
+
//-------------------------------------------------------------------------
|
692 |
+
|
693 |
+
/**
|
694 |
+
* Keeps reading from the token stream until either one of the specified
|
695 |
+
* token types is found or until the end of the input is reached.
|
696 |
+
* @param {int|int[]} tokenTypes Either a single token type or an array of
|
697 |
+
* token types that the next token should be. If an array is passed,
|
698 |
+
* it's assumed that the token must be one of these.
|
699 |
+
* @param {variant} channel (Optional) The channel to read from. If not
|
700 |
+
* provided, reads from the default (unnamed) channel.
|
701 |
+
* @return {void}
|
702 |
+
* @method advance
|
703 |
+
*/
|
704 |
+
advance: function(tokenTypes, channel){
|
705 |
+
|
706 |
+
while(this.LA(0) !== 0 && !this.match(tokenTypes, channel)){
|
707 |
+
this.get();
|
708 |
+
}
|
709 |
+
|
710 |
+
return this.LA(0);
|
711 |
+
},
|
712 |
+
|
713 |
+
/**
|
714 |
+
* Consumes the next token from the token stream.
|
715 |
+
* @return {int} The token type of the token that was just consumed.
|
716 |
+
* @method get
|
717 |
+
*/
|
718 |
+
get: function(channel){
|
719 |
+
|
720 |
+
var tokenInfo = this._tokenData,
|
721 |
+
reader = this._reader,
|
722 |
+
value,
|
723 |
+
i =0,
|
724 |
+
len = tokenInfo.length,
|
725 |
+
found = false,
|
726 |
+
token,
|
727 |
+
info;
|
728 |
+
|
729 |
+
//check the lookahead buffer first
|
730 |
+
if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length){
|
731 |
+
|
732 |
+
i++;
|
733 |
+
this._token = this._lt[this._ltIndex++];
|
734 |
+
info = tokenInfo[this._token.type];
|
735 |
+
|
736 |
+
//obey channels logic
|
737 |
+
while((info.channel !== undefined && channel !== info.channel) &&
|
738 |
+
this._ltIndex < this._lt.length){
|
739 |
+
this._token = this._lt[this._ltIndex++];
|
740 |
+
info = tokenInfo[this._token.type];
|
741 |
+
i++;
|
742 |
+
}
|
743 |
+
|
744 |
+
//here be dragons
|
745 |
+
if ((info.channel === undefined || channel === info.channel) &&
|
746 |
+
this._ltIndex <= this._lt.length){
|
747 |
+
this._ltIndexCache.push(i);
|
748 |
+
return this._token.type;
|
749 |
+
}
|
750 |
+
}
|
751 |
+
|
752 |
+
//call token retriever method
|
753 |
+
token = this._getToken();
|
754 |
+
|
755 |
+
//if it should be hidden, don't save a token
|
756 |
+
if (token.type > -1 && !tokenInfo[token.type].hide){
|
757 |
+
|
758 |
+
//apply token channel
|
759 |
+
token.channel = tokenInfo[token.type].channel;
|
760 |
+
|
761 |
+
//save for later
|
762 |
+
this._token = token;
|
763 |
+
this._lt.push(token);
|
764 |
+
|
765 |
+
//save space that will be moved (must be done before array is truncated)
|
766 |
+
this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
|
767 |
+
|
768 |
+
//keep the buffer under 5 items
|
769 |
+
if (this._lt.length > 5){
|
770 |
+
this._lt.shift();
|
771 |
+
}
|
772 |
+
|
773 |
+
//also keep the shift buffer under 5 items
|
774 |
+
if (this._ltIndexCache.length > 5){
|
775 |
+
this._ltIndexCache.shift();
|
776 |
+
}
|
777 |
+
|
778 |
+
//update lookahead index
|
779 |
+
this._ltIndex = this._lt.length;
|
780 |
+
}
|
781 |
+
|
782 |
+
/*
|
783 |
+
* Skip to the next token if:
|
784 |
+
* 1. The token type is marked as hidden.
|
785 |
+
* 2. The token type has a channel specified and it isn't the current channel.
|
786 |
+
*/
|
787 |
+
info = tokenInfo[token.type];
|
788 |
+
if (info &&
|
789 |
+
(info.hide ||
|
790 |
+
(info.channel !== undefined && channel !== info.channel))){
|
791 |
+
return this.get(channel);
|
792 |
+
} else {
|
793 |
+
//return just the type
|
794 |
+
return token.type;
|
795 |
+
}
|
796 |
+
},
|
797 |
+
|
798 |
+
/**
|
799 |
+
* Looks ahead a certain number of tokens and returns the token type at
|
800 |
+
* that position. This will throw an error if you lookahead past the
|
801 |
+
* end of input, past the size of the lookahead buffer, or back past
|
802 |
+
* the first token in the lookahead buffer.
|
803 |
+
* @param {int} The index of the token type to retrieve. 0 for the
|
804 |
+
* current token, 1 for the next, -1 for the previous, etc.
|
805 |
+
* @return {int} The token type of the token in the given position.
|
806 |
+
* @method LA
|
807 |
+
*/
|
808 |
+
LA: function(index){
|
809 |
+
var total = index,
|
810 |
+
tt;
|
811 |
+
if (index > 0){
|
812 |
+
//TODO: Store 5 somewhere
|
813 |
+
if (index > 5){
|
814 |
+
throw new Error("Too much lookahead.");
|
815 |
+
}
|
816 |
+
|
817 |
+
//get all those tokens
|
818 |
+
while(total){
|
819 |
+
tt = this.get();
|
820 |
+
total--;
|
821 |
+
}
|
822 |
+
|
823 |
+
//unget all those tokens
|
824 |
+
while(total < index){
|
825 |
+
this.unget();
|
826 |
+
total++;
|
827 |
+
}
|
828 |
+
} else if (index < 0){
|
829 |
+
|
830 |
+
if(this._lt[this._ltIndex+index]){
|
831 |
+
tt = this._lt[this._ltIndex+index].type;
|
832 |
+
} else {
|
833 |
+
throw new Error("Too much lookbehind.");
|
834 |
+
}
|
835 |
+
|
836 |
+
} else {
|
837 |
+
tt = this._token.type;
|
838 |
+
}
|
839 |
+
|
840 |
+
return tt;
|
841 |
+
|
842 |
+
},
|
843 |
+
|
844 |
+
/**
|
845 |
+
* Looks ahead a certain number of tokens and returns the token at
|
846 |
+
* that position. This will throw an error if you lookahead past the
|
847 |
+
* end of input, past the size of the lookahead buffer, or back past
|
848 |
+
* the first token in the lookahead buffer.
|
849 |
+
* @param {int} The index of the token type to retrieve. 0 for the
|
850 |
+
* current token, 1 for the next, -1 for the previous, etc.
|
851 |
+
* @return {Object} The token of the token in the given position.
|
852 |
+
* @method LA
|
853 |
+
*/
|
854 |
+
LT: function(index){
|
855 |
+
|
856 |
+
//lookahead first to prime the token buffer
|
857 |
+
this.LA(index);
|
858 |
+
|
859 |
+
//now find the token, subtract one because _ltIndex is already at the next index
|
860 |
+
return this._lt[this._ltIndex+index-1];
|
861 |
+
},
|
862 |
+
|
863 |
+
/**
|
864 |
+
* Returns the token type for the next token in the stream without
|
865 |
+
* consuming it.
|
866 |
+
* @return {int} The token type of the next token in the stream.
|
867 |
+
* @method peek
|
868 |
+
*/
|
869 |
+
peek: function(){
|
870 |
+
return this.LA(1);
|
871 |
+
},
|
872 |
+
|
873 |
+
/**
|
874 |
+
* Returns the actual token object for the last consumed token.
|
875 |
+
* @return {Token} The token object for the last consumed token.
|
876 |
+
* @method token
|
877 |
+
*/
|
878 |
+
token: function(){
|
879 |
+
return this._token;
|
880 |
+
},
|
881 |
+
|
882 |
+
/**
|
883 |
+
* Returns the name of the token for the given token type.
|
884 |
+
* @param {int} tokenType The type of token to get the name of.
|
885 |
+
* @return {String} The name of the token or "UNKNOWN_TOKEN" for any
|
886 |
+
* invalid token type.
|
887 |
+
* @method tokenName
|
888 |
+
*/
|
889 |
+
tokenName: function(tokenType){
|
890 |
+
if (tokenType < 0 || tokenType > this._tokenData.length){
|
891 |
+
return "UNKNOWN_TOKEN";
|
892 |
+
} else {
|
893 |
+
return this._tokenData[tokenType].name;
|
894 |
+
}
|
895 |
+
},
|
896 |
+
|
897 |
+
/**
|
898 |
+
* Returns the token type value for the given token name.
|
899 |
+
* @param {String} tokenName The name of the token whose value should be returned.
|
900 |
+
* @return {int} The token type value for the given token name or -1
|
901 |
+
* for an unknown token.
|
902 |
+
* @method tokenName
|
903 |
+
*/
|
904 |
+
tokenType: function(tokenName){
|
905 |
+
return this._tokenData[tokenName] || -1;
|
906 |
+
},
|
907 |
+
|
908 |
+
/**
|
909 |
+
* Returns the last consumed token to the token stream.
|
910 |
+
* @method unget
|
911 |
+
*/
|
912 |
+
unget: function(){
|
913 |
+
//if (this._ltIndex > -1){
|
914 |
+
if (this._ltIndexCache.length){
|
915 |
+
this._ltIndex -= this._ltIndexCache.pop();//--;
|
916 |
+
this._token = this._lt[this._ltIndex - 1];
|
917 |
+
} else {
|
918 |
+
throw new Error("Too much lookahead.");
|
919 |
+
}
|
920 |
+
}
|
921 |
+
|
922 |
+
};
|
923 |
+
|
924 |
+
|
925 |
+
|
926 |
+
|
927 |
+
parserlib.util = {
|
928 |
+
StringReader: StringReader,
|
929 |
+
SyntaxError : SyntaxError,
|
930 |
+
SyntaxUnit : SyntaxUnit,
|
931 |
+
EventTarget : EventTarget,
|
932 |
+
TokenStreamBase : TokenStreamBase
|
933 |
+
};
|
934 |
+
})();
|
935 |
+
|
936 |
+
|
937 |
+
/*
|
938 |
+
Parser-Lib
|
939 |
+
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
|
940 |
+
|
941 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
942 |
+
of this software and associated documentation files (the "Software"), to deal
|
943 |
+
in the Software without restriction, including without limitation the rights
|
944 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
945 |
+
copies of the Software, and to permit persons to whom the Software is
|
946 |
+
furnished to do so, subject to the following conditions:
|
947 |
+
|
948 |
+
The above copyright notice and this permission notice shall be included in
|
949 |
+
all copies or substantial portions of the Software.
|
950 |
+
|
951 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
952 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
953 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
954 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
955 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
956 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
957 |
+
THE SOFTWARE.
|
958 |
+
|
959 |
+
*/
|
960 |
+
/* Version v0.2.3, Build time: 19-June-2013 11:16:15 */
|
961 |
+
(function(){
|
962 |
+
var EventTarget = parserlib.util.EventTarget,
|
963 |
+
TokenStreamBase = parserlib.util.TokenStreamBase,
|
964 |
+
StringReader = parserlib.util.StringReader,
|
965 |
+
SyntaxError = parserlib.util.SyntaxError,
|
966 |
+
SyntaxUnit = parserlib.util.SyntaxUnit;
|
967 |
+
|
968 |
+
|
969 |
+
var Colors = {
|
970 |
+
aliceblue :"#f0f8ff",
|
971 |
+
antiquewhite :"#faebd7",
|
972 |
+
aqua :"#00ffff",
|
973 |
+
aquamarine :"#7fffd4",
|
974 |
+
azure :"#f0ffff",
|
975 |
+
beige :"#f5f5dc",
|
976 |
+
bisque :"#ffe4c4",
|
977 |
+
black :"#000000",
|
978 |
+
blanchedalmond :"#ffebcd",
|
979 |
+
blue :"#0000ff",
|
980 |
+
blueviolet :"#8a2be2",
|
981 |
+
brown :"#a52a2a",
|
982 |
+
burlywood :"#deb887",
|
983 |
+
cadetblue :"#5f9ea0",
|
984 |
+
chartreuse :"#7fff00",
|
985 |
+
chocolate :"#d2691e",
|
986 |
+
coral :"#ff7f50",
|
987 |
+
cornflowerblue :"#6495ed",
|
988 |
+
cornsilk :"#fff8dc",
|
989 |
+
crimson :"#dc143c",
|
990 |
+
cyan :"#00ffff",
|
991 |
+
darkblue :"#00008b",
|
992 |
+
darkcyan :"#008b8b",
|
993 |
+
darkgoldenrod :"#b8860b",
|
994 |
+
darkgray :"#a9a9a9",
|
995 |
+
darkgreen :"#006400",
|
996 |
+
darkkhaki :"#bdb76b",
|
997 |
+
darkmagenta :"#8b008b",
|
998 |
+
darkolivegreen :"#556b2f",
|
999 |
+
darkorange :"#ff8c00",
|
1000 |
+
darkorchid :"#9932cc",
|
1001 |
+
darkred :"#8b0000",
|
1002 |
+
darksalmon :"#e9967a",
|
1003 |
+
darkseagreen :"#8fbc8f",
|
1004 |
+
darkslateblue :"#483d8b",
|
1005 |
+
darkslategray :"#2f4f4f",
|
1006 |
+
darkturquoise :"#00ced1",
|
1007 |
+
darkviolet :"#9400d3",
|
1008 |
+
deeppink :"#ff1493",
|
1009 |
+
deepskyblue :"#00bfff",
|
1010 |
+
dimgray :"#696969",
|
1011 |
+
dodgerblue :"#1e90ff",
|
1012 |
+
firebrick :"#b22222",
|
1013 |
+
floralwhite :"#fffaf0",
|
1014 |
+
forestgreen :"#228b22",
|
1015 |
+
fuchsia :"#ff00ff",
|
1016 |
+
gainsboro :"#dcdcdc",
|
1017 |
+
ghostwhite :"#f8f8ff",
|
1018 |
+
gold :"#ffd700",
|
1019 |
+
goldenrod :"#daa520",
|
1020 |
+
gray :"#808080",
|
1021 |
+
green :"#008000",
|
1022 |
+
greenyellow :"#adff2f",
|
1023 |
+
honeydew :"#f0fff0",
|
1024 |
+
hotpink :"#ff69b4",
|
1025 |
+
indianred :"#cd5c5c",
|
1026 |
+
indigo :"#4b0082",
|
1027 |
+
ivory :"#fffff0",
|
1028 |
+
khaki :"#f0e68c",
|
1029 |
+
lavender :"#e6e6fa",
|
1030 |
+
lavenderblush :"#fff0f5",
|
1031 |
+
lawngreen :"#7cfc00",
|
1032 |
+
lemonchiffon :"#fffacd",
|
1033 |
+
lightblue :"#add8e6",
|
1034 |
+
lightcoral :"#f08080",
|
1035 |
+
lightcyan :"#e0ffff",
|
1036 |
+
lightgoldenrodyellow :"#fafad2",
|
1037 |
+
lightgray :"#d3d3d3",
|
1038 |
+
lightgreen :"#90ee90",
|
1039 |
+
lightpink :"#ffb6c1",
|
1040 |
+
lightsalmon :"#ffa07a",
|
1041 |
+
lightseagreen :"#20b2aa",
|
1042 |
+
lightskyblue :"#87cefa",
|
1043 |
+
lightslategray :"#778899",
|
1044 |
+
lightsteelblue :"#b0c4de",
|
1045 |
+
lightyellow :"#ffffe0",
|
1046 |
+
lime :"#00ff00",
|
1047 |
+
limegreen :"#32cd32",
|
1048 |
+
linen :"#faf0e6",
|
1049 |
+
magenta :"#ff00ff",
|
1050 |
+
maroon :"#800000",
|
1051 |
+
mediumaquamarine:"#66cdaa",
|
1052 |
+
mediumblue :"#0000cd",
|
1053 |
+
mediumorchid :"#ba55d3",
|
1054 |
+
mediumpurple :"#9370d8",
|
1055 |
+
mediumseagreen :"#3cb371",
|
1056 |
+
mediumslateblue :"#7b68ee",
|
1057 |
+
mediumspringgreen :"#00fa9a",
|
1058 |
+
mediumturquoise :"#48d1cc",
|
1059 |
+
mediumvioletred :"#c71585",
|
1060 |
+
midnightblue :"#191970",
|
1061 |
+
mintcream :"#f5fffa",
|
1062 |
+
mistyrose :"#ffe4e1",
|
1063 |
+
moccasin :"#ffe4b5",
|
1064 |
+
navajowhite :"#ffdead",
|
1065 |
+
navy :"#000080",
|
1066 |
+
oldlace :"#fdf5e6",
|
1067 |
+
olive :"#808000",
|
1068 |
+
olivedrab :"#6b8e23",
|
1069 |
+
orange :"#ffa500",
|
1070 |
+
orangered :"#ff4500",
|
1071 |
+
orchid :"#da70d6",
|
1072 |
+
palegoldenrod :"#eee8aa",
|
1073 |
+
palegreen :"#98fb98",
|
1074 |
+
paleturquoise :"#afeeee",
|
1075 |
+
palevioletred :"#d87093",
|
1076 |
+
papayawhip :"#ffefd5",
|
1077 |
+
peachpuff :"#ffdab9",
|
1078 |
+
peru :"#cd853f",
|
1079 |
+
pink :"#ffc0cb",
|
1080 |
+
plum :"#dda0dd",
|
1081 |
+
powderblue :"#b0e0e6",
|
1082 |
+
purple :"#800080",
|
1083 |
+
red :"#ff0000",
|
1084 |
+
rosybrown :"#bc8f8f",
|
1085 |
+
royalblue :"#4169e1",
|
1086 |
+
saddlebrown :"#8b4513",
|
1087 |
+
salmon :"#fa8072",
|
1088 |
+
sandybrown :"#f4a460",
|
1089 |
+
seagreen :"#2e8b57",
|
1090 |
+
seashell :"#fff5ee",
|
1091 |
+
sienna :"#a0522d",
|
1092 |
+
silver :"#c0c0c0",
|
1093 |
+
skyblue :"#87ceeb",
|
1094 |
+
slateblue :"#6a5acd",
|
1095 |
+
slategray :"#708090",
|
1096 |
+
snow :"#fffafa",
|
1097 |
+
springgreen :"#00ff7f",
|
1098 |
+
steelblue :"#4682b4",
|
1099 |
+
tan :"#d2b48c",
|
1100 |
+
teal :"#008080",
|
1101 |
+
thistle :"#d8bfd8",
|
1102 |
+
tomato :"#ff6347",
|
1103 |
+
turquoise :"#40e0d0",
|
1104 |
+
violet :"#ee82ee",
|
1105 |
+
wheat :"#f5deb3",
|
1106 |
+
white :"#ffffff",
|
1107 |
+
whitesmoke :"#f5f5f5",
|
1108 |
+
yellow :"#ffff00",
|
1109 |
+
yellowgreen :"#9acd32",
|
1110 |
+
//CSS2 system colors http://www.w3.org/TR/css3-color/#css2-system
|
1111 |
+
activeBorder :"Active window border.",
|
1112 |
+
activecaption :"Active window caption.",
|
1113 |
+
appworkspace :"Background color of multiple document interface.",
|
1114 |
+
background :"Desktop background.",
|
1115 |
+
buttonface :"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
|
1116 |
+
buttonhighlight :"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
|
1117 |
+
buttonshadow :"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
|
1118 |
+
buttontext :"Text on push buttons.",
|
1119 |
+
captiontext :"Text in caption, size box, and scrollbar arrow box.",
|
1120 |
+
graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
|
1121 |
+
highlight :"Item(s) selected in a control.",
|
1122 |
+
highlighttext :"Text of item(s) selected in a control.",
|
1123 |
+
inactiveborder :"Inactive window border.",
|
1124 |
+
inactivecaption :"Inactive window caption.",
|
1125 |
+
inactivecaptiontext :"Color of text in an inactive caption.",
|
1126 |
+
infobackground :"Background color for tooltip controls.",
|
1127 |
+
infotext :"Text color for tooltip controls.",
|
1128 |
+
menu :"Menu background.",
|
1129 |
+
menutext :"Text in menus.",
|
1130 |
+
scrollbar :"Scroll bar gray area.",
|
1131 |
+
threeddarkshadow :"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
|
1132 |
+
threedface :"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
|
1133 |
+
threedhighlight :"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
|
1134 |
+
threedlightshadow :"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
|
1135 |
+
threedshadow :"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
|
1136 |
+
window :"Window background.",
|
1137 |
+
windowframe :"Window frame.",
|
1138 |
+
windowtext :"Text in windows."
|
1139 |
+
};
|
1140 |
+
/*global SyntaxUnit, Parser*/
|
1141 |
+
/**
|
1142 |
+
* Represents a selector combinator (whitespace, +, >).
|
1143 |
+
* @namespace parserlib.css
|
1144 |
+
* @class Combinator
|
1145 |
+
* @extends parserlib.util.SyntaxUnit
|
1146 |
+
* @constructor
|
1147 |
+
* @param {String} text The text representation of the unit.
|
1148 |
+
* @param {int} line The line of text on which the unit resides.
|
1149 |
+
* @param {int} col The column of text on which the unit resides.
|
1150 |
+
*/
|
1151 |
+
function Combinator(text, line, col){
|
1152 |
+
|
1153 |
+
SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
|
1154 |
+
|
1155 |
+
/**
|
1156 |
+
* The type of modifier.
|
1157 |
+
* @type String
|
1158 |
+
* @property type
|
1159 |
+
*/
|
1160 |
+
this.type = "unknown";
|
1161 |
+
|
1162 |
+
//pretty simple
|
1163 |
+
if (/^\s+$/.test(text)){
|
1164 |
+
this.type = "descendant";
|
1165 |
+
} else if (text == ">"){
|
1166 |
+
this.type = "child";
|
1167 |
+
} else if (text == "+"){
|
1168 |
+
this.type = "adjacent-sibling";
|
1169 |
+
} else if (text == "~"){
|
1170 |
+
this.type = "sibling";
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
Combinator.prototype = new SyntaxUnit();
|
1176 |
+
Combinator.prototype.constructor = Combinator;
|
1177 |
+
|
1178 |
+
|
1179 |
+
/*global SyntaxUnit, Parser*/
|
1180 |
+
/**
|
1181 |
+
* Represents a media feature, such as max-width:500.
|
1182 |
+
* @namespace parserlib.css
|
1183 |
+
* @class MediaFeature
|
1184 |
+
* @extends parserlib.util.SyntaxUnit
|
1185 |
+
* @constructor
|
1186 |
+
* @param {SyntaxUnit} name The name of the feature.
|
1187 |
+
* @param {SyntaxUnit} value The value of the feature or null if none.
|
1188 |
+
*/
|
1189 |
+
function MediaFeature(name, value){
|
1190 |
+
|
1191 |
+
SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
|
1192 |
+
|
1193 |
+
/**
|
1194 |
+
* The name of the media feature
|
1195 |
+
* @type String
|
1196 |
+
* @property name
|
1197 |
+
*/
|
1198 |
+
this.name = name;
|
1199 |
+
|
1200 |
+
/**
|
1201 |
+
* The value for the feature or null if there is none.
|
1202 |
+
* @type SyntaxUnit
|
1203 |
+
* @property value
|
1204 |
+
*/
|
1205 |
+
this.value = value;
|
1206 |
+
}
|
1207 |
+
|
1208 |
+
MediaFeature.prototype = new SyntaxUnit();
|
1209 |
+
MediaFeature.prototype.constructor = MediaFeature;
|
1210 |
+
|
1211 |
+
|
1212 |
+
/*global SyntaxUnit, Parser*/
|
1213 |
+
/**
|
1214 |
+
* Represents an individual media query.
|
1215 |
+
* @namespace parserlib.css
|
1216 |
+
* @class MediaQuery
|
1217 |
+
* @extends parserlib.util.SyntaxUnit
|
1218 |
+
* @constructor
|
1219 |
+
* @param {String} modifier The modifier "not" or "only" (or null).
|
1220 |
+
* @param {String} mediaType The type of media (i.e., "print").
|
1221 |
+
* @param {Array} parts Array of selectors parts making up this selector.
|
1222 |
+
* @param {int} line The line of text on which the unit resides.
|
1223 |
+
* @param {int} col The column of text on which the unit resides.
|
1224 |
+
*/
|
1225 |
+
function MediaQuery(modifier, mediaType, features, line, col){
|
1226 |
+
|
1227 |
+
SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
|
1228 |
+
|
1229 |
+
/**
|
1230 |
+
* The media modifier ("not" or "only")
|
1231 |
+
* @type String
|
1232 |
+
* @property modifier
|
1233 |
+
*/
|
1234 |
+
this.modifier = modifier;
|
1235 |
+
|
1236 |
+
/**
|
1237 |
+
* The mediaType (i.e., "print")
|
1238 |
+
* @type String
|
1239 |
+
* @property mediaType
|
1240 |
+
*/
|
1241 |
+
this.mediaType = mediaType;
|
1242 |
+
|
1243 |
+
/**
|
1244 |
+
* The parts that make up the selector.
|
1245 |
+
* @type Array
|
1246 |
+
* @property features
|
1247 |
+
*/
|
1248 |
+
this.features = features;
|
1249 |
+
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
MediaQuery.prototype = new SyntaxUnit();
|
1253 |
+
MediaQuery.prototype.constructor = MediaQuery;
|
1254 |
+
|
1255 |
+
|
1256 |
+
/*global Tokens, TokenStream, SyntaxError, Properties, Validation, ValidationError, SyntaxUnit,
|
1257 |
+
PropertyValue, PropertyValuePart, SelectorPart, SelectorSubPart, Selector,
|
1258 |
+
PropertyName, Combinator, MediaFeature, MediaQuery, EventTarget */
|
1259 |
+
|
1260 |
+
/**
|
1261 |
+
* A CSS3 parser.
|
1262 |
+
* @namespace parserlib.css
|
1263 |
+
* @class Parser
|
1264 |
+
* @constructor
|
1265 |
+
* @param {Object} options (Optional) Various options for the parser:
|
1266 |
+
* starHack (true|false) to allow IE6 star hack as valid,
|
1267 |
+
* underscoreHack (true|false) to interpret leading underscores
|
1268 |
+
* as IE6-7 targeting for known properties, ieFilters (true|false)
|
1269 |
+
* to indicate that IE < 8 filters should be accepted and not throw
|
1270 |
+
* syntax errors.
|
1271 |
+
*/
|
1272 |
+
function Parser(options){
|
1273 |
+
|
1274 |
+
//inherit event functionality
|
1275 |
+
EventTarget.call(this);
|
1276 |
+
|
1277 |
+
|
1278 |
+
this.options = options || {};
|
1279 |
+
|
1280 |
+
this._tokenStream = null;
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
//Static constants
|
1284 |
+
Parser.DEFAULT_TYPE = 0;
|
1285 |
+
Parser.COMBINATOR_TYPE = 1;
|
1286 |
+
Parser.MEDIA_FEATURE_TYPE = 2;
|
1287 |
+
Parser.MEDIA_QUERY_TYPE = 3;
|
1288 |
+
Parser.PROPERTY_NAME_TYPE = 4;
|
1289 |
+
Parser.PROPERTY_VALUE_TYPE = 5;
|
1290 |
+
Parser.PROPERTY_VALUE_PART_TYPE = 6;
|
1291 |
+
Parser.SELECTOR_TYPE = 7;
|
1292 |
+
Parser.SELECTOR_PART_TYPE = 8;
|
1293 |
+
Parser.SELECTOR_SUB_PART_TYPE = 9;
|
1294 |
+
|
1295 |
+
Parser.prototype = function(){
|
1296 |
+
|
1297 |
+
var proto = new EventTarget(), //new prototype
|
1298 |
+
prop,
|
1299 |
+
additions = {
|
1300 |
+
|
1301 |
+
//restore constructor
|
1302 |
+
constructor: Parser,
|
1303 |
+
|
1304 |
+
//instance constants - yuck
|
1305 |
+
DEFAULT_TYPE : 0,
|
1306 |
+
COMBINATOR_TYPE : 1,
|
1307 |
+
MEDIA_FEATURE_TYPE : 2,
|
1308 |
+
MEDIA_QUERY_TYPE : 3,
|
1309 |
+
PROPERTY_NAME_TYPE : 4,
|
1310 |
+
PROPERTY_VALUE_TYPE : 5,
|
1311 |
+
PROPERTY_VALUE_PART_TYPE : 6,
|
1312 |
+
SELECTOR_TYPE : 7,
|
1313 |
+
SELECTOR_PART_TYPE : 8,
|
1314 |
+
SELECTOR_SUB_PART_TYPE : 9,
|
1315 |
+
|
1316 |
+
//-----------------------------------------------------------------
|
1317 |
+
// Grammar
|
1318 |
+
//-----------------------------------------------------------------
|
1319 |
+
|
1320 |
+
_stylesheet: function(){
|
1321 |
+
|
1322 |
+
/*
|
1323 |
+
* stylesheet
|
1324 |
+
* : [ CHARSET_SYM S* STRING S* ';' ]?
|
1325 |
+
* [S|CDO|CDC]* [ import [S|CDO|CDC]* ]*
|
1326 |
+
* [ namespace [S|CDO|CDC]* ]*
|
1327 |
+
* [ [ ruleset | media | page | font_face | keyframes ] [S|CDO|CDC]* ]*
|
1328 |
+
* ;
|
1329 |
+
*/
|
1330 |
+
|
1331 |
+
var tokenStream = this._tokenStream,
|
1332 |
+
charset = null,
|
1333 |
+
count,
|
1334 |
+
token,
|
1335 |
+
tt;
|
1336 |
+
|
1337 |
+
this.fire("startstylesheet");
|
1338 |
+
|
1339 |
+
//try to read character set
|
1340 |
+
this._charset();
|
1341 |
+
|
1342 |
+
this._skipCruft();
|
1343 |
+
|
1344 |
+
//try to read imports - may be more than one
|
1345 |
+
while (tokenStream.peek() == Tokens.IMPORT_SYM){
|
1346 |
+
this._import();
|
1347 |
+
this._skipCruft();
|
1348 |
+
}
|
1349 |
+
|
1350 |
+
//try to read namespaces - may be more than one
|
1351 |
+
while (tokenStream.peek() == Tokens.NAMESPACE_SYM){
|
1352 |
+
this._namespace();
|
1353 |
+
this._skipCruft();
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
//get the next token
|
1357 |
+
tt = tokenStream.peek();
|
1358 |
+
|
1359 |
+
//try to read the rest
|
1360 |
+
while(tt > Tokens.EOF){
|
1361 |
+
|
1362 |
+
try {
|
1363 |
+
|
1364 |
+
switch(tt){
|
1365 |
+
case Tokens.MEDIA_SYM:
|
1366 |
+
this._media();
|
1367 |
+
this._skipCruft();
|
1368 |
+
break;
|
1369 |
+
case Tokens.PAGE_SYM:
|
1370 |
+
this._page();
|
1371 |
+
this._skipCruft();
|
1372 |
+
break;
|
1373 |
+
case Tokens.FONT_FACE_SYM:
|
1374 |
+
this._font_face();
|
1375 |
+
this._skipCruft();
|
1376 |
+
break;
|
1377 |
+
case Tokens.KEYFRAMES_SYM:
|
1378 |
+
this._keyframes();
|
1379 |
+
this._skipCruft();
|
1380 |
+
break;
|
1381 |
+
case Tokens.VIEWPORT_SYM:
|
1382 |
+
this._viewport();
|
1383 |
+
this._skipCruft();
|
1384 |
+
break;
|
1385 |
+
case Tokens.UNKNOWN_SYM: //unknown @ rule
|
1386 |
+
tokenStream.get();
|
1387 |
+
if (!this.options.strict){
|
1388 |
+
|
1389 |
+
//fire error event
|
1390 |
+
this.fire({
|
1391 |
+
type: "error",
|
1392 |
+
error: null,
|
1393 |
+
message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
|
1394 |
+
line: tokenStream.LT(0).startLine,
|
1395 |
+
col: tokenStream.LT(0).startCol
|
1396 |
+
});
|
1397 |
+
|
1398 |
+
//skip braces
|
1399 |
+
count=0;
|
1400 |
+
while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) == Tokens.LBRACE){
|
1401 |
+
count++; //keep track of nesting depth
|
1402 |
+
}
|
1403 |
+
|
1404 |
+
while(count){
|
1405 |
+
tokenStream.advance([Tokens.RBRACE]);
|
1406 |
+
count--;
|
1407 |
+
}
|
1408 |
+
|
1409 |
+
} else {
|
1410 |
+
//not a syntax error, rethrow it
|
1411 |
+
throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
|
1412 |
+
}
|
1413 |
+
break;
|
1414 |
+
case Tokens.S:
|
1415 |
+
this._readWhitespace();
|
1416 |
+
break;
|
1417 |
+
default:
|
1418 |
+
if(!this._ruleset()){
|
1419 |
+
|
1420 |
+
//error handling for known issues
|
1421 |
+
switch(tt){
|
1422 |
+
case Tokens.CHARSET_SYM:
|
1423 |
+
token = tokenStream.LT(1);
|
1424 |
+
this._charset(false);
|
1425 |
+
throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol);
|
1426 |
+
case Tokens.IMPORT_SYM:
|
1427 |
+
token = tokenStream.LT(1);
|
1428 |
+
this._import(false);
|
1429 |
+
throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol);
|
1430 |
+
case Tokens.NAMESPACE_SYM:
|
1431 |
+
token = tokenStream.LT(1);
|
1432 |
+
this._namespace(false);
|
1433 |
+
throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol);
|
1434 |
+
default:
|
1435 |
+
tokenStream.get(); //get the last token
|
1436 |
+
this._unexpectedToken(tokenStream.token());
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
}
|
1440 |
+
}
|
1441 |
+
} catch(ex) {
|
1442 |
+
if (ex instanceof SyntaxError && !this.options.strict){
|
1443 |
+
this.fire({
|
1444 |
+
type: "error",
|
1445 |
+
error: ex,
|
1446 |
+
message: ex.message,
|
1447 |
+
line: ex.line,
|
1448 |
+
col: ex.col
|
1449 |
+
});
|
1450 |
+
} else {
|
1451 |
+
throw ex;
|
1452 |
+
}
|
1453 |
+
}
|
1454 |
+
|
1455 |
+
tt = tokenStream.peek();
|
1456 |
+
}
|
1457 |
+
|
1458 |
+
if (tt != Tokens.EOF){
|
1459 |
+
this._unexpectedToken(tokenStream.token());
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
this.fire("endstylesheet");
|
1463 |
+
},
|
1464 |
+
|
1465 |
+
_charset: function(emit){
|
1466 |
+
var tokenStream = this._tokenStream,
|
1467 |
+
charset,
|
1468 |
+
token,
|
1469 |
+
line,
|
1470 |
+
col;
|
1471 |
+
|
1472 |
+
if (tokenStream.match(Tokens.CHARSET_SYM)){
|
1473 |
+
line = tokenStream.token().startLine;
|
1474 |
+
col = tokenStream.token().startCol;
|
1475 |
+
|
1476 |
+
this._readWhitespace();
|
1477 |
+
tokenStream.mustMatch(Tokens.STRING);
|
1478 |
+
|
1479 |
+
token = tokenStream.token();
|
1480 |
+
charset = token.value;
|
1481 |
+
|
1482 |
+
this._readWhitespace();
|
1483 |
+
tokenStream.mustMatch(Tokens.SEMICOLON);
|
1484 |
+
|
1485 |
+
if (emit !== false){
|
1486 |
+
this.fire({
|
1487 |
+
type: "charset",
|
1488 |
+
charset:charset,
|
1489 |
+
line: line,
|
1490 |
+
col: col
|
1491 |
+
});
|
1492 |
+
}
|
1493 |
+
}
|
1494 |
+
},
|
1495 |
+
|
1496 |
+
_import: function(emit){
|
1497 |
+
/*
|
1498 |
+
* import
|
1499 |
+
* : IMPORT_SYM S*
|
1500 |
+
* [STRING|URI] S* media_query_list? ';' S*
|
1501 |
+
*/
|
1502 |
+
|
1503 |
+
var tokenStream = this._tokenStream,
|
1504 |
+
tt,
|
1505 |
+
uri,
|
1506 |
+
importToken,
|
1507 |
+
mediaList = [];
|
1508 |
+
|
1509 |
+
//read import symbol
|
1510 |
+
tokenStream.mustMatch(Tokens.IMPORT_SYM);
|
1511 |
+
importToken = tokenStream.token();
|
1512 |
+
this._readWhitespace();
|
1513 |
+
|
1514 |
+
tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
|
1515 |
+
|
1516 |
+
//grab the URI value
|
1517 |
+
uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
|
1518 |
+
|
1519 |
+
this._readWhitespace();
|
1520 |
+
|
1521 |
+
mediaList = this._media_query_list();
|
1522 |
+
|
1523 |
+
//must end with a semicolon
|
1524 |
+
tokenStream.mustMatch(Tokens.SEMICOLON);
|
1525 |
+
this._readWhitespace();
|
1526 |
+
|
1527 |
+
if (emit !== false){
|
1528 |
+
this.fire({
|
1529 |
+
type: "import",
|
1530 |
+
uri: uri,
|
1531 |
+
media: mediaList,
|
1532 |
+
line: importToken.startLine,
|
1533 |
+
col: importToken.startCol
|
1534 |
+
});
|
1535 |
+
}
|
1536 |
+
|
1537 |
+
},
|
1538 |
+
|
1539 |
+
_namespace: function(emit){
|
1540 |
+
/*
|
1541 |
+
* namespace
|
1542 |
+
* : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S*
|
1543 |
+
*/
|
1544 |
+
|
1545 |
+
var tokenStream = this._tokenStream,
|
1546 |
+
line,
|
1547 |
+
col,
|
1548 |
+
prefix,
|
1549 |
+
uri;
|
1550 |
+
|
1551 |
+
//read import symbol
|
1552 |
+
tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
|
1553 |
+
line = tokenStream.token().startLine;
|
1554 |
+
col = tokenStream.token().startCol;
|
1555 |
+
this._readWhitespace();
|
1556 |
+
|
1557 |
+
//it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT
|
1558 |
+
if (tokenStream.match(Tokens.IDENT)){
|
1559 |
+
prefix = tokenStream.token().value;
|
1560 |
+
this._readWhitespace();
|
1561 |
+
}
|
1562 |
+
|
1563 |
+
tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
|
1564 |
+
/*if (!tokenStream.match(Tokens.STRING)){
|
1565 |
+
tokenStream.mustMatch(Tokens.URI);
|
1566 |
+
}*/
|
1567 |
+
|
1568 |
+
//grab the URI value
|
1569 |
+
uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
|
1570 |
+
|
1571 |
+
this._readWhitespace();
|
1572 |
+
|
1573 |
+
//must end with a semicolon
|
1574 |
+
tokenStream.mustMatch(Tokens.SEMICOLON);
|
1575 |
+
this._readWhitespace();
|
1576 |
+
|
1577 |
+
if (emit !== false){
|
1578 |
+
this.fire({
|
1579 |
+
type: "namespace",
|
1580 |
+
prefix: prefix,
|
1581 |
+
uri: uri,
|
1582 |
+
line: line,
|
1583 |
+
col: col
|
1584 |
+
});
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
},
|
1588 |
+
|
1589 |
+
_media: function(){
|
1590 |
+
/*
|
1591 |
+
* media
|
1592 |
+
* : MEDIA_SYM S* media_query_list S* '{' S* ruleset* '}' S*
|
1593 |
+
* ;
|
1594 |
+
*/
|
1595 |
+
var tokenStream = this._tokenStream,
|
1596 |
+
line,
|
1597 |
+
col,
|
1598 |
+
mediaList;// = [];
|
1599 |
+
|
1600 |
+
//look for @media
|
1601 |
+
tokenStream.mustMatch(Tokens.MEDIA_SYM);
|
1602 |
+
line = tokenStream.token().startLine;
|
1603 |
+
col = tokenStream.token().startCol;
|
1604 |
+
|
1605 |
+
this._readWhitespace();
|
1606 |
+
|
1607 |
+
mediaList = this._media_query_list();
|
1608 |
+
|
1609 |
+
tokenStream.mustMatch(Tokens.LBRACE);
|
1610 |
+
this._readWhitespace();
|
1611 |
+
|
1612 |
+
this.fire({
|
1613 |
+
type: "startmedia",
|
1614 |
+
media: mediaList,
|
1615 |
+
line: line,
|
1616 |
+
col: col
|
1617 |
+
});
|
1618 |
+
|
1619 |
+
while(true) {
|
1620 |
+
if (tokenStream.peek() == Tokens.PAGE_SYM){
|
1621 |
+
this._page();
|
1622 |
+
} else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){
|
1623 |
+
this._font_face();
|
1624 |
+
} else if (!this._ruleset()){
|
1625 |
+
break;
|
1626 |
+
}
|
1627 |
+
}
|
1628 |
+
|
1629 |
+
tokenStream.mustMatch(Tokens.RBRACE);
|
1630 |
+
this._readWhitespace();
|
1631 |
+
|
1632 |
+
this.fire({
|
1633 |
+
type: "endmedia",
|
1634 |
+
media: mediaList,
|
1635 |
+
line: line,
|
1636 |
+
col: col
|
1637 |
+
});
|
1638 |
+
},
|
1639 |
+
|
1640 |
+
|
1641 |
+
//CSS3 Media Queries
|
1642 |
+
_media_query_list: function(){
|
1643 |
+
/*
|
1644 |
+
* media_query_list
|
1645 |
+
* : S* [media_query [ ',' S* media_query ]* ]?
|
1646 |
+
* ;
|
1647 |
+
*/
|
1648 |
+
var tokenStream = this._tokenStream,
|
1649 |
+
mediaList = [];
|
1650 |
+
|
1651 |
+
|
1652 |
+
this._readWhitespace();
|
1653 |
+
|
1654 |
+
if (tokenStream.peek() == Tokens.IDENT || tokenStream.peek() == Tokens.LPAREN){
|
1655 |
+
mediaList.push(this._media_query());
|
1656 |
+
}
|
1657 |
+
|
1658 |
+
while(tokenStream.match(Tokens.COMMA)){
|
1659 |
+
this._readWhitespace();
|
1660 |
+
mediaList.push(this._media_query());
|
1661 |
+
}
|
1662 |
+
|
1663 |
+
return mediaList;
|
1664 |
+
},
|
1665 |
+
|
1666 |
+
/*
|
1667 |
+
* Note: "expression" in the grammar maps to the _media_expression
|
1668 |
+
* method.
|
1669 |
+
|
1670 |
+
*/
|
1671 |
+
_media_query: function(){
|
1672 |
+
/*
|
1673 |
+
* media_query
|
1674 |
+
* : [ONLY | NOT]? S* media_type S* [ AND S* expression ]*
|
1675 |
+
* | expression [ AND S* expression ]*
|
1676 |
+
* ;
|
1677 |
+
*/
|
1678 |
+
var tokenStream = this._tokenStream,
|
1679 |
+
type = null,
|
1680 |
+
ident = null,
|
1681 |
+
token = null,
|
1682 |
+
expressions = [];
|
1683 |
+
|
1684 |
+
if (tokenStream.match(Tokens.IDENT)){
|
1685 |
+
ident = tokenStream.token().value.toLowerCase();
|
1686 |
+
|
1687 |
+
//since there's no custom tokens for these, need to manually check
|
1688 |
+
if (ident != "only" && ident != "not"){
|
1689 |
+
tokenStream.unget();
|
1690 |
+
ident = null;
|
1691 |
+
} else {
|
1692 |
+
token = tokenStream.token();
|
1693 |
+
}
|
1694 |
+
}
|
1695 |
+
|
1696 |
+
this._readWhitespace();
|
1697 |
+
|
1698 |
+
if (tokenStream.peek() == Tokens.IDENT){
|
1699 |
+
type = this._media_type();
|
1700 |
+
if (token === null){
|
1701 |
+
token = tokenStream.token();
|
1702 |
+
}
|
1703 |
+
} else if (tokenStream.peek() == Tokens.LPAREN){
|
1704 |
+
if (token === null){
|
1705 |
+
token = tokenStream.LT(1);
|
1706 |
+
}
|
1707 |
+
expressions.push(this._media_expression());
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
if (type === null && expressions.length === 0){
|
1711 |
+
return null;
|
1712 |
+
} else {
|
1713 |
+
this._readWhitespace();
|
1714 |
+
while (tokenStream.match(Tokens.IDENT)){
|
1715 |
+
if (tokenStream.token().value.toLowerCase() != "and"){
|
1716 |
+
this._unexpectedToken(tokenStream.token());
|
1717 |
+
}
|
1718 |
+
|
1719 |
+
this._readWhitespace();
|
1720 |
+
expressions.push(this._media_expression());
|
1721 |
+
}
|
1722 |
+
}
|
1723 |
+
|
1724 |
+
return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
|
1725 |
+
},
|
1726 |
+
|
1727 |
+
//CSS3 Media Queries
|
1728 |
+
_media_type: function(){
|
1729 |
+
/*
|
1730 |
+
* media_type
|
1731 |
+
* : IDENT
|
1732 |
+
* ;
|
1733 |
+
*/
|
1734 |
+
return this._media_feature();
|
1735 |
+
},
|
1736 |
+
|
1737 |
+
/**
|
1738 |
+
* Note: in CSS3 Media Queries, this is called "expression".
|
1739 |
+
* Renamed here to avoid conflict with CSS3 Selectors
|
1740 |
+
* definition of "expression". Also note that "expr" in the
|
1741 |
+
* grammar now maps to "expression" from CSS3 selectors.
|
1742 |
+
* @method _media_expression
|
1743 |
+
* @private
|
1744 |
+
*/
|
1745 |
+
_media_expression: function(){
|
1746 |
+
/*
|
1747 |
+
* expression
|
1748 |
+
* : '(' S* media_feature S* [ ':' S* expr ]? ')' S*
|
1749 |
+
* ;
|
1750 |
+
*/
|
1751 |
+
var tokenStream = this._tokenStream,
|
1752 |
+
feature = null,
|
1753 |
+
token,
|
1754 |
+
expression = null;
|
1755 |
+
|
1756 |
+
tokenStream.mustMatch(Tokens.LPAREN);
|
1757 |
+
|
1758 |
+
feature = this._media_feature();
|
1759 |
+
this._readWhitespace();
|
1760 |
+
|
1761 |
+
if (tokenStream.match(Tokens.COLON)){
|
1762 |
+
this._readWhitespace();
|
1763 |
+
token = tokenStream.LT(1);
|
1764 |
+
expression = this._expression();
|
1765 |
+
}
|
1766 |
+
|
1767 |
+
tokenStream.mustMatch(Tokens.RPAREN);
|
1768 |
+
this._readWhitespace();
|
1769 |
+
|
1770 |
+
return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null));
|
1771 |
+
},
|
1772 |
+
|
1773 |
+
//CSS3 Media Queries
|
1774 |
+
_media_feature: function(){
|
1775 |
+
/*
|
1776 |
+
* media_feature
|
1777 |
+
* : IDENT
|
1778 |
+
* ;
|
1779 |
+
*/
|
1780 |
+
var tokenStream = this._tokenStream;
|
1781 |
+
|
1782 |
+
tokenStream.mustMatch(Tokens.IDENT);
|
1783 |
+
|
1784 |
+
return SyntaxUnit.fromToken(tokenStream.token());
|
1785 |
+
},
|
1786 |
+
|
1787 |
+
//CSS3 Paged Media
|
1788 |
+
_page: function(){
|
1789 |
+
/*
|
1790 |
+
* page:
|
1791 |
+
* PAGE_SYM S* IDENT? pseudo_page? S*
|
1792 |
+
* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
|
1793 |
+
* ;
|
1794 |
+
*/
|
1795 |
+
var tokenStream = this._tokenStream,
|
1796 |
+
line,
|
1797 |
+
col,
|
1798 |
+
identifier = null,
|
1799 |
+
pseudoPage = null;
|
1800 |
+
|
1801 |
+
//look for @page
|
1802 |
+
tokenStream.mustMatch(Tokens.PAGE_SYM);
|
1803 |
+
line = tokenStream.token().startLine;
|
1804 |
+
col = tokenStream.token().startCol;
|
1805 |
+
|
1806 |
+
this._readWhitespace();
|
1807 |
+
|
1808 |
+
if (tokenStream.match(Tokens.IDENT)){
|
1809 |
+
identifier = tokenStream.token().value;
|
1810 |
+
|
1811 |
+
//The value 'auto' may not be used as a page name and MUST be treated as a syntax error.
|
1812 |
+
if (identifier.toLowerCase() === "auto"){
|
1813 |
+
this._unexpectedToken(tokenStream.token());
|
1814 |
+
}
|
1815 |
+
}
|
1816 |
+
|
1817 |
+
//see if there's a colon upcoming
|
1818 |
+
if (tokenStream.peek() == Tokens.COLON){
|
1819 |
+
pseudoPage = this._pseudo_page();
|
1820 |
+
}
|
1821 |
+
|
1822 |
+
this._readWhitespace();
|
1823 |
+
|
1824 |
+
this.fire({
|
1825 |
+
type: "startpage",
|
1826 |
+
id: identifier,
|
1827 |
+
pseudo: pseudoPage,
|
1828 |
+
line: line,
|
1829 |
+
col: col
|
1830 |
+
});
|
1831 |
+
|
1832 |
+
this._readDeclarations(true, true);
|
1833 |
+
|
1834 |
+
this.fire({
|
1835 |
+
type: "endpage",
|
1836 |
+
id: identifier,
|
1837 |
+
pseudo: pseudoPage,
|
1838 |
+
line: line,
|
1839 |
+
col: col
|
1840 |
+
});
|
1841 |
+
|
1842 |
+
},
|
1843 |
+
|
1844 |
+
//CSS3 Paged Media
|
1845 |
+
_margin: function(){
|
1846 |
+
/*
|
1847 |
+
* margin :
|
1848 |
+
* margin_sym S* '{' declaration [ ';' S* declaration? ]* '}' S*
|
1849 |
+
* ;
|
1850 |
+
*/
|
1851 |
+
var tokenStream = this._tokenStream,
|
1852 |
+
line,
|
1853 |
+
col,
|
1854 |
+
marginSym = this._margin_sym();
|
1855 |
+
|
1856 |
+
if (marginSym){
|
1857 |
+
line = tokenStream.token().startLine;
|
1858 |
+
col = tokenStream.token().startCol;
|
1859 |
+
|
1860 |
+
this.fire({
|
1861 |
+
type: "startpagemargin",
|
1862 |
+
margin: marginSym,
|
1863 |
+
line: line,
|
1864 |
+
col: col
|
1865 |
+
});
|
1866 |
+
|
1867 |
+
this._readDeclarations(true);
|
1868 |
+
|
1869 |
+
this.fire({
|
1870 |
+
type: "endpagemargin",
|
1871 |
+
margin: marginSym,
|
1872 |
+
line: line,
|
1873 |
+
col: col
|
1874 |
+
});
|
1875 |
+
return true;
|
1876 |
+
} else {
|
1877 |
+
return false;
|
1878 |
+
}
|
1879 |
+
},
|
1880 |
+
|
1881 |
+
//CSS3 Paged Media
|
1882 |
+
_margin_sym: function(){
|
1883 |
+
|
1884 |
+
/*
|
1885 |
+
* margin_sym :
|
1886 |
+
* TOPLEFTCORNER_SYM |
|
1887 |
+
* TOPLEFT_SYM |
|
1888 |
+
* TOPCENTER_SYM |
|
1889 |
+
* TOPRIGHT_SYM |
|
1890 |
+
* TOPRIGHTCORNER_SYM |
|
1891 |
+
* BOTTOMLEFTCORNER_SYM |
|
1892 |
+
* BOTTOMLEFT_SYM |
|
1893 |
+
* BOTTOMCENTER_SYM |
|
1894 |
+
* BOTTOMRIGHT_SYM |
|
1895 |
+
* BOTTOMRIGHTCORNER_SYM |
|
1896 |
+
* LEFTTOP_SYM |
|
1897 |
+
* LEFTMIDDLE_SYM |
|
1898 |
+
* LEFTBOTTOM_SYM |
|
1899 |
+
* RIGHTTOP_SYM |
|
1900 |
+
* RIGHTMIDDLE_SYM |
|
1901 |
+
* RIGHTBOTTOM_SYM
|
1902 |
+
* ;
|
1903 |
+
*/
|
1904 |
+
|
1905 |
+
var tokenStream = this._tokenStream;
|
1906 |
+
|
1907 |
+
if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM,
|
1908 |
+
Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM,
|
1909 |
+
Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM,
|
1910 |
+
Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM,
|
1911 |
+
Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM,
|
1912 |
+
Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM,
|
1913 |
+
Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM]))
|
1914 |
+
{
|
1915 |
+
return SyntaxUnit.fromToken(tokenStream.token());
|
1916 |
+
} else {
|
1917 |
+
return null;
|
1918 |
+
}
|
1919 |
+
|
1920 |
+
},
|
1921 |
+
|
1922 |
+
_pseudo_page: function(){
|
1923 |
+
/*
|
1924 |
+
* pseudo_page
|
1925 |
+
* : ':' IDENT
|
1926 |
+
* ;
|
1927 |
+
*/
|
1928 |
+
|
1929 |
+
var tokenStream = this._tokenStream;
|
1930 |
+
|
1931 |
+
tokenStream.mustMatch(Tokens.COLON);
|
1932 |
+
tokenStream.mustMatch(Tokens.IDENT);
|
1933 |
+
|
1934 |
+
//TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed
|
1935 |
+
|
1936 |
+
return tokenStream.token().value;
|
1937 |
+
},
|
1938 |
+
|
1939 |
+
_font_face: function(){
|
1940 |
+
/*
|
1941 |
+
* font_face
|
1942 |
+
* : FONT_FACE_SYM S*
|
1943 |
+
* '{' S* declaration [ ';' S* declaration ]* '}' S*
|
1944 |
+
* ;
|
1945 |
+
*/
|
1946 |
+
var tokenStream = this._tokenStream,
|
1947 |
+
line,
|
1948 |
+
col;
|
1949 |
+
|
1950 |
+
//look for @page
|
1951 |
+
tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
|
1952 |
+
line = tokenStream.token().startLine;
|
1953 |
+
col = tokenStream.token().startCol;
|
1954 |
+
|
1955 |
+
this._readWhitespace();
|
1956 |
+
|
1957 |
+
this.fire({
|
1958 |
+
type: "startfontface",
|
1959 |
+
line: line,
|
1960 |
+
col: col
|
1961 |
+
});
|
1962 |
+
|
1963 |
+
this._readDeclarations(true);
|
1964 |
+
|
1965 |
+
this.fire({
|
1966 |
+
type: "endfontface",
|
1967 |
+
line: line,
|
1968 |
+
col: col
|
1969 |
+
});
|
1970 |
+
},
|
1971 |
+
|
1972 |
+
_viewport: function(){
|
1973 |
+
/*
|
1974 |
+
* viewport
|
1975 |
+
* : VIEWPORT_SYM S*
|
1976 |
+
* '{' S* declaration? [ ';' S* declaration? ]* '}' S*
|
1977 |
+
* ;
|
1978 |
+
*/
|
1979 |
+
var tokenStream = this._tokenStream,
|
1980 |
+
line,
|
1981 |
+
col;
|
1982 |
+
|
1983 |
+
tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
|
1984 |
+
line = tokenStream.token().startLine;
|
1985 |
+
col = tokenStream.token().startCol;
|
1986 |
+
|
1987 |
+
this._readWhitespace();
|
1988 |
+
|
1989 |
+
this.fire({
|
1990 |
+
type: "startviewport",
|
1991 |
+
line: line,
|
1992 |
+
col: col
|
1993 |
+
});
|
1994 |
+
|
1995 |
+
this._readDeclarations(true);
|
1996 |
+
|
1997 |
+
this.fire({
|
1998 |
+
type: "endviewport",
|
1999 |
+
line: line,
|
2000 |
+
col: col
|
2001 |
+
});
|
2002 |
+
|
2003 |
+
},
|
2004 |
+
|
2005 |
+
_operator: function(inFunction){
|
2006 |
+
|
2007 |
+
/*
|
2008 |
+
* operator (outside function)
|
2009 |
+
* : '/' S* | ',' S* | /( empty )/
|
2010 |
+
* operator (inside function)
|
2011 |
+
* : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/
|
2012 |
+
* ;
|
2013 |
+
*/
|
2014 |
+
|
2015 |
+
var tokenStream = this._tokenStream,
|
2016 |
+
token = null;
|
2017 |
+
|
2018 |
+
if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
|
2019 |
+
(inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){
|
2020 |
+
token = tokenStream.token();
|
2021 |
+
this._readWhitespace();
|
2022 |
+
}
|
2023 |
+
return token ? PropertyValuePart.fromToken(token) : null;
|
2024 |
+
|
2025 |
+
},
|
2026 |
+
|
2027 |
+
_combinator: function(){
|
2028 |
+
|
2029 |
+
/*
|
2030 |
+
* combinator
|
2031 |
+
* : PLUS S* | GREATER S* | TILDE S* | S+
|
2032 |
+
* ;
|
2033 |
+
*/
|
2034 |
+
|
2035 |
+
var tokenStream = this._tokenStream,
|
2036 |
+
value = null,
|
2037 |
+
token;
|
2038 |
+
|
2039 |
+
if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){
|
2040 |
+
token = tokenStream.token();
|
2041 |
+
value = new Combinator(token.value, token.startLine, token.startCol);
|
2042 |
+
this._readWhitespace();
|
2043 |
+
}
|
2044 |
+
|
2045 |
+
return value;
|
2046 |
+
},
|
2047 |
+
|
2048 |
+
_unary_operator: function(){
|
2049 |
+
|
2050 |
+
/*
|
2051 |
+
* unary_operator
|
2052 |
+
* : '-' | '+'
|
2053 |
+
* ;
|
2054 |
+
*/
|
2055 |
+
|
2056 |
+
var tokenStream = this._tokenStream;
|
2057 |
+
|
2058 |
+
if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){
|
2059 |
+
return tokenStream.token().value;
|
2060 |
+
} else {
|
2061 |
+
return null;
|
2062 |
+
}
|
2063 |
+
},
|
2064 |
+
|
2065 |
+
_property: function(){
|
2066 |
+
|
2067 |
+
/*
|
2068 |
+
* property
|
2069 |
+
* : IDENT S*
|
2070 |
+
* ;
|
2071 |
+
*/
|
2072 |
+
|
2073 |
+
var tokenStream = this._tokenStream,
|
2074 |
+
value = null,
|
2075 |
+
hack = null,
|
2076 |
+
tokenValue,
|
2077 |
+
token,
|
2078 |
+
line,
|
2079 |
+
col;
|
2080 |
+
|
2081 |
+
//check for star hack - throws error if not allowed
|
2082 |
+
if (tokenStream.peek() == Tokens.STAR && this.options.starHack){
|
2083 |
+
tokenStream.get();
|
2084 |
+
token = tokenStream.token();
|
2085 |
+
hack = token.value;
|
2086 |
+
line = token.startLine;
|
2087 |
+
col = token.startCol;
|
2088 |
+
}
|
2089 |
+
|
2090 |
+
if(tokenStream.match(Tokens.IDENT)){
|
2091 |
+
token = tokenStream.token();
|
2092 |
+
tokenValue = token.value;
|
2093 |
+
|
2094 |
+
//check for underscore hack - no error if not allowed because it's valid CSS syntax
|
2095 |
+
if (tokenValue.charAt(0) == "_" && this.options.underscoreHack){
|
2096 |
+
hack = "_";
|
2097 |
+
tokenValue = tokenValue.substring(1);
|
2098 |
+
}
|
2099 |
+
|
2100 |
+
value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol));
|
2101 |
+
this._readWhitespace();
|
2102 |
+
}
|
2103 |
+
|
2104 |
+
return value;
|
2105 |
+
},
|
2106 |
+
|
2107 |
+
//Augmented with CSS3 Selectors
|
2108 |
+
_ruleset: function(){
|
2109 |
+
/*
|
2110 |
+
* ruleset
|
2111 |
+
* : selectors_group
|
2112 |
+
* '{' S* declaration? [ ';' S* declaration? ]* '}' S*
|
2113 |
+
* ;
|
2114 |
+
*/
|
2115 |
+
|
2116 |
+
var tokenStream = this._tokenStream,
|
2117 |
+
tt,
|
2118 |
+
selectors;
|
2119 |
+
|
2120 |
+
|
2121 |
+
/*
|
2122 |
+
* Error Recovery: If even a single selector fails to parse,
|
2123 |
+
* then the entire ruleset should be thrown away.
|
2124 |
+
*/
|
2125 |
+
try {
|
2126 |
+
selectors = this._selectors_group();
|
2127 |
+
} catch (ex){
|
2128 |
+
if (ex instanceof SyntaxError && !this.options.strict){
|
2129 |
+
|
2130 |
+
//fire error event
|
2131 |
+
this.fire({
|
2132 |
+
type: "error",
|
2133 |
+
error: ex,
|
2134 |
+
message: ex.message,
|
2135 |
+
line: ex.line,
|
2136 |
+
col: ex.col
|
2137 |
+
});
|
2138 |
+
|
2139 |
+
//skip over everything until closing brace
|
2140 |
+
tt = tokenStream.advance([Tokens.RBRACE]);
|
2141 |
+
if (tt == Tokens.RBRACE){
|
2142 |
+
//if there's a right brace, the rule is finished so don't do anything
|
2143 |
+
} else {
|
2144 |
+
//otherwise, rethrow the error because it wasn't handled properly
|
2145 |
+
throw ex;
|
2146 |
+
}
|
2147 |
+
|
2148 |
+
} else {
|
2149 |
+
//not a syntax error, rethrow it
|
2150 |
+
throw ex;
|
2151 |
+
}
|
2152 |
+
|
2153 |
+
//trigger parser to continue
|
2154 |
+
return true;
|
2155 |
+
}
|
2156 |
+
|
2157 |
+
//if it got here, all selectors parsed
|
2158 |
+
if (selectors){
|
2159 |
+
|
2160 |
+
this.fire({
|
2161 |
+
type: "startrule",
|
2162 |
+
selectors: selectors,
|
2163 |
+
line: selectors[0].line,
|
2164 |
+
col: selectors[0].col
|
2165 |
+
});
|
2166 |
+
|
2167 |
+
this._readDeclarations(true);
|
2168 |
+
|
2169 |
+
this.fire({
|
2170 |
+
type: "endrule",
|
2171 |
+
selectors: selectors,
|
2172 |
+
line: selectors[0].line,
|
2173 |
+
col: selectors[0].col
|
2174 |
+
});
|
2175 |
+
|
2176 |
+
}
|
2177 |
+
|
2178 |
+
return selectors;
|
2179 |
+
|
2180 |
+
},
|
2181 |
+
|
2182 |
+
//CSS3 Selectors
|
2183 |
+
_selectors_group: function(){
|
2184 |
+
|
2185 |
+
/*
|
2186 |
+
* selectors_group
|
2187 |
+
* : selector [ COMMA S* selector ]*
|
2188 |
+
* ;
|
2189 |
+
*/
|
2190 |
+
var tokenStream = this._tokenStream,
|
2191 |
+
selectors = [],
|
2192 |
+
selector;
|
2193 |
+
|
2194 |
+
selector = this._selector();
|
2195 |
+
if (selector !== null){
|
2196 |
+
|
2197 |
+
selectors.push(selector);
|
2198 |
+
while(tokenStream.match(Tokens.COMMA)){
|
2199 |
+
this._readWhitespace();
|
2200 |
+
selector = this._selector();
|
2201 |
+
if (selector !== null){
|
2202 |
+
selectors.push(selector);
|
2203 |
+
} else {
|
2204 |
+
this._unexpectedToken(tokenStream.LT(1));
|
2205 |
+
}
|
2206 |
+
}
|
2207 |
+
}
|
2208 |
+
|
2209 |
+
return selectors.length ? selectors : null;
|
2210 |
+
},
|
2211 |
+
|
2212 |
+
//CSS3 Selectors
|
2213 |
+
_selector: function(){
|
2214 |
+
/*
|
2215 |
+
* selector
|
2216 |
+
* : simple_selector_sequence [ combinator simple_selector_sequence ]*
|
2217 |
+
* ;
|
2218 |
+
*/
|
2219 |
+
|
2220 |
+
var tokenStream = this._tokenStream,
|
2221 |
+
selector = [],
|
2222 |
+
nextSelector = null,
|
2223 |
+
combinator = null,
|
2224 |
+
ws = null;
|
2225 |
+
|
2226 |
+
//if there's no simple selector, then there's no selector
|
2227 |
+
nextSelector = this._simple_selector_sequence();
|
2228 |
+
if (nextSelector === null){
|
2229 |
+
return null;
|
2230 |
+
}
|
2231 |
+
|
2232 |
+
selector.push(nextSelector);
|
2233 |
+
|
2234 |
+
do {
|
2235 |
+
|
2236 |
+
//look for a combinator
|
2237 |
+
combinator = this._combinator();
|
2238 |
+
|
2239 |
+
if (combinator !== null){
|
2240 |
+
selector.push(combinator);
|
2241 |
+
nextSelector = this._simple_selector_sequence();
|
2242 |
+
|
2243 |
+
//there must be a next selector
|
2244 |
+
if (nextSelector === null){
|
2245 |
+
this._unexpectedToken(tokenStream.LT(1));
|
2246 |
+
} else {
|
2247 |
+
|
2248 |
+
//nextSelector is an instance of SelectorPart
|
2249 |
+
selector.push(nextSelector);
|
2250 |
+
}
|
2251 |
+
} else {
|
2252 |
+
|
2253 |
+
//if there's not whitespace, we're done
|
2254 |
+
if (this._readWhitespace()){
|
2255 |
+
|
2256 |
+
//add whitespace separator
|
2257 |
+
ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
|
2258 |
+
|
2259 |
+
//combinator is not required
|
2260 |
+
combinator = this._combinator();
|
2261 |
+
|
2262 |
+
//selector is required if there's a combinator
|
2263 |
+
nextSelector = this._simple_selector_sequence();
|
2264 |
+
if (nextSelector === null){
|
2265 |
+
if (combinator !== null){
|
2266 |
+
this._unexpectedToken(tokenStream.LT(1));
|
2267 |
+
}
|
2268 |
+
} else {
|
2269 |
+
|
2270 |
+
if (combinator !== null){
|
2271 |
+
selector.push(combinator);
|
2272 |
+
} else {
|
2273 |
+
selector.push(ws);
|
2274 |
+
}
|
2275 |
+
|
2276 |
+
selector.push(nextSelector);
|
2277 |
+
}
|
2278 |
+
} else {
|
2279 |
+
break;
|
2280 |
+
}
|
2281 |
+
|
2282 |
+
}
|
2283 |
+
} while(true);
|
2284 |
+
|
2285 |
+
return new Selector(selector, selector[0].line, selector[0].col);
|
2286 |
+
},
|
2287 |
+
|
2288 |
+
//CSS3 Selectors
|
2289 |
+
_simple_selector_sequence: function(){
|
2290 |
+
/*
|
2291 |
+
* simple_selector_sequence
|
2292 |
+
* : [ type_selector | universal ]
|
2293 |
+
* [ HASH | class | attrib | pseudo | negation ]*
|
2294 |
+
* | [ HASH | class | attrib | pseudo | negation ]+
|
2295 |
+
* ;
|
2296 |
+
*/
|
2297 |
+
|
2298 |
+
var tokenStream = this._tokenStream,
|
2299 |
+
|
2300 |
+
//parts of a simple selector
|
2301 |
+
elementName = null,
|
2302 |
+
modifiers = [],
|
2303 |
+
|
2304 |
+
//complete selector text
|
2305 |
+
selectorText= "",
|
2306 |
+
|
2307 |
+
//the different parts after the element name to search for
|
2308 |
+
components = [
|
2309 |
+
//HASH
|
2310 |
+
function(){
|
2311 |
+
return tokenStream.match(Tokens.HASH) ?
|
2312 |
+
new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
|
2313 |
+
null;
|
2314 |
+
},
|
2315 |
+
this._class,
|
2316 |
+
this._attrib,
|
2317 |
+
this._pseudo,
|
2318 |
+
this._negation
|
2319 |
+
],
|
2320 |
+
i = 0,
|
2321 |
+
len = components.length,
|
2322 |
+
component = null,
|
2323 |
+
found = false,
|
2324 |
+
line,
|
2325 |
+
col;
|
2326 |
+
|
2327 |
+
|
2328 |
+
//get starting line and column for the selector
|
2329 |
+
line = tokenStream.LT(1).startLine;
|
2330 |
+
col = tokenStream.LT(1).startCol;
|
2331 |
+
|
2332 |
+
elementName = this._type_selector();
|
2333 |
+
if (!elementName){
|
2334 |
+
elementName = this._universal();
|
2335 |
+
}
|
2336 |
+
|
2337 |
+
if (elementName !== null){
|
2338 |
+
selectorText += elementName;
|
2339 |
+
}
|
2340 |
+
|
2341 |
+
while(true){
|
2342 |
+
|
2343 |
+
//whitespace means we're done
|
2344 |
+
if (tokenStream.peek() === Tokens.S){
|
2345 |
+
break;
|
2346 |
+
}
|
2347 |
+
|
2348 |
+
//check for each component
|
2349 |
+
while(i < len && component === null){
|
2350 |
+
component = components[i++].call(this);
|
2351 |
+
}
|
2352 |
+
|
2353 |
+
if (component === null){
|
2354 |
+
|
2355 |
+
//we don't have a selector
|
2356 |
+
if (selectorText === ""){
|
2357 |
+
return null;
|
2358 |
+
} else {
|
2359 |
+
break;
|
2360 |
+
}
|
2361 |
+
} else {
|
2362 |
+
i = 0;
|
2363 |
+
modifiers.push(component);
|
2364 |
+
selectorText += component.toString();
|
2365 |
+
component = null;
|
2366 |
+
}
|
2367 |
+
}
|
2368 |
+
|
2369 |
+
|
2370 |
+
return selectorText !== "" ?
|
2371 |
+
new SelectorPart(elementName, modifiers, selectorText, line, col) :
|
2372 |
+
null;
|
2373 |
+
},
|
2374 |
+
|
2375 |
+
//CSS3 Selectors
|
2376 |
+
_type_selector: function(){
|
2377 |
+
/*
|
2378 |
+
* type_selector
|
2379 |
+
* : [ namespace_prefix ]? element_name
|
2380 |
+
* ;
|
2381 |
+
*/
|
2382 |
+
|
2383 |
+
var tokenStream = this._tokenStream,
|
2384 |
+
ns = this._namespace_prefix(),
|
2385 |
+
elementName = this._element_name();
|
2386 |
+
|
2387 |
+
if (!elementName){
|
2388 |
+
/*
|
2389 |
+
* Need to back out the namespace that was read due to both
|
2390 |
+
* type_selector and universal reading namespace_prefix
|
2391 |
+
* first. Kind of hacky, but only way I can figure out
|
2392 |
+
* right now how to not change the grammar.
|
2393 |
+
*/
|
2394 |
+
if (ns){
|
2395 |
+
tokenStream.unget();
|
2396 |
+
if (ns.length > 1){
|
2397 |
+
tokenStream.unget();
|
2398 |
+
}
|
2399 |
+
}
|
2400 |
+
|
2401 |
+
return null;
|
2402 |
+
} else {
|
2403 |
+
if (ns){
|
2404 |
+
elementName.text = ns + elementName.text;
|
2405 |
+
elementName.col -= ns.length;
|
2406 |
+
}
|
2407 |
+
return elementName;
|
2408 |
+
}
|
2409 |
+
},
|
2410 |
+
|
2411 |
+
//CSS3 Selectors
|
2412 |
+
_class: function(){
|
2413 |
+
/*
|
2414 |
+
* class
|
2415 |
+
* : '.' IDENT
|
2416 |
+
* ;
|
2417 |
+
*/
|
2418 |
+
|
2419 |
+
var tokenStream = this._tokenStream,
|
2420 |
+
token;
|
2421 |
+
|
2422 |
+
if (tokenStream.match(Tokens.DOT)){
|
2423 |
+
tokenStream.mustMatch(Tokens.IDENT);
|
2424 |
+
token = tokenStream.token();
|
2425 |
+
return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
|
2426 |
+
} else {
|
2427 |
+
return null;
|
2428 |
+
}
|
2429 |
+
|
2430 |
+
},
|
2431 |
+
|
2432 |
+
//CSS3 Selectors
|
2433 |
+
_element_name: function(){
|
2434 |
+
/*
|
2435 |
+
* element_name
|
2436 |
+
* : IDENT
|
2437 |
+
* ;
|
2438 |
+
*/
|
2439 |
+
|
2440 |
+
var tokenStream = this._tokenStream,
|
2441 |
+
token;
|
2442 |
+
|
2443 |
+
if (tokenStream.match(Tokens.IDENT)){
|
2444 |
+
token = tokenStream.token();
|
2445 |
+
return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
|
2446 |
+
|
2447 |
+
} else {
|
2448 |
+
return null;
|
2449 |
+
}
|
2450 |
+
},
|
2451 |
+
|
2452 |
+
//CSS3 Selectors
|
2453 |
+
_namespace_prefix: function(){
|
2454 |
+
/*
|
2455 |
+
* namespace_prefix
|
2456 |
+
* : [ IDENT | '*' ]? '|'
|
2457 |
+
* ;
|
2458 |
+
*/
|
2459 |
+
var tokenStream = this._tokenStream,
|
2460 |
+
value = "";
|
2461 |
+
|
2462 |
+
//verify that this is a namespace prefix
|
2463 |
+
if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){
|
2464 |
+
|
2465 |
+
if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){
|
2466 |
+
value += tokenStream.token().value;
|
2467 |
+
}
|
2468 |
+
|
2469 |
+
tokenStream.mustMatch(Tokens.PIPE);
|
2470 |
+
value += "|";
|
2471 |
+
|
2472 |
+
}
|
2473 |
+
|
2474 |
+
return value.length ? value : null;
|
2475 |
+
},
|
2476 |
+
|
2477 |
+
//CSS3 Selectors
|
2478 |
+
_universal: function(){
|
2479 |
+
/*
|
2480 |
+
* universal
|
2481 |
+
* : [ namespace_prefix ]? '*'
|
2482 |
+
* ;
|
2483 |
+
*/
|
2484 |
+
var tokenStream = this._tokenStream,
|
2485 |
+
value = "",
|
2486 |
+
ns;
|
2487 |
+
|
2488 |
+
ns = this._namespace_prefix();
|
2489 |
+
if(ns){
|
2490 |
+
value += ns;
|
2491 |
+
}
|
2492 |
+
|
2493 |
+
if(tokenStream.match(Tokens.STAR)){
|
2494 |
+
value += "*";
|
2495 |
+
}
|
2496 |
+
|
2497 |
+
return value.length ? value : null;
|
2498 |
+
|
2499 |
+
},
|
2500 |
+
|
2501 |
+
//CSS3 Selectors
|
2502 |
+
_attrib: function(){
|
2503 |
+
/*
|
2504 |
+
* attrib
|
2505 |
+
* : '[' S* [ namespace_prefix ]? IDENT S*
|
2506 |
+
* [ [ PREFIXMATCH |
|
2507 |
+
* SUFFIXMATCH |
|
2508 |
+
* SUBSTRINGMATCH |
|
2509 |
+
* '=' |
|
2510 |
+
* INCLUDES |
|
2511 |
+
* DASHMATCH ] S* [ IDENT | STRING ] S*
|
2512 |
+
* ]? ']'
|
2513 |
+
* ;
|
2514 |
+
*/
|
2515 |
+
|
2516 |
+
var tokenStream = this._tokenStream,
|
2517 |
+
value = null,
|
2518 |
+
ns,
|
2519 |
+
token;
|
2520 |
+
|
2521 |
+
if (tokenStream.match(Tokens.LBRACKET)){
|
2522 |
+
token = tokenStream.token();
|
2523 |
+
value = token.value;
|
2524 |
+
value += this._readWhitespace();
|
2525 |
+
|
2526 |
+
ns = this._namespace_prefix();
|
2527 |
+
|
2528 |
+
if (ns){
|
2529 |
+
value += ns;
|
2530 |
+
}
|
2531 |
+
|
2532 |
+
tokenStream.mustMatch(Tokens.IDENT);
|
2533 |
+
value += tokenStream.token().value;
|
2534 |
+
value += this._readWhitespace();
|
2535 |
+
|
2536 |
+
if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH,
|
2537 |
+
Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){
|
2538 |
+
|
2539 |
+
value += tokenStream.token().value;
|
2540 |
+
value += this._readWhitespace();
|
2541 |
+
|
2542 |
+
tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
|
2543 |
+
value += tokenStream.token().value;
|
2544 |
+
value += this._readWhitespace();
|
2545 |
+
}
|
2546 |
+
|
2547 |
+
tokenStream.mustMatch(Tokens.RBRACKET);
|
2548 |
+
|
2549 |
+
return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
|
2550 |
+
} else {
|
2551 |
+
return null;
|
2552 |
+
}
|
2553 |
+
},
|
2554 |
+
|
2555 |
+
//CSS3 Selectors
|
2556 |
+
_pseudo: function(){
|
2557 |
+
|
2558 |
+
/*
|
2559 |
+
* pseudo
|
2560 |
+
* : ':' ':'? [ IDENT | functional_pseudo ]
|
2561 |
+
* ;
|
2562 |
+
*/
|
2563 |
+
|
2564 |
+
var tokenStream = this._tokenStream,
|
2565 |
+
pseudo = null,
|
2566 |
+
colons = ":",
|
2567 |
+
line,
|
2568 |
+
col;
|
2569 |
+
|
2570 |
+
if (tokenStream.match(Tokens.COLON)){
|
2571 |
+
|
2572 |
+
if (tokenStream.match(Tokens.COLON)){
|
2573 |
+
colons += ":";
|
2574 |
+
}
|
2575 |
+
|
2576 |
+
if (tokenStream.match(Tokens.IDENT)){
|
2577 |
+
pseudo = tokenStream.token().value;
|
2578 |
+
line = tokenStream.token().startLine;
|
2579 |
+
col = tokenStream.token().startCol - colons.length;
|
2580 |
+
} else if (tokenStream.peek() == Tokens.FUNCTION){
|
2581 |
+
line = tokenStream.LT(1).startLine;
|
2582 |
+
col = tokenStream.LT(1).startCol - colons.length;
|
2583 |
+
pseudo = this._functional_pseudo();
|
2584 |
+
}
|
2585 |
+
|
2586 |
+
if (pseudo){
|
2587 |
+
pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
|
2588 |
+
}
|
2589 |
+
}
|
2590 |
+
|
2591 |
+
return pseudo;
|
2592 |
+
},
|
2593 |
+
|
2594 |
+
//CSS3 Selectors
|
2595 |
+
_functional_pseudo: function(){
|
2596 |
+
/*
|
2597 |
+
* functional_pseudo
|
2598 |
+
* : FUNCTION S* expression ')'
|
2599 |
+
* ;
|
2600 |
+
*/
|
2601 |
+
|
2602 |
+
var tokenStream = this._tokenStream,
|
2603 |
+
value = null;
|
2604 |
+
|
2605 |
+
if(tokenStream.match(Tokens.FUNCTION)){
|
2606 |
+
value = tokenStream.token().value;
|
2607 |
+
value += this._readWhitespace();
|
2608 |
+
value += this._expression();
|
2609 |
+
tokenStream.mustMatch(Tokens.RPAREN);
|
2610 |
+
value += ")";
|
2611 |
+
}
|
2612 |
+
|
2613 |
+
return value;
|
2614 |
+
},
|
2615 |
+
|
2616 |
+
//CSS3 Selectors
|
2617 |
+
_expression: function(){
|
2618 |
+
/*
|
2619 |
+
* expression
|
2620 |
+
* : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
|
2621 |
+
* ;
|
2622 |
+
*/
|
2623 |
+
|
2624 |
+
var tokenStream = this._tokenStream,
|
2625 |
+
value = "";
|
2626 |
+
|
2627 |
+
while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
|
2628 |
+
Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
|
2629 |
+
Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
|
2630 |
+
Tokens.RESOLUTION, Tokens.SLASH])){
|
2631 |
+
|
2632 |
+
value += tokenStream.token().value;
|
2633 |
+
value += this._readWhitespace();
|
2634 |
+
}
|
2635 |
+
|
2636 |
+
return value.length ? value : null;
|
2637 |
+
|
2638 |
+
},
|
2639 |
+
|
2640 |
+
//CSS3 Selectors
|
2641 |
+
_negation: function(){
|
2642 |
+
/*
|
2643 |
+
* negation
|
2644 |
+
* : NOT S* negation_arg S* ')'
|
2645 |
+
* ;
|
2646 |
+
*/
|
2647 |
+
|
2648 |
+
var tokenStream = this._tokenStream,
|
2649 |
+
line,
|
2650 |
+
col,
|
2651 |
+
value = "",
|
2652 |
+
arg,
|
2653 |
+
subpart = null;
|
2654 |
+
|
2655 |
+
if (tokenStream.match(Tokens.NOT)){
|
2656 |
+
value = tokenStream.token().value;
|
2657 |
+
line = tokenStream.token().startLine;
|
2658 |
+
col = tokenStream.token().startCol;
|
2659 |
+
value += this._readWhitespace();
|
2660 |
+
arg = this._negation_arg();
|
2661 |
+
value += arg;
|
2662 |
+
value += this._readWhitespace();
|
2663 |
+
tokenStream.match(Tokens.RPAREN);
|
2664 |
+
value += tokenStream.token().value;
|
2665 |
+
|
2666 |
+
subpart = new SelectorSubPart(value, "not", line, col);
|
2667 |
+
subpart.args.push(arg);
|
2668 |
+
}
|
2669 |
+
|
2670 |
+
return subpart;
|
2671 |
+
},
|
2672 |
+
|
2673 |
+
//CSS3 Selectors
|
2674 |
+
_negation_arg: function(){
|
2675 |
+
/*
|
2676 |
+
* negation_arg
|
2677 |
+
* : type_selector | universal | HASH | class | attrib | pseudo
|
2678 |
+
* ;
|
2679 |
+
*/
|
2680 |
+
|
2681 |
+
var tokenStream = this._tokenStream,
|
2682 |
+
args = [
|
2683 |
+
this._type_selector,
|
2684 |
+
this._universal,
|
2685 |
+
function(){
|
2686 |
+
return tokenStream.match(Tokens.HASH) ?
|
2687 |
+
new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
|
2688 |
+
null;
|
2689 |
+
},
|
2690 |
+
this._class,
|
2691 |
+
this._attrib,
|
2692 |
+
this._pseudo
|
2693 |
+
],
|
2694 |
+
arg = null,
|
2695 |
+
i = 0,
|
2696 |
+
len = args.length,
|
2697 |
+
elementName,
|
2698 |
+
line,
|
2699 |
+
col,
|
2700 |
+
part;
|
2701 |
+
|
2702 |
+
line = tokenStream.LT(1).startLine;
|
2703 |
+
col = tokenStream.LT(1).startCol;
|
2704 |
+
|
2705 |
+
while(i < len && arg === null){
|
2706 |
+
|
2707 |
+
arg = args[i].call(this);
|
2708 |
+
i++;
|
2709 |
+
}
|
2710 |
+
|
2711 |
+
//must be a negation arg
|
2712 |
+
if (arg === null){
|
2713 |
+
this._unexpectedToken(tokenStream.LT(1));
|
2714 |
+
}
|
2715 |
+
|
2716 |
+
//it's an element name
|
2717 |
+
if (arg.type == "elementName"){
|
2718 |
+
part = new SelectorPart(arg, [], arg.toString(), line, col);
|
2719 |
+
} else {
|
2720 |
+
part = new SelectorPart(null, [arg], arg.toString(), line, col);
|
2721 |
+
}
|
2722 |
+
|
2723 |
+
return part;
|
2724 |
+
},
|
2725 |
+
|
2726 |
+
_declaration: function(){
|
2727 |
+
|
2728 |
+
/*
|
2729 |
+
* declaration
|
2730 |
+
* : property ':' S* expr prio?
|
2731 |
+
* | /( empty )/
|
2732 |
+
* ;
|
2733 |
+
*/
|
2734 |
+
|
2735 |
+
var tokenStream = this._tokenStream,
|
2736 |
+
property = null,
|
2737 |
+
expr = null,
|
2738 |
+
prio = null,
|
2739 |
+
error = null,
|
2740 |
+
invalid = null,
|
2741 |
+
propertyName= "";
|
2742 |
+
|
2743 |
+
property = this._property();
|
2744 |
+
if (property !== null){
|
2745 |
+
|
2746 |
+
tokenStream.mustMatch(Tokens.COLON);
|
2747 |
+
this._readWhitespace();
|
2748 |
+
|
2749 |
+
expr = this._expr();
|
2750 |
+
|
2751 |
+
//if there's no parts for the value, it's an error
|
2752 |
+
if (!expr || expr.length === 0){
|
2753 |
+
this._unexpectedToken(tokenStream.LT(1));
|
2754 |
+
}
|
2755 |
+
|
2756 |
+
prio = this._prio();
|
2757 |
+
|
2758 |
+
/*
|
2759 |
+
* If hacks should be allowed, then only check the root
|
2760 |
+
* property. If hacks should not be allowed, treat
|
2761 |
+
* _property or *property as invalid properties.
|
2762 |
+
*/
|
2763 |
+
propertyName = property.toString();
|
2764 |
+
if (this.options.starHack && property.hack == "*" ||
|
2765 |
+
this.options.underscoreHack && property.hack == "_") {
|
2766 |
+
|
2767 |
+
propertyName = property.text;
|
2768 |
+
}
|
2769 |
+
|
2770 |
+
try {
|
2771 |
+
this._validateProperty(propertyName, expr);
|
2772 |
+
} catch (ex) {
|
2773 |
+
invalid = ex;
|
2774 |
+
}
|
2775 |
+
|
2776 |
+
this.fire({
|
2777 |
+
type: "property",
|
2778 |
+
property: property,
|
2779 |
+
value: expr,
|
2780 |
+
important: prio,
|
2781 |
+
line: property.line,
|
2782 |
+
col: property.col,
|
2783 |
+
invalid: invalid
|
2784 |
+
});
|
2785 |
+
|
2786 |
+
return true;
|
2787 |
+
} else {
|
2788 |
+
return false;
|
2789 |
+
}
|
2790 |
+
},
|
2791 |
+
|
2792 |
+
_prio: function(){
|
2793 |
+
/*
|
2794 |
+
* prio
|
2795 |
+
* : IMPORTANT_SYM S*
|
2796 |
+
* ;
|
2797 |
+
*/
|
2798 |
+
|
2799 |
+
var tokenStream = this._tokenStream,
|
2800 |
+
result = tokenStream.match(Tokens.IMPORTANT_SYM);
|
2801 |
+
|
2802 |
+
this._readWhitespace();
|
2803 |
+
return result;
|
2804 |
+
},
|
2805 |
+
|
2806 |
+
_expr: function(inFunction){
|
2807 |
+
/*
|
2808 |
+
* expr
|
2809 |
+
* : term [ operator term ]*
|
2810 |
+
* ;
|
2811 |
+
*/
|
2812 |
+
|
2813 |
+
var tokenStream = this._tokenStream,
|
2814 |
+
values = [],
|
2815 |
+
//valueParts = [],
|
2816 |
+
value = null,
|
2817 |
+
operator = null;
|
2818 |
+
|
2819 |
+
value = this._term();
|
2820 |
+
if (value !== null){
|
2821 |
+
|
2822 |
+
values.push(value);
|
2823 |
+
|
2824 |
+
do {
|
2825 |
+
operator = this._operator(inFunction);
|
2826 |
+
|
2827 |
+
//if there's an operator, keep building up the value parts
|
2828 |
+
if (operator){
|
2829 |
+
values.push(operator);
|
2830 |
+
} /*else {
|
2831 |
+
//if there's not an operator, you have a full value
|
2832 |
+
values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
|
2833 |
+
valueParts = [];
|
2834 |
+
}*/
|
2835 |
+
|
2836 |
+
value = this._term();
|
2837 |
+
|
2838 |
+
if (value === null){
|
2839 |
+
break;
|
2840 |
+
} else {
|
2841 |
+
values.push(value);
|
2842 |
+
}
|
2843 |
+
} while(true);
|
2844 |
+
}
|
2845 |
+
|
2846 |
+
//cleanup
|
2847 |
+
/*if (valueParts.length){
|
2848 |
+
values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
|
2849 |
+
}*/
|
2850 |
+
|
2851 |
+
return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
|
2852 |
+
},
|
2853 |
+
|
2854 |
+
_term: function(){
|
2855 |
+
|
2856 |
+
/*
|
2857 |
+
* term
|
2858 |
+
* : unary_operator?
|
2859 |
+
* [ NUMBER S* | PERCENTAGE S* | LENGTH S* | ANGLE S* |
|
2860 |
+
* TIME S* | FREQ S* | function | ie_function ]
|
2861 |
+
* | STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor
|
2862 |
+
* ;
|
2863 |
+
*/
|
2864 |
+
|
2865 |
+
var tokenStream = this._tokenStream,
|
2866 |
+
unary = null,
|
2867 |
+
value = null,
|
2868 |
+
token,
|
2869 |
+
line,
|
2870 |
+
col;
|
2871 |
+
|
2872 |
+
//returns the operator or null
|
2873 |
+
unary = this._unary_operator();
|
2874 |
+
if (unary !== null){
|
2875 |
+
line = tokenStream.token().startLine;
|
2876 |
+
col = tokenStream.token().startCol;
|
2877 |
+
}
|
2878 |
+
|
2879 |
+
//exception for IE filters
|
2880 |
+
if (tokenStream.peek() == Tokens.IE_FUNCTION && this.options.ieFilters){
|
2881 |
+
|
2882 |
+
value = this._ie_function();
|
2883 |
+
if (unary === null){
|
2884 |
+
line = tokenStream.token().startLine;
|
2885 |
+
col = tokenStream.token().startCol;
|
2886 |
+
}
|
2887 |
+
|
2888 |
+
//see if there's a simple match
|
2889 |
+
} else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH,
|
2890 |
+
Tokens.ANGLE, Tokens.TIME,
|
2891 |
+
Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){
|
2892 |
+
|
2893 |
+
value = tokenStream.token().value;
|
2894 |
+
if (unary === null){
|
2895 |
+
line = tokenStream.token().startLine;
|
2896 |
+
col = tokenStream.token().startCol;
|
2897 |
+
}
|
2898 |
+
this._readWhitespace();
|
2899 |
+
} else {
|
2900 |
+
|
2901 |
+
//see if it's a color
|
2902 |
+
token = this._hexcolor();
|
2903 |
+
if (token === null){
|
2904 |
+
|
2905 |
+
//if there's no unary, get the start of the next token for line/col info
|
2906 |
+
if (unary === null){
|
2907 |
+
line = tokenStream.LT(1).startLine;
|
2908 |
+
col = tokenStream.LT(1).startCol;
|
2909 |
+
}
|
2910 |
+
|
2911 |
+
//has to be a function
|
2912 |
+
if (value === null){
|
2913 |
+
|
2914 |
+
/*
|
2915 |
+
* This checks for alpha(opacity=0) style of IE
|
2916 |
+
* functions. IE_FUNCTION only presents progid: style.
|
2917 |
+
*/
|
2918 |
+
if (tokenStream.LA(3) == Tokens.EQUALS && this.options.ieFilters){
|
2919 |
+
value = this._ie_function();
|
2920 |
+
} else {
|
2921 |
+
value = this._function();
|
2922 |
+
}
|
2923 |
+
}
|
2924 |
+
|
2925 |
+
/*if (value === null){
|
2926 |
+
return null;
|
2927 |
+
//throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + ".");
|
2928 |
+
}*/
|
2929 |
+
|
2930 |
+
} else {
|
2931 |
+
value = token.value;
|
2932 |
+
if (unary === null){
|
2933 |
+
line = token.startLine;
|
2934 |
+
col = token.startCol;
|
2935 |
+
}
|
2936 |
+
}
|
2937 |
+
|
2938 |
+
}
|
2939 |
+
|
2940 |
+
return value !== null ?
|
2941 |
+
new PropertyValuePart(unary !== null ? unary + value : value, line, col) :
|
2942 |
+
null;
|
2943 |
+
|
2944 |
+
},
|
2945 |
+
|
2946 |
+
_function: function(){
|
2947 |
+
|
2948 |
+
/*
|
2949 |
+
* function
|
2950 |
+
* : FUNCTION S* expr ')' S*
|
2951 |
+
* ;
|
2952 |
+
*/
|
2953 |
+
|
2954 |
+
var tokenStream = this._tokenStream,
|
2955 |
+
functionText = null,
|
2956 |
+
expr = null,
|
2957 |
+
lt;
|
2958 |
+
|
2959 |
+
if (tokenStream.match(Tokens.FUNCTION)){
|
2960 |
+
functionText = tokenStream.token().value;
|
2961 |
+
this._readWhitespace();
|
2962 |
+
expr = this._expr(true);
|
2963 |
+
functionText += expr;
|
2964 |
+
|
2965 |
+
//START: Horrible hack in case it's an IE filter
|
2966 |
+
if (this.options.ieFilters && tokenStream.peek() == Tokens.EQUALS){
|
2967 |
+
do {
|
2968 |
+
|
2969 |
+
if (this._readWhitespace()){
|
2970 |
+
functionText += tokenStream.token().value;
|
2971 |
+
}
|
2972 |
+
|
2973 |
+
//might be second time in the loop
|
2974 |
+
if (tokenStream.LA(0) == Tokens.COMMA){
|
2975 |
+
functionText += tokenStream.token().value;
|
2976 |
+
}
|
2977 |
+
|
2978 |
+
tokenStream.match(Tokens.IDENT);
|
2979 |
+
functionText += tokenStream.token().value;
|
2980 |
+
|
2981 |
+
tokenStream.match(Tokens.EQUALS);
|
2982 |
+
functionText += tokenStream.token().value;
|
2983 |
+
|
2984 |
+
//functionText += this._term();
|
2985 |
+
lt = tokenStream.peek();
|
2986 |
+
while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){
|
2987 |
+
tokenStream.get();
|
2988 |
+
functionText += tokenStream.token().value;
|
2989 |
+
lt = tokenStream.peek();
|
2990 |
+
}
|
2991 |
+
} while(tokenStream.match([Tokens.COMMA, Tokens.S]));
|
2992 |
+
}
|
2993 |
+
|
2994 |
+
//END: Horrible Hack
|
2995 |
+
|
2996 |
+
tokenStream.match(Tokens.RPAREN);
|
2997 |
+
functionText += ")";
|
2998 |
+
this._readWhitespace();
|
2999 |
+
}
|
3000 |
+
|
3001 |
+
return functionText;
|
3002 |
+
},
|
3003 |
+
|
3004 |
+
_ie_function: function(){
|
3005 |
+
|
3006 |
+
/* (My own extension)
|
3007 |
+
* ie_function
|
3008 |
+
* : IE_FUNCTION S* IDENT '=' term [S* ','? IDENT '=' term]+ ')' S*
|
3009 |
+
* ;
|
3010 |
+
*/
|
3011 |
+
|
3012 |
+
var tokenStream = this._tokenStream,
|
3013 |
+
functionText = null,
|
3014 |
+
expr = null,
|
3015 |
+
lt;
|
3016 |
+
|
3017 |
+
//IE function can begin like a regular function, too
|
3018 |
+
if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){
|
3019 |
+
functionText = tokenStream.token().value;
|
3020 |
+
|
3021 |
+
do {
|
3022 |
+
|
3023 |
+
if (this._readWhitespace()){
|
3024 |
+
functionText += tokenStream.token().value;
|
3025 |
+
}
|
3026 |
+
|
3027 |
+
//might be second time in the loop
|
3028 |
+
if (tokenStream.LA(0) == Tokens.COMMA){
|
3029 |
+
functionText += tokenStream.token().value;
|
3030 |
+
}
|
3031 |
+
|
3032 |
+
tokenStream.match(Tokens.IDENT);
|
3033 |
+
functionText += tokenStream.token().value;
|
3034 |
+
|
3035 |
+
tokenStream.match(Tokens.EQUALS);
|
3036 |
+
functionText += tokenStream.token().value;
|
3037 |
+
|
3038 |
+
//functionText += this._term();
|
3039 |
+
lt = tokenStream.peek();
|
3040 |
+
while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){
|
3041 |
+
tokenStream.get();
|
3042 |
+
functionText += tokenStream.token().value;
|
3043 |
+
lt = tokenStream.peek();
|
3044 |
+
}
|
3045 |
+
} while(tokenStream.match([Tokens.COMMA, Tokens.S]));
|
3046 |
+
|
3047 |
+
tokenStream.match(Tokens.RPAREN);
|
3048 |
+
functionText += ")";
|
3049 |
+
this._readWhitespace();
|
3050 |
+
}
|
3051 |
+
|
3052 |
+
return functionText;
|
3053 |
+
},
|
3054 |
+
|
3055 |
+
_hexcolor: function(){
|
3056 |
+
/*
|
3057 |
+
* There is a constraint on the color that it must
|
3058 |
+
* have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
|
3059 |
+
* after the "#"; e.g., "#000" is OK, but "#abcd" is not.
|
3060 |
+
*
|
3061 |
+
* hexcolor
|
3062 |
+
* : HASH S*
|
3063 |
+
* ;
|
3064 |
+
*/
|
3065 |
+
|
3066 |
+
var tokenStream = this._tokenStream,
|
3067 |
+
token = null,
|
3068 |
+
color;
|
3069 |
+
|
3070 |
+
if(tokenStream.match(Tokens.HASH)){
|
3071 |
+
|
3072 |
+
//need to do some validation here
|
3073 |
+
|
3074 |
+
token = tokenStream.token();
|
3075 |
+
color = token.value;
|
3076 |
+
if (!/#[a-f0-9]{3,6}/i.test(color)){
|
3077 |
+
throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
|
3078 |
+
}
|
3079 |
+
this._readWhitespace();
|
3080 |
+
}
|
3081 |
+
|
3082 |
+
return token;
|
3083 |
+
},
|
3084 |
+
|
3085 |
+
//-----------------------------------------------------------------
|
3086 |
+
// Animations methods
|
3087 |
+
//-----------------------------------------------------------------
|
3088 |
+
|
3089 |
+
_keyframes: function(){
|
3090 |
+
|
3091 |
+
/*
|
3092 |
+
* keyframes:
|
3093 |
+
* : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' {
|
3094 |
+
* ;
|
3095 |
+
*/
|
3096 |
+
var tokenStream = this._tokenStream,
|
3097 |
+
token,
|
3098 |
+
tt,
|
3099 |
+
name,
|
3100 |
+
prefix = "";
|
3101 |
+
|
3102 |
+
tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
|
3103 |
+
token = tokenStream.token();
|
3104 |
+
if (/^@\-([^\-]+)\-/.test(token.value)) {
|
3105 |
+
prefix = RegExp.$1;
|
3106 |
+
}
|
3107 |
+
|
3108 |
+
this._readWhitespace();
|
3109 |
+
name = this._keyframe_name();
|
3110 |
+
|
3111 |
+
this._readWhitespace();
|
3112 |
+
tokenStream.mustMatch(Tokens.LBRACE);
|
3113 |
+
|
3114 |
+
this.fire({
|
3115 |
+
type: "startkeyframes",
|
3116 |
+
name: name,
|
3117 |
+
prefix: prefix,
|
3118 |
+
line: token.startLine,
|
3119 |
+
col: token.startCol
|
3120 |
+
});
|
3121 |
+
|
3122 |
+
this._readWhitespace();
|
3123 |
+
tt = tokenStream.peek();
|
3124 |
+
|
3125 |
+
//check for key
|
3126 |
+
while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) {
|
3127 |
+
this._keyframe_rule();
|
3128 |
+
this._readWhitespace();
|
3129 |
+
tt = tokenStream.peek();
|
3130 |
+
}
|
3131 |
+
|
3132 |
+
this.fire({
|
3133 |
+
type: "endkeyframes",
|
3134 |
+
name: name,
|
3135 |
+
prefix: prefix,
|
3136 |
+
line: token.startLine,
|
3137 |
+
col: token.startCol
|
3138 |
+
});
|
3139 |
+
|
3140 |
+
this._readWhitespace();
|
3141 |
+
tokenStream.mustMatch(Tokens.RBRACE);
|
3142 |
+
|
3143 |
+
},
|
3144 |
+
|
3145 |
+
_keyframe_name: function(){
|
3146 |
+
|
3147 |
+
/*
|
3148 |
+
* keyframe_name:
|
3149 |
+
* : IDENT
|
3150 |
+
* | STRING
|
3151 |
+
* ;
|
3152 |
+
*/
|
3153 |
+
var tokenStream = this._tokenStream,
|
3154 |
+
token;
|
3155 |
+
|
3156 |
+
tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
|
3157 |
+
return SyntaxUnit.fromToken(tokenStream.token());
|
3158 |
+
},
|
3159 |
+
|
3160 |
+
_keyframe_rule: function(){
|
3161 |
+
|
3162 |
+
/*
|
3163 |
+
* keyframe_rule:
|
3164 |
+
* : key_list S*
|
3165 |
+
* '{' S* declaration [ ';' S* declaration ]* '}' S*
|
3166 |
+
* ;
|
3167 |
+
*/
|
3168 |
+
var tokenStream = this._tokenStream,
|
3169 |
+
token,
|
3170 |
+
keyList = this._key_list();
|
3171 |
+
|
3172 |
+
this.fire({
|
3173 |
+
type: "startkeyframerule",
|
3174 |
+
keys: keyList,
|
3175 |
+
line: keyList[0].line,
|
3176 |
+
col: keyList[0].col
|
3177 |
+
});
|
3178 |
+
|
3179 |
+
this._readDeclarations(true);
|
3180 |
+
|
3181 |
+
this.fire({
|
3182 |
+
type: "endkeyframerule",
|
3183 |
+
keys: keyList,
|
3184 |
+
line: keyList[0].line,
|
3185 |
+
col: keyList[0].col
|
3186 |
+
});
|
3187 |
+
|
3188 |
+
},
|
3189 |
+
|
3190 |
+
_key_list: function(){
|
3191 |
+
|
3192 |
+
/*
|
3193 |
+
* key_list:
|
3194 |
+
* : key [ S* ',' S* key]*
|
3195 |
+
* ;
|
3196 |
+
*/
|
3197 |
+
var tokenStream = this._tokenStream,
|
3198 |
+
token,
|
3199 |
+
key,
|
3200 |
+
keyList = [];
|
3201 |
+
|
3202 |
+
//must be least one key
|
3203 |
+
keyList.push(this._key());
|
3204 |
+
|
3205 |
+
this._readWhitespace();
|
3206 |
+
|
3207 |
+
while(tokenStream.match(Tokens.COMMA)){
|
3208 |
+
this._readWhitespace();
|
3209 |
+
keyList.push(this._key());
|
3210 |
+
this._readWhitespace();
|
3211 |
+
}
|
3212 |
+
|
3213 |
+
return keyList;
|
3214 |
+
},
|
3215 |
+
|
3216 |
+
_key: function(){
|
3217 |
+
/*
|
3218 |
+
* There is a restriction that IDENT can be only "from" or "to".
|
3219 |
+
*
|
3220 |
+
* key
|
3221 |
+
* : PERCENTAGE
|
3222 |
+
* | IDENT
|
3223 |
+
* ;
|
3224 |
+
*/
|
3225 |
+
|
3226 |
+
var tokenStream = this._tokenStream,
|
3227 |
+
token;
|
3228 |
+
|
3229 |
+
if (tokenStream.match(Tokens.PERCENTAGE)){
|
3230 |
+
return SyntaxUnit.fromToken(tokenStream.token());
|
3231 |
+
} else if (tokenStream.match(Tokens.IDENT)){
|
3232 |
+
token = tokenStream.token();
|
3233 |
+
|
3234 |
+
if (/from|to/i.test(token.value)){
|
3235 |
+
return SyntaxUnit.fromToken(token);
|
3236 |
+
}
|
3237 |
+
|
3238 |
+
tokenStream.unget();
|
3239 |
+
}
|
3240 |
+
|
3241 |
+
//if it gets here, there wasn't a valid token, so time to explode
|
3242 |
+
this._unexpectedToken(tokenStream.LT(1));
|
3243 |
+
},
|
3244 |
+
|
3245 |
+
//-----------------------------------------------------------------
|
3246 |
+
// Helper methods
|
3247 |
+
//-----------------------------------------------------------------
|
3248 |
+
|
3249 |
+
/**
|
3250 |
+
* Not part of CSS grammar, but useful for skipping over
|
3251 |
+
* combination of white space and HTML-style comments.
|
3252 |
+
* @return {void}
|
3253 |
+
* @method _skipCruft
|
3254 |
+
* @private
|
3255 |
+
*/
|
3256 |
+
_skipCruft: function(){
|
3257 |
+
while(this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])){
|
3258 |
+
//noop
|
3259 |
+
}
|
3260 |
+
},
|
3261 |
+
|
3262 |
+
/**
|
3263 |
+
* Not part of CSS grammar, but this pattern occurs frequently
|
3264 |
+
* in the official CSS grammar. Split out here to eliminate
|
3265 |
+
* duplicate code.
|
3266 |
+
* @param {Boolean} checkStart Indicates if the rule should check
|
3267 |
+
* for the left brace at the beginning.
|
3268 |
+
* @param {Boolean} readMargins Indicates if the rule should check
|
3269 |
+
* for margin patterns.
|
3270 |
+
* @return {void}
|
3271 |
+
* @method _readDeclarations
|
3272 |
+
* @private
|
3273 |
+
*/
|
3274 |
+
_readDeclarations: function(checkStart, readMargins){
|
3275 |
+
/*
|
3276 |
+
* Reads the pattern
|
3277 |
+
* S* '{' S* declaration [ ';' S* declaration ]* '}' S*
|
3278 |
+
* or
|
3279 |
+
* S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
|
3280 |
+
* Note that this is how it is described in CSS3 Paged Media, but is actually incorrect.
|
3281 |
+
* A semicolon is only necessary following a declaration is there's another declaration
|
3282 |
+
* or margin afterwards.
|
3283 |
+
*/
|
3284 |
+
var tokenStream = this._tokenStream,
|
3285 |
+
tt;
|
3286 |
+
|
3287 |
+
|
3288 |
+
this._readWhitespace();
|
3289 |
+
|
3290 |
+
if (checkStart){
|
3291 |
+
tokenStream.mustMatch(Tokens.LBRACE);
|
3292 |
+
}
|
3293 |
+
|
3294 |
+
this._readWhitespace();
|
3295 |
+
|
3296 |
+
try {
|
3297 |
+
|
3298 |
+
while(true){
|
3299 |
+
|
3300 |
+
if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){
|
3301 |
+
//noop
|
3302 |
+
} else if (this._declaration()){
|
3303 |
+
if (!tokenStream.match(Tokens.SEMICOLON)){
|
3304 |
+
break;
|
3305 |
+
}
|
3306 |
+
} else {
|
3307 |
+
break;
|
3308 |
+
}
|
3309 |
+
|
3310 |
+
//if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){
|
3311 |
+
// break;
|
3312 |
+
//}
|
3313 |
+
this._readWhitespace();
|
3314 |
+
}
|
3315 |
+
|
3316 |
+
tokenStream.mustMatch(Tokens.RBRACE);
|
3317 |
+
this._readWhitespace();
|
3318 |
+
|
3319 |
+
} catch (ex) {
|
3320 |
+
if (ex instanceof SyntaxError && !this.options.strict){
|
3321 |
+
|
3322 |
+
//fire error event
|
3323 |
+
this.fire({
|
3324 |
+
type: "error",
|
3325 |
+
error: ex,
|
3326 |
+
message: ex.message,
|
3327 |
+
line: ex.line,
|
3328 |
+
col: ex.col
|
3329 |
+
});
|
3330 |
+
|
3331 |
+
//see if there's another declaration
|
3332 |
+
tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
|
3333 |
+
if (tt == Tokens.SEMICOLON){
|
3334 |
+
//if there's a semicolon, then there might be another declaration
|
3335 |
+
this._readDeclarations(false, readMargins);
|
3336 |
+
} else if (tt != Tokens.RBRACE){
|
3337 |
+
//if there's a right brace, the rule is finished so don't do anything
|
3338 |
+
//otherwise, rethrow the error because it wasn't handled properly
|
3339 |
+
throw ex;
|
3340 |
+
}
|
3341 |
+
|
3342 |
+
} else {
|
3343 |
+
//not a syntax error, rethrow it
|
3344 |
+
throw ex;
|
3345 |
+
}
|
3346 |
+
}
|
3347 |
+
|
3348 |
+
},
|
3349 |
+
|
3350 |
+
/**
|
3351 |
+
* In some cases, you can end up with two white space tokens in a
|
3352 |
+
* row. Instead of making a change in every function that looks for
|
3353 |
+
* white space, this function is used to match as much white space
|
3354 |
+
* as necessary.
|
3355 |
+
* @method _readWhitespace
|
3356 |
+
* @return {String} The white space if found, empty string if not.
|
3357 |
+
* @private
|
3358 |
+
*/
|
3359 |
+
_readWhitespace: function(){
|
3360 |
+
|
3361 |
+
var tokenStream = this._tokenStream,
|
3362 |
+
ws = "";
|
3363 |
+
|
3364 |
+
while(tokenStream.match(Tokens.S)){
|
3365 |
+
ws += tokenStream.token().value;
|
3366 |
+
}
|
3367 |
+
|
3368 |
+
return ws;
|
3369 |
+
},
|
3370 |
+
|
3371 |
+
|
3372 |
+
/**
|
3373 |
+
* Throws an error when an unexpected token is found.
|
3374 |
+
* @param {Object} token The token that was found.
|
3375 |
+
* @method _unexpectedToken
|
3376 |
+
* @return {void}
|
3377 |
+
* @private
|
3378 |
+
*/
|
3379 |
+
_unexpectedToken: function(token){
|
3380 |
+
throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
|
3381 |
+
},
|
3382 |
+
|
3383 |
+
/**
|
3384 |
+
* Helper method used for parsing subparts of a style sheet.
|
3385 |
+
* @return {void}
|
3386 |
+
* @method _verifyEnd
|
3387 |
+
* @private
|
3388 |
+
*/
|
3389 |
+
_verifyEnd: function(){
|
3390 |
+
if (this._tokenStream.LA(1) != Tokens.EOF){
|
3391 |
+
this._unexpectedToken(this._tokenStream.LT(1));
|
3392 |
+
}
|
3393 |
+
},
|
3394 |
+
|
3395 |
+
//-----------------------------------------------------------------
|
3396 |
+
// Validation methods
|
3397 |
+
//-----------------------------------------------------------------
|
3398 |
+
_validateProperty: function(property, value){
|
3399 |
+
Validation.validate(property, value);
|
3400 |
+
},
|
3401 |
+
|
3402 |
+
//-----------------------------------------------------------------
|
3403 |
+
// Parsing methods
|
3404 |
+
//-----------------------------------------------------------------
|
3405 |
+
|
3406 |
+
parse: function(input){
|
3407 |
+
this._tokenStream = new TokenStream(input, Tokens);
|
3408 |
+
this._stylesheet();
|
3409 |
+
},
|
3410 |
+
|
3411 |
+
parseStyleSheet: function(input){
|
3412 |
+
//just passthrough
|
3413 |
+
return this.parse(input);
|
3414 |
+
},
|
3415 |
+
|
3416 |
+
parseMediaQuery: function(input){
|
3417 |
+
this._tokenStream = new TokenStream(input, Tokens);
|
3418 |
+
var result = this._media_query();
|
3419 |
+
|
3420 |
+
//if there's anything more, then it's an invalid selector
|
3421 |
+
this._verifyEnd();
|
3422 |
+
|
3423 |
+
//otherwise return result
|
3424 |
+
return result;
|
3425 |
+
},
|
3426 |
+
|
3427 |
+
/**
|
3428 |
+
* Parses a property value (everything after the semicolon).
|
3429 |
+
* @return {parserlib.css.PropertyValue} The property value.
|
3430 |
+
* @throws parserlib.util.SyntaxError If an unexpected token is found.
|
3431 |
+
* @method parserPropertyValue
|
3432 |
+
*/
|
3433 |
+
parsePropertyValue: function(input){
|
3434 |
+
|
3435 |
+
this._tokenStream = new TokenStream(input, Tokens);
|
3436 |
+
this._readWhitespace();
|
3437 |
+
|
3438 |
+
var result = this._expr();
|
3439 |
+
|
3440 |
+
//okay to have a trailing white space
|
3441 |
+
this._readWhitespace();
|
3442 |
+
|
3443 |
+
//if there's anything more, then it's an invalid selector
|
3444 |
+
this._verifyEnd();
|
3445 |
+
|
3446 |
+
//otherwise return result
|
3447 |
+
return result;
|
3448 |
+
},
|
3449 |
+
|
3450 |
+
/**
|
3451 |
+
* Parses a complete CSS rule, including selectors and
|
3452 |
+
* properties.
|
3453 |
+
* @param {String} input The text to parser.
|
3454 |
+
* @return {Boolean} True if the parse completed successfully, false if not.
|
3455 |
+
* @method parseRule
|
3456 |
+
*/
|
3457 |
+
parseRule: function(input){
|
3458 |
+
this._tokenStream = new TokenStream(input, Tokens);
|
3459 |
+
|
3460 |
+
//skip any leading white space
|
3461 |
+
this._readWhitespace();
|
3462 |
+
|
3463 |
+
var result = this._ruleset();
|
3464 |
+
|
3465 |
+
//skip any trailing white space
|
3466 |
+
this._readWhitespace();
|
3467 |
+
|
3468 |
+
//if there's anything more, then it's an invalid selector
|
3469 |
+
this._verifyEnd();
|
3470 |
+
|
3471 |
+
//otherwise return result
|
3472 |
+
return result;
|
3473 |
+
},
|
3474 |
+
|
3475 |
+
/**
|
3476 |
+
* Parses a single CSS selector (no comma)
|
3477 |
+
* @param {String} input The text to parse as a CSS selector.
|
3478 |
+
* @return {Selector} An object representing the selector.
|
3479 |
+
* @throws parserlib.util.SyntaxError If an unexpected token is found.
|
3480 |
+
* @method parseSelector
|
3481 |
+
*/
|
3482 |
+
parseSelector: function(input){
|
3483 |
+
|
3484 |
+
this._tokenStream = new TokenStream(input, Tokens);
|
3485 |
+
|
3486 |
+
//skip any leading white space
|
3487 |
+
this._readWhitespace();
|
3488 |
+
|
3489 |
+
var result = this._selector();
|
3490 |
+
|
3491 |
+
//skip any trailing white space
|
3492 |
+
this._readWhitespace();
|
3493 |
+
|
3494 |
+
//if there's anything more, then it's an invalid selector
|
3495 |
+
this._verifyEnd();
|
3496 |
+
|
3497 |
+
//otherwise return result
|
3498 |
+
return result;
|
3499 |
+
},
|
3500 |
+
|
3501 |
+
/**
|
3502 |
+
* Parses an HTML style attribute: a set of CSS declarations
|
3503 |
+
* separated by semicolons.
|
3504 |
+
* @param {String} input The text to parse as a style attribute
|
3505 |
+
* @return {void}
|
3506 |
+
* @method parseStyleAttribute
|
3507 |
+
*/
|
3508 |
+
parseStyleAttribute: function(input){
|
3509 |
+
input += "}"; // for error recovery in _readDeclarations()
|
3510 |
+
this._tokenStream = new TokenStream(input, Tokens);
|
3511 |
+
this._readDeclarations();
|
3512 |
+
}
|
3513 |
+
};
|
3514 |
+
|
3515 |
+
//copy over onto prototype
|
3516 |
+
for (prop in additions){
|
3517 |
+
if (additions.hasOwnProperty(prop)){
|
3518 |
+
proto[prop] = additions[prop];
|
3519 |
+
}
|
3520 |
+
}
|
3521 |
+
|
3522 |
+
return proto;
|
3523 |
+
}();
|
3524 |
+
|
3525 |
+
|
3526 |
+
/*
|
3527 |
+
nth
|
3528 |
+
: S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
|
3529 |
+
['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
|
3530 |
+
;
|
3531 |
+
*/
|
3532 |
+
|
3533 |
+
/*global Validation, ValidationTypes, ValidationError*/
|
3534 |
+
var Properties = {
|
3535 |
+
|
3536 |
+
//A
|
3537 |
+
"alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
|
3538 |
+
"alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
|
3539 |
+
"animation" : 1,
|
3540 |
+
"animation-delay" : { multi: "<time>", comma: true },
|
3541 |
+
"animation-direction" : { multi: "normal | alternate", comma: true },
|
3542 |
+
"animation-duration" : { multi: "<time>", comma: true },
|
3543 |
+
"animation-iteration-count" : { multi: "<number> | infinite", comma: true },
|
3544 |
+
"animation-name" : { multi: "none | <ident>", comma: true },
|
3545 |
+
"animation-play-state" : { multi: "running | paused", comma: true },
|
3546 |
+
"animation-timing-function" : 1,
|
3547 |
+
|
3548 |
+
//vendor prefixed
|
3549 |
+
"-moz-animation-delay" : { multi: "<time>", comma: true },
|
3550 |
+
"-moz-animation-direction" : { multi: "normal | alternate", comma: true },
|
3551 |
+
"-moz-animation-duration" : { multi: "<time>", comma: true },
|
3552 |
+
"-moz-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
|
3553 |
+
"-moz-animation-name" : { multi: "none | <ident>", comma: true },
|
3554 |
+
"-moz-animation-play-state" : { multi: "running | paused", comma: true },
|
3555 |
+
|
3556 |
+
"-ms-animation-delay" : { multi: "<time>", comma: true },
|
3557 |
+
"-ms-animation-direction" : { multi: "normal | alternate", comma: true },
|
3558 |
+
"-ms-animation-duration" : { multi: "<time>", comma: true },
|
3559 |
+
"-ms-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
|
3560 |
+
"-ms-animation-name" : { multi: "none | <ident>", comma: true },
|
3561 |
+
"-ms-animation-play-state" : { multi: "running | paused", comma: true },
|
3562 |
+
|
3563 |
+
"-webkit-animation-delay" : { multi: "<time>", comma: true },
|
3564 |
+
"-webkit-animation-direction" : { multi: "normal | alternate", comma: true },
|
3565 |
+
"-webkit-animation-duration" : { multi: "<time>", comma: true },
|
3566 |
+
"-webkit-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
|
3567 |
+
"-webkit-animation-name" : { multi: "none | <ident>", comma: true },
|
3568 |
+
"-webkit-animation-play-state" : { multi: "running | paused", comma: true },
|
3569 |
+
|
3570 |
+
"-o-animation-delay" : { multi: "<time>", comma: true },
|
3571 |
+
"-o-animation-direction" : { multi: "normal | alternate", comma: true },
|
3572 |
+
"-o-animation-duration" : { multi: "<time>", comma: true },
|
3573 |
+
"-o-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
|
3574 |
+
"-o-animation-name" : { multi: "none | <ident>", comma: true },
|
3575 |
+
"-o-animation-play-state" : { multi: "running | paused", comma: true },
|
3576 |
+
|
3577 |
+
"appearance" : "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit",
|
3578 |
+
"azimuth" : function (expression) {
|
3579 |
+
var simple = "<angle> | leftwards | rightwards | inherit",
|
3580 |
+
direction = "left-side | far-left | left | center-left | center | center-right | right | far-right | right-side",
|
3581 |
+
behind = false,
|
3582 |
+
valid = false,
|
3583 |
+
part;
|
3584 |
+
|
3585 |
+
if (!ValidationTypes.isAny(expression, simple)) {
|
3586 |
+
if (ValidationTypes.isAny(expression, "behind")) {
|
3587 |
+
behind = true;
|
3588 |
+
valid = true;
|
3589 |
+
}
|
3590 |
+
|
3591 |
+
if (ValidationTypes.isAny(expression, direction)) {
|
3592 |
+
valid = true;
|
3593 |
+
if (!behind) {
|
3594 |
+
ValidationTypes.isAny(expression, "behind");
|
3595 |
+
}
|
3596 |
+
}
|
3597 |
+
}
|
3598 |
+
|
3599 |
+
if (expression.hasNext()) {
|
3600 |
+
part = expression.next();
|
3601 |
+
if (valid) {
|
3602 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
3603 |
+
} else {
|
3604 |
+
throw new ValidationError("Expected (<'azimuth'>) but found '" + part + "'.", part.line, part.col);
|
3605 |
+
}
|
3606 |
+
}
|
3607 |
+
},
|
3608 |
+
|
3609 |
+
//B
|
3610 |
+
"backface-visibility" : "visible | hidden",
|
3611 |
+
"background" : 1,
|
3612 |
+
"background-attachment" : { multi: "<attachment>", comma: true },
|
3613 |
+
"background-clip" : { multi: "<box>", comma: true },
|
3614 |
+
"background-color" : "<color> | inherit",
|
3615 |
+
"background-image" : { multi: "<bg-image>", comma: true },
|
3616 |
+
"background-origin" : { multi: "<box>", comma: true },
|
3617 |
+
"background-position" : { multi: "<bg-position>", comma: true },
|
3618 |
+
"background-repeat" : { multi: "<repeat-style>" },
|
3619 |
+
"background-size" : { multi: "<bg-size>", comma: true },
|
3620 |
+
"baseline-shift" : "baseline | sub | super | <percentage> | <length>",
|
3621 |
+
"behavior" : 1,
|
3622 |
+
"binding" : 1,
|
3623 |
+
"bleed" : "<length>",
|
3624 |
+
"bookmark-label" : "<content> | <attr> | <string>",
|
3625 |
+
"bookmark-level" : "none | <integer>",
|
3626 |
+
"bookmark-state" : "open | closed",
|
3627 |
+
"bookmark-target" : "none | <uri> | <attr>",
|
3628 |
+
"border" : "<border-width> || <border-style> || <color>",
|
3629 |
+
"border-bottom" : "<border-width> || <border-style> || <color>",
|
3630 |
+
"border-bottom-color" : "<color> | inherit",
|
3631 |
+
"border-bottom-left-radius" : "<x-one-radius>",
|
3632 |
+
"border-bottom-right-radius" : "<x-one-radius>",
|
3633 |
+
"border-bottom-style" : "<border-style>",
|
3634 |
+
"border-bottom-width" : "<border-width>",
|
3635 |
+
"border-collapse" : "collapse | separate | inherit",
|
3636 |
+
"border-color" : { multi: "<color> | inherit", max: 4 },
|
3637 |
+
"border-image" : 1,
|
3638 |
+
"border-image-outset" : { multi: "<length> | <number>", max: 4 },
|
3639 |
+
"border-image-repeat" : { multi: "stretch | repeat | round", max: 2 },
|
3640 |
+
"border-image-slice" : function(expression) {
|
3641 |
+
|
3642 |
+
var valid = false,
|
3643 |
+
numeric = "<number> | <percentage>",
|
3644 |
+
fill = false,
|
3645 |
+
count = 0,
|
3646 |
+
max = 4,
|
3647 |
+
part;
|
3648 |
+
|
3649 |
+
if (ValidationTypes.isAny(expression, "fill")) {
|
3650 |
+
fill = true;
|
3651 |
+
valid = true;
|
3652 |
+
}
|
3653 |
+
|
3654 |
+
while (expression.hasNext() && count < max) {
|
3655 |
+
valid = ValidationTypes.isAny(expression, numeric);
|
3656 |
+
if (!valid) {
|
3657 |
+
break;
|
3658 |
+
}
|
3659 |
+
count++;
|
3660 |
+
}
|
3661 |
+
|
3662 |
+
|
3663 |
+
if (!fill) {
|
3664 |
+
ValidationTypes.isAny(expression, "fill");
|
3665 |
+
} else {
|
3666 |
+
valid = true;
|
3667 |
+
}
|
3668 |
+
|
3669 |
+
if (expression.hasNext()) {
|
3670 |
+
part = expression.next();
|
3671 |
+
if (valid) {
|
3672 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
3673 |
+
} else {
|
3674 |
+
throw new ValidationError("Expected ([<number> | <percentage>]{1,4} && fill?) but found '" + part + "'.", part.line, part.col);
|
3675 |
+
}
|
3676 |
+
}
|
3677 |
+
},
|
3678 |
+
"border-image-source" : "<image> | none",
|
3679 |
+
"border-image-width" : { multi: "<length> | <percentage> | <number> | auto", max: 4 },
|
3680 |
+
"border-left" : "<border-width> || <border-style> || <color>",
|
3681 |
+
"border-left-color" : "<color> | inherit",
|
3682 |
+
"border-left-style" : "<border-style>",
|
3683 |
+
"border-left-width" : "<border-width>",
|
3684 |
+
"border-radius" : function(expression) {
|
3685 |
+
|
3686 |
+
var valid = false,
|
3687 |
+
simple = "<length> | <percentage> | inherit",
|
3688 |
+
slash = false,
|
3689 |
+
fill = false,
|
3690 |
+
count = 0,
|
3691 |
+
max = 8,
|
3692 |
+
part;
|
3693 |
+
|
3694 |
+
while (expression.hasNext() && count < max) {
|
3695 |
+
valid = ValidationTypes.isAny(expression, simple);
|
3696 |
+
if (!valid) {
|
3697 |
+
|
3698 |
+
if (expression.peek() == "/" && count > 0 && !slash) {
|
3699 |
+
slash = true;
|
3700 |
+
max = count + 5;
|
3701 |
+
expression.next();
|
3702 |
+
} else {
|
3703 |
+
break;
|
3704 |
+
}
|
3705 |
+
}
|
3706 |
+
count++;
|
3707 |
+
}
|
3708 |
+
|
3709 |
+
if (expression.hasNext()) {
|
3710 |
+
part = expression.next();
|
3711 |
+
if (valid) {
|
3712 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
3713 |
+
} else {
|
3714 |
+
throw new ValidationError("Expected (<'border-radius'>) but found '" + part + "'.", part.line, part.col);
|
3715 |
+
}
|
3716 |
+
}
|
3717 |
+
},
|
3718 |
+
"border-right" : "<border-width> || <border-style> || <color>",
|
3719 |
+
"border-right-color" : "<color> | inherit",
|
3720 |
+
"border-right-style" : "<border-style>",
|
3721 |
+
"border-right-width" : "<border-width>",
|
3722 |
+
"border-spacing" : { multi: "<length> | inherit", max: 2 },
|
3723 |
+
"border-style" : { multi: "<border-style>", max: 4 },
|
3724 |
+
"border-top" : "<border-width> || <border-style> || <color>",
|
3725 |
+
"border-top-color" : "<color> | inherit",
|
3726 |
+
"border-top-left-radius" : "<x-one-radius>",
|
3727 |
+
"border-top-right-radius" : "<x-one-radius>",
|
3728 |
+
"border-top-style" : "<border-style>",
|
3729 |
+
"border-top-width" : "<border-width>",
|
3730 |
+
"border-width" : { multi: "<border-width>", max: 4 },
|
3731 |
+
"bottom" : "<margin-width> | inherit",
|
3732 |
+
"box-align" : "start | end | center | baseline | stretch", //http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/
|
3733 |
+
"box-decoration-break" : "slice |clone",
|
3734 |
+
"box-direction" : "normal | reverse | inherit",
|
3735 |
+
"box-flex" : "<number>",
|
3736 |
+
"box-flex-group" : "<integer>",
|
3737 |
+
"box-lines" : "single | multiple",
|
3738 |
+
"box-ordinal-group" : "<integer>",
|
3739 |
+
"box-orient" : "horizontal | vertical | inline-axis | block-axis | inherit",
|
3740 |
+
"box-pack" : "start | end | center | justify",
|
3741 |
+
"box-shadow" : function (expression) {
|
3742 |
+
var result = false,
|
3743 |
+
part;
|
3744 |
+
|
3745 |
+
if (!ValidationTypes.isAny(expression, "none")) {
|
3746 |
+
Validation.multiProperty("<shadow>", expression, true, Infinity);
|
3747 |
+
} else {
|
3748 |
+
if (expression.hasNext()) {
|
3749 |
+
part = expression.next();
|
3750 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
3751 |
+
}
|
3752 |
+
}
|
3753 |
+
},
|
3754 |
+
"box-sizing" : "content-box | border-box | inherit",
|
3755 |
+
"break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
|
3756 |
+
"break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
|
3757 |
+
"break-inside" : "auto | avoid | avoid-page | avoid-column",
|
3758 |
+
|
3759 |
+
//C
|
3760 |
+
"caption-side" : "top | bottom | inherit",
|
3761 |
+
"clear" : "none | right | left | both | inherit",
|
3762 |
+
"clip" : 1,
|
3763 |
+
"color" : "<color> | inherit",
|
3764 |
+
"color-profile" : 1,
|
3765 |
+
"column-count" : "<integer> | auto", //http://www.w3.org/TR/css3-multicol/
|
3766 |
+
"column-fill" : "auto | balance",
|
3767 |
+
"column-gap" : "<length> | normal",
|
3768 |
+
"column-rule" : "<border-width> || <border-style> || <color>",
|
3769 |
+
"column-rule-color" : "<color>",
|
3770 |
+
"column-rule-style" : "<border-style>",
|
3771 |
+
"column-rule-width" : "<border-width>",
|
3772 |
+
"column-span" : "none | all",
|
3773 |
+
"column-width" : "<length> | auto",
|
3774 |
+
"columns" : 1,
|
3775 |
+
"content" : 1,
|
3776 |
+
"counter-increment" : 1,
|
3777 |
+
"counter-reset" : 1,
|
3778 |
+
"crop" : "<shape> | auto",
|
3779 |
+
"cue" : "cue-after | cue-before | inherit",
|
3780 |
+
"cue-after" : 1,
|
3781 |
+
"cue-before" : 1,
|
3782 |
+
"cursor" : 1,
|
3783 |
+
|
3784 |
+
//D
|
3785 |
+
"direction" : "ltr | rtl | inherit",
|
3786 |
+
"display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | box | inline-box | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box",
|
3787 |
+
"dominant-baseline" : 1,
|
3788 |
+
"drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
|
3789 |
+
"drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
|
3790 |
+
"drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
|
3791 |
+
"drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
|
3792 |
+
"drop-initial-size" : "auto | line | <length> | <percentage>",
|
3793 |
+
"drop-initial-value" : "initial | <integer>",
|
3794 |
+
|
3795 |
+
//E
|
3796 |
+
"elevation" : "<angle> | below | level | above | higher | lower | inherit",
|
3797 |
+
"empty-cells" : "show | hide | inherit",
|
3798 |
+
|
3799 |
+
//F
|
3800 |
+
"filter" : 1,
|
3801 |
+
"fit" : "fill | hidden | meet | slice",
|
3802 |
+
"fit-position" : 1,
|
3803 |
+
"float" : "left | right | none | inherit",
|
3804 |
+
"float-offset" : 1,
|
3805 |
+
"font" : 1,
|
3806 |
+
"font-family" : 1,
|
3807 |
+
"font-size" : "<absolute-size> | <relative-size> | <length> | <percentage> | inherit",
|
3808 |
+
"font-size-adjust" : "<number> | none | inherit",
|
3809 |
+
"font-stretch" : "normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit",
|
3810 |
+
"font-style" : "normal | italic | oblique | inherit",
|
3811 |
+
"font-variant" : "normal | small-caps | inherit",
|
3812 |
+
"font-weight" : "normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit",
|
3813 |
+
|
3814 |
+
//G
|
3815 |
+
"grid-cell-stacking" : "columns | rows | layer",
|
3816 |
+
"grid-column" : 1,
|
3817 |
+
"grid-columns" : 1,
|
3818 |
+
"grid-column-align" : "start | end | center | stretch",
|
3819 |
+
"grid-column-sizing" : 1,
|
3820 |
+
"grid-column-span" : "<integer>",
|
3821 |
+
"grid-flow" : "none | rows | columns",
|
3822 |
+
"grid-layer" : "<integer>",
|
3823 |
+
"grid-row" : 1,
|
3824 |
+
"grid-rows" : 1,
|
3825 |
+
"grid-row-align" : "start | end | center | stretch",
|
3826 |
+
"grid-row-span" : "<integer>",
|
3827 |
+
"grid-row-sizing" : 1,
|
3828 |
+
|
3829 |
+
//H
|
3830 |
+
"hanging-punctuation" : 1,
|
3831 |
+
"height" : "<margin-width> | inherit",
|
3832 |
+
"hyphenate-after" : "<integer> | auto",
|
3833 |
+
"hyphenate-before" : "<integer> | auto",
|
3834 |
+
"hyphenate-character" : "<string> | auto",
|
3835 |
+
"hyphenate-lines" : "no-limit | <integer>",
|
3836 |
+
"hyphenate-resource" : 1,
|
3837 |
+
"hyphens" : "none | manual | auto",
|
3838 |
+
|
3839 |
+
//I
|
3840 |
+
"icon" : 1,
|
3841 |
+
"image-orientation" : "angle | auto",
|
3842 |
+
"image-rendering" : 1,
|
3843 |
+
"image-resolution" : 1,
|
3844 |
+
"inline-box-align" : "initial | last | <integer>",
|
3845 |
+
|
3846 |
+
//L
|
3847 |
+
"left" : "<margin-width> | inherit",
|
3848 |
+
"letter-spacing" : "<length> | normal | inherit",
|
3849 |
+
"line-height" : "<number> | <length> | <percentage> | normal | inherit",
|
3850 |
+
"line-break" : "auto | loose | normal | strict",
|
3851 |
+
"line-stacking" : 1,
|
3852 |
+
"line-stacking-ruby" : "exclude-ruby | include-ruby",
|
3853 |
+
"line-stacking-shift" : "consider-shifts | disregard-shifts",
|
3854 |
+
"line-stacking-strategy" : "inline-line-height | block-line-height | max-height | grid-height",
|
3855 |
+
"list-style" : 1,
|
3856 |
+
"list-style-image" : "<uri> | none | inherit",
|
3857 |
+
"list-style-position" : "inside | outside | inherit",
|
3858 |
+
"list-style-type" : "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit",
|
3859 |
+
|
3860 |
+
//M
|
3861 |
+
"margin" : { multi: "<margin-width> | inherit", max: 4 },
|
3862 |
+
"margin-bottom" : "<margin-width> | inherit",
|
3863 |
+
"margin-left" : "<margin-width> | inherit",
|
3864 |
+
"margin-right" : "<margin-width> | inherit",
|
3865 |
+
"margin-top" : "<margin-width> | inherit",
|
3866 |
+
"mark" : 1,
|
3867 |
+
"mark-after" : 1,
|
3868 |
+
"mark-before" : 1,
|
3869 |
+
"marks" : 1,
|
3870 |
+
"marquee-direction" : 1,
|
3871 |
+
"marquee-play-count" : 1,
|
3872 |
+
"marquee-speed" : 1,
|
3873 |
+
"marquee-style" : 1,
|
3874 |
+
"max-height" : "<length> | <percentage> | none | inherit",
|
3875 |
+
"max-width" : "<length> | <percentage> | none | inherit",
|
3876 |
+
"min-height" : "<length> | <percentage> | inherit",
|
3877 |
+
"min-width" : "<length> | <percentage> | inherit",
|
3878 |
+
"move-to" : 1,
|
3879 |
+
|
3880 |
+
//N
|
3881 |
+
"nav-down" : 1,
|
3882 |
+
"nav-index" : 1,
|
3883 |
+
"nav-left" : 1,
|
3884 |
+
"nav-right" : 1,
|
3885 |
+
"nav-up" : 1,
|
3886 |
+
|
3887 |
+
//O
|
3888 |
+
"opacity" : "<number> | inherit",
|
3889 |
+
"orphans" : "<integer> | inherit",
|
3890 |
+
"outline" : 1,
|
3891 |
+
"outline-color" : "<color> | invert | inherit",
|
3892 |
+
"outline-offset" : 1,
|
3893 |
+
"outline-style" : "<border-style> | inherit",
|
3894 |
+
"outline-width" : "<border-width> | inherit",
|
3895 |
+
"overflow" : "visible | hidden | scroll | auto | inherit",
|
3896 |
+
"overflow-style" : 1,
|
3897 |
+
"overflow-x" : 1,
|
3898 |
+
"overflow-y" : 1,
|
3899 |
+
|
3900 |
+
//P
|
3901 |
+
"padding" : { multi: "<padding-width> | inherit", max: 4 },
|
3902 |
+
"padding-bottom" : "<padding-width> | inherit",
|
3903 |
+
"padding-left" : "<padding-width> | inherit",
|
3904 |
+
"padding-right" : "<padding-width> | inherit",
|
3905 |
+
"padding-top" : "<padding-width> | inherit",
|
3906 |
+
"page" : 1,
|
3907 |
+
"page-break-after" : "auto | always | avoid | left | right | inherit",
|
3908 |
+
"page-break-before" : "auto | always | avoid | left | right | inherit",
|
3909 |
+
"page-break-inside" : "auto | avoid | inherit",
|
3910 |
+
"page-policy" : 1,
|
3911 |
+
"pause" : 1,
|
3912 |
+
"pause-after" : 1,
|
3913 |
+
"pause-before" : 1,
|
3914 |
+
"perspective" : 1,
|
3915 |
+
"perspective-origin" : 1,
|
3916 |
+
"phonemes" : 1,
|
3917 |
+
"pitch" : 1,
|
3918 |
+
"pitch-range" : 1,
|
3919 |
+
"play-during" : 1,
|
3920 |
+
"pointer-events" : "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit",
|
3921 |
+
"position" : "static | relative | absolute | fixed | inherit",
|
3922 |
+
"presentation-level" : 1,
|
3923 |
+
"punctuation-trim" : 1,
|
3924 |
+
|
3925 |
+
//Q
|
3926 |
+
"quotes" : 1,
|
3927 |
+
|
3928 |
+
//R
|
3929 |
+
"rendering-intent" : 1,
|
3930 |
+
"resize" : 1,
|
3931 |
+
"rest" : 1,
|
3932 |
+
"rest-after" : 1,
|
3933 |
+
"rest-before" : 1,
|
3934 |
+
"richness" : 1,
|
3935 |
+
"right" : "<margin-width> | inherit",
|
3936 |
+
"rotation" : 1,
|
3937 |
+
"rotation-point" : 1,
|
3938 |
+
"ruby-align" : 1,
|
3939 |
+
"ruby-overhang" : 1,
|
3940 |
+
"ruby-position" : 1,
|
3941 |
+
"ruby-span" : 1,
|
3942 |
+
|
3943 |
+
//S
|
3944 |
+
"size" : 1,
|
3945 |
+
"speak" : "normal | none | spell-out | inherit",
|
3946 |
+
"speak-header" : "once | always | inherit",
|
3947 |
+
"speak-numeral" : "digits | continuous | inherit",
|
3948 |
+
"speak-punctuation" : "code | none | inherit",
|
3949 |
+
"speech-rate" : 1,
|
3950 |
+
"src" : 1,
|
3951 |
+
"stress" : 1,
|
3952 |
+
"string-set" : 1,
|
3953 |
+
|
3954 |
+
"table-layout" : "auto | fixed | inherit",
|
3955 |
+
"tab-size" : "<integer> | <length>",
|
3956 |
+
"target" : 1,
|
3957 |
+
"target-name" : 1,
|
3958 |
+
"target-new" : 1,
|
3959 |
+
"target-position" : 1,
|
3960 |
+
"text-align" : "left | right | center | justify | inherit" ,
|
3961 |
+
"text-align-last" : 1,
|
3962 |
+
"text-decoration" : 1,
|
3963 |
+
"text-emphasis" : 1,
|
3964 |
+
"text-height" : 1,
|
3965 |
+
"text-indent" : "<length> | <percentage> | inherit",
|
3966 |
+
"text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
|
3967 |
+
"text-outline" : 1,
|
3968 |
+
"text-overflow" : 1,
|
3969 |
+
"text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit",
|
3970 |
+
"text-shadow" : 1,
|
3971 |
+
"text-transform" : "capitalize | uppercase | lowercase | none | inherit",
|
3972 |
+
"text-wrap" : "normal | none | avoid",
|
3973 |
+
"top" : "<margin-width> | inherit",
|
3974 |
+
"transform" : 1,
|
3975 |
+
"transform-origin" : 1,
|
3976 |
+
"transform-style" : 1,
|
3977 |
+
"transition" : 1,
|
3978 |
+
"transition-delay" : 1,
|
3979 |
+
"transition-duration" : 1,
|
3980 |
+
"transition-property" : 1,
|
3981 |
+
"transition-timing-function" : 1,
|
3982 |
+
|
3983 |
+
//U
|
3984 |
+
"unicode-bidi" : "normal | embed | bidi-override | inherit",
|
3985 |
+
"user-modify" : "read-only | read-write | write-only | inherit",
|
3986 |
+
"user-select" : "none | text | toggle | element | elements | all | inherit",
|
3987 |
+
|
3988 |
+
//V
|
3989 |
+
"vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",
|
3990 |
+
"visibility" : "visible | hidden | collapse | inherit",
|
3991 |
+
"voice-balance" : 1,
|
3992 |
+
"voice-duration" : 1,
|
3993 |
+
"voice-family" : 1,
|
3994 |
+
"voice-pitch" : 1,
|
3995 |
+
"voice-pitch-range" : 1,
|
3996 |
+
"voice-rate" : 1,
|
3997 |
+
"voice-stress" : 1,
|
3998 |
+
"voice-volume" : 1,
|
3999 |
+
"volume" : 1,
|
4000 |
+
|
4001 |
+
//W
|
4002 |
+
"white-space" : "normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", //http://perishablepress.com/wrapping-content/
|
4003 |
+
"white-space-collapse" : 1,
|
4004 |
+
"widows" : "<integer> | inherit",
|
4005 |
+
"width" : "<length> | <percentage> | auto | inherit" ,
|
4006 |
+
"word-break" : "normal | keep-all | break-all",
|
4007 |
+
"word-spacing" : "<length> | normal | inherit",
|
4008 |
+
"word-wrap" : 1,
|
4009 |
+
|
4010 |
+
//Z
|
4011 |
+
"z-index" : "<integer> | auto | inherit",
|
4012 |
+
"zoom" : "<number> | <percentage> | normal"
|
4013 |
+
};
|
4014 |
+
|
4015 |
+
/*global SyntaxUnit, Parser*/
|
4016 |
+
/**
|
4017 |
+
* Represents a selector combinator (whitespace, +, >).
|
4018 |
+
* @namespace parserlib.css
|
4019 |
+
* @class PropertyName
|
4020 |
+
* @extends parserlib.util.SyntaxUnit
|
4021 |
+
* @constructor
|
4022 |
+
* @param {String} text The text representation of the unit.
|
4023 |
+
* @param {String} hack The type of IE hack applied ("*", "_", or null).
|
4024 |
+
* @param {int} line The line of text on which the unit resides.
|
4025 |
+
* @param {int} col The column of text on which the unit resides.
|
4026 |
+
*/
|
4027 |
+
function PropertyName(text, hack, line, col){
|
4028 |
+
|
4029 |
+
SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
|
4030 |
+
|
4031 |
+
/**
|
4032 |
+
* The type of IE hack applied ("*", "_", or null).
|
4033 |
+
* @type String
|
4034 |
+
* @property hack
|
4035 |
+
*/
|
4036 |
+
this.hack = hack;
|
4037 |
+
|
4038 |
+
}
|
4039 |
+
|
4040 |
+
PropertyName.prototype = new SyntaxUnit();
|
4041 |
+
PropertyName.prototype.constructor = PropertyName;
|
4042 |
+
PropertyName.prototype.toString = function(){
|
4043 |
+
return (this.hack ? this.hack : "") + this.text;
|
4044 |
+
};
|
4045 |
+
|
4046 |
+
/*global SyntaxUnit, Parser*/
|
4047 |
+
/**
|
4048 |
+
* Represents a single part of a CSS property value, meaning that it represents
|
4049 |
+
* just everything single part between ":" and ";". If there are multiple values
|
4050 |
+
* separated by commas, this type represents just one of the values.
|
4051 |
+
* @param {String[]} parts An array of value parts making up this value.
|
4052 |
+
* @param {int} line The line of text on which the unit resides.
|
4053 |
+
* @param {int} col The column of text on which the unit resides.
|
4054 |
+
* @namespace parserlib.css
|
4055 |
+
* @class PropertyValue
|
4056 |
+
* @extends parserlib.util.SyntaxUnit
|
4057 |
+
* @constructor
|
4058 |
+
*/
|
4059 |
+
function PropertyValue(parts, line, col){
|
4060 |
+
|
4061 |
+
SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
|
4062 |
+
|
4063 |
+
/**
|
4064 |
+
* The parts that make up the selector.
|
4065 |
+
* @type Array
|
4066 |
+
* @property parts
|
4067 |
+
*/
|
4068 |
+
this.parts = parts;
|
4069 |
+
|
4070 |
+
}
|
4071 |
+
|
4072 |
+
PropertyValue.prototype = new SyntaxUnit();
|
4073 |
+
PropertyValue.prototype.constructor = PropertyValue;
|
4074 |
+
|
4075 |
+
|
4076 |
+
/*global SyntaxUnit, Parser*/
|
4077 |
+
/**
|
4078 |
+
* A utility class that allows for easy iteration over the various parts of a
|
4079 |
+
* property value.
|
4080 |
+
* @param {parserlib.css.PropertyValue} value The property value to iterate over.
|
4081 |
+
* @namespace parserlib.css
|
4082 |
+
* @class PropertyValueIterator
|
4083 |
+
* @constructor
|
4084 |
+
*/
|
4085 |
+
function PropertyValueIterator(value){
|
4086 |
+
|
4087 |
+
/**
|
4088 |
+
* Iterator value
|
4089 |
+
* @type int
|
4090 |
+
* @property _i
|
4091 |
+
* @private
|
4092 |
+
*/
|
4093 |
+
this._i = 0;
|
4094 |
+
|
4095 |
+
/**
|
4096 |
+
* The parts that make up the value.
|
4097 |
+
* @type Array
|
4098 |
+
* @property _parts
|
4099 |
+
* @private
|
4100 |
+
*/
|
4101 |
+
this._parts = value.parts;
|
4102 |
+
|
4103 |
+
/**
|
4104 |
+
* Keeps track of bookmarks along the way.
|
4105 |
+
* @type Array
|
4106 |
+
* @property _marks
|
4107 |
+
* @private
|
4108 |
+
*/
|
4109 |
+
this._marks = [];
|
4110 |
+
|
4111 |
+
/**
|
4112 |
+
* Holds the original property value.
|
4113 |
+
* @type parserlib.css.PropertyValue
|
4114 |
+
* @property value
|
4115 |
+
*/
|
4116 |
+
this.value = value;
|
4117 |
+
|
4118 |
+
}
|
4119 |
+
|
4120 |
+
/**
|
4121 |
+
* Returns the total number of parts in the value.
|
4122 |
+
* @return {int} The total number of parts in the value.
|
4123 |
+
* @method count
|
4124 |
+
*/
|
4125 |
+
PropertyValueIterator.prototype.count = function(){
|
4126 |
+
return this._parts.length;
|
4127 |
+
};
|
4128 |
+
|
4129 |
+
/**
|
4130 |
+
* Indicates if the iterator is positioned at the first item.
|
4131 |
+
* @return {Boolean} True if positioned at first item, false if not.
|
4132 |
+
* @method isFirst
|
4133 |
+
*/
|
4134 |
+
PropertyValueIterator.prototype.isFirst = function(){
|
4135 |
+
return this._i === 0;
|
4136 |
+
};
|
4137 |
+
|
4138 |
+
/**
|
4139 |
+
* Indicates if there are more parts of the property value.
|
4140 |
+
* @return {Boolean} True if there are more parts, false if not.
|
4141 |
+
* @method hasNext
|
4142 |
+
*/
|
4143 |
+
PropertyValueIterator.prototype.hasNext = function(){
|
4144 |
+
return (this._i < this._parts.length);
|
4145 |
+
};
|
4146 |
+
|
4147 |
+
/**
|
4148 |
+
* Marks the current spot in the iteration so it can be restored to
|
4149 |
+
* later on.
|
4150 |
+
* @return {void}
|
4151 |
+
* @method mark
|
4152 |
+
*/
|
4153 |
+
PropertyValueIterator.prototype.mark = function(){
|
4154 |
+
this._marks.push(this._i);
|
4155 |
+
};
|
4156 |
+
|
4157 |
+
/**
|
4158 |
+
* Returns the next part of the property value or null if there is no next
|
4159 |
+
* part. Does not move the internal counter forward.
|
4160 |
+
* @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
|
4161 |
+
* part.
|
4162 |
+
* @method peek
|
4163 |
+
*/
|
4164 |
+
PropertyValueIterator.prototype.peek = function(count){
|
4165 |
+
return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
|
4166 |
+
};
|
4167 |
+
|
4168 |
+
/**
|
4169 |
+
* Returns the next part of the property value or null if there is no next
|
4170 |
+
* part.
|
4171 |
+
* @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
|
4172 |
+
* part.
|
4173 |
+
* @method next
|
4174 |
+
*/
|
4175 |
+
PropertyValueIterator.prototype.next = function(){
|
4176 |
+
return this.hasNext() ? this._parts[this._i++] : null;
|
4177 |
+
};
|
4178 |
+
|
4179 |
+
/**
|
4180 |
+
* Returns the previous part of the property value or null if there is no
|
4181 |
+
* previous part.
|
4182 |
+
* @return {parserlib.css.PropertyValuePart} The previous part of the
|
4183 |
+
* property value or null if there is no next part.
|
4184 |
+
* @method previous
|
4185 |
+
*/
|
4186 |
+
PropertyValueIterator.prototype.previous = function(){
|
4187 |
+
return this._i > 0 ? this._parts[--this._i] : null;
|
4188 |
+
};
|
4189 |
+
|
4190 |
+
/**
|
4191 |
+
* Restores the last saved bookmark.
|
4192 |
+
* @return {void}
|
4193 |
+
* @method restore
|
4194 |
+
*/
|
4195 |
+
PropertyValueIterator.prototype.restore = function(){
|
4196 |
+
if (this._marks.length){
|
4197 |
+
this._i = this._marks.pop();
|
4198 |
+
}
|
4199 |
+
};
|
4200 |
+
|
4201 |
+
|
4202 |
+
/*global SyntaxUnit, Parser, Colors*/
|
4203 |
+
/**
|
4204 |
+
* Represents a single part of a CSS property value, meaning that it represents
|
4205 |
+
* just one part of the data between ":" and ";".
|
4206 |
+
* @param {String} text The text representation of the unit.
|
4207 |
+
* @param {int} line The line of text on which the unit resides.
|
4208 |
+
* @param {int} col The column of text on which the unit resides.
|
4209 |
+
* @namespace parserlib.css
|
4210 |
+
* @class PropertyValuePart
|
4211 |
+
* @extends parserlib.util.SyntaxUnit
|
4212 |
+
* @constructor
|
4213 |
+
*/
|
4214 |
+
function PropertyValuePart(text, line, col){
|
4215 |
+
|
4216 |
+
SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
|
4217 |
+
|
4218 |
+
/**
|
4219 |
+
* Indicates the type of value unit.
|
4220 |
+
* @type String
|
4221 |
+
* @property type
|
4222 |
+
*/
|
4223 |
+
this.type = "unknown";
|
4224 |
+
|
4225 |
+
//figure out what type of data it is
|
4226 |
+
|
4227 |
+
var temp;
|
4228 |
+
|
4229 |
+
//it is a measurement?
|
4230 |
+
if (/^([+\-]?[\d\.]+)([a-z]+)$/i.test(text)){ //dimension
|
4231 |
+
this.type = "dimension";
|
4232 |
+
this.value = +RegExp.$1;
|
4233 |
+
this.units = RegExp.$2;
|
4234 |
+
|
4235 |
+
//try to narrow down
|
4236 |
+
switch(this.units.toLowerCase()){
|
4237 |
+
|
4238 |
+
case "em":
|
4239 |
+
case "rem":
|
4240 |
+
case "ex":
|
4241 |
+
case "px":
|
4242 |
+
case "cm":
|
4243 |
+
case "mm":
|
4244 |
+
case "in":
|
4245 |
+
case "pt":
|
4246 |
+
case "pc":
|
4247 |
+
case "ch":
|
4248 |
+
case "vh":
|
4249 |
+
case "vw":
|
4250 |
+
case "vm":
|
4251 |
+
this.type = "length";
|
4252 |
+
break;
|
4253 |
+
|
4254 |
+
case "deg":
|
4255 |
+
case "rad":
|
4256 |
+
case "grad":
|
4257 |
+
this.type = "angle";
|
4258 |
+
break;
|
4259 |
+
|
4260 |
+
case "ms":
|
4261 |
+
case "s":
|
4262 |
+
this.type = "time";
|
4263 |
+
break;
|
4264 |
+
|
4265 |
+
case "hz":
|
4266 |
+
case "khz":
|
4267 |
+
this.type = "frequency";
|
4268 |
+
break;
|
4269 |
+
|
4270 |
+
case "dpi":
|
4271 |
+
case "dpcm":
|
4272 |
+
this.type = "resolution";
|
4273 |
+
break;
|
4274 |
+
|
4275 |
+
//default
|
4276 |
+
|
4277 |
+
}
|
4278 |
+
|
4279 |
+
} else if (/^([+\-]?[\d\.]+)%$/i.test(text)){ //percentage
|
4280 |
+
this.type = "percentage";
|
4281 |
+
this.value = +RegExp.$1;
|
4282 |
+
} else if (/^([+\-]?[\d\.]+)%$/i.test(text)){ //percentage
|
4283 |
+
this.type = "percentage";
|
4284 |
+
this.value = +RegExp.$1;
|
4285 |
+
} else if (/^([+\-]?\d+)$/i.test(text)){ //integer
|
4286 |
+
this.type = "integer";
|
4287 |
+
this.value = +RegExp.$1;
|
4288 |
+
} else if (/^([+\-]?[\d\.]+)$/i.test(text)){ //number
|
4289 |
+
this.type = "number";
|
4290 |
+
this.value = +RegExp.$1;
|
4291 |
+
|
4292 |
+
} else if (/^#([a-f0-9]{3,6})/i.test(text)){ //hexcolor
|
4293 |
+
this.type = "color";
|
4294 |
+
temp = RegExp.$1;
|
4295 |
+
if (temp.length == 3){
|
4296 |
+
this.red = parseInt(temp.charAt(0)+temp.charAt(0),16);
|
4297 |
+
this.green = parseInt(temp.charAt(1)+temp.charAt(1),16);
|
4298 |
+
this.blue = parseInt(temp.charAt(2)+temp.charAt(2),16);
|
4299 |
+
} else {
|
4300 |
+
this.red = parseInt(temp.substring(0,2),16);
|
4301 |
+
this.green = parseInt(temp.substring(2,4),16);
|
4302 |
+
this.blue = parseInt(temp.substring(4,6),16);
|
4303 |
+
}
|
4304 |
+
} else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)){ //rgb() color with absolute numbers
|
4305 |
+
this.type = "color";
|
4306 |
+
this.red = +RegExp.$1;
|
4307 |
+
this.green = +RegExp.$2;
|
4308 |
+
this.blue = +RegExp.$3;
|
4309 |
+
} else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){ //rgb() color with percentages
|
4310 |
+
this.type = "color";
|
4311 |
+
this.red = +RegExp.$1 * 255 / 100;
|
4312 |
+
this.green = +RegExp.$2 * 255 / 100;
|
4313 |
+
this.blue = +RegExp.$3 * 255 / 100;
|
4314 |
+
} else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with absolute numbers
|
4315 |
+
this.type = "color";
|
4316 |
+
this.red = +RegExp.$1;
|
4317 |
+
this.green = +RegExp.$2;
|
4318 |
+
this.blue = +RegExp.$3;
|
4319 |
+
this.alpha = +RegExp.$4;
|
4320 |
+
} else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with percentages
|
4321 |
+
this.type = "color";
|
4322 |
+
this.red = +RegExp.$1 * 255 / 100;
|
4323 |
+
this.green = +RegExp.$2 * 255 / 100;
|
4324 |
+
this.blue = +RegExp.$3 * 255 / 100;
|
4325 |
+
this.alpha = +RegExp.$4;
|
4326 |
+
} else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){ //hsl()
|
4327 |
+
this.type = "color";
|
4328 |
+
this.hue = +RegExp.$1;
|
4329 |
+
this.saturation = +RegExp.$2 / 100;
|
4330 |
+
this.lightness = +RegExp.$3 / 100;
|
4331 |
+
} else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //hsla() color with percentages
|
4332 |
+
this.type = "color";
|
4333 |
+
this.hue = +RegExp.$1;
|
4334 |
+
this.saturation = +RegExp.$2 / 100;
|
4335 |
+
this.lightness = +RegExp.$3 / 100;
|
4336 |
+
this.alpha = +RegExp.$4;
|
4337 |
+
} else if (/^url\(["']?([^\)"']+)["']?\)/i.test(text)){ //URI
|
4338 |
+
this.type = "uri";
|
4339 |
+
this.uri = RegExp.$1;
|
4340 |
+
} else if (/^([^\(]+)\(/i.test(text)){
|
4341 |
+
this.type = "function";
|
4342 |
+
this.name = RegExp.$1;
|
4343 |
+
this.value = text;
|
4344 |
+
} else if (/^["'][^"']*["']/.test(text)){ //string
|
4345 |
+
this.type = "string";
|
4346 |
+
this.value = eval(text);
|
4347 |
+
} else if (Colors[text.toLowerCase()]){ //named color
|
4348 |
+
this.type = "color";
|
4349 |
+
temp = Colors[text.toLowerCase()].substring(1);
|
4350 |
+
this.red = parseInt(temp.substring(0,2),16);
|
4351 |
+
this.green = parseInt(temp.substring(2,4),16);
|
4352 |
+
this.blue = parseInt(temp.substring(4,6),16);
|
4353 |
+
} else if (/^[\,\/]$/.test(text)){
|
4354 |
+
this.type = "operator";
|
4355 |
+
this.value = text;
|
4356 |
+
} else if (/^[a-z\-\u0080-\uFFFF][a-z0-9\-\u0080-\uFFFF]*$/i.test(text)){
|
4357 |
+
this.type = "identifier";
|
4358 |
+
this.value = text;
|
4359 |
+
}
|
4360 |
+
|
4361 |
+
}
|
4362 |
+
|
4363 |
+
PropertyValuePart.prototype = new SyntaxUnit();
|
4364 |
+
PropertyValuePart.prototype.constructor = PropertyValuePart;
|
4365 |
+
|
4366 |
+
/**
|
4367 |
+
* Create a new syntax unit based solely on the given token.
|
4368 |
+
* Convenience method for creating a new syntax unit when
|
4369 |
+
* it represents a single token instead of multiple.
|
4370 |
+
* @param {Object} token The token object to represent.
|
4371 |
+
* @return {parserlib.css.PropertyValuePart} The object representing the token.
|
4372 |
+
* @static
|
4373 |
+
* @method fromToken
|
4374 |
+
*/
|
4375 |
+
PropertyValuePart.fromToken = function(token){
|
4376 |
+
return new PropertyValuePart(token.value, token.startLine, token.startCol);
|
4377 |
+
};
|
4378 |
+
var Pseudos = {
|
4379 |
+
":first-letter": 1,
|
4380 |
+
":first-line": 1,
|
4381 |
+
":before": 1,
|
4382 |
+
":after": 1
|
4383 |
+
};
|
4384 |
+
|
4385 |
+
Pseudos.ELEMENT = 1;
|
4386 |
+
Pseudos.CLASS = 2;
|
4387 |
+
|
4388 |
+
Pseudos.isElement = function(pseudo){
|
4389 |
+
return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] == Pseudos.ELEMENT;
|
4390 |
+
};
|
4391 |
+
/*global SyntaxUnit, Parser, Specificity*/
|
4392 |
+
/**
|
4393 |
+
* Represents an entire single selector, including all parts but not
|
4394 |
+
* including multiple selectors (those separated by commas).
|
4395 |
+
* @namespace parserlib.css
|
4396 |
+
* @class Selector
|
4397 |
+
* @extends parserlib.util.SyntaxUnit
|
4398 |
+
* @constructor
|
4399 |
+
* @param {Array} parts Array of selectors parts making up this selector.
|
4400 |
+
* @param {int} line The line of text on which the unit resides.
|
4401 |
+
* @param {int} col The column of text on which the unit resides.
|
4402 |
+
*/
|
4403 |
+
function Selector(parts, line, col){
|
4404 |
+
|
4405 |
+
SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
|
4406 |
+
|
4407 |
+
/**
|
4408 |
+
* The parts that make up the selector.
|
4409 |
+
* @type Array
|
4410 |
+
* @property parts
|
4411 |
+
*/
|
4412 |
+
this.parts = parts;
|
4413 |
+
|
4414 |
+
/**
|
4415 |
+
* The specificity of the selector.
|
4416 |
+
* @type parserlib.css.Specificity
|
4417 |
+
* @property specificity
|
4418 |
+
*/
|
4419 |
+
this.specificity = Specificity.calculate(this);
|
4420 |
+
|
4421 |
+
}
|
4422 |
+
|
4423 |
+
Selector.prototype = new SyntaxUnit();
|
4424 |
+
Selector.prototype.constructor = Selector;
|
4425 |
+
|
4426 |
+
|
4427 |
+
/*global SyntaxUnit, Parser*/
|
4428 |
+
/**
|
4429 |
+
* Represents a single part of a selector string, meaning a single set of
|
4430 |
+
* element name and modifiers. This does not include combinators such as
|
4431 |
+
* spaces, +, >, etc.
|
4432 |
+
* @namespace parserlib.css
|
4433 |
+
* @class SelectorPart
|
4434 |
+
* @extends parserlib.util.SyntaxUnit
|
4435 |
+
* @constructor
|
4436 |
+
* @param {String} elementName The element name in the selector or null
|
4437 |
+
* if there is no element name.
|
4438 |
+
* @param {Array} modifiers Array of individual modifiers for the element.
|
4439 |
+
* May be empty if there are none.
|
4440 |
+
* @param {String} text The text representation of the unit.
|
4441 |
+
* @param {int} line The line of text on which the unit resides.
|
4442 |
+
* @param {int} col The column of text on which the unit resides.
|
4443 |
+
*/
|
4444 |
+
function SelectorPart(elementName, modifiers, text, line, col){
|
4445 |
+
|
4446 |
+
SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
|
4447 |
+
|
4448 |
+
/**
|
4449 |
+
* The tag name of the element to which this part
|
4450 |
+
* of the selector affects.
|
4451 |
+
* @type String
|
4452 |
+
* @property elementName
|
4453 |
+
*/
|
4454 |
+
this.elementName = elementName;
|
4455 |
+
|
4456 |
+
/**
|
4457 |
+
* The parts that come after the element name, such as class names, IDs,
|
4458 |
+
* pseudo classes/elements, etc.
|
4459 |
+
* @type Array
|
4460 |
+
* @property modifiers
|
4461 |
+
*/
|
4462 |
+
this.modifiers = modifiers;
|
4463 |
+
|
4464 |
+
}
|
4465 |
+
|
4466 |
+
SelectorPart.prototype = new SyntaxUnit();
|
4467 |
+
SelectorPart.prototype.constructor = SelectorPart;
|
4468 |
+
|
4469 |
+
|
4470 |
+
/*global SyntaxUnit, Parser*/
|
4471 |
+
/**
|
4472 |
+
* Represents a selector modifier string, meaning a class name, element name,
|
4473 |
+
* element ID, pseudo rule, etc.
|
4474 |
+
* @namespace parserlib.css
|
4475 |
+
* @class SelectorSubPart
|
4476 |
+
* @extends parserlib.util.SyntaxUnit
|
4477 |
+
* @constructor
|
4478 |
+
* @param {String} text The text representation of the unit.
|
4479 |
+
* @param {String} type The type of selector modifier.
|
4480 |
+
* @param {int} line The line of text on which the unit resides.
|
4481 |
+
* @param {int} col The column of text on which the unit resides.
|
4482 |
+
*/
|
4483 |
+
function SelectorSubPart(text, type, line, col){
|
4484 |
+
|
4485 |
+
SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
|
4486 |
+
|
4487 |
+
/**
|
4488 |
+
* The type of modifier.
|
4489 |
+
* @type String
|
4490 |
+
* @property type
|
4491 |
+
*/
|
4492 |
+
this.type = type;
|
4493 |
+
|
4494 |
+
/**
|
4495 |
+
* Some subparts have arguments, this represents them.
|
4496 |
+
* @type Array
|
4497 |
+
* @property args
|
4498 |
+
*/
|
4499 |
+
this.args = [];
|
4500 |
+
|
4501 |
+
}
|
4502 |
+
|
4503 |
+
SelectorSubPart.prototype = new SyntaxUnit();
|
4504 |
+
SelectorSubPart.prototype.constructor = SelectorSubPart;
|
4505 |
+
|
4506 |
+
|
4507 |
+
/*global Pseudos, SelectorPart*/
|
4508 |
+
/**
|
4509 |
+
* Represents a selector's specificity.
|
4510 |
+
* @namespace parserlib.css
|
4511 |
+
* @class Specificity
|
4512 |
+
* @constructor
|
4513 |
+
* @param {int} a Should be 1 for inline styles, zero for stylesheet styles
|
4514 |
+
* @param {int} b Number of ID selectors
|
4515 |
+
* @param {int} c Number of classes and pseudo classes
|
4516 |
+
* @param {int} d Number of element names and pseudo elements
|
4517 |
+
*/
|
4518 |
+
function Specificity(a, b, c, d){
|
4519 |
+
this.a = a;
|
4520 |
+
this.b = b;
|
4521 |
+
this.c = c;
|
4522 |
+
this.d = d;
|
4523 |
+
}
|
4524 |
+
|
4525 |
+
Specificity.prototype = {
|
4526 |
+
constructor: Specificity,
|
4527 |
+
|
4528 |
+
/**
|
4529 |
+
* Compare this specificity to another.
|
4530 |
+
* @param {Specificity} other The other specificity to compare to.
|
4531 |
+
* @return {int} -1 if the other specificity is larger, 1 if smaller, 0 if equal.
|
4532 |
+
* @method compare
|
4533 |
+
*/
|
4534 |
+
compare: function(other){
|
4535 |
+
var comps = ["a", "b", "c", "d"],
|
4536 |
+
i, len;
|
4537 |
+
|
4538 |
+
for (i=0, len=comps.length; i < len; i++){
|
4539 |
+
if (this[comps[i]] < other[comps[i]]){
|
4540 |
+
return -1;
|
4541 |
+
} else if (this[comps[i]] > other[comps[i]]){
|
4542 |
+
return 1;
|
4543 |
+
}
|
4544 |
+
}
|
4545 |
+
|
4546 |
+
return 0;
|
4547 |
+
},
|
4548 |
+
|
4549 |
+
/**
|
4550 |
+
* Creates a numeric value for the specificity.
|
4551 |
+
* @return {int} The numeric value for the specificity.
|
4552 |
+
* @method valueOf
|
4553 |
+
*/
|
4554 |
+
valueOf: function(){
|
4555 |
+
return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
|
4556 |
+
},
|
4557 |
+
|
4558 |
+
/**
|
4559 |
+
* Returns a string representation for specificity.
|
4560 |
+
* @return {String} The string representation of specificity.
|
4561 |
+
* @method toString
|
4562 |
+
*/
|
4563 |
+
toString: function(){
|
4564 |
+
return this.a + "," + this.b + "," + this.c + "," + this.d;
|
4565 |
+
}
|
4566 |
+
|
4567 |
+
};
|
4568 |
+
|
4569 |
+
/**
|
4570 |
+
* Calculates the specificity of the given selector.
|
4571 |
+
* @param {parserlib.css.Selector} The selector to calculate specificity for.
|
4572 |
+
* @return {parserlib.css.Specificity} The specificity of the selector.
|
4573 |
+
* @static
|
4574 |
+
* @method calculate
|
4575 |
+
*/
|
4576 |
+
Specificity.calculate = function(selector){
|
4577 |
+
|
4578 |
+
var i, len,
|
4579 |
+
part,
|
4580 |
+
b=0, c=0, d=0;
|
4581 |
+
|
4582 |
+
function updateValues(part){
|
4583 |
+
|
4584 |
+
var i, j, len, num,
|
4585 |
+
elementName = part.elementName ? part.elementName.text : "",
|
4586 |
+
modifier;
|
4587 |
+
|
4588 |
+
if (elementName && elementName.charAt(elementName.length-1) != "*") {
|
4589 |
+
d++;
|
4590 |
+
}
|
4591 |
+
|
4592 |
+
for (i=0, len=part.modifiers.length; i < len; i++){
|
4593 |
+
modifier = part.modifiers[i];
|
4594 |
+
switch(modifier.type){
|
4595 |
+
case "class":
|
4596 |
+
case "attribute":
|
4597 |
+
c++;
|
4598 |
+
break;
|
4599 |
+
|
4600 |
+
case "id":
|
4601 |
+
b++;
|
4602 |
+
break;
|
4603 |
+
|
4604 |
+
case "pseudo":
|
4605 |
+
if (Pseudos.isElement(modifier.text)){
|
4606 |
+
d++;
|
4607 |
+
} else {
|
4608 |
+
c++;
|
4609 |
+
}
|
4610 |
+
break;
|
4611 |
+
|
4612 |
+
case "not":
|
4613 |
+
for (j=0, num=modifier.args.length; j < num; j++){
|
4614 |
+
updateValues(modifier.args[j]);
|
4615 |
+
}
|
4616 |
+
}
|
4617 |
+
}
|
4618 |
+
}
|
4619 |
+
|
4620 |
+
for (i=0, len=selector.parts.length; i < len; i++){
|
4621 |
+
part = selector.parts[i];
|
4622 |
+
|
4623 |
+
if (part instanceof SelectorPart){
|
4624 |
+
updateValues(part);
|
4625 |
+
}
|
4626 |
+
}
|
4627 |
+
|
4628 |
+
return new Specificity(0, b, c, d);
|
4629 |
+
};
|
4630 |
+
|
4631 |
+
/*global Tokens, TokenStreamBase*/
|
4632 |
+
|
4633 |
+
var h = /^[0-9a-fA-F]$/,
|
4634 |
+
nonascii = /^[\u0080-\uFFFF]$/,
|
4635 |
+
nl = /\n|\r\n|\r|\f/;
|
4636 |
+
|
4637 |
+
//-----------------------------------------------------------------------------
|
4638 |
+
// Helper functions
|
4639 |
+
//-----------------------------------------------------------------------------
|
4640 |
+
|
4641 |
+
|
4642 |
+
function isHexDigit(c){
|
4643 |
+
return c !== null && h.test(c);
|
4644 |
+
}
|
4645 |
+
|
4646 |
+
function isDigit(c){
|
4647 |
+
return c !== null && /\d/.test(c);
|
4648 |
+
}
|
4649 |
+
|
4650 |
+
function isWhitespace(c){
|
4651 |
+
return c !== null && /\s/.test(c);
|
4652 |
+
}
|
4653 |
+
|
4654 |
+
function isNewLine(c){
|
4655 |
+
return c !== null && nl.test(c);
|
4656 |
+
}
|
4657 |
+
|
4658 |
+
function isNameStart(c){
|
4659 |
+
return c !== null && (/[a-z_\u0080-\uFFFF\\]/i.test(c));
|
4660 |
+
}
|
4661 |
+
|
4662 |
+
function isNameChar(c){
|
4663 |
+
return c !== null && (isNameStart(c) || /[0-9\-\\]/.test(c));
|
4664 |
+
}
|
4665 |
+
|
4666 |
+
function isIdentStart(c){
|
4667 |
+
return c !== null && (isNameStart(c) || /\-\\/.test(c));
|
4668 |
+
}
|
4669 |
+
|
4670 |
+
function mix(receiver, supplier){
|
4671 |
+
for (var prop in supplier){
|
4672 |
+
if (supplier.hasOwnProperty(prop)){
|
4673 |
+
receiver[prop] = supplier[prop];
|
4674 |
+
}
|
4675 |
+
}
|
4676 |
+
return receiver;
|
4677 |
+
}
|
4678 |
+
|
4679 |
+
//-----------------------------------------------------------------------------
|
4680 |
+
// CSS Token Stream
|
4681 |
+
//-----------------------------------------------------------------------------
|
4682 |
+
|
4683 |
+
|
4684 |
+
/**
|
4685 |
+
* A token stream that produces CSS tokens.
|
4686 |
+
* @param {String|Reader} input The source of text to tokenize.
|
4687 |
+
* @constructor
|
4688 |
+
* @class TokenStream
|
4689 |
+
* @namespace parserlib.css
|
4690 |
+
*/
|
4691 |
+
function TokenStream(input){
|
4692 |
+
TokenStreamBase.call(this, input, Tokens);
|
4693 |
+
}
|
4694 |
+
|
4695 |
+
TokenStream.prototype = mix(new TokenStreamBase(), {
|
4696 |
+
|
4697 |
+
/**
|
4698 |
+
* Overrides the TokenStreamBase method of the same name
|
4699 |
+
* to produce CSS tokens.
|
4700 |
+
* @param {variant} channel The name of the channel to use
|
4701 |
+
* for the next token.
|
4702 |
+
* @return {Object} A token object representing the next token.
|
4703 |
+
* @method _getToken
|
4704 |
+
* @private
|
4705 |
+
*/
|
4706 |
+
_getToken: function(channel){
|
4707 |
+
|
4708 |
+
var c,
|
4709 |
+
reader = this._reader,
|
4710 |
+
token = null,
|
4711 |
+
startLine = reader.getLine(),
|
4712 |
+
startCol = reader.getCol();
|
4713 |
+
|
4714 |
+
c = reader.read();
|
4715 |
+
|
4716 |
+
|
4717 |
+
while(c){
|
4718 |
+
switch(c){
|
4719 |
+
|
4720 |
+
/*
|
4721 |
+
* Potential tokens:
|
4722 |
+
* - COMMENT
|
4723 |
+
* - SLASH
|
4724 |
+
* - CHAR
|
4725 |
+
*/
|
4726 |
+
case "/":
|
4727 |
+
|
4728 |
+
if(reader.peek() == "*"){
|
4729 |
+
token = this.commentToken(c, startLine, startCol);
|
4730 |
+
} else {
|
4731 |
+
token = this.charToken(c, startLine, startCol);
|
4732 |
+
}
|
4733 |
+
break;
|
4734 |
+
|
4735 |
+
/*
|
4736 |
+
* Potential tokens:
|
4737 |
+
* - DASHMATCH
|
4738 |
+
* - INCLUDES
|
4739 |
+
* - PREFIXMATCH
|
4740 |
+
* - SUFFIXMATCH
|
4741 |
+
* - SUBSTRINGMATCH
|
4742 |
+
* - CHAR
|
4743 |
+
*/
|
4744 |
+
case "|":
|
4745 |
+
case "~":
|
4746 |
+
case "^":
|
4747 |
+
case "$":
|
4748 |
+
case "*":
|
4749 |
+
if(reader.peek() == "="){
|
4750 |
+
token = this.comparisonToken(c, startLine, startCol);
|
4751 |
+
} else {
|
4752 |
+
token = this.charToken(c, startLine, startCol);
|
4753 |
+
}
|
4754 |
+
break;
|
4755 |
+
|
4756 |
+
/*
|
4757 |
+
* Potential tokens:
|
4758 |
+
* - STRING
|
4759 |
+
* - INVALID
|
4760 |
+
*/
|
4761 |
+
case "\"":
|
4762 |
+
case "'":
|
4763 |
+
token = this.stringToken(c, startLine, startCol);
|
4764 |
+
break;
|
4765 |
+
|
4766 |
+
/*
|
4767 |
+
* Potential tokens:
|
4768 |
+
* - HASH
|
4769 |
+
* - CHAR
|
4770 |
+
*/
|
4771 |
+
case "#":
|
4772 |
+
if (isNameChar(reader.peek())){
|
4773 |
+
token = this.hashToken(c, startLine, startCol);
|
4774 |
+
} else {
|
4775 |
+
token = this.charToken(c, startLine, startCol);
|
4776 |
+
}
|
4777 |
+
break;
|
4778 |
+
|
4779 |
+
/*
|
4780 |
+
* Potential tokens:
|
4781 |
+
* - DOT
|
4782 |
+
* - NUMBER
|
4783 |
+
* - DIMENSION
|
4784 |
+
* - PERCENTAGE
|
4785 |
+
*/
|
4786 |
+
case ".":
|
4787 |
+
if (isDigit(reader.peek())){
|
4788 |
+
token = this.numberToken(c, startLine, startCol);
|
4789 |
+
} else {
|
4790 |
+
token = this.charToken(c, startLine, startCol);
|
4791 |
+
}
|
4792 |
+
break;
|
4793 |
+
|
4794 |
+
/*
|
4795 |
+
* Potential tokens:
|
4796 |
+
* - CDC
|
4797 |
+
* - MINUS
|
4798 |
+
* - NUMBER
|
4799 |
+
* - DIMENSION
|
4800 |
+
* - PERCENTAGE
|
4801 |
+
*/
|
4802 |
+
case "-":
|
4803 |
+
if (reader.peek() == "-"){ //could be closing HTML-style comment
|
4804 |
+
token = this.htmlCommentEndToken(c, startLine, startCol);
|
4805 |
+
} else if (isNameStart(reader.peek())){
|
4806 |
+
token = this.identOrFunctionToken(c, startLine, startCol);
|
4807 |
+
} else {
|
4808 |
+
token = this.charToken(c, startLine, startCol);
|
4809 |
+
}
|
4810 |
+
break;
|
4811 |
+
|
4812 |
+
/*
|
4813 |
+
* Potential tokens:
|
4814 |
+
* - IMPORTANT_SYM
|
4815 |
+
* - CHAR
|
4816 |
+
*/
|
4817 |
+
case "!":
|
4818 |
+
token = this.importantToken(c, startLine, startCol);
|
4819 |
+
break;
|
4820 |
+
|
4821 |
+
/*
|
4822 |
+
* Any at-keyword or CHAR
|
4823 |
+
*/
|
4824 |
+
case "@":
|
4825 |
+
token = this.atRuleToken(c, startLine, startCol);
|
4826 |
+
break;
|
4827 |
+
|
4828 |
+
/*
|
4829 |
+
* Potential tokens:
|
4830 |
+
* - NOT
|
4831 |
+
* - CHAR
|
4832 |
+
*/
|
4833 |
+
case ":":
|
4834 |
+
token = this.notToken(c, startLine, startCol);
|
4835 |
+
break;
|
4836 |
+
|
4837 |
+
/*
|
4838 |
+
* Potential tokens:
|
4839 |
+
* - CDO
|
4840 |
+
* - CHAR
|
4841 |
+
*/
|
4842 |
+
case "<":
|
4843 |
+
token = this.htmlCommentStartToken(c, startLine, startCol);
|
4844 |
+
break;
|
4845 |
+
|
4846 |
+
/*
|
4847 |
+
* Potential tokens:
|
4848 |
+
* - UNICODE_RANGE
|
4849 |
+
* - URL
|
4850 |
+
* - CHAR
|
4851 |
+
*/
|
4852 |
+
case "U":
|
4853 |
+
case "u":
|
4854 |
+
if (reader.peek() == "+"){
|
4855 |
+
token = this.unicodeRangeToken(c, startLine, startCol);
|
4856 |
+
break;
|
4857 |
+
}
|
4858 |
+
/* falls through */
|
4859 |
+
default:
|
4860 |
+
|
4861 |
+
/*
|
4862 |
+
* Potential tokens:
|
4863 |
+
* - NUMBER
|
4864 |
+
* - DIMENSION
|
4865 |
+
* - LENGTH
|
4866 |
+
* - FREQ
|
4867 |
+
* - TIME
|
4868 |
+
* - EMS
|
4869 |
+
* - EXS
|
4870 |
+
* - ANGLE
|
4871 |
+
*/
|
4872 |
+
if (isDigit(c)){
|
4873 |
+
token = this.numberToken(c, startLine, startCol);
|
4874 |
+
} else
|
4875 |
+
|
4876 |
+
/*
|
4877 |
+
* Potential tokens:
|
4878 |
+
* - S
|
4879 |
+
*/
|
4880 |
+
if (isWhitespace(c)){
|
4881 |
+
token = this.whitespaceToken(c, startLine, startCol);
|
4882 |
+
} else
|
4883 |
+
|
4884 |
+
/*
|
4885 |
+
* Potential tokens:
|
4886 |
+
* - IDENT
|
4887 |
+
*/
|
4888 |
+
if (isIdentStart(c)){
|
4889 |
+
token = this.identOrFunctionToken(c, startLine, startCol);
|
4890 |
+
} else
|
4891 |
+
|
4892 |
+
/*
|
4893 |
+
* Potential tokens:
|
4894 |
+
* - CHAR
|
4895 |
+
* - PLUS
|
4896 |
+
*/
|
4897 |
+
{
|
4898 |
+
token = this.charToken(c, startLine, startCol);
|
4899 |
+
}
|
4900 |
+
|
4901 |
+
|
4902 |
+
|
4903 |
+
|
4904 |
+
|
4905 |
+
|
4906 |
+
}
|
4907 |
+
|
4908 |
+
//make sure this token is wanted
|
4909 |
+
//TODO: check channel
|
4910 |
+
break;
|
4911 |
+
}
|
4912 |
+
|
4913 |
+
if (!token && c === null){
|
4914 |
+
token = this.createToken(Tokens.EOF,null,startLine,startCol);
|
4915 |
+
}
|
4916 |
+
|
4917 |
+
return token;
|
4918 |
+
},
|
4919 |
+
|
4920 |
+
//-------------------------------------------------------------------------
|
4921 |
+
// Methods to create tokens
|
4922 |
+
//-------------------------------------------------------------------------
|
4923 |
+
|
4924 |
+
/**
|
4925 |
+
* Produces a token based on available data and the current
|
4926 |
+
* reader position information. This method is called by other
|
4927 |
+
* private methods to create tokens and is never called directly.
|
4928 |
+
* @param {int} tt The token type.
|
4929 |
+
* @param {String} value The text value of the token.
|
4930 |
+
* @param {int} startLine The beginning line for the character.
|
4931 |
+
* @param {int} startCol The beginning column for the character.
|
4932 |
+
* @param {Object} options (Optional) Specifies a channel property
|
4933 |
+
* to indicate that a different channel should be scanned
|
4934 |
+
* and/or a hide property indicating that the token should
|
4935 |
+
* be hidden.
|
4936 |
+
* @return {Object} A token object.
|
4937 |
+
* @method createToken
|
4938 |
+
*/
|
4939 |
+
createToken: function(tt, value, startLine, startCol, options){
|
4940 |
+
var reader = this._reader;
|
4941 |
+
options = options || {};
|
4942 |
+
|
4943 |
+
return {
|
4944 |
+
value: value,
|
4945 |
+
type: tt,
|
4946 |
+
channel: options.channel,
|
4947 |
+
hide: options.hide || false,
|
4948 |
+
startLine: startLine,
|
4949 |
+
startCol: startCol,
|
4950 |
+
endLine: reader.getLine(),
|
4951 |
+
endCol: reader.getCol()
|
4952 |
+
};
|
4953 |
+
},
|
4954 |
+
|
4955 |
+
//-------------------------------------------------------------------------
|
4956 |
+
// Methods to create specific tokens
|
4957 |
+
//-------------------------------------------------------------------------
|
4958 |
+
|
4959 |
+
/**
|
4960 |
+
* Produces a token for any at-rule. If the at-rule is unknown, then
|
4961 |
+
* the token is for a single "@" character.
|
4962 |
+
* @param {String} first The first character for the token.
|
4963 |
+
* @param {int} startLine The beginning line for the character.
|
4964 |
+
* @param {int} startCol The beginning column for the character.
|
4965 |
+
* @return {Object} A token object.
|
4966 |
+
* @method atRuleToken
|
4967 |
+
*/
|
4968 |
+
atRuleToken: function(first, startLine, startCol){
|
4969 |
+
var rule = first,
|
4970 |
+
reader = this._reader,
|
4971 |
+
tt = Tokens.CHAR,
|
4972 |
+
valid = false,
|
4973 |
+
ident,
|
4974 |
+
c;
|
4975 |
+
|
4976 |
+
/*
|
4977 |
+
* First, mark where we are. There are only four @ rules,
|
4978 |
+
* so anything else is really just an invalid token.
|
4979 |
+
* Basically, if this doesn't match one of the known @
|
4980 |
+
* rules, just return '@' as an unknown token and allow
|
4981 |
+
* parsing to continue after that point.
|
4982 |
+
*/
|
4983 |
+
reader.mark();
|
4984 |
+
|
4985 |
+
//try to find the at-keyword
|
4986 |
+
ident = this.readName();
|
4987 |
+
rule = first + ident;
|
4988 |
+
tt = Tokens.type(rule.toLowerCase());
|
4989 |
+
|
4990 |
+
//if it's not valid, use the first character only and reset the reader
|
4991 |
+
if (tt == Tokens.CHAR || tt == Tokens.UNKNOWN){
|
4992 |
+
if (rule.length > 1){
|
4993 |
+
tt = Tokens.UNKNOWN_SYM;
|
4994 |
+
} else {
|
4995 |
+
tt = Tokens.CHAR;
|
4996 |
+
rule = first;
|
4997 |
+
reader.reset();
|
4998 |
+
}
|
4999 |
+
}
|
5000 |
+
|
5001 |
+
return this.createToken(tt, rule, startLine, startCol);
|
5002 |
+
},
|
5003 |
+
|
5004 |
+
/**
|
5005 |
+
* Produces a character token based on the given character
|
5006 |
+
* and location in the stream. If there's a special (non-standard)
|
5007 |
+
* token name, this is used; otherwise CHAR is used.
|
5008 |
+
* @param {String} c The character for the token.
|
5009 |
+
* @param {int} startLine The beginning line for the character.
|
5010 |
+
* @param {int} startCol The beginning column for the character.
|
5011 |
+
* @return {Object} A token object.
|
5012 |
+
* @method charToken
|
5013 |
+
*/
|
5014 |
+
charToken: function(c, startLine, startCol){
|
5015 |
+
var tt = Tokens.type(c);
|
5016 |
+
|
5017 |
+
if (tt == -1){
|
5018 |
+
tt = Tokens.CHAR;
|
5019 |
+
}
|
5020 |
+
|
5021 |
+
return this.createToken(tt, c, startLine, startCol);
|
5022 |
+
},
|
5023 |
+
|
5024 |
+
/**
|
5025 |
+
* Produces a character token based on the given character
|
5026 |
+
* and location in the stream. If there's a special (non-standard)
|
5027 |
+
* token name, this is used; otherwise CHAR is used.
|
5028 |
+
* @param {String} first The first character for the token.
|
5029 |
+
* @param {int} startLine The beginning line for the character.
|
5030 |
+
* @param {int} startCol The beginning column for the character.
|
5031 |
+
* @return {Object} A token object.
|
5032 |
+
* @method commentToken
|
5033 |
+
*/
|
5034 |
+
commentToken: function(first, startLine, startCol){
|
5035 |
+
var reader = this._reader,
|
5036 |
+
comment = this.readComment(first);
|
5037 |
+
|
5038 |
+
return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
|
5039 |
+
},
|
5040 |
+
|
5041 |
+
/**
|
5042 |
+
* Produces a comparison token based on the given character
|
5043 |
+
* and location in the stream. The next character must be
|
5044 |
+
* read and is already known to be an equals sign.
|
5045 |
+
* @param {String} c The character for the token.
|
5046 |
+
* @param {int} startLine The beginning line for the character.
|
5047 |
+
* @param {int} startCol The beginning column for the character.
|
5048 |
+
* @return {Object} A token object.
|
5049 |
+
* @method comparisonToken
|
5050 |
+
*/
|
5051 |
+
comparisonToken: function(c, startLine, startCol){
|
5052 |
+
var reader = this._reader,
|
5053 |
+
comparison = c + reader.read(),
|
5054 |
+
tt = Tokens.type(comparison) || Tokens.CHAR;
|
5055 |
+
|
5056 |
+
return this.createToken(tt, comparison, startLine, startCol);
|
5057 |
+
},
|
5058 |
+
|
5059 |
+
/**
|
5060 |
+
* Produces a hash token based on the specified information. The
|
5061 |
+
* first character provided is the pound sign (#) and then this
|
5062 |
+
* method reads a name afterward.
|
5063 |
+
* @param {String} first The first character (#) in the hash name.
|
5064 |
+
* @param {int} startLine The beginning line for the character.
|
5065 |
+
* @param {int} startCol The beginning column for the character.
|
5066 |
+
* @return {Object} A token object.
|
5067 |
+
* @method hashToken
|
5068 |
+
*/
|
5069 |
+
hashToken: function(first, startLine, startCol){
|
5070 |
+
var reader = this._reader,
|
5071 |
+
name = this.readName(first);
|
5072 |
+
|
5073 |
+
return this.createToken(Tokens.HASH, name, startLine, startCol);
|
5074 |
+
},
|
5075 |
+
|
5076 |
+
/**
|
5077 |
+
* Produces a CDO or CHAR token based on the specified information. The
|
5078 |
+
* first character is provided and the rest is read by the function to determine
|
5079 |
+
* the correct token to create.
|
5080 |
+
* @param {String} first The first character in the token.
|
5081 |
+
* @param {int} startLine The beginning line for the character.
|
5082 |
+
* @param {int} startCol The beginning column for the character.
|
5083 |
+
* @return {Object} A token object.
|
5084 |
+
* @method htmlCommentStartToken
|
5085 |
+
*/
|
5086 |
+
htmlCommentStartToken: function(first, startLine, startCol){
|
5087 |
+
var reader = this._reader,
|
5088 |
+
text = first;
|
5089 |
+
|
5090 |
+
reader.mark();
|
5091 |
+
text += reader.readCount(3);
|
5092 |
+
|
5093 |
+
if (text == "<!--"){
|
5094 |
+
return this.createToken(Tokens.CDO, text, startLine, startCol);
|
5095 |
+
} else {
|
5096 |
+
reader.reset();
|
5097 |
+
return this.charToken(first, startLine, startCol);
|
5098 |
+
}
|
5099 |
+
},
|
5100 |
+
|
5101 |
+
/**
|
5102 |
+
* Produces a CDC or CHAR token based on the specified information. The
|
5103 |
+
* first character is provided and the rest is read by the function to determine
|
5104 |
+
* the correct token to create.
|
5105 |
+
* @param {String} first The first character in the token.
|
5106 |
+
* @param {int} startLine The beginning line for the character.
|
5107 |
+
* @param {int} startCol The beginning column for the character.
|
5108 |
+
* @return {Object} A token object.
|
5109 |
+
* @method htmlCommentEndToken
|
5110 |
+
*/
|
5111 |
+
htmlCommentEndToken: function(first, startLine, startCol){
|
5112 |
+
var reader = this._reader,
|
5113 |
+
text = first;
|
5114 |
+
|
5115 |
+
reader.mark();
|
5116 |
+
text += reader.readCount(2);
|
5117 |
+
|
5118 |
+
if (text == "-->"){
|
5119 |
+
return this.createToken(Tokens.CDC, text, startLine, startCol);
|
5120 |
+
} else {
|
5121 |
+
reader.reset();
|
5122 |
+
return this.charToken(first, startLine, startCol);
|
5123 |
+
}
|
5124 |
+
},
|
5125 |
+
|
5126 |
+
/**
|
5127 |
+
* Produces an IDENT or FUNCTION token based on the specified information. The
|
5128 |
+
* first character is provided and the rest is read by the function to determine
|
5129 |
+
* the correct token to create.
|
5130 |
+
* @param {String} first The first character in the identifier.
|
5131 |
+
* @param {int} startLine The beginning line for the character.
|
5132 |
+
* @param {int} startCol The beginning column for the character.
|
5133 |
+
* @return {Object} A token object.
|
5134 |
+
* @method identOrFunctionToken
|
5135 |
+
*/
|
5136 |
+
identOrFunctionToken: function(first, startLine, startCol){
|
5137 |
+
var reader = this._reader,
|
5138 |
+
ident = this.readName(first),
|
5139 |
+
tt = Tokens.IDENT;
|
5140 |
+
|
5141 |
+
//if there's a left paren immediately after, it's a URI or function
|
5142 |
+
if (reader.peek() == "("){
|
5143 |
+
ident += reader.read();
|
5144 |
+
if (ident.toLowerCase() == "url("){
|
5145 |
+
tt = Tokens.URI;
|
5146 |
+
ident = this.readURI(ident);
|
5147 |
+
|
5148 |
+
//didn't find a valid URL or there's no closing paren
|
5149 |
+
if (ident.toLowerCase() == "url("){
|
5150 |
+
tt = Tokens.FUNCTION;
|
5151 |
+
}
|
5152 |
+
} else {
|
5153 |
+
tt = Tokens.FUNCTION;
|
5154 |
+
}
|
5155 |
+
} else if (reader.peek() == ":"){ //might be an IE function
|
5156 |
+
|
5157 |
+
//IE-specific functions always being with progid:
|
5158 |
+
if (ident.toLowerCase() == "progid"){
|
5159 |
+
ident += reader.readTo("(");
|
5160 |
+
tt = Tokens.IE_FUNCTION;
|
5161 |
+
}
|
5162 |
+
}
|
5163 |
+
|
5164 |
+
return this.createToken(tt, ident, startLine, startCol);
|
5165 |
+
},
|
5166 |
+
|
5167 |
+
/**
|
5168 |
+
* Produces an IMPORTANT_SYM or CHAR token based on the specified information. The
|
5169 |
+
* first character is provided and the rest is read by the function to determine
|
5170 |
+
* the correct token to create.
|
5171 |
+
* @param {String} first The first character in the token.
|
5172 |
+
* @param {int} startLine The beginning line for the character.
|
5173 |
+
* @param {int} startCol The beginning column for the character.
|
5174 |
+
* @return {Object} A token object.
|
5175 |
+
* @method importantToken
|
5176 |
+
*/
|
5177 |
+
importantToken: function(first, startLine, startCol){
|
5178 |
+
var reader = this._reader,
|
5179 |
+
important = first,
|
5180 |
+
tt = Tokens.CHAR,
|
5181 |
+
temp,
|
5182 |
+
c;
|
5183 |
+
|
5184 |
+
reader.mark();
|
5185 |
+
c = reader.read();
|
5186 |
+
|
5187 |
+
while(c){
|
5188 |
+
|
5189 |
+
//there can be a comment in here
|
5190 |
+
if (c == "/"){
|
5191 |
+
|
5192 |
+
//if the next character isn't a star, then this isn't a valid !important token
|
5193 |
+
if (reader.peek() != "*"){
|
5194 |
+
break;
|
5195 |
+
} else {
|
5196 |
+
temp = this.readComment(c);
|
5197 |
+
if (temp === ""){ //broken!
|
5198 |
+
break;
|
5199 |
+
}
|
5200 |
+
}
|
5201 |
+
} else if (isWhitespace(c)){
|
5202 |
+
important += c + this.readWhitespace();
|
5203 |
+
} else if (/i/i.test(c)){
|
5204 |
+
temp = reader.readCount(8);
|
5205 |
+
if (/mportant/i.test(temp)){
|
5206 |
+
important += c + temp;
|
5207 |
+
tt = Tokens.IMPORTANT_SYM;
|
5208 |
+
|
5209 |
+
}
|
5210 |
+
break; //we're done
|
5211 |
+
} else {
|
5212 |
+
break;
|
5213 |
+
}
|
5214 |
+
|
5215 |
+
c = reader.read();
|
5216 |
+
}
|
5217 |
+
|
5218 |
+
if (tt == Tokens.CHAR){
|
5219 |
+
reader.reset();
|
5220 |
+
return this.charToken(first, startLine, startCol);
|
5221 |
+
} else {
|
5222 |
+
return this.createToken(tt, important, startLine, startCol);
|
5223 |
+
}
|
5224 |
+
|
5225 |
+
|
5226 |
+
},
|
5227 |
+
|
5228 |
+
/**
|
5229 |
+
* Produces a NOT or CHAR token based on the specified information. The
|
5230 |
+
* first character is provided and the rest is read by the function to determine
|
5231 |
+
* the correct token to create.
|
5232 |
+
* @param {String} first The first character in the token.
|
5233 |
+
* @param {int} startLine The beginning line for the character.
|
5234 |
+
* @param {int} startCol The beginning column for the character.
|
5235 |
+
* @return {Object} A token object.
|
5236 |
+
* @method notToken
|
5237 |
+
*/
|
5238 |
+
notToken: function(first, startLine, startCol){
|
5239 |
+
var reader = this._reader,
|
5240 |
+
text = first;
|
5241 |
+
|
5242 |
+
reader.mark();
|
5243 |
+
text += reader.readCount(4);
|
5244 |
+
|
5245 |
+
if (text.toLowerCase() == ":not("){
|
5246 |
+
return this.createToken(Tokens.NOT, text, startLine, startCol);
|
5247 |
+
} else {
|
5248 |
+
reader.reset();
|
5249 |
+
return this.charToken(first, startLine, startCol);
|
5250 |
+
}
|
5251 |
+
},
|
5252 |
+
|
5253 |
+
/**
|
5254 |
+
* Produces a number token based on the given character
|
5255 |
+
* and location in the stream. This may return a token of
|
5256 |
+
* NUMBER, EMS, EXS, LENGTH, ANGLE, TIME, FREQ, DIMENSION,
|
5257 |
+
* or PERCENTAGE.
|
5258 |
+
* @param {String} first The first character for the token.
|
5259 |
+
* @param {int} startLine The beginning line for the character.
|
5260 |
+
* @param {int} startCol The beginning column for the character.
|
5261 |
+
* @return {Object} A token object.
|
5262 |
+
* @method numberToken
|
5263 |
+
*/
|
5264 |
+
numberToken: function(first, startLine, startCol){
|
5265 |
+
var reader = this._reader,
|
5266 |
+
value = this.readNumber(first),
|
5267 |
+
ident,
|
5268 |
+
tt = Tokens.NUMBER,
|
5269 |
+
c = reader.peek();
|
5270 |
+
|
5271 |
+
if (isIdentStart(c)){
|
5272 |
+
ident = this.readName(reader.read());
|
5273 |
+
value += ident;
|
5274 |
+
|
5275 |
+
if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vm$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)){
|
5276 |
+
tt = Tokens.LENGTH;
|
5277 |
+
} else if (/^deg|^rad$|^grad$/i.test(ident)){
|
5278 |
+
tt = Tokens.ANGLE;
|
5279 |
+
} else if (/^ms$|^s$/i.test(ident)){
|
5280 |
+
tt = Tokens.TIME;
|
5281 |
+
} else if (/^hz$|^khz$/i.test(ident)){
|
5282 |
+
tt = Tokens.FREQ;
|
5283 |
+
} else if (/^dpi$|^dpcm$/i.test(ident)){
|
5284 |
+
tt = Tokens.RESOLUTION;
|
5285 |
+
} else {
|
5286 |
+
tt = Tokens.DIMENSION;
|
5287 |
+
}
|
5288 |
+
|
5289 |
+
} else if (c == "%"){
|
5290 |
+
value += reader.read();
|
5291 |
+
tt = Tokens.PERCENTAGE;
|
5292 |
+
}
|
5293 |
+
|
5294 |
+
return this.createToken(tt, value, startLine, startCol);
|
5295 |
+
},
|
5296 |
+
|
5297 |
+
/**
|
5298 |
+
* Produces a string token based on the given character
|
5299 |
+
* and location in the stream. Since strings may be indicated
|
5300 |
+
* by single or double quotes, a failure to match starting
|
5301 |
+
* and ending quotes results in an INVALID token being generated.
|
5302 |
+
* The first character in the string is passed in and then
|
5303 |
+
* the rest are read up to and including the final quotation mark.
|
5304 |
+
* @param {String} first The first character in the string.
|
5305 |
+
* @param {int} startLine The beginning line for the character.
|
5306 |
+
* @param {int} startCol The beginning column for the character.
|
5307 |
+
* @return {Object} A token object.
|
5308 |
+
* @method stringToken
|
5309 |
+
*/
|
5310 |
+
stringToken: function(first, startLine, startCol){
|
5311 |
+
var delim = first,
|
5312 |
+
string = first,
|
5313 |
+
reader = this._reader,
|
5314 |
+
prev = first,
|
5315 |
+
tt = Tokens.STRING,
|
5316 |
+
c = reader.read();
|
5317 |
+
|
5318 |
+
while(c){
|
5319 |
+
string += c;
|
5320 |
+
|
5321 |
+
//if the delimiter is found with an escapement, we're done.
|
5322 |
+
if (c == delim && prev != "\\"){
|
5323 |
+
break;
|
5324 |
+
}
|
5325 |
+
|
5326 |
+
//if there's a newline without an escapement, it's an invalid string
|
5327 |
+
if (isNewLine(reader.peek()) && c != "\\"){
|
5328 |
+
tt = Tokens.INVALID;
|
5329 |
+
break;
|
5330 |
+
}
|
5331 |
+
|
5332 |
+
//save previous and get next
|
5333 |
+
prev = c;
|
5334 |
+
c = reader.read();
|
5335 |
+
}
|
5336 |
+
|
5337 |
+
//if c is null, that means we're out of input and the string was never closed
|
5338 |
+
if (c === null){
|
5339 |
+
tt = Tokens.INVALID;
|
5340 |
+
}
|
5341 |
+
|
5342 |
+
return this.createToken(tt, string, startLine, startCol);
|
5343 |
+
},
|
5344 |
+
|
5345 |
+
unicodeRangeToken: function(first, startLine, startCol){
|
5346 |
+
var reader = this._reader,
|
5347 |
+
value = first,
|
5348 |
+
temp,
|
5349 |
+
tt = Tokens.CHAR;
|
5350 |
+
|
5351 |
+
//then it should be a unicode range
|
5352 |
+
if (reader.peek() == "+"){
|
5353 |
+
reader.mark();
|
5354 |
+
value += reader.read();
|
5355 |
+
value += this.readUnicodeRangePart(true);
|
5356 |
+
|
5357 |
+
//ensure there's an actual unicode range here
|
5358 |
+
if (value.length == 2){
|
5359 |
+
reader.reset();
|
5360 |
+
} else {
|
5361 |
+
|
5362 |
+
tt = Tokens.UNICODE_RANGE;
|
5363 |
+
|
5364 |
+
//if there's a ? in the first part, there can't be a second part
|
5365 |
+
if (value.indexOf("?") == -1){
|
5366 |
+
|
5367 |
+
if (reader.peek() == "-"){
|
5368 |
+
reader.mark();
|
5369 |
+
temp = reader.read();
|
5370 |
+
temp += this.readUnicodeRangePart(false);
|
5371 |
+
|
5372 |
+
//if there's not another value, back up and just take the first
|
5373 |
+
if (temp.length == 1){
|
5374 |
+
reader.reset();
|
5375 |
+
} else {
|
5376 |
+
value += temp;
|
5377 |
+
}
|
5378 |
+
}
|
5379 |
+
|
5380 |
+
}
|
5381 |
+
}
|
5382 |
+
}
|
5383 |
+
|
5384 |
+
return this.createToken(tt, value, startLine, startCol);
|
5385 |
+
},
|
5386 |
+
|
5387 |
+
/**
|
5388 |
+
* Produces a S token based on the specified information. Since whitespace
|
5389 |
+
* may have multiple characters, this consumes all whitespace characters
|
5390 |
+
* into a single token.
|
5391 |
+
* @param {String} first The first character in the token.
|
5392 |
+
* @param {int} startLine The beginning line for the character.
|
5393 |
+
* @param {int} startCol The beginning column for the character.
|
5394 |
+
* @return {Object} A token object.
|
5395 |
+
* @method whitespaceToken
|
5396 |
+
*/
|
5397 |
+
whitespaceToken: function(first, startLine, startCol){
|
5398 |
+
var reader = this._reader,
|
5399 |
+
value = first + this.readWhitespace();
|
5400 |
+
return this.createToken(Tokens.S, value, startLine, startCol);
|
5401 |
+
},
|
5402 |
+
|
5403 |
+
|
5404 |
+
|
5405 |
+
|
5406 |
+
//-------------------------------------------------------------------------
|
5407 |
+
// Methods to read values from the string stream
|
5408 |
+
//-------------------------------------------------------------------------
|
5409 |
+
|
5410 |
+
readUnicodeRangePart: function(allowQuestionMark){
|
5411 |
+
var reader = this._reader,
|
5412 |
+
part = "",
|
5413 |
+
c = reader.peek();
|
5414 |
+
|
5415 |
+
//first read hex digits
|
5416 |
+
while(isHexDigit(c) && part.length < 6){
|
5417 |
+
reader.read();
|
5418 |
+
part += c;
|
5419 |
+
c = reader.peek();
|
5420 |
+
}
|
5421 |
+
|
5422 |
+
//then read question marks if allowed
|
5423 |
+
if (allowQuestionMark){
|
5424 |
+
while(c == "?" && part.length < 6){
|
5425 |
+
reader.read();
|
5426 |
+
part += c;
|
5427 |
+
c = reader.peek();
|
5428 |
+
}
|
5429 |
+
}
|
5430 |
+
|
5431 |
+
//there can't be any other characters after this point
|
5432 |
+
|
5433 |
+
return part;
|
5434 |
+
},
|
5435 |
+
|
5436 |
+
readWhitespace: function(){
|
5437 |
+
var reader = this._reader,
|
5438 |
+
whitespace = "",
|
5439 |
+
c = reader.peek();
|
5440 |
+
|
5441 |
+
while(isWhitespace(c)){
|
5442 |
+
reader.read();
|
5443 |
+
whitespace += c;
|
5444 |
+
c = reader.peek();
|
5445 |
+
}
|
5446 |
+
|
5447 |
+
return whitespace;
|
5448 |
+
},
|
5449 |
+
readNumber: function(first){
|
5450 |
+
var reader = this._reader,
|
5451 |
+
number = first,
|
5452 |
+
hasDot = (first == "."),
|
5453 |
+
c = reader.peek();
|
5454 |
+
|
5455 |
+
|
5456 |
+
while(c){
|
5457 |
+
if (isDigit(c)){
|
5458 |
+
number += reader.read();
|
5459 |
+
} else if (c == "."){
|
5460 |
+
if (hasDot){
|
5461 |
+
break;
|
5462 |
+
} else {
|
5463 |
+
hasDot = true;
|
5464 |
+
number += reader.read();
|
5465 |
+
}
|
5466 |
+
} else {
|
5467 |
+
break;
|
5468 |
+
}
|
5469 |
+
|
5470 |
+
c = reader.peek();
|
5471 |
+
}
|
5472 |
+
|
5473 |
+
return number;
|
5474 |
+
},
|
5475 |
+
readString: function(){
|
5476 |
+
var reader = this._reader,
|
5477 |
+
delim = reader.read(),
|
5478 |
+
string = delim,
|
5479 |
+
prev = delim,
|
5480 |
+
c = reader.peek();
|
5481 |
+
|
5482 |
+
while(c){
|
5483 |
+
c = reader.read();
|
5484 |
+
string += c;
|
5485 |
+
|
5486 |
+
//if the delimiter is found with an escapement, we're done.
|
5487 |
+
if (c == delim && prev != "\\"){
|
5488 |
+
break;
|
5489 |
+
}
|
5490 |
+
|
5491 |
+
//if there's a newline without an escapement, it's an invalid string
|
5492 |
+
if (isNewLine(reader.peek()) && c != "\\"){
|
5493 |
+
string = "";
|
5494 |
+
break;
|
5495 |
+
}
|
5496 |
+
|
5497 |
+
//save previous and get next
|
5498 |
+
prev = c;
|
5499 |
+
c = reader.peek();
|
5500 |
+
}
|
5501 |
+
|
5502 |
+
//if c is null, that means we're out of input and the string was never closed
|
5503 |
+
if (c === null){
|
5504 |
+
string = "";
|
5505 |
+
}
|
5506 |
+
|
5507 |
+
return string;
|
5508 |
+
},
|
5509 |
+
readURI: function(first){
|
5510 |
+
var reader = this._reader,
|
5511 |
+
uri = first,
|
5512 |
+
inner = "",
|
5513 |
+
c = reader.peek();
|
5514 |
+
|
5515 |
+
reader.mark();
|
5516 |
+
|
5517 |
+
//skip whitespace before
|
5518 |
+
while(c && isWhitespace(c)){
|
5519 |
+
reader.read();
|
5520 |
+
c = reader.peek();
|
5521 |
+
}
|
5522 |
+
|
5523 |
+
//it's a string
|
5524 |
+
if (c == "'" || c == "\""){
|
5525 |
+
inner = this.readString();
|
5526 |
+
} else {
|
5527 |
+
inner = this.readURL();
|
5528 |
+
}
|
5529 |
+
|
5530 |
+
c = reader.peek();
|
5531 |
+
|
5532 |
+
//skip whitespace after
|
5533 |
+
while(c && isWhitespace(c)){
|
5534 |
+
reader.read();
|
5535 |
+
c = reader.peek();
|
5536 |
+
}
|
5537 |
+
|
5538 |
+
//if there was no inner value or the next character isn't closing paren, it's not a URI
|
5539 |
+
if (inner === "" || c != ")"){
|
5540 |
+
uri = first;
|
5541 |
+
reader.reset();
|
5542 |
+
} else {
|
5543 |
+
uri += inner + reader.read();
|
5544 |
+
}
|
5545 |
+
|
5546 |
+
return uri;
|
5547 |
+
},
|
5548 |
+
readURL: function(){
|
5549 |
+
var reader = this._reader,
|
5550 |
+
url = "",
|
5551 |
+
c = reader.peek();
|
5552 |
+
|
5553 |
+
//TODO: Check for escape and nonascii
|
5554 |
+
while (/^[!#$%&\\*-~]$/.test(c)){
|
5555 |
+
url += reader.read();
|
5556 |
+
c = reader.peek();
|
5557 |
+
}
|
5558 |
+
|
5559 |
+
return url;
|
5560 |
+
|
5561 |
+
},
|
5562 |
+
readName: function(first){
|
5563 |
+
var reader = this._reader,
|
5564 |
+
ident = first || "",
|
5565 |
+
c = reader.peek();
|
5566 |
+
|
5567 |
+
while(true){
|
5568 |
+
if (c == "\\"){
|
5569 |
+
ident += this.readEscape(reader.read());
|
5570 |
+
c = reader.peek();
|
5571 |
+
} else if(c && isNameChar(c)){
|
5572 |
+
ident += reader.read();
|
5573 |
+
c = reader.peek();
|
5574 |
+
} else {
|
5575 |
+
break;
|
5576 |
+
}
|
5577 |
+
}
|
5578 |
+
|
5579 |
+
return ident;
|
5580 |
+
},
|
5581 |
+
|
5582 |
+
readEscape: function(first){
|
5583 |
+
var reader = this._reader,
|
5584 |
+
cssEscape = first || "",
|
5585 |
+
i = 0,
|
5586 |
+
c = reader.peek();
|
5587 |
+
|
5588 |
+
if (isHexDigit(c)){
|
5589 |
+
do {
|
5590 |
+
cssEscape += reader.read();
|
5591 |
+
c = reader.peek();
|
5592 |
+
} while(c && isHexDigit(c) && ++i < 6);
|
5593 |
+
}
|
5594 |
+
|
5595 |
+
if (cssEscape.length == 3 && /\s/.test(c) ||
|
5596 |
+
cssEscape.length == 7 || cssEscape.length == 1){
|
5597 |
+
reader.read();
|
5598 |
+
} else {
|
5599 |
+
c = "";
|
5600 |
+
}
|
5601 |
+
|
5602 |
+
return cssEscape + c;
|
5603 |
+
},
|
5604 |
+
|
5605 |
+
readComment: function(first){
|
5606 |
+
var reader = this._reader,
|
5607 |
+
comment = first || "",
|
5608 |
+
c = reader.read();
|
5609 |
+
|
5610 |
+
if (c == "*"){
|
5611 |
+
while(c){
|
5612 |
+
comment += c;
|
5613 |
+
|
5614 |
+
//look for end of comment
|
5615 |
+
if (comment.length > 2 && c == "*" && reader.peek() == "/"){
|
5616 |
+
comment += reader.read();
|
5617 |
+
break;
|
5618 |
+
}
|
5619 |
+
|
5620 |
+
c = reader.read();
|
5621 |
+
}
|
5622 |
+
|
5623 |
+
return comment;
|
5624 |
+
} else {
|
5625 |
+
return "";
|
5626 |
+
}
|
5627 |
+
|
5628 |
+
}
|
5629 |
+
});
|
5630 |
+
|
5631 |
+
|
5632 |
+
var Tokens = [
|
5633 |
+
|
5634 |
+
/*
|
5635 |
+
* The following token names are defined in CSS3 Grammar: http://www.w3.org/TR/css3-syntax/#lexical
|
5636 |
+
*/
|
5637 |
+
|
5638 |
+
//HTML-style comments
|
5639 |
+
{ name: "CDO"},
|
5640 |
+
{ name: "CDC"},
|
5641 |
+
|
5642 |
+
//ignorables
|
5643 |
+
{ name: "S", whitespace: true/*, channel: "ws"*/},
|
5644 |
+
{ name: "COMMENT", comment: true, hide: true, channel: "comment" },
|
5645 |
+
|
5646 |
+
//attribute equality
|
5647 |
+
{ name: "INCLUDES", text: "~="},
|
5648 |
+
{ name: "DASHMATCH", text: "|="},
|
5649 |
+
{ name: "PREFIXMATCH", text: "^="},
|
5650 |
+
{ name: "SUFFIXMATCH", text: "$="},
|
5651 |
+
{ name: "SUBSTRINGMATCH", text: "*="},
|
5652 |
+
|
5653 |
+
//identifier types
|
5654 |
+
{ name: "STRING"},
|
5655 |
+
{ name: "IDENT"},
|
5656 |
+
{ name: "HASH"},
|
5657 |
+
|
5658 |
+
//at-keywords
|
5659 |
+
{ name: "IMPORT_SYM", text: "@import"},
|
5660 |
+
{ name: "PAGE_SYM", text: "@page"},
|
5661 |
+
{ name: "MEDIA_SYM", text: "@media"},
|
5662 |
+
{ name: "FONT_FACE_SYM", text: "@font-face"},
|
5663 |
+
{ name: "CHARSET_SYM", text: "@charset"},
|
5664 |
+
{ name: "NAMESPACE_SYM", text: "@namespace"},
|
5665 |
+
{ name: "VIEWPORT_SYM", text: "@viewport"},
|
5666 |
+
{ name: "UNKNOWN_SYM" },
|
5667 |
+
//{ name: "ATKEYWORD"},
|
5668 |
+
|
5669 |
+
//CSS3 animations
|
5670 |
+
{ name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
|
5671 |
+
|
5672 |
+
//important symbol
|
5673 |
+
{ name: "IMPORTANT_SYM"},
|
5674 |
+
|
5675 |
+
//measurements
|
5676 |
+
{ name: "LENGTH"},
|
5677 |
+
{ name: "ANGLE"},
|
5678 |
+
{ name: "TIME"},
|
5679 |
+
{ name: "FREQ"},
|
5680 |
+
{ name: "DIMENSION"},
|
5681 |
+
{ name: "PERCENTAGE"},
|
5682 |
+
{ name: "NUMBER"},
|
5683 |
+
|
5684 |
+
//functions
|
5685 |
+
{ name: "URI"},
|
5686 |
+
{ name: "FUNCTION"},
|
5687 |
+
|
5688 |
+
//Unicode ranges
|
5689 |
+
{ name: "UNICODE_RANGE"},
|
5690 |
+
|
5691 |
+
/*
|
5692 |
+
* The following token names are defined in CSS3 Selectors: http://www.w3.org/TR/css3-selectors/#selector-syntax
|
5693 |
+
*/
|
5694 |
+
|
5695 |
+
//invalid string
|
5696 |
+
{ name: "INVALID"},
|
5697 |
+
|
5698 |
+
//combinators
|
5699 |
+
{ name: "PLUS", text: "+" },
|
5700 |
+
{ name: "GREATER", text: ">"},
|
5701 |
+
{ name: "COMMA", text: ","},
|
5702 |
+
{ name: "TILDE", text: "~"},
|
5703 |
+
|
5704 |
+
//modifier
|
5705 |
+
{ name: "NOT"},
|
5706 |
+
|
5707 |
+
/*
|
5708 |
+
* Defined in CSS3 Paged Media
|
5709 |
+
*/
|
5710 |
+
{ name: "TOPLEFTCORNER_SYM", text: "@top-left-corner"},
|
5711 |
+
{ name: "TOPLEFT_SYM", text: "@top-left"},
|
5712 |
+
{ name: "TOPCENTER_SYM", text: "@top-center"},
|
5713 |
+
{ name: "TOPRIGHT_SYM", text: "@top-right"},
|
5714 |
+
{ name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner"},
|
5715 |
+
{ name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner"},
|
5716 |
+
{ name: "BOTTOMLEFT_SYM", text: "@bottom-left"},
|
5717 |
+
{ name: "BOTTOMCENTER_SYM", text: "@bottom-center"},
|
5718 |
+
{ name: "BOTTOMRIGHT_SYM", text: "@bottom-right"},
|
5719 |
+
{ name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner"},
|
5720 |
+
{ name: "LEFTTOP_SYM", text: "@left-top"},
|
5721 |
+
{ name: "LEFTMIDDLE_SYM", text: "@left-middle"},
|
5722 |
+
{ name: "LEFTBOTTOM_SYM", text: "@left-bottom"},
|
5723 |
+
{ name: "RIGHTTOP_SYM", text: "@right-top"},
|
5724 |
+
{ name: "RIGHTMIDDLE_SYM", text: "@right-middle"},
|
5725 |
+
{ name: "RIGHTBOTTOM_SYM", text: "@right-bottom"},
|
5726 |
+
|
5727 |
+
/*
|
5728 |
+
* The following token names are defined in CSS3 Media Queries: http://www.w3.org/TR/css3-mediaqueries/#syntax
|
5729 |
+
*/
|
5730 |
+
/*{ name: "MEDIA_ONLY", state: "media"},
|
5731 |
+
{ name: "MEDIA_NOT", state: "media"},
|
5732 |
+
{ name: "MEDIA_AND", state: "media"},*/
|
5733 |
+
{ name: "RESOLUTION", state: "media"},
|
5734 |
+
|
5735 |
+
/*
|
5736 |
+
* The following token names are not defined in any CSS specification but are used by the lexer.
|
5737 |
+
*/
|
5738 |
+
|
5739 |
+
//not a real token, but useful for stupid IE filters
|
5740 |
+
{ name: "IE_FUNCTION" },
|
5741 |
+
|
5742 |
+
//part of CSS3 grammar but not the Flex code
|
5743 |
+
{ name: "CHAR" },
|
5744 |
+
|
5745 |
+
//TODO: Needed?
|
5746 |
+
//Not defined as tokens, but might as well be
|
5747 |
+
{
|
5748 |
+
name: "PIPE",
|
5749 |
+
text: "|"
|
5750 |
+
},
|
5751 |
+
{
|
5752 |
+
name: "SLASH",
|
5753 |
+
text: "/"
|
5754 |
+
},
|
5755 |
+
{
|
5756 |
+
name: "MINUS",
|
5757 |
+
text: "-"
|
5758 |
+
},
|
5759 |
+
{
|
5760 |
+
name: "STAR",
|
5761 |
+
text: "*"
|
5762 |
+
},
|
5763 |
+
|
5764 |
+
{
|
5765 |
+
name: "LBRACE",
|
5766 |
+
text: "{"
|
5767 |
+
},
|
5768 |
+
{
|
5769 |
+
name: "RBRACE",
|
5770 |
+
text: "}"
|
5771 |
+
},
|
5772 |
+
{
|
5773 |
+
name: "LBRACKET",
|
5774 |
+
text: "["
|
5775 |
+
},
|
5776 |
+
{
|
5777 |
+
name: "RBRACKET",
|
5778 |
+
text: "]"
|
5779 |
+
},
|
5780 |
+
{
|
5781 |
+
name: "EQUALS",
|
5782 |
+
text: "="
|
5783 |
+
},
|
5784 |
+
{
|
5785 |
+
name: "COLON",
|
5786 |
+
text: ":"
|
5787 |
+
},
|
5788 |
+
{
|
5789 |
+
name: "SEMICOLON",
|
5790 |
+
text: ";"
|
5791 |
+
},
|
5792 |
+
|
5793 |
+
{
|
5794 |
+
name: "LPAREN",
|
5795 |
+
text: "("
|
5796 |
+
},
|
5797 |
+
{
|
5798 |
+
name: "RPAREN",
|
5799 |
+
text: ")"
|
5800 |
+
},
|
5801 |
+
{
|
5802 |
+
name: "DOT",
|
5803 |
+
text: "."
|
5804 |
+
}
|
5805 |
+
];
|
5806 |
+
|
5807 |
+
(function(){
|
5808 |
+
|
5809 |
+
var nameMap = [],
|
5810 |
+
typeMap = {};
|
5811 |
+
|
5812 |
+
Tokens.UNKNOWN = -1;
|
5813 |
+
Tokens.unshift({name:"EOF"});
|
5814 |
+
for (var i=0, len = Tokens.length; i < len; i++){
|
5815 |
+
nameMap.push(Tokens[i].name);
|
5816 |
+
Tokens[Tokens[i].name] = i;
|
5817 |
+
if (Tokens[i].text){
|
5818 |
+
if (Tokens[i].text instanceof Array){
|
5819 |
+
for (var j=0; j < Tokens[i].text.length; j++){
|
5820 |
+
typeMap[Tokens[i].text[j]] = i;
|
5821 |
+
}
|
5822 |
+
} else {
|
5823 |
+
typeMap[Tokens[i].text] = i;
|
5824 |
+
}
|
5825 |
+
}
|
5826 |
+
}
|
5827 |
+
|
5828 |
+
Tokens.name = function(tt){
|
5829 |
+
return nameMap[tt];
|
5830 |
+
};
|
5831 |
+
|
5832 |
+
Tokens.type = function(c){
|
5833 |
+
return typeMap[c] || -1;
|
5834 |
+
};
|
5835 |
+
|
5836 |
+
})();
|
5837 |
+
|
5838 |
+
|
5839 |
+
|
5840 |
+
|
5841 |
+
//This file will likely change a lot! Very experimental!
|
5842 |
+
/*global Properties, ValidationTypes, ValidationError, PropertyValueIterator */
|
5843 |
+
var Validation = {
|
5844 |
+
|
5845 |
+
validate: function(property, value){
|
5846 |
+
|
5847 |
+
//normalize name
|
5848 |
+
var name = property.toString().toLowerCase(),
|
5849 |
+
parts = value.parts,
|
5850 |
+
expression = new PropertyValueIterator(value),
|
5851 |
+
spec = Properties[name],
|
5852 |
+
part,
|
5853 |
+
valid,
|
5854 |
+
j, count,
|
5855 |
+
msg,
|
5856 |
+
types,
|
5857 |
+
last,
|
5858 |
+
literals,
|
5859 |
+
max, multi, group;
|
5860 |
+
|
5861 |
+
if (!spec) {
|
5862 |
+
if (name.indexOf("-") !== 0){ //vendor prefixed are ok
|
5863 |
+
throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
|
5864 |
+
}
|
5865 |
+
} else if (typeof spec != "number"){
|
5866 |
+
|
5867 |
+
//initialization
|
5868 |
+
if (typeof spec == "string"){
|
5869 |
+
if (spec.indexOf("||") > -1) {
|
5870 |
+
this.groupProperty(spec, expression);
|
5871 |
+
} else {
|
5872 |
+
this.singleProperty(spec, expression, 1);
|
5873 |
+
}
|
5874 |
+
|
5875 |
+
} else if (spec.multi) {
|
5876 |
+
this.multiProperty(spec.multi, expression, spec.comma, spec.max || Infinity);
|
5877 |
+
} else if (typeof spec == "function") {
|
5878 |
+
spec(expression);
|
5879 |
+
}
|
5880 |
+
|
5881 |
+
}
|
5882 |
+
|
5883 |
+
},
|
5884 |
+
|
5885 |
+
singleProperty: function(types, expression, max, partial) {
|
5886 |
+
|
5887 |
+
var result = false,
|
5888 |
+
value = expression.value,
|
5889 |
+
count = 0,
|
5890 |
+
part;
|
5891 |
+
|
5892 |
+
while (expression.hasNext() && count < max) {
|
5893 |
+
result = ValidationTypes.isAny(expression, types);
|
5894 |
+
if (!result) {
|
5895 |
+
break;
|
5896 |
+
}
|
5897 |
+
count++;
|
5898 |
+
}
|
5899 |
+
|
5900 |
+
if (!result) {
|
5901 |
+
if (expression.hasNext() && !expression.isFirst()) {
|
5902 |
+
part = expression.peek();
|
5903 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
5904 |
+
} else {
|
5905 |
+
throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
|
5906 |
+
}
|
5907 |
+
} else if (expression.hasNext()) {
|
5908 |
+
part = expression.next();
|
5909 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
5910 |
+
}
|
5911 |
+
|
5912 |
+
},
|
5913 |
+
|
5914 |
+
multiProperty: function (types, expression, comma, max) {
|
5915 |
+
|
5916 |
+
var result = false,
|
5917 |
+
value = expression.value,
|
5918 |
+
count = 0,
|
5919 |
+
sep = false,
|
5920 |
+
part;
|
5921 |
+
|
5922 |
+
while(expression.hasNext() && !result && count < max) {
|
5923 |
+
if (ValidationTypes.isAny(expression, types)) {
|
5924 |
+
count++;
|
5925 |
+
if (!expression.hasNext()) {
|
5926 |
+
result = true;
|
5927 |
+
|
5928 |
+
} else if (comma) {
|
5929 |
+
if (expression.peek() == ",") {
|
5930 |
+
part = expression.next();
|
5931 |
+
} else {
|
5932 |
+
break;
|
5933 |
+
}
|
5934 |
+
}
|
5935 |
+
} else {
|
5936 |
+
break;
|
5937 |
+
|
5938 |
+
}
|
5939 |
+
}
|
5940 |
+
|
5941 |
+
if (!result) {
|
5942 |
+
if (expression.hasNext() && !expression.isFirst()) {
|
5943 |
+
part = expression.peek();
|
5944 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
5945 |
+
} else {
|
5946 |
+
part = expression.previous();
|
5947 |
+
if (comma && part == ",") {
|
5948 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
5949 |
+
} else {
|
5950 |
+
throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
|
5951 |
+
}
|
5952 |
+
}
|
5953 |
+
|
5954 |
+
} else if (expression.hasNext()) {
|
5955 |
+
part = expression.next();
|
5956 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
5957 |
+
}
|
5958 |
+
|
5959 |
+
},
|
5960 |
+
|
5961 |
+
groupProperty: function (types, expression, comma) {
|
5962 |
+
|
5963 |
+
var result = false,
|
5964 |
+
value = expression.value,
|
5965 |
+
typeCount = types.split("||").length,
|
5966 |
+
groups = { count: 0 },
|
5967 |
+
partial = false,
|
5968 |
+
name,
|
5969 |
+
part;
|
5970 |
+
|
5971 |
+
while(expression.hasNext() && !result) {
|
5972 |
+
name = ValidationTypes.isAnyOfGroup(expression, types);
|
5973 |
+
if (name) {
|
5974 |
+
|
5975 |
+
//no dupes
|
5976 |
+
if (groups[name]) {
|
5977 |
+
break;
|
5978 |
+
} else {
|
5979 |
+
groups[name] = 1;
|
5980 |
+
groups.count++;
|
5981 |
+
partial = true;
|
5982 |
+
|
5983 |
+
if (groups.count == typeCount || !expression.hasNext()) {
|
5984 |
+
result = true;
|
5985 |
+
}
|
5986 |
+
}
|
5987 |
+
} else {
|
5988 |
+
break;
|
5989 |
+
}
|
5990 |
+
}
|
5991 |
+
|
5992 |
+
if (!result) {
|
5993 |
+
if (partial && expression.hasNext()) {
|
5994 |
+
part = expression.peek();
|
5995 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
5996 |
+
} else {
|
5997 |
+
throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
|
5998 |
+
}
|
5999 |
+
} else if (expression.hasNext()) {
|
6000 |
+
part = expression.next();
|
6001 |
+
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
|
6002 |
+
}
|
6003 |
+
}
|
6004 |
+
|
6005 |
+
|
6006 |
+
|
6007 |
+
};
|
6008 |
+
/**
|
6009 |
+
* Type to use when a validation error occurs.
|
6010 |
+
* @class ValidationError
|
6011 |
+
* @namespace parserlib.util
|
6012 |
+
* @constructor
|
6013 |
+
* @param {String} message The error message.
|
6014 |
+
* @param {int} line The line at which the error occurred.
|
6015 |
+
* @param {int} col The column at which the error occurred.
|
6016 |
+
*/
|
6017 |
+
function ValidationError(message, line, col){
|
6018 |
+
|
6019 |
+
/**
|
6020 |
+
* The column at which the error occurred.
|
6021 |
+
* @type int
|
6022 |
+
* @property col
|
6023 |
+
*/
|
6024 |
+
this.col = col;
|
6025 |
+
|
6026 |
+
/**
|
6027 |
+
* The line at which the error occurred.
|
6028 |
+
* @type int
|
6029 |
+
* @property line
|
6030 |
+
*/
|
6031 |
+
this.line = line;
|
6032 |
+
|
6033 |
+
/**
|
6034 |
+
* The text representation of the unit.
|
6035 |
+
* @type String
|
6036 |
+
* @property text
|
6037 |
+
*/
|
6038 |
+
this.message = message;
|
6039 |
+
|
6040 |
+
}
|
6041 |
+
|
6042 |
+
//inherit from Error
|
6043 |
+
ValidationError.prototype = new Error();
|
6044 |
+
//This file will likely change a lot! Very experimental!
|
6045 |
+
/*global Properties, Validation, ValidationError, PropertyValueIterator, console*/
|
6046 |
+
var ValidationTypes = {
|
6047 |
+
|
6048 |
+
isLiteral: function (part, literals) {
|
6049 |
+
var text = part.text.toString().toLowerCase(),
|
6050 |
+
args = literals.split(" | "),
|
6051 |
+
i, len, found = false;
|
6052 |
+
|
6053 |
+
for (i=0,len=args.length; i < len && !found; i++){
|
6054 |
+
if (text == args[i].toLowerCase()){
|
6055 |
+
found = true;
|
6056 |
+
}
|
6057 |
+
}
|
6058 |
+
|
6059 |
+
return found;
|
6060 |
+
},
|
6061 |
+
|
6062 |
+
isSimple: function(type) {
|
6063 |
+
return !!this.simple[type];
|
6064 |
+
},
|
6065 |
+
|
6066 |
+
isComplex: function(type) {
|
6067 |
+
return !!this.complex[type];
|
6068 |
+
},
|
6069 |
+
|
6070 |
+
/**
|
6071 |
+
* Determines if the next part(s) of the given expression
|
6072 |
+
* are any of the given types.
|
6073 |
+
*/
|
6074 |
+
isAny: function (expression, types) {
|
6075 |
+
var args = types.split(" | "),
|
6076 |
+
i, len, found = false;
|
6077 |
+
|
6078 |
+
for (i=0,len=args.length; i < len && !found && expression.hasNext(); i++){
|
6079 |
+
found = this.isType(expression, args[i]);
|
6080 |
+
}
|
6081 |
+
|
6082 |
+
return found;
|
6083 |
+
},
|
6084 |
+
|
6085 |
+
/**
|
6086 |
+
* Determines if the next part(s) of the given expression
|
6087 |
+
* are one of a group.
|
6088 |
+
*/
|
6089 |
+
isAnyOfGroup: function(expression, types) {
|
6090 |
+
var args = types.split(" || "),
|
6091 |
+
i, len, found = false;
|
6092 |
+
|
6093 |
+
for (i=0,len=args.length; i < len && !found; i++){
|
6094 |
+
found = this.isType(expression, args[i]);
|
6095 |
+
}
|
6096 |
+
|
6097 |
+
return found ? args[i-1] : false;
|
6098 |
+
},
|
6099 |
+
|
6100 |
+
/**
|
6101 |
+
* Determines if the next part(s) of the given expression
|
6102 |
+
* are of a given type.
|
6103 |
+
*/
|
6104 |
+
isType: function (expression, type) {
|
6105 |
+
var part = expression.peek(),
|
6106 |
+
result = false;
|
6107 |
+
|
6108 |
+
if (type.charAt(0) != "<") {
|
6109 |
+
result = this.isLiteral(part, type);
|
6110 |
+
if (result) {
|
6111 |
+
expression.next();
|
6112 |
+
}
|
6113 |
+
} else if (this.simple[type]) {
|
6114 |
+
result = this.simple[type](part);
|
6115 |
+
if (result) {
|
6116 |
+
expression.next();
|
6117 |
+
}
|
6118 |
+
} else {
|
6119 |
+
result = this.complex[type](expression);
|
6120 |
+
}
|
6121 |
+
|
6122 |
+
return result;
|
6123 |
+
},
|
6124 |
+
|
6125 |
+
|
6126 |
+
|
6127 |
+
simple: {
|
6128 |
+
|
6129 |
+
"<absolute-size>": function(part){
|
6130 |
+
return ValidationTypes.isLiteral(part, "xx-small | x-small | small | medium | large | x-large | xx-large");
|
6131 |
+
},
|
6132 |
+
|
6133 |
+
"<attachment>": function(part){
|
6134 |
+
return ValidationTypes.isLiteral(part, "scroll | fixed | local");
|
6135 |
+
},
|
6136 |
+
|
6137 |
+
"<attr>": function(part){
|
6138 |
+
return part.type == "function" && part.name == "attr";
|
6139 |
+
},
|
6140 |
+
|
6141 |
+
"<bg-image>": function(part){
|
6142 |
+
return this["<image>"](part) || this["<gradient>"](part) || part == "none";
|
6143 |
+
},
|
6144 |
+
|
6145 |
+
"<gradient>": function(part) {
|
6146 |
+
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
|
6147 |
+
},
|
6148 |
+
|
6149 |
+
"<box>": function(part){
|
6150 |
+
return ValidationTypes.isLiteral(part, "padding-box | border-box | content-box");
|
6151 |
+
},
|
6152 |
+
|
6153 |
+
"<content>": function(part){
|
6154 |
+
return part.type == "function" && part.name == "content";
|
6155 |
+
},
|
6156 |
+
|
6157 |
+
"<relative-size>": function(part){
|
6158 |
+
return ValidationTypes.isLiteral(part, "smaller | larger");
|
6159 |
+
},
|
6160 |
+
|
6161 |
+
//any identifier
|
6162 |
+
"<ident>": function(part){
|
6163 |
+
return part.type == "identifier";
|
6164 |
+
},
|
6165 |
+
|
6166 |
+
"<length>": function(part){
|
6167 |
+
if (part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)){
|
6168 |
+
return true;
|
6169 |
+
}else{
|
6170 |
+
return part.type == "length" || part.type == "number" || part.type == "integer" || part == "0";
|
6171 |
+
}
|
6172 |
+
},
|
6173 |
+
|
6174 |
+
"<color>": function(part){
|
6175 |
+
return part.type == "color" || part == "transparent";
|
6176 |
+
},
|
6177 |
+
|
6178 |
+
"<number>": function(part){
|
6179 |
+
return part.type == "number" || this["<integer>"](part);
|
6180 |
+
},
|
6181 |
+
|
6182 |
+
"<integer>": function(part){
|
6183 |
+
return part.type == "integer";
|
6184 |
+
},
|
6185 |
+
|
6186 |
+
"<line>": function(part){
|
6187 |
+
return part.type == "integer";
|
6188 |
+
},
|
6189 |
+
|
6190 |
+
"<angle>": function(part){
|
6191 |
+
return part.type == "angle";
|
6192 |
+
},
|
6193 |
+
|
6194 |
+
"<uri>": function(part){
|
6195 |
+
return part.type == "uri";
|
6196 |
+
},
|
6197 |
+
|
6198 |
+
"<image>": function(part){
|
6199 |
+
return this["<uri>"](part);
|
6200 |
+
},
|
6201 |
+
|
6202 |
+
"<percentage>": function(part){
|
6203 |
+
return part.type == "percentage" || part == "0";
|
6204 |
+
},
|
6205 |
+
|
6206 |
+
"<border-width>": function(part){
|
6207 |
+
return this["<length>"](part) || ValidationTypes.isLiteral(part, "thin | medium | thick");
|
6208 |
+
},
|
6209 |
+
|
6210 |
+
"<border-style>": function(part){
|
6211 |
+
return ValidationTypes.isLiteral(part, "none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset");
|
6212 |
+
},
|
6213 |
+
|
6214 |
+
"<margin-width>": function(part){
|
6215 |
+
return this["<length>"](part) || this["<percentage>"](part) || ValidationTypes.isLiteral(part, "auto");
|
6216 |
+
},
|
6217 |
+
|
6218 |
+
"<padding-width>": function(part){
|
6219 |
+
return this["<length>"](part) || this["<percentage>"](part);
|
6220 |
+
},
|
6221 |
+
|
6222 |
+
"<shape>": function(part){
|
6223 |
+
return part.type == "function" && (part.name == "rect" || part.name == "inset-rect");
|
6224 |
+
},
|
6225 |
+
|
6226 |
+
"<time>": function(part) {
|
6227 |
+
return part.type == "time";
|
6228 |
+
}
|
6229 |
+
},
|
6230 |
+
|
6231 |
+
complex: {
|
6232 |
+
|
6233 |
+
"<bg-position>": function(expression){
|
6234 |
+
var types = this,
|
6235 |
+
result = false,
|
6236 |
+
numeric = "<percentage> | <length>",
|
6237 |
+
xDir = "left | right",
|
6238 |
+
yDir = "top | bottom",
|
6239 |
+
count = 0,
|
6240 |
+
hasNext = function() {
|
6241 |
+
return expression.hasNext() && expression.peek() != ",";
|
6242 |
+
};
|
6243 |
+
|
6244 |
+
while (expression.peek(count) && expression.peek(count) != ",") {
|
6245 |
+
count++;
|
6246 |
+
}
|
6247 |
+
|
6248 |
+
/*
|
6249 |
+
<position> = [
|
6250 |
+
[ left | center | right | top | bottom | <percentage> | <length> ]
|
6251 |
+
|
|
6252 |
+
[ left | center | right | <percentage> | <length> ]
|
6253 |
+
[ top | center | bottom | <percentage> | <length> ]
|
6254 |
+
|
|
6255 |
+
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
|
6256 |
+
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
|
6257 |
+
]
|
6258 |
+
*/
|
6259 |
+
|
6260 |
+
if (count < 3) {
|
6261 |
+
if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
|
6262 |
+
result = true;
|
6263 |
+
ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
|
6264 |
+
} else if (ValidationTypes.isAny(expression, yDir)) {
|
6265 |
+
result = true;
|
6266 |
+
ValidationTypes.isAny(expression, xDir + " | center");
|
6267 |
+
}
|
6268 |
+
} else {
|
6269 |
+
if (ValidationTypes.isAny(expression, xDir)) {
|
6270 |
+
if (ValidationTypes.isAny(expression, yDir)) {
|
6271 |
+
result = true;
|
6272 |
+
ValidationTypes.isAny(expression, numeric);
|
6273 |
+
} else if (ValidationTypes.isAny(expression, numeric)) {
|
6274 |
+
if (ValidationTypes.isAny(expression, yDir)) {
|
6275 |
+
result = true;
|
6276 |
+
ValidationTypes.isAny(expression, numeric);
|
6277 |
+
} else if (ValidationTypes.isAny(expression, "center")) {
|
6278 |
+
result = true;
|
6279 |
+
}
|
6280 |
+
}
|
6281 |
+
} else if (ValidationTypes.isAny(expression, yDir)) {
|
6282 |
+
if (ValidationTypes.isAny(expression, xDir)) {
|
6283 |
+
result = true;
|
6284 |
+
ValidationTypes.isAny(expression, numeric);
|
6285 |
+
} else if (ValidationTypes.isAny(expression, numeric)) {
|
6286 |
+
if (ValidationTypes.isAny(expression, xDir)) {
|
6287 |
+
result = true;
|
6288 |
+
ValidationTypes.isAny(expression, numeric);
|
6289 |
+
} else if (ValidationTypes.isAny(expression, "center")) {
|
6290 |
+
result = true;
|
6291 |
+
}
|
6292 |
+
}
|
6293 |
+
} else if (ValidationTypes.isAny(expression, "center")) {
|
6294 |
+
if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
|
6295 |
+
result = true;
|
6296 |
+
ValidationTypes.isAny(expression, numeric);
|
6297 |
+
}
|
6298 |
+
}
|
6299 |
+
}
|
6300 |
+
|
6301 |
+
return result;
|
6302 |
+
},
|
6303 |
+
|
6304 |
+
"<bg-size>": function(expression){
|
6305 |
+
//<bg-size> = [ <length> | <percentage> | auto ]{1,2} | cover | contain
|
6306 |
+
var types = this,
|
6307 |
+
result = false,
|
6308 |
+
numeric = "<percentage> | <length> | auto",
|
6309 |
+
part,
|
6310 |
+
i, len;
|
6311 |
+
|
6312 |
+
if (ValidationTypes.isAny(expression, "cover | contain")) {
|
6313 |
+
result = true;
|
6314 |
+
} else if (ValidationTypes.isAny(expression, numeric)) {
|
6315 |
+
result = true;
|
6316 |
+
ValidationTypes.isAny(expression, numeric);
|
6317 |
+
}
|
6318 |
+
|
6319 |
+
return result;
|
6320 |
+
},
|
6321 |
+
|
6322 |
+
"<repeat-style>": function(expression){
|
6323 |
+
//repeat-x | repeat-y | [repeat | space | round | no-repeat]{1,2}
|
6324 |
+
var result = false,
|
6325 |
+
values = "repeat | space | round | no-repeat",
|
6326 |
+
part;
|
6327 |
+
|
6328 |
+
if (expression.hasNext()){
|
6329 |
+
part = expression.next();
|
6330 |
+
|
6331 |
+
if (ValidationTypes.isLiteral(part, "repeat-x | repeat-y")) {
|
6332 |
+
result = true;
|
6333 |
+
} else if (ValidationTypes.isLiteral(part, values)) {
|
6334 |
+
result = true;
|
6335 |
+
|
6336 |
+
if (expression.hasNext() && ValidationTypes.isLiteral(expression.peek(), values)) {
|
6337 |
+
expression.next();
|
6338 |
+
}
|
6339 |
+
}
|
6340 |
+
}
|
6341 |
+
|
6342 |
+
return result;
|
6343 |
+
|
6344 |
+
},
|
6345 |
+
|
6346 |
+
"<shadow>": function(expression) {
|
6347 |
+
//inset? && [ <length>{2,4} && <color>? ]
|
6348 |
+
var result = false,
|
6349 |
+
count = 0,
|
6350 |
+
inset = false,
|
6351 |
+
color = false,
|
6352 |
+
part;
|
6353 |
+
|
6354 |
+
if (expression.hasNext()) {
|
6355 |
+
|
6356 |
+
if (ValidationTypes.isAny(expression, "inset")){
|
6357 |
+
inset = true;
|
6358 |
+
}
|
6359 |
+
|
6360 |
+
if (ValidationTypes.isAny(expression, "<color>")) {
|
6361 |
+
color = true;
|
6362 |
+
}
|
6363 |
+
|
6364 |
+
while (ValidationTypes.isAny(expression, "<length>") && count < 4) {
|
6365 |
+
count++;
|
6366 |
+
}
|
6367 |
+
|
6368 |
+
|
6369 |
+
if (expression.hasNext()) {
|
6370 |
+
if (!color) {
|
6371 |
+
ValidationTypes.isAny(expression, "<color>");
|
6372 |
+
}
|
6373 |
+
|
6374 |
+
if (!inset) {
|
6375 |
+
ValidationTypes.isAny(expression, "inset");
|
6376 |
+
}
|
6377 |
+
|
6378 |
+
}
|
6379 |
+
|
6380 |
+
result = (count >= 2 && count <= 4);
|
6381 |
+
|
6382 |
+
}
|
6383 |
+
|
6384 |
+
return result;
|
6385 |
+
},
|
6386 |
+
|
6387 |
+
"<x-one-radius>": function(expression) {
|
6388 |
+
//[ <length> | <percentage> ] [ <length> | <percentage> ]?
|
6389 |
+
var result = false,
|
6390 |
+
simple = "<length> | <percentage> | inherit";
|
6391 |
+
|
6392 |
+
if (ValidationTypes.isAny(expression, simple)){
|
6393 |
+
result = true;
|
6394 |
+
ValidationTypes.isAny(expression, simple);
|
6395 |
+
}
|
6396 |
+
|
6397 |
+
return result;
|
6398 |
+
}
|
6399 |
+
}
|
6400 |
+
};
|
6401 |
+
|
6402 |
+
|
6403 |
+
|
6404 |
+
parserlib.css = {
|
6405 |
+
Colors :Colors,
|
6406 |
+
Combinator :Combinator,
|
6407 |
+
Parser :Parser,
|
6408 |
+
PropertyName :PropertyName,
|
6409 |
+
PropertyValue :PropertyValue,
|
6410 |
+
PropertyValuePart :PropertyValuePart,
|
6411 |
+
MediaFeature :MediaFeature,
|
6412 |
+
MediaQuery :MediaQuery,
|
6413 |
+
Selector :Selector,
|
6414 |
+
SelectorPart :SelectorPart,
|
6415 |
+
SelectorSubPart :SelectorSubPart,
|
6416 |
+
Specificity :Specificity,
|
6417 |
+
TokenStream :TokenStream,
|
6418 |
+
Tokens :Tokens,
|
6419 |
+
ValidationError :ValidationError
|
6420 |
+
};
|
6421 |
+
})();
|
6422 |
+
|
6423 |
+
|
6424 |
+
|
6425 |
+
|
6426 |
+
(function(){
|
6427 |
+
for(var prop in parserlib){
|
6428 |
+
exports[prop] = parserlib[prop];
|
6429 |
+
}
|
6430 |
+
})();
|
6431 |
+
|
6432 |
+
|
6433 |
+
/**
|
6434 |
+
* Main CSSLint object.
|
6435 |
+
* @class CSSLint
|
6436 |
+
* @static
|
6437 |
+
* @extends parserlib.util.EventTarget
|
6438 |
+
*/
|
6439 |
+
/*global parserlib, Reporter*/
|
6440 |
+
var CSSLint = (function(){
|
6441 |
+
|
6442 |
+
var rules = [],
|
6443 |
+
formatters = [],
|
6444 |
+
embeddedRuleset = /\/\*csslint([^\*]*)\*\//,
|
6445 |
+
api = new parserlib.util.EventTarget();
|
6446 |
+
|
6447 |
+
api.version = "0.10.0";
|
6448 |
+
|
6449 |
+
//-------------------------------------------------------------------------
|
6450 |
+
// Rule Management
|
6451 |
+
//-------------------------------------------------------------------------
|
6452 |
+
|
6453 |
+
/**
|
6454 |
+
* Adds a new rule to the engine.
|
6455 |
+
* @param {Object} rule The rule to add.
|
6456 |
+
* @method addRule
|
6457 |
+
*/
|
6458 |
+
api.addRule = function(rule){
|
6459 |
+
rules.push(rule);
|
6460 |
+
rules[rule.id] = rule;
|
6461 |
+
};
|
6462 |
+
|
6463 |
+
/**
|
6464 |
+
* Clears all rule from the engine.
|
6465 |
+
* @method clearRules
|
6466 |
+
*/
|
6467 |
+
api.clearRules = function(){
|
6468 |
+
rules = [];
|
6469 |
+
};
|
6470 |
+
|
6471 |
+
/**
|
6472 |
+
* Returns the rule objects.
|
6473 |
+
* @return An array of rule objects.
|
6474 |
+
* @method getRules
|
6475 |
+
*/
|
6476 |
+
api.getRules = function(){
|
6477 |
+
return [].concat(rules).sort(function(a,b){
|
6478 |
+
return a.id > b.id ? 1 : 0;
|
6479 |
+
});
|
6480 |
+
};
|
6481 |
+
|
6482 |
+
/**
|
6483 |
+
* Returns a ruleset configuration object with all current rules.
|
6484 |
+
* @return A ruleset object.
|
6485 |
+
* @method getRuleset
|
6486 |
+
*/
|
6487 |
+
api.getRuleset = function() {
|
6488 |
+
var ruleset = {},
|
6489 |
+
i = 0,
|
6490 |
+
len = rules.length;
|
6491 |
+
|
6492 |
+
while (i < len){
|
6493 |
+
ruleset[rules[i++].id] = 1; //by default, everything is a warning
|
6494 |
+
}
|
6495 |
+
|
6496 |
+
return ruleset;
|
6497 |
+
};
|
6498 |
+
|
6499 |
+
/**
|
6500 |
+
* Returns a ruleset object based on embedded rules.
|
6501 |
+
* @param {String} text A string of css containing embedded rules.
|
6502 |
+
* @param {Object} ruleset A ruleset object to modify.
|
6503 |
+
* @return {Object} A ruleset object.
|
6504 |
+
* @method getEmbeddedRuleset
|
6505 |
+
*/
|
6506 |
+
function applyEmbeddedRuleset(text, ruleset){
|
6507 |
+
var valueMap,
|
6508 |
+
embedded = text && text.match(embeddedRuleset),
|
6509 |
+
rules = embedded && embedded[1];
|
6510 |
+
|
6511 |
+
if (rules) {
|
6512 |
+
valueMap = {
|
6513 |
+
"true": 2, // true is error
|
6514 |
+
"": 1, // blank is warning
|
6515 |
+
"false": 0, // false is ignore
|
6516 |
+
|
6517 |
+
"2": 2, // explicit error
|
6518 |
+
"1": 1, // explicit warning
|
6519 |
+
"0": 0 // explicit ignore
|
6520 |
+
};
|
6521 |
+
|
6522 |
+
rules.toLowerCase().split(",").forEach(function(rule){
|
6523 |
+
var pair = rule.split(":"),
|
6524 |
+
property = pair[0] || "",
|
6525 |
+
value = pair[1] || "";
|
6526 |
+
|
6527 |
+
ruleset[property.trim()] = valueMap[value.trim()];
|
6528 |
+
});
|
6529 |
+
}
|
6530 |
+
|
6531 |
+
return ruleset;
|
6532 |
+
}
|
6533 |
+
|
6534 |
+
//-------------------------------------------------------------------------
|
6535 |
+
// Formatters
|
6536 |
+
//-------------------------------------------------------------------------
|
6537 |
+
|
6538 |
+
/**
|
6539 |
+
* Adds a new formatter to the engine.
|
6540 |
+
* @param {Object} formatter The formatter to add.
|
6541 |
+
* @method addFormatter
|
6542 |
+
*/
|
6543 |
+
api.addFormatter = function(formatter) {
|
6544 |
+
// formatters.push(formatter);
|
6545 |
+
formatters[formatter.id] = formatter;
|
6546 |
+
};
|
6547 |
+
|
6548 |
+
/**
|
6549 |
+
* Retrieves a formatter for use.
|
6550 |
+
* @param {String} formatId The name of the format to retrieve.
|
6551 |
+
* @return {Object} The formatter or undefined.
|
6552 |
+
* @method getFormatter
|
6553 |
+
*/
|
6554 |
+
api.getFormatter = function(formatId){
|
6555 |
+
return formatters[formatId];
|
6556 |
+
};
|
6557 |
+
|
6558 |
+
/**
|
6559 |
+
* Formats the results in a particular format for a single file.
|
6560 |
+
* @param {Object} result The results returned from CSSLint.verify().
|
6561 |
+
* @param {String} filename The filename for which the results apply.
|
6562 |
+
* @param {String} formatId The name of the formatter to use.
|
6563 |
+
* @param {Object} options (Optional) for special output handling.
|
6564 |
+
* @return {String} A formatted string for the results.
|
6565 |
+
* @method format
|
6566 |
+
*/
|
6567 |
+
api.format = function(results, filename, formatId, options) {
|
6568 |
+
var formatter = this.getFormatter(formatId),
|
6569 |
+
result = null;
|
6570 |
+
|
6571 |
+
if (formatter){
|
6572 |
+
result = formatter.startFormat();
|
6573 |
+
result += formatter.formatResults(results, filename, options || {});
|
6574 |
+
result += formatter.endFormat();
|
6575 |
+
}
|
6576 |
+
|
6577 |
+
return result;
|
6578 |
+
};
|
6579 |
+
|
6580 |
+
/**
|
6581 |
+
* Indicates if the given format is supported.
|
6582 |
+
* @param {String} formatId The ID of the format to check.
|
6583 |
+
* @return {Boolean} True if the format exists, false if not.
|
6584 |
+
* @method hasFormat
|
6585 |
+
*/
|
6586 |
+
api.hasFormat = function(formatId){
|
6587 |
+
return formatters.hasOwnProperty(formatId);
|
6588 |
+
};
|
6589 |
+
|
6590 |
+
//-------------------------------------------------------------------------
|
6591 |
+
// Verification
|
6592 |
+
//-------------------------------------------------------------------------
|
6593 |
+
|
6594 |
+
/**
|
6595 |
+
* Starts the verification process for the given CSS text.
|
6596 |
+
* @param {String} text The CSS text to verify.
|
6597 |
+
* @param {Object} ruleset (Optional) List of rules to apply. If null, then
|
6598 |
+
* all rules are used. If a rule has a value of 1 then it's a warning,
|
6599 |
+
* a value of 2 means it's an error.
|
6600 |
+
* @return {Object} Results of the verification.
|
6601 |
+
* @method verify
|
6602 |
+
*/
|
6603 |
+
api.verify = function(text, ruleset){
|
6604 |
+
|
6605 |
+
var i = 0,
|
6606 |
+
len = rules.length,
|
6607 |
+
reporter,
|
6608 |
+
lines,
|
6609 |
+
report,
|
6610 |
+
parser = new parserlib.css.Parser({ starHack: true, ieFilters: true,
|
6611 |
+
underscoreHack: true, strict: false });
|
6612 |
+
|
6613 |
+
// normalize line endings
|
6614 |
+
lines = text.replace(/\n\r?/g, "$split$").split('$split$');
|
6615 |
+
|
6616 |
+
if (!ruleset){
|
6617 |
+
ruleset = this.getRuleset();
|
6618 |
+
}
|
6619 |
+
|
6620 |
+
if (embeddedRuleset.test(text)){
|
6621 |
+
ruleset = applyEmbeddedRuleset(text, ruleset);
|
6622 |
+
}
|
6623 |
+
|
6624 |
+
reporter = new Reporter(lines, ruleset);
|
6625 |
+
|
6626 |
+
ruleset.errors = 2; //always report parsing errors as errors
|
6627 |
+
for (i in ruleset){
|
6628 |
+
if(ruleset.hasOwnProperty(i) && ruleset[i]){
|
6629 |
+
if (rules[i]){
|
6630 |
+
rules[i].init(parser, reporter);
|
6631 |
+
}
|
6632 |
+
}
|
6633 |
+
}
|
6634 |
+
|
6635 |
+
|
6636 |
+
//capture most horrible error type
|
6637 |
+
try {
|
6638 |
+
parser.parse(text);
|
6639 |
+
} catch (ex) {
|
6640 |
+
reporter.error("Fatal error, cannot continue: " + ex.message, ex.line, ex.col, {});
|
6641 |
+
}
|
6642 |
+
|
6643 |
+
report = {
|
6644 |
+
messages : reporter.messages,
|
6645 |
+
stats : reporter.stats,
|
6646 |
+
ruleset : reporter.ruleset
|
6647 |
+
};
|
6648 |
+
|
6649 |
+
//sort by line numbers, rollups at the bottom
|
6650 |
+
report.messages.sort(function (a, b){
|
6651 |
+
if (a.rollup && !b.rollup){
|
6652 |
+
return 1;
|
6653 |
+
} else if (!a.rollup && b.rollup){
|
6654 |
+
return -1;
|
6655 |
+
} else {
|
6656 |
+
return a.line - b.line;
|
6657 |
+
}
|
6658 |
+
});
|
6659 |
+
|
6660 |
+
return report;
|
6661 |
+
};
|
6662 |
+
|
6663 |
+
//-------------------------------------------------------------------------
|
6664 |
+
// Publish the API
|
6665 |
+
//-------------------------------------------------------------------------
|
6666 |
+
|
6667 |
+
return api;
|
6668 |
+
|
6669 |
+
})();
|
6670 |
+
|
6671 |
+
/*global CSSLint*/
|
6672 |
+
/**
|
6673 |
+
* An instance of Report is used to report results of the
|
6674 |
+
* verification back to the main API.
|
6675 |
+
* @class Reporter
|
6676 |
+
* @constructor
|
6677 |
+
* @param {String[]} lines The text lines of the source.
|
6678 |
+
* @param {Object} ruleset The set of rules to work with, including if
|
6679 |
+
* they are errors or warnings.
|
6680 |
+
*/
|
6681 |
+
function Reporter(lines, ruleset){
|
6682 |
+
|
6683 |
+
/**
|
6684 |
+
* List of messages being reported.
|
6685 |
+
* @property messages
|
6686 |
+
* @type String[]
|
6687 |
+
*/
|
6688 |
+
this.messages = [];
|
6689 |
+
|
6690 |
+
/**
|
6691 |
+
* List of statistics being reported.
|
6692 |
+
* @property stats
|
6693 |
+
* @type String[]
|
6694 |
+
*/
|
6695 |
+
this.stats = [];
|
6696 |
+
|
6697 |
+
/**
|
6698 |
+
* Lines of code being reported on. Used to provide contextual information
|
6699 |
+
* for messages.
|
6700 |
+
* @property lines
|
6701 |
+
* @type String[]
|
6702 |
+
*/
|
6703 |
+
this.lines = lines;
|
6704 |
+
|
6705 |
+
/**
|
6706 |
+
* Information about the rules. Used to determine whether an issue is an
|
6707 |
+
* error or warning.
|
6708 |
+
* @property ruleset
|
6709 |
+
* @type Object
|
6710 |
+
*/
|
6711 |
+
this.ruleset = ruleset;
|
6712 |
+
}
|
6713 |
+
|
6714 |
+
Reporter.prototype = {
|
6715 |
+
|
6716 |
+
//restore constructor
|
6717 |
+
constructor: Reporter,
|
6718 |
+
|
6719 |
+
/**
|
6720 |
+
* Report an error.
|
6721 |
+
* @param {String} message The message to store.
|
6722 |
+
* @param {int} line The line number.
|
6723 |
+
* @param {int} col The column number.
|
6724 |
+
* @param {Object} rule The rule this message relates to.
|
6725 |
+
* @method error
|
6726 |
+
*/
|
6727 |
+
error: function(message, line, col, rule){
|
6728 |
+
this.messages.push({
|
6729 |
+
type : "error",
|
6730 |
+
line : line,
|
6731 |
+
col : col,
|
6732 |
+
message : message,
|
6733 |
+
evidence: this.lines[line-1],
|
6734 |
+
rule : rule || {}
|
6735 |
+
});
|
6736 |
+
},
|
6737 |
+
|
6738 |
+
/**
|
6739 |
+
* Report an warning.
|
6740 |
+
* @param {String} message The message to store.
|
6741 |
+
* @param {int} line The line number.
|
6742 |
+
* @param {int} col The column number.
|
6743 |
+
* @param {Object} rule The rule this message relates to.
|
6744 |
+
* @method warn
|
6745 |
+
* @deprecated Use report instead.
|
6746 |
+
*/
|
6747 |
+
warn: function(message, line, col, rule){
|
6748 |
+
this.report(message, line, col, rule);
|
6749 |
+
},
|
6750 |
+
|
6751 |
+
/**
|
6752 |
+
* Report an issue.
|
6753 |
+
* @param {String} message The message to store.
|
6754 |
+
* @param {int} line The line number.
|
6755 |
+
* @param {int} col The column number.
|
6756 |
+
* @param {Object} rule The rule this message relates to.
|
6757 |
+
* @method report
|
6758 |
+
*/
|
6759 |
+
report: function(message, line, col, rule){
|
6760 |
+
this.messages.push({
|
6761 |
+
type : this.ruleset[rule.id] == 2 ? "error" : "warning",
|
6762 |
+
line : line,
|
6763 |
+
col : col,
|
6764 |
+
message : message,
|
6765 |
+
evidence: this.lines[line-1],
|
6766 |
+
rule : rule
|
6767 |
+
});
|
6768 |
+
},
|
6769 |
+
|
6770 |
+
/**
|
6771 |
+
* Report some informational text.
|
6772 |
+
* @param {String} message The message to store.
|
6773 |
+
* @param {int} line The line number.
|
6774 |
+
* @param {int} col The column number.
|
6775 |
+
* @param {Object} rule The rule this message relates to.
|
6776 |
+
* @method info
|
6777 |
+
*/
|
6778 |
+
info: function(message, line, col, rule){
|
6779 |
+
this.messages.push({
|
6780 |
+
type : "info",
|
6781 |
+
line : line,
|
6782 |
+
col : col,
|
6783 |
+
message : message,
|
6784 |
+
evidence: this.lines[line-1],
|
6785 |
+
rule : rule
|
6786 |
+
});
|
6787 |
+
},
|
6788 |
+
|
6789 |
+
/**
|
6790 |
+
* Report some rollup error information.
|
6791 |
+
* @param {String} message The message to store.
|
6792 |
+
* @param {Object} rule The rule this message relates to.
|
6793 |
+
* @method rollupError
|
6794 |
+
*/
|
6795 |
+
rollupError: function(message, rule){
|
6796 |
+
this.messages.push({
|
6797 |
+
type : "error",
|
6798 |
+
rollup : true,
|
6799 |
+
message : message,
|
6800 |
+
rule : rule
|
6801 |
+
});
|
6802 |
+
},
|
6803 |
+
|
6804 |
+
/**
|
6805 |
+
* Report some rollup warning information.
|
6806 |
+
* @param {String} message The message to store.
|
6807 |
+
* @param {Object} rule The rule this message relates to.
|
6808 |
+
* @method rollupWarn
|
6809 |
+
*/
|
6810 |
+
rollupWarn: function(message, rule){
|
6811 |
+
this.messages.push({
|
6812 |
+
type : "warning",
|
6813 |
+
rollup : true,
|
6814 |
+
message : message,
|
6815 |
+
rule : rule
|
6816 |
+
});
|
6817 |
+
},
|
6818 |
+
|
6819 |
+
/**
|
6820 |
+
* Report a statistic.
|
6821 |
+
* @param {String} name The name of the stat to store.
|
6822 |
+
* @param {Variant} value The value of the stat.
|
6823 |
+
* @method stat
|
6824 |
+
*/
|
6825 |
+
stat: function(name, value){
|
6826 |
+
this.stats[name] = value;
|
6827 |
+
}
|
6828 |
+
};
|
6829 |
+
|
6830 |
+
//expose for testing purposes
|
6831 |
+
CSSLint._Reporter = Reporter;
|
6832 |
+
|
6833 |
+
/*global CSSLint*/
|
6834 |
+
|
6835 |
+
/*
|
6836 |
+
* Utility functions that make life easier.
|
6837 |
+
*/
|
6838 |
+
CSSLint.Util = {
|
6839 |
+
/*
|
6840 |
+
* Adds all properties from supplier onto receiver,
|
6841 |
+
* overwriting if the same name already exists on
|
6842 |
+
* reciever.
|
6843 |
+
* @param {Object} The object to receive the properties.
|
6844 |
+
* @param {Object} The object to provide the properties.
|
6845 |
+
* @return {Object} The receiver
|
6846 |
+
*/
|
6847 |
+
mix: function(receiver, supplier){
|
6848 |
+
var prop;
|
6849 |
+
|
6850 |
+
for (prop in supplier){
|
6851 |
+
if (supplier.hasOwnProperty(prop)){
|
6852 |
+
receiver[prop] = supplier[prop];
|
6853 |
+
}
|
6854 |
+
}
|
6855 |
+
|
6856 |
+
return prop;
|
6857 |
+
},
|
6858 |
+
|
6859 |
+
/*
|
6860 |
+
* Polyfill for array indexOf() method.
|
6861 |
+
* @param {Array} values The array to search.
|
6862 |
+
* @param {Variant} value The value to search for.
|
6863 |
+
* @return {int} The index of the value if found, -1 if not.
|
6864 |
+
*/
|
6865 |
+
indexOf: function(values, value){
|
6866 |
+
if (values.indexOf){
|
6867 |
+
return values.indexOf(value);
|
6868 |
+
} else {
|
6869 |
+
for (var i=0, len=values.length; i < len; i++){
|
6870 |
+
if (values[i] === value){
|
6871 |
+
return i;
|
6872 |
+
}
|
6873 |
+
}
|
6874 |
+
return -1;
|
6875 |
+
}
|
6876 |
+
},
|
6877 |
+
|
6878 |
+
/*
|
6879 |
+
* Polyfill for array forEach() method.
|
6880 |
+
* @param {Array} values The array to operate on.
|
6881 |
+
* @param {Function} func The function to call on each item.
|
6882 |
+
* @return {void}
|
6883 |
+
*/
|
6884 |
+
forEach: function(values, func) {
|
6885 |
+
if (values.forEach){
|
6886 |
+
return values.forEach(func);
|
6887 |
+
} else {
|
6888 |
+
for (var i=0, len=values.length; i < len; i++){
|
6889 |
+
func(values[i], i, values);
|
6890 |
+
}
|
6891 |
+
}
|
6892 |
+
}
|
6893 |
+
};
|
6894 |
+
/*global CSSLint*/
|
6895 |
+
/*
|
6896 |
+
* Rule: Don't use adjoining classes (.foo.bar).
|
6897 |
+
*/
|
6898 |
+
CSSLint.addRule({
|
6899 |
+
|
6900 |
+
//rule information
|
6901 |
+
id: "adjoining-classes",
|
6902 |
+
name: "Disallow adjoining classes",
|
6903 |
+
desc: "Don't use adjoining classes.",
|
6904 |
+
browsers: "IE6",
|
6905 |
+
|
6906 |
+
//initialization
|
6907 |
+
init: function(parser, reporter){
|
6908 |
+
var rule = this;
|
6909 |
+
parser.addListener("startrule", function(event){
|
6910 |
+
var selectors = event.selectors,
|
6911 |
+
selector,
|
6912 |
+
part,
|
6913 |
+
modifier,
|
6914 |
+
classCount,
|
6915 |
+
i, j, k;
|
6916 |
+
|
6917 |
+
for (i=0; i < selectors.length; i++){
|
6918 |
+
selector = selectors[i];
|
6919 |
+
for (j=0; j < selector.parts.length; j++){
|
6920 |
+
part = selector.parts[j];
|
6921 |
+
if (part.type == parser.SELECTOR_PART_TYPE){
|
6922 |
+
classCount = 0;
|
6923 |
+
for (k=0; k < part.modifiers.length; k++){
|
6924 |
+
modifier = part.modifiers[k];
|
6925 |
+
if (modifier.type == "class"){
|
6926 |
+
classCount++;
|
6927 |
+
}
|
6928 |
+
if (classCount > 1){
|
6929 |
+
reporter.report("Don't use adjoining classes.", part.line, part.col, rule);
|
6930 |
+
}
|
6931 |
+
}
|
6932 |
+
}
|
6933 |
+
}
|
6934 |
+
}
|
6935 |
+
});
|
6936 |
+
}
|
6937 |
+
|
6938 |
+
});
|
6939 |
+
/*global CSSLint*/
|
6940 |
+
|
6941 |
+
/*
|
6942 |
+
* Rule: Don't use width or height when using padding or border.
|
6943 |
+
*/
|
6944 |
+
CSSLint.addRule({
|
6945 |
+
|
6946 |
+
//rule information
|
6947 |
+
id: "box-model",
|
6948 |
+
name: "Beware of broken box size",
|
6949 |
+
desc: "Don't use width or height when using padding or border.",
|
6950 |
+
browsers: "All",
|
6951 |
+
|
6952 |
+
//initialization
|
6953 |
+
init: function(parser, reporter){
|
6954 |
+
var rule = this,
|
6955 |
+
widthProperties = {
|
6956 |
+
border: 1,
|
6957 |
+
"border-left": 1,
|
6958 |
+
"border-right": 1,
|
6959 |
+
padding: 1,
|
6960 |
+
"padding-left": 1,
|
6961 |
+
"padding-right": 1
|
6962 |
+
},
|
6963 |
+
heightProperties = {
|
6964 |
+
border: 1,
|
6965 |
+
"border-bottom": 1,
|
6966 |
+
"border-top": 1,
|
6967 |
+
padding: 1,
|
6968 |
+
"padding-bottom": 1,
|
6969 |
+
"padding-top": 1
|
6970 |
+
},
|
6971 |
+
properties,
|
6972 |
+
boxSizing = false;
|
6973 |
+
|
6974 |
+
function startRule(){
|
6975 |
+
properties = {};
|
6976 |
+
boxSizing = false;
|
6977 |
+
}
|
6978 |
+
|
6979 |
+
function endRule(){
|
6980 |
+
var prop, value;
|
6981 |
+
|
6982 |
+
if (!boxSizing) {
|
6983 |
+
if (properties.height){
|
6984 |
+
for (prop in heightProperties){
|
6985 |
+
if (heightProperties.hasOwnProperty(prop) && properties[prop]){
|
6986 |
+
value = properties[prop].value;
|
6987 |
+
//special case for padding
|
6988 |
+
if (!(prop == "padding" && value.parts.length === 2 && value.parts[0].value === 0)){
|
6989 |
+
reporter.report("Using height with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
|
6990 |
+
}
|
6991 |
+
}
|
6992 |
+
}
|
6993 |
+
}
|
6994 |
+
|
6995 |
+
if (properties.width){
|
6996 |
+
for (prop in widthProperties){
|
6997 |
+
if (widthProperties.hasOwnProperty(prop) && properties[prop]){
|
6998 |
+
value = properties[prop].value;
|
6999 |
+
|
7000 |
+
if (!(prop == "padding" && value.parts.length === 2 && value.parts[1].value === 0)){
|
7001 |
+
reporter.report("Using width with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
|
7002 |
+
}
|
7003 |
+
}
|
7004 |
+
}
|
7005 |
+
}
|
7006 |
+
}
|
7007 |
+
}
|
7008 |
+
|
7009 |
+
parser.addListener("startrule", startRule);
|
7010 |
+
parser.addListener("startfontface", startRule);
|
7011 |
+
parser.addListener("startpage", startRule);
|
7012 |
+
parser.addListener("startpagemargin", startRule);
|
7013 |
+
parser.addListener("startkeyframerule", startRule);
|
7014 |
+
|
7015 |
+
parser.addListener("property", function(event){
|
7016 |
+
var name = event.property.text.toLowerCase();
|
7017 |
+
|
7018 |
+
if (heightProperties[name] || widthProperties[name]){
|
7019 |
+
if (!/^0\S*$/.test(event.value) && !(name == "border" && event.value == "none")){
|
7020 |
+
properties[name] = { line: event.property.line, col: event.property.col, value: event.value };
|
7021 |
+
}
|
7022 |
+
} else {
|
7023 |
+
if (/^(width|height)/i.test(name) && /^(length|percentage)/.test(event.value.parts[0].type)){
|
7024 |
+
properties[name] = 1;
|
7025 |
+
} else if (name == "box-sizing") {
|
7026 |
+
boxSizing = true;
|
7027 |
+
}
|
7028 |
+
}
|
7029 |
+
|
7030 |
+
});
|
7031 |
+
|
7032 |
+
parser.addListener("endrule", endRule);
|
7033 |
+
parser.addListener("endfontface", endRule);
|
7034 |
+
parser.addListener("endpage", endRule);
|
7035 |
+
parser.addListener("endpagemargin", endRule);
|
7036 |
+
parser.addListener("endkeyframerule", endRule);
|
7037 |
+
}
|
7038 |
+
|
7039 |
+
});
|
7040 |
+
/*global CSSLint*/
|
7041 |
+
|
7042 |
+
/*
|
7043 |
+
* Rule: box-sizing doesn't work in IE6 and IE7.
|
7044 |
+
*/
|
7045 |
+
CSSLint.addRule({
|
7046 |
+
|
7047 |
+
//rule information
|
7048 |
+
id: "box-sizing",
|
7049 |
+
name: "Disallow use of box-sizing",
|
7050 |
+
desc: "The box-sizing properties isn't supported in IE6 and IE7.",
|
7051 |
+
browsers: "IE6, IE7",
|
7052 |
+
tags: ["Compatibility"],
|
7053 |
+
|
7054 |
+
//initialization
|
7055 |
+
init: function(parser, reporter){
|
7056 |
+
var rule = this;
|
7057 |
+
|
7058 |
+
parser.addListener("property", function(event){
|
7059 |
+
var name = event.property.text.toLowerCase();
|
7060 |
+
|
7061 |
+
if (name == "box-sizing"){
|
7062 |
+
reporter.report("The box-sizing property isn't supported in IE6 and IE7.", event.line, event.col, rule);
|
7063 |
+
}
|
7064 |
+
});
|
7065 |
+
}
|
7066 |
+
|
7067 |
+
});
|
7068 |
+
/*
|
7069 |
+
* Rule: Use the bulletproof @font-face syntax to avoid 404's in old IE
|
7070 |
+
* (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax)
|
7071 |
+
*/
|
7072 |
+
/*global CSSLint*/
|
7073 |
+
CSSLint.addRule({
|
7074 |
+
|
7075 |
+
//rule information
|
7076 |
+
id: "bulletproof-font-face",
|
7077 |
+
name: "Use the bulletproof @font-face syntax",
|
7078 |
+
desc: "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",
|
7079 |
+
browsers: "All",
|
7080 |
+
|
7081 |
+
//initialization
|
7082 |
+
init: function(parser, reporter){
|
7083 |
+
var rule = this,
|
7084 |
+
count = 0,
|
7085 |
+
fontFaceRule = false,
|
7086 |
+
firstSrc = true,
|
7087 |
+
ruleFailed = false,
|
7088 |
+
line, col;
|
7089 |
+
|
7090 |
+
// Mark the start of a @font-face declaration so we only test properties inside it
|
7091 |
+
parser.addListener("startfontface", function(event){
|
7092 |
+
fontFaceRule = true;
|
7093 |
+
});
|
7094 |
+
|
7095 |
+
parser.addListener("property", function(event){
|
7096 |
+
// If we aren't inside an @font-face declaration then just return
|
7097 |
+
if (!fontFaceRule) {
|
7098 |
+
return;
|
7099 |
+
}
|
7100 |
+
|
7101 |
+
var propertyName = event.property.toString().toLowerCase(),
|
7102 |
+
value = event.value.toString();
|
7103 |
+
|
7104 |
+
// Set the line and col numbers for use in the endfontface listener
|
7105 |
+
line = event.line;
|
7106 |
+
col = event.col;
|
7107 |
+
|
7108 |
+
// This is the property that we care about, we can ignore the rest
|
7109 |
+
if (propertyName === 'src') {
|
7110 |
+
var regex = /^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;
|
7111 |
+
|
7112 |
+
// We need to handle the advanced syntax with two src properties
|
7113 |
+
if (!value.match(regex) && firstSrc) {
|
7114 |
+
ruleFailed = true;
|
7115 |
+
firstSrc = false;
|
7116 |
+
} else if (value.match(regex) && !firstSrc) {
|
7117 |
+
ruleFailed = false;
|
7118 |
+
}
|
7119 |
+
}
|
7120 |
+
|
7121 |
+
|
7122 |
+
});
|
7123 |
+
|
7124 |
+
// Back to normal rules that we don't need to test
|
7125 |
+
parser.addListener("endfontface", function(event){
|
7126 |
+
fontFaceRule = false;
|
7127 |
+
|
7128 |
+
if (ruleFailed) {
|
7129 |
+
reporter.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.", line, col, rule);
|
7130 |
+
}
|
7131 |
+
});
|
7132 |
+
}
|
7133 |
+
});
|
7134 |
+
/*
|
7135 |
+
* Rule: Include all compatible vendor prefixes to reach a wider
|
7136 |
+
* range of users.
|
7137 |
+
*/
|
7138 |
+
/*global CSSLint*/
|
7139 |
+
CSSLint.addRule({
|
7140 |
+
|
7141 |
+
//rule information
|
7142 |
+
id: "compatible-vendor-prefixes",
|
7143 |
+
name: "Require compatible vendor prefixes",
|
7144 |
+
desc: "Include all compatible vendor prefixes to reach a wider range of users.",
|
7145 |
+
browsers: "All",
|
7146 |
+
|
7147 |
+
//initialization
|
7148 |
+
init: function (parser, reporter) {
|
7149 |
+
var rule = this,
|
7150 |
+
compatiblePrefixes,
|
7151 |
+
properties,
|
7152 |
+
prop,
|
7153 |
+
variations,
|
7154 |
+
prefixed,
|
7155 |
+
i,
|
7156 |
+
len,
|
7157 |
+
inKeyFrame = false,
|
7158 |
+
arrayPush = Array.prototype.push,
|
7159 |
+
applyTo = [];
|
7160 |
+
|
7161 |
+
// See http://peter.sh/experiments/vendor-prefixed-css-property-overview/ for details
|
7162 |
+
compatiblePrefixes = {
|
7163 |
+
"animation" : "webkit moz",
|
7164 |
+
"animation-delay" : "webkit moz",
|
7165 |
+
"animation-direction" : "webkit moz",
|
7166 |
+
"animation-duration" : "webkit moz",
|
7167 |
+
"animation-fill-mode" : "webkit moz",
|
7168 |
+
"animation-iteration-count" : "webkit moz",
|
7169 |
+
"animation-name" : "webkit moz",
|
7170 |
+
"animation-play-state" : "webkit moz",
|
7171 |
+
"animation-timing-function" : "webkit moz",
|
7172 |
+
"appearance" : "webkit moz",
|
7173 |
+
"border-end" : "webkit moz",
|
7174 |
+
"border-end-color" : "webkit moz",
|
7175 |
+
"border-end-style" : "webkit moz",
|
7176 |
+
"border-end-width" : "webkit moz",
|
7177 |
+
"border-image" : "webkit moz o",
|
7178 |
+
"border-radius" : "webkit",
|
7179 |
+
"border-start" : "webkit moz",
|
7180 |
+
"border-start-color" : "webkit moz",
|
7181 |
+
"border-start-style" : "webkit moz",
|
7182 |
+
"border-start-width" : "webkit moz",
|
7183 |
+
"box-align" : "webkit moz ms",
|
7184 |
+
"box-direction" : "webkit moz ms",
|
7185 |
+
"box-flex" : "webkit moz ms",
|
7186 |
+
"box-lines" : "webkit ms",
|
7187 |
+
"box-ordinal-group" : "webkit moz ms",
|
7188 |
+
"box-orient" : "webkit moz ms",
|
7189 |
+
"box-pack" : "webkit moz ms",
|
7190 |
+
"box-sizing" : "webkit moz",
|
7191 |
+
"box-shadow" : "webkit moz",
|
7192 |
+
"column-count" : "webkit moz ms",
|
7193 |
+
"column-gap" : "webkit moz ms",
|
7194 |
+
"column-rule" : "webkit moz ms",
|
7195 |
+
"column-rule-color" : "webkit moz ms",
|
7196 |
+
"column-rule-style" : "webkit moz ms",
|
7197 |
+
"column-rule-width" : "webkit moz ms",
|
7198 |
+
"column-width" : "webkit moz ms",
|
7199 |
+
"hyphens" : "epub moz",
|
7200 |
+
"line-break" : "webkit ms",
|
7201 |
+
"margin-end" : "webkit moz",
|
7202 |
+
"margin-start" : "webkit moz",
|
7203 |
+
"marquee-speed" : "webkit wap",
|
7204 |
+
"marquee-style" : "webkit wap",
|
7205 |
+
"padding-end" : "webkit moz",
|
7206 |
+
"padding-start" : "webkit moz",
|
7207 |
+
"tab-size" : "moz o",
|
7208 |
+
"text-size-adjust" : "webkit ms",
|
7209 |
+
"transform" : "webkit moz ms o",
|
7210 |
+
"transform-origin" : "webkit moz ms o",
|
7211 |
+
"transition" : "webkit moz o",
|
7212 |
+
"transition-delay" : "webkit moz o",
|
7213 |
+
"transition-duration" : "webkit moz o",
|
7214 |
+
"transition-property" : "webkit moz o",
|
7215 |
+
"transition-timing-function" : "webkit moz o",
|
7216 |
+
"user-modify" : "webkit moz",
|
7217 |
+
"user-select" : "webkit moz ms",
|
7218 |
+
"word-break" : "epub ms",
|
7219 |
+
"writing-mode" : "epub ms"
|
7220 |
+
};
|
7221 |
+
|
7222 |
+
|
7223 |
+
for (prop in compatiblePrefixes) {
|
7224 |
+
if (compatiblePrefixes.hasOwnProperty(prop)) {
|
7225 |
+
variations = [];
|
7226 |
+
prefixed = compatiblePrefixes[prop].split(' ');
|
7227 |
+
for (i = 0, len = prefixed.length; i < len; i++) {
|
7228 |
+
variations.push('-' + prefixed[i] + '-' + prop);
|
7229 |
+
}
|
7230 |
+
compatiblePrefixes[prop] = variations;
|
7231 |
+
arrayPush.apply(applyTo, variations);
|
7232 |
+
}
|
7233 |
+
}
|
7234 |
+
|
7235 |
+
parser.addListener("startrule", function () {
|
7236 |
+
properties = [];
|
7237 |
+
});
|
7238 |
+
|
7239 |
+
parser.addListener("startkeyframes", function (event) {
|
7240 |
+
inKeyFrame = event.prefix || true;
|
7241 |
+
});
|
7242 |
+
|
7243 |
+
parser.addListener("endkeyframes", function (event) {
|
7244 |
+
inKeyFrame = false;
|
7245 |
+
});
|
7246 |
+
|
7247 |
+
parser.addListener("property", function (event) {
|
7248 |
+
var name = event.property;
|
7249 |
+
if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
|
7250 |
+
|
7251 |
+
// e.g., -moz-transform is okay to be alone in @-moz-keyframes
|
7252 |
+
if (!inKeyFrame || typeof inKeyFrame != "string" ||
|
7253 |
+
name.text.indexOf("-" + inKeyFrame + "-") !== 0) {
|
7254 |
+
properties.push(name);
|
7255 |
+
}
|
7256 |
+
}
|
7257 |
+
});
|
7258 |
+
|
7259 |
+
parser.addListener("endrule", function (event) {
|
7260 |
+
if (!properties.length) {
|
7261 |
+
return;
|
7262 |
+
}
|
7263 |
+
|
7264 |
+
var propertyGroups = {},
|
7265 |
+
i,
|
7266 |
+
len,
|
7267 |
+
name,
|
7268 |
+
prop,
|
7269 |
+
variations,
|
7270 |
+
value,
|
7271 |
+
full,
|
7272 |
+
actual,
|
7273 |
+
item,
|
7274 |
+
propertiesSpecified;
|
7275 |
+
|
7276 |
+
for (i = 0, len = properties.length; i < len; i++) {
|
7277 |
+
name = properties[i];
|
7278 |
+
|
7279 |
+
for (prop in compatiblePrefixes) {
|
7280 |
+
if (compatiblePrefixes.hasOwnProperty(prop)) {
|
7281 |
+
variations = compatiblePrefixes[prop];
|
7282 |
+
if (CSSLint.Util.indexOf(variations, name.text) > -1) {
|
7283 |
+
if (!propertyGroups[prop]) {
|
7284 |
+
propertyGroups[prop] = {
|
7285 |
+
full : variations.slice(0),
|
7286 |
+
actual : [],
|
7287 |
+
actualNodes: []
|
7288 |
+
};
|
7289 |
+
}
|
7290 |
+
if (CSSLint.Util.indexOf(propertyGroups[prop].actual, name.text) === -1) {
|
7291 |
+
propertyGroups[prop].actual.push(name.text);
|
7292 |
+
propertyGroups[prop].actualNodes.push(name);
|
7293 |
+
}
|
7294 |
+
}
|
7295 |
+
}
|
7296 |
+
}
|
7297 |
+
}
|
7298 |
+
|
7299 |
+
for (prop in propertyGroups) {
|
7300 |
+
if (propertyGroups.hasOwnProperty(prop)) {
|
7301 |
+
value = propertyGroups[prop];
|
7302 |
+
full = value.full;
|
7303 |
+
actual = value.actual;
|
7304 |
+
|
7305 |
+
if (full.length > actual.length) {
|
7306 |
+
for (i = 0, len = full.length; i < len; i++) {
|
7307 |
+
item = full[i];
|
7308 |
+
if (CSSLint.Util.indexOf(actual, item) === -1) {
|
7309 |
+
propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length == 2) ? actual.join(" and ") : actual.join(", ");
|
7310 |
+
reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
|
7311 |
+
}
|
7312 |
+
}
|
7313 |
+
|
7314 |
+
}
|
7315 |
+
}
|
7316 |
+
}
|
7317 |
+
});
|
7318 |
+
}
|
7319 |
+
});
|
7320 |
+
/*
|
7321 |
+
* Rule: Certain properties don't play well with certain display values.
|
7322 |
+
* - float should not be used with inline-block
|
7323 |
+
* - height, width, margin-top, margin-bottom, float should not be used with inline
|
7324 |
+
* - vertical-align should not be used with block
|
7325 |
+
* - margin, float should not be used with table-*
|
7326 |
+
*/
|
7327 |
+
/*global CSSLint*/
|
7328 |
+
CSSLint.addRule({
|
7329 |
+
|
7330 |
+
//rule information
|
7331 |
+
id: "display-property-grouping",
|
7332 |
+
name: "Require properties appropriate for display",
|
7333 |
+
desc: "Certain properties shouldn't be used with certain display property values.",
|
7334 |
+
browsers: "All",
|
7335 |
+
|
7336 |
+
//initialization
|
7337 |
+
init: function(parser, reporter){
|
7338 |
+
var rule = this;
|
7339 |
+
|
7340 |
+
var propertiesToCheck = {
|
7341 |
+
display: 1,
|
7342 |
+
"float": "none",
|
7343 |
+
height: 1,
|
7344 |
+
width: 1,
|
7345 |
+
margin: 1,
|
7346 |
+
"margin-left": 1,
|
7347 |
+
"margin-right": 1,
|
7348 |
+
"margin-bottom": 1,
|
7349 |
+
"margin-top": 1,
|
7350 |
+
padding: 1,
|
7351 |
+
"padding-left": 1,
|
7352 |
+
"padding-right": 1,
|
7353 |
+
"padding-bottom": 1,
|
7354 |
+
"padding-top": 1,
|
7355 |
+
"vertical-align": 1
|
7356 |
+
},
|
7357 |
+
properties;
|
7358 |
+
|
7359 |
+
function reportProperty(name, display, msg){
|
7360 |
+
if (properties[name]){
|
7361 |
+
if (typeof propertiesToCheck[name] != "string" || properties[name].value.toLowerCase() != propertiesToCheck[name]){
|
7362 |
+
reporter.report(msg || name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
|
7363 |
+
}
|
7364 |
+
}
|
7365 |
+
}
|
7366 |
+
|
7367 |
+
function startRule(){
|
7368 |
+
properties = {};
|
7369 |
+
}
|
7370 |
+
|
7371 |
+
function endRule(){
|
7372 |
+
|
7373 |
+
var display = properties.display ? properties.display.value : null;
|
7374 |
+
if (display){
|
7375 |
+
switch(display){
|
7376 |
+
|
7377 |
+
case "inline":
|
7378 |
+
//height, width, margin-top, margin-bottom, float should not be used with inline
|
7379 |
+
reportProperty("height", display);
|
7380 |
+
reportProperty("width", display);
|
7381 |
+
reportProperty("margin", display);
|
7382 |
+
reportProperty("margin-top", display);
|
7383 |
+
reportProperty("margin-bottom", display);
|
7384 |
+
reportProperty("float", display, "display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");
|
7385 |
+
break;
|
7386 |
+
|
7387 |
+
case "block":
|
7388 |
+
//vertical-align should not be used with block
|
7389 |
+
reportProperty("vertical-align", display);
|
7390 |
+
break;
|
7391 |
+
|
7392 |
+
case "inline-block":
|
7393 |
+
//float should not be used with inline-block
|
7394 |
+
reportProperty("float", display);
|
7395 |
+
break;
|
7396 |
+
|
7397 |
+
default:
|
7398 |
+
//margin, float should not be used with table
|
7399 |
+
if (display.indexOf("table-") === 0){
|
7400 |
+
reportProperty("margin", display);
|
7401 |
+
reportProperty("margin-left", display);
|
7402 |
+
reportProperty("margin-right", display);
|
7403 |
+
reportProperty("margin-top", display);
|
7404 |
+
reportProperty("margin-bottom", display);
|
7405 |
+
reportProperty("float", display);
|
7406 |
+
}
|
7407 |
+
|
7408 |
+
//otherwise do nothing
|
7409 |
+
}
|
7410 |
+
}
|
7411 |
+
|
7412 |
+
}
|
7413 |
+
|
7414 |
+
parser.addListener("startrule", startRule);
|
7415 |
+
parser.addListener("startfontface", startRule);
|
7416 |
+
parser.addListener("startkeyframerule", startRule);
|
7417 |
+
parser.addListener("startpagemargin", startRule);
|
7418 |
+
parser.addListener("startpage", startRule);
|
7419 |
+
|
7420 |
+
parser.addListener("property", function(event){
|
7421 |
+
var name = event.property.text.toLowerCase();
|
7422 |
+
|
7423 |
+
if (propertiesToCheck[name]){
|
7424 |
+
properties[name] = { value: event.value.text, line: event.property.line, col: event.property.col };
|
7425 |
+
}
|
7426 |
+
});
|
7427 |
+
|
7428 |
+
parser.addListener("endrule", endRule);
|
7429 |
+
parser.addListener("endfontface", endRule);
|
7430 |
+
parser.addListener("endkeyframerule", endRule);
|
7431 |
+
parser.addListener("endpagemargin", endRule);
|
7432 |
+
parser.addListener("endpage", endRule);
|
7433 |
+
|
7434 |
+
}
|
7435 |
+
|
7436 |
+
});
|
7437 |
+
/*
|
7438 |
+
* Rule: Disallow duplicate background-images (using url).
|
7439 |
+
*/
|
7440 |
+
/*global CSSLint*/
|
7441 |
+
CSSLint.addRule({
|
7442 |
+
|
7443 |
+
//rule information
|
7444 |
+
id: "duplicate-background-images",
|
7445 |
+
name: "Disallow duplicate background images",
|
7446 |
+
desc: "Every background-image should be unique. Use a common class for e.g. sprites.",
|
7447 |
+
browsers: "All",
|
7448 |
+
|
7449 |
+
//initialization
|
7450 |
+
init: function(parser, reporter){
|
7451 |
+
var rule = this,
|
7452 |
+
stack = {};
|
7453 |
+
|
7454 |
+
parser.addListener("property", function(event){
|
7455 |
+
var name = event.property.text,
|
7456 |
+
value = event.value,
|
7457 |
+
i, len;
|
7458 |
+
|
7459 |
+
if (name.match(/background/i)) {
|
7460 |
+
for (i=0, len=value.parts.length; i < len; i++) {
|
7461 |
+
if (value.parts[i].type == 'uri') {
|
7462 |
+
if (typeof stack[value.parts[i].uri] === 'undefined') {
|
7463 |
+
stack[value.parts[i].uri] = event;
|
7464 |
+
}
|
7465 |
+
else {
|
7466 |
+
reporter.report("Background image '" + value.parts[i].uri + "' was used multiple times, first declared at line " + stack[value.parts[i].uri].line + ", col " + stack[value.parts[i].uri].col + ".", event.line, event.col, rule);
|
7467 |
+
}
|
7468 |
+
}
|
7469 |
+
}
|
7470 |
+
}
|
7471 |
+
});
|
7472 |
+
}
|
7473 |
+
});
|
7474 |
+
/*
|
7475 |
+
* Rule: Duplicate properties must appear one after the other. If an already-defined
|
7476 |
+
* property appears somewhere else in the rule, then it's likely an error.
|
7477 |
+
*/
|
7478 |
+
/*global CSSLint*/
|
7479 |
+
CSSLint.addRule({
|
7480 |
+
|
7481 |
+
//rule information
|
7482 |
+
id: "duplicate-properties",
|
7483 |
+
name: "Disallow duplicate properties",
|
7484 |
+
desc: "Duplicate properties must appear one after the other.",
|
7485 |
+
browsers: "All",
|
7486 |
+
|
7487 |
+
//initialization
|
7488 |
+
init: function(parser, reporter){
|
7489 |
+
var rule = this,
|
7490 |
+
properties,
|
7491 |
+
lastProperty;
|
7492 |
+
|
7493 |
+
function startRule(event){
|
7494 |
+
properties = {};
|
7495 |
+
}
|
7496 |
+
|
7497 |
+
parser.addListener("startrule", startRule);
|
7498 |
+
parser.addListener("startfontface", startRule);
|
7499 |
+
parser.addListener("startpage", startRule);
|
7500 |
+
parser.addListener("startpagemargin", startRule);
|
7501 |
+
parser.addListener("startkeyframerule", startRule);
|
7502 |
+
|
7503 |
+
parser.addListener("property", function(event){
|
7504 |
+
var property = event.property,
|
7505 |
+
name = property.text.toLowerCase();
|
7506 |
+
|
7507 |
+
if (properties[name] && (lastProperty != name || properties[name] == event.value.text)){
|
7508 |
+
reporter.report("Duplicate property '" + event.property + "' found.", event.line, event.col, rule);
|
7509 |
+
}
|
7510 |
+
|
7511 |
+
properties[name] = event.value.text;
|
7512 |
+
lastProperty = name;
|
7513 |
+
|
7514 |
+
});
|
7515 |
+
|
7516 |
+
|
7517 |
+
}
|
7518 |
+
|
7519 |
+
});
|
7520 |
+
/*
|
7521 |
+
* Rule: Style rules without any properties defined should be removed.
|
7522 |
+
*/
|
7523 |
+
/*global CSSLint*/
|
7524 |
+
CSSLint.addRule({
|
7525 |
+
|
7526 |
+
//rule information
|
7527 |
+
id: "empty-rules",
|
7528 |
+
name: "Disallow empty rules",
|
7529 |
+
desc: "Rules without any properties specified should be removed.",
|
7530 |
+
browsers: "All",
|
7531 |
+
|
7532 |
+
//initialization
|
7533 |
+
init: function(parser, reporter){
|
7534 |
+
var rule = this,
|
7535 |
+
count = 0;
|
7536 |
+
|
7537 |
+
parser.addListener("startrule", function(){
|
7538 |
+
count=0;
|
7539 |
+
});
|
7540 |
+
|
7541 |
+
parser.addListener("property", function(){
|
7542 |
+
count++;
|
7543 |
+
});
|
7544 |
+
|
7545 |
+
parser.addListener("endrule", function(event){
|
7546 |
+
var selectors = event.selectors;
|
7547 |
+
if (count === 0){
|
7548 |
+
reporter.report("Rule is empty.", selectors[0].line, selectors[0].col, rule);
|
7549 |
+
}
|
7550 |
+
});
|
7551 |
+
}
|
7552 |
+
|
7553 |
+
});
|
7554 |
+
/*
|
7555 |
+
* Rule: There should be no syntax errors. (Duh.)
|
7556 |
+
*/
|
7557 |
+
/*global CSSLint*/
|
7558 |
+
CSSLint.addRule({
|
7559 |
+
|
7560 |
+
//rule information
|
7561 |
+
id: "errors",
|
7562 |
+
name: "Parsing Errors",
|
7563 |
+
desc: "This rule looks for recoverable syntax errors.",
|
7564 |
+
browsers: "All",
|
7565 |
+
|
7566 |
+
//initialization
|
7567 |
+
init: function(parser, reporter){
|
7568 |
+
var rule = this;
|
7569 |
+
|
7570 |
+
parser.addListener("error", function(event){
|
7571 |
+
reporter.error(event.message, event.line, event.col, rule);
|
7572 |
+
});
|
7573 |
+
|
7574 |
+
}
|
7575 |
+
|
7576 |
+
});
|
7577 |
+
|
7578 |
+
/*global CSSLint*/
|
7579 |
+
CSSLint.addRule({
|
7580 |
+
|
7581 |
+
//rule information
|
7582 |
+
id: "fallback-colors",
|
7583 |
+
name: "Require fallback colors",
|
7584 |
+
desc: "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.",
|
7585 |
+
browsers: "IE6,IE7,IE8",
|
7586 |
+
|
7587 |
+
//initialization
|
7588 |
+
init: function(parser, reporter){
|
7589 |
+
var rule = this,
|
7590 |
+
lastProperty,
|
7591 |
+
propertiesToCheck = {
|
7592 |
+
color: 1,
|
7593 |
+
background: 1,
|
7594 |
+
"border-color": 1,
|
7595 |
+
"border-top-color": 1,
|
7596 |
+
"border-right-color": 1,
|
7597 |
+
"border-bottom-color": 1,
|
7598 |
+
"border-left-color": 1,
|
7599 |
+
border: 1,
|
7600 |
+
"border-top": 1,
|
7601 |
+
"border-right": 1,
|
7602 |
+
"border-bottom": 1,
|
7603 |
+
"border-left": 1,
|
7604 |
+
"background-color": 1
|
7605 |
+
},
|
7606 |
+
properties;
|
7607 |
+
|
7608 |
+
function startRule(event){
|
7609 |
+
properties = {};
|
7610 |
+
lastProperty = null;
|
7611 |
+
}
|
7612 |
+
|
7613 |
+
parser.addListener("startrule", startRule);
|
7614 |
+
parser.addListener("startfontface", startRule);
|
7615 |
+
parser.addListener("startpage", startRule);
|
7616 |
+
parser.addListener("startpagemargin", startRule);
|
7617 |
+
parser.addListener("startkeyframerule", startRule);
|
7618 |
+
|
7619 |
+
parser.addListener("property", function(event){
|
7620 |
+
var property = event.property,
|
7621 |
+
name = property.text.toLowerCase(),
|
7622 |
+
parts = event.value.parts,
|
7623 |
+
i = 0,
|
7624 |
+
colorType = "",
|
7625 |
+
len = parts.length;
|
7626 |
+
|
7627 |
+
if(propertiesToCheck[name]){
|
7628 |
+
while(i < len){
|
7629 |
+
if (parts[i].type == "color"){
|
7630 |
+
if ("alpha" in parts[i] || "hue" in parts[i]){
|
7631 |
+
|
7632 |
+
if (/([^\)]+)\(/.test(parts[i])){
|
7633 |
+
colorType = RegExp.$1.toUpperCase();
|
7634 |
+
}
|
7635 |
+
|
7636 |
+
if (!lastProperty || (lastProperty.property.text.toLowerCase() != name || lastProperty.colorType != "compat")){
|
7637 |
+
reporter.report("Fallback " + name + " (hex or RGB) should precede " + colorType + " " + name + ".", event.line, event.col, rule);
|
7638 |
+
}
|
7639 |
+
} else {
|
7640 |
+
event.colorType = "compat";
|
7641 |
+
}
|
7642 |
+
}
|
7643 |
+
|
7644 |
+
i++;
|
7645 |
+
}
|
7646 |
+
}
|
7647 |
+
|
7648 |
+
lastProperty = event;
|
7649 |
+
});
|
7650 |
+
|
7651 |
+
}
|
7652 |
+
|
7653 |
+
});
|
7654 |
+
/*
|
7655 |
+
* Rule: You shouldn't use more than 10 floats. If you do, there's probably
|
7656 |
+
* room for some abstraction.
|
7657 |
+
*/
|
7658 |
+
/*global CSSLint*/
|
7659 |
+
CSSLint.addRule({
|
7660 |
+
|
7661 |
+
//rule information
|
7662 |
+
id: "floats",
|
7663 |
+
name: "Disallow too many floats",
|
7664 |
+
desc: "This rule tests if the float property is used too many times",
|
7665 |
+
browsers: "All",
|
7666 |
+
|
7667 |
+
//initialization
|
7668 |
+
init: function(parser, reporter){
|
7669 |
+
var rule = this;
|
7670 |
+
var count = 0;
|
7671 |
+
|
7672 |
+
//count how many times "float" is used
|
7673 |
+
parser.addListener("property", function(event){
|
7674 |
+
if (event.property.text.toLowerCase() == "float" &&
|
7675 |
+
event.value.text.toLowerCase() != "none"){
|
7676 |
+
count++;
|
7677 |
+
}
|
7678 |
+
});
|
7679 |
+
|
7680 |
+
//report the results
|
7681 |
+
parser.addListener("endstylesheet", function(){
|
7682 |
+
reporter.stat("floats", count);
|
7683 |
+
if (count >= 10){
|
7684 |
+
reporter.rollupWarn("Too many floats (" + count + "), you're probably using them for layout. Consider using a grid system instead.", rule);
|
7685 |
+
}
|
7686 |
+
});
|
7687 |
+
}
|
7688 |
+
|
7689 |
+
});
|
7690 |
+
/*
|
7691 |
+
* Rule: Avoid too many @font-face declarations in the same stylesheet.
|
7692 |
+
*/
|
7693 |
+
/*global CSSLint*/
|
7694 |
+
CSSLint.addRule({
|
7695 |
+
|
7696 |
+
//rule information
|
7697 |
+
id: "font-faces",
|
7698 |
+
name: "Don't use too many web fonts",
|
7699 |
+
desc: "Too many different web fonts in the same stylesheet.",
|
7700 |
+
browsers: "All",
|
7701 |
+
|
7702 |
+
//initialization
|
7703 |
+
init: function(parser, reporter){
|
7704 |
+
var rule = this,
|
7705 |
+
count = 0;
|
7706 |
+
|
7707 |
+
|
7708 |
+
parser.addListener("startfontface", function(){
|
7709 |
+
count++;
|
7710 |
+
});
|
7711 |
+
|
7712 |
+
parser.addListener("endstylesheet", function(){
|
7713 |
+
if (count > 5){
|
7714 |
+
reporter.rollupWarn("Too many @font-face declarations (" + count + ").", rule);
|
7715 |
+
}
|
7716 |
+
});
|
7717 |
+
}
|
7718 |
+
|
7719 |
+
});
|
7720 |
+
/*
|
7721 |
+
* Rule: You shouldn't need more than 9 font-size declarations.
|
7722 |
+
*/
|
7723 |
+
|
7724 |
+
/*global CSSLint*/
|
7725 |
+
CSSLint.addRule({
|
7726 |
+
|
7727 |
+
//rule information
|
7728 |
+
id: "font-sizes",
|
7729 |
+
name: "Disallow too many font sizes",
|
7730 |
+
desc: "Checks the number of font-size declarations.",
|
7731 |
+
browsers: "All",
|
7732 |
+
|
7733 |
+
//initialization
|
7734 |
+
init: function(parser, reporter){
|
7735 |
+
var rule = this,
|
7736 |
+
count = 0;
|
7737 |
+
|
7738 |
+
//check for use of "font-size"
|
7739 |
+
parser.addListener("property", function(event){
|
7740 |
+
if (event.property == "font-size"){
|
7741 |
+
count++;
|
7742 |
+
}
|
7743 |
+
});
|
7744 |
+
|
7745 |
+
//report the results
|
7746 |
+
parser.addListener("endstylesheet", function(){
|
7747 |
+
reporter.stat("font-sizes", count);
|
7748 |
+
if (count >= 10){
|
7749 |
+
reporter.rollupWarn("Too many font-size declarations (" + count + "), abstraction needed.", rule);
|
7750 |
+
}
|
7751 |
+
});
|
7752 |
+
}
|
7753 |
+
|
7754 |
+
});
|
7755 |
+
/*
|
7756 |
+
* Rule: When using a vendor-prefixed gradient, make sure to use them all.
|
7757 |
+
*/
|
7758 |
+
/*global CSSLint*/
|
7759 |
+
CSSLint.addRule({
|
7760 |
+
|
7761 |
+
//rule information
|
7762 |
+
id: "gradients",
|
7763 |
+
name: "Require all gradient definitions",
|
7764 |
+
desc: "When using a vendor-prefixed gradient, make sure to use them all.",
|
7765 |
+
browsers: "All",
|
7766 |
+
|
7767 |
+
//initialization
|
7768 |
+
init: function(parser, reporter){
|
7769 |
+
var rule = this,
|
7770 |
+
gradients;
|
7771 |
+
|
7772 |
+
parser.addListener("startrule", function(){
|
7773 |
+
gradients = {
|
7774 |
+
moz: 0,
|
7775 |
+
webkit: 0,
|
7776 |
+
oldWebkit: 0,
|
7777 |
+
o: 0
|
7778 |
+
};
|
7779 |
+
});
|
7780 |
+
|
7781 |
+
parser.addListener("property", function(event){
|
7782 |
+
|
7783 |
+
if (/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)){
|
7784 |
+
gradients[RegExp.$1] = 1;
|
7785 |
+
} else if (/\-webkit\-gradient/i.test(event.value)){
|
7786 |
+
gradients.oldWebkit = 1;
|
7787 |
+
}
|
7788 |
+
|
7789 |
+
});
|
7790 |
+
|
7791 |
+
parser.addListener("endrule", function(event){
|
7792 |
+
var missing = [];
|
7793 |
+
|
7794 |
+
if (!gradients.moz){
|
7795 |
+
missing.push("Firefox 3.6+");
|
7796 |
+
}
|
7797 |
+
|
7798 |
+
if (!gradients.webkit){
|
7799 |
+
missing.push("Webkit (Safari 5+, Chrome)");
|
7800 |
+
}
|
7801 |
+
|
7802 |
+
if (!gradients.oldWebkit){
|
7803 |
+
missing.push("Old Webkit (Safari 4+, Chrome)");
|
7804 |
+
}
|
7805 |
+
|
7806 |
+
if (!gradients.o){
|
7807 |
+
missing.push("Opera 11.1+");
|
7808 |
+
}
|
7809 |
+
|
7810 |
+
if (missing.length && missing.length < 4){
|
7811 |
+
reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
|
7812 |
+
}
|
7813 |
+
|
7814 |
+
});
|
7815 |
+
|
7816 |
+
}
|
7817 |
+
|
7818 |
+
});
|
7819 |
+
|
7820 |
+
/*
|
7821 |
+
* Rule: Don't use IDs for selectors.
|
7822 |
+
*/
|
7823 |
+
/*global CSSLint*/
|
7824 |
+
CSSLint.addRule({
|
7825 |
+
|
7826 |
+
//rule information
|
7827 |
+
id: "ids",
|
7828 |
+
name: "Disallow IDs in selectors",
|
7829 |
+
desc: "Selectors should not contain IDs.",
|
7830 |
+
browsers: "All",
|
7831 |
+
|
7832 |
+
//initialization
|
7833 |
+
init: function(parser, reporter){
|
7834 |
+
var rule = this;
|
7835 |
+
parser.addListener("startrule", function(event){
|
7836 |
+
var selectors = event.selectors,
|
7837 |
+
selector,
|
7838 |
+
part,
|
7839 |
+
modifier,
|
7840 |
+
idCount,
|
7841 |
+
i, j, k;
|
7842 |
+
|
7843 |
+
for (i=0; i < selectors.length; i++){
|
7844 |
+
selector = selectors[i];
|
7845 |
+
idCount = 0;
|
7846 |
+
|
7847 |
+
for (j=0; j < selector.parts.length; j++){
|
7848 |
+
part = selector.parts[j];
|
7849 |
+
if (part.type == parser.SELECTOR_PART_TYPE){
|
7850 |
+
for (k=0; k < part.modifiers.length; k++){
|
7851 |
+
modifier = part.modifiers[k];
|
7852 |
+
if (modifier.type == "id"){
|
7853 |
+
idCount++;
|
7854 |
+
}
|
7855 |
+
}
|
7856 |
+
}
|
7857 |
+
}
|
7858 |
+
|
7859 |
+
if (idCount == 1){
|
7860 |
+
reporter.report("Don't use IDs in selectors.", selector.line, selector.col, rule);
|
7861 |
+
} else if (idCount > 1){
|
7862 |
+
reporter.report(idCount + " IDs in the selector, really?", selector.line, selector.col, rule);
|
7863 |
+
}
|
7864 |
+
}
|
7865 |
+
|
7866 |
+
});
|
7867 |
+
}
|
7868 |
+
|
7869 |
+
});
|
7870 |
+
/*
|
7871 |
+
* Rule: Don't use @import, use <link> instead.
|
7872 |
+
*/
|
7873 |
+
/*global CSSLint*/
|
7874 |
+
CSSLint.addRule({
|
7875 |
+
|
7876 |
+
//rule information
|
7877 |
+
id: "import",
|
7878 |
+
name: "Disallow @import",
|
7879 |
+
desc: "Don't use @import, use <link> instead.",
|
7880 |
+
browsers: "All",
|
7881 |
+
|
7882 |
+
//initialization
|
7883 |
+
init: function(parser, reporter){
|
7884 |
+
var rule = this;
|
7885 |
+
|
7886 |
+
parser.addListener("import", function(event){
|
7887 |
+
reporter.report("@import prevents parallel downloads, use <link> instead.", event.line, event.col, rule);
|
7888 |
+
});
|
7889 |
+
|
7890 |
+
}
|
7891 |
+
|
7892 |
+
});
|
7893 |
+
/*
|
7894 |
+
* Rule: Make sure !important is not overused, this could lead to specificity
|
7895 |
+
* war. Display a warning on !important declarations, an error if it's
|
7896 |
+
* used more at least 10 times.
|
7897 |
+
*/
|
7898 |
+
/*global CSSLint*/
|
7899 |
+
CSSLint.addRule({
|
7900 |
+
|
7901 |
+
//rule information
|
7902 |
+
id: "important",
|
7903 |
+
name: "Disallow !important",
|
7904 |
+
desc: "Be careful when using !important declaration",
|
7905 |
+
browsers: "All",
|
7906 |
+
|
7907 |
+
//initialization
|
7908 |
+
init: function(parser, reporter){
|
7909 |
+
var rule = this,
|
7910 |
+
count = 0;
|
7911 |
+
|
7912 |
+
//warn that important is used and increment the declaration counter
|
7913 |
+
parser.addListener("property", function(event){
|
7914 |
+
if (event.important === true){
|
7915 |
+
count++;
|
7916 |
+
reporter.report("Use of !important", event.line, event.col, rule);
|
7917 |
+
}
|
7918 |
+
});
|
7919 |
+
|
7920 |
+
//if there are more than 10, show an error
|
7921 |
+
parser.addListener("endstylesheet", function(){
|
7922 |
+
reporter.stat("important", count);
|
7923 |
+
if (count >= 10){
|
7924 |
+
reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
|
7925 |
+
}
|
7926 |
+
});
|
7927 |
+
}
|
7928 |
+
|
7929 |
+
});
|
7930 |
+
/*
|
7931 |
+
* Rule: Properties should be known (listed in CSS3 specification) or
|
7932 |
+
* be a vendor-prefixed property.
|
7933 |
+
*/
|
7934 |
+
/*global CSSLint*/
|
7935 |
+
CSSLint.addRule({
|
7936 |
+
|
7937 |
+
//rule information
|
7938 |
+
id: "known-properties",
|
7939 |
+
name: "Require use of known properties",
|
7940 |
+
desc: "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",
|
7941 |
+
browsers: "All",
|
7942 |
+
|
7943 |
+
//initialization
|
7944 |
+
init: function(parser, reporter){
|
7945 |
+
var rule = this;
|
7946 |
+
|
7947 |
+
parser.addListener("property", function(event){
|
7948 |
+
var name = event.property.text.toLowerCase();
|
7949 |
+
|
7950 |
+
// the check is handled entirely by the parser-lib (https://github.com/nzakas/parser-lib)
|
7951 |
+
if (event.invalid) {
|
7952 |
+
reporter.report(event.invalid.message, event.line, event.col, rule);
|
7953 |
+
}
|
7954 |
+
|
7955 |
+
});
|
7956 |
+
}
|
7957 |
+
|
7958 |
+
});
|
7959 |
+
/*
|
7960 |
+
* Rule: outline: none or outline: 0 should only be used in a :focus rule
|
7961 |
+
* and only if there are other properties in the same rule.
|
7962 |
+
*/
|
7963 |
+
/*global CSSLint*/
|
7964 |
+
CSSLint.addRule({
|
7965 |
+
|
7966 |
+
//rule information
|
7967 |
+
id: "outline-none",
|
7968 |
+
name: "Disallow outline: none",
|
7969 |
+
desc: "Use of outline: none or outline: 0 should be limited to :focus rules.",
|
7970 |
+
browsers: "All",
|
7971 |
+
tags: ["Accessibility"],
|
7972 |
+
|
7973 |
+
//initialization
|
7974 |
+
init: function(parser, reporter){
|
7975 |
+
var rule = this,
|
7976 |
+
lastRule;
|
7977 |
+
|
7978 |
+
function startRule(event){
|
7979 |
+
if (event.selectors){
|
7980 |
+
lastRule = {
|
7981 |
+
line: event.line,
|
7982 |
+
col: event.col,
|
7983 |
+
selectors: event.selectors,
|
7984 |
+
propCount: 0,
|
7985 |
+
outline: false
|
7986 |
+
};
|
7987 |
+
} else {
|
7988 |
+
lastRule = null;
|
7989 |
+
}
|
7990 |
+
}
|
7991 |
+
|
7992 |
+
function endRule(event){
|
7993 |
+
if (lastRule){
|
7994 |
+
if (lastRule.outline){
|
7995 |
+
if (lastRule.selectors.toString().toLowerCase().indexOf(":focus") == -1){
|
7996 |
+
reporter.report("Outlines should only be modified using :focus.", lastRule.line, lastRule.col, rule);
|
7997 |
+
} else if (lastRule.propCount == 1) {
|
7998 |
+
reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
|
7999 |
+
}
|
8000 |
+
}
|
8001 |
+
}
|
8002 |
+
}
|
8003 |
+
|
8004 |
+
parser.addListener("startrule", startRule);
|
8005 |
+
parser.addListener("startfontface", startRule);
|
8006 |
+
parser.addListener("startpage", startRule);
|
8007 |
+
parser.addListener("startpagemargin", startRule);
|
8008 |
+
parser.addListener("startkeyframerule", startRule);
|
8009 |
+
|
8010 |
+
parser.addListener("property", function(event){
|
8011 |
+
var name = event.property.text.toLowerCase(),
|
8012 |
+
value = event.value;
|
8013 |
+
|
8014 |
+
if (lastRule){
|
8015 |
+
lastRule.propCount++;
|
8016 |
+
if (name == "outline" && (value == "none" || value == "0")){
|
8017 |
+
lastRule.outline = true;
|
8018 |
+
}
|
8019 |
+
}
|
8020 |
+
|
8021 |
+
});
|
8022 |
+
|
8023 |
+
parser.addListener("endrule", endRule);
|
8024 |
+
parser.addListener("endfontface", endRule);
|
8025 |
+
parser.addListener("endpage", endRule);
|
8026 |
+
parser.addListener("endpagemargin", endRule);
|
8027 |
+
parser.addListener("endkeyframerule", endRule);
|
8028 |
+
|
8029 |
+
}
|
8030 |
+
|
8031 |
+
});
|
8032 |
+
/*
|
8033 |
+
* Rule: Don't use classes or IDs with elements (a.foo or a#foo).
|
8034 |
+
*/
|
8035 |
+
/*global CSSLint*/
|
8036 |
+
CSSLint.addRule({
|
8037 |
+
|
8038 |
+
//rule information
|
8039 |
+
id: "overqualified-elements",
|
8040 |
+
name: "Disallow overqualified elements",
|
8041 |
+
desc: "Don't use classes or IDs with elements (a.foo or a#foo).",
|
8042 |
+
browsers: "All",
|
8043 |
+
|
8044 |
+
//initialization
|
8045 |
+
init: function(parser, reporter){
|
8046 |
+
var rule = this,
|
8047 |
+
classes = {};
|
8048 |
+
|
8049 |
+
parser.addListener("startrule", function(event){
|
8050 |
+
var selectors = event.selectors,
|
8051 |
+
selector,
|
8052 |
+
part,
|
8053 |
+
modifier,
|
8054 |
+
i, j, k;
|
8055 |
+
|
8056 |
+
for (i=0; i < selectors.length; i++){
|
8057 |
+
selector = selectors[i];
|
8058 |
+
|
8059 |
+
for (j=0; j < selector.parts.length; j++){
|
8060 |
+
part = selector.parts[j];
|
8061 |
+
if (part.type == parser.SELECTOR_PART_TYPE){
|
8062 |
+
for (k=0; k < part.modifiers.length; k++){
|
8063 |
+
modifier = part.modifiers[k];
|
8064 |
+
if (part.elementName && modifier.type == "id"){
|
8065 |
+
reporter.report("Element (" + part + ") is overqualified, just use " + modifier + " without element name.", part.line, part.col, rule);
|
8066 |
+
} else if (modifier.type == "class"){
|
8067 |
+
|
8068 |
+
if (!classes[modifier]){
|
8069 |
+
classes[modifier] = [];
|
8070 |
+
}
|
8071 |
+
classes[modifier].push({ modifier: modifier, part: part });
|
8072 |
+
}
|
8073 |
+
}
|
8074 |
+
}
|
8075 |
+
}
|
8076 |
+
}
|
8077 |
+
});
|
8078 |
+
|
8079 |
+
parser.addListener("endstylesheet", function(){
|
8080 |
+
|
8081 |
+
var prop;
|
8082 |
+
for (prop in classes){
|
8083 |
+
if (classes.hasOwnProperty(prop)){
|
8084 |
+
|
8085 |
+
//one use means that this is overqualified
|
8086 |
+
if (classes[prop].length == 1 && classes[prop][0].part.elementName){
|
8087 |
+
reporter.report("Element (" + classes[prop][0].part + ") is overqualified, just use " + classes[prop][0].modifier + " without element name.", classes[prop][0].part.line, classes[prop][0].part.col, rule);
|
8088 |
+
}
|
8089 |
+
}
|
8090 |
+
}
|
8091 |
+
});
|
8092 |
+
}
|
8093 |
+
|
8094 |
+
});
|
8095 |
+
/*
|
8096 |
+
* Rule: Headings (h1-h6) should not be qualified (namespaced).
|
8097 |
+
*/
|
8098 |
+
/*global CSSLint*/
|
8099 |
+
CSSLint.addRule({
|
8100 |
+
|
8101 |
+
//rule information
|
8102 |
+
id: "qualified-headings",
|
8103 |
+
name: "Disallow qualified headings",
|
8104 |
+
desc: "Headings should not be qualified (namespaced).",
|
8105 |
+
browsers: "All",
|
8106 |
+
|
8107 |
+
//initialization
|
8108 |
+
init: function(parser, reporter){
|
8109 |
+
var rule = this;
|
8110 |
+
|
8111 |
+
parser.addListener("startrule", function(event){
|
8112 |
+
var selectors = event.selectors,
|
8113 |
+
selector,
|
8114 |
+
part,
|
8115 |
+
i, j;
|
8116 |
+
|
8117 |
+
for (i=0; i < selectors.length; i++){
|
8118 |
+
selector = selectors[i];
|
8119 |
+
|
8120 |
+
for (j=0; j < selector.parts.length; j++){
|
8121 |
+
part = selector.parts[j];
|
8122 |
+
if (part.type == parser.SELECTOR_PART_TYPE){
|
8123 |
+
if (part.elementName && /h[1-6]/.test(part.elementName.toString()) && j > 0){
|
8124 |
+
reporter.report("Heading (" + part.elementName + ") should not be qualified.", part.line, part.col, rule);
|
8125 |
+
}
|
8126 |
+
}
|
8127 |
+
}
|
8128 |
+
}
|
8129 |
+
});
|
8130 |
+
}
|
8131 |
+
|
8132 |
+
});
|
8133 |
+
/*
|
8134 |
+
* Rule: Selectors that look like regular expressions are slow and should be avoided.
|
8135 |
+
*/
|
8136 |
+
/*global CSSLint*/
|
8137 |
+
CSSLint.addRule({
|
8138 |
+
|
8139 |
+
//rule information
|
8140 |
+
id: "regex-selectors",
|
8141 |
+
name: "Disallow selectors that look like regexs",
|
8142 |
+
desc: "Selectors that look like regular expressions are slow and should be avoided.",
|
8143 |
+
browsers: "All",
|
8144 |
+
|
8145 |
+
//initialization
|
8146 |
+
init: function(parser, reporter){
|
8147 |
+
var rule = this;
|
8148 |
+
|
8149 |
+
parser.addListener("startrule", function(event){
|
8150 |
+
var selectors = event.selectors,
|
8151 |
+
selector,
|
8152 |
+
part,
|
8153 |
+
modifier,
|
8154 |
+
i, j, k;
|
8155 |
+
|
8156 |
+
for (i=0; i < selectors.length; i++){
|
8157 |
+
selector = selectors[i];
|
8158 |
+
for (j=0; j < selector.parts.length; j++){
|
8159 |
+
part = selector.parts[j];
|
8160 |
+
if (part.type == parser.SELECTOR_PART_TYPE){
|
8161 |
+
for (k=0; k < part.modifiers.length; k++){
|
8162 |
+
modifier = part.modifiers[k];
|
8163 |
+
if (modifier.type == "attribute"){
|
8164 |
+
if (/([\~\|\^\$\*]=)/.test(modifier)){
|
8165 |
+
reporter.report("Attribute selectors with " + RegExp.$1 + " are slow!", modifier.line, modifier.col, rule);
|
8166 |
+
}
|
8167 |
+
}
|
8168 |
+
|
8169 |
+
}
|
8170 |
+
}
|
8171 |
+
}
|
8172 |
+
}
|
8173 |
+
});
|
8174 |
+
}
|
8175 |
+
|
8176 |
+
});
|
8177 |
+
/*
|
8178 |
+
* Rule: Total number of rules should not exceed x.
|
8179 |
+
*/
|
8180 |
+
/*global CSSLint*/
|
8181 |
+
CSSLint.addRule({
|
8182 |
+
|
8183 |
+
//rule information
|
8184 |
+
id: "rules-count",
|
8185 |
+
name: "Rules Count",
|
8186 |
+
desc: "Track how many rules there are.",
|
8187 |
+
browsers: "All",
|
8188 |
+
|
8189 |
+
//initialization
|
8190 |
+
init: function(parser, reporter){
|
8191 |
+
var rule = this,
|
8192 |
+
count = 0;
|
8193 |
+
|
8194 |
+
//count each rule
|
8195 |
+
parser.addListener("startrule", function(){
|
8196 |
+
count++;
|
8197 |
+
});
|
8198 |
+
|
8199 |
+
parser.addListener("endstylesheet", function(){
|
8200 |
+
reporter.stat("rule-count", count);
|
8201 |
+
});
|
8202 |
+
}
|
8203 |
+
|
8204 |
+
});
|
8205 |
+
/*
|
8206 |
+
* Rule: Warn people with approaching the IE 4095 limit
|
8207 |
+
*/
|
8208 |
+
/*global CSSLint*/
|
8209 |
+
CSSLint.addRule({
|
8210 |
+
|
8211 |
+
//rule information
|
8212 |
+
id: "selector-max-approaching",
|
8213 |
+
name: "Warn when approaching the 4095 selector limit for IE",
|
8214 |
+
desc: "Will warn when selector count is >= 3800 selectors.",
|
8215 |
+
browsers: "IE",
|
8216 |
+
|
8217 |
+
//initialization
|
8218 |
+
init: function(parser, reporter) {
|
8219 |
+
var rule = this, count = 0;
|
8220 |
+
|
8221 |
+
parser.addListener('startrule', function(event) {
|
8222 |
+
count += event.selectors.length;
|
8223 |
+
});
|
8224 |
+
|
8225 |
+
parser.addListener("endstylesheet", function() {
|
8226 |
+
if (count >= 3800) {
|
8227 |
+
reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);
|
8228 |
+
}
|
8229 |
+
});
|
8230 |
+
}
|
8231 |
+
|
8232 |
+
});
|
8233 |
+
|
8234 |
+
/*
|
8235 |
+
* Rule: Warn people past the IE 4095 limit
|
8236 |
+
*/
|
8237 |
+
/*global CSSLint*/
|
8238 |
+
CSSLint.addRule({
|
8239 |
+
|
8240 |
+
//rule information
|
8241 |
+
id: "selector-max",
|
8242 |
+
name: "Error when past the 4095 selector limit for IE",
|
8243 |
+
desc: "Will error when selector count is > 4095.",
|
8244 |
+
browsers: "IE",
|
8245 |
+
|
8246 |
+
//initialization
|
8247 |
+
init: function(parser, reporter){
|
8248 |
+
var rule = this, count = 0;
|
8249 |
+
|
8250 |
+
parser.addListener('startrule',function(event) {
|
8251 |
+
count += event.selectors.length;
|
8252 |
+
});
|
8253 |
+
|
8254 |
+
parser.addListener("endstylesheet", function() {
|
8255 |
+
if (count > 4095) {
|
8256 |
+
reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);
|
8257 |
+
}
|
8258 |
+
});
|
8259 |
+
}
|
8260 |
+
|
8261 |
+
});
|
8262 |
+
/*
|
8263 |
+
* Rule: Use shorthand properties where possible.
|
8264 |
+
*
|
8265 |
+
*/
|
8266 |
+
/*global CSSLint*/
|
8267 |
+
CSSLint.addRule({
|
8268 |
+
|
8269 |
+
//rule information
|
8270 |
+
id: "shorthand",
|
8271 |
+
name: "Require shorthand properties",
|
8272 |
+
desc: "Use shorthand properties where possible.",
|
8273 |
+
browsers: "All",
|
8274 |
+
|
8275 |
+
//initialization
|
8276 |
+
init: function(parser, reporter){
|
8277 |
+
var rule = this,
|
8278 |
+
prop, i, len,
|
8279 |
+
propertiesToCheck = {},
|
8280 |
+
properties,
|
8281 |
+
mapping = {
|
8282 |
+
"margin": [
|
8283 |
+
"margin-top",
|
8284 |
+
"margin-bottom",
|
8285 |
+
"margin-left",
|
8286 |
+
"margin-right"
|
8287 |
+
],
|
8288 |
+
"padding": [
|
8289 |
+
"padding-top",
|
8290 |
+
"padding-bottom",
|
8291 |
+
"padding-left",
|
8292 |
+
"padding-right"
|
8293 |
+
]
|
8294 |
+
};
|
8295 |
+
|
8296 |
+
//initialize propertiesToCheck
|
8297 |
+
for (prop in mapping){
|
8298 |
+
if (mapping.hasOwnProperty(prop)){
|
8299 |
+
for (i=0, len=mapping[prop].length; i < len; i++){
|
8300 |
+
propertiesToCheck[mapping[prop][i]] = prop;
|
8301 |
+
}
|
8302 |
+
}
|
8303 |
+
}
|
8304 |
+
|
8305 |
+
function startRule(event){
|
8306 |
+
properties = {};
|
8307 |
+
}
|
8308 |
+
|
8309 |
+
//event handler for end of rules
|
8310 |
+
function endRule(event){
|
8311 |
+
|
8312 |
+
var prop, i, len, total;
|
8313 |
+
|
8314 |
+
//check which properties this rule has
|
8315 |
+
for (prop in mapping){
|
8316 |
+
if (mapping.hasOwnProperty(prop)){
|
8317 |
+
total=0;
|
8318 |
+
|
8319 |
+
for (i=0, len=mapping[prop].length; i < len; i++){
|
8320 |
+
total += properties[mapping[prop][i]] ? 1 : 0;
|
8321 |
+
}
|
8322 |
+
|
8323 |
+
if (total == mapping[prop].length){
|
8324 |
+
reporter.report("The properties " + mapping[prop].join(", ") + " can be replaced by " + prop + ".", event.line, event.col, rule);
|
8325 |
+
}
|
8326 |
+
}
|
8327 |
+
}
|
8328 |
+
}
|
8329 |
+
|
8330 |
+
parser.addListener("startrule", startRule);
|
8331 |
+
parser.addListener("startfontface", startRule);
|
8332 |
+
|
8333 |
+
//check for use of "font-size"
|
8334 |
+
parser.addListener("property", function(event){
|
8335 |
+
var name = event.property.toString().toLowerCase(),
|
8336 |
+
value = event.value.parts[0].value;
|
8337 |
+
|
8338 |
+
if (propertiesToCheck[name]){
|
8339 |
+
properties[name] = 1;
|
8340 |
+
}
|
8341 |
+
});
|
8342 |
+
|
8343 |
+
parser.addListener("endrule", endRule);
|
8344 |
+
parser.addListener("endfontface", endRule);
|
8345 |
+
|
8346 |
+
}
|
8347 |
+
|
8348 |
+
});
|
8349 |
+
/*
|
8350 |
+
* Rule: Don't use properties with a star prefix.
|
8351 |
+
*
|
8352 |
+
*/
|
8353 |
+
/*global CSSLint*/
|
8354 |
+
CSSLint.addRule({
|
8355 |
+
|
8356 |
+
//rule information
|
8357 |
+
id: "star-property-hack",
|
8358 |
+
name: "Disallow properties with a star prefix",
|
8359 |
+
desc: "Checks for the star property hack (targets IE6/7)",
|
8360 |
+
browsers: "All",
|
8361 |
+
|
8362 |
+
//initialization
|
8363 |
+
init: function(parser, reporter){
|
8364 |
+
var rule = this;
|
8365 |
+
|
8366 |
+
//check if property name starts with "*"
|
8367 |
+
parser.addListener("property", function(event){
|
8368 |
+
var property = event.property;
|
8369 |
+
|
8370 |
+
if (property.hack == "*") {
|
8371 |
+
reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
|
8372 |
+
}
|
8373 |
+
});
|
8374 |
+
}
|
8375 |
+
});
|
8376 |
+
/*
|
8377 |
+
* Rule: Don't use text-indent for image replacement if you need to support rtl.
|
8378 |
+
*
|
8379 |
+
*/
|
8380 |
+
/*global CSSLint*/
|
8381 |
+
CSSLint.addRule({
|
8382 |
+
|
8383 |
+
//rule information
|
8384 |
+
id: "text-indent",
|
8385 |
+
name: "Disallow negative text-indent",
|
8386 |
+
desc: "Checks for text indent less than -99px",
|
8387 |
+
browsers: "All",
|
8388 |
+
|
8389 |
+
//initialization
|
8390 |
+
init: function(parser, reporter){
|
8391 |
+
var rule = this,
|
8392 |
+
textIndent,
|
8393 |
+
direction;
|
8394 |
+
|
8395 |
+
|
8396 |
+
function startRule(event){
|
8397 |
+
textIndent = false;
|
8398 |
+
direction = "inherit";
|
8399 |
+
}
|
8400 |
+
|
8401 |
+
//event handler for end of rules
|
8402 |
+
function endRule(event){
|
8403 |
+
if (textIndent && direction != "ltr"){
|
8404 |
+
reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
|
8405 |
+
}
|
8406 |
+
}
|
8407 |
+
|
8408 |
+
parser.addListener("startrule", startRule);
|
8409 |
+
parser.addListener("startfontface", startRule);
|
8410 |
+
|
8411 |
+
//check for use of "font-size"
|
8412 |
+
parser.addListener("property", function(event){
|
8413 |
+
var name = event.property.toString().toLowerCase(),
|
8414 |
+
value = event.value;
|
8415 |
+
|
8416 |
+
if (name == "text-indent" && value.parts[0].value < -99){
|
8417 |
+
textIndent = event.property;
|
8418 |
+
} else if (name == "direction" && value == "ltr"){
|
8419 |
+
direction = "ltr";
|
8420 |
+
}
|
8421 |
+
});
|
8422 |
+
|
8423 |
+
parser.addListener("endrule", endRule);
|
8424 |
+
parser.addListener("endfontface", endRule);
|
8425 |
+
|
8426 |
+
}
|
8427 |
+
|
8428 |
+
});
|
8429 |
+
/*
|
8430 |
+
* Rule: Don't use properties with a underscore prefix.
|
8431 |
+
*
|
8432 |
+
*/
|
8433 |
+
/*global CSSLint*/
|
8434 |
+
CSSLint.addRule({
|
8435 |
+
|
8436 |
+
//rule information
|
8437 |
+
id: "underscore-property-hack",
|
8438 |
+
name: "Disallow properties with an underscore prefix",
|
8439 |
+
desc: "Checks for the underscore property hack (targets IE6)",
|
8440 |
+
browsers: "All",
|
8441 |
+
|
8442 |
+
//initialization
|
8443 |
+
init: function(parser, reporter){
|
8444 |
+
var rule = this;
|
8445 |
+
|
8446 |
+
//check if property name starts with "_"
|
8447 |
+
parser.addListener("property", function(event){
|
8448 |
+
var property = event.property;
|
8449 |
+
|
8450 |
+
if (property.hack == "_") {
|
8451 |
+
reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
|
8452 |
+
}
|
8453 |
+
});
|
8454 |
+
}
|
8455 |
+
});
|
8456 |
+
/*
|
8457 |
+
* Rule: Headings (h1-h6) should be defined only once.
|
8458 |
+
*/
|
8459 |
+
/*global CSSLint*/
|
8460 |
+
CSSLint.addRule({
|
8461 |
+
|
8462 |
+
//rule information
|
8463 |
+
id: "unique-headings",
|
8464 |
+
name: "Headings should only be defined once",
|
8465 |
+
desc: "Headings should be defined only once.",
|
8466 |
+
browsers: "All",
|
8467 |
+
|
8468 |
+
//initialization
|
8469 |
+
init: function(parser, reporter){
|
8470 |
+
var rule = this;
|
8471 |
+
|
8472 |
+
var headings = {
|
8473 |
+
h1: 0,
|
8474 |
+
h2: 0,
|
8475 |
+
h3: 0,
|
8476 |
+
h4: 0,
|
8477 |
+
h5: 0,
|
8478 |
+
h6: 0
|
8479 |
+
};
|
8480 |
+
|
8481 |
+
parser.addListener("startrule", function(event){
|
8482 |
+
var selectors = event.selectors,
|
8483 |
+
selector,
|
8484 |
+
part,
|
8485 |
+
pseudo,
|
8486 |
+
i, j;
|
8487 |
+
|
8488 |
+
for (i=0; i < selectors.length; i++){
|
8489 |
+
selector = selectors[i];
|
8490 |
+
part = selector.parts[selector.parts.length-1];
|
8491 |
+
|
8492 |
+
if (part.elementName && /(h[1-6])/i.test(part.elementName.toString())){
|
8493 |
+
|
8494 |
+
for (j=0; j < part.modifiers.length; j++){
|
8495 |
+
if (part.modifiers[j].type == "pseudo"){
|
8496 |
+
pseudo = true;
|
8497 |
+
break;
|
8498 |
+
}
|
8499 |
+
}
|
8500 |
+
|
8501 |
+
if (!pseudo){
|
8502 |
+
headings[RegExp.$1]++;
|
8503 |
+
if (headings[RegExp.$1] > 1) {
|
8504 |
+
reporter.report("Heading (" + part.elementName + ") has already been defined.", part.line, part.col, rule);
|
8505 |
+
}
|
8506 |
+
}
|
8507 |
+
}
|
8508 |
+
}
|
8509 |
+
});
|
8510 |
+
|
8511 |
+
parser.addListener("endstylesheet", function(event){
|
8512 |
+
var prop,
|
8513 |
+
messages = [];
|
8514 |
+
|
8515 |
+
for (prop in headings){
|
8516 |
+
if (headings.hasOwnProperty(prop)){
|
8517 |
+
if (headings[prop] > 1){
|
8518 |
+
messages.push(headings[prop] + " " + prop + "s");
|
8519 |
+
}
|
8520 |
+
}
|
8521 |
+
}
|
8522 |
+
|
8523 |
+
if (messages.length){
|
8524 |
+
reporter.rollupWarn("You have " + messages.join(", ") + " defined in this stylesheet.", rule);
|
8525 |
+
}
|
8526 |
+
});
|
8527 |
+
}
|
8528 |
+
|
8529 |
+
});
|
8530 |
+
/*
|
8531 |
+
* Rule: Don't use universal selector because it's slow.
|
8532 |
+
*/
|
8533 |
+
/*global CSSLint*/
|
8534 |
+
CSSLint.addRule({
|
8535 |
+
|
8536 |
+
//rule information
|
8537 |
+
id: "universal-selector",
|
8538 |
+
name: "Disallow universal selector",
|
8539 |
+
desc: "The universal selector (*) is known to be slow.",
|
8540 |
+
browsers: "All",
|
8541 |
+
|
8542 |
+
//initialization
|
8543 |
+
init: function(parser, reporter){
|
8544 |
+
var rule = this;
|
8545 |
+
|
8546 |
+
parser.addListener("startrule", function(event){
|
8547 |
+
var selectors = event.selectors,
|
8548 |
+
selector,
|
8549 |
+
part,
|
8550 |
+
modifier,
|
8551 |
+
i, j, k;
|
8552 |
+
|
8553 |
+
for (i=0; i < selectors.length; i++){
|
8554 |
+
selector = selectors[i];
|
8555 |
+
|
8556 |
+
part = selector.parts[selector.parts.length-1];
|
8557 |
+
if (part.elementName == "*"){
|
8558 |
+
reporter.report(rule.desc, part.line, part.col, rule);
|
8559 |
+
}
|
8560 |
+
}
|
8561 |
+
});
|
8562 |
+
}
|
8563 |
+
|
8564 |
+
});
|
8565 |
+
/*
|
8566 |
+
* Rule: Don't use unqualified attribute selectors because they're just like universal selectors.
|
8567 |
+
*/
|
8568 |
+
/*global CSSLint*/
|
8569 |
+
CSSLint.addRule({
|
8570 |
+
|
8571 |
+
//rule information
|
8572 |
+
id: "unqualified-attributes",
|
8573 |
+
name: "Disallow unqualified attribute selectors",
|
8574 |
+
desc: "Unqualified attribute selectors are known to be slow.",
|
8575 |
+
browsers: "All",
|
8576 |
+
|
8577 |
+
//initialization
|
8578 |
+
init: function(parser, reporter){
|
8579 |
+
var rule = this;
|
8580 |
+
|
8581 |
+
parser.addListener("startrule", function(event){
|
8582 |
+
|
8583 |
+
var selectors = event.selectors,
|
8584 |
+
selector,
|
8585 |
+
part,
|
8586 |
+
modifier,
|
8587 |
+
i, j, k;
|
8588 |
+
|
8589 |
+
for (i=0; i < selectors.length; i++){
|
8590 |
+
selector = selectors[i];
|
8591 |
+
|
8592 |
+
part = selector.parts[selector.parts.length-1];
|
8593 |
+
if (part.type == parser.SELECTOR_PART_TYPE){
|
8594 |
+
for (k=0; k < part.modifiers.length; k++){
|
8595 |
+
modifier = part.modifiers[k];
|
8596 |
+
if (modifier.type == "attribute" && (!part.elementName || part.elementName == "*")){
|
8597 |
+
reporter.report(rule.desc, part.line, part.col, rule);
|
8598 |
+
}
|
8599 |
+
}
|
8600 |
+
}
|
8601 |
+
|
8602 |
+
}
|
8603 |
+
});
|
8604 |
+
}
|
8605 |
+
|
8606 |
+
});
|
8607 |
+
/*
|
8608 |
+
* Rule: When using a vendor-prefixed property, make sure to
|
8609 |
+
* include the standard one.
|
8610 |
+
*/
|
8611 |
+
/*global CSSLint*/
|
8612 |
+
CSSLint.addRule({
|
8613 |
+
|
8614 |
+
//rule information
|
8615 |
+
id: "vendor-prefix",
|
8616 |
+
name: "Require standard property with vendor prefix",
|
8617 |
+
desc: "When using a vendor-prefixed property, make sure to include the standard one.",
|
8618 |
+
browsers: "All",
|
8619 |
+
|
8620 |
+
//initialization
|
8621 |
+
init: function(parser, reporter){
|
8622 |
+
var rule = this,
|
8623 |
+
properties,
|
8624 |
+
num,
|
8625 |
+
propertiesToCheck = {
|
8626 |
+
"-webkit-border-radius": "border-radius",
|
8627 |
+
"-webkit-border-top-left-radius": "border-top-left-radius",
|
8628 |
+
"-webkit-border-top-right-radius": "border-top-right-radius",
|
8629 |
+
"-webkit-border-bottom-left-radius": "border-bottom-left-radius",
|
8630 |
+
"-webkit-border-bottom-right-radius": "border-bottom-right-radius",
|
8631 |
+
|
8632 |
+
"-o-border-radius": "border-radius",
|
8633 |
+
"-o-border-top-left-radius": "border-top-left-radius",
|
8634 |
+
"-o-border-top-right-radius": "border-top-right-radius",
|
8635 |
+
"-o-border-bottom-left-radius": "border-bottom-left-radius",
|
8636 |
+
"-o-border-bottom-right-radius": "border-bottom-right-radius",
|
8637 |
+
|
8638 |
+
"-moz-border-radius": "border-radius",
|
8639 |
+
"-moz-border-radius-topleft": "border-top-left-radius",
|
8640 |
+
"-moz-border-radius-topright": "border-top-right-radius",
|
8641 |
+
"-moz-border-radius-bottomleft": "border-bottom-left-radius",
|
8642 |
+
"-moz-border-radius-bottomright": "border-bottom-right-radius",
|
8643 |
+
|
8644 |
+
"-moz-column-count": "column-count",
|
8645 |
+
"-webkit-column-count": "column-count",
|
8646 |
+
|
8647 |
+
"-moz-column-gap": "column-gap",
|
8648 |
+
"-webkit-column-gap": "column-gap",
|
8649 |
+
|
8650 |
+
"-moz-column-rule": "column-rule",
|
8651 |
+
"-webkit-column-rule": "column-rule",
|
8652 |
+
|
8653 |
+
"-moz-column-rule-style": "column-rule-style",
|
8654 |
+
"-webkit-column-rule-style": "column-rule-style",
|
8655 |
+
|
8656 |
+
"-moz-column-rule-color": "column-rule-color",
|
8657 |
+
"-webkit-column-rule-color": "column-rule-color",
|
8658 |
+
|
8659 |
+
"-moz-column-rule-width": "column-rule-width",
|
8660 |
+
"-webkit-column-rule-width": "column-rule-width",
|
8661 |
+
|
8662 |
+
"-moz-column-width": "column-width",
|
8663 |
+
"-webkit-column-width": "column-width",
|
8664 |
+
|
8665 |
+
"-webkit-column-span": "column-span",
|
8666 |
+
"-webkit-columns": "columns",
|
8667 |
+
|
8668 |
+
"-moz-box-shadow": "box-shadow",
|
8669 |
+
"-webkit-box-shadow": "box-shadow",
|
8670 |
+
|
8671 |
+
"-moz-transform" : "transform",
|
8672 |
+
"-webkit-transform" : "transform",
|
8673 |
+
"-o-transform" : "transform",
|
8674 |
+
"-ms-transform" : "transform",
|
8675 |
+
|
8676 |
+
"-moz-transform-origin" : "transform-origin",
|
8677 |
+
"-webkit-transform-origin" : "transform-origin",
|
8678 |
+
"-o-transform-origin" : "transform-origin",
|
8679 |
+
"-ms-transform-origin" : "transform-origin",
|
8680 |
+
|
8681 |
+
"-moz-box-sizing" : "box-sizing",
|
8682 |
+
"-webkit-box-sizing" : "box-sizing",
|
8683 |
+
|
8684 |
+
"-moz-user-select" : "user-select",
|
8685 |
+
"-khtml-user-select" : "user-select",
|
8686 |
+
"-webkit-user-select" : "user-select"
|
8687 |
+
};
|
8688 |
+
|
8689 |
+
//event handler for beginning of rules
|
8690 |
+
function startRule(){
|
8691 |
+
properties = {};
|
8692 |
+
num=1;
|
8693 |
+
}
|
8694 |
+
|
8695 |
+
//event handler for end of rules
|
8696 |
+
function endRule(event){
|
8697 |
+
var prop,
|
8698 |
+
i, len,
|
8699 |
+
standard,
|
8700 |
+
needed,
|
8701 |
+
actual,
|
8702 |
+
needsStandard = [];
|
8703 |
+
|
8704 |
+
for (prop in properties){
|
8705 |
+
if (propertiesToCheck[prop]){
|
8706 |
+
needsStandard.push({ actual: prop, needed: propertiesToCheck[prop]});
|
8707 |
+
}
|
8708 |
+
}
|
8709 |
+
|
8710 |
+
for (i=0, len=needsStandard.length; i < len; i++){
|
8711 |
+
needed = needsStandard[i].needed;
|
8712 |
+
actual = needsStandard[i].actual;
|
8713 |
+
|
8714 |
+
if (!properties[needed]){
|
8715 |
+
reporter.report("Missing standard property '" + needed + "' to go along with '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
|
8716 |
+
} else {
|
8717 |
+
//make sure standard property is last
|
8718 |
+
if (properties[needed][0].pos < properties[actual][0].pos){
|
8719 |
+
reporter.report("Standard property '" + needed + "' should come after vendor-prefixed property '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
|
8720 |
+
}
|
8721 |
+
}
|
8722 |
+
}
|
8723 |
+
|
8724 |
+
}
|
8725 |
+
|
8726 |
+
parser.addListener("startrule", startRule);
|
8727 |
+
parser.addListener("startfontface", startRule);
|
8728 |
+
parser.addListener("startpage", startRule);
|
8729 |
+
parser.addListener("startpagemargin", startRule);
|
8730 |
+
parser.addListener("startkeyframerule", startRule);
|
8731 |
+
|
8732 |
+
parser.addListener("property", function(event){
|
8733 |
+
var name = event.property.text.toLowerCase();
|
8734 |
+
|
8735 |
+
if (!properties[name]){
|
8736 |
+
properties[name] = [];
|
8737 |
+
}
|
8738 |
+
|
8739 |
+
properties[name].push({ name: event.property, value : event.value, pos:num++ });
|
8740 |
+
});
|
8741 |
+
|
8742 |
+
parser.addListener("endrule", endRule);
|
8743 |
+
parser.addListener("endfontface", endRule);
|
8744 |
+
parser.addListener("endpage", endRule);
|
8745 |
+
parser.addListener("endpagemargin", endRule);
|
8746 |
+
parser.addListener("endkeyframerule", endRule);
|
8747 |
+
}
|
8748 |
+
|
8749 |
+
});
|
8750 |
+
/*
|
8751 |
+
* Rule: You don't need to specify units when a value is 0.
|
8752 |
+
*/
|
8753 |
+
/*global CSSLint*/
|
8754 |
+
CSSLint.addRule({
|
8755 |
+
|
8756 |
+
//rule information
|
8757 |
+
id: "zero-units",
|
8758 |
+
name: "Disallow units for 0 values",
|
8759 |
+
desc: "You don't need to specify units when a value is 0.",
|
8760 |
+
browsers: "All",
|
8761 |
+
|
8762 |
+
//initialization
|
8763 |
+
init: function(parser, reporter){
|
8764 |
+
var rule = this;
|
8765 |
+
|
8766 |
+
//count how many times "float" is used
|
8767 |
+
parser.addListener("property", function(event){
|
8768 |
+
var parts = event.value.parts,
|
8769 |
+
i = 0,
|
8770 |
+
len = parts.length;
|
8771 |
+
|
8772 |
+
while(i < len){
|
8773 |
+
if ((parts[i].units || parts[i].type == "percentage") && parts[i].value === 0 && parts[i].type != "time"){
|
8774 |
+
reporter.report("Values of 0 shouldn't have units specified.", parts[i].line, parts[i].col, rule);
|
8775 |
+
}
|
8776 |
+
i++;
|
8777 |
+
}
|
8778 |
+
|
8779 |
+
});
|
8780 |
+
|
8781 |
+
}
|
8782 |
+
|
8783 |
+
});
|
8784 |
+
/*global CSSLint*/
|
8785 |
+
(function() {
|
8786 |
+
|
8787 |
+
/**
|
8788 |
+
* Replace special characters before write to output.
|
8789 |
+
*
|
8790 |
+
* Rules:
|
8791 |
+
* - single quotes is the escape sequence for double-quotes
|
8792 |
+
* - & is the escape sequence for &
|
8793 |
+
* - < is the escape sequence for <
|
8794 |
+
* - > is the escape sequence for >
|
8795 |
+
*
|
8796 |
+
* @param {String} message to escape
|
8797 |
+
* @return escaped message as {String}
|
8798 |
+
*/
|
8799 |
+
var xmlEscape = function(str) {
|
8800 |
+
if (!str || str.constructor !== String) {
|
8801 |
+
return "";
|
8802 |
+
}
|
8803 |
+
|
8804 |
+
return str.replace(/[\"&><]/g, function(match) {
|
8805 |
+
switch (match) {
|
8806 |
+
case "\"":
|
8807 |
+
return """;
|
8808 |
+
case "&":
|
8809 |
+
return "&";
|
8810 |
+
case "<":
|
8811 |
+
return "<";
|
8812 |
+
case ">":
|
8813 |
+
return ">";
|
8814 |
+
}
|
8815 |
+
});
|
8816 |
+
};
|
8817 |
+
|
8818 |
+
CSSLint.addFormatter({
|
8819 |
+
//format information
|
8820 |
+
id: "checkstyle-xml",
|
8821 |
+
name: "Checkstyle XML format",
|
8822 |
+
|
8823 |
+
/**
|
8824 |
+
* Return opening root XML tag.
|
8825 |
+
* @return {String} to prepend before all results
|
8826 |
+
*/
|
8827 |
+
startFormat: function(){
|
8828 |
+
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
|
8829 |
+
},
|
8830 |
+
|
8831 |
+
/**
|
8832 |
+
* Return closing root XML tag.
|
8833 |
+
* @return {String} to append after all results
|
8834 |
+
*/
|
8835 |
+
endFormat: function(){
|
8836 |
+
return "</checkstyle>";
|
8837 |
+
},
|
8838 |
+
|
8839 |
+
/**
|
8840 |
+
* Returns message when there is a file read error.
|
8841 |
+
* @param {String} filename The name of the file that caused the error.
|
8842 |
+
* @param {String} message The error message
|
8843 |
+
* @return {String} The error message.
|
8844 |
+
*/
|
8845 |
+
readError: function(filename, message) {
|
8846 |
+
return "<file name=\"" + xmlEscape(filename) + "\"><error line=\"0\" column=\"0\" severty=\"error\" message=\"" + xmlEscape(message) + "\"></error></file>";
|
8847 |
+
},
|
8848 |
+
|
8849 |
+
/**
|
8850 |
+
* Given CSS Lint results for a file, return output for this format.
|
8851 |
+
* @param results {Object} with error and warning messages
|
8852 |
+
* @param filename {String} relative file path
|
8853 |
+
* @param options {Object} (UNUSED for now) specifies special handling of output
|
8854 |
+
* @return {String} output for results
|
8855 |
+
*/
|
8856 |
+
formatResults: function(results, filename, options) {
|
8857 |
+
var messages = results.messages,
|
8858 |
+
output = [];
|
8859 |
+
|
8860 |
+
/**
|
8861 |
+
* Generate a source string for a rule.
|
8862 |
+
* Checkstyle source strings usually resemble Java class names e.g
|
8863 |
+
* net.csslint.SomeRuleName
|
8864 |
+
* @param {Object} rule
|
8865 |
+
* @return rule source as {String}
|
8866 |
+
*/
|
8867 |
+
var generateSource = function(rule) {
|
8868 |
+
if (!rule || !('name' in rule)) {
|
8869 |
+
return "";
|
8870 |
+
}
|
8871 |
+
return 'net.csslint.' + rule.name.replace(/\s/g,'');
|
8872 |
+
};
|
8873 |
+
|
8874 |
+
|
8875 |
+
|
8876 |
+
if (messages.length > 0) {
|
8877 |
+
output.push("<file name=\""+filename+"\">");
|
8878 |
+
CSSLint.Util.forEach(messages, function (message, i) {
|
8879 |
+
//ignore rollups for now
|
8880 |
+
if (!message.rollup) {
|
8881 |
+
output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
|
8882 |
+
" message=\"" + xmlEscape(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
|
8883 |
+
}
|
8884 |
+
});
|
8885 |
+
output.push("</file>");
|
8886 |
+
}
|
8887 |
+
|
8888 |
+
return output.join("");
|
8889 |
+
}
|
8890 |
+
});
|
8891 |
+
|
8892 |
+
}());
|
8893 |
+
/*global CSSLint*/
|
8894 |
+
CSSLint.addFormatter({
|
8895 |
+
//format information
|
8896 |
+
id: "compact",
|
8897 |
+
name: "Compact, 'porcelain' format",
|
8898 |
+
|
8899 |
+
/**
|
8900 |
+
* Return content to be printed before all file results.
|
8901 |
+
* @return {String} to prepend before all results
|
8902 |
+
*/
|
8903 |
+
startFormat: function() {
|
8904 |
+
return "";
|
8905 |
+
},
|
8906 |
+
|
8907 |
+
/**
|
8908 |
+
* Return content to be printed after all file results.
|
8909 |
+
* @return {String} to append after all results
|
8910 |
+
*/
|
8911 |
+
endFormat: function() {
|
8912 |
+
return "";
|
8913 |
+
},
|
8914 |
+
|
8915 |
+
/**
|
8916 |
+
* Given CSS Lint results for a file, return output for this format.
|
8917 |
+
* @param results {Object} with error and warning messages
|
8918 |
+
* @param filename {String} relative file path
|
8919 |
+
* @param options {Object} (Optional) specifies special handling of output
|
8920 |
+
* @return {String} output for results
|
8921 |
+
*/
|
8922 |
+
formatResults: function(results, filename, options) {
|
8923 |
+
var messages = results.messages,
|
8924 |
+
output = "";
|
8925 |
+
options = options || {};
|
8926 |
+
|
8927 |
+
/**
|
8928 |
+
* Capitalize and return given string.
|
8929 |
+
* @param str {String} to capitalize
|
8930 |
+
* @return {String} capitalized
|
8931 |
+
*/
|
8932 |
+
var capitalize = function(str) {
|
8933 |
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
8934 |
+
};
|
8935 |
+
|
8936 |
+
if (messages.length === 0) {
|
8937 |
+
return options.quiet ? "" : filename + ": Lint Free!";
|
8938 |
+
}
|
8939 |
+
|
8940 |
+
CSSLint.Util.forEach(messages, function(message, i) {
|
8941 |
+
if (message.rollup) {
|
8942 |
+
output += filename + ": " + capitalize(message.type) + " - " + message.message + "\n";
|
8943 |
+
} else {
|
8944 |
+
output += filename + ": " + "line " + message.line +
|
8945 |
+
", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + "\n";
|
8946 |
+
}
|
8947 |
+
});
|
8948 |
+
|
8949 |
+
return output;
|
8950 |
+
}
|
8951 |
+
});
|
8952 |
+
/*global CSSLint*/
|
8953 |
+
CSSLint.addFormatter({
|
8954 |
+
//format information
|
8955 |
+
id: "csslint-xml",
|
8956 |
+
name: "CSSLint XML format",
|
8957 |
+
|
8958 |
+
/**
|
8959 |
+
* Return opening root XML tag.
|
8960 |
+
* @return {String} to prepend before all results
|
8961 |
+
*/
|
8962 |
+
startFormat: function(){
|
8963 |
+
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
|
8964 |
+
},
|
8965 |
+
|
8966 |
+
/**
|
8967 |
+
* Return closing root XML tag.
|
8968 |
+
* @return {String} to append after all results
|
8969 |
+
*/
|
8970 |
+
endFormat: function(){
|
8971 |
+
return "</csslint>";
|
8972 |
+
},
|
8973 |
+
|
8974 |
+
/**
|
8975 |
+
* Given CSS Lint results for a file, return output for this format.
|
8976 |
+
* @param results {Object} with error and warning messages
|
8977 |
+
* @param filename {String} relative file path
|
8978 |
+
* @param options {Object} (UNUSED for now) specifies special handling of output
|
8979 |
+
* @return {String} output for results
|
8980 |
+
*/
|
8981 |
+
formatResults: function(results, filename, options) {
|
8982 |
+
var messages = results.messages,
|
8983 |
+
output = [];
|
8984 |
+
|
8985 |
+
/**
|
8986 |
+
* Replace special characters before write to output.
|
8987 |
+
*
|
8988 |
+
* Rules:
|
8989 |
+
* - single quotes is the escape sequence for double-quotes
|
8990 |
+
* - & is the escape sequence for &
|
8991 |
+
* - < is the escape sequence for <
|
8992 |
+
* - > is the escape sequence for >
|
8993 |
+
*
|
8994 |
+
* @param {String} message to escape
|
8995 |
+
* @return escaped message as {String}
|
8996 |
+
*/
|
8997 |
+
var escapeSpecialCharacters = function(str) {
|
8998 |
+
if (!str || str.constructor !== String) {
|
8999 |
+
return "";
|
9000 |
+
}
|
9001 |
+
return str.replace(/\"/g, "'").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
9002 |
+
};
|
9003 |
+
|
9004 |
+
if (messages.length > 0) {
|
9005 |
+
output.push("<file name=\""+filename+"\">");
|
9006 |
+
CSSLint.Util.forEach(messages, function (message, i) {
|
9007 |
+
if (message.rollup) {
|
9008 |
+
output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
9009 |
+
} else {
|
9010 |
+
output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
|
9011 |
+
" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
9012 |
+
}
|
9013 |
+
});
|
9014 |
+
output.push("</file>");
|
9015 |
+
}
|
9016 |
+
|
9017 |
+
return output.join("");
|
9018 |
+
}
|
9019 |
+
});
|
9020 |
+
/*global CSSLint*/
|
9021 |
+
CSSLint.addFormatter({
|
9022 |
+
//format information
|
9023 |
+
id: "junit-xml",
|
9024 |
+
name: "JUNIT XML format",
|
9025 |
+
|
9026 |
+
/**
|
9027 |
+
* Return opening root XML tag.
|
9028 |
+
* @return {String} to prepend before all results
|
9029 |
+
*/
|
9030 |
+
startFormat: function(){
|
9031 |
+
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";
|
9032 |
+
},
|
9033 |
+
|
9034 |
+
/**
|
9035 |
+
* Return closing root XML tag.
|
9036 |
+
* @return {String} to append after all results
|
9037 |
+
*/
|
9038 |
+
endFormat: function() {
|
9039 |
+
return "</testsuites>";
|
9040 |
+
},
|
9041 |
+
|
9042 |
+
/**
|
9043 |
+
* Given CSS Lint results for a file, return output for this format.
|
9044 |
+
* @param results {Object} with error and warning messages
|
9045 |
+
* @param filename {String} relative file path
|
9046 |
+
* @param options {Object} (UNUSED for now) specifies special handling of output
|
9047 |
+
* @return {String} output for results
|
9048 |
+
*/
|
9049 |
+
formatResults: function(results, filename, options) {
|
9050 |
+
|
9051 |
+
var messages = results.messages,
|
9052 |
+
output = [],
|
9053 |
+
tests = {
|
9054 |
+
'error': 0,
|
9055 |
+
'failure': 0
|
9056 |
+
};
|
9057 |
+
|
9058 |
+
/**
|
9059 |
+
* Generate a source string for a rule.
|
9060 |
+
* JUNIT source strings usually resemble Java class names e.g
|
9061 |
+
* net.csslint.SomeRuleName
|
9062 |
+
* @param {Object} rule
|
9063 |
+
* @return rule source as {String}
|
9064 |
+
*/
|
9065 |
+
var generateSource = function(rule) {
|
9066 |
+
if (!rule || !('name' in rule)) {
|
9067 |
+
return "";
|
9068 |
+
}
|
9069 |
+
return 'net.csslint.' + rule.name.replace(/\s/g,'');
|
9070 |
+
};
|
9071 |
+
|
9072 |
+
/**
|
9073 |
+
* Replace special characters before write to output.
|
9074 |
+
*
|
9075 |
+
* Rules:
|
9076 |
+
* - single quotes is the escape sequence for double-quotes
|
9077 |
+
* - < is the escape sequence for <
|
9078 |
+
* - > is the escape sequence for >
|
9079 |
+
*
|
9080 |
+
* @param {String} message to escape
|
9081 |
+
* @return escaped message as {String}
|
9082 |
+
*/
|
9083 |
+
var escapeSpecialCharacters = function(str) {
|
9084 |
+
|
9085 |
+
if (!str || str.constructor !== String) {
|
9086 |
+
return "";
|
9087 |
+
}
|
9088 |
+
|
9089 |
+
return str.replace(/\"/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
9090 |
+
|
9091 |
+
};
|
9092 |
+
|
9093 |
+
if (messages.length > 0) {
|
9094 |
+
|
9095 |
+
messages.forEach(function (message, i) {
|
9096 |
+
|
9097 |
+
// since junit has no warning class
|
9098 |
+
// all issues as errors
|
9099 |
+
var type = message.type === 'warning' ? 'error' : message.type;
|
9100 |
+
|
9101 |
+
//ignore rollups for now
|
9102 |
+
if (!message.rollup) {
|
9103 |
+
|
9104 |
+
// build the test case seperately, once joined
|
9105 |
+
// we'll add it to a custom array filtered by type
|
9106 |
+
output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">");
|
9107 |
+
output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ':' + message.col + ':' + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
|
9108 |
+
output.push("</testcase>");
|
9109 |
+
|
9110 |
+
tests[type] += 1;
|
9111 |
+
|
9112 |
+
}
|
9113 |
+
|
9114 |
+
});
|
9115 |
+
|
9116 |
+
output.unshift("<testsuite time=\"0\" tests=\"" + messages.length + "\" skipped=\"0\" errors=\"" + tests.error + "\" failures=\"" + tests.failure + "\" package=\"net.csslint\" name=\"" + filename + "\">");
|
9117 |
+
output.push("</testsuite>");
|
9118 |
+
|
9119 |
+
}
|
9120 |
+
|
9121 |
+
return output.join("");
|
9122 |
+
|
9123 |
+
}
|
9124 |
+
});
|
9125 |
+
/*global CSSLint*/
|
9126 |
+
CSSLint.addFormatter({
|
9127 |
+
//format information
|
9128 |
+
id: "lint-xml",
|
9129 |
+
name: "Lint XML format",
|
9130 |
+
|
9131 |
+
/**
|
9132 |
+
* Return opening root XML tag.
|
9133 |
+
* @return {String} to prepend before all results
|
9134 |
+
*/
|
9135 |
+
startFormat: function(){
|
9136 |
+
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
|
9137 |
+
},
|
9138 |
+
|
9139 |
+
/**
|
9140 |
+
* Return closing root XML tag.
|
9141 |
+
* @return {String} to append after all results
|
9142 |
+
*/
|
9143 |
+
endFormat: function(){
|
9144 |
+
return "</lint>";
|
9145 |
+
},
|
9146 |
+
|
9147 |
+
/**
|
9148 |
+
* Given CSS Lint results for a file, return output for this format.
|
9149 |
+
* @param results {Object} with error and warning messages
|
9150 |
+
* @param filename {String} relative file path
|
9151 |
+
* @param options {Object} (UNUSED for now) specifies special handling of output
|
9152 |
+
* @return {String} output for results
|
9153 |
+
*/
|
9154 |
+
formatResults: function(results, filename, options) {
|
9155 |
+
var messages = results.messages,
|
9156 |
+
output = [];
|
9157 |
+
|
9158 |
+
/**
|
9159 |
+
* Replace special characters before write to output.
|
9160 |
+
*
|
9161 |
+
* Rules:
|
9162 |
+
* - single quotes is the escape sequence for double-quotes
|
9163 |
+
* - & is the escape sequence for &
|
9164 |
+
* - < is the escape sequence for <
|
9165 |
+
* - > is the escape sequence for >
|
9166 |
+
*
|
9167 |
+
* @param {String} message to escape
|
9168 |
+
* @return escaped message as {String}
|
9169 |
+
*/
|
9170 |
+
var escapeSpecialCharacters = function(str) {
|
9171 |
+
if (!str || str.constructor !== String) {
|
9172 |
+
return "";
|
9173 |
+
}
|
9174 |
+
return str.replace(/\"/g, "'").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
9175 |
+
};
|
9176 |
+
|
9177 |
+
if (messages.length > 0) {
|
9178 |
+
|
9179 |
+
output.push("<file name=\""+filename+"\">");
|
9180 |
+
CSSLint.Util.forEach(messages, function (message, i) {
|
9181 |
+
if (message.rollup) {
|
9182 |
+
output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
9183 |
+
} else {
|
9184 |
+
output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
|
9185 |
+
" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
9186 |
+
}
|
9187 |
+
});
|
9188 |
+
output.push("</file>");
|
9189 |
+
}
|
9190 |
+
|
9191 |
+
return output.join("");
|
9192 |
+
}
|
9193 |
+
});
|
9194 |
+
/*global CSSLint*/
|
9195 |
+
CSSLint.addFormatter({
|
9196 |
+
//format information
|
9197 |
+
id: "text",
|
9198 |
+
name: "Plain Text",
|
9199 |
+
|
9200 |
+
/**
|
9201 |
+
* Return content to be printed before all file results.
|
9202 |
+
* @return {String} to prepend before all results
|
9203 |
+
*/
|
9204 |
+
startFormat: function() {
|
9205 |
+
return "";
|
9206 |
+
},
|
9207 |
+
|
9208 |
+
/**
|
9209 |
+
* Return content to be printed after all file results.
|
9210 |
+
* @return {String} to append after all results
|
9211 |
+
*/
|
9212 |
+
endFormat: function() {
|
9213 |
+
return "";
|
9214 |
+
},
|
9215 |
+
|
9216 |
+
/**
|
9217 |
+
* Given CSS Lint results for a file, return output for this format.
|
9218 |
+
* @param results {Object} with error and warning messages
|
9219 |
+
* @param filename {String} relative file path
|
9220 |
+
* @param options {Object} (Optional) specifies special handling of output
|
9221 |
+
* @return {String} output for results
|
9222 |
+
*/
|
9223 |
+
formatResults: function(results, filename, options) {
|
9224 |
+
var messages = results.messages,
|
9225 |
+
output = "";
|
9226 |
+
options = options || {};
|
9227 |
+
|
9228 |
+
if (messages.length === 0) {
|
9229 |
+
return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
|
9230 |
+
}
|
9231 |
+
|
9232 |
+
output = "\n\ncsslint: There are " + messages.length + " problems in " + filename + ".";
|
9233 |
+
var pos = filename.lastIndexOf("/"),
|
9234 |
+
shortFilename = filename;
|
9235 |
+
|
9236 |
+
if (pos === -1){
|
9237 |
+
pos = filename.lastIndexOf("\\");
|
9238 |
+
}
|
9239 |
+
if (pos > -1){
|
9240 |
+
shortFilename = filename.substring(pos+1);
|
9241 |
+
}
|
9242 |
+
|
9243 |
+
CSSLint.Util.forEach(messages, function (message, i) {
|
9244 |
+
output = output + "\n\n" + shortFilename;
|
9245 |
+
if (message.rollup) {
|
9246 |
+
output += "\n" + (i+1) + ": " + message.type;
|
9247 |
+
output += "\n" + message.message;
|
9248 |
+
} else {
|
9249 |
+
output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col;
|
9250 |
+
output += "\n" + message.message;
|
9251 |
+
output += "\n" + message.evidence;
|
9252 |
+
}
|
9253 |
+
});
|
9254 |
+
|
9255 |
+
return output;
|
9256 |
+
}
|
9257 |
+
});
|
9258 |
+
return CSSLint;
|
9259 |
+
})();
|
js/csslint.min.js
ADDED
@@ -0,0 +1,277 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
var exports=exports||{};var CSSLint=(function(){var parserlib={};(function(){function EventTarget(){this._listeners={};}
|
3 |
+
EventTarget.prototype={constructor:EventTarget,addListener:function(type,listener){if(!this._listeners[type]){this._listeners[type]=[];}
|
4 |
+
this._listeners[type].push(listener);},fire:function(event){if(typeof event=="string"){event={type:event};}
|
5 |
+
if(typeof event.target!="undefined"){event.target=this;}
|
6 |
+
if(typeof event.type=="undefined"){throw new Error("Event object missing 'type' property.");}
|
7 |
+
if(this._listeners[event.type]){var listeners=this._listeners[event.type].concat();for(var i=0,len=listeners.length;i<len;i++){listeners[i].call(this,event);}}},removeListener:function(type,listener){if(this._listeners[type]){var listeners=this._listeners[type];for(var i=0,len=listeners.length;i<len;i++){if(listeners[i]===listener){listeners.splice(i,1);break;}}}}};function StringReader(text){this._input=text.replace(/\n\r?/g,"\n");this._line=1;this._col=1;this._cursor=0;}
|
8 |
+
StringReader.prototype={constructor:StringReader,getCol:function(){return this._col;},getLine:function(){return this._line;},eof:function(){return(this._cursor==this._input.length);},peek:function(count){var c=null;count=(typeof count=="undefined"?1:count);if(this._cursor<this._input.length){c=this._input.charAt(this._cursor+count-1);}
|
9 |
+
return c;},read:function(){var c=null;if(this._cursor<this._input.length){if(this._input.charAt(this._cursor)=="\n"){this._line++;this._col=1;}else{this._col++;}
|
10 |
+
c=this._input.charAt(this._cursor++);}
|
11 |
+
return c;},mark:function(){this._bookmark={cursor:this._cursor,line:this._line,col:this._col};},reset:function(){if(this._bookmark){this._cursor=this._bookmark.cursor;this._line=this._bookmark.line;this._col=this._bookmark.col;delete this._bookmark;}},readTo:function(pattern){var buffer="",c;while(buffer.length<pattern.length||buffer.lastIndexOf(pattern)!=buffer.length-pattern.length){c=this.read();if(c){buffer+=c;}else{throw new Error("Expected \""+pattern+"\" at line "+this._line+", col "+this._col+".");}}
|
12 |
+
return buffer;},readWhile:function(filter){var buffer="",c=this.read();while(c!==null&&filter(c)){buffer+=c;c=this.read();}
|
13 |
+
return buffer;},readMatch:function(matcher){var source=this._input.substring(this._cursor),value=null;if(typeof matcher=="string"){if(source.indexOf(matcher)===0){value=this.readCount(matcher.length);}}else if(matcher instanceof RegExp){if(matcher.test(source)){value=this.readCount(RegExp.lastMatch.length);}}
|
14 |
+
return value;},readCount:function(count){var buffer="";while(count--){buffer+=this.read();}
|
15 |
+
return buffer;}};function SyntaxError(message,line,col){this.col=col;this.line=line;this.message=message;}
|
16 |
+
SyntaxError.prototype=new Error();function SyntaxUnit(text,line,col,type){this.col=col;this.line=line;this.text=text;this.type=type;}
|
17 |
+
SyntaxUnit.fromToken=function(token){return new SyntaxUnit(token.value,token.startLine,token.startCol);};SyntaxUnit.prototype={constructor:SyntaxUnit,valueOf:function(){return this.toString();},toString:function(){return this.text;}};function TokenStreamBase(input,tokenData){this._reader=input?new StringReader(input.toString()):null;this._token=null;this._tokenData=tokenData;this._lt=[];this._ltIndex=0;this._ltIndexCache=[];}
|
18 |
+
TokenStreamBase.createTokenData=function(tokens){var nameMap=[],typeMap={},tokenData=tokens.concat([]),i=0,len=tokenData.length+1;tokenData.UNKNOWN=-1;tokenData.unshift({name:"EOF"});for(;i<len;i++){nameMap.push(tokenData[i].name);tokenData[tokenData[i].name]=i;if(tokenData[i].text){typeMap[tokenData[i].text]=i;}}
|
19 |
+
tokenData.name=function(tt){return nameMap[tt];};tokenData.type=function(c){return typeMap[c];};return tokenData;};TokenStreamBase.prototype={constructor:TokenStreamBase,match:function(tokenTypes,channel){if(!(tokenTypes instanceof Array)){tokenTypes=[tokenTypes];}
|
20 |
+
var tt=this.get(channel),i=0,len=tokenTypes.length;while(i<len){if(tt==tokenTypes[i++]){return true;}}
|
21 |
+
this.unget();return false;},mustMatch:function(tokenTypes,channel){var token;if(!(tokenTypes instanceof Array)){tokenTypes=[tokenTypes];}
|
22 |
+
if(!this.match.apply(this,arguments)){token=this.LT(1);throw new SyntaxError("Expected "+this._tokenData[tokenTypes[0]].name+" at line "+token.startLine+", col "+token.startCol+".",token.startLine,token.startCol);}},advance:function(tokenTypes,channel){while(this.LA(0)!==0&&!this.match(tokenTypes,channel)){this.get();}
|
23 |
+
return this.LA(0);},get:function(channel){var tokenInfo=this._tokenData,reader=this._reader,value,i=0,len=tokenInfo.length,found=false,token,info;if(this._lt.length&&this._ltIndex>=0&&this._ltIndex<this._lt.length){i++;this._token=this._lt[this._ltIndex++];info=tokenInfo[this._token.type];while((info.channel!==undefined&&channel!==info.channel)&&this._ltIndex<this._lt.length){this._token=this._lt[this._ltIndex++];info=tokenInfo[this._token.type];i++;}
|
24 |
+
if((info.channel===undefined||channel===info.channel)&&this._ltIndex<=this._lt.length){this._ltIndexCache.push(i);return this._token.type;}}
|
25 |
+
token=this._getToken();if(token.type>-1&&!tokenInfo[token.type].hide){token.channel=tokenInfo[token.type].channel;this._token=token;this._lt.push(token);this._ltIndexCache.push(this._lt.length-this._ltIndex+i);if(this._lt.length>5){this._lt.shift();}
|
26 |
+
if(this._ltIndexCache.length>5){this._ltIndexCache.shift();}
|
27 |
+
this._ltIndex=this._lt.length;}
|
28 |
+
info=tokenInfo[token.type];if(info&&(info.hide||(info.channel!==undefined&&channel!==info.channel))){return this.get(channel);}else{return token.type;}},LA:function(index){var total=index,tt;if(index>0){if(index>5){throw new Error("Too much lookahead.");}
|
29 |
+
while(total){tt=this.get();total--;}
|
30 |
+
while(total<index){this.unget();total++;}}else if(index<0){if(this._lt[this._ltIndex+index]){tt=this._lt[this._ltIndex+index].type;}else{throw new Error("Too much lookbehind.");}}else{tt=this._token.type;}
|
31 |
+
return tt;},LT:function(index){this.LA(index);return this._lt[this._ltIndex+index-1];},peek:function(){return this.LA(1);},token:function(){return this._token;},tokenName:function(tokenType){if(tokenType<0||tokenType>this._tokenData.length){return"UNKNOWN_TOKEN";}else{return this._tokenData[tokenType].name;}},tokenType:function(tokenName){return this._tokenData[tokenName]||-1;},unget:function(){if(this._ltIndexCache.length){this._ltIndex-=this._ltIndexCache.pop();this._token=this._lt[this._ltIndex-1];}else{throw new Error("Too much lookahead.");}}};parserlib.util={StringReader:StringReader,SyntaxError:SyntaxError,SyntaxUnit:SyntaxUnit,EventTarget:EventTarget,TokenStreamBase:TokenStreamBase};})();(function(){var EventTarget=parserlib.util.EventTarget,TokenStreamBase=parserlib.util.TokenStreamBase,StringReader=parserlib.util.StringReader,SyntaxError=parserlib.util.SyntaxError,SyntaxUnit=parserlib.util.SyntaxUnit;var Colors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",activeBorder:"Active window border.",activecaption:"Active window caption.",appworkspace:"Background color of multiple document interface.",background:"Desktop background.",buttonface:"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonhighlight:"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonshadow:"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttontext:"Text on push buttons.",captiontext:"Text in caption, size box, and scrollbar arrow box.",graytext:"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",highlight:"Item(s) selected in a control.",highlighttext:"Text of item(s) selected in a control.",inactiveborder:"Inactive window border.",inactivecaption:"Inactive window caption.",inactivecaptiontext:"Color of text in an inactive caption.",infobackground:"Background color for tooltip controls.",infotext:"Text color for tooltip controls.",menu:"Menu background.",menutext:"Text in menus.",scrollbar:"Scroll bar gray area.",threeddarkshadow:"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedface:"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedhighlight:"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedlightshadow:"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedshadow:"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",window:"Window background.",windowframe:"Window frame.",windowtext:"Text in windows."};function Combinator(text,line,col){SyntaxUnit.call(this,text,line,col,Parser.COMBINATOR_TYPE);this.type="unknown";if(/^\s+$/.test(text)){this.type="descendant";}else if(text==">"){this.type="child";}else if(text=="+"){this.type="adjacent-sibling";}else if(text=="~"){this.type="sibling";}}
|
32 |
+
Combinator.prototype=new SyntaxUnit();Combinator.prototype.constructor=Combinator;function MediaFeature(name,value){SyntaxUnit.call(this,"("+name+(value!==null?":"+value:"")+")",name.startLine,name.startCol,Parser.MEDIA_FEATURE_TYPE);this.name=name;this.value=value;}
|
33 |
+
MediaFeature.prototype=new SyntaxUnit();MediaFeature.prototype.constructor=MediaFeature;function MediaQuery(modifier,mediaType,features,line,col){SyntaxUnit.call(this,(modifier?modifier+" ":"")+(mediaType?mediaType:"")+(mediaType&&features.length>0?" and ":"")+features.join(" and "),line,col,Parser.MEDIA_QUERY_TYPE);this.modifier=modifier;this.mediaType=mediaType;this.features=features;}
|
34 |
+
MediaQuery.prototype=new SyntaxUnit();MediaQuery.prototype.constructor=MediaQuery;function Parser(options){EventTarget.call(this);this.options=options||{};this._tokenStream=null;}
|
35 |
+
Parser.DEFAULT_TYPE=0;Parser.COMBINATOR_TYPE=1;Parser.MEDIA_FEATURE_TYPE=2;Parser.MEDIA_QUERY_TYPE=3;Parser.PROPERTY_NAME_TYPE=4;Parser.PROPERTY_VALUE_TYPE=5;Parser.PROPERTY_VALUE_PART_TYPE=6;Parser.SELECTOR_TYPE=7;Parser.SELECTOR_PART_TYPE=8;Parser.SELECTOR_SUB_PART_TYPE=9;Parser.prototype=function(){var proto=new EventTarget(),prop,additions={constructor:Parser,DEFAULT_TYPE:0,COMBINATOR_TYPE:1,MEDIA_FEATURE_TYPE:2,MEDIA_QUERY_TYPE:3,PROPERTY_NAME_TYPE:4,PROPERTY_VALUE_TYPE:5,PROPERTY_VALUE_PART_TYPE:6,SELECTOR_TYPE:7,SELECTOR_PART_TYPE:8,SELECTOR_SUB_PART_TYPE:9,_stylesheet:function(){var tokenStream=this._tokenStream,charset=null,count,token,tt;this.fire("startstylesheet");this._charset();this._skipCruft();while(tokenStream.peek()==Tokens.IMPORT_SYM){this._import();this._skipCruft();}
|
36 |
+
while(tokenStream.peek()==Tokens.NAMESPACE_SYM){this._namespace();this._skipCruft();}
|
37 |
+
tt=tokenStream.peek();while(tt>Tokens.EOF){try{switch(tt){case Tokens.MEDIA_SYM:this._media();this._skipCruft();break;case Tokens.PAGE_SYM:this._page();this._skipCruft();break;case Tokens.FONT_FACE_SYM:this._font_face();this._skipCruft();break;case Tokens.KEYFRAMES_SYM:this._keyframes();this._skipCruft();break;case Tokens.VIEWPORT_SYM:this._viewport();this._skipCruft();break;case Tokens.UNKNOWN_SYM:tokenStream.get();if(!this.options.strict){this.fire({type:"error",error:null,message:"Unknown @ rule: "+tokenStream.LT(0).value+".",line:tokenStream.LT(0).startLine,col:tokenStream.LT(0).startCol});count=0;while(tokenStream.advance([Tokens.LBRACE,Tokens.RBRACE])==Tokens.LBRACE){count++;}
|
38 |
+
while(count){tokenStream.advance([Tokens.RBRACE]);count--;}}else{throw new SyntaxError("Unknown @ rule.",tokenStream.LT(0).startLine,tokenStream.LT(0).startCol);}
|
39 |
+
break;case Tokens.S:this._readWhitespace();break;default:if(!this._ruleset()){switch(tt){case Tokens.CHARSET_SYM:token=tokenStream.LT(1);this._charset(false);throw new SyntaxError("@charset not allowed here.",token.startLine,token.startCol);case Tokens.IMPORT_SYM:token=tokenStream.LT(1);this._import(false);throw new SyntaxError("@import not allowed here.",token.startLine,token.startCol);case Tokens.NAMESPACE_SYM:token=tokenStream.LT(1);this._namespace(false);throw new SyntaxError("@namespace not allowed here.",token.startLine,token.startCol);default:tokenStream.get();this._unexpectedToken(tokenStream.token());}}}}catch(ex){if(ex instanceof SyntaxError&&!this.options.strict){this.fire({type:"error",error:ex,message:ex.message,line:ex.line,col:ex.col});}else{throw ex;}}
|
40 |
+
tt=tokenStream.peek();}
|
41 |
+
if(tt!=Tokens.EOF){this._unexpectedToken(tokenStream.token());}
|
42 |
+
this.fire("endstylesheet");},_charset:function(emit){var tokenStream=this._tokenStream,charset,token,line,col;if(tokenStream.match(Tokens.CHARSET_SYM)){line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();tokenStream.mustMatch(Tokens.STRING);token=tokenStream.token();charset=token.value;this._readWhitespace();tokenStream.mustMatch(Tokens.SEMICOLON);if(emit!==false){this.fire({type:"charset",charset:charset,line:line,col:col});}}},_import:function(emit){var tokenStream=this._tokenStream,tt,uri,importToken,mediaList=[];tokenStream.mustMatch(Tokens.IMPORT_SYM);importToken=tokenStream.token();this._readWhitespace();tokenStream.mustMatch([Tokens.STRING,Tokens.URI]);uri=tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1");this._readWhitespace();mediaList=this._media_query_list();tokenStream.mustMatch(Tokens.SEMICOLON);this._readWhitespace();if(emit!==false){this.fire({type:"import",uri:uri,media:mediaList,line:importToken.startLine,col:importToken.startCol});}},_namespace:function(emit){var tokenStream=this._tokenStream,line,col,prefix,uri;tokenStream.mustMatch(Tokens.NAMESPACE_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();if(tokenStream.match(Tokens.IDENT)){prefix=tokenStream.token().value;this._readWhitespace();}
|
43 |
+
tokenStream.mustMatch([Tokens.STRING,Tokens.URI]);uri=tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1");this._readWhitespace();tokenStream.mustMatch(Tokens.SEMICOLON);this._readWhitespace();if(emit!==false){this.fire({type:"namespace",prefix:prefix,uri:uri,line:line,col:col});}},_media:function(){var tokenStream=this._tokenStream,line,col,mediaList;tokenStream.mustMatch(Tokens.MEDIA_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();mediaList=this._media_query_list();tokenStream.mustMatch(Tokens.LBRACE);this._readWhitespace();this.fire({type:"startmedia",media:mediaList,line:line,col:col});while(true){if(tokenStream.peek()==Tokens.PAGE_SYM){this._page();}else if(tokenStream.peek()==Tokens.FONT_FACE_SYM){this._font_face();}else if(!this._ruleset()){break;}}
|
44 |
+
tokenStream.mustMatch(Tokens.RBRACE);this._readWhitespace();this.fire({type:"endmedia",media:mediaList,line:line,col:col});},_media_query_list:function(){var tokenStream=this._tokenStream,mediaList=[];this._readWhitespace();if(tokenStream.peek()==Tokens.IDENT||tokenStream.peek()==Tokens.LPAREN){mediaList.push(this._media_query());}
|
45 |
+
while(tokenStream.match(Tokens.COMMA)){this._readWhitespace();mediaList.push(this._media_query());}
|
46 |
+
return mediaList;},_media_query:function(){var tokenStream=this._tokenStream,type=null,ident=null,token=null,expressions=[];if(tokenStream.match(Tokens.IDENT)){ident=tokenStream.token().value.toLowerCase();if(ident!="only"&&ident!="not"){tokenStream.unget();ident=null;}else{token=tokenStream.token();}}
|
47 |
+
this._readWhitespace();if(tokenStream.peek()==Tokens.IDENT){type=this._media_type();if(token===null){token=tokenStream.token();}}else if(tokenStream.peek()==Tokens.LPAREN){if(token===null){token=tokenStream.LT(1);}
|
48 |
+
expressions.push(this._media_expression());}
|
49 |
+
if(type===null&&expressions.length===0){return null;}else{this._readWhitespace();while(tokenStream.match(Tokens.IDENT)){if(tokenStream.token().value.toLowerCase()!="and"){this._unexpectedToken(tokenStream.token());}
|
50 |
+
this._readWhitespace();expressions.push(this._media_expression());}}
|
51 |
+
return new MediaQuery(ident,type,expressions,token.startLine,token.startCol);},_media_type:function(){return this._media_feature();},_media_expression:function(){var tokenStream=this._tokenStream,feature=null,token,expression=null;tokenStream.mustMatch(Tokens.LPAREN);feature=this._media_feature();this._readWhitespace();if(tokenStream.match(Tokens.COLON)){this._readWhitespace();token=tokenStream.LT(1);expression=this._expression();}
|
52 |
+
tokenStream.mustMatch(Tokens.RPAREN);this._readWhitespace();return new MediaFeature(feature,(expression?new SyntaxUnit(expression,token.startLine,token.startCol):null));},_media_feature:function(){var tokenStream=this._tokenStream;tokenStream.mustMatch(Tokens.IDENT);return SyntaxUnit.fromToken(tokenStream.token());},_page:function(){var tokenStream=this._tokenStream,line,col,identifier=null,pseudoPage=null;tokenStream.mustMatch(Tokens.PAGE_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();if(tokenStream.match(Tokens.IDENT)){identifier=tokenStream.token().value;if(identifier.toLowerCase()==="auto"){this._unexpectedToken(tokenStream.token());}}
|
53 |
+
if(tokenStream.peek()==Tokens.COLON){pseudoPage=this._pseudo_page();}
|
54 |
+
this._readWhitespace();this.fire({type:"startpage",id:identifier,pseudo:pseudoPage,line:line,col:col});this._readDeclarations(true,true);this.fire({type:"endpage",id:identifier,pseudo:pseudoPage,line:line,col:col});},_margin:function(){var tokenStream=this._tokenStream,line,col,marginSym=this._margin_sym();if(marginSym){line=tokenStream.token().startLine;col=tokenStream.token().startCol;this.fire({type:"startpagemargin",margin:marginSym,line:line,col:col});this._readDeclarations(true);this.fire({type:"endpagemargin",margin:marginSym,line:line,col:col});return true;}else{return false;}},_margin_sym:function(){var tokenStream=this._tokenStream;if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM,Tokens.TOPLEFT_SYM,Tokens.TOPCENTER_SYM,Tokens.TOPRIGHT_SYM,Tokens.TOPRIGHTCORNER_SYM,Tokens.BOTTOMLEFTCORNER_SYM,Tokens.BOTTOMLEFT_SYM,Tokens.BOTTOMCENTER_SYM,Tokens.BOTTOMRIGHT_SYM,Tokens.BOTTOMRIGHTCORNER_SYM,Tokens.LEFTTOP_SYM,Tokens.LEFTMIDDLE_SYM,Tokens.LEFTBOTTOM_SYM,Tokens.RIGHTTOP_SYM,Tokens.RIGHTMIDDLE_SYM,Tokens.RIGHTBOTTOM_SYM]))
|
55 |
+
{return SyntaxUnit.fromToken(tokenStream.token());}else{return null;}},_pseudo_page:function(){var tokenStream=this._tokenStream;tokenStream.mustMatch(Tokens.COLON);tokenStream.mustMatch(Tokens.IDENT);return tokenStream.token().value;},_font_face:function(){var tokenStream=this._tokenStream,line,col;tokenStream.mustMatch(Tokens.FONT_FACE_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();this.fire({type:"startfontface",line:line,col:col});this._readDeclarations(true);this.fire({type:"endfontface",line:line,col:col});},_viewport:function(){var tokenStream=this._tokenStream,line,col;tokenStream.mustMatch(Tokens.VIEWPORT_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();this.fire({type:"startviewport",line:line,col:col});this._readDeclarations(true);this.fire({type:"endviewport",line:line,col:col});},_operator:function(inFunction){var tokenStream=this._tokenStream,token=null;if(tokenStream.match([Tokens.SLASH,Tokens.COMMA])||(inFunction&&tokenStream.match([Tokens.PLUS,Tokens.STAR,Tokens.MINUS]))){token=tokenStream.token();this._readWhitespace();}
|
56 |
+
return token?PropertyValuePart.fromToken(token):null;},_combinator:function(){var tokenStream=this._tokenStream,value=null,token;if(tokenStream.match([Tokens.PLUS,Tokens.GREATER,Tokens.TILDE])){token=tokenStream.token();value=new Combinator(token.value,token.startLine,token.startCol);this._readWhitespace();}
|
57 |
+
return value;},_unary_operator:function(){var tokenStream=this._tokenStream;if(tokenStream.match([Tokens.MINUS,Tokens.PLUS])){return tokenStream.token().value;}else{return null;}},_property:function(){var tokenStream=this._tokenStream,value=null,hack=null,tokenValue,token,line,col;if(tokenStream.peek()==Tokens.STAR&&this.options.starHack){tokenStream.get();token=tokenStream.token();hack=token.value;line=token.startLine;col=token.startCol;}
|
58 |
+
if(tokenStream.match(Tokens.IDENT)){token=tokenStream.token();tokenValue=token.value;if(tokenValue.charAt(0)=="_"&&this.options.underscoreHack){hack="_";tokenValue=tokenValue.substring(1);}
|
59 |
+
value=new PropertyName(tokenValue,hack,(line||token.startLine),(col||token.startCol));this._readWhitespace();}
|
60 |
+
return value;},_ruleset:function(){var tokenStream=this._tokenStream,tt,selectors;try{selectors=this._selectors_group();}catch(ex){if(ex instanceof SyntaxError&&!this.options.strict){this.fire({type:"error",error:ex,message:ex.message,line:ex.line,col:ex.col});tt=tokenStream.advance([Tokens.RBRACE]);if(tt==Tokens.RBRACE){}else{throw ex;}}else{throw ex;}
|
61 |
+
return true;}
|
62 |
+
if(selectors){this.fire({type:"startrule",selectors:selectors,line:selectors[0].line,col:selectors[0].col});this._readDeclarations(true);this.fire({type:"endrule",selectors:selectors,line:selectors[0].line,col:selectors[0].col});}
|
63 |
+
return selectors;},_selectors_group:function(){var tokenStream=this._tokenStream,selectors=[],selector;selector=this._selector();if(selector!==null){selectors.push(selector);while(tokenStream.match(Tokens.COMMA)){this._readWhitespace();selector=this._selector();if(selector!==null){selectors.push(selector);}else{this._unexpectedToken(tokenStream.LT(1));}}}
|
64 |
+
return selectors.length?selectors:null;},_selector:function(){var tokenStream=this._tokenStream,selector=[],nextSelector=null,combinator=null,ws=null;nextSelector=this._simple_selector_sequence();if(nextSelector===null){return null;}
|
65 |
+
selector.push(nextSelector);do{combinator=this._combinator();if(combinator!==null){selector.push(combinator);nextSelector=this._simple_selector_sequence();if(nextSelector===null){this._unexpectedToken(tokenStream.LT(1));}else{selector.push(nextSelector);}}else{if(this._readWhitespace()){ws=new Combinator(tokenStream.token().value,tokenStream.token().startLine,tokenStream.token().startCol);combinator=this._combinator();nextSelector=this._simple_selector_sequence();if(nextSelector===null){if(combinator!==null){this._unexpectedToken(tokenStream.LT(1));}}else{if(combinator!==null){selector.push(combinator);}else{selector.push(ws);}
|
66 |
+
selector.push(nextSelector);}}else{break;}}}while(true);return new Selector(selector,selector[0].line,selector[0].col);},_simple_selector_sequence:function(){var tokenStream=this._tokenStream,elementName=null,modifiers=[],selectorText="",components=[function(){return tokenStream.match(Tokens.HASH)?new SelectorSubPart(tokenStream.token().value,"id",tokenStream.token().startLine,tokenStream.token().startCol):null;},this._class,this._attrib,this._pseudo,this._negation],i=0,len=components.length,component=null,found=false,line,col;line=tokenStream.LT(1).startLine;col=tokenStream.LT(1).startCol;elementName=this._type_selector();if(!elementName){elementName=this._universal();}
|
67 |
+
if(elementName!==null){selectorText+=elementName;}
|
68 |
+
while(true){if(tokenStream.peek()===Tokens.S){break;}
|
69 |
+
while(i<len&&component===null){component=components[i++].call(this);}
|
70 |
+
if(component===null){if(selectorText===""){return null;}else{break;}}else{i=0;modifiers.push(component);selectorText+=component.toString();component=null;}}
|
71 |
+
return selectorText!==""?new SelectorPart(elementName,modifiers,selectorText,line,col):null;},_type_selector:function(){var tokenStream=this._tokenStream,ns=this._namespace_prefix(),elementName=this._element_name();if(!elementName){if(ns){tokenStream.unget();if(ns.length>1){tokenStream.unget();}}
|
72 |
+
return null;}else{if(ns){elementName.text=ns+elementName.text;elementName.col-=ns.length;}
|
73 |
+
return elementName;}},_class:function(){var tokenStream=this._tokenStream,token;if(tokenStream.match(Tokens.DOT)){tokenStream.mustMatch(Tokens.IDENT);token=tokenStream.token();return new SelectorSubPart("."+token.value,"class",token.startLine,token.startCol-1);}else{return null;}},_element_name:function(){var tokenStream=this._tokenStream,token;if(tokenStream.match(Tokens.IDENT)){token=tokenStream.token();return new SelectorSubPart(token.value,"elementName",token.startLine,token.startCol);}else{return null;}},_namespace_prefix:function(){var tokenStream=this._tokenStream,value="";if(tokenStream.LA(1)===Tokens.PIPE||tokenStream.LA(2)===Tokens.PIPE){if(tokenStream.match([Tokens.IDENT,Tokens.STAR])){value+=tokenStream.token().value;}
|
74 |
+
tokenStream.mustMatch(Tokens.PIPE);value+="|";}
|
75 |
+
return value.length?value:null;},_universal:function(){var tokenStream=this._tokenStream,value="",ns;ns=this._namespace_prefix();if(ns){value+=ns;}
|
76 |
+
if(tokenStream.match(Tokens.STAR)){value+="*";}
|
77 |
+
return value.length?value:null;},_attrib:function(){var tokenStream=this._tokenStream,value=null,ns,token;if(tokenStream.match(Tokens.LBRACKET)){token=tokenStream.token();value=token.value;value+=this._readWhitespace();ns=this._namespace_prefix();if(ns){value+=ns;}
|
78 |
+
tokenStream.mustMatch(Tokens.IDENT);value+=tokenStream.token().value;value+=this._readWhitespace();if(tokenStream.match([Tokens.PREFIXMATCH,Tokens.SUFFIXMATCH,Tokens.SUBSTRINGMATCH,Tokens.EQUALS,Tokens.INCLUDES,Tokens.DASHMATCH])){value+=tokenStream.token().value;value+=this._readWhitespace();tokenStream.mustMatch([Tokens.IDENT,Tokens.STRING]);value+=tokenStream.token().value;value+=this._readWhitespace();}
|
79 |
+
tokenStream.mustMatch(Tokens.RBRACKET);return new SelectorSubPart(value+"]","attribute",token.startLine,token.startCol);}else{return null;}},_pseudo:function(){var tokenStream=this._tokenStream,pseudo=null,colons=":",line,col;if(tokenStream.match(Tokens.COLON)){if(tokenStream.match(Tokens.COLON)){colons+=":";}
|
80 |
+
if(tokenStream.match(Tokens.IDENT)){pseudo=tokenStream.token().value;line=tokenStream.token().startLine;col=tokenStream.token().startCol-colons.length;}else if(tokenStream.peek()==Tokens.FUNCTION){line=tokenStream.LT(1).startLine;col=tokenStream.LT(1).startCol-colons.length;pseudo=this._functional_pseudo();}
|
81 |
+
if(pseudo){pseudo=new SelectorSubPart(colons+pseudo,"pseudo",line,col);}}
|
82 |
+
return pseudo;},_functional_pseudo:function(){var tokenStream=this._tokenStream,value=null;if(tokenStream.match(Tokens.FUNCTION)){value=tokenStream.token().value;value+=this._readWhitespace();value+=this._expression();tokenStream.mustMatch(Tokens.RPAREN);value+=")";}
|
83 |
+
return value;},_expression:function(){var tokenStream=this._tokenStream,value="";while(tokenStream.match([Tokens.PLUS,Tokens.MINUS,Tokens.DIMENSION,Tokens.NUMBER,Tokens.STRING,Tokens.IDENT,Tokens.LENGTH,Tokens.FREQ,Tokens.ANGLE,Tokens.TIME,Tokens.RESOLUTION,Tokens.SLASH])){value+=tokenStream.token().value;value+=this._readWhitespace();}
|
84 |
+
return value.length?value:null;},_negation:function(){var tokenStream=this._tokenStream,line,col,value="",arg,subpart=null;if(tokenStream.match(Tokens.NOT)){value=tokenStream.token().value;line=tokenStream.token().startLine;col=tokenStream.token().startCol;value+=this._readWhitespace();arg=this._negation_arg();value+=arg;value+=this._readWhitespace();tokenStream.match(Tokens.RPAREN);value+=tokenStream.token().value;subpart=new SelectorSubPart(value,"not",line,col);subpart.args.push(arg);}
|
85 |
+
return subpart;},_negation_arg:function(){var tokenStream=this._tokenStream,args=[this._type_selector,this._universal,function(){return tokenStream.match(Tokens.HASH)?new SelectorSubPart(tokenStream.token().value,"id",tokenStream.token().startLine,tokenStream.token().startCol):null;},this._class,this._attrib,this._pseudo],arg=null,i=0,len=args.length,elementName,line,col,part;line=tokenStream.LT(1).startLine;col=tokenStream.LT(1).startCol;while(i<len&&arg===null){arg=args[i].call(this);i++;}
|
86 |
+
if(arg===null){this._unexpectedToken(tokenStream.LT(1));}
|
87 |
+
if(arg.type=="elementName"){part=new SelectorPart(arg,[],arg.toString(),line,col);}else{part=new SelectorPart(null,[arg],arg.toString(),line,col);}
|
88 |
+
return part;},_declaration:function(){var tokenStream=this._tokenStream,property=null,expr=null,prio=null,error=null,invalid=null,propertyName="";property=this._property();if(property!==null){tokenStream.mustMatch(Tokens.COLON);this._readWhitespace();expr=this._expr();if(!expr||expr.length===0){this._unexpectedToken(tokenStream.LT(1));}
|
89 |
+
prio=this._prio();propertyName=property.toString();if(this.options.starHack&&property.hack=="*"||this.options.underscoreHack&&property.hack=="_"){propertyName=property.text;}
|
90 |
+
try{this._validateProperty(propertyName,expr);}catch(ex){invalid=ex;}
|
91 |
+
this.fire({type:"property",property:property,value:expr,important:prio,line:property.line,col:property.col,invalid:invalid});return true;}else{return false;}},_prio:function(){var tokenStream=this._tokenStream,result=tokenStream.match(Tokens.IMPORTANT_SYM);this._readWhitespace();return result;},_expr:function(inFunction){var tokenStream=this._tokenStream,values=[],value=null,operator=null;value=this._term();if(value!==null){values.push(value);do{operator=this._operator(inFunction);if(operator){values.push(operator);}
|
92 |
+
value=this._term();if(value===null){break;}else{values.push(value);}}while(true);}
|
93 |
+
return values.length>0?new PropertyValue(values,values[0].line,values[0].col):null;},_term:function(){var tokenStream=this._tokenStream,unary=null,value=null,token,line,col;unary=this._unary_operator();if(unary!==null){line=tokenStream.token().startLine;col=tokenStream.token().startCol;}
|
94 |
+
if(tokenStream.peek()==Tokens.IE_FUNCTION&&this.options.ieFilters){value=this._ie_function();if(unary===null){line=tokenStream.token().startLine;col=tokenStream.token().startCol;}}else if(tokenStream.match([Tokens.NUMBER,Tokens.PERCENTAGE,Tokens.LENGTH,Tokens.ANGLE,Tokens.TIME,Tokens.FREQ,Tokens.STRING,Tokens.IDENT,Tokens.URI,Tokens.UNICODE_RANGE])){value=tokenStream.token().value;if(unary===null){line=tokenStream.token().startLine;col=tokenStream.token().startCol;}
|
95 |
+
this._readWhitespace();}else{token=this._hexcolor();if(token===null){if(unary===null){line=tokenStream.LT(1).startLine;col=tokenStream.LT(1).startCol;}
|
96 |
+
if(value===null){if(tokenStream.LA(3)==Tokens.EQUALS&&this.options.ieFilters){value=this._ie_function();}else{value=this._function();}}}else{value=token.value;if(unary===null){line=token.startLine;col=token.startCol;}}}
|
97 |
+
return value!==null?new PropertyValuePart(unary!==null?unary+value:value,line,col):null;},_function:function(){var tokenStream=this._tokenStream,functionText=null,expr=null,lt;if(tokenStream.match(Tokens.FUNCTION)){functionText=tokenStream.token().value;this._readWhitespace();expr=this._expr(true);functionText+=expr;if(this.options.ieFilters&&tokenStream.peek()==Tokens.EQUALS){do{if(this._readWhitespace()){functionText+=tokenStream.token().value;}
|
98 |
+
if(tokenStream.LA(0)==Tokens.COMMA){functionText+=tokenStream.token().value;}
|
99 |
+
tokenStream.match(Tokens.IDENT);functionText+=tokenStream.token().value;tokenStream.match(Tokens.EQUALS);functionText+=tokenStream.token().value;lt=tokenStream.peek();while(lt!=Tokens.COMMA&<!=Tokens.S&<!=Tokens.RPAREN){tokenStream.get();functionText+=tokenStream.token().value;lt=tokenStream.peek();}}while(tokenStream.match([Tokens.COMMA,Tokens.S]));}
|
100 |
+
tokenStream.match(Tokens.RPAREN);functionText+=")";this._readWhitespace();}
|
101 |
+
return functionText;},_ie_function:function(){var tokenStream=this._tokenStream,functionText=null,expr=null,lt;if(tokenStream.match([Tokens.IE_FUNCTION,Tokens.FUNCTION])){functionText=tokenStream.token().value;do{if(this._readWhitespace()){functionText+=tokenStream.token().value;}
|
102 |
+
if(tokenStream.LA(0)==Tokens.COMMA){functionText+=tokenStream.token().value;}
|
103 |
+
tokenStream.match(Tokens.IDENT);functionText+=tokenStream.token().value;tokenStream.match(Tokens.EQUALS);functionText+=tokenStream.token().value;lt=tokenStream.peek();while(lt!=Tokens.COMMA&<!=Tokens.S&<!=Tokens.RPAREN){tokenStream.get();functionText+=tokenStream.token().value;lt=tokenStream.peek();}}while(tokenStream.match([Tokens.COMMA,Tokens.S]));tokenStream.match(Tokens.RPAREN);functionText+=")";this._readWhitespace();}
|
104 |
+
return functionText;},_hexcolor:function(){var tokenStream=this._tokenStream,token=null,color;if(tokenStream.match(Tokens.HASH)){token=tokenStream.token();color=token.value;if(!/#[a-f0-9]{3,6}/i.test(color)){throw new SyntaxError("Expected a hex color but found '"+color+"' at line "+token.startLine+", col "+token.startCol+".",token.startLine,token.startCol);}
|
105 |
+
this._readWhitespace();}
|
106 |
+
return token;},_keyframes:function(){var tokenStream=this._tokenStream,token,tt,name,prefix="";tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);token=tokenStream.token();if(/^@\-([^\-]+)\-/.test(token.value)){prefix=RegExp.$1;}
|
107 |
+
this._readWhitespace();name=this._keyframe_name();this._readWhitespace();tokenStream.mustMatch(Tokens.LBRACE);this.fire({type:"startkeyframes",name:name,prefix:prefix,line:token.startLine,col:token.startCol});this._readWhitespace();tt=tokenStream.peek();while(tt==Tokens.IDENT||tt==Tokens.PERCENTAGE){this._keyframe_rule();this._readWhitespace();tt=tokenStream.peek();}
|
108 |
+
this.fire({type:"endkeyframes",name:name,prefix:prefix,line:token.startLine,col:token.startCol});this._readWhitespace();tokenStream.mustMatch(Tokens.RBRACE);},_keyframe_name:function(){var tokenStream=this._tokenStream,token;tokenStream.mustMatch([Tokens.IDENT,Tokens.STRING]);return SyntaxUnit.fromToken(tokenStream.token());},_keyframe_rule:function(){var tokenStream=this._tokenStream,token,keyList=this._key_list();this.fire({type:"startkeyframerule",keys:keyList,line:keyList[0].line,col:keyList[0].col});this._readDeclarations(true);this.fire({type:"endkeyframerule",keys:keyList,line:keyList[0].line,col:keyList[0].col});},_key_list:function(){var tokenStream=this._tokenStream,token,key,keyList=[];keyList.push(this._key());this._readWhitespace();while(tokenStream.match(Tokens.COMMA)){this._readWhitespace();keyList.push(this._key());this._readWhitespace();}
|
109 |
+
return keyList;},_key:function(){var tokenStream=this._tokenStream,token;if(tokenStream.match(Tokens.PERCENTAGE)){return SyntaxUnit.fromToken(tokenStream.token());}else if(tokenStream.match(Tokens.IDENT)){token=tokenStream.token();if(/from|to/i.test(token.value)){return SyntaxUnit.fromToken(token);}
|
110 |
+
tokenStream.unget();}
|
111 |
+
this._unexpectedToken(tokenStream.LT(1));},_skipCruft:function(){while(this._tokenStream.match([Tokens.S,Tokens.CDO,Tokens.CDC])){}},_readDeclarations:function(checkStart,readMargins){var tokenStream=this._tokenStream,tt;this._readWhitespace();if(checkStart){tokenStream.mustMatch(Tokens.LBRACE);}
|
112 |
+
this._readWhitespace();try{while(true){if(tokenStream.match(Tokens.SEMICOLON)||(readMargins&&this._margin())){}else if(this._declaration()){if(!tokenStream.match(Tokens.SEMICOLON)){break;}}else{break;}
|
113 |
+
this._readWhitespace();}
|
114 |
+
tokenStream.mustMatch(Tokens.RBRACE);this._readWhitespace();}catch(ex){if(ex instanceof SyntaxError&&!this.options.strict){this.fire({type:"error",error:ex,message:ex.message,line:ex.line,col:ex.col});tt=tokenStream.advance([Tokens.SEMICOLON,Tokens.RBRACE]);if(tt==Tokens.SEMICOLON){this._readDeclarations(false,readMargins);}else if(tt!=Tokens.RBRACE){throw ex;}}else{throw ex;}}},_readWhitespace:function(){var tokenStream=this._tokenStream,ws="";while(tokenStream.match(Tokens.S)){ws+=tokenStream.token().value;}
|
115 |
+
return ws;},_unexpectedToken:function(token){throw new SyntaxError("Unexpected token '"+token.value+"' at line "+token.startLine+", col "+token.startCol+".",token.startLine,token.startCol);},_verifyEnd:function(){if(this._tokenStream.LA(1)!=Tokens.EOF){this._unexpectedToken(this._tokenStream.LT(1));}},_validateProperty:function(property,value){Validation.validate(property,value);},parse:function(input){this._tokenStream=new TokenStream(input,Tokens);this._stylesheet();},parseStyleSheet:function(input){return this.parse(input);},parseMediaQuery:function(input){this._tokenStream=new TokenStream(input,Tokens);var result=this._media_query();this._verifyEnd();return result;},parsePropertyValue:function(input){this._tokenStream=new TokenStream(input,Tokens);this._readWhitespace();var result=this._expr();this._readWhitespace();this._verifyEnd();return result;},parseRule:function(input){this._tokenStream=new TokenStream(input,Tokens);this._readWhitespace();var result=this._ruleset();this._readWhitespace();this._verifyEnd();return result;},parseSelector:function(input){this._tokenStream=new TokenStream(input,Tokens);this._readWhitespace();var result=this._selector();this._readWhitespace();this._verifyEnd();return result;},parseStyleAttribute:function(input){input+="}";this._tokenStream=new TokenStream(input,Tokens);this._readDeclarations();}};for(prop in additions){if(additions.hasOwnProperty(prop)){proto[prop]=additions[prop];}}
|
116 |
+
return proto;}();var Properties={"alignment-adjust":"auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>","alignment-baseline":"baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","animation":1,"animation-delay":{multi:"<time>",comma:true},"animation-direction":{multi:"normal | alternate",comma:true},"animation-duration":{multi:"<time>",comma:true},"animation-iteration-count":{multi:"<number> | infinite",comma:true},"animation-name":{multi:"none | <ident>",comma:true},"animation-play-state":{multi:"running | paused",comma:true},"animation-timing-function":1,"-moz-animation-delay":{multi:"<time>",comma:true},"-moz-animation-direction":{multi:"normal | alternate",comma:true},"-moz-animation-duration":{multi:"<time>",comma:true},"-moz-animation-iteration-count":{multi:"<number> | infinite",comma:true},"-moz-animation-name":{multi:"none | <ident>",comma:true},"-moz-animation-play-state":{multi:"running | paused",comma:true},"-ms-animation-delay":{multi:"<time>",comma:true},"-ms-animation-direction":{multi:"normal | alternate",comma:true},"-ms-animation-duration":{multi:"<time>",comma:true},"-ms-animation-iteration-count":{multi:"<number> | infinite",comma:true},"-ms-animation-name":{multi:"none | <ident>",comma:true},"-ms-animation-play-state":{multi:"running | paused",comma:true},"-webkit-animation-delay":{multi:"<time>",comma:true},"-webkit-animation-direction":{multi:"normal | alternate",comma:true},"-webkit-animation-duration":{multi:"<time>",comma:true},"-webkit-animation-iteration-count":{multi:"<number> | infinite",comma:true},"-webkit-animation-name":{multi:"none | <ident>",comma:true},"-webkit-animation-play-state":{multi:"running | paused",comma:true},"-o-animation-delay":{multi:"<time>",comma:true},"-o-animation-direction":{multi:"normal | alternate",comma:true},"-o-animation-duration":{multi:"<time>",comma:true},"-o-animation-iteration-count":{multi:"<number> | infinite",comma:true},"-o-animation-name":{multi:"none | <ident>",comma:true},"-o-animation-play-state":{multi:"running | paused",comma:true},"appearance":"icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit","azimuth":function(expression){var simple="<angle> | leftwards | rightwards | inherit",direction="left-side | far-left | left | center-left | center | center-right | right | far-right | right-side",behind=false,valid=false,part;if(!ValidationTypes.isAny(expression,simple)){if(ValidationTypes.isAny(expression,"behind")){behind=true;valid=true;}
|
117 |
+
if(ValidationTypes.isAny(expression,direction)){valid=true;if(!behind){ValidationTypes.isAny(expression,"behind");}}}
|
118 |
+
if(expression.hasNext()){part=expression.next();if(valid){throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected (<'azimuth'>) but found '"+part+"'.",part.line,part.col);}}},"backface-visibility":"visible | hidden","background":1,"background-attachment":{multi:"<attachment>",comma:true},"background-clip":{multi:"<box>",comma:true},"background-color":"<color> | inherit","background-image":{multi:"<bg-image>",comma:true},"background-origin":{multi:"<box>",comma:true},"background-position":{multi:"<bg-position>",comma:true},"background-repeat":{multi:"<repeat-style>"},"background-size":{multi:"<bg-size>",comma:true},"baseline-shift":"baseline | sub | super | <percentage> | <length>","behavior":1,"binding":1,"bleed":"<length>","bookmark-label":"<content> | <attr> | <string>","bookmark-level":"none | <integer>","bookmark-state":"open | closed","bookmark-target":"none | <uri> | <attr>","border":"<border-width> || <border-style> || <color>","border-bottom":"<border-width> || <border-style> || <color>","border-bottom-color":"<color> | inherit","border-bottom-left-radius":"<x-one-radius>","border-bottom-right-radius":"<x-one-radius>","border-bottom-style":"<border-style>","border-bottom-width":"<border-width>","border-collapse":"collapse | separate | inherit","border-color":{multi:"<color> | inherit",max:4},"border-image":1,"border-image-outset":{multi:"<length> | <number>",max:4},"border-image-repeat":{multi:"stretch | repeat | round",max:2},"border-image-slice":function(expression){var valid=false,numeric="<number> | <percentage>",fill=false,count=0,max=4,part;if(ValidationTypes.isAny(expression,"fill")){fill=true;valid=true;}
|
119 |
+
while(expression.hasNext()&&count<max){valid=ValidationTypes.isAny(expression,numeric);if(!valid){break;}
|
120 |
+
count++;}
|
121 |
+
if(!fill){ValidationTypes.isAny(expression,"fill");}else{valid=true;}
|
122 |
+
if(expression.hasNext()){part=expression.next();if(valid){throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected ([<number> | <percentage>]{1,4} && fill?) but found '"+part+"'.",part.line,part.col);}}},"border-image-source":"<image> | none","border-image-width":{multi:"<length> | <percentage> | <number> | auto",max:4},"border-left":"<border-width> || <border-style> || <color>","border-left-color":"<color> | inherit","border-left-style":"<border-style>","border-left-width":"<border-width>","border-radius":function(expression){var valid=false,simple="<length> | <percentage> | inherit",slash=false,fill=false,count=0,max=8,part;while(expression.hasNext()&&count<max){valid=ValidationTypes.isAny(expression,simple);if(!valid){if(expression.peek()=="/"&&count>0&&!slash){slash=true;max=count+5;expression.next();}else{break;}}
|
123 |
+
count++;}
|
124 |
+
if(expression.hasNext()){part=expression.next();if(valid){throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected (<'border-radius'>) but found '"+part+"'.",part.line,part.col);}}},"border-right":"<border-width> || <border-style> || <color>","border-right-color":"<color> | inherit","border-right-style":"<border-style>","border-right-width":"<border-width>","border-spacing":{multi:"<length> | inherit",max:2},"border-style":{multi:"<border-style>",max:4},"border-top":"<border-width> || <border-style> || <color>","border-top-color":"<color> | inherit","border-top-left-radius":"<x-one-radius>","border-top-right-radius":"<x-one-radius>","border-top-style":"<border-style>","border-top-width":"<border-width>","border-width":{multi:"<border-width>",max:4},"bottom":"<margin-width> | inherit","box-align":"start | end | center | baseline | stretch","box-decoration-break":"slice |clone","box-direction":"normal | reverse | inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single | multiple","box-ordinal-group":"<integer>","box-orient":"horizontal | vertical | inline-axis | block-axis | inherit","box-pack":"start | end | center | justify","box-shadow":function(expression){var result=false,part;if(!ValidationTypes.isAny(expression,"none")){Validation.multiProperty("<shadow>",expression,true,Infinity);}else{if(expression.hasNext()){part=expression.next();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}}},"box-sizing":"content-box | border-box | inherit","break-after":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-before":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-inside":"auto | avoid | avoid-page | avoid-column","caption-side":"top | bottom | inherit","clear":"none | right | left | both | inherit","clip":1,"color":"<color> | inherit","color-profile":1,"column-count":"<integer> | auto","column-fill":"auto | balance","column-gap":"<length> | normal","column-rule":"<border-width> || <border-style> || <color>","column-rule-color":"<color>","column-rule-style":"<border-style>","column-rule-width":"<border-width>","column-span":"none | all","column-width":"<length> | auto","columns":1,"content":1,"counter-increment":1,"counter-reset":1,"crop":"<shape> | auto","cue":"cue-after | cue-before | inherit","cue-after":1,"cue-before":1,"cursor":1,"direction":"ltr | rtl | inherit","display":"inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | box | inline-box | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box","dominant-baseline":1,"drop-initial-after-adjust":"central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>","drop-initial-after-align":"baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-before-adjust":"before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>","drop-initial-before-align":"caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-size":"auto | line | <length> | <percentage>","drop-initial-value":"initial | <integer>","elevation":"<angle> | below | level | above | higher | lower | inherit","empty-cells":"show | hide | inherit","filter":1,"fit":"fill | hidden | meet | slice","fit-position":1,"float":"left | right | none | inherit","float-offset":1,"font":1,"font-family":1,"font-size":"<absolute-size> | <relative-size> | <length> | <percentage> | inherit","font-size-adjust":"<number> | none | inherit","font-stretch":"normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit","font-style":"normal | italic | oblique | inherit","font-variant":"normal | small-caps | inherit","font-weight":"normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit","grid-cell-stacking":"columns | rows | layer","grid-column":1,"grid-columns":1,"grid-column-align":"start | end | center | stretch","grid-column-sizing":1,"grid-column-span":"<integer>","grid-flow":"none | rows | columns","grid-layer":"<integer>","grid-row":1,"grid-rows":1,"grid-row-align":"start | end | center | stretch","grid-row-span":"<integer>","grid-row-sizing":1,"hanging-punctuation":1,"height":"<margin-width> | inherit","hyphenate-after":"<integer> | auto","hyphenate-before":"<integer> | auto","hyphenate-character":"<string> | auto","hyphenate-lines":"no-limit | <integer>","hyphenate-resource":1,"hyphens":"none | manual | auto","icon":1,"image-orientation":"angle | auto","image-rendering":1,"image-resolution":1,"inline-box-align":"initial | last | <integer>","left":"<margin-width> | inherit","letter-spacing":"<length> | normal | inherit","line-height":"<number> | <length> | <percentage> | normal | inherit","line-break":"auto | loose | normal | strict","line-stacking":1,"line-stacking-ruby":"exclude-ruby | include-ruby","line-stacking-shift":"consider-shifts | disregard-shifts","line-stacking-strategy":"inline-line-height | block-line-height | max-height | grid-height","list-style":1,"list-style-image":"<uri> | none | inherit","list-style-position":"inside | outside | inherit","list-style-type":"disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit","margin":{multi:"<margin-width> | inherit",max:4},"margin-bottom":"<margin-width> | inherit","margin-left":"<margin-width> | inherit","margin-right":"<margin-width> | inherit","margin-top":"<margin-width> | inherit","mark":1,"mark-after":1,"mark-before":1,"marks":1,"marquee-direction":1,"marquee-play-count":1,"marquee-speed":1,"marquee-style":1,"max-height":"<length> | <percentage> | none | inherit","max-width":"<length> | <percentage> | none | inherit","min-height":"<length> | <percentage> | inherit","min-width":"<length> | <percentage> | inherit","move-to":1,"nav-down":1,"nav-index":1,"nav-left":1,"nav-right":1,"nav-up":1,"opacity":"<number> | inherit","orphans":"<integer> | inherit","outline":1,"outline-color":"<color> | invert | inherit","outline-offset":1,"outline-style":"<border-style> | inherit","outline-width":"<border-width> | inherit","overflow":"visible | hidden | scroll | auto | inherit","overflow-style":1,"overflow-x":1,"overflow-y":1,"padding":{multi:"<padding-width> | inherit",max:4},"padding-bottom":"<padding-width> | inherit","padding-left":"<padding-width> | inherit","padding-right":"<padding-width> | inherit","padding-top":"<padding-width> | inherit","page":1,"page-break-after":"auto | always | avoid | left | right | inherit","page-break-before":"auto | always | avoid | left | right | inherit","page-break-inside":"auto | avoid | inherit","page-policy":1,"pause":1,"pause-after":1,"pause-before":1,"perspective":1,"perspective-origin":1,"phonemes":1,"pitch":1,"pitch-range":1,"play-during":1,"pointer-events":"auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit","position":"static | relative | absolute | fixed | inherit","presentation-level":1,"punctuation-trim":1,"quotes":1,"rendering-intent":1,"resize":1,"rest":1,"rest-after":1,"rest-before":1,"richness":1,"right":"<margin-width> | inherit","rotation":1,"rotation-point":1,"ruby-align":1,"ruby-overhang":1,"ruby-position":1,"ruby-span":1,"size":1,"speak":"normal | none | spell-out | inherit","speak-header":"once | always | inherit","speak-numeral":"digits | continuous | inherit","speak-punctuation":"code | none | inherit","speech-rate":1,"src":1,"stress":1,"string-set":1,"table-layout":"auto | fixed | inherit","tab-size":"<integer> | <length>","target":1,"target-name":1,"target-new":1,"target-position":1,"text-align":"left | right | center | justify | inherit","text-align-last":1,"text-decoration":1,"text-emphasis":1,"text-height":1,"text-indent":"<length> | <percentage> | inherit","text-justify":"auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida","text-outline":1,"text-overflow":1,"text-rendering":"auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit","text-shadow":1,"text-transform":"capitalize | uppercase | lowercase | none | inherit","text-wrap":"normal | none | avoid","top":"<margin-width> | inherit","transform":1,"transform-origin":1,"transform-style":1,"transition":1,"transition-delay":1,"transition-duration":1,"transition-property":1,"transition-timing-function":1,"unicode-bidi":"normal | embed | bidi-override | inherit","user-modify":"read-only | read-write | write-only | inherit","user-select":"none | text | toggle | element | elements | all | inherit","vertical-align":"auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>","visibility":"visible | hidden | collapse | inherit","voice-balance":1,"voice-duration":1,"voice-family":1,"voice-pitch":1,"voice-pitch-range":1,"voice-rate":1,"voice-stress":1,"voice-volume":1,"volume":1,"white-space":"normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap","white-space-collapse":1,"widows":"<integer> | inherit","width":"<length> | <percentage> | auto | inherit","word-break":"normal | keep-all | break-all","word-spacing":"<length> | normal | inherit","word-wrap":1,"z-index":"<integer> | auto | inherit","zoom":"<number> | <percentage> | normal"};function PropertyName(text,hack,line,col){SyntaxUnit.call(this,text,line,col,Parser.PROPERTY_NAME_TYPE);this.hack=hack;}
|
125 |
+
PropertyName.prototype=new SyntaxUnit();PropertyName.prototype.constructor=PropertyName;PropertyName.prototype.toString=function(){return(this.hack?this.hack:"")+this.text;};function PropertyValue(parts,line,col){SyntaxUnit.call(this,parts.join(" "),line,col,Parser.PROPERTY_VALUE_TYPE);this.parts=parts;}
|
126 |
+
PropertyValue.prototype=new SyntaxUnit();PropertyValue.prototype.constructor=PropertyValue;function PropertyValueIterator(value){this._i=0;this._parts=value.parts;this._marks=[];this.value=value;}
|
127 |
+
PropertyValueIterator.prototype.count=function(){return this._parts.length;};PropertyValueIterator.prototype.isFirst=function(){return this._i===0;};PropertyValueIterator.prototype.hasNext=function(){return(this._i<this._parts.length);};PropertyValueIterator.prototype.mark=function(){this._marks.push(this._i);};PropertyValueIterator.prototype.peek=function(count){return this.hasNext()?this._parts[this._i+(count||0)]:null;};PropertyValueIterator.prototype.next=function(){return this.hasNext()?this._parts[this._i++]:null;};PropertyValueIterator.prototype.previous=function(){return this._i>0?this._parts[--this._i]:null;};PropertyValueIterator.prototype.restore=function(){if(this._marks.length){this._i=this._marks.pop();}};function PropertyValuePart(text,line,col){SyntaxUnit.call(this,text,line,col,Parser.PROPERTY_VALUE_PART_TYPE);this.type="unknown";var temp;if(/^([+\-]?[\d\.]+)([a-z]+)$/i.test(text)){this.type="dimension";this.value=+RegExp.$1;this.units=RegExp.$2;switch(this.units.toLowerCase()){case"em":case"rem":case"ex":case"px":case"cm":case"mm":case"in":case"pt":case"pc":case"ch":case"vh":case"vw":case"vm":this.type="length";break;case"deg":case"rad":case"grad":this.type="angle";break;case"ms":case"s":this.type="time";break;case"hz":case"khz":this.type="frequency";break;case"dpi":case"dpcm":this.type="resolution";break;}}else if(/^([+\-]?[\d\.]+)%$/i.test(text)){this.type="percentage";this.value=+RegExp.$1;}else if(/^([+\-]?[\d\.]+)%$/i.test(text)){this.type="percentage";this.value=+RegExp.$1;}else if(/^([+\-]?\d+)$/i.test(text)){this.type="integer";this.value=+RegExp.$1;}else if(/^([+\-]?[\d\.]+)$/i.test(text)){this.type="number";this.value=+RegExp.$1;}else if(/^#([a-f0-9]{3,6})/i.test(text)){this.type="color";temp=RegExp.$1;if(temp.length==3){this.red=parseInt(temp.charAt(0)+temp.charAt(0),16);this.green=parseInt(temp.charAt(1)+temp.charAt(1),16);this.blue=parseInt(temp.charAt(2)+temp.charAt(2),16);}else{this.red=parseInt(temp.substring(0,2),16);this.green=parseInt(temp.substring(2,4),16);this.blue=parseInt(temp.substring(4,6),16);}}else if(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)){this.type="color";this.red=+RegExp.$1;this.green=+RegExp.$2;this.blue=+RegExp.$3;}else if(/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){this.type="color";this.red=+RegExp.$1*255/100;this.green=+RegExp.$2*255/100;this.blue=+RegExp.$3*255/100;}else if(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)){this.type="color";this.red=+RegExp.$1;this.green=+RegExp.$2;this.blue=+RegExp.$3;this.alpha=+RegExp.$4;}else if(/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){this.type="color";this.red=+RegExp.$1*255/100;this.green=+RegExp.$2*255/100;this.blue=+RegExp.$3*255/100;this.alpha=+RegExp.$4;}else if(/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){this.type="color";this.hue=+RegExp.$1;this.saturation=+RegExp.$2/100;this.lightness=+RegExp.$3/100;}else if(/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){this.type="color";this.hue=+RegExp.$1;this.saturation=+RegExp.$2/100;this.lightness=+RegExp.$3/100;this.alpha=+RegExp.$4;}else if(/^url\(["']?([^\)"']+)["']?\)/i.test(text)){this.type="uri";this.uri=RegExp.$1;}else if(/^([^\(]+)\(/i.test(text)){this.type="function";this.name=RegExp.$1;this.value=text;}else if(/^["'][^"']*["']/.test(text)){this.type="string";this.value=eval(text);}else if(Colors[text.toLowerCase()]){this.type="color";temp=Colors[text.toLowerCase()].substring(1);this.red=parseInt(temp.substring(0,2),16);this.green=parseInt(temp.substring(2,4),16);this.blue=parseInt(temp.substring(4,6),16);}else if(/^[\,\/]$/.test(text)){this.type="operator";this.value=text;}else if(/^[a-z\-\u0080-\uFFFF][a-z0-9\-\u0080-\uFFFF]*$/i.test(text)){this.type="identifier";this.value=text;}}
|
128 |
+
PropertyValuePart.prototype=new SyntaxUnit();PropertyValuePart.prototype.constructor=PropertyValuePart;PropertyValuePart.fromToken=function(token){return new PropertyValuePart(token.value,token.startLine,token.startCol);};var Pseudos={":first-letter":1,":first-line":1,":before":1,":after":1};Pseudos.ELEMENT=1;Pseudos.CLASS=2;Pseudos.isElement=function(pseudo){return pseudo.indexOf("::")===0||Pseudos[pseudo.toLowerCase()]==Pseudos.ELEMENT;};function Selector(parts,line,col){SyntaxUnit.call(this,parts.join(" "),line,col,Parser.SELECTOR_TYPE);this.parts=parts;this.specificity=Specificity.calculate(this);}
|
129 |
+
Selector.prototype=new SyntaxUnit();Selector.prototype.constructor=Selector;function SelectorPart(elementName,modifiers,text,line,col){SyntaxUnit.call(this,text,line,col,Parser.SELECTOR_PART_TYPE);this.elementName=elementName;this.modifiers=modifiers;}
|
130 |
+
SelectorPart.prototype=new SyntaxUnit();SelectorPart.prototype.constructor=SelectorPart;function SelectorSubPart(text,type,line,col){SyntaxUnit.call(this,text,line,col,Parser.SELECTOR_SUB_PART_TYPE);this.type=type;this.args=[];}
|
131 |
+
SelectorSubPart.prototype=new SyntaxUnit();SelectorSubPart.prototype.constructor=SelectorSubPart;function Specificity(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d;}
|
132 |
+
Specificity.prototype={constructor:Specificity,compare:function(other){var comps=["a","b","c","d"],i,len;for(i=0,len=comps.length;i<len;i++){if(this[comps[i]]<other[comps[i]]){return-1;}else if(this[comps[i]]>other[comps[i]]){return 1;}}
|
133 |
+
return 0;},valueOf:function(){return(this.a*1000)+(this.b*100)+(this.c*10)+this.d;},toString:function(){return this.a+","+this.b+","+this.c+","+this.d;}};Specificity.calculate=function(selector){var i,len,part,b=0,c=0,d=0;function updateValues(part){var i,j,len,num,elementName=part.elementName?part.elementName.text:"",modifier;if(elementName&&elementName.charAt(elementName.length-1)!="*"){d++;}
|
134 |
+
for(i=0,len=part.modifiers.length;i<len;i++){modifier=part.modifiers[i];switch(modifier.type){case"class":case"attribute":c++;break;case"id":b++;break;case"pseudo":if(Pseudos.isElement(modifier.text)){d++;}else{c++;}
|
135 |
+
break;case"not":for(j=0,num=modifier.args.length;j<num;j++){updateValues(modifier.args[j]);}}}}
|
136 |
+
for(i=0,len=selector.parts.length;i<len;i++){part=selector.parts[i];if(part instanceof SelectorPart){updateValues(part);}}
|
137 |
+
return new Specificity(0,b,c,d);};var h=/^[0-9a-fA-F]$/,nonascii=/^[\u0080-\uFFFF]$/,nl=/\n|\r\n|\r|\f/;function isHexDigit(c){return c!==null&&h.test(c);}
|
138 |
+
function isDigit(c){return c!==null&&/\d/.test(c);}
|
139 |
+
function isWhitespace(c){return c!==null&&/\s/.test(c);}
|
140 |
+
function isNewLine(c){return c!==null&&nl.test(c);}
|
141 |
+
function isNameStart(c){return c!==null&&(/[a-z_\u0080-\uFFFF\\]/i.test(c));}
|
142 |
+
function isNameChar(c){return c!==null&&(isNameStart(c)||/[0-9\-\\]/.test(c));}
|
143 |
+
function isIdentStart(c){return c!==null&&(isNameStart(c)||/\-\\/.test(c));}
|
144 |
+
function mix(receiver,supplier){for(var prop in supplier){if(supplier.hasOwnProperty(prop)){receiver[prop]=supplier[prop];}}
|
145 |
+
return receiver;}
|
146 |
+
function TokenStream(input){TokenStreamBase.call(this,input,Tokens);}
|
147 |
+
TokenStream.prototype=mix(new TokenStreamBase(),{_getToken:function(channel){var c,reader=this._reader,token=null,startLine=reader.getLine(),startCol=reader.getCol();c=reader.read();while(c){switch(c){case"/":if(reader.peek()=="*"){token=this.commentToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
148 |
+
break;case"|":case"~":case"^":case"$":case"*":if(reader.peek()=="="){token=this.comparisonToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
149 |
+
break;case"\"":case"'":token=this.stringToken(c,startLine,startCol);break;case"#":if(isNameChar(reader.peek())){token=this.hashToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
150 |
+
break;case".":if(isDigit(reader.peek())){token=this.numberToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
151 |
+
break;case"-":if(reader.peek()=="-"){token=this.htmlCommentEndToken(c,startLine,startCol);}else if(isNameStart(reader.peek())){token=this.identOrFunctionToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
152 |
+
break;case"!":token=this.importantToken(c,startLine,startCol);break;case"@":token=this.atRuleToken(c,startLine,startCol);break;case":":token=this.notToken(c,startLine,startCol);break;case"<":token=this.htmlCommentStartToken(c,startLine,startCol);break;case"U":case"u":if(reader.peek()=="+"){token=this.unicodeRangeToken(c,startLine,startCol);break;}
|
153 |
+
default:if(isDigit(c)){token=this.numberToken(c,startLine,startCol);}else
|
154 |
+
if(isWhitespace(c)){token=this.whitespaceToken(c,startLine,startCol);}else
|
155 |
+
if(isIdentStart(c)){token=this.identOrFunctionToken(c,startLine,startCol);}else
|
156 |
+
{token=this.charToken(c,startLine,startCol);}}
|
157 |
+
break;}
|
158 |
+
if(!token&&c===null){token=this.createToken(Tokens.EOF,null,startLine,startCol);}
|
159 |
+
return token;},createToken:function(tt,value,startLine,startCol,options){var reader=this._reader;options=options||{};return{value:value,type:tt,channel:options.channel,hide:options.hide||false,startLine:startLine,startCol:startCol,endLine:reader.getLine(),endCol:reader.getCol()};},atRuleToken:function(first,startLine,startCol){var rule=first,reader=this._reader,tt=Tokens.CHAR,valid=false,ident,c;reader.mark();ident=this.readName();rule=first+ident;tt=Tokens.type(rule.toLowerCase());if(tt==Tokens.CHAR||tt==Tokens.UNKNOWN){if(rule.length>1){tt=Tokens.UNKNOWN_SYM;}else{tt=Tokens.CHAR;rule=first;reader.reset();}}
|
160 |
+
return this.createToken(tt,rule,startLine,startCol);},charToken:function(c,startLine,startCol){var tt=Tokens.type(c);if(tt==-1){tt=Tokens.CHAR;}
|
161 |
+
return this.createToken(tt,c,startLine,startCol);},commentToken:function(first,startLine,startCol){var reader=this._reader,comment=this.readComment(first);return this.createToken(Tokens.COMMENT,comment,startLine,startCol);},comparisonToken:function(c,startLine,startCol){var reader=this._reader,comparison=c+reader.read(),tt=Tokens.type(comparison)||Tokens.CHAR;return this.createToken(tt,comparison,startLine,startCol);},hashToken:function(first,startLine,startCol){var reader=this._reader,name=this.readName(first);return this.createToken(Tokens.HASH,name,startLine,startCol);},htmlCommentStartToken:function(first,startLine,startCol){var reader=this._reader,text=first;reader.mark();text+=reader.readCount(3);if(text=="<!--"){return this.createToken(Tokens.CDO,text,startLine,startCol);}else{reader.reset();return this.charToken(first,startLine,startCol);}},htmlCommentEndToken:function(first,startLine,startCol){var reader=this._reader,text=first;reader.mark();text+=reader.readCount(2);if(text=="-->"){return this.createToken(Tokens.CDC,text,startLine,startCol);}else{reader.reset();return this.charToken(first,startLine,startCol);}},identOrFunctionToken:function(first,startLine,startCol){var reader=this._reader,ident=this.readName(first),tt=Tokens.IDENT;if(reader.peek()=="("){ident+=reader.read();if(ident.toLowerCase()=="url("){tt=Tokens.URI;ident=this.readURI(ident);if(ident.toLowerCase()=="url("){tt=Tokens.FUNCTION;}}else{tt=Tokens.FUNCTION;}}else if(reader.peek()==":"){if(ident.toLowerCase()=="progid"){ident+=reader.readTo("(");tt=Tokens.IE_FUNCTION;}}
|
162 |
+
return this.createToken(tt,ident,startLine,startCol);},importantToken:function(first,startLine,startCol){var reader=this._reader,important=first,tt=Tokens.CHAR,temp,c;reader.mark();c=reader.read();while(c){if(c=="/"){if(reader.peek()!="*"){break;}else{temp=this.readComment(c);if(temp===""){break;}}}else if(isWhitespace(c)){important+=c+this.readWhitespace();}else if(/i/i.test(c)){temp=reader.readCount(8);if(/mportant/i.test(temp)){important+=c+temp;tt=Tokens.IMPORTANT_SYM;}
|
163 |
+
break;}else{break;}
|
164 |
+
c=reader.read();}
|
165 |
+
if(tt==Tokens.CHAR){reader.reset();return this.charToken(first,startLine,startCol);}else{return this.createToken(tt,important,startLine,startCol);}},notToken:function(first,startLine,startCol){var reader=this._reader,text=first;reader.mark();text+=reader.readCount(4);if(text.toLowerCase()==":not("){return this.createToken(Tokens.NOT,text,startLine,startCol);}else{reader.reset();return this.charToken(first,startLine,startCol);}},numberToken:function(first,startLine,startCol){var reader=this._reader,value=this.readNumber(first),ident,tt=Tokens.NUMBER,c=reader.peek();if(isIdentStart(c)){ident=this.readName(reader.read());value+=ident;if(/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vm$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)){tt=Tokens.LENGTH;}else if(/^deg|^rad$|^grad$/i.test(ident)){tt=Tokens.ANGLE;}else if(/^ms$|^s$/i.test(ident)){tt=Tokens.TIME;}else if(/^hz$|^khz$/i.test(ident)){tt=Tokens.FREQ;}else if(/^dpi$|^dpcm$/i.test(ident)){tt=Tokens.RESOLUTION;}else{tt=Tokens.DIMENSION;}}else if(c=="%"){value+=reader.read();tt=Tokens.PERCENTAGE;}
|
166 |
+
return this.createToken(tt,value,startLine,startCol);},stringToken:function(first,startLine,startCol){var delim=first,string=first,reader=this._reader,prev=first,tt=Tokens.STRING,c=reader.read();while(c){string+=c;if(c==delim&&prev!="\\"){break;}
|
167 |
+
if(isNewLine(reader.peek())&&c!="\\"){tt=Tokens.INVALID;break;}
|
168 |
+
prev=c;c=reader.read();}
|
169 |
+
if(c===null){tt=Tokens.INVALID;}
|
170 |
+
return this.createToken(tt,string,startLine,startCol);},unicodeRangeToken:function(first,startLine,startCol){var reader=this._reader,value=first,temp,tt=Tokens.CHAR;if(reader.peek()=="+"){reader.mark();value+=reader.read();value+=this.readUnicodeRangePart(true);if(value.length==2){reader.reset();}else{tt=Tokens.UNICODE_RANGE;if(value.indexOf("?")==-1){if(reader.peek()=="-"){reader.mark();temp=reader.read();temp+=this.readUnicodeRangePart(false);if(temp.length==1){reader.reset();}else{value+=temp;}}}}}
|
171 |
+
return this.createToken(tt,value,startLine,startCol);},whitespaceToken:function(first,startLine,startCol){var reader=this._reader,value=first+this.readWhitespace();return this.createToken(Tokens.S,value,startLine,startCol);},readUnicodeRangePart:function(allowQuestionMark){var reader=this._reader,part="",c=reader.peek();while(isHexDigit(c)&&part.length<6){reader.read();part+=c;c=reader.peek();}
|
172 |
+
if(allowQuestionMark){while(c=="?"&&part.length<6){reader.read();part+=c;c=reader.peek();}}
|
173 |
+
return part;},readWhitespace:function(){var reader=this._reader,whitespace="",c=reader.peek();while(isWhitespace(c)){reader.read();whitespace+=c;c=reader.peek();}
|
174 |
+
return whitespace;},readNumber:function(first){var reader=this._reader,number=first,hasDot=(first=="."),c=reader.peek();while(c){if(isDigit(c)){number+=reader.read();}else if(c=="."){if(hasDot){break;}else{hasDot=true;number+=reader.read();}}else{break;}
|
175 |
+
c=reader.peek();}
|
176 |
+
return number;},readString:function(){var reader=this._reader,delim=reader.read(),string=delim,prev=delim,c=reader.peek();while(c){c=reader.read();string+=c;if(c==delim&&prev!="\\"){break;}
|
177 |
+
if(isNewLine(reader.peek())&&c!="\\"){string="";break;}
|
178 |
+
prev=c;c=reader.peek();}
|
179 |
+
if(c===null){string="";}
|
180 |
+
return string;},readURI:function(first){var reader=this._reader,uri=first,inner="",c=reader.peek();reader.mark();while(c&&isWhitespace(c)){reader.read();c=reader.peek();}
|
181 |
+
if(c=="'"||c=="\""){inner=this.readString();}else{inner=this.readURL();}
|
182 |
+
c=reader.peek();while(c&&isWhitespace(c)){reader.read();c=reader.peek();}
|
183 |
+
if(inner===""||c!=")"){uri=first;reader.reset();}else{uri+=inner+reader.read();}
|
184 |
+
return uri;},readURL:function(){var reader=this._reader,url="",c=reader.peek();while(/^[!#$%&\\*-~]$/.test(c)){url+=reader.read();c=reader.peek();}
|
185 |
+
return url;},readName:function(first){var reader=this._reader,ident=first||"",c=reader.peek();while(true){if(c=="\\"){ident+=this.readEscape(reader.read());c=reader.peek();}else if(c&&isNameChar(c)){ident+=reader.read();c=reader.peek();}else{break;}}
|
186 |
+
return ident;},readEscape:function(first){var reader=this._reader,cssEscape=first||"",i=0,c=reader.peek();if(isHexDigit(c)){do{cssEscape+=reader.read();c=reader.peek();}while(c&&isHexDigit(c)&&++i<6);}
|
187 |
+
if(cssEscape.length==3&&/\s/.test(c)||cssEscape.length==7||cssEscape.length==1){reader.read();}else{c="";}
|
188 |
+
return cssEscape+c;},readComment:function(first){var reader=this._reader,comment=first||"",c=reader.read();if(c=="*"){while(c){comment+=c;if(comment.length>2&&c=="*"&&reader.peek()=="/"){comment+=reader.read();break;}
|
189 |
+
c=reader.read();}
|
190 |
+
return comment;}else{return"";}}});var Tokens=[{name:"CDO"},{name:"CDC"},{name:"S",whitespace:true},{name:"COMMENT",comment:true,hide:true,channel:"comment"},{name:"INCLUDES",text:"~="},{name:"DASHMATCH",text:"|="},{name:"PREFIXMATCH",text:"^="},{name:"SUFFIXMATCH",text:"$="},{name:"SUBSTRINGMATCH",text:"*="},{name:"STRING"},{name:"IDENT"},{name:"HASH"},{name:"IMPORT_SYM",text:"@import"},{name:"PAGE_SYM",text:"@page"},{name:"MEDIA_SYM",text:"@media"},{name:"FONT_FACE_SYM",text:"@font-face"},{name:"CHARSET_SYM",text:"@charset"},{name:"NAMESPACE_SYM",text:"@namespace"},{name:"VIEWPORT_SYM",text:"@viewport"},{name:"UNKNOWN_SYM"},{name:"KEYFRAMES_SYM",text:["@keyframes","@-webkit-keyframes","@-moz-keyframes","@-o-keyframes"]},{name:"IMPORTANT_SYM"},{name:"LENGTH"},{name:"ANGLE"},{name:"TIME"},{name:"FREQ"},{name:"DIMENSION"},{name:"PERCENTAGE"},{name:"NUMBER"},{name:"URI"},{name:"FUNCTION"},{name:"UNICODE_RANGE"},{name:"INVALID"},{name:"PLUS",text:"+"},{name:"GREATER",text:">"},{name:"COMMA",text:","},{name:"TILDE",text:"~"},{name:"NOT"},{name:"TOPLEFTCORNER_SYM",text:"@top-left-corner"},{name:"TOPLEFT_SYM",text:"@top-left"},{name:"TOPCENTER_SYM",text:"@top-center"},{name:"TOPRIGHT_SYM",text:"@top-right"},{name:"TOPRIGHTCORNER_SYM",text:"@top-right-corner"},{name:"BOTTOMLEFTCORNER_SYM",text:"@bottom-left-corner"},{name:"BOTTOMLEFT_SYM",text:"@bottom-left"},{name:"BOTTOMCENTER_SYM",text:"@bottom-center"},{name:"BOTTOMRIGHT_SYM",text:"@bottom-right"},{name:"BOTTOMRIGHTCORNER_SYM",text:"@bottom-right-corner"},{name:"LEFTTOP_SYM",text:"@left-top"},{name:"LEFTMIDDLE_SYM",text:"@left-middle"},{name:"LEFTBOTTOM_SYM",text:"@left-bottom"},{name:"RIGHTTOP_SYM",text:"@right-top"},{name:"RIGHTMIDDLE_SYM",text:"@right-middle"},{name:"RIGHTBOTTOM_SYM",text:"@right-bottom"},{name:"RESOLUTION",state:"media"},{name:"IE_FUNCTION"},{name:"CHAR"},{name:"PIPE",text:"|"},{name:"SLASH",text:"/"},{name:"MINUS",text:"-"},{name:"STAR",text:"*"},{name:"LBRACE",text:"{"},{name:"RBRACE",text:"}"},{name:"LBRACKET",text:"["},{name:"RBRACKET",text:"]"},{name:"EQUALS",text:"="},{name:"COLON",text:":"},{name:"SEMICOLON",text:";"},{name:"LPAREN",text:"("},{name:"RPAREN",text:")"},{name:"DOT",text:"."}];(function(){var nameMap=[],typeMap={};Tokens.UNKNOWN=-1;Tokens.unshift({name:"EOF"});for(var i=0,len=Tokens.length;i<len;i++){nameMap.push(Tokens[i].name);Tokens[Tokens[i].name]=i;if(Tokens[i].text){if(Tokens[i].text instanceof Array){for(var j=0;j<Tokens[i].text.length;j++){typeMap[Tokens[i].text[j]]=i;}}else{typeMap[Tokens[i].text]=i;}}}
|
191 |
+
Tokens.name=function(tt){return nameMap[tt];};Tokens.type=function(c){return typeMap[c]||-1;};})();var Validation={validate:function(property,value){var name=property.toString().toLowerCase(),parts=value.parts,expression=new PropertyValueIterator(value),spec=Properties[name],part,valid,j,count,msg,types,last,literals,max,multi,group;if(!spec){if(name.indexOf("-")!==0){throw new ValidationError("Unknown property '"+property+"'.",property.line,property.col);}}else if(typeof spec!="number"){if(typeof spec=="string"){if(spec.indexOf("||")>-1){this.groupProperty(spec,expression);}else{this.singleProperty(spec,expression,1);}}else if(spec.multi){this.multiProperty(spec.multi,expression,spec.comma,spec.max||Infinity);}else if(typeof spec=="function"){spec(expression);}}},singleProperty:function(types,expression,max,partial){var result=false,value=expression.value,count=0,part;while(expression.hasNext()&&count<max){result=ValidationTypes.isAny(expression,types);if(!result){break;}
|
192 |
+
count++;}
|
193 |
+
if(!result){if(expression.hasNext()&&!expression.isFirst()){part=expression.peek();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected ("+types+") but found '"+value+"'.",value.line,value.col);}}else if(expression.hasNext()){part=expression.next();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}},multiProperty:function(types,expression,comma,max){var result=false,value=expression.value,count=0,sep=false,part;while(expression.hasNext()&&!result&&count<max){if(ValidationTypes.isAny(expression,types)){count++;if(!expression.hasNext()){result=true;}else if(comma){if(expression.peek()==","){part=expression.next();}else{break;}}}else{break;}}
|
194 |
+
if(!result){if(expression.hasNext()&&!expression.isFirst()){part=expression.peek();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{part=expression.previous();if(comma&&part==","){throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected ("+types+") but found '"+value+"'.",value.line,value.col);}}}else if(expression.hasNext()){part=expression.next();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}},groupProperty:function(types,expression,comma){var result=false,value=expression.value,typeCount=types.split("||").length,groups={count:0},partial=false,name,part;while(expression.hasNext()&&!result){name=ValidationTypes.isAnyOfGroup(expression,types);if(name){if(groups[name]){break;}else{groups[name]=1;groups.count++;partial=true;if(groups.count==typeCount||!expression.hasNext()){result=true;}}}else{break;}}
|
195 |
+
if(!result){if(partial&&expression.hasNext()){part=expression.peek();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected ("+types+") but found '"+value+"'.",value.line,value.col);}}else if(expression.hasNext()){part=expression.next();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}}};function ValidationError(message,line,col){this.col=col;this.line=line;this.message=message;}
|
196 |
+
ValidationError.prototype=new Error();var ValidationTypes={isLiteral:function(part,literals){var text=part.text.toString().toLowerCase(),args=literals.split(" | "),i,len,found=false;for(i=0,len=args.length;i<len&&!found;i++){if(text==args[i].toLowerCase()){found=true;}}
|
197 |
+
return found;},isSimple:function(type){return!!this.simple[type];},isComplex:function(type){return!!this.complex[type];},isAny:function(expression,types){var args=types.split(" | "),i,len,found=false;for(i=0,len=args.length;i<len&&!found&&expression.hasNext();i++){found=this.isType(expression,args[i]);}
|
198 |
+
return found;},isAnyOfGroup:function(expression,types){var args=types.split(" || "),i,len,found=false;for(i=0,len=args.length;i<len&&!found;i++){found=this.isType(expression,args[i]);}
|
199 |
+
return found?args[i-1]:false;},isType:function(expression,type){var part=expression.peek(),result=false;if(type.charAt(0)!="<"){result=this.isLiteral(part,type);if(result){expression.next();}}else if(this.simple[type]){result=this.simple[type](part);if(result){expression.next();}}else{result=this.complex[type](expression);}
|
200 |
+
return result;},simple:{"<absolute-size>":function(part){return ValidationTypes.isLiteral(part,"xx-small | x-small | small | medium | large | x-large | xx-large");},"<attachment>":function(part){return ValidationTypes.isLiteral(part,"scroll | fixed | local");},"<attr>":function(part){return part.type=="function"&&part.name=="attr";},"<bg-image>":function(part){return this["<image>"](part)||this["<gradient>"](part)||part=="none";},"<gradient>":function(part){return part.type=="function"&&/^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);},"<box>":function(part){return ValidationTypes.isLiteral(part,"padding-box | border-box | content-box");},"<content>":function(part){return part.type=="function"&&part.name=="content";},"<relative-size>":function(part){return ValidationTypes.isLiteral(part,"smaller | larger");},"<ident>":function(part){return part.type=="identifier";},"<length>":function(part){if(part.type=="function"&&/^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)){return true;}else{return part.type=="length"||part.type=="number"||part.type=="integer"||part=="0";}},"<color>":function(part){return part.type=="color"||part=="transparent";},"<number>":function(part){return part.type=="number"||this["<integer>"](part);},"<integer>":function(part){return part.type=="integer";},"<line>":function(part){return part.type=="integer";},"<angle>":function(part){return part.type=="angle";},"<uri>":function(part){return part.type=="uri";},"<image>":function(part){return this["<uri>"](part);},"<percentage>":function(part){return part.type=="percentage"||part=="0";},"<border-width>":function(part){return this["<length>"](part)||ValidationTypes.isLiteral(part,"thin | medium | thick");},"<border-style>":function(part){return ValidationTypes.isLiteral(part,"none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset");},"<margin-width>":function(part){return this["<length>"](part)||this["<percentage>"](part)||ValidationTypes.isLiteral(part,"auto");},"<padding-width>":function(part){return this["<length>"](part)||this["<percentage>"](part);},"<shape>":function(part){return part.type=="function"&&(part.name=="rect"||part.name=="inset-rect");},"<time>":function(part){return part.type=="time";}},complex:{"<bg-position>":function(expression){var types=this,result=false,numeric="<percentage> | <length>",xDir="left | right",yDir="top | bottom",count=0,hasNext=function(){return expression.hasNext()&&expression.peek()!=",";};while(expression.peek(count)&&expression.peek(count)!=","){count++;}
|
201 |
+
if(count<3){if(ValidationTypes.isAny(expression,xDir+" | center | "+numeric)){result=true;ValidationTypes.isAny(expression,yDir+" | center | "+numeric);}else if(ValidationTypes.isAny(expression,yDir)){result=true;ValidationTypes.isAny(expression,xDir+" | center");}}else{if(ValidationTypes.isAny(expression,xDir)){if(ValidationTypes.isAny(expression,yDir)){result=true;ValidationTypes.isAny(expression,numeric);}else if(ValidationTypes.isAny(expression,numeric)){if(ValidationTypes.isAny(expression,yDir)){result=true;ValidationTypes.isAny(expression,numeric);}else if(ValidationTypes.isAny(expression,"center")){result=true;}}}else if(ValidationTypes.isAny(expression,yDir)){if(ValidationTypes.isAny(expression,xDir)){result=true;ValidationTypes.isAny(expression,numeric);}else if(ValidationTypes.isAny(expression,numeric)){if(ValidationTypes.isAny(expression,xDir)){result=true;ValidationTypes.isAny(expression,numeric);}else if(ValidationTypes.isAny(expression,"center")){result=true;}}}else if(ValidationTypes.isAny(expression,"center")){if(ValidationTypes.isAny(expression,xDir+" | "+yDir)){result=true;ValidationTypes.isAny(expression,numeric);}}}
|
202 |
+
return result;},"<bg-size>":function(expression){var types=this,result=false,numeric="<percentage> | <length> | auto",part,i,len;if(ValidationTypes.isAny(expression,"cover | contain")){result=true;}else if(ValidationTypes.isAny(expression,numeric)){result=true;ValidationTypes.isAny(expression,numeric);}
|
203 |
+
return result;},"<repeat-style>":function(expression){var result=false,values="repeat | space | round | no-repeat",part;if(expression.hasNext()){part=expression.next();if(ValidationTypes.isLiteral(part,"repeat-x | repeat-y")){result=true;}else if(ValidationTypes.isLiteral(part,values)){result=true;if(expression.hasNext()&&ValidationTypes.isLiteral(expression.peek(),values)){expression.next();}}}
|
204 |
+
return result;},"<shadow>":function(expression){var result=false,count=0,inset=false,color=false,part;if(expression.hasNext()){if(ValidationTypes.isAny(expression,"inset")){inset=true;}
|
205 |
+
if(ValidationTypes.isAny(expression,"<color>")){color=true;}
|
206 |
+
while(ValidationTypes.isAny(expression,"<length>")&&count<4){count++;}
|
207 |
+
if(expression.hasNext()){if(!color){ValidationTypes.isAny(expression,"<color>");}
|
208 |
+
if(!inset){ValidationTypes.isAny(expression,"inset");}}
|
209 |
+
result=(count>=2&&count<=4);}
|
210 |
+
return result;},"<x-one-radius>":function(expression){var result=false,simple="<length> | <percentage> | inherit";if(ValidationTypes.isAny(expression,simple)){result=true;ValidationTypes.isAny(expression,simple);}
|
211 |
+
return result;}}};parserlib.css={Colors:Colors,Combinator:Combinator,Parser:Parser,PropertyName:PropertyName,PropertyValue:PropertyValue,PropertyValuePart:PropertyValuePart,MediaFeature:MediaFeature,MediaQuery:MediaQuery,Selector:Selector,SelectorPart:SelectorPart,SelectorSubPart:SelectorSubPart,Specificity:Specificity,TokenStream:TokenStream,Tokens:Tokens,ValidationError:ValidationError};})();(function(){for(var prop in parserlib){exports[prop]=parserlib[prop];}})();var CSSLint=(function(){var rules=[],formatters=[],embeddedRuleset=/\/\*csslint([^\*]*)\*\//,api=new parserlib.util.EventTarget();api.version="0.10.0";api.addRule=function(rule){rules.push(rule);rules[rule.id]=rule;};api.clearRules=function(){rules=[];};api.getRules=function(){return[].concat(rules).sort(function(a,b){return a.id>b.id?1:0;});};api.getRuleset=function(){var ruleset={},i=0,len=rules.length;while(i<len){ruleset[rules[i++].id]=1;}
|
212 |
+
return ruleset;};function applyEmbeddedRuleset(text,ruleset){var valueMap,embedded=text&&text.match(embeddedRuleset),rules=embedded&&embedded[1];if(rules){valueMap={"true":2,"":1,"false":0,"2":2,"1":1,"0":0};rules.toLowerCase().split(",").forEach(function(rule){var pair=rule.split(":"),property=pair[0]||"",value=pair[1]||"";ruleset[property.trim()]=valueMap[value.trim()];});}
|
213 |
+
return ruleset;}
|
214 |
+
api.addFormatter=function(formatter){formatters[formatter.id]=formatter;};api.getFormatter=function(formatId){return formatters[formatId];};api.format=function(results,filename,formatId,options){var formatter=this.getFormatter(formatId),result=null;if(formatter){result=formatter.startFormat();result+=formatter.formatResults(results,filename,options||{});result+=formatter.endFormat();}
|
215 |
+
return result;};api.hasFormat=function(formatId){return formatters.hasOwnProperty(formatId);};api.verify=function(text,ruleset){var i=0,len=rules.length,reporter,lines,report,parser=new parserlib.css.Parser({starHack:true,ieFilters:true,underscoreHack:true,strict:false});lines=text.replace(/\n\r?/g,"$split$").split('$split$');if(!ruleset){ruleset=this.getRuleset();}
|
216 |
+
if(embeddedRuleset.test(text)){ruleset=applyEmbeddedRuleset(text,ruleset);}
|
217 |
+
reporter=new Reporter(lines,ruleset);ruleset.errors=2;for(i in ruleset){if(ruleset.hasOwnProperty(i)&&ruleset[i]){if(rules[i]){rules[i].init(parser,reporter);}}}
|
218 |
+
try{parser.parse(text);}catch(ex){reporter.error("Fatal error, cannot continue: "+ex.message,ex.line,ex.col,{});}
|
219 |
+
report={messages:reporter.messages,stats:reporter.stats,ruleset:reporter.ruleset};report.messages.sort(function(a,b){if(a.rollup&&!b.rollup){return 1;}else if(!a.rollup&&b.rollup){return-1;}else{return a.line-b.line;}});return report;};return api;})();function Reporter(lines,ruleset){this.messages=[];this.stats=[];this.lines=lines;this.ruleset=ruleset;}
|
220 |
+
Reporter.prototype={constructor:Reporter,error:function(message,line,col,rule){this.messages.push({type:"error",line:line,col:col,message:message,evidence:this.lines[line-1],rule:rule||{}});},warn:function(message,line,col,rule){this.report(message,line,col,rule);},report:function(message,line,col,rule){this.messages.push({type:this.ruleset[rule.id]==2?"error":"warning",line:line,col:col,message:message,evidence:this.lines[line-1],rule:rule});},info:function(message,line,col,rule){this.messages.push({type:"info",line:line,col:col,message:message,evidence:this.lines[line-1],rule:rule});},rollupError:function(message,rule){this.messages.push({type:"error",rollup:true,message:message,rule:rule});},rollupWarn:function(message,rule){this.messages.push({type:"warning",rollup:true,message:message,rule:rule});},stat:function(name,value){this.stats[name]=value;}};CSSLint._Reporter=Reporter;CSSLint.Util={mix:function(receiver,supplier){var prop;for(prop in supplier){if(supplier.hasOwnProperty(prop)){receiver[prop]=supplier[prop];}}
|
221 |
+
return prop;},indexOf:function(values,value){if(values.indexOf){return values.indexOf(value);}else{for(var i=0,len=values.length;i<len;i++){if(values[i]===value){return i;}}
|
222 |
+
return-1;}},forEach:function(values,func){if(values.forEach){return values.forEach(func);}else{for(var i=0,len=values.length;i<len;i++){func(values[i],i,values);}}}};CSSLint.addRule({id:"adjoining-classes",name:"Disallow adjoining classes",desc:"Don't use adjoining classes.",browsers:"IE6",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,classCount,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){classCount=0;for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(modifier.type=="class"){classCount++;}
|
223 |
+
if(classCount>1){reporter.report("Don't use adjoining classes.",part.line,part.col,rule);}}}}}});}});CSSLint.addRule({id:"box-model",name:"Beware of broken box size",desc:"Don't use width or height when using padding or border.",browsers:"All",init:function(parser,reporter){var rule=this,widthProperties={border:1,"border-left":1,"border-right":1,padding:1,"padding-left":1,"padding-right":1},heightProperties={border:1,"border-bottom":1,"border-top":1,padding:1,"padding-bottom":1,"padding-top":1},properties,boxSizing=false;function startRule(){properties={};boxSizing=false;}
|
224 |
+
function endRule(){var prop,value;if(!boxSizing){if(properties.height){for(prop in heightProperties){if(heightProperties.hasOwnProperty(prop)&&properties[prop]){value=properties[prop].value;if(!(prop=="padding"&&value.parts.length===2&&value.parts[0].value===0)){reporter.report("Using height with "+prop+" can sometimes make elements larger than you expect.",properties[prop].line,properties[prop].col,rule);}}}}
|
225 |
+
if(properties.width){for(prop in widthProperties){if(widthProperties.hasOwnProperty(prop)&&properties[prop]){value=properties[prop].value;if(!(prop=="padding"&&value.parts.length===2&&value.parts[1].value===0)){reporter.report("Using width with "+prop+" can sometimes make elements larger than you expect.",properties[prop].line,properties[prop].col,rule);}}}}}}
|
226 |
+
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(heightProperties[name]||widthProperties[name]){if(!/^0\S*$/.test(event.value)&&!(name=="border"&&event.value=="none")){properties[name]={line:event.property.line,col:event.property.col,value:event.value};}}else{if(/^(width|height)/i.test(name)&&/^(length|percentage)/.test(event.value.parts[0].type)){properties[name]=1;}else if(name=="box-sizing"){boxSizing=true;}}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);parser.addListener("endpage",endRule);parser.addListener("endpagemargin",endRule);parser.addListener("endkeyframerule",endRule);}});CSSLint.addRule({id:"box-sizing",name:"Disallow use of box-sizing",desc:"The box-sizing properties isn't supported in IE6 and IE7.",browsers:"IE6, IE7",tags:["Compatibility"],init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(name=="box-sizing"){reporter.report("The box-sizing property isn't supported in IE6 and IE7.",event.line,event.col,rule);}});}});CSSLint.addRule({id:"bulletproof-font-face",name:"Use the bulletproof @font-face syntax",desc:"Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",browsers:"All",init:function(parser,reporter){var rule=this,count=0,fontFaceRule=false,firstSrc=true,ruleFailed=false,line,col;parser.addListener("startfontface",function(event){fontFaceRule=true;});parser.addListener("property",function(event){if(!fontFaceRule){return;}
|
227 |
+
var propertyName=event.property.toString().toLowerCase(),value=event.value.toString();line=event.line;col=event.col;if(propertyName==='src'){var regex=/^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;if(!value.match(regex)&&firstSrc){ruleFailed=true;firstSrc=false;}else if(value.match(regex)&&!firstSrc){ruleFailed=false;}}});parser.addListener("endfontface",function(event){fontFaceRule=false;if(ruleFailed){reporter.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.",line,col,rule);}});}});CSSLint.addRule({id:"compatible-vendor-prefixes",name:"Require compatible vendor prefixes",desc:"Include all compatible vendor prefixes to reach a wider range of users.",browsers:"All",init:function(parser,reporter){var rule=this,compatiblePrefixes,properties,prop,variations,prefixed,i,len,inKeyFrame=false,arrayPush=Array.prototype.push,applyTo=[];compatiblePrefixes={"animation":"webkit moz","animation-delay":"webkit moz","animation-direction":"webkit moz","animation-duration":"webkit moz","animation-fill-mode":"webkit moz","animation-iteration-count":"webkit moz","animation-name":"webkit moz","animation-play-state":"webkit moz","animation-timing-function":"webkit moz","appearance":"webkit moz","border-end":"webkit moz","border-end-color":"webkit moz","border-end-style":"webkit moz","border-end-width":"webkit moz","border-image":"webkit moz o","border-radius":"webkit","border-start":"webkit moz","border-start-color":"webkit moz","border-start-style":"webkit moz","border-start-width":"webkit moz","box-align":"webkit moz ms","box-direction":"webkit moz ms","box-flex":"webkit moz ms","box-lines":"webkit ms","box-ordinal-group":"webkit moz ms","box-orient":"webkit moz ms","box-pack":"webkit moz ms","box-sizing":"webkit moz","box-shadow":"webkit moz","column-count":"webkit moz ms","column-gap":"webkit moz ms","column-rule":"webkit moz ms","column-rule-color":"webkit moz ms","column-rule-style":"webkit moz ms","column-rule-width":"webkit moz ms","column-width":"webkit moz ms","hyphens":"epub moz","line-break":"webkit ms","margin-end":"webkit moz","margin-start":"webkit moz","marquee-speed":"webkit wap","marquee-style":"webkit wap","padding-end":"webkit moz","padding-start":"webkit moz","tab-size":"moz o","text-size-adjust":"webkit ms","transform":"webkit moz ms o","transform-origin":"webkit moz ms o","transition":"webkit moz o","transition-delay":"webkit moz o","transition-duration":"webkit moz o","transition-property":"webkit moz o","transition-timing-function":"webkit moz o","user-modify":"webkit moz","user-select":"webkit moz ms","word-break":"epub ms","writing-mode":"epub ms"};for(prop in compatiblePrefixes){if(compatiblePrefixes.hasOwnProperty(prop)){variations=[];prefixed=compatiblePrefixes[prop].split(' ');for(i=0,len=prefixed.length;i<len;i++){variations.push('-'+prefixed[i]+'-'+prop);}
|
228 |
+
compatiblePrefixes[prop]=variations;arrayPush.apply(applyTo,variations);}}
|
229 |
+
parser.addListener("startrule",function(){properties=[];});parser.addListener("startkeyframes",function(event){inKeyFrame=event.prefix||true;});parser.addListener("endkeyframes",function(event){inKeyFrame=false;});parser.addListener("property",function(event){var name=event.property;if(CSSLint.Util.indexOf(applyTo,name.text)>-1){if(!inKeyFrame||typeof inKeyFrame!="string"||name.text.indexOf("-"+inKeyFrame+"-")!==0){properties.push(name);}}});parser.addListener("endrule",function(event){if(!properties.length){return;}
|
230 |
+
var propertyGroups={},i,len,name,prop,variations,value,full,actual,item,propertiesSpecified;for(i=0,len=properties.length;i<len;i++){name=properties[i];for(prop in compatiblePrefixes){if(compatiblePrefixes.hasOwnProperty(prop)){variations=compatiblePrefixes[prop];if(CSSLint.Util.indexOf(variations,name.text)>-1){if(!propertyGroups[prop]){propertyGroups[prop]={full:variations.slice(0),actual:[],actualNodes:[]};}
|
231 |
+
if(CSSLint.Util.indexOf(propertyGroups[prop].actual,name.text)===-1){propertyGroups[prop].actual.push(name.text);propertyGroups[prop].actualNodes.push(name);}}}}}
|
232 |
+
for(prop in propertyGroups){if(propertyGroups.hasOwnProperty(prop)){value=propertyGroups[prop];full=value.full;actual=value.actual;if(full.length>actual.length){for(i=0,len=full.length;i<len;i++){item=full[i];if(CSSLint.Util.indexOf(actual,item)===-1){propertiesSpecified=(actual.length===1)?actual[0]:(actual.length==2)?actual.join(" and "):actual.join(", ");reporter.report("The property "+item+" is compatible with "+propertiesSpecified+" and should be included as well.",value.actualNodes[0].line,value.actualNodes[0].col,rule);}}}}}});}});CSSLint.addRule({id:"display-property-grouping",name:"Require properties appropriate for display",desc:"Certain properties shouldn't be used with certain display property values.",browsers:"All",init:function(parser,reporter){var rule=this;var propertiesToCheck={display:1,"float":"none",height:1,width:1,margin:1,"margin-left":1,"margin-right":1,"margin-bottom":1,"margin-top":1,padding:1,"padding-left":1,"padding-right":1,"padding-bottom":1,"padding-top":1,"vertical-align":1},properties;function reportProperty(name,display,msg){if(properties[name]){if(typeof propertiesToCheck[name]!="string"||properties[name].value.toLowerCase()!=propertiesToCheck[name]){reporter.report(msg||name+" can't be used with display: "+display+".",properties[name].line,properties[name].col,rule);}}}
|
233 |
+
function startRule(){properties={};}
|
234 |
+
function endRule(){var display=properties.display?properties.display.value:null;if(display){switch(display){case"inline":reportProperty("height",display);reportProperty("width",display);reportProperty("margin",display);reportProperty("margin-top",display);reportProperty("margin-bottom",display);reportProperty("float",display,"display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");break;case"block":reportProperty("vertical-align",display);break;case"inline-block":reportProperty("float",display);break;default:if(display.indexOf("table-")===0){reportProperty("margin",display);reportProperty("margin-left",display);reportProperty("margin-right",display);reportProperty("margin-top",display);reportProperty("margin-bottom",display);reportProperty("float",display);}}}}
|
235 |
+
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startpage",startRule);parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(propertiesToCheck[name]){properties[name]={value:event.value.text,line:event.property.line,col:event.property.col};}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);parser.addListener("endkeyframerule",endRule);parser.addListener("endpagemargin",endRule);parser.addListener("endpage",endRule);}});CSSLint.addRule({id:"duplicate-background-images",name:"Disallow duplicate background images",desc:"Every background-image should be unique. Use a common class for e.g. sprites.",browsers:"All",init:function(parser,reporter){var rule=this,stack={};parser.addListener("property",function(event){var name=event.property.text,value=event.value,i,len;if(name.match(/background/i)){for(i=0,len=value.parts.length;i<len;i++){if(value.parts[i].type=='uri'){if(typeof stack[value.parts[i].uri]==='undefined'){stack[value.parts[i].uri]=event;}
|
236 |
+
else{reporter.report("Background image '"+value.parts[i].uri+"' was used multiple times, first declared at line "+stack[value.parts[i].uri].line+", col "+stack[value.parts[i].uri].col+".",event.line,event.col,rule);}}}}});}});CSSLint.addRule({id:"duplicate-properties",name:"Disallow duplicate properties",desc:"Duplicate properties must appear one after the other.",browsers:"All",init:function(parser,reporter){var rule=this,properties,lastProperty;function startRule(event){properties={};}
|
237 |
+
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var property=event.property,name=property.text.toLowerCase();if(properties[name]&&(lastProperty!=name||properties[name]==event.value.text)){reporter.report("Duplicate property '"+event.property+"' found.",event.line,event.col,rule);}
|
238 |
+
properties[name]=event.value.text;lastProperty=name;});}});CSSLint.addRule({id:"empty-rules",name:"Disallow empty rules",desc:"Rules without any properties specified should be removed.",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("startrule",function(){count=0;});parser.addListener("property",function(){count++;});parser.addListener("endrule",function(event){var selectors=event.selectors;if(count===0){reporter.report("Rule is empty.",selectors[0].line,selectors[0].col,rule);}});}});CSSLint.addRule({id:"errors",name:"Parsing Errors",desc:"This rule looks for recoverable syntax errors.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("error",function(event){reporter.error(event.message,event.line,event.col,rule);});}});CSSLint.addRule({id:"fallback-colors",name:"Require fallback colors",desc:"For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.",browsers:"IE6,IE7,IE8",init:function(parser,reporter){var rule=this,lastProperty,propertiesToCheck={color:1,background:1,"border-color":1,"border-top-color":1,"border-right-color":1,"border-bottom-color":1,"border-left-color":1,border:1,"border-top":1,"border-right":1,"border-bottom":1,"border-left":1,"background-color":1},properties;function startRule(event){properties={};lastProperty=null;}
|
239 |
+
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var property=event.property,name=property.text.toLowerCase(),parts=event.value.parts,i=0,colorType="",len=parts.length;if(propertiesToCheck[name]){while(i<len){if(parts[i].type=="color"){if("alpha"in parts[i]||"hue"in parts[i]){if(/([^\)]+)\(/.test(parts[i])){colorType=RegExp.$1.toUpperCase();}
|
240 |
+
if(!lastProperty||(lastProperty.property.text.toLowerCase()!=name||lastProperty.colorType!="compat")){reporter.report("Fallback "+name+" (hex or RGB) should precede "+colorType+" "+name+".",event.line,event.col,rule);}}else{event.colorType="compat";}}
|
241 |
+
i++;}}
|
242 |
+
lastProperty=event;});}});CSSLint.addRule({id:"floats",name:"Disallow too many floats",desc:"This rule tests if the float property is used too many times",browsers:"All",init:function(parser,reporter){var rule=this;var count=0;parser.addListener("property",function(event){if(event.property.text.toLowerCase()=="float"&&event.value.text.toLowerCase()!="none"){count++;}});parser.addListener("endstylesheet",function(){reporter.stat("floats",count);if(count>=10){reporter.rollupWarn("Too many floats ("+count+"), you're probably using them for layout. Consider using a grid system instead.",rule);}});}});CSSLint.addRule({id:"font-faces",name:"Don't use too many web fonts",desc:"Too many different web fonts in the same stylesheet.",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("startfontface",function(){count++;});parser.addListener("endstylesheet",function(){if(count>5){reporter.rollupWarn("Too many @font-face declarations ("+count+").",rule);}});}});CSSLint.addRule({id:"font-sizes",name:"Disallow too many font sizes",desc:"Checks the number of font-size declarations.",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("property",function(event){if(event.property=="font-size"){count++;}});parser.addListener("endstylesheet",function(){reporter.stat("font-sizes",count);if(count>=10){reporter.rollupWarn("Too many font-size declarations ("+count+"), abstraction needed.",rule);}});}});CSSLint.addRule({id:"gradients",name:"Require all gradient definitions",desc:"When using a vendor-prefixed gradient, make sure to use them all.",browsers:"All",init:function(parser,reporter){var rule=this,gradients;parser.addListener("startrule",function(){gradients={moz:0,webkit:0,oldWebkit:0,o:0};});parser.addListener("property",function(event){if(/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)){gradients[RegExp.$1]=1;}else if(/\-webkit\-gradient/i.test(event.value)){gradients.oldWebkit=1;}});parser.addListener("endrule",function(event){var missing=[];if(!gradients.moz){missing.push("Firefox 3.6+");}
|
243 |
+
if(!gradients.webkit){missing.push("Webkit (Safari 5+, Chrome)");}
|
244 |
+
if(!gradients.oldWebkit){missing.push("Old Webkit (Safari 4+, Chrome)");}
|
245 |
+
if(!gradients.o){missing.push("Opera 11.1+");}
|
246 |
+
if(missing.length&&missing.length<4){reporter.report("Missing vendor-prefixed CSS gradients for "+missing.join(", ")+".",event.selectors[0].line,event.selectors[0].col,rule);}});}});CSSLint.addRule({id:"ids",name:"Disallow IDs in selectors",desc:"Selectors should not contain IDs.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,idCount,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];idCount=0;for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(modifier.type=="id"){idCount++;}}}}
|
247 |
+
if(idCount==1){reporter.report("Don't use IDs in selectors.",selector.line,selector.col,rule);}else if(idCount>1){reporter.report(idCount+" IDs in the selector, really?",selector.line,selector.col,rule);}}});}});CSSLint.addRule({id:"import",name:"Disallow @import",desc:"Don't use @import, use <link> instead.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("import",function(event){reporter.report("@import prevents parallel downloads, use <link> instead.",event.line,event.col,rule);});}});CSSLint.addRule({id:"important",name:"Disallow !important",desc:"Be careful when using !important declaration",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("property",function(event){if(event.important===true){count++;reporter.report("Use of !important",event.line,event.col,rule);}});parser.addListener("endstylesheet",function(){reporter.stat("important",count);if(count>=10){reporter.rollupWarn("Too many !important declarations ("+count+"), try to use less than 10 to avoid specificity issues.",rule);}});}});CSSLint.addRule({id:"known-properties",name:"Require use of known properties",desc:"Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(event.invalid){reporter.report(event.invalid.message,event.line,event.col,rule);}});}});CSSLint.addRule({id:"outline-none",name:"Disallow outline: none",desc:"Use of outline: none or outline: 0 should be limited to :focus rules.",browsers:"All",tags:["Accessibility"],init:function(parser,reporter){var rule=this,lastRule;function startRule(event){if(event.selectors){lastRule={line:event.line,col:event.col,selectors:event.selectors,propCount:0,outline:false};}else{lastRule=null;}}
|
248 |
+
function endRule(event){if(lastRule){if(lastRule.outline){if(lastRule.selectors.toString().toLowerCase().indexOf(":focus")==-1){reporter.report("Outlines should only be modified using :focus.",lastRule.line,lastRule.col,rule);}else if(lastRule.propCount==1){reporter.report("Outlines shouldn't be hidden unless other visual changes are made.",lastRule.line,lastRule.col,rule);}}}}
|
249 |
+
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var name=event.property.text.toLowerCase(),value=event.value;if(lastRule){lastRule.propCount++;if(name=="outline"&&(value=="none"||value=="0")){lastRule.outline=true;}}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);parser.addListener("endpage",endRule);parser.addListener("endpagemargin",endRule);parser.addListener("endkeyframerule",endRule);}});CSSLint.addRule({id:"overqualified-elements",name:"Disallow overqualified elements",desc:"Don't use classes or IDs with elements (a.foo or a#foo).",browsers:"All",init:function(parser,reporter){var rule=this,classes={};parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(part.elementName&&modifier.type=="id"){reporter.report("Element ("+part+") is overqualified, just use "+modifier+" without element name.",part.line,part.col,rule);}else if(modifier.type=="class"){if(!classes[modifier]){classes[modifier]=[];}
|
250 |
+
classes[modifier].push({modifier:modifier,part:part});}}}}}});parser.addListener("endstylesheet",function(){var prop;for(prop in classes){if(classes.hasOwnProperty(prop)){if(classes[prop].length==1&&classes[prop][0].part.elementName){reporter.report("Element ("+classes[prop][0].part+") is overqualified, just use "+classes[prop][0].modifier+" without element name.",classes[prop][0].part.line,classes[prop][0].part.col,rule);}}}});}});CSSLint.addRule({id:"qualified-headings",name:"Disallow qualified headings",desc:"Headings should not be qualified (namespaced).",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,i,j;for(i=0;i<selectors.length;i++){selector=selectors[i];for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){if(part.elementName&&/h[1-6]/.test(part.elementName.toString())&&j>0){reporter.report("Heading ("+part.elementName+") should not be qualified.",part.line,part.col,rule);}}}}});}});CSSLint.addRule({id:"regex-selectors",name:"Disallow selectors that look like regexs",desc:"Selectors that look like regular expressions are slow and should be avoided.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(modifier.type=="attribute"){if(/([\~\|\^\$\*]=)/.test(modifier)){reporter.report("Attribute selectors with "+RegExp.$1+" are slow!",modifier.line,modifier.col,rule);}}}}}}});}});CSSLint.addRule({id:"rules-count",name:"Rules Count",desc:"Track how many rules there are.",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("startrule",function(){count++;});parser.addListener("endstylesheet",function(){reporter.stat("rule-count",count);});}});CSSLint.addRule({id:"selector-max-approaching",name:"Warn when approaching the 4095 selector limit for IE",desc:"Will warn when selector count is >= 3800 selectors.",browsers:"IE",init:function(parser,reporter){var rule=this,count=0;parser.addListener('startrule',function(event){count+=event.selectors.length;});parser.addListener("endstylesheet",function(){if(count>=3800){reporter.report("You have "+count+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);}});}});CSSLint.addRule({id:"selector-max",name:"Error when past the 4095 selector limit for IE",desc:"Will error when selector count is > 4095.",browsers:"IE",init:function(parser,reporter){var rule=this,count=0;parser.addListener('startrule',function(event){count+=event.selectors.length;});parser.addListener("endstylesheet",function(){if(count>4095){reporter.report("You have "+count+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);}});}});CSSLint.addRule({id:"shorthand",name:"Require shorthand properties",desc:"Use shorthand properties where possible.",browsers:"All",init:function(parser,reporter){var rule=this,prop,i,len,propertiesToCheck={},properties,mapping={"margin":["margin-top","margin-bottom","margin-left","margin-right"],"padding":["padding-top","padding-bottom","padding-left","padding-right"]};for(prop in mapping){if(mapping.hasOwnProperty(prop)){for(i=0,len=mapping[prop].length;i<len;i++){propertiesToCheck[mapping[prop][i]]=prop;}}}
|
251 |
+
function startRule(event){properties={};}
|
252 |
+
function endRule(event){var prop,i,len,total;for(prop in mapping){if(mapping.hasOwnProperty(prop)){total=0;for(i=0,len=mapping[prop].length;i<len;i++){total+=properties[mapping[prop][i]]?1:0;}
|
253 |
+
if(total==mapping[prop].length){reporter.report("The properties "+mapping[prop].join(", ")+" can be replaced by "+prop+".",event.line,event.col,rule);}}}}
|
254 |
+
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("property",function(event){var name=event.property.toString().toLowerCase(),value=event.value.parts[0].value;if(propertiesToCheck[name]){properties[name]=1;}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);}});CSSLint.addRule({id:"star-property-hack",name:"Disallow properties with a star prefix",desc:"Checks for the star property hack (targets IE6/7)",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var property=event.property;if(property.hack=="*"){reporter.report("Property with star prefix found.",event.property.line,event.property.col,rule);}});}});CSSLint.addRule({id:"text-indent",name:"Disallow negative text-indent",desc:"Checks for text indent less than -99px",browsers:"All",init:function(parser,reporter){var rule=this,textIndent,direction;function startRule(event){textIndent=false;direction="inherit";}
|
255 |
+
function endRule(event){if(textIndent&&direction!="ltr"){reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.",textIndent.line,textIndent.col,rule);}}
|
256 |
+
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("property",function(event){var name=event.property.toString().toLowerCase(),value=event.value;if(name=="text-indent"&&value.parts[0].value<-99){textIndent=event.property;}else if(name=="direction"&&value=="ltr"){direction="ltr";}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);}});CSSLint.addRule({id:"underscore-property-hack",name:"Disallow properties with an underscore prefix",desc:"Checks for the underscore property hack (targets IE6)",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var property=event.property;if(property.hack=="_"){reporter.report("Property with underscore prefix found.",event.property.line,event.property.col,rule);}});}});CSSLint.addRule({id:"unique-headings",name:"Headings should only be defined once",desc:"Headings should be defined only once.",browsers:"All",init:function(parser,reporter){var rule=this;var headings={h1:0,h2:0,h3:0,h4:0,h5:0,h6:0};parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,pseudo,i,j;for(i=0;i<selectors.length;i++){selector=selectors[i];part=selector.parts[selector.parts.length-1];if(part.elementName&&/(h[1-6])/i.test(part.elementName.toString())){for(j=0;j<part.modifiers.length;j++){if(part.modifiers[j].type=="pseudo"){pseudo=true;break;}}
|
257 |
+
if(!pseudo){headings[RegExp.$1]++;if(headings[RegExp.$1]>1){reporter.report("Heading ("+part.elementName+") has already been defined.",part.line,part.col,rule);}}}}});parser.addListener("endstylesheet",function(event){var prop,messages=[];for(prop in headings){if(headings.hasOwnProperty(prop)){if(headings[prop]>1){messages.push(headings[prop]+" "+prop+"s");}}}
|
258 |
+
if(messages.length){reporter.rollupWarn("You have "+messages.join(", ")+" defined in this stylesheet.",rule);}});}});CSSLint.addRule({id:"universal-selector",name:"Disallow universal selector",desc:"The universal selector (*) is known to be slow.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];part=selector.parts[selector.parts.length-1];if(part.elementName=="*"){reporter.report(rule.desc,part.line,part.col,rule);}}});}});CSSLint.addRule({id:"unqualified-attributes",name:"Disallow unqualified attribute selectors",desc:"Unqualified attribute selectors are known to be slow.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];part=selector.parts[selector.parts.length-1];if(part.type==parser.SELECTOR_PART_TYPE){for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(modifier.type=="attribute"&&(!part.elementName||part.elementName=="*")){reporter.report(rule.desc,part.line,part.col,rule);}}}}});}});CSSLint.addRule({id:"vendor-prefix",name:"Require standard property with vendor prefix",desc:"When using a vendor-prefixed property, make sure to include the standard one.",browsers:"All",init:function(parser,reporter){var rule=this,properties,num,propertiesToCheck={"-webkit-border-radius":"border-radius","-webkit-border-top-left-radius":"border-top-left-radius","-webkit-border-top-right-radius":"border-top-right-radius","-webkit-border-bottom-left-radius":"border-bottom-left-radius","-webkit-border-bottom-right-radius":"border-bottom-right-radius","-o-border-radius":"border-radius","-o-border-top-left-radius":"border-top-left-radius","-o-border-top-right-radius":"border-top-right-radius","-o-border-bottom-left-radius":"border-bottom-left-radius","-o-border-bottom-right-radius":"border-bottom-right-radius","-moz-border-radius":"border-radius","-moz-border-radius-topleft":"border-top-left-radius","-moz-border-radius-topright":"border-top-right-radius","-moz-border-radius-bottomleft":"border-bottom-left-radius","-moz-border-radius-bottomright":"border-bottom-right-radius","-moz-column-count":"column-count","-webkit-column-count":"column-count","-moz-column-gap":"column-gap","-webkit-column-gap":"column-gap","-moz-column-rule":"column-rule","-webkit-column-rule":"column-rule","-moz-column-rule-style":"column-rule-style","-webkit-column-rule-style":"column-rule-style","-moz-column-rule-color":"column-rule-color","-webkit-column-rule-color":"column-rule-color","-moz-column-rule-width":"column-rule-width","-webkit-column-rule-width":"column-rule-width","-moz-column-width":"column-width","-webkit-column-width":"column-width","-webkit-column-span":"column-span","-webkit-columns":"columns","-moz-box-shadow":"box-shadow","-webkit-box-shadow":"box-shadow","-moz-transform":"transform","-webkit-transform":"transform","-o-transform":"transform","-ms-transform":"transform","-moz-transform-origin":"transform-origin","-webkit-transform-origin":"transform-origin","-o-transform-origin":"transform-origin","-ms-transform-origin":"transform-origin","-moz-box-sizing":"box-sizing","-webkit-box-sizing":"box-sizing","-moz-user-select":"user-select","-khtml-user-select":"user-select","-webkit-user-select":"user-select"};function startRule(){properties={};num=1;}
|
259 |
+
function endRule(event){var prop,i,len,standard,needed,actual,needsStandard=[];for(prop in properties){if(propertiesToCheck[prop]){needsStandard.push({actual:prop,needed:propertiesToCheck[prop]});}}
|
260 |
+
for(i=0,len=needsStandard.length;i<len;i++){needed=needsStandard[i].needed;actual=needsStandard[i].actual;if(!properties[needed]){reporter.report("Missing standard property '"+needed+"' to go along with '"+actual+"'.",properties[actual][0].name.line,properties[actual][0].name.col,rule);}else{if(properties[needed][0].pos<properties[actual][0].pos){reporter.report("Standard property '"+needed+"' should come after vendor-prefixed property '"+actual+"'.",properties[actual][0].name.line,properties[actual][0].name.col,rule);}}}}
|
261 |
+
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(!properties[name]){properties[name]=[];}
|
262 |
+
properties[name].push({name:event.property,value:event.value,pos:num++});});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);parser.addListener("endpage",endRule);parser.addListener("endpagemargin",endRule);parser.addListener("endkeyframerule",endRule);}});CSSLint.addRule({id:"zero-units",name:"Disallow units for 0 values",desc:"You don't need to specify units when a value is 0.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var parts=event.value.parts,i=0,len=parts.length;while(i<len){if((parts[i].units||parts[i].type=="percentage")&&parts[i].value===0&&parts[i].type!="time"){reporter.report("Values of 0 shouldn't have units specified.",parts[i].line,parts[i].col,rule);}
|
263 |
+
i++;}});}});(function(){var xmlEscape=function(str){if(!str||str.constructor!==String){return"";}
|
264 |
+
return str.replace(/[\"&><]/g,function(match){switch(match){case"\"":return""";case"&":return"&";case"<":return"<";case">":return">";}});};CSSLint.addFormatter({id:"checkstyle-xml",name:"Checkstyle XML format",startFormat:function(){return"<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";},endFormat:function(){return"</checkstyle>";},readError:function(filename,message){return"<file name=\""+xmlEscape(filename)+"\"><error line=\"0\" column=\"0\" severty=\"error\" message=\""+xmlEscape(message)+"\"></error></file>";},formatResults:function(results,filename,options){var messages=results.messages,output=[];var generateSource=function(rule){if(!rule||!('name'in rule)){return"";}
|
265 |
+
return'net.csslint.'+rule.name.replace(/\s/g,'');};if(messages.length>0){output.push("<file name=\""+filename+"\">");CSSLint.Util.forEach(messages,function(message,i){if(!message.rollup){output.push("<error line=\""+message.line+"\" column=\""+message.col+"\" severity=\""+message.type+"\""+" message=\""+xmlEscape(message.message)+"\" source=\""+generateSource(message.rule)+"\"/>");}});output.push("</file>");}
|
266 |
+
return output.join("");}});}());CSSLint.addFormatter({id:"compact",name:"Compact, 'porcelain' format",startFormat:function(){return"";},endFormat:function(){return"";},formatResults:function(results,filename,options){var messages=results.messages,output="";options=options||{};var capitalize=function(str){return str.charAt(0).toUpperCase()+str.slice(1);};if(messages.length===0){return options.quiet?"":filename+": Lint Free!";}
|
267 |
+
CSSLint.Util.forEach(messages,function(message,i){if(message.rollup){output+=filename+": "+capitalize(message.type)+" - "+message.message+"\n";}else{output+=filename+": "+"line "+message.line+", col "+message.col+", "+capitalize(message.type)+" - "+message.message+"\n";}});return output;}});CSSLint.addFormatter({id:"csslint-xml",name:"CSSLint XML format",startFormat:function(){return"<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";},endFormat:function(){return"</csslint>";},formatResults:function(results,filename,options){var messages=results.messages,output=[];var escapeSpecialCharacters=function(str){if(!str||str.constructor!==String){return"";}
|
268 |
+
return str.replace(/\"/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");};if(messages.length>0){output.push("<file name=\""+filename+"\">");CSSLint.Util.forEach(messages,function(message,i){if(message.rollup){output.push("<issue severity=\""+message.type+"\" reason=\""+escapeSpecialCharacters(message.message)+"\" evidence=\""+escapeSpecialCharacters(message.evidence)+"\"/>");}else{output.push("<issue line=\""+message.line+"\" char=\""+message.col+"\" severity=\""+message.type+"\""+" reason=\""+escapeSpecialCharacters(message.message)+"\" evidence=\""+escapeSpecialCharacters(message.evidence)+"\"/>");}});output.push("</file>");}
|
269 |
+
return output.join("");}});CSSLint.addFormatter({id:"junit-xml",name:"JUNIT XML format",startFormat:function(){return"<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";},endFormat:function(){return"</testsuites>";},formatResults:function(results,filename,options){var messages=results.messages,output=[],tests={'error':0,'failure':0};var generateSource=function(rule){if(!rule||!('name'in rule)){return"";}
|
270 |
+
return'net.csslint.'+rule.name.replace(/\s/g,'');};var escapeSpecialCharacters=function(str){if(!str||str.constructor!==String){return"";}
|
271 |
+
return str.replace(/\"/g,"'").replace(/</g,"<").replace(/>/g,">");};if(messages.length>0){messages.forEach(function(message,i){var type=message.type==='warning'?'error':message.type;if(!message.rollup){output.push("<testcase time=\"0\" name=\""+generateSource(message.rule)+"\">");output.push("<"+type+" message=\""+escapeSpecialCharacters(message.message)+"\"><![CDATA["+message.line+':'+message.col+':'+escapeSpecialCharacters(message.evidence)+"]]></"+type+">");output.push("</testcase>");tests[type]+=1;}});output.unshift("<testsuite time=\"0\" tests=\""+messages.length+"\" skipped=\"0\" errors=\""+tests.error+"\" failures=\""+tests.failure+"\" package=\"net.csslint\" name=\""+filename+"\">");output.push("</testsuite>");}
|
272 |
+
return output.join("");}});CSSLint.addFormatter({id:"lint-xml",name:"Lint XML format",startFormat:function(){return"<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";},endFormat:function(){return"</lint>";},formatResults:function(results,filename,options){var messages=results.messages,output=[];var escapeSpecialCharacters=function(str){if(!str||str.constructor!==String){return"";}
|
273 |
+
return str.replace(/\"/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");};if(messages.length>0){output.push("<file name=\""+filename+"\">");CSSLint.Util.forEach(messages,function(message,i){if(message.rollup){output.push("<issue severity=\""+message.type+"\" reason=\""+escapeSpecialCharacters(message.message)+"\" evidence=\""+escapeSpecialCharacters(message.evidence)+"\"/>");}else{output.push("<issue line=\""+message.line+"\" char=\""+message.col+"\" severity=\""+message.type+"\""+" reason=\""+escapeSpecialCharacters(message.message)+"\" evidence=\""+escapeSpecialCharacters(message.evidence)+"\"/>");}});output.push("</file>");}
|
274 |
+
return output.join("");}});CSSLint.addFormatter({id:"text",name:"Plain Text",startFormat:function(){return"";},endFormat:function(){return"";},formatResults:function(results,filename,options){var messages=results.messages,output="";options=options||{};if(messages.length===0){return options.quiet?"":"\n\ncsslint: No errors in "+filename+".";}
|
275 |
+
output="\n\ncsslint: There are "+messages.length+" problems in "+filename+".";var pos=filename.lastIndexOf("/"),shortFilename=filename;if(pos===-1){pos=filename.lastIndexOf("\\");}
|
276 |
+
if(pos>-1){shortFilename=filename.substring(pos+1);}
|
277 |
+
CSSLint.Util.forEach(messages,function(message,i){output=output+"\n\n"+shortFilename;if(message.rollup){output+="\n"+(i+1)+": "+message.type;output+="\n"+message.message;}else{output+="\n"+(i+1)+": "+message.type+" at line "+message.line+", col "+message.col;output+="\n"+message.message;output+="\n"+message.evidence;}});return output;}});return CSSLint;})();
|
js/editor.js
ADDED
@@ -0,0 +1,1527 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
/* globals jQuery, _, socssOptions, Backbone, CodeMirror, console, cssjs, wp */
|
2 |
+
|
3 |
+
(function ($, _, socssOptions) {
|
4 |
+
|
5 |
+
var socss = {
|
6 |
+
model: {},
|
7 |
+
collection: {},
|
8 |
+
view: {},
|
9 |
+
fn: {}
|
10 |
+
};
|
11 |
+
|
12 |
+
window.socss = socss;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* The toolbar view
|
16 |
+
*/
|
17 |
+
socss.view.toolbar = Backbone.View.extend({
|
18 |
+
|
19 |
+
button: _.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),
|
20 |
+
|
21 |
+
editor: null,
|
22 |
+
|
23 |
+
initialize: function ( attr ) {
|
24 |
+
this.editor = attr.editor;
|
25 |
+
|
26 |
+
var thisView = this;
|
27 |
+
this.$('.editor-expand').click(function (e) {
|
28 |
+
e.preventDefault();
|
29 |
+
$(this).blur();
|
30 |
+
thisView.trigger('click_expand');
|
31 |
+
});
|
32 |
+
|
33 |
+
this.$('.editor-visual').click(function (e) {
|
34 |
+
e.preventDefault();
|
35 |
+
$(this).blur();
|
36 |
+
thisView.trigger('click_visual');
|
37 |
+
});
|
38 |
+
},
|
39 |
+
|
40 |
+
addButton: function (text, action) {
|
41 |
+
var thisView = this;
|
42 |
+
var button = $(this.button({text: text}))
|
43 |
+
.appendTo(this.$('.toolbar-function-buttons .toolbar-buttons'))
|
44 |
+
.click(function (e) {
|
45 |
+
e.preventDefault();
|
46 |
+
$(this).blur();
|
47 |
+
thisView.trigger('click_' + action);
|
48 |
+
});
|
49 |
+
|
50 |
+
return button;
|
51 |
+
}
|
52 |
+
});
|
53 |
+
|
54 |
+
/**
|
55 |
+
* The editor view, which handles codemirror stuff
|
56 |
+
*/
|
57 |
+
socss.view.editor = Backbone.View.extend({
|
58 |
+
|
59 |
+
codeMirror: null,
|
60 |
+
snippets: null,
|
61 |
+
toolbar: null,
|
62 |
+
visualProperties: null,
|
63 |
+
|
64 |
+
inspector: null,
|
65 |
+
|
66 |
+
cssSelectors: [],
|
67 |
+
|
68 |
+
initialize: function (args) {
|
69 |
+
this.setupEditor();
|
70 |
+
},
|
71 |
+
|
72 |
+
render: function () {
|
73 |
+
var thisView = this;
|
74 |
+
|
75 |
+
// Setup the toolbar
|
76 |
+
this.toolbar = new socss.view.toolbar({
|
77 |
+
editor: this,
|
78 |
+
el: this.$('.custom-css-toolbar')
|
79 |
+
});
|
80 |
+
this.toolbar.editor = this;
|
81 |
+
this.toolbar.render();
|
82 |
+
|
83 |
+
// Create the visual properties view
|
84 |
+
this.visualProperties = new socss.view.properties({
|
85 |
+
editor: this,
|
86 |
+
el: $('#so-custom-css-properties')
|
87 |
+
});
|
88 |
+
this.visualProperties.render();
|
89 |
+
|
90 |
+
this.toolbar.on('click_expand', function () {
|
91 |
+
thisView.toggleExpand();
|
92 |
+
});
|
93 |
+
|
94 |
+
this.toolbar.on('click_visual', function () {
|
95 |
+
thisView.visualProperties.loadCSS( thisView.codeMirror.getValue() );
|
96 |
+
thisView.visualProperties.show();
|
97 |
+
});
|
98 |
+
|
99 |
+
this.preview = new socss.view.preview({
|
100 |
+
editor: this,
|
101 |
+
el: this.$('.custom-css-preview')
|
102 |
+
});
|
103 |
+
this.preview.render();
|
104 |
+
},
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Do the initial setup of the CodeMirror editor
|
108 |
+
*/
|
109 |
+
setupEditor: function () {
|
110 |
+
var thisView = this;
|
111 |
+
this.registerCodeMirrorAutocomplete();
|
112 |
+
|
113 |
+
// Setup the Codemirror instance
|
114 |
+
this.codeMirror = CodeMirror.fromTextArea(this.$('textarea.css-editor').get(0), {
|
115 |
+
tabSize: 2,
|
116 |
+
mode: 'css',
|
117 |
+
theme: 'neat',
|
118 |
+
gutters: [
|
119 |
+
"CodeMirror-lint-markers"
|
120 |
+
],
|
121 |
+
lint: true
|
122 |
+
});
|
123 |
+
|
124 |
+
// Make sure the user doesn't leave without saving
|
125 |
+
var startCss = this.$('textarea.css-editor').val();
|
126 |
+
this.$el.on('submit', function(){
|
127 |
+
startCss = thisView.codeMirror.getValue();
|
128 |
+
});
|
129 |
+
$(window).bind('beforeunload', function(){
|
130 |
+
if( thisView.codeMirror.getValue() !== startCss ) {
|
131 |
+
return socssOptions.loc.leave;
|
132 |
+
}
|
133 |
+
});
|
134 |
+
|
135 |
+
|
136 |
+
// Set the container to visible overflow once the editor is setup
|
137 |
+
this.$el.find('.custom-css-container').css('overflow', 'visible');
|
138 |
+
this.scaleEditor();
|
139 |
+
|
140 |
+
// Scale the editor whenever the window is resized
|
141 |
+
$(window).resize(function () {
|
142 |
+
thisView.scaleEditor();
|
143 |
+
});
|
144 |
+
|
145 |
+
// Setup the extensions
|
146 |
+
this.setupCodeMirrorExtensions();
|
147 |
+
},
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Register the autocomplete helper. Based on css-hint.js in the codemirror addon folder.
|
151 |
+
*/
|
152 |
+
registerCodeMirrorAutocomplete: function () {
|
153 |
+
var thisView = this;
|
154 |
+
|
155 |
+
var pseudoClasses = {
|
156 |
+
link: 1, visited: 1, active: 1, hover: 1, focus: 1,
|
157 |
+
"first-letter": 1, "first-line": 1, "first-child": 1,
|
158 |
+
before: 1, after: 1, lang: 1
|
159 |
+
};
|
160 |
+
|
161 |
+
CodeMirror.registerHelper("hint", "css", function (cm) {
|
162 |
+
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
163 |
+
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
|
164 |
+
if (inner.mode.name !== "css") {
|
165 |
+
return;
|
166 |
+
}
|
167 |
+
|
168 |
+
if (token.type === "keyword" && "!important".indexOf(token.string) === 0) {
|
169 |
+
return {
|
170 |
+
list: ["!important"], from: CodeMirror.Pos(cur.line, token.start),
|
171 |
+
to: CodeMirror.Pos(cur.line, token.end)
|
172 |
+
};
|
173 |
+
}
|
174 |
+
|
175 |
+
var start = token.start, end = cur.ch, word = token.string.slice(0, end - start);
|
176 |
+
if (/[^\w$_-]/.test(word)) {
|
177 |
+
word = "";
|
178 |
+
start = end = cur.ch;
|
179 |
+
}
|
180 |
+
|
181 |
+
var spec = CodeMirror.resolveMode("text/css");
|
182 |
+
|
183 |
+
var result = [];
|
184 |
+
|
185 |
+
function add(keywords) {
|
186 |
+
for (var name in keywords) {
|
187 |
+
if (!word || name.lastIndexOf(word, 0) === 0) {
|
188 |
+
result.push(name);
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
var st = inner.state.state;
|
194 |
+
|
195 |
+
if (st === 'top') {
|
196 |
+
// We're going to autocomplete the selector using our own set of rules
|
197 |
+
var line = cm.getLine(cur.line).trim();
|
198 |
+
|
199 |
+
var selectors = thisView.cssSelectors;
|
200 |
+
for (var i = 0; i < selectors.length; i++) {
|
201 |
+
if (selectors[i].selector.indexOf(line) !== -1) {
|
202 |
+
result.push(selectors[i].selector);
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
if (result.length) {
|
207 |
+
return {
|
208 |
+
list: result,
|
209 |
+
from: CodeMirror.Pos(cur.line, 0),
|
210 |
+
to: CodeMirror.Pos(cur.line, end)
|
211 |
+
};
|
212 |
+
}
|
213 |
+
}
|
214 |
+
else {
|
215 |
+
|
216 |
+
if (st === "pseudo" || token.type === "variable-3") {
|
217 |
+
add(pseudoClasses);
|
218 |
+
}
|
219 |
+
else if (st === "block" || st === "maybeprop") {
|
220 |
+
add(spec.propertyKeywords);
|
221 |
+
}
|
222 |
+
else if (st === "prop" || st === "parens" || st === "at" || st === "params") {
|
223 |
+
add(spec.valueKeywords);
|
224 |
+
add(spec.colorKeywords);
|
225 |
+
}
|
226 |
+
else if (st === "media" || st === "media_parens") {
|
227 |
+
add(spec.mediaTypes);
|
228 |
+
add(spec.mediaFeatures);
|
229 |
+
}
|
230 |
+
|
231 |
+
if (result.length) {
|
232 |
+
return {
|
233 |
+
list: result,
|
234 |
+
from: CodeMirror.Pos(cur.line, start),
|
235 |
+
to: CodeMirror.Pos(cur.line, end)
|
236 |
+
};
|
237 |
+
}
|
238 |
+
|
239 |
+
}
|
240 |
+
|
241 |
+
});
|
242 |
+
},
|
243 |
+
|
244 |
+
setupCodeMirrorExtensions: function () {
|
245 |
+
var thisView = this;
|
246 |
+
|
247 |
+
this.codeMirror.on('cursorActivity', function (cm) {
|
248 |
+
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
249 |
+
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
|
250 |
+
|
251 |
+
// If we have a qualifier selected, then highlight that in the preview
|
252 |
+
if (token.type === 'qualifier' || token.type === 'tag' || token.type === 'builtin') {
|
253 |
+
var line = cm.getLine(cur.line);
|
254 |
+
var selector = line.substring(0, token.end);
|
255 |
+
|
256 |
+
thisView.preview.highlight(selector);
|
257 |
+
}
|
258 |
+
else {
|
259 |
+
thisView.preview.clearHighlight();
|
260 |
+
}
|
261 |
+
});
|
262 |
+
|
263 |
+
// This sets up automatic autocompletion at all times
|
264 |
+
this.codeMirror.on('keyup', function (cm, e) {
|
265 |
+
if (
|
266 |
+
( e.keyCode >= 65 && e.keyCode <= 90 ) ||
|
267 |
+
( e.keyCode === 189 && !e.shiftKey ) ||
|
268 |
+
( e.keyCode === 190 && !e.shiftKey ) ||
|
269 |
+
( e.keyCode === 51 && e.shiftKey ) ||
|
270 |
+
( e.keyCode === 189 && e.shiftKey )
|
271 |
+
) {
|
272 |
+
cm.showHint(e);
|
273 |
+
}
|
274 |
+
});
|
275 |
+
},
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Scale the size of the editor depending on whether it's expanded or not
|
279 |
+
*/
|
280 |
+
scaleEditor: function () {
|
281 |
+
if (this.$el.hasClass('expanded')) {
|
282 |
+
// If we're in the expanded view, then resize the editor
|
283 |
+
this.codeMirror.setSize('100%', $(window).outerHeight() - this.$('.custom-css-toolbar').outerHeight());
|
284 |
+
}
|
285 |
+
else {
|
286 |
+
this.codeMirror.setSize('100%', 'auto');
|
287 |
+
}
|
288 |
+
},
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Check if the editor is in expanded mode
|
292 |
+
* @returns bool
|
293 |
+
*/
|
294 |
+
isExpanded: function () {
|
295 |
+
return this.$el.hasClass('expanded');
|
296 |
+
},
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Toggle if this is expanded or not
|
300 |
+
*/
|
301 |
+
toggleExpand: function () {
|
302 |
+
this.$el.toggleClass('expanded');
|
303 |
+
this.scaleEditor();
|
304 |
+
},
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Set the expanded state of the editor
|
308 |
+
* @param expanded
|
309 |
+
*/
|
310 |
+
setExpand: function (expanded) {
|
311 |
+
if (expanded) {
|
312 |
+
this.$el.addClass('expanded');
|
313 |
+
}
|
314 |
+
else {
|
315 |
+
this.$el.removeClass('expanded');
|
316 |
+
}
|
317 |
+
this.scaleEditor();
|
318 |
+
},
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Set the snippets available to this editor
|
322 |
+
*/
|
323 |
+
setSnippets: function (snippets) {
|
324 |
+
if (!_.isEmpty(snippets)) {
|
325 |
+
var thisView = this;
|
326 |
+
|
327 |
+
this.snippets = new socss.view.snippets({
|
328 |
+
snippets: snippets
|
329 |
+
});
|
330 |
+
this.snippets.editor = this;
|
331 |
+
|
332 |
+
this.snippets.render();
|
333 |
+
this.toolbar.addButton('Snippets', 'snippets');
|
334 |
+
this.toolbar.on('click_snippets', function () {
|
335 |
+
thisView.snippets.show();
|
336 |
+
});
|
337 |
+
}
|
338 |
+
},
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Add some CSS to the editor.
|
342 |
+
* @param css
|
343 |
+
*/
|
344 |
+
addCode: function (css) {
|
345 |
+
var editor = this.codeMirror;
|
346 |
+
|
347 |
+
var before_css = '';
|
348 |
+
if (editor.doc.lineCount() === 1 && editor.doc.getLine(editor.doc.lastLine()).length === 0) {
|
349 |
+
before_css = "";
|
350 |
+
}
|
351 |
+
else if (editor.doc.getLine(editor.doc.lastLine()).length === 0) {
|
352 |
+
before_css = "\n";
|
353 |
+
}
|
354 |
+
else {
|
355 |
+
before_css = "\n\n";
|
356 |
+
}
|
357 |
+
|
358 |
+
// Now insert the code in the editor
|
359 |
+
editor.doc.setCursor(
|
360 |
+
editor.doc.lastLine(),
|
361 |
+
editor.doc.getLine(editor.doc.lastLine()).length
|
362 |
+
);
|
363 |
+
editor.doc.replaceSelection(before_css + css);
|
364 |
+
},
|
365 |
+
|
366 |
+
addEmptySelector: function (selector) {
|
367 |
+
this.addCode(selector + " {\n \n}");
|
368 |
+
},
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Sets the inspector view that's being used by the editor
|
372 |
+
*/
|
373 |
+
setInspector: function (inspector) {
|
374 |
+
var thisView = this;
|
375 |
+
this.inspector = inspector;
|
376 |
+
this.cssSelectors = inspector.pageSelectors;
|
377 |
+
|
378 |
+
// A selector is clicked in the inspector
|
379 |
+
inspector.on('click_selector', function (selector) {
|
380 |
+
if ( thisView.visualProperties.isVisible() ) {
|
381 |
+
thisView.visualProperties.addSelector(selector);
|
382 |
+
}
|
383 |
+
else {
|
384 |
+
thisView.addEmptySelector(selector);
|
385 |
+
}
|
386 |
+
});
|
387 |
+
|
388 |
+
// A property is clicked in the inspector
|
389 |
+
inspector.on('click_property', function (property) {
|
390 |
+
if ( ! thisView.visualProperties.isVisible() ) {
|
391 |
+
thisView.codeMirror.replaceSelection(property + ";\n ");
|
392 |
+
}
|
393 |
+
});
|
394 |
+
|
395 |
+
inspector.on('set_active_element', function(el, selectors){
|
396 |
+
if ( thisView.visualProperties.isVisible() && selectors.length ) {
|
397 |
+
thisView.visualProperties.addSelector( selectors[0].selector );
|
398 |
+
}
|
399 |
+
});
|
400 |
+
}
|
401 |
+
|
402 |
+
});
|
403 |
+
|
404 |
+
/**
|
405 |
+
* The preview.
|
406 |
+
*/
|
407 |
+
socss.view.preview = Backbone.View.extend({
|
408 |
+
|
409 |
+
template: _.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),
|
410 |
+
editor: null,
|
411 |
+
|
412 |
+
initialize: function (attr) {
|
413 |
+
this.editor = attr.editor;
|
414 |
+
|
415 |
+
var thisView = this;
|
416 |
+
this.editor.codeMirror.on('change', function (cm, c) {
|
417 |
+
thisView.updatePreviewCss();
|
418 |
+
});
|
419 |
+
},
|
420 |
+
|
421 |
+
render: function () {
|
422 |
+
var thisView = this;
|
423 |
+
|
424 |
+
this.$el.html(this.template());
|
425 |
+
|
426 |
+
this.$('.preview-iframe')
|
427 |
+
.attr('src', socssOptions.homeURL)
|
428 |
+
.load(function () {
|
429 |
+
var $$ = $(this);
|
430 |
+
$$.contents().find('a').each(function () {
|
431 |
+
var href = $(this).attr('href');
|
432 |
+
if (href === undefined) {
|
433 |
+
return true;
|
434 |
+
}
|
435 |
+
|
436 |
+
var firstSeperator = (href.indexOf('?') === -1 ? '?' : '&');
|
437 |
+
$(this).attr('href', href + firstSeperator + 'so_css_preview=1');
|
438 |
+
});
|
439 |
+
|
440 |
+
thisView.updatePreviewCss();
|
441 |
+
})
|
442 |
+
.mouseleave(function () {
|
443 |
+
thisView.clearHighlight();
|
444 |
+
});
|
445 |
+
},
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Update the preview CSS from the CodeMirror value in the editor
|
449 |
+
*/
|
450 |
+
updatePreviewCss: function () {
|
451 |
+
var preview = this.$('.preview-iframe');
|
452 |
+
if (preview.length === 0) {
|
453 |
+
return;
|
454 |
+
}
|
455 |
+
|
456 |
+
var head = preview.contents().find('head');
|
457 |
+
if (head.find('style.siteorigin-custom-css').length === 0) {
|
458 |
+
head.append('<style class="siteorigin-custom-css" type="text/css"></style>');
|
459 |
+
}
|
460 |
+
var style = head.find('style.siteorigin-custom-css');
|
461 |
+
|
462 |
+
// Update the CSS after a short delay
|
463 |
+
var css = this.editor.codeMirror.getValue();
|
464 |
+
style.html(css);
|
465 |
+
},
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Highlight all elements with a given selector
|
469 |
+
*/
|
470 |
+
highlight: function (selector) {
|
471 |
+
try {
|
472 |
+
this.editor.inspector.hl.highlight(selector);
|
473 |
+
}
|
474 |
+
catch (err) {
|
475 |
+
console.log('No inspector to highlight with');
|
476 |
+
}
|
477 |
+
},
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Clear the currently highlighted elements in preview
|
481 |
+
*/
|
482 |
+
clearHighlight: function () {
|
483 |
+
try {
|
484 |
+
this.editor.inspector.hl.clear();
|
485 |
+
}
|
486 |
+
catch (err) {
|
487 |
+
console.log('No inspector to highlight with');
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
});
|
492 |
+
|
493 |
+
/**
|
494 |
+
* The dialog for the snippets browser
|
495 |
+
*/
|
496 |
+
socss.view.snippets = Backbone.View.extend({
|
497 |
+
template: _.template($('#template-snippet-browser').html()),
|
498 |
+
snippet: _.template('<li class="snippet"><%- name %></li>'),
|
499 |
+
className: 'css-editor-snippet-browser',
|
500 |
+
snippets: null,
|
501 |
+
editor: null,
|
502 |
+
|
503 |
+
events: {
|
504 |
+
'click .close': 'hide',
|
505 |
+
'click .buttons .insert-snippet': 'insertSnippet'
|
506 |
+
},
|
507 |
+
|
508 |
+
currentSnippet: null,
|
509 |
+
|
510 |
+
initialize: function (args) {
|
511 |
+
this.snippets = args.snippets;
|
512 |
+
},
|
513 |
+
|
514 |
+
render: function () {
|
515 |
+
var thisView = this;
|
516 |
+
|
517 |
+
|
518 |
+
var clickSnippet = function (e) {
|
519 |
+
e.preventDefault();
|
520 |
+
var $$ = $(this);
|
521 |
+
|
522 |
+
thisView.$('.snippets li.snippet').removeClass('active');
|
523 |
+
$(this).addClass('active');
|
524 |
+
thisView.viewSnippet({
|
525 |
+
name: $$.html(),
|
526 |
+
description: $$.data('description'),
|
527 |
+
css: $$.data('css')
|
528 |
+
});
|
529 |
+
};
|
530 |
+
|
531 |
+
this.$el.html(this.template());
|
532 |
+
for (var i = 0; i < this.snippets.length; i++) {
|
533 |
+
$(this.snippet({name: this.snippets[i].Name}))
|
534 |
+
.data({
|
535 |
+
'description': this.snippets[i].Description,
|
536 |
+
'css': this.snippets[i].css
|
537 |
+
})
|
538 |
+
.appendTo(this.$('ul.snippets'))
|
539 |
+
.click(clickSnippet);
|
540 |
+
}
|
541 |
+
|
542 |
+
// Click on the first one
|
543 |
+
thisView.$('.snippets li.snippet').eq(0).click();
|
544 |
+
|
545 |
+
this.attach();
|
546 |
+
return this;
|
547 |
+
},
|
548 |
+
|
549 |
+
viewSnippet: function (args) {
|
550 |
+
var w = this.$('.main .snippet-view');
|
551 |
+
|
552 |
+
w.find('.snippet-title').html(args.name);
|
553 |
+
w.find('.snippet-description').html(args.description);
|
554 |
+
w.find('.snippet-code').html(args.css);
|
555 |
+
|
556 |
+
this.currentSnippet = args;
|
557 |
+
},
|
558 |
+
|
559 |
+
insertSnippet: function () {
|
560 |
+
var editor = this.editor.codeMirror;
|
561 |
+
var css = this.currentSnippet.css;
|
562 |
+
|
563 |
+
var before_css = '';
|
564 |
+
if (editor.doc.lineCount() === 1 && editor.doc.getLine(editor.doc.lastLine()).length === 0) {
|
565 |
+
before_css = "";
|
566 |
+
}
|
567 |
+
else if (editor.doc.getLine(editor.doc.lastLine()).length === 0) {
|
568 |
+
before_css = "\n";
|
569 |
+
}
|
570 |
+
else {
|
571 |
+
before_css = "\n\n";
|
572 |
+
}
|
573 |
+
|
574 |
+
// Now insert the code in the editor
|
575 |
+
editor.doc.setCursor(
|
576 |
+
editor.doc.lastLine(),
|
577 |
+
editor.doc.getLine(editor.doc.lastLine()).length
|
578 |
+
);
|
579 |
+
editor.doc.replaceSelection(before_css + css);
|
580 |
+
|
581 |
+
this.hide();
|
582 |
+
},
|
583 |
+
|
584 |
+
attach: function () {
|
585 |
+
this.$el.appendTo('body');
|
586 |
+
},
|
587 |
+
|
588 |
+
show: function () {
|
589 |
+
this.$el.show();
|
590 |
+
},
|
591 |
+
|
592 |
+
hide: function () {
|
593 |
+
this.$el.hide();
|
594 |
+
}
|
595 |
+
});
|
596 |
+
|
597 |
+
|
598 |
+
/**
|
599 |
+
* The visual properties editor
|
600 |
+
*/
|
601 |
+
socss.view.properties = Backbone.View.extend({
|
602 |
+
|
603 |
+
model: socss.model.cssRules,
|
604 |
+
|
605 |
+
tabTemplate: _.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),
|
606 |
+
sectionTemplate: _.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),
|
607 |
+
controllerTemplate: _.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),
|
608 |
+
|
609 |
+
/**
|
610 |
+
* The controllers for each of the properties
|
611 |
+
*/
|
612 |
+
propertyControllers: [],
|
613 |
+
|
614 |
+
/**
|
615 |
+
* The editor view
|
616 |
+
*/
|
617 |
+
editor: null,
|
618 |
+
|
619 |
+
/**
|
620 |
+
* The current, raw CSS
|
621 |
+
*/
|
622 |
+
css: '',
|
623 |
+
|
624 |
+
/**
|
625 |
+
* Parsed CSS
|
626 |
+
*/
|
627 |
+
parsed: {},
|
628 |
+
|
629 |
+
/**
|
630 |
+
* The current active selector
|
631 |
+
*/
|
632 |
+
activeSelector: '',
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Was the editor expanded before we went into the property editor
|
636 |
+
*/
|
637 |
+
editorExpandedBefore: false,
|
638 |
+
|
639 |
+
events: {
|
640 |
+
'click .close': 'hide'
|
641 |
+
},
|
642 |
+
|
643 |
+
/**
|
644 |
+
* Initialize the properties editor with a new model
|
645 |
+
*/
|
646 |
+
initialize: function ( attr ) {
|
647 |
+
this.parser = new cssjs();
|
648 |
+
this.editor = attr.editor;
|
649 |
+
},
|
650 |
+
|
651 |
+
/**
|
652 |
+
* Render the property editor
|
653 |
+
*/
|
654 |
+
render: function () {
|
655 |
+
var thisView = this;
|
656 |
+
|
657 |
+
var controllers = socssOptions.propertyControllers;
|
658 |
+
|
659 |
+
for (var id in controllers) {
|
660 |
+
// Create the tabs
|
661 |
+
var $t = $(this.tabTemplate({
|
662 |
+
id: id,
|
663 |
+
icon: controllers[id].icon,
|
664 |
+
title: controllers[id].title
|
665 |
+
})).appendTo(this.$('.section-tabs'));
|
666 |
+
|
667 |
+
// Create the section wrapper
|
668 |
+
var $s = $(this.sectionTemplate({
|
669 |
+
id: id
|
670 |
+
})).appendTo(this.$('.sections'));
|
671 |
+
|
672 |
+
// Now lets add the controllers
|
673 |
+
if (!_.isEmpty(controllers[id].controllers)) {
|
674 |
+
|
675 |
+
for (var i = 0; i < controllers[id].controllers.length; i++) {
|
676 |
+
|
677 |
+
var $c = $(thisView.controllerTemplate({
|
678 |
+
title: controllers[id].controllers[i].title
|
679 |
+
})).appendTo($s.find('tbody'));
|
680 |
+
|
681 |
+
var controllerAtts = controllers[id].controllers[i];
|
682 |
+
var controller;
|
683 |
+
|
684 |
+
if (typeof socss.view.properties.controllers[controllerAtts.type] === 'undefined') {
|
685 |
+
// Setup a default controller
|
686 |
+
controller = new socss.view.propertyController({
|
687 |
+
el: $c.find('td'),
|
688 |
+
propertiesView: thisView,
|
689 |
+
args: ( typeof controllerAtts.args === 'undefined' ? {} : controllerAtts.args )
|
690 |
+
});
|
691 |
+
}
|
692 |
+
else {
|
693 |
+
// Setup a specific controller
|
694 |
+
controller = new socss.view.properties.controllers[controllerAtts.type]({
|
695 |
+
el: $c.find('td'),
|
696 |
+
propertiesView: thisView,
|
697 |
+
args: ( typeof controllerAtts.args === 'undefined' ? {} : controllerAtts.args )
|
698 |
+
});
|
699 |
+
}
|
700 |
+
|
701 |
+
thisView.propertyControllers.push(controller);
|
702 |
+
|
703 |
+
// Setup and render the controller
|
704 |
+
controller.render();
|
705 |
+
controller.initChangeEvents();
|
706 |
+
}
|
707 |
+
}
|
708 |
+
}
|
709 |
+
|
710 |
+
// Setup the tab switching for the property sections
|
711 |
+
this.$('.section-tabs li').click(function () {
|
712 |
+
var $$ = $(this);
|
713 |
+
var show = thisView.$('.sections .section[data-section="' + $$.data('section') + '"]');
|
714 |
+
|
715 |
+
thisView.$('.sections .section').not(show).hide().removeClass('active');
|
716 |
+
show.show().addClass('active');
|
717 |
+
|
718 |
+
thisView.$('.section-tabs li').not($$).removeClass('active');
|
719 |
+
$$.addClass('active');
|
720 |
+
}).eq(0).click();
|
721 |
+
|
722 |
+
this.$('.toolbar select').change(function () {
|
723 |
+
thisView.setActivateSelector($(this).find(':selected').data('selector'));
|
724 |
+
});
|
725 |
+
},
|
726 |
+
|
727 |
+
/**
|
728 |
+
* Sets the rule value for the active selector
|
729 |
+
* @param rule
|
730 |
+
* @param value
|
731 |
+
*/
|
732 |
+
setRuleValue: function (rule, value) {
|
733 |
+
if (typeof this.activeSelector === 'undefined' || typeof this.activeSelector.rules === 'undefined') {
|
734 |
+
return;
|
735 |
+
}
|
736 |
+
|
737 |
+
var newRule = true;
|
738 |
+
for (var i = 0; i < this.activeSelector.rules.length; i++) {
|
739 |
+
if (this.activeSelector.rules[i].directive === rule) {
|
740 |
+
this.activeSelector.rules[i].value = value;
|
741 |
+
newRule = false;
|
742 |
+
break;
|
743 |
+
}
|
744 |
+
}
|
745 |
+
|
746 |
+
if (newRule) {
|
747 |
+
this.activeSelector.rules.push({
|
748 |
+
directive: rule,
|
749 |
+
value: value
|
750 |
+
});
|
751 |
+
}
|
752 |
+
|
753 |
+
this.updateMainEditor( false );
|
754 |
+
},
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Get the rule value for the active selector
|
758 |
+
* @param rule
|
759 |
+
*/
|
760 |
+
getRuleValue: function (rule) {
|
761 |
+
if (typeof this.activeSelector === 'undefined' || typeof this.activeSelector.rules === 'undefined') {
|
762 |
+
return '';
|
763 |
+
}
|
764 |
+
|
765 |
+
for (var i = 0; i < this.activeSelector.rules.length; i++) {
|
766 |
+
if (this.activeSelector.rules[i].directive === rule) {
|
767 |
+
return this.activeSelector.rules[i].value;
|
768 |
+
}
|
769 |
+
}
|
770 |
+
return '';
|
771 |
+
},
|
772 |
+
|
773 |
+
/**
|
774 |
+
* Update the main editor with the value of the parsed CSS
|
775 |
+
*/
|
776 |
+
updateMainEditor: function ( compress ) {
|
777 |
+
var css;
|
778 |
+
if( typeof compress === 'undefined' || compress === true ) {
|
779 |
+
css = this.parser.compressCSS( this.parsed );
|
780 |
+
// Also remove any empty selectors
|
781 |
+
css = css.filter( function(v){
|
782 |
+
return (
|
783 |
+
typeof v.type !== 'undefined' ||
|
784 |
+
v.rules.length > 0
|
785 |
+
);
|
786 |
+
} );
|
787 |
+
}
|
788 |
+
else {
|
789 |
+
css = this.parsed;
|
790 |
+
}
|
791 |
+
|
792 |
+
this.editor.codeMirror.setValue( this.parser.getCSSForEditor( css ).trim() );
|
793 |
+
},
|
794 |
+
|
795 |
+
/**
|
796 |
+
* Show the properties editor
|
797 |
+
*/
|
798 |
+
show: function () {
|
799 |
+
this.editorExpandedBefore = this.editor.isExpanded();
|
800 |
+
this.editor.setExpand(true);
|
801 |
+
|
802 |
+
this.$el.show().animate({'left': 0}, 'fast');
|
803 |
+
},
|
804 |
+
|
805 |
+
/**
|
806 |
+
* Hide the properties editor
|
807 |
+
*/
|
808 |
+
hide: function () {
|
809 |
+
this.editor.setExpand(this.editorExpandedBefore);
|
810 |
+
this.$el.animate( {'left': -338}, 'fast', function(){
|
811 |
+
$(this).hide();
|
812 |
+
} );
|
813 |
+
|
814 |
+
// Update the main editor with compressed CSS when we close the properties editor
|
815 |
+
this.updateMainEditor( true );
|
816 |
+
},
|
817 |
+
|
818 |
+
/**
|
819 |
+
* @returns boolean
|
820 |
+
*/
|
821 |
+
isVisible: function () {
|
822 |
+
return this.$el.is(':visible');
|
823 |
+
},
|
824 |
+
|
825 |
+
/**
|
826 |
+
* Loads a single CSS selector and associated properties into the model
|
827 |
+
* @param css
|
828 |
+
*/
|
829 |
+
loadCSS: function (css, activeSelector) {
|
830 |
+
this.css = css;
|
831 |
+
|
832 |
+
// Load the CSS and combine rules
|
833 |
+
this.parsed = this.parser.compressCSS( this.parser.parseCSS(css) );
|
834 |
+
|
835 |
+
// Add the dropdown menu items
|
836 |
+
var dropdown = this.$('.toolbar select').empty();
|
837 |
+
for (var i = 0; i < this.parsed.length; i++) {
|
838 |
+
var rule = this.parsed[i];
|
839 |
+
|
840 |
+
if( typeof rule.subStyles !== 'undefined' ) {
|
841 |
+
|
842 |
+
for (var j = 0; j < rule.subStyles.length; j++) {
|
843 |
+
var subRule = rule.subStyles[j];
|
844 |
+
dropdown.append(
|
845 |
+
$('<option>')
|
846 |
+
.html( rule.selector + ': ' + subRule.selector )
|
847 |
+
.attr( 'val', rule.selector + ': ' + subRule.selector )
|
848 |
+
.data( 'selector', subRule )
|
849 |
+
);
|
850 |
+
}
|
851 |
+
|
852 |
+
}
|
853 |
+
else {
|
854 |
+
dropdown.append(
|
855 |
+
$('<option>')
|
856 |
+
.html( rule.selector )
|
857 |
+
.attr( 'val', rule.selector )
|
858 |
+
.data( 'selector', rule )
|
859 |
+
);
|
860 |
+
}
|
861 |
+
}
|
862 |
+
|
863 |
+
if (typeof activeSelector === 'undefined') {
|
864 |
+
activeSelector = dropdown.find('option').eq(0).attr('val');
|
865 |
+
}
|
866 |
+
dropdown.val(activeSelector).change();
|
867 |
+
},
|
868 |
+
|
869 |
+
/**
|
870 |
+
* Set the selector that we're currently dealing with
|
871 |
+
* @param selector
|
872 |
+
*/
|
873 |
+
setActivateSelector: function (selector) {
|
874 |
+
this.activeSelector = selector;
|
875 |
+
for (var i = 0; i < this.propertyControllers.length; i++) {
|
876 |
+
this.propertyControllers[i].refreshFromRule();
|
877 |
+
}
|
878 |
+
},
|
879 |
+
|
880 |
+
/**
|
881 |
+
* Add or select a selector.
|
882 |
+
*
|
883 |
+
* @param selector
|
884 |
+
*/
|
885 |
+
addSelector: function(selector) {
|
886 |
+
// Check if this selector already exists
|
887 |
+
var dropdown = this.$('.toolbar select');
|
888 |
+
dropdown.val( selector );
|
889 |
+
|
890 |
+
if( dropdown.val() === selector ) {
|
891 |
+
// Trigger a change event to load the existing selector
|
892 |
+
dropdown.change();
|
893 |
+
}
|
894 |
+
else {
|
895 |
+
// The selector doesn't exist, so add it to the CSS, then reload
|
896 |
+
this.editor.addEmptySelector(selector);
|
897 |
+
this.loadCSS( this.editor.codeMirror.getValue(), selector );
|
898 |
+
}
|
899 |
+
|
900 |
+
dropdown.addClass('highlighted');
|
901 |
+
setTimeout(function(){
|
902 |
+
dropdown.removeClass('highlighted');
|
903 |
+
}, 2000);
|
904 |
+
}
|
905 |
+
|
906 |
+
});
|
907 |
+
|
908 |
+
// The basic property controller
|
909 |
+
socss.view.propertyController = Backbone.View.extend({
|
910 |
+
|
911 |
+
template: _.template('<input type="text" value="" />'),
|
912 |
+
activeRule: null,
|
913 |
+
args: null,
|
914 |
+
propertiesView: null,
|
915 |
+
|
916 |
+
initialize: function (args) {
|
917 |
+
|
918 |
+
this.args = args.args;
|
919 |
+
this.propertiesView = args.propertiesView;
|
920 |
+
|
921 |
+
// By default, update the active rule whenever things change
|
922 |
+
this.on('set_value', this.updateRule, this);
|
923 |
+
this.on('change', this.updateRule, this);
|
924 |
+
},
|
925 |
+
|
926 |
+
/**
|
927 |
+
* Render the property field controller
|
928 |
+
*/
|
929 |
+
render: function () {
|
930 |
+
this.$el.append( $(this.template( {} )) );
|
931 |
+
this.field = this.$('input');
|
932 |
+
},
|
933 |
+
|
934 |
+
/**
|
935 |
+
* Initialize the events that constitute a change
|
936 |
+
*/
|
937 |
+
initChangeEvents: function () {
|
938 |
+
var thisView = this;
|
939 |
+
this.field.on( 'change keyup', function () {
|
940 |
+
thisView.trigger('change', $(this).val());
|
941 |
+
} );
|
942 |
+
},
|
943 |
+
|
944 |
+
|
945 |
+
/**
|
946 |
+
* Update the value of an active rule
|
947 |
+
*/
|
948 |
+
updateRule: function () {
|
949 |
+
this.propertiesView.setRuleValue(
|
950 |
+
this.args.property,
|
951 |
+
this.getValue()
|
952 |
+
);
|
953 |
+
},
|
954 |
+
|
955 |
+
/**
|
956 |
+
* This is called when the selector changes
|
957 |
+
*/
|
958 |
+
refreshFromRule: function () {
|
959 |
+
var value = this.propertiesView.getRuleValue(this.args.property);
|
960 |
+
this.setValue(value, {silent: true});
|
961 |
+
},
|
962 |
+
|
963 |
+
/**
|
964 |
+
* Get the current value
|
965 |
+
* @return string
|
966 |
+
*/
|
967 |
+
getValue: function () {
|
968 |
+
return this.field.val();
|
969 |
+
},
|
970 |
+
|
971 |
+
/**
|
972 |
+
* Set the current value
|
973 |
+
* @param socss.view.properties val
|
974 |
+
*/
|
975 |
+
setValue: function (val, options) {
|
976 |
+
options = _.extend({silent: false}, options);
|
977 |
+
|
978 |
+
this.field.val(val);
|
979 |
+
|
980 |
+
if (!options.silent) {
|
981 |
+
this.trigger('set_value', val);
|
982 |
+
}
|
983 |
+
},
|
984 |
+
|
985 |
+
/**
|
986 |
+
* Reset the current value
|
987 |
+
*/
|
988 |
+
reset: function (options) {
|
989 |
+
options = _.extend({silent: false}, options);
|
990 |
+
|
991 |
+
this.setValue('', options);
|
992 |
+
}
|
993 |
+
|
994 |
+
});
|
995 |
+
|
996 |
+
// All the value controllers
|
997 |
+
socss.view.properties.controllers = {};
|
998 |
+
|
999 |
+
// The color controller
|
1000 |
+
socss.view.properties.controllers.color = socss.view.propertyController.extend({
|
1001 |
+
|
1002 |
+
template: _.template('<input type="text" value="" />'),
|
1003 |
+
|
1004 |
+
render: function () {
|
1005 |
+
var thisView = this;
|
1006 |
+
|
1007 |
+
this.$el.append($(this.template({})));
|
1008 |
+
|
1009 |
+
// Set this up as a color picker
|
1010 |
+
this.field = this.$el.find('input');
|
1011 |
+
this.field.minicolors({});
|
1012 |
+
|
1013 |
+
},
|
1014 |
+
|
1015 |
+
initChangeEvents: function () {
|
1016 |
+
var thisView = this;
|
1017 |
+
this.field.on('change keyup', function () {
|
1018 |
+
thisView.trigger('change', thisView.field.minicolors('value'));
|
1019 |
+
});
|
1020 |
+
},
|
1021 |
+
|
1022 |
+
getValue: function () {
|
1023 |
+
return this.field.minicolors('value');
|
1024 |
+
},
|
1025 |
+
|
1026 |
+
setValue: function (val, options) {
|
1027 |
+
options = _.extend({silent: false}, options);
|
1028 |
+
|
1029 |
+
this.field.minicolors('value', val);
|
1030 |
+
|
1031 |
+
if (!options.silent) {
|
1032 |
+
this.trigger('set_value', val);
|
1033 |
+
}
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
});
|
1037 |
+
|
1038 |
+
// The dropdown select box controller
|
1039 |
+
socss.view.properties.controllers.select = socss.view.propertyController.extend( {
|
1040 |
+
template: _.template('<select></select>'),
|
1041 |
+
|
1042 |
+
render: function(){
|
1043 |
+
var thisView = this;
|
1044 |
+
|
1045 |
+
this.$el.append($(this.template({})));
|
1046 |
+
this.field = this.$el.find('select');
|
1047 |
+
|
1048 |
+
// Add the unchanged option
|
1049 |
+
this.field.append( $('<option value=""></option>').html('') );
|
1050 |
+
|
1051 |
+
// Add all the options to the dropdown
|
1052 |
+
for( var k in this.args.options ) {
|
1053 |
+
this.field.append( $('<option></option>').attr('value', k).html( this.args.options[k] ) );
|
1054 |
+
}
|
1055 |
+
|
1056 |
+
if( typeof this.args.option_icons !== 'undefined' ) {
|
1057 |
+
this.setupVisualSelect();
|
1058 |
+
}
|
1059 |
+
},
|
1060 |
+
|
1061 |
+
setupVisualSelect: function(){
|
1062 |
+
var thisView = this;
|
1063 |
+
this.field.hide();
|
1064 |
+
|
1065 |
+
var $tc = $('<div class="select-tabs"></div>').appendTo( this.$el );
|
1066 |
+
|
1067 |
+
// Add the none value
|
1068 |
+
$('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo($tc);
|
1069 |
+
|
1070 |
+
// Now add one for each of the option icons
|
1071 |
+
for ( var k in this.args.option_icons ) {
|
1072 |
+
$('<div class="select-tab"></div>')
|
1073 |
+
.appendTo($tc)
|
1074 |
+
.append(
|
1075 |
+
$('<span class="fa"></span>')
|
1076 |
+
.addClass('fa-' + this.args.option_icons[k])
|
1077 |
+
)
|
1078 |
+
.attr('data-value', k)
|
1079 |
+
;
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
$tc.find('.select-tab')
|
1083 |
+
.css('width', 100/( $tc.find('>div').length ) + "%" )
|
1084 |
+
.click( function(){
|
1085 |
+
var $t = $(this);
|
1086 |
+
$tc.find('.select-tab').removeClass('active');
|
1087 |
+
$t.addClass('active');
|
1088 |
+
thisView.field.val( $t.data('value')).change();
|
1089 |
+
} );
|
1090 |
+
},
|
1091 |
+
|
1092 |
+
/**
|
1093 |
+
* Set the current value
|
1094 |
+
* @param socss.view.properties val
|
1095 |
+
*/
|
1096 |
+
setValue: function (val, options) {
|
1097 |
+
options = _.extend({silent: false}, options);
|
1098 |
+
|
1099 |
+
this.field.val(val);
|
1100 |
+
|
1101 |
+
this.$('.select-tabs .select-tab').removeClass('active').filter('[data-value="' + val + '"]').addClass('active');
|
1102 |
+
|
1103 |
+
if (!options.silent) {
|
1104 |
+
this.trigger('set_value', val);
|
1105 |
+
}
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
} );
|
1109 |
+
|
1110 |
+
// A field that lets a user upload an image
|
1111 |
+
socss.view.properties.controllers.image = socss.view.propertyController.extend( {
|
1112 |
+
template: _.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),
|
1113 |
+
|
1114 |
+
render: function(){
|
1115 |
+
var thisView = this;
|
1116 |
+
|
1117 |
+
this.media = wp.media({
|
1118 |
+
// Set the title of the modal.
|
1119 |
+
title: socssOptions.loc.select_image,
|
1120 |
+
|
1121 |
+
// Tell the modal to show only images.
|
1122 |
+
library: {
|
1123 |
+
type: 'image'
|
1124 |
+
},
|
1125 |
+
|
1126 |
+
// Customize the submit button.
|
1127 |
+
button: {
|
1128 |
+
// Set the text of the button.
|
1129 |
+
text: socssOptions.loc.select,
|
1130 |
+
// Tell the button not to close the modal, since we're
|
1131 |
+
// going to refresh the page when the image is selected.
|
1132 |
+
close: false
|
1133 |
+
}
|
1134 |
+
});
|
1135 |
+
|
1136 |
+
this.$el.append( $(this.template({
|
1137 |
+
select: socssOptions.loc.select
|
1138 |
+
})) );
|
1139 |
+
|
1140 |
+
this.field = this.$el.find('input');
|
1141 |
+
|
1142 |
+
this.$('.select').click(function(){
|
1143 |
+
thisView.media.open();
|
1144 |
+
});
|
1145 |
+
|
1146 |
+
this.media.on('select', function(){
|
1147 |
+
// Grab the selected attachment.
|
1148 |
+
var attachment = this.state().get('selection').first().attributes;
|
1149 |
+
var val = thisView.args.value.replace('{{url}}', attachment.url);
|
1150 |
+
|
1151 |
+
// Change the field value and trigger a change event
|
1152 |
+
thisView.field.val( val ).change();
|
1153 |
+
|
1154 |
+
// Close the image selector
|
1155 |
+
thisView.media.close();
|
1156 |
+
|
1157 |
+
}, this.media);
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
} );
|
1161 |
+
|
1162 |
+
// A simple measurement field
|
1163 |
+
socss.view.properties.controllers.measurement = socss.view.propertyController.extend( {
|
1164 |
+
|
1165 |
+
wrapperClass: 'socss-field-measurement',
|
1166 |
+
|
1167 |
+
render: function(){
|
1168 |
+
this.$el.append($(this.template({})));
|
1169 |
+
this.field = this.$('input');
|
1170 |
+
this.setupMeasurementField( this.field, {} );
|
1171 |
+
},
|
1172 |
+
|
1173 |
+
setValue: function (val, options) {
|
1174 |
+
options = _.extend({silent: false}, options);
|
1175 |
+
this.field.val(val).trigger('measurement_refresh');
|
1176 |
+
if (!options.silent) {
|
1177 |
+
this.trigger('set_value', val);
|
1178 |
+
}
|
1179 |
+
},
|
1180 |
+
|
1181 |
+
units : [
|
1182 |
+
'px',
|
1183 |
+
'%',
|
1184 |
+
'em',
|
1185 |
+
'cm',
|
1186 |
+
'mm',
|
1187 |
+
'in',
|
1188 |
+
'pt',
|
1189 |
+
'pc',
|
1190 |
+
'ex',
|
1191 |
+
'ch',
|
1192 |
+
'rem',
|
1193 |
+
'vw',
|
1194 |
+
'vh',
|
1195 |
+
'vmin',
|
1196 |
+
'vmax'
|
1197 |
+
],
|
1198 |
+
|
1199 |
+
parseUnits: function( value ){
|
1200 |
+
var escapeRegExp = function(str) {
|
1201 |
+
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
1202 |
+
};
|
1203 |
+
|
1204 |
+
var regexUnits = this.units.map(escapeRegExp);
|
1205 |
+
var regex = new RegExp('([0-9\\.\\-]+)(' + regexUnits.join('|') + ')?', 'i');
|
1206 |
+
var result = regex.exec( value );
|
1207 |
+
|
1208 |
+
if( result === null ) {
|
1209 |
+
return {
|
1210 |
+
value: '',
|
1211 |
+
unit: ''
|
1212 |
+
};
|
1213 |
+
}
|
1214 |
+
else {
|
1215 |
+
return {
|
1216 |
+
value: result[1],
|
1217 |
+
unit: result[2] === undefined ? '' : result[2]
|
1218 |
+
};
|
1219 |
+
}
|
1220 |
+
},
|
1221 |
+
|
1222 |
+
setupMeasurementField: function( $el, options ){
|
1223 |
+
var thisView = this;
|
1224 |
+
var $p = $el.parent();
|
1225 |
+
|
1226 |
+
options = _.extend( {
|
1227 |
+
defaultUnit: 'px'
|
1228 |
+
}, options );
|
1229 |
+
|
1230 |
+
$el.hide();
|
1231 |
+
$p.addClass( this.wrapperClass ).data('unit', options.defaultUnit);
|
1232 |
+
|
1233 |
+
// Create the fake input field
|
1234 |
+
var $fi = $('<input type="text" class="socss-field-input"/>').appendTo($p);
|
1235 |
+
var $da = $('<span class="dashicons dashicons-arrow-down"></span>').appendTo($p);
|
1236 |
+
var $dd = $('<ul class="dropdown"></ul>').appendTo($p);
|
1237 |
+
var $u = $('<span class="units"></span>').html( options.defaultUnit ).appendTo( $p );
|
1238 |
+
|
1239 |
+
for( var i = 0; i < thisView.units.length; i++ ) {
|
1240 |
+
var $o = $('<li></li>').html( thisView.units[i] ).data('unit', thisView.units[i]);
|
1241 |
+
if( thisView.units[i] === options.defaultUnit ) {
|
1242 |
+
$o.addClass('active');
|
1243 |
+
}
|
1244 |
+
$dd.append( $o );
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
var updateValue = function(){
|
1248 |
+
var value = thisView.parseUnits( $fi.val() );
|
1249 |
+
|
1250 |
+
if( value.unit !== '' && value.unit !== $p.data( 'unit' ) ) {
|
1251 |
+
$fi.val( value.value );
|
1252 |
+
setUnit( value.unit );
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
if( value.value === '' ) {
|
1256 |
+
$el.val( '' );
|
1257 |
+
}
|
1258 |
+
else {
|
1259 |
+
$el.val( value.value + $p.data( 'unit' ) );
|
1260 |
+
}
|
1261 |
+
};
|
1262 |
+
|
1263 |
+
var setUnit = function( unit ){
|
1264 |
+
$u.html( unit );
|
1265 |
+
$p.data( 'unit', unit );
|
1266 |
+
$fi.trigger('keydown');
|
1267 |
+
};
|
1268 |
+
|
1269 |
+
$da.click( function(){
|
1270 |
+
$dd.toggle();
|
1271 |
+
} );
|
1272 |
+
|
1273 |
+
$dd.find('li').click( function(){
|
1274 |
+
$dd.toggle();
|
1275 |
+
setUnit( $(this).data('unit') );
|
1276 |
+
updateValue();
|
1277 |
+
$el.trigger('change');
|
1278 |
+
} );
|
1279 |
+
|
1280 |
+
$fi.on( 'keyup keydown', function(e){
|
1281 |
+
var $$ = $(this);
|
1282 |
+
|
1283 |
+
var char = '';
|
1284 |
+
if( e.type === 'keydown' ) {
|
1285 |
+
if(e.keyCode >= 48 && e.keyCode <= 57 ) {
|
1286 |
+
char = String.fromCharCode(e.keyCode);
|
1287 |
+
}
|
1288 |
+
else if( e.keyCode === 189 ) {
|
1289 |
+
char = '-';
|
1290 |
+
}
|
1291 |
+
else if( e.keyCode === 190 ) {
|
1292 |
+
char = '.';
|
1293 |
+
}
|
1294 |
+
}
|
1295 |
+
|
1296 |
+
var $pl = $('<span class="socss-hidden-placeholder"></span>')
|
1297 |
+
.css( {
|
1298 |
+
'font-size' : '14px'
|
1299 |
+
} )
|
1300 |
+
.html( $fi.val() + char )
|
1301 |
+
.appendTo( 'body' );
|
1302 |
+
var width = $pl.width();
|
1303 |
+
width = Math.min(width, 63);
|
1304 |
+
$pl.remove();
|
1305 |
+
|
1306 |
+
$u.css('left', width + 12);
|
1307 |
+
} );
|
1308 |
+
|
1309 |
+
$fi.on('keyup', function(e){
|
1310 |
+
updateValue();
|
1311 |
+
$el.trigger('change');
|
1312 |
+
} );
|
1313 |
+
|
1314 |
+
$el.on('measurement_refresh', function(){
|
1315 |
+
var value = thisView.parseUnits( $el.val() );
|
1316 |
+
$fi.val( value.value );
|
1317 |
+
|
1318 |
+
var unit = value.unit === '' ? options.defaultUnit : value.unit;
|
1319 |
+
$p.data( 'unit', unit );
|
1320 |
+
$u.html( unit );
|
1321 |
+
|
1322 |
+
var $pl = $('<span class="socss-hidden-placeholder"></span>')
|
1323 |
+
.css({
|
1324 |
+
'font-size' : '14px'
|
1325 |
+
})
|
1326 |
+
.html( value.value )
|
1327 |
+
.appendTo( 'body' );
|
1328 |
+
var width = $pl.width();
|
1329 |
+
width = Math.min(width, 63);
|
1330 |
+
$pl.remove();
|
1331 |
+
|
1332 |
+
$u.css('left', width + 12);
|
1333 |
+
} );
|
1334 |
+
|
1335 |
+
// Now add the increment/decrement buttons
|
1336 |
+
var $diw = $('<div class="socss-diw"></div>').appendTo($p);
|
1337 |
+
var $dec = $('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo($diw);
|
1338 |
+
var $inc = $('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo($diw);
|
1339 |
+
|
1340 |
+
// Increment is clicked
|
1341 |
+
$inc.click( function(){
|
1342 |
+
var value = thisView.parseUnits( $el.val() );
|
1343 |
+
if( value.value === '' ) {
|
1344 |
+
return true;
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
var newVal = Math.ceil( value.value * 1.05 );
|
1348 |
+
|
1349 |
+
$fi.val( newVal );
|
1350 |
+
updateValue();
|
1351 |
+
$el.trigger('change').trigger('measurement_refresh');
|
1352 |
+
} );
|
1353 |
+
|
1354 |
+
$dec.click( function(){
|
1355 |
+
var value = thisView.parseUnits( $el.val() );
|
1356 |
+
if( value.value === '' ) {
|
1357 |
+
return true;
|
1358 |
+
}
|
1359 |
+
|
1360 |
+
var newVal = Math.floor( value.value / 1.05 );
|
1361 |
+
|
1362 |
+
$fi.val( newVal );
|
1363 |
+
updateValue();
|
1364 |
+
$el.trigger('change').trigger('measurement_refresh');
|
1365 |
+
} );
|
1366 |
+
}
|
1367 |
+
|
1368 |
+
} );
|
1369 |
+
|
1370 |
+
// A simple measurement field
|
1371 |
+
socss.view.properties.controllers.number = socss.view.propertyController.extend( {
|
1372 |
+
|
1373 |
+
render: function(){
|
1374 |
+
this.$el.append($(this.template({})));
|
1375 |
+
this.field = this.$('input');
|
1376 |
+
|
1377 |
+
// Setup the measurement field
|
1378 |
+
this.setupNumberField(this.field, this.args);
|
1379 |
+
},
|
1380 |
+
|
1381 |
+
/**
|
1382 |
+
* Setup the number field
|
1383 |
+
* @param el
|
1384 |
+
* @param options
|
1385 |
+
*/
|
1386 |
+
setupNumberField: function($el, options){
|
1387 |
+
options = _.extend({
|
1388 |
+
change: null,
|
1389 |
+
default: 0,
|
1390 |
+
increment: 1,
|
1391 |
+
decrement: -1,
|
1392 |
+
max: null,
|
1393 |
+
min: null
|
1394 |
+
}, options);
|
1395 |
+
|
1396 |
+
var $p = $el.parent();
|
1397 |
+
$p.addClass('socss-field-number');
|
1398 |
+
|
1399 |
+
// Now add the increment/decrement buttons
|
1400 |
+
var $diw = $('<div class="socss-diw"></div>').appendTo($p);
|
1401 |
+
var $dec = $('<div class="dec-button socss-button">-</div>').appendTo($diw);
|
1402 |
+
var $inc = $('<div class="inc-button socss-button">+</div>').appendTo($diw);
|
1403 |
+
|
1404 |
+
// Increment is clicked
|
1405 |
+
$diw.find('> div').click( function(e){
|
1406 |
+
e.preventDefault();
|
1407 |
+
|
1408 |
+
var val = options.default;
|
1409 |
+
if( $el.val() !== '' ) {
|
1410 |
+
val = Number($el.val());
|
1411 |
+
}
|
1412 |
+
val = val + ( $(this).is( $dec ) ? options.decrement : options.increment );
|
1413 |
+
|
1414 |
+
val = Math.round(val*100)/100;
|
1415 |
+
|
1416 |
+
if( options.max !== null ) {
|
1417 |
+
val = Math.min( options.max, val);
|
1418 |
+
}
|
1419 |
+
|
1420 |
+
if( options.min !== null ) {
|
1421 |
+
val = Math.max( options.min, val);
|
1422 |
+
}
|
1423 |
+
|
1424 |
+
$el.val( val );
|
1425 |
+
$el.trigger('change');
|
1426 |
+
} );
|
1427 |
+
|
1428 |
+
return this;
|
1429 |
+
}
|
1430 |
+
|
1431 |
+
} );
|
1432 |
+
|
1433 |
+
|
1434 |
+
socss.view.properties.controllers.sides = socss.view.propertyController.extend( {
|
1435 |
+
|
1436 |
+
template: _.template( $('#template-sides-field').html().trim() ),
|
1437 |
+
|
1438 |
+
controllers: [],
|
1439 |
+
|
1440 |
+
render: function(){
|
1441 |
+
var thisView = this;
|
1442 |
+
|
1443 |
+
this.$el.append( $(this.template({})) );
|
1444 |
+
this.field = this.$el.find('input');
|
1445 |
+
|
1446 |
+
if( !thisView.args.hasAll ) {
|
1447 |
+
this.$('.select-tab').eq(0).remove();
|
1448 |
+
this.$('.select-tab').css('width', '25%');
|
1449 |
+
}
|
1450 |
+
|
1451 |
+
this.$('.select-tab').each( function(){
|
1452 |
+
var dir = $(this).data('direction');
|
1453 |
+
|
1454 |
+
var container = $('<li class="side">')
|
1455 |
+
.appendTo( thisView.$('.sides') )
|
1456 |
+
.hide();
|
1457 |
+
|
1458 |
+
for( var i = 0; i < thisView.args.controllers.length; i++ ) {
|
1459 |
+
|
1460 |
+
var controllerArgs = thisView.args.controllers[i];
|
1461 |
+
|
1462 |
+
if( typeof socss.view.properties.controllers[ controllerArgs.type ] ) {
|
1463 |
+
|
1464 |
+
// Create the measurement view
|
1465 |
+
var property = '';
|
1466 |
+
if( dir === 'all' ) {
|
1467 |
+
property = controllerArgs.args.propertyAll;
|
1468 |
+
}
|
1469 |
+
else {
|
1470 |
+
property = controllerArgs.args.property.replace('{dir}', dir);
|
1471 |
+
}
|
1472 |
+
|
1473 |
+
var theseControllerArgs = _.extend({}, controllerArgs.args, {property: property});
|
1474 |
+
|
1475 |
+
var controller = new socss.view.properties.controllers[ controllerArgs.type ]( {
|
1476 |
+
el: $('<div>').appendTo( container ),
|
1477 |
+
propertiesView: thisView.propertiesView,
|
1478 |
+
args: theseControllerArgs
|
1479 |
+
} );
|
1480 |
+
|
1481 |
+
// Setup and render the measurement controller and register it with the properties view
|
1482 |
+
controller.render();
|
1483 |
+
controller.initChangeEvents();
|
1484 |
+
thisView.propertiesView.propertyControllers.push(controller);
|
1485 |
+
|
1486 |
+
}
|
1487 |
+
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
$(this).on( 'click', function(){
|
1491 |
+
thisView.$('.select-tab').removeClass('active');
|
1492 |
+
$(this).addClass('active');
|
1493 |
+
|
1494 |
+
thisView.$('.sides .side').hide();
|
1495 |
+
container.show();
|
1496 |
+
} );
|
1497 |
+
|
1498 |
+
} );
|
1499 |
+
|
1500 |
+
// Select the first tab by default
|
1501 |
+
this.$('.select-tab').eq(0).click();
|
1502 |
+
}
|
1503 |
+
|
1504 |
+
} );
|
1505 |
+
|
1506 |
+
})(jQuery, _, socssOptions);
|
1507 |
+
|
1508 |
+
// Setup the main editor
|
1509 |
+
jQuery(function ($) {
|
1510 |
+
var socss = window.socss;
|
1511 |
+
|
1512 |
+
// Setup the editor
|
1513 |
+
var editor = new socss.view.editor({
|
1514 |
+
el: $('#so-custom-css-form').get(0)
|
1515 |
+
});
|
1516 |
+
editor.render();
|
1517 |
+
editor.setSnippets(socssOptions.snippets);
|
1518 |
+
|
1519 |
+
window.socss.mainEditor = editor;
|
1520 |
+
|
1521 |
+
// This is for hiding the getting started video
|
1522 |
+
$('#so-custom-css-getting-started a.hide').click( function(e){
|
1523 |
+
e.preventDefault();
|
1524 |
+
$('#so-custom-css-getting-started').slideUp();
|
1525 |
+
$.get( $(this).attr('href') );
|
1526 |
+
} );
|
1527 |
+
});
|
js/editor.min.js
ADDED
@@ -0,0 +1,63 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function($,_,socssOptions){var socss={model:{},collection:{},view:{},fn:{}};window.socss=socss;socss.view.toolbar=Backbone.View.extend({button:_.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(attr){this.editor=attr.editor;var thisView=this;this.$('.editor-expand').click(function(e){e.preventDefault();$(this).blur();thisView.trigger('click_expand');});this.$('.editor-visual').click(function(e){e.preventDefault();$(this).blur();thisView.trigger('click_visual');});},addButton:function(text,action){var thisView=this;var button=$(this.button({text:text})).appendTo(this.$('.toolbar-function-buttons .toolbar-buttons')).click(function(e){e.preventDefault();$(this).blur();thisView.trigger('click_'+action);});return button;}});socss.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(args){this.setupEditor();},render:function(){var thisView=this;this.toolbar=new socss.view.toolbar({editor:this,el:this.$('.custom-css-toolbar')});this.toolbar.editor=this;this.toolbar.render();this.visualProperties=new socss.view.properties({editor:this,el:$('#so-custom-css-properties')});this.visualProperties.render();this.toolbar.on('click_expand',function(){thisView.toggleExpand();});this.toolbar.on('click_visual',function(){thisView.visualProperties.loadCSS(thisView.codeMirror.getValue());thisView.visualProperties.show();});this.preview=new socss.view.preview({editor:this,el:this.$('.custom-css-preview')});this.preview.render();},setupEditor:function(){var thisView=this;this.registerCodeMirrorAutocomplete();this.codeMirror=CodeMirror.fromTextArea(this.$('textarea.css-editor').get(0),{tabSize:2,mode:'css',theme:'neat',gutters:["CodeMirror-lint-markers"],lint:true});var startCss=this.$('textarea.css-editor').val();this.$el.on('submit',function(){startCss=thisView.codeMirror.getValue();});$(window).bind('beforeunload',function(){if(thisView.codeMirror.getValue()!==startCss){return socssOptions.loc.leave;}});this.$el.find('.custom-css-container').css('overflow','visible');this.scaleEditor();$(window).resize(function(){thisView.scaleEditor();});this.setupCodeMirrorExtensions();},registerCodeMirrorAutocomplete:function(){var thisView=this;var pseudoClasses={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(cm){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(inner.mode.name!=="css"){return;}
|
3 |
+
if(token.type==="keyword"&&"!important".indexOf(token.string)===0){return{list:["!important"],from:CodeMirror.Pos(cur.line,token.start),to:CodeMirror.Pos(cur.line,token.end)};}
|
4 |
+
var start=token.start,end=cur.ch,word=token.string.slice(0,end-start);if(/[^\w$_-]/.test(word)){word="";start=end=cur.ch;}
|
5 |
+
var spec=CodeMirror.resolveMode("text/css");var result=[];function add(keywords){for(var name in keywords){if(!word||name.lastIndexOf(word,0)===0){result.push(name);}}}
|
6 |
+
var st=inner.state.state;if(st==='top'){var line=cm.getLine(cur.line).trim();var selectors=thisView.cssSelectors;for(var i=0;i<selectors.length;i++){if(selectors[i].selector.indexOf(line)!==-1){result.push(selectors[i].selector);}}
|
7 |
+
if(result.length){return{list:result,from:CodeMirror.Pos(cur.line,0),to:CodeMirror.Pos(cur.line,end)};}}
|
8 |
+
else{if(st==="pseudo"||token.type==="variable-3"){add(pseudoClasses);}
|
9 |
+
else if(st==="block"||st==="maybeprop"){add(spec.propertyKeywords);}
|
10 |
+
else if(st==="prop"||st==="parens"||st==="at"||st==="params"){add(spec.valueKeywords);add(spec.colorKeywords);}
|
11 |
+
else if(st==="media"||st==="media_parens"){add(spec.mediaTypes);add(spec.mediaFeatures);}
|
12 |
+
if(result.length){return{list:result,from:CodeMirror.Pos(cur.line,start),to:CodeMirror.Pos(cur.line,end)};}}});},setupCodeMirrorExtensions:function(){var thisView=this;this.codeMirror.on('cursorActivity',function(cm){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(token.type==='qualifier'||token.type==='tag'||token.type==='builtin'){var line=cm.getLine(cur.line);var selector=line.substring(0,token.end);thisView.preview.highlight(selector);}
|
13 |
+
else{thisView.preview.clearHighlight();}});this.codeMirror.on('keyup',function(cm,e){if((e.keyCode>=65&&e.keyCode<=90)||(e.keyCode===189&&!e.shiftKey)||(e.keyCode===190&&!e.shiftKey)||(e.keyCode===51&&e.shiftKey)||(e.keyCode===189&&e.shiftKey)){cm.showHint(e);}});},scaleEditor:function(){if(this.$el.hasClass('expanded')){this.codeMirror.setSize('100%',$(window).outerHeight()-this.$('.custom-css-toolbar').outerHeight());}
|
14 |
+
else{this.codeMirror.setSize('100%','auto');}},isExpanded:function(){return this.$el.hasClass('expanded');},toggleExpand:function(){this.$el.toggleClass('expanded');this.scaleEditor();},setExpand:function(expanded){if(expanded){this.$el.addClass('expanded');}
|
15 |
+
else{this.$el.removeClass('expanded');}
|
16 |
+
this.scaleEditor();},setSnippets:function(snippets){if(!_.isEmpty(snippets)){var thisView=this;this.snippets=new socss.view.snippets({snippets:snippets});this.snippets.editor=this;this.snippets.render();this.toolbar.addButton('Snippets','snippets');this.toolbar.on('click_snippets',function(){thisView.snippets.show();});}},addCode:function(css){var editor=this.codeMirror;var before_css='';if(editor.doc.lineCount()===1&&editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="";}
|
17 |
+
else if(editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="\n";}
|
18 |
+
else{before_css="\n\n";}
|
19 |
+
editor.doc.setCursor(editor.doc.lastLine(),editor.doc.getLine(editor.doc.lastLine()).length);editor.doc.replaceSelection(before_css+css);},addEmptySelector:function(selector){this.addCode(selector+" {\n \n}");},setInspector:function(inspector){var thisView=this;this.inspector=inspector;this.cssSelectors=inspector.pageSelectors;inspector.on('click_selector',function(selector){if(thisView.visualProperties.isVisible()){thisView.visualProperties.addSelector(selector);}
|
20 |
+
else{thisView.addEmptySelector(selector);}});inspector.on('click_property',function(property){if(!thisView.visualProperties.isVisible()){thisView.codeMirror.replaceSelection(property+";\n ");}});inspector.on('set_active_element',function(el,selectors){if(thisView.visualProperties.isVisible()&&selectors.length){thisView.visualProperties.addSelector(selectors[0].selector);}});}});socss.view.preview=Backbone.View.extend({template:_.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),editor:null,initialize:function(attr){this.editor=attr.editor;var thisView=this;this.editor.codeMirror.on('change',function(cm,c){thisView.updatePreviewCss();});},render:function(){var thisView=this;this.$el.html(this.template());this.$('.preview-iframe').attr('src',socssOptions.homeURL).load(function(){var $$=$(this);$$.contents().find('a').each(function(){var href=$(this).attr('href');if(href===undefined){return true;}
|
21 |
+
var firstSeperator=(href.indexOf('?')===-1?'?':'&');$(this).attr('href',href+firstSeperator+'so_css_preview=1');});thisView.updatePreviewCss();}).mouseleave(function(){thisView.clearHighlight();});},updatePreviewCss:function(){var preview=this.$('.preview-iframe');if(preview.length===0){return;}
|
22 |
+
var head=preview.contents().find('head');if(head.find('style.siteorigin-custom-css').length===0){head.append('<style class="siteorigin-custom-css" type="text/css"></style>');}
|
23 |
+
var style=head.find('style.siteorigin-custom-css');var css=this.editor.codeMirror.getValue();style.html(css);},highlight:function(selector){try{this.editor.inspector.hl.highlight(selector);}
|
24 |
+
catch(err){console.log('No inspector to highlight with');}},clearHighlight:function(){try{this.editor.inspector.hl.clear();}
|
25 |
+
catch(err){console.log('No inspector to highlight with');}}});socss.view.snippets=Backbone.View.extend({template:_.template($('#template-snippet-browser').html()),snippet:_.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(args){this.snippets=args.snippets;},render:function(){var thisView=this;var clickSnippet=function(e){e.preventDefault();var $$=$(this);thisView.$('.snippets li.snippet').removeClass('active');$(this).addClass('active');thisView.viewSnippet({name:$$.html(),description:$$.data('description'),css:$$.data('css')});};this.$el.html(this.template());for(var i=0;i<this.snippets.length;i++){$(this.snippet({name:this.snippets[i].Name})).data({'description':this.snippets[i].Description,'css':this.snippets[i].css}).appendTo(this.$('ul.snippets')).click(clickSnippet);}
|
26 |
+
thisView.$('.snippets li.snippet').eq(0).click();this.attach();return this;},viewSnippet:function(args){var w=this.$('.main .snippet-view');w.find('.snippet-title').html(args.name);w.find('.snippet-description').html(args.description);w.find('.snippet-code').html(args.css);this.currentSnippet=args;},insertSnippet:function(){var editor=this.editor.codeMirror;var css=this.currentSnippet.css;var before_css='';if(editor.doc.lineCount()===1&&editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="";}
|
27 |
+
else if(editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="\n";}
|
28 |
+
else{before_css="\n\n";}
|
29 |
+
editor.doc.setCursor(editor.doc.lastLine(),editor.doc.getLine(editor.doc.lastLine()).length);editor.doc.replaceSelection(before_css+css);this.hide();},attach:function(){this.$el.appendTo('body');},show:function(){this.$el.show();},hide:function(){this.$el.hide();}});socss.view.properties=Backbone.View.extend({model:socss.model.cssRules,tabTemplate:_.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:_.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:_.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:'',parsed:{},activeSelector:'',editorExpandedBefore:false,events:{'click .close':'hide'},initialize:function(attr){this.parser=new cssjs();this.editor=attr.editor;},render:function(){var thisView=this;var controllers=socssOptions.propertyControllers;for(var id in controllers){var $t=$(this.tabTemplate({id:id,icon:controllers[id].icon,title:controllers[id].title})).appendTo(this.$('.section-tabs'));var $s=$(this.sectionTemplate({id:id})).appendTo(this.$('.sections'));if(!_.isEmpty(controllers[id].controllers)){for(var i=0;i<controllers[id].controllers.length;i++){var $c=$(thisView.controllerTemplate({title:controllers[id].controllers[i].title})).appendTo($s.find('tbody'));var controllerAtts=controllers[id].controllers[i];var controller;if(typeof socss.view.properties.controllers[controllerAtts.type]==='undefined'){controller=new socss.view.propertyController({el:$c.find('td'),propertiesView:thisView,args:(typeof controllerAtts.args==='undefined'?{}:controllerAtts.args)});}
|
30 |
+
else{controller=new socss.view.properties.controllers[controllerAtts.type]({el:$c.find('td'),propertiesView:thisView,args:(typeof controllerAtts.args==='undefined'?{}:controllerAtts.args)});}
|
31 |
+
thisView.propertyControllers.push(controller);controller.render();controller.initChangeEvents();}}}
|
32 |
+
this.$('.section-tabs li').click(function(){var $$=$(this);var show=thisView.$('.sections .section[data-section="'+$$.data('section')+'"]');thisView.$('.sections .section').not(show).hide().removeClass('active');show.show().addClass('active');thisView.$('.section-tabs li').not($$).removeClass('active');$$.addClass('active');}).eq(0).click();this.$('.toolbar select').change(function(){thisView.setActivateSelector($(this).find(':selected').data('selector'));});},setRuleValue:function(rule,value){if(typeof this.activeSelector==='undefined'||typeof this.activeSelector.rules==='undefined'){return;}
|
33 |
+
var newRule=true;for(var i=0;i<this.activeSelector.rules.length;i++){if(this.activeSelector.rules[i].directive===rule){this.activeSelector.rules[i].value=value;newRule=false;break;}}
|
34 |
+
if(newRule){this.activeSelector.rules.push({directive:rule,value:value});}
|
35 |
+
this.updateMainEditor(false);},getRuleValue:function(rule){if(typeof this.activeSelector==='undefined'||typeof this.activeSelector.rules==='undefined'){return'';}
|
36 |
+
for(var i=0;i<this.activeSelector.rules.length;i++){if(this.activeSelector.rules[i].directive===rule){return this.activeSelector.rules[i].value;}}
|
37 |
+
return'';},updateMainEditor:function(compress){var css;if(typeof compress==='undefined'||compress===true){css=this.parser.compressCSS(this.parsed);css=css.filter(function(v){return(typeof v.type!=='undefined'||v.rules.length>0);});}
|
38 |
+
else{css=this.parsed;}
|
39 |
+
this.editor.codeMirror.setValue(this.parser.getCSSForEditor(css).trim());},show:function(){this.editorExpandedBefore=this.editor.isExpanded();this.editor.setExpand(true);this.$el.show().animate({'left':0},'fast');},hide:function(){this.editor.setExpand(this.editorExpandedBefore);this.$el.animate({'left':-338},'fast',function(){$(this).hide();});this.updateMainEditor(true);},isVisible:function(){return this.$el.is(':visible');},loadCSS:function(css,activeSelector){this.css=css;this.parsed=this.parser.compressCSS(this.parser.parseCSS(css));var dropdown=this.$('.toolbar select').empty();for(var i=0;i<this.parsed.length;i++){var rule=this.parsed[i];if(typeof rule.subStyles!=='undefined'){for(var j=0;j<rule.subStyles.length;j++){var subRule=rule.subStyles[j];dropdown.append($('<option>').html(rule.selector+': '+subRule.selector).attr('val',rule.selector+': '+subRule.selector).data('selector',subRule));}}
|
40 |
+
else{dropdown.append($('<option>').html(rule.selector).attr('val',rule.selector).data('selector',rule));}}
|
41 |
+
if(typeof activeSelector==='undefined'){activeSelector=dropdown.find('option').eq(0).attr('val');}
|
42 |
+
dropdown.val(activeSelector).change();},setActivateSelector:function(selector){this.activeSelector=selector;for(var i=0;i<this.propertyControllers.length;i++){this.propertyControllers[i].refreshFromRule();}},addSelector:function(selector){var dropdown=this.$('.toolbar select');dropdown.val(selector);if(dropdown.val()===selector){dropdown.change();}
|
43 |
+
else{this.editor.addEmptySelector(selector);this.loadCSS(this.editor.codeMirror.getValue(),selector);}
|
44 |
+
dropdown.addClass('highlighted');setTimeout(function(){dropdown.removeClass('highlighted');},2000);}});socss.view.propertyController=Backbone.View.extend({template:_.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(args){this.args=args.args;this.propertiesView=args.propertiesView;this.on('set_value',this.updateRule,this);this.on('change',this.updateRule,this);},render:function(){this.$el.append($(this.template({})));this.field=this.$('input');},initChangeEvents:function(){var thisView=this;this.field.on('change keyup',function(){thisView.trigger('change',$(this).val());});},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue());},refreshFromRule:function(){var value=this.propertiesView.getRuleValue(this.args.property);this.setValue(value,{silent:true});},getValue:function(){return this.field.val();},setValue:function(val,options){options=_.extend({silent:false},options);this.field.val(val);if(!options.silent){this.trigger('set_value',val);}},reset:function(options){options=_.extend({silent:false},options);this.setValue('',options);}});socss.view.properties.controllers={};socss.view.properties.controllers.color=socss.view.propertyController.extend({template:_.template('<input type="text" value="" />'),render:function(){var thisView=this;this.$el.append($(this.template({})));this.field=this.$el.find('input');this.field.minicolors({});},initChangeEvents:function(){var thisView=this;this.field.on('change keyup',function(){thisView.trigger('change',thisView.field.minicolors('value'));});},getValue:function(){return this.field.minicolors('value');},setValue:function(val,options){options=_.extend({silent:false},options);this.field.minicolors('value',val);if(!options.silent){this.trigger('set_value',val);}}});socss.view.properties.controllers.select=socss.view.propertyController.extend({template:_.template('<select></select>'),render:function(){var thisView=this;this.$el.append($(this.template({})));this.field=this.$el.find('select');this.field.append($('<option value=""></option>').html(''));for(var k in this.args.options){this.field.append($('<option></option>').attr('value',k).html(this.args.options[k]));}
|
45 |
+
if(typeof this.args.option_icons!=='undefined'){this.setupVisualSelect();}},setupVisualSelect:function(){var thisView=this;this.field.hide();var $tc=$('<div class="select-tabs"></div>').appendTo(this.$el);$('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo($tc);for(var k in this.args.option_icons){$('<div class="select-tab"></div>').appendTo($tc).append($('<span class="fa"></span>').addClass('fa-'+this.args.option_icons[k])).attr('data-value',k);}
|
46 |
+
$tc.find('.select-tab').css('width',100/($tc.find('>div').length)+"%").click(function(){var $t=$(this);$tc.find('.select-tab').removeClass('active');$t.addClass('active');thisView.field.val($t.data('value')).change();});},setValue:function(val,options){options=_.extend({silent:false},options);this.field.val(val);this.$('.select-tabs .select-tab').removeClass('active').filter('[data-value="'+val+'"]').addClass('active');if(!options.silent){this.trigger('set_value',val);}}});socss.view.properties.controllers.image=socss.view.propertyController.extend({template:_.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var thisView=this;this.media=wp.media({title:socssOptions.loc.select_image,library:{type:'image'},button:{text:socssOptions.loc.select,close:false}});this.$el.append($(this.template({select:socssOptions.loc.select})));this.field=this.$el.find('input');this.$('.select').click(function(){thisView.media.open();});this.media.on('select',function(){var attachment=this.state().get('selection').first().attributes;var val=thisView.args.value.replace('{{url}}',attachment.url);thisView.field.val(val).change();thisView.media.close();},this.media);}});socss.view.properties.controllers.measurement=socss.view.propertyController.extend({wrapperClass:'socss-field-measurement',render:function(){this.$el.append($(this.template({})));this.field=this.$('input');this.setupMeasurementField(this.field,{});},setValue:function(val,options){options=_.extend({silent:false},options);this.field.val(val).trigger('measurement_refresh');if(!options.silent){this.trigger('set_value',val);}},units:['px','%','em','cm','mm','in','pt','pc','ex','ch','rem','vw','vh','vmin','vmax'],parseUnits:function(value){var escapeRegExp=function(str){return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");};var regexUnits=this.units.map(escapeRegExp);var regex=new RegExp('([0-9\\.\\-]+)('+regexUnits.join('|')+')?','i');var result=regex.exec(value);if(result===null){return{value:'',unit:''};}
|
47 |
+
else{return{value:result[1],unit:result[2]===undefined?'':result[2]};}},setupMeasurementField:function($el,options){var thisView=this;var $p=$el.parent();options=_.extend({defaultUnit:'px'},options);$el.hide();$p.addClass(this.wrapperClass).data('unit',options.defaultUnit);var $fi=$('<input type="text" class="socss-field-input"/>').appendTo($p);var $da=$('<span class="dashicons dashicons-arrow-down"></span>').appendTo($p);var $dd=$('<ul class="dropdown"></ul>').appendTo($p);var $u=$('<span class="units"></span>').html(options.defaultUnit).appendTo($p);for(var i=0;i<thisView.units.length;i++){var $o=$('<li></li>').html(thisView.units[i]).data('unit',thisView.units[i]);if(thisView.units[i]===options.defaultUnit){$o.addClass('active');}
|
48 |
+
$dd.append($o);}
|
49 |
+
var updateValue=function(){var value=thisView.parseUnits($fi.val());if(value.unit!==''&&value.unit!==$p.data('unit')){$fi.val(value.value);setUnit(value.unit);}
|
50 |
+
if(value.value===''){$el.val('');}
|
51 |
+
else{$el.val(value.value+$p.data('unit'));}};var setUnit=function(unit){$u.html(unit);$p.data('unit',unit);$fi.trigger('keydown');};$da.click(function(){$dd.toggle();});$dd.find('li').click(function(){$dd.toggle();setUnit($(this).data('unit'));updateValue();$el.trigger('change');});$fi.on('keyup keydown',function(e){var $$=$(this);var char='';if(e.type==='keydown'){if(e.keyCode>=48&&e.keyCode<=57){char=String.fromCharCode(e.keyCode);}
|
52 |
+
else if(e.keyCode===189){char='-';}
|
53 |
+
else if(e.keyCode===190){char='.';}}
|
54 |
+
var $pl=$('<span class="socss-hidden-placeholder"></span>').css({'font-size':'14px'}).html($fi.val()+char).appendTo('body');var width=$pl.width();width=Math.min(width,63);$pl.remove();$u.css('left',width+12);});$fi.on('keyup',function(e){updateValue();$el.trigger('change');});$el.on('measurement_refresh',function(){var value=thisView.parseUnits($el.val());$fi.val(value.value);var unit=value.unit===''?options.defaultUnit:value.unit;$p.data('unit',unit);$u.html(unit);var $pl=$('<span class="socss-hidden-placeholder"></span>').css({'font-size':'14px'}).html(value.value).appendTo('body');var width=$pl.width();width=Math.min(width,63);$pl.remove();$u.css('left',width+12);});var $diw=$('<div class="socss-diw"></div>').appendTo($p);var $dec=$('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo($diw);var $inc=$('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo($diw);$inc.click(function(){var value=thisView.parseUnits($el.val());if(value.value===''){return true;}
|
55 |
+
var newVal=Math.ceil(value.value*1.05);$fi.val(newVal);updateValue();$el.trigger('change').trigger('measurement_refresh');});$dec.click(function(){var value=thisView.parseUnits($el.val());if(value.value===''){return true;}
|
56 |
+
var newVal=Math.floor(value.value/1.05);$fi.val(newVal);updateValue();$el.trigger('change').trigger('measurement_refresh');});}});socss.view.properties.controllers.number=socss.view.propertyController.extend({render:function(){this.$el.append($(this.template({})));this.field=this.$('input');this.setupNumberField(this.field,this.args);},setupNumberField:function($el,options){options=_.extend({change:null,default:0,increment:1,decrement:-1,max:null,min:null},options);var $p=$el.parent();$p.addClass('socss-field-number');var $diw=$('<div class="socss-diw"></div>').appendTo($p);var $dec=$('<div class="dec-button socss-button">-</div>').appendTo($diw);var $inc=$('<div class="inc-button socss-button">+</div>').appendTo($diw);$diw.find('> div').click(function(e){e.preventDefault();var val=options.default;if($el.val()!==''){val=Number($el.val());}
|
57 |
+
val=val+($(this).is($dec)?options.decrement:options.increment);val=Math.round(val*100)/100;if(options.max!==null){val=Math.min(options.max,val);}
|
58 |
+
if(options.min!==null){val=Math.max(options.min,val);}
|
59 |
+
$el.val(val);$el.trigger('change');});return this;}});socss.view.properties.controllers.sides=socss.view.propertyController.extend({template:_.template($('#template-sides-field').html().trim()),controllers:[],render:function(){var thisView=this;this.$el.append($(this.template({})));this.field=this.$el.find('input');if(!thisView.args.hasAll){this.$('.select-tab').eq(0).remove();this.$('.select-tab').css('width','25%');}
|
60 |
+
this.$('.select-tab').each(function(){var dir=$(this).data('direction');var container=$('<li class="side">').appendTo(thisView.$('.sides')).hide();for(var i=0;i<thisView.args.controllers.length;i++){var controllerArgs=thisView.args.controllers[i];if(typeof socss.view.properties.controllers[controllerArgs.type]){var property='';if(dir==='all'){property=controllerArgs.args.propertyAll;}
|
61 |
+
else{property=controllerArgs.args.property.replace('{dir}',dir);}
|
62 |
+
var theseControllerArgs=_.extend({},controllerArgs.args,{property:property});var controller=new socss.view.properties.controllers[controllerArgs.type]({el:$('<div>').appendTo(container),propertiesView:thisView.propertiesView,args:theseControllerArgs});controller.render();controller.initChangeEvents();thisView.propertiesView.propertyControllers.push(controller);}}
|
63 |
+
$(this).on('click',function(){thisView.$('.select-tab').removeClass('active');$(this).addClass('active');thisView.$('.sides .side').hide();container.show();});});this.$('.select-tab').eq(0).click();}});})(jQuery,_,socssOptions);jQuery(function($){var socss=window.socss;var editor=new socss.view.editor({el:$('#so-custom-css-form').get(0)});editor.render();editor.setSnippets(socssOptions.snippets);window.socss.mainEditor=editor;$('#so-custom-css-getting-started a.hide').click(function(e){e.preventDefault();$('#so-custom-css-getting-started').slideUp();$.get($(this).attr('href'));});});
|
js/inspector.js
ADDED
@@ -0,0 +1,432 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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
6 |
+
var socss = {
|
7 |
+
model : { },
|
8 |
+
collection : { },
|
9 |
+
view : { },
|
10 |
+
fn : {}
|
11 |
+
};
|
12 |
+
|
13 |
+
/**
|
14 |
+
* This is the main view for the app
|
15 |
+
*/
|
16 |
+
socss.view.inspector = Backbone.View.extend( {
|
17 |
+
|
18 |
+
active: false,
|
19 |
+
hl: false,
|
20 |
+
hoverEl: false,
|
21 |
+
pageSelectors: [],
|
22 |
+
|
23 |
+
selectorTemplate: _.template('<div class="socss-selector"><%= selector %></div>'),
|
24 |
+
|
25 |
+
initialize: function(){
|
26 |
+
var thisView = this;
|
27 |
+
|
28 |
+
this.hl = new socss.view.highlighter();
|
29 |
+
this.hl.initialize();
|
30 |
+
|
31 |
+
this.pageSelectors = socss.fn.pageSelectors();
|
32 |
+
|
33 |
+
// Setup hovering
|
34 |
+
$('body').on('mouseover', '*', function(e){
|
35 |
+
if( !thisView.active ) {
|
36 |
+
return true;
|
37 |
+
}
|
38 |
+
|
39 |
+
var $$ = $(this);
|
40 |
+
if( $$.closest('.socss-element').length === 0 ) {
|
41 |
+
e.stopPropagation();
|
42 |
+
thisView.setHoverEl( $(this) );
|
43 |
+
}
|
44 |
+
});
|
45 |
+
|
46 |
+
// Setup the click event
|
47 |
+
$('body *').click(function( e ){
|
48 |
+
if( !thisView.active || thisView.$el.is(':hover') ) {
|
49 |
+
return true;
|
50 |
+
}
|
51 |
+
|
52 |
+
e.preventDefault();
|
53 |
+
e.stopPropagation();
|
54 |
+
|
55 |
+
var $$ = $(this);
|
56 |
+
$$.blur();
|
57 |
+
thisView.setActiveEl( thisView.hoverEl );
|
58 |
+
});
|
59 |
+
|
60 |
+
this.$('.socss-enable-inspector').click( function(){
|
61 |
+
thisView.toggleActive();
|
62 |
+
} );
|
63 |
+
|
64 |
+
this.$el.mouseenter( function(){
|
65 |
+
thisView.hl.clear();
|
66 |
+
} );
|
67 |
+
|
68 |
+
// Try register this inspector with the parent editor
|
69 |
+
try {
|
70 |
+
parent.socss.mainEditor.setInspector( this );
|
71 |
+
}
|
72 |
+
catch( err ){
|
73 |
+
console.log( 'No editor to register this inspector with' );
|
74 |
+
}
|
75 |
+
|
76 |
+
},
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Set the element that's currently being hovered
|
80 |
+
*
|
81 |
+
* @param hoverEl
|
82 |
+
*/
|
83 |
+
setHoverEl: function( hoverEl ){
|
84 |
+
this.hoverEl = hoverEl;
|
85 |
+
this.hl.highlight( hoverEl );
|
86 |
+
},
|
87 |
+
|
88 |
+
activate: function(){
|
89 |
+
this.active = true;
|
90 |
+
$('body').addClass('socss-active');
|
91 |
+
$('body').removeClass('socss-inactive');
|
92 |
+
},
|
93 |
+
|
94 |
+
deactivate: function(){
|
95 |
+
this.active = false;
|
96 |
+
$('body').addClass('socss-inactive');
|
97 |
+
$('body').removeClass('socss-active');
|
98 |
+
this.hl.clear();
|
99 |
+
this.$('.socss-hierarchy').empty();
|
100 |
+
},
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Toggle the active status
|
104 |
+
*/
|
105 |
+
toggleActive: function(){
|
106 |
+
if( this.active ) {
|
107 |
+
this.deactivate();
|
108 |
+
}
|
109 |
+
else {
|
110 |
+
this.activate();
|
111 |
+
}
|
112 |
+
},
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Set the element that we're busy inspecting
|
116 |
+
* @param el
|
117 |
+
*/
|
118 |
+
setActiveEl: function( el ) {
|
119 |
+
var thisView = this;
|
120 |
+
|
121 |
+
var $h = this.$('.socss-hierarchy');
|
122 |
+
$h.empty();
|
123 |
+
|
124 |
+
if (el.prop('tagName').toLowerCase() !== 'body') {
|
125 |
+
var cel = $(el);
|
126 |
+
do {
|
127 |
+
$(this.selectorTemplate({selector: socss.fn.elSelector(cel)}))
|
128 |
+
.prependTo($h)
|
129 |
+
.data('el', cel);
|
130 |
+
cel = cel.parent();
|
131 |
+
} while (cel.prop('tagName').toLowerCase() !== 'body');
|
132 |
+
|
133 |
+
$(this.selectorTemplate({selector: 'body'}))
|
134 |
+
.prependTo($h)
|
135 |
+
.data('el', $('body'));
|
136 |
+
|
137 |
+
this.$('.socss-hierarchy .socss-selector')
|
138 |
+
.hover(function () {
|
139 |
+
thisView.hl.highlight($(this).data('el'));
|
140 |
+
})
|
141 |
+
.click(function (e) {
|
142 |
+
e.preventDefault();
|
143 |
+
e.stopPropagation();
|
144 |
+
thisView.setActiveEl($(this).data('el'));
|
145 |
+
});
|
146 |
+
}
|
147 |
+
|
148 |
+
// Scroll all the way left...
|
149 |
+
$h.scrollLeft( 99999 );
|
150 |
+
|
151 |
+
// Now lets add all the CSS selectors
|
152 |
+
var selectors = this.pageSelectors.filter( function(a){
|
153 |
+
// Use try to catch any malformed selectors
|
154 |
+
try {
|
155 |
+
return el.is( a.selector );
|
156 |
+
}
|
157 |
+
catch(err) {
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
} );
|
161 |
+
|
162 |
+
var container = this.$('.socss-selectors-window').empty();
|
163 |
+
|
164 |
+
_.each( selectors, function(selector){
|
165 |
+
container.append(
|
166 |
+
$( thisView.selectorTemplate(selector) )
|
167 |
+
.data( selector )
|
168 |
+
);
|
169 |
+
} );
|
170 |
+
container.find('> div')
|
171 |
+
.mouseenter( function(){
|
172 |
+
thisView.hl.highlight( $(this).data('selector') );
|
173 |
+
} )
|
174 |
+
.click( function(e){
|
175 |
+
e.preventDefault();
|
176 |
+
e.stopPropagation();
|
177 |
+
|
178 |
+
thisView.trigger( 'click_selector', $(this).data('selector') );
|
179 |
+
} );
|
180 |
+
|
181 |
+
// And the CSS attributes
|
182 |
+
var attributes = socss.fn.elementAttributes(el);
|
183 |
+
container = this.$('.socss-properties-window').empty();
|
184 |
+
|
185 |
+
_.each( attributes, function(v, k){
|
186 |
+
container.append(
|
187 |
+
$( thisView.selectorTemplate( { selector: '<strong>' + k + '</strong>: ' + v } ) )
|
188 |
+
.data( 'property', k + ': ' + v )
|
189 |
+
);
|
190 |
+
} );
|
191 |
+
|
192 |
+
container.find('> div')
|
193 |
+
.click( function(e){
|
194 |
+
e.preventDefault();
|
195 |
+
e.stopPropagation();
|
196 |
+
|
197 |
+
thisView.trigger( 'click_property', $(this).data('property') );
|
198 |
+
});
|
199 |
+
|
200 |
+
this.trigger('set_active_element', el, selectors);
|
201 |
+
}
|
202 |
+
|
203 |
+
} );
|
204 |
+
|
205 |
+
socss.view.highlighter = Backbone.View.extend( {
|
206 |
+
template: _.template( $('#socss-template-hover').html().trim() ),
|
207 |
+
highlighted: [ ],
|
208 |
+
|
209 |
+
highlight: function( els ){
|
210 |
+
this.clear();
|
211 |
+
var thisView = this;
|
212 |
+
|
213 |
+
$(els).each(function(i, el){
|
214 |
+
el = $(el);
|
215 |
+
|
216 |
+
if( !el.is(':visible') ) {
|
217 |
+
// Skip over invisible elements
|
218 |
+
return true;
|
219 |
+
}
|
220 |
+
|
221 |
+
var hl = $( thisView.template() );
|
222 |
+
hl.css({
|
223 |
+
'top' : el.offset().top,
|
224 |
+
'left' : el.offset().left,
|
225 |
+
'width' : el.outerWidth(),
|
226 |
+
'height' : el.outerHeight()
|
227 |
+
}).appendTo( 'body' );
|
228 |
+
|
229 |
+
var g;
|
230 |
+
|
231 |
+
var padding = el.padding();
|
232 |
+
for( var k in padding ) {
|
233 |
+
if( parseInt( padding[k] ) > 0 ) {
|
234 |
+
g = hl.find( '.socss-guide-padding.socss-guide-' + k ).show();
|
235 |
+
if( k === 'top' || k === 'bottom' ) {
|
236 |
+
g.css('height', padding[k]);
|
237 |
+
}
|
238 |
+
else {
|
239 |
+
g.css('width', padding[k]);
|
240 |
+
g.css({
|
241 |
+
'width': padding[k],
|
242 |
+
'top' : padding.top,
|
243 |
+
'bottom' : padding.bottom
|
244 |
+
});
|
245 |
+
}
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
var margin = el.margin();
|
250 |
+
for( var k in margin ) {
|
251 |
+
if( parseInt( margin[k] ) > 0 ) {
|
252 |
+
g = hl.find( '.socss-guide-margin.socss-guide-' + k ).show();
|
253 |
+
if( k === 'top' || k === 'bottom' ) {
|
254 |
+
g.css('height', margin[k]);
|
255 |
+
}
|
256 |
+
else {
|
257 |
+
g.css('width', margin[k]);
|
258 |
+
}
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
thisView.highlighted.push( hl );
|
263 |
+
} );
|
264 |
+
},
|
265 |
+
|
266 |
+
clear: function(){
|
267 |
+
while( this.highlighted.length ) {
|
268 |
+
this.highlighted.pop().remove();
|
269 |
+
}
|
270 |
+
}
|
271 |
+
} );
|
272 |
+
|
273 |
+
socss.parsedCss = {};
|
274 |
+
socss.fn.getParsedCss = function(){
|
275 |
+
// Load all the parsed CSS
|
276 |
+
if( Object.keys(socss.parsedCss).length === 0 ) {
|
277 |
+
var parser = new cssjs();
|
278 |
+
$('.socss-theme-styles').each(function(){
|
279 |
+
var $$ = $(this);
|
280 |
+
var p = parser.parseCSS( $$.html() );
|
281 |
+
socss.parsedCss[ $$.attr('id') ] = p;
|
282 |
+
});
|
283 |
+
}
|
284 |
+
return socss.parsedCss;
|
285 |
+
};
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Function to get all the available page selectors
|
289 |
+
*/
|
290 |
+
socss.fn.pageSelectors = function(){
|
291 |
+
var selectors = [];
|
292 |
+
var parsedCss = socss.fn.getParsedCss();
|
293 |
+
|
294 |
+
for( var k in parsedCss ) {
|
295 |
+
for( var i = 0; i < parsedCss[k].length; i++ ) {
|
296 |
+
if (typeof parsedCss[k][i].selector === 'undefined') {
|
297 |
+
continue;
|
298 |
+
}
|
299 |
+
|
300 |
+
var ruleSpecificity = SPECIFICITY.calculate( parsedCss[k][i].selector );
|
301 |
+
for (var j = 0; j < ruleSpecificity.length; j++) {
|
302 |
+
selectors.push({
|
303 |
+
'selector': ruleSpecificity[j].selector.trim(),
|
304 |
+
'specificity': parseInt(ruleSpecificity[j].specificity.replace(/,/g, ''))
|
305 |
+
});
|
306 |
+
}
|
307 |
+
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
// Also add selectors for all the elements in the
|
312 |
+
$('body *').each(function(){
|
313 |
+
var $$ = $(this);
|
314 |
+
var elName = socss.fn.elSelector( $$ );
|
315 |
+
var ruleSpecificity = SPECIFICITY.calculate( elName );
|
316 |
+
for (var k = 0; k < ruleSpecificity.length; k++) {
|
317 |
+
selectors.push({
|
318 |
+
'selector': ruleSpecificity[k].selector.trim(),
|
319 |
+
'specificity': parseInt(ruleSpecificity[k].specificity.replace(/,/g, ''))
|
320 |
+
});
|
321 |
+
}
|
322 |
+
});
|
323 |
+
|
324 |
+
selectors = _.uniq( selectors, false, function( a ){
|
325 |
+
return a.selector;
|
326 |
+
} );
|
327 |
+
|
328 |
+
selectors.sort(function(a, b){
|
329 |
+
return a.specificity > b.specificity ? -1 : 1;
|
330 |
+
});
|
331 |
+
|
332 |
+
return selectors;
|
333 |
+
};
|
334 |
+
|
335 |
+
socss.fn.elementAttributes = function( el ) {
|
336 |
+
if( !document.styleSheets ) {
|
337 |
+
return [];
|
338 |
+
}
|
339 |
+
|
340 |
+
var elProperties = [];
|
341 |
+
|
342 |
+
var trimFunc = function(e) {
|
343 |
+
return e.trim();
|
344 |
+
};
|
345 |
+
|
346 |
+
var filterFunc = function(e){
|
347 |
+
return e !== '';
|
348 |
+
};
|
349 |
+
|
350 |
+
var splitFunc = function(e) {
|
351 |
+
return e.split(':').map( trimFunc );
|
352 |
+
};
|
353 |
+
|
354 |
+
|
355 |
+
var parsedCss = socss.fn.getParsedCss();
|
356 |
+
|
357 |
+
for( var k in parsedCss ) {
|
358 |
+
for( var i = 0; i < parsedCss[k].length; i++ ) {
|
359 |
+
if (
|
360 |
+
typeof parsedCss[k][i].selector === 'undefined' ||
|
361 |
+
typeof parsedCss[k][i].type !== 'undefined' ||
|
362 |
+
parsedCss[k][i].selector[0] === '@'
|
363 |
+
) {
|
364 |
+
continue;
|
365 |
+
}
|
366 |
+
|
367 |
+
var ruleSpecificity = SPECIFICITY.calculate( parsedCss[k][i].selector );
|
368 |
+
for (var j = 0; j < ruleSpecificity.length; j++) {
|
369 |
+
try {
|
370 |
+
if( el.is( ruleSpecificity[j].selector ) ) {
|
371 |
+
for( var l = 0; l < parsedCss[k][i].rules.length; l++ ) {
|
372 |
+
elProperties.push({
|
373 |
+
'name' : parsedCss[k][i].rules[l].directive,
|
374 |
+
'value' : parsedCss[k][i].rules[l].value,
|
375 |
+
'specificity' : parseInt(ruleSpecificity[j].specificity.replace(/,/g, ''))
|
376 |
+
});
|
377 |
+
}
|
378 |
+
}
|
379 |
+
}
|
380 |
+
catch( e ) {
|
381 |
+
// For now, we're just going to ignore rules that trigger jQuery errors
|
382 |
+
}
|
383 |
+
}
|
384 |
+
|
385 |
+
}
|
386 |
+
}
|
387 |
+
|
388 |
+
elProperties.sort( function(a,b) {
|
389 |
+
return a.specificity > b.specificity ? 1 : -1;
|
390 |
+
}).reverse();
|
391 |
+
|
392 |
+
var returnProperties = {};
|
393 |
+
for( var pi = 0; pi < elProperties.length; pi++ ) {
|
394 |
+
if( typeof returnProperties[elProperties[pi].name] === 'undefined' ) {
|
395 |
+
returnProperties[elProperties[pi].name] = elProperties[pi].value;
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
return returnProperties;
|
400 |
+
};
|
401 |
+
|
402 |
+
socss.fn.elSelector = function( el ){
|
403 |
+
var elName = '';
|
404 |
+
if( el.attr('id') !== undefined ) {
|
405 |
+
elName += '#' + el.attr('id');
|
406 |
+
}
|
407 |
+
if( el.attr('class') !== undefined ) {
|
408 |
+
elName += '.' + el.attr('class').replace(/\s+/, '.');
|
409 |
+
}
|
410 |
+
|
411 |
+
if( elName === '' ) {
|
412 |
+
elName = el.prop('tagName').toLowerCase();
|
413 |
+
}
|
414 |
+
|
415 |
+
return elName;
|
416 |
+
};
|
417 |
+
|
418 |
+
window.socssInspector = socss;
|
419 |
+
|
420 |
+
} ) ( jQuery, _, socssOptions );
|
421 |
+
|
422 |
+
jQuery( function($){
|
423 |
+
var socss = window.socssInspector;
|
424 |
+
|
425 |
+
// Setup the editor
|
426 |
+
var inspector = new socss.view.inspector( {
|
427 |
+
el : $('#socss-inspector-interface').get(0)
|
428 |
+
} );
|
429 |
+
inspector.activate();
|
430 |
+
|
431 |
+
window.socssInspector.mainInspector = inspector;
|
432 |
+
} );
|
js/inspector.min.js
ADDED
@@ -0,0 +1,24 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function($,_,socssOptions){var socss={model:{},collection:{},view:{},fn:{}};socss.view.inspector=Backbone.View.extend({active:false,hl:false,hoverEl:false,pageSelectors:[],selectorTemplate:_.template('<div class="socss-selector"><%= selector %></div>'),initialize:function(){var thisView=this;this.hl=new socss.view.highlighter();this.hl.initialize();this.pageSelectors=socss.fn.pageSelectors();$('body').on('mouseover','*',function(e){if(!thisView.active){return true;}
|
3 |
+
var $$=$(this);if($$.closest('.socss-element').length===0){e.stopPropagation();thisView.setHoverEl($(this));}});$('body *').click(function(e){if(!thisView.active||thisView.$el.is(':hover')){return true;}
|
4 |
+
e.preventDefault();e.stopPropagation();var $$=$(this);$$.blur();thisView.setActiveEl(thisView.hoverEl);});this.$('.socss-enable-inspector').click(function(){thisView.toggleActive();});this.$el.mouseenter(function(){thisView.hl.clear();});try{parent.socss.mainEditor.setInspector(this);}
|
5 |
+
catch(err){console.log('No editor to register this inspector with');}},setHoverEl:function(hoverEl){this.hoverEl=hoverEl;this.hl.highlight(hoverEl);},activate:function(){this.active=true;$('body').addClass('socss-active');$('body').removeClass('socss-inactive');},deactivate:function(){this.active=false;$('body').addClass('socss-inactive');$('body').removeClass('socss-active');this.hl.clear();this.$('.socss-hierarchy').empty();},toggleActive:function(){if(this.active){this.deactivate();}
|
6 |
+
else{this.activate();}},setActiveEl:function(el){var thisView=this;var $h=this.$('.socss-hierarchy');$h.empty();if(el.prop('tagName').toLowerCase()!=='body'){var cel=$(el);do{$(this.selectorTemplate({selector:socss.fn.elSelector(cel)})).prependTo($h).data('el',cel);cel=cel.parent();}while(cel.prop('tagName').toLowerCase()!=='body');$(this.selectorTemplate({selector:'body'})).prependTo($h).data('el',$('body'));this.$('.socss-hierarchy .socss-selector').hover(function(){thisView.hl.highlight($(this).data('el'));}).click(function(e){e.preventDefault();e.stopPropagation();thisView.setActiveEl($(this).data('el'));});}
|
7 |
+
$h.scrollLeft(99999);var selectors=this.pageSelectors.filter(function(a){try{return el.is(a.selector);}
|
8 |
+
catch(err){return false;}});var container=this.$('.socss-selectors-window').empty();_.each(selectors,function(selector){container.append($(thisView.selectorTemplate(selector)).data(selector));});container.find('> div').mouseenter(function(){thisView.hl.highlight($(this).data('selector'));}).click(function(e){e.preventDefault();e.stopPropagation();thisView.trigger('click_selector',$(this).data('selector'));});var attributes=socss.fn.elementAttributes(el);container=this.$('.socss-properties-window').empty();_.each(attributes,function(v,k){container.append($(thisView.selectorTemplate({selector:'<strong>'+k+'</strong>: '+v})).data('property',k+': '+v));});container.find('> div').click(function(e){e.preventDefault();e.stopPropagation();thisView.trigger('click_property',$(this).data('property'));});this.trigger('set_active_element',el,selectors);}});socss.view.highlighter=Backbone.View.extend({template:_.template($('#socss-template-hover').html().trim()),highlighted:[],highlight:function(els){this.clear();var thisView=this;$(els).each(function(i,el){el=$(el);if(!el.is(':visible')){return true;}
|
9 |
+
var hl=$(thisView.template());hl.css({'top':el.offset().top,'left':el.offset().left,'width':el.outerWidth(),'height':el.outerHeight()}).appendTo('body');var g;var padding=el.padding();for(var k in padding){if(parseInt(padding[k])>0){g=hl.find('.socss-guide-padding.socss-guide-'+k).show();if(k==='top'||k==='bottom'){g.css('height',padding[k]);}
|
10 |
+
else{g.css('width',padding[k]);g.css({'width':padding[k],'top':padding.top,'bottom':padding.bottom});}}}
|
11 |
+
var margin=el.margin();for(var k in margin){if(parseInt(margin[k])>0){g=hl.find('.socss-guide-margin.socss-guide-'+k).show();if(k==='top'||k==='bottom'){g.css('height',margin[k]);}
|
12 |
+
else{g.css('width',margin[k]);}}}
|
13 |
+
thisView.highlighted.push(hl);});},clear:function(){while(this.highlighted.length){this.highlighted.pop().remove();}}});socss.parsedCss={};socss.fn.getParsedCss=function(){if(Object.keys(socss.parsedCss).length===0){var parser=new cssjs();$('.socss-theme-styles').each(function(){var $$=$(this);var p=parser.parseCSS($$.html());socss.parsedCss[$$.attr('id')]=p;});}
|
14 |
+
return socss.parsedCss;};socss.fn.pageSelectors=function(){var selectors=[];var parsedCss=socss.fn.getParsedCss();for(var k in parsedCss){for(var i=0;i<parsedCss[k].length;i++){if(typeof parsedCss[k][i].selector==='undefined'){continue;}
|
15 |
+
var ruleSpecificity=SPECIFICITY.calculate(parsedCss[k][i].selector);for(var j=0;j<ruleSpecificity.length;j++){selectors.push({'selector':ruleSpecificity[j].selector.trim(),'specificity':parseInt(ruleSpecificity[j].specificity.replace(/,/g,''))});}}}
|
16 |
+
$('body *').each(function(){var $$=$(this);var elName=socss.fn.elSelector($$);var ruleSpecificity=SPECIFICITY.calculate(elName);for(var k=0;k<ruleSpecificity.length;k++){selectors.push({'selector':ruleSpecificity[k].selector.trim(),'specificity':parseInt(ruleSpecificity[k].specificity.replace(/,/g,''))});}});selectors=_.uniq(selectors,false,function(a){return a.selector;});selectors.sort(function(a,b){return a.specificity>b.specificity?-1:1;});return selectors;};socss.fn.elementAttributes=function(el){if(!document.styleSheets){return[];}
|
17 |
+
var elProperties=[];var trimFunc=function(e){return e.trim();};var filterFunc=function(e){return e!=='';};var splitFunc=function(e){return e.split(':').map(trimFunc);};var parsedCss=socss.fn.getParsedCss();for(var k in parsedCss){for(var i=0;i<parsedCss[k].length;i++){if(typeof parsedCss[k][i].selector==='undefined'||typeof parsedCss[k][i].type!=='undefined'||parsedCss[k][i].selector[0]==='@'){continue;}
|
18 |
+
var ruleSpecificity=SPECIFICITY.calculate(parsedCss[k][i].selector);for(var j=0;j<ruleSpecificity.length;j++){try{if(el.is(ruleSpecificity[j].selector)){for(var l=0;l<parsedCss[k][i].rules.length;l++){elProperties.push({'name':parsedCss[k][i].rules[l].directive,'value':parsedCss[k][i].rules[l].value,'specificity':parseInt(ruleSpecificity[j].specificity.replace(/,/g,''))});}}}
|
19 |
+
catch(e){}}}}
|
20 |
+
elProperties.sort(function(a,b){return a.specificity>b.specificity?1:-1;}).reverse();var returnProperties={};for(var pi=0;pi<elProperties.length;pi++){if(typeof returnProperties[elProperties[pi].name]==='undefined'){returnProperties[elProperties[pi].name]=elProperties[pi].value;}}
|
21 |
+
return returnProperties;};socss.fn.elSelector=function(el){var elName='';if(el.attr('id')!==undefined){elName+='#'+el.attr('id');}
|
22 |
+
if(el.attr('class')!==undefined){elName+='.'+el.attr('class').replace(/\s+/,'.');}
|
23 |
+
if(elName===''){elName=el.prop('tagName').toLowerCase();}
|
24 |
+
return elName;};window.socssInspector=socss;})(jQuery,_,socssOptions);jQuery(function($){var socss=window.socssInspector;var inspector=new socss.view.inspector({el:$('#socss-inspector-interface').get(0)});inspector.activate();window.socssInspector.mainInspector=inspector;});
|
js/jquery.sizes.js
ADDED
@@ -0,0 +1,76 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
/**
|
2 |
+
* @preserve JSizes - JQuery plugin v0.33
|
3 |
+
*
|
4 |
+
* Licensed under the revised BSD License.
|
5 |
+
* Copyright 2008-2010 Bram Stein
|
6 |
+
* All rights reserved.
|
7 |
+
*/
|
8 |
+
/*global jQuery*/
|
9 |
+
(function ($) {
|
10 |
+
'use strict';
|
11 |
+
var num = function (value) {
|
12 |
+
return parseInt(value, 10) || 0;
|
13 |
+
};
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Sets or gets the values for min-width, min-height, max-width
|
17 |
+
* and max-height.
|
18 |
+
*/
|
19 |
+
$.each(['min', 'max'], function (i, name) {
|
20 |
+
$.fn[name + 'Size'] = function (value) {
|
21 |
+
var width, height;
|
22 |
+
if (value) {
|
23 |
+
if (value.width !== undefined) {
|
24 |
+
this.css(name + '-width', value.width);
|
25 |
+
}
|
26 |
+
if (value.height !== undefined) {
|
27 |
+
this.css(name + '-height', value.height);
|
28 |
+
}
|
29 |
+
} else {
|
30 |
+
width = this.css(name + '-width');
|
31 |
+
height = this.css(name + '-height');
|
32 |
+
// Apparently:
|
33 |
+
// * Opera returns -1px instead of none
|
34 |
+
// * IE6 returns undefined instead of none
|
35 |
+
return {'width': (name === 'max' && (width === undefined || width === 'none' || num(width) === -1) && Number.MAX_VALUE) || num(width),
|
36 |
+
'height': (name === 'max' && (height === undefined || height === 'none' || num(height) === -1) && Number.MAX_VALUE) || num(height)};
|
37 |
+
}
|
38 |
+
return this;
|
39 |
+
};
|
40 |
+
});
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Returns whether or not an element is visible.
|
44 |
+
*/
|
45 |
+
$.fn.isVisible = function () {
|
46 |
+
return this.is(':visible');
|
47 |
+
};
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Sets or gets the values for border, margin and padding.
|
51 |
+
*/
|
52 |
+
$.each(['border', 'margin', 'padding'], function (i, name) {
|
53 |
+
$.fn[name] = function (value) {
|
54 |
+
if (value) {
|
55 |
+
if (value.top !== undefined) {
|
56 |
+
this.css(name + '-top' + (name === 'border' ? '-width' : ''), value.top);
|
57 |
+
}
|
58 |
+
if (value.bottom !== undefined) {
|
59 |
+
this.css(name + '-bottom' + (name === 'border' ? '-width' : ''), value.bottom);
|
60 |
+
}
|
61 |
+
if (value.left !== undefined) {
|
62 |
+
this.css(name + '-left' + (name === 'border' ? '-width' : ''), value.left);
|
63 |
+
}
|
64 |
+
if (value.right !== undefined) {
|
65 |
+
this.css(name + '-right' + (name === 'border' ? '-width' : ''), value.right);
|
66 |
+
}
|
67 |
+
} else {
|
68 |
+
return {top: num(this.css(name + '-top' + (name === 'border' ? '-width' : ''))),
|
69 |
+
bottom: num(this.css(name + '-bottom' + (name === 'border' ? '-width' : ''))),
|
70 |
+
left: num(this.css(name + '-left' + (name === 'border' ? '-width' : ''))),
|
71 |
+
right: num(this.css(name + '-right' + (name === 'border' ? '-width' : '')))};
|
72 |
+
}
|
73 |
+
return this;
|
74 |
+
};
|
75 |
+
});
|
76 |
+
}(jQuery));
|
js/jquery.sizes.min.js
ADDED
@@ -0,0 +1,8 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function($){'use strict';var num=function(value){return parseInt(value,10)||0;};$.each(['min','max'],function(i,name){$.fn[name+'Size']=function(value){var width,height;if(value){if(value.width!==undefined){this.css(name+'-width',value.width);}
|
3 |
+
if(value.height!==undefined){this.css(name+'-height',value.height);}}else{width=this.css(name+'-width');height=this.css(name+'-height');return{'width':(name==='max'&&(width===undefined||width==='none'||num(width)===-1)&&Number.MAX_VALUE)||num(width),'height':(name==='max'&&(height===undefined||height==='none'||num(height)===-1)&&Number.MAX_VALUE)||num(height)};}
|
4 |
+
return this;};});$.fn.isVisible=function(){return this.is(':visible');};$.each(['border','margin','padding'],function(i,name){$.fn[name]=function(value){if(value){if(value.top!==undefined){this.css(name+'-top'+(name==='border'?'-width':''),value.top);}
|
5 |
+
if(value.bottom!==undefined){this.css(name+'-bottom'+(name==='border'?'-width':''),value.bottom);}
|
6 |
+
if(value.left!==undefined){this.css(name+'-left'+(name==='border'?'-width':''),value.left);}
|
7 |
+
if(value.right!==undefined){this.css(name+'-right'+(name==='border'?'-width':''),value.right);}}else{return{top:num(this.css(name+'-top'+(name==='border'?'-width':''))),bottom:num(this.css(name+'-bottom'+(name==='border'?'-width':''))),left:num(this.css(name+'-left'+(name==='border'?'-width':''))),right:num(this.css(name+'-right'+(name==='border'?'-width':'')))};}
|
8 |
+
return this;};});}(jQuery));
|
js/specificity.js
ADDED
@@ -0,0 +1,141 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
/**
|
2 |
+
* Calculates the specificity of CSS selectors
|
3 |
+
* https://github.com/keeganstreet/specificity - licensed under MIT.
|
4 |
+
*
|
5 |
+
* Returns an array of objects with the following properties:
|
6 |
+
* - selector: the input
|
7 |
+
* - specificity: e.g. 0,1,0,0
|
8 |
+
* - parts: array with details about each part of the selector that counts towards the specificity
|
9 |
+
*/
|
10 |
+
var SPECIFICITY = (function() {
|
11 |
+
var calculate,
|
12 |
+
calculateSingle;
|
13 |
+
|
14 |
+
calculate = function(input) {
|
15 |
+
var selectors,
|
16 |
+
selector,
|
17 |
+
i,
|
18 |
+
len,
|
19 |
+
results = [];
|
20 |
+
|
21 |
+
// Separate input by commas
|
22 |
+
selectors = input.split(',');
|
23 |
+
|
24 |
+
for (i = 0, len = selectors.length; i < len; i += 1) {
|
25 |
+
selector = selectors[i];
|
26 |
+
if (selector.length > 0) {
|
27 |
+
results.push(calculateSingle(selector));
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
return results;
|
32 |
+
};
|
33 |
+
|
34 |
+
// Calculate the specificity for a selector by dividing it into simple selectors and counting them
|
35 |
+
calculateSingle = function(input) {
|
36 |
+
var selector = input,
|
37 |
+
findMatch,
|
38 |
+
typeCount = {
|
39 |
+
'a': 0,
|
40 |
+
'b': 0,
|
41 |
+
'c': 0
|
42 |
+
},
|
43 |
+
parts = [],
|
44 |
+
// The following regular expressions assume that selectors matching the preceding regular expressions have been removed
|
45 |
+
attributeRegex = /(\[[^\]]+\])/g,
|
46 |
+
idRegex = /(#[^\s\+>~\.\[:]+)/g,
|
47 |
+
classRegex = /(\.[^\s\+>~\.\[:]+)/g,
|
48 |
+
pseudoElementRegex = /(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,
|
49 |
+
// A regex for pseudo classes with brackets - :nth-child(), :nth-last-child(), :nth-of-type(), :nth-last-type(), :lang()
|
50 |
+
pseudoClassWithBracketsRegex = /(:[\w-]+\([^\)]*\))/gi,
|
51 |
+
// A regex for other pseudo classes, which don't have brackets
|
52 |
+
pseudoClassRegex = /(:[^\s\+>~\.\[:]+)/g,
|
53 |
+
elementRegex = /([^\s\+>~\.\[:]+)/g;
|
54 |
+
|
55 |
+
// Find matches for a regular expression in a string and push their details to parts
|
56 |
+
// Type is "a" for IDs, "b" for classes, attributes and pseudo-classes and "c" for elements and pseudo-elements
|
57 |
+
findMatch = function(regex, type) {
|
58 |
+
var matches, i, len, match, index, length;
|
59 |
+
if (regex.test(selector)) {
|
60 |
+
matches = selector.match(regex);
|
61 |
+
for (i = 0, len = matches.length; i < len; i += 1) {
|
62 |
+
typeCount[type] += 1;
|
63 |
+
match = matches[i];
|
64 |
+
index = selector.indexOf(match);
|
65 |
+
length = match.length;
|
66 |
+
parts.push({
|
67 |
+
selector: match,
|
68 |
+
type: type,
|
69 |
+
index: index,
|
70 |
+
length: length
|
71 |
+
});
|
72 |
+
// Replace this simple selector with whitespace so it won't be counted in further simple selectors
|
73 |
+
selector = selector.replace(match, Array(length + 1).join(' '));
|
74 |
+
}
|
75 |
+
}
|
76 |
+
};
|
77 |
+
|
78 |
+
// Remove the negation psuedo-class (:not) but leave its argument because specificity is calculated on its argument
|
79 |
+
(function() {
|
80 |
+
var regex = /:not\(([^\)]*)\)/g;
|
81 |
+
if (regex.test(selector)) {
|
82 |
+
selector = selector.replace(regex, ' $1 ');
|
83 |
+
}
|
84 |
+
}());
|
85 |
+
|
86 |
+
// Remove anything after a left brace in case a user has pasted in a rule, not just a selector
|
87 |
+
(function() {
|
88 |
+
var regex = /{[^]*/gm,
|
89 |
+
matches, i, len, match;
|
90 |
+
if (regex.test(selector)) {
|
91 |
+
matches = selector.match(regex);
|
92 |
+
for (i = 0, len = matches.length; i < len; i += 1) {
|
93 |
+
match = matches[i];
|
94 |
+
selector = selector.replace(match, Array(match.length + 1).join(' '));
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}());
|
98 |
+
|
99 |
+
// Add attribute selectors to parts collection (type b)
|
100 |
+
findMatch(attributeRegex, 'b');
|
101 |
+
|
102 |
+
// Add ID selectors to parts collection (type a)
|
103 |
+
findMatch(idRegex, 'a');
|
104 |
+
|
105 |
+
// Add class selectors to parts collection (type b)
|
106 |
+
findMatch(classRegex, 'b');
|
107 |
+
|
108 |
+
// Add pseudo-element selectors to parts collection (type c)
|
109 |
+
findMatch(pseudoElementRegex, 'c');
|
110 |
+
|
111 |
+
// Add pseudo-class selectors to parts collection (type b)
|
112 |
+
findMatch(pseudoClassWithBracketsRegex, 'b');
|
113 |
+
findMatch(pseudoClassRegex, 'b');
|
114 |
+
|
115 |
+
// Remove universal selector and separator characters
|
116 |
+
selector = selector.replace(/[\*\s\+>~]/g, ' ');
|
117 |
+
|
118 |
+
// Remove any stray dots or hashes which aren't attached to words
|
119 |
+
// These may be present if the user is live-editing this selector
|
120 |
+
selector = selector.replace(/[#\.]/g, ' ');
|
121 |
+
|
122 |
+
// The only things left should be element selectors (type c)
|
123 |
+
findMatch(elementRegex, 'c');
|
124 |
+
|
125 |
+
// Order the parts in the order they appear in the original selector
|
126 |
+
// This is neater for external apps to deal with
|
127 |
+
parts.sort(function(a, b) {
|
128 |
+
return a.index - b.index;
|
129 |
+
});
|
130 |
+
|
131 |
+
return {
|
132 |
+
selector: input,
|
133 |
+
specificity: '0,' + typeCount.a.toString() + ',' + typeCount.b.toString() + ',' + typeCount.c.toString(),
|
134 |
+
parts: parts
|
135 |
+
};
|
136 |
+
};
|
137 |
+
|
138 |
+
return {
|
139 |
+
calculate: calculate
|
140 |
+
};
|
141 |
+
}());
|
js/specificity.min.js
ADDED
@@ -0,0 +1,3 @@
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
var SPECIFICITY=(function(){var calculate,calculateSingle;calculate=function(input){var selectors,selector,i,len,results=[];selectors=input.split(',');for(i=0,len=selectors.length;i<len;i+=1){selector=selectors[i];if(selector.length>0){results.push(calculateSingle(selector));}}
|
3 |
+
return results;};calculateSingle=function(input){var selector=input,findMatch,typeCount={'a':0,'b':0,'c':0},parts=[],attributeRegex=/(\[[^\]]+\])/g,idRegex=/(#[^\s\+>~\.\[:]+)/g,classRegex=/(\.[^\s\+>~\.\[:]+)/g,pseudoElementRegex=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,pseudoClassWithBracketsRegex=/(:[\w-]+\([^\)]*\))/gi,pseudoClassRegex=/(:[^\s\+>~\.\[:]+)/g,elementRegex=/([^\s\+>~\.\[:]+)/g;findMatch=function(regex,type){var matches,i,len,match,index,length;if(regex.test(selector)){matches=selector.match(regex);for(i=0,len=matches.length;i<len;i+=1){typeCount[type]+=1;match=matches[i];index=selector.indexOf(match);length=match.length;parts.push({selector:match,type:type,index:index,length:length});selector=selector.replace(match,Array(length+1).join(' '));}}};(function(){var regex=/:not\(([^\)]*)\)/g;if(regex.test(selector)){selector=selector.replace(regex,' $1 ');}}());(function(){var regex=/{[^]*/gm,matches,i,len,match;if(regex.test(selector)){matches=selector.match(regex);for(i=0,len=matches.length;i<len;i+=1){match=matches[i];selector=selector.replace(match,Array(match.length+1).join(' '));}}}());findMatch(attributeRegex,'b');findMatch(idRegex,'a');findMatch(classRegex,'b');findMatch(pseudoElementRegex,'c');findMatch(pseudoClassWithBracketsRegex,'b');findMatch(pseudoClassRegex,'b');selector=selector.replace(/[\*\s\+>~]/g,' ');selector=selector.replace(/[#\.]/g,' ');findMatch(elementRegex,'c');parts.sort(function(a,b){return a.index-b.index;});return{selector:input,specificity:'0,'+typeCount.a.toString()+','+typeCount.b.toString()+','+typeCount.c.toString(),parts:parts};};return{calculate:calculate};}());
|
lib/codemirror/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
Copyright (C) 2014 by Marijn Haverbeke <marijnh@gmail.com> and others
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
+
of this software and associated documentation files (the "Software"), to deal
|
5 |
+
in the Software without restriction, including without limitation the rights
|
6 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
+
copies of the Software, and to permit persons to whom the Software is
|
8 |
+
furnished to do so, subject to the following conditions:
|
9 |
+
|
10 |
+
The above copyright notice and this permission notice shall be included in
|
11 |
+
all copies or substantial portions of the Software.
|
12 |
+
|
13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
+
THE SOFTWARE.
|
lib/codemirror/addon/fold/brace-fold.js
ADDED
@@ -0,0 +1,105 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
CodeMirror.registerHelper("fold", "brace", function(cm, start) {
|
15 |
+
var line = start.line, lineText = cm.getLine(line);
|
16 |
+
var startCh, tokenType;
|
17 |
+
|
18 |
+
function findOpening(openCh) {
|
19 |
+
for (var at = start.ch, pass = 0;;) {
|
20 |
+
var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1);
|
21 |
+
if (found == -1) {
|
22 |
+
if (pass == 1) break;
|
23 |
+
pass = 1;
|
24 |
+
at = lineText.length;
|
25 |
+
continue;
|
26 |
+
}
|
27 |
+
if (pass == 1 && found < start.ch) break;
|
28 |
+
tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
|
29 |
+
if (!/^(comment|string)/.test(tokenType)) return found + 1;
|
30 |
+
at = found - 1;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
var startToken = "{", endToken = "}", startCh = findOpening("{");
|
35 |
+
if (startCh == null) {
|
36 |
+
startToken = "[", endToken = "]";
|
37 |
+
startCh = findOpening("[");
|
38 |
+
}
|
39 |
+
|
40 |
+
if (startCh == null) return;
|
41 |
+
var count = 1, lastLine = cm.lastLine(), end, endCh;
|
42 |
+
outer: for (var i = line; i <= lastLine; ++i) {
|
43 |
+
var text = cm.getLine(i), pos = i == line ? startCh : 0;
|
44 |
+
for (;;) {
|
45 |
+
var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
|
46 |
+
if (nextOpen < 0) nextOpen = text.length;
|
47 |
+
if (nextClose < 0) nextClose = text.length;
|
48 |
+
pos = Math.min(nextOpen, nextClose);
|
49 |
+
if (pos == text.length) break;
|
50 |
+
if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) {
|
51 |
+
if (pos == nextOpen) ++count;
|
52 |
+
else if (!--count) { end = i; endCh = pos; break outer; }
|
53 |
+
}
|
54 |
+
++pos;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
if (end == null || line == end && endCh == startCh) return;
|
58 |
+
return {from: CodeMirror.Pos(line, startCh),
|
59 |
+
to: CodeMirror.Pos(end, endCh)};
|
60 |
+
});
|
61 |
+
|
62 |
+
CodeMirror.registerHelper("fold", "import", function(cm, start) {
|
63 |
+
function hasImport(line) {
|
64 |
+
if (line < cm.firstLine() || line > cm.lastLine()) return null;
|
65 |
+
var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
|
66 |
+
if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
|
67 |
+
if (start.type != "keyword" || start.string != "import") return null;
|
68 |
+
// Now find closing semicolon, return its position
|
69 |
+
for (var i = line, e = Math.min(cm.lastLine(), line + 10); i <= e; ++i) {
|
70 |
+
var text = cm.getLine(i), semi = text.indexOf(";");
|
71 |
+
if (semi != -1) return {startCh: start.end, end: CodeMirror.Pos(i, semi)};
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
var start = start.line, has = hasImport(start), prev;
|
76 |
+
if (!has || hasImport(start - 1) || ((prev = hasImport(start - 2)) && prev.end.line == start - 1))
|
77 |
+
return null;
|
78 |
+
for (var end = has.end;;) {
|
79 |
+
var next = hasImport(end.line + 1);
|
80 |
+
if (next == null) break;
|
81 |
+
end = next.end;
|
82 |
+
}
|
83 |
+
return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
|
84 |
+
});
|
85 |
+
|
86 |
+
CodeMirror.registerHelper("fold", "include", function(cm, start) {
|
87 |
+
function hasInclude(line) {
|
88 |
+
if (line < cm.firstLine() || line > cm.lastLine()) return null;
|
89 |
+
var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
|
90 |
+
if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
|
91 |
+
if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
|
92 |
+
}
|
93 |
+
|
94 |
+
var start = start.line, has = hasInclude(start);
|
95 |
+
if (has == null || hasInclude(start - 1) != null) return null;
|
96 |
+
for (var end = start;;) {
|
97 |
+
var next = hasInclude(end + 1);
|
98 |
+
if (next == null) break;
|
99 |
+
++end;
|
100 |
+
}
|
101 |
+
return {from: CodeMirror.Pos(start, has + 1),
|
102 |
+
to: cm.clipPos(CodeMirror.Pos(end))};
|
103 |
+
});
|
104 |
+
|
105 |
+
});
|
lib/codemirror/addon/fold/brace-fold.min.js
ADDED
@@ -0,0 +1,15 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("fold","brace",function(cm,start){var line=start.line,lineText=cm.getLine(line);var startCh,tokenType;function findOpening(openCh){for(var at=start.ch,pass=0;;){var found=at<=0?-1:lineText.lastIndexOf(openCh,at-1);if(found==-1){if(pass==1)break;pass=1;at=lineText.length;continue;}
|
6 |
+
if(pass==1&&found<start.ch)break;tokenType=cm.getTokenTypeAt(CodeMirror.Pos(line,found+1));if(!/^(comment|string)/.test(tokenType))return found+1;at=found-1;}}
|
7 |
+
var startToken="{",endToken="}",startCh=findOpening("{");if(startCh==null){startToken="[",endToken="]";startCh=findOpening("[");}
|
8 |
+
if(startCh==null)return;var count=1,lastLine=cm.lastLine(),end,endCh;outer:for(var i=line;i<=lastLine;++i){var text=cm.getLine(i),pos=i==line?startCh:0;for(;;){var nextOpen=text.indexOf(startToken,pos),nextClose=text.indexOf(endToken,pos);if(nextOpen<0)nextOpen=text.length;if(nextClose<0)nextClose=text.length;pos=Math.min(nextOpen,nextClose);if(pos==text.length)break;if(cm.getTokenTypeAt(CodeMirror.Pos(i,pos+1))==tokenType){if(pos==nextOpen)++count;else if(!--count){end=i;endCh=pos;break outer;}}
|
9 |
+
++pos;}}
|
10 |
+
if(end==null||line==end&&endCh==startCh)return;return{from:CodeMirror.Pos(line,startCh),to:CodeMirror.Pos(end,endCh)};});CodeMirror.registerHelper("fold","import",function(cm,start){function hasImport(line){if(line<cm.firstLine()||line>cm.lastLine())return null;var start=cm.getTokenAt(CodeMirror.Pos(line,1));if(!/\S/.test(start.string))start=cm.getTokenAt(CodeMirror.Pos(line,start.end+1));if(start.type!="keyword"||start.string!="import")return null;for(var i=line,e=Math.min(cm.lastLine(),line+10);i<=e;++i){var text=cm.getLine(i),semi=text.indexOf(";");if(semi!=-1)return{startCh:start.end,end:CodeMirror.Pos(i,semi)};}}
|
11 |
+
var start=start.line,has=hasImport(start),prev;if(!has||hasImport(start-1)||((prev=hasImport(start-2))&&prev.end.line==start-1))
|
12 |
+
return null;for(var end=has.end;;){var next=hasImport(end.line+1);if(next==null)break;end=next.end;}
|
13 |
+
return{from:cm.clipPos(CodeMirror.Pos(start,has.startCh+1)),to:end};});CodeMirror.registerHelper("fold","include",function(cm,start){function hasInclude(line){if(line<cm.firstLine()||line>cm.lastLine())return null;var start=cm.getTokenAt(CodeMirror.Pos(line,1));if(!/\S/.test(start.string))start=cm.getTokenAt(CodeMirror.Pos(line,start.end+1));if(start.type=="meta"&&start.string.slice(0,8)=="#include")return start.start+8;}
|
14 |
+
var start=start.line,has=hasInclude(start);if(has==null||hasInclude(start-1)!=null)return null;for(var end=start;;){var next=hasInclude(end+1);if(next==null)break;++end;}
|
15 |
+
return{from:CodeMirror.Pos(start,has+1),to:cm.clipPos(CodeMirror.Pos(end))};});});
|
lib/codemirror/addon/fold/comment-fold.js
ADDED
@@ -0,0 +1,57 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
|
15 |
+
return mode.blockCommentStart && mode.blockCommentEnd;
|
16 |
+
}, function(cm, start) {
|
17 |
+
var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd;
|
18 |
+
if (!startToken || !endToken) return;
|
19 |
+
var line = start.line, lineText = cm.getLine(line);
|
20 |
+
|
21 |
+
var startCh;
|
22 |
+
for (var at = start.ch, pass = 0;;) {
|
23 |
+
var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1);
|
24 |
+
if (found == -1) {
|
25 |
+
if (pass == 1) return;
|
26 |
+
pass = 1;
|
27 |
+
at = lineText.length;
|
28 |
+
continue;
|
29 |
+
}
|
30 |
+
if (pass == 1 && found < start.ch) return;
|
31 |
+
if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
|
32 |
+
startCh = found + startToken.length;
|
33 |
+
break;
|
34 |
+
}
|
35 |
+
at = found - 1;
|
36 |
+
}
|
37 |
+
|
38 |
+
var depth = 1, lastLine = cm.lastLine(), end, endCh;
|
39 |
+
outer: for (var i = line; i <= lastLine; ++i) {
|
40 |
+
var text = cm.getLine(i), pos = i == line ? startCh : 0;
|
41 |
+
for (;;) {
|
42 |
+
var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
|
43 |
+
if (nextOpen < 0) nextOpen = text.length;
|
44 |
+
if (nextClose < 0) nextClose = text.length;
|
45 |
+
pos = Math.min(nextOpen, nextClose);
|
46 |
+
if (pos == text.length) break;
|
47 |
+
if (pos == nextOpen) ++depth;
|
48 |
+
else if (!--depth) { end = i; endCh = pos; break outer; }
|
49 |
+
++pos;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
if (end == null || line == end && endCh == startCh) return;
|
53 |
+
return {from: CodeMirror.Pos(line, startCh),
|
54 |
+
to: CodeMirror.Pos(end, endCh)};
|
55 |
+
});
|
56 |
+
|
57 |
+
});
|
lib/codemirror/addon/fold/comment-fold.min.js
ADDED
@@ -0,0 +1,10 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerGlobalHelper("fold","comment",function(mode){return mode.blockCommentStart&&mode.blockCommentEnd;},function(cm,start){var mode=cm.getModeAt(start),startToken=mode.blockCommentStart,endToken=mode.blockCommentEnd;if(!startToken||!endToken)return;var line=start.line,lineText=cm.getLine(line);var startCh;for(var at=start.ch,pass=0;;){var found=at<=0?-1:lineText.lastIndexOf(startToken,at-1);if(found==-1){if(pass==1)return;pass=1;at=lineText.length;continue;}
|
6 |
+
if(pass==1&&found<start.ch)return;if(/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line,found+1)))){startCh=found+startToken.length;break;}
|
7 |
+
at=found-1;}
|
8 |
+
var depth=1,lastLine=cm.lastLine(),end,endCh;outer:for(var i=line;i<=lastLine;++i){var text=cm.getLine(i),pos=i==line?startCh:0;for(;;){var nextOpen=text.indexOf(startToken,pos),nextClose=text.indexOf(endToken,pos);if(nextOpen<0)nextOpen=text.length;if(nextClose<0)nextClose=text.length;pos=Math.min(nextOpen,nextClose);if(pos==text.length)break;if(pos==nextOpen)++depth;else if(!--depth){end=i;endCh=pos;break outer;}
|
9 |
+
++pos;}}
|
10 |
+
if(end==null||line==end&&endCh==startCh)return;return{from:CodeMirror.Pos(line,startCh),to:CodeMirror.Pos(end,endCh)};});});
|
lib/codemirror/addon/fold/foldcode.js
ADDED
@@ -0,0 +1,149 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
function doFold(cm, pos, options, force) {
|
15 |
+
if (options && options.call) {
|
16 |
+
var finder = options;
|
17 |
+
options = null;
|
18 |
+
} else {
|
19 |
+
var finder = getOption(cm, options, "rangeFinder");
|
20 |
+
}
|
21 |
+
if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);
|
22 |
+
var minSize = getOption(cm, options, "minFoldSize");
|
23 |
+
|
24 |
+
function getRange(allowFolded) {
|
25 |
+
var range = finder(cm, pos);
|
26 |
+
if (!range || range.to.line - range.from.line < minSize) return null;
|
27 |
+
var marks = cm.findMarksAt(range.from);
|
28 |
+
for (var i = 0; i < marks.length; ++i) {
|
29 |
+
if (marks[i].__isFold && force !== "fold") {
|
30 |
+
if (!allowFolded) return null;
|
31 |
+
range.cleared = true;
|
32 |
+
marks[i].clear();
|
33 |
+
}
|
34 |
+
}
|
35 |
+
return range;
|
36 |
+
}
|
37 |
+
|
38 |
+
var range = getRange(true);
|
39 |
+
if (getOption(cm, options, "scanUp")) while (!range && pos.line > cm.firstLine()) {
|
40 |
+
pos = CodeMirror.Pos(pos.line - 1, 0);
|
41 |
+
range = getRange(false);
|
42 |
+
}
|
43 |
+
if (!range || range.cleared || force === "unfold") return;
|
44 |
+
|
45 |
+
var myWidget = makeWidget(cm, options);
|
46 |
+
CodeMirror.on(myWidget, "mousedown", function(e) {
|
47 |
+
myRange.clear();
|
48 |
+
CodeMirror.e_preventDefault(e);
|
49 |
+
});
|
50 |
+
var myRange = cm.markText(range.from, range.to, {
|
51 |
+
replacedWith: myWidget,
|
52 |
+
clearOnEnter: true,
|
53 |
+
__isFold: true
|
54 |
+
});
|
55 |
+
myRange.on("clear", function(from, to) {
|
56 |
+
CodeMirror.signal(cm, "unfold", cm, from, to);
|
57 |
+
});
|
58 |
+
CodeMirror.signal(cm, "fold", cm, range.from, range.to);
|
59 |
+
}
|
60 |
+
|
61 |
+
function makeWidget(cm, options) {
|
62 |
+
var widget = getOption(cm, options, "widget");
|
63 |
+
if (typeof widget == "string") {
|
64 |
+
var text = document.createTextNode(widget);
|
65 |
+
widget = document.createElement("span");
|
66 |
+
widget.appendChild(text);
|
67 |
+
widget.className = "CodeMirror-foldmarker";
|
68 |
+
}
|
69 |
+
return widget;
|
70 |
+
}
|
71 |
+
|
72 |
+
// Clumsy backwards-compatible interface
|
73 |
+
CodeMirror.newFoldFunction = function(rangeFinder, widget) {
|
74 |
+
return function(cm, pos) { doFold(cm, pos, {rangeFinder: rangeFinder, widget: widget}); };
|
75 |
+
};
|
76 |
+
|
77 |
+
// New-style interface
|
78 |
+
CodeMirror.defineExtension("foldCode", function(pos, options, force) {
|
79 |
+
doFold(this, pos, options, force);
|
80 |
+
});
|
81 |
+
|
82 |
+
CodeMirror.defineExtension("isFolded", function(pos) {
|
83 |
+
var marks = this.findMarksAt(pos);
|
84 |
+
for (var i = 0; i < marks.length; ++i)
|
85 |
+
if (marks[i].__isFold) return true;
|
86 |
+
});
|
87 |
+
|
88 |
+
CodeMirror.commands.toggleFold = function(cm) {
|
89 |
+
cm.foldCode(cm.getCursor());
|
90 |
+
};
|
91 |
+
CodeMirror.commands.fold = function(cm) {
|
92 |
+
cm.foldCode(cm.getCursor(), null, "fold");
|
93 |
+
};
|
94 |
+
CodeMirror.commands.unfold = function(cm) {
|
95 |
+
cm.foldCode(cm.getCursor(), null, "unfold");
|
96 |
+
};
|
97 |
+
CodeMirror.commands.foldAll = function(cm) {
|
98 |
+
cm.operation(function() {
|
99 |
+
for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
|
100 |
+
cm.foldCode(CodeMirror.Pos(i, 0), null, "fold");
|
101 |
+
});
|
102 |
+
};
|
103 |
+
CodeMirror.commands.unfoldAll = function(cm) {
|
104 |
+
cm.operation(function() {
|
105 |
+
for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
|
106 |
+
cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold");
|
107 |
+
});
|
108 |
+
};
|
109 |
+
|
110 |
+
CodeMirror.registerHelper("fold", "combine", function() {
|
111 |
+
var funcs = Array.prototype.slice.call(arguments, 0);
|
112 |
+
return function(cm, start) {
|
113 |
+
for (var i = 0; i < funcs.length; ++i) {
|
114 |
+
var found = funcs[i](cm, start);
|
115 |
+
if (found) return found;
|
116 |
+
}
|
117 |
+
};
|
118 |
+
});
|
119 |
+
|
120 |
+
CodeMirror.registerHelper("fold", "auto", function(cm, start) {
|
121 |
+
var helpers = cm.getHelpers(start, "fold");
|
122 |
+
for (var i = 0; i < helpers.length; i++) {
|
123 |
+
var cur = helpers[i](cm, start);
|
124 |
+
if (cur) return cur;
|
125 |
+
}
|
126 |
+
});
|
127 |
+
|
128 |
+
var defaultOptions = {
|
129 |
+
rangeFinder: CodeMirror.fold.auto,
|
130 |
+
widget: "\u2194",
|
131 |
+
minFoldSize: 0,
|
132 |
+
scanUp: false
|
133 |
+
};
|
134 |
+
|
135 |
+
CodeMirror.defineOption("foldOptions", null);
|
136 |
+
|
137 |
+
function getOption(cm, options, name) {
|
138 |
+
if (options && options[name] !== undefined)
|
139 |
+
return options[name];
|
140 |
+
var editorOptions = cm.options.foldOptions;
|
141 |
+
if (editorOptions && editorOptions[name] !== undefined)
|
142 |
+
return editorOptions[name];
|
143 |
+
return defaultOptions[name];
|
144 |
+
}
|
145 |
+
|
146 |
+
CodeMirror.defineExtension("foldOption", function(options, name) {
|
147 |
+
return getOption(this, options, name);
|
148 |
+
});
|
149 |
+
});
|
lib/codemirror/addon/fold/foldcode.min.js
ADDED
@@ -0,0 +1,18 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";function doFold(cm,pos,options,force){if(options&&options.call){var finder=options;options=null;}else{var finder=getOption(cm,options,"rangeFinder");}
|
6 |
+
if(typeof pos=="number")pos=CodeMirror.Pos(pos,0);var minSize=getOption(cm,options,"minFoldSize");function getRange(allowFolded){var range=finder(cm,pos);if(!range||range.to.line-range.from.line<minSize)return null;var marks=cm.findMarksAt(range.from);for(var i=0;i<marks.length;++i){if(marks[i].__isFold&&force!=="fold"){if(!allowFolded)return null;range.cleared=true;marks[i].clear();}}
|
7 |
+
return range;}
|
8 |
+
var range=getRange(true);if(getOption(cm,options,"scanUp"))while(!range&&pos.line>cm.firstLine()){pos=CodeMirror.Pos(pos.line-1,0);range=getRange(false);}
|
9 |
+
if(!range||range.cleared||force==="unfold")return;var myWidget=makeWidget(cm,options);CodeMirror.on(myWidget,"mousedown",function(e){myRange.clear();CodeMirror.e_preventDefault(e);});var myRange=cm.markText(range.from,range.to,{replacedWith:myWidget,clearOnEnter:true,__isFold:true});myRange.on("clear",function(from,to){CodeMirror.signal(cm,"unfold",cm,from,to);});CodeMirror.signal(cm,"fold",cm,range.from,range.to);}
|
10 |
+
function makeWidget(cm,options){var widget=getOption(cm,options,"widget");if(typeof widget=="string"){var text=document.createTextNode(widget);widget=document.createElement("span");widget.appendChild(text);widget.className="CodeMirror-foldmarker";}
|
11 |
+
return widget;}
|
12 |
+
CodeMirror.newFoldFunction=function(rangeFinder,widget){return function(cm,pos){doFold(cm,pos,{rangeFinder:rangeFinder,widget:widget});};};CodeMirror.defineExtension("foldCode",function(pos,options,force){doFold(this,pos,options,force);});CodeMirror.defineExtension("isFolded",function(pos){var marks=this.findMarksAt(pos);for(var i=0;i<marks.length;++i)
|
13 |
+
if(marks[i].__isFold)return true;});CodeMirror.commands.toggleFold=function(cm){cm.foldCode(cm.getCursor());};CodeMirror.commands.fold=function(cm){cm.foldCode(cm.getCursor(),null,"fold");};CodeMirror.commands.unfold=function(cm){cm.foldCode(cm.getCursor(),null,"unfold");};CodeMirror.commands.foldAll=function(cm){cm.operation(function(){for(var i=cm.firstLine(),e=cm.lastLine();i<=e;i++)
|
14 |
+
cm.foldCode(CodeMirror.Pos(i,0),null,"fold");});};CodeMirror.commands.unfoldAll=function(cm){cm.operation(function(){for(var i=cm.firstLine(),e=cm.lastLine();i<=e;i++)
|
15 |
+
cm.foldCode(CodeMirror.Pos(i,0),null,"unfold");});};CodeMirror.registerHelper("fold","combine",function(){var funcs=Array.prototype.slice.call(arguments,0);return function(cm,start){for(var i=0;i<funcs.length;++i){var found=funcs[i](cm,start);if(found)return found;}};});CodeMirror.registerHelper("fold","auto",function(cm,start){var helpers=cm.getHelpers(start,"fold");for(var i=0;i<helpers.length;i++){var cur=helpers[i](cm,start);if(cur)return cur;}});var defaultOptions={rangeFinder:CodeMirror.fold.auto,widget:"\u2194",minFoldSize:0,scanUp:false};CodeMirror.defineOption("foldOptions",null);function getOption(cm,options,name){if(options&&options[name]!==undefined)
|
16 |
+
return options[name];var editorOptions=cm.options.foldOptions;if(editorOptions&&editorOptions[name]!==undefined)
|
17 |
+
return editorOptions[name];return defaultOptions[name];}
|
18 |
+
CodeMirror.defineExtension("foldOption",function(options,name){return getOption(this,options,name);});});
|
lib/codemirror/addon/fold/foldgutter.css
ADDED
@@ -0,0 +1,20 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
.CodeMirror-foldmarker {
|
2 |
+
color: blue;
|
3 |
+
text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
|
4 |
+
font-family: arial;
|
5 |
+
line-height: .3;
|
6 |
+
cursor: pointer;
|
7 |
+
}
|
8 |
+
.CodeMirror-foldgutter {
|
9 |
+
width: .7em;
|
10 |
+
}
|
11 |
+
.CodeMirror-foldgutter-open,
|
12 |
+
.CodeMirror-foldgutter-folded {
|
13 |
+
cursor: pointer;
|
14 |
+
}
|
15 |
+
.CodeMirror-foldgutter-open:after {
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
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"), require("./foldcode"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror", "./foldcode"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
CodeMirror.defineOption("foldGutter", false, function(cm, val, old) {
|
15 |
+
if (old && old != CodeMirror.Init) {
|
16 |
+
cm.clearGutter(cm.state.foldGutter.options.gutter);
|
17 |
+
cm.state.foldGutter = null;
|
18 |
+
cm.off("gutterClick", onGutterClick);
|
19 |
+
cm.off("change", onChange);
|
20 |
+
cm.off("viewportChange", onViewportChange);
|
21 |
+
cm.off("fold", onFold);
|
22 |
+
cm.off("unfold", onFold);
|
23 |
+
cm.off("swapDoc", updateInViewport);
|
24 |
+
}
|
25 |
+
if (val) {
|
26 |
+
cm.state.foldGutter = new State(parseOptions(val));
|
27 |
+
updateInViewport(cm);
|
28 |
+
cm.on("gutterClick", onGutterClick);
|
29 |
+
cm.on("change", onChange);
|
30 |
+
cm.on("viewportChange", onViewportChange);
|
31 |
+
cm.on("fold", onFold);
|
32 |
+
cm.on("unfold", onFold);
|
33 |
+
cm.on("swapDoc", updateInViewport);
|
34 |
+
}
|
35 |
+
});
|
36 |
+
|
37 |
+
var Pos = CodeMirror.Pos;
|
38 |
+
|
39 |
+
function State(options) {
|
40 |
+
this.options = options;
|
41 |
+
this.from = this.to = 0;
|
42 |
+
}
|
43 |
+
|
44 |
+
function parseOptions(opts) {
|
45 |
+
if (opts === true) opts = {};
|
46 |
+
if (opts.gutter == null) opts.gutter = "CodeMirror-foldgutter";
|
47 |
+
if (opts.indicatorOpen == null) opts.indicatorOpen = "CodeMirror-foldgutter-open";
|
48 |
+
if (opts.indicatorFolded == null) opts.indicatorFolded = "CodeMirror-foldgutter-folded";
|
49 |
+
return opts;
|
50 |
+
}
|
51 |
+
|
52 |
+
function isFolded(cm, line) {
|
53 |
+
var marks = cm.findMarksAt(Pos(line));
|
54 |
+
for (var i = 0; i < marks.length; ++i)
|
55 |
+
if (marks[i].__isFold && marks[i].find().from.line == line) return marks[i];
|
56 |
+
}
|
57 |
+
|
58 |
+
function marker(spec) {
|
59 |
+
if (typeof spec == "string") {
|
60 |
+
var elt = document.createElement("div");
|
61 |
+
elt.className = spec + " CodeMirror-guttermarker-subtle";
|
62 |
+
return elt;
|
63 |
+
} else {
|
64 |
+
return spec.cloneNode(true);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
function updateFoldInfo(cm, from, to) {
|
69 |
+
var opts = cm.state.foldGutter.options, cur = from;
|
70 |
+
var minSize = cm.foldOption(opts, "minFoldSize");
|
71 |
+
var func = cm.foldOption(opts, "rangeFinder");
|
72 |
+
cm.eachLine(from, to, function(line) {
|
73 |
+
var mark = null;
|
74 |
+
if (isFolded(cm, cur)) {
|
75 |
+
mark = marker(opts.indicatorFolded);
|
76 |
+
} else {
|
77 |
+
var pos = Pos(cur, 0);
|
78 |
+
var range = func && func(cm, pos);
|
79 |
+
if (range && range.to.line - range.from.line >= minSize)
|
80 |
+
mark = marker(opts.indicatorOpen);
|
81 |
+
}
|
82 |
+
cm.setGutterMarker(line, opts.gutter, mark);
|
83 |
+
++cur;
|
84 |
+
});
|
85 |
+
}
|
86 |
+
|
87 |
+
function updateInViewport(cm) {
|
88 |
+
var vp = cm.getViewport(), state = cm.state.foldGutter;
|
89 |
+
if (!state) return;
|
90 |
+
cm.operation(function() {
|
91 |
+
updateFoldInfo(cm, vp.from, vp.to);
|
92 |
+
});
|
93 |
+
state.from = vp.from; state.to = vp.to;
|
94 |
+
}
|
95 |
+
|
96 |
+
function onGutterClick(cm, line, gutter) {
|
97 |
+
var state = cm.state.foldGutter;
|
98 |
+
if (!state) return;
|
99 |
+
var opts = state.options;
|
100 |
+
if (gutter != opts.gutter) return;
|
101 |
+
var folded = isFolded(cm, line);
|
102 |
+
if (folded) folded.clear();
|
103 |
+
else cm.foldCode(Pos(line, 0), opts.rangeFinder);
|
104 |
+
}
|
105 |
+
|
106 |
+
function onChange(cm) {
|
107 |
+
var state = cm.state.foldGutter;
|
108 |
+
if (!state) return;
|
109 |
+
var opts = state.options;
|
110 |
+
state.from = state.to = 0;
|
111 |
+
clearTimeout(state.changeUpdate);
|
112 |
+
state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, opts.foldOnChangeTimeSpan || 600);
|
113 |
+
}
|
114 |
+
|
115 |
+
function onViewportChange(cm) {
|
116 |
+
var state = cm.state.foldGutter;
|
117 |
+
if (!state) return;
|
118 |
+
var opts = state.options;
|
119 |
+
clearTimeout(state.changeUpdate);
|
120 |
+
state.changeUpdate = setTimeout(function() {
|
121 |
+
var vp = cm.getViewport();
|
122 |
+
if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
|
123 |
+
updateInViewport(cm);
|
124 |
+
} else {
|
125 |
+
cm.operation(function() {
|
126 |
+
if (vp.from < state.from) {
|
127 |
+
updateFoldInfo(cm, vp.from, state.from);
|
128 |
+
state.from = vp.from;
|
129 |
+
}
|
130 |
+
if (vp.to > state.to) {
|
131 |
+
updateFoldInfo(cm, state.to, vp.to);
|
132 |
+
state.to = vp.to;
|
133 |
+
}
|
134 |
+
});
|
135 |
+
}
|
136 |
+
}, opts.updateViewportTimeSpan || 400);
|
137 |
+
}
|
138 |
+
|
139 |
+
function onFold(cm, from) {
|
140 |
+
var state = cm.state.foldGutter;
|
141 |
+
if (!state) return;
|
142 |
+
var line = from.line;
|
143 |
+
if (line >= state.from && line < state.to)
|
144 |
+
updateFoldInfo(cm, line, line + 1);
|
145 |
+
}
|
146 |
+
});
|
lib/codemirror/addon/fold/foldgutter.min.js
ADDED
@@ -0,0 +1,20 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"),require("./foldcode"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror","./foldcode"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.defineOption("foldGutter",false,function(cm,val,old){if(old&&old!=CodeMirror.Init){cm.clearGutter(cm.state.foldGutter.options.gutter);cm.state.foldGutter=null;cm.off("gutterClick",onGutterClick);cm.off("change",onChange);cm.off("viewportChange",onViewportChange);cm.off("fold",onFold);cm.off("unfold",onFold);cm.off("swapDoc",updateInViewport);}
|
6 |
+
if(val){cm.state.foldGutter=new State(parseOptions(val));updateInViewport(cm);cm.on("gutterClick",onGutterClick);cm.on("change",onChange);cm.on("viewportChange",onViewportChange);cm.on("fold",onFold);cm.on("unfold",onFold);cm.on("swapDoc",updateInViewport);}});var Pos=CodeMirror.Pos;function State(options){this.options=options;this.from=this.to=0;}
|
7 |
+
function parseOptions(opts){if(opts===true)opts={};if(opts.gutter==null)opts.gutter="CodeMirror-foldgutter";if(opts.indicatorOpen==null)opts.indicatorOpen="CodeMirror-foldgutter-open";if(opts.indicatorFolded==null)opts.indicatorFolded="CodeMirror-foldgutter-folded";return opts;}
|
8 |
+
function isFolded(cm,line){var marks=cm.findMarksAt(Pos(line));for(var i=0;i<marks.length;++i)
|
9 |
+
if(marks[i].__isFold&&marks[i].find().from.line==line)return marks[i];}
|
10 |
+
function marker(spec){if(typeof spec=="string"){var elt=document.createElement("div");elt.className=spec+" CodeMirror-guttermarker-subtle";return elt;}else{return spec.cloneNode(true);}}
|
11 |
+
function updateFoldInfo(cm,from,to){var opts=cm.state.foldGutter.options,cur=from;var minSize=cm.foldOption(opts,"minFoldSize");var func=cm.foldOption(opts,"rangeFinder");cm.eachLine(from,to,function(line){var mark=null;if(isFolded(cm,cur)){mark=marker(opts.indicatorFolded);}else{var pos=Pos(cur,0);var range=func&&func(cm,pos);if(range&&range.to.line-range.from.line>=minSize)
|
12 |
+
mark=marker(opts.indicatorOpen);}
|
13 |
+
cm.setGutterMarker(line,opts.gutter,mark);++cur;});}
|
14 |
+
function updateInViewport(cm){var vp=cm.getViewport(),state=cm.state.foldGutter;if(!state)return;cm.operation(function(){updateFoldInfo(cm,vp.from,vp.to);});state.from=vp.from;state.to=vp.to;}
|
15 |
+
function onGutterClick(cm,line,gutter){var state=cm.state.foldGutter;if(!state)return;var opts=state.options;if(gutter!=opts.gutter)return;var folded=isFolded(cm,line);if(folded)folded.clear();else cm.foldCode(Pos(line,0),opts.rangeFinder);}
|
16 |
+
function onChange(cm){var state=cm.state.foldGutter;if(!state)return;var opts=state.options;state.from=state.to=0;clearTimeout(state.changeUpdate);state.changeUpdate=setTimeout(function(){updateInViewport(cm);},opts.foldOnChangeTimeSpan||600);}
|
17 |
+
function onViewportChange(cm){var state=cm.state.foldGutter;if(!state)return;var opts=state.options;clearTimeout(state.changeUpdate);state.changeUpdate=setTimeout(function(){var vp=cm.getViewport();if(state.from==state.to||vp.from-state.to>20||state.from-vp.to>20){updateInViewport(cm);}else{cm.operation(function(){if(vp.from<state.from){updateFoldInfo(cm,vp.from,state.from);state.from=vp.from;}
|
18 |
+
if(vp.to>state.to){updateFoldInfo(cm,state.to,vp.to);state.to=vp.to;}});}},opts.updateViewportTimeSpan||400);}
|
19 |
+
function onFold(cm,from){var state=cm.state.foldGutter;if(!state)return;var line=from.line;if(line>=state.from&&line<state.to)
|
20 |
+
updateFoldInfo(cm,line,line+1);}});
|
lib/codemirror/addon/fold/indent-fold.js
ADDED
@@ -0,0 +1,44 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
|
15 |
+
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
|
16 |
+
if (!/\S/.test(firstLine)) return;
|
17 |
+
var getIndent = function(line) {
|
18 |
+
return CodeMirror.countColumn(line, null, tabSize);
|
19 |
+
};
|
20 |
+
var myIndent = getIndent(firstLine);
|
21 |
+
var lastLineInFold = null;
|
22 |
+
// Go through lines until we find a line that definitely doesn't belong in
|
23 |
+
// the block we're folding, or to the end.
|
24 |
+
for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {
|
25 |
+
var curLine = cm.getLine(i);
|
26 |
+
var curIndent = getIndent(curLine);
|
27 |
+
if (curIndent > myIndent) {
|
28 |
+
// Lines with a greater indent are considered part of the block.
|
29 |
+
lastLineInFold = i;
|
30 |
+
} else if (!/\S/.test(curLine)) {
|
31 |
+
// Empty lines might be breaks within the block we're trying to fold.
|
32 |
+
} else {
|
33 |
+
// A non-empty line at an indent equal to or less than ours marks the
|
34 |
+
// start of another block.
|
35 |
+
break;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
if (lastLineInFold) return {
|
39 |
+
from: CodeMirror.Pos(start.line, firstLine.length),
|
40 |
+
to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
|
41 |
+
};
|
42 |
+
});
|
43 |
+
|
44 |
+
});
|
lib/codemirror/addon/fold/indent-fold.min.js
ADDED
@@ -0,0 +1,6 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("fold","indent",function(cm,start){var tabSize=cm.getOption("tabSize"),firstLine=cm.getLine(start.line);if(!/\S/.test(firstLine))return;var getIndent=function(line){return CodeMirror.countColumn(line,null,tabSize);};var myIndent=getIndent(firstLine);var lastLineInFold=null;for(var i=start.line+1,end=cm.lastLine();i<=end;++i){var curLine=cm.getLine(i);var curIndent=getIndent(curLine);if(curIndent>myIndent){lastLineInFold=i;}else if(!/\S/.test(curLine)){}else{break;}}
|
6 |
+
if(lastLineInFold)return{from:CodeMirror.Pos(start.line,firstLine.length),to:CodeMirror.Pos(lastLineInFold,cm.getLine(lastLineInFold).length)};});});
|
lib/codemirror/addon/fold/markdown-fold.js
ADDED
@@ -0,0 +1,49 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
CodeMirror.registerHelper("fold", "markdown", function(cm, start) {
|
15 |
+
var maxDepth = 100;
|
16 |
+
|
17 |
+
function isHeader(lineNo) {
|
18 |
+
var tokentype = cm.getTokenTypeAt(CodeMirror.Pos(lineNo, 0));
|
19 |
+
return tokentype && /\bheader\b/.test(tokentype);
|
20 |
+
}
|
21 |
+
|
22 |
+
function headerLevel(lineNo, line, nextLine) {
|
23 |
+
var match = line && line.match(/^#+/);
|
24 |
+
if (match && isHeader(lineNo)) return match[0].length;
|
25 |
+
match = nextLine && nextLine.match(/^[=\-]+\s*$/);
|
26 |
+
if (match && isHeader(lineNo + 1)) return nextLine[0] == "=" ? 1 : 2;
|
27 |
+
return maxDepth;
|
28 |
+
}
|
29 |
+
|
30 |
+
var firstLine = cm.getLine(start.line), nextLine = cm.getLine(start.line + 1);
|
31 |
+
var level = headerLevel(start.line, firstLine, nextLine);
|
32 |
+
if (level === maxDepth) return undefined;
|
33 |
+
|
34 |
+
var lastLineNo = cm.lastLine();
|
35 |
+
var end = start.line, nextNextLine = cm.getLine(end + 2);
|
36 |
+
while (end < lastLineNo) {
|
37 |
+
if (headerLevel(end + 1, nextLine, nextNextLine) <= level) break;
|
38 |
+
++end;
|
39 |
+
nextLine = nextNextLine;
|
40 |
+
nextNextLine = cm.getLine(end + 2);
|
41 |
+
}
|
42 |
+
|
43 |
+
return {
|
44 |
+
from: CodeMirror.Pos(start.line, firstLine.length),
|
45 |
+
to: CodeMirror.Pos(end, cm.getLine(end).length)
|
46 |
+
};
|
47 |
+
});
|
48 |
+
|
49 |
+
});
|
lib/codemirror/addon/fold/markdown-fold.min.js
ADDED
@@ -0,0 +1,8 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("fold","markdown",function(cm,start){var maxDepth=100;function isHeader(lineNo){var tokentype=cm.getTokenTypeAt(CodeMirror.Pos(lineNo,0));return tokentype&&/\bheader\b/.test(tokentype);}
|
6 |
+
function headerLevel(lineNo,line,nextLine){var match=line&&line.match(/^#+/);if(match&&isHeader(lineNo))return match[0].length;match=nextLine&&nextLine.match(/^[=\-]+\s*$/);if(match&&isHeader(lineNo+1))return nextLine[0]=="="?1:2;return maxDepth;}
|
7 |
+
var firstLine=cm.getLine(start.line),nextLine=cm.getLine(start.line+1);var level=headerLevel(start.line,firstLine,nextLine);if(level===maxDepth)return undefined;var lastLineNo=cm.lastLine();var end=start.line,nextNextLine=cm.getLine(end+2);while(end<lastLineNo){if(headerLevel(end+1,nextLine,nextNextLine)<=level)break;++end;nextLine=nextNextLine;nextNextLine=cm.getLine(end+2);}
|
8 |
+
return{from:CodeMirror.Pos(start.line,firstLine.length),to:CodeMirror.Pos(end,cm.getLine(end).length)};});});
|
lib/codemirror/addon/fold/xml-fold.js
ADDED
@@ -0,0 +1,182 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var Pos = CodeMirror.Pos;
|
15 |
+
function cmp(a, b) { return a.line - b.line || a.ch - b.ch; }
|
16 |
+
|
17 |
+
var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
18 |
+
var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
19 |
+
var xmlTagStart = new RegExp("<(/?)([" + nameStartChar + "][" + nameChar + "]*)", "g");
|
20 |
+
|
21 |
+
function Iter(cm, line, ch, range) {
|
22 |
+
this.line = line; this.ch = ch;
|
23 |
+
this.cm = cm; this.text = cm.getLine(line);
|
24 |
+
this.min = range ? range.from : cm.firstLine();
|
25 |
+
this.max = range ? range.to - 1 : cm.lastLine();
|
26 |
+
}
|
27 |
+
|
28 |
+
function tagAt(iter, ch) {
|
29 |
+
var type = iter.cm.getTokenTypeAt(Pos(iter.line, ch));
|
30 |
+
return type && /\btag\b/.test(type);
|
31 |
+
}
|
32 |
+
|
33 |
+
function nextLine(iter) {
|
34 |
+
if (iter.line >= iter.max) return;
|
35 |
+
iter.ch = 0;
|
36 |
+
iter.text = iter.cm.getLine(++iter.line);
|
37 |
+
return true;
|
38 |
+
}
|
39 |
+
function prevLine(iter) {
|
40 |
+
if (iter.line <= iter.min) return;
|
41 |
+
iter.text = iter.cm.getLine(--iter.line);
|
42 |
+
iter.ch = iter.text.length;
|
43 |
+
return true;
|
44 |
+
}
|
45 |
+
|
46 |
+
function toTagEnd(iter) {
|
47 |
+
for (;;) {
|
48 |
+
var gt = iter.text.indexOf(">", iter.ch);
|
49 |
+
if (gt == -1) { if (nextLine(iter)) continue; else return; }
|
50 |
+
if (!tagAt(iter, gt + 1)) { iter.ch = gt + 1; continue; }
|
51 |
+
var lastSlash = iter.text.lastIndexOf("/", gt);
|
52 |
+
var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
|
53 |
+
iter.ch = gt + 1;
|
54 |
+
return selfClose ? "selfClose" : "regular";
|
55 |
+
}
|
56 |
+
}
|
57 |
+
function toTagStart(iter) {
|
58 |
+
for (;;) {
|
59 |
+
var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1;
|
60 |
+
if (lt == -1) { if (prevLine(iter)) continue; else return; }
|
61 |
+
if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; }
|
62 |
+
xmlTagStart.lastIndex = lt;
|
63 |
+
iter.ch = lt;
|
64 |
+
var match = xmlTagStart.exec(iter.text);
|
65 |
+
if (match && match.index == lt) return match;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
function toNextTag(iter) {
|
70 |
+
for (;;) {
|
71 |
+
xmlTagStart.lastIndex = iter.ch;
|
72 |
+
var found = xmlTagStart.exec(iter.text);
|
73 |
+
if (!found) { if (nextLine(iter)) continue; else return; }
|
74 |
+
if (!tagAt(iter, found.index + 1)) { iter.ch = found.index + 1; continue; }
|
75 |
+
iter.ch = found.index + found[0].length;
|
76 |
+
return found;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
function toPrevTag(iter) {
|
80 |
+
for (;;) {
|
81 |
+
var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1;
|
82 |
+
if (gt == -1) { if (prevLine(iter)) continue; else return; }
|
83 |
+
if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; }
|
84 |
+
var lastSlash = iter.text.lastIndexOf("/", gt);
|
85 |
+
var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
|
86 |
+
iter.ch = gt + 1;
|
87 |
+
return selfClose ? "selfClose" : "regular";
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
function findMatchingClose(iter, tag) {
|
92 |
+
var stack = [];
|
93 |
+
for (;;) {
|
94 |
+
var next = toNextTag(iter), end, startLine = iter.line, startCh = iter.ch - (next ? next[0].length : 0);
|
95 |
+
if (!next || !(end = toTagEnd(iter))) return;
|
96 |
+
if (end == "selfClose") continue;
|
97 |
+
if (next[1]) { // closing tag
|
98 |
+
for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == next[2]) {
|
99 |
+
stack.length = i;
|
100 |
+
break;
|
101 |
+
}
|
102 |
+
if (i < 0 && (!tag || tag == next[2])) return {
|
103 |
+
tag: next[2],
|
104 |
+
from: Pos(startLine, startCh),
|
105 |
+
to: Pos(iter.line, iter.ch)
|
106 |
+
};
|
107 |
+
} else { // opening tag
|
108 |
+
stack.push(next[2]);
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
function findMatchingOpen(iter, tag) {
|
113 |
+
var stack = [];
|
114 |
+
for (;;) {
|
115 |
+
var prev = toPrevTag(iter);
|
116 |
+
if (!prev) return;
|
117 |
+
if (prev == "selfClose") { toTagStart(iter); continue; }
|
118 |
+
var endLine = iter.line, endCh = iter.ch;
|
119 |
+
var start = toTagStart(iter);
|
120 |
+
if (!start) return;
|
121 |
+
if (start[1]) { // closing tag
|
122 |
+
stack.push(start[2]);
|
123 |
+
} else { // opening tag
|
124 |
+
for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == start[2]) {
|
125 |
+
stack.length = i;
|
126 |
+
break;
|
127 |
+
}
|
128 |
+
if (i < 0 && (!tag || tag == start[2])) return {
|
129 |
+
tag: start[2],
|
130 |
+
from: Pos(iter.line, iter.ch),
|
131 |
+
to: Pos(endLine, endCh)
|
132 |
+
};
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
CodeMirror.registerHelper("fold", "xml", function(cm, start) {
|
138 |
+
var iter = new Iter(cm, start.line, 0);
|
139 |
+
for (;;) {
|
140 |
+
var openTag = toNextTag(iter), end;
|
141 |
+
if (!openTag || iter.line != start.line || !(end = toTagEnd(iter))) return;
|
142 |
+
if (!openTag[1] && end != "selfClose") {
|
143 |
+
var start = Pos(iter.line, iter.ch);
|
144 |
+
var close = findMatchingClose(iter, openTag[2]);
|
145 |
+
return close && {from: start, to: close.from};
|
146 |
+
}
|
147 |
+
}
|
148 |
+
});
|
149 |
+
CodeMirror.findMatchingTag = function(cm, pos, range) {
|
150 |
+
var iter = new Iter(cm, pos.line, pos.ch, range);
|
151 |
+
if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return;
|
152 |
+
var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch);
|
153 |
+
var start = end && toTagStart(iter);
|
154 |
+
if (!end || !start || cmp(iter, pos) > 0) return;
|
155 |
+
var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]};
|
156 |
+
if (end == "selfClose") return {open: here, close: null, at: "open"};
|
157 |
+
|
158 |
+
if (start[1]) { // closing tag
|
159 |
+
return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"};
|
160 |
+
} else { // opening tag
|
161 |
+
iter = new Iter(cm, to.line, to.ch, range);
|
162 |
+
return {open: here, close: findMatchingClose(iter, start[2]), at: "open"};
|
163 |
+
}
|
164 |
+
};
|
165 |
+
|
166 |
+
CodeMirror.findEnclosingTag = function(cm, pos, range) {
|
167 |
+
var iter = new Iter(cm, pos.line, pos.ch, range);
|
168 |
+
for (;;) {
|
169 |
+
var open = findMatchingOpen(iter);
|
170 |
+
if (!open) break;
|
171 |
+
var forward = new Iter(cm, pos.line, pos.ch, range);
|
172 |
+
var close = findMatchingClose(forward, open.tag);
|
173 |
+
if (close) return {open: open, close: close};
|
174 |
+
}
|
175 |
+
};
|
176 |
+
|
177 |
+
// Used by addon/edit/closetag.js
|
178 |
+
CodeMirror.scanForClosingTag = function(cm, pos, name, end) {
|
179 |
+
var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null);
|
180 |
+
return findMatchingClose(iter, name);
|
181 |
+
};
|
182 |
+
});
|
lib/codemirror/addon/fold/xml-fold.min.js
ADDED
@@ -0,0 +1,27 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";var Pos=CodeMirror.Pos;function cmp(a,b){return a.line-b.line||a.ch-b.ch;}
|
6 |
+
var nameStartChar="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";var nameChar=nameStartChar+"\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";var xmlTagStart=new RegExp("<(/?)(["+nameStartChar+"]["+nameChar+"]*)","g");function Iter(cm,line,ch,range){this.line=line;this.ch=ch;this.cm=cm;this.text=cm.getLine(line);this.min=range?range.from:cm.firstLine();this.max=range?range.to-1:cm.lastLine();}
|
7 |
+
function tagAt(iter,ch){var type=iter.cm.getTokenTypeAt(Pos(iter.line,ch));return type&&/\btag\b/.test(type);}
|
8 |
+
function nextLine(iter){if(iter.line>=iter.max)return;iter.ch=0;iter.text=iter.cm.getLine(++iter.line);return true;}
|
9 |
+
function prevLine(iter){if(iter.line<=iter.min)return;iter.text=iter.cm.getLine(--iter.line);iter.ch=iter.text.length;return true;}
|
10 |
+
function toTagEnd(iter){for(;;){var gt=iter.text.indexOf(">",iter.ch);if(gt==-1){if(nextLine(iter))continue;else return;}
|
11 |
+
if(!tagAt(iter,gt+1)){iter.ch=gt+1;continue;}
|
12 |
+
var lastSlash=iter.text.lastIndexOf("/",gt);var selfClose=lastSlash>-1&&!/\S/.test(iter.text.slice(lastSlash+1,gt));iter.ch=gt+1;return selfClose?"selfClose":"regular";}}
|
13 |
+
function toTagStart(iter){for(;;){var lt=iter.ch?iter.text.lastIndexOf("<",iter.ch-1):-1;if(lt==-1){if(prevLine(iter))continue;else return;}
|
14 |
+
if(!tagAt(iter,lt+1)){iter.ch=lt;continue;}
|
15 |
+
xmlTagStart.lastIndex=lt;iter.ch=lt;var match=xmlTagStart.exec(iter.text);if(match&&match.index==lt)return match;}}
|
16 |
+
function toNextTag(iter){for(;;){xmlTagStart.lastIndex=iter.ch;var found=xmlTagStart.exec(iter.text);if(!found){if(nextLine(iter))continue;else return;}
|
17 |
+
if(!tagAt(iter,found.index+1)){iter.ch=found.index+1;continue;}
|
18 |
+
iter.ch=found.index+found[0].length;return found;}}
|
19 |
+
function toPrevTag(iter){for(;;){var gt=iter.ch?iter.text.lastIndexOf(">",iter.ch-1):-1;if(gt==-1){if(prevLine(iter))continue;else return;}
|
20 |
+
if(!tagAt(iter,gt+1)){iter.ch=gt;continue;}
|
21 |
+
var lastSlash=iter.text.lastIndexOf("/",gt);var selfClose=lastSlash>-1&&!/\S/.test(iter.text.slice(lastSlash+1,gt));iter.ch=gt+1;return selfClose?"selfClose":"regular";}}
|
22 |
+
function findMatchingClose(iter,tag){var stack=[];for(;;){var next=toNextTag(iter),end,startLine=iter.line,startCh=iter.ch-(next?next[0].length:0);if(!next||!(end=toTagEnd(iter)))return;if(end=="selfClose")continue;if(next[1]){for(var i=stack.length-1;i>=0;--i)if(stack[i]==next[2]){stack.length=i;break;}
|
23 |
+
if(i<0&&(!tag||tag==next[2]))return{tag:next[2],from:Pos(startLine,startCh),to:Pos(iter.line,iter.ch)};}else{stack.push(next[2]);}}}
|
24 |
+
function findMatchingOpen(iter,tag){var stack=[];for(;;){var prev=toPrevTag(iter);if(!prev)return;if(prev=="selfClose"){toTagStart(iter);continue;}
|
25 |
+
var endLine=iter.line,endCh=iter.ch;var start=toTagStart(iter);if(!start)return;if(start[1]){stack.push(start[2]);}else{for(var i=stack.length-1;i>=0;--i)if(stack[i]==start[2]){stack.length=i;break;}
|
26 |
+
if(i<0&&(!tag||tag==start[2]))return{tag:start[2],from:Pos(iter.line,iter.ch),to:Pos(endLine,endCh)};}}}
|
27 |
+
CodeMirror.registerHelper("fold","xml",function(cm,start){var iter=new Iter(cm,start.line,0);for(;;){var openTag=toNextTag(iter),end;if(!openTag||iter.line!=start.line||!(end=toTagEnd(iter)))return;if(!openTag[1]&&end!="selfClose"){var start=Pos(iter.line,iter.ch);var close=findMatchingClose(iter,openTag[2]);return close&&{from:start,to:close.from};}}});CodeMirror.findMatchingTag=function(cm,pos,range){var iter=new Iter(cm,pos.line,pos.ch,range);if(iter.text.indexOf(">")==-1&&iter.text.indexOf("<")==-1)return;var end=toTagEnd(iter),to=end&&Pos(iter.line,iter.ch);var start=end&&toTagStart(iter);if(!end||!start||cmp(iter,pos)>0)return;var here={from:Pos(iter.line,iter.ch),to:to,tag:start[2]};if(end=="selfClose")return{open:here,close:null,at:"open"};if(start[1]){return{open:findMatchingOpen(iter,start[2]),close:here,at:"close"};}else{iter=new Iter(cm,to.line,to.ch,range);return{open:here,close:findMatchingClose(iter,start[2]),at:"open"};}};CodeMirror.findEnclosingTag=function(cm,pos,range){var iter=new Iter(cm,pos.line,pos.ch,range);for(;;){var open=findMatchingOpen(iter);if(!open)break;var forward=new Iter(cm,pos.line,pos.ch,range);var close=findMatchingClose(forward,open.tag);if(close)return{open:open,close:close};}};CodeMirror.scanForClosingTag=function(cm,pos,name,end){var iter=new Iter(cm,pos.line,pos.ch,end?{from:0,to:end}:null);return findMatchingClose(iter,name);};});
|
lib/codemirror/addon/hint/anyword-hint.js
ADDED
@@ -0,0 +1,41 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var WORD = /[\w$]+/, RANGE = 500;
|
15 |
+
|
16 |
+
CodeMirror.registerHelper("hint", "anyword", function(editor, options) {
|
17 |
+
var word = options && options.word || WORD;
|
18 |
+
var range = options && options.range || RANGE;
|
19 |
+
var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
|
20 |
+
var end = cur.ch, start = end;
|
21 |
+
while (start && word.test(curLine.charAt(start - 1))) --start;
|
22 |
+
var curWord = start != end && curLine.slice(start, end);
|
23 |
+
|
24 |
+
var list = [], seen = {};
|
25 |
+
var re = new RegExp(word.source, "g");
|
26 |
+
for (var dir = -1; dir <= 1; dir += 2) {
|
27 |
+
var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
|
28 |
+
for (; line != endLine; line += dir) {
|
29 |
+
var text = editor.getLine(line), m;
|
30 |
+
while (m = re.exec(text)) {
|
31 |
+
if (line == cur.line && m[0] === curWord) continue;
|
32 |
+
if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) {
|
33 |
+
seen[m[0]] = true;
|
34 |
+
list.push(m[0]);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)};
|
40 |
+
});
|
41 |
+
});
|
lib/codemirror/addon/hint/anyword-hint.min.js
ADDED
@@ -0,0 +1,6 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";var WORD=/[\w$]+/,RANGE=500;CodeMirror.registerHelper("hint","anyword",function(editor,options){var word=options&&options.word||WORD;var range=options&&options.range||RANGE;var cur=editor.getCursor(),curLine=editor.getLine(cur.line);var end=cur.ch,start=end;while(start&&word.test(curLine.charAt(start-1)))--start;var curWord=start!=end&&curLine.slice(start,end);var list=[],seen={};var re=new RegExp(word.source,"g");for(var dir=-1;dir<=1;dir+=2){var line=cur.line,endLine=Math.min(Math.max(line+dir*range,editor.firstLine()),editor.lastLine())+dir;for(;line!=endLine;line+=dir){var text=editor.getLine(line),m;while(m=re.exec(text)){if(line==cur.line&&m[0]===curWord)continue;if((!curWord||m[0].lastIndexOf(curWord,0)==0)&&!Object.prototype.hasOwnProperty.call(seen,m[0])){seen[m[0]]=true;list.push(m[0]);}}}}
|
6 |
+
return{list:list,from:CodeMirror.Pos(cur.line,start),to:CodeMirror.Pos(cur.line,end)};});});
|
lib/codemirror/addon/hint/css-hint.js
ADDED
@@ -0,0 +1,60 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"), require("../../mode/css/css"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror", "../../mode/css/css"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var pseudoClasses = {link: 1, visited: 1, active: 1, hover: 1, focus: 1,
|
15 |
+
"first-letter": 1, "first-line": 1, "first-child": 1,
|
16 |
+
before: 1, after: 1, lang: 1};
|
17 |
+
|
18 |
+
CodeMirror.registerHelper("hint", "css", function(cm) {
|
19 |
+
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
20 |
+
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
|
21 |
+
if (inner.mode.name != "css") return;
|
22 |
+
|
23 |
+
if (token.type == "keyword" && "!important".indexOf(token.string) == 0)
|
24 |
+
return {list: ["!important"], from: CodeMirror.Pos(cur.line, token.start),
|
25 |
+
to: CodeMirror.Pos(cur.line, token.end)};
|
26 |
+
|
27 |
+
var start = token.start, end = cur.ch, word = token.string.slice(0, end - start);
|
28 |
+
if (/[^\w$_-]/.test(word)) {
|
29 |
+
word = ""; start = end = cur.ch;
|
30 |
+
}
|
31 |
+
|
32 |
+
var spec = CodeMirror.resolveMode("text/css");
|
33 |
+
|
34 |
+
var result = [];
|
35 |
+
function add(keywords) {
|
36 |
+
for (var name in keywords)
|
37 |
+
if (!word || name.lastIndexOf(word, 0) == 0)
|
38 |
+
result.push(name);
|
39 |
+
}
|
40 |
+
|
41 |
+
var st = inner.state.state;
|
42 |
+
if (st == "pseudo" || token.type == "variable-3") {
|
43 |
+
add(pseudoClasses);
|
44 |
+
} else if (st == "block" || st == "maybeprop") {
|
45 |
+
add(spec.propertyKeywords);
|
46 |
+
} else if (st == "prop" || st == "parens" || st == "at" || st == "params") {
|
47 |
+
add(spec.valueKeywords);
|
48 |
+
add(spec.colorKeywords);
|
49 |
+
} else if (st == "media" || st == "media_parens") {
|
50 |
+
add(spec.mediaTypes);
|
51 |
+
add(spec.mediaFeatures);
|
52 |
+
}
|
53 |
+
|
54 |
+
if (result.length) return {
|
55 |
+
list: result,
|
56 |
+
from: CodeMirror.Pos(cur.line, start),
|
57 |
+
to: CodeMirror.Pos(cur.line, end)
|
58 |
+
};
|
59 |
+
});
|
60 |
+
});
|
lib/codemirror/addon/hint/css-hint.min.js
ADDED
@@ -0,0 +1,11 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"),require("../../mode/css/css"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror","../../mode/css/css"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";var pseudoClasses={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(cm){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(inner.mode.name!="css")return;if(token.type=="keyword"&&"!important".indexOf(token.string)==0)
|
6 |
+
return{list:["!important"],from:CodeMirror.Pos(cur.line,token.start),to:CodeMirror.Pos(cur.line,token.end)};var start=token.start,end=cur.ch,word=token.string.slice(0,end-start);if(/[^\w$_-]/.test(word)){word="";start=end=cur.ch;}
|
7 |
+
var spec=CodeMirror.resolveMode("text/css");var result=[];function add(keywords){for(var name in keywords)
|
8 |
+
if(!word||name.lastIndexOf(word,0)==0)
|
9 |
+
result.push(name);}
|
10 |
+
var st=inner.state.state;if(st=="pseudo"||token.type=="variable-3"){add(pseudoClasses);}else if(st=="block"||st=="maybeprop"){add(spec.propertyKeywords);}else if(st=="prop"||st=="parens"||st=="at"||st=="params"){add(spec.valueKeywords);add(spec.colorKeywords);}else if(st=="media"||st=="media_parens"){add(spec.mediaTypes);add(spec.mediaFeatures);}
|
11 |
+
if(result.length)return{list:result,from:CodeMirror.Pos(cur.line,start),to:CodeMirror.Pos(cur.line,end)};});});
|
lib/codemirror/addon/hint/html-hint.js
ADDED
@@ -0,0 +1,348 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"), require("./xml-hint"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror", "./xml-hint"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var langs = "ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" ");
|
15 |
+
var targets = ["_blank", "_self", "_top", "_parent"];
|
16 |
+
var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"];
|
17 |
+
var methods = ["get", "post", "put", "delete"];
|
18 |
+
var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"];
|
19 |
+
var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech",
|
20 |
+
"3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait",
|
21 |
+
"orientation:landscape", "device-height: [X]", "device-width: [X]"];
|
22 |
+
var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags
|
23 |
+
|
24 |
+
var data = {
|
25 |
+
a: {
|
26 |
+
attrs: {
|
27 |
+
href: null, ping: null, type: null,
|
28 |
+
media: media,
|
29 |
+
target: targets,
|
30 |
+
hreflang: langs
|
31 |
+
}
|
32 |
+
},
|
33 |
+
abbr: s,
|
34 |
+
acronym: s,
|
35 |
+
address: s,
|
36 |
+
applet: s,
|
37 |
+
area: {
|
38 |
+
attrs: {
|
39 |
+
alt: null, coords: null, href: null, target: null, ping: null,
|
40 |
+
media: media, hreflang: langs, type: null,
|
41 |
+
shape: ["default", "rect", "circle", "poly"]
|
42 |
+
}
|
43 |
+
},
|
44 |
+
article: s,
|
45 |
+
aside: s,
|
46 |
+
audio: {
|
47 |
+
attrs: {
|
48 |
+
src: null, mediagroup: null,
|
49 |
+
crossorigin: ["anonymous", "use-credentials"],
|
50 |
+
preload: ["none", "metadata", "auto"],
|
51 |
+
autoplay: ["", "autoplay"],
|
52 |
+
loop: ["", "loop"],
|
53 |
+
controls: ["", "controls"]
|
54 |
+
}
|
55 |
+
},
|
56 |
+
b: s,
|
57 |
+
base: { attrs: { href: null, target: targets } },
|
58 |
+
basefont: s,
|
59 |
+
bdi: s,
|
60 |
+
bdo: s,
|
61 |
+
big: s,
|
62 |
+
blockquote: { attrs: { cite: null } },
|
63 |
+
body: s,
|
64 |
+
br: s,
|
65 |
+
button: {
|
66 |
+
attrs: {
|
67 |
+
form: null, formaction: null, name: null, value: null,
|
68 |
+
autofocus: ["", "autofocus"],
|
69 |
+
disabled: ["", "autofocus"],
|
70 |
+
formenctype: encs,
|
71 |
+
formmethod: methods,
|
72 |
+
formnovalidate: ["", "novalidate"],
|
73 |
+
formtarget: targets,
|
74 |
+
type: ["submit", "reset", "button"]
|
75 |
+
}
|
76 |
+
},
|
77 |
+
canvas: { attrs: { width: null, height: null } },
|
78 |
+
caption: s,
|
79 |
+
center: s,
|
80 |
+
cite: s,
|
81 |
+
code: s,
|
82 |
+
col: { attrs: { span: null } },
|
83 |
+
colgroup: { attrs: { span: null } },
|
84 |
+
command: {
|
85 |
+
attrs: {
|
86 |
+
type: ["command", "checkbox", "radio"],
|
87 |
+
label: null, icon: null, radiogroup: null, command: null, title: null,
|
88 |
+
disabled: ["", "disabled"],
|
89 |
+
checked: ["", "checked"]
|
90 |
+
}
|
91 |
+
},
|
92 |
+
data: { attrs: { value: null } },
|
93 |
+
datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } },
|
94 |
+
datalist: { attrs: { data: null } },
|
95 |
+
dd: s,
|
96 |
+
del: { attrs: { cite: null, datetime: null } },
|
97 |
+
details: { attrs: { open: ["", "open"] } },
|
98 |
+
dfn: s,
|
99 |
+
dir: s,
|
100 |
+
div: s,
|
101 |
+
dl: s,
|
102 |
+
dt: s,
|
103 |
+
em: s,
|
104 |
+
embed: { attrs: { src: null, type: null, width: null, height: null } },
|
105 |
+
eventsource: { attrs: { src: null } },
|
106 |
+
fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } },
|
107 |
+
figcaption: s,
|
108 |
+
figure: s,
|
109 |
+
font: s,
|
110 |
+
footer: s,
|
111 |
+
form: {
|
112 |
+
attrs: {
|
113 |
+
action: null, name: null,
|
114 |
+
"accept-charset": charsets,
|
115 |
+
autocomplete: ["on", "off"],
|
116 |
+
enctype: encs,
|
117 |
+
method: methods,
|
118 |
+
novalidate: ["", "novalidate"],
|
119 |
+
target: targets
|
120 |
+
}
|
121 |
+
},
|
122 |
+
frame: s,
|
123 |
+
frameset: s,
|
124 |
+
h1: s, h2: s, h3: s, h4: s, h5: s, h6: s,
|
125 |
+
head: {
|
126 |
+
attrs: {},
|
127 |
+
children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
|
128 |
+
},
|
129 |
+
header: s,
|
130 |
+
hgroup: s,
|
131 |
+
hr: s,
|
132 |
+
html: {
|
133 |
+
attrs: { manifest: null },
|
134 |
+
children: ["head", "body"]
|
135 |
+
},
|
136 |
+
i: s,
|
137 |
+
iframe: {
|
138 |
+
attrs: {
|
139 |
+
src: null, srcdoc: null, name: null, width: null, height: null,
|
140 |
+
sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
|
141 |
+
seamless: ["", "seamless"]
|
142 |
+
}
|
143 |
+
},
|
144 |
+
img: {
|
145 |
+
attrs: {
|
146 |
+
alt: null, src: null, ismap: null, usemap: null, width: null, height: null,
|
147 |
+
crossorigin: ["anonymous", "use-credentials"]
|
148 |
+
}
|
149 |
+
},
|
150 |
+
input: {
|
151 |
+
attrs: {
|
152 |
+
alt: null, dirname: null, form: null, formaction: null,
|
153 |
+
height: null, list: null, max: null, maxlength: null, min: null,
|
154 |
+
name: null, pattern: null, placeholder: null, size: null, src: null,
|
155 |
+
step: null, value: null, width: null,
|
156 |
+
accept: ["audio/*", "video/*", "image/*"],
|
157 |
+
autocomplete: ["on", "off"],
|
158 |
+
autofocus: ["", "autofocus"],
|
159 |
+
checked: ["", "checked"],
|
160 |
+
disabled: ["", "disabled"],
|
161 |
+
formenctype: encs,
|
162 |
+
formmethod: methods,
|
163 |
+
formnovalidate: ["", "novalidate"],
|
164 |
+
formtarget: targets,
|
165 |
+
multiple: ["", "multiple"],
|
166 |
+
readonly: ["", "readonly"],
|
167 |
+
required: ["", "required"],
|
168 |
+
type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month",
|
169 |
+
"week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
|
170 |
+
"file", "submit", "image", "reset", "button"]
|
171 |
+
}
|
172 |
+
},
|
173 |
+
ins: { attrs: { cite: null, datetime: null } },
|
174 |
+
kbd: s,
|
175 |
+
keygen: {
|
176 |
+
attrs: {
|
177 |
+
challenge: null, form: null, name: null,
|
178 |
+
autofocus: ["", "autofocus"],
|
179 |
+
disabled: ["", "disabled"],
|
180 |
+
keytype: ["RSA"]
|
181 |
+
}
|
182 |
+
},
|
183 |
+
label: { attrs: { "for": null, form: null } },
|
184 |
+
legend: s,
|
185 |
+
li: { attrs: { value: null } },
|
186 |
+
link: {
|
187 |
+
attrs: {
|
188 |
+
href: null, type: null,
|
189 |
+
hreflang: langs,
|
190 |
+
media: media,
|
191 |
+
sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
|
192 |
+
}
|
193 |
+
},
|
194 |
+
map: { attrs: { name: null } },
|
195 |
+
mark: s,
|
196 |
+
menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
|
197 |
+
meta: {
|
198 |
+
attrs: {
|
199 |
+
content: null,
|
200 |
+
charset: charsets,
|
201 |
+
name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
|
202 |
+
"http-equiv": ["content-language", "content-type", "default-style", "refresh"]
|
203 |
+
}
|
204 |
+
},
|
205 |
+
meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
|
206 |
+
nav: s,
|
207 |
+
noframes: s,
|
208 |
+
noscript: s,
|
209 |
+
object: {
|
210 |
+
attrs: {
|
211 |
+
data: null, type: null, name: null, usemap: null, form: null, width: null, height: null,
|
212 |
+
typemustmatch: ["", "typemustmatch"]
|
213 |
+
}
|
214 |
+
},
|
215 |
+
ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } },
|
216 |
+
optgroup: { attrs: { disabled: ["", "disabled"], label: null } },
|
217 |
+
option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } },
|
218 |
+
output: { attrs: { "for": null, form: null, name: null } },
|
219 |
+
p: s,
|
220 |
+
param: { attrs: { name: null, value: null } },
|
221 |
+
pre: s,
|
222 |
+
progress: { attrs: { value: null, max: null } },
|
223 |
+
q: { attrs: { cite: null } },
|
224 |
+
rp: s,
|
225 |
+
rt: s,
|
226 |
+
ruby: s,
|
227 |
+
s: s,
|
228 |
+
samp: s,
|
229 |
+
script: {
|
230 |
+
attrs: {
|
231 |
+
type: ["text/javascript"],
|
232 |
+
src: null,
|
233 |
+
async: ["", "async"],
|
234 |
+
defer: ["", "defer"],
|
235 |
+
charset: charsets
|
236 |
+
}
|
237 |
+
},
|
238 |
+
section: s,
|
239 |
+
select: {
|
240 |
+
attrs: {
|
241 |
+
form: null, name: null, size: null,
|
242 |
+
autofocus: ["", "autofocus"],
|
243 |
+
disabled: ["", "disabled"],
|
244 |
+
multiple: ["", "multiple"]
|
245 |
+
}
|
246 |
+
},
|
247 |
+
small: s,
|
248 |
+
source: { attrs: { src: null, type: null, media: null } },
|
249 |
+
span: s,
|
250 |
+
strike: s,
|
251 |
+
strong: s,
|
252 |
+
style: {
|
253 |
+
attrs: {
|
254 |
+
type: ["text/css"],
|
255 |
+
media: media,
|
256 |
+
scoped: null
|
257 |
+
}
|
258 |
+
},
|
259 |
+
sub: s,
|
260 |
+
summary: s,
|
261 |
+
sup: s,
|
262 |
+
table: s,
|
263 |
+
tbody: s,
|
264 |
+
td: { attrs: { colspan: null, rowspan: null, headers: null } },
|
265 |
+
textarea: {
|
266 |
+
attrs: {
|
267 |
+
dirname: null, form: null, maxlength: null, name: null, placeholder: null,
|
268 |
+
rows: null, cols: null,
|
269 |
+
autofocus: ["", "autofocus"],
|
270 |
+
disabled: ["", "disabled"],
|
271 |
+
readonly: ["", "readonly"],
|
272 |
+
required: ["", "required"],
|
273 |
+
wrap: ["soft", "hard"]
|
274 |
+
}
|
275 |
+
},
|
276 |
+
tfoot: s,
|
277 |
+
th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
|
278 |
+
thead: s,
|
279 |
+
time: { attrs: { datetime: null } },
|
280 |
+
title: s,
|
281 |
+
tr: s,
|
282 |
+
track: {
|
283 |
+
attrs: {
|
284 |
+
src: null, label: null, "default": null,
|
285 |
+
kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
|
286 |
+
srclang: langs
|
287 |
+
}
|
288 |
+
},
|
289 |
+
tt: s,
|
290 |
+
u: s,
|
291 |
+
ul: s,
|
292 |
+
"var": s,
|
293 |
+
video: {
|
294 |
+
attrs: {
|
295 |
+
src: null, poster: null, width: null, height: null,
|
296 |
+
crossorigin: ["anonymous", "use-credentials"],
|
297 |
+
preload: ["auto", "metadata", "none"],
|
298 |
+
autoplay: ["", "autoplay"],
|
299 |
+
mediagroup: ["movie"],
|
300 |
+
muted: ["", "muted"],
|
301 |
+
controls: ["", "controls"]
|
302 |
+
}
|
303 |
+
},
|
304 |
+
wbr: s
|
305 |
+
};
|
306 |
+
|
307 |
+
var globalAttrs = {
|
308 |
+
accesskey: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
|
309 |
+
"class": null,
|
310 |
+
contenteditable: ["true", "false"],
|
311 |
+
contextmenu: null,
|
312 |
+
dir: ["ltr", "rtl", "auto"],
|
313 |
+
draggable: ["true", "false", "auto"],
|
314 |
+
dropzone: ["copy", "move", "link", "string:", "file:"],
|
315 |
+
hidden: ["hidden"],
|
316 |
+
id: null,
|
317 |
+
inert: ["inert"],
|
318 |
+
itemid: null,
|
319 |
+
itemprop: null,
|
320 |
+
itemref: null,
|
321 |
+
itemscope: ["itemscope"],
|
322 |
+
itemtype: null,
|
323 |
+
lang: ["en", "es"],
|
324 |
+
spellcheck: ["true", "false"],
|
325 |
+
style: null,
|
326 |
+
tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
|
327 |
+
title: null,
|
328 |
+
translate: ["yes", "no"],
|
329 |
+
onclick: null,
|
330 |
+
rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"]
|
331 |
+
};
|
332 |
+
function populate(obj) {
|
333 |
+
for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr))
|
334 |
+
obj.attrs[attr] = globalAttrs[attr];
|
335 |
+
}
|
336 |
+
|
337 |
+
populate(s);
|
338 |
+
for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s)
|
339 |
+
populate(data[tag]);
|
340 |
+
|
341 |
+
CodeMirror.htmlSchema = data;
|
342 |
+
function htmlHint(cm, options) {
|
343 |
+
var local = {schemaInfo: data};
|
344 |
+
if (options) for (var opt in options) local[opt] = options[opt];
|
345 |
+
return CodeMirror.hint.xml(cm, local);
|
346 |
+
}
|
347 |
+
CodeMirror.registerHelper("hint", "html", htmlHint);
|
348 |
+
});
|
lib/codemirror/addon/hint/html-hint.min.js
ADDED
@@ -0,0 +1,9 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"),require("./xml-hint"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror","./xml-hint"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";var langs="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" ");var targets=["_blank","_self","_top","_parent"];var charsets=["ascii","utf-8","utf-16","latin1","latin1"];var methods=["get","post","put","delete"];var encs=["application/x-www-form-urlencoded","multipart/form-data","text/plain"];var media=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"];var s={attrs:{}};var data={a:{attrs:{href:null,ping:null,type:null,media:media,target:targets,hreflang:langs}},abbr:s,acronym:s,address:s,applet:s,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:media,hreflang:langs,type:null,shape:["default","rect","circle","poly"]}},article:s,aside:s,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:s,base:{attrs:{href:null,target:targets}},basefont:s,bdi:s,bdo:s,big:s,blockquote:{attrs:{cite:null}},body:s,br:s,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:encs,formmethod:methods,formnovalidate:["","novalidate"],formtarget:targets,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:s,center:s,cite:s,code:s,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:s,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:s,dir:s,div:s,dl:s,dt:s,em:s,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:s,figure:s,font:s,footer:s,form:{attrs:{action:null,name:null,"accept-charset":charsets,autocomplete:["on","off"],enctype:encs,method:methods,novalidate:["","novalidate"],target:targets}},frame:s,frameset:s,h1:s,h2:s,h3:s,h4:s,h5:s,h6:s,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:s,hgroup:s,hr:s,html:{attrs:{manifest:null},children:["head","body"]},i:s,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:encs,formmethod:methods,formnovalidate:["","novalidate"],formtarget:targets,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:s,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{"for":null,form:null}},legend:s,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:langs,media:media,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:s,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:charsets,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:s,noframes:s,noscript:s,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{"for":null,form:null,name:null}},p:s,param:{attrs:{name:null,value:null}},pre:s,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:s,rt:s,ruby:s,s:s,samp:s,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:charsets}},section:s,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:s,source:{attrs:{src:null,type:null,media:null}},span:s,strike:s,strong:s,style:{attrs:{type:["text/css"],media:media,scoped:null}},sub:s,summary:s,sup:s,table:s,tbody:s,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:s,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:s,time:{attrs:{datetime:null}},title:s,tr:s,track:{attrs:{src:null,label:null,"default":null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:langs}},tt:s,u:s,ul:s,"var":s,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:s};var globalAttrs={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],"class":null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};function populate(obj){for(var attr in globalAttrs)if(globalAttrs.hasOwnProperty(attr))
|
6 |
+
obj.attrs[attr]=globalAttrs[attr];}
|
7 |
+
populate(s);for(var tag in data)if(data.hasOwnProperty(tag)&&data[tag]!=s)
|
8 |
+
populate(data[tag]);CodeMirror.htmlSchema=data;function htmlHint(cm,options){var local={schemaInfo:data};if(options)for(var opt in options)local[opt]=options[opt];return CodeMirror.hint.xml(cm,local);}
|
9 |
+
CodeMirror.registerHelper("hint","html",htmlHint);});
|
lib/codemirror/addon/hint/javascript-hint.js
ADDED
@@ -0,0 +1,146 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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&& typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
var Pos = CodeMirror.Pos;
|
13 |
+
|
14 |
+
function forEach(arr, f) {
|
15 |
+
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
16 |
+
}
|
17 |
+
|
18 |
+
function arrayContains(arr, item) {
|
19 |
+
if (!Array.prototype.indexOf) {
|
20 |
+
var i = arr.length;
|
21 |
+
while (i--) {
|
22 |
+
if (arr[i] === item) {
|
23 |
+
return true;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
return false;
|
27 |
+
}
|
28 |
+
return arr.indexOf(item) != -1;
|
29 |
+
}
|
30 |
+
|
31 |
+
function scriptHint(editor, keywords, getToken, options) {
|
32 |
+
// Find the token at the cursor
|
33 |
+
var cur = editor.getCursor(), token = getToken(editor, cur);
|
34 |
+
if (/\b(?:string|comment)\b/.test(token.type)) return;
|
35 |
+
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
|
36 |
+
|
37 |
+
// If it's not a 'word-style' token, ignore the token.
|
38 |
+
if (!/^[\w$_]*$/.test(token.string)) {
|
39 |
+
token = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
40 |
+
type: token.string == "." ? "property" : null};
|
41 |
+
} else if (token.end > cur.ch) {
|
42 |
+
token.end = cur.ch;
|
43 |
+
token.string = token.string.slice(0, cur.ch - token.start);
|
44 |
+
}
|
45 |
+
|
46 |
+
var tprop = token;
|
47 |
+
// If it is a property, find out what it is a property of.
|
48 |
+
while (tprop.type == "property") {
|
49 |
+
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
50 |
+
if (tprop.string != ".") return;
|
51 |
+
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
52 |
+
if (!context) var context = [];
|
53 |
+
context.push(tprop);
|
54 |
+
}
|
55 |
+
return {list: getCompletions(token, context, keywords, options),
|
56 |
+
from: Pos(cur.line, token.start),
|
57 |
+
to: Pos(cur.line, token.end)};
|
58 |
+
}
|
59 |
+
|
60 |
+
function javascriptHint(editor, options) {
|
61 |
+
return scriptHint(editor, javascriptKeywords,
|
62 |
+
function (e, cur) {return e.getTokenAt(cur);},
|
63 |
+
options);
|
64 |
+
};
|
65 |
+
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
|
66 |
+
|
67 |
+
function getCoffeeScriptToken(editor, cur) {
|
68 |
+
// This getToken, it is for coffeescript, imitates the behavior of
|
69 |
+
// getTokenAt method in javascript.js, that is, returning "property"
|
70 |
+
// type and treat "." as indepenent token.
|
71 |
+
var token = editor.getTokenAt(cur);
|
72 |
+
if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
|
73 |
+
token.end = token.start;
|
74 |
+
token.string = '.';
|
75 |
+
token.type = "property";
|
76 |
+
}
|
77 |
+
else if (/^\.[\w$_]*$/.test(token.string)) {
|
78 |
+
token.type = "property";
|
79 |
+
token.start++;
|
80 |
+
token.string = token.string.replace(/\./, '');
|
81 |
+
}
|
82 |
+
return token;
|
83 |
+
}
|
84 |
+
|
85 |
+
function coffeescriptHint(editor, options) {
|
86 |
+
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
|
87 |
+
}
|
88 |
+
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
|
89 |
+
|
90 |
+
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
|
91 |
+
"toUpperCase toLowerCase split concat match replace search").split(" ");
|
92 |
+
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
|
93 |
+
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
|
94 |
+
var funcProps = "prototype apply call bind".split(" ");
|
95 |
+
var javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
|
96 |
+
"if in instanceof new null return switch throw true try typeof var void while with").split(" ");
|
97 |
+
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
98 |
+
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
99 |
+
|
100 |
+
function getCompletions(token, context, keywords, options) {
|
101 |
+
var found = [], start = token.string, global = options && options.globalScope || window;
|
102 |
+
function maybeAdd(str) {
|
103 |
+
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
|
104 |
+
}
|
105 |
+
function gatherCompletions(obj) {
|
106 |
+
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
107 |
+
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
108 |
+
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
109 |
+
for (var name in obj) maybeAdd(name);
|
110 |
+
}
|
111 |
+
|
112 |
+
if (context && context.length) {
|
113 |
+
// If this is a property, see if it belongs to some object we can
|
114 |
+
// find in the current environment.
|
115 |
+
var obj = context.pop(), base;
|
116 |
+
if (obj.type && obj.type.indexOf("variable") === 0) {
|
117 |
+
if (options && options.additionalContext)
|
118 |
+
base = options.additionalContext[obj.string];
|
119 |
+
if (!options || options.useGlobalScope !== false)
|
120 |
+
base = base || global[obj.string];
|
121 |
+
} else if (obj.type == "string") {
|
122 |
+
base = "";
|
123 |
+
} else if (obj.type == "atom") {
|
124 |
+
base = 1;
|
125 |
+
} else if (obj.type == "function") {
|
126 |
+
if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
127 |
+
(typeof global.jQuery == 'function'))
|
128 |
+
base = global.jQuery();
|
129 |
+
else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function'))
|
130 |
+
base = global._();
|
131 |
+
}
|
132 |
+
while (base != null && context.length)
|
133 |
+
base = base[context.pop().string];
|
134 |
+
if (base != null) gatherCompletions(base);
|
135 |
+
} else {
|
136 |
+
// If not, just look in the global object and any local scope
|
137 |
+
// (reading into JS mode internals to get at the local and global variables)
|
138 |
+
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
|
139 |
+
for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
|
140 |
+
if (!options || options.useGlobalScope !== false)
|
141 |
+
gatherCompletions(global);
|
142 |
+
forEach(keywords, maybeAdd);
|
143 |
+
}
|
144 |
+
return found;
|
145 |
+
}
|
146 |
+
});
|
lib/codemirror/addon/hint/javascript-hint.min.js
ADDED
@@ -0,0 +1,26 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){var Pos=CodeMirror.Pos;function forEach(arr,f){for(var i=0,e=arr.length;i<e;++i)f(arr[i]);}
|
6 |
+
function arrayContains(arr,item){if(!Array.prototype.indexOf){var i=arr.length;while(i--){if(arr[i]===item){return true;}}
|
7 |
+
return false;}
|
8 |
+
return arr.indexOf(item)!=-1;}
|
9 |
+
function scriptHint(editor,keywords,getToken,options){var cur=editor.getCursor(),token=getToken(editor,cur);if(/\b(?:string|comment)\b/.test(token.type))return;token.state=CodeMirror.innerMode(editor.getMode(),token.state).state;if(!/^[\w$_]*$/.test(token.string)){token={start:cur.ch,end:cur.ch,string:"",state:token.state,type:token.string=="."?"property":null};}else if(token.end>cur.ch){token.end=cur.ch;token.string=token.string.slice(0,cur.ch-token.start);}
|
10 |
+
var tprop=token;while(tprop.type=="property"){tprop=getToken(editor,Pos(cur.line,tprop.start));if(tprop.string!=".")return;tprop=getToken(editor,Pos(cur.line,tprop.start));if(!context)var context=[];context.push(tprop);}
|
11 |
+
return{list:getCompletions(token,context,keywords,options),from:Pos(cur.line,token.start),to:Pos(cur.line,token.end)};}
|
12 |
+
function javascriptHint(editor,options){return scriptHint(editor,javascriptKeywords,function(e,cur){return e.getTokenAt(cur);},options);};CodeMirror.registerHelper("hint","javascript",javascriptHint);function getCoffeeScriptToken(editor,cur){var token=editor.getTokenAt(cur);if(cur.ch==token.start+1&&token.string.charAt(0)=='.'){token.end=token.start;token.string='.';token.type="property";}
|
13 |
+
else if(/^\.[\w$_]*$/.test(token.string)){token.type="property";token.start++;token.string=token.string.replace(/\./,'');}
|
14 |
+
return token;}
|
15 |
+
function coffeescriptHint(editor,options){return scriptHint(editor,coffeescriptKeywords,getCoffeeScriptToken,options);}
|
16 |
+
CodeMirror.registerHelper("hint","coffeescript",coffeescriptHint);var stringProps=("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight "+"toUpperCase toLowerCase split concat match replace search").split(" ");var arrayProps=("length concat join splice push pop shift unshift slice reverse sort indexOf "+"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");var funcProps="prototype apply call bind".split(" ");var javascriptKeywords=("break case catch continue debugger default delete do else false finally for function "+"if in instanceof new null return switch throw true try typeof var void while with").split(" ");var coffeescriptKeywords=("and break catch class continue delete do else extends false finally for "+"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");function getCompletions(token,context,keywords,options){var found=[],start=token.string,global=options&&options.globalScope||window;function maybeAdd(str){if(str.lastIndexOf(start,0)==0&&!arrayContains(found,str))found.push(str);}
|
17 |
+
function gatherCompletions(obj){if(typeof obj=="string")forEach(stringProps,maybeAdd);else if(obj instanceof Array)forEach(arrayProps,maybeAdd);else if(obj instanceof Function)forEach(funcProps,maybeAdd);for(var name in obj)maybeAdd(name);}
|
18 |
+
if(context&&context.length){var obj=context.pop(),base;if(obj.type&&obj.type.indexOf("variable")===0){if(options&&options.additionalContext)
|
19 |
+
base=options.additionalContext[obj.string];if(!options||options.useGlobalScope!==false)
|
20 |
+
base=base||global[obj.string];}else if(obj.type=="string"){base="";}else if(obj.type=="atom"){base=1;}else if(obj.type=="function"){if(global.jQuery!=null&&(obj.string=='$'||obj.string=='jQuery')&&(typeof global.jQuery=='function'))
|
21 |
+
base=global.jQuery();else if(global._!=null&&(obj.string=='_')&&(typeof global._=='function'))
|
22 |
+
base=global._();}
|
23 |
+
while(base!=null&&context.length)
|
24 |
+
base=base[context.pop().string];if(base!=null)gatherCompletions(base);}else{for(var v=token.state.localVars;v;v=v.next)maybeAdd(v.name);for(var v=token.state.globalVars;v;v=v.next)maybeAdd(v.name);if(!options||options.useGlobalScope!==false)
|
25 |
+
gatherCompletions(global);forEach(keywords,maybeAdd);}
|
26 |
+
return found;}});
|
lib/codemirror/addon/hint/show-hint.css
ADDED
@@ -0,0 +1,38 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
.CodeMirror-hints {
|
2 |
+
position: absolute;
|
3 |
+
z-index: 10;
|
4 |
+
overflow: hidden;
|
5 |
+
list-style: none;
|
6 |
+
|
7 |
+
margin: 0;
|
8 |
+
padding: 2px;
|
9 |
+
|
10 |
+
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
11 |
+
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
12 |
+
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
13 |
+
border-radius: 3px;
|
14 |
+
border: 1px solid silver;
|
15 |
+
|
16 |
+
background: white;
|
17 |
+
font-size: 90%;
|
18 |
+
font-family: monospace;
|
19 |
+
|
20 |
+
max-height: 20em;
|
21 |
+
overflow-y: auto;
|
22 |
+
}
|
23 |
+
|
24 |
+
.CodeMirror-hint {
|
25 |
+
margin: 0;
|
26 |
+
padding: 0 4px;
|
27 |
+
border-radius: 2px;
|
28 |
+
max-width: 19em;
|
29 |
+
overflow: hidden;
|
30 |
+
white-space: pre;
|
31 |
+
color: black;
|
32 |
+
cursor: pointer;
|
33 |
+
}
|
34 |
+
|
35 |
+
li.CodeMirror-hint-active {
|
36 |
+
background: #08f;
|
37 |
+
color: white;
|
38 |
+
}
|
lib/codemirror/addon/hint/show-hint.js
ADDED
@@ -0,0 +1,392 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var HINT_ELEMENT_CLASS = "CodeMirror-hint";
|
15 |
+
var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
|
16 |
+
|
17 |
+
// This is the old interface, kept around for now to stay
|
18 |
+
// backwards-compatible.
|
19 |
+
CodeMirror.showHint = function(cm, getHints, options) {
|
20 |
+
if (!getHints) return cm.showHint(options);
|
21 |
+
if (options && options.async) getHints.async = true;
|
22 |
+
var newOpts = {hint: getHints};
|
23 |
+
if (options) for (var prop in options) newOpts[prop] = options[prop];
|
24 |
+
return cm.showHint(newOpts);
|
25 |
+
};
|
26 |
+
|
27 |
+
CodeMirror.defineExtension("showHint", function(options) {
|
28 |
+
// We want a single cursor position.
|
29 |
+
if (this.listSelections().length > 1 || this.somethingSelected()) return;
|
30 |
+
|
31 |
+
if (this.state.completionActive) this.state.completionActive.close();
|
32 |
+
var completion = this.state.completionActive = new Completion(this, options);
|
33 |
+
if (!completion.options.hint) return;
|
34 |
+
|
35 |
+
CodeMirror.signal(this, "startCompletion", this);
|
36 |
+
completion.update();
|
37 |
+
});
|
38 |
+
|
39 |
+
function Completion(cm, options) {
|
40 |
+
this.cm = cm;
|
41 |
+
this.options = this.buildOptions(options);
|
42 |
+
this.widget = null;
|
43 |
+
this.debounce = 0;
|
44 |
+
this.tick = 0;
|
45 |
+
this.startPos = this.cm.getCursor();
|
46 |
+
this.startLen = this.cm.getLine(this.startPos.line).length;
|
47 |
+
|
48 |
+
var self = this;
|
49 |
+
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
50 |
+
}
|
51 |
+
|
52 |
+
var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
|
53 |
+
return setTimeout(fn, 1000/60);
|
54 |
+
};
|
55 |
+
var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
56 |
+
|
57 |
+
Completion.prototype = {
|
58 |
+
close: function() {
|
59 |
+
if (!this.active()) return;
|
60 |
+
this.cm.state.completionActive = null;
|
61 |
+
this.tick = null;
|
62 |
+
this.cm.off("cursorActivity", this.activityFunc);
|
63 |
+
|
64 |
+
if (this.widget) this.widget.close();
|
65 |
+
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
66 |
+
},
|
67 |
+
|
68 |
+
active: function() {
|
69 |
+
return this.cm.state.completionActive == this;
|
70 |
+
},
|
71 |
+
|
72 |
+
pick: function(data, i) {
|
73 |
+
var completion = data.list[i];
|
74 |
+
if (completion.hint) completion.hint(this.cm, data, completion);
|
75 |
+
else this.cm.replaceRange(getText(completion), completion.from || data.from,
|
76 |
+
completion.to || data.to, "complete");
|
77 |
+
CodeMirror.signal(data, "pick", completion);
|
78 |
+
this.close();
|
79 |
+
},
|
80 |
+
|
81 |
+
showHints: function(data) {
|
82 |
+
if (!data || !data.list.length || !this.active()) return this.close();
|
83 |
+
|
84 |
+
if (this.options.completeSingle && data.list.length == 1)
|
85 |
+
this.pick(data, 0);
|
86 |
+
else
|
87 |
+
this.showWidget(data);
|
88 |
+
},
|
89 |
+
|
90 |
+
cursorActivity: function() {
|
91 |
+
if (this.debounce) {
|
92 |
+
cancelAnimationFrame(this.debounce);
|
93 |
+
this.debounce = 0;
|
94 |
+
}
|
95 |
+
|
96 |
+
var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
|
97 |
+
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
|
98 |
+
pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
|
99 |
+
(pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
|
100 |
+
this.close();
|
101 |
+
} else {
|
102 |
+
var self = this;
|
103 |
+
this.debounce = requestAnimationFrame(function() {self.update();});
|
104 |
+
if (this.widget) this.widget.disable();
|
105 |
+
}
|
106 |
+
},
|
107 |
+
|
108 |
+
update: function() {
|
109 |
+
if (this.tick == null) return;
|
110 |
+
if (this.data) CodeMirror.signal(this.data, "update");
|
111 |
+
if (!this.options.hint.async) {
|
112 |
+
this.finishUpdate(this.options.hint(this.cm, this.options), myTick);
|
113 |
+
} else {
|
114 |
+
var myTick = ++this.tick, self = this;
|
115 |
+
this.options.hint(this.cm, function(data) {
|
116 |
+
if (self.tick == myTick) self.finishUpdate(data);
|
117 |
+
}, this.options);
|
118 |
+
}
|
119 |
+
},
|
120 |
+
|
121 |
+
finishUpdate: function(data) {
|
122 |
+
this.data = data;
|
123 |
+
var picked = this.widget && this.widget.picked;
|
124 |
+
if (this.widget) this.widget.close();
|
125 |
+
if (data && data.list.length) {
|
126 |
+
if (picked && data.list.length == 1) this.pick(data, 0);
|
127 |
+
else this.widget = new Widget(this, data);
|
128 |
+
}
|
129 |
+
},
|
130 |
+
|
131 |
+
showWidget: function(data) {
|
132 |
+
this.data = data;
|
133 |
+
this.widget = new Widget(this, data);
|
134 |
+
CodeMirror.signal(data, "shown");
|
135 |
+
},
|
136 |
+
|
137 |
+
buildOptions: function(options) {
|
138 |
+
var editor = this.cm.options.hintOptions;
|
139 |
+
var out = {};
|
140 |
+
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
141 |
+
if (editor) for (var prop in editor)
|
142 |
+
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
143 |
+
if (options) for (var prop in options)
|
144 |
+
if (options[prop] !== undefined) out[prop] = options[prop];
|
145 |
+
return out;
|
146 |
+
}
|
147 |
+
};
|
148 |
+
|
149 |
+
function getText(completion) {
|
150 |
+
if (typeof completion == "string") return completion;
|
151 |
+
else return completion.text;
|
152 |
+
}
|
153 |
+
|
154 |
+
function buildKeyMap(completion, handle) {
|
155 |
+
var baseMap = {
|
156 |
+
Up: function() {handle.moveFocus(-1);},
|
157 |
+
Down: function() {handle.moveFocus(1);},
|
158 |
+
PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},
|
159 |
+
PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},
|
160 |
+
Home: function() {handle.setFocus(0);},
|
161 |
+
End: function() {handle.setFocus(handle.length - 1);},
|
162 |
+
Enter: handle.pick,
|
163 |
+
Tab: handle.pick,
|
164 |
+
Esc: handle.close
|
165 |
+
};
|
166 |
+
var custom = completion.options.customKeys;
|
167 |
+
var ourMap = custom ? {} : baseMap;
|
168 |
+
function addBinding(key, val) {
|
169 |
+
var bound;
|
170 |
+
if (typeof val != "string")
|
171 |
+
bound = function(cm) { return val(cm, handle); };
|
172 |
+
// This mechanism is deprecated
|
173 |
+
else if (baseMap.hasOwnProperty(val))
|
174 |
+
bound = baseMap[val];
|
175 |
+
else
|
176 |
+
bound = val;
|
177 |
+
ourMap[key] = bound;
|
178 |
+
}
|
179 |
+
if (custom)
|
180 |
+
for (var key in custom) if (custom.hasOwnProperty(key))
|
181 |
+
addBinding(key, custom[key]);
|
182 |
+
var extra = completion.options.extraKeys;
|
183 |
+
if (extra)
|
184 |
+
for (var key in extra) if (extra.hasOwnProperty(key))
|
185 |
+
addBinding(key, extra[key]);
|
186 |
+
return ourMap;
|
187 |
+
}
|
188 |
+
|
189 |
+
function getHintElement(hintsElement, el) {
|
190 |
+
while (el && el != hintsElement) {
|
191 |
+
if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
|
192 |
+
el = el.parentNode;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
function Widget(completion, data) {
|
197 |
+
this.completion = completion;
|
198 |
+
this.data = data;
|
199 |
+
this.picked = false;
|
200 |
+
var widget = this, cm = completion.cm;
|
201 |
+
|
202 |
+
var hints = this.hints = document.createElement("ul");
|
203 |
+
hints.className = "CodeMirror-hints";
|
204 |
+
this.selectedHint = data.selectedHint || 0;
|
205 |
+
|
206 |
+
var completions = data.list;
|
207 |
+
for (var i = 0; i < completions.length; ++i) {
|
208 |
+
var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
|
209 |
+
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
|
210 |
+
if (cur.className != null) className = cur.className + " " + className;
|
211 |
+
elt.className = className;
|
212 |
+
if (cur.render) cur.render(elt, data, cur);
|
213 |
+
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
|
214 |
+
elt.hintId = i;
|
215 |
+
}
|
216 |
+
|
217 |
+
var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
|
218 |
+
var left = pos.left, top = pos.bottom, below = true;
|
219 |
+
hints.style.left = left + "px";
|
220 |
+
hints.style.top = top + "px";
|
221 |
+
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
222 |
+
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
223 |
+
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
|
224 |
+
(completion.options.container || document.body).appendChild(hints);
|
225 |
+
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
|
226 |
+
if (overlapY > 0) {
|
227 |
+
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
|
228 |
+
if (curTop - height > 0) { // Fits above cursor
|
229 |
+
hints.style.top = (top = pos.top - height) + "px";
|
230 |
+
below = false;
|
231 |
+
} else if (height > winH) {
|
232 |
+
hints.style.height = (winH - 5) + "px";
|
233 |
+
hints.style.top = (top = pos.bottom - box.top) + "px";
|
234 |
+
var cursor = cm.getCursor();
|
235 |
+
if (data.from.ch != cursor.ch) {
|
236 |
+
pos = cm.cursorCoords(cursor);
|
237 |
+
hints.style.left = (left = pos.left) + "px";
|
238 |
+
box = hints.getBoundingClientRect();
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
var overlapX = box.right - winW;
|
243 |
+
if (overlapX > 0) {
|
244 |
+
if (box.right - box.left > winW) {
|
245 |
+
hints.style.width = (winW - 5) + "px";
|
246 |
+
overlapX -= (box.right - box.left) - winW;
|
247 |
+
}
|
248 |
+
hints.style.left = (left = pos.left - overlapX) + "px";
|
249 |
+
}
|
250 |
+
|
251 |
+
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
|
252 |
+
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
|
253 |
+
setFocus: function(n) { widget.changeActive(n); },
|
254 |
+
menuSize: function() { return widget.screenAmount(); },
|
255 |
+
length: completions.length,
|
256 |
+
close: function() { completion.close(); },
|
257 |
+
pick: function() { widget.pick(); },
|
258 |
+
data: data
|
259 |
+
}));
|
260 |
+
|
261 |
+
if (completion.options.closeOnUnfocus) {
|
262 |
+
var closingOnBlur;
|
263 |
+
cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });
|
264 |
+
cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
|
265 |
+
}
|
266 |
+
|
267 |
+
var startScroll = cm.getScrollInfo();
|
268 |
+
cm.on("scroll", this.onScroll = function() {
|
269 |
+
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
270 |
+
var newTop = top + startScroll.top - curScroll.top;
|
271 |
+
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
|
272 |
+
if (!below) point += hints.offsetHeight;
|
273 |
+
if (point <= editor.top || point >= editor.bottom) return completion.close();
|
274 |
+
hints.style.top = newTop + "px";
|
275 |
+
hints.style.left = (left + startScroll.left - curScroll.left) + "px";
|
276 |
+
});
|
277 |
+
|
278 |
+
CodeMirror.on(hints, "dblclick", function(e) {
|
279 |
+
var t = getHintElement(hints, e.target || e.srcElement);
|
280 |
+
if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}
|
281 |
+
});
|
282 |
+
|
283 |
+
CodeMirror.on(hints, "click", function(e) {
|
284 |
+
var t = getHintElement(hints, e.target || e.srcElement);
|
285 |
+
if (t && t.hintId != null) {
|
286 |
+
widget.changeActive(t.hintId);
|
287 |
+
if (completion.options.completeOnSingleClick) widget.pick();
|
288 |
+
}
|
289 |
+
});
|
290 |
+
|
291 |
+
CodeMirror.on(hints, "mousedown", function() {
|
292 |
+
setTimeout(function(){cm.focus();}, 20);
|
293 |
+
});
|
294 |
+
|
295 |
+
CodeMirror.signal(data, "select", completions[0], hints.firstChild);
|
296 |
+
return true;
|
297 |
+
}
|
298 |
+
|
299 |
+
Widget.prototype = {
|
300 |
+
close: function() {
|
301 |
+
if (this.completion.widget != this) return;
|
302 |
+
this.completion.widget = null;
|
303 |
+
this.hints.parentNode.removeChild(this.hints);
|
304 |
+
this.completion.cm.removeKeyMap(this.keyMap);
|
305 |
+
|
306 |
+
var cm = this.completion.cm;
|
307 |
+
if (this.completion.options.closeOnUnfocus) {
|
308 |
+
cm.off("blur", this.onBlur);
|
309 |
+
cm.off("focus", this.onFocus);
|
310 |
+
}
|
311 |
+
cm.off("scroll", this.onScroll);
|
312 |
+
},
|
313 |
+
|
314 |
+
disable: function() {
|
315 |
+
this.completion.cm.removeKeyMap(this.keyMap);
|
316 |
+
var widget = this;
|
317 |
+
this.keyMap = {Enter: function() { widget.picked = true; }};
|
318 |
+
this.completion.cm.addKeyMap(this.keyMap);
|
319 |
+
},
|
320 |
+
|
321 |
+
pick: function() {
|
322 |
+
this.completion.pick(this.data, this.selectedHint);
|
323 |
+
},
|
324 |
+
|
325 |
+
changeActive: function(i, avoidWrap) {
|
326 |
+
if (i >= this.data.list.length)
|
327 |
+
i = avoidWrap ? this.data.list.length - 1 : 0;
|
328 |
+
else if (i < 0)
|
329 |
+
i = avoidWrap ? 0 : this.data.list.length - 1;
|
330 |
+
if (this.selectedHint == i) return;
|
331 |
+
var node = this.hints.childNodes[this.selectedHint];
|
332 |
+
node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
|
333 |
+
node = this.hints.childNodes[this.selectedHint = i];
|
334 |
+
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
|
335 |
+
if (node.offsetTop < this.hints.scrollTop)
|
336 |
+
this.hints.scrollTop = node.offsetTop - 3;
|
337 |
+
else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
|
338 |
+
this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
|
339 |
+
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
|
340 |
+
},
|
341 |
+
|
342 |
+
screenAmount: function() {
|
343 |
+
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
|
344 |
+
}
|
345 |
+
};
|
346 |
+
|
347 |
+
CodeMirror.registerHelper("hint", "auto", function(cm, options) {
|
348 |
+
var helpers = cm.getHelpers(cm.getCursor(), "hint"), words;
|
349 |
+
if (helpers.length) {
|
350 |
+
for (var i = 0; i < helpers.length; i++) {
|
351 |
+
var cur = helpers[i](cm, options);
|
352 |
+
if (cur && cur.list.length) return cur;
|
353 |
+
}
|
354 |
+
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
355 |
+
if (words) return CodeMirror.hint.fromList(cm, {words: words});
|
356 |
+
} else if (CodeMirror.hint.anyword) {
|
357 |
+
return CodeMirror.hint.anyword(cm, options);
|
358 |
+
}
|
359 |
+
});
|
360 |
+
|
361 |
+
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
|
362 |
+
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
363 |
+
var found = [];
|
364 |
+
for (var i = 0; i < options.words.length; i++) {
|
365 |
+
var word = options.words[i];
|
366 |
+
if (word.slice(0, token.string.length) == token.string)
|
367 |
+
found.push(word);
|
368 |
+
}
|
369 |
+
|
370 |
+
if (found.length) return {
|
371 |
+
list: found,
|
372 |
+
from: CodeMirror.Pos(cur.line, token.start),
|
373 |
+
to: CodeMirror.Pos(cur.line, token.end)
|
374 |
+
};
|
375 |
+
});
|
376 |
+
|
377 |
+
CodeMirror.commands.autocomplete = CodeMirror.showHint;
|
378 |
+
|
379 |
+
var defaultOptions = {
|
380 |
+
hint: CodeMirror.hint.auto,
|
381 |
+
completeSingle: true,
|
382 |
+
alignWithWord: true,
|
383 |
+
closeCharacters: /[\s()\[\]{};:>,]/,
|
384 |
+
closeOnUnfocus: true,
|
385 |
+
completeOnSingleClick: false,
|
386 |
+
container: null,
|
387 |
+
customKeys: null,
|
388 |
+
extraKeys: null
|
389 |
+
};
|
390 |
+
|
391 |
+
CodeMirror.defineOption("hintOptions", null);
|
392 |
+
});
|
lib/codemirror/addon/hint/show-hint.min.js
ADDED
@@ -0,0 +1,35 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";var HINT_ELEMENT_CLASS="CodeMirror-hint";var ACTIVE_HINT_ELEMENT_CLASS="CodeMirror-hint-active";CodeMirror.showHint=function(cm,getHints,options){if(!getHints)return cm.showHint(options);if(options&&options.async)getHints.async=true;var newOpts={hint:getHints};if(options)for(var prop in options)newOpts[prop]=options[prop];return cm.showHint(newOpts);};CodeMirror.defineExtension("showHint",function(options){if(this.listSelections().length>1||this.somethingSelected())return;if(this.state.completionActive)this.state.completionActive.close();var completion=this.state.completionActive=new Completion(this,options);if(!completion.options.hint)return;CodeMirror.signal(this,"startCompletion",this);completion.update();});function Completion(cm,options){this.cm=cm;this.options=this.buildOptions(options);this.widget=null;this.debounce=0;this.tick=0;this.startPos=this.cm.getCursor();this.startLen=this.cm.getLine(this.startPos.line).length;var self=this;cm.on("cursorActivity",this.activityFunc=function(){self.cursorActivity();});}
|
6 |
+
var requestAnimationFrame=window.requestAnimationFrame||function(fn){return setTimeout(fn,1000/60);};var cancelAnimationFrame=window.cancelAnimationFrame||clearTimeout;Completion.prototype={close:function(){if(!this.active())return;this.cm.state.completionActive=null;this.tick=null;this.cm.off("cursorActivity",this.activityFunc);if(this.widget)this.widget.close();CodeMirror.signal(this.cm,"endCompletion",this.cm);},active:function(){return this.cm.state.completionActive==this;},pick:function(data,i){var completion=data.list[i];if(completion.hint)completion.hint(this.cm,data,completion);else this.cm.replaceRange(getText(completion),completion.from||data.from,completion.to||data.to,"complete");CodeMirror.signal(data,"pick",completion);this.close();},showHints:function(data){if(!data||!data.list.length||!this.active())return this.close();if(this.options.completeSingle&&data.list.length==1)
|
7 |
+
this.pick(data,0);else
|
8 |
+
this.showWidget(data);},cursorActivity:function(){if(this.debounce){cancelAnimationFrame(this.debounce);this.debounce=0;}
|
9 |
+
var pos=this.cm.getCursor(),line=this.cm.getLine(pos.line);if(pos.line!=this.startPos.line||line.length-pos.ch!=this.startLen-this.startPos.ch||pos.ch<this.startPos.ch||this.cm.somethingSelected()||(pos.ch&&this.options.closeCharacters.test(line.charAt(pos.ch-1)))){this.close();}else{var self=this;this.debounce=requestAnimationFrame(function(){self.update();});if(this.widget)this.widget.disable();}},update:function(){if(this.tick==null)return;if(this.data)CodeMirror.signal(this.data,"update");if(!this.options.hint.async){this.finishUpdate(this.options.hint(this.cm,this.options),myTick);}else{var myTick=++this.tick,self=this;this.options.hint(this.cm,function(data){if(self.tick==myTick)self.finishUpdate(data);},this.options);}},finishUpdate:function(data){this.data=data;var picked=this.widget&&this.widget.picked;if(this.widget)this.widget.close();if(data&&data.list.length){if(picked&&data.list.length==1)this.pick(data,0);else this.widget=new Widget(this,data);}},showWidget:function(data){this.data=data;this.widget=new Widget(this,data);CodeMirror.signal(data,"shown");},buildOptions:function(options){var editor=this.cm.options.hintOptions;var out={};for(var prop in defaultOptions)out[prop]=defaultOptions[prop];if(editor)for(var prop in editor)
|
10 |
+
if(editor[prop]!==undefined)out[prop]=editor[prop];if(options)for(var prop in options)
|
11 |
+
if(options[prop]!==undefined)out[prop]=options[prop];return out;}};function getText(completion){if(typeof completion=="string")return completion;else return completion.text;}
|
12 |
+
function buildKeyMap(completion,handle){var baseMap={Up:function(){handle.moveFocus(-1);},Down:function(){handle.moveFocus(1);},PageUp:function(){handle.moveFocus(-handle.menuSize()+1,true);},PageDown:function(){handle.moveFocus(handle.menuSize()-1,true);},Home:function(){handle.setFocus(0);},End:function(){handle.setFocus(handle.length-1);},Enter:handle.pick,Tab:handle.pick,Esc:handle.close};var custom=completion.options.customKeys;var ourMap=custom?{}:baseMap;function addBinding(key,val){var bound;if(typeof val!="string")
|
13 |
+
bound=function(cm){return val(cm,handle);};else if(baseMap.hasOwnProperty(val))
|
14 |
+
bound=baseMap[val];else
|
15 |
+
bound=val;ourMap[key]=bound;}
|
16 |
+
if(custom)
|
17 |
+
for(var key in custom)if(custom.hasOwnProperty(key))
|
18 |
+
addBinding(key,custom[key]);var extra=completion.options.extraKeys;if(extra)
|
19 |
+
for(var key in extra)if(extra.hasOwnProperty(key))
|
20 |
+
addBinding(key,extra[key]);return ourMap;}
|
21 |
+
function getHintElement(hintsElement,el){while(el&&el!=hintsElement){if(el.nodeName.toUpperCase()==="LI"&&el.parentNode==hintsElement)return el;el=el.parentNode;}}
|
22 |
+
function Widget(completion,data){this.completion=completion;this.data=data;this.picked=false;var widget=this,cm=completion.cm;var hints=this.hints=document.createElement("ul");hints.className="CodeMirror-hints";this.selectedHint=data.selectedHint||0;var completions=data.list;for(var i=0;i<completions.length;++i){var elt=hints.appendChild(document.createElement("li")),cur=completions[i];var className=HINT_ELEMENT_CLASS+(i!=this.selectedHint?"":" "+ACTIVE_HINT_ELEMENT_CLASS);if(cur.className!=null)className=cur.className+" "+className;elt.className=className;if(cur.render)cur.render(elt,data,cur);else elt.appendChild(document.createTextNode(cur.displayText||getText(cur)));elt.hintId=i;}
|
23 |
+
var pos=cm.cursorCoords(completion.options.alignWithWord?data.from:null);var left=pos.left,top=pos.bottom,below=true;hints.style.left=left+"px";hints.style.top=top+"px";var winW=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth);var winH=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(completion.options.container||document.body).appendChild(hints);var box=hints.getBoundingClientRect(),overlapY=box.bottom-winH;if(overlapY>0){var height=box.bottom-box.top,curTop=pos.top-(pos.bottom-box.top);if(curTop-height>0){hints.style.top=(top=pos.top-height)+"px";below=false;}else if(height>winH){hints.style.height=(winH-5)+"px";hints.style.top=(top=pos.bottom-box.top)+"px";var cursor=cm.getCursor();if(data.from.ch!=cursor.ch){pos=cm.cursorCoords(cursor);hints.style.left=(left=pos.left)+"px";box=hints.getBoundingClientRect();}}}
|
24 |
+
var overlapX=box.right-winW;if(overlapX>0){if(box.right-box.left>winW){hints.style.width=(winW-5)+"px";overlapX-=(box.right-box.left)-winW;}
|
25 |
+
hints.style.left=(left=pos.left-overlapX)+"px";}
|
26 |
+
cm.addKeyMap(this.keyMap=buildKeyMap(completion,{moveFocus:function(n,avoidWrap){widget.changeActive(widget.selectedHint+n,avoidWrap);},setFocus:function(n){widget.changeActive(n);},menuSize:function(){return widget.screenAmount();},length:completions.length,close:function(){completion.close();},pick:function(){widget.pick();},data:data}));if(completion.options.closeOnUnfocus){var closingOnBlur;cm.on("blur",this.onBlur=function(){closingOnBlur=setTimeout(function(){completion.close();},100);});cm.on("focus",this.onFocus=function(){clearTimeout(closingOnBlur);});}
|
27 |
+
var startScroll=cm.getScrollInfo();cm.on("scroll",this.onScroll=function(){var curScroll=cm.getScrollInfo(),editor=cm.getWrapperElement().getBoundingClientRect();var newTop=top+startScroll.top-curScroll.top;var point=newTop-(window.pageYOffset||(document.documentElement||document.body).scrollTop);if(!below)point+=hints.offsetHeight;if(point<=editor.top||point>=editor.bottom)return completion.close();hints.style.top=newTop+"px";hints.style.left=(left+startScroll.left-curScroll.left)+"px";});CodeMirror.on(hints,"dblclick",function(e){var t=getHintElement(hints,e.target||e.srcElement);if(t&&t.hintId!=null){widget.changeActive(t.hintId);widget.pick();}});CodeMirror.on(hints,"click",function(e){var t=getHintElement(hints,e.target||e.srcElement);if(t&&t.hintId!=null){widget.changeActive(t.hintId);if(completion.options.completeOnSingleClick)widget.pick();}});CodeMirror.on(hints,"mousedown",function(){setTimeout(function(){cm.focus();},20);});CodeMirror.signal(data,"select",completions[0],hints.firstChild);return true;}
|
28 |
+
Widget.prototype={close:function(){if(this.completion.widget!=this)return;this.completion.widget=null;this.hints.parentNode.removeChild(this.hints);this.completion.cm.removeKeyMap(this.keyMap);var cm=this.completion.cm;if(this.completion.options.closeOnUnfocus){cm.off("blur",this.onBlur);cm.off("focus",this.onFocus);}
|
29 |
+
cm.off("scroll",this.onScroll);},disable:function(){this.completion.cm.removeKeyMap(this.keyMap);var widget=this;this.keyMap={Enter:function(){widget.picked=true;}};this.completion.cm.addKeyMap(this.keyMap);},pick:function(){this.completion.pick(this.data,this.selectedHint);},changeActive:function(i,avoidWrap){if(i>=this.data.list.length)
|
30 |
+
i=avoidWrap?this.data.list.length-1:0;else if(i<0)
|
31 |
+
i=avoidWrap?0:this.data.list.length-1;if(this.selectedHint==i)return;var node=this.hints.childNodes[this.selectedHint];node.className=node.className.replace(" "+ACTIVE_HINT_ELEMENT_CLASS,"");node=this.hints.childNodes[this.selectedHint=i];node.className+=" "+ACTIVE_HINT_ELEMENT_CLASS;if(node.offsetTop<this.hints.scrollTop)
|
32 |
+
this.hints.scrollTop=node.offsetTop-3;else if(node.offsetTop+node.offsetHeight>this.hints.scrollTop+this.hints.clientHeight)
|
33 |
+
this.hints.scrollTop=node.offsetTop+node.offsetHeight-this.hints.clientHeight+3;CodeMirror.signal(this.data,"select",this.data.list[this.selectedHint],node);},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1;}};CodeMirror.registerHelper("hint","auto",function(cm,options){var helpers=cm.getHelpers(cm.getCursor(),"hint"),words;if(helpers.length){for(var i=0;i<helpers.length;i++){var cur=helpers[i](cm,options);if(cur&&cur.list.length)return cur;}}else if(words=cm.getHelper(cm.getCursor(),"hintWords")){if(words)return CodeMirror.hint.fromList(cm,{words:words});}else if(CodeMirror.hint.anyword){return CodeMirror.hint.anyword(cm,options);}});CodeMirror.registerHelper("hint","fromList",function(cm,options){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var found=[];for(var i=0;i<options.words.length;i++){var word=options.words[i];if(word.slice(0,token.string.length)==token.string)
|
34 |
+
found.push(word);}
|
35 |
+
if(found.length)return{list:found,from:CodeMirror.Pos(cur.line,token.start),to:CodeMirror.Pos(cur.line,token.end)};});CodeMirror.commands.autocomplete=CodeMirror.showHint;var defaultOptions={hint:CodeMirror.hint.auto,completeSingle:true,alignWithWord:true,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:true,completeOnSingleClick:false,container:null,customKeys:null,extraKeys:null};CodeMirror.defineOption("hintOptions",null);});
|
lib/codemirror/addon/hint/sql-hint.js
ADDED
@@ -0,0 +1,245 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"), require("../../mode/sql/sql"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror", "../../mode/sql/sql"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var tables;
|
15 |
+
var defaultTable;
|
16 |
+
var keywords;
|
17 |
+
var CONS = {
|
18 |
+
QUERY_DIV: ";",
|
19 |
+
ALIAS_KEYWORD: "AS"
|
20 |
+
};
|
21 |
+
var Pos = CodeMirror.Pos;
|
22 |
+
|
23 |
+
function getKeywords(editor) {
|
24 |
+
var mode = editor.doc.modeOption;
|
25 |
+
if (mode === "sql") mode = "text/x-sql";
|
26 |
+
return CodeMirror.resolveMode(mode).keywords;
|
27 |
+
}
|
28 |
+
|
29 |
+
function getText(item) {
|
30 |
+
return typeof item == "string" ? item : item.text;
|
31 |
+
}
|
32 |
+
|
33 |
+
function getItem(list, item) {
|
34 |
+
if (!list.slice) return list[item];
|
35 |
+
for (var i = list.length - 1; i >= 0; i--) if (getText(list[i]) == item)
|
36 |
+
return list[i];
|
37 |
+
}
|
38 |
+
|
39 |
+
function shallowClone(object) {
|
40 |
+
var result = {};
|
41 |
+
for (var key in object) if (object.hasOwnProperty(key))
|
42 |
+
result[key] = object[key];
|
43 |
+
return result;
|
44 |
+
}
|
45 |
+
|
46 |
+
function match(string, word) {
|
47 |
+
var len = string.length;
|
48 |
+
var sub = getText(word).substr(0, len);
|
49 |
+
return string.toUpperCase() === sub.toUpperCase();
|
50 |
+
}
|
51 |
+
|
52 |
+
function addMatches(result, search, wordlist, formatter) {
|
53 |
+
for (var word in wordlist) {
|
54 |
+
if (!wordlist.hasOwnProperty(word)) continue;
|
55 |
+
if (wordlist.slice) word = wordlist[word];
|
56 |
+
|
57 |
+
if (match(search, word)) result.push(formatter(word));
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
function cleanName(name) {
|
62 |
+
// Get rid name from backticks(`) and preceding dot(.)
|
63 |
+
if (name.charAt(0) == ".") {
|
64 |
+
name = name.substr(1);
|
65 |
+
}
|
66 |
+
return name.replace(/`/g, "");
|
67 |
+
}
|
68 |
+
|
69 |
+
function insertBackticks(name) {
|
70 |
+
var nameParts = getText(name).split(".");
|
71 |
+
for (var i = 0; i < nameParts.length; i++)
|
72 |
+
nameParts[i] = "`" + nameParts[i] + "`";
|
73 |
+
var escaped = nameParts.join(".");
|
74 |
+
if (typeof name == "string") return escaped;
|
75 |
+
name = shallowClone(name);
|
76 |
+
name.text = escaped;
|
77 |
+
return name;
|
78 |
+
}
|
79 |
+
|
80 |
+
function nameCompletion(cur, token, result, editor) {
|
81 |
+
// Try to complete table, colunm names and return start position of completion
|
82 |
+
var useBacktick = false;
|
83 |
+
var nameParts = [];
|
84 |
+
var start = token.start;
|
85 |
+
var cont = true;
|
86 |
+
while (cont) {
|
87 |
+
cont = (token.string.charAt(0) == ".");
|
88 |
+
useBacktick = useBacktick || (token.string.charAt(0) == "`");
|
89 |
+
|
90 |
+
start = token.start;
|
91 |
+
nameParts.unshift(cleanName(token.string));
|
92 |
+
|
93 |
+
token = editor.getTokenAt(Pos(cur.line, token.start));
|
94 |
+
if (token.string == ".") {
|
95 |
+
cont = true;
|
96 |
+
token = editor.getTokenAt(Pos(cur.line, token.start));
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
// Try to complete table names
|
101 |
+
var string = nameParts.join(".");
|
102 |
+
addMatches(result, string, tables, function(w) {
|
103 |
+
return useBacktick ? insertBackticks(w) : w;
|
104 |
+
});
|
105 |
+
|
106 |
+
// Try to complete columns from defaultTable
|
107 |
+
addMatches(result, string, defaultTable, function(w) {
|
108 |
+
return useBacktick ? insertBackticks(w) : w;
|
109 |
+
});
|
110 |
+
|
111 |
+
// Try to complete columns
|
112 |
+
string = nameParts.pop();
|
113 |
+
var table = nameParts.join(".");
|
114 |
+
|
115 |
+
// Check if table is available. If not, find table by Alias
|
116 |
+
if (!getItem(tables, table))
|
117 |
+
table = findTableByAlias(table, editor);
|
118 |
+
|
119 |
+
var columns = getItem(tables, table);
|
120 |
+
if (columns && columns.columns)
|
121 |
+
columns = columns.columns;
|
122 |
+
|
123 |
+
if (columns) {
|
124 |
+
addMatches(result, string, columns, function(w) {
|
125 |
+
if (typeof w == "string") {
|
126 |
+
w = table + "." + w;
|
127 |
+
} else {
|
128 |
+
w = shallowClone(w);
|
129 |
+
w.text = table + "." + w.text;
|
130 |
+
}
|
131 |
+
return useBacktick ? insertBackticks(w) : w;
|
132 |
+
});
|
133 |
+
}
|
134 |
+
|
135 |
+
return start;
|
136 |
+
}
|
137 |
+
|
138 |
+
function eachWord(lineText, f) {
|
139 |
+
if (!lineText) return;
|
140 |
+
var excepted = /[,;]/g;
|
141 |
+
var words = lineText.split(" ");
|
142 |
+
for (var i = 0; i < words.length; i++) {
|
143 |
+
f(words[i]?words[i].replace(excepted, '') : '');
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
function convertCurToNumber(cur) {
|
148 |
+
// max characters of a line is 999,999.
|
149 |
+
return cur.line + cur.ch / Math.pow(10, 6);
|
150 |
+
}
|
151 |
+
|
152 |
+
function convertNumberToCur(num) {
|
153 |
+
return Pos(Math.floor(num), +num.toString().split('.').pop());
|
154 |
+
}
|
155 |
+
|
156 |
+
function findTableByAlias(alias, editor) {
|
157 |
+
var doc = editor.doc;
|
158 |
+
var fullQuery = doc.getValue();
|
159 |
+
var aliasUpperCase = alias.toUpperCase();
|
160 |
+
var previousWord = "";
|
161 |
+
var table = "";
|
162 |
+
var separator = [];
|
163 |
+
var validRange = {
|
164 |
+
start: Pos(0, 0),
|
165 |
+
end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length)
|
166 |
+
};
|
167 |
+
|
168 |
+
//add separator
|
169 |
+
var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV);
|
170 |
+
while(indexOfSeparator != -1) {
|
171 |
+
separator.push(doc.posFromIndex(indexOfSeparator));
|
172 |
+
indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1);
|
173 |
+
}
|
174 |
+
separator.unshift(Pos(0, 0));
|
175 |
+
separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
|
176 |
+
|
177 |
+
//find valid range
|
178 |
+
var prevItem = 0;
|
179 |
+
var current = convertCurToNumber(editor.getCursor());
|
180 |
+
for (var i=0; i< separator.length; i++) {
|
181 |
+
var _v = convertCurToNumber(separator[i]);
|
182 |
+
if (current > prevItem && current <= _v) {
|
183 |
+
validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
|
184 |
+
break;
|
185 |
+
}
|
186 |
+
prevItem = _v;
|
187 |
+
}
|
188 |
+
|
189 |
+
var query = doc.getRange(validRange.start, validRange.end, false);
|
190 |
+
|
191 |
+
for (var i = 0; i < query.length; i++) {
|
192 |
+
var lineText = query[i];
|
193 |
+
eachWord(lineText, function(word) {
|
194 |
+
var wordUpperCase = word.toUpperCase();
|
195 |
+
if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
|
196 |
+
table = previousWord;
|
197 |
+
if (wordUpperCase !== CONS.ALIAS_KEYWORD)
|
198 |
+
previousWord = word;
|
199 |
+
});
|
200 |
+
if (table) break;
|
201 |
+
}
|
202 |
+
return table;
|
203 |
+
}
|
204 |
+
|
205 |
+
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
|
206 |
+
tables = (options && options.tables) || {};
|
207 |
+
var defaultTableName = options && options.defaultTable;
|
208 |
+
defaultTable = defaultTableName && getItem(tables, defaultTableName);
|
209 |
+
keywords = keywords || getKeywords(editor);
|
210 |
+
|
211 |
+
if (defaultTableName && !defaultTable)
|
212 |
+
defaultTable = findTableByAlias(defaultTableName, editor);
|
213 |
+
|
214 |
+
defaultTable = defaultTable || [];
|
215 |
+
|
216 |
+
if (defaultTable.columns)
|
217 |
+
defaultTable = defaultTable.columns;
|
218 |
+
|
219 |
+
var cur = editor.getCursor();
|
220 |
+
var result = [];
|
221 |
+
var token = editor.getTokenAt(cur), start, end, search;
|
222 |
+
if (token.end > cur.ch) {
|
223 |
+
token.end = cur.ch;
|
224 |
+
token.string = token.string.slice(0, cur.ch - token.start);
|
225 |
+
}
|
226 |
+
|
227 |
+
if (token.string.match(/^[.`\w@]\w*$/)) {
|
228 |
+
search = token.string;
|
229 |
+
start = token.start;
|
230 |
+
end = token.end;
|
231 |
+
} else {
|
232 |
+
start = end = cur.ch;
|
233 |
+
search = "";
|
234 |
+
}
|
235 |
+
if (search.charAt(0) == "." || search.charAt(0) == "`") {
|
236 |
+
start = nameCompletion(cur, token, result, editor);
|
237 |
+
} else {
|
238 |
+
addMatches(result, search, tables, function(w) {return w;});
|
239 |
+
addMatches(result, search, defaultTable, function(w) {return w;});
|
240 |
+
addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
|
241 |
+
}
|
242 |
+
|
243 |
+
return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
|
244 |
+
});
|
245 |
+
});
|
lib/codemirror/addon/hint/sql-hint.min.js
ADDED
@@ -0,0 +1,38 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"),require("../../mode/sql/sql"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror","../../mode/sql/sql"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";var tables;var defaultTable;var keywords;var CONS={QUERY_DIV:";",ALIAS_KEYWORD:"AS"};var Pos=CodeMirror.Pos;function getKeywords(editor){var mode=editor.doc.modeOption;if(mode==="sql")mode="text/x-sql";return CodeMirror.resolveMode(mode).keywords;}
|
6 |
+
function getText(item){return typeof item=="string"?item:item.text;}
|
7 |
+
function getItem(list,item){if(!list.slice)return list[item];for(var i=list.length-1;i>=0;i--)if(getText(list[i])==item)
|
8 |
+
return list[i];}
|
9 |
+
function shallowClone(object){var result={};for(var key in object)if(object.hasOwnProperty(key))
|
10 |
+
result[key]=object[key];return result;}
|
11 |
+
function match(string,word){var len=string.length;var sub=getText(word).substr(0,len);return string.toUpperCase()===sub.toUpperCase();}
|
12 |
+
function addMatches(result,search,wordlist,formatter){for(var word in wordlist){if(!wordlist.hasOwnProperty(word))continue;if(wordlist.slice)word=wordlist[word];if(match(search,word))result.push(formatter(word));}}
|
13 |
+
function cleanName(name){if(name.charAt(0)=="."){name=name.substr(1);}
|
14 |
+
return name.replace(/`/g,"");}
|
15 |
+
function insertBackticks(name){var nameParts=getText(name).split(".");for(var i=0;i<nameParts.length;i++)
|
16 |
+
nameParts[i]="`"+nameParts[i]+"`";var escaped=nameParts.join(".");if(typeof name=="string")return escaped;name=shallowClone(name);name.text=escaped;return name;}
|
17 |
+
function nameCompletion(cur,token,result,editor){var useBacktick=false;var nameParts=[];var start=token.start;var cont=true;while(cont){cont=(token.string.charAt(0)==".");useBacktick=useBacktick||(token.string.charAt(0)=="`");start=token.start;nameParts.unshift(cleanName(token.string));token=editor.getTokenAt(Pos(cur.line,token.start));if(token.string=="."){cont=true;token=editor.getTokenAt(Pos(cur.line,token.start));}}
|
18 |
+
var string=nameParts.join(".");addMatches(result,string,tables,function(w){return useBacktick?insertBackticks(w):w;});addMatches(result,string,defaultTable,function(w){return useBacktick?insertBackticks(w):w;});string=nameParts.pop();var table=nameParts.join(".");if(!getItem(tables,table))
|
19 |
+
table=findTableByAlias(table,editor);var columns=getItem(tables,table);if(columns&&columns.columns)
|
20 |
+
columns=columns.columns;if(columns){addMatches(result,string,columns,function(w){if(typeof w=="string"){w=table+"."+w;}else{w=shallowClone(w);w.text=table+"."+w.text;}
|
21 |
+
return useBacktick?insertBackticks(w):w;});}
|
22 |
+
return start;}
|
23 |
+
function eachWord(lineText,f){if(!lineText)return;var excepted=/[,;]/g;var words=lineText.split(" ");for(var i=0;i<words.length;i++){f(words[i]?words[i].replace(excepted,''):'');}}
|
24 |
+
function convertCurToNumber(cur){return cur.line+cur.ch/Math.pow(10,6);}
|
25 |
+
function convertNumberToCur(num){return Pos(Math.floor(num),+num.toString().split('.').pop());}
|
26 |
+
function findTableByAlias(alias,editor){var doc=editor.doc;var fullQuery=doc.getValue();var aliasUpperCase=alias.toUpperCase();var previousWord="";var table="";var separator=[];var validRange={start:Pos(0,0),end:Pos(editor.lastLine(),editor.getLineHandle(editor.lastLine()).length)};var indexOfSeparator=fullQuery.indexOf(CONS.QUERY_DIV);while(indexOfSeparator!=-1){separator.push(doc.posFromIndex(indexOfSeparator));indexOfSeparator=fullQuery.indexOf(CONS.QUERY_DIV,indexOfSeparator+1);}
|
27 |
+
separator.unshift(Pos(0,0));separator.push(Pos(editor.lastLine(),editor.getLineHandle(editor.lastLine()).text.length));var prevItem=0;var current=convertCurToNumber(editor.getCursor());for(var i=0;i<separator.length;i++){var _v=convertCurToNumber(separator[i]);if(current>prevItem&¤t<=_v){validRange={start:convertNumberToCur(prevItem),end:convertNumberToCur(_v)};break;}
|
28 |
+
prevItem=_v;}
|
29 |
+
var query=doc.getRange(validRange.start,validRange.end,false);for(var i=0;i<query.length;i++){var lineText=query[i];eachWord(lineText,function(word){var wordUpperCase=word.toUpperCase();if(wordUpperCase===aliasUpperCase&&getItem(tables,previousWord))
|
30 |
+
table=previousWord;if(wordUpperCase!==CONS.ALIAS_KEYWORD)
|
31 |
+
previousWord=word;});if(table)break;}
|
32 |
+
return table;}
|
33 |
+
CodeMirror.registerHelper("hint","sql",function(editor,options){tables=(options&&options.tables)||{};var defaultTableName=options&&options.defaultTable;defaultTable=defaultTableName&&getItem(tables,defaultTableName);keywords=keywords||getKeywords(editor);if(defaultTableName&&!defaultTable)
|
34 |
+
defaultTable=findTableByAlias(defaultTableName,editor);defaultTable=defaultTable||[];if(defaultTable.columns)
|
35 |
+
defaultTable=defaultTable.columns;var cur=editor.getCursor();var result=[];var token=editor.getTokenAt(cur),start,end,search;if(token.end>cur.ch){token.end=cur.ch;token.string=token.string.slice(0,cur.ch-token.start);}
|
36 |
+
if(token.string.match(/^[.`\w@]\w*$/)){search=token.string;start=token.start;end=token.end;}else{start=end=cur.ch;search="";}
|
37 |
+
if(search.charAt(0)=="."||search.charAt(0)=="`"){start=nameCompletion(cur,token,result,editor);}else{addMatches(result,search,tables,function(w){return w;});addMatches(result,search,defaultTable,function(w){return w;});addMatches(result,search,keywords,function(w){return w.toUpperCase();});}
|
38 |
+
return{list:result,from:Pos(cur.line,start),to:Pos(cur.line,end)};});});
|
lib/codemirror/addon/hint/xml-hint.js
ADDED
@@ -0,0 +1,110 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var Pos = CodeMirror.Pos;
|
15 |
+
|
16 |
+
function getHints(cm, options) {
|
17 |
+
var tags = options && options.schemaInfo;
|
18 |
+
var quote = (options && options.quoteChar) || '"';
|
19 |
+
if (!tags) return;
|
20 |
+
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
21 |
+
if (token.end > cur.ch) {
|
22 |
+
token.end = cur.ch;
|
23 |
+
token.string = token.string.slice(0, cur.ch - token.start);
|
24 |
+
}
|
25 |
+
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
|
26 |
+
if (inner.mode.name != "xml") return;
|
27 |
+
var result = [], replaceToken = false, prefix;
|
28 |
+
var tag = /\btag\b/.test(token.type) && !/>$/.test(token.string);
|
29 |
+
var tagName = tag && /^\w/.test(token.string), tagStart;
|
30 |
+
|
31 |
+
if (tagName) {
|
32 |
+
var before = cm.getLine(cur.line).slice(Math.max(0, token.start - 2), token.start);
|
33 |
+
var tagType = /<\/$/.test(before) ? "close" : /<$/.test(before) ? "open" : null;
|
34 |
+
if (tagType) tagStart = token.start - (tagType == "close" ? 2 : 1);
|
35 |
+
} else if (tag && token.string == "<") {
|
36 |
+
tagType = "open";
|
37 |
+
} else if (tag && token.string == "</") {
|
38 |
+
tagType = "close";
|
39 |
+
}
|
40 |
+
|
41 |
+
if (!tag && !inner.state.tagName || tagType) {
|
42 |
+
if (tagName)
|
43 |
+
prefix = token.string;
|
44 |
+
replaceToken = tagType;
|
45 |
+
var cx = inner.state.context, curTag = cx && tags[cx.tagName];
|
46 |
+
var childList = cx ? curTag && curTag.children : tags["!top"];
|
47 |
+
if (childList && tagType != "close") {
|
48 |
+
for (var i = 0; i < childList.length; ++i) if (!prefix || childList[i].lastIndexOf(prefix, 0) == 0)
|
49 |
+
result.push("<" + childList[i]);
|
50 |
+
} else if (tagType != "close") {
|
51 |
+
for (var name in tags)
|
52 |
+
if (tags.hasOwnProperty(name) && name != "!top" && name != "!attrs" && (!prefix || name.lastIndexOf(prefix, 0) == 0))
|
53 |
+
result.push("<" + name);
|
54 |
+
}
|
55 |
+
if (cx && (!prefix || tagType == "close" && cx.tagName.lastIndexOf(prefix, 0) == 0))
|
56 |
+
result.push("</" + cx.tagName + ">");
|
57 |
+
} else {
|
58 |
+
// Attribute completion
|
59 |
+
var curTag = tags[inner.state.tagName], attrs = curTag && curTag.attrs;
|
60 |
+
var globalAttrs = tags["!attrs"];
|
61 |
+
if (!attrs && !globalAttrs) return;
|
62 |
+
if (!attrs) {
|
63 |
+
attrs = globalAttrs;
|
64 |
+
} else if (globalAttrs) { // Combine tag-local and global attributes
|
65 |
+
var set = {};
|
66 |
+
for (var nm in globalAttrs) if (globalAttrs.hasOwnProperty(nm)) set[nm] = globalAttrs[nm];
|
67 |
+
for (var nm in attrs) if (attrs.hasOwnProperty(nm)) set[nm] = attrs[nm];
|
68 |
+
attrs = set;
|
69 |
+
}
|
70 |
+
if (token.type == "string" || token.string == "=") { // A value
|
71 |
+
var before = cm.getRange(Pos(cur.line, Math.max(0, cur.ch - 60)),
|
72 |
+
Pos(cur.line, token.type == "string" ? token.start : token.end));
|
73 |
+
var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues;
|
74 |
+
if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return;
|
75 |
+
if (typeof atValues == 'function') atValues = atValues.call(this, cm); // Functions can be used to supply values for autocomplete widget
|
76 |
+
if (token.type == "string") {
|
77 |
+
prefix = token.string;
|
78 |
+
var n = 0;
|
79 |
+
if (/['"]/.test(token.string.charAt(0))) {
|
80 |
+
quote = token.string.charAt(0);
|
81 |
+
prefix = token.string.slice(1);
|
82 |
+
n++;
|
83 |
+
}
|
84 |
+
var len = token.string.length;
|
85 |
+
if (/['"]/.test(token.string.charAt(len - 1))) {
|
86 |
+
quote = token.string.charAt(len - 1);
|
87 |
+
prefix = token.string.substr(n, len - 2);
|
88 |
+
}
|
89 |
+
replaceToken = true;
|
90 |
+
}
|
91 |
+
for (var i = 0; i < atValues.length; ++i) if (!prefix || atValues[i].lastIndexOf(prefix, 0) == 0)
|
92 |
+
result.push(quote + atValues[i] + quote);
|
93 |
+
} else { // An attribute name
|
94 |
+
if (token.type == "attribute") {
|
95 |
+
prefix = token.string;
|
96 |
+
replaceToken = true;
|
97 |
+
}
|
98 |
+
for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || attr.lastIndexOf(prefix, 0) == 0))
|
99 |
+
result.push(attr);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
return {
|
103 |
+
list: result,
|
104 |
+
from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur,
|
105 |
+
to: replaceToken ? Pos(cur.line, token.end) : cur
|
106 |
+
};
|
107 |
+
}
|
108 |
+
|
109 |
+
CodeMirror.registerHelper("hint", "xml", getHints);
|
110 |
+
});
|
lib/codemirror/addon/hint/xml-hint.min.js
ADDED
@@ -0,0 +1,22 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";var Pos=CodeMirror.Pos;function getHints(cm,options){var tags=options&&options.schemaInfo;var quote=(options&&options.quoteChar)||'"';if(!tags)return;var cur=cm.getCursor(),token=cm.getTokenAt(cur);if(token.end>cur.ch){token.end=cur.ch;token.string=token.string.slice(0,cur.ch-token.start);}
|
6 |
+
var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(inner.mode.name!="xml")return;var result=[],replaceToken=false,prefix;var tag=/\btag\b/.test(token.type)&&!/>$/.test(token.string);var tagName=tag&&/^\w/.test(token.string),tagStart;if(tagName){var before=cm.getLine(cur.line).slice(Math.max(0,token.start-2),token.start);var tagType=/<\/$/.test(before)?"close":/<$/.test(before)?"open":null;if(tagType)tagStart=token.start-(tagType=="close"?2:1);}else if(tag&&token.string=="<"){tagType="open";}else if(tag&&token.string=="</"){tagType="close";}
|
7 |
+
if(!tag&&!inner.state.tagName||tagType){if(tagName)
|
8 |
+
prefix=token.string;replaceToken=tagType;var cx=inner.state.context,curTag=cx&&tags[cx.tagName];var childList=cx?curTag&&curTag.children:tags["!top"];if(childList&&tagType!="close"){for(var i=0;i<childList.length;++i)if(!prefix||childList[i].lastIndexOf(prefix,0)==0)
|
9 |
+
result.push("<"+childList[i]);}else if(tagType!="close"){for(var name in tags)
|
10 |
+
if(tags.hasOwnProperty(name)&&name!="!top"&&name!="!attrs"&&(!prefix||name.lastIndexOf(prefix,0)==0))
|
11 |
+
result.push("<"+name);}
|
12 |
+
if(cx&&(!prefix||tagType=="close"&&cx.tagName.lastIndexOf(prefix,0)==0))
|
13 |
+
result.push("</"+cx.tagName+">");}else{var curTag=tags[inner.state.tagName],attrs=curTag&&curTag.attrs;var globalAttrs=tags["!attrs"];if(!attrs&&!globalAttrs)return;if(!attrs){attrs=globalAttrs;}else if(globalAttrs){var set={};for(var nm in globalAttrs)if(globalAttrs.hasOwnProperty(nm))set[nm]=globalAttrs[nm];for(var nm in attrs)if(attrs.hasOwnProperty(nm))set[nm]=attrs[nm];attrs=set;}
|
14 |
+
if(token.type=="string"||token.string=="="){var before=cm.getRange(Pos(cur.line,Math.max(0,cur.ch-60)),Pos(cur.line,token.type=="string"?token.start:token.end));var atName=before.match(/([^\s\u00a0=<>\"\']+)=$/),atValues;if(!atName||!attrs.hasOwnProperty(atName[1])||!(atValues=attrs[atName[1]]))return;if(typeof atValues=='function')atValues=atValues.call(this,cm);if(token.type=="string"){prefix=token.string;var n=0;if(/['"]/.test(token.string.charAt(0))){quote=token.string.charAt(0);prefix=token.string.slice(1);n++;}
|
15 |
+
var len=token.string.length;if(/['"]/.test(token.string.charAt(len-1))){quote=token.string.charAt(len-1);prefix=token.string.substr(n,len-2);}
|
16 |
+
replaceToken=true;}
|
17 |
+
for(var i=0;i<atValues.length;++i)if(!prefix||atValues[i].lastIndexOf(prefix,0)==0)
|
18 |
+
result.push(quote+atValues[i]+quote);}else{if(token.type=="attribute"){prefix=token.string;replaceToken=true;}
|
19 |
+
for(var attr in attrs)if(attrs.hasOwnProperty(attr)&&(!prefix||attr.lastIndexOf(prefix,0)==0))
|
20 |
+
result.push(attr);}}
|
21 |
+
return{list:result,from:replaceToken?Pos(cur.line,tagStart==null?token.start:tagStart):cur,to:replaceToken?Pos(cur.line,token.end):cur};}
|
22 |
+
CodeMirror.registerHelper("hint","xml",getHints);});
|
lib/codemirror/addon/lint/coffeescript-lint.js
ADDED
@@ -0,0 +1,41 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
|
5 |
+
|
6 |
+
// declare global: coffeelint
|
7 |
+
|
8 |
+
(function(mod) {
|
9 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10 |
+
mod(require("../../lib/codemirror"));
|
11 |
+
else if (typeof define == "function" && define.amd) // AMD
|
12 |
+
define(["../../lib/codemirror"], mod);
|
13 |
+
else // Plain browser env
|
14 |
+
mod(CodeMirror);
|
15 |
+
})(function(CodeMirror) {
|
16 |
+
"use strict";
|
17 |
+
|
18 |
+
CodeMirror.registerHelper("lint", "coffeescript", function(text) {
|
19 |
+
var found = [];
|
20 |
+
var parseError = function(err) {
|
21 |
+
var loc = err.lineNumber;
|
22 |
+
found.push({from: CodeMirror.Pos(loc-1, 0),
|
23 |
+
to: CodeMirror.Pos(loc, 0),
|
24 |
+
severity: err.level,
|
25 |
+
message: err.message});
|
26 |
+
};
|
27 |
+
try {
|
28 |
+
var res = coffeelint.lint(text);
|
29 |
+
for(var i = 0; i < res.length; i++) {
|
30 |
+
parseError(res[i]);
|
31 |
+
}
|
32 |
+
} catch(e) {
|
33 |
+
found.push({from: CodeMirror.Pos(e.location.first_line, 0),
|
34 |
+
to: CodeMirror.Pos(e.location.last_line, e.location.last_column),
|
35 |
+
severity: 'error',
|
36 |
+
message: e.message});
|
37 |
+
}
|
38 |
+
return found;
|
39 |
+
});
|
40 |
+
|
41 |
+
});
|
lib/codemirror/addon/lint/coffeescript-lint.min.js
ADDED
@@ -0,0 +1,6 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("lint","coffeescript",function(text){var found=[];var parseError=function(err){var loc=err.lineNumber;found.push({from:CodeMirror.Pos(loc-1,0),to:CodeMirror.Pos(loc,0),severity:err.level,message:err.message});};try{var res=coffeelint.lint(text);for(var i=0;i<res.length;i++){parseError(res[i]);}}catch(e){found.push({from:CodeMirror.Pos(e.location.first_line,0),to:CodeMirror.Pos(e.location.last_line,e.location.last_column),severity:'error',message:e.message});}
|
6 |
+
return found;});});
|
lib/codemirror/addon/lint/css-lint.js
ADDED
@@ -0,0 +1,43 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
// Depends on csslint.js from https://github.com/stubbornella/csslint
|
5 |
+
|
6 |
+
// declare global: CSSLint
|
7 |
+
|
8 |
+
(function(mod) {
|
9 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10 |
+
mod(require("../../lib/codemirror"));
|
11 |
+
else if (typeof define == "function" && define.amd) // AMD
|
12 |
+
define(["../../lib/codemirror"], mod);
|
13 |
+
else // Plain browser env
|
14 |
+
mod(CodeMirror);
|
15 |
+
})(function(CodeMirror) {
|
16 |
+
"use strict";
|
17 |
+
|
18 |
+
CodeMirror.registerHelper("lint", "css", function(text) {
|
19 |
+
var found = [];
|
20 |
+
if (!window.CSSLint) return found;
|
21 |
+
// This has been modified to only display certain errors
|
22 |
+
var results = CSSLint.verify(text, {
|
23 |
+
"box-model": 1,
|
24 |
+
"display-property-grouping": 1,
|
25 |
+
"duplicate-properties": 1,
|
26 |
+
"empty-rules": 1,
|
27 |
+
"known-properties": 1
|
28 |
+
}), messages = results.messages, message = null;
|
29 |
+
|
30 |
+
for ( var i = 0; i < messages.length; i++) {
|
31 |
+
message = messages[i];
|
32 |
+
var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
|
33 |
+
found.push({
|
34 |
+
from: CodeMirror.Pos(startLine, startCol),
|
35 |
+
to: CodeMirror.Pos(endLine, endCol),
|
36 |
+
message: message.message,
|
37 |
+
severity : message.type
|
38 |
+
});
|
39 |
+
}
|
40 |
+
return found;
|
41 |
+
});
|
42 |
+
|
43 |
+
});
|
lib/codemirror/addon/lint/css-lint.min.js
ADDED
@@ -0,0 +1,6 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("lint","css",function(text){var found=[];if(!window.CSSLint)return found;var results=CSSLint.verify(text,{"box-model":1,"display-property-grouping":1,"duplicate-properties":1,"empty-rules":1,"known-properties":1}),messages=results.messages,message=null;for(var i=0;i<messages.length;i++){message=messages[i];var startLine=message.line-1,endLine=message.line-1,startCol=message.col-1,endCol=message.col;found.push({from:CodeMirror.Pos(startLine,startCol),to:CodeMirror.Pos(endLine,endCol),message:message.message,severity:message.type});}
|
6 |
+
return found;});});
|
lib/codemirror/addon/lint/javascript-lint.js
ADDED
@@ -0,0 +1,136 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
// declare global: JSHINT
|
14 |
+
|
15 |
+
var bogus = [ "Dangerous comment" ];
|
16 |
+
|
17 |
+
var warnings = [ [ "Expected '{'",
|
18 |
+
"Statement body should be inside '{ }' braces." ] ];
|
19 |
+
|
20 |
+
var errors = [ "Missing semicolon", "Extra comma", "Missing property name",
|
21 |
+
"Unmatched ", " and instead saw", " is not defined",
|
22 |
+
"Unclosed string", "Stopping, unable to continue" ];
|
23 |
+
|
24 |
+
function validator(text, options) {
|
25 |
+
if (!window.JSHINT) return [];
|
26 |
+
JSHINT(text, options, options.globals);
|
27 |
+
var errors = JSHINT.data().errors, result = [];
|
28 |
+
if (errors) parseErrors(errors, result);
|
29 |
+
return result;
|
30 |
+
}
|
31 |
+
|
32 |
+
CodeMirror.registerHelper("lint", "javascript", validator);
|
33 |
+
|
34 |
+
function cleanup(error) {
|
35 |
+
// All problems are warnings by default
|
36 |
+
fixWith(error, warnings, "warning", true);
|
37 |
+
fixWith(error, errors, "error");
|
38 |
+
|
39 |
+
return isBogus(error) ? null : error;
|
40 |
+
}
|
41 |
+
|
42 |
+
function fixWith(error, fixes, severity, force) {
|
43 |
+
var description, fix, find, replace, found;
|
44 |
+
|
45 |
+
description = error.description;
|
46 |
+
|
47 |
+
for ( var i = 0; i < fixes.length; i++) {
|
48 |
+
fix = fixes[i];
|
49 |
+
find = (typeof fix === "string" ? fix : fix[0]);
|
50 |
+
replace = (typeof fix === "string" ? null : fix[1]);
|
51 |
+
found = description.indexOf(find) !== -1;
|
52 |
+
|
53 |
+
if (force || found) {
|
54 |
+
error.severity = severity;
|
55 |
+
}
|
56 |
+
if (found && replace) {
|
57 |
+
error.description = replace;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
function isBogus(error) {
|
63 |
+
var description = error.description;
|
64 |
+
for ( var i = 0; i < bogus.length; i++) {
|
65 |
+
if (description.indexOf(bogus[i]) !== -1) {
|
66 |
+
return true;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
function parseErrors(errors, output) {
|
73 |
+
for ( var i = 0; i < errors.length; i++) {
|
74 |
+
var error = errors[i];
|
75 |
+
if (error) {
|
76 |
+
var linetabpositions, index;
|
77 |
+
|
78 |
+
linetabpositions = [];
|
79 |
+
|
80 |
+
// This next block is to fix a problem in jshint. Jshint
|
81 |
+
// replaces
|
82 |
+
// all tabs with spaces then performs some checks. The error
|
83 |
+
// positions (character/space) are then reported incorrectly,
|
84 |
+
// not taking the replacement step into account. Here we look
|
85 |
+
// at the evidence line and try to adjust the character position
|
86 |
+
// to the correct value.
|
87 |
+
if (error.evidence) {
|
88 |
+
// Tab positions are computed once per line and cached
|
89 |
+
var tabpositions = linetabpositions[error.line];
|
90 |
+
if (!tabpositions) {
|
91 |
+
var evidence = error.evidence;
|
92 |
+
tabpositions = [];
|
93 |
+
// ugggh phantomjs does not like this
|
94 |
+
// forEachChar(evidence, function(item, index) {
|
95 |
+
Array.prototype.forEach.call(evidence, function(item,
|
96 |
+
index) {
|
97 |
+
if (item === '\t') {
|
98 |
+
// First col is 1 (not 0) to match error
|
99 |
+
// positions
|
100 |
+
tabpositions.push(index + 1);
|
101 |
+
}
|
102 |
+
});
|
103 |
+
linetabpositions[error.line] = tabpositions;
|
104 |
+
}
|
105 |
+
if (tabpositions.length > 0) {
|
106 |
+
var pos = error.character;
|
107 |
+
tabpositions.forEach(function(tabposition) {
|
108 |
+
if (pos > tabposition) pos -= 1;
|
109 |
+
});
|
110 |
+
error.character = pos;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
var start = error.character - 1, end = start + 1;
|
115 |
+
if (error.evidence) {
|
116 |
+
index = error.evidence.substring(start).search(/.\b/);
|
117 |
+
if (index > -1) {
|
118 |
+
end += index;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
// Convert to format expected by validation service
|
123 |
+
error.description = error.reason;// + "(jshint)";
|
124 |
+
error.start = error.character;
|
125 |
+
error.end = end;
|
126 |
+
error = cleanup(error);
|
127 |
+
|
128 |
+
if (error)
|
129 |
+
output.push({message: error.description,
|
130 |
+
severity: error.severity,
|
131 |
+
from: CodeMirror.Pos(error.line - 1, start),
|
132 |
+
to: CodeMirror.Pos(error.line - 1, end)});
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
});
|
lib/codemirror/addon/lint/javascript-lint.min.js
ADDED
@@ -0,0 +1,15 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";var bogus=["Dangerous comment"];var warnings=[["Expected '{'","Statement body should be inside '{ }' braces."]];var errors=["Missing semicolon","Extra comma","Missing property name","Unmatched "," and instead saw"," is not defined","Unclosed string","Stopping, unable to continue"];function validator(text,options){if(!window.JSHINT)return[];JSHINT(text,options,options.globals);var errors=JSHINT.data().errors,result=[];if(errors)parseErrors(errors,result);return result;}
|
6 |
+
CodeMirror.registerHelper("lint","javascript",validator);function cleanup(error){fixWith(error,warnings,"warning",true);fixWith(error,errors,"error");return isBogus(error)?null:error;}
|
7 |
+
function fixWith(error,fixes,severity,force){var description,fix,find,replace,found;description=error.description;for(var i=0;i<fixes.length;i++){fix=fixes[i];find=(typeof fix==="string"?fix:fix[0]);replace=(typeof fix==="string"?null:fix[1]);found=description.indexOf(find)!==-1;if(force||found){error.severity=severity;}
|
8 |
+
if(found&&replace){error.description=replace;}}}
|
9 |
+
function isBogus(error){var description=error.description;for(var i=0;i<bogus.length;i++){if(description.indexOf(bogus[i])!==-1){return true;}}
|
10 |
+
return false;}
|
11 |
+
function parseErrors(errors,output){for(var i=0;i<errors.length;i++){var error=errors[i];if(error){var linetabpositions,index;linetabpositions=[];if(error.evidence){var tabpositions=linetabpositions[error.line];if(!tabpositions){var evidence=error.evidence;tabpositions=[];Array.prototype.forEach.call(evidence,function(item,index){if(item==='\t'){tabpositions.push(index+1);}});linetabpositions[error.line]=tabpositions;}
|
12 |
+
if(tabpositions.length>0){var pos=error.character;tabpositions.forEach(function(tabposition){if(pos>tabposition)pos-=1;});error.character=pos;}}
|
13 |
+
var start=error.character-1,end=start+1;if(error.evidence){index=error.evidence.substring(start).search(/.\b/);if(index>-1){end+=index;}}
|
14 |
+
error.description=error.reason;error.start=error.character;error.end=end;error=cleanup(error);if(error)
|
15 |
+
output.push({message:error.description,severity:error.severity,from:CodeMirror.Pos(error.line-1,start),to:CodeMirror.Pos(error.line-1,end)});}}}});
|
lib/codemirror/addon/lint/json-lint.js
ADDED
@@ -0,0 +1,31 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
// Depends on jsonlint.js from https://github.com/zaach/jsonlint
|
5 |
+
|
6 |
+
// declare global: jsonlint
|
7 |
+
|
8 |
+
(function(mod) {
|
9 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10 |
+
mod(require("../../lib/codemirror"));
|
11 |
+
else if (typeof define == "function" && define.amd) // AMD
|
12 |
+
define(["../../lib/codemirror"], mod);
|
13 |
+
else // Plain browser env
|
14 |
+
mod(CodeMirror);
|
15 |
+
})(function(CodeMirror) {
|
16 |
+
"use strict";
|
17 |
+
|
18 |
+
CodeMirror.registerHelper("lint", "json", function(text) {
|
19 |
+
var found = [];
|
20 |
+
jsonlint.parseError = function(str, hash) {
|
21 |
+
var loc = hash.loc;
|
22 |
+
found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
|
23 |
+
to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
|
24 |
+
message: str});
|
25 |
+
};
|
26 |
+
try { jsonlint.parse(text); }
|
27 |
+
catch(e) {}
|
28 |
+
return found;
|
29 |
+
});
|
30 |
+
|
31 |
+
});
|
lib/codemirror/addon/lint/json-lint.min.js
ADDED
@@ -0,0 +1,7 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("lint","json",function(text){var found=[];jsonlint.parseError=function(str,hash){var loc=hash.loc;found.push({from:CodeMirror.Pos(loc.first_line-1,loc.first_column),to:CodeMirror.Pos(loc.last_line-1,loc.last_column),message:str});};try{jsonlint.parse(text);}
|
6 |
+
catch(e){}
|
7 |
+
return found;});});
|
lib/codemirror/addon/lint/lint.css
ADDED
@@ -0,0 +1,73 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
/* The lint marker gutter */
|
2 |
+
.CodeMirror-lint-markers {
|
3 |
+
width: 16px;
|
4 |
+
}
|
5 |
+
|
6 |
+
.CodeMirror-lint-tooltip {
|
7 |
+
background-color: infobackground;
|
8 |
+
border: 1px solid black;
|
9 |
+
border-radius: 4px 4px 4px 4px;
|
10 |
+
color: infotext;
|
11 |
+
font-family: monospace;
|
12 |
+
font-size: 10pt;
|
13 |
+
overflow: hidden;
|
14 |
+
padding: 2px 5px;
|
15 |
+
position: fixed;
|
16 |
+
white-space: pre;
|
17 |
+
white-space: pre-wrap;
|
18 |
+
z-index: 100;
|
19 |
+
max-width: 600px;
|
20 |
+
opacity: 0;
|
21 |
+
transition: opacity .4s;
|
22 |
+
-moz-transition: opacity .4s;
|
23 |
+
-webkit-transition: opacity .4s;
|
24 |
+
-o-transition: opacity .4s;
|
25 |
+
-ms-transition: opacity .4s;
|
26 |
+
}
|
27 |
+
|
28 |
+
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning {
|
29 |
+
background-position: left bottom;
|
30 |
+
background-repeat: repeat-x;
|
31 |
+
}
|
32 |
+
|
33 |
+
.CodeMirror-lint-mark-error {
|
34 |
+
background-image:
|
35 |
+
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==")
|
36 |
+
;
|
37 |
+
}
|
38 |
+
|
39 |
+
.CodeMirror-lint-mark-warning {
|
40 |
+
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
41 |
+
}
|
42 |
+
|
43 |
+
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning {
|
44 |
+
background-position: center center;
|
45 |
+
background-repeat: no-repeat;
|
46 |
+
cursor: pointer;
|
47 |
+
display: inline-block;
|
48 |
+
height: 16px;
|
49 |
+
width: 16px;
|
50 |
+
vertical-align: middle;
|
51 |
+
position: relative;
|
52 |
+
}
|
53 |
+
|
54 |
+
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning {
|
55 |
+
padding-left: 18px;
|
56 |
+
background-position: top left;
|
57 |
+
background-repeat: no-repeat;
|
58 |
+
}
|
59 |
+
|
60 |
+
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {
|
61 |
+
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=");
|
62 |
+
}
|
63 |
+
|
64 |
+
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {
|
65 |
+
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=");
|
66 |
+
}
|
67 |
+
|
68 |
+
.CodeMirror-lint-marker-multiple {
|
69 |
+
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");
|
70 |
+
background-repeat: no-repeat;
|
71 |
+
background-position: right bottom;
|
72 |
+
width: 100%; height: 100%;
|
73 |
+
}
|
lib/codemirror/addon/lint/lint.js
ADDED
@@ -0,0 +1,207 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
var GUTTER_ID = "CodeMirror-lint-markers";
|
14 |
+
|
15 |
+
function showTooltip(e, content) {
|
16 |
+
var tt = document.createElement("div");
|
17 |
+
tt.className = "CodeMirror-lint-tooltip";
|
18 |
+
tt.appendChild(content.cloneNode(true));
|
19 |
+
document.body.appendChild(tt);
|
20 |
+
|
21 |
+
function position(e) {
|
22 |
+
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
|
23 |
+
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
|
24 |
+
tt.style.left = (e.clientX + 5) + "px";
|
25 |
+
}
|
26 |
+
CodeMirror.on(document, "mousemove", position);
|
27 |
+
position(e);
|
28 |
+
if (tt.style.opacity != null) tt.style.opacity = 1;
|
29 |
+
return tt;
|
30 |
+
}
|
31 |
+
function rm(elt) {
|
32 |
+
if (elt.parentNode) elt.parentNode.removeChild(elt);
|
33 |
+
}
|
34 |
+
function hideTooltip(tt) {
|
35 |
+
if (!tt.parentNode) return;
|
36 |
+
if (tt.style.opacity == null) rm(tt);
|
37 |
+
tt.style.opacity = 0;
|
38 |
+
setTimeout(function() { rm(tt); }, 600);
|
39 |
+
}
|
40 |
+
|
41 |
+
function showTooltipFor(e, content, node) {
|
42 |
+
var tooltip = showTooltip(e, content);
|
43 |
+
function hide() {
|
44 |
+
CodeMirror.off(node, "mouseout", hide);
|
45 |
+
if (tooltip) { hideTooltip(tooltip); tooltip = null; }
|
46 |
+
}
|
47 |
+
var poll = setInterval(function() {
|
48 |
+
if (tooltip) for (var n = node;; n = n.parentNode) {
|
49 |
+
if (n && n.nodeType == 11) n = n.host;
|
50 |
+
if (n == document.body) return;
|
51 |
+
if (!n) { hide(); break; }
|
52 |
+
}
|
53 |
+
if (!tooltip) return clearInterval(poll);
|
54 |
+
}, 400);
|
55 |
+
CodeMirror.on(node, "mouseout", hide);
|
56 |
+
}
|
57 |
+
|
58 |
+
function LintState(cm, options, hasGutter) {
|
59 |
+
this.marked = [];
|
60 |
+
this.options = options;
|
61 |
+
this.timeout = null;
|
62 |
+
this.hasGutter = hasGutter;
|
63 |
+
this.onMouseOver = function(e) { onMouseOver(cm, e); };
|
64 |
+
}
|
65 |
+
|
66 |
+
function parseOptions(cm, options) {
|
67 |
+
if (options instanceof Function) return {getAnnotations: options};
|
68 |
+
if (!options || options === true) options = {};
|
69 |
+
if (!options.getAnnotations) options.getAnnotations = cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
70 |
+
if (!options.getAnnotations) throw new Error("Required option 'getAnnotations' missing (lint addon)");
|
71 |
+
return options;
|
72 |
+
}
|
73 |
+
|
74 |
+
function clearMarks(cm) {
|
75 |
+
var state = cm.state.lint;
|
76 |
+
if (state.hasGutter) cm.clearGutter(GUTTER_ID);
|
77 |
+
for (var i = 0; i < state.marked.length; ++i)
|
78 |
+
state.marked[i].clear();
|
79 |
+
state.marked.length = 0;
|
80 |
+
}
|
81 |
+
|
82 |
+
function makeMarker(labels, severity, multiple, tooltips) {
|
83 |
+
var marker = document.createElement("div"), inner = marker;
|
84 |
+
marker.className = "CodeMirror-lint-marker-" + severity;
|
85 |
+
if (multiple) {
|
86 |
+
inner = marker.appendChild(document.createElement("div"));
|
87 |
+
inner.className = "CodeMirror-lint-marker-multiple";
|
88 |
+
}
|
89 |
+
|
90 |
+
if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) {
|
91 |
+
showTooltipFor(e, labels, inner);
|
92 |
+
});
|
93 |
+
|
94 |
+
return marker;
|
95 |
+
}
|
96 |
+
|
97 |
+
function getMaxSeverity(a, b) {
|
98 |
+
if (a == "error") return a;
|
99 |
+
else return b;
|
100 |
+
}
|
101 |
+
|
102 |
+
function groupByLine(annotations) {
|
103 |
+
var lines = [];
|
104 |
+
for (var i = 0; i < annotations.length; ++i) {
|
105 |
+
var ann = annotations[i], line = ann.from.line;
|
106 |
+
(lines[line] || (lines[line] = [])).push(ann);
|
107 |
+
}
|
108 |
+
return lines;
|
109 |
+
}
|
110 |
+
|
111 |
+
function annotationTooltip(ann) {
|
112 |
+
var severity = ann.severity;
|
113 |
+
if (!severity) severity = "error";
|
114 |
+
var tip = document.createElement("div");
|
115 |
+
tip.className = "CodeMirror-lint-message-" + severity;
|
116 |
+
tip.appendChild(document.createTextNode(ann.message));
|
117 |
+
return tip;
|
118 |
+
}
|
119 |
+
|
120 |
+
function startLinting(cm) {
|
121 |
+
var state = cm.state.lint, options = state.options;
|
122 |
+
var passOptions = options.options || options; // Support deprecated passing of `options` property in options
|
123 |
+
if (options.async || options.getAnnotations.async)
|
124 |
+
options.getAnnotations(cm.getValue(), updateLinting, passOptions, cm);
|
125 |
+
else
|
126 |
+
updateLinting(cm, options.getAnnotations(cm.getValue(), passOptions, cm));
|
127 |
+
}
|
128 |
+
|
129 |
+
function updateLinting(cm, annotationsNotSorted) {
|
130 |
+
clearMarks(cm);
|
131 |
+
var state = cm.state.lint, options = state.options;
|
132 |
+
|
133 |
+
var annotations = groupByLine(annotationsNotSorted);
|
134 |
+
|
135 |
+
for (var line = 0; line < annotations.length; ++line) {
|
136 |
+
var anns = annotations[line];
|
137 |
+
if (!anns) continue;
|
138 |
+
|
139 |
+
var maxSeverity = null;
|
140 |
+
var tipLabel = state.hasGutter && document.createDocumentFragment();
|
141 |
+
|
142 |
+
for (var i = 0; i < anns.length; ++i) {
|
143 |
+
var ann = anns[i];
|
144 |
+
var severity = ann.severity;
|
145 |
+
if (!severity) severity = "error";
|
146 |
+
maxSeverity = getMaxSeverity(maxSeverity, severity);
|
147 |
+
|
148 |
+
if (options.formatAnnotation) ann = options.formatAnnotation(ann);
|
149 |
+
if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann));
|
150 |
+
|
151 |
+
if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, {
|
152 |
+
className: "CodeMirror-lint-mark-" + severity,
|
153 |
+
__annotation: ann
|
154 |
+
}));
|
155 |
+
}
|
156 |
+
|
157 |
+
if (state.hasGutter)
|
158 |
+
cm.setGutterMarker(line, GUTTER_ID, makeMarker(tipLabel, maxSeverity, anns.length > 1,
|
159 |
+
state.options.tooltips));
|
160 |
+
}
|
161 |
+
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
|
162 |
+
}
|
163 |
+
|
164 |
+
function onChange(cm) {
|
165 |
+
var state = cm.state.lint;
|
166 |
+
if (!state) return;
|
167 |
+
clearTimeout(state.timeout);
|
168 |
+
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
|
169 |
+
}
|
170 |
+
|
171 |
+
function popupSpanTooltip(ann, e) {
|
172 |
+
var target = e.target || e.srcElement;
|
173 |
+
showTooltipFor(e, annotationTooltip(ann), target);
|
174 |
+
}
|
175 |
+
|
176 |
+
function onMouseOver(cm, e) {
|
177 |
+
var target = e.target || e.srcElement;
|
178 |
+
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
|
179 |
+
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
|
180 |
+
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
|
181 |
+
for (var i = 0; i < spans.length; ++i) {
|
182 |
+
var ann = spans[i].__annotation;
|
183 |
+
if (ann) return popupSpanTooltip(ann, e);
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
188 |
+
if (old && old != CodeMirror.Init) {
|
189 |
+
clearMarks(cm);
|
190 |
+
cm.off("change", onChange);
|
191 |
+
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
|
192 |
+
clearTimeout(cm.state.lint.timeout);
|
193 |
+
delete cm.state.lint;
|
194 |
+
}
|
195 |
+
|
196 |
+
if (val) {
|
197 |
+
var gutters = cm.getOption("gutters"), hasLintGutter = false;
|
198 |
+
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
|
199 |
+
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
|
200 |
+
cm.on("change", onChange);
|
201 |
+
if (state.options.tooltips != false)
|
202 |
+
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
|
203 |
+
|
204 |
+
startLinting(cm);
|
205 |
+
}
|
206 |
+
});
|
207 |
+
});
|
lib/codemirror/addon/lint/lint.min.js
ADDED
@@ -0,0 +1,34 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";var GUTTER_ID="CodeMirror-lint-markers";function showTooltip(e,content){var tt=document.createElement("div");tt.className="CodeMirror-lint-tooltip";tt.appendChild(content.cloneNode(true));document.body.appendChild(tt);function position(e){if(!tt.parentNode)return CodeMirror.off(document,"mousemove",position);tt.style.top=Math.max(0,e.clientY-tt.offsetHeight-5)+"px";tt.style.left=(e.clientX+5)+"px";}
|
6 |
+
CodeMirror.on(document,"mousemove",position);position(e);if(tt.style.opacity!=null)tt.style.opacity=1;return tt;}
|
7 |
+
function rm(elt){if(elt.parentNode)elt.parentNode.removeChild(elt);}
|
8 |
+
function hideTooltip(tt){if(!tt.parentNode)return;if(tt.style.opacity==null)rm(tt);tt.style.opacity=0;setTimeout(function(){rm(tt);},600);}
|
9 |
+
function showTooltipFor(e,content,node){var tooltip=showTooltip(e,content);function hide(){CodeMirror.off(node,"mouseout",hide);if(tooltip){hideTooltip(tooltip);tooltip=null;}}
|
10 |
+
var poll=setInterval(function(){if(tooltip)for(var n=node;;n=n.parentNode){if(n&&n.nodeType==11)n=n.host;if(n==document.body)return;if(!n){hide();break;}}
|
11 |
+
if(!tooltip)return clearInterval(poll);},400);CodeMirror.on(node,"mouseout",hide);}
|
12 |
+
function LintState(cm,options,hasGutter){this.marked=[];this.options=options;this.timeout=null;this.hasGutter=hasGutter;this.onMouseOver=function(e){onMouseOver(cm,e);};}
|
13 |
+
function parseOptions(cm,options){if(options instanceof Function)return{getAnnotations:options};if(!options||options===true)options={};if(!options.getAnnotations)options.getAnnotations=cm.getHelper(CodeMirror.Pos(0,0),"lint");if(!options.getAnnotations)throw new Error("Required option 'getAnnotations' missing (lint addon)");return options;}
|
14 |
+
function clearMarks(cm){var state=cm.state.lint;if(state.hasGutter)cm.clearGutter(GUTTER_ID);for(var i=0;i<state.marked.length;++i)
|
15 |
+
state.marked[i].clear();state.marked.length=0;}
|
16 |
+
function makeMarker(labels,severity,multiple,tooltips){var marker=document.createElement("div"),inner=marker;marker.className="CodeMirror-lint-marker-"+severity;if(multiple){inner=marker.appendChild(document.createElement("div"));inner.className="CodeMirror-lint-marker-multiple";}
|
17 |
+
if(tooltips!=false)CodeMirror.on(inner,"mouseover",function(e){showTooltipFor(e,labels,inner);});return marker;}
|
18 |
+
function getMaxSeverity(a,b){if(a=="error")return a;else return b;}
|
19 |
+
function groupByLine(annotations){var lines=[];for(var i=0;i<annotations.length;++i){var ann=annotations[i],line=ann.from.line;(lines[line]||(lines[line]=[])).push(ann);}
|
20 |
+
return lines;}
|
21 |
+
function annotationTooltip(ann){var severity=ann.severity;if(!severity)severity="error";var tip=document.createElement("div");tip.className="CodeMirror-lint-message-"+severity;tip.appendChild(document.createTextNode(ann.message));return tip;}
|
22 |
+
function startLinting(cm){var state=cm.state.lint,options=state.options;var passOptions=options.options||options;if(options.async||options.getAnnotations.async)
|
23 |
+
options.getAnnotations(cm.getValue(),updateLinting,passOptions,cm);else
|
24 |
+
updateLinting(cm,options.getAnnotations(cm.getValue(),passOptions,cm));}
|
25 |
+
function updateLinting(cm,annotationsNotSorted){clearMarks(cm);var state=cm.state.lint,options=state.options;var annotations=groupByLine(annotationsNotSorted);for(var line=0;line<annotations.length;++line){var anns=annotations[line];if(!anns)continue;var maxSeverity=null;var tipLabel=state.hasGutter&&document.createDocumentFragment();for(var i=0;i<anns.length;++i){var ann=anns[i];var severity=ann.severity;if(!severity)severity="error";maxSeverity=getMaxSeverity(maxSeverity,severity);if(options.formatAnnotation)ann=options.formatAnnotation(ann);if(state.hasGutter)tipLabel.appendChild(annotationTooltip(ann));if(ann.to)state.marked.push(cm.markText(ann.from,ann.to,{className:"CodeMirror-lint-mark-"+severity,__annotation:ann}));}
|
26 |
+
if(state.hasGutter)
|
27 |
+
cm.setGutterMarker(line,GUTTER_ID,makeMarker(tipLabel,maxSeverity,anns.length>1,state.options.tooltips));}
|
28 |
+
if(options.onUpdateLinting)options.onUpdateLinting(annotationsNotSorted,annotations,cm);}
|
29 |
+
function onChange(cm){var state=cm.state.lint;if(!state)return;clearTimeout(state.timeout);state.timeout=setTimeout(function(){startLinting(cm);},state.options.delay||500);}
|
30 |
+
function popupSpanTooltip(ann,e){var target=e.target||e.srcElement;showTooltipFor(e,annotationTooltip(ann),target);}
|
31 |
+
function onMouseOver(cm,e){var target=e.target||e.srcElement;if(!/\bCodeMirror-lint-mark-/.test(target.className))return;var box=target.getBoundingClientRect(),x=(box.left+box.right)/2,y=(box.top+box.bottom)/2;var spans=cm.findMarksAt(cm.coordsChar({left:x,top:y},"client"));for(var i=0;i<spans.length;++i){var ann=spans[i].__annotation;if(ann)return popupSpanTooltip(ann,e);}}
|
32 |
+
CodeMirror.defineOption("lint",false,function(cm,val,old){if(old&&old!=CodeMirror.Init){clearMarks(cm);cm.off("change",onChange);CodeMirror.off(cm.getWrapperElement(),"mouseover",cm.state.lint.onMouseOver);clearTimeout(cm.state.lint.timeout);delete cm.state.lint;}
|
33 |
+
if(val){var gutters=cm.getOption("gutters"),hasLintGutter=false;for(var i=0;i<gutters.length;++i)if(gutters[i]==GUTTER_ID)hasLintGutter=true;var state=cm.state.lint=new LintState(cm,parseOptions(cm,val),hasLintGutter);cm.on("change",onChange);if(state.options.tooltips!=false)
|
34 |
+
CodeMirror.on(cm.getWrapperElement(),"mouseover",state.onMouseOver);startLinting(cm);}});});
|
lib/codemirror/addon/lint/yaml-lint.js
ADDED
@@ -0,0 +1,28 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
// Depends on js-yaml.js from https://github.com/nodeca/js-yaml
|
15 |
+
|
16 |
+
// declare global: jsyaml
|
17 |
+
|
18 |
+
CodeMirror.registerHelper("lint", "yaml", function(text) {
|
19 |
+
var found = [];
|
20 |
+
try { jsyaml.load(text); }
|
21 |
+
catch(e) {
|
22 |
+
var loc = e.mark;
|
23 |
+
found.push({ from: CodeMirror.Pos(loc.line, loc.column), to: CodeMirror.Pos(loc.line, loc.column), message: e.message });
|
24 |
+
}
|
25 |
+
return found;
|
26 |
+
});
|
27 |
+
|
28 |
+
});
|
lib/codemirror/addon/lint/yaml-lint.min.js
ADDED
@@ -0,0 +1,7 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror"],mod);else
|
5 |
+
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("lint","yaml",function(text){var found=[];try{jsyaml.load(text);}
|
6 |
+
catch(e){var loc=e.mark;found.push({from:CodeMirror.Pos(loc.line,loc.column),to:CodeMirror.Pos(loc.line,loc.column),message:e.message});}
|
7 |
+
return found;});});
|
lib/codemirror/addon/merge/merge.css
ADDED
@@ -0,0 +1,112 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
.CodeMirror-merge {
|
2 |
+
position: relative;
|
3 |
+
border: 1px solid #ddd;
|
4 |
+
white-space: pre;
|
5 |
+
}
|
6 |
+
|
7 |
+
.CodeMirror-merge, .CodeMirror-merge .CodeMirror {
|
8 |
+
height: 350px;
|
9 |
+
}
|
10 |
+
|
11 |
+
.CodeMirror-merge-2pane .CodeMirror-merge-pane { width: 47%; }
|
12 |
+
.CodeMirror-merge-2pane .CodeMirror-merge-gap { width: 6%; }
|
13 |
+
.CodeMirror-merge-3pane .CodeMirror-merge-pane { width: 31%; }
|
14 |
+
.CodeMirror-merge-3pane .CodeMirror-merge-gap { width: 3.5%; }
|
15 |
+
|
16 |
+
.CodeMirror-merge-pane {
|
17 |
+
display: inline-block;
|
18 |
+
white-space: normal;
|
19 |
+
vertical-align: top;
|
20 |
+
}
|
21 |
+
.CodeMirror-merge-pane-rightmost {
|
22 |
+
position: absolute;
|
23 |
+
right: 0px;
|
24 |
+
z-index: 1;
|
25 |
+
}
|
26 |
+
|
27 |
+
.CodeMirror-merge-gap {
|
28 |
+
z-index: 2;
|
29 |
+
display: inline-block;
|
30 |
+
height: 100%;
|
31 |
+
-moz-box-sizing: border-box;
|
32 |
+
box-sizing: border-box;
|
33 |
+
overflow: hidden;
|
34 |
+
border-left: 1px solid #ddd;
|
35 |
+
border-right: 1px solid #ddd;
|
36 |
+
position: relative;
|
37 |
+
background: #f8f8f8;
|
38 |
+
}
|
39 |
+
|
40 |
+
.CodeMirror-merge-scrolllock-wrap {
|
41 |
+
position: absolute;
|
42 |
+
bottom: 0; left: 50%;
|
43 |
+
}
|
44 |
+
.CodeMirror-merge-scrolllock {
|
45 |
+
position: relative;
|
46 |
+
left: -50%;
|
47 |
+
cursor: pointer;
|
48 |
+
color: #555;
|
49 |
+
line-height: 1;
|
50 |
+
}
|
51 |
+
|
52 |
+
.CodeMirror-merge-copybuttons-left, .CodeMirror-merge-copybuttons-right {
|
53 |
+
position: absolute;
|
54 |
+
left: 0; top: 0;
|
55 |
+
right: 0; bottom: 0;
|
56 |
+
line-height: 1;
|
57 |
+
}
|
58 |
+
|
59 |
+
.CodeMirror-merge-copy {
|
60 |
+
position: absolute;
|
61 |
+
cursor: pointer;
|
62 |
+
color: #44c;
|
63 |
+
}
|
64 |
+
|
65 |
+
.CodeMirror-merge-copy-reverse {
|
66 |
+
position: absolute;
|
67 |
+
cursor: pointer;
|
68 |
+
color: #44c;
|
69 |
+
}
|
70 |
+
|
71 |
+
.CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy { left: 2px; }
|
72 |
+
.CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy { right: 2px; }
|
73 |
+
|
74 |
+
.CodeMirror-merge-r-inserted, .CodeMirror-merge-l-inserted {
|
75 |
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==);
|
76 |
+
background-position: bottom left;
|
77 |
+
background-repeat: repeat-x;
|
78 |
+
}
|
79 |
+
|
80 |
+
.CodeMirror-merge-r-deleted, .CodeMirror-merge-l-deleted {
|
81 |
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==);
|
82 |
+
background-position: bottom left;
|
83 |
+
background-repeat: repeat-x;
|
84 |
+
}
|
85 |
+
|
86 |
+
.CodeMirror-merge-r-chunk { background: #ffffe0; }
|
87 |
+
.CodeMirror-merge-r-chunk-start { border-top: 1px solid #ee8; }
|
88 |
+
.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #ee8; }
|
89 |
+
.CodeMirror-merge-r-connect { fill: #ffffe0; stroke: #ee8; stroke-width: 1px; }
|
90 |
+
|
91 |
+
.CodeMirror-merge-l-chunk { background: #eef; }
|
92 |
+
.CodeMirror-merge-l-chunk-start { border-top: 1px solid #88e; }
|
93 |
+
.CodeMirror-merge-l-chunk-end { border-bottom: 1px solid #88e; }
|
94 |
+
.CodeMirror-merge-l-connect { fill: #eef; stroke: #88e; stroke-width: 1px; }
|
95 |
+
|
96 |
+
.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk { background: #dfd; }
|
97 |
+
.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start { border-top: 1px solid #4e4; }
|
98 |
+
.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #4e4; }
|
99 |
+
|
100 |
+
.CodeMirror-merge-collapsed-widget:before {
|
101 |
+
content: "(...)";
|
102 |
+
}
|
103 |
+
.CodeMirror-merge-collapsed-widget {
|
104 |
+
cursor: pointer;
|
105 |
+
color: #88b;
|
106 |
+
background: #eef;
|
107 |
+
border: 1px solid #ddf;
|
108 |
+
font-size: 90%;
|
109 |
+
padding: 0 3px;
|
110 |
+
border-radius: 4px;
|
111 |
+
}
|
112 |
+
.CodeMirror-merge-collapsed-line .CodeMirror-gutter-elt { display: none; }
|
lib/codemirror/addon/merge/merge.js
ADDED
@@ -0,0 +1,775 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
|
5 |
+
|
6 |
+
(function(mod) {
|
7 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
8 |
+
mod(require("../../lib/codemirror"), require("diff_match_patch"));
|
9 |
+
else if (typeof define == "function" && define.amd) // AMD
|
10 |
+
define(["../../lib/codemirror", "diff_match_patch"], mod);
|
11 |
+
else // Plain browser env
|
12 |
+
mod(CodeMirror, diff_match_patch);
|
13 |
+
})(function(CodeMirror, diff_match_patch) {
|
14 |
+
"use strict";
|
15 |
+
var Pos = CodeMirror.Pos;
|
16 |
+
var svgNS = "http://www.w3.org/2000/svg";
|
17 |
+
|
18 |
+
function DiffView(mv, type) {
|
19 |
+
this.mv = mv;
|
20 |
+
this.type = type;
|
21 |
+
this.classes = type == "left"
|
22 |
+
? {chunk: "CodeMirror-merge-l-chunk",
|
23 |
+
start: "CodeMirror-merge-l-chunk-start",
|
24 |
+
end: "CodeMirror-merge-l-chunk-end",
|
25 |
+
insert: "CodeMirror-merge-l-inserted",
|
26 |
+
del: "CodeMirror-merge-l-deleted",
|
27 |
+
connect: "CodeMirror-merge-l-connect"}
|
28 |
+
: {chunk: "CodeMirror-merge-r-chunk",
|
29 |
+
start: "CodeMirror-merge-r-chunk-start",
|
30 |
+
end: "CodeMirror-merge-r-chunk-end",
|
31 |
+
insert: "CodeMirror-merge-r-inserted",
|
32 |
+
del: "CodeMirror-merge-r-deleted",
|
33 |
+
connect: "CodeMirror-merge-r-connect"};
|
34 |
+
}
|
35 |
+
|
36 |
+
DiffView.prototype = {
|
37 |
+
constructor: DiffView,
|
38 |
+
init: function(pane, orig, options) {
|
39 |
+
this.edit = this.mv.edit;
|
40 |
+
(this.edit.state.diffViews || (this.edit.state.diffViews = [])).push(this);
|
41 |
+
this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options)));
|
42 |
+
this.orig.state.diffViews = [this];
|
43 |
+
|
44 |
+
this.diff = getDiff(asString(orig), asString(options.value));
|
45 |
+
this.chunks = getChunks(this.diff);
|
46 |
+
this.diffOutOfDate = this.dealigned = false;
|
47 |
+
|
48 |
+
this.showDifferences = options.showDifferences !== false;
|
49 |
+
this.forceUpdate = registerUpdate(this);
|
50 |
+
setScrollLock(this, true, false);
|
51 |
+
registerScroll(this);
|
52 |
+
},
|
53 |
+
setShowDifferences: function(val) {
|
54 |
+
val = val !== false;
|
55 |
+
if (val != this.showDifferences) {
|
56 |
+
this.showDifferences = val;
|
57 |
+
this.forceUpdate("full");
|
58 |
+
}
|
59 |
+
}
|
60 |
+
};
|
61 |
+
|
62 |
+
function ensureDiff(dv) {
|
63 |
+
if (dv.diffOutOfDate) {
|
64 |
+
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue());
|
65 |
+
dv.chunks = getChunks(dv.diff);
|
66 |
+
dv.diffOutOfDate = false;
|
67 |
+
CodeMirror.signal(dv.edit, "updateDiff", dv.diff);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
var updating = false;
|
72 |
+
function registerUpdate(dv) {
|
73 |
+
var edit = {from: 0, to: 0, marked: []};
|
74 |
+
var orig = {from: 0, to: 0, marked: []};
|
75 |
+
var debounceChange, updatingFast = false;
|
76 |
+
function update(mode) {
|
77 |
+
updating = true;
|
78 |
+
updatingFast = false;
|
79 |
+
if (mode == "full") {
|
80 |
+
if (dv.svg) clear(dv.svg);
|
81 |
+
if (dv.copyButtons) clear(dv.copyButtons);
|
82 |
+
clearMarks(dv.edit, edit.marked, dv.classes);
|
83 |
+
clearMarks(dv.orig, orig.marked, dv.classes);
|
84 |
+
edit.from = edit.to = orig.from = orig.to = 0;
|
85 |
+
}
|
86 |
+
ensureDiff(dv);
|
87 |
+
if (dv.showDifferences) {
|
88 |
+
updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes);
|
89 |
+
updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes);
|
90 |
+
}
|
91 |
+
makeConnections(dv);
|
92 |
+
|
93 |
+
if (dv.mv.options.connect == "align")
|
94 |
+
alignChunks(dv);
|
95 |
+
updating = false;
|
96 |
+
}
|
97 |
+
function setDealign(fast) {
|
98 |
+
if (updating) return;
|
99 |
+
dv.dealigned = true;
|
100 |
+
set(fast);
|
101 |
+
}
|
102 |
+
function set(fast) {
|
103 |
+
if (updating || updatingFast) return;
|
104 |
+
clearTimeout(debounceChange);
|
105 |
+
if (fast === true) updatingFast = true;
|
106 |
+
debounceChange = setTimeout(update, fast === true ? 20 : 250);
|
107 |
+
}
|
108 |
+
function change(_cm, change) {
|
109 |
+
if (!dv.diffOutOfDate) {
|
110 |
+
dv.diffOutOfDate = true;
|
111 |
+
edit.from = edit.to = orig.from = orig.to = 0;
|
112 |
+
}
|
113 |
+
// Update faster when a line was added/removed
|
114 |
+
setDealign(change.text.length - 1 != change.to.line - change.from.line);
|
115 |
+
}
|
116 |
+
dv.edit.on("change", change);
|
117 |
+
dv.orig.on("change", change);
|
118 |
+
dv.edit.on("markerAdded", setDealign);
|
119 |
+
dv.edit.on("markerCleared", setDealign);
|
120 |
+
dv.orig.on("markerAdded", setDealign);
|
121 |
+
dv.orig.on("markerCleared", setDealign);
|
122 |
+
dv.edit.on("viewportChange", function() { set(false); });
|
123 |
+
dv.orig.on("viewportChange", function() { set(false); });
|
124 |
+
update();
|
125 |
+
return update;
|
126 |
+
}
|
127 |
+
|
128 |
+
function registerScroll(dv) {
|
129 |
+
dv.edit.on("scroll", function() {
|
130 |
+
syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
|
131 |
+
});
|
132 |
+
dv.orig.on("scroll", function() {
|
133 |
+
syncScroll(dv, DIFF_DELETE) && makeConnections(dv);
|
134 |
+
});
|
135 |
+
}
|
136 |
+
|
137 |
+
function syncScroll(dv, type) {
|
138 |
+
// Change handler will do a refresh after a timeout when diff is out of date
|
139 |
+
if (dv.diffOutOfDate) return false;
|
140 |
+
if (!dv.lockScroll) return true;
|
141 |
+
var editor, other, now = +new Date;
|
142 |
+
if (type == DIFF_INSERT) { editor = dv.edit; other = dv.orig; }
|
143 |
+
else { editor = dv.orig; other = dv.edit; }
|
144 |
+
// Don't take action if the position of this editor was recently set
|
145 |
+
// (to prevent feedback loops)
|
146 |
+
if (editor.state.scrollSetBy == dv && (editor.state.scrollSetAt || 0) + 50 > now) return false;
|
147 |
+
|
148 |
+
var sInfo = editor.getScrollInfo();
|
149 |
+
if (dv.mv.options.connect == "align") {
|
150 |
+
targetPos = sInfo.top;
|
151 |
+
} else {
|
152 |
+
var halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen;
|
153 |
+
var mid = editor.lineAtHeight(midY, "local");
|
154 |
+
var around = chunkBoundariesAround(dv.chunks, mid, type == DIFF_INSERT);
|
155 |
+
var off = getOffsets(editor, type == DIFF_INSERT ? around.edit : around.orig);
|
156 |
+
var offOther = getOffsets(other, type == DIFF_INSERT ? around.orig : around.edit);
|
157 |
+
var ratio = (midY - off.top) / (off.bot - off.top);
|
158 |
+
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top);
|
159 |
+
|
160 |
+
var botDist, mix;
|
161 |
+
// Some careful tweaking to make sure no space is left out of view
|
162 |
+
// when scrolling to top or bottom.
|
163 |
+
if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) {
|
164 |
+
targetPos = targetPos * mix + sInfo.top * (1 - mix);
|
165 |
+
} else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) {
|
166 |
+
var otherInfo = other.getScrollInfo();
|
167 |
+
var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos;
|
168 |
+
if (botDistOther > botDist && (mix = botDist / halfScreen) < 1)
|
169 |
+
targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix);
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
other.scrollTo(sInfo.left, targetPos);
|
174 |
+
other.state.scrollSetAt = now;
|
175 |
+
other.state.scrollSetBy = dv;
|
176 |
+
return true;
|
177 |
+
}
|
178 |
+
|
179 |
+
function getOffsets(editor, around) {
|
180 |
+
var bot = around.after;
|
181 |
+
if (bot == null) bot = editor.lastLine() + 1;
|
182 |
+
return {top: editor.heightAtLine(around.before || 0, "local"),
|
183 |
+
bot: editor.heightAtLine(bot, "local")};
|
184 |
+
}
|
185 |
+
|
186 |
+
function setScrollLock(dv, val, action) {
|
187 |
+
dv.lockScroll = val;
|
188 |
+
if (val && action != false) syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
|
189 |
+
dv.lockButton.innerHTML = val ? "\u21db\u21da" : "\u21db \u21da";
|
190 |
+
}
|
191 |
+
|
192 |
+
// Updating the marks for editor content
|
193 |
+
|
194 |
+
function clearMarks(editor, arr, classes) {
|
195 |
+
for (var i = 0; i < arr.length; ++i) {
|
196 |
+
var mark = arr[i];
|
197 |
+
if (mark instanceof CodeMirror.TextMarker) {
|
198 |
+
mark.clear();
|
199 |
+
} else if (mark.parent) {
|
200 |
+
editor.removeLineClass(mark, "background", classes.chunk);
|
201 |
+
editor.removeLineClass(mark, "background", classes.start);
|
202 |
+
editor.removeLineClass(mark, "background", classes.end);
|
203 |
+
}
|
204 |
+
}
|
205 |
+
arr.length = 0;
|
206 |
+
}
|
207 |
+
|
208 |
+
// FIXME maybe add a margin around viewport to prevent too many updates
|
209 |
+
function updateMarks(editor, diff, state, type, classes) {
|
210 |
+
var vp = editor.getViewport();
|
211 |
+
editor.operation(function() {
|
212 |
+
if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
|
213 |
+
clearMarks(editor, state.marked, classes);
|
214 |
+
markChanges(editor, diff, type, state.marked, vp.from, vp.to, classes);
|
215 |
+
state.from = vp.from; state.to = vp.to;
|
216 |
+
} else {
|
217 |
+
if (vp.from < state.from) {
|
218 |
+
markChanges(editor, diff, type, state.marked, vp.from, state.from, classes);
|
219 |
+
state.from = vp.from;
|
220 |
+
}
|
221 |
+
if (vp.to > state.to) {
|
222 |
+
markChanges(editor, diff, type, state.marked, state.to, vp.to, classes);
|
223 |
+
state.to = vp.to;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
});
|
227 |
+
}
|
228 |
+
|
229 |
+
function markChanges(editor, diff, type, marks, from, to, classes) {
|
230 |
+
var pos = Pos(0, 0);
|
231 |
+
var top = Pos(from, 0), bot = editor.clipPos(Pos(to - 1));
|
232 |
+
var cls = type == DIFF_DELETE ? classes.del : classes.insert;
|
233 |
+
function markChunk(start, end) {
|
234 |
+
var bfrom = Math.max(from, start), bto = Math.min(to, end);
|
235 |
+
for (var i = bfrom; i < bto; ++i) {
|
236 |
+
var line = editor.addLineClass(i, "background", classes.chunk);
|
237 |
+
if (i == start) editor.addLineClass(line, "background", classes.start);
|
238 |
+
if (i == end - 1) editor.addLineClass(line, "background", classes.end);
|
239 |
+
marks.push(line);
|
240 |
+
}
|
241 |
+
// When the chunk is empty, make sure a horizontal line shows up
|
242 |
+
if (start == end && bfrom == end && bto == end) {
|
243 |
+
if (bfrom)
|
244 |
+
marks.push(editor.addLineClass(bfrom - 1, "background", classes.end));
|
245 |
+
else
|
246 |
+
marks.push(editor.addLineClass(bfrom, "background", classes.start));
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
var chunkStart = 0;
|
251 |
+
for (var i = 0; i < diff.length; ++i) {
|
252 |
+
var part = diff[i], tp = part[0], str = part[1];
|
253 |
+
if (tp == DIFF_EQUAL) {
|
254 |
+
var cleanFrom = pos.line + (startOfLineClean(diff, i) ? 0 : 1);
|
255 |
+
moveOver(pos, str);
|
256 |
+
var cleanTo = pos.line + (endOfLineClean(diff, i) ? 1 : 0);
|
257 |
+
if (cleanTo > cleanFrom) {
|
258 |
+
if (i) markChunk(chunkStart, cleanFrom);
|
259 |
+
chunkStart = cleanTo;
|
260 |
+
}
|
261 |
+
} else {
|
262 |
+
if (tp == type) {
|
263 |
+
var end = moveOver(pos, str, true);
|
264 |
+
var a = posMax(top, pos), b = posMin(bot, end);
|
265 |
+
if (!posEq(a, b))
|
266 |
+
marks.push(editor.markText(a, b, {className: cls}));
|
267 |
+
pos = end;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
+
if (chunkStart <= pos.line) markChunk(chunkStart, pos.line + 1);
|
272 |
+
}
|
273 |
+
|
274 |
+
// Updating the gap between editor and original
|
275 |
+
|
276 |
+
function makeConnections(dv) {
|
277 |
+
if (!dv.showDifferences) return;
|
278 |
+
|
279 |
+
if (dv.svg) {
|
280 |
+
clear(dv.svg);
|
281 |
+
var w = dv.gap.offsetWidth;
|
282 |
+
attrs(dv.svg, "width", w, "height", dv.gap.offsetHeight);
|
283 |
+
}
|
284 |
+
if (dv.copyButtons) clear(dv.copyButtons);
|
285 |
+
|
286 |
+
var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
|
287 |
+
var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top;
|
288 |
+
for (var i = 0; i < dv.chunks.length; i++) {
|
289 |
+
var ch = dv.chunks[i];
|
290 |
+
if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from &&
|
291 |
+
ch.origFrom <= vpOrig.to && ch.origTo >= vpOrig.from)
|
292 |
+
drawConnectorsForChunk(dv, ch, sTopOrig, sTopEdit, w);
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
function getMatchingOrigLine(editLine, chunks) {
|
297 |
+
var editStart = 0, origStart = 0;
|
298 |
+
for (var i = 0; i < chunks.length; i++) {
|
299 |
+
var chunk = chunks[i];
|
300 |
+
if (chunk.editTo > editLine && chunk.editFrom <= editLine) return null;
|
301 |
+
if (chunk.editFrom > editLine) break;
|
302 |
+
editStart = chunk.editTo;
|
303 |
+
origStart = chunk.origTo;
|
304 |
+
}
|
305 |
+
return origStart + (editLine - editStart);
|
306 |
+
}
|
307 |
+
|
308 |
+
function findAlignedLines(dv, other) {
|
309 |
+
var linesToAlign = [];
|
310 |
+
for (var i = 0; i < dv.chunks.length; i++) {
|
311 |
+
var chunk = dv.chunks[i];
|
312 |
+
linesToAlign.push([chunk.origTo, chunk.editTo, other ? getMatchingOrigLine(chunk.editTo, other.chunks) : null]);
|
313 |
+
}
|
314 |
+
if (other) {
|
315 |
+
for (var i = 0; i < other.chunks.length; i++) {
|
316 |
+
var chunk = other.chunks[i];
|
317 |
+
for (var j = 0; j < linesToAlign.length; j++) {
|
318 |
+
var align = linesToAlign[j];
|
319 |
+
if (align[1] == chunk.editTo) {
|
320 |
+
j = -1;
|
321 |
+
break;
|
322 |
+
} else if (align[1] > chunk.editTo) {
|
323 |
+
break;
|
324 |
+
}
|
325 |
+
}
|
326 |
+
if (j > -1)
|
327 |
+
linesToAlign.splice(j - 1, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]);
|
328 |
+
}
|
329 |
+
}
|
330 |
+
return linesToAlign;
|
331 |
+
}
|
332 |
+
|
333 |
+
function alignChunks(dv, force) {
|
334 |
+
if (!dv.dealigned && !force) return;
|
335 |
+
if (!dv.orig.curOp) return dv.orig.operation(function() {
|
336 |
+
alignChunks(dv, force);
|
337 |
+
});
|
338 |
+
|
339 |
+
dv.dealigned = false;
|
340 |
+
var other = dv.mv.left == dv ? dv.mv.right : dv.mv.left;
|
341 |
+
if (other) {
|
342 |
+
ensureDiff(other);
|
343 |
+
other.dealigned = false;
|
344 |
+
}
|
345 |
+
var linesToAlign = findAlignedLines(dv, other);
|
346 |
+
|
347 |
+
// Clear old aligners
|
348 |
+
var aligners = dv.mv.aligners;
|
349 |
+
for (var i = 0; i < aligners.length; i++)
|
350 |
+
aligners[i].clear();
|
351 |
+
aligners.length = 0;
|
352 |
+
|
353 |
+
var cm = [dv.orig, dv.edit], scroll = [];
|
354 |
+
if (other) cm.push(other.orig);
|
355 |
+
for (var i = 0; i < cm.length; i++)
|
356 |
+
scroll.push(cm[i].getScrollInfo().top);
|
357 |
+
|
358 |
+
for (var ln = 0; ln < linesToAlign.length; ln++)
|
359 |
+
alignLines(cm, linesToAlign[ln], aligners);
|
360 |
+
|
361 |
+
for (var i = 0; i < cm.length; i++)
|
362 |
+
cm[i].scrollTo(null, scroll[i]);
|
363 |
+
}
|
364 |
+
|
365 |
+
function alignLines(cm, lines, aligners) {
|
366 |
+
var maxOffset = 0, offset = [];
|
367 |
+
for (var i = 0; i < cm.length; i++) if (lines[i] != null) {
|
368 |
+
var off = cm[i].heightAtLine(lines[i], "local");
|
369 |
+
offset[i] = off;
|
370 |
+
maxOffset = Math.max(maxOffset, off);
|
371 |
+
}
|
372 |
+
for (var i = 0; i < cm.length; i++) if (lines[i] != null) {
|
373 |
+
var diff = maxOffset - offset[i];
|
374 |
+
if (diff > 1)
|
375 |
+
aligners.push(padAbove(cm[i], lines[i], diff));
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
function padAbove(cm, line, size) {
|
380 |
+
var above = true;
|
381 |
+
if (line > cm.lastLine()) {
|
382 |
+
line--;
|
383 |
+
above = false;
|
384 |
+
}
|
385 |
+
var elt = document.createElement("div");
|
386 |
+
elt.className = "CodeMirror-merge-spacer";
|
387 |
+
elt.style.height = size + "px"; elt.style.minWidth = "1px";
|
388 |
+
return cm.addLineWidget(line, elt, {height: size, above: above});
|
389 |
+
}
|
390 |
+
|
391 |
+
function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) {
|
392 |
+
var flip = dv.type == "left";
|
393 |
+
var top = dv.orig.heightAtLine(chunk.origFrom, "local") - sTopOrig;
|
394 |
+
if (dv.svg) {
|
395 |
+
var topLpx = top;
|
396 |
+
var topRpx = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit;
|
397 |
+
if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; }
|
398 |
+
var botLpx = dv.orig.heightAtLine(chunk.origTo, "local") - sTopOrig;
|
399 |
+
var botRpx = dv.edit.heightAtLine(chunk.editTo, "local") - sTopEdit;
|
400 |
+
if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; }
|
401 |
+
var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx;
|
402 |
+
var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx;
|
403 |
+
attrs(dv.svg.appendChild(document.createElementNS(svgNS, "path")),
|
404 |
+
"d", "M -1 " + topRpx + curveTop + " L " + (w + 2) + " " + botLpx + curveBot + " z",
|
405 |
+
"class", dv.classes.connect);
|
406 |
+
}
|
407 |
+
if (dv.copyButtons) {
|
408 |
+
var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc",
|
409 |
+
"CodeMirror-merge-copy"));
|
410 |
+
var editOriginals = dv.mv.options.allowEditingOriginals;
|
411 |
+
copy.title = editOriginals ? "Push to left" : "Revert chunk";
|
412 |
+
copy.chunk = chunk;
|
413 |
+
copy.style.top = top + "px";
|
414 |
+
|
415 |
+
if (editOriginals) {
|
416 |
+
var topReverse = dv.orig.heightAtLine(chunk.editFrom, "local") - sTopEdit;
|
417 |
+
var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc",
|
418 |
+
"CodeMirror-merge-copy-reverse"));
|
419 |
+
copyReverse.title = "Push to right";
|
420 |
+
copyReverse.chunk = {editFrom: chunk.origFrom, editTo: chunk.origTo,
|
421 |
+
origFrom: chunk.editFrom, origTo: chunk.editTo};
|
422 |
+
copyReverse.style.top = topReverse + "px";
|
423 |
+
dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px";
|
424 |
+
}
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
function copyChunk(dv, to, from, chunk) {
|
429 |
+
if (dv.diffOutOfDate) return;
|
430 |
+
to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
|
431 |
+
Pos(chunk.editFrom, 0), Pos(chunk.editTo, 0));
|
432 |
+
}
|
433 |
+
|
434 |
+
// Merge view, containing 0, 1, or 2 diff views.
|
435 |
+
|
436 |
+
var MergeView = CodeMirror.MergeView = function(node, options) {
|
437 |
+
if (!(this instanceof MergeView)) return new MergeView(node, options);
|
438 |
+
|
439 |
+
this.options = options;
|
440 |
+
var origLeft = options.origLeft, origRight = options.origRight == null ? options.orig : options.origRight;
|
441 |
+
|
442 |
+
var hasLeft = origLeft != null, hasRight = origRight != null;
|
443 |
+
var panes = 1 + (hasLeft ? 1 : 0) + (hasRight ? 1 : 0);
|
444 |
+
var wrap = [], left = this.left = null, right = this.right = null;
|
445 |
+
var self = this;
|
446 |
+
|
447 |
+
if (hasLeft) {
|
448 |
+
left = this.left = new DiffView(this, "left");
|
449 |
+
var leftPane = elt("div", null, "CodeMirror-merge-pane");
|
450 |
+
wrap.push(leftPane);
|
451 |
+
wrap.push(buildGap(left));
|
452 |
+
}
|
453 |
+
|
454 |
+
var editPane = elt("div", null, "CodeMirror-merge-pane");
|
455 |
+
wrap.push(editPane);
|
456 |
+
|
457 |
+
if (hasRight) {
|
458 |
+
right = this.right = new DiffView(this, "right");
|
459 |
+
wrap.push(buildGap(right));
|
460 |
+
var rightPane = elt("div", null, "CodeMirror-merge-pane");
|
461 |
+
wrap.push(rightPane);
|
462 |
+
}
|
463 |
+
|
464 |
+
(hasRight ? rightPane : editPane).className += " CodeMirror-merge-pane-rightmost";
|
465 |
+
|
466 |
+
wrap.push(elt("div", null, null, "height: 0; clear: both;"));
|
467 |
+
|
468 |
+
var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-merge CodeMirror-merge-" + panes + "pane"));
|
469 |
+
this.edit = CodeMirror(editPane, copyObj(options));
|
470 |
+
|
471 |
+
if (left) left.init(leftPane, origLeft, options);
|
472 |
+
if (right) right.init(rightPane, origRight, options);
|
473 |
+
|
474 |
+
if (options.collapseIdentical) {
|
475 |
+
updating = true;
|
476 |
+
this.editor().operation(function() {
|
477 |
+
collapseIdenticalStretches(self, options.collapseIdentical);
|
478 |
+
});
|
479 |
+
updating = false;
|
480 |
+
}
|
481 |
+
if (options.connect == "align") {
|
482 |
+
this.aligners = [];
|
483 |
+
alignChunks(this.left || this.right, true);
|
484 |
+
}
|
485 |
+
|
486 |
+
var onResize = function() {
|
487 |
+
if (left) makeConnections(left);
|
488 |
+
if (right) makeConnections(right);
|
489 |
+
};
|
490 |
+
CodeMirror.on(window, "resize", onResize);
|
491 |
+
var resizeInterval = setInterval(function() {
|
492 |
+
for (var p = wrapElt.parentNode; p && p != document.body; p = p.parentNode) {}
|
493 |
+
if (!p) { clearInterval(resizeInterval); CodeMirror.off(window, "resize", onResize); }
|
494 |
+
}, 5000);
|
495 |
+
};
|
496 |
+
|
497 |
+
function buildGap(dv) {
|
498 |
+
var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock");
|
499 |
+
lock.title = "Toggle locked scrolling";
|
500 |
+
var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap");
|
501 |
+
CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); });
|
502 |
+
var gapElts = [lockWrap];
|
503 |
+
if (dv.mv.options.revertButtons !== false) {
|
504 |
+
dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type);
|
505 |
+
CodeMirror.on(dv.copyButtons, "click", function(e) {
|
506 |
+
var node = e.target || e.srcElement;
|
507 |
+
if (!node.chunk) return;
|
508 |
+
if (node.className == "CodeMirror-merge-copy-reverse") {
|
509 |
+
copyChunk(dv, dv.orig, dv.edit, node.chunk);
|
510 |
+
return;
|
511 |
+
}
|
512 |
+
copyChunk(dv, dv.edit, dv.orig, node.chunk);
|
513 |
+
});
|
514 |
+
gapElts.unshift(dv.copyButtons);
|
515 |
+
}
|
516 |
+
if (dv.mv.options.connect != "align") {
|
517 |
+
var svg = document.createElementNS && document.createElementNS(svgNS, "svg");
|
518 |
+
if (svg && !svg.createSVGRect) svg = null;
|
519 |
+
dv.svg = svg;
|
520 |
+
if (svg) gapElts.push(svg);
|
521 |
+
}
|
522 |
+
|
523 |
+
return dv.gap = elt("div", gapElts, "CodeMirror-merge-gap");
|
524 |
+
}
|
525 |
+
|
526 |
+
MergeView.prototype = {
|
527 |
+
constuctor: MergeView,
|
528 |
+
editor: function() { return this.edit; },
|
529 |
+
rightOriginal: function() { return this.right && this.right.orig; },
|
530 |
+
leftOriginal: function() { return this.left && this.left.orig; },
|
531 |
+
setShowDifferences: function(val) {
|
532 |
+
if (this.right) this.right.setShowDifferences(val);
|
533 |
+
if (this.left) this.left.setShowDifferences(val);
|
534 |
+
},
|
535 |
+
rightChunks: function() {
|
536 |
+
if (this.right) { ensureDiff(this.right); return this.right.chunks; }
|
537 |
+
},
|
538 |
+
leftChunks: function() {
|
539 |
+
if (this.left) { ensureDiff(this.left); return this.left.chunks; }
|
540 |
+
}
|
541 |
+
};
|
542 |
+
|
543 |
+
function asString(obj) {
|
544 |
+
if (typeof obj == "string") return obj;
|
545 |
+
else return obj.getValue();
|
546 |
+
}
|
547 |
+
|
548 |
+
// Operations on diffs
|
549 |
+
|
550 |
+
var dmp = new diff_match_patch();
|
551 |
+
function getDiff(a, b) {
|
552 |
+
var diff = dmp.diff_main(a, b);
|
553 |
+
dmp.diff_cleanupSemantic(diff);
|
554 |
+
// The library sometimes leaves in empty parts, which confuse the algorithm
|
555 |
+
for (var i = 0; i < diff.length; ++i) {
|
556 |
+
var part = diff[i];
|
557 |
+
if (!part[1]) {
|
558 |
+
diff.splice(i--, 1);
|
559 |
+
} else if (i && diff[i - 1][0] == part[0]) {
|
560 |
+
diff.splice(i--, 1);
|
561 |
+
diff[i][1] += part[1];
|
562 |
+
}
|
563 |
+
}
|
564 |
+
return diff;
|
565 |
+
}
|
566 |
+
|
567 |
+
function getChunks(diff) {
|
568 |
+
var chunks = [];
|
569 |
+
var startEdit = 0, startOrig = 0;
|
570 |
+
var edit = Pos(0, 0), orig = Pos(0, 0);
|
571 |
+
for (var i = 0; i < diff.length; ++i) {
|
572 |
+
var part = diff[i], tp = part[0];
|
573 |
+
if (tp == DIFF_EQUAL) {
|
574 |
+
var startOff = startOfLineClean(diff, i) ? 0 : 1;
|
575 |
+
var cleanFromEdit = edit.line + startOff, cleanFromOrig = orig.line + startOff;
|
576 |
+
moveOver(edit, part[1], null, orig);
|
577 |
+
var endOff = endOfLineClean(diff, i) ? 1 : 0;
|
578 |
+
var cleanToEdit = edit.line + endOff, cleanToOrig = orig.line + endOff;
|
579 |
+
if (cleanToEdit > cleanFromEdit) {
|
580 |
+
if (i) chunks.push({origFrom: startOrig, origTo: cleanFromOrig,
|
581 |
+
editFrom: startEdit, editTo: cleanFromEdit});
|
582 |
+
startEdit = cleanToEdit; startOrig = cleanToOrig;
|
583 |
+
}
|
584 |
+
} else {
|
585 |
+
moveOver(tp == DIFF_INSERT ? edit : orig, part[1]);
|
586 |
+
}
|
587 |
+
}
|
588 |
+
if (startEdit <= edit.line || startOrig <= orig.line)
|
589 |
+
chunks.push({origFrom: startOrig, origTo: orig.line + 1,
|
590 |
+
editFrom: startEdit, editTo: edit.line + 1});
|
591 |
+
return chunks;
|
592 |
+
}
|
593 |
+
|
594 |
+
function endOfLineClean(diff, i) {
|
595 |
+
if (i == diff.length - 1) return true;
|
596 |
+
var next = diff[i + 1][1];
|
597 |
+
if (next.length == 1 || next.charCodeAt(0) != 10) return false;
|
598 |
+
if (i == diff.length - 2) return true;
|
599 |
+
next = diff[i + 2][1];
|
600 |
+
return next.length > 1 && next.charCodeAt(0) == 10;
|
601 |
+
}
|
602 |
+
|
603 |
+
function startOfLineClean(diff, i) {
|
604 |
+
if (i == 0) return true;
|
605 |
+
var last = diff[i - 1][1];
|
606 |
+
if (last.charCodeAt(last.length - 1) != 10) return false;
|
607 |
+
if (i == 1) return true;
|
608 |
+
last = diff[i - 2][1];
|
609 |
+
return last.charCodeAt(last.length - 1) == 10;
|
610 |
+
}
|
611 |
+
|
612 |
+
function chunkBoundariesAround(chunks, n, nInEdit) {
|
613 |
+
var beforeE, afterE, beforeO, afterO;
|
614 |
+
for (var i = 0; i < chunks.length; i++) {
|
615 |
+
var chunk = chunks[i];
|
616 |
+
var fromLocal = nInEdit ? chunk.editFrom : chunk.origFrom;
|
617 |
+
var toLocal = nInEdit ? chunk.editTo : chunk.origTo;
|
618 |
+
if (afterE == null) {
|
619 |
+
if (fromLocal > n) { afterE = chunk.editFrom; afterO = chunk.origFrom; }
|
620 |
+
else if (toLocal > n) { afterE = chunk.editTo; afterO = chunk.origTo; }
|
621 |
+
}
|
622 |
+
if (toLocal <= n) { beforeE = chunk.editTo; beforeO = chunk.origTo; }
|
623 |
+
else if (fromLocal <= n) { beforeE = chunk.editFrom; beforeO = chunk.origFrom; }
|
624 |
+
}
|
625 |
+
return {edit: {before: beforeE, after: afterE}, orig: {before: beforeO, after: afterO}};
|
626 |
+
}
|
627 |
+
|
628 |
+
function collapseSingle(cm, from, to) {
|
629 |
+
cm.addLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
630 |
+
var widget = document.createElement("span");
|
631 |
+
widget.className = "CodeMirror-merge-collapsed-widget";
|
632 |
+
widget.title = "Identical text collapsed. Click to expand.";
|
633 |
+
var mark = cm.markText(Pos(from, 0), Pos(to - 1), {
|
634 |
+
inclusiveLeft: true,
|
635 |
+
inclusiveRight: true,
|
636 |
+
replacedWith: widget,
|
637 |
+
clearOnEnter: true
|
638 |
+
});
|
639 |
+
function clear() {
|
640 |
+
mark.clear();
|
641 |
+
cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
642 |
+
}
|
643 |
+
widget.addEventListener("click", clear);
|
644 |
+
return {mark: mark, clear: clear};
|
645 |
+
}
|
646 |
+
|
647 |
+
function collapseStretch(size, editors) {
|
648 |
+
var marks = [];
|
649 |
+
function clear() {
|
650 |
+
for (var i = 0; i < marks.length; i++) marks[i].clear();
|
651 |
+
}
|
652 |
+
for (var i = 0; i < editors.length; i++) {
|
653 |
+
var editor = editors[i];
|
654 |
+
var mark = collapseSingle(editor.cm, editor.line, editor.line + size);
|
655 |
+
marks.push(mark);
|
656 |
+
mark.mark.on("clear", clear);
|
657 |
+
}
|
658 |
+
return marks[0].mark;
|
659 |
+
}
|
660 |
+
|
661 |
+
function unclearNearChunks(dv, margin, off, clear) {
|
662 |
+
for (var i = 0; i < dv.chunks.length; i++) {
|
663 |
+
var chunk = dv.chunks[i];
|
664 |
+
for (var l = chunk.editFrom - margin; l < chunk.editTo + margin; l++) {
|
665 |
+
var pos = l + off;
|
666 |
+
if (pos >= 0 && pos < clear.length) clear[pos] = false;
|
667 |
+
}
|
668 |
+
}
|
669 |
+
}
|
670 |
+
|
671 |
+
function collapseIdenticalStretches(mv, margin) {
|
672 |
+
if (typeof margin != "number") margin = 2;
|
673 |
+
var clear = [], edit = mv.editor(), off = edit.firstLine();
|
674 |
+
for (var l = off, e = edit.lastLine(); l <= e; l++) clear.push(true);
|
675 |
+
if (mv.left) unclearNearChunks(mv.left, margin, off, clear);
|
676 |
+
if (mv.right) unclearNearChunks(mv.right, margin, off, clear);
|
677 |
+
|
678 |
+
for (var i = 0; i < clear.length; i++) {
|
679 |
+
if (clear[i]) {
|
680 |
+
var line = i + off;
|
681 |
+
for (var size = 1; i < clear.length - 1 && clear[i + 1]; i++, size++) {}
|
682 |
+
if (size > margin) {
|
683 |
+
var editors = [{line: line, cm: edit}];
|
684 |
+
if (mv.left) editors.push({line: getMatchingOrigLine(line, mv.left.chunks), cm: mv.left.orig});
|
685 |
+
if (mv.right) editors.push({line: getMatchingOrigLine(line, mv.right.chunks), cm: mv.right.orig});
|
686 |
+
var mark = collapseStretch(size, editors);
|
687 |
+
if (mv.options.onCollapse) mv.options.onCollapse(mv, line, size, mark);
|
688 |
+
}
|
689 |
+
}
|
690 |
+
}
|
691 |
+
}
|
692 |
+
|
693 |
+
// General utilities
|
694 |
+
|
695 |
+
function elt(tag, content, className, style) {
|
696 |
+
var e = document.createElement(tag);
|
697 |
+
if (className) e.className = className;
|
698 |
+
if (style) e.style.cssText = style;
|
699 |
+
if (typeof content == "string") e.appendChild(document.createTextNode(content));
|
700 |
+
else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
|
701 |
+
return e;
|
702 |
+
}
|
703 |
+
|
704 |
+
function clear(node) {
|
705 |
+
for (var count = node.childNodes.length; count > 0; --count)
|
706 |
+
node.removeChild(node.firstChild);
|
707 |
+
}
|
708 |
+
|
709 |
+
function attrs(elt) {
|
710 |
+
for (var i = 1; i < arguments.length; i += 2)
|
711 |
+
elt.setAttribute(arguments[i], arguments[i+1]);
|
712 |
+
}
|
713 |
+
|
714 |
+
function copyObj(obj, target) {
|
715 |
+
if (!target) target = {};
|
716 |
+
for (var prop in obj) if (obj.hasOwnProperty(prop)) target[prop] = obj[prop];
|
717 |
+
return target;
|
718 |
+
}
|
719 |
+
|
720 |
+
function moveOver(pos, str, copy, other) {
|
721 |
+
var out = copy ? Pos(pos.line, pos.ch) : pos, at = 0;
|
722 |
+
for (;;) {
|
723 |
+
var nl = str.indexOf("\n", at);
|
724 |
+
if (nl == -1) break;
|
725 |
+
++out.line;
|
726 |
+
if (other) ++other.line;
|
727 |
+
at = nl + 1;
|
728 |
+
}
|
729 |
+
out.ch = (at ? 0 : out.ch) + (str.length - at);
|
730 |
+
if (other) other.ch = (at ? 0 : other.ch) + (str.length - at);
|
731 |
+
return out;
|
732 |
+
}
|
733 |
+
|
734 |
+
function posMin(a, b) { return (a.line - b.line || a.ch - b.ch) < 0 ? a : b; }
|
735 |
+
function posMax(a, b) { return (a.line - b.line || a.ch - b.ch) > 0 ? a : b; }
|
736 |
+
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
|
737 |
+
|
738 |
+
function findPrevDiff(chunks, start, isOrig) {
|
739 |
+
for (var i = chunks.length - 1; i >= 0; i--) {
|
740 |
+
var chunk = chunks[i];
|
741 |
+
var to = (isOrig ? chunk.origTo : chunk.editTo) - 1;
|
742 |
+
if (to < start) return to;
|
743 |
+
}
|
744 |
+
}
|
745 |
+
|
746 |
+
function findNextDiff(chunks, start, isOrig) {
|
747 |
+
for (var i = 0; i < chunks.length; i++) {
|
748 |
+
var chunk = chunks[i];
|
749 |
+
var from = (isOrig ? chunk.origFrom : chunk.editFrom);
|
750 |
+
if (from > start) return from;
|
751 |
+
}
|
752 |
+
}
|
753 |
+
|
754 |
+
function goNearbyDiff(cm, dir) {
|
755 |
+
var found = null, views = cm.state.diffViews, line = cm.getCursor().line;
|
756 |
+
if (views) for (var i = 0; i < views.length; i++) {
|
757 |
+
var dv = views[i], isOrig = cm == dv.orig;
|
758 |
+
ensureDiff(dv);
|
759 |
+
var pos = dir < 0 ? findPrevDiff(dv.chunks, line, isOrig) : findNextDiff(dv.chunks, line, isOrig);
|
760 |
+
if (pos != null && (found == null || (dir < 0 ? pos > found : pos < found)))
|
761 |
+
found = pos;
|
762 |
+
}
|
763 |
+
if (found != null)
|
764 |
+
cm.setCursor(found, 0);
|
765 |
+
else
|
766 |
+
return CodeMirror.Pass;
|
767 |
+
}
|
768 |
+
|
769 |
+
CodeMirror.commands.goNextDiff = function(cm) {
|
770 |
+
return goNearbyDiff(cm, 1);
|
771 |
+
};
|
772 |
+
CodeMirror.commands.goPrevDiff = function(cm) {
|
773 |
+
return goNearbyDiff(cm, -1);
|
774 |
+
};
|
775 |
+
});
|
lib/codemirror/addon/merge/merge.min.js
ADDED
@@ -0,0 +1,109 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
|
2 |
+
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
+
mod(require("../../lib/codemirror"),require("diff_match_patch"));else if(typeof define=="function"&&define.amd)
|
4 |
+
define(["../../lib/codemirror","diff_match_patch"],mod);else
|
5 |
+
mod(CodeMirror,diff_match_patch);})(function(CodeMirror,diff_match_patch){"use strict";var Pos=CodeMirror.Pos;var svgNS="http://www.w3.org/2000/svg";function DiffView(mv,type){this.mv=mv;this.type=type;this.classes=type=="left"?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"};}
|
6 |
+
DiffView.prototype={constructor:DiffView,init:function(pane,orig,options){this.edit=this.mv.edit;(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this);this.orig=CodeMirror(pane,copyObj({value:orig,readOnly:!this.mv.options.allowEditingOriginals},copyObj(options)));this.orig.state.diffViews=[this];this.diff=getDiff(asString(orig),asString(options.value));this.chunks=getChunks(this.diff);this.diffOutOfDate=this.dealigned=false;this.showDifferences=options.showDifferences!==false;this.forceUpdate=registerUpdate(this);setScrollLock(this,true,false);registerScroll(this);},setShowDifferences:function(val){val=val!==false;if(val!=this.showDifferences){this.showDifferences=val;this.forceUpdate("full");}}};function ensureDiff(dv){if(dv.diffOutOfDate){dv.diff=getDiff(dv.orig.getValue(),dv.edit.getValue());dv.chunks=getChunks(dv.diff);dv.diffOutOfDate=false;CodeMirror.signal(dv.edit,"updateDiff",dv.diff);}}
|
7 |
+
var updating=false;function registerUpdate(dv){var edit={from:0,to:0,marked:[]};var orig={from:0,to:0,marked:[]};var debounceChange,updatingFast=false;function update(mode){updating=true;updatingFast=false;if(mode=="full"){if(dv.svg)clear(dv.svg);if(dv.copyButtons)clear(dv.copyButtons);clearMarks(dv.edit,edit.marked,dv.classes);clearMarks(dv.orig,orig.marked,dv.classes);edit.from=edit.to=orig.from=orig.to=0;}
|
8 |
+
ensureDiff(dv);if(dv.showDifferences){updateMarks(dv.edit,dv.diff,edit,DIFF_INSERT,dv.classes);updateMarks(dv.orig,dv.diff,orig,DIFF_DELETE,dv.classes);}
|
9 |
+
makeConnections(dv);if(dv.mv.options.connect=="align")
|
10 |
+
alignChunks(dv);updating=false;}
|
11 |
+
function setDealign(fast){if(updating)return;dv.dealigned=true;set(fast);}
|
12 |
+
function set(fast){if(updating||updatingFast)return;clearTimeout(debounceChange);if(fast===true)updatingFast=true;debounceChange=setTimeout(update,fast===true?20:250);}
|
13 |
+
function change(_cm,change){if(!dv.diffOutOfDate){dv.diffOutOfDate=true;edit.from=edit.to=orig.from=orig.to=0;}
|
14 |
+
setDealign(change.text.length-1!=change.to.line-change.from.line);}
|
15 |
+
dv.edit.on("change",change);dv.orig.on("change",change);dv.edit.on("markerAdded",setDealign);dv.edit.on("markerCleared",setDealign);dv.orig.on("markerAdded",setDealign);dv.orig.on("markerCleared",setDealign);dv.edit.on("viewportChange",function(){set(false);});dv.orig.on("viewportChange",function(){set(false);});update();return update;}
|
16 |
+
function registerScroll(dv){dv.edit.on("scroll",function(){syncScroll(dv,DIFF_INSERT)&&makeConnections(dv);});dv.orig.on("scroll",function(){syncScroll(dv,DIFF_DELETE)&&makeConnections(dv);});}
|
17 |
+
function syncScroll(dv,type){if(dv.diffOutOfDate)return false;if(!dv.lockScroll)return true;var editor,other,now=+new Date;if(type==DIFF_INSERT){editor=dv.edit;other=dv.orig;}
|
18 |
+
else{editor=dv.orig;other=dv.edit;}
|
19 |
+
if(editor.state.scrollSetBy==dv&&(editor.state.scrollSetAt||0)+50>now)return false;var sInfo=editor.getScrollInfo();if(dv.mv.options.connect=="align"){targetPos=sInfo.top;}else{var halfScreen=.5*sInfo.clientHeight,midY=sInfo.top+halfScreen;var mid=editor.lineAtHeight(midY,"local");var around=chunkBoundariesAround(dv.chunks,mid,type==DIFF_INSERT);var off=getOffsets(editor,type==DIFF_INSERT?around.edit:around.orig);var offOther=getOffsets(other,type==DIFF_INSERT?around.orig:around.edit);var ratio=(midY-off.top)/(off.bot-off.top);var targetPos=(offOther.top-halfScreen)+ratio*(offOther.bot-offOther.top);var botDist,mix;if(targetPos>sInfo.top&&(mix=sInfo.top/halfScreen)<1){targetPos=targetPos*mix+sInfo.top*(1-mix);}else if((botDist=sInfo.height-sInfo.clientHeight-sInfo.top)<halfScreen){var otherInfo=other.getScrollInfo();var botDistOther=otherInfo.height-otherInfo.clientHeight-targetPos;if(botDistOther>botDist&&(mix=botDist/halfScreen)<1)
|
20 |
+
targetPos=targetPos*mix+(otherInfo.height-otherInfo.clientHeight-botDist)*(1-mix);}}
|
21 |
+
other.scrollTo(sInfo.left,targetPos);other.state.scrollSetAt=now;other.state.scrollSetBy=dv;return true;}
|
22 |
+
function getOffsets(editor,around){var bot=around.after;if(bot==null)bot=editor.lastLine()+1;return{top:editor.heightAtLine(around.before||0,"local"),bot:editor.heightAtLine(bot,"local")};}
|
23 |
+
function setScrollLock(dv,val,action){dv.lockScroll=val;if(val&&action!=false)syncScroll(dv,DIFF_INSERT)&&makeConnections(dv);dv.lockButton.innerHTML=val?"\u21db\u21da":"\u21db \u21da";}
|
24 |
+
function clearMarks(editor,arr,classes){for(var i=0;i<arr.length;++i){var mark=arr[i];if(mark instanceof CodeMirror.TextMarker){mark.clear();}else if(mark.parent){editor.removeLineClass(mark,"background",classes.chunk);editor.removeLineClass(mark,"background",classes.start);editor.removeLineClass(mark,"background",classes.end);}}
|
25 |
+
arr.length=0;}
|
26 |
+
function updateMarks(editor,diff,state,type,classes){var vp=editor.getViewport();editor.operation(function(){if(state.from==state.to||vp.from-state.to>20||state.from-vp.to>20){clearMarks(editor,state.marked,classes);markChanges(editor,diff,type,state.marked,vp.from,vp.to,classes);state.from=vp.from;state.to=vp.to;}else{if(vp.from<state.from){markChanges(editor,diff,type,state.marked,vp.from,state.from,classes);state.from=vp.from;}
|
27 |
+
if(vp.to>state.to){markChanges(editor,diff,type,state.marked,state.to,vp.to,classes);state.to=vp.to;}}});}
|
28 |
+
function markChanges(editor,diff,type,marks,from,to,classes){var pos=Pos(0,0);var top=Pos(from,0),bot=editor.clipPos(Pos(to-1));var cls=type==DIFF_DELETE?classes.del:classes.insert;function markChunk(start,end){var bfrom=Math.max(from,start),bto=Math.min(to,end);for(var i=bfrom;i<bto;++i){var line=editor.addLineClass(i,"background",classes.chunk);if(i==start)editor.addLineClass(line,"background",classes.start);if(i==end-1)editor.addLineClass(line,"background",classes.end);marks.push(line);}
|
29 |
+
if(start==end&&bfrom==end&&bto==end){if(bfrom)
|
30 |
+
marks.push(editor.addLineClass(bfrom-1,"background",classes.end));else
|
31 |
+
marks.push(editor.addLineClass(bfrom,"background",classes.start));}}
|
32 |
+
var chunkStart=0;for(var i=0;i<diff.length;++i){var part=diff[i],tp=part[0],str=part[1];if(tp==DIFF_EQUAL){var cleanFrom=pos.line+(startOfLineClean(diff,i)?0:1);moveOver(pos,str);var cleanTo=pos.line+(endOfLineClean(diff,i)?1:0);if(cleanTo>cleanFrom){if(i)markChunk(chunkStart,cleanFrom);chunkStart=cleanTo;}}else{if(tp==type){var end=moveOver(pos,str,true);var a=posMax(top,pos),b=posMin(bot,end);if(!posEq(a,b))
|
33 |
+
marks.push(editor.markText(a,b,{className:cls}));pos=end;}}}
|
34 |
+
if(chunkStart<=pos.line)markChunk(chunkStart,pos.line+1);}
|
35 |
+
function makeConnections(dv){if(!dv.showDifferences)return;if(dv.svg){clear(dv.svg);var w=dv.gap.offsetWidth;attrs(dv.svg,"width",w,"height",dv.gap.offsetHeight);}
|
36 |
+
if(dv.copyButtons)clear(dv.copyButtons);var vpEdit=dv.edit.getViewport(),vpOrig=dv.orig.getViewport();var sTopEdit=dv.edit.getScrollInfo().top,sTopOrig=dv.orig.getScrollInfo().top;for(var i=0;i<dv.chunks.length;i++){var ch=dv.chunks[i];if(ch.editFrom<=vpEdit.to&&ch.editTo>=vpEdit.from&&ch.origFrom<=vpOrig.to&&ch.origTo>=vpOrig.from)
|
37 |
+
drawConnectorsForChunk(dv,ch,sTopOrig,sTopEdit,w);}}
|
38 |
+
function getMatchingOrigLine(editLine,chunks){var editStart=0,origStart=0;for(var i=0;i<chunks.length;i++){var chunk=chunks[i];if(chunk.editTo>editLine&&chunk.editFrom<=editLine)return null;if(chunk.editFrom>editLine)break;editStart=chunk.editTo;origStart=chunk.origTo;}
|
39 |
+
return origStart+(editLine-editStart);}
|
40 |
+
function findAlignedLines(dv,other){var linesToAlign=[];for(var i=0;i<dv.chunks.length;i++){var chunk=dv.chunks[i];linesToAlign.push([chunk.origTo,chunk.editTo,other?getMatchingOrigLine(chunk.editTo,other.chunks):null]);}
|
41 |
+
if(other){for(var i=0;i<other.chunks.length;i++){var chunk=other.chunks[i];for(var j=0;j<linesToAlign.length;j++){var align=linesToAlign[j];if(align[1]==chunk.editTo){j=-1;break;}else if(align[1]>chunk.editTo){break;}}
|
42 |
+
if(j>-1)
|
43 |
+
linesToAlign.splice(j-1,0,[getMatchingOrigLine(chunk.editTo,dv.chunks),chunk.editTo,chunk.origTo]);}}
|
44 |
+
return linesToAlign;}
|
45 |
+
function alignChunks(dv,force){if(!dv.dealigned&&!force)return;if(!dv.orig.curOp)return dv.orig.operation(function(){alignChunks(dv,force);});dv.dealigned=false;var other=dv.mv.left==dv?dv.mv.right:dv.mv.left;if(other){ensureDiff(other);other.dealigned=false;}
|
46 |
+
var linesToAlign=findAlignedLines(dv,other);var aligners=dv.mv.aligners;for(var i=0;i<aligners.length;i++)
|
47 |
+
aligners[i].clear();aligners.length=0;var cm=[dv.orig,dv.edit],scroll=[];if(other)cm.push(other.orig);for(var i=0;i<cm.length;i++)
|
48 |
+
scroll.push(cm[i].getScrollInfo().top);for(var ln=0;ln<linesToAlign.length;ln++)
|
49 |
+
alignLines(cm,linesToAlign[ln],aligners);for(var i=0;i<cm.length;i++)
|
50 |
+
cm[i].scrollTo(null,scroll[i]);}
|
51 |
+
function alignLines(cm,lines,aligners){var maxOffset=0,offset=[];for(var i=0;i<cm.length;i++)if(lines[i]!=null){var off=cm[i].heightAtLine(lines[i],"local");offset[i]=off;maxOffset=Math.max(maxOffset,off);}
|
52 |
+
for(var i=0;i<cm.length;i++)if(lines[i]!=null){var diff=maxOffset-offset[i];if(diff>1)
|
53 |
+
aligners.push(padAbove(cm[i],lines[i],diff));}}
|
54 |
+
function padAbove(cm,line,size){var above=true;if(line>cm.lastLine()){line--;above=false;}
|
55 |
+
var elt=document.createElement("div");elt.className="CodeMirror-merge-spacer";elt.style.height=size+"px";elt.style.minWidth="1px";return cm.addLineWidget(line,elt,{height:size,above:above});}
|
56 |
+
function drawConnectorsForChunk(dv,chunk,sTopOrig,sTopEdit,w){var flip=dv.type=="left";var top=dv.orig.heightAtLine(chunk.origFrom,"local")-sTopOrig;if(dv.svg){var topLpx=top;var topRpx=dv.edit.heightAtLine(chunk.editFrom,"local")-sTopEdit;if(flip){var tmp=topLpx;topLpx=topRpx;topRpx=tmp;}
|
57 |
+
var botLpx=dv.orig.heightAtLine(chunk.origTo,"local")-sTopOrig;var botRpx=dv.edit.heightAtLine(chunk.editTo,"local")-sTopEdit;if(flip){var tmp=botLpx;botLpx=botRpx;botRpx=tmp;}
|
58 |
+
var curveTop=" C "+w/2+" "+topRpx+" "+w/2+" "+topLpx+" "+(w+2)+" "+topLpx;var curveBot=" C "+w/2+" "+botLpx+" "+w/2+" "+botRpx+" -1 "+botRpx;attrs(dv.svg.appendChild(document.createElementNS(svgNS,"path")),"d","M -1 "+topRpx+curveTop+" L "+(w+2)+" "+botLpx+curveBot+" z","class",dv.classes.connect);}
|
59 |
+
if(dv.copyButtons){var copy=dv.copyButtons.appendChild(elt("div",dv.type=="left"?"\u21dd":"\u21dc","CodeMirror-merge-copy"));var editOriginals=dv.mv.options.allowEditingOriginals;copy.title=editOriginals?"Push to left":"Revert chunk";copy.chunk=chunk;copy.style.top=top+"px";if(editOriginals){var topReverse=dv.orig.heightAtLine(chunk.editFrom,"local")-sTopEdit;var copyReverse=dv.copyButtons.appendChild(elt("div",dv.type=="right"?"\u21dd":"\u21dc","CodeMirror-merge-copy-reverse"));copyReverse.title="Push to right";copyReverse.chunk={editFrom:chunk.origFrom,editTo:chunk.origTo,origFrom:chunk.editFrom,origTo:chunk.editTo};copyReverse.style.top=topReverse+"px";dv.type=="right"?copyReverse.style.left="2px":copyReverse.style.right="2px";}}}
|
60 |
+
function copyChunk(dv,to,from,chunk){if(dv.diffOutOfDate)return;to.replaceRange(from.getRange(Pos(chunk.origFrom,0),Pos(chunk.origTo,0)),Pos(chunk.editFrom,0),Pos(chunk.editTo,0));}
|
61 |
+
var MergeView=CodeMirror.MergeView=function(node,options){if(!(this instanceof MergeView))return new MergeView(node,options);this.options=options;var origLeft=options.origLeft,origRight=options.origRight==null?options.orig:options.origRight;var hasLeft=origLeft!=null,hasRight=origRight!=null;var panes=1+(hasLeft?1:0)+(hasRight?1:0);var wrap=[],left=this.left=null,right=this.right=null;var self=this;if(hasLeft){left=this.left=new DiffView(this,"left");var leftPane=elt("div",null,"CodeMirror-merge-pane");wrap.push(leftPane);wrap.push(buildGap(left));}
|
62 |
+
var editPane=elt("div",null,"CodeMirror-merge-pane");wrap.push(editPane);if(hasRight){right=this.right=new DiffView(this,"right");wrap.push(buildGap(right));var rightPane=elt("div",null,"CodeMirror-merge-pane");wrap.push(rightPane);}
|
63 |
+
(hasRight?rightPane:editPane).className+=" CodeMirror-merge-pane-rightmost";wrap.push(elt("div",null,null,"height: 0; clear: both;"));var wrapElt=this.wrap=node.appendChild(elt("div",wrap,"CodeMirror-merge CodeMirror-merge-"+panes+"pane"));this.edit=CodeMirror(editPane,copyObj(options));if(left)left.init(leftPane,origLeft,options);if(right)right.init(rightPane,origRight,options);if(options.collapseIdentical){updating=true;this.editor().operation(function(){collapseIdenticalStretches(self,options.collapseIdentical);});updating=false;}
|
64 |
+
if(options.connect=="align"){this.aligners=[];alignChunks(this.left||this.right,true);}
|
65 |
+
var onResize=function(){if(left)makeConnections(left);if(right)makeConnections(right);};CodeMirror.on(window,"resize",onResize);var resizeInterval=setInterval(function(){for(var p=wrapElt.parentNode;p&&p!=document.body;p=p.parentNode){}
|
66 |
+
if(!p){clearInterval(resizeInterval);CodeMirror.off(window,"resize",onResize);}},5000);};function buildGap(dv){var lock=dv.lockButton=elt("div",null,"CodeMirror-merge-scrolllock");lock.title="Toggle locked scrolling";var lockWrap=elt("div",[lock],"CodeMirror-merge-scrolllock-wrap");CodeMirror.on(lock,"click",function(){setScrollLock(dv,!dv.lockScroll);});var gapElts=[lockWrap];if(dv.mv.options.revertButtons!==false){dv.copyButtons=elt("div",null,"CodeMirror-merge-copybuttons-"+dv.type);CodeMirror.on(dv.copyButtons,"click",function(e){var node=e.target||e.srcElement;if(!node.chunk)return;if(node.className=="CodeMirror-merge-copy-reverse"){copyChunk(dv,dv.orig,dv.edit,node.chunk);return;}
|
67 |
+
copyChunk(dv,dv.edit,dv.orig,node.chunk);});gapElts.unshift(dv.copyButtons);}
|
68 |
+
if(dv.mv.options.connect!="align"){var svg=document.createElementNS&&document.createElementNS(svgNS,"svg");if(svg&&!svg.createSVGRect)svg=null;dv.svg=svg;if(svg)gapElts.push(svg);}
|
69 |
+
return dv.gap=elt("div",gapElts,"CodeMirror-merge-gap");}
|
70 |
+
MergeView.prototype={constuctor:MergeView,editor:function(){return this.edit;},rightOriginal:function(){return this.right&&this.right.orig;},leftOriginal:function(){return this.left&&this.left.orig;},setShowDifferences:function(val){if(this.right)this.right.setShowDifferences(val);if(this.left)this.left.setShowDifferences(val);},rightChunks:function(){if(this.right){ensureDiff(this.right);return this.right.chunks;}},leftChunks:function(){if(this.left){ensureDiff(this.left);return this.left.chunks;}}};function asString(obj){if(typeof obj=="string")return obj;else return obj.getValue();}
|
71 |
+
var dmp=new diff_match_patch();function getDiff(a,b){var diff=dmp.diff_main(a,b);dmp.diff_cleanupSemantic(diff);for(var i=0;i<diff.length;++i){var part=diff[i];if(!part[1]){diff.splice(i--,1);}else if(i&&diff[i-1][0]==part[0]){diff.splice(i--,1);diff[i][1]+=part[1];}}
|
72 |
+
return diff;}
|
73 |
+
function getChunks(diff){var chunks=[];var startEdit=0,startOrig=0;var edit=Pos(0,0),orig=Pos(0,0);for(var i=0;i<diff.length;++i){var part=diff[i],tp=part[0];if(tp==DIFF_EQUAL){var startOff=startOfLineClean(diff,i)?0:1;var cleanFromEdit=edit.line+startOff,cleanFromOrig=orig.line+startOff;moveOver(edit,part[1],null,orig);var endOff=endOfLineClean(diff,i)?1:0;var cleanToEdit=edit.line+endOff,cleanToOrig=orig.line+endOff;if(cleanToEdit>cleanFromEdit){if(i)chunks.push({origFrom:startOrig,origTo:cleanFromOrig,editFrom:startEdit,editTo:cleanFromEdit});startEdit=cleanToEdit;startOrig=cleanToOrig;}}else{moveOver(tp==DIFF_INSERT?edit:orig,part[1]);}}
|
74 |
+
if(startEdit<=edit.line||startOrig<=orig.line)
|
75 |
+
chunks.push({origFrom:startOrig,origTo:orig.line+1,editFrom:startEdit,editTo:edit.line+1});return chunks;}
|
76 |
+
function endOfLineClean(diff,i){if(i==diff.length-1)return true;var next=diff[i+1][1];if(next.length==1||next.charCodeAt(0)!=10)return false;if(i==diff.length-2)return true;next=diff[i+2][1];return next.length>1&&next.charCodeAt(0)==10;}
|
77 |
+
function startOfLineClean(diff,i){if(i==0)return true;var last=diff[i-1][1];if(last.charCodeAt(last.length-1)!=10)return false;if(i==1)return true;last=diff[i-2][1];return last.charCodeAt(last.length-1)==10;}
|
78 |
+
function chunkBoundariesAround(chunks,n,nInEdit){var beforeE,afterE,beforeO,afterO;for(var i=0;i<chunks.length;i++){var chunk=chunks[i];var fromLocal=nInEdit?chunk.editFrom:chunk.origFrom;var toLocal=nInEdit?chunk.editTo:chunk.origTo;if(afterE==null){if(fromLocal>n){afterE=chunk.editFrom;afterO=chunk.origFrom;}
|
79 |
+
else if(toLocal>n){afterE=chunk.editTo;afterO=chunk.origTo;}}
|
80 |
+
if(toLocal<=n){beforeE=chunk.editTo;beforeO=chunk.origTo;}
|
81 |
+
else if(fromLocal<=n){beforeE=chunk.editFrom;beforeO=chunk.origFrom;}}
|
82 |
+
return{edit:{before:beforeE,after:afterE},orig:{before:beforeO,after:afterO}};}
|
83 |
+
function collapseSingle(cm,from,to){cm.addLineClass(from,"wrap","CodeMirror-merge-collapsed-line");var widget=document.createElement("span");widget.className="CodeMirror-merge-collapsed-widget";widget.title="Identical text collapsed. Click to expand.";var mark=cm.markText(Pos(from,0),Pos(to-1),{inclusiveLeft:true,inclusiveRight:true,replacedWith:widget,clearOnEnter:true});function clear(){mark.clear();cm.removeLineClass(from,"wrap","CodeMirror-merge-collapsed-line");}
|
84 |
+
widget.addEventListener("click",clear);return{mark:mark,clear:clear};}
|
85 |
+
function collapseStretch(size,editors){var marks=[];function clear(){for(var i=0;i<marks.length;i++)marks[i].clear();}
|
86 |
+
for(var i=0;i<editors.length;i++){var editor=editors[i];var mark=collapseSingle(editor.cm,editor.line,editor.line+size);marks.push(mark);mark.mark.on("clear",clear);}
|
87 |
+
return marks[0].mark;}
|
88 |
+
function unclearNearChunks(dv,margin,off,clear){for(var i=0;i<dv.chunks.length;i++){var chunk=dv.chunks[i];for(var l=chunk.editFrom-margin;l<chunk.editTo+margin;l++){var pos=l+off;if(pos>=0&&pos<clear.length)clear[pos]=false;}}}
|
89 |
+
function collapseIdenticalStretches(mv,margin){if(typeof margin!="number")margin=2;var clear=[],edit=mv.editor(),off=edit.firstLine();for(var l=off,e=edit.lastLine();l<=e;l++)clear.push(true);if(mv.left)unclearNearChunks(mv.left,margin,off,clear);if(mv.right)unclearNearChunks(mv.right,margin,off,clear);for(var i=0;i<clear.length;i++){if(clear[i]){var line=i+off;for(var size=1;i<clear.length-1&&clear[i+1];i++,size++){}
|
90 |
+
if(size>margin){var editors=[{line:line,cm:edit}];if(mv.left)editors.push({line:getMatchingOrigLine(line,mv.left.chunks),cm:mv.left.orig});if(mv.right)editors.push({line:getMatchingOrigLine(line,mv.right.chunks),cm:mv.right.orig});var mark=collapseStretch(size,editors);if(mv.options.onCollapse)mv.options.onCollapse(mv,line,size,mark);}}}}
|
91 |
+
function elt(tag,content,className,style){var e=document.createElement(tag);if(className)e.className=className;if(style)e.style.cssText=style;if(typeof content=="string")e.appendChild(document.createTextNode(content));else if(content)for(var i=0;i<content.length;++i)e.appendChild(content[i]);return e;}
|
92 |
+
function clear(node){for(var count=node.childNodes.length;count>0;--count)
|
93 |
+
node.removeChild(node.firstChild);}
|
94 |
+
function attrs(elt){for(var i=1;i<arguments.length;i+=2)
|
95 |
+
elt.setAttribute(arguments[i],arguments[i+1]);}
|
96 |
+
function copyObj(obj,target){if(!target)target={};for(var prop in obj)if(obj.hasOwnProperty(prop))target[prop]=obj[prop];return target;}
|
97 |
+
function moveOver(pos,str,copy,other){var out=copy?Pos(pos.line,pos.ch):pos,at=0;for(;;){var nl=str.indexOf("\n",at);if(nl==-1)break;++out.line;if(other)++other.line;at=nl+1;}
|
98 |
+
out.ch=(at?0:out.ch)+(str.length-at);if(other)other.ch=(at?0:other.ch)+(str.length-at);return out;}
|
99 |
+
function posMin(a,b){return(a.line-b.line||a.ch-b.ch)<0?a:b;}
|
100 |
+
function posMax(a,b){return(a.line-b.line||a.ch-b.ch)>0?a:b;}
|
101 |
+
function posEq(a,b){return a.line==b.line&&a.ch==b.ch;}
|
102 |
+
function findPrevDiff(chunks,start,isOrig){for(var i=chunks.length-1;i>=0;i--){var chunk=chunks[i];var to=(isOrig?chunk.origTo:chunk.editTo)-1;if(to<start)return to;}}
|
103 |
+
function findNextDiff(chunks,start,isOrig){for(var i=0;i<chunks.length;i++){var chunk=chunks[i];var from=(isOrig?chunk.origFrom:chunk.editFrom);if(from>start)return from;}}
|
104 |
+
function goNearbyDiff(cm,dir){var found=null,views=cm.state.diffViews,line=cm.getCursor().line;if(views)for(var i=0;i<views.length;i++){var dv=views[i],isOrig=cm==dv.orig;ensureDiff(dv);var pos=dir<0?findPrevDiff(dv.chunks,line,isOrig):findNextDiff(dv.chunks,line,isOrig);if(pos!=null&&(found==null||(dir<0?pos>found:pos<found)))
|
105 |
+
found=pos;}
|
106 |
+
if(found!=null)
|
107 |
+
cm.setCursor(found,0);else
|
108 |
+
return CodeMirror.Pass;}
|
109 |
+
CodeMirror.commands.goNextDiff=function(cm){return goNearbyDiff(cm,1);};CodeMirror.commands.goPrevDiff=function(cm){return goNearbyDiff(cm,-1);};});
|
lib/codemirror/lib/codemirror.css
ADDED
@@ -0,0 +1,325 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
/* BASICS */
|
2 |
+
|
3 |
+
.CodeMirror {
|
4 |
+
/* Set height, width, borders, and global font properties here */
|
5 |
+
font-family: monospace;
|
6 |
+
height: 300px;
|
7 |
+
color: black;
|
8 |
+
}
|
9 |
+
|
10 |
+
/* PADDING */
|
11 |
+
|
12 |
+
.CodeMirror-lines {
|
13 |
+
padding: 4px 0; /* Vertical padding around content */
|
14 |
+
}
|
15 |
+
.CodeMirror pre {
|
16 |
+
padding: 0 4px; /* Horizontal padding of content */
|
17 |
+
}
|
18 |
+
|
19 |
+
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
20 |
+
background-color: white; /* The little square between H and V scrollbars */
|
21 |
+
}
|
22 |
+
|
23 |
+
/* GUTTER */
|
24 |
+
|
25 |
+
.CodeMirror-gutters {
|
26 |
+
border-right: 1px solid #ddd;
|
27 |
+
background-color: #f7f7f7;
|
28 |
+
white-space: nowrap;
|
29 |
+
}
|
30 |
+
.CodeMirror-linenumbers {}
|
31 |
+
.CodeMirror-linenumber {
|
32 |
+
padding: 0 3px 0 5px;
|
33 |
+
min-width: 20px;
|
34 |
+
text-align: right;
|
35 |
+
color: #999;
|
36 |
+
white-space: nowrap;
|
37 |
+
}
|
38 |
+
|
39 |
+
.CodeMirror-guttermarker { color: black; }
|
40 |
+
.CodeMirror-guttermarker-subtle { color: #999; }
|
41 |
+
|
42 |
+
/* CURSOR */
|
43 |
+
|
44 |
+
.CodeMirror div.CodeMirror-cursor {
|
45 |
+
border-left: 1px solid black;
|
46 |
+
}
|
47 |
+
/* Shown when moving in bi-directional text */
|
48 |
+
.CodeMirror div.CodeMirror-secondarycursor {
|
49 |
+
border-left: 1px solid silver;
|
50 |
+
}
|
51 |
+
.CodeMirror.cm-fat-cursor div.CodeMirror-cursor {
|
52 |
+
width: auto;
|
53 |
+
border: 0;
|
54 |
+
background: #7e7;
|
55 |
+
}
|
56 |
+
.CodeMirror.cm-fat-cursor div.CodeMirror-cursors {
|
57 |
+
z-index: 1;
|
58 |
+
}
|
59 |
+
|
60 |
+
.cm-animate-fat-cursor {
|
61 |
+
width: auto;
|
62 |
+
border: 0;
|
63 |
+
-webkit-animation: blink 1.06s steps(1) infinite;
|
64 |
+
-moz-animation: blink 1.06s steps(1) infinite;
|
65 |
+
animation: blink 1.06s steps(1) infinite;
|
66 |
+
}
|
67 |
+
@-moz-keyframes blink {
|
68 |
+
0% { background: #7e7; }
|
69 |
+
50% { background: none; }
|
70 |
+
100% { background: #7e7; }
|
71 |
+
}
|
72 |
+
@-webkit-keyframes blink {
|
73 |
+
0% { background: #7e7; }
|
74 |
+
50% { background: none; }
|
75 |
+
100% { background: #7e7; }
|
76 |
+
}
|
77 |
+
@keyframes blink {
|
78 |
+
0% { background: #7e7; }
|
79 |
+
50% { background: none; }
|
80 |
+
100% { background: #7e7; }
|
81 |
+
}
|
82 |
+
|
83 |
+
/* Can style cursor different in overwrite (non-insert) mode */
|
84 |
+
div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
85 |
+
|
86 |
+
.cm-tab { display: inline-block; text-decoration: inherit; }
|
87 |
+
|
88 |
+
.CodeMirror-ruler {
|
89 |
+
border-left: 1px solid #ccc;
|
90 |
+
position: absolute;
|
91 |
+
}
|
92 |
+
|
93 |
+
/* DEFAULT THEME */
|
94 |
+
|
95 |
+
.cm-s-default .cm-keyword {color: #708;}
|
96 |
+
.cm-s-default .cm-atom {color: #219;}
|
97 |
+
.cm-s-default .cm-number {color: #164;}
|
98 |
+
.cm-s-default .cm-def {color: #00f;}
|
99 |
+
.cm-s-default .cm-variable,
|
100 |
+
.cm-s-default .cm-punctuation,
|
101 |
+
.cm-s-default .cm-property,
|
102 |
+
.cm-s-default .cm-operator {}
|
103 |
+
.cm-s-default .cm-variable-2 {color: #05a;}
|
104 |
+
.cm-s-default .cm-variable-3 {color: #085;}
|
105 |
+
.cm-s-default .cm-comment {color: #a50;}
|
106 |
+
.cm-s-default .cm-string {color: #a11;}
|
107 |
+
.cm-s-default .cm-string-2 {color: #f50;}
|
108 |
+
.cm-s-default .cm-meta {color: #555;}
|
109 |
+
.cm-s-default .cm-qualifier {color: #555;}
|
110 |
+
.cm-s-default .cm-builtin {color: #30a;}
|
111 |
+
.cm-s-default .cm-bracket {color: #997;}
|
112 |
+
.cm-s-default .cm-tag {color: #170;}
|
113 |
+
.cm-s-default .cm-attribute {color: #00c;}
|
114 |
+
.cm-s-default .cm-header {color: blue;}
|
115 |
+
.cm-s-default .cm-quote {color: #090;}
|
116 |
+
.cm-s-default .cm-hr {color: #999;}
|
117 |
+
.cm-s-default .cm-link {color: #00c;}
|
118 |
+
|
119 |
+
.cm-negative {color: #d44;}
|
120 |
+
.cm-positive {color: #292;}
|
121 |
+
.cm-header, .cm-strong {font-weight: bold;}
|
122 |
+
.cm-em {font-style: italic;}
|
123 |
+
.cm-link {text-decoration: underline;}
|
124 |
+
.cm-strikethrough {text-decoration: line-through;}
|
125 |
+
|
126 |
+
.cm-s-default .cm-error {color: #f00;}
|
127 |
+
.cm-invalidchar {color: #f00;}
|
128 |
+
|
129 |
+
.CodeMirror-composing { border-bottom: 2px solid; }
|
130 |
+
|
131 |
+
/* Default styles for common addons */
|
132 |
+
|
133 |
+
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
134 |
+
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
135 |
+
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
136 |
+
.CodeMirror-activeline-background {background: #e8f2ff;}
|
137 |
+
|
138 |
+
/* STOP */
|
139 |
+
|
140 |
+
/* The rest of this file contains styles related to the mechanics of
|
141 |
+
the editor. You probably shouldn't touch them. */
|
142 |
+
|
143 |
+
.CodeMirror {
|
144 |
+
position: relative;
|
145 |
+
overflow: hidden;
|
146 |
+
background: white;
|
147 |
+
}
|
148 |
+
|
149 |
+
.CodeMirror-scroll {
|
150 |
+
overflow: scroll !important; /* Things will break if this is overridden */
|
151 |
+
/* 30px is the magic margin used to hide the element's real scrollbars */
|
152 |
+
/* See overflow: hidden in .CodeMirror */
|
153 |
+
margin-bottom: -30px; margin-right: -30px;
|
154 |
+
padding-bottom: 30px;
|
155 |
+
height: 100%;
|
156 |
+
outline: none; /* Prevent dragging from highlighting the element */
|
157 |
+
position: relative;
|
158 |
+
}
|
159 |
+
.CodeMirror-sizer {
|
160 |
+
position: relative;
|
161 |
+
border-right: 30px solid transparent;
|
162 |
+
}
|
163 |
+
|
164 |
+
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
165 |
+
before actuall scrolling happens, thus preventing shaking and
|
166 |
+
flickering artifacts. */
|
167 |
+
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
168 |
+
position: absolute;
|
169 |
+
z-index: 6;
|
170 |
+
display: none;
|
171 |
+
}
|
172 |
+
.CodeMirror-vscrollbar {
|
173 |
+
right: 0; top: 0;
|
174 |
+
overflow-x: hidden;
|
175 |
+
overflow-y: scroll;
|
176 |
+
}
|
177 |
+
.CodeMirror-hscrollbar {
|
178 |
+
bottom: 0; left: 0;
|
179 |
+
overflow-y: hidden;
|
180 |
+
overflow-x: scroll;
|
181 |
+
}
|
182 |
+
.CodeMirror-scrollbar-filler {
|
183 |
+
right: 0; bottom: 0;
|
184 |
+
}
|
185 |
+
.CodeMirror-gutter-filler {
|
186 |
+
left: 0; bottom: 0;
|
187 |
+
}
|
188 |
+
|
189 |
+
.CodeMirror-gutters {
|
190 |
+
position: absolute; left: 0; top: 0;
|
191 |
+
z-index: 3;
|
192 |
+
}
|
193 |
+
.CodeMirror-gutter {
|
194 |
+
white-space: normal;
|
195 |
+
height: 100%;
|
196 |
+
display: inline-block;
|
197 |
+
margin-bottom: -30px;
|
198 |
+
/* Hack to make IE7 behave */
|
199 |
+
*zoom:1;
|
200 |
+
*display:inline;
|
201 |
+
}
|
202 |
+
.CodeMirror-gutter-wrapper {
|
203 |
+
position: absolute;
|
204 |
+
z-index: 4;
|
205 |
+
height: 100%;
|
206 |
+
}
|
207 |
+
.CodeMirror-gutter-elt {
|
208 |
+
position: absolute;
|
209 |
+
cursor: default;
|
210 |
+
z-index: 4;
|
211 |
+
}
|
212 |
+
.CodeMirror-gutter-wrapper {
|
213 |
+
-webkit-user-select: none;
|
214 |
+
-moz-user-select: none;
|
215 |
+
user-select: none;
|
216 |
+
}
|
217 |
+
|
218 |
+
.CodeMirror-lines {
|
219 |
+
cursor: text;
|
220 |
+
min-height: 1px; /* prevents collapsing before first draw */
|
221 |
+
}
|
222 |
+
.CodeMirror pre {
|
223 |
+
/* Reset some styles that the rest of the page might have set */
|
224 |
+
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
225 |
+
border-width: 0;
|
226 |
+
background: transparent;
|
227 |
+
font-family: inherit;
|
228 |
+
font-size: inherit;
|
229 |
+
margin: 0;
|
230 |
+
white-space: pre;
|
231 |
+
word-wrap: normal;
|
232 |
+
line-height: inherit;
|
233 |
+
color: inherit;
|
234 |
+
z-index: 2;
|
235 |
+
position: relative;
|
236 |
+
overflow: visible;
|
237 |
+
-webkit-tap-highlight-color: transparent;
|
238 |
+
}
|
239 |
+
.CodeMirror-wrap pre {
|
240 |
+
word-wrap: break-word;
|
241 |
+
white-space: pre-wrap;
|
242 |
+
word-break: normal;
|
243 |
+
}
|
244 |
+
|
245 |
+
.CodeMirror-linebackground {
|
246 |
+
position: absolute;
|
247 |
+
left: 0; right: 0; top: 0; bottom: 0;
|
248 |
+
z-index: 0;
|
249 |
+
}
|
250 |
+
|
251 |
+
.CodeMirror-linewidget {
|
252 |
+
position: relative;
|
253 |
+
z-index: 2;
|
254 |
+
overflow: auto;
|
255 |
+
}
|
256 |
+
|
257 |
+
.CodeMirror-widget {}
|
258 |
+
|
259 |
+
.CodeMirror-code {
|
260 |
+
outline: none;
|
261 |
+
}
|
262 |
+
|
263 |
+
/* Force content-box sizing for the elements where we expect it */
|
264 |
+
.CodeMirror-scroll,
|
265 |
+
.CodeMirror-sizer,
|
266 |
+
.CodeMirror-gutter,
|
267 |
+
.CodeMirror-gutters,
|
268 |
+
.CodeMirror-linenumber {
|
269 |
+
-moz-box-sizing: content-box;
|
270 |
+
box-sizing: content-box;
|
271 |
+
}
|
272 |
+
|
273 |
+
.CodeMirror-measure {
|
274 |
+
position: absolute;
|
275 |
+
width: 100%;
|
276 |
+
height: 0;
|
277 |
+
overflow: hidden;
|
278 |
+
visibility: hidden;
|
279 |
+
}
|
280 |
+
.CodeMirror-measure pre { position: static; }
|
281 |
+
|
282 |
+
.CodeMirror div.CodeMirror-cursor {
|
283 |
+
position: absolute;
|
284 |
+
border-right: none;
|
285 |
+
width: 0;
|
286 |
+
}
|
287 |
+
|
288 |
+
div.CodeMirror-cursors {
|
289 |
+
visibility: hidden;
|
290 |
+
position: relative;
|
291 |
+
z-index: 3;
|
292 |
+
}
|
293 |
+
.CodeMirror-focused div.CodeMirror-cursors {
|
294 |
+
visibility: visible;
|
295 |
+
}
|
296 |
+
|
297 |
+
.CodeMirror-selected { background: #d9d9d9; }
|
298 |
+
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
299 |
+
.CodeMirror-crosshair { cursor: crosshair; }
|
300 |
+
.CodeMirror ::selection { background: #d7d4f0; }
|
301 |
+
.CodeMirror ::-moz-selection { background: #d7d4f0; }
|
302 |
+
|
303 |
+
.cm-searching {
|
304 |
+
background: #ffa;
|
305 |
+
background: rgba(255, 255, 0, .4);
|
306 |
+
}
|
307 |
+
|
308 |
+
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
309 |
+
.CodeMirror span { *vertical-align: text-bottom; }
|
310 |
+
|
311 |
+
/* Used to force a border model for a node */
|
312 |
+
.cm-force-border { padding-right: .1px; }
|
313 |
+
|
314 |
+
@media print {
|
315 |
+
/* Hide the cursor when printing */
|
316 |
+
.CodeMirror div.CodeMirror-cursors {
|
317 |
+
visibility: hidden;
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
/* See issue #2901 */
|
322 |
+
.cm-tab-wrap-hack:after { content: ''; }
|
323 |
+
|
324 |
+
/* Help users use markselection to safely style text background */
|
325 |
+
span.CodeMirror-selectedtext { background: none; }
|
lib/codemirror/lib/codemirror.js
ADDED
@@ -0,0 +1,8738 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
// This is CodeMirror (http://codemirror.net), a code editor
|
5 |
+
// implemented in JavaScript on top of the browser's DOM.
|
6 |
+
//
|
7 |
+
// You can find some technical background for some of the code below
|
8 |
+
// at http://marijnhaverbeke.nl/blog/#cm-internals .
|
9 |
+
|
10 |
+
(function(mod) {
|
11 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12 |
+
module.exports = mod();
|
13 |
+
else if (typeof define == "function" && define.amd) // AMD
|
14 |
+
return define([], mod);
|
15 |
+
else // Plain browser env
|
16 |
+
this.CodeMirror = mod();
|
17 |
+
})(function() {
|
18 |
+
"use strict";
|
19 |
+
|
20 |
+
// BROWSER SNIFFING
|
21 |
+
|
22 |
+
// Kludges for bugs and behavior differences that can't be feature
|
23 |
+
// detected are enabled based on userAgent etc sniffing.
|
24 |
+
|
25 |
+
var gecko = /gecko\/\d/i.test(navigator.userAgent);
|
26 |
+
var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
|
27 |
+
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
28 |
+
var ie = ie_upto10 || ie_11up;
|
29 |
+
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
|
30 |
+
var webkit = /WebKit\//.test(navigator.userAgent);
|
31 |
+
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
|
32 |
+
var chrome = /Chrome\//.test(navigator.userAgent);
|
33 |
+
var presto = /Opera\//.test(navigator.userAgent);
|
34 |
+
var safari = /Apple Computer/.test(navigator.vendor);
|
35 |
+
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
|
36 |
+
var phantom = /PhantomJS/.test(navigator.userAgent);
|
37 |
+
|
38 |
+
var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
39 |
+
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
40 |
+
var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
|
41 |
+
var mac = ios || /Mac/.test(navigator.platform);
|
42 |
+
var windows = /win/i.test(navigator.platform);
|
43 |
+
|
44 |
+
var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
|
45 |
+
if (presto_version) presto_version = Number(presto_version[1]);
|
46 |
+
if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
|
47 |
+
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
|
48 |
+
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
|
49 |
+
var captureRightClick = gecko || (ie && ie_version >= 9);
|
50 |
+
|
51 |
+
// Optimize some code when these features are not used.
|
52 |
+
var sawReadOnlySpans = false, sawCollapsedSpans = false;
|
53 |
+
|
54 |
+
// EDITOR CONSTRUCTOR
|
55 |
+
|
56 |
+
// A CodeMirror instance represents an editor. This is the object
|
57 |
+
// that user code is usually dealing with.
|
58 |
+
|
59 |
+
function CodeMirror(place, options) {
|
60 |
+
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
|
61 |
+
|
62 |
+
this.options = options = options ? copyObj(options) : {};
|
63 |
+
// Determine effective options based on given values and defaults.
|
64 |
+
copyObj(defaults, options, false);
|
65 |
+
setGuttersForLineNumbers(options);
|
66 |
+
|
67 |
+
var doc = options.value;
|
68 |
+
if (typeof doc == "string") doc = new Doc(doc, options.mode);
|
69 |
+
this.doc = doc;
|
70 |
+
|
71 |
+
var input = new CodeMirror.inputStyles[options.inputStyle](this);
|
72 |
+
var display = this.display = new Display(place, doc, input);
|
73 |
+
display.wrapper.CodeMirror = this;
|
74 |
+
updateGutters(this);
|
75 |
+
themeChanged(this);
|
76 |
+
if (options.lineWrapping)
|
77 |
+
this.display.wrapper.className += " CodeMirror-wrap";
|
78 |
+
if (options.autofocus && !mobile) display.input.focus();
|
79 |
+
initScrollbars(this);
|
80 |
+
|
81 |
+
this.state = {
|
82 |
+
keyMaps: [], // stores maps added by addKeyMap
|
83 |
+
overlays: [], // highlighting overlays, as added by addOverlay
|
84 |
+
modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
|
85 |
+
overwrite: false,
|
86 |
+
delayingBlurEvent: false,
|
87 |
+
focused: false,
|
88 |
+
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
|
89 |
+
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
|
90 |
+
draggingText: false,
|
91 |
+
highlight: new Delayed(), // stores highlight worker timeout
|
92 |
+
keySeq: null, // Unfinished key sequence
|
93 |
+
specialChars: null
|
94 |
+
};
|
95 |
+
|
96 |
+
var cm = this;
|
97 |
+
|
98 |
+
// Override magic textarea content restore that IE sometimes does
|
99 |
+
// on our hidden textarea on reload
|
100 |
+
if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
|
101 |
+
|
102 |
+
registerEventHandlers(this);
|
103 |
+
ensureGlobalHandlers();
|
104 |
+
|
105 |
+
startOperation(this);
|
106 |
+
this.curOp.forceUpdate = true;
|
107 |
+
attachDoc(this, doc);
|
108 |
+
|
109 |
+
if ((options.autofocus && !mobile) || cm.hasFocus())
|
110 |
+
setTimeout(bind(onFocus, this), 20);
|
111 |
+
else
|
112 |
+
onBlur(this);
|
113 |
+
|
114 |
+
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
|
115 |
+
optionHandlers[opt](this, options[opt], Init);
|
116 |
+
maybeUpdateLineNumberWidth(this);
|
117 |
+
if (options.finishInit) options.finishInit(this);
|
118 |
+
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
|
119 |
+
endOperation(this);
|
120 |
+
// Suppress optimizelegibility in Webkit, since it breaks text
|
121 |
+
// measuring on line wrapping boundaries.
|
122 |
+
if (webkit && options.lineWrapping &&
|
123 |
+
getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
|
124 |
+
display.lineDiv.style.textRendering = "auto";
|
125 |
+
}
|
126 |
+
|
127 |
+
// DISPLAY CONSTRUCTOR
|
128 |
+
|
129 |
+
// The display handles the DOM integration, both for input reading
|
130 |
+
// and content drawing. It holds references to DOM nodes and
|
131 |
+
// display-related state.
|
132 |
+
|
133 |
+
function Display(place, doc, input) {
|
134 |
+
var d = this;
|
135 |
+
this.input = input;
|
136 |
+
|
137 |
+
// Covers bottom-right square when both scrollbars are present.
|
138 |
+
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
|
139 |
+
d.scrollbarFiller.setAttribute("cm-not-content", "true");
|
140 |
+
// Covers bottom of gutter when coverGutterNextToScrollbar is on
|
141 |
+
// and h scrollbar is present.
|
142 |
+
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
|
143 |
+
d.gutterFiller.setAttribute("cm-not-content", "true");
|
144 |
+
// Will contain the actual code, positioned to cover the viewport.
|
145 |
+
d.lineDiv = elt("div", null, "CodeMirror-code");
|
146 |
+
// Elements are added to these to represent selection and cursors.
|
147 |
+
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
|
148 |
+
d.cursorDiv = elt("div", null, "CodeMirror-cursors");
|
149 |
+
// A visibility: hidden element used to find the size of things.
|
150 |
+
d.measure = elt("div", null, "CodeMirror-measure");
|
151 |
+
// When lines outside of the viewport are measured, they are drawn in this.
|
152 |
+
d.lineMeasure = elt("div", null, "CodeMirror-measure");
|
153 |
+
// Wraps everything that needs to exist inside the vertically-padded coordinate system
|
154 |
+
d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
|
155 |
+
null, "position: relative; outline: none");
|
156 |
+
// Moved around its parent to cover visible view.
|
157 |
+
d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
|
158 |
+
// Set to the height of the document, allowing scrolling.
|
159 |
+
d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
|
160 |
+
d.sizerWidth = null;
|
161 |
+
// Behavior of elts with overflow: auto and padding is
|
162 |
+
// inconsistent across browsers. This is used to ensure the
|
163 |
+
// scrollable area is big enough.
|
164 |
+
d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
|
165 |
+
// Will contain the gutters, if any.
|
166 |
+
d.gutters = elt("div", null, "CodeMirror-gutters");
|
167 |
+
d.lineGutter = null;
|
168 |
+
// Actual scrollable element.
|
169 |
+
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
|
170 |
+
d.scroller.setAttribute("tabIndex", "-1");
|
171 |
+
// The element in which the editor lives.
|
172 |
+
d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
|
173 |
+
|
174 |
+
// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
|
175 |
+
if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
|
176 |
+
if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
|
177 |
+
|
178 |
+
if (place) {
|
179 |
+
if (place.appendChild) place.appendChild(d.wrapper);
|
180 |
+
else place(d.wrapper);
|
181 |
+
}
|
182 |
+
|
183 |
+
// Current rendered range (may be bigger than the view window).
|
184 |
+
d.viewFrom = d.viewTo = doc.first;
|
185 |
+
d.reportedViewFrom = d.reportedViewTo = doc.first;
|
186 |
+
// Information about the rendered lines.
|
187 |
+
d.view = [];
|
188 |
+
d.renderedView = null;
|
189 |
+
// Holds info about a single rendered line when it was rendered
|
190 |
+
// for measurement, while not in view.
|
191 |
+
d.externalMeasured = null;
|
192 |
+
// Empty space (in pixels) above the view
|
193 |
+
d.viewOffset = 0;
|
194 |
+
d.lastWrapHeight = d.lastWrapWidth = 0;
|
195 |
+
d.updateLineNumbers = null;
|
196 |
+
|
197 |
+
d.nativeBarWidth = d.barHeight = d.barWidth = 0;
|
198 |
+
d.scrollbarsClipped = false;
|
199 |
+
|
200 |
+
// Used to only resize the line number gutter when necessary (when
|
201 |
+
// the amount of lines crosses a boundary that makes its width change)
|
202 |
+
d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
|
203 |
+
// Set to true when a non-horizontal-scrolling line widget is
|
204 |
+
// added. As an optimization, line widget aligning is skipped when
|
205 |
+
// this is false.
|
206 |
+
d.alignWidgets = false;
|
207 |
+
|
208 |
+
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
|
209 |
+
|
210 |
+
// Tracks the maximum line length so that the horizontal scrollbar
|
211 |
+
// can be kept static when scrolling.
|
212 |
+
d.maxLine = null;
|
213 |
+
d.maxLineLength = 0;
|
214 |
+
d.maxLineChanged = false;
|
215 |
+
|
216 |
+
// Used for measuring wheel scrolling granularity
|
217 |
+
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
|
218 |
+
|
219 |
+
// True when shift is held down.
|
220 |
+
d.shift = false;
|
221 |
+
|
222 |
+
// Used to track whether anything happened since the context menu
|
223 |
+
// was opened.
|
224 |
+
d.selForContextMenu = null;
|
225 |
+
|
226 |
+
d.activeTouch = null;
|
227 |
+
|
228 |
+
input.init(d);
|
229 |
+
}
|
230 |
+
|
231 |
+
// STATE UPDATES
|
232 |
+
|
233 |
+
// Used to get the editor into a consistent state again when options change.
|
234 |
+
|
235 |
+
function loadMode(cm) {
|
236 |
+
cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
|
237 |
+
resetModeState(cm);
|
238 |
+
}
|
239 |
+
|
240 |
+
function resetModeState(cm) {
|
241 |
+
cm.doc.iter(function(line) {
|
242 |
+
if (line.stateAfter) line.stateAfter = null;
|
243 |
+
if (line.styles) line.styles = null;
|
244 |
+
});
|
245 |
+
cm.doc.frontier = cm.doc.first;
|
246 |
+
startWorker(cm, 100);
|
247 |
+
cm.state.modeGen++;
|
248 |
+
if (cm.curOp) regChange(cm);
|
249 |
+
}
|
250 |
+
|
251 |
+
function wrappingChanged(cm) {
|
252 |
+
if (cm.options.lineWrapping) {
|
253 |
+
addClass(cm.display.wrapper, "CodeMirror-wrap");
|
254 |
+
cm.display.sizer.style.minWidth = "";
|
255 |
+
cm.display.sizerWidth = null;
|
256 |
+
} else {
|
257 |
+
rmClass(cm.display.wrapper, "CodeMirror-wrap");
|
258 |
+
findMaxLine(cm);
|
259 |
+
}
|
260 |
+
estimateLineHeights(cm);
|
261 |
+
regChange(cm);
|
262 |
+
clearCaches(cm);
|
263 |
+
setTimeout(function(){updateScrollbars(cm);}, 100);
|
264 |
+
}
|
265 |
+
|
266 |
+
// Returns a function that estimates the height of a line, to use as
|
267 |
+
// first approximation until the line becomes visible (and is thus
|
268 |
+
// properly measurable).
|
269 |
+
function estimateHeight(cm) {
|
270 |
+
var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
|
271 |
+
var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
|
272 |
+
return function(line) {
|
273 |
+
if (lineIsHidden(cm.doc, line)) return 0;
|
274 |
+
|
275 |
+
var widgetsHeight = 0;
|
276 |
+
if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
|
277 |
+
if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
|
278 |
+
}
|
279 |
+
|
280 |
+
if (wrapping)
|
281 |
+
return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
|
282 |
+
else
|
283 |
+
return widgetsHeight + th;
|
284 |
+
};
|
285 |
+
}
|
286 |
+
|
287 |
+
function estimateLineHeights(cm) {
|
288 |
+
var doc = cm.doc, est = estimateHeight(cm);
|
289 |
+
doc.iter(function(line) {
|
290 |
+
var estHeight = est(line);
|
291 |
+
if (estHeight != line.height) updateLineHeight(line, estHeight);
|
292 |
+
});
|
293 |
+
}
|
294 |
+
|
295 |
+
function themeChanged(cm) {
|
296 |
+
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
|
297 |
+
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
|
298 |
+
clearCaches(cm);
|
299 |
+
}
|
300 |
+
|
301 |
+
function guttersChanged(cm) {
|
302 |
+
updateGutters(cm);
|
303 |
+
regChange(cm);
|
304 |
+
setTimeout(function(){alignHorizontally(cm);}, 20);
|
305 |
+
}
|
306 |
+
|
307 |
+
// Rebuild the gutter elements, ensure the margin to the left of the
|
308 |
+
// code matches their width.
|
309 |
+
function updateGutters(cm) {
|
310 |
+
var gutters = cm.display.gutters, specs = cm.options.gutters;
|
311 |
+
removeChildren(gutters);
|
312 |
+
for (var i = 0; i < specs.length; ++i) {
|
313 |
+
var gutterClass = specs[i];
|
314 |
+
var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
|
315 |
+
if (gutterClass == "CodeMirror-linenumbers") {
|
316 |
+
cm.display.lineGutter = gElt;
|
317 |
+
gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
|
318 |
+
}
|
319 |
+
}
|
320 |
+
gutters.style.display = i ? "" : "none";
|
321 |
+
updateGutterSpace(cm);
|
322 |
+
}
|
323 |
+
|
324 |
+
function updateGutterSpace(cm) {
|
325 |
+
var width = cm.display.gutters.offsetWidth;
|
326 |
+
cm.display.sizer.style.marginLeft = width + "px";
|
327 |
+
}
|
328 |
+
|
329 |
+
// Compute the character length of a line, taking into account
|
330 |
+
// collapsed ranges (see markText) that might hide parts, and join
|
331 |
+
// other lines onto it.
|
332 |
+
function lineLength(line) {
|
333 |
+
if (line.height == 0) return 0;
|
334 |
+
var len = line.text.length, merged, cur = line;
|
335 |
+
while (merged = collapsedSpanAtStart(cur)) {
|
336 |
+
var found = merged.find(0, true);
|
337 |
+
cur = found.from.line;
|
338 |
+
len += found.from.ch - found.to.ch;
|
339 |
+
}
|
340 |
+
cur = line;
|
341 |
+
while (merged = collapsedSpanAtEnd(cur)) {
|
342 |
+
var found = merged.find(0, true);
|
343 |
+
len -= cur.text.length - found.from.ch;
|
344 |
+
cur = found.to.line;
|
345 |
+
len += cur.text.length - found.to.ch;
|
346 |
+
}
|
347 |
+
return len;
|
348 |
+
}
|
349 |
+
|
350 |
+
// Find the longest line in the document.
|
351 |
+
function findMaxLine(cm) {
|
352 |
+
var d = cm.display, doc = cm.doc;
|
353 |
+
d.maxLine = getLine(doc, doc.first);
|
354 |
+
d.maxLineLength = lineLength(d.maxLine);
|
355 |
+
d.maxLineChanged = true;
|
356 |
+
doc.iter(function(line) {
|
357 |
+
var len = lineLength(line);
|
358 |
+
if (len > d.maxLineLength) {
|
359 |
+
d.maxLineLength = len;
|
360 |
+
d.maxLine = line;
|
361 |
+
}
|
362 |
+
});
|
363 |
+
}
|
364 |
+
|
365 |
+
// Make sure the gutters options contains the element
|
366 |
+
// "CodeMirror-linenumbers" when the lineNumbers option is true.
|
367 |
+
function setGuttersForLineNumbers(options) {
|
368 |
+
var found = indexOf(options.gutters, "CodeMirror-linenumbers");
|
369 |
+
if (found == -1 && options.lineNumbers) {
|
370 |
+
options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
|
371 |
+
} else if (found > -1 && !options.lineNumbers) {
|
372 |
+
options.gutters = options.gutters.slice(0);
|
373 |
+
options.gutters.splice(found, 1);
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
// SCROLLBARS
|
378 |
+
|
379 |
+
// Prepare DOM reads needed to update the scrollbars. Done in one
|
380 |
+
// shot to minimize update/measure roundtrips.
|
381 |
+
function measureForScrollbars(cm) {
|
382 |
+
var d = cm.display, gutterW = d.gutters.offsetWidth;
|
383 |
+
var docH = Math.round(cm.doc.height + paddingVert(cm.display));
|
384 |
+
return {
|
385 |
+
clientHeight: d.scroller.clientHeight,
|
386 |
+
viewHeight: d.wrapper.clientHeight,
|
387 |
+
scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
|
388 |
+
viewWidth: d.wrapper.clientWidth,
|
389 |
+
barLeft: cm.options.fixedGutter ? gutterW : 0,
|
390 |
+
docHeight: docH,
|
391 |
+
scrollHeight: docH + scrollGap(cm) + d.barHeight,
|
392 |
+
nativeBarWidth: d.nativeBarWidth,
|
393 |
+
gutterWidth: gutterW
|
394 |
+
};
|
395 |
+
}
|
396 |
+
|
397 |
+
function NativeScrollbars(place, scroll, cm) {
|
398 |
+
this.cm = cm;
|
399 |
+
var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
|
400 |
+
var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
|
401 |
+
place(vert); place(horiz);
|
402 |
+
|
403 |
+
on(vert, "scroll", function() {
|
404 |
+
if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
|
405 |
+
});
|
406 |
+
on(horiz, "scroll", function() {
|
407 |
+
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
|
408 |
+
});
|
409 |
+
|
410 |
+
this.checkedOverlay = false;
|
411 |
+
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
|
412 |
+
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
|
413 |
+
}
|
414 |
+
|
415 |
+
NativeScrollbars.prototype = copyObj({
|
416 |
+
update: function(measure) {
|
417 |
+
var needsH = measure.scrollWidth > measure.clientWidth + 1;
|
418 |
+
var needsV = measure.scrollHeight > measure.clientHeight + 1;
|
419 |
+
var sWidth = measure.nativeBarWidth;
|
420 |
+
|
421 |
+
if (needsV) {
|
422 |
+
this.vert.style.display = "block";
|
423 |
+
this.vert.style.bottom = needsH ? sWidth + "px" : "0";
|
424 |
+
var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
|
425 |
+
// A bug in IE8 can cause this value to be negative, so guard it.
|
426 |
+
this.vert.firstChild.style.height =
|
427 |
+
Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
|
428 |
+
} else {
|
429 |
+
this.vert.style.display = "";
|
430 |
+
this.vert.firstChild.style.height = "0";
|
431 |
+
}
|
432 |
+
|
433 |
+
if (needsH) {
|
434 |
+
this.horiz.style.display = "block";
|
435 |
+
this.horiz.style.right = needsV ? sWidth + "px" : "0";
|
436 |
+
this.horiz.style.left = measure.barLeft + "px";
|
437 |
+
var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
|
438 |
+
this.horiz.firstChild.style.width =
|
439 |
+
(measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
|
440 |
+
} else {
|
441 |
+
this.horiz.style.display = "";
|
442 |
+
this.horiz.firstChild.style.width = "0";
|
443 |
+
}
|
444 |
+
|
445 |
+
if (!this.checkedOverlay && measure.clientHeight > 0) {
|
446 |
+
if (sWidth == 0) this.overlayHack();
|
447 |
+
this.checkedOverlay = true;
|
448 |
+
}
|
449 |
+
|
450 |
+
return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
|
451 |
+
},
|
452 |
+
setScrollLeft: function(pos) {
|
453 |
+
if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
|
454 |
+
},
|
455 |
+
setScrollTop: function(pos) {
|
456 |
+
if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
|
457 |
+
},
|
458 |
+
overlayHack: function() {
|
459 |
+
var w = mac && !mac_geMountainLion ? "12px" : "18px";
|
460 |
+
this.horiz.style.minHeight = this.vert.style.minWidth = w;
|
461 |
+
var self = this;
|
462 |
+
var barMouseDown = function(e) {
|
463 |
+
if (e_target(e) != self.vert && e_target(e) != self.horiz)
|
464 |
+
operation(self.cm, onMouseDown)(e);
|
465 |
+
};
|
466 |
+
on(this.vert, "mousedown", barMouseDown);
|
467 |
+
on(this.horiz, "mousedown", barMouseDown);
|
468 |
+
},
|
469 |
+
clear: function() {
|
470 |
+
var parent = this.horiz.parentNode;
|
471 |
+
parent.removeChild(this.horiz);
|
472 |
+
parent.removeChild(this.vert);
|
473 |
+
}
|
474 |
+
}, NativeScrollbars.prototype);
|
475 |
+
|
476 |
+
function NullScrollbars() {}
|
477 |
+
|
478 |
+
NullScrollbars.prototype = copyObj({
|
479 |
+
update: function() { return {bottom: 0, right: 0}; },
|
480 |
+
setScrollLeft: function() {},
|
481 |
+
setScrollTop: function() {},
|
482 |
+
clear: function() {}
|
483 |
+
}, NullScrollbars.prototype);
|
484 |
+
|
485 |
+
CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
|
486 |
+
|
487 |
+
function initScrollbars(cm) {
|
488 |
+
if (cm.display.scrollbars) {
|
489 |
+
cm.display.scrollbars.clear();
|
490 |
+
if (cm.display.scrollbars.addClass)
|
491 |
+
rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
|
492 |
+
}
|
493 |
+
|
494 |
+
cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
|
495 |
+
cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
|
496 |
+
// Prevent clicks in the scrollbars from killing focus
|
497 |
+
on(node, "mousedown", function() {
|
498 |
+
if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
|
499 |
+
});
|
500 |
+
node.setAttribute("cm-not-content", "true");
|
501 |
+
}, function(pos, axis) {
|
502 |
+
if (axis == "horizontal") setScrollLeft(cm, pos);
|
503 |
+
else setScrollTop(cm, pos);
|
504 |
+
}, cm);
|
505 |
+
if (cm.display.scrollbars.addClass)
|
506 |
+
addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
|
507 |
+
}
|
508 |
+
|
509 |
+
function updateScrollbars(cm, measure) {
|
510 |
+
if (!measure) measure = measureForScrollbars(cm);
|
511 |
+
var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
|
512 |
+
updateScrollbarsInner(cm, measure);
|
513 |
+
for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
|
514 |
+
if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
|
515 |
+
updateHeightsInViewport(cm);
|
516 |
+
updateScrollbarsInner(cm, measureForScrollbars(cm));
|
517 |
+
startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
|
518 |
+
}
|
519 |
+
}
|
520 |
+
|
521 |
+
// Re-synchronize the fake scrollbars with the actual size of the
|
522 |
+
// content.
|
523 |
+
function updateScrollbarsInner(cm, measure) {
|
524 |
+
var d = cm.display;
|
525 |
+
var sizes = d.scrollbars.update(measure);
|
526 |
+
|
527 |
+
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
|
528 |
+
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
|
529 |
+
|
530 |
+
if (sizes.right && sizes.bottom) {
|
531 |
+
d.scrollbarFiller.style.display = "block";
|
532 |
+
d.scrollbarFiller.style.height = sizes.bottom + "px";
|
533 |
+
d.scrollbarFiller.style.width = sizes.right + "px";
|
534 |
+
} else d.scrollbarFiller.style.display = "";
|
535 |
+
if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
|
536 |
+
d.gutterFiller.style.display = "block";
|
537 |
+
d.gutterFiller.style.height = sizes.bottom + "px";
|
538 |
+
d.gutterFiller.style.width = measure.gutterWidth + "px";
|
539 |
+
} else d.gutterFiller.style.display = "";
|
540 |
+
}
|
541 |
+
|
542 |
+
// Compute the lines that are visible in a given viewport (defaults
|
543 |
+
// the the current scroll position). viewport may contain top,
|
544 |
+
// height, and ensure (see op.scrollToPos) properties.
|
545 |
+
function visibleLines(display, doc, viewport) {
|
546 |
+
var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
|
547 |
+
top = Math.floor(top - paddingTop(display));
|
548 |
+
var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
|
549 |
+
|
550 |
+
var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
|
551 |
+
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
|
552 |
+
// forces those lines into the viewport (if possible).
|
553 |
+
if (viewport && viewport.ensure) {
|
554 |
+
var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
|
555 |
+
if (ensureFrom < from) {
|
556 |
+
from = ensureFrom;
|
557 |
+
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
|
558 |
+
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
|
559 |
+
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
|
560 |
+
to = ensureTo;
|
561 |
+
}
|
562 |
+
}
|
563 |
+
return {from: from, to: Math.max(to, from + 1)};
|
564 |
+
}
|
565 |
+
|
566 |
+
// LINE NUMBERS
|
567 |
+
|
568 |
+
// Re-align line numbers and gutter marks to compensate for
|
569 |
+
// horizontal scrolling.
|
570 |
+
function alignHorizontally(cm) {
|
571 |
+
var display = cm.display, view = display.view;
|
572 |
+
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
|
573 |
+
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
|
574 |
+
var gutterW = display.gutters.offsetWidth, left = comp + "px";
|
575 |
+
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
|
576 |
+
if (cm.options.fixedGutter && view[i].gutter)
|
577 |
+
view[i].gutter.style.left = left;
|
578 |
+
var align = view[i].alignable;
|
579 |
+
if (align) for (var j = 0; j < align.length; j++)
|
580 |
+
align[j].style.left = left;
|
581 |
+
}
|
582 |
+
if (cm.options.fixedGutter)
|
583 |
+
display.gutters.style.left = (comp + gutterW) + "px";
|
584 |
+
}
|
585 |
+
|
586 |
+
// Used to ensure that the line number gutter is still the right
|
587 |
+
// size for the current document size. Returns true when an update
|
588 |
+
// is needed.
|
589 |
+
function maybeUpdateLineNumberWidth(cm) {
|
590 |
+
if (!cm.options.lineNumbers) return false;
|
591 |
+
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
|
592 |
+
if (last.length != display.lineNumChars) {
|
593 |
+
var test = display.measure.appendChild(elt("div", [elt("div", last)],
|
594 |
+
"CodeMirror-linenumber CodeMirror-gutter-elt"));
|
595 |
+
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
|
596 |
+
display.lineGutter.style.width = "";
|
597 |
+
display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
|
598 |
+
display.lineNumWidth = display.lineNumInnerWidth + padding;
|
599 |
+
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
|
600 |
+
display.lineGutter.style.width = display.lineNumWidth + "px";
|
601 |
+
updateGutterSpace(cm);
|
602 |
+
return true;
|
603 |
+
}
|
604 |
+
return false;
|
605 |
+
}
|
606 |
+
|
607 |
+
function lineNumberFor(options, i) {
|
608 |
+
return String(options.lineNumberFormatter(i + options.firstLineNumber));
|
609 |
+
}
|
610 |
+
|
611 |
+
// Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
|
612 |
+
// but using getBoundingClientRect to get a sub-pixel-accurate
|
613 |
+
// result.
|
614 |
+
function compensateForHScroll(display) {
|
615 |
+
return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
|
616 |
+
}
|
617 |
+
|
618 |
+
// DISPLAY DRAWING
|
619 |
+
|
620 |
+
function DisplayUpdate(cm, viewport, force) {
|
621 |
+
var display = cm.display;
|
622 |
+
|
623 |
+
this.viewport = viewport;
|
624 |
+
// Store some values that we'll need later (but don't want to force a relayout for)
|
625 |
+
this.visible = visibleLines(display, cm.doc, viewport);
|
626 |
+
this.editorIsHidden = !display.wrapper.offsetWidth;
|
627 |
+
this.wrapperHeight = display.wrapper.clientHeight;
|
628 |
+
this.wrapperWidth = display.wrapper.clientWidth;
|
629 |
+
this.oldDisplayWidth = displayWidth(cm);
|
630 |
+
this.force = force;
|
631 |
+
this.dims = getDimensions(cm);
|
632 |
+
this.events = [];
|
633 |
+
}
|
634 |
+
|
635 |
+
DisplayUpdate.prototype.signal = function(emitter, type) {
|
636 |
+
if (hasHandler(emitter, type))
|
637 |
+
this.events.push(arguments);
|
638 |
+
};
|
639 |
+
DisplayUpdate.prototype.finish = function() {
|
640 |
+
for (var i = 0; i < this.events.length; i++)
|
641 |
+
signal.apply(null, this.events[i]);
|
642 |
+
};
|
643 |
+
|
644 |
+
function maybeClipScrollbars(cm) {
|
645 |
+
var display = cm.display;
|
646 |
+
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
|
647 |
+
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
|
648 |
+
display.heightForcer.style.height = scrollGap(cm) + "px";
|
649 |
+
display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
|
650 |
+
display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
|
651 |
+
display.scrollbarsClipped = true;
|
652 |
+
}
|
653 |
+
}
|
654 |
+
|
655 |
+
// Does the actual updating of the line display. Bails out
|
656 |
+
// (returning false) when there is nothing to be done and forced is
|
657 |
+
// false.
|
658 |
+
function updateDisplayIfNeeded(cm, update) {
|
659 |
+
var display = cm.display, doc = cm.doc;
|
660 |
+
|
661 |
+
if (update.editorIsHidden) {
|
662 |
+
resetView(cm);
|
663 |
+
return false;
|
664 |
+
}
|
665 |
+
|
666 |
+
// Bail out if the visible area is already rendered and nothing changed.
|
667 |
+
if (!update.force &&
|
668 |
+
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
|
669 |
+
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
|
670 |
+
display.renderedView == display.view && countDirtyView(cm) == 0)
|
671 |
+
return false;
|
672 |
+
|
673 |
+
if (maybeUpdateLineNumberWidth(cm)) {
|
674 |
+
resetView(cm);
|
675 |
+
update.dims = getDimensions(cm);
|
676 |
+
}
|
677 |
+
|
678 |
+
// Compute a suitable new viewport (from & to)
|
679 |
+
var end = doc.first + doc.size;
|
680 |
+
var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
|
681 |
+
var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
|
682 |
+
if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
|
683 |
+
if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
|
684 |
+
if (sawCollapsedSpans) {
|
685 |
+
from = visualLineNo(cm.doc, from);
|
686 |
+
to = visualLineEndNo(cm.doc, to);
|
687 |
+
}
|
688 |
+
|
689 |
+
var different = from != display.viewFrom || to != display.viewTo ||
|
690 |
+
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
|
691 |
+
adjustView(cm, from, to);
|
692 |
+
|
693 |
+
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
|
694 |
+
// Position the mover div to align with the current scroll position
|
695 |
+
cm.display.mover.style.top = display.viewOffset + "px";
|
696 |
+
|
697 |
+
var toUpdate = countDirtyView(cm);
|
698 |
+
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
|
699 |
+
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
|
700 |
+
return false;
|
701 |
+
|
702 |
+
// For big changes, we hide the enclosing element during the
|
703 |
+
// update, since that speeds up the operations on most browsers.
|
704 |
+
var focused = activeElt();
|
705 |
+
if (toUpdate > 4) display.lineDiv.style.display = "none";
|
706 |
+
patchDisplay(cm, display.updateLineNumbers, update.dims);
|
707 |
+
if (toUpdate > 4) display.lineDiv.style.display = "";
|
708 |
+
display.renderedView = display.view;
|
709 |
+
// There might have been a widget with a focused element that got
|
710 |
+
// hidden or updated, if so re-focus it.
|
711 |
+
if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
|
712 |
+
|
713 |
+
// Prevent selection and cursors from interfering with the scroll
|
714 |
+
// width and height.
|
715 |
+
removeChildren(display.cursorDiv);
|
716 |
+
removeChildren(display.selectionDiv);
|
717 |
+
display.gutters.style.height = 0;
|
718 |
+
|
719 |
+
if (different) {
|
720 |
+
display.lastWrapHeight = update.wrapperHeight;
|
721 |
+
display.lastWrapWidth = update.wrapperWidth;
|
722 |
+
startWorker(cm, 400);
|
723 |
+
}
|
724 |
+
|
725 |
+
display.updateLineNumbers = null;
|
726 |
+
|
727 |
+
return true;
|
728 |
+
}
|
729 |
+
|
730 |
+
function postUpdateDisplay(cm, update) {
|
731 |
+
var force = update.force, viewport = update.viewport;
|
732 |
+
for (var first = true;; first = false) {
|
733 |
+
if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) {
|
734 |
+
force = true;
|
735 |
+
} else {
|
736 |
+
force = false;
|
737 |
+
// Clip forced viewport to actual scrollable area.
|
738 |
+
if (viewport && viewport.top != null)
|
739 |
+
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
|
740 |
+
// Updated line heights might result in the drawn area not
|
741 |
+
// actually covering the viewport. Keep looping until it does.
|
742 |
+
update.visible = visibleLines(cm.display, cm.doc, viewport);
|
743 |
+
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
|
744 |
+
break;
|
745 |
+
}
|
746 |
+
if (!updateDisplayIfNeeded(cm, update)) break;
|
747 |
+
updateHeightsInViewport(cm);
|
748 |
+
var barMeasure = measureForScrollbars(cm);
|
749 |
+
updateSelection(cm);
|
750 |
+
setDocumentHeight(cm, barMeasure);
|
751 |
+
updateScrollbars(cm, barMeasure);
|
752 |
+
}
|
753 |
+
|
754 |
+
update.signal(cm, "update", cm);
|
755 |
+
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
|
756 |
+
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
|
757 |
+
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
|
758 |
+
}
|
759 |
+
}
|
760 |
+
|
761 |
+
function updateDisplaySimple(cm, viewport) {
|
762 |
+
var update = new DisplayUpdate(cm, viewport);
|
763 |
+
if (updateDisplayIfNeeded(cm, update)) {
|
764 |
+
updateHeightsInViewport(cm);
|
765 |
+
postUpdateDisplay(cm, update);
|
766 |
+
var barMeasure = measureForScrollbars(cm);
|
767 |
+
updateSelection(cm);
|
768 |
+
setDocumentHeight(cm, barMeasure);
|
769 |
+
updateScrollbars(cm, barMeasure);
|
770 |
+
update.finish();
|
771 |
+
}
|
772 |
+
}
|
773 |
+
|
774 |
+
function setDocumentHeight(cm, measure) {
|
775 |
+
cm.display.sizer.style.minHeight = measure.docHeight + "px";
|
776 |
+
var total = measure.docHeight + cm.display.barHeight;
|
777 |
+
cm.display.heightForcer.style.top = total + "px";
|
778 |
+
cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
|
779 |
+
}
|
780 |
+
|
781 |
+
// Read the actual heights of the rendered lines, and update their
|
782 |
+
// stored heights to match.
|
783 |
+
function updateHeightsInViewport(cm) {
|
784 |
+
var display = cm.display;
|
785 |
+
var prevBottom = display.lineDiv.offsetTop;
|
786 |
+
for (var i = 0; i < display.view.length; i++) {
|
787 |
+
var cur = display.view[i], height;
|
788 |
+
if (cur.hidden) continue;
|
789 |
+
if (ie && ie_version < 8) {
|
790 |
+
var bot = cur.node.offsetTop + cur.node.offsetHeight;
|
791 |
+
height = bot - prevBottom;
|
792 |
+
prevBottom = bot;
|
793 |
+
} else {
|
794 |
+
var box = cur.node.getBoundingClientRect();
|
795 |
+
height = box.bottom - box.top;
|
796 |
+
}
|
797 |
+
var diff = cur.line.height - height;
|
798 |
+
if (height < 2) height = textHeight(display);
|
799 |
+
if (diff > .001 || diff < -.001) {
|
800 |
+
updateLineHeight(cur.line, height);
|
801 |
+
updateWidgetHeight(cur.line);
|
802 |
+
if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
|
803 |
+
updateWidgetHeight(cur.rest[j]);
|
804 |
+
}
|
805 |
+
}
|
806 |
+
}
|
807 |
+
|
808 |
+
// Read and store the height of line widgets associated with the
|
809 |
+
// given line.
|
810 |
+
function updateWidgetHeight(line) {
|
811 |
+
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
|
812 |
+
line.widgets[i].height = line.widgets[i].node.offsetHeight;
|
813 |
+
}
|
814 |
+
|
815 |
+
// Do a bulk-read of the DOM positions and sizes needed to draw the
|
816 |
+
// view, so that we don't interleave reading and writing to the DOM.
|
817 |
+
function getDimensions(cm) {
|
818 |
+
var d = cm.display, left = {}, width = {};
|
819 |
+
var gutterLeft = d.gutters.clientLeft;
|
820 |
+
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
|
821 |
+
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
|
822 |
+
width[cm.options.gutters[i]] = n.clientWidth;
|
823 |
+
}
|
824 |
+
return {fixedPos: compensateForHScroll(d),
|
825 |
+
gutterTotalWidth: d.gutters.offsetWidth,
|
826 |
+
gutterLeft: left,
|
827 |
+
gutterWidth: width,
|
828 |
+
wrapperWidth: d.wrapper.clientWidth};
|
829 |
+
}
|
830 |
+
|
831 |
+
// Sync the actual display DOM structure with display.view, removing
|
832 |
+
// nodes for lines that are no longer in view, and creating the ones
|
833 |
+
// that are not there yet, and updating the ones that are out of
|
834 |
+
// date.
|
835 |
+
function patchDisplay(cm, updateNumbersFrom, dims) {
|
836 |
+
var display = cm.display, lineNumbers = cm.options.lineNumbers;
|
837 |
+
var container = display.lineDiv, cur = container.firstChild;
|
838 |
+
|
839 |
+
function rm(node) {
|
840 |
+
var next = node.nextSibling;
|
841 |
+
// Works around a throw-scroll bug in OS X Webkit
|
842 |
+
if (webkit && mac && cm.display.currentWheelTarget == node)
|
843 |
+
node.style.display = "none";
|
844 |
+
else
|
845 |
+
node.parentNode.removeChild(node);
|
846 |
+
return next;
|
847 |
+
}
|
848 |
+
|
849 |
+
var view = display.view, lineN = display.viewFrom;
|
850 |
+
// Loop over the elements in the view, syncing cur (the DOM nodes
|
851 |
+
// in display.lineDiv) with the view as we go.
|
852 |
+
for (var i = 0; i < view.length; i++) {
|
853 |
+
var lineView = view[i];
|
854 |
+
if (lineView.hidden) {
|
855 |
+
} else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
|
856 |
+
var node = buildLineElement(cm, lineView, lineN, dims);
|
857 |
+
container.insertBefore(node, cur);
|
858 |
+
} else { // Already drawn
|
859 |
+
while (cur != lineView.node) cur = rm(cur);
|
860 |
+
var updateNumber = lineNumbers && updateNumbersFrom != null &&
|
861 |
+
updateNumbersFrom <= lineN && lineView.lineNumber;
|
862 |
+
if (lineView.changes) {
|
863 |
+
if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
|
864 |
+
updateLineForChanges(cm, lineView, lineN, dims);
|
865 |
+
}
|
866 |
+
if (updateNumber) {
|
867 |
+
removeChildren(lineView.lineNumber);
|
868 |
+
lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
|
869 |
+
}
|
870 |
+
cur = lineView.node.nextSibling;
|
871 |
+
}
|
872 |
+
lineN += lineView.size;
|
873 |
+
}
|
874 |
+
while (cur) cur = rm(cur);
|
875 |
+
}
|
876 |
+
|
877 |
+
// When an aspect of a line changes, a string is added to
|
878 |
+
// lineView.changes. This updates the relevant part of the line's
|
879 |
+
// DOM structure.
|
880 |
+
function updateLineForChanges(cm, lineView, lineN, dims) {
|
881 |
+
for (var j = 0; j < lineView.changes.length; j++) {
|
882 |
+
var type = lineView.changes[j];
|
883 |
+
if (type == "text") updateLineText(cm, lineView);
|
884 |
+
else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
|
885 |
+
else if (type == "class") updateLineClasses(lineView);
|
886 |
+
else if (type == "widget") updateLineWidgets(cm, lineView, dims);
|
887 |
+
}
|
888 |
+
lineView.changes = null;
|
889 |
+
}
|
890 |
+
|
891 |
+
// Lines with gutter elements, widgets or a background class need to
|
892 |
+
// be wrapped, and have the extra elements added to the wrapper div
|
893 |
+
function ensureLineWrapped(lineView) {
|
894 |
+
if (lineView.node == lineView.text) {
|
895 |
+
lineView.node = elt("div", null, null, "position: relative");
|
896 |
+
if (lineView.text.parentNode)
|
897 |
+
lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
|
898 |
+
lineView.node.appendChild(lineView.text);
|
899 |
+
if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
|
900 |
+
}
|
901 |
+
return lineView.node;
|
902 |
+
}
|
903 |
+
|
904 |
+
function updateLineBackground(lineView) {
|
905 |
+
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
|
906 |
+
if (cls) cls += " CodeMirror-linebackground";
|
907 |
+
if (lineView.background) {
|
908 |
+
if (cls) lineView.background.className = cls;
|
909 |
+
else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
|
910 |
+
} else if (cls) {
|
911 |
+
var wrap = ensureLineWrapped(lineView);
|
912 |
+
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
|
913 |
+
}
|
914 |
+
}
|
915 |
+
|
916 |
+
// Wrapper around buildLineContent which will reuse the structure
|
917 |
+
// in display.externalMeasured when possible.
|
918 |
+
function getLineContent(cm, lineView) {
|
919 |
+
var ext = cm.display.externalMeasured;
|
920 |
+
if (ext && ext.line == lineView.line) {
|
921 |
+
cm.display.externalMeasured = null;
|
922 |
+
lineView.measure = ext.measure;
|
923 |
+
return ext.built;
|
924 |
+
}
|
925 |
+
return buildLineContent(cm, lineView);
|
926 |
+
}
|
927 |
+
|
928 |
+
// Redraw the line's text. Interacts with the background and text
|
929 |
+
// classes because the mode may output tokens that influence these
|
930 |
+
// classes.
|
931 |
+
function updateLineText(cm, lineView) {
|
932 |
+
var cls = lineView.text.className;
|
933 |
+
var built = getLineContent(cm, lineView);
|
934 |
+
if (lineView.text == lineView.node) lineView.node = built.pre;
|
935 |
+
lineView.text.parentNode.replaceChild(built.pre, lineView.text);
|
936 |
+
lineView.text = built.pre;
|
937 |
+
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
|
938 |
+
lineView.bgClass = built.bgClass;
|
939 |
+
lineView.textClass = built.textClass;
|
940 |
+
updateLineClasses(lineView);
|
941 |
+
} else if (cls) {
|
942 |
+
lineView.text.className = cls;
|
943 |
+
}
|
944 |
+
}
|
945 |
+
|
946 |
+
function updateLineClasses(lineView) {
|
947 |
+
updateLineBackground(lineView);
|
948 |
+
if (lineView.line.wrapClass)
|
949 |
+
ensureLineWrapped(lineView).className = lineView.line.wrapClass;
|
950 |
+
else if (lineView.node != lineView.text)
|
951 |
+
lineView.node.className = "";
|
952 |
+
var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
|
953 |
+
lineView.text.className = textClass || "";
|
954 |
+
}
|
955 |
+
|
956 |
+
function updateLineGutter(cm, lineView, lineN, dims) {
|
957 |
+
if (lineView.gutter) {
|
958 |
+
lineView.node.removeChild(lineView.gutter);
|
959 |
+
lineView.gutter = null;
|
960 |
+
}
|
961 |
+
var markers = lineView.line.gutterMarkers;
|
962 |
+
if (cm.options.lineNumbers || markers) {
|
963 |
+
var wrap = ensureLineWrapped(lineView);
|
964 |
+
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
|
965 |
+
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
|
966 |
+
"px; width: " + dims.gutterTotalWidth + "px");
|
967 |
+
cm.display.input.setUneditable(gutterWrap);
|
968 |
+
wrap.insertBefore(gutterWrap, lineView.text);
|
969 |
+
if (lineView.line.gutterClass)
|
970 |
+
gutterWrap.className += " " + lineView.line.gutterClass;
|
971 |
+
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
|
972 |
+
lineView.lineNumber = gutterWrap.appendChild(
|
973 |
+
elt("div", lineNumberFor(cm.options, lineN),
|
974 |
+
"CodeMirror-linenumber CodeMirror-gutter-elt",
|
975 |
+
"left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
|
976 |
+
+ cm.display.lineNumInnerWidth + "px"));
|
977 |
+
if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
|
978 |
+
var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
|
979 |
+
if (found)
|
980 |
+
gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
|
981 |
+
dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
|
982 |
+
}
|
983 |
+
}
|
984 |
+
}
|
985 |
+
|
986 |
+
function updateLineWidgets(cm, lineView, dims) {
|
987 |
+
if (lineView.alignable) lineView.alignable = null;
|
988 |
+
for (var node = lineView.node.firstChild, next; node; node = next) {
|
989 |
+
var next = node.nextSibling;
|
990 |
+
if (node.className == "CodeMirror-linewidget")
|
991 |
+
lineView.node.removeChild(node);
|
992 |
+
}
|
993 |
+
insertLineWidgets(cm, lineView, dims);
|
994 |
+
}
|
995 |
+
|
996 |
+
// Build a line's DOM representation from scratch
|
997 |
+
function buildLineElement(cm, lineView, lineN, dims) {
|
998 |
+
var built = getLineContent(cm, lineView);
|
999 |
+
lineView.text = lineView.node = built.pre;
|
1000 |
+
if (built.bgClass) lineView.bgClass = built.bgClass;
|
1001 |
+
if (built.textClass) lineView.textClass = built.textClass;
|
1002 |
+
|
1003 |
+
updateLineClasses(lineView);
|
1004 |
+
updateLineGutter(cm, lineView, lineN, dims);
|
1005 |
+
insertLineWidgets(cm, lineView, dims);
|
1006 |
+
return lineView.node;
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
// A lineView may contain multiple logical lines (when merged by
|
1010 |
+
// collapsed spans). The widgets for all of them need to be drawn.
|
1011 |
+
function insertLineWidgets(cm, lineView, dims) {
|
1012 |
+
insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
|
1013 |
+
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
|
1014 |
+
insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
|
1018 |
+
if (!line.widgets) return;
|
1019 |
+
var wrap = ensureLineWrapped(lineView);
|
1020 |
+
for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
|
1021 |
+
var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
|
1022 |
+
if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
|
1023 |
+
positionLineWidget(widget, node, lineView, dims);
|
1024 |
+
cm.display.input.setUneditable(node);
|
1025 |
+
if (allowAbove && widget.above)
|
1026 |
+
wrap.insertBefore(node, lineView.gutter || lineView.text);
|
1027 |
+
else
|
1028 |
+
wrap.appendChild(node);
|
1029 |
+
signalLater(widget, "redraw");
|
1030 |
+
}
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
function positionLineWidget(widget, node, lineView, dims) {
|
1034 |
+
if (widget.noHScroll) {
|
1035 |
+
(lineView.alignable || (lineView.alignable = [])).push(node);
|
1036 |
+
var width = dims.wrapperWidth;
|
1037 |
+
node.style.left = dims.fixedPos + "px";
|
1038 |
+
if (!widget.coverGutter) {
|
1039 |
+
width -= dims.gutterTotalWidth;
|
1040 |
+
node.style.paddingLeft = dims.gutterTotalWidth + "px";
|
1041 |
+
}
|
1042 |
+
node.style.width = width + "px";
|
1043 |
+
}
|
1044 |
+
if (widget.coverGutter) {
|
1045 |
+
node.style.zIndex = 5;
|
1046 |
+
node.style.position = "relative";
|
1047 |
+
if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
|
1048 |
+
}
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
// POSITION OBJECT
|
1052 |
+
|
1053 |
+
// A Pos instance represents a position within the text.
|
1054 |
+
var Pos = CodeMirror.Pos = function(line, ch) {
|
1055 |
+
if (!(this instanceof Pos)) return new Pos(line, ch);
|
1056 |
+
this.line = line; this.ch = ch;
|
1057 |
+
};
|
1058 |
+
|
1059 |
+
// Compare two positions, return 0 if they are the same, a negative
|
1060 |
+
// number when a is less, and a positive number otherwise.
|
1061 |
+
var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
|
1062 |
+
|
1063 |
+
function copyPos(x) {return Pos(x.line, x.ch);}
|
1064 |
+
function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
|
1065 |
+
function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
|
1066 |
+
|
1067 |
+
// INPUT HANDLING
|
1068 |
+
|
1069 |
+
function ensureFocus(cm) {
|
1070 |
+
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
|
1071 |
+
}
|
1072 |
+
|
1073 |
+
function isReadOnly(cm) {
|
1074 |
+
return cm.options.readOnly || cm.doc.cantEdit;
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
// This will be set to an array of strings when copying, so that,
|
1078 |
+
// when pasting, we know what kind of selections the copied text
|
1079 |
+
// was made out of.
|
1080 |
+
var lastCopied = null;
|
1081 |
+
|
1082 |
+
function applyTextInput(cm, inserted, deleted, sel, origin) {
|
1083 |
+
var doc = cm.doc;
|
1084 |
+
cm.display.shift = false;
|
1085 |
+
if (!sel) sel = doc.sel;
|
1086 |
+
|
1087 |
+
var textLines = splitLines(inserted), multiPaste = null;
|
1088 |
+
// When pasing N lines into N selections, insert one line per selection
|
1089 |
+
if (cm.state.pasteIncoming && sel.ranges.length > 1) {
|
1090 |
+
if (lastCopied && lastCopied.join("\n") == inserted)
|
1091 |
+
multiPaste = sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines);
|
1092 |
+
else if (textLines.length == sel.ranges.length)
|
1093 |
+
multiPaste = map(textLines, function(l) { return [l]; });
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
// Normal behavior is to insert the new text into every selection
|
1097 |
+
for (var i = sel.ranges.length - 1; i >= 0; i--) {
|
1098 |
+
var range = sel.ranges[i];
|
1099 |
+
var from = range.from(), to = range.to();
|
1100 |
+
if (range.empty()) {
|
1101 |
+
if (deleted && deleted > 0) // Handle deletion
|
1102 |
+
from = Pos(from.line, from.ch - deleted);
|
1103 |
+
else if (cm.state.overwrite && !cm.state.pasteIncoming) // Handle overwrite
|
1104 |
+
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
|
1105 |
+
}
|
1106 |
+
var updateInput = cm.curOp.updateInput;
|
1107 |
+
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
|
1108 |
+
origin: origin || (cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
|
1109 |
+
makeChange(cm.doc, changeEvent);
|
1110 |
+
signalLater(cm, "inputRead", cm, changeEvent);
|
1111 |
+
// When an 'electric' character is inserted, immediately trigger a reindent
|
1112 |
+
if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
|
1113 |
+
cm.options.smartIndent && range.head.ch < 100 &&
|
1114 |
+
(!i || sel.ranges[i - 1].head.line != range.head.line)) {
|
1115 |
+
var mode = cm.getModeAt(range.head);
|
1116 |
+
var end = changeEnd(changeEvent);
|
1117 |
+
var indented = false;
|
1118 |
+
if (mode.electricChars) {
|
1119 |
+
for (var j = 0; j < mode.electricChars.length; j++)
|
1120 |
+
if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
|
1121 |
+
indented = indentLine(cm, end.line, "smart");
|
1122 |
+
break;
|
1123 |
+
}
|
1124 |
+
} else if (mode.electricInput) {
|
1125 |
+
if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch)))
|
1126 |
+
indented = indentLine(cm, end.line, "smart");
|
1127 |
+
}
|
1128 |
+
if (indented) signalLater(cm, "electricInput", cm, end.line);
|
1129 |
+
}
|
1130 |
+
}
|
1131 |
+
ensureCursorVisible(cm);
|
1132 |
+
cm.curOp.updateInput = updateInput;
|
1133 |
+
cm.curOp.typing = true;
|
1134 |
+
cm.state.pasteIncoming = cm.state.cutIncoming = false;
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
function copyableRanges(cm) {
|
1138 |
+
var text = [], ranges = [];
|
1139 |
+
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
|
1140 |
+
var line = cm.doc.sel.ranges[i].head.line;
|
1141 |
+
var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
|
1142 |
+
ranges.push(lineRange);
|
1143 |
+
text.push(cm.getRange(lineRange.anchor, lineRange.head));
|
1144 |
+
}
|
1145 |
+
return {text: text, ranges: ranges};
|
1146 |
+
}
|
1147 |
+
|
1148 |
+
function disableBrowserMagic(field) {
|
1149 |
+
field.setAttribute("autocorrect", "off");
|
1150 |
+
field.setAttribute("autocapitalize", "off");
|
1151 |
+
field.setAttribute("spellcheck", "false");
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
// TEXTAREA INPUT STYLE
|
1155 |
+
|
1156 |
+
function TextareaInput(cm) {
|
1157 |
+
this.cm = cm;
|
1158 |
+
// See input.poll and input.reset
|
1159 |
+
this.prevInput = "";
|
1160 |
+
|
1161 |
+
// Flag that indicates whether we expect input to appear real soon
|
1162 |
+
// now (after some event like 'keypress' or 'input') and are
|
1163 |
+
// polling intensively.
|
1164 |
+
this.pollingFast = false;
|
1165 |
+
// Self-resetting timeout for the poller
|
1166 |
+
this.polling = new Delayed();
|
1167 |
+
// Tracks when input.reset has punted to just putting a short
|
1168 |
+
// string into the textarea instead of the full selection.
|
1169 |
+
this.inaccurateSelection = false;
|
1170 |
+
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
|
1171 |
+
this.hasSelection = false;
|
1172 |
+
this.composing = null;
|
1173 |
+
};
|
1174 |
+
|
1175 |
+
function hiddenTextarea() {
|
1176 |
+
var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
|
1177 |
+
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
|
1178 |
+
// The textarea is kept positioned near the cursor to prevent the
|
1179 |
+
// fact that it'll be scrolled into view on input from scrolling
|
1180 |
+
// our fake cursor out of view. On webkit, when wrap=off, paste is
|
1181 |
+
// very slow. So make the area wide instead.
|
1182 |
+
if (webkit) te.style.width = "1000px";
|
1183 |
+
else te.setAttribute("wrap", "off");
|
1184 |
+
// If border: 0; -- iOS fails to open keyboard (issue #1287)
|
1185 |
+
if (ios) te.style.border = "1px solid black";
|
1186 |
+
disableBrowserMagic(te);
|
1187 |
+
return div;
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
TextareaInput.prototype = copyObj({
|
1191 |
+
init: function(display) {
|
1192 |
+
var input = this, cm = this.cm;
|
1193 |
+
|
1194 |
+
// Wraps and hides input textarea
|
1195 |
+
var div = this.wrapper = hiddenTextarea();
|
1196 |
+
// The semihidden textarea that is focused when the editor is
|
1197 |
+
// focused, and receives input.
|
1198 |
+
var te = this.textarea = div.firstChild;
|
1199 |
+
display.wrapper.insertBefore(div, display.wrapper.firstChild);
|
1200 |
+
|
1201 |
+
// Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
|
1202 |
+
if (ios) te.style.width = "0px";
|
1203 |
+
|
1204 |
+
on(te, "input", function() {
|
1205 |
+
if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null;
|
1206 |
+
input.poll();
|
1207 |
+
});
|
1208 |
+
|
1209 |
+
on(te, "paste", function() {
|
1210 |
+
// Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206
|
1211 |
+
// Add a char to the end of textarea before paste occur so that
|
1212 |
+
// selection doesn't span to the end of textarea.
|
1213 |
+
if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
|
1214 |
+
var start = te.selectionStart, end = te.selectionEnd;
|
1215 |
+
te.value += "$";
|
1216 |
+
// The selection end needs to be set before the start, otherwise there
|
1217 |
+
// can be an intermediate non-empty selection between the two, which
|
1218 |
+
// can override the middle-click paste buffer on linux and cause the
|
1219 |
+
// wrong thing to get pasted.
|
1220 |
+
te.selectionEnd = end;
|
1221 |
+
te.selectionStart = start;
|
1222 |
+
cm.state.fakedLastChar = true;
|
1223 |
+
}
|
1224 |
+
cm.state.pasteIncoming = true;
|
1225 |
+
input.fastPoll();
|
1226 |
+
});
|
1227 |
+
|
1228 |
+
function prepareCopyCut(e) {
|
1229 |
+
if (cm.somethingSelected()) {
|
1230 |
+
lastCopied = cm.getSelections();
|
1231 |
+
if (input.inaccurateSelection) {
|
1232 |
+
input.prevInput = "";
|
1233 |
+
input.inaccurateSelection = false;
|
1234 |
+
te.value = lastCopied.join("\n");
|
1235 |
+
selectInput(te);
|
1236 |
+
}
|
1237 |
+
} else if (!cm.options.lineWiseCopyCut) {
|
1238 |
+
return;
|
1239 |
+
} else {
|
1240 |
+
var ranges = copyableRanges(cm);
|
1241 |
+
lastCopied = ranges.text;
|
1242 |
+
if (e.type == "cut") {
|
1243 |
+
cm.setSelections(ranges.ranges, null, sel_dontScroll);
|
1244 |
+
} else {
|
1245 |
+
input.prevInput = "";
|
1246 |
+
te.value = ranges.text.join("\n");
|
1247 |
+
selectInput(te);
|
1248 |
+
}
|
1249 |
+
}
|
1250 |
+
if (e.type == "cut") cm.state.cutIncoming = true;
|
1251 |
+
}
|
1252 |
+
on(te, "cut", prepareCopyCut);
|
1253 |
+
on(te, "copy", prepareCopyCut);
|
1254 |
+
|
1255 |
+
on(display.scroller, "paste", function(e) {
|
1256 |
+
if (eventInWidget(display, e)) return;
|
1257 |
+
cm.state.pasteIncoming = true;
|
1258 |
+
input.focus();
|
1259 |
+
});
|
1260 |
+
|
1261 |
+
// Prevent normal selection in the editor (we handle our own)
|
1262 |
+
on(display.lineSpace, "selectstart", function(e) {
|
1263 |
+
if (!eventInWidget(display, e)) e_preventDefault(e);
|
1264 |
+
});
|
1265 |
+
|
1266 |
+
on(te, "compositionstart", function() {
|
1267 |
+
var start = cm.getCursor("from");
|
1268 |
+
input.composing = {
|
1269 |
+
start: start,
|
1270 |
+
range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
|
1271 |
+
};
|
1272 |
+
});
|
1273 |
+
on(te, "compositionend", function() {
|
1274 |
+
if (input.composing) {
|
1275 |
+
input.poll();
|
1276 |
+
input.composing.range.clear();
|
1277 |
+
input.composing = null;
|
1278 |
+
}
|
1279 |
+
});
|
1280 |
+
},
|
1281 |
+
|
1282 |
+
prepareSelection: function() {
|
1283 |
+
// Redraw the selection and/or cursor
|
1284 |
+
var cm = this.cm, display = cm.display, doc = cm.doc;
|
1285 |
+
var result = prepareSelection(cm);
|
1286 |
+
|
1287 |
+
// Move the hidden textarea near the cursor to prevent scrolling artifacts
|
1288 |
+
if (cm.options.moveInputWithCursor) {
|
1289 |
+
var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
|
1290 |
+
var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
|
1291 |
+
result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
|
1292 |
+
headPos.top + lineOff.top - wrapOff.top));
|
1293 |
+
result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
|
1294 |
+
headPos.left + lineOff.left - wrapOff.left));
|
1295 |
+
}
|
1296 |
+
|
1297 |
+
return result;
|
1298 |
+
},
|
1299 |
+
|
1300 |
+
showSelection: function(drawn) {
|
1301 |
+
var cm = this.cm, display = cm.display;
|
1302 |
+
removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
|
1303 |
+
removeChildrenAndAdd(display.selectionDiv, drawn.selection);
|
1304 |
+
if (drawn.teTop != null) {
|
1305 |
+
this.wrapper.style.top = drawn.teTop + "px";
|
1306 |
+
this.wrapper.style.left = drawn.teLeft + "px";
|
1307 |
+
}
|
1308 |
+
},
|
1309 |
+
|
1310 |
+
// Reset the input to correspond to the selection (or to be empty,
|
1311 |
+
// when not typing and nothing is selected)
|
1312 |
+
reset: function(typing) {
|
1313 |
+
if (this.contextMenuPending) return;
|
1314 |
+
var minimal, selected, cm = this.cm, doc = cm.doc;
|
1315 |
+
if (cm.somethingSelected()) {
|
1316 |
+
this.prevInput = "";
|
1317 |
+
var range = doc.sel.primary();
|
1318 |
+
minimal = hasCopyEvent &&
|
1319 |
+
(range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
|
1320 |
+
var content = minimal ? "-" : selected || cm.getSelection();
|
1321 |
+
this.textarea.value = content;
|
1322 |
+
if (cm.state.focused) selectInput(this.textarea);
|
1323 |
+
if (ie && ie_version >= 9) this.hasSelection = content;
|
1324 |
+
} else if (!typing) {
|
1325 |
+
this.prevInput = this.textarea.value = "";
|
1326 |
+
if (ie && ie_version >= 9) this.hasSelection = null;
|
1327 |
+
}
|
1328 |
+
this.inaccurateSelection = minimal;
|
1329 |
+
},
|
1330 |
+
|
1331 |
+
getField: function() { return this.textarea; },
|
1332 |
+
|
1333 |
+
supportsTouch: function() { return false; },
|
1334 |
+
|
1335 |
+
focus: function() {
|
1336 |
+
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
|
1337 |
+
try { this.textarea.focus(); }
|
1338 |
+
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
|
1339 |
+
}
|
1340 |
+
},
|
1341 |
+
|
1342 |
+
blur: function() { this.textarea.blur(); },
|
1343 |
+
|
1344 |
+
resetPosition: function() {
|
1345 |
+
this.wrapper.style.top = this.wrapper.style.left = 0;
|
1346 |
+
},
|
1347 |
+
|
1348 |
+
receivedFocus: function() { this.slowPoll(); },
|
1349 |
+
|
1350 |
+
// Poll for input changes, using the normal rate of polling. This
|
1351 |
+
// runs as long as the editor is focused.
|
1352 |
+
slowPoll: function() {
|
1353 |
+
var input = this;
|
1354 |
+
if (input.pollingFast) return;
|
1355 |
+
input.polling.set(this.cm.options.pollInterval, function() {
|
1356 |
+
input.poll();
|
1357 |
+
if (input.cm.state.focused) input.slowPoll();
|
1358 |
+
});
|
1359 |
+
},
|
1360 |
+
|
1361 |
+
// When an event has just come in that is likely to add or change
|
1362 |
+
// something in the input textarea, we poll faster, to ensure that
|
1363 |
+
// the change appears on the screen quickly.
|
1364 |
+
fastPoll: function() {
|
1365 |
+
var missed = false, input = this;
|
1366 |
+
input.pollingFast = true;
|
1367 |
+
function p() {
|
1368 |
+
var changed = input.poll();
|
1369 |
+
if (!changed && !missed) {missed = true; input.polling.set(60, p);}
|
1370 |
+
else {input.pollingFast = false; input.slowPoll();}
|
1371 |
+
}
|
1372 |
+
input.polling.set(20, p);
|
1373 |
+
},
|
1374 |
+
|
1375 |
+
// Read input from the textarea, and update the document to match.
|
1376 |
+
// When something is selected, it is present in the textarea, and
|
1377 |
+
// selected (unless it is huge, in which case a placeholder is
|
1378 |
+
// used). When nothing is selected, the cursor sits after previously
|
1379 |
+
// seen text (can be empty), which is stored in prevInput (we must
|
1380 |
+
// not reset the textarea when typing, because that breaks IME).
|
1381 |
+
poll: function() {
|
1382 |
+
var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
|
1383 |
+
// Since this is called a *lot*, try to bail out as cheaply as
|
1384 |
+
// possible when it is clear that nothing happened. hasSelection
|
1385 |
+
// will be the case when there is a lot of text in the textarea,
|
1386 |
+
// in which case reading its value would be expensive.
|
1387 |
+
if (!cm.state.focused || (hasSelection(input) && !prevInput) ||
|
1388 |
+
isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
|
1389 |
+
return false;
|
1390 |
+
// See paste handler for more on the fakedLastChar kludge
|
1391 |
+
if (cm.state.pasteIncoming && cm.state.fakedLastChar) {
|
1392 |
+
input.value = input.value.substring(0, input.value.length - 1);
|
1393 |
+
cm.state.fakedLastChar = false;
|
1394 |
+
}
|
1395 |
+
var text = input.value;
|
1396 |
+
// If nothing changed, bail.
|
1397 |
+
if (text == prevInput && !cm.somethingSelected()) return false;
|
1398 |
+
// Work around nonsensical selection resetting in IE9/10, and
|
1399 |
+
// inexplicable appearance of private area unicode characters on
|
1400 |
+
// some key combos in Mac (#2689).
|
1401 |
+
if (ie && ie_version >= 9 && this.hasSelection === text ||
|
1402 |
+
mac && /[\uf700-\uf7ff]/.test(text)) {
|
1403 |
+
cm.display.input.reset();
|
1404 |
+
return false;
|
1405 |
+
}
|
1406 |
+
|
1407 |
+
if (cm.doc.sel == cm.display.selForContextMenu) {
|
1408 |
+
var first = text.charCodeAt(0);
|
1409 |
+
if (first == 0x200b && !prevInput) prevInput = "\u200b";
|
1410 |
+
if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); }
|
1411 |
+
}
|
1412 |
+
// Find the part of the input that is actually new
|
1413 |
+
var same = 0, l = Math.min(prevInput.length, text.length);
|
1414 |
+
while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
|
1415 |
+
|
1416 |
+
var self = this;
|
1417 |
+
runInOp(cm, function() {
|
1418 |
+
applyTextInput(cm, text.slice(same), prevInput.length - same,
|
1419 |
+
null, self.composing ? "*compose" : null);
|
1420 |
+
|
1421 |
+
// Don't leave long text in the textarea, since it makes further polling slow
|
1422 |
+
if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = "";
|
1423 |
+
else self.prevInput = text;
|
1424 |
+
|
1425 |
+
if (self.composing) {
|
1426 |
+
self.composing.range.clear();
|
1427 |
+
self.composing.range = cm.markText(self.composing.start, cm.getCursor("to"),
|
1428 |
+
{className: "CodeMirror-composing"});
|
1429 |
+
}
|
1430 |
+
});
|
1431 |
+
return true;
|
1432 |
+
},
|
1433 |
+
|
1434 |
+
ensurePolled: function() {
|
1435 |
+
if (this.pollingFast && this.poll()) this.pollingFast = false;
|
1436 |
+
},
|
1437 |
+
|
1438 |
+
onKeyPress: function() {
|
1439 |
+
if (ie && ie_version >= 9) this.hasSelection = null;
|
1440 |
+
this.fastPoll();
|
1441 |
+
},
|
1442 |
+
|
1443 |
+
onContextMenu: function(e) {
|
1444 |
+
var input = this, cm = input.cm, display = cm.display, te = input.textarea;
|
1445 |
+
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
|
1446 |
+
if (!pos || presto) return; // Opera is difficult.
|
1447 |
+
|
1448 |
+
// Reset the current text selection only if the click is done outside of the selection
|
1449 |
+
// and 'resetSelectionOnContextMenu' option is true.
|
1450 |
+
var reset = cm.options.resetSelectionOnContextMenu;
|
1451 |
+
if (reset && cm.doc.sel.contains(pos) == -1)
|
1452 |
+
operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
|
1453 |
+
|
1454 |
+
var oldCSS = te.style.cssText;
|
1455 |
+
input.wrapper.style.position = "absolute";
|
1456 |
+
te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
|
1457 |
+
"px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
|
1458 |
+
(ie ? "rgba(255, 255, 255, .05)" : "transparent") +
|
1459 |
+
"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
|
1460 |
+
if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
|
1461 |
+
display.input.focus();
|
1462 |
+
if (webkit) window.scrollTo(null, oldScrollY);
|
1463 |
+
display.input.reset();
|
1464 |
+
// Adds "Select all" to context menu in FF
|
1465 |
+
if (!cm.somethingSelected()) te.value = input.prevInput = " ";
|
1466 |
+
input.contextMenuPending = true;
|
1467 |
+
display.selForContextMenu = cm.doc.sel;
|
1468 |
+
clearTimeout(display.detectingSelectAll);
|
1469 |
+
|
1470 |
+
// Select-all will be greyed out if there's nothing to select, so
|
1471 |
+
// this adds a zero-width space so that we can later check whether
|
1472 |
+
// it got selected.
|
1473 |
+
function prepareSelectAllHack() {
|
1474 |
+
if (te.selectionStart != null) {
|
1475 |
+
var selected = cm.somethingSelected();
|
1476 |
+
var extval = "\u200b" + (selected ? te.value : "");
|
1477 |
+
te.value = "\u21da"; // Used to catch context-menu undo
|
1478 |
+
te.value = extval;
|
1479 |
+
input.prevInput = selected ? "" : "\u200b";
|
1480 |
+
te.selectionStart = 1; te.selectionEnd = extval.length;
|
1481 |
+
// Re-set this, in case some other handler touched the
|
1482 |
+
// selection in the meantime.
|
1483 |
+
display.selForContextMenu = cm.doc.sel;
|
1484 |
+
}
|
1485 |
+
}
|
1486 |
+
function rehide() {
|
1487 |
+
input.contextMenuPending = false;
|
1488 |
+
input.wrapper.style.position = "relative";
|
1489 |
+
te.style.cssText = oldCSS;
|
1490 |
+
if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
|
1491 |
+
|
1492 |
+
// Try to detect the user choosing select-all
|
1493 |
+
if (te.selectionStart != null) {
|
1494 |
+
if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
|
1495 |
+
var i = 0, poll = function() {
|
1496 |
+
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
|
1497 |
+
te.selectionEnd > 0 && input.prevInput == "\u200b")
|
1498 |
+
operation(cm, commands.selectAll)(cm);
|
1499 |
+
else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
|
1500 |
+
else display.input.reset();
|
1501 |
+
};
|
1502 |
+
display.detectingSelectAll = setTimeout(poll, 200);
|
1503 |
+
}
|
1504 |
+
}
|
1505 |
+
|
1506 |
+
if (ie && ie_version >= 9) prepareSelectAllHack();
|
1507 |
+
if (captureRightClick) {
|
1508 |
+
e_stop(e);
|
1509 |
+
var mouseup = function() {
|
1510 |
+
off(window, "mouseup", mouseup);
|
1511 |
+
setTimeout(rehide, 20);
|
1512 |
+
};
|
1513 |
+
on(window, "mouseup", mouseup);
|
1514 |
+
} else {
|
1515 |
+
setTimeout(rehide, 50);
|
1516 |
+
}
|
1517 |
+
},
|
1518 |
+
|
1519 |
+
setUneditable: nothing,
|
1520 |
+
|
1521 |
+
needsContentAttribute: false
|
1522 |
+
}, TextareaInput.prototype);
|
1523 |
+
|
1524 |
+
// CONTENTEDITABLE INPUT STYLE
|
1525 |
+
|
1526 |
+
function ContentEditableInput(cm) {
|
1527 |
+
this.cm = cm;
|
1528 |
+
this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
|
1529 |
+
this.polling = new Delayed();
|
1530 |
+
this.gracePeriod = false;
|
1531 |
+
}
|
1532 |
+
|
1533 |
+
ContentEditableInput.prototype = copyObj({
|
1534 |
+
init: function(display) {
|
1535 |
+
var input = this, cm = input.cm;
|
1536 |
+
var div = input.div = display.lineDiv;
|
1537 |
+
div.contentEditable = "true";
|
1538 |
+
disableBrowserMagic(div);
|
1539 |
+
|
1540 |
+
on(div, "paste", function(e) {
|
1541 |
+
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
1542 |
+
if (pasted) {
|
1543 |
+
e.preventDefault();
|
1544 |
+
cm.replaceSelection(pasted, null, "paste");
|
1545 |
+
}
|
1546 |
+
});
|
1547 |
+
|
1548 |
+
on(div, "compositionstart", function(e) {
|
1549 |
+
var data = e.data;
|
1550 |
+
input.composing = {sel: cm.doc.sel, data: data, startData: data};
|
1551 |
+
if (!data) return;
|
1552 |
+
var prim = cm.doc.sel.primary();
|
1553 |
+
var line = cm.getLine(prim.head.line);
|
1554 |
+
var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length));
|
1555 |
+
if (found > -1 && found <= prim.head.ch)
|
1556 |
+
input.composing.sel = simpleSelection(Pos(prim.head.line, found),
|
1557 |
+
Pos(prim.head.line, found + data.length));
|
1558 |
+
});
|
1559 |
+
on(div, "compositionupdate", function(e) {
|
1560 |
+
input.composing.data = e.data;
|
1561 |
+
});
|
1562 |
+
on(div, "compositionend", function(e) {
|
1563 |
+
var ours = input.composing;
|
1564 |
+
if (!ours) return;
|
1565 |
+
if (e.data != ours.startData && !/\u200b/.test(e.data))
|
1566 |
+
ours.data = e.data;
|
1567 |
+
// Need a small delay to prevent other code (input event,
|
1568 |
+
// selection polling) from doing damage when fired right after
|
1569 |
+
// compositionend.
|
1570 |
+
setTimeout(function() {
|
1571 |
+
if (!ours.handled)
|
1572 |
+
input.applyComposition(ours);
|
1573 |
+
if (input.composing == ours)
|
1574 |
+
input.composing = null;
|
1575 |
+
}, 50);
|
1576 |
+
});
|
1577 |
+
|
1578 |
+
on(div, "touchstart", function() {
|
1579 |
+
input.forceCompositionEnd();
|
1580 |
+
});
|
1581 |
+
|
1582 |
+
on(div, "input", function() {
|
1583 |
+
if (input.composing) return;
|
1584 |
+
if (!input.pollContent())
|
1585 |
+
runInOp(input.cm, function() {regChange(cm);});
|
1586 |
+
});
|
1587 |
+
|
1588 |
+
function onCopyCut(e) {
|
1589 |
+
if (cm.somethingSelected()) {
|
1590 |
+
lastCopied = cm.getSelections();
|
1591 |
+
if (e.type == "cut") cm.replaceSelection("", null, "cut");
|
1592 |
+
} else if (!cm.options.lineWiseCopyCut) {
|
1593 |
+
return;
|
1594 |
+
} else {
|
1595 |
+
var ranges = copyableRanges(cm);
|
1596 |
+
lastCopied = ranges.text;
|
1597 |
+
if (e.type == "cut") {
|
1598 |
+
cm.operation(function() {
|
1599 |
+
cm.setSelections(ranges.ranges, 0, sel_dontScroll);
|
1600 |
+
cm.replaceSelection("", null, "cut");
|
1601 |
+
});
|
1602 |
+
}
|
1603 |
+
}
|
1604 |
+
// iOS exposes the clipboard API, but seems to discard content inserted into it
|
1605 |
+
if (e.clipboardData && !ios) {
|
1606 |
+
e.preventDefault();
|
1607 |
+
e.clipboardData.clearData();
|
1608 |
+
e.clipboardData.setData("text/plain", lastCopied.join("\n"));
|
1609 |
+
} else {
|
1610 |
+
// Old-fashioned briefly-focus-a-textarea hack
|
1611 |
+
var kludge = hiddenTextarea(), te = kludge.firstChild;
|
1612 |
+
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
1613 |
+
te.value = lastCopied.join("\n");
|
1614 |
+
var hadFocus = document.activeElement;
|
1615 |
+
selectInput(te);
|
1616 |
+
setTimeout(function() {
|
1617 |
+
cm.display.lineSpace.removeChild(kludge);
|
1618 |
+
hadFocus.focus();
|
1619 |
+
}, 50);
|
1620 |
+
}
|
1621 |
+
}
|
1622 |
+
on(div, "copy", onCopyCut);
|
1623 |
+
on(div, "cut", onCopyCut);
|
1624 |
+
},
|
1625 |
+
|
1626 |
+
prepareSelection: function() {
|
1627 |
+
var result = prepareSelection(this.cm, false);
|
1628 |
+
result.focus = this.cm.state.focused;
|
1629 |
+
return result;
|
1630 |
+
},
|
1631 |
+
|
1632 |
+
showSelection: function(info) {
|
1633 |
+
if (!info || !this.cm.display.view.length) return;
|
1634 |
+
if (info.focus) this.showPrimarySelection();
|
1635 |
+
this.showMultipleSelections(info);
|
1636 |
+
},
|
1637 |
+
|
1638 |
+
showPrimarySelection: function() {
|
1639 |
+
var sel = window.getSelection(), prim = this.cm.doc.sel.primary();
|
1640 |
+
var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset);
|
1641 |
+
var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset);
|
1642 |
+
if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
|
1643 |
+
cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
|
1644 |
+
cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
|
1645 |
+
return;
|
1646 |
+
|
1647 |
+
var start = posToDOM(this.cm, prim.from());
|
1648 |
+
var end = posToDOM(this.cm, prim.to());
|
1649 |
+
if (!start && !end) return;
|
1650 |
+
|
1651 |
+
var view = this.cm.display.view;
|
1652 |
+
var old = sel.rangeCount && sel.getRangeAt(0);
|
1653 |
+
if (!start) {
|
1654 |
+
start = {node: view[0].measure.map[2], offset: 0};
|
1655 |
+
} else if (!end) { // FIXME dangerously hacky
|
1656 |
+
var measure = view[view.length - 1].measure;
|
1657 |
+
var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
|
1658 |
+
end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]};
|
1659 |
+
}
|
1660 |
+
|
1661 |
+
try { var rng = range(start.node, start.offset, end.offset, end.node); }
|
1662 |
+
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
1663 |
+
if (rng) {
|
1664 |
+
sel.removeAllRanges();
|
1665 |
+
sel.addRange(rng);
|
1666 |
+
if (old && sel.anchorNode == null) sel.addRange(old);
|
1667 |
+
else if (gecko) this.startGracePeriod();
|
1668 |
+
}
|
1669 |
+
this.rememberSelection();
|
1670 |
+
},
|
1671 |
+
|
1672 |
+
startGracePeriod: function() {
|
1673 |
+
var input = this;
|
1674 |
+
clearTimeout(this.gracePeriod);
|
1675 |
+
this.gracePeriod = setTimeout(function() {
|
1676 |
+
input.gracePeriod = false;
|
1677 |
+
if (input.selectionChanged())
|
1678 |
+
input.cm.operation(function() { input.cm.curOp.selectionChanged = true; });
|
1679 |
+
}, 20);
|
1680 |
+
},
|
1681 |
+
|
1682 |
+
showMultipleSelections: function(info) {
|
1683 |
+
removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
|
1684 |
+
removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
|
1685 |
+
},
|
1686 |
+
|
1687 |
+
rememberSelection: function() {
|
1688 |
+
var sel = window.getSelection();
|
1689 |
+
this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
|
1690 |
+
this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
|
1691 |
+
},
|
1692 |
+
|
1693 |
+
selectionInEditor: function() {
|
1694 |
+
var sel = window.getSelection();
|
1695 |
+
if (!sel.rangeCount) return false;
|
1696 |
+
var node = sel.getRangeAt(0).commonAncestorContainer;
|
1697 |
+
return contains(this.div, node);
|
1698 |
+
},
|
1699 |
+
|
1700 |
+
focus: function() {
|
1701 |
+
if (this.cm.options.readOnly != "nocursor") this.div.focus();
|
1702 |
+
},
|
1703 |
+
blur: function() { this.div.blur(); },
|
1704 |
+
getField: function() { return this.div; },
|
1705 |
+
|
1706 |
+
supportsTouch: function() { return true; },
|
1707 |
+
|
1708 |
+
receivedFocus: function() {
|
1709 |
+
var input = this;
|
1710 |
+
if (this.selectionInEditor())
|
1711 |
+
this.pollSelection();
|
1712 |
+
else
|
1713 |
+
runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; });
|
1714 |
+
|
1715 |
+
function poll() {
|
1716 |
+
if (input.cm.state.focused) {
|
1717 |
+
input.pollSelection();
|
1718 |
+
input.polling.set(input.cm.options.pollInterval, poll);
|
1719 |
+
}
|
1720 |
+
}
|
1721 |
+
this.polling.set(this.cm.options.pollInterval, poll);
|
1722 |
+
},
|
1723 |
+
|
1724 |
+
selectionChanged: function() {
|
1725 |
+
var sel = window.getSelection();
|
1726 |
+
return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
|
1727 |
+
sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset;
|
1728 |
+
},
|
1729 |
+
|
1730 |
+
pollSelection: function() {
|
1731 |
+
if (!this.composing && !this.gracePeriod && this.selectionChanged()) {
|
1732 |
+
var sel = window.getSelection(), cm = this.cm;
|
1733 |
+
this.rememberSelection();
|
1734 |
+
var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
|
1735 |
+
var head = domToPos(cm, sel.focusNode, sel.focusOffset);
|
1736 |
+
if (anchor && head) runInOp(cm, function() {
|
1737 |
+
setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
|
1738 |
+
if (anchor.bad || head.bad) cm.curOp.selectionChanged = true;
|
1739 |
+
});
|
1740 |
+
}
|
1741 |
+
},
|
1742 |
+
|
1743 |
+
pollContent: function() {
|
1744 |
+
var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
|
1745 |
+
var from = sel.from(), to = sel.to();
|
1746 |
+
if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false;
|
1747 |
+
|
1748 |
+
var fromIndex;
|
1749 |
+
if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
|
1750 |
+
var fromLine = lineNo(display.view[0].line);
|
1751 |
+
var fromNode = display.view[0].node;
|
1752 |
+
} else {
|
1753 |
+
var fromLine = lineNo(display.view[fromIndex].line);
|
1754 |
+
var fromNode = display.view[fromIndex - 1].node.nextSibling;
|
1755 |
+
}
|
1756 |
+
var toIndex = findViewIndex(cm, to.line);
|
1757 |
+
if (toIndex == display.view.length - 1) {
|
1758 |
+
var toLine = display.viewTo - 1;
|
1759 |
+
var toNode = display.view[toIndex].node;
|
1760 |
+
} else {
|
1761 |
+
var toLine = lineNo(display.view[toIndex + 1].line) - 1;
|
1762 |
+
var toNode = display.view[toIndex + 1].node.previousSibling;
|
1763 |
+
}
|
1764 |
+
|
1765 |
+
var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
|
1766 |
+
var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
|
1767 |
+
while (newText.length > 1 && oldText.length > 1) {
|
1768 |
+
if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
|
1769 |
+
else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
|
1770 |
+
else break;
|
1771 |
+
}
|
1772 |
+
|
1773 |
+
var cutFront = 0, cutEnd = 0;
|
1774 |
+
var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
|
1775 |
+
while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
|
1776 |
+
++cutFront;
|
1777 |
+
var newBot = lst(newText), oldBot = lst(oldText);
|
1778 |
+
var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
|
1779 |
+
oldBot.length - (oldText.length == 1 ? cutFront : 0));
|
1780 |
+
while (cutEnd < maxCutEnd &&
|
1781 |
+
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
|
1782 |
+
++cutEnd;
|
1783 |
+
|
1784 |
+
newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd);
|
1785 |
+
newText[0] = newText[0].slice(cutFront);
|
1786 |
+
|
1787 |
+
var chFrom = Pos(fromLine, cutFront);
|
1788 |
+
var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
|
1789 |
+
if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
|
1790 |
+
replaceRange(cm.doc, newText, chFrom, chTo, "+input");
|
1791 |
+
return true;
|
1792 |
+
}
|
1793 |
+
},
|
1794 |
+
|
1795 |
+
ensurePolled: function() {
|
1796 |
+
this.forceCompositionEnd();
|
1797 |
+
},
|
1798 |
+
reset: function() {
|
1799 |
+
this.forceCompositionEnd();
|
1800 |
+
},
|
1801 |
+
forceCompositionEnd: function() {
|
1802 |
+
if (!this.composing || this.composing.handled) return;
|
1803 |
+
this.applyComposition(this.composing);
|
1804 |
+
this.composing.handled = true;
|
1805 |
+
this.div.blur();
|
1806 |
+
this.div.focus();
|
1807 |
+
},
|
1808 |
+
applyComposition: function(composing) {
|
1809 |
+
if (composing.data && composing.data != composing.startData)
|
1810 |
+
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
|
1811 |
+
},
|
1812 |
+
|
1813 |
+
setUneditable: function(node) {
|
1814 |
+
node.setAttribute("contenteditable", "false");
|
1815 |
+
},
|
1816 |
+
|
1817 |
+
onKeyPress: function(e) {
|
1818 |
+
e.preventDefault();
|
1819 |
+
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
|
1820 |
+
},
|
1821 |
+
|
1822 |
+
onContextMenu: nothing,
|
1823 |
+
resetPosition: nothing,
|
1824 |
+
|
1825 |
+
needsContentAttribute: true
|
1826 |
+
}, ContentEditableInput.prototype);
|
1827 |
+
|
1828 |
+
function posToDOM(cm, pos) {
|
1829 |
+
var view = findViewForLine(cm, pos.line);
|
1830 |
+
if (!view || view.hidden) return null;
|
1831 |
+
var line = getLine(cm.doc, pos.line);
|
1832 |
+
var info = mapFromLineView(view, line, pos.line);
|
1833 |
+
|
1834 |
+
var order = getOrder(line), side = "left";
|
1835 |
+
if (order) {
|
1836 |
+
var partPos = getBidiPartAt(order, pos.ch);
|
1837 |
+
side = partPos % 2 ? "right" : "left";
|
1838 |
+
}
|
1839 |
+
var result = nodeAndOffsetInLineMap(info.map, pos.ch, "left");
|
1840 |
+
result.offset = result.collapse == "right" ? result.end : result.start;
|
1841 |
+
return result;
|
1842 |
+
}
|
1843 |
+
|
1844 |
+
function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
|
1845 |
+
|
1846 |
+
function domToPos(cm, node, offset) {
|
1847 |
+
var lineNode;
|
1848 |
+
if (node == cm.display.lineDiv) {
|
1849 |
+
lineNode = cm.display.lineDiv.childNodes[offset];
|
1850 |
+
if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
|
1851 |
+
node = null; offset = 0;
|
1852 |
+
} else {
|
1853 |
+
for (lineNode = node;; lineNode = lineNode.parentNode) {
|
1854 |
+
if (!lineNode || lineNode == cm.display.lineDiv) return null;
|
1855 |
+
if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
|
1856 |
+
}
|
1857 |
+
}
|
1858 |
+
for (var i = 0; i < cm.display.view.length; i++) {
|
1859 |
+
var lineView = cm.display.view[i];
|
1860 |
+
if (lineView.node == lineNode)
|
1861 |
+
return locateNodeInLineView(lineView, node, offset);
|
1862 |
+
}
|
1863 |
+
}
|
1864 |
+
|
1865 |
+
function locateNodeInLineView(lineView, node, offset) {
|
1866 |
+
var wrapper = lineView.text.firstChild, bad = false;
|
1867 |
+
if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
|
1868 |
+
if (node == wrapper) {
|
1869 |
+
bad = true;
|
1870 |
+
node = wrapper.childNodes[offset];
|
1871 |
+
offset = 0;
|
1872 |
+
if (!node) {
|
1873 |
+
var line = lineView.rest ? lst(lineView.rest) : lineView.line;
|
1874 |
+
return badPos(Pos(lineNo(line), line.text.length), bad);
|
1875 |
+
}
|
1876 |
+
}
|
1877 |
+
|
1878 |
+
var textNode = node.nodeType == 3 ? node : null, topNode = node;
|
1879 |
+
if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
|
1880 |
+
textNode = node.firstChild;
|
1881 |
+
if (offset) offset = textNode.nodeValue.length;
|
1882 |
+
}
|
1883 |
+
while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
|
1884 |
+
var measure = lineView.measure, maps = measure.maps;
|
1885 |
+
|
1886 |
+
function find(textNode, topNode, offset) {
|
1887 |
+
for (var i = -1; i < (maps ? maps.length : 0); i++) {
|
1888 |
+
var map = i < 0 ? measure.map : maps[i];
|
1889 |
+
for (var j = 0; j < map.length; j += 3) {
|
1890 |
+
var curNode = map[j + 2];
|
1891 |
+
if (curNode == textNode || curNode == topNode) {
|
1892 |
+
var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
|
1893 |
+
var ch = map[j] + offset;
|
1894 |
+
if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
|
1895 |
+
return Pos(line, ch);
|
1896 |
+
}
|
1897 |
+
}
|
1898 |
+
}
|
1899 |
+
}
|
1900 |
+
var found = find(textNode, topNode, offset);
|
1901 |
+
if (found) return badPos(found, bad);
|
1902 |
+
|
1903 |
+
// FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
|
1904 |
+
for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
|
1905 |
+
found = find(after, after.firstChild, 0);
|
1906 |
+
if (found)
|
1907 |
+
return badPos(Pos(found.line, found.ch - dist), bad);
|
1908 |
+
else
|
1909 |
+
dist += after.textContent.length;
|
1910 |
+
}
|
1911 |
+
for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) {
|
1912 |
+
found = find(before, before.firstChild, -1);
|
1913 |
+
if (found)
|
1914 |
+
return badPos(Pos(found.line, found.ch + dist), bad);
|
1915 |
+
else
|
1916 |
+
dist += after.textContent.length;
|
1917 |
+
}
|
1918 |
+
}
|
1919 |
+
|
1920 |
+
function domTextBetween(cm, from, to, fromLine, toLine) {
|
1921 |
+
var text = "", closing = false;
|
1922 |
+
function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
|
1923 |
+
function walk(node) {
|
1924 |
+
if (node.nodeType == 1) {
|
1925 |
+
var cmText = node.getAttribute("cm-text");
|
1926 |
+
if (cmText != null) {
|
1927 |
+
if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
|
1928 |
+
text += cmText;
|
1929 |
+
return;
|
1930 |
+
}
|
1931 |
+
var markerID = node.getAttribute("cm-marker"), range;
|
1932 |
+
if (markerID) {
|
1933 |
+
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
|
1934 |
+
if (found.length && (range = found[0].find()))
|
1935 |
+
text += getBetween(cm.doc, range.from, range.to).join("\n");
|
1936 |
+
return;
|
1937 |
+
}
|
1938 |
+
if (node.getAttribute("contenteditable") == "false") return;
|
1939 |
+
for (var i = 0; i < node.childNodes.length; i++)
|
1940 |
+
walk(node.childNodes[i]);
|
1941 |
+
if (/^(pre|div|p)$/i.test(node.nodeName))
|
1942 |
+
closing = true;
|
1943 |
+
} else if (node.nodeType == 3) {
|
1944 |
+
var val = node.nodeValue;
|
1945 |
+
if (!val) return;
|
1946 |
+
if (closing) {
|
1947 |
+
text += "\n";
|
1948 |
+
closing = false;
|
1949 |
+
}
|
1950 |
+
text += val;
|
1951 |
+
}
|
1952 |
+
}
|
1953 |
+
for (;;) {
|
1954 |
+
walk(from);
|
1955 |
+
if (from == to) break;
|
1956 |
+
from = from.nextSibling;
|
1957 |
+
}
|
1958 |
+
return text;
|
1959 |
+
}
|
1960 |
+
|
1961 |
+
CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
|
1962 |
+
|
1963 |
+
// SELECTION / CURSOR
|
1964 |
+
|
1965 |
+
// Selection objects are immutable. A new one is created every time
|
1966 |
+
// the selection changes. A selection is one or more non-overlapping
|
1967 |
+
// (and non-touching) ranges, sorted, and an integer that indicates
|
1968 |
+
// which one is the primary selection (the one that's scrolled into
|
1969 |
+
// view, that getCursor returns, etc).
|
1970 |
+
function Selection(ranges, primIndex) {
|
1971 |
+
this.ranges = ranges;
|
1972 |
+
this.primIndex = primIndex;
|
1973 |
+
}
|
1974 |
+
|
1975 |
+
Selection.prototype = {
|
1976 |
+
primary: function() { return this.ranges[this.primIndex]; },
|
1977 |
+
equals: function(other) {
|
1978 |
+
if (other == this) return true;
|
1979 |
+
if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
|
1980 |
+
for (var i = 0; i < this.ranges.length; i++) {
|
1981 |
+
var here = this.ranges[i], there = other.ranges[i];
|
1982 |
+
if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
|
1983 |
+
}
|
1984 |
+
return true;
|
1985 |
+
},
|
1986 |
+
deepCopy: function() {
|
1987 |
+
for (var out = [], i = 0; i < this.ranges.length; i++)
|
1988 |
+
out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
|
1989 |
+
return new Selection(out, this.primIndex);
|
1990 |
+
},
|
1991 |
+
somethingSelected: function() {
|
1992 |
+
for (var i = 0; i < this.ranges.length; i++)
|
1993 |
+
if (!this.ranges[i].empty()) return true;
|
1994 |
+
return false;
|
1995 |
+
},
|
1996 |
+
contains: function(pos, end) {
|
1997 |
+
if (!end) end = pos;
|
1998 |
+
for (var i = 0; i < this.ranges.length; i++) {
|
1999 |
+
var range = this.ranges[i];
|
2000 |
+
if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
|
2001 |
+
return i;
|
2002 |
+
}
|
2003 |
+
return -1;
|
2004 |
+
}
|
2005 |
+
};
|
2006 |
+
|
2007 |
+
function Range(anchor, head) {
|
2008 |
+
this.anchor = anchor; this.head = head;
|
2009 |
+
}
|
2010 |
+
|
2011 |
+
Range.prototype = {
|
2012 |
+
from: function() { return minPos(this.anchor, this.head); },
|
2013 |
+
to: function() { return maxPos(this.anchor, this.head); },
|
2014 |
+
empty: function() {
|
2015 |
+
return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
|
2016 |
+
}
|
2017 |
+
};
|
2018 |
+
|
2019 |
+
// Take an unsorted, potentially overlapping set of ranges, and
|
2020 |
+
// build a selection out of it. 'Consumes' ranges array (modifying
|
2021 |
+
// it).
|
2022 |
+
function normalizeSelection(ranges, primIndex) {
|
2023 |
+
var prim = ranges[primIndex];
|
2024 |
+
ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
|
2025 |
+
primIndex = indexOf(ranges, prim);
|
2026 |
+
for (var i = 1; i < ranges.length; i++) {
|
2027 |
+
var cur = ranges[i], prev = ranges[i - 1];
|
2028 |
+
if (cmp(prev.to(), cur.from()) >= 0) {
|
2029 |
+
var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
|
2030 |
+
var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
|
2031 |
+
if (i <= primIndex) --primIndex;
|
2032 |
+
ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
|
2033 |
+
}
|
2034 |
+
}
|
2035 |
+
return new Selection(ranges, primIndex);
|
2036 |
+
}
|
2037 |
+
|
2038 |
+
function simpleSelection(anchor, head) {
|
2039 |
+
return new Selection([new Range(anchor, head || anchor)], 0);
|
2040 |
+
}
|
2041 |
+
|
2042 |
+
// Most of the external API clips given positions to make sure they
|
2043 |
+
// actually exist within the document.
|
2044 |
+
function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
|
2045 |
+
function clipPos(doc, pos) {
|
2046 |
+
if (pos.line < doc.first) return Pos(doc.first, 0);
|
2047 |
+
var last = doc.first + doc.size - 1;
|
2048 |
+
if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
|
2049 |
+
return clipToLen(pos, getLine(doc, pos.line).text.length);
|
2050 |
+
}
|
2051 |
+
function clipToLen(pos, linelen) {
|
2052 |
+
var ch = pos.ch;
|
2053 |
+
if (ch == null || ch > linelen) return Pos(pos.line, linelen);
|
2054 |
+
else if (ch < 0) return Pos(pos.line, 0);
|
2055 |
+
else return pos;
|
2056 |
+
}
|
2057 |
+
function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
|
2058 |
+
function clipPosArray(doc, array) {
|
2059 |
+
for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
|
2060 |
+
return out;
|
2061 |
+
}
|
2062 |
+
|
2063 |
+
// SELECTION UPDATES
|
2064 |
+
|
2065 |
+
// The 'scroll' parameter given to many of these indicated whether
|
2066 |
+
// the new cursor position should be scrolled into view after
|
2067 |
+
// modifying the selection.
|
2068 |
+
|
2069 |
+
// If shift is held or the extend flag is set, extends a range to
|
2070 |
+
// include a given position (and optionally a second position).
|
2071 |
+
// Otherwise, simply returns the range between the given positions.
|
2072 |
+
// Used for cursor motion and such.
|
2073 |
+
function extendRange(doc, range, head, other) {
|
2074 |
+
if (doc.cm && doc.cm.display.shift || doc.extend) {
|
2075 |
+
var anchor = range.anchor;
|
2076 |
+
if (other) {
|
2077 |
+
var posBefore = cmp(head, anchor) < 0;
|
2078 |
+
if (posBefore != (cmp(other, anchor) < 0)) {
|
2079 |
+
anchor = head;
|
2080 |
+
head = other;
|
2081 |
+
} else if (posBefore != (cmp(head, other) < 0)) {
|
2082 |
+
head = other;
|
2083 |
+
}
|
2084 |
+
}
|
2085 |
+
return new Range(anchor, head);
|
2086 |
+
} else {
|
2087 |
+
return new Range(other || head, head);
|
2088 |
+
}
|
2089 |
+
}
|
2090 |
+
|
2091 |
+
// Extend the primary selection range, discard the rest.
|
2092 |
+
function extendSelection(doc, head, other, options) {
|
2093 |
+
setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
|
2094 |
+
}
|
2095 |
+
|
2096 |
+
// Extend all selections (pos is an array of selections with length
|
2097 |
+
// equal the number of selections)
|
2098 |
+
function extendSelections(doc, heads, options) {
|
2099 |
+
for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
|
2100 |
+
out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
|
2101 |
+
var newSel = normalizeSelection(out, doc.sel.primIndex);
|
2102 |
+
setSelection(doc, newSel, options);
|
2103 |
+
}
|
2104 |
+
|
2105 |
+
// Updates a single range in the selection.
|
2106 |
+
function replaceOneSelection(doc, i, range, options) {
|
2107 |
+
var ranges = doc.sel.ranges.slice(0);
|
2108 |
+
ranges[i] = range;
|
2109 |
+
setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
|
2110 |
+
}
|
2111 |
+
|
2112 |
+
// Reset the selection to a single range.
|
2113 |
+
function setSimpleSelection(doc, anchor, head, options) {
|
2114 |
+
setSelection(doc, simpleSelection(anchor, head), options);
|
2115 |
+
}
|
2116 |
+
|
2117 |
+
// Give beforeSelectionChange handlers a change to influence a
|
2118 |
+
// selection update.
|
2119 |
+
function filterSelectionChange(doc, sel) {
|
2120 |
+
var obj = {
|
2121 |
+
ranges: sel.ranges,
|
2122 |
+
update: function(ranges) {
|
2123 |
+
this.ranges = [];
|
2124 |
+
for (var i = 0; i < ranges.length; i++)
|
2125 |
+
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
2126 |
+
clipPos(doc, ranges[i].head));
|
2127 |
+
}
|
2128 |
+
};
|
2129 |
+
signal(doc, "beforeSelectionChange", doc, obj);
|
2130 |
+
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
|
2131 |
+
if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
|
2132 |
+
else return sel;
|
2133 |
+
}
|
2134 |
+
|
2135 |
+
function setSelectionReplaceHistory(doc, sel, options) {
|
2136 |
+
var done = doc.history.done, last = lst(done);
|
2137 |
+
if (last && last.ranges) {
|
2138 |
+
done[done.length - 1] = sel;
|
2139 |
+
setSelectionNoUndo(doc, sel, options);
|
2140 |
+
} else {
|
2141 |
+
setSelection(doc, sel, options);
|
2142 |
+
}
|
2143 |
+
}
|
2144 |
+
|
2145 |
+
// Set a new selection.
|
2146 |
+
function setSelection(doc, sel, options) {
|
2147 |
+
setSelectionNoUndo(doc, sel, options);
|
2148 |
+
addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
|
2149 |
+
}
|
2150 |
+
|
2151 |
+
function setSelectionNoUndo(doc, sel, options) {
|
2152 |
+
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
2153 |
+
sel = filterSelectionChange(doc, sel);
|
2154 |
+
|
2155 |
+
var bias = options && options.bias ||
|
2156 |
+
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
2157 |
+
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
|
2158 |
+
|
2159 |
+
if (!(options && options.scroll === false) && doc.cm)
|
2160 |
+
ensureCursorVisible(doc.cm);
|
2161 |
+
}
|
2162 |
+
|
2163 |
+
function setSelectionInner(doc, sel) {
|
2164 |
+
if (sel.equals(doc.sel)) return;
|
2165 |
+
|
2166 |
+
doc.sel = sel;
|
2167 |
+
|
2168 |
+
if (doc.cm) {
|
2169 |
+
doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
|
2170 |
+
signalCursorActivity(doc.cm);
|
2171 |
+
}
|
2172 |
+
signalLater(doc, "cursorActivity", doc);
|
2173 |
+
}
|
2174 |
+
|
2175 |
+
// Verify that the selection does not partially select any atomic
|
2176 |
+
// marked ranges.
|
2177 |
+
function reCheckSelection(doc) {
|
2178 |
+
setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
|
2179 |
+
}
|
2180 |
+
|
2181 |
+
// Return a selection that does not partially select any atomic
|
2182 |
+
// ranges.
|
2183 |
+
function skipAtomicInSelection(doc, sel, bias, mayClear) {
|
2184 |
+
var out;
|
2185 |
+
for (var i = 0; i < sel.ranges.length; i++) {
|
2186 |
+
var range = sel.ranges[i];
|
2187 |
+
var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
|
2188 |
+
var newHead = skipAtomic(doc, range.head, bias, mayClear);
|
2189 |
+
if (out || newAnchor != range.anchor || newHead != range.head) {
|
2190 |
+
if (!out) out = sel.ranges.slice(0, i);
|
2191 |
+
out[i] = new Range(newAnchor, newHead);
|
2192 |
+
}
|
2193 |
+
}
|
2194 |
+
return out ? normalizeSelection(out, sel.primIndex) : sel;
|
2195 |
+
}
|
2196 |
+
|
2197 |
+
// Ensure a given position is not inside an atomic range.
|
2198 |
+
function skipAtomic(doc, pos, bias, mayClear) {
|
2199 |
+
var flipped = false, curPos = pos;
|
2200 |
+
var dir = bias || 1;
|
2201 |
+
doc.cantEdit = false;
|
2202 |
+
search: for (;;) {
|
2203 |
+
var line = getLine(doc, curPos.line);
|
2204 |
+
if (line.markedSpans) {
|
2205 |
+
for (var i = 0; i < line.markedSpans.length; ++i) {
|
2206 |
+
var sp = line.markedSpans[i], m = sp.marker;
|
2207 |
+
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
|
2208 |
+
(sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
|
2209 |
+
if (mayClear) {
|
2210 |
+
signal(m, "beforeCursorEnter");
|
2211 |
+
if (m.explicitlyCleared) {
|
2212 |
+
if (!line.markedSpans) break;
|
2213 |
+
else {--i; continue;}
|
2214 |
+
}
|
2215 |
+
}
|
2216 |
+
if (!m.atomic) continue;
|
2217 |
+
var newPos = m.find(dir < 0 ? -1 : 1);
|
2218 |
+
if (cmp(newPos, curPos) == 0) {
|
2219 |
+
newPos.ch += dir;
|
2220 |
+
if (newPos.ch < 0) {
|
2221 |
+
if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
|
2222 |
+
else newPos = null;
|
2223 |
+
} else if (newPos.ch > line.text.length) {
|
2224 |
+
if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
|
2225 |
+
else newPos = null;
|
2226 |
+
}
|
2227 |
+
if (!newPos) {
|
2228 |
+
if (flipped) {
|
2229 |
+
// Driven in a corner -- no valid cursor position found at all
|
2230 |
+
// -- try again *with* clearing, if we didn't already
|
2231 |
+
if (!mayClear) return skipAtomic(doc, pos, bias, true);
|
2232 |
+
// Otherwise, turn off editing until further notice, and return the start of the doc
|
2233 |
+
doc.cantEdit = true;
|
2234 |
+
return Pos(doc.first, 0);
|
2235 |
+
}
|
2236 |
+
flipped = true; newPos = pos; dir = -dir;
|
2237 |
+
}
|
2238 |
+
}
|
2239 |
+
curPos = newPos;
|
2240 |
+
continue search;
|
2241 |
+
}
|
2242 |
+
}
|
2243 |
+
}
|
2244 |
+
return curPos;
|
2245 |
+
}
|
2246 |
+
}
|
2247 |
+
|
2248 |
+
// SELECTION DRAWING
|
2249 |
+
|
2250 |
+
function updateSelection(cm) {
|
2251 |
+
cm.display.input.showSelection(cm.display.input.prepareSelection());
|
2252 |
+
}
|
2253 |
+
|
2254 |
+
function prepareSelection(cm, primary) {
|
2255 |
+
var doc = cm.doc, result = {};
|
2256 |
+
var curFragment = result.cursors = document.createDocumentFragment();
|
2257 |
+
var selFragment = result.selection = document.createDocumentFragment();
|
2258 |
+
|
2259 |
+
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
2260 |
+
if (primary === false && i == doc.sel.primIndex) continue;
|
2261 |
+
var range = doc.sel.ranges[i];
|
2262 |
+
var collapsed = range.empty();
|
2263 |
+
if (collapsed || cm.options.showCursorWhenSelecting)
|
2264 |
+
drawSelectionCursor(cm, range, curFragment);
|
2265 |
+
if (!collapsed)
|
2266 |
+
drawSelectionRange(cm, range, selFragment);
|
2267 |
+
}
|
2268 |
+
return result;
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
// Draws a cursor for the given range
|
2272 |
+
function drawSelectionCursor(cm, range, output) {
|
2273 |
+
var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine);
|
2274 |
+
|
2275 |
+
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
|
2276 |
+
cursor.style.left = pos.left + "px";
|
2277 |
+
cursor.style.top = pos.top + "px";
|
2278 |
+
cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
|
2279 |
+
|
2280 |
+
if (pos.other) {
|
2281 |
+
// Secondary cursor, shown when on a 'jump' in bi-directional text
|
2282 |
+
var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
|
2283 |
+
otherCursor.style.display = "";
|
2284 |
+
otherCursor.style.left = pos.other.left + "px";
|
2285 |
+
otherCursor.style.top = pos.other.top + "px";
|
2286 |
+
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
|
2287 |
+
}
|
2288 |
+
}
|
2289 |
+
|
2290 |
+
// Draws the given range as a highlighted selection
|
2291 |
+
function drawSelectionRange(cm, range, output) {
|
2292 |
+
var display = cm.display, doc = cm.doc;
|
2293 |
+
var fragment = document.createDocumentFragment();
|
2294 |
+
var padding = paddingH(cm.display), leftSide = padding.left;
|
2295 |
+
var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
|
2296 |
+
|
2297 |
+
function add(left, top, width, bottom) {
|
2298 |
+
if (top < 0) top = 0;
|
2299 |
+
top = Math.round(top);
|
2300 |
+
bottom = Math.round(bottom);
|
2301 |
+
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
|
2302 |
+
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
|
2303 |
+
"px; height: " + (bottom - top) + "px"));
|
2304 |
+
}
|
2305 |
+
|
2306 |
+
function drawForLine(line, fromArg, toArg) {
|
2307 |
+
var lineObj = getLine(doc, line);
|
2308 |
+
var lineLen = lineObj.text.length;
|
2309 |
+
var start, end;
|
2310 |
+
function coords(ch, bias) {
|
2311 |
+
return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
|
2312 |
+
}
|
2313 |
+
|
2314 |
+
iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
|
2315 |
+
var leftPos = coords(from, "left"), rightPos, left, right;
|
2316 |
+
if (from == to) {
|
2317 |
+
rightPos = leftPos;
|
2318 |
+
left = right = leftPos.left;
|
2319 |
+
} else {
|
2320 |
+
rightPos = coords(to - 1, "right");
|
2321 |
+
if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
|
2322 |
+
left = leftPos.left;
|
2323 |
+
right = rightPos.right;
|
2324 |
+
}
|
2325 |
+
if (fromArg == null && from == 0) left = leftSide;
|
2326 |
+
if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
|
2327 |
+
add(left, leftPos.top, null, leftPos.bottom);
|
2328 |
+
left = leftSide;
|
2329 |
+
if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
|
2330 |
+
}
|
2331 |
+
if (toArg == null && to == lineLen) right = rightSide;
|
2332 |
+
if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
|
2333 |
+
start = leftPos;
|
2334 |
+
if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
|
2335 |
+
end = rightPos;
|
2336 |
+
if (left < leftSide + 1) left = leftSide;
|
2337 |
+
add(left, rightPos.top, right - left, rightPos.bottom);
|
2338 |
+
});
|
2339 |
+
return {start: start, end: end};
|
2340 |
+
}
|
2341 |
+
|
2342 |
+
var sFrom = range.from(), sTo = range.to();
|
2343 |
+
if (sFrom.line == sTo.line) {
|
2344 |
+
drawForLine(sFrom.line, sFrom.ch, sTo.ch);
|
2345 |
+
} else {
|
2346 |
+
var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
|
2347 |
+
var singleVLine = visualLine(fromLine) == visualLine(toLine);
|
2348 |
+
var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
|
2349 |
+
var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
|
2350 |
+
if (singleVLine) {
|
2351 |
+
if (leftEnd.top < rightStart.top - 2) {
|
2352 |
+
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
|
2353 |
+
add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
|
2354 |
+
} else {
|
2355 |
+
add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
|
2356 |
+
}
|
2357 |
+
}
|
2358 |
+
if (leftEnd.bottom < rightStart.top)
|
2359 |
+
add(leftSide, leftEnd.bottom, null, rightStart.top);
|
2360 |
+
}
|
2361 |
+
|
2362 |
+
output.appendChild(fragment);
|
2363 |
+
}
|
2364 |
+
|
2365 |
+
// Cursor-blinking
|
2366 |
+
function restartBlink(cm) {
|
2367 |
+
if (!cm.state.focused) return;
|
2368 |
+
var display = cm.display;
|
2369 |
+
clearInterval(display.blinker);
|
2370 |
+
var on = true;
|
2371 |
+
display.cursorDiv.style.visibility = "";
|
2372 |
+
if (cm.options.cursorBlinkRate > 0)
|
2373 |
+
display.blinker = setInterval(function() {
|
2374 |
+
display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
|
2375 |
+
}, cm.options.cursorBlinkRate);
|
2376 |
+
else if (cm.options.cursorBlinkRate < 0)
|
2377 |
+
display.cursorDiv.style.visibility = "hidden";
|
2378 |
+
}
|
2379 |
+
|
2380 |
+
// HIGHLIGHT WORKER
|
2381 |
+
|
2382 |
+
function startWorker(cm, time) {
|
2383 |
+
if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
|
2384 |
+
cm.state.highlight.set(time, bind(highlightWorker, cm));
|
2385 |
+
}
|
2386 |
+
|
2387 |
+
function highlightWorker(cm) {
|
2388 |
+
var doc = cm.doc;
|
2389 |
+
if (doc.frontier < doc.first) doc.frontier = doc.first;
|
2390 |
+
if (doc.frontier >= cm.display.viewTo) return;
|
2391 |
+
var end = +new Date + cm.options.workTime;
|
2392 |
+
var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
|
2393 |
+
var changedLines = [];
|
2394 |
+
|
2395 |
+
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
|
2396 |
+
if (doc.frontier >= cm.display.viewFrom) { // Visible
|
2397 |
+
var oldStyles = line.styles;
|
2398 |
+
var highlighted = highlightLine(cm, line, state, true);
|
2399 |
+
line.styles = highlighted.styles;
|
2400 |
+
var oldCls = line.styleClasses, newCls = highlighted.classes;
|
2401 |
+
if (newCls) line.styleClasses = newCls;
|
2402 |
+
else if (oldCls) line.styleClasses = null;
|
2403 |
+
var ischange = !oldStyles || oldStyles.length != line.styles.length ||
|
2404 |
+
oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
|
2405 |
+
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
|
2406 |
+
if (ischange) changedLines.push(doc.frontier);
|
2407 |
+
line.stateAfter = copyState(doc.mode, state);
|
2408 |
+
} else {
|
2409 |
+
processLine(cm, line.text, state);
|
2410 |
+
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
|
2411 |
+
}
|
2412 |
+
++doc.frontier;
|
2413 |
+
if (+new Date > end) {
|
2414 |
+
startWorker(cm, cm.options.workDelay);
|
2415 |
+
return true;
|
2416 |
+
}
|
2417 |
+
});
|
2418 |
+
if (changedLines.length) runInOp(cm, function() {
|
2419 |
+
for (var i = 0; i < changedLines.length; i++)
|
2420 |
+
regLineChange(cm, changedLines[i], "text");
|
2421 |
+
});
|
2422 |
+
}
|
2423 |
+
|
2424 |
+
// Finds the line to start with when starting a parse. Tries to
|
2425 |
+
// find a line with a stateAfter, so that it can start with a
|
2426 |
+
// valid state. If that fails, it returns the line with the
|
2427 |
+
// smallest indentation, which tends to need the least context to
|
2428 |
+
// parse correctly.
|
2429 |
+
function findStartLine(cm, n, precise) {
|
2430 |
+
var minindent, minline, doc = cm.doc;
|
2431 |
+
var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
|
2432 |
+
for (var search = n; search > lim; --search) {
|
2433 |
+
if (search <= doc.first) return doc.first;
|
2434 |
+
var line = getLine(doc, search - 1);
|
2435 |
+
if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
|
2436 |
+
var indented = countColumn(line.text, null, cm.options.tabSize);
|
2437 |
+
if (minline == null || minindent > indented) {
|
2438 |
+
minline = search - 1;
|
2439 |
+
minindent = indented;
|
2440 |
+
}
|
2441 |
+
}
|
2442 |
+
return minline;
|
2443 |
+
}
|
2444 |
+
|
2445 |
+
function getStateBefore(cm, n, precise) {
|
2446 |
+
var doc = cm.doc, display = cm.display;
|
2447 |
+
if (!doc.mode.startState) return true;
|
2448 |
+
var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
|
2449 |
+
if (!state) state = startState(doc.mode);
|
2450 |
+
else state = copyState(doc.mode, state);
|
2451 |
+
doc.iter(pos, n, function(line) {
|
2452 |
+
processLine(cm, line.text, state);
|
2453 |
+
var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
|
2454 |
+
line.stateAfter = save ? copyState(doc.mode, state) : null;
|
2455 |
+
++pos;
|
2456 |
+
});
|
2457 |
+
if (precise) doc.frontier = pos;
|
2458 |
+
return state;
|
2459 |
+
}
|
2460 |
+
|
2461 |
+
// POSITION MEASUREMENT
|
2462 |
+
|
2463 |
+
function paddingTop(display) {return display.lineSpace.offsetTop;}
|
2464 |
+
function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;}
|
2465 |
+
function paddingH(display) {
|
2466 |
+
if (display.cachedPaddingH) return display.cachedPaddingH;
|
2467 |
+
var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
|
2468 |
+
var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
|
2469 |
+
var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
|
2470 |
+
if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
|
2471 |
+
return data;
|
2472 |
+
}
|
2473 |
+
|
2474 |
+
function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; }
|
2475 |
+
function displayWidth(cm) {
|
2476 |
+
return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
|
2477 |
+
}
|
2478 |
+
function displayHeight(cm) {
|
2479 |
+
return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
|
2480 |
+
}
|
2481 |
+
|
2482 |
+
// Ensure the lineView.wrapping.heights array is populated. This is
|
2483 |
+
// an array of bottom offsets for the lines that make up a drawn
|
2484 |
+
// line. When lineWrapping is on, there might be more than one
|
2485 |
+
// height.
|
2486 |
+
function ensureLineHeights(cm, lineView, rect) {
|
2487 |
+
var wrapping = cm.options.lineWrapping;
|
2488 |
+
var curWidth = wrapping && displayWidth(cm);
|
2489 |
+
if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
|
2490 |
+
var heights = lineView.measure.heights = [];
|
2491 |
+
if (wrapping) {
|
2492 |
+
lineView.measure.width = curWidth;
|
2493 |
+
var rects = lineView.text.firstChild.getClientRects();
|
2494 |
+
for (var i = 0; i < rects.length - 1; i++) {
|
2495 |
+
var cur = rects[i], next = rects[i + 1];
|
2496 |
+
if (Math.abs(cur.bottom - next.bottom) > 2)
|
2497 |
+
heights.push((cur.bottom + next.top) / 2 - rect.top);
|
2498 |
+
}
|
2499 |
+
}
|
2500 |
+
heights.push(rect.bottom - rect.top);
|
2501 |
+
}
|
2502 |
+
}
|
2503 |
+
|
2504 |
+
// Find a line map (mapping character offsets to text nodes) and a
|
2505 |
+
// measurement cache for the given line number. (A line view might
|
2506 |
+
// contain multiple lines when collapsed ranges are present.)
|
2507 |
+
function mapFromLineView(lineView, line, lineN) {
|
2508 |
+
if (lineView.line == line)
|
2509 |
+
return {map: lineView.measure.map, cache: lineView.measure.cache};
|
2510 |
+
for (var i = 0; i < lineView.rest.length; i++)
|
2511 |
+
if (lineView.rest[i] == line)
|
2512 |
+
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
|
2513 |
+
for (var i = 0; i < lineView.rest.length; i++)
|
2514 |
+
if (lineNo(lineView.rest[i]) > lineN)
|
2515 |
+
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
|
2516 |
+
}
|
2517 |
+
|
2518 |
+
// Render a line into the hidden node display.externalMeasured. Used
|
2519 |
+
// when measurement is needed for a line that's not in the viewport.
|
2520 |
+
function updateExternalMeasurement(cm, line) {
|
2521 |
+
line = visualLine(line);
|
2522 |
+
var lineN = lineNo(line);
|
2523 |
+
var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
|
2524 |
+
view.lineN = lineN;
|
2525 |
+
var built = view.built = buildLineContent(cm, view);
|
2526 |
+
view.text = built.pre;
|
2527 |
+
removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
|
2528 |
+
return view;
|
2529 |
+
}
|
2530 |
+
|
2531 |
+
// Get a {top, bottom, left, right} box (in line-local coordinates)
|
2532 |
+
// for a given character.
|
2533 |
+
function measureChar(cm, line, ch, bias) {
|
2534 |
+
return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
|
2535 |
+
}
|
2536 |
+
|
2537 |
+
// Find a line view that corresponds to the given line number.
|
2538 |
+
function findViewForLine(cm, lineN) {
|
2539 |
+
if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
|
2540 |
+
return cm.display.view[findViewIndex(cm, lineN)];
|
2541 |
+
var ext = cm.display.externalMeasured;
|
2542 |
+
if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
|
2543 |
+
return ext;
|
2544 |
+
}
|
2545 |
+
|
2546 |
+
// Measurement can be split in two steps, the set-up work that
|
2547 |
+
// applies to the whole line, and the measurement of the actual
|
2548 |
+
// character. Functions like coordsChar, that need to do a lot of
|
2549 |
+
// measurements in a row, can thus ensure that the set-up work is
|
2550 |
+
// only done once.
|
2551 |
+
function prepareMeasureForLine(cm, line) {
|
2552 |
+
var lineN = lineNo(line);
|
2553 |
+
var view = findViewForLine(cm, lineN);
|
2554 |
+
if (view && !view.text)
|
2555 |
+
view = null;
|
2556 |
+
else if (view && view.changes)
|
2557 |
+
updateLineForChanges(cm, view, lineN, getDimensions(cm));
|
2558 |
+
if (!view)
|
2559 |
+
view = updateExternalMeasurement(cm, line);
|
2560 |
+
|
2561 |
+
var info = mapFromLineView(view, line, lineN);
|
2562 |
+
return {
|
2563 |
+
line: line, view: view, rect: null,
|
2564 |
+
map: info.map, cache: info.cache, before: info.before,
|
2565 |
+
hasHeights: false
|
2566 |
+
};
|
2567 |
+
}
|
2568 |
+
|
2569 |
+
// Given a prepared measurement object, measures the position of an
|
2570 |
+
// actual character (or fetches it from the cache).
|
2571 |
+
function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
|
2572 |
+
if (prepared.before) ch = -1;
|
2573 |
+
var key = ch + (bias || ""), found;
|
2574 |
+
if (prepared.cache.hasOwnProperty(key)) {
|
2575 |
+
found = prepared.cache[key];
|
2576 |
+
} else {
|
2577 |
+
if (!prepared.rect)
|
2578 |
+
prepared.rect = prepared.view.text.getBoundingClientRect();
|
2579 |
+
if (!prepared.hasHeights) {
|
2580 |
+
ensureLineHeights(cm, prepared.view, prepared.rect);
|
2581 |
+
prepared.hasHeights = true;
|
2582 |
+
}
|
2583 |
+
found = measureCharInner(cm, prepared, ch, bias);
|
2584 |
+
if (!found.bogus) prepared.cache[key] = found;
|
2585 |
+
}
|
2586 |
+
return {left: found.left, right: found.right,
|
2587 |
+
top: varHeight ? found.rtop : found.top,
|
2588 |
+
bottom: varHeight ? found.rbottom : found.bottom};
|
2589 |
+
}
|
2590 |
+
|
2591 |
+
var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
|
2592 |
+
|
2593 |
+
function nodeAndOffsetInLineMap(map, ch, bias) {
|
2594 |
+
var node, start, end, collapse;
|
2595 |
+
// First, search the line map for the text node corresponding to,
|
2596 |
+
// or closest to, the target character.
|
2597 |
+
for (var i = 0; i < map.length; i += 3) {
|
2598 |
+
var mStart = map[i], mEnd = map[i + 1];
|
2599 |
+
if (ch < mStart) {
|
2600 |
+
start = 0; end = 1;
|
2601 |
+
collapse = "left";
|
2602 |
+
} else if (ch < mEnd) {
|
2603 |
+
start = ch - mStart;
|
2604 |
+
end = start + 1;
|
2605 |
+
} else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
|
2606 |
+
end = mEnd - mStart;
|
2607 |
+
start = end - 1;
|
2608 |
+
if (ch >= mEnd) collapse = "right";
|
2609 |
+
}
|
2610 |
+
if (start != null) {
|
2611 |
+
node = map[i + 2];
|
2612 |
+
if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
|
2613 |
+
collapse = bias;
|
2614 |
+
if (bias == "left" && start == 0)
|
2615 |
+
while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
|
2616 |
+
node = map[(i -= 3) + 2];
|
2617 |
+
collapse = "left";
|
2618 |
+
}
|
2619 |
+
if (bias == "right" && start == mEnd - mStart)
|
2620 |
+
while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
|
2621 |
+
node = map[(i += 3) + 2];
|
2622 |
+
collapse = "right";
|
2623 |
+
}
|
2624 |
+
break;
|
2625 |
+
}
|
2626 |
+
}
|
2627 |
+
return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
|
2628 |
+
}
|
2629 |
+
|
2630 |
+
function measureCharInner(cm, prepared, ch, bias) {
|
2631 |
+
var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
|
2632 |
+
var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
|
2633 |
+
|
2634 |
+
var rect;
|
2635 |
+
if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
|
2636 |
+
for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
|
2637 |
+
while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
|
2638 |
+
while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
|
2639 |
+
if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) {
|
2640 |
+
rect = node.parentNode.getBoundingClientRect();
|
2641 |
+
} else if (ie && cm.options.lineWrapping) {
|
2642 |
+
var rects = range(node, start, end).getClientRects();
|
2643 |
+
if (rects.length)
|
2644 |
+
rect = rects[bias == "right" ? rects.length - 1 : 0];
|
2645 |
+
else
|
2646 |
+
rect = nullRect;
|
2647 |
+
} else {
|
2648 |
+
rect = range(node, start, end).getBoundingClientRect() || nullRect;
|
2649 |
+
}
|
2650 |
+
if (rect.left || rect.right || start == 0) break;
|
2651 |
+
end = start;
|
2652 |
+
start = start - 1;
|
2653 |
+
collapse = "right";
|
2654 |
+
}
|
2655 |
+
if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
|
2656 |
+
} else { // If it is a widget, simply get the box for the whole widget.
|
2657 |
+
if (start > 0) collapse = bias = "right";
|
2658 |
+
var rects;
|
2659 |
+
if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
|
2660 |
+
rect = rects[bias == "right" ? rects.length - 1 : 0];
|
2661 |
+
else
|
2662 |
+
rect = node.getBoundingClientRect();
|
2663 |
+
}
|
2664 |
+
if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
|
2665 |
+
var rSpan = node.parentNode.getClientRects()[0];
|
2666 |
+
if (rSpan)
|
2667 |
+
rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
|
2668 |
+
else
|
2669 |
+
rect = nullRect;
|
2670 |
+
}
|
2671 |
+
|
2672 |
+
var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
|
2673 |
+
var mid = (rtop + rbot) / 2;
|
2674 |
+
var heights = prepared.view.measure.heights;
|
2675 |
+
for (var i = 0; i < heights.length - 1; i++)
|
2676 |
+
if (mid < heights[i]) break;
|
2677 |
+
var top = i ? heights[i - 1] : 0, bot = heights[i];
|
2678 |
+
var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
|
2679 |
+
right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
|
2680 |
+
top: top, bottom: bot};
|
2681 |
+
if (!rect.left && !rect.right) result.bogus = true;
|
2682 |
+
if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
|
2683 |
+
|
2684 |
+
return result;
|
2685 |
+
}
|
2686 |
+
|
2687 |
+
// Work around problem with bounding client rects on ranges being
|
2688 |
+
// returned incorrectly when zoomed on IE10 and below.
|
2689 |
+
function maybeUpdateRectForZooming(measure, rect) {
|
2690 |
+
if (!window.screen || screen.logicalXDPI == null ||
|
2691 |
+
screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
|
2692 |
+
return rect;
|
2693 |
+
var scaleX = screen.logicalXDPI / screen.deviceXDPI;
|
2694 |
+
var scaleY = screen.logicalYDPI / screen.deviceYDPI;
|
2695 |
+
return {left: rect.left * scaleX, right: rect.right * scaleX,
|
2696 |
+
top: rect.top * scaleY, bottom: rect.bottom * scaleY};
|
2697 |
+
}
|
2698 |
+
|
2699 |
+
function clearLineMeasurementCacheFor(lineView) {
|
2700 |
+
if (lineView.measure) {
|
2701 |
+
lineView.measure.cache = {};
|
2702 |
+
lineView.measure.heights = null;
|
2703 |
+
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
|
2704 |
+
lineView.measure.caches[i] = {};
|
2705 |
+
}
|
2706 |
+
}
|
2707 |
+
|
2708 |
+
function clearLineMeasurementCache(cm) {
|
2709 |
+
cm.display.externalMeasure = null;
|
2710 |
+
removeChildren(cm.display.lineMeasure);
|
2711 |
+
for (var i = 0; i < cm.display.view.length; i++)
|
2712 |
+
clearLineMeasurementCacheFor(cm.display.view[i]);
|
2713 |
+
}
|
2714 |
+
|
2715 |
+
function clearCaches(cm) {
|
2716 |
+
clearLineMeasurementCache(cm);
|
2717 |
+
cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
|
2718 |
+
if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
|
2719 |
+
cm.display.lineNumChars = null;
|
2720 |
+
}
|
2721 |
+
|
2722 |
+
function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
|
2723 |
+
function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
|
2724 |
+
|
2725 |
+
// Converts a {top, bottom, left, right} box from line-local
|
2726 |
+
// coordinates into another coordinate system. Context may be one of
|
2727 |
+
// "line", "div" (display.lineDiv), "local"/null (editor), "window",
|
2728 |
+
// or "page".
|
2729 |
+
function intoCoordSystem(cm, lineObj, rect, context) {
|
2730 |
+
if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
|
2731 |
+
var size = widgetHeight(lineObj.widgets[i]);
|
2732 |
+
rect.top += size; rect.bottom += size;
|
2733 |
+
}
|
2734 |
+
if (context == "line") return rect;
|
2735 |
+
if (!context) context = "local";
|
2736 |
+
var yOff = heightAtLine(lineObj);
|
2737 |
+
if (context == "local") yOff += paddingTop(cm.display);
|
2738 |
+
else yOff -= cm.display.viewOffset;
|
2739 |
+
if (context == "page" || context == "window") {
|
2740 |
+
var lOff = cm.display.lineSpace.getBoundingClientRect();
|
2741 |
+
yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
|
2742 |
+
var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
|
2743 |
+
rect.left += xOff; rect.right += xOff;
|
2744 |
+
}
|
2745 |
+
rect.top += yOff; rect.bottom += yOff;
|
2746 |
+
return rect;
|
2747 |
+
}
|
2748 |
+
|
2749 |
+
// Coverts a box from "div" coords to another coordinate system.
|
2750 |
+
// Context may be "window", "page", "div", or "local"/null.
|
2751 |
+
function fromCoordSystem(cm, coords, context) {
|
2752 |
+
if (context == "div") return coords;
|
2753 |
+
var left = coords.left, top = coords.top;
|
2754 |
+
// First move into "page" coordinate system
|
2755 |
+
if (context == "page") {
|
2756 |
+
left -= pageScrollX();
|
2757 |
+
top -= pageScrollY();
|
2758 |
+
} else if (context == "local" || !context) {
|
2759 |
+
var localBox = cm.display.sizer.getBoundingClientRect();
|
2760 |
+
left += localBox.left;
|
2761 |
+
top += localBox.top;
|
2762 |
+
}
|
2763 |
+
|
2764 |
+
var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
|
2765 |
+
return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
|
2766 |
+
}
|
2767 |
+
|
2768 |
+
function charCoords(cm, pos, context, lineObj, bias) {
|
2769 |
+
if (!lineObj) lineObj = getLine(cm.doc, pos.line);
|
2770 |
+
return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
|
2771 |
+
}
|
2772 |
+
|
2773 |
+
// Returns a box for a given cursor position, which may have an
|
2774 |
+
// 'other' property containing the position of the secondary cursor
|
2775 |
+
// on a bidi boundary.
|
2776 |
+
function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
|
2777 |
+
lineObj = lineObj || getLine(cm.doc, pos.line);
|
2778 |
+
if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
|
2779 |
+
function get(ch, right) {
|
2780 |
+
var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
|
2781 |
+
if (right) m.left = m.right; else m.right = m.left;
|
2782 |
+
return intoCoordSystem(cm, lineObj, m, context);
|
2783 |
+
}
|
2784 |
+
function getBidi(ch, partPos) {
|
2785 |
+
var part = order[partPos], right = part.level % 2;
|
2786 |
+
if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
|
2787 |
+
part = order[--partPos];
|
2788 |
+
ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
|
2789 |
+
right = true;
|
2790 |
+
} else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
|
2791 |
+
part = order[++partPos];
|
2792 |
+
ch = bidiLeft(part) - part.level % 2;
|
2793 |
+
right = false;
|
2794 |
+
}
|
2795 |
+
if (right && ch == part.to && ch > part.from) return get(ch - 1);
|
2796 |
+
return get(ch, right);
|
2797 |
+
}
|
2798 |
+
var order = getOrder(lineObj), ch = pos.ch;
|
2799 |
+
if (!order) return get(ch);
|
2800 |
+
var partPos = getBidiPartAt(order, ch);
|
2801 |
+
var val = getBidi(ch, partPos);
|
2802 |
+
if (bidiOther != null) val.other = getBidi(ch, bidiOther);
|
2803 |
+
return val;
|
2804 |
+
}
|
2805 |
+
|
2806 |
+
// Used to cheaply estimate the coordinates for a position. Used for
|
2807 |
+
// intermediate scroll updates.
|
2808 |
+
function estimateCoords(cm, pos) {
|
2809 |
+
var left = 0, pos = clipPos(cm.doc, pos);
|
2810 |
+
if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
|
2811 |
+
var lineObj = getLine(cm.doc, pos.line);
|
2812 |
+
var top = heightAtLine(lineObj) + paddingTop(cm.display);
|
2813 |
+
return {left: left, right: left, top: top, bottom: top + lineObj.height};
|
2814 |
+
}
|
2815 |
+
|
2816 |
+
// Positions returned by coordsChar contain some extra information.
|
2817 |
+
// xRel is the relative x position of the input coordinates compared
|
2818 |
+
// to the found position (so xRel > 0 means the coordinates are to
|
2819 |
+
// the right of the character position, for example). When outside
|
2820 |
+
// is true, that means the coordinates lie outside the line's
|
2821 |
+
// vertical range.
|
2822 |
+
function PosWithInfo(line, ch, outside, xRel) {
|
2823 |
+
var pos = Pos(line, ch);
|
2824 |
+
pos.xRel = xRel;
|
2825 |
+
if (outside) pos.outside = true;
|
2826 |
+
return pos;
|
2827 |
+
}
|
2828 |
+
|
2829 |
+
// Compute the character position closest to the given coordinates.
|
2830 |
+
// Input must be lineSpace-local ("div" coordinate system).
|
2831 |
+
function coordsChar(cm, x, y) {
|
2832 |
+
var doc = cm.doc;
|
2833 |
+
y += cm.display.viewOffset;
|
2834 |
+
if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
|
2835 |
+
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
|
2836 |
+
if (lineN > last)
|
2837 |
+
return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
|
2838 |
+
if (x < 0) x = 0;
|
2839 |
+
|
2840 |
+
var lineObj = getLine(doc, lineN);
|
2841 |
+
for (;;) {
|
2842 |
+
var found = coordsCharInner(cm, lineObj, lineN, x, y);
|
2843 |
+
var merged = collapsedSpanAtEnd(lineObj);
|
2844 |
+
var mergedPos = merged && merged.find(0, true);
|
2845 |
+
if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
|
2846 |
+
lineN = lineNo(lineObj = mergedPos.to.line);
|
2847 |
+
else
|
2848 |
+
return found;
|
2849 |
+
}
|
2850 |
+
}
|
2851 |
+
|
2852 |
+
function coordsCharInner(cm, lineObj, lineNo, x, y) {
|
2853 |
+
var innerOff = y - heightAtLine(lineObj);
|
2854 |
+
var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
|
2855 |
+
var preparedMeasure = prepareMeasureForLine(cm, lineObj);
|
2856 |
+
|
2857 |
+
function getX(ch) {
|
2858 |
+
var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
|
2859 |
+
wrongLine = true;
|
2860 |
+
if (innerOff > sp.bottom) return sp.left - adjust;
|
2861 |
+
else if (innerOff < sp.top) return sp.left + adjust;
|
2862 |
+
else wrongLine = false;
|
2863 |
+
return sp.left;
|
2864 |
+
}
|
2865 |
+
|
2866 |
+
var bidi = getOrder(lineObj), dist = lineObj.text.length;
|
2867 |
+
var from = lineLeft(lineObj), to = lineRight(lineObj);
|
2868 |
+
var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
|
2869 |
+
|
2870 |
+
if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
|
2871 |
+
// Do a binary search between these bounds.
|
2872 |
+
for (;;) {
|
2873 |
+
if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
|
2874 |
+
var ch = x < fromX || x - fromX <= toX - x ? from : to;
|
2875 |
+
var xDiff = x - (ch == from ? fromX : toX);
|
2876 |
+
while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
|
2877 |
+
var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
|
2878 |
+
xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
|
2879 |
+
return pos;
|
2880 |
+
}
|
2881 |
+
var step = Math.ceil(dist / 2), middle = from + step;
|
2882 |
+
if (bidi) {
|
2883 |
+
middle = from;
|
2884 |
+
for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
|
2885 |
+
}
|
2886 |
+
var middleX = getX(middle);
|
2887 |
+
if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
|
2888 |
+
else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
|
2889 |
+
}
|
2890 |
+
}
|
2891 |
+
|
2892 |
+
var measureText;
|
2893 |
+
// Compute the default text height.
|
2894 |
+
function textHeight(display) {
|
2895 |
+
if (display.cachedTextHeight != null) return display.cachedTextHeight;
|
2896 |
+
if (measureText == null) {
|
2897 |
+
measureText = elt("pre");
|
2898 |
+
// Measure a bunch of lines, for browsers that compute
|
2899 |
+
// fractional heights.
|
2900 |
+
for (var i = 0; i < 49; ++i) {
|
2901 |
+
measureText.appendChild(document.createTextNode("x"));
|
2902 |
+
measureText.appendChild(elt("br"));
|
2903 |
+
}
|
2904 |
+
measureText.appendChild(document.createTextNode("x"));
|
2905 |
+
}
|
2906 |
+
removeChildrenAndAdd(display.measure, measureText);
|
2907 |
+
var height = measureText.offsetHeight / 50;
|
2908 |
+
if (height > 3) display.cachedTextHeight = height;
|
2909 |
+
removeChildren(display.measure);
|
2910 |
+
return height || 1;
|
2911 |
+
}
|
2912 |
+
|
2913 |
+
// Compute the default character width.
|
2914 |
+
function charWidth(display) {
|
2915 |
+
if (display.cachedCharWidth != null) return display.cachedCharWidth;
|
2916 |
+
var anchor = elt("span", "xxxxxxxxxx");
|
2917 |
+
var pre = elt("pre", [anchor]);
|
2918 |
+
removeChildrenAndAdd(display.measure, pre);
|
2919 |
+
var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
|
2920 |
+
if (width > 2) display.cachedCharWidth = width;
|
2921 |
+
return width || 10;
|
2922 |
+
}
|
2923 |
+
|
2924 |
+
// OPERATIONS
|
2925 |
+
|
2926 |
+
// Operations are used to wrap a series of changes to the editor
|
2927 |
+
// state in such a way that each change won't have to update the
|
2928 |
+
// cursor and display (which would be awkward, slow, and
|
2929 |
+
// error-prone). Instead, display updates are batched and then all
|
2930 |
+
// combined and executed at once.
|
2931 |
+
|
2932 |
+
var operationGroup = null;
|
2933 |
+
|
2934 |
+
var nextOpId = 0;
|
2935 |
+
// Start a new operation.
|
2936 |
+
function startOperation(cm) {
|
2937 |
+
cm.curOp = {
|
2938 |
+
cm: cm,
|
2939 |
+
viewChanged: false, // Flag that indicates that lines might need to be redrawn
|
2940 |
+
startHeight: cm.doc.height, // Used to detect need to update scrollbar
|
2941 |
+
forceUpdate: false, // Used to force a redraw
|
2942 |
+
updateInput: null, // Whether to reset the input textarea
|
2943 |
+
typing: false, // Whether this reset should be careful to leave existing text (for compositing)
|
2944 |
+
changeObjs: null, // Accumulated changes, for firing change events
|
2945 |
+
cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
|
2946 |
+
cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
|
2947 |
+
selectionChanged: false, // Whether the selection needs to be redrawn
|
2948 |
+
updateMaxLine: false, // Set when the widest line needs to be determined anew
|
2949 |
+
scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
|
2950 |
+
scrollToPos: null, // Used to scroll to a specific position
|
2951 |
+
focus: false,
|
2952 |
+
id: ++nextOpId // Unique ID
|
2953 |
+
};
|
2954 |
+
if (operationGroup) {
|
2955 |
+
operationGroup.ops.push(cm.curOp);
|
2956 |
+
} else {
|
2957 |
+
cm.curOp.ownsGroup = operationGroup = {
|
2958 |
+
ops: [cm.curOp],
|
2959 |
+
delayedCallbacks: []
|
2960 |
+
};
|
2961 |
+
}
|
2962 |
+
}
|
2963 |
+
|
2964 |
+
function fireCallbacksForOps(group) {
|
2965 |
+
// Calls delayed callbacks and cursorActivity handlers until no
|
2966 |
+
// new ones appear
|
2967 |
+
var callbacks = group.delayedCallbacks, i = 0;
|
2968 |
+
do {
|
2969 |
+
for (; i < callbacks.length; i++)
|
2970 |
+
callbacks[i]();
|
2971 |
+
for (var j = 0; j < group.ops.length; j++) {
|
2972 |
+
var op = group.ops[j];
|
2973 |
+
if (op.cursorActivityHandlers)
|
2974 |
+
while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
|
2975 |
+
op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);
|
2976 |
+
}
|
2977 |
+
} while (i < callbacks.length);
|
2978 |
+
}
|
2979 |
+
|
2980 |
+
// Finish an operation, updating the display and signalling delayed events
|
2981 |
+
function endOperation(cm) {
|
2982 |
+
var op = cm.curOp, group = op.ownsGroup;
|
2983 |
+
if (!group) return;
|
2984 |
+
|
2985 |
+
try { fireCallbacksForOps(group); }
|
2986 |
+
finally {
|
2987 |
+
operationGroup = null;
|
2988 |
+
for (var i = 0; i < group.ops.length; i++)
|
2989 |
+
group.ops[i].cm.curOp = null;
|
2990 |
+
endOperations(group);
|
2991 |
+
}
|
2992 |
+
}
|
2993 |
+
|
2994 |
+
// The DOM updates done when an operation finishes are batched so
|
2995 |
+
// that the minimum number of relayouts are required.
|
2996 |
+
function endOperations(group) {
|
2997 |
+
var ops = group.ops;
|
2998 |
+
for (var i = 0; i < ops.length; i++) // Read DOM
|
2999 |
+
endOperation_R1(ops[i]);
|
3000 |
+
for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
|
3001 |
+
endOperation_W1(ops[i]);
|
3002 |
+
for (var i = 0; i < ops.length; i++) // Read DOM
|
3003 |
+
endOperation_R2(ops[i]);
|
3004 |
+
for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
|
3005 |
+
endOperation_W2(ops[i]);
|
3006 |
+
for (var i = 0; i < ops.length; i++) // Read DOM
|
3007 |
+
endOperation_finish(ops[i]);
|
3008 |
+
}
|
3009 |
+
|
3010 |
+
function endOperation_R1(op) {
|
3011 |
+
var cm = op.cm, display = cm.display;
|
3012 |
+
maybeClipScrollbars(cm);
|
3013 |
+
if (op.updateMaxLine) findMaxLine(cm);
|
3014 |
+
|
3015 |
+
op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
|
3016 |
+
op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
|
3017 |
+
op.scrollToPos.to.line >= display.viewTo) ||
|
3018 |
+
display.maxLineChanged && cm.options.lineWrapping;
|
3019 |
+
op.update = op.mustUpdate &&
|
3020 |
+
new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
|
3021 |
+
}
|
3022 |
+
|
3023 |
+
function endOperation_W1(op) {
|
3024 |
+
op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
|
3025 |
+
}
|
3026 |
+
|
3027 |
+
function endOperation_R2(op) {
|
3028 |
+
var cm = op.cm, display = cm.display;
|
3029 |
+
if (op.updatedDisplay) updateHeightsInViewport(cm);
|
3030 |
+
|
3031 |
+
op.barMeasure = measureForScrollbars(cm);
|
3032 |
+
|
3033 |
+
// If the max line changed since it was last measured, measure it,
|
3034 |
+
// and ensure the document's width matches it.
|
3035 |
+
// updateDisplay_W2 will use these properties to do the actual resizing
|
3036 |
+
if (display.maxLineChanged && !cm.options.lineWrapping) {
|
3037 |
+
op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
|
3038 |
+
cm.display.sizerWidth = op.adjustWidthTo;
|
3039 |
+
op.barMeasure.scrollWidth =
|
3040 |
+
Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
|
3041 |
+
op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
|
3042 |
+
}
|
3043 |
+
|
3044 |
+
if (op.updatedDisplay || op.selectionChanged)
|
3045 |
+
op.preparedSelection = display.input.prepareSelection();
|
3046 |
+
}
|
3047 |
+
|
3048 |
+
function endOperation_W2(op) {
|
3049 |
+
var cm = op.cm;
|
3050 |
+
|
3051 |
+
if (op.adjustWidthTo != null) {
|
3052 |
+
cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
|
3053 |
+
if (op.maxScrollLeft < cm.doc.scrollLeft)
|
3054 |
+
setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
|
3055 |
+
cm.display.maxLineChanged = false;
|
3056 |
+
}
|
3057 |
+
|
3058 |
+
if (op.preparedSelection)
|
3059 |
+
cm.display.input.showSelection(op.preparedSelection);
|
3060 |
+
if (op.updatedDisplay)
|
3061 |
+
setDocumentHeight(cm, op.barMeasure);
|
3062 |
+
if (op.updatedDisplay || op.startHeight != cm.doc.height)
|
3063 |
+
updateScrollbars(cm, op.barMeasure);
|
3064 |
+
|
3065 |
+
if (op.selectionChanged) restartBlink(cm);
|
3066 |
+
|
3067 |
+
if (cm.state.focused && op.updateInput)
|
3068 |
+
cm.display.input.reset(op.typing);
|
3069 |
+
if (op.focus && op.focus == activeElt()) ensureFocus(op.cm);
|
3070 |
+
}
|
3071 |
+
|
3072 |
+
function endOperation_finish(op) {
|
3073 |
+
var cm = op.cm, display = cm.display, doc = cm.doc;
|
3074 |
+
|
3075 |
+
if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
|
3076 |
+
|
3077 |
+
// Abort mouse wheel delta measurement, when scrolling explicitly
|
3078 |
+
if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
|
3079 |
+
display.wheelStartX = display.wheelStartY = null;
|
3080 |
+
|
3081 |
+
// Propagate the scroll position to the actual DOM scroller
|
3082 |
+
if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {
|
3083 |
+
doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));
|
3084 |
+
display.scrollbars.setScrollTop(doc.scrollTop);
|
3085 |
+
display.scroller.scrollTop = doc.scrollTop;
|
3086 |
+
}
|
3087 |
+
if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
|
3088 |
+
doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft));
|
3089 |
+
display.scrollbars.setScrollLeft(doc.scrollLeft);
|
3090 |
+
display.scroller.scrollLeft = doc.scrollLeft;
|
3091 |
+
alignHorizontally(cm);
|
3092 |
+
}
|
3093 |
+
// If we need to scroll a specific position into view, do so.
|
3094 |
+
if (op.scrollToPos) {
|
3095 |
+
var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
|
3096 |
+
clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
|
3097 |
+
if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);
|
3098 |
+
}
|
3099 |
+
|
3100 |
+
// Fire events for markers that are hidden/unidden by editing or
|
3101 |
+
// undoing
|
3102 |
+
var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
|
3103 |
+
if (hidden) for (var i = 0; i < hidden.length; ++i)
|
3104 |
+
if (!hidden[i].lines.length) signal(hidden[i], "hide");
|
3105 |
+
if (unhidden) for (var i = 0; i < unhidden.length; ++i)
|
3106 |
+
if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
|
3107 |
+
|
3108 |
+
if (display.wrapper.offsetHeight)
|
3109 |
+
doc.scrollTop = cm.display.scroller.scrollTop;
|
3110 |
+
|
3111 |
+
// Fire change events, and delayed event handlers
|
3112 |
+
if (op.changeObjs)
|
3113 |
+
signal(cm, "changes", cm, op.changeObjs);
|
3114 |
+
if (op.update)
|
3115 |
+
op.update.finish();
|
3116 |
+
}
|
3117 |
+
|
3118 |
+
// Run the given function in an operation
|
3119 |
+
function runInOp(cm, f) {
|
3120 |
+
if (cm.curOp) return f();
|
3121 |
+
startOperation(cm);
|
3122 |
+
try { return f(); }
|
3123 |
+
finally { endOperation(cm); }
|
3124 |
+
}
|
3125 |
+
// Wraps a function in an operation. Returns the wrapped function.
|
3126 |
+
function operation(cm, f) {
|
3127 |
+
return function() {
|
3128 |
+
if (cm.curOp) return f.apply(cm, arguments);
|
3129 |
+
startOperation(cm);
|
3130 |
+
try { return f.apply(cm, arguments); }
|
3131 |
+
finally { endOperation(cm); }
|
3132 |
+
};
|
3133 |
+
}
|
3134 |
+
// Used to add methods to editor and doc instances, wrapping them in
|
3135 |
+
// operations.
|
3136 |
+
function methodOp(f) {
|
3137 |
+
return function() {
|
3138 |
+
if (this.curOp) return f.apply(this, arguments);
|
3139 |
+
startOperation(this);
|
3140 |
+
try { return f.apply(this, arguments); }
|
3141 |
+
finally { endOperation(this); }
|
3142 |
+
};
|
3143 |
+
}
|
3144 |
+
function docMethodOp(f) {
|
3145 |
+
return function() {
|
3146 |
+
var cm = this.cm;
|
3147 |
+
if (!cm || cm.curOp) return f.apply(this, arguments);
|
3148 |
+
startOperation(cm);
|
3149 |
+
try { return f.apply(this, arguments); }
|
3150 |
+
finally { endOperation(cm); }
|
3151 |
+
};
|
3152 |
+
}
|
3153 |
+
|
3154 |
+
// VIEW TRACKING
|
3155 |
+
|
3156 |
+
// These objects are used to represent the visible (currently drawn)
|
3157 |
+
// part of the document. A LineView may correspond to multiple
|
3158 |
+
// logical lines, if those are connected by collapsed ranges.
|
3159 |
+
function LineView(doc, line, lineN) {
|
3160 |
+
// The starting line
|
3161 |
+
this.line = line;
|
3162 |
+
// Continuing lines, if any
|
3163 |
+
this.rest = visualLineContinued(line);
|
3164 |
+
// Number of logical lines in this visual line
|
3165 |
+
this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
|
3166 |
+
this.node = this.text = null;
|
3167 |
+
this.hidden = lineIsHidden(doc, line);
|
3168 |
+
}
|
3169 |
+
|
3170 |
+
// Create a range of LineView objects for the given lines.
|
3171 |
+
function buildViewArray(cm, from, to) {
|
3172 |
+
var array = [], nextPos;
|
3173 |
+
for (var pos = from; pos < to; pos = nextPos) {
|
3174 |
+
var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
|
3175 |
+
nextPos = pos + view.size;
|
3176 |
+
array.push(view);
|
3177 |
+
}
|
3178 |
+
return array;
|
3179 |
+
}
|
3180 |
+
|
3181 |
+
// Updates the display.view data structure for a given change to the
|
3182 |
+
// document. From and to are in pre-change coordinates. Lendiff is
|
3183 |
+
// the amount of lines added or subtracted by the change. This is
|
3184 |
+
// used for changes that span multiple lines, or change the way
|
3185 |
+
// lines are divided into visual lines. regLineChange (below)
|
3186 |
+
// registers single-line changes.
|
3187 |
+
function regChange(cm, from, to, lendiff) {
|
3188 |
+
if (from == null) from = cm.doc.first;
|
3189 |
+
if (to == null) to = cm.doc.first + cm.doc.size;
|
3190 |
+
if (!lendiff) lendiff = 0;
|
3191 |
+
|
3192 |
+
var display = cm.display;
|
3193 |
+
if (lendiff && to < display.viewTo &&
|
3194 |
+
(display.updateLineNumbers == null || display.updateLineNumbers > from))
|
3195 |
+
display.updateLineNumbers = from;
|
3196 |
+
|
3197 |
+
cm.curOp.viewChanged = true;
|
3198 |
+
|
3199 |
+
if (from >= display.viewTo) { // Change after
|
3200 |
+
if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
|
3201 |
+
resetView(cm);
|
3202 |
+
} else if (to <= display.viewFrom) { // Change before
|
3203 |
+
if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
|
3204 |
+
resetView(cm);
|
3205 |
+
} else {
|
3206 |
+
display.viewFrom += lendiff;
|
3207 |
+
display.viewTo += lendiff;
|
3208 |
+
}
|
3209 |
+
} else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
|
3210 |
+
resetView(cm);
|
3211 |
+
} else if (from <= display.viewFrom) { // Top overlap
|
3212 |
+
var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
|
3213 |
+
if (cut) {
|
3214 |
+
display.view = display.view.slice(cut.index);
|
3215 |
+
display.viewFrom = cut.lineN;
|
3216 |
+
display.viewTo += lendiff;
|
3217 |
+
} else {
|
3218 |
+
resetView(cm);
|
3219 |
+
}
|
3220 |
+
} else if (to >= display.viewTo) { // Bottom overlap
|
3221 |
+
var cut = viewCuttingPoint(cm, from, from, -1);
|
3222 |
+
if (cut) {
|
3223 |
+
display.view = display.view.slice(0, cut.index);
|
3224 |
+
display.viewTo = cut.lineN;
|
3225 |
+
} else {
|
3226 |
+
resetView(cm);
|
3227 |
+
}
|
3228 |
+
} else { // Gap in the middle
|
3229 |
+
var cutTop = viewCuttingPoint(cm, from, from, -1);
|
3230 |
+
var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
|
3231 |
+
if (cutTop && cutBot) {
|
3232 |
+
display.view = display.view.slice(0, cutTop.index)
|
3233 |
+
.concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
|
3234 |
+
.concat(display.view.slice(cutBot.index));
|
3235 |
+
display.viewTo += lendiff;
|
3236 |
+
} else {
|
3237 |
+
resetView(cm);
|
3238 |
+
}
|
3239 |
+
}
|
3240 |
+
|
3241 |
+
var ext = display.externalMeasured;
|
3242 |
+
if (ext) {
|
3243 |
+
if (to < ext.lineN)
|
3244 |
+
ext.lineN += lendiff;
|
3245 |
+
else if (from < ext.lineN + ext.size)
|
3246 |
+
display.externalMeasured = null;
|
3247 |
+
}
|
3248 |
+
}
|
3249 |
+
|
3250 |
+
// Register a change to a single line. Type must be one of "text",
|
3251 |
+
// "gutter", "class", "widget"
|
3252 |
+
function regLineChange(cm, line, type) {
|
3253 |
+
cm.curOp.viewChanged = true;
|
3254 |
+
var display = cm.display, ext = cm.display.externalMeasured;
|
3255 |
+
if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
|
3256 |
+
display.externalMeasured = null;
|
3257 |
+
|
3258 |
+
if (line < display.viewFrom || line >= display.viewTo) return;
|
3259 |
+
var lineView = display.view[findViewIndex(cm, line)];
|
3260 |
+
if (lineView.node == null) return;
|
3261 |
+
var arr = lineView.changes || (lineView.changes = []);
|
3262 |
+
if (indexOf(arr, type) == -1) arr.push(type);
|
3263 |
+
}
|
3264 |
+
|
3265 |
+
// Clear the view.
|
3266 |
+
function resetView(cm) {
|
3267 |
+
cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
|
3268 |
+
cm.display.view = [];
|
3269 |
+
cm.display.viewOffset = 0;
|
3270 |
+
}
|
3271 |
+
|
3272 |
+
// Find the view element corresponding to a given line. Return null
|
3273 |
+
// when the line isn't visible.
|
3274 |
+
function findViewIndex(cm, n) {
|
3275 |
+
if (n >= cm.display.viewTo) return null;
|
3276 |
+
n -= cm.display.viewFrom;
|
3277 |
+
if (n < 0) return null;
|
3278 |
+
var view = cm.display.view;
|
3279 |
+
for (var i = 0; i < view.length; i++) {
|
3280 |
+
n -= view[i].size;
|
3281 |
+
if (n < 0) return i;
|
3282 |
+
}
|
3283 |
+
}
|
3284 |
+
|
3285 |
+
function viewCuttingPoint(cm, oldN, newN, dir) {
|
3286 |
+
var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
|
3287 |
+
if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
|
3288 |
+
return {index: index, lineN: newN};
|
3289 |
+
for (var i = 0, n = cm.display.viewFrom; i < index; i++)
|
3290 |
+
n += view[i].size;
|
3291 |
+
if (n != oldN) {
|
3292 |
+
if (dir > 0) {
|
3293 |
+
if (index == view.length - 1) return null;
|
3294 |
+
diff = (n + view[index].size) - oldN;
|
3295 |
+
index++;
|
3296 |
+
} else {
|
3297 |
+
diff = n - oldN;
|
3298 |
+
}
|
3299 |
+
oldN += diff; newN += diff;
|
3300 |
+
}
|
3301 |
+
while (visualLineNo(cm.doc, newN) != newN) {
|
3302 |
+
if (index == (dir < 0 ? 0 : view.length - 1)) return null;
|
3303 |
+
newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
|
3304 |
+
index += dir;
|
3305 |
+
}
|
3306 |
+
return {index: index, lineN: newN};
|
3307 |
+
}
|
3308 |
+
|
3309 |
+
// Force the view to cover a given range, adding empty view element
|
3310 |
+
// or clipping off existing ones as needed.
|
3311 |
+
function adjustView(cm, from, to) {
|
3312 |
+
var display = cm.display, view = display.view;
|
3313 |
+
if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
|
3314 |
+
display.view = buildViewArray(cm, from, to);
|
3315 |
+
display.viewFrom = from;
|
3316 |
+
} else {
|
3317 |
+
if (display.viewFrom > from)
|
3318 |
+
display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
|
3319 |
+
else if (display.viewFrom < from)
|
3320 |
+
display.view = display.view.slice(findViewIndex(cm, from));
|
3321 |
+
display.viewFrom = from;
|
3322 |
+
if (display.viewTo < to)
|
3323 |
+
display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
|
3324 |
+
else if (display.viewTo > to)
|
3325 |
+
display.view = display.view.slice(0, findViewIndex(cm, to));
|
3326 |
+
}
|
3327 |
+
display.viewTo = to;
|
3328 |
+
}
|
3329 |
+
|
3330 |
+
// Count the number of lines in the view whose DOM representation is
|
3331 |
+
// out of date (or nonexistent).
|
3332 |
+
function countDirtyView(cm) {
|
3333 |
+
var view = cm.display.view, dirty = 0;
|
3334 |
+
for (var i = 0; i < view.length; i++) {
|
3335 |
+
var lineView = view[i];
|
3336 |
+
if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
|
3337 |
+
}
|
3338 |
+
return dirty;
|
3339 |
+
}
|
3340 |
+
|
3341 |
+
// EVENT HANDLERS
|
3342 |
+
|
3343 |
+
// Attach the necessary event handlers when initializing the editor
|
3344 |
+
function registerEventHandlers(cm) {
|
3345 |
+
var d = cm.display;
|
3346 |
+
on(d.scroller, "mousedown", operation(cm, onMouseDown));
|
3347 |
+
// Older IE's will not fire a second mousedown for a double click
|
3348 |
+
if (ie && ie_version < 11)
|
3349 |
+
on(d.scroller, "dblclick", operation(cm, function(e) {
|
3350 |
+
if (signalDOMEvent(cm, e)) return;
|
3351 |
+
var pos = posFromMouse(cm, e);
|
3352 |
+
if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
|
3353 |
+
e_preventDefault(e);
|
3354 |
+
var word = cm.findWordAt(pos);
|
3355 |
+
extendSelection(cm.doc, word.anchor, word.head);
|
3356 |
+
}));
|
3357 |
+
else
|
3358 |
+
on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
|
3359 |
+
// Some browsers fire contextmenu *after* opening the menu, at
|
3360 |
+
// which point we can't mess with it anymore. Context menu is
|
3361 |
+
// handled in onMouseDown for these browsers.
|
3362 |
+
if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
|
3363 |
+
|
3364 |
+
// Used to suppress mouse event handling when a touch happens
|
3365 |
+
var touchFinished, prevTouch = {end: 0};
|
3366 |
+
function finishTouch() {
|
3367 |
+
if (d.activeTouch) {
|
3368 |
+
touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000);
|
3369 |
+
prevTouch = d.activeTouch;
|
3370 |
+
prevTouch.end = +new Date;
|
3371 |
+
}
|
3372 |
+
};
|
3373 |
+
function isMouseLikeTouchEvent(e) {
|
3374 |
+
if (e.touches.length != 1) return false;
|
3375 |
+
var touch = e.touches[0];
|
3376 |
+
return touch.radiusX <= 1 && touch.radiusY <= 1;
|
3377 |
+
}
|
3378 |
+
function farAway(touch, other) {
|
3379 |
+
if (other.left == null) return true;
|
3380 |
+
var dx = other.left - touch.left, dy = other.top - touch.top;
|
3381 |
+
return dx * dx + dy * dy > 20 * 20;
|
3382 |
+
}
|
3383 |
+
on(d.scroller, "touchstart", function(e) {
|
3384 |
+
if (!isMouseLikeTouchEvent(e)) {
|
3385 |
+
clearTimeout(touchFinished);
|
3386 |
+
var now = +new Date;
|
3387 |
+
d.activeTouch = {start: now, moved: false,
|
3388 |
+
prev: now - prevTouch.end <= 300 ? prevTouch : null};
|
3389 |
+
if (e.touches.length == 1) {
|
3390 |
+
d.activeTouch.left = e.touches[0].pageX;
|
3391 |
+
d.activeTouch.top = e.touches[0].pageY;
|
3392 |
+
}
|
3393 |
+
}
|
3394 |
+
});
|
3395 |
+
on(d.scroller, "touchmove", function() {
|
3396 |
+
if (d.activeTouch) d.activeTouch.moved = true;
|
3397 |
+
});
|
3398 |
+
on(d.scroller, "touchend", function(e) {
|
3399 |
+
var touch = d.activeTouch;
|
3400 |
+
if (touch && !eventInWidget(d, e) && touch.left != null &&
|
3401 |
+
!touch.moved && new Date - touch.start < 300) {
|
3402 |
+
var pos = cm.coordsChar(d.activeTouch, "page"), range;
|
3403 |
+
if (!touch.prev || farAway(touch, touch.prev)) // Single tap
|
3404 |
+
range = new Range(pos, pos);
|
3405 |
+
else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
|
3406 |
+
range = cm.findWordAt(pos);
|
3407 |
+
else // Triple tap
|
3408 |
+
range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)));
|
3409 |
+
cm.setSelection(range.anchor, range.head);
|
3410 |
+
cm.focus();
|
3411 |
+
e_preventDefault(e);
|
3412 |
+
}
|
3413 |
+
finishTouch();
|
3414 |
+
});
|
3415 |
+
on(d.scroller, "touchcancel", finishTouch);
|
3416 |
+
|
3417 |
+
// Sync scrolling between fake scrollbars and real scrollable
|
3418 |
+
// area, ensure viewport is updated when scrolling.
|
3419 |
+
on(d.scroller, "scroll", function() {
|
3420 |
+
if (d.scroller.clientHeight) {
|
3421 |
+
setScrollTop(cm, d.scroller.scrollTop);
|
3422 |
+
setScrollLeft(cm, d.scroller.scrollLeft, true);
|
3423 |
+
signal(cm, "scroll", cm);
|
3424 |
+
}
|
3425 |
+
});
|
3426 |
+
|
3427 |
+
// Listen to wheel events in order to try and update the viewport on time.
|
3428 |
+
on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
|
3429 |
+
on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
|
3430 |
+
|
3431 |
+
// Prevent wrapper from ever scrolling
|
3432 |
+
on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
|
3433 |
+
|
3434 |
+
d.dragFunctions = {
|
3435 |
+
simple: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
|
3436 |
+
start: function(e){onDragStart(cm, e);},
|
3437 |
+
drop: operation(cm, onDrop)
|
3438 |
+
};
|
3439 |
+
|
3440 |
+
var inp = d.input.getField();
|
3441 |
+
on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
|
3442 |
+
on(inp, "keydown", operation(cm, onKeyDown));
|
3443 |
+
on(inp, "keypress", operation(cm, onKeyPress));
|
3444 |
+
on(inp, "focus", bind(onFocus, cm));
|
3445 |
+
on(inp, "blur", bind(onBlur, cm));
|
3446 |
+
}
|
3447 |
+
|
3448 |
+
function dragDropChanged(cm, value, old) {
|
3449 |
+
var wasOn = old && old != CodeMirror.Init;
|
3450 |
+
if (!value != !wasOn) {
|
3451 |
+
var funcs = cm.display.dragFunctions;
|
3452 |
+
var toggle = value ? on : off;
|
3453 |
+
toggle(cm.display.scroller, "dragstart", funcs.start);
|
3454 |
+
toggle(cm.display.scroller, "dragenter", funcs.simple);
|
3455 |
+
toggle(cm.display.scroller, "dragover", funcs.simple);
|
3456 |
+
toggle(cm.display.scroller, "drop", funcs.drop);
|
3457 |
+
}
|
3458 |
+
}
|
3459 |
+
|
3460 |
+
// Called when the window resizes
|
3461 |
+
function onResize(cm) {
|
3462 |
+
var d = cm.display;
|
3463 |
+
if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
|
3464 |
+
return;
|
3465 |
+
// Might be a text scaling operation, clear size caches.
|
3466 |
+
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
|
3467 |
+
d.scrollbarsClipped = false;
|
3468 |
+
cm.setSize();
|
3469 |
+
}
|
3470 |
+
|
3471 |
+
// MOUSE EVENTS
|
3472 |
+
|
3473 |
+
// Return true when the given mouse event happened in a widget
|
3474 |
+
function eventInWidget(display, e) {
|
3475 |
+
for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
|
3476 |
+
if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
|
3477 |
+
(n.parentNode == display.sizer && n != display.mover))
|
3478 |
+
return true;
|
3479 |
+
}
|
3480 |
+
}
|
3481 |
+
|
3482 |
+
// Given a mouse event, find the corresponding position. If liberal
|
3483 |
+
// is false, it checks whether a gutter or scrollbar was clicked,
|
3484 |
+
// and returns null if it was. forRect is used by rectangular
|
3485 |
+
// selections, and tries to estimate a character position even for
|
3486 |
+
// coordinates beyond the right of the text.
|
3487 |
+
function posFromMouse(cm, e, liberal, forRect) {
|
3488 |
+
var display = cm.display;
|
3489 |
+
if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null;
|
3490 |
+
|
3491 |
+
var x, y, space = display.lineSpace.getBoundingClientRect();
|
3492 |
+
// Fails unpredictably on IE[67] when mouse is dragged around quickly.
|
3493 |
+
try { x = e.clientX - space.left; y = e.clientY - space.top; }
|
3494 |
+
catch (e) { return null; }
|
3495 |
+
var coords = coordsChar(cm, x, y), line;
|
3496 |
+
if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
|
3497 |
+
var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
|
3498 |
+
coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
|
3499 |
+
}
|
3500 |
+
return coords;
|
3501 |
+
}
|
3502 |
+
|
3503 |
+
// A mouse down can be a single click, double click, triple click,
|
3504 |
+
// start of selection drag, start of text drag, new cursor
|
3505 |
+
// (ctrl-click), rectangle drag (alt-drag), or xwin
|
3506 |
+
// middle-click-paste. Or it might be a click on something we should
|
3507 |
+
// not interfere with, such as a scrollbar or widget.
|
3508 |
+
function onMouseDown(e) {
|
3509 |
+
var cm = this, display = cm.display;
|
3510 |
+
if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return;
|
3511 |
+
display.shift = e.shiftKey;
|
3512 |
+
|
3513 |
+
if (eventInWidget(display, e)) {
|
3514 |
+
if (!webkit) {
|
3515 |
+
// Briefly turn off draggability, to allow widgets to do
|
3516 |
+
// normal dragging things.
|
3517 |
+
display.scroller.draggable = false;
|
3518 |
+
setTimeout(function(){display.scroller.draggable = true;}, 100);
|
3519 |
+
}
|
3520 |
+
return;
|
3521 |
+
}
|
3522 |
+
if (clickInGutter(cm, e)) return;
|
3523 |
+
var start = posFromMouse(cm, e);
|
3524 |
+
window.focus();
|
3525 |
+
|
3526 |
+
switch (e_button(e)) {
|
3527 |
+
case 1:
|
3528 |
+
if (start)
|
3529 |
+
leftButtonDown(cm, e, start);
|
3530 |
+
else if (e_target(e) == display.scroller)
|
3531 |
+
e_preventDefault(e);
|
3532 |
+
break;
|
3533 |
+
case 2:
|
3534 |
+
if (webkit) cm.state.lastMiddleDown = +new Date;
|
3535 |
+
if (start) extendSelection(cm.doc, start);
|
3536 |
+
setTimeout(function() {display.input.focus();}, 20);
|
3537 |
+
e_preventDefault(e);
|
3538 |
+
break;
|
3539 |
+
case 3:
|
3540 |
+
if (captureRightClick) onContextMenu(cm, e);
|
3541 |
+
else delayBlurEvent(cm);
|
3542 |
+
break;
|
3543 |
+
}
|
3544 |
+
}
|
3545 |
+
|
3546 |
+
var lastClick, lastDoubleClick;
|
3547 |
+
function leftButtonDown(cm, e, start) {
|
3548 |
+
if (ie) setTimeout(bind(ensureFocus, cm), 0);
|
3549 |
+
else cm.curOp.focus = activeElt();
|
3550 |
+
|
3551 |
+
var now = +new Date, type;
|
3552 |
+
if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
|
3553 |
+
type = "triple";
|
3554 |
+
} else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
|
3555 |
+
type = "double";
|
3556 |
+
lastDoubleClick = {time: now, pos: start};
|
3557 |
+
} else {
|
3558 |
+
type = "single";
|
3559 |
+
lastClick = {time: now, pos: start};
|
3560 |
+
}
|
3561 |
+
|
3562 |
+
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
|
3563 |
+
if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
|
3564 |
+
type == "single" && (contained = sel.contains(start)) > -1 &&
|
3565 |
+
!sel.ranges[contained].empty())
|
3566 |
+
leftButtonStartDrag(cm, e, start, modifier);
|
3567 |
+
else
|
3568 |
+
leftButtonSelect(cm, e, start, type, modifier);
|
3569 |
+
}
|
3570 |
+
|
3571 |
+
// Start a text drag. When it ends, see if any dragging actually
|
3572 |
+
// happen, and treat as a click if it didn't.
|
3573 |
+
function leftButtonStartDrag(cm, e, start, modifier) {
|
3574 |
+
var display = cm.display, startTime = +new Date;
|
3575 |
+
var dragEnd = operation(cm, function(e2) {
|
3576 |
+
if (webkit) display.scroller.draggable = false;
|
3577 |
+
cm.state.draggingText = false;
|
3578 |
+
off(document, "mouseup", dragEnd);
|
3579 |
+
off(display.scroller, "drop", dragEnd);
|
3580 |
+
if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
|
3581 |
+
e_preventDefault(e2);
|
3582 |
+
if (!modifier && +new Date - 200 < startTime)
|
3583 |
+
extendSelection(cm.doc, start);
|
3584 |
+
// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
|
3585 |
+
if (webkit || ie && ie_version == 9)
|
3586 |
+
setTimeout(function() {document.body.focus(); display.input.focus();}, 20);
|
3587 |
+
else
|
3588 |
+
display.input.focus();
|
3589 |
+
}
|
3590 |
+
});
|
3591 |
+
// Let the drag handler handle this.
|
3592 |
+
if (webkit) display.scroller.draggable = true;
|
3593 |
+
cm.state.draggingText = dragEnd;
|
3594 |
+
// IE's approach to draggable
|
3595 |
+
if (display.scroller.dragDrop) display.scroller.dragDrop();
|
3596 |
+
on(document, "mouseup", dragEnd);
|
3597 |
+
on(display.scroller, "drop", dragEnd);
|
3598 |
+
}
|
3599 |
+
|
3600 |
+
// Normal selection, as opposed to text dragging.
|
3601 |
+
function leftButtonSelect(cm, e, start, type, addNew) {
|
3602 |
+
var display = cm.display, doc = cm.doc;
|
3603 |
+
e_preventDefault(e);
|
3604 |
+
|
3605 |
+
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
|
3606 |
+
if (addNew && !e.shiftKey) {
|
3607 |
+
ourIndex = doc.sel.contains(start);
|
3608 |
+
if (ourIndex > -1)
|
3609 |
+
ourRange = ranges[ourIndex];
|
3610 |
+
else
|
3611 |
+
ourRange = new Range(start, start);
|
3612 |
+
} else {
|
3613 |
+
ourRange = doc.sel.primary();
|
3614 |
+
ourIndex = doc.sel.primIndex;
|
3615 |
+
}
|
3616 |
+
|
3617 |
+
if (e.altKey) {
|
3618 |
+
type = "rect";
|
3619 |
+
if (!addNew) ourRange = new Range(start, start);
|
3620 |
+
start = posFromMouse(cm, e, true, true);
|
3621 |
+
ourIndex = -1;
|
3622 |
+
} else if (type == "double") {
|
3623 |
+
var word = cm.findWordAt(start);
|
3624 |
+
if (cm.display.shift || doc.extend)
|
3625 |
+
ourRange = extendRange(doc, ourRange, word.anchor, word.head);
|
3626 |
+
else
|
3627 |
+
ourRange = word;
|
3628 |
+
} else if (type == "triple") {
|
3629 |
+
var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
|
3630 |
+
if (cm.display.shift || doc.extend)
|
3631 |
+
ourRange = extendRange(doc, ourRange, line.anchor, line.head);
|
3632 |
+
else
|
3633 |
+
ourRange = line;
|
3634 |
+
} else {
|
3635 |
+
ourRange = extendRange(doc, ourRange, start);
|
3636 |
+
}
|
3637 |
+
|
3638 |
+
if (!addNew) {
|
3639 |
+
ourIndex = 0;
|
3640 |
+
setSelection(doc, new Selection([ourRange], 0), sel_mouse);
|
3641 |
+
startSel = doc.sel;
|
3642 |
+
} else if (ourIndex == -1) {
|
3643 |
+
ourIndex = ranges.length;
|
3644 |
+
setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
|
3645 |
+
{scroll: false, origin: "*mouse"});
|
3646 |
+
} else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
|
3647 |
+
setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0));
|
3648 |
+
startSel = doc.sel;
|
3649 |
+
} else {
|
3650 |
+
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
|
3651 |
+
}
|
3652 |
+
|
3653 |
+
var lastPos = start;
|
3654 |
+
function extendTo(pos) {
|
3655 |
+
if (cmp(lastPos, pos) == 0) return;
|
3656 |
+
lastPos = pos;
|
3657 |
+
|
3658 |
+
if (type == "rect") {
|
3659 |
+
var ranges = [], tabSize = cm.options.tabSize;
|
3660 |
+
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
|
3661 |
+
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
|
3662 |
+
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
|
3663 |
+
for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
|
3664 |
+
line <= end; line++) {
|
3665 |
+
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
|
3666 |
+
if (left == right)
|
3667 |
+
ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
|
3668 |
+
else if (text.length > leftPos)
|
3669 |
+
ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
|
3670 |
+
}
|
3671 |
+
if (!ranges.length) ranges.push(new Range(start, start));
|
3672 |
+
setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
3673 |
+
{origin: "*mouse", scroll: false});
|
3674 |
+
cm.scrollIntoView(pos);
|
3675 |
+
} else {
|
3676 |
+
var oldRange = ourRange;
|
3677 |
+
var anchor = oldRange.anchor, head = pos;
|
3678 |
+
if (type != "single") {
|
3679 |
+
if (type == "double")
|
3680 |
+
var range = cm.findWordAt(pos);
|
3681 |
+
else
|
3682 |
+
var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
|
3683 |
+
if (cmp(range.anchor, anchor) > 0) {
|
3684 |
+
head = range.head;
|
3685 |
+
anchor = minPos(oldRange.from(), range.anchor);
|
3686 |
+
} else {
|
3687 |
+
head = range.anchor;
|
3688 |
+
anchor = maxPos(oldRange.to(), range.head);
|
3689 |
+
}
|
3690 |
+
}
|
3691 |
+
var ranges = startSel.ranges.slice(0);
|
3692 |
+
ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
|
3693 |
+
setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
|
3694 |
+
}
|
3695 |
+
}
|
3696 |
+
|
3697 |
+
var editorSize = display.wrapper.getBoundingClientRect();
|
3698 |
+
// Used to ensure timeout re-tries don't fire when another extend
|
3699 |
+
// happened in the meantime (clearTimeout isn't reliable -- at
|
3700 |
+
// least on Chrome, the timeouts still happen even when cleared,
|
3701 |
+
// if the clear happens after their scheduled firing time).
|
3702 |
+
var counter = 0;
|
3703 |
+
|
3704 |
+
function extend(e) {
|
3705 |
+
var curCount = ++counter;
|
3706 |
+
var cur = posFromMouse(cm, e, true, type == "rect");
|
3707 |
+
if (!cur) return;
|
3708 |
+
if (cmp(cur, lastPos) != 0) {
|
3709 |
+
cm.curOp.focus = activeElt();
|
3710 |
+
extendTo(cur);
|
3711 |
+
var visible = visibleLines(display, doc);
|
3712 |
+
if (cur.line >= visible.to || cur.line < visible.from)
|
3713 |
+
setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
|
3714 |
+
} else {
|
3715 |
+
var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
|
3716 |
+
if (outside) setTimeout(operation(cm, function() {
|
3717 |
+
if (counter != curCount) return;
|
3718 |
+
display.scroller.scrollTop += outside;
|
3719 |
+
extend(e);
|
3720 |
+
}), 50);
|
3721 |
+
}
|
3722 |
+
}
|
3723 |
+
|
3724 |
+
function done(e) {
|
3725 |
+
counter = Infinity;
|
3726 |
+
e_preventDefault(e);
|
3727 |
+
display.input.focus();
|
3728 |
+
off(document, "mousemove", move);
|
3729 |
+
off(document, "mouseup", up);
|
3730 |
+
doc.history.lastSelOrigin = null;
|
3731 |
+
}
|
3732 |
+
|
3733 |
+
var move = operation(cm, function(e) {
|
3734 |
+
if (!e_button(e)) done(e);
|
3735 |
+
else extend(e);
|
3736 |
+
});
|
3737 |
+
var up = operation(cm, done);
|
3738 |
+
on(document, "mousemove", move);
|
3739 |
+
on(document, "mouseup", up);
|
3740 |
+
}
|
3741 |
+
|
3742 |
+
// Determines whether an event happened in the gutter, and fires the
|
3743 |
+
// handlers for the corresponding event.
|
3744 |
+
function gutterEvent(cm, e, type, prevent, signalfn) {
|
3745 |
+
try { var mX = e.clientX, mY = e.clientY; }
|
3746 |
+
catch(e) { return false; }
|
3747 |
+
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
|
3748 |
+
if (prevent) e_preventDefault(e);
|
3749 |
+
|
3750 |
+
var display = cm.display;
|
3751 |
+
var lineBox = display.lineDiv.getBoundingClientRect();
|
3752 |
+
|
3753 |
+
if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
|
3754 |
+
mY -= lineBox.top - display.viewOffset;
|
3755 |
+
|
3756 |
+
for (var i = 0; i < cm.options.gutters.length; ++i) {
|
3757 |
+
var g = display.gutters.childNodes[i];
|
3758 |
+
if (g && g.getBoundingClientRect().right >= mX) {
|
3759 |
+
var line = lineAtHeight(cm.doc, mY);
|
3760 |
+
var gutter = cm.options.gutters[i];
|
3761 |
+
signalfn(cm, type, cm, line, gutter, e);
|
3762 |
+
return e_defaultPrevented(e);
|
3763 |
+
}
|
3764 |
+
}
|
3765 |
+
}
|
3766 |
+
|
3767 |
+
function clickInGutter(cm, e) {
|
3768 |
+
return gutterEvent(cm, e, "gutterClick", true, signalLater);
|
3769 |
+
}
|
3770 |
+
|
3771 |
+
// Kludge to work around strange IE behavior where it'll sometimes
|
3772 |
+
// re-fire a series of drag-related events right after the drop (#1551)
|
3773 |
+
var lastDrop = 0;
|
3774 |
+
|
3775 |
+
function onDrop(e) {
|
3776 |
+
var cm = this;
|
3777 |
+
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
|
3778 |
+
return;
|
3779 |
+
e_preventDefault(e);
|
3780 |
+
if (ie) lastDrop = +new Date;
|
3781 |
+
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
|
3782 |
+
if (!pos || isReadOnly(cm)) return;
|
3783 |
+
// Might be a file drop, in which case we simply extract the text
|
3784 |
+
// and insert it.
|
3785 |
+
if (files && files.length && window.FileReader && window.File) {
|
3786 |
+
var n = files.length, text = Array(n), read = 0;
|
3787 |
+
var loadFile = function(file, i) {
|
3788 |
+
var reader = new FileReader;
|
3789 |
+
reader.onload = operation(cm, function() {
|
3790 |
+
text[i] = reader.result;
|
3791 |
+
if (++read == n) {
|
3792 |
+
pos = clipPos(cm.doc, pos);
|
3793 |
+
var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
|
3794 |
+
makeChange(cm.doc, change);
|
3795 |
+
setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
|
3796 |
+
}
|
3797 |
+
});
|
3798 |
+
reader.readAsText(file);
|
3799 |
+
};
|
3800 |
+
for (var i = 0; i < n; ++i) loadFile(files[i], i);
|
3801 |
+
} else { // Normal drop
|
3802 |
+
// Don't do a replace if the drop happened inside of the selected text.
|
3803 |
+
if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
|
3804 |
+
cm.state.draggingText(e);
|
3805 |
+
// Ensure the editor is re-focused
|
3806 |
+
setTimeout(function() {cm.display.input.focus();}, 20);
|
3807 |
+
return;
|
3808 |
+
}
|
3809 |
+
try {
|
3810 |
+
var text = e.dataTransfer.getData("Text");
|
3811 |
+
if (text) {
|
3812 |
+
if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey))
|
3813 |
+
var selected = cm.listSelections();
|
3814 |
+
setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
|
3815 |
+
if (selected) for (var i = 0; i < selected.length; ++i)
|
3816 |
+
replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
|
3817 |
+
cm.replaceSelection(text, "around", "paste");
|
3818 |
+
cm.display.input.focus();
|
3819 |
+
}
|
3820 |
+
}
|
3821 |
+
catch(e){}
|
3822 |
+
}
|
3823 |
+
}
|
3824 |
+
|
3825 |
+
function onDragStart(cm, e) {
|
3826 |
+
if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
|
3827 |
+
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
|
3828 |
+
|
3829 |
+
e.dataTransfer.setData("Text", cm.getSelection());
|
3830 |
+
|
3831 |
+
// Use dummy image instead of default browsers image.
|
3832 |
+
// Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
|
3833 |
+
if (e.dataTransfer.setDragImage && !safari) {
|
3834 |
+
var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
|
3835 |
+
img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
|
3836 |
+
if (presto) {
|
3837 |
+
img.width = img.height = 1;
|
3838 |
+
cm.display.wrapper.appendChild(img);
|
3839 |
+
// Force a relayout, or Opera won't use our image for some obscure reason
|
3840 |
+
img._top = img.offsetTop;
|
3841 |
+
}
|
3842 |
+
e.dataTransfer.setDragImage(img, 0, 0);
|
3843 |
+
if (presto) img.parentNode.removeChild(img);
|
3844 |
+
}
|
3845 |
+
}
|
3846 |
+
|
3847 |
+
// SCROLL EVENTS
|
3848 |
+
|
3849 |
+
// Sync the scrollable area and scrollbars, ensure the viewport
|
3850 |
+
// covers the visible area.
|
3851 |
+
function setScrollTop(cm, val) {
|
3852 |
+
if (Math.abs(cm.doc.scrollTop - val) < 2) return;
|
3853 |
+
cm.doc.scrollTop = val;
|
3854 |
+
if (!gecko) updateDisplaySimple(cm, {top: val});
|
3855 |
+
if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
|
3856 |
+
cm.display.scrollbars.setScrollTop(val);
|
3857 |
+
if (gecko) updateDisplaySimple(cm);
|
3858 |
+
startWorker(cm, 100);
|
3859 |
+
}
|
3860 |
+
// Sync scroller and scrollbar, ensure the gutter elements are
|
3861 |
+
// aligned.
|
3862 |
+
function setScrollLeft(cm, val, isScroller) {
|
3863 |
+
if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
|
3864 |
+
val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
|
3865 |
+
cm.doc.scrollLeft = val;
|
3866 |
+
alignHorizontally(cm);
|
3867 |
+
if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
|
3868 |
+
cm.display.scrollbars.setScrollLeft(val);
|
3869 |
+
}
|
3870 |
+
|
3871 |
+
// Since the delta values reported on mouse wheel events are
|
3872 |
+
// unstandardized between browsers and even browser versions, and
|
3873 |
+
// generally horribly unpredictable, this code starts by measuring
|
3874 |
+
// the scroll effect that the first few mouse wheel events have,
|
3875 |
+
// and, from that, detects the way it can convert deltas to pixel
|
3876 |
+
// offsets afterwards.
|
3877 |
+
//
|
3878 |
+
// The reason we want to know the amount a wheel event will scroll
|
3879 |
+
// is that it gives us a chance to update the display before the
|
3880 |
+
// actual scrolling happens, reducing flickering.
|
3881 |
+
|
3882 |
+
var wheelSamples = 0, wheelPixelsPerUnit = null;
|
3883 |
+
// Fill in a browser-detected starting value on browsers where we
|
3884 |
+
// know one. These don't have to be accurate -- the result of them
|
3885 |
+
// being wrong would just be a slight flicker on the first wheel
|
3886 |
+
// scroll (if it is large enough).
|
3887 |
+
if (ie) wheelPixelsPerUnit = -.53;
|
3888 |
+
else if (gecko) wheelPixelsPerUnit = 15;
|
3889 |
+
else if (chrome) wheelPixelsPerUnit = -.7;
|
3890 |
+
else if (safari) wheelPixelsPerUnit = -1/3;
|
3891 |
+
|
3892 |
+
var wheelEventDelta = function(e) {
|
3893 |
+
var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
|
3894 |
+
if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
|
3895 |
+
if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
|
3896 |
+
else if (dy == null) dy = e.wheelDelta;
|
3897 |
+
return {x: dx, y: dy};
|
3898 |
+
};
|
3899 |
+
CodeMirror.wheelEventPixels = function(e) {
|
3900 |
+
var delta = wheelEventDelta(e);
|
3901 |
+
delta.x *= wheelPixelsPerUnit;
|
3902 |
+
delta.y *= wheelPixelsPerUnit;
|
3903 |
+
return delta;
|
3904 |
+
};
|
3905 |
+
|
3906 |
+
function onScrollWheel(cm, e) {
|
3907 |
+
var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
|
3908 |
+
|
3909 |
+
var display = cm.display, scroll = display.scroller;
|
3910 |
+
// Quit if there's nothing to scroll here
|
3911 |
+
if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
|
3912 |
+
dy && scroll.scrollHeight > scroll.clientHeight)) return;
|
3913 |
+
|
3914 |
+
// Webkit browsers on OS X abort momentum scrolls when the target
|
3915 |
+
// of the scroll event is removed from the scrollable element.
|
3916 |
+
// This hack (see related code in patchDisplay) makes sure the
|
3917 |
+
// element is kept around.
|
3918 |
+
if (dy && mac && webkit) {
|
3919 |
+
outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
|
3920 |
+
for (var i = 0; i < view.length; i++) {
|
3921 |
+
if (view[i].node == cur) {
|
3922 |
+
cm.display.currentWheelTarget = cur;
|
3923 |
+
break outer;
|
3924 |
+
}
|
3925 |
+
}
|
3926 |
+
}
|
3927 |
+
}
|
3928 |
+
|
3929 |
+
// On some browsers, horizontal scrolling will cause redraws to
|
3930 |
+
// happen before the gutter has been realigned, causing it to
|
3931 |
+
// wriggle around in a most unseemly way. When we have an
|
3932 |
+
// estimated pixels/delta value, we just handle horizontal
|
3933 |
+
// scrolling entirely here. It'll be slightly off from native, but
|
3934 |
+
// better than glitching out.
|
3935 |
+
if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
|
3936 |
+
if (dy)
|
3937 |
+
setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
|
3938 |
+
setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
|
3939 |
+
e_preventDefault(e);
|
3940 |
+
display.wheelStartX = null; // Abort measurement, if in progress
|
3941 |
+
return;
|
3942 |
+
}
|
3943 |
+
|
3944 |
+
// 'Project' the visible viewport to cover the area that is being
|
3945 |
+
// scrolled into view (if we know enough to estimate it).
|
3946 |
+
if (dy && wheelPixelsPerUnit != null) {
|
3947 |
+
var pixels = dy * wheelPixelsPerUnit;
|
3948 |
+
var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
|
3949 |
+
if (pixels < 0) top = Math.max(0, top + pixels - 50);
|
3950 |
+
else bot = Math.min(cm.doc.height, bot + pixels + 50);
|
3951 |
+
updateDisplaySimple(cm, {top: top, bottom: bot});
|
3952 |
+
}
|
3953 |
+
|
3954 |
+
if (wheelSamples < 20) {
|
3955 |
+
if (display.wheelStartX == null) {
|
3956 |
+
display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
|
3957 |
+
display.wheelDX = dx; display.wheelDY = dy;
|
3958 |
+
setTimeout(function() {
|
3959 |
+
if (display.wheelStartX == null) return;
|
3960 |
+
var movedX = scroll.scrollLeft - display.wheelStartX;
|
3961 |
+
var movedY = scroll.scrollTop - display.wheelStartY;
|
3962 |
+
var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
|
3963 |
+
(movedX && display.wheelDX && movedX / display.wheelDX);
|
3964 |
+
display.wheelStartX = display.wheelStartY = null;
|
3965 |
+
if (!sample) return;
|
3966 |
+
wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
|
3967 |
+
++wheelSamples;
|
3968 |
+
}, 200);
|
3969 |
+
} else {
|
3970 |
+
display.wheelDX += dx; display.wheelDY += dy;
|
3971 |
+
}
|
3972 |
+
}
|
3973 |
+
}
|
3974 |
+
|
3975 |
+
// KEY EVENTS
|
3976 |
+
|
3977 |
+
// Run a handler that was bound to a key.
|
3978 |
+
function doHandleBinding(cm, bound, dropShift) {
|
3979 |
+
if (typeof bound == "string") {
|
3980 |
+
bound = commands[bound];
|
3981 |
+
if (
|