Make WordPress Core

Ticket #48277: 48277.diff

File 48277.diff, 372.0 KB (added by Hareesh Pillai, 5 years ago)
  • src/js/_enqueues/vendor/plupload/license.txt

     
    1                     GNU GENERAL PUBLIC LICENSE
    2                        Version 2, June 1991
     1GNU AFFERO GENERAL PUBLIC LICENSE
     2   Version 3, 19 November 2007
    33
    4  Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
    5  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    6  Everyone is permitted to copy and distribute verbatim copies
    7  of this license document, but changing it is not allowed.
     4Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
     5Everyone is permitted to copy and distribute verbatim copies
     6of this license document, but changing it is not allowed.
    87
    9                             Preamble
     8                Preamble
    109
    11   The licenses for most software are designed to take away your
    12 freedom to share and change it.  By contrast, the GNU General Public
    13 License is intended to guarantee your freedom to share and change free
    14 software--to make sure the software is free for all its users.  This
    15 General Public License applies to most of the Free Software
    16 Foundation's software and to any other program whose authors commit to
    17 using it.  (Some other Free Software Foundation software is covered by
    18 the GNU Lesser General Public License instead.)  You can apply it to
    19 your programs, too.
     10The GNU Affero General Public License is a free, copyleft license for
     11software and other kinds of works, specifically designed to ensure
     12cooperation with the community in the case of network server software.
    2013
    21   When we speak of free software, we are referring to freedom, not
     14The licenses for most software and other practical works are designed
     15to take away your freedom to share and change the works.  By contrast,
     16our General Public Licenses are intended to guarantee your freedom to
     17share and change all versions of a program--to make sure it remains free
     18software for all its users.
     19
     20When we speak of free software, we are referring to freedom, not
    2221price.  Our General Public Licenses are designed to make sure that you
    2322have the freedom to distribute copies of free software (and charge for
    24 this service if you wish), that you receive source code or can get it
    25 if you want it, that you can change the software or use pieces of it
    26 in new free programs; and that you know you can do these things.
     23them if you wish), that you receive source code or can get it if you
     24want it, that you can change the software or use pieces of it in new
     25free programs, and that you know you can do these things.
    2726
    28   To protect your rights, we need to make restrictions that forbid
    29 anyone to deny you these rights or to ask you to surrender the rights.
    30 These restrictions translate to certain responsibilities for you if you
    31 distribute copies of the software, or if you modify it.
     27Developers that use our General Public Licenses protect your rights
     28with two steps: (1) assert copyright on the software, and (2) offer
     29you this License which gives you legal permission to copy, distribute
     30and/or modify the software.
    3231
    33   For example, if you distribute copies of such a program, whether
    34 gratis or for a fee, you must give the recipients all the rights that
    35 you have.  You must make sure that they, too, receive or can get the
    36 source code.  And you must show them these terms so they know their
    37 rights.
     32A secondary benefit of defending all users' freedom is that
     33improvements made in alternate versions of the program, if they
     34receive widespread use, become available for other developers to
     35incorporate.  Many developers of free software are heartened and
     36encouraged by the resulting cooperation.  However, in the case of
     37software used on network servers, this result may fail to come about.
     38The GNU General Public License permits making a modified version and
     39letting the public access it on a server without ever releasing its
     40source code to the public.
    3841
    39   We protect your rights with two steps: (1) copyright the software, and
    40 (2) offer you this license which gives you legal permission to copy,
    41 distribute and/or modify the software.
     42The GNU Affero General Public License is designed specifically to
     43ensure that, in such cases, the modified source code becomes available
     44to the community.  It requires the operator of a network server to
     45provide the source code of the modified version running there to the
     46users of that server.  Therefore, public use of a modified version, on
     47a publicly accessible server, gives the public access to the source
     48code of the modified version.
    4249
    43   Also, for each author's protection and ours, we want to make certain
    44 that everyone understands that there is no warranty for this free
    45 software.  If the software is modified by someone else and passed on, we
    46 want its recipients to know that what they have is not the original, so
    47 that any problems introduced by others will not reflect on the original
    48 authors' reputations.
     50An older license, called the Affero General Public License and
     51published by Affero, was designed to accomplish similar goals.  This is
     52a different license, not a version of the Affero GPL, but Affero has
     53released a new version of the Affero GPL which permits relicensing under
     54this license.
    4955
    50   Finally, any free program is threatened constantly by software
    51 patents.  We wish to avoid the danger that redistributors of a free
    52 program will individually obtain patent licenses, in effect making the
    53 program proprietary.  To prevent this, we have made it clear that any
    54 patent must be licensed for everyone's free use or not licensed at all.
    55 
    56   The precise terms and conditions for copying, distribution and
     56The precise terms and conditions for copying, distribution and
    5757modification follow.
    5858
    59                     GNU GENERAL PUBLIC LICENSE
    60    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
     59   TERMS AND CONDITIONS
    6160
    62   0. This License applies to any program or other work which contains
    63 a notice placed by the copyright holder saying it may be distributed
    64 under the terms of this General Public License.  The "Program", below,
    65 refers to any such program or work, and a "work based on the Program"
    66 means either the Program or any derivative work under copyright law:
    67 that is to say, a work containing the Program or a portion of it,
    68 either verbatim or with modifications and/or translated into another
    69 language.  (Hereinafter, translation is included without limitation in
    70 the term "modification".)  Each licensee is addressed as "you".
     610. Definitions.
    7162
    72 Activities other than copying, distribution and modification are not
    73 covered by this License; they are outside its scope.  The act of
    74 running the Program is not restricted, and the output from the Program
    75 is covered only if its contents constitute a work based on the
    76 Program (independent of having been made by running the Program).
    77 Whether that is true depends on what the Program does.
     63"This License" refers to version 3 of the GNU Affero General Public License.
    7864
    79   1. You may copy and distribute verbatim copies of the Program's
    80 source code as you receive it, in any medium, provided that you
    81 conspicuously and appropriately publish on each copy an appropriate
    82 copyright notice and disclaimer of warranty; keep intact all the
    83 notices that refer to this License and to the absence of any warranty;
    84 and give any other recipients of the Program a copy of this License
    85 along with the Program.
     65"Copyright" also means copyright-like laws that apply to other kinds of
     66works, such as semiconductor masks.
    8667
    87 You may charge a fee for the physical act of transferring a copy, and
    88 you may at your option offer warranty protection in exchange for a fee.
     68"The Program" refers to any copyrightable work licensed under this
     69License.  Each licensee is addressed as "you".  "Licensees" and
     70"recipients" may be individuals or organizations.
    8971
    90   2. You may modify your copy or copies of the Program or any portion
    91 of it, thus forming a work based on the Program, and copy and
    92 distribute such modifications or work under the terms of Section 1
    93 above, provided that you also meet all of these conditions:
     72To "modify" a work means to copy from or adapt all or part of the work
     73in a fashion requiring copyright permission, other than the making of an
     74exact copy.  The resulting work is called a "modified version" of the
     75earlier work or a work "based on" the earlier work.
    9476
    95     a) You must cause the modified files to carry prominent notices
    96     stating that you changed the files and the date of any change.
     77A "covered work" means either the unmodified Program or a work based
     78on the Program.
    9779
    98     b) You must cause any work that you distribute or publish, that in
    99     whole or in part contains or is derived from the Program or any
    100     part thereof, to be licensed as a whole at no charge to all third
    101     parties under the terms of this License.
     80To "propagate" a work means to do anything with it that, without
     81permission, would make you directly or secondarily liable for
     82infringement under applicable copyright law, except executing it on a
     83computer or modifying a private copy.  Propagation includes copying,
     84distribution (with or without modification), making available to the
     85public, and in some countries other activities as well.
    10286
    103     c) If the modified program normally reads commands interactively
    104     when run, you must cause it, when started running for such
    105     interactive use in the most ordinary way, to print or display an
    106     announcement including an appropriate copyright notice and a
    107     notice that there is no warranty (or else, saying that you provide
    108     a warranty) and that users may redistribute the program under
    109     these conditions, and telling the user how to view a copy of this
    110     License.  (Exception: if the Program itself is interactive but
    111     does not normally print such an announcement, your work based on
    112     the Program is not required to print an announcement.)
     87To "convey" a work means any kind of propagation that enables other
     88parties to make or receive copies.  Mere interaction with a user through
     89a computer network, with no transfer of a copy, is not conveying.
    11390
    114 These requirements apply to the modified work as a whole.  If
    115 identifiable sections of that work are not derived from the Program,
    116 and can be reasonably considered independent and separate works in
    117 themselves, then this License, and its terms, do not apply to those
    118 sections when you distribute them as separate works.  But when you
    119 distribute the same sections as part of a whole which is a work based
    120 on the Program, the distribution of the whole must be on the terms of
    121 this License, whose permissions for other licensees extend to the
    122 entire whole, and thus to each and every part regardless of who wrote it.
     91An interactive user interface displays "Appropriate Legal Notices"
     92to the extent that it includes a convenient and prominently visible
     93feature that (1) displays an appropriate copyright notice, and (2)
     94tells the user that there is no warranty for the work (except to the
     95extent that warranties are provided), that licensees may convey the
     96work under this License, and how to view a copy of this License.  If
     97the interface presents a list of user commands or options, such as a
     98menu, a prominent item in the list meets this criterion.
    12399
    124 Thus, it is not the intent of this section to claim rights or contest
    125 your rights to work written entirely by you; rather, the intent is to
    126 exercise the right to control the distribution of derivative or
    127 collective works based on the Program.
     1001. Source Code.
    128101
    129 In addition, mere aggregation of another work not based on the Program
    130 with the Program (or with a work based on the Program) on a volume of
    131 a storage or distribution medium does not bring the other work under
    132 the scope of this License.
     102The "source code" for a work means the preferred form of the work
     103for making modifications to it.  "Object code" means any non-source
     104form of a work.
    133105
    134   3. You may copy and distribute the Program (or a work based on it,
    135 under Section 2) in object code or executable form under the terms of
    136 Sections 1 and 2 above provided that you also do one of the following:
     106A "Standard Interface" means an interface that either is an official
     107standard defined by a recognized standards body, or, in the case of
     108interfaces specified for a particular programming language, one that
     109is widely used among developers working in that language.
    137110
    138     a) Accompany it with the complete corresponding machine-readable
    139     source code, which must be distributed under the terms of Sections
    140     1 and 2 above on a medium customarily used for software interchange; or,
     111The "System Libraries" of an executable work include anything, other
     112than the work as a whole, that (a) is included in the normal form of
     113packaging a Major Component, but which is not part of that Major
     114Component, and (b) serves only to enable use of the work with that
     115Major Component, or to implement a Standard Interface for which an
     116implementation is available to the public in source code form.  A
     117"Major Component", in this context, means a major essential component
     118(kernel, window system, and so on) of the specific operating system
     119(if any) on which the executable work runs, or a compiler used to
     120produce the work, or an object code interpreter used to run it.
    141121
    142     b) Accompany it with a written offer, valid for at least three
    143     years, to give any third party, for a charge no more than your
    144     cost of physically performing source distribution, a complete
    145     machine-readable copy of the corresponding source code, to be
    146     distributed under the terms of Sections 1 and 2 above on a medium
    147     customarily used for software interchange; or,
     122The "Corresponding Source" for a work in object code form means all
     123the source code needed to generate, install, and (for an executable
     124work) run the object code and to modify the work, including scripts to
     125control those activities.  However, it does not include the work's
     126System Libraries, or general-purpose tools or generally available free
     127programs which are used unmodified in performing those activities but
     128which are not part of the work.  For example, Corresponding Source
     129includes interface definition files associated with source files for
     130the work, and the source code for shared libraries and dynamically
     131linked subprograms that the work is specifically designed to require,
     132such as by intimate data communication or control flow between those
     133subprograms and other parts of the work.
    148134
    149     c) Accompany it with the information you received as to the offer
    150     to distribute corresponding source code.  (This alternative is
    151     allowed only for noncommercial distribution and only if you
    152     received the program in object code or executable form with such
    153     an offer, in accord with Subsection b above.)
     135The Corresponding Source need not include anything that users
     136can regenerate automatically from other parts of the Corresponding
     137Source.
    154138
    155 The source code for a work means the preferred form of the work for
    156 making modifications to it.  For an executable work, complete source
    157 code means all the source code for all modules it contains, plus any
    158 associated interface definition files, plus the scripts used to
    159 control compilation and installation of the executable.  However, as a
    160 special exception, the source code distributed need not include
    161 anything that is normally distributed (in either source or binary
    162 form) with the major components (compiler, kernel, and so on) of the
    163 operating system on which the executable runs, unless that component
    164 itself accompanies the executable.
     139The Corresponding Source for a work in source code form is that
     140same work.
    165141
    166 If distribution of executable or object code is made by offering
    167 access to copy from a designated place, then offering equivalent
    168 access to copy the source code from the same place counts as
    169 distribution of the source code, even though third parties are not
    170 compelled to copy the source along with the object code.
     1422. Basic Permissions.
    171143
    172   4. You may not copy, modify, sublicense, or distribute the Program
    173 except as expressly provided under this License.  Any attempt
    174 otherwise to copy, modify, sublicense or distribute the Program is
    175 void, and will automatically terminate your rights under this License.
    176 However, parties who have received copies, or rights, from you under
    177 this License will not have their licenses terminated so long as such
    178 parties remain in full compliance.
     144All rights granted under this License are granted for the term of
     145copyright on the Program, and are irrevocable provided the stated
     146conditions are met.  This License explicitly affirms your unlimited
     147permission to run the unmodified Program.  The output from running a
     148covered work is covered by this License only if the output, given its
     149content, constitutes a covered work.  This License acknowledges your
     150rights of fair use or other equivalent, as provided by copyright law.
    179151
    180   5. You are not required to accept this License, since you have not
    181 signed it.  However, nothing else grants you permission to modify or
    182 distribute the Program or its derivative works.  These actions are
    183 prohibited by law if you do not accept this License.  Therefore, by
    184 modifying or distributing the Program (or any work based on the
    185 Program), you indicate your acceptance of this License to do so, and
    186 all its terms and conditions for copying, distributing or modifying
    187 the Program or works based on it.
     152You may make, run and propagate covered works that you do not
     153convey, without conditions so long as your license otherwise remains
     154in force.  You may convey covered works to others for the sole purpose
     155of having them make modifications exclusively for you, or provide you
     156with facilities for running those works, provided that you comply with
     157the terms of this License in conveying all material for which you do
     158not control copyright.  Those thus making or running the covered works
     159for you must do so exclusively on your behalf, under your direction
     160and control, on terms that prohibit them from making any copies of
     161your copyrighted material outside their relationship with you.
    188162
    189   6. Each time you redistribute the Program (or any work based on the
    190 Program), the recipient automatically receives a license from the
    191 original licensor to copy, distribute or modify the Program subject to
    192 these terms and conditions.  You may not impose any further
    193 restrictions on the recipients' exercise of the rights granted herein.
    194 You are not responsible for enforcing compliance by third parties to
     163Conveying under any other circumstances is permitted solely under
     164the conditions stated below.  Sublicensing is not allowed; section 10
     165makes it unnecessary.
     166
     1673. Protecting Users' Legal Rights From Anti-Circumvention Law.
     168
     169No covered work shall be deemed part of an effective technological
     170measure under any applicable law fulfilling obligations under article
     17111 of the WIPO copyright treaty adopted on 20 December 1996, or
     172similar laws prohibiting or restricting circumvention of such
     173measures.
     174
     175When you convey a covered work, you waive any legal power to forbid
     176circumvention of technological measures to the extent such circumvention
     177is effected by exercising rights under this License with respect to
     178the covered work, and you disclaim any intention to limit operation or
     179modification of the work as a means of enforcing, against the work's
     180users, your or third parties' legal rights to forbid circumvention of
     181technological measures.
     182
     1834. Conveying Verbatim Copies.
     184
     185You may convey verbatim copies of the Program's source code as you
     186receive it, in any medium, provided that you conspicuously and
     187appropriately publish on each copy an appropriate copyright notice;
     188keep intact all notices stating that this License and any
     189non-permissive terms added in accord with section 7 apply to the code;
     190keep intact all notices of the absence of any warranty; and give all
     191recipients a copy of this License along with the Program.
     192
     193You may charge any price or no price for each copy that you convey,
     194and you may offer support or warranty protection for a fee.
     195
     1965. Conveying Modified Source Versions.
     197
     198You may convey a work based on the Program, or the modifications to
     199produce it from the Program, in the form of source code under the
     200terms of section 4, provided that you also meet all of these conditions:
     201
     202a) The work must carry prominent notices stating that you modified
     203it, and giving a relevant date.
     204
     205b) The work must carry prominent notices stating that it is
     206released under this License and any conditions added under section
     2077.  This requirement modifies the requirement in section 4 to
     208"keep intact all notices".
     209
     210c) You must license the entire work, as a whole, under this
     211License to anyone who comes into possession of a copy.  This
     212License will therefore apply, along with any applicable section 7
     213additional terms, to the whole of the work, and all its parts,
     214regardless of how they are packaged.  This License gives no
     215permission to license the work in any other way, but it does not
     216invalidate such permission if you have separately received it.
     217
     218d) If the work has interactive user interfaces, each must display
     219Appropriate Legal Notices; however, if the Program has interactive
     220interfaces that do not display Appropriate Legal Notices, your
     221work need not make them do so.
     222
     223A compilation of a covered work with other separate and independent
     224works, which are not by their nature extensions of the covered work,
     225and which are not combined with it such as to form a larger program,
     226in or on a volume of a storage or distribution medium, is called an
     227"aggregate" if the compilation and its resulting copyright are not
     228used to limit the access or legal rights of the compilation's users
     229beyond what the individual works permit.  Inclusion of a covered work
     230in an aggregate does not cause this License to apply to the other
     231parts of the aggregate.
     232
     2336. Conveying Non-Source Forms.
     234
     235You may convey a covered work in object code form under the terms
     236of sections 4 and 5, provided that you also convey the
     237machine-readable Corresponding Source under the terms of this License,
     238in one of these ways:
     239
     240a) Convey the object code in, or embodied in, a physical product
     241(including a physical distribution medium), accompanied by the
     242Corresponding Source fixed on a durable physical medium
     243customarily used for software interchange.
     244
     245b) Convey the object code in, or embodied in, a physical product
     246(including a physical distribution medium), accompanied by a
     247written offer, valid for at least three years and valid for as
     248long as you offer spare parts or customer support for that product
     249model, to give anyone who possesses the object code either (1) a
     250copy of the Corresponding Source for all the software in the
     251product that is covered by this License, on a durable physical
     252medium customarily used for software interchange, for a price no
     253more than your reasonable cost of physically performing this
     254conveying of source, or (2) access to copy the
     255Corresponding Source from a network server at no charge.
     256
     257c) Convey individual copies of the object code with a copy of the
     258written offer to provide the Corresponding Source.  This
     259alternative is allowed only occasionally and noncommercially, and
     260only if you received the object code with such an offer, in accord
     261with subsection 6b.
     262
     263d) Convey the object code by offering access from a designated
     264place (gratis or for a charge), and offer equivalent access to the
     265Corresponding Source in the same way through the same place at no
     266further charge.  You need not require recipients to copy the
     267Corresponding Source along with the object code.  If the place to
     268copy the object code is a network server, the Corresponding Source
     269may be on a different server (operated by you or a third party)
     270that supports equivalent copying facilities, provided you maintain
     271clear directions next to the object code saying where to find the
     272Corresponding Source.  Regardless of what server hosts the
     273Corresponding Source, you remain obligated to ensure that it is
     274available for as long as needed to satisfy these requirements.
     275
     276e) Convey the object code using peer-to-peer transmission, provided
     277you inform other peers where the object code and Corresponding
     278Source of the work are being offered to the general public at no
     279charge under subsection 6d.
     280
     281A separable portion of the object code, whose source code is excluded
     282from the Corresponding Source as a System Library, need not be
     283included in conveying the object code work.
     284
     285A "User Product" is either (1) a "consumer product", which means any
     286tangible personal property which is normally used for personal, family,
     287or household purposes, or (2) anything designed or sold for incorporation
     288into a dwelling.  In determining whether a product is a consumer product,
     289doubtful cases shall be resolved in favor of coverage.  For a particular
     290product received by a particular user, "normally used" refers to a
     291typical or common use of that class of product, regardless of the status
     292of the particular user or of the way in which the particular user
     293actually uses, or expects or is expected to use, the product.  A product
     294is a consumer product regardless of whether the product has substantial
     295commercial, industrial or non-consumer uses, unless such uses represent
     296the only significant mode of use of the product.
     297
     298"Installation Information" for a User Product means any methods,
     299procedures, authorization keys, or other information required to install
     300and execute modified versions of a covered work in that User Product from
     301a modified version of its Corresponding Source.  The information must
     302suffice to ensure that the continued functioning of the modified object
     303code is in no case prevented or interfered with solely because
     304modification has been made.
     305
     306If you convey an object code work under this section in, or with, or
     307specifically for use in, a User Product, and the conveying occurs as
     308part of a transaction in which the right of possession and use of the
     309User Product is transferred to the recipient in perpetuity or for a
     310fixed term (regardless of how the transaction is characterized), the
     311Corresponding Source conveyed under this section must be accompanied
     312by the Installation Information.  But this requirement does not apply
     313if neither you nor any third party retains the ability to install
     314modified object code on the User Product (for example, the work has
     315been installed in ROM).
     316
     317The requirement to provide Installation Information does not include a
     318requirement to continue to provide support service, warranty, or updates
     319for a work that has been modified or installed by the recipient, or for
     320the User Product in which it has been modified or installed.  Access to a
     321network may be denied when the modification itself materially and
     322adversely affects the operation of the network or violates the rules and
     323protocols for communication across the network.
     324
     325Corresponding Source conveyed, and Installation Information provided,
     326in accord with this section must be in a format that is publicly
     327documented (and with an implementation available to the public in
     328source code form), and must require no special password or key for
     329unpacking, reading or copying.
     330
     3317. Additional Terms.
     332
     333"Additional permissions" are terms that supplement the terms of this
     334License by making exceptions from one or more of its conditions.
     335Additional permissions that are applicable to the entire Program shall
     336be treated as though they were included in this License, to the extent
     337that they are valid under applicable law.  If additional permissions
     338apply only to part of the Program, that part may be used separately
     339under those permissions, but the entire Program remains governed by
     340this License without regard to the additional permissions.
     341
     342When you convey a copy of a covered work, you may at your option
     343remove any additional permissions from that copy, or from any part of
     344it.  (Additional permissions may be written to require their own
     345removal in certain cases when you modify the work.)  You may place
     346additional permissions on material, added by you to a covered work,
     347for which you have or can give appropriate copyright permission.
     348
     349Notwithstanding any other provision of this License, for material you
     350add to a covered work, you may (if authorized by the copyright holders of
     351that material) supplement the terms of this License with terms:
     352
     353a) Disclaiming warranty or limiting liability differently from the
     354terms of sections 15 and 16 of this License; or
     355
     356b) Requiring preservation of specified reasonable legal notices or
     357author attributions in that material or in the Appropriate Legal
     358Notices displayed by works containing it; or
     359
     360c) Prohibiting misrepresentation of the origin of that material, or
     361requiring that modified versions of such material be marked in
     362reasonable ways as different from the original version; or
     363
     364d) Limiting the use for publicity purposes of names of licensors or
     365authors of the material; or
     366
     367e) Declining to grant rights under trademark law for use of some
     368trade names, trademarks, or service marks; or
     369
     370f) Requiring indemnification of licensors and authors of that
     371material by anyone who conveys the material (or modified versions of
     372it) with contractual assumptions of liability to the recipient, for
     373any liability that these contractual assumptions directly impose on
     374those licensors and authors.
     375
     376All other non-permissive additional terms are considered "further
     377restrictions" within the meaning of section 10.  If the Program as you
     378received it, or any part of it, contains a notice stating that it is
     379governed by this License along with a term that is a further
     380restriction, you may remove that term.  If a license document contains
     381a further restriction but permits relicensing or conveying under this
     382License, you may add to a covered work material governed by the terms
     383of that license document, provided that the further restriction does
     384not survive such relicensing or conveying.
     385
     386If you add terms to a covered work in accord with this section, you
     387must place, in the relevant source files, a statement of the
     388additional terms that apply to those files, or a notice indicating
     389where to find the applicable terms.
     390
     391Additional terms, permissive or non-permissive, may be stated in the
     392form of a separately written license, or stated as exceptions;
     393the above requirements apply either way.
     394
     3958. Termination.
     396
     397You may not propagate or modify a covered work except as expressly
     398provided under this License.  Any attempt otherwise to propagate or
     399modify it is void, and will automatically terminate your rights under
     400this License (including any patent licenses granted under the third
     401paragraph of section 11).
     402
     403However, if you cease all violation of this License, then your
     404license from a particular copyright holder is reinstated (a)
     405provisionally, unless and until the copyright holder explicitly and
     406finally terminates your license, and (b) permanently, if the copyright
     407holder fails to notify you of the violation by some reasonable means
     408prior to 60 days after the cessation.
     409
     410Moreover, your license from a particular copyright holder is
     411reinstated permanently if the copyright holder notifies you of the
     412violation by some reasonable means, this is the first time you have
     413received notice of violation of this License (for any work) from that
     414copyright holder, and you cure the violation prior to 30 days after
     415your receipt of the notice.
     416
     417Termination of your rights under this section does not terminate the
     418licenses of parties who have received copies or rights from you under
     419this License.  If your rights have been terminated and not permanently
     420reinstated, you do not qualify to receive new licenses for the same
     421material under section 10.
     422
     4239. Acceptance Not Required for Having Copies.
     424
     425You are not required to accept this License in order to receive or
     426run a copy of the Program.  Ancillary propagation of a covered work
     427occurring solely as a consequence of using peer-to-peer transmission
     428to receive a copy likewise does not require acceptance.  However,
     429nothing other than this License grants you permission to propagate or
     430modify any covered work.  These actions infringe copyright if you do
     431not accept this License.  Therefore, by modifying or propagating a
     432covered work, you indicate your acceptance of this License to do so.
     433
     43410. Automatic Licensing of Downstream Recipients.
     435
     436Each time you convey a covered work, the recipient automatically
     437receives a license from the original licensors, to run, modify and
     438propagate that work, subject to this License.  You are not responsible
     439for enforcing compliance by third parties with this License.
     440
     441An "entity transaction" is a transaction transferring control of an
     442organization, or substantially all assets of one, or subdividing an
     443organization, or merging organizations.  If propagation of a covered
     444work results from an entity transaction, each party to that
     445transaction who receives a copy of the work also receives whatever
     446licenses to the work the party's predecessor in interest had or could
     447give under the previous paragraph, plus a right to possession of the
     448Corresponding Source of the work from the predecessor in interest, if
     449the predecessor has it or can get it with reasonable efforts.
     450
     451You may not impose any further restrictions on the exercise of the
     452rights granted or affirmed under this License.  For example, you may
     453not impose a license fee, royalty, or other charge for exercise of
     454rights granted under this License, and you may not initiate litigation
     455(including a cross-claim or counterclaim in a lawsuit) alleging that
     456any patent claim is infringed by making, using, selling, offering for
     457sale, or importing the Program or any portion of it.
     458
     45911. Patents.
     460
     461A "contributor" is a copyright holder who authorizes use under this
     462License of the Program or a work on which the Program is based.  The
     463work thus licensed is called the contributor's "contributor version".
     464
     465A contributor's "essential patent claims" are all patent claims
     466owned or controlled by the contributor, whether already acquired or
     467hereafter acquired, that would be infringed by some manner, permitted
     468by this License, of making, using, or selling its contributor version,
     469but do not include claims that would be infringed only as a
     470consequence of further modification of the contributor version.  For
     471purposes of this definition, "control" includes the right to grant
     472patent sublicenses in a manner consistent with the requirements of
    195473this License.
    196474
    197   7. If, as a consequence of a court judgment or allegation of patent
    198 infringement or for any other reason (not limited to patent issues),
    199 conditions are imposed on you (whether by court order, agreement or
     475Each contributor grants you a non-exclusive, worldwide, royalty-free
     476patent license under the contributor's essential patent claims, to
     477make, use, sell, offer for sale, import and otherwise run, modify and
     478propagate the contents of its contributor version.
     479
     480In the following three paragraphs, a "patent license" is any express
     481agreement or commitment, however denominated, not to enforce a patent
     482(such as an express permission to practice a patent or covenant not to
     483sue for patent infringement).  To "grant" such a patent license to a
     484party means to make such an agreement or commitment not to enforce a
     485patent against the party.
     486
     487If you convey a covered work, knowingly relying on a patent license,
     488and the Corresponding Source of the work is not available for anyone
     489to copy, free of charge and under the terms of this License, through a
     490publicly available network server or other readily accessible means,
     491then you must either (1) cause the Corresponding Source to be so
     492available, or (2) arrange to deprive yourself of the benefit of the
     493patent license for this particular work, or (3) arrange, in a manner
     494consistent with the requirements of this License, to extend the patent
     495license to downstream recipients.  "Knowingly relying" means you have
     496actual knowledge that, but for the patent license, your conveying the
     497covered work in a country, or your recipient's use of the covered work
     498in a country, would infringe one or more identifiable patents in that
     499country that you have reason to believe are valid.
     500
     501If, pursuant to or in connection with a single transaction or
     502arrangement, you convey, or propagate by procuring conveyance of, a
     503covered work, and grant a patent license to some of the parties
     504receiving the covered work authorizing them to use, propagate, modify
     505or convey a specific copy of the covered work, then the patent license
     506you grant is automatically extended to all recipients of the covered
     507work and works based on it.
     508
     509A patent license is "discriminatory" if it does not include within
     510the scope of its coverage, prohibits the exercise of, or is
     511conditioned on the non-exercise of one or more of the rights that are
     512specifically granted under this License.  You may not convey a covered
     513work if you are a party to an arrangement with a third party that is
     514in the business of distributing software, under which you make payment
     515to the third party based on the extent of your activity of conveying
     516the work, and under which the third party grants, to any of the
     517parties who would receive the covered work from you, a discriminatory
     518patent license (a) in connection with copies of the covered work
     519conveyed by you (or copies made from those copies), or (b) primarily
     520for and in connection with specific products or compilations that
     521contain the covered work, unless you entered into that arrangement,
     522or that patent license was granted, prior to 28 March 2007.
     523
     524Nothing in this License shall be construed as excluding or limiting
     525any implied license or other defenses to infringement that may
     526otherwise be available to you under applicable patent law.
     527
     52812. No Surrender of Others' Freedom.
     529
     530If conditions are imposed on you (whether by court order, agreement or
    200531otherwise) that contradict the conditions of this License, they do not
    201 excuse you from the conditions of this License.  If you cannot
    202 distribute so as to satisfy simultaneously your obligations under this
    203 License and any other pertinent obligations, then as a consequence you
    204 may not distribute the Program at all.  For example, if a patent
    205 license would not permit royalty-free redistribution of the Program by
    206 all those who receive copies directly or indirectly through you, then
    207 the only way you could satisfy both it and this License would be to
    208 refrain entirely from distribution of the Program.
     532excuse you from the conditions of this License.  If you cannot convey a
     533covered work so as to satisfy simultaneously your obligations under this
     534License and any other pertinent obligations, then as a consequence you may
     535not convey it at all.  For example, if you agree to terms that obligate you
     536to collect a royalty for further conveying from those to whom you convey
     537the Program, the only way you could satisfy both those terms and this
     538License would be to refrain entirely from conveying the Program.
    209539
    210 If any portion of this section is held invalid or unenforceable under
    211 any particular circumstance, the balance of the section is intended to
    212 apply and the section as a whole is intended to apply in other
    213 circumstances.
     54013. Remote Network Interaction; Use with the GNU General Public License.
    214541
    215 It is not the purpose of this section to induce you to infringe any
    216 patents or other property right claims or to contest validity of any
    217 such claims; this section has the sole purpose of protecting the
    218 integrity of the free software distribution system, which is
    219 implemented by public license practices.  Many people have made
    220 generous contributions to the wide range of software distributed
    221 through that system in reliance on consistent application of that
    222 system; it is up to the author/donor to decide if he or she is willing
    223 to distribute software through any other system and a licensee cannot
    224 impose that choice.
     542Notwithstanding any other provision of this License, if you modify the
     543Program, your modified version must prominently offer all users
     544interacting with it remotely through a computer network (if your version
     545supports such interaction) an opportunity to receive the Corresponding
     546Source of your version by providing access to the Corresponding Source
     547from a network server at no charge, through some standard or customary
     548means of facilitating copying of software.  This Corresponding Source
     549shall include the Corresponding Source for any work covered by version 3
     550of the GNU General Public License that is incorporated pursuant to the
     551following paragraph.
    225552
    226 This section is intended to make thoroughly clear what is believed to
    227 be a consequence of the rest of this License.
     553Notwithstanding any other provision of this License, you have
     554permission to link or combine any covered work with a work licensed
     555under version 3 of the GNU General Public License into a single
     556combined work, and to convey the resulting work.  The terms of this
     557License will continue to apply to the part which is the covered work,
     558but the work with which it is combined will remain governed by version
     5593 of the GNU General Public License.
    228560
    229   8. If the distribution and/or use of the Program is restricted in
    230 certain countries either by patents or by copyrighted interfaces, the
    231 original copyright holder who places the Program under this License
    232 may add an explicit geographical distribution limitation excluding
    233 those countries, so that distribution is permitted only in or among
    234 countries not thus excluded.  In such case, this License incorporates
    235 the limitation as if written in the body of this License.
     56114. Revised Versions of this License.
    236562
    237   9. The Free Software Foundation may publish revised and/or new versions
    238 of the General Public License from time to time.  Such new versions will
    239 be similar in spirit to the present version, but may differ in detail to
     563The Free Software Foundation may publish revised and/or new versions of
     564the GNU Affero General Public License from time to time.  Such new versions
     565will be similar in spirit to the present version, but may differ in detail to
    240566address new problems or concerns.
    241567
    242 Each version is given a distinguishing version number.  If the Program
    243 specifies a version number of this License which applies to it and "any
    244 later version", you have the option of following the terms and conditions
    245 either of that version or of any later version published by the Free
    246 Software Foundation.  If the Program does not specify a version number of
    247 this License, you may choose any version ever published by the Free Software
    248 Foundation.
     568Each version is given a distinguishing version number.  If the
     569Program specifies that a certain numbered version of the GNU Affero General
     570Public License "or any later version" applies to it, you have the
     571option of following the terms and conditions either of that numbered
     572version or of any later version published by the Free Software
     573Foundation.  If the Program does not specify a version number of the
     574GNU Affero General Public License, you may choose any version ever published
     575by the Free Software Foundation.
    249576
    250   10. If you wish to incorporate parts of the Program into other free
    251 programs whose distribution conditions are different, write to the author
    252 to ask for permission.  For software which is copyrighted by the Free
    253 Software Foundation, write to the Free Software Foundation; we sometimes
    254 make exceptions for this.  Our decision will be guided by the two goals
    255 of preserving the free status of all derivatives of our free software and
    256 of promoting the sharing and reuse of software generally.
     577If the Program specifies that a proxy can decide which future
     578versions of the GNU Affero General Public License can be used, that proxy's
     579public statement of acceptance of a version permanently authorizes you
     580to choose that version for the Program.
    257581
    258                             NO WARRANTY
     582Later license versions may give you additional or different
     583permissions.  However, no additional obligations are imposed on any
     584author or copyright holder as a result of your choosing to follow a
     585later version.
    259586
    260   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
    261 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
    262 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
    263 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
    264 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    265 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
    266 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
    267 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
    268 REPAIR OR CORRECTION.
     58715. Disclaimer of Warranty.
    269588
    270   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
    271 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
    272 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
    273 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
    274 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
    275 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
    276 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
    277 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
    278 POSSIBILITY OF SUCH DAMAGES.
     589THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
     590APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
     591HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
     592OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
     593THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     594PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
     595IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
     596ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
    279597
    280                      END OF TERMS AND CONDITIONS
     59816. Limitation of Liability.
    281599
    282             How to Apply These Terms to Your New Programs
     600IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
     601WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
     602THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
     603GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
     604USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
     605DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
     606PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
     607EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
     608SUCH DAMAGES.
    283609
    284   If you develop a new program, and you want it to be of the greatest
     61017. Interpretation of Sections 15 and 16.
     611
     612If the disclaimer of warranty and limitation of liability provided
     613above cannot be given local legal effect according to their terms,
     614reviewing courts shall apply local law that most closely approximates
     615an absolute waiver of all civil liability in connection with the
     616Program, unless a warranty or assumption of liability accompanies a
     617copy of the Program in return for a fee.
     618
     619 END OF TERMS AND CONDITIONS
     620
     621How to Apply These Terms to Your New Programs
     622
     623If you develop a new program, and you want it to be of the greatest
    285624possible use to the public, the best way to achieve this is to make it
    286625free software which everyone can redistribute and change under these terms.
    287626
    288   To do so, attach the following notices to the program.  It is safest
     627To do so, attach the following notices to the program.  It is safest
    289628to attach them to the start of each source file to most effectively
    290 convey the exclusion of warranty; and each file should have at least
     629state the exclusion of warranty; and each file should have at least
    291630the "copyright" line and a pointer to where the full notice is found.
    292631
    293     <one line to give the program's name and a brief idea of what it does.>
    294     Copyright (C) <year>  <name of author>
     632<one line to give the program's name and a brief idea of what it does.>
     633Copyright (C) <year>  <name of author>
    295634
    296     This program is free software; you can redistribute it and/or modify
    297     it under the terms of the GNU General Public License as published by
    298     the Free Software Foundation; either version 2 of the License, or
    299     (at your option) any later version.
     635This program is free software: you can redistribute it and/or modify
     636it under the terms of the GNU Affero General Public License as published by
     637the Free Software Foundation, either version 3 of the License, or
     638(at your option) any later version.
    300639
    301     This program is distributed in the hope that it will be useful,
    302     but WITHOUT ANY WARRANTY; without even the implied warranty of
    303     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    304     GNU General Public License for more details.
     640This program is distributed in the hope that it will be useful,
     641but WITHOUT ANY WARRANTY; without even the implied warranty of
     642MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     643GNU Affero General Public License for more details.
    305644
    306     You should have received a copy of the GNU General Public License along
    307     with this program; if not, write to the Free Software Foundation, Inc.,
    308     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     645You should have received a copy of the GNU Affero General Public License
     646along with this program.  If not, see <http://www.gnu.org/licenses/>.
    309647
    310648Also add information on how to contact you by electronic and paper mail.
    311649
    312 If the program is interactive, make it output a short notice like this
    313 when it starts in an interactive mode:
     650If your software can interact with users remotely through a computer
     651network, you should also make sure that it provides a way for users to
     652get its source.  For example, if your program is a web application, its
     653interface could display a "Source" link that leads users to an archive
     654of the code.  There are many ways you could offer source, and different
     655solutions will be better for different programs; see section 13 for the
     656specific requirements.
    314657
    315     Gnomovision version 69, Copyright (C) year name of author
    316     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    317     This is free software, and you are welcome to redistribute it
    318     under certain conditions; type `show c' for details.
    319 
    320 The hypothetical commands `show w' and `show c' should show the appropriate
    321 parts of the General Public License.  Of course, the commands you use may
    322 be called something other than `show w' and `show c'; they could even be
    323 mouse-clicks or menu items--whatever suits your program.
    324 
    325 You should also get your employer (if you work as a programmer) or your
    326 school, if any, to sign a "copyright disclaimer" for the program, if
    327 necessary.  Here is a sample; alter the names:
    328 
    329   Yoyodyne, Inc., hereby disclaims all copyright interest in the program
    330   `Gnomovision' (which makes passes at compilers) written by James Hacker.
    331 
    332   <signature of Ty Coon>, 1 April 1989
    333   Ty Coon, President of Vice
    334 
    335 This General Public License does not permit incorporating your program into
    336 proprietary programs.  If your program is a subroutine library, you may
    337 consider it more useful to permit linking proprietary applications with the
    338 library.  If this is what you want to do, use the GNU Lesser General
    339 Public License instead of this License.
     658You should also get your employer (if you work as a programmer) or school,
     659if any, to sign a "copyright disclaimer" for the program, if necessary.
     660For more information on this, and how to apply and follow the GNU AGPL, see
     661<http://www.gnu.org/licenses/>.
  • src/js/_enqueues/vendor/plupload/moxie.js

     
    11;var MXI_DEBUG = false;
    22/**
    33 * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill
    4  * v1.3.5
     4 * v1.5.7
    55 *
    66 * Copyright 2013, Moxiecode Systems AB
    77 * Released under GPL License.
     
    99 * License: http://www.plupload.com/license
    1010 * Contributing: http://www.plupload.com/contributing
    1111 *
    12  * Date: 2016-05-15
     12 * Date: 2017-11-03
    1313 */
     14;(function (global, factory) {
     15        var extract = function() {
     16                var ctx = {};
     17                factory.apply(ctx, arguments);
     18                return ctx.moxie;
     19        };
     20       
     21        if (typeof define === "function" && define.amd) {
     22                define("moxie", [], extract);
     23        } else if (typeof module === "object" && module.exports) {
     24                module.exports = extract();
     25        } else {
     26                global.moxie = extract();
     27        }
     28}(this || window, function() {
    1429/**
    1530 * Compiled inline version. (Library mode)
    1631 */
    1732
    18 /**
    19  * Modified for WordPress, Silverlight and Flash runtimes support was removed.
    20  * See https://core.trac.wordpress.org/ticket/41755.
    21  */
    22 
    2333/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
    2434/*globals $code */
    2535
     
    110120 * Contributing: http://www.plupload.com/contributing
    111121 */
    112122
     123/**
     124@class moxie/core/utils/Basic
     125@public
     126@static
     127*/
     128
    113129define('moxie/core/utils/Basic', [], function() {
    114130        /**
    115131        Gets the true type of the built-in object (better version of typeof).
     
    116132        @author Angus Croll (http://javascriptweblog.wordpress.com/)
    117133
    118134        @method typeOf
    119         @for Utils
    120135        @static
    121136        @param {Object} o Object to check.
    122137        @return {String} Object [[Class]]
    123138        */
    124         var typeOf = function(o) {
     139        function typeOf(o) {
    125140                var undef;
    126141
    127142                if (o === undef) {
     
    134149
    135150                // the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8
    136151                return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
    137         };
    138                
     152        }
     153
    139154        /**
    140         Extends the specified object with another object.
     155        Extends the specified object with another object(s).
    141156
    142157        @method extend
    143158        @static
     
    145160        @param {Object} [obj]* Multiple objects to extend with.
    146161        @return {Object} Same as target, the extended object.
    147162        */
    148         var extend = function(target) {
     163        function extend() {
     164                return merge(false, false, arguments);
     165        }
     166
     167
     168        /**
     169        Extends the specified object with another object(s), but only if the property exists in the target.
     170
     171        @method extendIf
     172        @static
     173        @param {Object} target Object to extend.
     174        @param {Object} [obj]* Multiple objects to extend with.
     175        @return {Object} Same as target, the extended object.
     176        */
     177        function extendIf() {
     178                return merge(true, false, arguments);
     179        }
     180
     181
     182        function extendImmutable() {
     183                return merge(false, true, arguments);
     184        }
     185
     186
     187        function extendImmutableIf() {
     188                return merge(true, true, arguments);
     189        }
     190
     191
     192        function clone(value) {
     193                switch (typeOf(value)) {
     194                        case 'array':
     195                                return merge(false, true, [[], value]);
     196
     197                        case 'object':
     198                                return merge(false, true, [{}, value]);
     199
     200                        default:
     201                                return value;
     202                }
     203        }
     204
     205
     206        function shallowCopy(obj) {
     207                switch (typeOf(obj)) {
     208                        case 'array':
     209                                return Array.prototype.slice.call(obj);
     210
     211                        case 'object':
     212                                return extend({}, obj);
     213                }
     214                return obj;
     215        }
     216
     217
     218        function merge(strict, immutable, args) {
    149219                var undef;
     220                var target = args[0];
    150221
    151                 each(arguments, function(arg, i) {
     222                each(args, function(arg, i) {
    152223                        if (i > 0) {
    153224                                each(arg, function(value, key) {
    154                                         if (value !== undef) {
    155                                                 if (typeOf(target[key]) === typeOf(value) && !!~inArray(typeOf(value), ['array', 'object'])) {
    156                                                         extend(target[key], value);
    157                                                 } else {
    158                                                         target[key] = value;
    159                                                 }
     225                                        var isComplex = inArray(typeOf(value), ['array', 'object']) !== -1;
     226
     227                                        if (value === undef || strict && target[key] === undef) {
     228                                                return true;
    160229                                        }
     230
     231                                        if (isComplex && immutable) {
     232                                                value = shallowCopy(value);
     233                                        }
     234
     235                                        if (typeOf(target[key]) === typeOf(value) && isComplex) {
     236                                                merge(strict, immutable, [target[key], value]);
     237                                        } else {
     238                                                target[key] = value;
     239                                        }
    161240                                });
    162241                        }
    163242                });
     243
    164244                return target;
    165         };
    166                
     245        }
     246
     247
    167248        /**
     249        A way to inherit one `class` from another in a consisstent way (more or less)
     250
     251        @method inherit
     252        @static
     253        @since >1.4.1
     254        @param {Function} child
     255        @param {Function} parent
     256        @return {Function} Prepared constructor
     257        */
     258        function inherit(child, parent) {
     259                // copy over all parent properties
     260                for (var key in parent) {
     261                        if ({}.hasOwnProperty.call(parent, key)) {
     262                                child[key] = parent[key];
     263                        }
     264                }
     265
     266                // give child `class` a place to define its own methods
     267                function ctor() {
     268                        this.constructor = child;
     269
     270                        if (MXI_DEBUG) {
     271                                var getCtorName = function(fn) {
     272                                        var m = fn.toString().match(/^function\s([^\(\s]+)/);
     273                                        return m ? m[1] : false;
     274                                };
     275
     276                                this.ctorName = getCtorName(child);
     277                        }
     278                }
     279                ctor.prototype = parent.prototype;
     280                child.prototype = new ctor();
     281
     282                // keep a way to reference parent methods
     283                child.parent = parent.prototype;
     284                return child;
     285        }
     286
     287
     288        /**
    168289        Executes the callback function for each item in array/object. If you return false in the
    169290        callback it will break the loop.
    170291
     
    173294        @param {Object} obj Object to iterate.
    174295        @param {function} callback Callback function to execute for each item.
    175296        */
    176         var each = function(obj, callback) {
     297        function each(obj, callback) {
    177298                var length, key, i, undef;
    178299
    179300                if (obj) {
    180                         if (typeOf(obj.length) === 'number') { // it might be Array, FileList or even arguments object
    181                                 // Loop array items
    182                                 for (i = 0, length = obj.length; i < length; i++) {
    183                                         if (callback(obj[i], i) === false) {
    184                                                 return;
    185                                         }
    186                                 }
    187                         } else if (typeOf(obj) === 'object') {
     301                        try {
     302                                length = obj.length;
     303                        } catch(ex) {
     304                                length = undef;
     305                        }
     306
     307                        if (length === undef || typeof(length) !== 'number') {
    188308                                // Loop object items
    189309                                for (key in obj) {
    190310                                        if (obj.hasOwnProperty(key)) {
     
    193313                                                }
    194314                                        }
    195315                                }
     316                        } else {
     317                                // Loop array items
     318                                for (i = 0; i < length; i++) {
     319                                        if (callback(obj[i], i) === false) {
     320                                                return;
     321                                        }
     322                                }
    196323                        }
    197324                }
    198         };
     325        }
    199326
    200327        /**
    201328        Checks if object is empty.
    202        
     329
    203330        @method isEmptyObj
    204331        @static
    205332        @param {Object} o Object to check.
    206333        @return {Boolean}
    207334        */
    208         var isEmptyObj = function(obj) {
     335        function isEmptyObj(obj) {
    209336                var prop;
    210337
    211338                if (!obj || typeOf(obj) !== 'object') {
     
    217344                }
    218345
    219346                return true;
    220         };
     347        }
    221348
    222349        /**
    223350        Recieve an array of functions (usually async) to call in sequence, each  function
     
    231358        @param {Array} queue Array of functions to call in sequence
    232359        @param {Function} cb Main callback that is called in the end, or in case of error
    233360        */
    234         var inSeries = function(queue, cb) {
     361        function inSeries(queue, cb) {
    235362                var i = 0, length = queue.length;
    236363
    237364                if (typeOf(cb) !== 'function') {
     
    251378                        }
    252379                }
    253380                callNext(i);
    254         };
     381        }
    255382
    256383
    257384        /**
    258385        Recieve an array of functions (usually async) to call in parallel, each  function
    259         receives a callback as first argument that it should call, when it completes. After 
     386        receives a callback as first argument that it should call, when it completes. After
    260387        everything is complete, main callback is called. Passing truthy value to the
    261388        callback as a first argument will interrupt the process and invoke main callback
    262389        immediately.
     
    264391        @method inParallel
    265392        @static
    266393        @param {Array} queue Array of functions to call in sequence
    267         @param {Function} cb Main callback that is called in the end, or in case of error
     394        @param {Function} cb Main callback that is called in the end, or in case of erro
    268395        */
    269         var inParallel = function(queue, cb) {
     396        function inParallel(queue, cb) {
    270397                var count = 0, num = queue.length, cbArgs = new Array(num);
    271398
    272399                each(queue, function(fn, i) {
     
    274401                                if (error) {
    275402                                        return cb(error);
    276403                                }
    277                                
     404
    278405                                var args = [].slice.call(arguments);
    279406                                args.shift(); // strip error - undefined or not
    280407
     
    284411                                if (count === num) {
    285412                                        cbArgs.unshift(null);
    286413                                        cb.apply(this, cbArgs);
    287                                 } 
     414                                }
    288415                        });
    289416                });
    290         };
    291        
    292        
     417        }
     418
     419
    293420        /**
    294421        Find an element in array and return it's index if present, otherwise return -1.
    295        
     422
    296423        @method inArray
    297424        @static
    298425        @param {Mixed} needle Element to find
     
    299426        @param {Array} array
    300427        @return {Int} Index of the element, or -1 if not found
    301428        */
    302         var inArray = function(needle, array) {
     429        function inArray(needle, array) {
    303430                if (array) {
    304431                        if (Array.prototype.indexOf) {
    305432                                return Array.prototype.indexOf.call(array, needle);
    306433                        }
    307                
     434
    308435                        for (var i = 0, length = array.length; i < length; i++) {
    309436                                if (array[i] === needle) {
    310437                                        return i;
     
    312439                        }
    313440                }
    314441                return -1;
    315         };
     442        }
    316443
    317444
    318445        /**
     
    324451        @param {Array} array
    325452        @return {Array|Boolean}
    326453        */
    327         var arrayDiff = function(needles, array) {
     454        function arrayDiff(needles, array) {
    328455                var diff = [];
    329456
    330457                if (typeOf(needles) !== 'array') {
     
    338465                for (var i in needles) {
    339466                        if (inArray(needles[i], array) === -1) {
    340467                                diff.push(needles[i]);
    341                         }       
     468                        }
    342469                }
    343470                return diff.length ? diff : false;
    344         };
     471        }
    345472
    346473
    347474        /**
     
    353480        @param {Array} array2
    354481        @return {Array} Intersection of two arrays or null if there is none
    355482        */
    356         var arrayIntersect = function(array1, array2) {
     483        function arrayIntersect(array1, array2) {
    357484                var result = [];
    358485                each(array1, function(item) {
    359486                        if (inArray(item, array2) !== -1) {
     
    361488                        }
    362489                });
    363490                return result.length ? result : null;
    364         };
    365        
    366        
     491        }
     492
     493
    367494        /**
    368495        Forces anything into an array.
    369        
     496
    370497        @method toArray
    371498        @static
    372499        @param {Object} obj Object with length field.
    373500        @return {Array} Array object containing all items.
    374501        */
    375         var toArray = function(obj) {
     502        function toArray(obj) {
    376503                var i, arr = [];
    377504
    378505                for (i = 0; i < obj.length; i++) {
     
    380507                }
    381508
    382509                return arr;
    383         };
    384        
    385                        
     510        }
     511
     512
    386513        /**
    387514        Generates an unique ID. The only way a user would be able to get the same ID is if the two persons
    388         at the same exact millisecond manage to get the same 5 random numbers between 0-65535; it also uses 
    389         a counter so each ID is guaranteed to be unique for the given page. It is more probable for the earth 
     515        at the same exact millisecond manage to get the same 5 random numbers between 0-65535; it also uses
     516        a counter so each ID is guaranteed to be unique for the given page. It is more probable for the earth
    390517        to be hit with an asteroid.
    391        
     518
    392519        @method guid
    393520        @static
    394521        @param {String} prefix to prepend (by default 'o' will be prepended).
     
    397524        */
    398525        var guid = (function() {
    399526                var counter = 0;
    400                
     527
    401528                return function(prefix) {
    402529                        var guid = new Date().getTime().toString(32), i;
    403530
     
    404531                        for (i = 0; i < 5; i++) {
    405532                                guid += Math.floor(Math.random() * 65535).toString(32);
    406533                        }
    407                        
     534
    408535                        return (prefix || 'o_') + guid + (counter++).toString(32);
    409536                };
    410537        }());
    411        
    412538
     539
    413540        /**
    414541        Trims white spaces around the string
    415        
     542
    416543        @method trim
    417544        @static
    418545        @param {String} str
    419546        @return {String}
    420547        */
    421         var trim = function(str) {
     548        function trim(str) {
    422549                if (!str) {
    423550                        return str;
    424551                }
    425552                return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, '');
    426         };
     553        }
    427554
    428555
    429556        /**
    430557        Parses the specified size string into a byte value. For example 10kb becomes 10240.
    431        
     558
    432559        @method parseSizeStr
    433560        @static
    434561        @param {String/Number} size String to parse or number to just pass through.
    435562        @return {Number} Size in bytes.
    436563        */
    437         var parseSizeStr = function(size) {
     564        function parseSizeStr(size) {
    438565                if (typeof(size) !== 'string') {
    439566                        return size;
    440567                }
    441                
     568
    442569                var muls = {
    443570                                t: 1099511627776,
    444571                                g: 1073741824,
     
    447574                        },
    448575                        mul;
    449576
    450 
    451577                size = /^([0-9\.]+)([tmgk]?)$/.exec(size.toLowerCase().replace(/[^0-9\.tmkg]/g, ''));
    452578                mul = size[2];
    453579                size = +size[1];
    454                
     580
    455581                if (muls.hasOwnProperty(mul)) {
    456582                        size *= muls[mul];
    457583                }
    458584                return Math.floor(size);
    459         };
     585        }
    460586
    461587
    462588        /**
     
    465591         * @param {String} str String with tokens
    466592         * @return {String} String with replaced tokens
    467593         */
    468         var sprintf = function(str) {
     594        function sprintf(str) {
    469595                var args = [].slice.call(arguments, 1);
    470596
    471                 return str.replace(/%[a-z]/g, function() {
     597                return str.replace(/%([a-z])/g, function($0, $1) {
    472598                        var value = args.shift();
    473                         return typeOf(value) !== 'undefined' ? value : '';
     599
     600                        switch ($1) {
     601                                case 's':
     602                                        return value + '';
     603
     604                                case 'd':
     605                                        return parseInt(value, 10);
     606
     607                                case 'f':
     608                                        return parseFloat(value);
     609
     610                                case 'c':
     611                                        return '';
     612
     613                                default:
     614                                        return value;
     615                        }
    474616                });
    475         };
    476        
     617        }
    477618
     619
     620
     621        function delay(cb, timeout) {
     622                var self = this;
     623                setTimeout(function() {
     624                        cb.call(self);
     625                }, timeout || 1);
     626        }
     627
     628
    478629        return {
    479630                guid: guid,
    480631                typeOf: typeOf,
    481632                extend: extend,
     633                extendIf: extendIf,
     634                extendImmutable: extendImmutable,
     635                extendImmutableIf: extendImmutableIf,
     636                clone: clone,
     637                inherit: inherit,
    482638                each: each,
    483639                isEmptyObj: isEmptyObj,
    484640                inSeries: inSeries,
     
    489645                toArray: toArray,
    490646                trim: trim,
    491647                sprintf: sprintf,
    492                 parseSizeStr: parseSizeStr
     648                parseSizeStr: parseSizeStr,
     649                delay: delay
    493650        };
    494651});
    495652
     653// Included from: src/javascript/core/utils/Encode.js
     654
     655/**
     656 * Encode.js
     657 *
     658 * Copyright 2013, Moxiecode Systems AB
     659 * Released under GPL License.
     660 *
     661 * License: http://www.plupload.com/license
     662 * Contributing: http://www.plupload.com/contributing
     663 */
     664
     665/**
     666@class moxie/core/utils/Encode
     667@public
     668@static
     669*/
     670
     671define('moxie/core/utils/Encode', [], function() {
     672
     673        /**
     674        Encode string with UTF-8
     675
     676        @method utf8_encode
     677        @static
     678        @param {String} str String to encode
     679        @return {String} UTF-8 encoded string
     680        */
     681        var utf8_encode = function(str) {
     682                return unescape(encodeURIComponent(str));
     683        };
     684       
     685        /**
     686        Decode UTF-8 encoded string
     687
     688        @method utf8_decode
     689        @static
     690        @param {String} str String to decode
     691        @return {String} Decoded string
     692        */
     693        var utf8_decode = function(str_data) {
     694                return decodeURIComponent(escape(str_data));
     695        };
     696       
     697        /**
     698        Decode Base64 encoded string (uses browser's default method if available),
     699        from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js
     700
     701        @method atob
     702        @static
     703        @param {String} data String to decode
     704        @return {String} Decoded string
     705        */
     706        var atob = function(data, utf8) {
     707                if (typeof(window.atob) === 'function') {
     708                        return utf8 ? utf8_decode(window.atob(data)) : window.atob(data);
     709                }
     710
     711                // http://kevin.vanzonneveld.net
     712                // +   original by: Tyler Akins (http://rumkin.com)
     713                // +   improved by: Thunder.m
     714                // +      input by: Aman Gupta
     715                // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
     716                // +   bugfixed by: Onno Marsman
     717                // +   bugfixed by: Pellentesque Malesuada
     718                // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
     719                // +      input by: Brett Zamir (http://brett-zamir.me)
     720                // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
     721                // *     example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
     722                // *     returns 1: 'Kevin van Zonneveld'
     723                // mozilla has this native
     724                // - but breaks in 2.0.0.12!
     725                //if (typeof this.window.atob == 'function') {
     726                //    return atob(data);
     727                //}
     728                var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
     729                var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
     730                        ac = 0,
     731                        dec = "",
     732                        tmp_arr = [];
     733
     734                if (!data) {
     735                        return data;
     736                }
     737
     738                data += '';
     739
     740                do { // unpack four hexets into three octets using index points in b64
     741                        h1 = b64.indexOf(data.charAt(i++));
     742                        h2 = b64.indexOf(data.charAt(i++));
     743                        h3 = b64.indexOf(data.charAt(i++));
     744                        h4 = b64.indexOf(data.charAt(i++));
     745
     746                        bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
     747
     748                        o1 = bits >> 16 & 0xff;
     749                        o2 = bits >> 8 & 0xff;
     750                        o3 = bits & 0xff;
     751
     752                        if (h3 == 64) {
     753                                tmp_arr[ac++] = String.fromCharCode(o1);
     754                        } else if (h4 == 64) {
     755                                tmp_arr[ac++] = String.fromCharCode(o1, o2);
     756                        } else {
     757                                tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
     758                        }
     759                } while (i < data.length);
     760
     761                dec = tmp_arr.join('');
     762
     763                return utf8 ? utf8_decode(dec) : dec;
     764        };
     765       
     766        /**
     767        Base64 encode string (uses browser's default method if available),
     768        from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js
     769
     770        @method btoa
     771        @static
     772        @param {String} data String to encode
     773        @return {String} Base64 encoded string
     774        */
     775        var btoa = function(data, utf8) {
     776                if (utf8) {
     777                        data = utf8_encode(data);
     778                }
     779
     780                if (typeof(window.btoa) === 'function') {
     781                        return window.btoa(data);
     782                }
     783
     784                // http://kevin.vanzonneveld.net
     785                // +   original by: Tyler Akins (http://rumkin.com)
     786                // +   improved by: Bayron Guevara
     787                // +   improved by: Thunder.m
     788                // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
     789                // +   bugfixed by: Pellentesque Malesuada
     790                // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
     791                // +   improved by: Rafał Kukawski (http://kukawski.pl)
     792                // *     example 1: base64_encode('Kevin van Zonneveld');
     793                // *     returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
     794                // mozilla has this native
     795                // - but breaks in 2.0.0.12!
     796                var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
     797                var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
     798                        ac = 0,
     799                        enc = "",
     800                        tmp_arr = [];
     801
     802                if (!data) {
     803                        return data;
     804                }
     805
     806                do { // pack three octets into four hexets
     807                        o1 = data.charCodeAt(i++);
     808                        o2 = data.charCodeAt(i++);
     809                        o3 = data.charCodeAt(i++);
     810
     811                        bits = o1 << 16 | o2 << 8 | o3;
     812
     813                        h1 = bits >> 18 & 0x3f;
     814                        h2 = bits >> 12 & 0x3f;
     815                        h3 = bits >> 6 & 0x3f;
     816                        h4 = bits & 0x3f;
     817
     818                        // use hexets to index into b64, and append result to encoded string
     819                        tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
     820                } while (i < data.length);
     821
     822                enc = tmp_arr.join('');
     823
     824                var r = data.length % 3;
     825
     826                return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
     827        };
     828
     829
     830        return {
     831                utf8_encode: utf8_encode,
     832                utf8_decode: utf8_decode,
     833                atob: atob,
     834                btoa: btoa
     835        };
     836});
     837
    496838// Included from: src/javascript/core/utils/Env.js
    497839
    498840/**
     
    505847 * Contributing: http://www.plupload.com/contributing
    506848 */
    507849
     850/**
     851@class moxie/core/utils/Env
     852@public
     853@static
     854*/
     855
    508856define("moxie/core/utils/Env", [
    509857        "moxie/core/utils/Basic"
    510858], function(Basic) {
    511        
     859
    512860        /**
    513861         * UAParser.js v0.7.7
    514862         * Lightweight JavaScript-based User-Agent string parser
     
    7111059            var regexes = {
    7121060
    7131061                browser : [[
    714                
     1062
    7151063                    // Presto based
    7161064                    /(opera\smini)\/([\w\.-]+)/i,                                       // Opera Mini
    7171065                    /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i,                      // Opera Mobi/Tablet
     
    10461394
    10471395        var can = (function() {
    10481396                var caps = {
    1049                                 define_property: (function() {
    1050                                         /* // currently too much extra code required, not exactly worth it
    1051                                         try { // as of IE8, getters/setters are supported only on DOM elements
    1052                                                 var obj = {};
    1053                                                 if (Object.defineProperty) {
    1054                                                         Object.defineProperty(obj, 'prop', {
    1055                                                                 enumerable: true,
    1056                                                                 configurable: true
    1057                                                         });
    1058                                                         return true;
    1059                                                 }
    1060                                         } catch(ex) {}
     1397                        access_global_ns: function () {
     1398                                return !!window.moxie;
     1399                        },
    10611400
    1062                                         if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) {
     1401                        define_property: (function() {
     1402                                /* // currently too much extra code required, not exactly worth it
     1403                                try { // as of IE8, getters/setters are supported only on DOM elements
     1404                                        var obj = {};
     1405                                        if (Object.defineProperty) {
     1406                                                Object.defineProperty(obj, 'prop', {
     1407                                                        enumerable: true,
     1408                                                        configurable: true
     1409                                                });
    10631410                                                return true;
    1064                                         }*/
    1065                                         return false;
    1066                                 }()),
     1411                                        }
     1412                                } catch(ex) {}
    10671413
    1068                                 create_canvas: (function() {
    1069                                         // On the S60 and BB Storm, getContext exists, but always returns undefined
    1070                                         // so we actually have to call getContext() to verify
    1071                                         // github.com/Modernizr/Modernizr/issues/issue/97/
    1072                                         var el = document.createElement('canvas');
    1073                                         return !!(el.getContext && el.getContext('2d'));
    1074                                 }()),
     1414                                if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) {
     1415                                        return true;
     1416                                }*/
     1417                                return false;
     1418                        }()),
    10751419
    1076                                 return_response_type: function(responseType) {
    1077                                         try {
    1078                                                 if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) {
     1420                        create_canvas: function() {
     1421                                // On the S60 and BB Storm, getContext exists, but always returns undefined
     1422                                // so we actually have to call getContext() to verify
     1423                                // github.com/Modernizr/Modernizr/issues/issue/97/
     1424                                var el = document.createElement('canvas');
     1425                                var isSupported = !!(el.getContext && el.getContext('2d'));
     1426                                caps.create_canvas = isSupported;
     1427                                return isSupported;
     1428                        },
     1429
     1430                        return_response_type: function(responseType) {
     1431                                try {
     1432                                        if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) {
     1433                                                return true;
     1434                                        } else if (window.XMLHttpRequest) {
     1435                                                var xhr = new XMLHttpRequest();
     1436                                                xhr.open('get', '/'); // otherwise Gecko throws an exception
     1437                                                if ('responseType' in xhr) {
     1438                                                        xhr.responseType = responseType;
     1439                                                        // as of 23.0.1271.64, Chrome switched from throwing exception to merely logging it to the console (why? o why?)
     1440                                                        if (xhr.responseType !== responseType) {
     1441                                                                return false;
     1442                                                        }
    10791443                                                        return true;
    1080                                                 } else if (window.XMLHttpRequest) {
    1081                                                         var xhr = new XMLHttpRequest();
    1082                                                         xhr.open('get', '/'); // otherwise Gecko throws an exception
    1083                                                         if ('responseType' in xhr) {
    1084                                                                 xhr.responseType = responseType;
    1085                                                                 // as of 23.0.1271.64, Chrome switched from throwing exception to merely logging it to the console (why? o why?)
    1086                                                                 if (xhr.responseType !== responseType) {
    1087                                                                         return false;
    1088                                                                 }
    1089                                                                 return true;
    1090                                                         }
    10911444                                                }
    1092                                         } catch (ex) {}
    1093                                         return false;
    1094                                 },
     1445                                        }
     1446                                } catch (ex) {}
     1447                                return false;
     1448                        },
    10951449
    1096                                 // ideas for this heavily come from Modernizr (http://modernizr.com/)
    1097                                 use_data_uri: (function() {
    1098                                         var du = new Image();
     1450                        use_blob_uri: function() {
     1451                                var URL = window.URL;
     1452                                caps.use_blob_uri = (URL &&
     1453                                        'createObjectURL' in URL &&
     1454                                        'revokeObjectURL' in URL &&
     1455                                        (Env.browser !== 'IE' || Env.verComp(Env.version, '11.0.46', '>=')) // IE supports createObjectURL, but not fully, for example it fails to use it as a src for the image
     1456                                );
     1457                                return caps.use_blob_uri;
     1458                        },
    10991459
    1100                                         du.onload = function() {
    1101                                                 caps.use_data_uri = (du.width === 1 && du.height === 1);
    1102                                         };
    1103                                        
    1104                                         setTimeout(function() {
    1105                                                 du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==";
    1106                                         }, 1);
    1107                                         return false;
    1108                                 }()),
     1460                        // ideas for this heavily come from Modernizr (http://modernizr.com/)
     1461                        use_data_uri: (function() {
     1462                                var du = new Image();
    11091463
    1110                                 use_data_uri_over32kb: function() { // IE8
    1111                                         return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9);
    1112                                 },
     1464                                du.onload = function() {
     1465                                        caps.use_data_uri = (du.width === 1 && du.height === 1);
     1466                                };
    11131467
    1114                                 use_data_uri_of: function(bytes) {
    1115                                         return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb());
    1116                                 },
     1468                                setTimeout(function() {
     1469                                        du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==";
     1470                                }, 1);
     1471                                return false;
     1472                        }()),
    11171473
    1118                                 use_fileinput: function() {
    1119                                         if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) {
    1120                                                 return false;
    1121                                         }
     1474                        use_data_uri_over32kb: function() { // IE8
     1475                                return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9);
     1476                        },
    11221477
    1123                                         var el = document.createElement('input');
    1124                                         el.setAttribute('type', 'file');
    1125                                         return !el.disabled;
     1478                        use_data_uri_of: function(bytes) {
     1479                                return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb());
     1480                        },
     1481
     1482                        use_fileinput: function() {
     1483                                if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) {
     1484                                        return false;
    11261485                                }
    1127                         };
    11281486
     1487                                var el = document.createElement('input');
     1488                                el.setAttribute('type', 'file');
     1489                                return caps.use_fileinput = !el.disabled;
     1490                        },
     1491
     1492                        use_webgl: function() {
     1493                                var canvas = document.createElement('canvas');
     1494                                var gl = null, isSupported;
     1495                                try {
     1496                                        gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
     1497                                }
     1498                                catch(e) {}
     1499
     1500                                if (!gl) { // it seems that sometimes it doesn't throw exception, but still fails to get context
     1501                                        gl = null;
     1502                                }
     1503
     1504                                isSupported = !!gl;
     1505                                caps.use_webgl = isSupported; // save result of our check
     1506                                canvas = undefined;
     1507                                return isSupported;
     1508                        }
     1509                };
     1510
    11291511                return function(cap) {
    11301512                        var args = [].slice.call(arguments);
    11311513                        args.shift(); // shift of cap
     
    11411523                can: can,
    11421524
    11431525                uaParser: UAParser,
    1144                
     1526
    11451527                browser: uaResult.browser.name,
    11461528                version: uaResult.browser.version,
    11471529                os: uaResult.os.name, // everybody intuitively types it in a lowercase for some reason
     
    11491531
    11501532                verComp: version_compare,
    11511533
     1534                swf_url: "../flash/Moxie.swf",
     1535                xap_url: "../silverlight/Moxie.xap",
    11521536                global_event_dispatcher: "moxie.core.EventTarget.instance.dispatchEvent"
    11531537        };
    11541538
     
    11631547                };
    11641548
    11651549                Env.log = function() {
    1166                        
     1550
    11671551                        function logObj(data) {
    11681552                                // TODO: this should recursively print out the object in a pretty way
    11691553                                console.appendChild(document.createTextNode(data + "\n"));
    11701554                        }
    11711555
    1172                         var data = arguments[0];
    1173 
    1174                         if (Basic.typeOf(data) === 'string') {
    1175                                 data = Basic.sprintf.apply(this, arguments);
    1176                         }
    1177 
    1178                         if (window && window.console && window.console.log) {
    1179                                 window.console.log(data);
     1556                        // if debugger present, IE8 might have window.console.log method, but not be able to apply on it (why...)
     1557                        if (window && window.console && window.console.log && window.console.log.apply) {
     1558                                window.console.log.apply(window.console, arguments);
    11801559                        } else if (document) {
    11811560                                var console = document.getElementById('moxie-console');
    11821561                                if (!console) {
     
    11861565                                        document.body.appendChild(console);
    11871566                                }
    11881567
    1189                                 if (Basic.inArray(Basic.typeOf(data), ['object', 'array']) !== -1) {
     1568                                var data = arguments[0];
     1569                                if (Basic.typeOf(data) === 'string') {
     1570                                        data = Basic.sprintf.apply(this, arguments);
     1571                                } else if (Basic.inArray(Basic.typeOf(data), ['object', 'array']) !== -1) {
    11901572                                        logObj(data);
    1191                                 } else {
    1192                                         console.appendChild(document.createTextNode(data + "\n"));
     1573                                        return;
    11931574                                }
     1575
     1576                                console.appendChild(document.createTextNode(data + "\n"));
    11941577                        }
    11951578                };
    11961579        }
     
    11981581        return Env;
    11991582});
    12001583
    1201 // Included from: src/javascript/core/I18n.js
     1584// Included from: src/javascript/core/Exceptions.js
    12021585
    12031586/**
    1204  * I18n.js
     1587 * Exceptions.js
    12051588 *
    12061589 * Copyright 2013, Moxiecode Systems AB
    12071590 * Released under GPL License.
     
    12101593 * Contributing: http://www.plupload.com/contributing
    12111594 */
    12121595
    1213 define("moxie/core/I18n", [
    1214         "moxie/core/utils/Basic"
     1596define('moxie/core/Exceptions', [
     1597        'moxie/core/utils/Basic'
    12151598], function(Basic) {
    1216         var i18n = {};
     1599       
     1600        function _findKey(obj, value) {
     1601                var key;
     1602                for (key in obj) {
     1603                        if (obj[key] === value) {
     1604                                return key;
     1605                        }
     1606                }
     1607                return null;
     1608        }
    12171609
     1610        /**
     1611        @class moxie/core/Exception
     1612        */
    12181613        return {
    1219                 /**
    1220                  * Extends the language pack object with new items.
    1221                  *
    1222                  * @param {Object} pack Language pack items to add.
    1223                  * @return {Object} Extended language pack object.
    1224                  */
    1225                 addI18n: function(pack) {
    1226                         return Basic.extend(i18n, pack);
    1227                 },
     1614                RuntimeError: (function() {
     1615                        var namecodes = {
     1616                                NOT_INIT_ERR: 1,
     1617                                EXCEPTION_ERR: 3,
     1618                                NOT_SUPPORTED_ERR: 9,
     1619                                JS_ERR: 4
     1620                        };
    12281621
    1229                 /**
    1230                  * Translates the specified string by checking for the english string in the language pack lookup.
    1231                  *
    1232                  * @param {String} str String to look for.
    1233                  * @return {String} Translated string or the input string if it wasn't found.
    1234                  */
    1235                 translate: function(str) {
    1236                         return i18n[str] || str;
    1237                 },
    1238 
    1239                 /**
    1240                  * Shortcut for translate function
    1241                  *
    1242                  * @param {String} str String to look for.
    1243                  * @return {String} Translated string or the input string if it wasn't found.
    1244                  */
    1245                 _: function(str) {
    1246                         return this.translate(str);
    1247                 },
    1248 
    1249                 /**
    1250                  * Pseudo sprintf implementation - simple way to replace tokens with specified values.
    1251                  *
    1252                  * @param {String} str String with tokens
    1253                  * @return {String} String with replaced tokens
    1254                  */
    1255                 sprintf: function(str) {
    1256                         var args = [].slice.call(arguments, 1);
    1257 
    1258                         return str.replace(/%[a-z]/g, function() {
    1259                                 var value = args.shift();
    1260                                 return Basic.typeOf(value) !== 'undefined' ? value : '';
     1622                        function RuntimeError(code, message) {
     1623                                this.code = code;
     1624                                this.name = _findKey(namecodes, code);
     1625                                this.message = this.name + (message || ": RuntimeError " + this.code);
     1626                        }
     1627                       
     1628                        Basic.extend(RuntimeError, namecodes);
     1629                        RuntimeError.prototype = Error.prototype;
     1630                        return RuntimeError;
     1631                }()),
     1632               
     1633                OperationNotAllowedException: (function() {
     1634                       
     1635                        function OperationNotAllowedException(code) {
     1636                                this.code = code;
     1637                                this.name = 'OperationNotAllowedException';
     1638                        }
     1639                       
     1640                        Basic.extend(OperationNotAllowedException, {
     1641                                NOT_ALLOWED_ERR: 1
    12611642                        });
    1262                 }
    1263         };
    1264 });
     1643                       
     1644                        OperationNotAllowedException.prototype = Error.prototype;
     1645                       
     1646                        return OperationNotAllowedException;
     1647                }()),
    12651648
    1266 // Included from: src/javascript/core/utils/Mime.js
     1649                ImageError: (function() {
     1650                        var namecodes = {
     1651                                WRONG_FORMAT: 1,
     1652                                MAX_RESOLUTION_ERR: 2,
     1653                                INVALID_META_ERR: 3
     1654                        };
    12671655
    1268 /**
    1269  * Mime.js
    1270  *
    1271  * Copyright 2013, Moxiecode Systems AB
    1272  * Released under GPL License.
    1273  *
    1274  * License: http://www.plupload.com/license
    1275  * Contributing: http://www.plupload.com/contributing
    1276  */
    1277 
    1278 define("moxie/core/utils/Mime", [
    1279         "moxie/core/utils/Basic",
    1280         "moxie/core/I18n"
    1281 ], function(Basic, I18n) {
    1282        
    1283         var mimeData = "" +
    1284                 "application/msword,doc dot," +
    1285                 "application/pdf,pdf," +
    1286                 "application/pgp-signature,pgp," +
    1287                 "application/postscript,ps ai eps," +
    1288                 "application/rtf,rtf," +
    1289                 "application/vnd.ms-excel,xls xlb," +
    1290                 "application/vnd.ms-powerpoint,ppt pps pot," +
    1291                 "application/zip,zip," +
    1292                 "application/x-shockwave-flash,swf swfl," +
    1293                 "application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," +
    1294                 "application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," +
    1295                 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," +
    1296                 "application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," +
    1297                 "application/vnd.openxmlformats-officedocument.presentationml.template,potx," +
    1298                 "application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," +
    1299                 "application/x-javascript,js," +
    1300                 "application/json,json," +
    1301                 "audio/mpeg,mp3 mpga mpega mp2," +
    1302                 "audio/x-wav,wav," +
    1303                 "audio/x-m4a,m4a," +
    1304                 "audio/ogg,oga ogg," +
    1305                 "audio/aiff,aiff aif," +
    1306                 "audio/flac,flac," +
    1307                 "audio/aac,aac," +
    1308                 "audio/ac3,ac3," +
    1309                 "audio/x-ms-wma,wma," +
    1310                 "image/bmp,bmp," +
    1311                 "image/gif,gif," +
    1312                 "image/jpeg,jpg jpeg jpe," +
    1313                 "image/photoshop,psd," +
    1314                 "image/png,png," +
    1315                 "image/svg+xml,svg svgz," +
    1316                 "image/tiff,tiff tif," +
    1317                 "text/plain,asc txt text diff log," +
    1318                 "text/html,htm html xhtml," +
    1319                 "text/css,css," +
    1320                 "text/csv,csv," +
    1321                 "text/rtf,rtf," +
    1322                 "video/mpeg,mpeg mpg mpe m2v," +
    1323                 "video/quicktime,qt mov," +
    1324                 "video/mp4,mp4," +
    1325                 "video/x-m4v,m4v," +
    1326                 "video/x-flv,flv," +
    1327                 "video/x-ms-wmv,wmv," +
    1328                 "video/avi,avi," +
    1329                 "video/webm,webm," +
    1330                 "video/3gpp,3gpp 3gp," +
    1331                 "video/3gpp2,3g2," +
    1332                 "video/vnd.rn-realvideo,rv," +
    1333                 "video/ogg,ogv," +
    1334                 "video/x-matroska,mkv," +
    1335                 "application/vnd.oasis.opendocument.formula-template,otf," +
    1336                 "application/octet-stream,exe";
    1337        
    1338        
    1339         var Mime = {
    1340 
    1341                 mimes: {},
    1342 
    1343                 extensions: {},
    1344 
    1345                 // Parses the default mime types string into a mimes and extensions lookup maps
    1346                 addMimeType: function (mimeData) {
    1347                         var items = mimeData.split(/,/), i, ii, ext;
    1348                        
    1349                         for (i = 0; i < items.length; i += 2) {
    1350                                 ext = items[i + 1].split(/ /);
    1351 
    1352                                 // extension to mime lookup
    1353                                 for (ii = 0; ii < ext.length; ii++) {
    1354                                         this.mimes[ext[ii]] = items[i];
    1355                                 }
    1356                                 // mime to extension lookup
    1357                                 this.extensions[items[i]] = ext;
     1656                        function ImageError(code) {
     1657                                this.code = code;
     1658                                this.name = _findKey(namecodes, code);
     1659                                this.message = this.name + ": ImageError " + this.code;
    13581660                        }
    1359                 },
    1360 
    1361 
    1362                 extList2mimes: function (filters, addMissingExtensions) {
    1363                         var self = this, ext, i, ii, type, mimes = [];
    13641661                       
    1365                         // convert extensions to mime types list
    1366                         for (i = 0; i < filters.length; i++) {
    1367                                 ext = filters[i].extensions.split(/\s*,\s*/);
     1662                        Basic.extend(ImageError, namecodes);
     1663                        ImageError.prototype = Error.prototype;
    13681664
    1369                                 for (ii = 0; ii < ext.length; ii++) {
    1370                                        
    1371                                         // if there's an asterisk in the list, then accept attribute is not required
    1372                                         if (ext[ii] === '*') {
    1373                                                 return [];
    1374                                         }
     1665                        return ImageError;
     1666                }()),
    13751667
    1376                                         type = self.mimes[ext[ii]];
    1377                                         if (type && Basic.inArray(type, mimes) === -1) {
    1378                                                 mimes.push(type);
    1379                                         }
     1668                FileException: (function() {
     1669                        var namecodes = {
     1670                                NOT_FOUND_ERR: 1,
     1671                                SECURITY_ERR: 2,
     1672                                ABORT_ERR: 3,
     1673                                NOT_READABLE_ERR: 4,
     1674                                ENCODING_ERR: 5,
     1675                                NO_MODIFICATION_ALLOWED_ERR: 6,
     1676                                INVALID_STATE_ERR: 7,
     1677                                SYNTAX_ERR: 8
     1678                        };
    13801679
    1381                                         // future browsers should filter by extension, finally
    1382                                         if (addMissingExtensions && /^\w+$/.test(ext[ii])) {
    1383                                                 mimes.push('.' + ext[ii]);
    1384                                         } else if (!type) {
    1385                                                 // if we have no type in our map, then accept all
    1386                                                 return [];
    1387                                         }
    1388                                 }
     1680                        function FileException(code) {
     1681                                this.code = code;
     1682                                this.name = _findKey(namecodes, code);
     1683                                this.message = this.name + ": FileException " + this.code;
    13891684                        }
    1390                         return mimes;
    1391                 },
    1392 
    1393 
    1394                 mimes2exts: function(mimes) {
    1395                         var self = this, exts = [];
    13961685                       
    1397                         Basic.each(mimes, function(mime) {
    1398                                 if (mime === '*') {
    1399                                         exts = [];
    1400                                         return false;
    1401                                 }
     1686                        Basic.extend(FileException, namecodes);
     1687                        FileException.prototype = Error.prototype;
     1688                        return FileException;
     1689                }()),
     1690               
     1691                DOMException: (function() {
     1692                        var namecodes = {
     1693                                INDEX_SIZE_ERR: 1,
     1694                                DOMSTRING_SIZE_ERR: 2,
     1695                                HIERARCHY_REQUEST_ERR: 3,
     1696                                WRONG_DOCUMENT_ERR: 4,
     1697                                INVALID_CHARACTER_ERR: 5,
     1698                                NO_DATA_ALLOWED_ERR: 6,
     1699                                NO_MODIFICATION_ALLOWED_ERR: 7,
     1700                                NOT_FOUND_ERR: 8,
     1701                                NOT_SUPPORTED_ERR: 9,
     1702                                INUSE_ATTRIBUTE_ERR: 10,
     1703                                INVALID_STATE_ERR: 11,
     1704                                SYNTAX_ERR: 12,
     1705                                INVALID_MODIFICATION_ERR: 13,
     1706                                NAMESPACE_ERR: 14,
     1707                                INVALID_ACCESS_ERR: 15,
     1708                                VALIDATION_ERR: 16,
     1709                                TYPE_MISMATCH_ERR: 17,
     1710                                SECURITY_ERR: 18,
     1711                                NETWORK_ERR: 19,
     1712                                ABORT_ERR: 20,
     1713                                URL_MISMATCH_ERR: 21,
     1714                                QUOTA_EXCEEDED_ERR: 22,
     1715                                TIMEOUT_ERR: 23,
     1716                                INVALID_NODE_TYPE_ERR: 24,
     1717                                DATA_CLONE_ERR: 25
     1718                        };
    14021719
    1403                                 // check if this thing looks like mime type
    1404                                 var m = mime.match(/^(\w+)\/(\*|\w+)$/);
    1405                                 if (m) {
    1406                                         if (m[2] === '*') {
    1407                                                 // wildcard mime type detected
    1408                                                 Basic.each(self.extensions, function(arr, mime) {
    1409                                                         if ((new RegExp('^' + m[1] + '/')).test(mime)) {
    1410                                                                 [].push.apply(exts, self.extensions[mime]);
    1411                                                         }
    1412                                                 });
    1413                                         } else if (self.extensions[mime]) {
    1414                                                 [].push.apply(exts, self.extensions[mime]);
    1415                                         }
    1416                                 }
    1417                         });
    1418                         return exts;
    1419                 },
    1420 
    1421 
    1422                 mimes2extList: function(mimes) {
    1423                         var accept = [], exts = [];
    1424 
    1425                         if (Basic.typeOf(mimes) === 'string') {
    1426                                 mimes = Basic.trim(mimes).split(/\s*,\s*/);
     1720                        function DOMException(code) {
     1721                                this.code = code;
     1722                                this.name = _findKey(namecodes, code);
     1723                                this.message = this.name + ": DOMException " + this.code;
    14271724                        }
    1428 
    1429                         exts = this.mimes2exts(mimes);
    14301725                       
    1431                         accept.push({
    1432                                 title: I18n.translate('Files'),
    1433                                 extensions: exts.length ? exts.join(',') : '*'
     1726                        Basic.extend(DOMException, namecodes);
     1727                        DOMException.prototype = Error.prototype;
     1728                        return DOMException;
     1729                }()),
     1730               
     1731                EventException: (function() {
     1732                        function EventException(code) {
     1733                                this.code = code;
     1734                                this.name = 'EventException';
     1735                        }
     1736                       
     1737                        Basic.extend(EventException, {
     1738                                UNSPECIFIED_EVENT_TYPE_ERR: 0
    14341739                        });
    14351740                       
    1436                         // save original mimes string
    1437                         accept.mimes = mimes;
    1438 
    1439                         return accept;
    1440                 },
    1441 
    1442 
    1443                 getFileExtension: function(fileName) {
    1444                         var matches = fileName && fileName.match(/\.([^.]+)$/);
    1445                         if (matches) {
    1446                                 return matches[1].toLowerCase();
    1447                         }
    1448                         return '';
    1449                 },
    1450 
    1451                 getFileMime: function(fileName) {
    1452                         return this.mimes[this.getFileExtension(fileName)] || '';
    1453                 }
     1741                        EventException.prototype = Error.prototype;
     1742                       
     1743                        return EventException;
     1744                }())
    14541745        };
    1455 
    1456         Mime.addMimeType(mimeData);
    1457 
    1458         return Mime;
    14591746});
    14601747
    14611748// Included from: src/javascript/core/utils/Dom.js
     
    14701757 * Contributing: http://www.plupload.com/contributing
    14711758 */
    14721759
     1760/**
     1761@class moxie/core/utils/Dom
     1762@public
     1763@static
     1764*/
     1765
    14731766define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) {
    14741767
    14751768        /**
     
    14761769        Get DOM Element by it's id.
    14771770
    14781771        @method get
    1479         @for Utils
    14801772        @param {String} id Identifier of the DOM Element
    14811773        @return {DOMElement}
    14821774        */
     
    16411933        };
    16421934});
    16431935
    1644 // Included from: src/javascript/core/Exceptions.js
     1936// Included from: src/javascript/core/EventTarget.js
    16451937
    16461938/**
    1647  * Exceptions.js
     1939 * EventTarget.js
    16481940 *
    16491941 * Copyright 2013, Moxiecode Systems AB
    16501942 * Released under GPL License.
     
    16531945 * Contributing: http://www.plupload.com/contributing
    16541946 */
    16551947
    1656 define('moxie/core/Exceptions', [
     1948define('moxie/core/EventTarget', [
     1949        'moxie/core/utils/Env',
     1950        'moxie/core/Exceptions',
    16571951        'moxie/core/utils/Basic'
    1658 ], function(Basic) {
    1659         function _findKey(obj, value) {
    1660                 var key;
    1661                 for (key in obj) {
    1662                         if (obj[key] === value) {
    1663                                 return key;
    1664                         }
    1665                 }
    1666                 return null;
     1952], function(Env, x, Basic) {
     1953
     1954        // hash of event listeners by object uid
     1955        var eventpool = {};
     1956
     1957        /**
     1958        Parent object for all event dispatching components and objects
     1959
     1960        @class moxie/core/EventTarget
     1961        @constructor EventTarget
     1962        */
     1963        function EventTarget() {
     1964                /**
     1965                Unique id of the event dispatcher, usually overriden by children
     1966
     1967                @property uid
     1968                @type String
     1969                */
     1970                this.uid = Basic.guid();
    16671971        }
    16681972
    1669         return {
    1670                 RuntimeError: (function() {
    1671                         var namecodes = {
    1672                                 NOT_INIT_ERR: 1,
    1673                                 NOT_SUPPORTED_ERR: 9,
    1674                                 JS_ERR: 4
    1675                         };
    16761973
    1677                         function RuntimeError(code) {
    1678                                 this.code = code;
    1679                                 this.name = _findKey(namecodes, code);
    1680                                 this.message = this.name + ": RuntimeError " + this.code;
    1681                         }
    1682                        
    1683                         Basic.extend(RuntimeError, namecodes);
    1684                         RuntimeError.prototype = Error.prototype;
    1685                         return RuntimeError;
    1686                 }()),
    1687                
    1688                 OperationNotAllowedException: (function() {
    1689                        
    1690                         function OperationNotAllowedException(code) {
    1691                                 this.code = code;
    1692                                 this.name = 'OperationNotAllowedException';
    1693                         }
    1694                        
    1695                         Basic.extend(OperationNotAllowedException, {
    1696                                 NOT_ALLOWED_ERR: 1
    1697                         });
    1698                        
    1699                         OperationNotAllowedException.prototype = Error.prototype;
    1700                        
    1701                         return OperationNotAllowedException;
    1702                 }()),
     1974        Basic.extend(EventTarget.prototype, {
    17031975
    1704                 ImageError: (function() {
    1705                         var namecodes = {
    1706                                 WRONG_FORMAT: 1,
    1707                                 MAX_RESOLUTION_ERR: 2,
    1708                                 INVALID_META_ERR: 3
    1709                         };
     1976                /**
     1977                Can be called from within a child  in order to acquire uniqie id in automated manner
    17101978
    1711                         function ImageError(code) {
    1712                                 this.code = code;
    1713                                 this.name = _findKey(namecodes, code);
    1714                                 this.message = this.name + ": ImageError " + this.code;
     1979                @method init
     1980                */
     1981                init: function() {
     1982                        if (!this.uid) {
     1983                                this.uid = Basic.guid('uid_');
    17151984                        }
    1716                        
    1717                         Basic.extend(ImageError, namecodes);
    1718                         ImageError.prototype = Error.prototype;
     1985                },
    17191986
    1720                         return ImageError;
    1721                 }()),
     1987                /**
     1988                Register a handler to a specific event dispatched by the object
    17221989
    1723                 FileException: (function() {
    1724                         var namecodes = {
    1725                                 NOT_FOUND_ERR: 1,
    1726                                 SECURITY_ERR: 2,
    1727                                 ABORT_ERR: 3,
    1728                                 NOT_READABLE_ERR: 4,
    1729                                 ENCODING_ERR: 5,
    1730                                 NO_MODIFICATION_ALLOWED_ERR: 6,
    1731                                 INVALID_STATE_ERR: 7,
    1732                                 SYNTAX_ERR: 8
    1733                         };
     1990                @method addEventListener
     1991                @param {String} type Type or basically a name of the event to subscribe to
     1992                @param {Function} fn Callback function that will be called when event happens
     1993                @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first
     1994                @param {Object} [scope=this] A scope to invoke event handler in
     1995                */
     1996                addEventListener: function(type, fn, priority, scope) {
     1997                        var self = this, list;
    17341998
    1735                         function FileException(code) {
    1736                                 this.code = code;
    1737                                 this.name = _findKey(namecodes, code);
    1738                                 this.message = this.name + ": FileException " + this.code;
     1999                        // without uid no event handlers can be added, so make sure we got one
     2000                        if (!this.hasOwnProperty('uid')) {
     2001                                this.uid = Basic.guid('uid_');
    17392002                        }
    1740                        
    1741                         Basic.extend(FileException, namecodes);
    1742                         FileException.prototype = Error.prototype;
    1743                         return FileException;
    1744                 }()),
    1745                
    1746                 DOMException: (function() {
    1747                         var namecodes = {
    1748                                 INDEX_SIZE_ERR: 1,
    1749                                 DOMSTRING_SIZE_ERR: 2,
    1750                                 HIERARCHY_REQUEST_ERR: 3,
    1751                                 WRONG_DOCUMENT_ERR: 4,
    1752                                 INVALID_CHARACTER_ERR: 5,
    1753                                 NO_DATA_ALLOWED_ERR: 6,
    1754                                 NO_MODIFICATION_ALLOWED_ERR: 7,
    1755                                 NOT_FOUND_ERR: 8,
    1756                                 NOT_SUPPORTED_ERR: 9,
    1757                                 INUSE_ATTRIBUTE_ERR: 10,
    1758                                 INVALID_STATE_ERR: 11,
    1759                                 SYNTAX_ERR: 12,
    1760                                 INVALID_MODIFICATION_ERR: 13,
    1761                                 NAMESPACE_ERR: 14,
    1762                                 INVALID_ACCESS_ERR: 15,
    1763                                 VALIDATION_ERR: 16,
    1764                                 TYPE_MISMATCH_ERR: 17,
    1765                                 SECURITY_ERR: 18,
    1766                                 NETWORK_ERR: 19,
    1767                                 ABORT_ERR: 20,
    1768                                 URL_MISMATCH_ERR: 21,
    1769                                 QUOTA_EXCEEDED_ERR: 22,
    1770                                 TIMEOUT_ERR: 23,
    1771                                 INVALID_NODE_TYPE_ERR: 24,
    1772                                 DATA_CLONE_ERR: 25
    1773                         };
    17742003
    1775                         function DOMException(code) {
    1776                                 this.code = code;
    1777                                 this.name = _findKey(namecodes, code);
    1778                                 this.message = this.name + ": DOMException " + this.code;
     2004                        type = Basic.trim(type);
     2005
     2006                        if (/\s/.test(type)) {
     2007                                // multiple event types were passed for one handler
     2008                                Basic.each(type.split(/\s+/), function(type) {
     2009                                        self.addEventListener(type, fn, priority, scope);
     2010                                });
     2011                                return;
    17792012                        }
    1780                        
    1781                         Basic.extend(DOMException, namecodes);
    1782                         DOMException.prototype = Error.prototype;
    1783                         return DOMException;
    1784                 }()),
    1785                
    1786                 EventException: (function() {
    1787                         function EventException(code) {
    1788                                 this.code = code;
    1789                                 this.name = 'EventException';
    1790                         }
    1791                        
    1792                         Basic.extend(EventException, {
    1793                                 UNSPECIFIED_EVENT_TYPE_ERR: 0
    1794                         });
    1795                        
    1796                         EventException.prototype = Error.prototype;
    1797                        
    1798                         return EventException;
    1799                 }())
    1800         };
    1801 });
    18022013
    1803 // Included from: src/javascript/core/EventTarget.js
     2014                        type = type.toLowerCase();
     2015                        priority = parseInt(priority, 10) || 0;
    18042016
    1805 /**
    1806  * EventTarget.js
    1807  *
    1808  * Copyright 2013, Moxiecode Systems AB
    1809  * Released under GPL License.
    1810  *
    1811  * License: http://www.plupload.com/license
    1812  * Contributing: http://www.plupload.com/contributing
    1813  */
     2017                        list = eventpool[this.uid] && eventpool[this.uid][type] || [];
     2018                        list.push({fn : fn, priority : priority, scope : scope || this});
    18142019
    1815 define('moxie/core/EventTarget', [
    1816         'moxie/core/utils/Env',
    1817         'moxie/core/Exceptions',
    1818         'moxie/core/utils/Basic'
    1819 ], function(Env, x, Basic) {
    1820         /**
    1821         Parent object for all event dispatching components and objects
     2020                        if (!eventpool[this.uid]) {
     2021                                eventpool[this.uid] = {};
     2022                        }
     2023                        eventpool[this.uid][type] = list;
     2024                },
    18222025
    1823         @class EventTarget
    1824         @constructor EventTarget
    1825         */
    1826         function EventTarget() {
    1827                 // hash of event listeners by object uid
    1828                 var eventpool = {};
    1829                                
    1830                 Basic.extend(this, {
    1831                        
    1832                         /**
    1833                         Unique id of the event dispatcher, usually overriden by children
     2026                /**
     2027                Check if any handlers were registered to the specified event
    18342028
    1835                         @property uid
    1836                         @type String
    1837                         */
    1838                         uid: null,
    1839                        
    1840                         /**
    1841                         Can be called from within a child  in order to acquire uniqie id in automated manner
     2029                @method hasEventListener
     2030                @param {String} [type] Type or basically a name of the event to check
     2031                @return {Mixed} Returns a handler if it was found and false, if - not
     2032                */
     2033                hasEventListener: function(type) {
     2034                        var list;
     2035                        if (type) {
     2036                                type = type.toLowerCase();
     2037                                list = eventpool[this.uid] && eventpool[this.uid][type];
     2038                        } else {
     2039                                list = eventpool[this.uid];
     2040                        }
     2041                        return list ? list : false;
     2042                },
    18422043
    1843                         @method init
    1844                         */
    1845                         init: function() {
    1846                                 if (!this.uid) {
    1847                                         this.uid = Basic.guid('uid_');
    1848                                 }
    1849                         },
     2044                /**
     2045                Unregister the handler from the event, or if former was not specified - unregister all handlers
    18502046
    1851                         /**
    1852                         Register a handler to a specific event dispatched by the object
     2047                @method removeEventListener
     2048                @param {String} type Type or basically a name of the event
     2049                @param {Function} [fn] Handler to unregister
     2050                */
     2051                removeEventListener: function(type, fn) {
     2052                        var self = this, list, i;
    18532053
    1854                         @method addEventListener
    1855                         @param {String} type Type or basically a name of the event to subscribe to
    1856                         @param {Function} fn Callback function that will be called when event happens
    1857                         @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first
    1858                         @param {Object} [scope=this] A scope to invoke event handler in
    1859                         */
    1860                         addEventListener: function(type, fn, priority, scope) {
    1861                                 var self = this, list;
     2054                        type = type.toLowerCase();
    18622055
    1863                                 // without uid no event handlers can be added, so make sure we got one
    1864                                 if (!this.hasOwnProperty('uid')) {
    1865                                         this.uid = Basic.guid('uid_');
    1866                                 }
    1867                                
    1868                                 type = Basic.trim(type);
    1869                                
    1870                                 if (/\s/.test(type)) {
    1871                                         // multiple event types were passed for one handler
    1872                                         Basic.each(type.split(/\s+/), function(type) {
    1873                                                 self.addEventListener(type, fn, priority, scope);
    1874                                         });
    1875                                         return;
    1876                                 }
    1877                                
    1878                                 type = type.toLowerCase();
    1879                                 priority = parseInt(priority, 10) || 0;
    1880                                
    1881                                 list = eventpool[this.uid] && eventpool[this.uid][type] || [];
    1882                                 list.push({fn : fn, priority : priority, scope : scope || this});
    1883                                
    1884                                 if (!eventpool[this.uid]) {
    1885                                         eventpool[this.uid] = {};
    1886                                 }
    1887                                 eventpool[this.uid][type] = list;
    1888                         },
    1889                        
    1890                         /**
    1891                         Check if any handlers were registered to the specified event
     2056                        if (/\s/.test(type)) {
     2057                                // multiple event types were passed for one handler
     2058                                Basic.each(type.split(/\s+/), function(type) {
     2059                                        self.removeEventListener(type, fn);
     2060                                });
     2061                                return;
     2062                        }
    18922063
    1893                         @method hasEventListener
    1894                         @param {String} type Type or basically a name of the event to check
    1895                         @return {Mixed} Returns a handler if it was found and false, if - not
    1896                         */
    1897                         hasEventListener: function(type) {
    1898                                 var list = type ? eventpool[this.uid] && eventpool[this.uid][type] : eventpool[this.uid];
    1899                                 return list ? list : false;
    1900                         },
    1901                        
    1902                         /**
    1903                         Unregister the handler from the event, or if former was not specified - unregister all handlers
     2064                        list = eventpool[this.uid] && eventpool[this.uid][type];
    19042065
    1905                         @method removeEventListener
    1906                         @param {String} type Type or basically a name of the event
    1907                         @param {Function} [fn] Handler to unregister
    1908                         */
    1909                         removeEventListener: function(type, fn) {
    1910                                 type = type.toLowerCase();
    1911        
    1912                                 var list = eventpool[this.uid] && eventpool[this.uid][type], i;
    1913        
    1914                                 if (list) {
    1915                                         if (fn) {
    1916                                                 for (i = list.length - 1; i >= 0; i--) {
    1917                                                         if (list[i].fn === fn) {
    1918                                                                 list.splice(i, 1);
    1919                                                                 break;
    1920                                                         }
     2066                        if (list) {
     2067                                if (fn) {
     2068                                        for (i = list.length - 1; i >= 0; i--) {
     2069                                                if (list[i].fn === fn) {
     2070                                                        list.splice(i, 1);
     2071                                                        break;
    19212072                                                }
    1922                                         } else {
    1923                                                 list = [];
    19242073                                        }
    1925        
    1926                                         // delete event list if it has become empty
    1927                                         if (!list.length) {
    1928                                                 delete eventpool[this.uid][type];
    1929                                                
    1930                                                 // and object specific entry in a hash if it has no more listeners attached
    1931                                                 if (Basic.isEmptyObj(eventpool[this.uid])) {
    1932                                                         delete eventpool[this.uid];
    1933                                                 }
    1934                                         }
     2074                                } else {
     2075                                        list = [];
    19352076                                }
    1936                         },
    1937                        
    1938                         /**
    1939                         Remove all event handlers from the object
    19402077
    1941                         @method removeAllEventListeners
    1942                         */
    1943                         removeAllEventListeners: function() {
    1944                                 if (eventpool[this.uid]) {
    1945                                         delete eventpool[this.uid];
     2078                                // delete event list if it has become empty
     2079                                if (!list.length) {
     2080                                        delete eventpool[this.uid][type];
     2081
     2082                                        // and object specific entry in a hash if it has no more listeners attached
     2083                                        if (Basic.isEmptyObj(eventpool[this.uid])) {
     2084                                                delete eventpool[this.uid];
     2085                                        }
    19462086                                }
    1947                         },
    1948                        
    1949                         /**
    1950                         Dispatch the event
     2087                        }
     2088                },
    19512089
    1952                         @method dispatchEvent
    1953                         @param {String/Object} Type of event or event object to dispatch
    1954                         @param {Mixed} [...] Variable number of arguments to be passed to a handlers
    1955                         @return {Boolean} true by default and false if any handler returned false
    1956                         */
    1957                         dispatchEvent: function(type) {
    1958                                 var uid, list, args, tmpEvt, evt = {}, result = true, undef;
    1959                                
    1960                                 if (Basic.typeOf(type) !== 'string') {
    1961                                         // we can't use original object directly (because of Silverlight)
    1962                                         tmpEvt = type;
     2090                /**
     2091                Remove all event handlers from the object
    19632092
    1964                                         if (Basic.typeOf(tmpEvt.type) === 'string') {
    1965                                                 type = tmpEvt.type;
     2093                @method removeAllEventListeners
     2094                */
     2095                removeAllEventListeners: function() {
     2096                        if (eventpool[this.uid]) {
     2097                                delete eventpool[this.uid];
     2098                        }
     2099                },
    19662100
    1967                                                 if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event
    1968                                                         evt.total = tmpEvt.total;
    1969                                                         evt.loaded = tmpEvt.loaded;
    1970                                                 }
    1971                                                 evt.async = tmpEvt.async || false;
    1972                                         } else {
    1973                                                 throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR);
     2101                /**
     2102                Dispatch the event
     2103
     2104                @method dispatchEvent
     2105                @param {String/Object} Type of event or event object to dispatch
     2106                @param {Mixed} [...] Variable number of arguments to be passed to a handlers
     2107                @return {Boolean} true by default and false if any handler returned false
     2108                */
     2109                dispatchEvent: function(type) {
     2110                        var uid, list, args, tmpEvt, evt = {}, result = true, undef;
     2111
     2112                        if (Basic.typeOf(type) !== 'string') {
     2113                                // we can't use original object directly (because of Silverlight)
     2114                                tmpEvt = type;
     2115
     2116                                if (Basic.typeOf(tmpEvt.type) === 'string') {
     2117                                        type = tmpEvt.type;
     2118
     2119                                        if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event
     2120                                                evt.total = tmpEvt.total;
     2121                                                evt.loaded = tmpEvt.loaded;
    19742122                                        }
    1975                                 }
    1976                                
    1977                                 // check if event is meant to be dispatched on an object having specific uid
    1978                                 if (type.indexOf('::') !== -1) {
    1979                                         (function(arr) {
    1980                                                 uid = arr[0];
    1981                                                 type = arr[1];
    1982                                         }(type.split('::')));
     2123                                        evt.async = tmpEvt.async || false;
    19832124                                } else {
    1984                                         uid = this.uid;
     2125                                        throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR);
    19852126                                }
    1986                                
    1987                                 type = type.toLowerCase();
    1988                                                                
    1989                                 list = eventpool[uid] && eventpool[uid][type];
     2127                        }
    19902128
    1991                                 if (list) {
    1992                                         // sort event list by prority
    1993                                         list.sort(function(a, b) { return b.priority - a.priority; });
    1994                                        
    1995                                         args = [].slice.call(arguments);
    1996                                        
    1997                                         // first argument will be pseudo-event object
    1998                                         args.shift();
    1999                                         evt.type = type;
    2000                                         args.unshift(evt);
     2129                        // check if event is meant to be dispatched on an object having specific uid
     2130                        if (type.indexOf('::') !== -1) {
     2131                                (function(arr) {
     2132                                        uid = arr[0];
     2133                                        type = arr[1];
     2134                                }(type.split('::')));
     2135                        } else {
     2136                                uid = this.uid;
     2137                        }
    20012138
    2002                                         if (MXI_DEBUG && Env.debug.events) {
    2003                                                 Env.log("Event '%s' fired on %u", evt.type, uid);       
    2004                                         }
     2139                        type = type.toLowerCase();
    20052140
    2006                                         // Dispatch event to all listeners
    2007                                         var queue = [];
    2008                                         Basic.each(list, function(handler) {
    2009                                                 // explicitly set the target, otherwise events fired from shims do not get it
    2010                                                 args[0].target = handler.scope;
    2011                                                 // if event is marked as async, detach the handler
    2012                                                 if (evt.async) {
    2013                                                         queue.push(function(cb) {
    2014                                                                 setTimeout(function() {
    2015                                                                         cb(handler.fn.apply(handler.scope, args) === false);
    2016                                                                 }, 1);
    2017                                                         });
    2018                                                 } else {
    2019                                                         queue.push(function(cb) {
    2020                                                                 cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation
    2021                                                         });
    2022                                                 }
    2023                                         });
    2024                                         if (queue.length) {
    2025                                                 Basic.inSeries(queue, function(err) {
    2026                                                         result = !err;
     2141                        list = eventpool[uid] && eventpool[uid][type];
     2142
     2143                        if (list) {
     2144                                // sort event list by prority
     2145                                list.sort(function(a, b) { return b.priority - a.priority; });
     2146
     2147                                args = [].slice.call(arguments);
     2148
     2149                                // first argument will be pseudo-event object
     2150                                args.shift();
     2151                                evt.type = type;
     2152                                args.unshift(evt);
     2153
     2154                                if (MXI_DEBUG && Env.debug.events) {
     2155                                        Env.log("%cEvent '%s' fired on %s", 'color: #999;', evt.type, (this.ctorName ? this.ctorName + '::' : '') + uid);
     2156                                }
     2157
     2158                                // Dispatch event to all listeners
     2159                                var queue = [];
     2160                                Basic.each(list, function(handler) {
     2161                                        // explicitly set the target, otherwise events fired from shims do not get it
     2162                                        args[0].target = handler.scope;
     2163                                        // if event is marked as async, detach the handler
     2164                                        if (evt.async) {
     2165                                                queue.push(function(cb) {
     2166                                                        setTimeout(function() {
     2167                                                                cb(handler.fn.apply(handler.scope, args) === false);
     2168                                                        }, 1);
    20272169                                                });
     2170                                        } else {
     2171                                                queue.push(function(cb) {
     2172                                                        cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation
     2173                                                });
    20282174                                        }
     2175                                });
     2176                                if (queue.length) {
     2177                                        Basic.inSeries(queue, function(err) {
     2178                                                result = !err;
     2179                                        });
    20292180                                }
    2030                                 return result;
    2031                         },
    2032                        
    2033                         /**
    2034                         Alias for addEventListener
     2181                        }
     2182                        return result;
     2183                },
    20352184
    2036                         @method bind
    2037                         @protected
    2038                         */
    2039                         bind: function() {
    2040                                 this.addEventListener.apply(this, arguments);
    2041                         },
    2042                        
    2043                         /**
    2044                         Alias for removeEventListener
     2185                /**
     2186                Register a handler to the event type that will run only once
    20452187
    2046                         @method unbind
    2047                         @protected
    2048                         */
    2049                         unbind: function() {
    2050                                 this.removeEventListener.apply(this, arguments);
    2051                         },
    2052                        
    2053                         /**
    2054                         Alias for removeAllEventListeners
     2188                @method bindOnce
     2189                @since >1.4.1
     2190                @param {String} type Type or basically a name of the event to subscribe to
     2191                @param {Function} fn Callback function that will be called when event happens
     2192                @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first
     2193                @param {Object} [scope=this] A scope to invoke event handler in
     2194                */
     2195                bindOnce: function(type, fn, priority, scope) {
     2196                        var self = this;
     2197                        self.bind.call(this, type, function cb() {
     2198                                self.unbind(type, cb);
     2199                                return fn.apply(this, arguments);
     2200                        }, priority, scope);
     2201                },
    20552202
    2056                         @method unbindAll
    2057                         @protected
    2058                         */
    2059                         unbindAll: function() {
    2060                                 this.removeAllEventListeners.apply(this, arguments);
    2061                         },
    2062                        
    2063                         /**
    2064                         Alias for dispatchEvent
     2203                /**
     2204                Alias for addEventListener
    20652205
    2066                         @method trigger
    2067                         @protected
    2068                         */
    2069                         trigger: function() {
    2070                                 return this.dispatchEvent.apply(this, arguments);
    2071                         },
    2072                        
     2206                @method bind
     2207                @protected
     2208                */
     2209                bind: function() {
     2210                        this.addEventListener.apply(this, arguments);
     2211                },
    20732212
    2074                         /**
    2075                         Handle properties of on[event] type.
     2213                /**
     2214                Alias for removeEventListener
    20762215
    2077                         @method handleEventProps
    2078                         @private
    2079                         */
    2080                         handleEventProps: function(dispatches) {
    2081                                 var self = this;
     2216                @method unbind
     2217                @protected
     2218                */
     2219                unbind: function() {
     2220                        this.removeEventListener.apply(this, arguments);
     2221                },
    20822222
    2083                                 this.bind(dispatches.join(' '), function(e) {
    2084                                         var prop = 'on' + e.type.toLowerCase();
    2085                                         if (Basic.typeOf(this[prop]) === 'function') {
    2086                                                 this[prop].apply(this, arguments);
    2087                                         }
    2088                                 });
     2223                /**
     2224                Alias for removeAllEventListeners
    20892225
    2090                                 // object must have defined event properties, even if it doesn't make use of them
    2091                                 Basic.each(dispatches, function(prop) {
    2092                                         prop = 'on' + prop.toLowerCase(prop);
    2093                                         if (Basic.typeOf(self[prop]) === 'undefined') {
    2094                                                 self[prop] = null;
    2095                                         }
    2096                                 });
    2097                         }
    2098                        
    2099                 });
    2100         }
     2226                @method unbindAll
     2227                @protected
     2228                */
     2229                unbindAll: function() {
     2230                        this.removeAllEventListeners.apply(this, arguments);
     2231                },
    21012232
    2102         EventTarget.instance = new EventTarget();
     2233                /**
     2234                Alias for dispatchEvent
    21032235
     2236                @method trigger
     2237                @protected
     2238                */
     2239                trigger: function() {
     2240                        return this.dispatchEvent.apply(this, arguments);
     2241                },
     2242
     2243
     2244                /**
     2245                Handle properties of on[event] type.
     2246
     2247                @method handleEventProps
     2248                @private
     2249                */
     2250                handleEventProps: function(dispatches) {
     2251                        var self = this;
     2252
     2253                        this.bind(dispatches.join(' '), function(e) {
     2254                                var prop = 'on' + e.type.toLowerCase();
     2255                                if (Basic.typeOf(this[prop]) === 'function') {
     2256                                        this[prop].apply(this, arguments);
     2257                                }
     2258                        });
     2259
     2260                        // object must have defined event properties, even if it doesn't make use of them
     2261                        Basic.each(dispatches, function(prop) {
     2262                                prop = 'on' + prop.toLowerCase(prop);
     2263                                if (Basic.typeOf(self[prop]) === 'undefined') {
     2264                                        self[prop] = null;
     2265                                }
     2266                        });
     2267                }
     2268
     2269        });
     2270
     2271
     2272        EventTarget.instance = new EventTarget();
     2273
    21042274        return EventTarget;
    21052275});
    21062276
     
    21272297        /**
    21282298        Common set of methods and properties for every runtime instance
    21292299
    2130         @class Runtime
     2300        @class moxie/runtime/Runtime
    21312301
    21322302        @param {Object} options
    21332303        @param {String} type Sanitized name of the runtime
     
    23712541
    23722542                                // if no container for shim, create one
    23732543                                if (!shimContainer) {
    2374                                         container = this.options.container ? Dom.get(this.options.container) : document.body;
     2544                                        container = Dom.get(this.options.container) || document.body;
    23752545
    23762546                                        // create shim container and insert it at an absolute position into the outer container
    23772547                                        shimContainer = document.createElement('div');
     
    24752645        @type String
    24762646        @static
    24772647        */
    2478         Runtime.order = 'html5,html4';
     2648        Runtime.order = 'html5,flash,silverlight,html4';
    24792649
    24802650
    24812651        /**
     
    26462816                                                // if cap requires conflicting mode - runtime cannot fulfill required caps
    26472817
    26482818                                                if (MXI_DEBUG && Env.debug.runtime) {
    2649                                                         Env.log("\t\t%c: %v (conflicting mode requested: %s)", cap, value, capMode);   
     2819                                                        Env.log("\t\t%s: %s (conflicting mode requested: %s)", cap, value, capMode);
    26502820                                                }
    26512821
    26522822                                                return (mode = false);
     
    26542824                                }
    26552825
    26562826                                if (MXI_DEBUG && Env.debug.runtime) {
    2657                                         Env.log("\t\t%c: %v (compatible modes: %s)", cap, value, mode);
     2827                                        Env.log("\t\t%s: %s (compatible modes: %s)", cap, value, mode);
    26582828                                }
    26592829                        });
    26602830
     
    26692839
    26702840
    26712841        /**
     2842         * Third party shims (Flash and Silverlight) require global event target against which they
     2843         * will fire their events. However when moxie is not loaded to global namespace, default
     2844         * event target is not accessible and we have to create artificial ones.
     2845         *
     2846         * @method getGlobalEventTarget
     2847         * @static
     2848         * @return {String} Name of the global event target
     2849         */
     2850        Runtime.getGlobalEventTarget = function() {
     2851                if (/^moxie\./.test(Env.global_event_dispatcher) && !Env.can('access_global_ns')) {
     2852                        var uniqueCallbackName = Basic.guid('moxie_event_target_');
     2853
     2854                        window[uniqueCallbackName] = function(e, data) {
     2855                                EventTarget.instance.dispatchEvent(e, data);
     2856                        };
     2857
     2858                        Env.global_event_dispatcher = uniqueCallbackName;
     2859                }
     2860
     2861                return Env.global_event_dispatcher;
     2862        };
     2863
     2864
     2865        /**
    26722866        Capability check that always returns true
    26732867
    26742868        @private
     
    27282922        /**
    27292923        Set of methods and properties, required by a component to acquire ability to connect to a runtime
    27302924
    2731         @class RuntimeClient
     2925        @class moxie/runtime/RuntimeClient
    27322926        */
    27332927        return function RuntimeClient() {
    27342928                var runtime;
     
    27582952                                        type = items.shift().toLowerCase();
    27592953                                        constructor = Runtime.getConstructor(type);
    27602954                                        if (!constructor) {
     2955                                                if (MXI_DEBUG && Env.debug.runtime) {
     2956                                                        Env.log("Constructor for '%s' runtime is not available.", type);
     2957                                                }
    27612958                                                initialize(items);
    27622959                                                return;
    27632960                                        }
     
    27812978                                                // jailbreak ...
    27822979                                                setTimeout(function() {
    27832980                                                        runtime.clients++;
     2981                                                        comp.ruid = runtime.uid;
    27842982                                                        // this will be triggered on component
    27852983                                                        comp.trigger('RuntimeInit', runtime);
    27862984                                                }, 1);
     
    27952993                                                initialize(items);
    27962994                                        });
    27972995
    2798                                         /*runtime.bind('Exception', function() { });*/
     2996                                        runtime.bind('Exception', function(e, err) {
     2997                                                var message = err.name + "(#" + err.code + ")" + (err.message ? ", from: " + err.message : '');
     2998                                               
     2999                                                if (MXI_DEBUG && Env.debug.runtime) {
     3000                                                        Env.log("Runtime '%s' has thrown an exception: %s", this.type, message);
     3001                                                }
     3002                                                comp.trigger('RuntimeError', new x.RuntimeError(x.RuntimeError.EXCEPTION_ERR, message));
     3003                                        });
    27993004
    28003005                                        if (MXI_DEBUG && Env.debug.runtime) {
    28013006                                                Env.log("\tselected mode: %s", runtime.mode);   
     
    28203025                                if (ruid) {
    28213026                                        runtime = Runtime.getRuntime(ruid);
    28223027                                        if (runtime) {
     3028                                                comp.ruid = ruid;
    28233029                                                runtime.clients++;
    28243030                                                return runtime;
    28253031                                        } else {
     
    28713077                        @return {Mixed} Whatever runtime extension method returns
    28723078                        */
    28733079                        exec: function() {
    2874                                 if (runtime) {
    2875                                         return runtime.exec.apply(this, arguments);
     3080                                return runtime ? runtime.exec.apply(this, arguments) : null;
     3081                        },
     3082
     3083
     3084                        /**
     3085                        Test runtime client for specific capability
     3086                       
     3087                        @method can
     3088                        @param {String} cap
     3089                        @return {Bool}
     3090                        */
     3091                        can: function(cap) {
     3092                                return runtime ? runtime.can(cap) : false;
     3093                        }
     3094
     3095                });
     3096        };
     3097
     3098
     3099});
     3100
     3101// Included from: src/javascript/file/Blob.js
     3102
     3103/**
     3104 * Blob.js
     3105 *
     3106 * Copyright 2013, Moxiecode Systems AB
     3107 * Released under GPL License.
     3108 *
     3109 * License: http://www.plupload.com/license
     3110 * Contributing: http://www.plupload.com/contributing
     3111 */
     3112
     3113define('moxie/file/Blob', [
     3114        'moxie/core/utils/Basic',
     3115        'moxie/core/utils/Encode',
     3116        'moxie/runtime/RuntimeClient'
     3117], function(Basic, Encode, RuntimeClient) {
     3118       
     3119        var blobpool = {};
     3120
     3121        /**
     3122        @class moxie/file/Blob
     3123        @constructor
     3124        @param {String} ruid Unique id of the runtime, to which this blob belongs to
     3125        @param {Object} blob Object "Native" blob object, as it is represented in the runtime
     3126        */
     3127        function Blob(ruid, blob) {
     3128
     3129                function _sliceDetached(start, end, type) {
     3130                        var blob, data = blobpool[this.uid];
     3131
     3132                        if (Basic.typeOf(data) !== 'string' || !data.length) {
     3133                                return null; // or throw exception
     3134                        }
     3135
     3136                        blob = new Blob(null, {
     3137                                type: type,
     3138                                size: end - start
     3139                        });
     3140                        blob.detach(data.substr(start, blob.size));
     3141
     3142                        return blob;
     3143                }
     3144
     3145                RuntimeClient.call(this);
     3146
     3147                if (ruid) {     
     3148                        this.connectRuntime(ruid);
     3149                }
     3150
     3151                if (!blob) {
     3152                        blob = {};
     3153                } else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string
     3154                        blob = { data: blob };
     3155                }
     3156
     3157                Basic.extend(this, {
     3158                       
     3159                        /**
     3160                        Unique id of the component
     3161
     3162                        @property uid
     3163                        @type {String}
     3164                        */
     3165                        uid: blob.uid || Basic.guid('uid_'),
     3166                       
     3167                        /**
     3168                        Unique id of the connected runtime, if falsy, then runtime will have to be initialized
     3169                        before this Blob can be used, modified or sent
     3170
     3171                        @property ruid
     3172                        @type {String}
     3173                        */
     3174                        ruid: ruid,
     3175       
     3176                        /**
     3177                        Size of blob
     3178
     3179                        @property size
     3180                        @type {Number}
     3181                        @default 0
     3182                        */
     3183                        size: blob.size || 0,
     3184                       
     3185                        /**
     3186                        Mime type of blob
     3187
     3188                        @property type
     3189                        @type {String}
     3190                        @default ''
     3191                        */
     3192                        type: blob.type || '',
     3193                       
     3194                        /**
     3195                        @method slice
     3196                        @param {Number} [start=0]
     3197                        */
     3198                        slice: function(start, end, type) {             
     3199                                if (this.isDetached()) {
     3200                                        return _sliceDetached.apply(this, arguments);
    28763201                                }
    2877                                 return null;
     3202                                return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type);
     3203                        },
     3204
     3205                        /**
     3206                        Returns "native" blob object (as it is represented in connected runtime) or null if not found
     3207
     3208                        @method getSource
     3209                        @return {Blob} Returns "native" blob object or null if not found
     3210                        */
     3211                        getSource: function() {
     3212                                if (!blobpool[this.uid]) {
     3213                                        return null;   
     3214                                }
     3215                                return blobpool[this.uid];
     3216                        },
     3217
     3218                        /**
     3219                        Detaches blob from any runtime that it depends on and initialize with standalone value
     3220
     3221                        @method detach
     3222                        @protected
     3223                        @param {DOMString} [data=''] Standalone value
     3224                        */
     3225                        detach: function(data) {
     3226                                if (this.ruid) {
     3227                                        this.getRuntime().exec.call(this, 'Blob', 'destroy');
     3228                                        this.disconnectRuntime();
     3229                                        this.ruid = null;
     3230                                }
     3231
     3232                                data = data || '';
     3233
     3234                                // if dataUrl, convert to binary string
     3235                                if (data.substr(0, 5) == 'data:') {
     3236                                        var base64Offset = data.indexOf(';base64,');
     3237                                        this.type = data.substring(5, base64Offset);
     3238                                        data = Encode.atob(data.substring(base64Offset + 8));
     3239                                }
     3240
     3241                                this.size = data.length;
     3242
     3243                                blobpool[this.uid] = data;
     3244                        },
     3245
     3246                        /**
     3247                        Checks if blob is standalone (detached of any runtime)
     3248                       
     3249                        @method isDetached
     3250                        @protected
     3251                        @return {Boolean}
     3252                        */
     3253                        isDetached: function() {
     3254                                return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string';
     3255                        },
     3256                       
     3257                        /**
     3258                        Destroy Blob and free any resources it was using
     3259
     3260                        @method destroy
     3261                        */
     3262                        destroy: function() {
     3263                                this.detach();
     3264                                delete blobpool[this.uid];
    28783265                        }
     3266                });
    28793267
     3268               
     3269                if (blob.data) {
     3270                        this.detach(blob.data); // auto-detach if payload has been passed
     3271                } else {
     3272                        blobpool[this.uid] = blob;     
     3273                }
     3274        }
     3275       
     3276        return Blob;
     3277});
     3278
     3279// Included from: src/javascript/core/I18n.js
     3280
     3281/**
     3282 * I18n.js
     3283 *
     3284 * Copyright 2013, Moxiecode Systems AB
     3285 * Released under GPL License.
     3286 *
     3287 * License: http://www.plupload.com/license
     3288 * Contributing: http://www.plupload.com/contributing
     3289 */
     3290
     3291define("moxie/core/I18n", [
     3292        "moxie/core/utils/Basic"
     3293], function(Basic) {
     3294        var i18n = {};
     3295
     3296        /**
     3297        @class moxie/core/I18n
     3298        */
     3299        return {
     3300                /**
     3301                 * Extends the language pack object with new items.
     3302                 *
     3303                 * @param {Object} pack Language pack items to add.
     3304                 * @return {Object} Extended language pack object.
     3305                 */
     3306                addI18n: function(pack) {
     3307                        return Basic.extend(i18n, pack);
     3308                },
     3309
     3310                /**
     3311                 * Translates the specified string by checking for the english string in the language pack lookup.
     3312                 *
     3313                 * @param {String} str String to look for.
     3314                 * @return {String} Translated string or the input string if it wasn't found.
     3315                 */
     3316                translate: function(str) {
     3317                        return i18n[str] || str;
     3318                },
     3319
     3320                /**
     3321                 * Shortcut for translate function
     3322                 *
     3323                 * @param {String} str String to look for.
     3324                 * @return {String} Translated string or the input string if it wasn't found.
     3325                 */
     3326                _: function(str) {
     3327                        return this.translate(str);
     3328                },
     3329
     3330                /**
     3331                 * Pseudo sprintf implementation - simple way to replace tokens with specified values.
     3332                 *
     3333                 * @param {String} str String with tokens
     3334                 * @return {String} String with replaced tokens
     3335                 */
     3336                sprintf: function(str) {
     3337                        var args = [].slice.call(arguments, 1);
     3338
     3339                        return str.replace(/%[a-z]/g, function() {
     3340                                var value = args.shift();
     3341                                return Basic.typeOf(value) !== 'undefined' ? value : '';
     3342                        });
     3343                }
     3344        };
     3345});
     3346
     3347// Included from: src/javascript/core/utils/Mime.js
     3348
     3349/**
     3350 * Mime.js
     3351 *
     3352 * Copyright 2013, Moxiecode Systems AB
     3353 * Released under GPL License.
     3354 *
     3355 * License: http://www.plupload.com/license
     3356 * Contributing: http://www.plupload.com/contributing
     3357 */
     3358
     3359/**
     3360@class moxie/core/utils/Mime
     3361@public
     3362@static
     3363*/
     3364
     3365define("moxie/core/utils/Mime", [
     3366        "moxie/core/utils/Basic",
     3367        "moxie/core/I18n"
     3368], function(Basic, I18n) {
     3369
     3370        var mimeData = "" +
     3371                "application/msword,doc dot," +
     3372                "application/pdf,pdf," +
     3373                "application/pgp-signature,pgp," +
     3374                "application/postscript,ps ai eps," +
     3375                "application/rtf,rtf," +
     3376                "application/vnd.ms-excel,xls xlb xlt xla," +
     3377                "application/vnd.ms-powerpoint,ppt pps pot ppa," +
     3378                "application/zip,zip," +
     3379                "application/x-shockwave-flash,swf swfl," +
     3380                "application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," +
     3381                "application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," +
     3382                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," +
     3383                "application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," +
     3384                "application/vnd.openxmlformats-officedocument.presentationml.template,potx," +
     3385                "application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," +
     3386                "application/x-javascript,js," +
     3387                "application/json,json," +
     3388                "audio/mpeg,mp3 mpga mpega mp2," +
     3389                "audio/x-wav,wav," +
     3390                "audio/x-m4a,m4a," +
     3391                "audio/ogg,oga ogg," +
     3392                "audio/aiff,aiff aif," +
     3393                "audio/flac,flac," +
     3394                "audio/aac,aac," +
     3395                "audio/ac3,ac3," +
     3396                "audio/x-ms-wma,wma," +
     3397                "image/bmp,bmp," +
     3398                "image/gif,gif," +
     3399                "image/jpeg,jpg jpeg jpe," +
     3400                "image/photoshop,psd," +
     3401                "image/png,png," +
     3402                "image/svg+xml,svg svgz," +
     3403                "image/tiff,tiff tif," +
     3404                "text/plain,asc txt text diff log," +
     3405                "text/html,htm html xhtml," +
     3406                "text/css,css," +
     3407                "text/csv,csv," +
     3408                "text/rtf,rtf," +
     3409                "video/mpeg,mpeg mpg mpe m2v," +
     3410                "video/quicktime,qt mov," +
     3411                "video/mp4,mp4," +
     3412                "video/x-m4v,m4v," +
     3413                "video/x-flv,flv," +
     3414                "video/x-ms-wmv,wmv," +
     3415                "video/avi,avi," +
     3416                "video/webm,webm," +
     3417                "video/3gpp,3gpp 3gp," +
     3418                "video/3gpp2,3g2," +
     3419                "video/vnd.rn-realvideo,rv," +
     3420                "video/ogg,ogv," +
     3421                "video/x-matroska,mkv," +
     3422                "application/vnd.oasis.opendocument.formula-template,otf," +
     3423                "application/octet-stream,exe";
     3424
     3425
     3426        /**
     3427         * Map of mimes to extensions
     3428         *
     3429         * @property mimes
     3430         * @type {Object}
     3431         */
     3432        var mimes = {};
     3433
     3434        /**
     3435         * Map of extensions to mimes
     3436         *
     3437         * @property extensions
     3438         * @type {Object}
     3439         */
     3440        var extensions = {};
     3441
     3442
     3443        /**
     3444        * Parses mimeData string into a mimes and extensions lookup maps. String should have the
     3445        * following format:
     3446        *
     3447        * application/msword,doc dot,application/pdf,pdf, ...
     3448        *
     3449        * so mime-type followed by comma and followed by space-separated list of associated extensions,
     3450        * then comma again and then another mime-type, etc.
     3451        *
     3452        * If invoked externally will replace override internal lookup maps with user-provided data.
     3453        *
     3454        * @method addMimeType
     3455        * @param {String} mimeData
     3456        */
     3457        var addMimeType = function (mimeData) {
     3458                var items = mimeData.split(/,/), i, ii, ext;
     3459
     3460                for (i = 0; i < items.length; i += 2) {
     3461                        ext = items[i + 1].split(/ /);
     3462
     3463                        // extension to mime lookup
     3464                        for (ii = 0; ii < ext.length; ii++) {
     3465                                mimes[ext[ii]] = items[i];
     3466                        }
     3467                        // mime to extension lookup
     3468                        extensions[items[i]] = ext;
     3469                }
     3470        };
     3471
     3472
     3473        var extList2mimes = function (filters, addMissingExtensions) {
     3474                var ext, i, ii, type, mimes = [];
     3475
     3476                // convert extensions to mime types list
     3477                for (i = 0; i < filters.length; i++) {
     3478                        ext = filters[i].extensions.toLowerCase().split(/\s*,\s*/);
     3479
     3480                        for (ii = 0; ii < ext.length; ii++) {
     3481
     3482                                // if there's an asterisk in the list, then accept attribute is not required
     3483                                if (ext[ii] === '*') {
     3484                                        return [];
     3485                                }
     3486
     3487                                type = mimes[ext[ii]];
     3488
     3489                                // future browsers should filter by extension, finally
     3490                                if (addMissingExtensions && /^\w+$/.test(ext[ii])) {
     3491                                        mimes.push('.' + ext[ii]);
     3492                                } else if (type && Basic.inArray(type, mimes) === -1) {
     3493                                        mimes.push(type);
     3494                                } else if (!type) {
     3495                                        // if we have no type in our map, then accept all
     3496                                        return [];
     3497                                }
     3498                        }
     3499                }
     3500                return mimes;
     3501        };
     3502
     3503
     3504        var mimes2exts = function(mimes) {
     3505                var exts = [];
     3506
     3507                Basic.each(mimes, function(mime) {
     3508                        mime = mime.toLowerCase();
     3509
     3510                        if (mime === '*') {
     3511                                exts = [];
     3512                                return false;
     3513                        }
     3514
     3515                        // check if this thing looks like mime type
     3516                        var m = mime.match(/^(\w+)\/(\*|\w+)$/);
     3517                        if (m) {
     3518                                if (m[2] === '*') {
     3519                                        // wildcard mime type detected
     3520                                        Basic.each(extensions, function(arr, mime) {
     3521                                                if ((new RegExp('^' + m[1] + '/')).test(mime)) {
     3522                                                        [].push.apply(exts, extensions[mime]);
     3523                                                }
     3524                                        });
     3525                                } else if (extensions[mime]) {
     3526                                        [].push.apply(exts, extensions[mime]);
     3527                                }
     3528                        }
    28803529                });
     3530                return exts;
    28813531        };
    28823532
    28833533
     3534        var mimes2extList = function(mimes) {
     3535                var accept = [], exts = [];
     3536
     3537                if (Basic.typeOf(mimes) === 'string') {
     3538                        mimes = Basic.trim(mimes).split(/\s*,\s*/);
     3539                }
     3540
     3541                exts = mimes2exts(mimes);
     3542
     3543                accept.push({
     3544                        title: I18n.translate('Files'),
     3545                        extensions: exts.length ? exts.join(',') : '*'
     3546                });
     3547
     3548                return accept;
     3549        };
     3550
     3551        /**
     3552         * Extract extension from the given filename
     3553         *
     3554         * @method getFileExtension
     3555         * @param {String} fileName
     3556         * @return {String} File extension
     3557         */
     3558        var getFileExtension = function(fileName) {
     3559                var matches = fileName && fileName.match(/\.([^.]+)$/);
     3560                if (matches) {
     3561                        return matches[1].toLowerCase();
     3562                }
     3563                return '';
     3564        };
     3565
     3566
     3567        /**
     3568         * Get file mime-type from it's filename - will try to match the extension
     3569         * against internal mime-type lookup map
     3570         *
     3571         * @method getFileMime
     3572         * @param {String} fileName
     3573         * @return File mime-type if found or an empty string if not
     3574         */
     3575        var getFileMime = function(fileName) {
     3576                return mimes[getFileExtension(fileName)] || '';
     3577        };
     3578
     3579
     3580        addMimeType(mimeData);
     3581
     3582        return {
     3583                mimes: mimes,
     3584                extensions: extensions,
     3585                addMimeType: addMimeType,
     3586                extList2mimes: extList2mimes,
     3587                mimes2exts: mimes2exts,
     3588                mimes2extList: mimes2extList,
     3589                getFileExtension: getFileExtension,
     3590                getFileMime: getFileMime
     3591        }
    28843592});
    28853593
    28863594// Included from: src/javascript/file/FileInput.js
     
    29113619        converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory
    29123620        with _FileReader_ or uploaded to a server through _XMLHttpRequest_.
    29133621
    2914         @class FileInput
     3622        @class moxie/file/FileInput
    29153623        @constructor
    29163624        @extends EventTarget
    29173625        @uses RuntimeClient
     
    29183626        @param {Object|String|DOMElement} options If options is string or node, argument is considered as _browse\_button_.
    29193627                @param {String|DOMElement} options.browse_button DOM Element to turn into file picker.
    29203628                @param {Array} [options.accept] Array of mime types to accept. By default accepts all.
    2921                 @param {String} [options.file='file'] Name of the file field (not the filename).
    29223629                @param {Boolean} [options.multiple=false] Enable selection of multiple files.
    29233630                @param {Boolean} [options.directory=false] Turn file input into the folder input (cannot be both at the same time).
    2924                 @param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode 
     3631                @param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode
    29253632                for _browse\_button_.
    29263633                @param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support.
    29273634
     
    29313638                </div>
    29323639
    29333640                <script>
    2934                         var fileInput = new mOxie.FileInput({
     3641                        var fileInput = new moxie.file.FileInput({
    29353642                                browse_button: 'file-picker', // or document.getElementById('file-picker')
    29363643                                container: 'container',
    29373644                                accept: [
     
    29583665                'ready',
    29593666
    29603667                /**
    2961                 Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked. 
     3668                Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked.
    29623669                Check [corresponding documentation entry](#method_refresh) for more info.
    29633670
    29643671                @event refresh
     
    30123719
    30133720        function FileInput(options) {
    30143721                if (MXI_DEBUG) {
    3015                         Env.log("Instantiating FileInput..."); 
     3722                        Env.log("Instantiating FileInput...");
    30163723                }
    30173724
    3018                 var self = this,
    3019                         container, browseButton, defaults;
     3725                var container, browseButton, defaults;
    30203726
    30213727                // if flat argument passed it should be browse_button id
    30223728                if (Basic.inArray(Basic.typeOf(options), ['string', 'node']) !== -1) {
     
    30363742                                title: I18n.translate('All Files'),
    30373743                                extensions: '*'
    30383744                        }],
    3039                         name: 'file',
    30403745                        multiple: false,
    30413746                        required_caps: false,
    30423747                        container: browseButton.parentNode || document.body
    30433748                };
    3044                
     3749
    30453750                options = Basic.extend({}, defaults, options);
    30463751
    30473752                // convert to object representation
     
    30483753                if (typeof(options.required_caps) === 'string') {
    30493754                        options.required_caps = Runtime.parseCaps(options.required_caps);
    30503755                }
    3051                                        
     3756
    30523757                // normalize accept option (could be list of mime types or array of title/extensions pairs)
    30533758                if (typeof(options.accept) === 'string') {
    30543759                        options.accept = Mime.mimes2extList(options.accept);
     
    30663771                }
    30673772
    30683773                container = browseButton = null; // IE
    3069                                                
    3070                 RuntimeClient.call(self);
    3071                
    3072                 Basic.extend(self, {
     3774
     3775                RuntimeClient.call(this);
     3776
     3777                Basic.extend(this, {
    30733778                        /**
    30743779                        Unique id of the component
    30753780
     
    30803785                        @default UID
    30813786                        */
    30823787                        uid: Basic.guid('uid_'),
    3083                        
     3788
    30843789                        /**
    30853790                        Unique id of the connected runtime, if any.
    30863791
     
    30983803                        @type {String}
    30993804                        */
    31003805                        shimid: null,
    3101                        
     3806
    31023807                        /**
    3103                         Array of selected mOxie.File objects
     3808                        Array of selected moxie.file.File objects
    31043809
    31053810                        @property files
    31063811                        @type {Array}
     
    31143819                        @method init
    31153820                        */
    31163821                        init: function() {
     3822                                var self = this;
     3823
    31173824                                self.bind('RuntimeInit', function(e, runtime) {
    31183825                                        self.ruid = runtime.uid;
    31193826                                        self.shimid = runtime.shimid;
     
    31243831
    31253832                                        // re-position and resize shim container
    31263833                                        self.bind('Refresh', function() {
    3127                                                 var pos, size, browseButton, shimContainer;
    3128                                                
     3834                                                var pos, size, browseButton, shimContainer, zIndex;
     3835
    31293836                                                browseButton = Dom.get(options.browse_button);
    31303837                                                shimContainer = Dom.get(runtime.shimid); // do not use runtime.getShimContainer(), since it will create container if it doesn't exist
    31313838
     
    31323839                                                if (browseButton) {
    31333840                                                        pos = Dom.getPos(browseButton, Dom.get(options.container));
    31343841                                                        size = Dom.getSize(browseButton);
     3842                                                        zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 0;
    31353843
    31363844                                                        if (shimContainer) {
    31373845                                                                Basic.extend(shimContainer.style, {
    3138                                                                         top     : pos.y + 'px',
    3139                                                                         left    : pos.x + 'px',
    3140                                                                         width   : size.w + 'px',
    3141                                                                         height  : size.h + 'px'
     3846                                                                        top: pos.y + 'px',
     3847                                                                        left: pos.x + 'px',
     3848                                                                        width: size.w + 'px',
     3849                                                                        height: size.h + 'px',
     3850                                                                        zIndex: zIndex + 1
    31423851                                                                });
    31433852                                                        }
    31443853                                                }
    31453854                                                shimContainer = browseButton = null;
    31463855                                        });
    3147                                        
     3856
    31483857                                        runtime.exec.call(self, 'FileInput', 'init', options);
    31493858                                });
    31503859
     
    31563865                                }));
    31573866                        },
    31583867
     3868
    31593869                        /**
     3870                         * Get current option value by its name
     3871                         *
     3872                         * @method getOption
     3873                         * @param name
     3874                         * @return {Mixed}
     3875                         */
     3876                        getOption: function(name) {
     3877                                return options[name];
     3878                        },
     3879
     3880
     3881                        /**
     3882                         * Sets a new value for the option specified by name
     3883                         *
     3884                         * @method setOption
     3885                         * @param name
     3886                         * @param value
     3887                         */
     3888                        setOption: function(name, value) {
     3889                                if (!options.hasOwnProperty(name)) {
     3890                                        return;
     3891                                }
     3892
     3893                                var oldValue = options[name];
     3894
     3895                                switch (name) {
     3896                                        case 'accept':
     3897                                                if (typeof(value) === 'string') {
     3898                                                        value = Mime.mimes2extList(value);
     3899                                                }
     3900                                                break;
     3901
     3902                                        case 'container':
     3903                                        case 'required_caps':
     3904                                                throw new x.FileException(x.FileException.NO_MODIFICATION_ALLOWED_ERR);
     3905                                }
     3906
     3907                                options[name] = value;
     3908                                this.exec('FileInput', 'setOption', name, value);
     3909
     3910                                this.trigger('OptionChanged', name, value, oldValue);
     3911                        },
     3912
     3913                        /**
    31603914                        Disables file-picker element, so that it doesn't react to mouse clicks.
    31613915
    31623916                        @method disable
     
    31653919                        disable: function(state) {
    31663920                                var runtime = this.getRuntime();
    31673921                                if (runtime) {
    3168                                         runtime.exec.call(this, 'FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state);
     3922                                        this.exec('FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state);
    31693923                                }
    31703924                        },
    31713925
     
    31763930                        @method refresh
    31773931                        */
    31783932                        refresh: function() {
    3179                                 self.trigger("Refresh");
     3933                                this.trigger("Refresh");
    31803934                        },
    31813935
    31823936
     
    31973951                                        Basic.each(this.files, function(file) {
    31983952                                                file.destroy();
    31993953                                        });
    3200                                 } 
     3954                                }
    32013955                                this.files = null;
    32023956
    32033957                                this.unbindAll();
     
    32123966        return FileInput;
    32133967});
    32143968
    3215 // Included from: src/javascript/core/utils/Encode.js
    3216 
    3217 /**
    3218  * Encode.js
    3219  *
    3220  * Copyright 2013, Moxiecode Systems AB
    3221  * Released under GPL License.
    3222  *
    3223  * License: http://www.plupload.com/license
    3224  * Contributing: http://www.plupload.com/contributing
    3225  */
    3226 
    3227 define('moxie/core/utils/Encode', [], function() {
    3228 
    3229         /**
    3230         Encode string with UTF-8
    3231 
    3232         @method utf8_encode
    3233         @for Utils
    3234         @static
    3235         @param {String} str String to encode
    3236         @return {String} UTF-8 encoded string
    3237         */
    3238         var utf8_encode = function(str) {
    3239                 return unescape(encodeURIComponent(str));
    3240         };
    3241        
    3242         /**
    3243         Decode UTF-8 encoded string
    3244 
    3245         @method utf8_decode
    3246         @static
    3247         @param {String} str String to decode
    3248         @return {String} Decoded string
    3249         */
    3250         var utf8_decode = function(str_data) {
    3251                 return decodeURIComponent(escape(str_data));
    3252         };
    3253        
    3254         /**
    3255         Decode Base64 encoded string (uses browser's default method if available),
    3256         from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js
    3257 
    3258         @method atob
    3259         @static
    3260         @param {String} data String to decode
    3261         @return {String} Decoded string
    3262         */
    3263         var atob = function(data, utf8) {
    3264                 if (typeof(window.atob) === 'function') {
    3265                         return utf8 ? utf8_decode(window.atob(data)) : window.atob(data);
    3266                 }
    3267 
    3268                 // http://kevin.vanzonneveld.net
    3269                 // +   original by: Tyler Akins (http://rumkin.com)
    3270                 // +   improved by: Thunder.m
    3271                 // +      input by: Aman Gupta
    3272                 // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    3273                 // +   bugfixed by: Onno Marsman
    3274                 // +   bugfixed by: Pellentesque Malesuada
    3275                 // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    3276                 // +      input by: Brett Zamir (http://brett-zamir.me)
    3277                 // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    3278                 // *     example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
    3279                 // *     returns 1: 'Kevin van Zonneveld'
    3280                 // mozilla has this native
    3281                 // - but breaks in 2.0.0.12!
    3282                 //if (typeof this.window.atob == 'function') {
    3283                 //    return atob(data);
    3284                 //}
    3285                 var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    3286                 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
    3287                         ac = 0,
    3288                         dec = "",
    3289                         tmp_arr = [];
    3290 
    3291                 if (!data) {
    3292                         return data;
    3293                 }
    3294 
    3295                 data += '';
    3296 
    3297                 do { // unpack four hexets into three octets using index points in b64
    3298                         h1 = b64.indexOf(data.charAt(i++));
    3299                         h2 = b64.indexOf(data.charAt(i++));
    3300                         h3 = b64.indexOf(data.charAt(i++));
    3301                         h4 = b64.indexOf(data.charAt(i++));
    3302 
    3303                         bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
    3304 
    3305                         o1 = bits >> 16 & 0xff;
    3306                         o2 = bits >> 8 & 0xff;
    3307                         o3 = bits & 0xff;
    3308 
    3309                         if (h3 == 64) {
    3310                                 tmp_arr[ac++] = String.fromCharCode(o1);
    3311                         } else if (h4 == 64) {
    3312                                 tmp_arr[ac++] = String.fromCharCode(o1, o2);
    3313                         } else {
    3314                                 tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
    3315                         }
    3316                 } while (i < data.length);
    3317 
    3318                 dec = tmp_arr.join('');
    3319 
    3320                 return utf8 ? utf8_decode(dec) : dec;
    3321         };
    3322        
    3323         /**
    3324         Base64 encode string (uses browser's default method if available),
    3325         from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js
    3326 
    3327         @method btoa
    3328         @static
    3329         @param {String} data String to encode
    3330         @return {String} Base64 encoded string
    3331         */
    3332         var btoa = function(data, utf8) {
    3333                 if (utf8) {
    3334                         data = utf8_encode(data);
    3335                 }
    3336 
    3337                 if (typeof(window.btoa) === 'function') {
    3338                         return window.btoa(data);
    3339                 }
    3340 
    3341                 // http://kevin.vanzonneveld.net
    3342                 // +   original by: Tyler Akins (http://rumkin.com)
    3343                 // +   improved by: Bayron Guevara
    3344                 // +   improved by: Thunder.m
    3345                 // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    3346                 // +   bugfixed by: Pellentesque Malesuada
    3347                 // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    3348                 // +   improved by: Rafał Kukawski (http://kukawski.pl)
    3349                 // *     example 1: base64_encode('Kevin van Zonneveld');
    3350                 // *     returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
    3351                 // mozilla has this native
    3352                 // - but breaks in 2.0.0.12!
    3353                 var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    3354                 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
    3355                         ac = 0,
    3356                         enc = "",
    3357                         tmp_arr = [];
    3358 
    3359                 if (!data) {
    3360                         return data;
    3361                 }
    3362 
    3363                 do { // pack three octets into four hexets
    3364                         o1 = data.charCodeAt(i++);
    3365                         o2 = data.charCodeAt(i++);
    3366                         o3 = data.charCodeAt(i++);
    3367 
    3368                         bits = o1 << 16 | o2 << 8 | o3;
    3369 
    3370                         h1 = bits >> 18 & 0x3f;
    3371                         h2 = bits >> 12 & 0x3f;
    3372                         h3 = bits >> 6 & 0x3f;
    3373                         h4 = bits & 0x3f;
    3374 
    3375                         // use hexets to index into b64, and append result to encoded string
    3376                         tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
    3377                 } while (i < data.length);
    3378 
    3379                 enc = tmp_arr.join('');
    3380 
    3381                 var r = data.length % 3;
    3382 
    3383                 return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
    3384         };
    3385 
    3386 
    3387         return {
    3388                 utf8_encode: utf8_encode,
    3389                 utf8_decode: utf8_decode,
    3390                 atob: atob,
    3391                 btoa: btoa
    3392         };
    3393 });
    3394 
    3395 // Included from: src/javascript/file/Blob.js
    3396 
    3397 /**
    3398  * Blob.js
    3399  *
    3400  * Copyright 2013, Moxiecode Systems AB
    3401  * Released under GPL License.
    3402  *
    3403  * License: http://www.plupload.com/license
    3404  * Contributing: http://www.plupload.com/contributing
    3405  */
    3406 
    3407 define('moxie/file/Blob', [
    3408         'moxie/core/utils/Basic',
    3409         'moxie/core/utils/Encode',
    3410         'moxie/runtime/RuntimeClient'
    3411 ], function(Basic, Encode, RuntimeClient) {
    3412        
    3413         var blobpool = {};
    3414 
    3415         /**
    3416         @class Blob
    3417         @constructor
    3418         @param {String} ruid Unique id of the runtime, to which this blob belongs to
    3419         @param {Object} blob Object "Native" blob object, as it is represented in the runtime
    3420         */
    3421         function Blob(ruid, blob) {
    3422 
    3423                 function _sliceDetached(start, end, type) {
    3424                         var blob, data = blobpool[this.uid];
    3425 
    3426                         if (Basic.typeOf(data) !== 'string' || !data.length) {
    3427                                 return null; // or throw exception
    3428                         }
    3429 
    3430                         blob = new Blob(null, {
    3431                                 type: type,
    3432                                 size: end - start
    3433                         });
    3434                         blob.detach(data.substr(start, blob.size));
    3435 
    3436                         return blob;
    3437                 }
    3438 
    3439                 RuntimeClient.call(this);
    3440 
    3441                 if (ruid) {     
    3442                         this.connectRuntime(ruid);
    3443                 }
    3444 
    3445                 if (!blob) {
    3446                         blob = {};
    3447                 } else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string
    3448                         blob = { data: blob };
    3449                 }
    3450 
    3451                 Basic.extend(this, {
    3452                        
    3453                         /**
    3454                         Unique id of the component
    3455 
    3456                         @property uid
    3457                         @type {String}
    3458                         */
    3459                         uid: blob.uid || Basic.guid('uid_'),
    3460                        
    3461                         /**
    3462                         Unique id of the connected runtime, if falsy, then runtime will have to be initialized
    3463                         before this Blob can be used, modified or sent
    3464 
    3465                         @property ruid
    3466                         @type {String}
    3467                         */
    3468                         ruid: ruid,
    3469        
    3470                         /**
    3471                         Size of blob
    3472 
    3473                         @property size
    3474                         @type {Number}
    3475                         @default 0
    3476                         */
    3477                         size: blob.size || 0,
    3478                        
    3479                         /**
    3480                         Mime type of blob
    3481 
    3482                         @property type
    3483                         @type {String}
    3484                         @default ''
    3485                         */
    3486                         type: blob.type || '',
    3487                        
    3488                         /**
    3489                         @method slice
    3490                         @param {Number} [start=0]
    3491                         */
    3492                         slice: function(start, end, type) {             
    3493                                 if (this.isDetached()) {
    3494                                         return _sliceDetached.apply(this, arguments);
    3495                                 }
    3496                                 return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type);
    3497                         },
    3498 
    3499                         /**
    3500                         Returns "native" blob object (as it is represented in connected runtime) or null if not found
    3501 
    3502                         @method getSource
    3503                         @return {Blob} Returns "native" blob object or null if not found
    3504                         */
    3505                         getSource: function() {
    3506                                 if (!blobpool[this.uid]) {
    3507                                         return null;   
    3508                                 }
    3509                                 return blobpool[this.uid];
    3510                         },
    3511 
    3512                         /**
    3513                         Detaches blob from any runtime that it depends on and initialize with standalone value
    3514 
    3515                         @method detach
    3516                         @protected
    3517                         @param {DOMString} [data=''] Standalone value
    3518                         */
    3519                         detach: function(data) {
    3520                                 if (this.ruid) {
    3521                                         this.getRuntime().exec.call(this, 'Blob', 'destroy');
    3522                                         this.disconnectRuntime();
    3523                                         this.ruid = null;
    3524                                 }
    3525 
    3526                                 data = data || '';
    3527 
    3528                                 // if dataUrl, convert to binary string
    3529                                 if (data.substr(0, 5) == 'data:') {
    3530                                         var base64Offset = data.indexOf(';base64,');
    3531                                         this.type = data.substring(5, base64Offset);
    3532                                         data = Encode.atob(data.substring(base64Offset + 8));
    3533                                 }
    3534 
    3535                                 this.size = data.length;
    3536 
    3537                                 blobpool[this.uid] = data;
    3538                         },
    3539 
    3540                         /**
    3541                         Checks if blob is standalone (detached of any runtime)
    3542                        
    3543                         @method isDetached
    3544                         @protected
    3545                         @return {Boolean}
    3546                         */
    3547                         isDetached: function() {
    3548                                 return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string';
    3549                         },
    3550                        
    3551                         /**
    3552                         Destroy Blob and free any resources it was using
    3553 
    3554                         @method destroy
    3555                         */
    3556                         destroy: function() {
    3557                                 this.detach();
    3558                                 delete blobpool[this.uid];
    3559                         }
    3560                 });
    3561 
    3562                
    3563                 if (blob.data) {
    3564                         this.detach(blob.data); // auto-detach if payload has been passed
    3565                 } else {
    3566                         blobpool[this.uid] = blob;     
    3567                 }
    3568         }
    3569        
    3570         return Blob;
    3571 });
    3572 
    35733969// Included from: src/javascript/file/File.js
    35743970
    35753971/**
     
    35883984        'moxie/file/Blob'
    35893985], function(Basic, Mime, Blob) {
    35903986        /**
    3591         @class File
     3987        @class moxie/file/File
    35923988        @extends Blob
    35933989        @constructor
    35943990        @param {String} ruid Unique id of the runtime, to which this blob belongs to
     
    36914087                <div id="filelist"></div>
    36924088
    36934089                <script type="text/javascript">
    3694                         var fileDrop = new mOxie.FileDrop('drop_zone'), fileList = mOxie.get('filelist');
     4090                        var fileDrop = new moxie.file.FileDrop('drop_zone'), fileList = moxie.utils.Dom.get('filelist');
    36954091
    36964092                        fileDrop.ondrop = function() {
    3697                                 mOxie.each(this.files, function(file) {
     4093                                moxie.utils.Basic.each(this.files, function(file) {
    36984094                                        fileList.innerHTML += '<div>' + file.name + '</div>';
    36994095                                });
    37004096                        };
     
    37024098                        fileDrop.init();
    37034099                </script>
    37044100
    3705         @class FileDrop
     4101        @class moxie/file/FileDrop
    37064102        @constructor
    37074103        @extends EventTarget
    37084104        @uses RuntimeClient
     
    38554251        Utility for preloading o.Blob/o.File objects in memory. By design closely follows [W3C FileReader](http://www.w3.org/TR/FileAPI/#dfn-filereader)
    38564252        interface. Where possible uses native FileReader, where - not falls back to shims.
    38574253
    3858         @class FileReader
     4254        @class moxie/file/FileReader
    38594255        @constructor FileReader
    38604256        @extends EventTarget
    38614257        @uses RuntimeClient
     
    41184514 * Contributing: http://www.plupload.com/contributing
    41194515 */
    41204516
    4121 define('moxie/core/utils/Url', [], function() {
     4517/**
     4518@class moxie/core/utils/Url
     4519@public
     4520@static
     4521*/
     4522
     4523define('moxie/core/utils/Url', [
     4524        'moxie/core/utils/Basic'
     4525], function(Basic) {
    41224526        /**
    41234527        Parse url into separate components and fill in absent parts with parts from current url,
    41244528        based on https://raw.github.com/kvz/phpjs/master/functions/url/parse_url.js
    41254529
    41264530        @method parseUrl
    4127         @for Utils
    41284531        @static
    41294532        @param {String} url Url to parse (defaults to empty string if undefined)
    41304533        @return {Object} Hash containing extracted uri components
     
    41374540                        https: 443
    41384541                }
    41394542                , uri = {}
    4140                 , regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/
     4543                , regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@\/]*):?([^:@\/]*))?@)?(\[[\da-fA-F:]+\]|[^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/
    41414544                , m = regex.exec(url || '')
     4545                , isRelative
     4546                , isSchemeLess = /^\/\/\w/.test(url)
    41424547                ;
    4143                                        
     4548
     4549                switch (Basic.typeOf(currentUrl)) {
     4550                        case 'undefined':
     4551                                currentUrl = parseUrl(document.location.href, false);
     4552                                break;
     4553
     4554                        case 'string':
     4555                                currentUrl = parseUrl(currentUrl, false);
     4556                                break;
     4557                }
     4558
    41444559                while (i--) {
    41454560                        if (m[i]) {
    41464561                                uri[key[i]] = m[i];
     
    41474562                        }
    41484563                }
    41494564
    4150                 // when url is relative, we set the origin and the path ourselves
    4151                 if (!uri.scheme) {
    4152                         // come up with defaults
    4153                         if (!currentUrl || typeof(currentUrl) === 'string') {
    4154                                 currentUrl = parseUrl(currentUrl || document.location.href);
    4155                         }
     4565                isRelative = !isSchemeLess && !uri.scheme;
    41564566
     4567                if (isSchemeLess || isRelative) {
    41574568                        uri.scheme = currentUrl.scheme;
     4569                }
     4570
     4571                // when url is relative, we set the origin and the path ourselves
     4572                if (isRelative) {
    41584573                        uri.host = currentUrl.host;
    41594574                        uri.port = currentUrl.port;
    41604575
     
    41754590
    41764591                if (!uri.port) {
    41774592                        uri.port = ports[uri.scheme] || 80;
    4178                 } 
    4179                
     4593                }
     4594
    41804595                uri.port = parseInt(uri.port, 10);
    41814596
    41824597                if (!uri.path) {
     
    42114626        Check if specified url has the same origin as the current document
    42124627
    42134628        @method hasSameOrigin
     4629        @static
    42144630        @param {String|Object} url
    42154631        @return {Boolean}
    42164632        */
     
    42184634                function origin(url) {
    42194635                        return [url.scheme, url.host, url.port].join('/');
    42204636                }
    4221                        
     4637
    42224638                if (typeof url === 'string') {
    42234639                        url = parseUrl(url);
    4224                 }       
    4225                
     4640                }
     4641
    42264642                return origin(parseUrl()) === origin(url);
    42274643        };
    42284644
     
    42544670        Instance of this class can be used as a target for the events dispatched by shims,
    42554671        when allowing them onto components is for either reason inappropriate
    42564672
    4257         @class RuntimeTarget
     4673        @class moxie/runtime/RuntimeTarget
    42584674        @constructor
    42594675        @protected
    42604676        @extends EventTarget
     
    42974713        it can be used to read only preloaded blobs/files and only below certain size (not yet sure what that'd be,
    42984714        but probably < 1mb). Not meant to be used directly by user.
    42994715
    4300         @class FileReaderSync
     4716        @class moxie/file/FileReaderSync
    43014717        @private
    43024718        @constructor
    43034719        */
     
    43684784        /**
    43694785        FormData
    43704786
    4371         @class FormData
     4787        @class moxie/xhr/FormData
    43724788        @constructor
    43734789        */
    43744790        function FormData() {
     
    45554971        function XMLHttpRequestUpload() {
    45564972                this.uid = Basic.guid('uid_');
    45574973        }
    4558        
     4974
    45594975        XMLHttpRequestUpload.prototype = EventTarget.instance;
    45604976
    45614977        /**
    45624978        Implementation of XMLHttpRequest
    45634979
    4564         @class XMLHttpRequest
     4980        @class moxie/xhr/XMLHttpRequest
    45654981        @constructor
    45664982        @uses RuntimeClient
    45674983        @extends EventTarget
     
    45824998                'loadend'
    45834999
    45845000                // readystatechange (for historical reasons)
    4585         ]; 
    4586        
     5001        ];
     5002
    45875003        var NATIVE = 1, RUNTIME = 2;
    4588                                        
     5004
    45895005        function XMLHttpRequest() {
    45905006                var self = this,
    45915007                        // this (together with _p() @see below) is here to gracefully upgrade to setter/getter syntax where possible
     
    46515067                                /**
    46525068                                Returns the response type. Can be set to change the response type. Values are:
    46535069                                the empty string (default), "arraybuffer", "blob", "document", "json", and "text".
    4654                                
     5070
    46555071                                @property responseType
    46565072              &nb