diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-03-13 17:55:22 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-08-15 19:46:35 +0200 |
| commit | 9fea58a7096be7920555123193567a607a014ab7 (patch) | |
| tree | fa75dcdc1ad4d24bd4eb78d849280c27b104aaa1 | |
| download | wvs-vplan-9fea58a7096be7920555123193567a607a014ab7.tar.gz wvs-vplan-9fea58a7096be7920555123193567a607a014ab7.zip | |
erster Commit
| -rw-r--r-- | COPYING | 662 | ||||
| -rw-r--r-- | config.xml | 97 | ||||
| -rw-r--r-- | css/OpenSans-SemiBold.ttf | bin | 0 -> 221328 bytes | |||
| -rw-r--r-- | css/brick-1.0.0.css | 1053 | ||||
| -rw-r--r-- | css/index.css | 38 | ||||
| -rw-r--r-- | index.html | 50 | ||||
| -rw-r--r-- | js/brick-1.0.0.js | 4081 | ||||
| -rw-r--r-- | js/index.js | 50 |
8 files changed, 6031 insertions, 0 deletions
@@ -0,0 +1,662 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +<http://www.gnu.org/licenses/>. + diff --git a/config.xml b/config.xml new file mode 100644 index 0000000..4cb944f --- /dev/null +++ b/config.xml @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- config.xml reference: https://build.phonegap.com/docs/config-xml --> +<widget xmlns = "http://www.w3.org/ns/widgets" + xmlns:gap = "http://phonegap.com/ns/1.0" + id = "***REMOVED***" + version = "1.0.0"> + + <name>WvS VPlan</name> + + <description> + WvS VPlan lädt den Vertretungsplan des Werner-von-Siemens-Gymnasiums vollautomatisch herunter. + </description> + + <author href="http://***REMOVED***"> + </author> + + <!-- + Enable individual API permissions here. + The "device" permission is required for the 'deviceready' event. + --> + <feature name="http://api.phonegap.com/1.0/device" /> + + <!-- + If you do not want any permissions to be added to your app, add the + following tag to your config.xml; you will still have the INTERNET + permission on your app, which PhoneGap requires. + --> + <preference name="permissions" value="none"/> + + <!-- Customize your app and platform with the preference element. --> + <!-- <preference name="phonegap-version" value="3.4.0" /> --> <!-- all: current version of PhoneGap --> + <preference name="orientation" value="default" /> <!-- all: default means both landscape and portrait are enabled --> + <preference name="target-device" value="universal" /> <!-- all: possible values handset, tablet, or universal --> + <preference name="fullscreen" value="false" /> <!-- all: hides the status bar at the top of the screen --> + <preference name="webviewbounce" value="true" /> <!-- ios: control whether the screen 'bounces' when scrolled beyond the top --> + <preference name="prerendered-icon" value="true" /> <!-- ios: if icon is prerendered, iOS will not apply it's gloss to the app's icon on the user's home screen --> + <preference name="stay-in-webview" value="false" /> <!-- ios: external links should open in the default browser, 'true' would use the webview the app lives in --> + <preference name="ios-statusbarstyle" value="black-opaque" /> <!-- ios: black-translucent will appear black because the PhoneGap webview doesn't go beneath the status bar --> + <preference name="detect-data-types" value="true" /> <!-- ios: controls whether data types (such as phone no. and dates) are automatically turned into links by the system --> + <preference name="exit-on-suspend" value="false" /> <!-- ios: if set to true, app will terminate when home button is pressed --> + <preference name="show-splash-screen-spinner" value="true" /> <!-- ios: if set to false, the spinner won't appear on the splash screen during app loading --> + <preference name="auto-hide-splash-screen" value="true" /> <!-- ios: if set to false, the splash screen must be hidden using a JavaScript API --> + <preference name="disable-cursor" value="false" /> <!-- blackberry: prevents a mouse-icon/cursor from being displayed on the app --> + <preference name="android-minSdkVersion" value="7" /> <!-- android: MIN SDK version supported on the target device. MAX version is blank by default. --> + <preference name="android-installLocation" value="auto" /> <!-- android: app install location. 'auto' will choose. 'internalOnly' is device memory. 'preferExternal' is SDCard. --> + + <!-- Plugins can also be added here. --> + <!-- + <gap:plugin name="Example" /> + A list of available plugins are available at https://build.phonegap.com/docs/plugins + --> + + <!-- Define app icon for each platform. --> + <icon src="icon.png" /> + <icon src="res/icon/android/icon-36-ldpi.png" gap:platform="android" gap:density="ldpi" /> + <icon src="res/icon/android/icon-48-mdpi.png" gap:platform="android" gap:density="mdpi" /> + <icon src="res/icon/android/icon-72-hdpi.png" gap:platform="android" gap:density="hdpi" /> + <icon src="res/icon/android/icon-96-xhdpi.png" gap:platform="android" gap:density="xhdpi" /> + <icon src="res/icon/blackberry/icon-80.png" gap:platform="blackberry" /> + <icon src="res/icon/blackberry/icon-80.png" gap:platform="blackberry" gap:state="hover"/> + <icon src="res/icon/ios/icon-57.png" gap:platform="ios" width="57" height="57" /> + <icon src="res/icon/ios/icon-72.png" gap:platform="ios" width="72" height="72" /> + <icon src="res/icon/ios/icon-57-2x.png" gap:platform="ios" width="114" height="114" /> + <icon src="res/icon/ios/icon-72-2x.png" gap:platform="ios" width="144" height="144" /> + <icon src="res/icon/webos/icon-64.png" gap:platform="webos" /> + <icon src="res/icon/windows-phone/icon-48.png" gap:platform="winphone" /> + <icon src="res/icon/windows-phone/icon-173.png" gap:platform="winphone" gap:role="background" /> + + <!-- Define app splash screen for each platform. --> + <gap:splash src="res/screen/android/screen-ldpi-portrait.png" gap:platform="android" gap:density="ldpi" /> + <gap:splash src="res/screen/android/screen-mdpi-portrait.png" gap:platform="android" gap:density="mdpi" /> + <gap:splash src="res/screen/android/screen-hdpi-portrait.png" gap:platform="android" gap:density="hdpi" /> + <gap:splash src="res/screen/android/screen-xhdpi-portrait.png" gap:platform="android" gap:density="xhdpi" /> + <gap:splash src="res/screen/blackberry/screen-225.png" gap:platform="blackberry" /> + <gap:splash src="res/screen/ios/screen-iphone-portrait.png" gap:platform="ios" width="320" height="480" /> + <gap:splash src="res/screen/ios/screen-iphone-portrait-2x.png" gap:platform="ios" width="640" height="960" /> + <gap:splash src="res/screen/ios/screen-ipad-portrait.png" gap:platform="ios" width="768" height="1024" /> + <gap:splash src="res/screen/ios/screen-ipad-landscape.png" gap:platform="ios" width="1024" height="768" /> + <gap:splash src="res/screen/windows-phone/screen-portrait.jpg" gap:platform="winphone" /> + + <!-- + Define access to external domains. + + <access /> - a blank access tag denies access to all external resources. + <access origin="*" /> - a wildcard access tag allows access to all external resource. + + Otherwise, you can specify specific domains: + --> + <access origin="*"/> <!-- allow everything TODO DEBUG--> + <!-- + <access origin="http://phonegap.com" /> - allow any secure requests to http://phonegap.com/ + <access origin="http://phonegap.com" subdomains="true" /> - same as above, but including subdomains, such as http://build.phonegap.com/ + <access origin="http://phonegap.com" browserOnly="true" /> - only allows http://phonegap.com to be opened by the child browser. + --> + +</widget> diff --git a/css/OpenSans-SemiBold.ttf b/css/OpenSans-SemiBold.ttf Binary files differnew file mode 100644 index 0000000..1a7679e --- /dev/null +++ b/css/OpenSans-SemiBold.ttf diff --git a/css/brick-1.0.0.css b/css/brick-1.0.0.css new file mode 100644 index 0000000..628e6cc --- /dev/null +++ b/css/brick-1.0.0.css @@ -0,0 +1,1053 @@ +x-appbar { + padding: 0; + width: 100%; + display: -webkit-box; + display: -moz-box; + display: -ms-flexbox; + display: -webkit-flex; + display: flex; +} +x-appbar, +x-appbar * { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +x-appbar > * { + border: none; + vertical-align: middle; + text-align: center; + -webkit-flex-align: center; + -ms-flex-align: center; + -webkit-align-items: center; + -webkit-align-items: center; + -moz-align-items: center; + -ms-align-items: center; + align-items: center; + text-align: center; +} +x-appbar > h1, +x-appbar h2, +x-appbar h3, +x-appbar h4, +x-appbar h5, +x-appbar h6 { + min-width: auto; + min-height: auto; + -webkit-box-flex: 1; + -moz-box-flex: 1; + -webkit-flex: 1; + -ms-flex: 1; + box-flex: 1; + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + margin: 0; +} + +x-calendar { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + -webkit-tap-highlight-color: transparent; + -moz-tap-highlight-color: transparent; + tap-highlight-color: transparent; + position: relative; + display: inline-block; + margin: 0; + padding: 0; + max-width: 100%; + font-size: 1em; + text-align: center; + overflow: hidden; +} +x-calendar, +x-calendar * { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +x-calendar .calendar { + position: relative; + display: inline-block; + overflow: hidden; + width: 100%; + height: 100%; +} +x-calendar .month { + display: inline-block; + margin: 0; + padding: 0; + vertical-align: top; + white-space: nowrap; + width: 224px; + max-width: 100%; +} +x-calendar .week, +x-calendar .weekday-labels { + margin: 1px 0; + overflow: visible; + width: 100%; + white-space: nowrap; +} +x-calendar .day, +x-calendar .prev, +x-calendar .next, +x-calendar .weekday-label { + display: inline-block; + width: 32px; +} +x-calendar .month-label, +x-calendar .weekday-labels, +x-calendar .week, +x-calendar .prev, +x-calendar .next { + height: 2em; + line-height: 2em; +} +x-calendar .weekday-label { + opacity: 0.8; + font-size: 0.8em; +} +x-calendar .weekday-label, +x-calendar .day { + height: 100%; + line-height: inherit; + margin: 0 auto; +} +x-calendar .month-label { + width: 100%; +} +x-calendar .day { + position: relative; + white-space: nowrap; +} +x-calendar .badmonth { + opacity: 0.5; +} +x-calendar:not([controls]) .controls { + display: none !important; +} +x-calendar[controls] .controls { + display: block; +} +x-calendar .prev, +x-calendar .next { + position: absolute; + top: 0px; + max-width: 3em; +} +x-calendar .prev { + left: 0px; +} +x-calendar .next { + right: 0px; +} +x-calendar:not([active]) .day:hover, +x-calendar:not([active]) .prev:hover, +x-calendar:not([active]) .next:hover { + cursor: pointer; +} + +x-deck { + display: block; + position: relative; + overflow: hidden; + height: 100%; + width: 100%; +} +x-deck > x-card { + display: none; + position: absolute !important; + left: 0; + right: 0; + height: 100%; + width: 100%; + overflow: hidden; + z-index: 0; + opacity: 1; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + -webkit-transform-style: preserve-3d; + -moz-transform-style: preserve-3d; + -ms-transform-style: preserve-3d; + -o-transform-style: preserve-3d; + transform-style: preserve-3d; + -webkit-transform: translate(0%, 0%) scale(1); + -moz-transform: translate(0%, 0%) scale(1); + -ms-transform: translate(0%, 0%) scale(1); + -o-transform: translate(0%, 0%) scale(1); + transform: translate(0%, 0%) scale(1); +} +x-deck > x-card[selected], +x-deck > x-card[transition] { + display: block; +} +/*** Fade 'n' Scale ***/ +x-deck[transition-type="fade-scale"] > x-card, +x-deck > x-card[transition-type="fade-scale"] { + opacity: 0; + -webkit-transform: scale(0.85); + -moz-transform: scale(0.85); + -ms-transform: scale(0.85); + -o-transform: scale(0.85); + transform: scale(0.85); + -webkit-transition: opacity 0.5s ease, -webkit-transform 0.5s ease; + -moz-transition: opacity 0.5s ease, -moz-transform 0.5s ease; + -ms-transition: opacity 0.5s ease, -ms-transform 0.5s ease; + -o-transition: opacity 0.5s ease, -o-transform 0.5s ease; + transition: opacity 0.5s ease, transform 0.5s ease; +} +x-deck > x-card[show][transition] { + opacity: 1; + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); +} +/*** General Slide Setup ***/ +x-deck[transition-type^="slide"] > x-card, +x-deck > x-card[transition-type^="slide"] { + z-index: 1; +} +x-deck[transition-type^="slide"] > x-card[transition-direction="reverse"], +x-deck > x-card[transition-type^="slide"][transition-direction="reverse"] { + z-index: 2; +} +x-deck[transition-type^="slide"] > x-card[show], +x-deck > x-card[show][transition-type^="slide"], +x-deck[transition-type^="slide"] > x-card[hide], +x-deck > x-card[hide][transition-type^="slide"] { + -webkit-transition: -webkit-transform 0.4s ease; + -moz-transition: -moz-transform 0.4s ease; + -ms-transition: -ms-transform 0.4s ease; + -o-transition: -o-transform 0.4s ease; + transition: transform 0.4s ease; +} +/*** Right/Left Slide Styles ***/ +x-deck[transition-type="slide-right"] > x-card[show][transition-direction="forward"], +x-deck > x-card[show][transition-direction="forward"][transition-type="slide-right"], +x-deck[transition-type="slide-right"] > x-card[hide][transition-direction="reverse"], +x-deck > x-card[hide][transition-direction="reverse"][transition-type="slide-right"], +x-deck[transition-type="slide-left"] > x-card[show][transition-direction="reverse"], +x-deck > x-card[show][transition-direction="reverse"][transition-type="slide-left"], +x-deck[transition-type="slide-left"] > x-card[hide][transition-direction="forward"], +x-deck > x-card[hide][transition-direction="forward"][transition-type="slide-left"] { + -webkit-transform: translate(-100%, 0); + -moz-transform: translate(-100%, 0); + -ms-transform: translate(-100%, 0); + -o-transform: translate(-100%, 0); + transform: translate(-100%, 0); +} +x-deck[transition-type="slide-right"] > x-card[show][transition-direction="reverse"], +x-deck > x-card[show][transition-direction="reverse"][transition-type="slide-right"], +x-deck[transition-type="slide-right"] > x-card[hide][transition-direction="forward"], +x-deck > x-card[hide][transition-direction="forward"][transition-type="slide-right"], +x-deck[transition-type="slide-left"] > x-card[show][transition-direction="forward"], +x-deck > x-card[show][transition-direction="forward"][transition-type="slide-left"], +x-deck[transition-type="slide-left"] > x-card[hide][transition-direction="reverse"], +x-deck > x-card[hide][transition-direction="reverse"][transition-type="slide-left"] { + -webkit-transform: translate(100%, 0); + -moz-transform: translate(100%, 0); + -ms-transform: translate(100%, 0); + -o-transform: translate(100%, 0); + transform: translate(100%, 0); +} +/*** Up/Down Slide Styles ***/ +x-deck[transition-type="slide-up"] > x-card[show][transition-direction="reverse"], +x-deck > x-card[show][transition-direction="reverse"][transition-type="slide-up"], +x-deck[transition-type="slide-up"] > x-card[hide][transition-direction="forward"], +x-deck > x-card[hide][transition-direction="forward"][transition-type="slide-up"], +x-deck[transition-type="slide-down"] > x-card[show][transition-direction="forward"], +x-deck > x-card[show][transition-direction="forward"][transition-type="slide-down"], +x-deck[transition-type="slide-down"] > x-card[hide][transition-direction="reverse"], +x-deck > x-card[hide][transition-direction="reverse"][transition-type="slide-down"] { + -webkit-transform: translate(0, -100%); + -moz-transform: translate(0, -100%); + -ms-transform: translate(0, -100%); + -o-transform: translate(0, -100%); + transform: translate(0, -100%); +} +x-deck[transition-type="slide-up"] > x-card[show][transition-direction="forward"], +x-deck > x-card[show][transition-direction="forward"][transition-type="slide-up"], +x-deck[transition-type="slide-up"] > x-card[hide][transition-direction="reverse"], +x-deck > x-card[hide][transition-direction="reverse"][transition-type="slide-up"], +x-deck[transition-type="slide-down"] > x-card[show][transition-direction="reverse"], +x-deck > x-card[show][transition-direction="reverse"][transition-type="slide-down"], +x-deck[transition-type="slide-down"] > x-card[hide][transition-direction="forward"], +x-deck > x-card[hide][transition-direction="forward"][transition-type="slide-down"] { + -webkit-transform: translate(0, 100%); + -moz-transform: translate(0, 100%); + -ms-transform: translate(0, 100%); + -o-transform: translate(0, 100%); + transform: translate(0, 100%); +} +/*** General Slide Show State ***/ +x-deck[transition-type^="slide"] > x-card[show][transition], +x-deck > x-card[show][transition][transition-type^="slide"] { + -webkit-transform: translate(0%, 0%); + -moz-transform: translate(0%, 0%); + -ms-transform: translate(0%, 0%); + -o-transform: translate(0%, 0%); + transform: translate(0%, 0%); +} + +x-flipbox { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: block; + position: relative; + height: 100%; + width: 100%; + -webkit-transform-style: preserve-3d; + -moz-transform-style: preserve-3d; + -ms-transform-style: preserve-3d; + -o-transform-style: preserve-3d; + transform-style: preserve-3d; +} +x-flipbox > * { + display: block; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + -webkit-backface-visibility: hidden; + -moz-backface-visibility: hidden; + -ms-backface-visibility: hidden; + -o-backface-visibility: hidden; + backface-visibility: hidden; + -webkit-transition-property: -webkit-transform; + -moz-transition-property: -moz-transform; + -ms-transition-property: -ms-transform; + -o-transition-property: -o-transform; + transition-property: transform; + -webkit-transition-duration: 0.25s; + -moz-transition-duration: 0.25s; + -ms-transition-duration: 0.25s; + -o-transition-duration: 0.25s; + transition-duration: 0.25s; + -webkit-transition-timing-function: linear; + -moz-transition-timing-function: linear; + -ms-transition-timing-function: linear; + -o-transition-timing-function: linear; + transition-timing-function: linear; + -webkit-transition-delay: 0s; + -moz-transition-delay: 0s; + -ms-transition-delay: 0s; + -o-transition-delay: 0s; + transition-delay: 0s; +/* DO NOT ERASE THESE TRANSFORM-STYLES; they fix a flickering issue in FFOS*/ + -webkit-transform-style: preserve-3d; + -moz-transform-style: preserve-3d; + -ms-transform-style: preserve-3d; + -o-transform-style: preserve-3d; + transform-style: preserve-3d; +} +x-flipbox > *:first-child { + -webkit-transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 2px); + -moz-transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 2px); + -ms-transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 2px); + -o-transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 2px); + transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 2px); + z-index: 2; +} +x-flipbox > *:last-child { + -webkit-transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 1px); + -moz-transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 1px); + -ms-transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 1px); + -o-transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 1px); + transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 1px); + z-index: 1; +} +x-flipbox[_anim-direction="up"] > *:first-child, +x-flipbox[_anim-direction="down"] > *:first-child { + -webkit-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 2px); + -moz-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 2px); + -ms-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 2px); + -o-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 2px); + transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 2px); +} +x-flipbox[_anim-direction="up"] > *:last-child { + -webkit-transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 1px); + -moz-transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 1px); + -ms-transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 1px); + -o-transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 1px); + transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 1px); +} +x-flipbox[_anim-direction="down"] > *:last-child { + -webkit-transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 1px); + -moz-transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 1px); + -ms-transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 1px); + -o-transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 1px); + transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 1px); +} +x-flipbox[flipped]:after { +/* DO NOT ERASE THIS :after SELECTOR */ + content: ""; + display: none; +} +x-flipbox[flipped] > *:first-child { + -webkit-transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 2px); + -moz-transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 2px); + -ms-transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 2px); + -o-transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 2px); + transform: perspective(800px) rotateY(180deg) translate3d(0px, 0px, 2px); + z-index: 1; +} +x-flipbox[flipped] > *:last-child { + -webkit-transform: perspective(800px) rotateY(360deg) translate3d(0px, 0px, 1px); + -moz-transform: perspective(800px) rotateY(360deg) translate3d(0px, 0px, 1px); + -ms-transform: perspective(800px) rotateY(360deg) translate3d(0px, 0px, 1px); + -o-transform: perspective(800px) rotateY(360deg) translate3d(0px, 0px, 1px); + transform: perspective(800px) rotateY(360deg) translate3d(0px, 0px, 1px); + z-index: 2; +} +x-flipbox[_anim-direction="left"][flipped] > *:first-child { + -webkit-transform: perspective(800px) rotateY(-180deg) translate3d(0px, 0px, 2px); + -moz-transform: perspective(800px) rotateY(-180deg) translate3d(0px, 0px, 2px); + -ms-transform: perspective(800px) rotateY(-180deg) translate3d(0px, 0px, 2px); + -o-transform: perspective(800px) rotateY(-180deg) translate3d(0px, 0px, 2px); + transform: perspective(800px) rotateY(-180deg) translate3d(0px, 0px, 2px); +} +x-flipbox[_anim-direction="left"][flipped] > *:last-child { + -webkit-transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 1px); + -moz-transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 1px); + -ms-transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 1px); + -o-transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 1px); + transform: perspective(800px) rotateY(0deg) translate3d(0px, 0px, 1px); +} +x-flipbox[_anim-direction="up"][flipped] > *:first-child { + -webkit-transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 2px); + -moz-transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 2px); + -ms-transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 2px); + -o-transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 2px); + transform: perspective(800px) rotateX(180deg) translate3d(0px, 0px, 2px); +} +x-flipbox[_anim-direction="up"][flipped] > *:last-child { + -webkit-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); + -moz-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); + -ms-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); + -o-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); + transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); +} +x-flipbox[_anim-direction="down"][flipped] > *:first-child { + -webkit-transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 2px); + -moz-transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 2px); + -ms-transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 2px); + -o-transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 2px); + transform: perspective(800px) rotateX(-180deg) translate3d(0px, 0px, 2px); +} +x-flipbox[_anim-direction="down"][flipped] > *:last-child { + -webkit-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); + -moz-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); + -ms-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); + -o-transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); + transform: perspective(800px) rotateX(0deg) translate3d(0px, 0px, 1px); +} + +x-layout { +/* relative positioning is important because x-layout should really be + * placed in a parent container for it to fill; + * also, setting position:absolute causes older flexbox implementations, + * such as Firefox 18 (which is the version in FirefoxOS) to render + * flex items in a way such that it won't override a height:0 declaration, + * which is important for allowing the flex item to shrink past its + * content size */ + position: relative !important; + display: -webkit-box; +/* OLD - iOS 6-, Safari 3.1-6 */ + display: -moz-box; +/* OLD - Firefox 19- (buggy but mostly works) */ + display: -ms-flexbox; +/* TWEENER - IE 10 */ + display: -webkit-flex; +/* NEW - Chrome */ + display: flex; +/* NEW, Spec - Opera 12.1, Firefox 20+ */ + width: 100%; + height: 100%; + overflow: hidden; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + -webkit-box-orient: vertical; + -moz-box-orient: vertical; + -ms-box-orient: vertical; + box-orient: vertical; + -webkit-flex-direction: column; + -moz-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; +} +x-layout > header, +x-layout > footer { + margin: 0 !important; + overflow: hidden; + z-index: 1; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + -webkit-transform: translateZ(0); + -moz-transform: translateZ(0); + -ms-transform: translateZ(0); + transform: translateZ(0); +} +x-layout > header, +x-layout > footer { + -webkit-transition: -webkit-transform 0.2s ease-in-out; + -moz-transition: -moz-transform 0.2s ease-in-out; + -ms-transition: -ms-transform 0.2s ease-in-out; + transition: transform 0.2s ease-in-out; +} +x-layout > section { + -webkit-box-flex: 1; + -moz-box-flex: 1; + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; + -webkit-transition: margin 0.2s ease-in-out; + -moz-transition: margin 0.2s ease-in-out; + -ms-transition: margin 0.2s ease-in-out; + transition: margin 0.2s ease-in-out; + -webkit-transform: translateZ(0); + -moz-transform: translateZ(0); + -ms-transform: translateZ(0); + transform: translateZ(0); + overflow: auto; +/* DON'T ERASE THIS: although this gets overridden by the flex display + * render, this fixes an issue with older browsers (ex: FF18) where unless + * a flex item was height 0, it would refuse to shrink past the auto + * height of the content, preventing the scrollbar from appearing */ + height: 0; + position: relative; +} +x-layout:not([content-maximizing]):not([maxcontent]) > section { + margin: 0 !important; +} +x-layout > section > *:only-child { +/* fix for issue where 100% height children of flex items render as zero + * height in Webkit + * see: http://stackoverflow.com/a/15389545 + */ + height: 100%; + position: absolute; +} +x-layout[hide-trigger] > header, +x-layout[hide-trigger] > footer, +x-layout[content-maximizing] > header, +x-layout[content-maximized] > header, +x-layout[maxcontent] > header, +x-layout[content-maximizing] > footer, +x-layout[content-maximized] > footer, +x-layout[maxcontent] > footer { + position: absolute; + width: 100%; +} +x-layout[hide-trigger] > footer, +x-layout[content-maximizing] > footer, +x-layout[content-maximized] > footer, +x-layout[maxcontent] > footer { + bottom: 0; +} +x-layout[content-maximizing] > header, +x-layout[content-maximized] > header, +x-layout[maxcontent] > header { + -webkit-transform: translateY(-100%); + -moz-transform: translateY(-100%); + -ms-transform: translateY(-100%); + transform: translateY(-100%); +} +x-layout[content-maximizing] > footer, +x-layout[content-maximized] > footer, +x-layout[maxcontent] > footer { + -webkit-transform: translateY(100%); + -moz-transform: translateY(100%); + -ms-transform: translateY(100%); + transform: translateY(100%); +} + +x-slider { + display: inline-block; + position: relative; + margin: 0; + padding: 0; +} +x-slider > input { + margin: 0; + padding: 0; + position: relative; + overflow: hidden; + vertical-align: middle; + width: 100%; + min-height: 100%; +} +x-slider .slider-track { + position: absolute; + display: block; + left: 0; + right: 0; + bottom: 0; + top: 0; + width: 100%; + height: 4px; + margin: auto; + pointer-events: none; +} +x-slider .slider-thumb { + cursor: default; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + -webkit-tap-highlight-color: transparent; + -moz-tap-highlight-color: transparent; + tap-highlight-color: transparent; + vertical-align: middle; + position: absolute !important; + top: 0; + left: 0; + width: 32px; + height: 32px; + margin: 0; + padding: 0; +} +x-slider[polyfill] { + cursor: default; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + -webkit-tap-highlight-color: transparent; + -moz-tap-highlight-color: transparent; + tap-highlight-color: transparent; +} +x-slider[polyfill] > input { + cursor: default; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + -webkit-tap-highlight-color: transparent; + -moz-tap-highlight-color: transparent; + tap-highlight-color: transparent; + display: block; + position: relative; +} +x-slider[polyfill] > input::-webkit-slider-thumb { + visibility: hidden; +} +x-slider[polyfill] > input::-moz-range-thumb { + width: 0px; + height: 0px; +} +x-slider[polyfill] > input::-moz-range-track { + height: 0; + width: 0; +} +x-slider:not([polyfill]) > .slider-thumb { + visibility: hidden !important; +} + +x-tabbar { + display: block; + display: -webkit-box; + display: -moz-box; + display: -ms-flexbox; + display: -webkit-flex; + display: flex; + width: 100%; + overflow: hidden; + white-space: nowrap; + text-align: center; +} +x-tabbar > x-tabbar-tab { + min-width: auto; + min-height: auto; + -webkit-box-flex: 1; + -moz-box-flex: 1; + -webkit-flex: 1; + -ms-flex: 1; + box-flex: 1; + flex: 1; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: inline-block; + min-width: auto; + min-height: auto; + vertical-align: middle; +} +x-tabbar > x-tabbar-tab > *:only-child { + vertical-align: top; + height: 100%; + width: 100%; + margin: 0 !important; +} + +x-toggle { + display: inline-block; + cursor: pointer; +} +x-toggle[focus] { + outline: 1px dashed rgba(0,0,0,0.3); +} +x-toggle[no-box] .x-toggle-check { + display: none; +} +x-toggle input:checked + .x-toggle-check { + background: #000; +} +x-toggle[type="radio"] .x-toggle-check { + -webkit-border-radius: 1em; + -moz-border-radius: 1em; + border-radius: 1em; +} +x-toggle:after { + content: attr(label); + display: inline-block; + vertical-align: middle; +} +x-toggle .x-toggle-check { + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 16px; + height: 16px; + margin: 0px 3px 0px 0px; + color: #000; + vertical-align: middle; + border: 1px solid; + overflow: hidden !important; +} +x-toggle input { + position: absolute; + outline: none; + z-index: -1; +/* do not remove visibility or display because we still want tab-ability */ + opacity: 0.0001 !important; +} +x-togglebar { + display: -webkit-box; + display: -moz-box; + display: -ms-flexbox; + display: -webkit-flex; + display: flex; + border: 1px solid #000; + border-radius: 4px; + clear: both; +} +x-togglebar x-toggle { + display: -webkit-box; + display: -moz-box; + display: -ms-flexbox; + display: -webkit-flex; + display: flex; + padding: 1px 4px 2px; + border-left: inherit; + text-align: center; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-box-flex: 1; + -moz-box-flex: 1; + -webkit-flex: 1; + -ms-flex: 1; + box-flex: 1; + flex: 1; + -webkit-box-align: center; + -moz-box-align: center; + -ms-flex-align: center; + -webkit-align-items: center; + align-items: center; + -webkit-box-pack: center; + -moz-box-pack: center; + -ms-flex-pack: center; + -webkit-justify-content: center; + justify-content: center; +} +x-togglebar x-toggle:first-child { + border-left-color: transparent; +} +x-togglebar x-toggle[checked] { + background: rgba(0,0,0,0.2); +} +x-togglebar x-toggle[focus] { + -webkit-box-shadow: 0 0 2px 0 transparent; + -moz-box-shadow: 0 0 2px 0 transparent; + box-shadow: 0 0 2px 0 transparent; +} +x-togglebar x-toggle .x-toggle-check { + height: 10px; + width: 10px; +} +x-togglebar x-toggle[type="checkbox"] .x-toggle-check { + display: none; +} +x-togglebar[orientation="vertical"] { + -webkit-box-orient: vertical; + -moz-box-orient: vertical; + -ms-box-orient: vertical; + box-orient: vertical; + -webkit-flex-direction: column; + -moz-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; +} +x-togglebar[orientation="vertical"] x-toggle { + border-top: inherit; + border-left: none; +} +x-togglebar[orientation="vertical"] x-toggle:first-child { + border-top: none; +} + +x-appbar { + background-color: #00202f; + color: #fff; + font-family: "Fira Sans", "Fira Sans", "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; + font-size: 17px; + height: 45px; + line-height: 45px; +} +x-appbar > header { + font-weight: 600; +} +x-appbar > * { + color: #fff; + font-family: "Fira Sans", "Fira Sans", "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; + font-size: inherit; + line-height: inherit; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +x-appbar > button { + cursor: pointer; + padding-left: 2px; + padding-right: 2px; + min-width: 45px; + background: transparent; +} +x-appbar > button:hover { + background-color: #00405d; +} +x-appbar > button::-moz-focus-inner { + border: 0; + padding: 0; +} +x-appbar > header:after { + padding-left: 6px; + font-size: 60%; +} + +x-calendar { + border: 1px solid #cecece; + border-radius: 3px; + font-size: 1em; + font-family: "Fira Sans", "Fira Sans", "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; + background-color: #fff; + color: #444; +} +x-calendar .weekday-label { + opacity: 0.8; +} +x-calendar .month-label { + border-bottom: 1px solid #cecece; +} +x-calendar .day[active] { + border-color: #ffa500; +} +x-calendar .day.chosen { + background: #0095dd; + color: #fff; +} +x-calendar .day.today { + font-weight: bold; +} +x-calendar:not([active]) .prev:hover, +x-calendar:not([active]) .next:hover { + background-color: #f9f9f9; + opacity: 0.7; +} +x-calendar:not([active]) .day:not(.chosen):hover { + background: #ccc; +} + +html, +body { + min-height: 100%; +} + +x-slider { + height: 27px; +} +x-slider:not([polyfill]) .slider-thumb { + display: none; +} +x-slider:not([polyfill]) input { + z-index: 1; +} +x-slider[polyfill] input { + visibility: hidden; +} +x-slider .slider-progress { + position: absolute; + top: 0; + left: 0; + height: 100%; + border-radius: 3px; + background: #0095dd; +} +x-slider .slider-thumb, +x-slider input[type='range']::-webkit-slider-thumb { + background: #fff; + -webkit-appearance: none; + border-radius: 13px; + border: 1px solid #acacac; + box-shadow: 0px 0.5px 1px 0px rgba(0,0,0,0.2); + cursor: pointer; + display: block; + height: 25px; + width: 25px; +} +x-slider .slider-thumb, +x-slider input[type='range']::-moz-range-thumb { + background: #fff; + -moz-appearance: none; + border-radius: 13px; + border: 1px solid #acacac; + box-shadow: 0px 0.5px 1px 0px rgba(0,0,0,0.2); + cursor: pointer; + display: block; + height: 25px; + width: 25px; +} +x-slider .slider-track { + background: #d8d8d8; + border-radius: 3px; + height: 2px; + overflow: hidden; +} +x-slider input[type=range]::-moz-range-track { + -moz-appearance: none; + background: #d8d8d8; + border: 0 !important; + outline: 0; + border-radius: 3px; + height: 2px; + box-shadow: 0 none; +} +x-slider input[type=range]::-moz-range-progress { + background: #0095dd; + border-radius: 3px; +} +x-slider input { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + background: transparent; + border: 0px solid transparent; + color: transparent; +} + +x-tabbar { + background: #00202f; + color: #fff; + font-family: "Fira Sans", "Fira Sans", "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; + height: 45px; + line-height: 45px; +} +x-tabbar > x-tabbar-tab { + letter-spacing: normal; + overflow: hidden; + cursor: pointer; +} +x-tabbar > x-tabbar-tab:hover { + background-color: #00405d; + color: #eaeaea; +} +x-tabbar > x-tabbar-tab:active { + color: #f2f2f2; +} +x-tabbar > x-tabbar-tab > x-iconbutton:only-child { + border: 0; +} + +x-toggle[focus] { + outline: 0; +} +x-toggle .x-toggle-content { + min-height: 22px; + line-height: 24px; +} +x-toggle .x-toggle-check { + width: 22px; + height: 22px; + border-radius: 3px; + margin: 0px 3px 0px 0px; + color: #000; + vertical-align: middle; + border: 1px solid #00202f; + position: relative; + background: #fff; +} +x-toggle[no-box] .x-toggle-check { + display: none !important; +} +x-toggle[type="radio"] input:checked + .x-toggle-check { + background: #fff; +} +x-toggle[type="radio"] input:checked + .x-toggle-check:after { + content: ''; + display: block; + position: absolute; + left: 0; + top: 0; + bottom: 0; + right: 0; + margin: auto; + border-radius: 50%; + width: 14px; + height: 14px; + background: #0095dd; +} +x-toggle[type="checkbox"] input:checked + .x-toggle-check { + border-width: 0; + background: #0095dd; +} +x-toggle[type="checkbox"] input:checked + .x-toggle-check:after { + content: ''; + display: block; + position: absolute; + left: 0; + top: 0; + bottom: 3.2px; + right: 0; + margin: auto; + width: 10px; + height: 5px; + border: solid #fff; + border-width: 0 0 2px 2px; + -webkit-transform: rotate(-45deg); + -moz-transform: rotate(-45deg); + -ms-transform: rotate(-45deg); + -o-transform: rotate(-45deg); + transform: rotate(-45deg); +} diff --git a/css/index.css b/css/index.css new file mode 100644 index 0000000..d1fce0d --- /dev/null +++ b/css/index.css @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 + * This file is part of WvS VPlan. + * + * WvS VPlan is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +* { + -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ +} + +body { + -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */ + -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */ + -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ +} + +/* Portrait layout (default) */ +.app { +} + +/* Landscape layout (with min-width) */ +@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) { + .app { + } +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..71087ba --- /dev/null +++ b/index.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<!-- + Copyright (C) 2014 + This file is part of WvS VPlan. + + WvS VPlan is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +--> +<html> + <head> + <meta charset="utf-8" /> + <meta name="format-detection" content="telephone=no" /> + <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 --> + <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> + <link rel="stylesheet" type="text/css" href="css/index.css" /> + <link rel="stylesheet" type="text/css" href="css/brick-1.0.0.css" /> + <title>WvS VPlan</title> + </head> + <body> + <div class="app"> + <figure class="Login"> + <x-appbar> + <h1>WvS VPlan | Login</h1> + <button>=</button> + </x-appbar> + <x-layout> + <section> + Hallo Welt + </section> + </x-layout> + </figure> + </div> + <script type="text/javascript" src="phonegap.js"></script> + <script type="text/javascript" src="js/index.js"></script> + <script type="text/javascript"> + app.initialize(); + </script> + <script type="text/javascript" src="js/brick-1.0.0.js"></script> + </body> +</html> diff --git a/js/brick-1.0.0.js b/js/brick-1.0.0.js new file mode 100644 index 0000000..db94c1d --- /dev/null +++ b/js/brick-1.0.0.js @@ -0,0 +1,4081 @@ +window.Platform = {}; + +var logFlags = {}; + +(function() { + if (typeof window.Element === "undefined" || "classList" in document.documentElement) return; + var prototype = Array.prototype, indexOf = prototype.indexOf, slice = prototype.slice, push = prototype.push, splice = prototype.splice, join = prototype.join; + function DOMTokenList(el) { + this._element = el; + if (el.className != this._classCache) { + this._classCache = el.className; + if (!this._classCache) return; + var classes = this._classCache.replace(/^\s+|\s+$/g, "").split(/\s+/), i; + for (i = 0; i < classes.length; i++) { + push.call(this, classes[i]); + } + } + } + function setToClassName(el, classes) { + el.className = classes.join(" "); + } + DOMTokenList.prototype = { + add: function(token) { + if (this.contains(token)) return; + push.call(this, token); + setToClassName(this._element, slice.call(this, 0)); + }, + contains: function(token) { + return indexOf.call(this, token) !== -1; + }, + item: function(index) { + return this[index] || null; + }, + remove: function(token) { + var i = indexOf.call(this, token); + if (i === -1) { + return; + } + splice.call(this, i, 1); + setToClassName(this._element, slice.call(this, 0)); + }, + toString: function() { + return join.call(this, " "); + }, + toggle: function(token) { + if (indexOf.call(this, token) === -1) { + this.add(token); + } else { + this.remove(token); + } + } + }; + window.DOMTokenList = DOMTokenList; + function defineElementGetter(obj, prop, getter) { + if (Object.defineProperty) { + Object.defineProperty(obj, prop, { + get: getter + }); + } else { + obj.__defineGetter__(prop, getter); + } + } + defineElementGetter(Element.prototype, "classList", function() { + return new DOMTokenList(this); + }); +})(); + +if (typeof WeakMap === "undefined") { + (function() { + var defineProperty = Object.defineProperty; + var counter = Date.now() % 1e9; + var WeakMap = function() { + this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); + }; + WeakMap.prototype = { + set: function(key, value) { + var entry = key[this.name]; + if (entry && entry[0] === key) entry[1] = value; else defineProperty(key, this.name, { + value: [ key, value ], + writable: true + }); + }, + get: function(key) { + var entry; + return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined; + }, + "delete": function(key) { + this.set(key, undefined); + } + }; + window.WeakMap = WeakMap; + })(); +} + +(function(global) { + var registrationsTable = new WeakMap(); + var setImmediate = window.msSetImmediate; + if (!setImmediate) { + var setImmediateQueue = []; + var sentinel = String(Math.random()); + window.addEventListener("message", function(e) { + if (e.data === sentinel) { + var queue = setImmediateQueue; + setImmediateQueue = []; + queue.forEach(function(func) { + func(); + }); + } + }); + setImmediate = function(func) { + setImmediateQueue.push(func); + window.postMessage(sentinel, "*"); + }; + } + var isScheduled = false; + var scheduledObservers = []; + function scheduleCallback(observer) { + scheduledObservers.push(observer); + if (!isScheduled) { + isScheduled = true; + setImmediate(dispatchCallbacks); + } + } + function wrapIfNeeded(node) { + return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node; + } + function dispatchCallbacks() { + isScheduled = false; + var observers = scheduledObservers; + scheduledObservers = []; + observers.sort(function(o1, o2) { + return o1.uid_ - o2.uid_; + }); + var anyNonEmpty = false; + observers.forEach(function(observer) { + var queue = observer.takeRecords(); + removeTransientObserversFor(observer); + if (queue.length) { + observer.callback_(queue, observer); + anyNonEmpty = true; + } + }); + if (anyNonEmpty) dispatchCallbacks(); + } + function removeTransientObserversFor(observer) { + observer.nodes_.forEach(function(node) { + var registrations = registrationsTable.get(node); + if (!registrations) return; + registrations.forEach(function(registration) { + if (registration.observer === observer) registration.removeTransientObservers(); + }); + }); + } + function forEachAncestorAndObserverEnqueueRecord(target, callback) { + for (var node = target; node; node = node.parentNode) { + var registrations = registrationsTable.get(node); + if (registrations) { + for (var j = 0; j < registrations.length; j++) { + var registration = registrations[j]; + var options = registration.options; + if (node !== target && !options.subtree) continue; + var record = callback(options); + if (record) registration.enqueue(record); + } + } + } + } + var uidCounter = 0; + function JsMutationObserver(callback) { + this.callback_ = callback; + this.nodes_ = []; + this.records_ = []; + this.uid_ = ++uidCounter; + } + JsMutationObserver.prototype = { + observe: function(target, options) { + target = wrapIfNeeded(target); + if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) { + throw new SyntaxError(); + } + var registrations = registrationsTable.get(target); + if (!registrations) registrationsTable.set(target, registrations = []); + var registration; + for (var i = 0; i < registrations.length; i++) { + if (registrations[i].observer === this) { + registration = registrations[i]; + registration.removeListeners(); + registration.options = options; + break; + } + } + if (!registration) { + registration = new Registration(this, target, options); + registrations.push(registration); + this.nodes_.push(target); + } + registration.addListeners(); + }, + disconnect: function() { + this.nodes_.forEach(function(node) { + var registrations = registrationsTable.get(node); + for (var i = 0; i < registrations.length; i++) { + var registration = registrations[i]; + if (registration.observer === this) { + registration.removeListeners(); + registrations.splice(i, 1); + break; + } + } + }, this); + this.records_ = []; + }, + takeRecords: function() { + var copyOfRecords = this.records_; + this.records_ = []; + return copyOfRecords; + } + }; + function MutationRecord(type, target) { + this.type = type; + this.target = target; + this.addedNodes = []; + this.removedNodes = []; + this.previousSibling = null; + this.nextSibling = null; + this.attributeName = null; + this.attributeNamespace = null; + this.oldValue = null; + } + function copyMutationRecord(original) { + var record = new MutationRecord(original.type, original.target); + record.addedNodes = original.addedNodes.slice(); + record.removedNodes = original.removedNodes.slice(); + record.previousSibling = original.previousSibling; + record.nextSibling = original.nextSibling; + record.attributeName = original.attributeName; + record.attributeNamespace = original.attributeNamespace; + record.oldValue = original.oldValue; + return record; + } + var currentRecord, recordWithOldValue; + function getRecord(type, target) { + return currentRecord = new MutationRecord(type, target); + } + function getRecordWithOldValue(oldValue) { + if (recordWithOldValue) return recordWithOldValue; + recordWithOldValue = copyMutationRecord(currentRecord); + recordWithOldValue.oldValue = oldValue; + return recordWithOldValue; + } + function clearRecords() { + currentRecord = recordWithOldValue = undefined; + } + function recordRepresentsCurrentMutation(record) { + return record === recordWithOldValue || record === currentRecord; + } + function selectRecord(lastRecord, newRecord) { + if (lastRecord === newRecord) return lastRecord; + if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue; + return null; + } + function Registration(observer, target, options) { + this.observer = observer; + this.target = target; + this.options = options; + this.transientObservedNodes = []; + } + Registration.prototype = { + enqueue: function(record) { + var records = this.observer.records_; + var length = records.length; + if (records.length > 0) { + var lastRecord = records[length - 1]; + var recordToReplaceLast = selectRecord(lastRecord, record); + if (recordToReplaceLast) { + records[length - 1] = recordToReplaceLast; + return; + } + } else { + scheduleCallback(this.observer); + } + records[length] = record; + }, + addListeners: function() { + this.addListeners_(this.target); + }, + addListeners_: function(node) { + var options = this.options; + if (options.attributes) node.addEventListener("DOMAttrModified", this, true); + if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true); + if (options.childList) node.addEventListener("DOMNodeInserted", this, true); + if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true); + }, + removeListeners: function() { + this.removeListeners_(this.target); + }, + removeListeners_: function(node) { + var options = this.options; + if (options.attributes) node.removeEventListener("DOMAttrModified", this, true); + if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true); + if (options.childList) node.removeEventListener("DOMNodeInserted", this, true); + if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true); + }, + addTransientObserver: function(node) { + if (node === this.target) return; + this.addListeners_(node); + this.transientObservedNodes.push(node); + var registrations = registrationsTable.get(node); + if (!registrations) registrationsTable.set(node, registrations = []); + registrations.push(this); + }, + removeTransientObservers: function() { + var transientObservedNodes = this.transientObservedNodes; + this.transientObservedNodes = []; + transientObservedNodes.forEach(function(node) { + this.removeListeners_(node); + var registrations = registrationsTable.get(node); + for (var i = 0; i < registrations.length; i++) { + if (registrations[i] === this) { + registrations.splice(i, 1); + break; + } + } + }, this); + }, + handleEvent: function(e) { + e.stopImmediatePropagation(); + switch (e.type) { + case "DOMAttrModified": + var name = e.attrName; + var namespace = e.relatedNode.namespaceURI; + var target = e.target; + var record = new getRecord("attributes", target); + record.attributeName = name; + record.attributeNamespace = namespace; + var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue; + forEachAncestorAndObserverEnqueueRecord(target, function(options) { + if (!options.attributes) return; + if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) { + return; + } + if (options.attributeOldValue) return getRecordWithOldValue(oldValue); + return record; + }); + break; + + case "DOMCharacterDataModified": + var target = e.target; + var record = getRecord("characterData", target); + var oldValue = e.prevValue; + forEachAncestorAndObserverEnqueueRecord(target, function(options) { + if (!options.characterData) return; + if (options.characterDataOldValue) return getRecordWithOldValue(oldValue); + return record; + }); + break; + + case "DOMNodeRemoved": + this.addTransientObserver(e.target); + + case "DOMNodeInserted": + var target = e.relatedNode; + var changedNode = e.target; + var addedNodes, removedNodes; + if (e.type === "DOMNodeInserted") { + addedNodes = [ changedNode ]; + removedNodes = []; + } else { + addedNodes = []; + removedNodes = [ changedNode ]; + } + var previousSibling = changedNode.previousSibling; + var nextSibling = changedNode.nextSibling; + var record = getRecord("childList", target); + record.addedNodes = addedNodes; + record.removedNodes = removedNodes; + record.previousSibling = previousSibling; + record.nextSibling = nextSibling; + forEachAncestorAndObserverEnqueueRecord(target, function(options) { + if (!options.childList) return; + return record; + }); + } + clearRecords(); + } + }; + global.JsMutationObserver = JsMutationObserver; + if (!global.MutationObserver && global.WebKitMutationObserver) global.MutationObserver = global.WebKitMutationObserver; + if (!global.MutationObserver) global.MutationObserver = JsMutationObserver; +})(this); + +(function(scope) { + if (!scope) { + scope = window.CustomElements = { + flags: {} + }; + } + var flags = scope.flags; + var hasNative = Boolean(document.registerElement); + var useNative = !flags.register && hasNative; + if (useNative) { + var nop = function() {}; + scope.registry = {}; + scope.upgradeElement = nop; + scope.watchShadow = nop; + scope.upgrade = nop; + scope.upgradeAll = nop; + scope.upgradeSubtree = nop; + scope.observeDocument = nop; + scope.upgradeDocument = nop; + scope.takeRecords = nop; + } else { + function register(name, options) { + var definition = options || {}; + if (!name) { + throw new Error("document.registerElement: first argument `name` must not be empty"); + } + if (name.indexOf("-") < 0) { + throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '" + String(name) + "'."); + } + if (getRegisteredDefinition(name)) { + throw new Error("DuplicateDefinitionError: a type with name '" + String(name) + "' is already registered"); + } + if (!definition.prototype) { + throw new Error("Options missing required prototype property"); + } + definition.__name = name.toLowerCase(); + definition.lifecycle = definition.lifecycle || {}; + definition.ancestry = ancestry(definition.extends); + resolveTagName(definition); + resolvePrototypeChain(definition); + overrideAttributeApi(definition.prototype); + registerDefinition(definition.__name, definition); + definition.ctor = generateConstructor(definition); + definition.ctor.prototype = definition.prototype; + definition.prototype.constructor = definition.ctor; + if (scope.ready) { + scope.upgradeAll(document); + } + return definition.ctor; + } + function ancestry(extnds) { + var extendee = getRegisteredDefinition(extnds); + if (extendee) { + return ancestry(extendee.extends).concat([ extendee ]); + } + return []; + } + function resolveTagName(definition) { + var baseTag = definition.extends; + for (var i = 0, a; a = definition.ancestry[i]; i++) { + baseTag = a.is && a.tag; + } + definition.tag = baseTag || definition.__name; + if (baseTag) { + definition.is = definition.__name; + } + } + function resolvePrototypeChain(definition) { + if (!Object.__proto__) { + var nativePrototype = HTMLElement.prototype; + if (definition.is) { + var inst = document.createElement(definition.tag); + nativePrototype = Object.getPrototypeOf(inst); + } + var proto = definition.prototype, ancestor; + while (proto && proto !== nativePrototype) { + var ancestor = Object.getPrototypeOf(proto); + proto.__proto__ = ancestor; + proto = ancestor; + } + } + definition.native = nativePrototype; + } + function instantiate(definition) { + return upgrade(domCreateElement(definition.tag), definition); + } + function upgrade(element, definition) { + if (definition.is) { + element.setAttribute("is", definition.is); + } + element.removeAttribute("unresolved"); + implement(element, definition); + element.__upgraded__ = true; + scope.upgradeSubtree(element); + created(element); + return element; + } + function implement(element, definition) { + if (Object.__proto__) { + element.__proto__ = definition.prototype; + } else { + customMixin(element, definition.prototype, definition.native); + element.__proto__ = definition.prototype; + } + } + function customMixin(inTarget, inSrc, inNative) { + var used = {}; + var p = inSrc; + while (p !== inNative && p !== HTMLUnknownElement.prototype) { + var keys = Object.getOwnPropertyNames(p); + for (var i = 0, k; k = keys[i]; i++) { + if (!used[k]) { + Object.defineProperty(inTarget, k, Object.getOwnPropertyDescriptor(p, k)); + used[k] = 1; + } + } + p = Object.getPrototypeOf(p); + } + } + function created(element) { + if (element.createdCallback) { + element.createdCallback(); + } + } + function overrideAttributeApi(prototype) { + if (prototype.setAttribute._polyfilled) { + return; + } + var setAttribute = prototype.setAttribute; + prototype.setAttribute = function(name, value) { + changeAttribute.call(this, name, value, setAttribute); + }; + var removeAttribute = prototype.removeAttribute; + prototype.removeAttribute = function(name) { + changeAttribute.call(this, name, null, removeAttribute); + }; + prototype.setAttribute._polyfilled = true; + } + function changeAttribute(name, value, operation) { + var oldValue = this.getAttribute(name); + operation.apply(this, arguments); + var newValue = this.getAttribute(name); + if (this.attributeChangedCallback && newValue !== oldValue) { + this.attributeChangedCallback(name, oldValue, newValue); + } + } + var registry = {}; + function getRegisteredDefinition(name) { + if (name) { + return registry[name.toLowerCase()]; + } + } + function registerDefinition(name, definition) { + registry[name] = definition; + } + function generateConstructor(definition) { + return function() { + return instantiate(definition); + }; + } + function createElement(tag, typeExtension) { + var definition = getRegisteredDefinition(typeExtension || tag); + if (definition) { + return new definition.ctor(); + } + return domCreateElement(tag); + } + function upgradeElement(element) { + if (!element.__upgraded__ && element.nodeType === Node.ELEMENT_NODE) { + var type = element.getAttribute("is") || element.localName; + var definition = getRegisteredDefinition(type); + return definition && upgrade(element, definition); + } + } + function cloneNode(deep) { + var n = domCloneNode.call(this, deep); + scope.upgradeAll(n); + return n; + } + var domCreateElement = document.createElement.bind(document); + var domCloneNode = Node.prototype.cloneNode; + document.registerElement = register; + document.createElement = createElement; + Node.prototype.cloneNode = cloneNode; + scope.registry = registry; + scope.upgrade = upgradeElement; + } + document.register = document.registerElement; + scope.hasNative = hasNative; + scope.useNative = useNative; +})(window.CustomElements); + +(function(scope) { + var logFlags = window.logFlags || {}; + function findAll(node, find, data) { + var e = node.firstElementChild; + if (!e) { + e = node.firstChild; + while (e && e.nodeType !== Node.ELEMENT_NODE) { + e = e.nextSibling; + } + } + while (e) { + if (find(e, data) !== true) { + findAll(e, find, data); + } + e = e.nextElementSibling; + } + return null; + } + function forRoots(node, cb) { + var root = node.shadowRoot; + while (root) { + forSubtree(root, cb); + root = root.olderShadowRoot; + } + } + function forSubtree(node, cb) { + findAll(node, function(e) { + if (cb(e)) { + return true; + } + forRoots(e, cb); + }); + forRoots(node, cb); + } + function added(node) { + if (upgrade(node)) { + insertedNode(node); + return true; + } + inserted(node); + } + function addedSubtree(node) { + forSubtree(node, function(e) { + if (added(e)) { + return true; + } + }); + } + function addedNode(node) { + return added(node) || addedSubtree(node); + } + function upgrade(node) { + if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) { + var type = node.getAttribute("is") || node.localName; + var definition = scope.registry[type]; + if (definition) { + logFlags.dom && console.group("upgrade:", node.localName); + scope.upgrade(node); + logFlags.dom && console.groupEnd(); + return true; + } + } + } + function insertedNode(node) { + inserted(node); + if (inDocument(node)) { + forSubtree(node, function(e) { + inserted(e); + }); + } + } + var hasPolyfillMutations = !window.MutationObserver || window.MutationObserver === window.JsMutationObserver; + scope.hasPolyfillMutations = hasPolyfillMutations; + var isPendingMutations = false; + var pendingMutations = []; + function deferMutation(fn) { + pendingMutations.push(fn); + if (!isPendingMutations) { + isPendingMutations = true; + var async = window.Platform && window.Platform.endOfMicrotask || setTimeout; + async(takeMutations); + } + } + function takeMutations() { + isPendingMutations = false; + var $p = pendingMutations; + for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) { + p(); + } + pendingMutations = []; + } + function inserted(element) { + if (hasPolyfillMutations) { + deferMutation(function() { + _inserted(element); + }); + } else { + _inserted(element); + } + } + function _inserted(element) { + if (element.attachedCallback || element.detachedCallback || element.__upgraded__ && logFlags.dom) { + logFlags.dom && console.group("inserted:", element.localName); + if (inDocument(element)) { + element.__inserted = (element.__inserted || 0) + 1; + if (element.__inserted < 1) { + element.__inserted = 1; + } + if (element.__inserted > 1) { + logFlags.dom && console.warn("inserted:", element.localName, "insert/remove count:", element.__inserted); + } else if (element.attachedCallback) { + logFlags.dom && console.log("inserted:", element.localName); + element.attachedCallback(); + } + } + logFlags.dom && console.groupEnd(); + } + } + function removedNode(node) { + removed(node); + forSubtree(node, function(e) { + removed(e); + }); + } + function removed(element) { + if (hasPolyfillMutations) { + deferMutation(function() { + _removed(element); + }); + } else { + _removed(element); + } + } + function _removed(element) { + if (element.attachedCallback || element.detachedCallback || element.__upgraded__ && logFlags.dom) { + logFlags.dom && console.group("removed:", element.localName); + if (!inDocument(element)) { + element.__inserted = (element.__inserted || 0) - 1; + if (element.__inserted > 0) { + element.__inserted = 0; + } + if (element.__inserted < 0) { + logFlags.dom && console.warn("removed:", element.localName, "insert/remove count:", element.__inserted); + } else if (element.detachedCallback) { + element.detachedCallback(); + } + } + logFlags.dom && console.groupEnd(); + } + } + function inDocument(element) { + var p = element; + var doc = window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(document) || document; + while (p) { + if (p == doc) { + return true; + } + p = p.parentNode || p.host; + } + } + function watchShadow(node) { + if (node.shadowRoot && !node.shadowRoot.__watched) { + logFlags.dom && console.log("watching shadow-root for: ", node.localName); + var root = node.shadowRoot; + while (root) { + watchRoot(root); + root = root.olderShadowRoot; + } + } + } + function watchRoot(root) { + if (!root.__watched) { + observe(root); + root.__watched = true; + } + } + function handler(mutations) { + if (logFlags.dom) { + var mx = mutations[0]; + if (mx && mx.type === "childList" && mx.addedNodes) { + if (mx.addedNodes) { + var d = mx.addedNodes[0]; + while (d && d !== document && !d.host) { + d = d.parentNode; + } + var u = d && (d.URL || d._URL || d.host && d.host.localName) || ""; + u = u.split("/?").shift().split("/").pop(); + } + } + console.group("mutations (%d) [%s]", mutations.length, u || ""); + } + mutations.forEach(function(mx) { + if (mx.type === "childList") { + forEach(mx.addedNodes, function(n) { + if (!n.localName) { + return; + } + addedNode(n); + }); + forEach(mx.removedNodes, function(n) { + if (!n.localName) { + return; + } + removedNode(n); + }); + } + }); + logFlags.dom && console.groupEnd(); + } + var observer = new MutationObserver(handler); + function takeRecords() { + handler(observer.takeRecords()); + takeMutations(); + } + var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); + function observe(inRoot) { + observer.observe(inRoot, { + childList: true, + subtree: true + }); + } + function observeDocument(document) { + observe(document); + } + function upgradeDocument(document) { + logFlags.dom && console.group("upgradeDocument: ", (document.URL || document._URL || "").split("/").pop()); + addedNode(document); + logFlags.dom && console.groupEnd(); + } + scope.watchShadow = watchShadow; + scope.upgradeAll = addedNode; + scope.upgradeSubtree = addedSubtree; + scope.observeDocument = observeDocument; + scope.upgradeDocument = upgradeDocument; + scope.takeRecords = takeRecords; +})(window.CustomElements); + +(function() { + var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : "none"; + var parser = { + selectors: [ "link[rel=" + IMPORT_LINK_TYPE + "]" ], + map: { + link: "parseLink" + }, + parse: function(inDocument) { + if (!inDocument.__parsed) { + inDocument.__parsed = true; + var elts = inDocument.querySelectorAll(parser.selectors); + forEach(elts, function(e) { + parser[parser.map[e.localName]](e); + }); + CustomElements.upgradeDocument(inDocument); + CustomElements.observeDocument(inDocument); + } + }, + parseLink: function(linkElt) { + if (isDocumentLink(linkElt)) { + this.parseImport(linkElt); + } + }, + parseImport: function(linkElt) { + if (linkElt.content) { + parser.parse(linkElt.content); + } + } + }; + function isDocumentLink(inElt) { + return inElt.localName === "link" && inElt.getAttribute("rel") === IMPORT_LINK_TYPE; + } + var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); + CustomElements.parser = parser; +})(); + +(function(scope) { + function bootstrap() { + CustomElements.parser.parse(document); + CustomElements.upgradeDocument(document); + var async = window.Platform && Platform.endOfMicrotask ? Platform.endOfMicrotask : setTimeout; + async(function() { + CustomElements.ready = true; + CustomElements.readyTime = Date.now(); + if (window.HTMLImports) { + CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime; + } + document.dispatchEvent(new CustomEvent("WebComponentsReady", { + bubbles: true + })); + }); + } + if (typeof window.CustomEvent !== "function") { + window.CustomEvent = function(inType) { + var e = document.createEvent("HTMLEvents"); + e.initEvent(inType, true, true); + return e; + }; + } + if (document.readyState === "complete" || scope.flags.eager) { + bootstrap(); + } else if (document.readyState === "interactive" && !window.attachEvent && (!window.HTMLImports || window.HTMLImports.ready)) { + bootstrap(); + } else { + var loadEvent = window.HTMLImports && !HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded"; + window.addEventListener(loadEvent, bootstrap); + } +})(window.CustomElements); + +(function() { + var win = window, doc = document, container = doc.createElement("div"), noop = function() {}, trueop = function() { + return true; + }, regexPseudoSplit = /([\w-]+(?:\([^\)]+\))?)/g, regexPseudoReplace = /(\w*)(?:\(([^\)]*)\))?/, regexDigits = /(\d+)/g, keypseudo = { + action: function(pseudo, event) { + return pseudo.value.match(regexDigits).indexOf(String(event.keyCode)) > -1 == (pseudo.name == "keypass") || null; + } + }, prefix = function() { + var styles = win.getComputedStyle(doc.documentElement, ""), pre = (Array.prototype.slice.call(styles).join("").match(/-(moz|webkit|ms)-/) || styles.OLink === "" && [ "", "o" ])[1]; + return { + dom: pre == "ms" ? "MS" : pre, + lowercase: pre, + css: "-" + pre + "-", + js: pre == "ms" ? pre : pre[0].toUpperCase() + pre.substr(1) + }; + }(), matchSelector = Element.prototype.matchesSelector || Element.prototype[prefix.lowercase + "MatchesSelector"], mutation = win.MutationObserver || win[prefix.js + "MutationObserver"]; + var typeCache = {}, typeString = typeCache.toString, typeRegexp = /\s([a-zA-Z]+)/; + function typeOf(obj) { + var type = typeString.call(obj); + return typeCache[type] || (typeCache[type] = type.match(typeRegexp)[1].toLowerCase()); + } + function clone(item, type) { + var fn = clone[type || typeOf(item)]; + return fn ? fn(item) : item; + } + clone.object = function(src) { + var obj = {}; + for (var key in src) obj[key] = clone(src[key]); + return obj; + }; + clone.array = function(src) { + var i = src.length, array = new Array(i); + while (i--) array[i] = clone(src[i]); + return array; + }; + var unsliceable = [ "undefined", "null", "number", "boolean", "string", "function" ]; + function toArray(obj) { + return unsliceable.indexOf(typeOf(obj)) == -1 ? Array.prototype.slice.call(obj, 0) : [ obj ]; + } + var str = ""; + function query(element, selector) { + return (selector || str).length ? toArray(element.querySelectorAll(selector)) : []; + } + function parseMutations(element, mutations) { + var diff = { + added: [], + removed: [] + }; + mutations.forEach(function(record) { + record._mutation = true; + for (var z in diff) { + var type = element._records[z == "added" ? "inserted" : "removed"], nodes = record[z + "Nodes"], length = nodes.length; + for (var i = 0; i < length && diff[z].indexOf(nodes[i]) == -1; i++) { + diff[z].push(nodes[i]); + type.forEach(function(fn) { + fn(nodes[i], record); + }); + } + } + }); + } + function mergeOne(source, key, current) { + var type = typeOf(current); + if (type == "object" && typeOf(source[key]) == "object") xtag.merge(source[key], current); else source[key] = clone(current, type); + return source; + } + function wrapMixin(tag, key, pseudo, value, original) { + var fn = original[key]; + if (!(key in original)) original[key] = value; else if (typeof original[key] == "function") { + if (!fn.__mixins__) fn.__mixins__ = []; + fn.__mixins__.push(xtag.applyPseudos(pseudo, value, tag.pseudos)); + } + } + var uniqueMixinCount = 0; + function mergeMixin(tag, mixin, original, mix) { + if (mix) { + var uniques = {}; + for (var z in original) uniques[z.split(":")[0]] = z; + for (z in mixin) { + wrapMixin(tag, uniques[z.split(":")[0]] || z, z, mixin[z], original); + } + } else { + for (var zz in mixin) { + original[zz + ":__mixin__(" + uniqueMixinCount++ + ")"] = xtag.applyPseudos(zz, mixin[zz], tag.pseudos); + } + } + } + function applyMixins(tag) { + tag.mixins.forEach(function(name) { + var mixin = xtag.mixins[name]; + for (var type in mixin) { + var item = mixin[type], original = tag[type]; + if (!original) tag[type] = item; else { + switch (type) { + case "accessors": + case "prototype": + for (var z in item) { + if (!original[z]) original[z] = item[z]; else mergeMixin(tag, item[z], original[z], true); + } + break; + + default: + mergeMixin(tag, item, original, type != "events"); + } + } + } + }); + return tag; + } + function delegateAction(pseudo, event) { + var match, target = event.target; + if (!target.tagName) return null; + if (xtag.matchSelector(target, pseudo.value)) match = target; else if (xtag.matchSelector(target, pseudo.value + " *")) { + var parent = target.parentNode; + while (!match) { + if (xtag.matchSelector(parent, pseudo.value)) match = parent; + parent = parent.parentNode; + } + } + return match ? pseudo.listener = pseudo.listener.bind(match) : null; + } + function touchFilter(event) { + if (event.type.match("touch")) { + event.target.__touched__ = true; + } else if (event.target.__touched__ && event.type.match("mouse")) { + delete event.target.__touched__; + return; + } + return true; + } + function createFlowEvent(type) { + var flow = type == "over"; + return { + attach: "OverflowEvent" in win ? "overflowchanged" : [], + condition: function(event, custom) { + event.flow = type; + return event.type == type + "flow" || event.orient === 0 && event.horizontalOverflow == flow || event.orient == 1 && event.verticalOverflow == flow || event.orient == 2 && event.horizontalOverflow == flow && event.verticalOverflow == flow; + } + }; + } + function writeProperty(key, event, base, desc) { + if (desc) event[key] = base[key]; else Object.defineProperty(event, key, { + writable: true, + enumerable: true, + value: base[key] + }); + } + var skipProps = {}; + for (var z in doc.createEvent("CustomEvent")) skipProps[z] = 1; + function inheritEvent(event, base) { + var desc = Object.getOwnPropertyDescriptor(event, "target"); + for (var z in base) { + if (!skipProps[z]) writeProperty(z, event, base, desc); + } + event.baseEvent = base; + } + function getArgs(attr, value) { + return { + value: attr.boolean ? "" : value, + method: attr.boolean && !value ? "removeAttribute" : "setAttribute" + }; + } + function modAttr(element, attr, name, value) { + var args = getArgs(attr, value); + element[args.method](name, args.value); + } + function syncAttr(element, attr, name, value, method) { + var nodes = attr.property ? [ element.xtag[attr.property] ] : attr.selector ? xtag.query(element, attr.selector) : [], index = nodes.length; + while (index--) nodes[index][method](name, value); + } + function updateView(element, name, value) { + if (element.__view__) { + element.__view__.updateBindingValue(element, name, value); + } + } + function attachProperties(tag, prop, z, accessor, attr, name) { + var key = z.split(":"), type = key[0]; + if (type == "get") { + key[0] = prop; + tag.prototype[prop].get = xtag.applyPseudos(key.join(":"), accessor[z], tag.pseudos, accessor[z]); + } else if (type == "set") { + key[0] = prop; + var setter = tag.prototype[prop].set = xtag.applyPseudos(key.join(":"), attr ? function(value) { + this.xtag._skipSet = true; + if (!this.xtag._skipAttr) modAttr(this, attr, name, value); + if (this.xtag._skipAttr && attr.skip) delete this.xtag._skipAttr; + accessor[z].call(this, attr.boolean ? !!value : value); + updateView(this, name, value); + delete this.xtag._skipSet; + } : accessor[z] ? function(value) { + accessor[z].call(this, value); + updateView(this, name, value); + } : null, tag.pseudos, accessor[z]); + if (attr) attr.setter = setter; + } else tag.prototype[prop][z] = accessor[z]; + } + function parseAccessor(tag, prop) { + tag.prototype[prop] = {}; + var accessor = tag.accessors[prop], attr = accessor.attribute, name = attr && attr.name ? attr.name.toLowerCase() : prop; + if (attr) { + attr.key = prop; + tag.attributes[name] = attr; + } + for (var z in accessor) attachProperties(tag, prop, z, accessor, attr, name); + if (attr) { + if (!tag.prototype[prop].get) { + var method = (attr.boolean ? "has" : "get") + "Attribute"; + tag.prototype[prop].get = function() { + return this[method](name); + }; + } + if (!tag.prototype[prop].set) tag.prototype[prop].set = function(value) { + modAttr(this, attr, name, value); + updateView(this, name, value); + }; + } + } + var readyTags = {}; + function fireReady(name) { + readyTags[name] = (readyTags[name] || []).filter(function(obj) { + return (obj.tags = obj.tags.filter(function(z) { + return z != name && !xtag.tags[z]; + })).length || obj.fn(); + }); + } + var xtag = { + tags: {}, + defaultOptions: { + pseudos: [], + mixins: [], + events: {}, + methods: {}, + accessors: {}, + lifecycle: {}, + attributes: {}, + prototype: { + xtag: { + get: function() { + return this.__xtag__ ? this.__xtag__ : this.__xtag__ = { + data: {} + }; + } + } + } + }, + register: function(name, options) { + var _name; + if (typeof name == "string") { + _name = name.toLowerCase(); + } else { + return; + } + var basePrototype = options.prototype; + delete options.prototype; + var tag = xtag.tags[_name] = applyMixins(xtag.merge({}, xtag.defaultOptions, options)); + for (var z in tag.events) tag.events[z] = xtag.parseEvent(z, tag.events[z]); + for (z in tag.lifecycle) tag.lifecycle[z.split(":")[0]] = xtag.applyPseudos(z, tag.lifecycle[z], tag.pseudos, tag.lifecycle[z]); + for (z in tag.methods) tag.prototype[z.split(":")[0]] = { + value: xtag.applyPseudos(z, tag.methods[z], tag.pseudos, tag.methods[z]), + enumerable: true + }; + for (z in tag.accessors) parseAccessor(tag, z); + var ready = tag.lifecycle.created || tag.lifecycle.ready; + tag.prototype.createdCallback = { + enumerable: true, + value: function() { + var element = this; + xtag.addEvents(this, tag.events); + tag.mixins.forEach(function(mixin) { + if (xtag.mixins[mixin].events) xtag.addEvents(element, xtag.mixins[mixin].events); + }); + var output = ready ? ready.apply(this, arguments) : null; + for (var name in tag.attributes) { + var attr = tag.attributes[name], hasAttr = this.hasAttribute(name); + if (hasAttr || attr.boolean) { + this[attr.key] = attr.boolean ? hasAttr : this.getAttribute(name); + } + } + tag.pseudos.forEach(function(obj) { + obj.onAdd.call(element, obj); + }); + return output; + } + }; + var inserted = tag.lifecycle.inserted, removed = tag.lifecycle.removed; + if (inserted || removed) { + tag.prototype.attachedCallback = { + value: function() { + if (removed) this.xtag.__parentNode__ = this.parentNode; + if (inserted) return inserted.apply(this, arguments); + }, + enumerable: true + }; + } + if (removed) { + tag.prototype.detachedCallback = { + value: function() { + var args = toArray(arguments); + args.unshift(this.xtag.__parentNode__); + var output = removed.apply(this, args); + delete this.xtag.__parentNode__; + return output; + }, + enumerable: true + }; + } + if (tag.lifecycle.attributeChanged) tag.prototype.attributeChangedCallback = { + value: tag.lifecycle.attributeChanged, + enumerable: true + }; + var setAttribute = tag.prototype.setAttribute || HTMLElement.prototype.setAttribute; + tag.prototype.setAttribute = { + writable: true, + enumberable: true, + value: function(name, value) { + var attr = tag.attributes[name.toLowerCase()]; + if (!this.xtag._skipAttr) setAttribute.call(this, name, attr && attr.boolean ? "" : value); + if (attr) { + if (attr.setter && !this.xtag._skipSet) { + this.xtag._skipAttr = true; + attr.setter.call(this, attr.boolean ? true : value); + } + value = attr.skip ? attr.boolean ? this.hasAttribute(name) : this.getAttribute(name) : value; + syncAttr(this, attr, name, attr.boolean ? "" : value, "setAttribute"); + } + delete this.xtag._skipAttr; + } + }; + var removeAttribute = tag.prototype.removeAttribute || HTMLElement.prototype.removeAttribute; + tag.prototype.removeAttribute = { + writable: true, + enumberable: true, + value: function(name) { + var attr = tag.attributes[name.toLowerCase()]; + if (!this.xtag._skipAttr) removeAttribute.call(this, name); + if (attr) { + if (attr.setter && !this.xtag._skipSet) { + this.xtag._skipAttr = true; + attr.setter.call(this, attr.boolean ? false : undefined); + } + syncAttr(this, attr, name, undefined, "removeAttribute"); + } + delete this.xtag._skipAttr; + } + }; + var elementProto = basePrototype ? basePrototype : options["extends"] ? Object.create(doc.createElement(options["extends"]).constructor).prototype : win.HTMLElement.prototype; + var definition = { + prototype: Object.create(elementProto, tag.prototype) + }; + if (options["extends"]) { + definition["extends"] = options["extends"]; + } + var reg = doc.registerElement(_name, definition); + fireReady(_name); + return reg; + }, + ready: function(names, fn) { + var obj = { + tags: toArray(names), + fn: fn + }; + if (obj.tags.reduce(function(last, name) { + if (xtag.tags[name]) return last; + (readyTags[name] = readyTags[name] || []).push(obj); + }, true)) fn(); + }, + mixins: {}, + prefix: prefix, + captureEvents: [ "focus", "blur", "scroll", "underflow", "overflow", "overflowchanged", "DOMMouseScroll" ], + customEvents: { + overflow: createFlowEvent("over"), + underflow: createFlowEvent("under"), + animationstart: { + attach: [ prefix.dom + "AnimationStart" ] + }, + animationend: { + attach: [ prefix.dom + "AnimationEnd" ] + }, + transitionend: { + attach: [ prefix.dom + "TransitionEnd" ] + }, + move: { + attach: [ "mousemove", "touchmove" ], + condition: touchFilter + }, + enter: { + attach: [ "mouseover", "touchenter" ], + condition: touchFilter + }, + leave: { + attach: [ "mouseout", "touchleave" ], + condition: touchFilter + }, + scrollwheel: { + attach: [ "DOMMouseScroll", "mousewheel" ], + condition: function(event) { + event.delta = event.wheelDelta ? event.wheelDelta / 40 : Math.round(event.detail / 3.5 * -1); + return true; + } + }, + tapstart: { + observe: { + mousedown: doc, + touchstart: doc + }, + condition: touchFilter + }, + tapend: { + observe: { + mouseup: doc, + touchend: doc + }, + condition: touchFilter + }, + tapmove: { + attach: [ "tapstart", "dragend", "touchcancel" ], + condition: function(event, custom) { + switch (event.type) { + case "move": + return true; + + case "dragover": + var last = custom.lastDrag || {}; + custom.lastDrag = event; + return last.pageX != event.pageX && last.pageY != event.pageY || null; + + case "tapstart": + if (!custom.move) { + custom.current = this; + custom.move = xtag.addEvents(this, { + move: custom.listener, + dragover: custom.listener + }); + custom.tapend = xtag.addEvent(doc, "tapend", custom.listener); + } + break; + + case "tapend": + case "dragend": + case "touchcancel": + if (!event.touches.length) { + if (custom.move) xtag.removeEvents(custom.current, custom.move || {}); + if (custom.tapend) xtag.removeEvent(doc, custom.tapend || {}); + delete custom.lastDrag; + delete custom.current; + delete custom.tapend; + delete custom.move; + } + } + } + } + }, + pseudos: { + __mixin__: {}, + mixins: { + onCompiled: function(fn, pseudo) { + var mixins = pseudo.source.__mixins__; + if (mixins) switch (pseudo.value) { + case "before": + return function() { + var self = this, args = arguments; + mixins.forEach(function(m) { + m.apply(self, args); + }); + return fn.apply(self, args); + }; + + case "after": + case null: + return function() { + var self = this, args = arguments; + returns = fn.apply(self, args); + mixins.forEach(function(m) { + m.apply(self, args); + }); + return returns; + }; + } + } + }, + keypass: keypseudo, + keyfail: keypseudo, + delegate: { + action: delegateAction + }, + within: { + action: delegateAction, + onAdd: function(pseudo) { + var condition = pseudo.source.condition; + if (condition) pseudo.source.condition = function(event, custom) { + return xtag.query(this, pseudo.value).filter(function(node) { + return node == event.target || node.contains ? node.contains(event.target) : null; + })[0] ? condition.call(this, event, custom) : null; + }; + } + }, + preventable: { + action: function(pseudo, event) { + return !event.defaultPrevented; + } + } + }, + clone: clone, + typeOf: typeOf, + toArray: toArray, + wrap: function(original, fn) { + return function() { + var args = arguments, output = original.apply(this, args); + fn.apply(this, args); + return output; + }; + }, + merge: function(source, k, v) { + if (typeOf(k) == "string") return mergeOne(source, k, v); + for (var i = 1, l = arguments.length; i < l; i++) { + var object = arguments[i]; + for (var key in object) mergeOne(source, key, object[key]); + } + return source; + }, + uid: function() { + return Math.random().toString(36).substr(2, 10); + }, + query: query, + skipTransition: function(element, fn, bind) { + var prop = prefix.js + "TransitionProperty"; + element.style[prop] = element.style.transitionProperty = "none"; + var callback = fn ? fn.call(bind) : null; + return xtag.requestFrame(function() { + xtag.requestFrame(function() { + element.style[prop] = element.style.transitionProperty = ""; + if (callback) xtag.requestFrame(callback); + }); + }); + }, + requestFrame: function() { + var raf = win.requestAnimationFrame || win[prefix.lowercase + "RequestAnimationFrame"] || function(fn) { + return win.setTimeout(fn, 20); + }; + return function(fn) { + return raf(fn); + }; + }(), + cancelFrame: function() { + var cancel = win.cancelAnimationFrame || win[prefix.lowercase + "CancelAnimationFrame"] || win.clearTimeout; + return function(id) { + return cancel(id); + }; + }(), + matchSelector: function(element, selector) { + return matchSelector.call(element, selector); + }, + set: function(element, method, value) { + element[method] = value; + if (window.CustomElements) CustomElements.upgradeAll(element); + }, + innerHTML: function(el, html) { + xtag.set(el, "innerHTML", html); + }, + hasClass: function(element, klass) { + return element.className.split(" ").indexOf(klass.trim()) > -1; + }, + addClass: function(element, klass) { + var list = element.className.trim().split(" "); + klass.trim().split(" ").forEach(function(name) { + if (!~list.indexOf(name)) list.push(name); + }); + element.className = list.join(" ").trim(); + return element; + }, + removeClass: function(element, klass) { + var classes = klass.trim().split(" "); + element.className = element.className.trim().split(" ").filter(function(name) { + return name && !~classes.indexOf(name); + }).join(" "); + return element; + }, + toggleClass: function(element, klass) { + return xtag[xtag.hasClass(element, klass) ? "removeClass" : "addClass"].call(null, element, klass); + }, + queryChildren: function(element, selector) { + var id = element.id, guid = element.id = id || "x_" + xtag.uid(), attr = "#" + guid + " > ", noParent = false; + if (!element.parentNode) { + noParent = true; + container.appendChild(element); + } + selector = attr + (selector + "").replace(",", "," + attr, "g"); + var result = element.parentNode.querySelectorAll(selector); + if (!id) element.removeAttribute("id"); + if (noParent) { + container.removeChild(element); + } + return toArray(result); + }, + createFragment: function(content) { + var frag = doc.createDocumentFragment(); + if (content) { + var div = frag.appendChild(doc.createElement("div")), nodes = toArray(content.nodeName ? arguments : !(div.innerHTML = content) || div.children), length = nodes.length, index = 0; + while (index < length) frag.insertBefore(nodes[index++], div); + frag.removeChild(div); + } + return frag; + }, + manipulate: function(element, fn) { + var next = element.nextSibling, parent = element.parentNode, frag = doc.createDocumentFragment(), returned = fn.call(frag.appendChild(element), frag) || element; + if (next) parent.insertBefore(returned, next); else parent.appendChild(returned); + }, + applyPseudos: function(key, fn, target, source) { + var listener = fn, pseudos = {}; + if (key.match(":")) { + var split = key.match(regexPseudoSplit), i = split.length; + while (--i) { + split[i].replace(regexPseudoReplace, function(match, name, value) { + if (!xtag.pseudos[name]) throw "pseudo not found: " + name + " " + split; + value = value === "" || typeof value == "undefined" ? null : value; + var pseudo = pseudos[i] = Object.create(xtag.pseudos[name]); + pseudo.key = key; + pseudo.name = name; + pseudo.value = value; + pseudo["arguments"] = (value || "").split(","); + pseudo.action = pseudo.action || trueop; + pseudo.source = source; + var last = listener; + listener = function() { + var args = toArray(arguments), obj = { + key: key, + name: name, + value: value, + source: source, + arguments: pseudo["arguments"], + listener: last + }; + var output = pseudo.action.apply(this, [ obj ].concat(args)); + if (output === null || output === false) return output; + return obj.listener.apply(this, args); + }; + if (target && pseudo.onAdd) { + if (target.nodeName) pseudo.onAdd.call(target, pseudo); else target.push(pseudo); + } + }); + } + } + for (var z in pseudos) { + if (pseudos[z].onCompiled) listener = pseudos[z].onCompiled(listener, pseudos[z]) || listener; + } + return listener; + }, + removePseudos: function(target, pseudos) { + pseudos.forEach(function(obj) { + if (obj.onRemove) obj.onRemove.call(target, obj); + }); + }, + parseEvent: function(type, fn) { + var pseudos = type.split(":"), key = pseudos.shift(), custom = xtag.customEvents[key], event = xtag.merge({ + type: key, + stack: noop, + condition: trueop, + attach: [], + _attach: [], + pseudos: "", + _pseudos: [], + onAdd: noop, + onRemove: noop + }, custom || {}); + event.attach = toArray(event.base || event.attach); + event.chain = key + (event.pseudos.length ? ":" + event.pseudos : "") + (pseudos.length ? ":" + pseudos.join(":") : ""); + var condition = event.condition; + event.condition = function(e) { + var t = e.touches, tt = e.targetTouches; + return condition.apply(this, arguments); + }; + var stack = xtag.applyPseudos(event.chain, fn, event._pseudos, event); + event.stack = function(e) { + e.currentTarget = e.currentTarget || this; + var t = e.touches, tt = e.targetTouches; + var detail = e.detail || {}; + if (!detail.__stack__) return stack.apply(this, arguments); else if (detail.__stack__ == stack) { + e.stopPropagation(); + e.cancelBubble = true; + return stack.apply(this, arguments); + } + }; + event.listener = function(e) { + var args = toArray(arguments), output = event.condition.apply(this, args.concat([ event ])); + if (!output) return output; + if (e.type != key) { + xtag.fireEvent(e.target, key, { + baseEvent: e, + detail: output !== true && (output.__stack__ = stack) ? output : { + __stack__: stack + } + }); + } else return event.stack.apply(this, args); + }; + event.attach.forEach(function(name) { + event._attach.push(xtag.parseEvent(name, event.listener)); + }); + if (custom && custom.observe && !custom.__observing__) { + custom.observer = function(e) { + var output = event.condition.apply(this, toArray(arguments).concat([ custom ])); + if (!output) return output; + xtag.fireEvent(e.target, key, { + baseEvent: e, + detail: output !== true ? output : {} + }); + }; + for (var z in custom.observe) xtag.addEvent(custom.observe[z] || document, z, custom.observer, true); + custom.__observing__ = true; + } + return event; + }, + addEvent: function(element, type, fn, capture) { + var event = typeof fn == "function" ? xtag.parseEvent(type, fn) : fn; + event._pseudos.forEach(function(obj) { + obj.onAdd.call(element, obj); + }); + event._attach.forEach(function(obj) { + xtag.addEvent(element, obj.type, obj); + }); + event.onAdd.call(element, event, event.listener); + element.addEventListener(event.type, event.stack, capture || xtag.captureEvents.indexOf(event.type) > -1); + return event; + }, + addEvents: function(element, obj) { + var events = {}; + for (var z in obj) { + events[z] = xtag.addEvent(element, z, obj[z]); + } + return events; + }, + removeEvent: function(element, type, event) { + event = event || type; + event.onRemove.call(element, event, event.listener); + xtag.removePseudos(element, event._pseudos); + event._attach.forEach(function(obj) { + xtag.removeEvent(element, obj); + }); + element.removeEventListener(event.type, event.stack); + }, + removeEvents: function(element, obj) { + for (var z in obj) xtag.removeEvent(element, obj[z]); + }, + fireEvent: function(element, type, options, warn) { + var event = doc.createEvent("CustomEvent"); + options = options || {}; + if (warn) console.warn("fireEvent has been modified"); + event.initCustomEvent(type, options.bubbles !== false, options.cancelable !== false, options.detail); + if (options.baseEvent) inheritEvent(event, options.baseEvent); + try { + element.dispatchEvent(event); + } catch (e) { + console.warn("This error may have been caused by a change in the fireEvent method", e); + } + }, + addObserver: function(element, type, fn) { + if (!element._records) { + element._records = { + inserted: [], + removed: [] + }; + if (mutation) { + element._observer = new mutation(function(mutations) { + parseMutations(element, mutations); + }); + element._observer.observe(element, { + subtree: true, + childList: true, + attributes: !true, + characterData: false + }); + } else [ "Inserted", "Removed" ].forEach(function(type) { + element.addEventListener("DOMNode" + type, function(event) { + event._mutation = true; + element._records[type.toLowerCase()].forEach(function(fn) { + fn(event.target, event); + }); + }, false); + }); + } + if (element._records[type].indexOf(fn) == -1) element._records[type].push(fn); + }, + removeObserver: function(element, type, fn) { + var obj = element._records; + if (obj && fn) { + obj[type].splice(obj[type].indexOf(fn), 1); + } else { + obj[type] = []; + } + } + }; + var touching = false, touchTarget = null; + doc.addEventListener("mousedown", function(e) { + touching = true; + touchTarget = e.target; + }, true); + doc.addEventListener("mouseup", function() { + touching = false; + touchTarget = null; + }, true); + doc.addEventListener("dragend", function() { + touching = false; + touchTarget = null; + }, true); + var UIEventProto = { + touches: { + configurable: true, + get: function() { + return this.__touches__ || (this.identifier = 0) || (this.__touches__ = touching ? [ this ] : []); + } + }, + targetTouches: { + configurable: true, + get: function() { + return this.__targetTouches__ || (this.__targetTouches__ = touching && this.currentTarget && (this.currentTarget == touchTarget || this.currentTarget.contains && this.currentTarget.contains(touchTarget)) ? (this.identifier = 0) || [ this ] : []); + } + }, + changedTouches: { + configurable: true, + get: function() { + return this.__changedTouches__ || (this.identifier = 0) || (this.__changedTouches__ = [ this ]); + } + } + }; + for (z in UIEventProto) { + UIEvent.prototype[z] = UIEventProto[z]; + Object.defineProperty(UIEvent.prototype, z, UIEventProto[z]); + } + function addTap(el, tap, e) { + if (!el.__tap__) { + el.__tap__ = { + click: e.type == "mousedown" + }; + if (el.__tap__.click) el.addEventListener("click", tap.observer); else { + el.__tap__.scroll = tap.observer.bind(el); + window.addEventListener("scroll", el.__tap__.scroll, true); + el.addEventListener("touchmove", tap.observer); + el.addEventListener("touchcancel", tap.observer); + el.addEventListener("touchend", tap.observer); + } + } + if (!el.__tap__.click) { + el.__tap__.x = e.touches[0].pageX; + el.__tap__.y = e.touches[0].pageY; + } + } + function removeTap(el, tap) { + if (el.__tap__) { + if (el.__tap__.click) el.removeEventListener("click", tap.observer); else { + window.removeEventListener("scroll", el.__tap__.scroll, true); + el.removeEventListener("touchmove", tap.observer); + el.removeEventListener("touchcancel", tap.observer); + el.removeEventListener("touchend", tap.observer); + } + delete el.__tap__; + } + } + function checkTapPosition(el, tap, e) { + var touch = e.changedTouches[0], tol = tap.gesture.tolerance; + if (touch.pageX < el.__tap__.x + tol && touch.pageX > el.__tap__.x - tol && touch.pageY < el.__tap__.y + tol && touch.pageY > el.__tap__.y - tol) return true; + } + xtag.customEvents.tap = { + observe: { + mousedown: document, + touchstart: document + }, + gesture: { + tolerance: 8 + }, + condition: function(e, tap) { + var el = e.target; + switch (e.type) { + case "touchstart": + if (el.__tap__ && el.__tap__.click) removeTap(el, tap); + addTap(el, tap, e); + return; + + case "mousedown": + if (!el.__tap__) addTap(el, tap, e); + return; + + case "scroll": + case "touchcancel": + removeTap(this, tap); + return; + + case "touchmove": + case "touchend": + if (this.__tap__ && !checkTapPosition(this, tap, e)) { + removeTap(this, tap); + return; + } + return e.type == "touchend" || null; + + case "click": + removeTap(this, tap); + return true; + } + } + }; + win.xtag = xtag; + if (typeof define == "function" && define.amd) define(xtag); + doc.addEventListener("WebComponentsReady", function() { + xtag.fireEvent(doc.body, "DOMComponentsLoaded"); + }); +})(); + +(function() { + xtag.register("x-appbar", { + lifecycle: { + created: function() { + var header = xtag.queryChildren(this, "h1,h2,h3,h4,h5,h6")[0]; + if (!header) { + header = document.createElement("h1"); + this.appendChild(header); + } + this.xtag.data.header = header; + this.subheading = this.subheading; + } + }, + accessors: { + heading: { + attribute: {}, + get: function() { + return this.xtag.data.header.innerHTML; + }, + set: function(value) { + this.xtag.data.header.innerHTML = value; + } + }, + subheading: { + attribute: {}, + get: function() { + return this.getAttribute("subheading") || ""; + }, + set: function(value) { + this.xtag.data.header.setAttribute("subheading", value); + } + } + } + }); +})(); + +(function() { + var LEFT_MOUSE_BTN = 0; + var GET_DEFAULT_LABELS = function() { + return { + prev: "←", + next: "→", + months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], + weekdays: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ] + }; + }; + function normalize(localDate) { + var normalizedDate = new Date(localDate.valueOf()); + normalizedDate.setHours(0); + normalizedDate.setMinutes(0); + normalizedDate.setSeconds(0); + normalizedDate.setMilliseconds(0); + return normalizedDate; + } + var TODAY = normalize(new Date()); + var DRAG_ADD = "add"; + var DRAG_REMOVE = "remove"; + var CHOSEN_CLASS = "chosen"; + var className = "className"; + function appendChild(parent, child) { + parent.appendChild(child); + } + function parseIntDec(num) { + return parseInt(num, 10); + } + function isWeekdayNum(dayNum) { + var dayInt = parseIntDec(dayNum); + return dayInt === dayNum && !isNaN(dayInt) && dayInt >= 0 && dayInt <= 6; + } + function isValidDateObj(d) { + return d instanceof Date && !!d.getTime && !isNaN(d.getTime()); + } + function isArray(a) { + if (a && a.isArray) { + return a.isArray(); + } else { + return Object.prototype.toString.call(a) === "[object Array]"; + } + } + function makeEl(s) { + var a = s.split("."); + var tag = a.shift(); + var el = document.createElement(tag); + el[className] = a.join(" "); + return el; + } + function getWindowViewport() { + var docElem = document.documentElement; + var rect = { + left: docElem.scrollLeft || document.body.scrollLeft || 0, + top: docElem.scrollTop || document.body.scrollTop || 0, + width: docElem.clientWidth, + height: docElem.clientHeight + }; + rect.right = rect.left + rect.width; + rect.bottom = rect.top + rect.height; + return rect; + } + function getRect(el) { + var rect = el.getBoundingClientRect(); + var viewport = getWindowViewport(); + var docScrollLeft = viewport.left; + var docScrollTop = viewport.top; + return { + left: rect.left + docScrollLeft, + right: rect.right + docScrollLeft, + top: rect.top + docScrollTop, + bottom: rect.bottom + docScrollTop, + width: rect.width, + height: rect.height + }; + } + function addClass(el, c) { + xtag.addClass(el, c); + } + function removeClass(el, c) { + xtag.removeClass(el, c); + } + function hasClass(el, c) { + return xtag.hasClass(el, c); + } + function getYear(d) { + return d.getFullYear(); + } + function getMonth(d) { + return d.getMonth(); + } + function getDate(d) { + return d.getDate(); + } + function getDay(d) { + return d.getDay(); + } + function pad(n, padSize) { + var str = n.toString(); + var padZeros = new Array(padSize).join("0"); + return (padZeros + str).substr(-padSize); + } + function iso(d) { + return [ pad(getYear(d), 4), pad(getMonth(d) + 1, 2), pad(getDate(d), 2) ].join("-"); + } + var ISO_DATE_REGEX = /(\d{4})[^\d]?(\d{2})[^\d]?(\d{2})/; + function fromIso(s) { + if (isValidDateObj(s)) { + return s; + } + var d = ISO_DATE_REGEX.exec(s); + if (d) { + return normalize(new Date(d[1], d[2] - 1, d[3])); + } else { + return null; + } + } + function parseSingleDate(dateStr) { + if (isValidDateObj(dateStr)) { + return dateStr; + } + var isoParsed = fromIso(dateStr); + if (isoParsed) { + return isoParsed; + } else { + var parsedMs = Date.parse(dateStr); + if (!isNaN(parsedMs)) { + return normalize(new Date(parsedMs)); + } + return null; + } + } + function parseMultiDates(multiDateStr) { + var ranges; + if (isArray(multiDateStr)) { + ranges = multiDateStr.slice(0); + } else if (isValidDateObj(multiDateStr)) { + return [ multiDateStr ]; + } else if (typeof multiDateStr === "string" && multiDateStr.length > 0) { + try { + ranges = JSON.parse(multiDateStr); + if (!isArray(ranges)) { + return null; + } + } catch (err) { + var parsedSingle = parseSingleDate(multiDateStr); + if (parsedSingle) { + return [ parsedSingle ]; + } else { + return null; + } + } + } else { + return null; + } + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i]; + if (isValidDateObj(range)) { + continue; + } else if (typeof range === "string") { + var parsedDate = parseSingleDate(range); + if (!parsedDate) { + return null; + } + ranges[i] = parsedDate; + } else if (isArray(range) && range.length === 2) { + var parsedStartDate = parseSingleDate(range[0]); + if (!parsedStartDate) { + return null; + } + var parsedEndDate = parseSingleDate(range[1]); + if (!parsedEndDate) { + return null; + } + if (parsedStartDate.valueOf() > parsedEndDate.valueOf()) { + return null; + } + ranges[i] = [ parsedStartDate, parsedEndDate ]; + } else { + return null; + } + } + return ranges; + } + function from(base, y, m, d) { + if (y === undefined) { + y = getYear(base); + } + if (m === undefined) { + m = getMonth(base); + } + if (d === undefined) { + d = getDate(base); + } + return normalize(new Date(y, m, d)); + } + function daysInMonth(month, year) { + if (!year) { + year = new Date().getFullYear(); + } + return new Date(year, month + 1, 0).getDate(); + } + function relOffset(base, y, m, d) { + return from(base, getYear(base) + y, getMonth(base) + m, getDate(base) + d); + } + function nextMonth(d) { + var date = d.getDate(); + var daysInNextMonth = daysInMonth(d.getMonth() + 1, d.getFullYear()); + if (date > daysInNextMonth) { + date = daysInNextMonth; + } + return new Date(d.getFullYear(), d.getMonth() + 1, date); + } + function prevMonth(d) { + var date = d.getDate(); + var daysInPrevMonth = daysInMonth(d.getMonth() - 1, d.getFullYear()); + if (date > daysInPrevMonth) { + date = daysInPrevMonth; + } + return new Date(d.getFullYear(), d.getMonth() - 1, date); + } + function findWeekStart(d, firstWeekday) { + firstWeekday = parseIntDec(firstWeekday); + if (!isWeekdayNum(firstWeekday)) { + firstWeekday = 0; + } + for (var step = 0; step < 7; step++) { + if (getDay(d) === firstWeekday) { + return d; + } else { + d = prevDay(d); + } + } + throw "unable to find week start"; + } + function findWeekEnd(d, lastWeekDay) { + lastWeekDay = parseIntDec(lastWeekDay); + if (!isWeekdayNum(lastWeekDay)) { + lastWeekDay = 6; + } + for (var step = 0; step < 7; step++) { + if (getDay(d) === lastWeekDay) { + return d; + } else { + d = nextDay(d); + } + } + throw "unable to find week end"; + } + function findFirst(d) { + d = new Date(d.valueOf()); + d.setDate(1); + return normalize(d); + } + function findLast(d) { + return prevDay(relOffset(d, 0, 1, 0)); + } + function nextDay(d) { + return relOffset(d, 0, 0, 1); + } + function prevDay(d) { + return relOffset(d, 0, 0, -1); + } + function dateMatches(d, matches) { + if (!matches) { + return; + } + matches = matches.length === undefined ? [ matches ] : matches; + var foundMatch = false; + matches.forEach(function(match) { + if (match.length === 2) { + if (dateInRange(match[0], match[1], d)) { + foundMatch = true; + } + } else { + if (iso(match) === iso(d)) { + foundMatch = true; + } + } + }); + return foundMatch; + } + function dateInRange(start, end, d) { + return iso(start) <= iso(d) && iso(d) <= iso(end); + } + function sortRanges(ranges) { + ranges.sort(function(rangeA, rangeB) { + var dateA = isValidDateObj(rangeA) ? rangeA : rangeA[0]; + var dateB = isValidDateObj(rangeB) ? rangeB : rangeB[0]; + return dateA.valueOf() - dateB.valueOf(); + }); + } + function makeControls(labelData) { + var controls = makeEl("div.controls"); + var prev = makeEl("span.prev"); + var next = makeEl("span.next"); + prev.innerHTML = labelData.prev; + next.innerHTML = labelData.next; + appendChild(controls, prev); + appendChild(controls, next); + return controls; + } + function Calendar(data) { + var self = this; + data = data || {}; + self._span = data.span || 1; + self._multiple = data.multiple || false; + self._viewDate = self._sanitizeViewDate(data.view, data.chosen); + self._chosenRanges = self._sanitizeChosenRanges(data.chosen, data.view); + self._firstWeekdayNum = data.firstWeekdayNum || 0; + self._el = makeEl("div.calendar"); + self._labels = GET_DEFAULT_LABELS(); + self._customRenderFn = null; + self._renderRecursionFlag = false; + self.render(true); + } + var CALENDAR_PROTOTYPE = Calendar.prototype; + CALENDAR_PROTOTYPE.makeMonth = function(d) { + if (!isValidDateObj(d)) { + throw "Invalid view date!"; + } + var firstWeekday = this.firstWeekdayNum; + var chosen = this.chosen; + var labels = this.labels; + var month = getMonth(d); + var sDate = findWeekStart(findFirst(d), firstWeekday); + var monthEl = makeEl("div.month"); + var monthLabel = makeEl("div.month-label"); + monthLabel.textContent = labels.months[month] + " " + getYear(d); + appendChild(monthEl, monthLabel); + var weekdayLabels = makeEl("div.weekday-labels"); + for (var step = 0; step < 7; step++) { + var weekdayNum = (firstWeekday + step) % 7; + var weekdayLabel = makeEl("span.weekday-label"); + weekdayLabel.textContent = labels.weekdays[weekdayNum]; + appendChild(weekdayLabels, weekdayLabel); + } + appendChild(monthEl, weekdayLabels); + var week = makeEl("div.week"); + var cDate = sDate; + var maxDays = 7 * 6; + for (step = 0; step < maxDays; step++) { + var day = makeEl("span.day"); + day.setAttribute("data-date", iso(cDate)); + day.textContent = getDate(cDate); + if (getMonth(cDate) !== month) { + addClass(day, "badmonth"); + } + if (dateMatches(cDate, chosen)) { + addClass(day, CHOSEN_CLASS); + } + if (dateMatches(cDate, TODAY)) { + addClass(day, "today"); + } + appendChild(week, day); + cDate = nextDay(cDate); + if ((step + 1) % 7 === 0) { + appendChild(monthEl, week); + week = makeEl("div.week"); + var done = getMonth(cDate) > month || getMonth(cDate) < month && getYear(cDate) > getYear(sDate); + if (done) { + break; + } + } + } + return monthEl; + }; + CALENDAR_PROTOTYPE._sanitizeViewDate = function(viewDate, chosenRanges) { + chosenRanges = chosenRanges === undefined ? this.chosen : chosenRanges; + var saneDate; + if (isValidDateObj(viewDate)) { + saneDate = viewDate; + } else if (isValidDateObj(chosenRanges)) { + saneDate = chosenRanges; + } else if (isArray(chosenRanges) && chosenRanges.length > 0) { + var firstRange = chosenRanges[0]; + if (isValidDateObj(firstRange)) { + saneDate = firstRange; + } else { + saneDate = firstRange[0]; + } + } else { + saneDate = TODAY; + } + return saneDate; + }; + function _collapseRanges(ranges) { + ranges = ranges.slice(0); + sortRanges(ranges); + var collapsed = []; + for (var i = 0; i < ranges.length; i++) { + var currRange = ranges[i]; + var prevRange = collapsed.length > 0 ? collapsed[collapsed.length - 1] : null; + var currStart, currEnd; + var prevStart, prevEnd; + if (isValidDateObj(currRange)) { + currStart = currEnd = currRange; + } else { + currStart = currRange[0]; + currEnd = currRange[1]; + } + currRange = dateMatches(currStart, currEnd) ? currStart : [ currStart, currEnd ]; + if (isValidDateObj(prevRange)) { + prevStart = prevEnd = prevRange; + } else if (prevRange) { + prevStart = prevRange[0]; + prevEnd = prevRange[1]; + } else { + collapsed.push(currRange); + continue; + } + if (dateMatches(currStart, [ prevRange ]) || dateMatches(prevDay(currStart), [ prevRange ])) { + var minStart = prevStart.valueOf() < currStart.valueOf() ? prevStart : currStart; + var maxEnd = prevEnd.valueOf() > currEnd.valueOf() ? prevEnd : currEnd; + var newRange = dateMatches(minStart, maxEnd) ? minStart : [ minStart, maxEnd ]; + collapsed[collapsed.length - 1] = newRange; + } else { + collapsed.push(currRange); + } + } + return collapsed; + } + CALENDAR_PROTOTYPE._sanitizeChosenRanges = function(chosenRanges, viewDate) { + viewDate = viewDate === undefined ? this.view : viewDate; + var cleanRanges; + if (isValidDateObj(chosenRanges)) { + cleanRanges = [ chosenRanges ]; + } else if (isArray(chosenRanges)) { + cleanRanges = chosenRanges; + } else if (chosenRanges === null || chosenRanges === undefined || !viewDate) { + cleanRanges = []; + } else { + cleanRanges = [ viewDate ]; + } + var collapsedRanges = _collapseRanges(cleanRanges); + if (!this.multiple && collapsedRanges.length > 0) { + var firstRange = collapsedRanges[0]; + if (isValidDateObj(firstRange)) { + return [ firstRange ]; + } else { + return [ firstRange[0] ]; + } + } else { + return collapsedRanges; + } + }; + CALENDAR_PROTOTYPE.addDate = function(dateObj, append) { + if (isValidDateObj(dateObj)) { + if (append) { + this.chosen.push(dateObj); + this.chosen = this.chosen; + } else { + this.chosen = [ dateObj ]; + } + } + }; + CALENDAR_PROTOTYPE.removeDate = function(dateObj) { + if (!isValidDateObj(dateObj)) { + return; + } + var ranges = this.chosen.slice(0); + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i]; + if (dateMatches(dateObj, [ range ])) { + ranges.splice(i, 1); + if (isArray(range)) { + var rangeStart = range[0]; + var rangeEnd = range[1]; + var prevDate = prevDay(dateObj); + var nextDate = nextDay(dateObj); + if (dateMatches(prevDate, [ range ])) { + ranges.push([ rangeStart, prevDate ]); + } + if (dateMatches(nextDate, [ range ])) { + ranges.push([ nextDate, rangeEnd ]); + } + } + this.chosen = _collapseRanges(ranges); + break; + } + } + }; + CALENDAR_PROTOTYPE.hasChosenDate = function(dateObj) { + return dateMatches(dateObj, this._chosenRanges); + }; + CALENDAR_PROTOTYPE.hasVisibleDate = function(dateObj, excludeBadMonths) { + var startDate = excludeBadMonths ? this.firstVisibleMonth : this.firstVisibleDate; + var endDate = excludeBadMonths ? findLast(this.lastVisibleMonth) : this.lastVisibleDate; + return dateMatches(dateObj, [ [ startDate, endDate ] ]); + }; + CALENDAR_PROTOTYPE.render = function(preserveNodes) { + var span = this._span; + var i; + if (!preserveNodes) { + this.el.innerHTML = ""; + var ref = this.firstVisibleMonth; + for (i = 0; i < span; i++) { + appendChild(this.el, this.makeMonth(ref)); + ref = relOffset(ref, 0, 1, 0); + } + } else { + var days = xtag.query(this.el, ".day"); + var day; + for (i = 0; i < days.length; i++) { + day = days[i]; + if (!day.hasAttribute("data-date")) { + continue; + } + var dateIso = day.getAttribute("data-date"); + var parsedDate = fromIso(dateIso); + if (!parsedDate) { + continue; + } else { + if (dateMatches(parsedDate, this._chosenRanges)) { + addClass(day, CHOSEN_CLASS); + } else { + removeClass(day, CHOSEN_CLASS); + } + if (dateMatches(parsedDate, [ TODAY ])) { + addClass(day, "today"); + } else { + removeClass(day, "today"); + } + } + } + } + this._callCustomRenderer(); + }; + CALENDAR_PROTOTYPE._callCustomRenderer = function() { + if (!this._customRenderFn) { + return; + } + if (this._renderRecursionFlag) { + throw "Error: customRenderFn causes recursive loop of " + "rendering calendar; make sure your custom rendering " + "function doesn't modify attributes of the x-calendar that " + "would require a re-render!"; + } + var days = xtag.query(this.el, ".day"); + for (var i = 0; i < days.length; i++) { + var day = days[i]; + var dateIso = day.getAttribute("data-date"); + var parsedDate = fromIso(dateIso); + this._renderRecursionFlag = true; + this._customRenderFn(day, parsedDate ? parsedDate : null, dateIso); + this._renderRecursionFlag = false; + } + }; + Object.defineProperties(CALENDAR_PROTOTYPE, { + el: { + get: function() { + return this._el; + } + }, + multiple: { + get: function() { + return this._multiple; + }, + set: function(multi) { + this._multiple = multi; + this.chosen = this._sanitizeChosenRanges(this.chosen); + this.render(true); + } + }, + span: { + get: function() { + return this._span; + }, + set: function(newSpan) { + var parsedSpan = parseIntDec(newSpan); + if (!isNaN(parsedSpan) && parsedSpan >= 0) { + this._span = parsedSpan; + } else { + this._span = 0; + } + this.render(false); + } + }, + view: { + attribute: {}, + get: function() { + return this._viewDate; + }, + set: function(rawViewDate) { + var newViewDate = this._sanitizeViewDate(rawViewDate); + var oldViewDate = this._viewDate; + this._viewDate = newViewDate; + this.render(getMonth(oldViewDate) === getMonth(newViewDate) && getYear(oldViewDate) === getYear(newViewDate)); + } + }, + chosen: { + get: function() { + return this._chosenRanges; + }, + set: function(newChosenRanges) { + this._chosenRanges = this._sanitizeChosenRanges(newChosenRanges); + this.render(true); + } + }, + firstWeekdayNum: { + get: function() { + return this._firstWeekdayNum; + }, + set: function(weekdayNum) { + weekdayNum = parseIntDec(weekdayNum); + if (!isWeekdayNum(weekdayNum)) { + weekdayNum = 0; + } + this._firstWeekdayNum = weekdayNum; + this.render(false); + } + }, + lastWeekdayNum: { + get: function() { + return (this._firstWeekdayNum + 6) % 7; + } + }, + customRenderFn: { + get: function() { + return this._customRenderFn; + }, + set: function(newRenderFn) { + this._customRenderFn = newRenderFn; + this.render(true); + } + }, + chosenString: { + get: function() { + if (this.multiple) { + var isoDates = this.chosen.slice(0); + for (var i = 0; i < isoDates.length; i++) { + var range = isoDates[i]; + if (isValidDateObj(range)) { + isoDates[i] = iso(range); + } else { + isoDates[i] = [ iso(range[0]), iso(range[1]) ]; + } + } + return JSON.stringify(isoDates); + } else if (this.chosen.length > 0) { + return iso(this.chosen[0]); + } else { + return ""; + } + } + }, + firstVisibleMonth: { + get: function() { + return findFirst(this.view); + } + }, + lastVisibleMonth: { + get: function() { + return relOffset(this.firstVisibleMonth, 0, Math.max(0, this.span - 1), 0); + } + }, + firstVisibleDate: { + get: function() { + return findWeekStart(this.firstVisibleMonth, this.firstWeekdayNum); + } + }, + lastVisibleDate: { + get: function() { + return findWeekEnd(findLast(this.lastVisibleMonth), this.lastWeekdayNum); + } + }, + labels: { + get: function() { + return this._labels; + }, + set: function(newLabelData) { + var oldLabelData = this.labels; + for (var labelType in oldLabelData) { + if (!(labelType in newLabelData)) { + continue; + } + var oldLabel = this._labels[labelType]; + var newLabel = newLabelData[labelType]; + if (isArray(oldLabel)) { + if (isArray(newLabel) && oldLabel.length === newLabel.length) { + newLabel = newLabel.slice(0); + for (var i = 0; i < newLabel.length; i++) { + newLabel[i] = newLabel[i].toString ? newLabel[i].toString() : String(newLabel[i]); + } + } else { + throw "invalid label given for '" + labelType + "': expected array of " + oldLabel.length + " labels, got " + JSON.stringify(newLabel); + } + } else { + newLabel = String(newLabel); + } + oldLabelData[labelType] = newLabel; + } + this.render(false); + } + } + }); + function _onDragStart(xCalendar, day) { + var isoDate = day.getAttribute("data-date"); + var dateObj = parseSingleDate(isoDate); + var toggleEventName; + if (hasClass(day, CHOSEN_CLASS)) { + xCalendar.xtag.dragType = DRAG_REMOVE; + toggleEventName = "datetoggleoff"; + } else { + xCalendar.xtag.dragType = DRAG_ADD; + toggleEventName = "datetoggleon"; + } + xCalendar.xtag.dragStartEl = day; + xCalendar.xtag.dragAllowTap = true; + if (!xCalendar.noToggle) { + xtag.fireEvent(xCalendar, toggleEventName, { + detail: { + date: dateObj, + iso: isoDate + } + }); + } + xCalendar.setAttribute("active", true); + day.setAttribute("active", true); + } + function _onDragMove(xCalendar, day) { + var isoDate = day.getAttribute("data-date"); + var dateObj = parseSingleDate(isoDate); + if (day !== xCalendar.xtag.dragStartEl) { + xCalendar.xtag.dragAllowTap = false; + } + if (!xCalendar.noToggle) { + if (xCalendar.xtag.dragType === DRAG_ADD && !hasClass(day, CHOSEN_CLASS)) { + xtag.fireEvent(xCalendar, "datetoggleon", { + detail: { + date: dateObj, + iso: isoDate + } + }); + } else if (xCalendar.xtag.dragType === DRAG_REMOVE && hasClass(day, CHOSEN_CLASS)) { + xtag.fireEvent(xCalendar, "datetoggleoff", { + detail: { + date: dateObj, + iso: isoDate + } + }); + } + } + if (xCalendar.xtag.dragType) { + day.setAttribute("active", true); + } + } + function _onDragEnd() { + var xCalendars = xtag.query(document, "x-calendar"); + for (var i = 0; i < xCalendars.length; i++) { + var xCalendar = xCalendars[i]; + xCalendar.xtag.dragType = null; + xCalendar.xtag.dragStartEl = null; + xCalendar.xtag.dragAllowTap = false; + xCalendar.removeAttribute("active"); + } + var days = xtag.query(document, "x-calendar .day[active]"); + for (var j = 0; j < days.length; j++) { + days[j].removeAttribute("active"); + } + } + function _pointIsInRect(x, y, rect) { + return rect.left <= x && x <= rect.right && rect.top <= y && y <= rect.bottom; + } + var DOC_MOUSEUP_LISTENER = null; + var DOC_TOUCHEND_LISTENER = null; + xtag.register("x-calendar", { + lifecycle: { + created: function() { + this.innerHTML = ""; + var chosenRange = this.getAttribute("chosen"); + this.xtag.calObj = new Calendar({ + span: this.getAttribute("span"), + view: parseSingleDate(this.getAttribute("view")), + chosen: parseMultiDates(chosenRange), + multiple: this.hasAttribute("multiple"), + firstWeekdayNum: this.getAttribute("first-weekday-num") + }); + appendChild(this, this.xtag.calObj.el); + this.xtag.calControls = null; + this.xtag.dragType = null; + this.xtag.dragStartEl = null; + this.xtag.dragAllowTap = false; + }, + inserted: function() { + if (!DOC_MOUSEUP_LISTENER) { + DOC_MOUSEUP_LISTENER = xtag.addEvent(document, "mouseup", _onDragEnd); + } + if (!DOC_TOUCHEND_LISTENER) { + DOC_TOUCHEND_LISTENER = xtag.addEvent(document, "touchend", _onDragEnd); + } + this.render(false); + }, + removed: function() { + if (xtag.query(document, "x-calendar").length === 0) { + if (DOC_MOUSEUP_LISTENER) { + xtag.removeEvent(document, "mouseup", DOC_MOUSEUP_LISTENER); + DOC_MOUSEUP_LISTENER = null; + } + if (DOC_TOUCHEND_LISTENER) { + xtag.removeEvent(document, "touchend", DOC_TOUCHEND_LISTENER); + DOC_TOUCHEND_LISTENER = null; + } + } + } + }, + events: { + "tap:delegate(.next)": function(e) { + var xCalendar = e.currentTarget; + xCalendar.nextMonth(); + xtag.fireEvent(xCalendar, "nextmonth"); + }, + "tap:delegate(.prev)": function(e) { + var xCalendar = e.currentTarget; + xCalendar.prevMonth(); + xtag.fireEvent(xCalendar, "prevmonth"); + }, + "tapstart:delegate(.day)": function(e) { + if (!e.touches && e.button && e.button !== LEFT_MOUSE_BTN) { + return; + } + e.preventDefault(); + if (e.baseEvent) { + e.baseEvent.preventDefault(); + } + _onDragStart(e.currentTarget, this); + }, + touchmove: function(e) { + if (!(e.touches && e.touches.length > 0)) { + return; + } + var xCalendar = e.currentTarget; + if (!xCalendar.xtag.dragType) { + return; + } + var touch = e.touches[0]; + var days = xtag.query(xCalendar, ".day"); + for (var i = 0; i < days.length; i++) { + var day = days[i]; + if (_pointIsInRect(touch.pageX, touch.pageY, getRect(day))) { + _onDragMove(xCalendar, day); + } else { + day.removeAttribute("active"); + } + } + }, + "mouseover:delegate(.day)": function(e) { + var xCalendar = e.currentTarget; + var day = this; + _onDragMove(xCalendar, day); + }, + "mouseout:delegate(.day)": function() { + var day = this; + day.removeAttribute("active"); + }, + "tapend:delegate(.day)": function(e) { + var xCalendar = e.currentTarget; + if (!xCalendar.xtag.dragAllowTap) { + return; + } + var day = this; + var isoDate = day.getAttribute("data-date"); + var dateObj = parseSingleDate(isoDate); + xtag.fireEvent(xCalendar, "datetap", { + detail: { + date: dateObj, + iso: isoDate + } + }); + }, + datetoggleon: function(e) { + var xCalendar = this; + xCalendar.toggleDateOn(e.detail.date, xCalendar.multiple); + }, + datetoggleoff: function(e) { + var xCalendar = this; + xCalendar.toggleDateOff(e.detail.date); + } + }, + accessors: { + controls: { + attribute: { + "boolean": true + }, + set: function(hasControls) { + if (hasControls && !this.xtag.calControls) { + this.xtag.calControls = makeControls(this.xtag.calObj.labels); + appendChild(this, this.xtag.calControls); + } + } + }, + multiple: { + attribute: { + "boolean": true + }, + get: function() { + return this.xtag.calObj.multiple; + }, + set: function(multi) { + this.xtag.calObj.multiple = multi; + this.chosen = this.chosen; + } + }, + span: { + attribute: {}, + get: function() { + return this.xtag.calObj.span; + }, + set: function(newCalSpan) { + this.xtag.calObj.span = newCalSpan; + } + }, + view: { + attribute: {}, + get: function() { + return this.xtag.calObj.view; + }, + set: function(newView) { + var parsedDate = parseSingleDate(newView); + if (parsedDate) { + this.xtag.calObj.view = parsedDate; + } + } + }, + chosen: { + attribute: { + skip: true + }, + get: function() { + var chosenRanges = this.xtag.calObj.chosen; + if (!this.multiple) { + if (chosenRanges.length > 0) { + var firstRange = chosenRanges[0]; + if (isValidDateObj(firstRange)) { + return firstRange; + } else { + return firstRange[0]; + } + } else { + return null; + } + } else { + return this.xtag.calObj.chosen; + } + }, + set: function(newDates) { + var parsedDateRanges = this.multiple ? parseMultiDates(newDates) : parseSingleDate(newDates); + if (parsedDateRanges) { + this.xtag.calObj.chosen = parsedDateRanges; + } else { + this.xtag.calObj.chosen = null; + } + if (this.xtag.calObj.chosenString) { + this.setAttribute("chosen", this.xtag.calObj.chosenString); + } else { + this.removeAttribute("chosen"); + } + } + }, + firstWeekdayNum: { + attribute: { + name: "first-weekday-num" + }, + set: function(weekdayNum) { + this.xtag.calObj.firstWeekdayNum = weekdayNum; + } + }, + noToggle: { + attribute: { + "boolean": true, + name: "notoggle" + }, + set: function(toggleDisabled) { + if (toggleDisabled) { + this.chosen = null; + } + } + }, + firstVisibleMonth: { + get: function() { + return this.xtag.calObj.firstVisibleMonth; + } + }, + lastVisibleMonth: { + get: function() { + return this.xtag.calObj.lastVisibleMonth; + } + }, + firstVisibleDate: { + get: function() { + return this.xtag.calObj.firstVisibleDate; + } + }, + lastVisibleDate: { + get: function() { + return this.xtag.calObj.lastVisibleDate; + } + }, + customRenderFn: { + get: function() { + return this.xtag.calObj.customRenderFn; + }, + set: function(newRenderFn) { + this.xtag.calObj.customRenderFn = newRenderFn; + } + }, + labels: { + get: function() { + return JSON.parse(JSON.stringify(this.xtag.calObj.labels)); + }, + set: function(newLabelData) { + this.xtag.calObj.labels = newLabelData; + var labels = this.xtag.calObj.labels; + var prevControl = this.querySelector(".controls > .prev"); + if (prevControl) { + prevControl.textContent = labels.prev; + } + var nextControl = this.querySelector(".controls > .next"); + if (nextControl) { + nextControl.textContent = labels.next; + } + } + } + }, + methods: { + render: function(preserveNodes) { + this.xtag.calObj.render(preserveNodes); + }, + prevMonth: function() { + var calObj = this.xtag.calObj; + calObj.view = prevMonth(calObj.view); + }, + nextMonth: function() { + var calObj = this.xtag.calObj; + calObj.view = nextMonth(calObj.view); + }, + toggleDateOn: function(newDateObj, append) { + this.xtag.calObj.addDate(newDateObj, append); + this.chosen = this.chosen; + }, + toggleDateOff: function(dateObj) { + this.xtag.calObj.removeDate(dateObj); + this.chosen = this.chosen; + }, + toggleDate: function(dateObj, appendIfAdd) { + if (this.xtag.calObj.hasChosenDate(dateObj)) { + this.toggleDateOff(dateObj); + } else { + this.toggleDateOn(dateObj, appendIfAdd); + } + }, + hasVisibleDate: function(dateObj, excludeBadMonths) { + return this.xtag.calObj.hasVisibleDate(dateObj, excludeBadMonths); + } + } + }); +})(); + +(function() { + var matchNum = /[1-9]/; + var replaceSpaces = / /g; + var captureTimes = /(\d|\d+?[.]?\d+?)(s|ms)(?!\w)/gi; + var transPre = "transition" in getComputedStyle(document.documentElement) ? "t" : xtag.prefix.js + "T"; + var transDur = transPre + "ransitionDuration"; + var transProp = transPre + "ransitionProperty"; + var skipFrame = function(fn) { + xtag.requestFrame(function() { + xtag.requestFrame(fn); + }); + }; + var ready; + if (document.readyState == "complete") { + ready = skipFrame(function() { + ready = false; + }); + } else { + ready = xtag.addEvent(document, "readystatechange", function() { + if (document.readyState == "complete") { + skipFrame(function() { + ready = false; + }); + xtag.removeEvent(document, "readystatechange", ready); + } + }); + } + function getTransitions(node) { + node.__transitions__ = node.__transitions__ || {}; + return node.__transitions__; + } + function startTransition(node, name, transitions) { + var style = getComputedStyle(node), after = transitions[name].after; + node.setAttribute("transition", name); + if (after && !style[transDur].match(matchNum)) { + after(); + } + } + xtag.addEvents(document, { + transitionend: function(e) { + var node = e.target, name = node.getAttribute("transition"); + if (name) { + var i = 0, max = 0, prop = null, style = getComputedStyle(node), transitions = getTransitions(node), props = style[transProp].replace(replaceSpaces, "").split(","); + style[transDur].replace(captureTimes, function(match, time, unit) { + time = parseFloat(time) * (unit === "s" ? 1e3 : 1); + if (time > max) { + prop = i; + max = time; + } + i++; + }); + prop = props[prop]; + if (!prop) { + throw new SyntaxError("No matching transition property found"); + } else if (e.propertyName == prop && transitions[name].after) { + transitions[name].after(); + } + } + } + }); + xtag.transition = function(node, name, obj) { + var transitions = getTransitions(node), options = transitions[name] = obj || {}; + if (options.immediate) { + options.immediate(); + } + if (options.before) { + options.before(); + if (ready) { + xtag.skipTransition(node, function() { + startTransition(node, name, transitions); + }); + } else { + skipFrame(function() { + startTransition(node, name, transitions); + }); + } + } else { + startTransition(node, name, transitions); + } + }; + xtag.pseudos.transition = { + onCompiled: function(fn, pseudo) { + var options = {}, when = pseudo["arguments"][0] || "immediate", name = pseudo["arguments"][1] || pseudo.key.split(":")[0]; + return function() { + var target = this, args = arguments; + if (this.hasAttribute("transition")) { + options[when] = function() { + return fn.apply(target, args); + }; + xtag.transition(this, name, options); + } else { + return fn.apply(this, args); + } + }; + } + }; +})(); + +(function() { + var sides = { + next: [ "nextElementSibling", "firstElementChild" ], + previous: [ "previousElementSibling", "lastElementChild" ] + }; + function indexOfCard(deck, card) { + return Array.prototype.indexOf.call(deck.children, card); + } + function getCard(deck, item) { + return item && item.nodeName ? item : isNaN(item) ? xtag.queryChildren(deck, item) : deck.children[item]; + } + function checkCard(deck, card, selected) { + return card && (selected ? card == deck.xtag.selected : card != deck.xtag.selected) && deck == card.parentNode && card.nodeName == "X-CARD"; + } + function shuffle(deck, side, direction) { + var getters = sides[side]; + var selected = deck.xtag.selected && deck.xtag.selected[getters[0]]; + if (selected) { + deck.showCard(selected, direction); + } else if (deck.loop || deck.selectedIndex == -1) { + deck.showCard(deck[getters[1]], direction); + } + } + xtag.register("x-deck", { + events: { + "reveal:delegate(x-card)": function(e) { + if (this.parentNode == e.currentTarget) { + e.currentTarget.showCard(this); + } + } + }, + accessors: { + loop: { + attribute: { + "boolean": true + } + }, + cards: { + get: function() { + return xtag.queryChildren(this, "x-card"); + } + }, + selectedCard: { + get: function() { + return this.xtag.selected || null; + }, + set: function(card) { + this.showCard(card); + } + }, + selectedIndex: { + attribute: { + name: "selected-index", + unlink: true + }, + get: function() { + return this.hasAttribute("selected-index") ? Number(this.getAttribute("selected-index")) : -1; + }, + set: function(value) { + var index = Number(value), card = this.cards[index]; + if (card) { + this.setAttribute("selected-index", index); + if (card != this.xtag.selected) { + this.showCard(card); + } + } else { + this.removeAttribute("selected-index"); + if (this.xtag.selected) { + this.hideCard(this.xtag.selected); + } + } + } + }, + transitionType: { + attribute: { + name: "transition-type" + } + } + }, + methods: { + nextCard: function(direction) { + shuffle(this, "next", direction); + }, + previousCard: function(direction) { + shuffle(this, "previous", direction); + }, + showCard: function(item, direction) { + var card = getCard(this, item); + if (checkCard(this, card, false)) { + var selected = this.xtag.selected, nextIndex = indexOfCard(this, card); + direction = direction || (nextIndex > indexOfCard(this, selected) ? "forward" : "reverse"); + if (selected) { + this.hideCard(selected, direction); + } + this.xtag.selected = card; + this.selectedIndex = nextIndex; + if (!card.hasAttribute("selected")) { + card.selected = true; + } + xtag.transition(card, "show", { + before: function() { + card.setAttribute("show", ""); + card.setAttribute("transition-direction", direction); + }, + after: function() { + xtag.fireEvent(card, "show"); + } + }); + } + }, + hideCard: function(item, direction) { + var card = getCard(this, item); + if (checkCard(this, card, true)) { + this.xtag.selected = null; + if (card.hasAttribute("selected")) { + card.selected = false; + } + xtag.transition(card, "hide", { + before: function() { + card.removeAttribute("show"); + card.setAttribute("hide", ""); + card.setAttribute("transition-direction", direction || "reverse"); + }, + after: function() { + card.removeAttribute("hide"); + card.removeAttribute("transition"); + card.removeAttribute("transition-direction"); + xtag.fireEvent(card, "hide"); + } + }); + } + } + } + }); + xtag.register("x-card", { + lifecycle: { + inserted: function() { + var deck = this.parentNode; + if (deck.nodeName == "X-DECK") { + this.xtag.deck = deck; + if (this != deck.selected && this.selected) { + deck.showCard(this); + } + } + }, + removed: function() { + var deck = this.xtag.deck; + if (deck) { + if (this == deck.xtag.selected) { + deck.xtag.selected = null; + deck.removeAttribute("selected-index"); + } else { + deck.showCard(deck.selectedCard); + } + this.xtag.deck = null; + } + } + }, + accessors: { + transitionType: { + attribute: { + name: "transition-type" + } + }, + selected: { + attribute: { + "boolean": true + }, + set: function(val) { + var deck = this.xtag.deck; + if (deck) { + if (val && this != deck.selected) { + deck.showCard(this); + } else if (!val && this == deck.selected) { + deck.hideCard(this); + } + } + } + } + } + }); +})(); + +(function() { + function reveal(e) { + var flipBox = e.currentTarget; + if (this.parentNode == flipBox) { + if (this.parentNode.firstElementChild == this) { + flipBox.flipped = false; + } else if (this.parentNode.lastElementChild == this) { + flipBox.flipped = true; + } + } + } + xtag.register("x-flipbox", { + lifecycle: { + created: function() { + if (this.firstElementChild) { + xtag.skipTransition(this.firstElementChild, function() {}); + } + if (this.lastElementChild) { + xtag.skipTransition(this.lastElementChild, function() {}); + } + if (!this.hasAttribute("direction")) { + this.xtag._direction = "right"; + } + } + }, + events: { + "transitionend:delegate(x-flipbox > *:first-child)": function(e) { + var flipBox = e.currentTarget; + if (this.parentNode == flipBox) { + xtag.fireEvent(flipBox, "flipend"); + } + }, + "reveal:delegate(x-flipbox > *)": reveal + }, + accessors: { + direction: { + attribute: {}, + get: function() { + return this.xtag._direction; + }, + set: function(value) { + var self = this; + xtag.skipTransition(this.firstElementChild, function() { + self.setAttribute("_anim-direction", value); + return function() {}; + }); + xtag.skipTransition(this.lastElementChild, function() { + self.setAttribute("_anim-direction", value); + }); + this.xtag._direction = value; + } + }, + flipped: { + attribute: { + "boolean": true + } + } + }, + methods: { + toggle: function() { + this.flipped = !this.flipped; + }, + showFront: function() { + this.flipped = false; + }, + showBack: function() { + this.flipped = true; + } + } + }); +})(); + +(function() { + function getLayoutScroll(layout, element) { + var scroll = element.__layoutScroll__ = element.__layoutScroll__ || Object.defineProperty(element, "__layoutScroll__", { + value: { + last: element.scrollTop + } + }).__layoutScroll__; + var now = element.scrollTop, buffer = layout.scrollBuffer; + scroll.max = scroll.max || Math.max(now + buffer, buffer); + scroll.min = scroll.min || Math.max(now - buffer, buffer); + return scroll; + } + function maxContent(layout) { + layout.setAttribute("content-maximizing", null); + } + function minContent(layout) { + layout.removeAttribute("content-maximized"); + layout.removeAttribute("content-maximizing"); + } + function evaluateScroll(event) { + var layout = event.currentTarget; + if (layout.hideTrigger == "scroll" && !event.currentTarget.hasAttribute("content-maximizing")) { + var target = event.target; + if (layout.scrollTarget ? xtag.matchSelector(target, layout.scrollTarget) : target.parentNode == layout) { + var now = target.scrollTop, buffer = layout.scrollBuffer, scroll = getLayoutScroll(layout, target); + if (now > scroll.last) { + scroll.min = Math.max(now - buffer, buffer); + } else if (now < scroll.last) { + scroll.max = Math.max(now + buffer, buffer); + } + if (!layout.maxcontent) { + if (now > scroll.max && !layout.hasAttribute("content-maximized")) { + maxContent(layout); + } else if (now < scroll.min) { + minContent(layout); + } + } + scroll.last = now; + } + } + } + xtag.register("x-layout", { + events: { + scroll: evaluateScroll, + transitionend: function(e) { + var node = e.target; + if (this.hasAttribute("content-maximizing") && node.parentNode == this && (node.nodeName == "HEADER" || node.nodeName == "FOOTER")) { + this.setAttribute("content-maximized", null); + this.removeAttribute("content-maximizing"); + } + }, + "tap:delegate(section)": function(e) { + var layout = e.currentTarget; + if (layout.hideTrigger == "tap" && !layout.maxcontent && this.parentNode == layout) { + if (layout.hasAttribute("content-maximizing") || layout.hasAttribute("content-maximized")) { + minContent(layout); + } else { + maxContent(layout); + } + } + }, + mouseout: function(e) { + if (this.hideTrigger == "hover" && !this.maxcontent && !this.hasAttribute("content-maximized") && (!e.relatedTarget || !this.contains(e.relatedTarget))) { + maxContent(this); + } + }, + mouseover: function(e) { + if (this.hideTrigger == "hover" && !this.maxcontent && (this.hasAttribute("content-maximized") || this.hasAttribute("content-maximizing")) && (this == e.relatedTarget || !this.contains(e.relatedTarget))) { + minContent(this); + } + } + }, + accessors: { + scrollTarget: { + attribute: { + name: "scroll-target" + } + }, + scrollBuffer: { + attribute: { + name: "scroll-buffer" + }, + get: function() { + return Number(this.getAttribute("scroll-buffer")) || 80; + } + }, + hideTrigger: { + attribute: { + name: "hide-trigger" + } + }, + maxcontent: { + attribute: { + "boolean": true + }, + set: function(value) { + if (value) { + maxContent(this); + } else if (!this.hasAttribute("content-maximizing")) { + minContent(this); + } + } + } + } + }); +})(); + +(function() { + var KEYCODES = { + 33: "PAGE_UP", + 34: "PAGE_DOWN", + 35: "END", + 36: "HOME", + 37: "LEFT_ARROW", + 38: "UP_ARROW", + 39: "RIGHT_ARROW", + 40: "DOWN_ARROW" + }; + var LEFT_MOUSE_BTN = 0; + function isNum(num) { + return !isNaN(parseFloat(num)); + } + function hasNumAttr(elem, attrName) { + return elem.hasAttribute(attrName) && isNum(elem.getAttribute(attrName)); + } + function roundToStep(rawRangeVal, step, rangeMin, roundFn) { + roundFn = roundFn ? roundFn : Math.round; + rangeMin = isNum(rangeMin) ? rangeMin : 0; + if (!isNum(rawRangeVal)) { + throw "invalid value " + rawRangeVal; + } + if (!isNum(step) || +step <= 0) { + throw "invalid step " + step; + } + return roundFn((rawRangeVal - rangeMin) / step) * step + rangeMin; + } + function constrainToSteppedRange(value, min, max, step) { + if (value < min) { + return min; + } else if (value > max) { + return Math.max(min, roundToStep(max, step, min, Math.floor)); + } else { + return value; + } + } + function getDefaultVal(min, max, step) { + var roundedVal = roundToStep((max - min) / 2 + min, step, min); + return constrainToSteppedRange(roundedVal, min, max, step); + } + function _rawValToFraction(slider, value) { + var min = slider.min; + var max = slider.max; + return (value - min) / (max - min); + } + function _fractionToRawVal(slider, fraction) { + var min = slider.min; + var max = slider.max; + return (max - min) * fraction + min; + } + function _fractionToCorrectedVal(slider, sliderFraction) { + sliderFraction = Math.min(Math.max(0, sliderFraction), 1); + var rawVal = _fractionToRawVal(slider, sliderFraction); + var roundedVal = roundToStep(rawVal, slider.step, slider.min); + return constrainToSteppedRange(roundedVal, slider.min, slider.max, slider.step); + } + function _positionThumb(slider, value) { + var thumb = slider.xtag.sliderThumb; + if (!thumb) { + return; + } + var sliderRect = slider.getBoundingClientRect(); + var thumbRect = thumb.getBoundingClientRect(); + var fraction = _rawValToFraction(slider, value); + var vertical = slider.vertical; + var sliderWidth = sliderRect[vertical ? "height" : "width"]; + var thumbWidth = thumbRect[vertical ? "height" : "width"]; + var availableWidth = Math.max(sliderWidth - thumbWidth, 0); + var newThumbX = availableWidth * fraction; + var finalPercentage = newThumbX / sliderWidth; + thumb.style[vertical ? "left" : "top"] = 0; + thumb.style[vertical ? "top" : "left"] = finalPercentage * 100 + "%"; + slider.xtag.sliderProgress.style[vertical ? "height" : "width"] = fraction * 100 + "%"; + } + function _redraw(slider) { + _positionThumb(slider, slider.value); + } + function _onMouseInput(slider, pageX, pageY) { + var inputEl = slider.xtag.rangeInputEl; + var inputOffsets = inputEl.getBoundingClientRect(); + var thumbWidth = slider.xtag.sliderThumb.getBoundingClientRect().width; + var inputClickX = pageX - inputOffsets.left - thumbWidth / 2; + var divideby = inputOffsets.width - thumbWidth / 2; + if (slider.vertical) { + divideby = inputOffsets.height; + inputClickX = pageY - inputOffsets.top; + } + slider.value = _fractionToCorrectedVal(slider, inputClickX / divideby); + xtag.fireEvent(slider, "input"); + _redraw(slider); + } + function _onDragStart(slider, pageX, pageY) { + slider.xtag.dragInitVal = slider.value; + _onMouseInput(slider, pageX, pageY); + var callbacks = slider.xtag.callbackFns; + var _addBodyListener = function(event, listener) { + document.body.addEventListener(event, listener); + }; + _addBodyListener("mousemove", callbacks.onMouseDragMove); + _addBodyListener("touchmove", callbacks.onTouchDragMove); + _addBodyListener("mouseup", callbacks.onDragEnd); + _addBodyListener("touchend", callbacks.onDragEnd); + var thumb = slider.xtag.sliderThumb; + if (thumb) { + thumb.setAttribute("active", true); + } + } + function _onDragMove(slider, pageX, pageY) { + _onMouseInput(slider, pageX, pageY); + } + function _makeCallbackFns(slider) { + return { + onMouseDragStart: function(e) { + if (e.button !== LEFT_MOUSE_BTN) { + return; + } + _onDragStart(slider, e.pageX, e.pageY); + e.preventDefault(); + }, + onTouchDragStart: function(e) { + var touches = e.targetTouches; + if (touches.length !== 1) { + return; + } + _onDragStart(slider, touches[0].pageX, touches[0].pageY); + e.preventDefault(); + }, + onMouseDragMove: function(e) { + _onDragMove(slider, e.pageX, e.pageY); + e.preventDefault(); + }, + onTouchDragMove: function(e) { + var touches = e.targetTouches; + if (touches.length !== 1) { + return; + } + _onDragMove(slider, touches[0].pageX, touches[0].pageY); + e.preventDefault(); + }, + onDragEnd: function(e) { + var callbacks = slider.xtag.callbackFns; + var _removeBodyListener = function(event, listener) { + document.body.removeEventListener(event, listener); + }; + _removeBodyListener("mousemove", callbacks.onMouseDragMove); + _removeBodyListener("touchmove", callbacks.onTouchDragMove); + _removeBodyListener("mouseup", callbacks.onDragEnd); + _removeBodyListener("touchend", callbacks.onDragEnd); + var thumb = slider.xtag.sliderThumb; + if (thumb) { + thumb.removeAttribute("active"); + } + if (slider.value !== slider.xtag.dragInitVal) { + xtag.fireEvent(slider, "change"); + } + slider.xtag.dragInitVal = null; + e.preventDefault(); + }, + onKeyDown: function(e) { + var keyCode = e.keyCode; + if (keyCode in KEYCODES) { + var oldVal = this.value; + var min = this.min; + var max = this.max; + var step = this.step; + var rangeSize = Math.max(0, max - min); + var largeStep = Math.max(rangeSize / 10, step); + switch (KEYCODES[keyCode]) { + case "LEFT_ARROW": + case "DOWN_ARROW": + this.value = Math.max(oldVal - step, min); + break; + + case "RIGHT_ARROW": + case "UP_ARROW": + this.value = Math.min(oldVal + step, max); + break; + + case "HOME": + this.value = min; + break; + + case "END": + this.value = max; + break; + + case "PAGE_DOWN": + this.value = Math.max(oldVal - largeStep, min); + break; + + case "PAGE_UP": + this.value = Math.min(oldVal + largeStep, max); + break; + + default: + break; + } + if (this.value !== oldVal) { + xtag.fireEvent(this, "change"); + } + e.preventDefault(); + } + } + }; + } + xtag.register("x-slider", { + lifecycle: { + created: function() { + var self = this; + self.xtag.callbackFns = _makeCallbackFns(self); + self.xtag.dragInitVal = null; + var input = document.createElement("input"); + xtag.addClass(input, "input"); + input.setAttribute("type", "range"); + var initMax = hasNumAttr(self, "max") ? +self.getAttribute("max") : 100; + var initMin = hasNumAttr(self, "min") ? +self.getAttribute("min") : 0; + var initStep = hasNumAttr(self, "step") ? +self.getAttribute("step") : 1; + initStep = initStep > 0 ? initStep : 1; + var initVal = hasNumAttr(self, "value") ? +self.getAttribute("value") : getDefaultVal(initMin, initMax, initStep); + input.setAttribute("max", initMax); + input.setAttribute("min", initMin); + input.setAttribute("step", initStep); + input.setAttribute("value", initVal); + self.xtag.rangeInputEl = input; + self.appendChild(self.xtag.rangeInputEl); + var sliderTrack = document.createElement("div"); + xtag.addClass(sliderTrack, "slider-track"); + this.xtag.sliderTrack = sliderTrack; + this.appendChild(sliderTrack); + var sliderProgress = document.createElement("div"); + xtag.addClass(sliderProgress, "slider-progress"); + this.xtag.sliderProgress = sliderProgress; + sliderTrack.appendChild(sliderProgress); + var sliderThumb = document.createElement("span"); + xtag.addClass(sliderThumb, "slider-thumb"); + this.xtag.sliderThumb = sliderThumb; + this.appendChild(sliderThumb); + if (input.type !== "range" || self.hasAttribute("polyfill")) { + self.setAttribute("polyfill", true); + } else { + self.removeAttribute("polyfill"); + } + this.addEventListener("mousedown", self.xtag.callbackFns.onMouseDragStart); + this.addEventListener("touchstart", self.xtag.callbackFns.onTouchDragStart); + this.addEventListener("keydown", self.xtag.callbackFns.onKeyDown); + self.setAttribute("value", initVal); + }, + inserted: function() { + var self = this; + xtag.requestFrame(function() { + xtag.requestFrame(function() { + _redraw(self); + }); + }); + }, + attributeChanged: function(property) { + if (property == "min" || property == "max" || property == "step") { + _redraw(this); + } + } + }, + events: { + "change:delegate(input[type=range])": function(e) { + e.stopPropagation(); + xtag.fireEvent(e.currentTarget, "change"); + }, + "input:delegate(input[type=range])": function(e) { + e.stopPropagation(); + xtag.fireEvent(e.currentTarget, "input"); + }, + "focus:delegate(input[type=range])": function(e) { + var slider = e.currentTarget; + xtag.fireEvent(slider, "focus", {}, { + bubbles: false + }); + }, + "blur:delegate(input[type=range])": function(e) { + var slider = e.currentTarget; + xtag.fireEvent(slider, "blur", {}, { + bubbles: false + }); + } + }, + accessors: { + polyfill: { + attribute: { + "boolean": true + }, + set: function(isPolyfill) { + var callbackFns = this.xtag.callbackFns; + if (isPolyfill) { + this.setAttribute("tabindex", 0); + this.xtag.rangeInputEl.setAttribute("tabindex", -1); + this.xtag.rangeInputEl.setAttribute("readonly", true); + _redraw(this); + } else { + this.removeAttribute("tabindex"); + this.xtag.rangeInputEl.removeAttribute("tabindex"); + this.xtag.rangeInputEl.removeAttribute("readonly"); + } + } + }, + vertical: { + attribute: { + "boolean": true + }, + set: function() { + _redraw(this); + } + }, + max: { + attribute: { + selector: "input[type=range]" + }, + get: function() { + return +this.xtag.rangeInputEl.getAttribute("max"); + } + }, + min: { + attribute: { + selector: "input[type=range]" + }, + get: function() { + return +this.xtag.rangeInputEl.getAttribute("min"); + } + }, + step: { + attribute: { + selector: "input[type=range]" + }, + get: function() { + return +this.xtag.rangeInputEl.getAttribute("step"); + } + }, + name: { + attribute: { + selector: "input[type=range]" + }, + set: function(newName) { + var input = this.xtag.rangeInputEl; + if (newName === null || newName === undefined) { + input.removeAttribute("name"); + } else { + input.setAttribute("name", newName); + } + } + }, + value: { + attribute: { + selector: "input[type=range]" + }, + get: function() { + return +this.xtag.rangeInputEl.value; + }, + set: function(rawVal) { + if (!isNum(rawVal)) { + rawVal = getDefaultVal(this.min, this.max, this.step); + } + rawVal = +rawVal; + var min = this.min; + var max = this.max; + var step = this.step; + var roundedVal = roundToStep(rawVal, step, min); + var finalVal = constrainToSteppedRange(roundedVal, min, max, step); + this.xtag.rangeInputEl.value = finalVal; + _redraw(this); + } + }, + inputElem: { + get: function() { + return this.xtag.rangeInputEl; + } + } + }, + methods: {} + }); +})(); + +(function() { + function getWindowViewport() { + var docElem = document.documentElement; + var rect = { + left: docElem.scrollLeft || document.body.scrollLeft || 0, + top: docElem.scrollTop || document.body.scrollTop || 0, + width: docElem.clientWidth, + height: docElem.clientHeight + }; + rect.right = rect.left + rect.width; + rect.bottom = rect.top + rect.height; + return rect; + } + function getRect(el) { + var rect = el.getBoundingClientRect(); + var viewport = getWindowViewport(); + var docScrollLeft = viewport.left; + var docScrollTop = viewport.top; + return { + left: rect.left + docScrollLeft, + right: rect.right + docScrollLeft, + top: rect.top + docScrollTop, + bottom: rect.bottom + docScrollTop, + width: rect.width, + height: rect.height + }; + } + function _pointIsInRect(x, y, rect) { + return rect.left <= x && x <= rect.right && rect.top <= y && y <= rect.bottom; + } + xtag.register("x-tabbar", { + lifecycle: { + created: function() { + this.xtag.overallEventToFire = "reveal"; + } + }, + events: { + "tap:delegate(x-tabbar-tab)": function() { + var activeTab = xtag.query(this.parentNode, "x-tabbar-tab[selected]"); + if (activeTab.length) { + activeTab.forEach(function(t) { + t.removeAttribute("selected"); + }); + } + this.setAttribute("selected", true); + } + }, + accessors: { + tabs: { + get: function() { + return xtag.queryChildren(this, "x-tabbar-tab"); + } + }, + targetEvent: { + attribute: { + name: "target-event" + }, + get: function() { + return this.xtag.overallEventToFire; + }, + set: function(newEventType) { + this.xtag.overallEventToFire = newEventType; + } + } + }, + methods: {} + }); + function _onTabbarTabTap(tabEl) { + if (tabEl.parentNode.nodeName.toLowerCase() === "x-tabbar") { + var targetEvent = tabEl.targetEvent; + var targets = tabEl.targetSelector ? xtag.query(document, tabEl.targetSelector) : tabEl.targetElems; + targets.forEach(function(targ) { + xtag.fireEvent(targ, targetEvent); + }); + } + } + xtag.register("x-tabbar-tab", { + lifecycle: { + created: function() { + this.xtag.targetSelector = null; + this.xtag.overrideTargetElems = null; + this.xtag.targetEvent = null; + } + }, + events: { + tap: function(e) { + var tabEl = e.currentTarget; + if (e.changedTouches && e.changedTouches.length > 0) { + var releasedTouch = e.changedTouches[0]; + var tabRect = getRect(tabEl); + if (_pointIsInRect(releasedTouch.pageX, releasedTouch.pageY, tabRect)) { + _onTabbarTabTap(tabEl); + } + } else { + _onTabbarTabTap(tabEl); + } + } + }, + accessors: { + targetSelector: { + attribute: { + name: "target-selector" + }, + get: function() { + return this.xtag.targetSelector; + }, + set: function(newTargetSelector) { + this.xtag.targetSelector = newTargetSelector; + if (newTargetSelector) { + this.xtag.overrideTargetElems = null; + } + } + }, + targetElems: { + get: function() { + if (this.targetSelector) { + return xtag.query(document, this.targetSelector); + } else if (this.xtag.overrideTargetElems !== null) { + return this.xtag.overrideTargetElems; + } else { + return []; + } + }, + set: function(newElems) { + this.removeAttribute("target-selector"); + this.xtag.overrideTargetElems = newElems; + } + }, + targetEvent: { + attribute: { + name: "target-event" + }, + get: function() { + if (this.xtag.targetEvent) { + return this.xtag.targetEvent; + } else if (this.parentNode.nodeName.toLowerCase() === "x-tabbar") { + return this.parentNode.targetEvent; + } else { + throw "tabbar-tab is missing event to fire"; + } + }, + set: function(newEvent) { + this.xtag.targetEvent = newEvent; + } + } + }, + methods: {} + }); +})(); + +(function() { + function setScope(toggle) { + var form = toggle.xtag.input.form; + if (form) toggle.removeAttribute("x-toggle-no-form"); else toggle.setAttribute("x-toggle-no-form", ""); + toggle.xtag.scope = toggle.parentNode ? form || document : null; + } + function updateScope(scope) { + var names = {}; + var docSelector = scope == document ? "[x-toggle-no-form]" : ""; + xtag.query(scope, "x-toggle[name]" + docSelector).forEach(function(toggle) { + var name = toggle.name; + if (name && !names[name]) { + var named = xtag.query(scope, 'x-toggle[name="' + name + '"]' + docSelector); + var type = named.length > 1 ? "radio" : "checkbox"; + named.forEach(function(toggle) { + if (toggle.xtag && toggle.xtag.input) { + toggle.type = type; + } + }); + names[name] = true; + } + }); + } + function toggleGroup(toggle) { + if (shifted && toggle.group && toggle.type != "radio") { + var toggles = toggle.groupToggles; + var selector = 'x-toggle[group="' + toggle.group + '"][active]'; + var active = toggle.xtag.scope.querySelector(selector); + if (active && toggle != active) { + toggle.checked = active.checked; + var state = active.checked; + var index = toggles.indexOf(toggle); + var activeIndex = toggles.indexOf(active); + var minIndex = Math.min(index, activeIndex); + var maxIndex = Math.max(index, activeIndex); + toggles.slice(minIndex, maxIndex + 1).forEach(function(toggle) { + if (toggle != active) toggle.checked = state; + }); + return true; + } + } + } + function activateToggle(toggle) { + if (inTogglebar(toggle)) return; + toggle.groupToggles.forEach(function(node) { + node.active = false; + }); + toggle.active = true; + } + function inTogglebar(toggle) { + return toggle.parentNode && toggle.parentNode.nodeName == "X-TOGGLEBAR"; + } + var shifted = false; + xtag.addEvents(document, { + DOMComponentsLoaded: function() { + updateScope(document); + xtag.toArray(document.forms).forEach(updateScope); + }, + WebComponentsReady: function() { + updateScope(document); + xtag.toArray(document.forms).forEach(updateScope); + }, + keydown: function(e) { + shifted = e.shiftKey; + }, + keyup: function(e) { + shifted = e.shiftKey; + }, + "focus:delegate(x-toggle)": function(e) { + this.focus = true; + this.xtag.input.focus(); + }, + "blur:delegate(x-toggle)": function(e) { + this.focus = false; + }, + "tap:delegate(x-toggle)": function(e) { + var input = this.xtag.input; + if (input.type == "radio" ? !this.checked : true) { + input.checked = !input.checked; + var change = document.createEvent("Event"); + change.initEvent("change", true, false); + input.dispatchEvent(change); + } + input.focus(); + }, + "change:delegate(x-toggle)": function(e) { + this.xtag.input.focus(); + if (inTogglebar(this) || !toggleGroup(this) && this.type != "radio") this.checked = this.xtag.input.checked; + activateToggle(this); + } + }); + var template = xtag.createFragment('<input /><div class="x-toggle-check"></div>'); + xtag.register("x-toggle", { + lifecycle: { + created: function() { + this.appendChild(template.cloneNode(true)); + this.xtag.input = this.querySelector("input"); + this.xtag.checkEl = this.querySelector(".x-toggle-check"); + this.type = "checkbox"; + setScope(this); + var name = this.getAttribute("name"); + if (name) { + this.xtag.input.name = this.getAttribute("name"); + } + if (this.hasAttribute("checked")) { + this.checked = true; + } + }, + inserted: function() { + setScope(this); + if (this.name) { + updateScope(this.xtag.scope); + } + }, + removed: function() { + updateScope(this.xtag.scope); + setScope(this); + } + }, + accessors: { + noBox: { + attribute: { + name: "no-box", + "boolean": true + } + }, + type: { + attribute: {}, + set: function(type) { + this.xtag.input.type = type; + } + }, + label: { + attribute: {} + }, + focus: { + attribute: { + "boolean": true + } + }, + active: { + attribute: { + "boolean": true + } + }, + group: { + attribute: {} + }, + groupToggles: { + get: function() { + return xtag.query(this.xtag.scope, 'x-toggle[group="' + this.group + '"]'); + } + }, + name: { + attribute: { + skip: true + }, + set: function(name) { + if (name === null) { + this.removeAttribute("name"); + this.type = "checkbox"; + } else { + this.setAttribute("name", name); + } + this.xtag.input.name = name; + updateScope(this.xtag.scope); + } + }, + checked: { + get: function() { + return this.xtag.input.checked; + }, + set: function(value) { + var name = this.name, state = value === "true" || value === true; + if (name) { + var scopeSelector = this.xtag.scope == document ? "[x-toggle-no-form]" : ""; + var selector = 'x-toggle[checked][name="' + name + '"]' + scopeSelector; + var previous = this.xtag.scope.querySelector(selector); + if (previous) { + previous.removeAttribute("checked"); + } + } + this.xtag.input.checked = state; + if (state) { + this.setAttribute("checked", ""); + } else { + this.removeAttribute("checked"); + } + } + }, + value: { + attribute: {}, + get: function() { + return this.xtag.input.value; + }, + set: function(value) { + this.xtag.input.value = value; + } + } + } + }); + xtag.register("x-togglebar", { + events: {} + }); +})();
\ No newline at end of file diff --git a/js/index.js b/js/index.js new file mode 100644 index 0000000..1f239e8 --- /dev/null +++ b/js/index.js @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2014 + * This file is part of WvS VPlan. + * + * WvS VPlan is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +var app = { + // Application Constructor + initialize: function() { + this.bindEvents(); + }, + // Bind Event Listeners + // + // Bind any events that are required on startup. Common events are: + // 'load', 'deviceready', 'offline', and 'online'. + bindEvents: function() { + document.addEventListener('deviceready', this.onDeviceReady, false); + }, + // deviceready Event Handler + // + // The scope of 'this' is the event. In order to call the 'receivedEvent' + // function, we must explicity call 'app.receivedEvent(...);' + onDeviceReady: function() { + app.receivedEvent('deviceready'); + }, + // Update DOM on a Received Event + receivedEvent: function(id) { + /* var parentElement = document.getElementById(id); + var listeningElement = parentElement.querySelector('.listening'); + var receivedElement = parentElement.querySelector('.received'); + + listeningElement.setAttribute('style', 'display:none;'); + receivedElement.setAttribute('style', 'display:block;'); + + */ + console.log('Received Event: ' + id); + } +}; |
