Ticket #48277: 48277.2.diff
File 48277.2.diff, 788.0 KB (added by , 5 years ago) |
---|
-
src/js/_enqueues/vendor/plupload/license.txt
1 GNUGENERAL PUBLIC LICENSE2 Version 2, June 1991 1 GNU AFFERO GENERAL PUBLIC LICENSE 2 Version 3, 19 November 2007 3 3 4 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> 6 5 Everyone is permitted to copy and distribute verbatim copies 7 6 of this license document, but changing it is not allowed. 8 7 9 8 Preamble 10 9 11 The licenses for most software are designed to take away your12 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.10 The GNU Affero General Public License is a free, copyleft license for 11 software and other kinds of works, specifically designed to ensure 12 cooperation with the community in the case of network server software. 13 14 The licenses for most software and other practical works are designed 15 to take away your freedom to share and change the works. By contrast, 16 our General Public Licenses are intended to guarantee your freedom to 17 share and change all versions of a program--to make sure it remains free 18 software for all its users. 20 19 21 20 When we speak of free software, we are referring to freedom, not 22 21 price. Our General Public Licenses are designed to make sure that you 23 22 have the freedom to distribute copies of free software (and charge for 24 this service if you wish), that you receive source code or can get it 25 if you want it, that you can change the software or use pieces of it 26 in new free programs; and that you know you can do these things. 27 28 To protect your rights, we need to make restrictions that forbid 29 anyone to deny you these rights or to ask you to surrender the rights. 30 These restrictions translate to certain responsibilities for you if you 31 distribute copies of the software, or if you modify it. 32 33 For example, if you distribute copies of such a program, whether 34 gratis or for a fee, you must give the recipients all the rights that 35 you have. You must make sure that they, too, receive or can get the 36 source code. And you must show them these terms so they know their 37 rights. 38 39 We protect your rights with two steps: (1) copyright the software, and 40 (2) offer you this license which gives you legal permission to copy, 41 distribute and/or modify the software. 42 43 Also, for each author's protection and ours, we want to make certain 44 that everyone understands that there is no warranty for this free 45 software. If the software is modified by someone else and passed on, we 46 want its recipients to know that what they have is not the original, so 47 that any problems introduced by others will not reflect on the original 48 authors' reputations. 49 50 Finally, any free program is threatened constantly by software 51 patents. We wish to avoid the danger that redistributors of a free 52 program will individually obtain patent licenses, in effect making the 53 program proprietary. To prevent this, we have made it clear that any 54 patent must be licensed for everyone's free use or not licensed at all. 23 them if you wish), that you receive source code or can get it if you 24 want it, that you can change the software or use pieces of it in new 25 free programs, and that you know you can do these things. 26 27 Developers that use our General Public Licenses protect your rights 28 with two steps: (1) assert copyright on the software, and (2) offer 29 you this License which gives you legal permission to copy, distribute 30 and/or modify the software. 31 32 A secondary benefit of defending all users' freedom is that 33 improvements made in alternate versions of the program, if they 34 receive widespread use, become available for other developers to 35 incorporate. Many developers of free software are heartened and 36 encouraged by the resulting cooperation. However, in the case of 37 software used on network servers, this result may fail to come about. 38 The GNU General Public License permits making a modified version and 39 letting the public access it on a server without ever releasing its 40 source code to the public. 41 42 The GNU Affero General Public License is designed specifically to 43 ensure that, in such cases, the modified source code becomes available 44 to the community. It requires the operator of a network server to 45 provide the source code of the modified version running there to the 46 users of that server. Therefore, public use of a modified version, on 47 a publicly accessible server, gives the public access to the source 48 code of the modified version. 49 50 An older license, called the Affero General Public License and 51 published by Affero, was designed to accomplish similar goals. This is 52 a different license, not a version of the Affero GPL, but Affero has 53 released a new version of the Affero GPL which permits relicensing under 54 this license. 55 55 56 56 The precise terms and conditions for copying, distribution and 57 57 modification follow. 58 58 59 GNU GENERAL PUBLIC LICENSE 60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 59 TERMS AND CONDITIONS 61 60 62 0. This License applies to any program or other work which contains 63 a notice placed by the copyright holder saying it may be distributed 64 under the terms of this General Public License. The "Program", below, 65 refers to any such program or work, and a "work based on the Program" 66 means either the Program or any derivative work under copyright law: 67 that is to say, a work containing the Program or a portion of it, 68 either verbatim or with modifications and/or translated into another 69 language. (Hereinafter, translation is included without limitation in 70 the term "modification".) Each licensee is addressed as "you". 71 72 Activities other than copying, distribution and modification are not 73 covered by this License; they are outside its scope. The act of 74 running the Program is not restricted, and the output from the Program 75 is covered only if its contents constitute a work based on the 76 Program (independent of having been made by running the Program). 77 Whether that is true depends on what the Program does. 78 79 1. You may copy and distribute verbatim copies of the Program's 80 source code as you receive it, in any medium, provided that you 81 conspicuously and appropriately publish on each copy an appropriate 82 copyright notice and disclaimer of warranty; keep intact all the 83 notices that refer to this License and to the absence of any warranty; 84 and give any other recipients of the Program a copy of this License 85 along with the Program. 86 87 You may charge a fee for the physical act of transferring a copy, and 88 you may at your option offer warranty protection in exchange for a fee. 89 90 2. You may modify your copy or copies of the Program or any portion 91 of it, thus forming a work based on the Program, and copy and 92 distribute such modifications or work under the terms of Section 1 93 above, provided that you also meet all of these conditions: 94 95 a) You must cause the modified files to carry prominent notices 96 stating that you changed the files and the date of any change. 97 98 b) You must cause any work that you distribute or publish, that in 99 whole or in part contains or is derived from the Program or any 100 part thereof, to be licensed as a whole at no charge to all third 101 parties under the terms of this License. 102 103 c) If the modified program normally reads commands interactively 104 when run, you must cause it, when started running for such 105 interactive use in the most ordinary way, to print or display an 106 announcement including an appropriate copyright notice and a 107 notice that there is no warranty (or else, saying that you provide 108 a warranty) and that users may redistribute the program under 109 these conditions, and telling the user how to view a copy of this 110 License. (Exception: if the Program itself is interactive but 111 does not normally print such an announcement, your work based on 112 the Program is not required to print an announcement.) 113 114 These requirements apply to the modified work as a whole. If 115 identifiable sections of that work are not derived from the Program, 116 and can be reasonably considered independent and separate works in 117 themselves, then this License, and its terms, do not apply to those 118 sections when you distribute them as separate works. But when you 119 distribute the same sections as part of a whole which is a work based 120 on the Program, the distribution of the whole must be on the terms of 121 this License, whose permissions for other licensees extend to the 122 entire whole, and thus to each and every part regardless of who wrote it. 123 124 Thus, it is not the intent of this section to claim rights or contest 125 your rights to work written entirely by you; rather, the intent is to 126 exercise the right to control the distribution of derivative or 127 collective works based on the Program. 128 129 In addition, mere aggregation of another work not based on the Program 130 with the Program (or with a work based on the Program) on a volume of 131 a storage or distribution medium does not bring the other work under 132 the scope of this License. 133 134 3. You may copy and distribute the Program (or a work based on it, 135 under Section 2) in object code or executable form under the terms of 136 Sections 1 and 2 above provided that you also do one of the following: 137 138 a) Accompany it with the complete corresponding machine-readable 139 source code, which must be distributed under the terms of Sections 140 1 and 2 above on a medium customarily used for software interchange; or, 141 142 b) Accompany it with a written offer, valid for at least three 143 years, to give any third party, for a charge no more than your 144 cost of physically performing source distribution, a complete 145 machine-readable copy of the corresponding source code, to be 146 distributed under the terms of Sections 1 and 2 above on a medium 147 customarily used for software interchange; or, 148 149 c) Accompany it with the information you received as to the offer 150 to distribute corresponding source code. (This alternative is 151 allowed only for noncommercial distribution and only if you 152 received the program in object code or executable form with such 153 an offer, in accord with Subsection b above.) 154 155 The source code for a work means the preferred form of the work for 156 making modifications to it. For an executable work, complete source 157 code means all the source code for all modules it contains, plus any 158 associated interface definition files, plus the scripts used to 159 control compilation and installation of the executable. However, as a 160 special exception, the source code distributed need not include 161 anything that is normally distributed (in either source or binary 162 form) with the major components (compiler, kernel, and so on) of the 163 operating system on which the executable runs, unless that component 164 itself accompanies the executable. 165 166 If distribution of executable or object code is made by offering 167 access to copy from a designated place, then offering equivalent 168 access to copy the source code from the same place counts as 169 distribution of the source code, even though third parties are not 170 compelled to copy the source along with the object code. 171 172 4. You may not copy, modify, sublicense, or distribute the Program 173 except as expressly provided under this License. Any attempt 174 otherwise to copy, modify, sublicense or distribute the Program is 175 void, and will automatically terminate your rights under this License. 176 However, parties who have received copies, or rights, from you under 177 this License will not have their licenses terminated so long as such 178 parties remain in full compliance. 179 180 5. You are not required to accept this License, since you have not 181 signed it. However, nothing else grants you permission to modify or 182 distribute the Program or its derivative works. These actions are 183 prohibited by law if you do not accept this License. Therefore, by 184 modifying or distributing the Program (or any work based on the 185 Program), you indicate your acceptance of this License to do so, and 186 all its terms and conditions for copying, distributing or modifying 187 the Program or works based on it. 188 189 6. Each time you redistribute the Program (or any work based on the 190 Program), the recipient automatically receives a license from the 191 original licensor to copy, distribute or modify the Program subject to 192 these terms and conditions. You may not impose any further 193 restrictions on the recipients' exercise of the rights granted herein. 194 You are not responsible for enforcing compliance by third parties to 61 0. Definitions. 62 63 "This License" refers to version 3 of the GNU Affero General Public License. 64 65 "Copyright" also means copyright-like laws that apply to other kinds of 66 works, such as semiconductor masks. 67 68 "The Program" refers to any copyrightable work licensed under this 69 License. Each licensee is addressed as "you". "Licensees" and 70 "recipients" may be individuals or organizations. 71 72 To "modify" a work means to copy from or adapt all or part of the work 73 in a fashion requiring copyright permission, other than the making of an 74 exact copy. The resulting work is called a "modified version" of the 75 earlier work or a work "based on" the earlier work. 76 77 A "covered work" means either the unmodified Program or a work based 78 on the Program. 79 80 To "propagate" a work means to do anything with it that, without 81 permission, would make you directly or secondarily liable for 82 infringement under applicable copyright law, except executing it on a 83 computer or modifying a private copy. Propagation includes copying, 84 distribution (with or without modification), making available to the 85 public, and in some countries other activities as well. 86 87 To "convey" a work means any kind of propagation that enables other 88 parties to make or receive copies. Mere interaction with a user through 89 a computer network, with no transfer of a copy, is not conveying. 90 91 An interactive user interface displays "Appropriate Legal Notices" 92 to the extent that it includes a convenient and prominently visible 93 feature that (1) displays an appropriate copyright notice, and (2) 94 tells the user that there is no warranty for the work (except to the 95 extent that warranties are provided), that licensees may convey the 96 work under this License, and how to view a copy of this License. If 97 the interface presents a list of user commands or options, such as a 98 menu, a prominent item in the list meets this criterion. 99 100 1. Source Code. 101 102 The "source code" for a work means the preferred form of the work 103 for making modifications to it. "Object code" means any non-source 104 form of a work. 105 106 A "Standard Interface" means an interface that either is an official 107 standard defined by a recognized standards body, or, in the case of 108 interfaces specified for a particular programming language, one that 109 is widely used among developers working in that language. 110 111 The "System Libraries" of an executable work include anything, other 112 than the work as a whole, that (a) is included in the normal form of 113 packaging a Major Component, but which is not part of that Major 114 Component, and (b) serves only to enable use of the work with that 115 Major Component, or to implement a Standard Interface for which an 116 implementation 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 120 produce the work, or an object code interpreter used to run it. 121 122 The "Corresponding Source" for a work in object code form means all 123 the source code needed to generate, install, and (for an executable 124 work) run the object code and to modify the work, including scripts to 125 control those activities. However, it does not include the work's 126 System Libraries, or general-purpose tools or generally available free 127 programs which are used unmodified in performing those activities but 128 which are not part of the work. For example, Corresponding Source 129 includes interface definition files associated with source files for 130 the work, and the source code for shared libraries and dynamically 131 linked subprograms that the work is specifically designed to require, 132 such as by intimate data communication or control flow between those 133 subprograms and other parts of the work. 134 135 The Corresponding Source need not include anything that users 136 can regenerate automatically from other parts of the Corresponding 137 Source. 138 139 The Corresponding Source for a work in source code form is that 140 same work. 141 142 2. Basic Permissions. 143 144 All rights granted under this License are granted for the term of 145 copyright on the Program, and are irrevocable provided the stated 146 conditions are met. This License explicitly affirms your unlimited 147 permission to run the unmodified Program. The output from running a 148 covered work is covered by this License only if the output, given its 149 content, constitutes a covered work. This License acknowledges your 150 rights of fair use or other equivalent, as provided by copyright law. 151 152 You may make, run and propagate covered works that you do not 153 convey, without conditions so long as your license otherwise remains 154 in force. You may convey covered works to others for the sole purpose 155 of having them make modifications exclusively for you, or provide you 156 with facilities for running those works, provided that you comply with 157 the terms of this License in conveying all material for which you do 158 not control copyright. Those thus making or running the covered works 159 for you must do so exclusively on your behalf, under your direction 160 and control, on terms that prohibit them from making any copies of 161 your copyrighted material outside their relationship with you. 162 163 Conveying under any other circumstances is permitted solely under 164 the conditions stated below. Sublicensing is not allowed; section 10 165 makes it unnecessary. 166 167 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 169 No covered work shall be deemed part of an effective technological 170 measure under any applicable law fulfilling obligations under article 171 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 similar laws prohibiting or restricting circumvention of such 173 measures. 174 175 When you convey a covered work, you waive any legal power to forbid 176 circumvention of technological measures to the extent such circumvention 177 is effected by exercising rights under this License with respect to 178 the covered work, and you disclaim any intention to limit operation or 179 modification of the work as a means of enforcing, against the work's 180 users, your or third parties' legal rights to forbid circumvention of 181 technological measures. 182 183 4. Conveying Verbatim Copies. 184 185 You may convey verbatim copies of the Program's source code as you 186 receive it, in any medium, provided that you conspicuously and 187 appropriately publish on each copy an appropriate copyright notice; 188 keep intact all notices stating that this License and any 189 non-permissive terms added in accord with section 7 apply to the code; 190 keep intact all notices of the absence of any warranty; and give all 191 recipients a copy of this License along with the Program. 192 193 You may charge any price or no price for each copy that you convey, 194 and you may offer support or warranty protection for a fee. 195 196 5. Conveying Modified Source Versions. 197 198 You may convey a work based on the Program, or the modifications to 199 produce it from the Program, in the form of source code under the 200 terms of section 4, provided that you also meet all of these conditions: 201 202 a) The work must carry prominent notices stating that you modified 203 it, and giving a relevant date. 204 205 b) The work must carry prominent notices stating that it is 206 released under this License and any conditions added under section 207 7. This requirement modifies the requirement in section 4 to 208 "keep intact all notices". 209 210 c) You must license the entire work, as a whole, under this 211 License to anyone who comes into possession of a copy. This 212 License will therefore apply, along with any applicable section 7 213 additional terms, to the whole of the work, and all its parts, 214 regardless of how they are packaged. This License gives no 215 permission to license the work in any other way, but it does not 216 invalidate such permission if you have separately received it. 217 218 d) If the work has interactive user interfaces, each must display 219 Appropriate Legal Notices; however, if the Program has interactive 220 interfaces that do not display Appropriate Legal Notices, your 221 work need not make them do so. 222 223 A compilation of a covered work with other separate and independent 224 works, which are not by their nature extensions of the covered work, 225 and which are not combined with it such as to form a larger program, 226 in or on a volume of a storage or distribution medium, is called an 227 "aggregate" if the compilation and its resulting copyright are not 228 used to limit the access or legal rights of the compilation's users 229 beyond what the individual works permit. Inclusion of a covered work 230 in an aggregate does not cause this License to apply to the other 231 parts of the aggregate. 232 233 6. Conveying Non-Source Forms. 234 235 You may convey a covered work in object code form under the terms 236 of sections 4 and 5, provided that you also convey the 237 machine-readable Corresponding Source under the terms of this License, 238 in one of these ways: 239 240 a) Convey the object code in, or embodied in, a physical product 241 (including a physical distribution medium), accompanied by the 242 Corresponding Source fixed on a durable physical medium 243 customarily used for software interchange. 244 245 b) Convey the object code in, or embodied in, a physical product 246 (including a physical distribution medium), accompanied by a 247 written offer, valid for at least three years and valid for as 248 long as you offer spare parts or customer support for that product 249 model, to give anyone who possesses the object code either (1) a 250 copy of the Corresponding Source for all the software in the 251 product that is covered by this License, on a durable physical 252 medium customarily used for software interchange, for a price no 253 more than your reasonable cost of physically performing this 254 conveying of source, or (2) access to copy the 255 Corresponding Source from a network server at no charge. 256 257 c) Convey individual copies of the object code with a copy of the 258 written offer to provide the Corresponding Source. This 259 alternative is allowed only occasionally and noncommercially, and 260 only if you received the object code with such an offer, in accord 261 with subsection 6b. 262 263 d) Convey the object code by offering access from a designated 264 place (gratis or for a charge), and offer equivalent access to the 265 Corresponding Source in the same way through the same place at no 266 further charge. You need not require recipients to copy the 267 Corresponding Source along with the object code. If the place to 268 copy the object code is a network server, the Corresponding Source 269 may be on a different server (operated by you or a third party) 270 that supports equivalent copying facilities, provided you maintain 271 clear directions next to the object code saying where to find the 272 Corresponding Source. Regardless of what server hosts the 273 Corresponding Source, you remain obligated to ensure that it is 274 available for as long as needed to satisfy these requirements. 275 276 e) Convey the object code using peer-to-peer transmission, provided 277 you inform other peers where the object code and Corresponding 278 Source of the work are being offered to the general public at no 279 charge under subsection 6d. 280 281 A separable portion of the object code, whose source code is excluded 282 from the Corresponding Source as a System Library, need not be 283 included in conveying the object code work. 284 285 A "User Product" is either (1) a "consumer product", which means any 286 tangible personal property which is normally used for personal, family, 287 or household purposes, or (2) anything designed or sold for incorporation 288 into a dwelling. In determining whether a product is a consumer product, 289 doubtful cases shall be resolved in favor of coverage. For a particular 290 product received by a particular user, "normally used" refers to a 291 typical or common use of that class of product, regardless of the status 292 of the particular user or of the way in which the particular user 293 actually uses, or expects or is expected to use, the product. A product 294 is a consumer product regardless of whether the product has substantial 295 commercial, industrial or non-consumer uses, unless such uses represent 296 the only significant mode of use of the product. 297 298 "Installation Information" for a User Product means any methods, 299 procedures, authorization keys, or other information required to install 300 and execute modified versions of a covered work in that User Product from 301 a modified version of its Corresponding Source. The information must 302 suffice to ensure that the continued functioning of the modified object 303 code is in no case prevented or interfered with solely because 304 modification has been made. 305 306 If you convey an object code work under this section in, or with, or 307 specifically for use in, a User Product, and the conveying occurs as 308 part of a transaction in which the right of possession and use of the 309 User Product is transferred to the recipient in perpetuity or for a 310 fixed term (regardless of how the transaction is characterized), the 311 Corresponding Source conveyed under this section must be accompanied 312 by the Installation Information. But this requirement does not apply 313 if neither you nor any third party retains the ability to install 314 modified object code on the User Product (for example, the work has 315 been installed in ROM). 316 317 The requirement to provide Installation Information does not include a 318 requirement to continue to provide support service, warranty, or updates 319 for a work that has been modified or installed by the recipient, or for 320 the User Product in which it has been modified or installed. Access to a 321 network may be denied when the modification itself materially and 322 adversely affects the operation of the network or violates the rules and 323 protocols for communication across the network. 324 325 Corresponding Source conveyed, and Installation Information provided, 326 in accord with this section must be in a format that is publicly 327 documented (and with an implementation available to the public in 328 source code form), and must require no special password or key for 329 unpacking, reading or copying. 330 331 7. Additional Terms. 332 333 "Additional permissions" are terms that supplement the terms of this 334 License by making exceptions from one or more of its conditions. 335 Additional permissions that are applicable to the entire Program shall 336 be treated as though they were included in this License, to the extent 337 that they are valid under applicable law. If additional permissions 338 apply only to part of the Program, that part may be used separately 339 under those permissions, but the entire Program remains governed by 340 this License without regard to the additional permissions. 341 342 When you convey a copy of a covered work, you may at your option 343 remove any additional permissions from that copy, or from any part of 344 it. (Additional permissions may be written to require their own 345 removal in certain cases when you modify the work.) You may place 346 additional permissions on material, added by you to a covered work, 347 for which you have or can give appropriate copyright permission. 348 349 Notwithstanding any other provision of this License, for material you 350 add to a covered work, you may (if authorized by the copyright holders of 351 that material) supplement the terms of this License with terms: 352 353 a) Disclaiming warranty or limiting liability differently from the 354 terms of sections 15 and 16 of this License; or 355 356 b) Requiring preservation of specified reasonable legal notices or 357 author attributions in that material or in the Appropriate Legal 358 Notices displayed by works containing it; or 359 360 c) Prohibiting misrepresentation of the origin of that material, or 361 requiring that modified versions of such material be marked in 362 reasonable ways as different from the original version; or 363 364 d) Limiting the use for publicity purposes of names of licensors or 365 authors of the material; or 366 367 e) Declining to grant rights under trademark law for use of some 368 trade names, trademarks, or service marks; or 369 370 f) Requiring indemnification of licensors and authors of that 371 material by anyone who conveys the material (or modified versions of 372 it) with contractual assumptions of liability to the recipient, for 373 any liability that these contractual assumptions directly impose on 374 those licensors and authors. 375 376 All other non-permissive additional terms are considered "further 377 restrictions" within the meaning of section 10. If the Program as you 378 received it, or any part of it, contains a notice stating that it is 379 governed by this License along with a term that is a further 380 restriction, you may remove that term. If a license document contains 381 a further restriction but permits relicensing or conveying under this 382 License, you may add to a covered work material governed by the terms 383 of that license document, provided that the further restriction does 384 not survive such relicensing or conveying. 385 386 If you add terms to a covered work in accord with this section, you 387 must place, in the relevant source files, a statement of the 388 additional terms that apply to those files, or a notice indicating 389 where to find the applicable terms. 390 391 Additional terms, permissive or non-permissive, may be stated in the 392 form of a separately written license, or stated as exceptions; 393 the above requirements apply either way. 394 395 8. Termination. 396 397 You may not propagate or modify a covered work except as expressly 398 provided under this License. Any attempt otherwise to propagate or 399 modify it is void, and will automatically terminate your rights under 400 this License (including any patent licenses granted under the third 401 paragraph of section 11). 402 403 However, if you cease all violation of this License, then your 404 license from a particular copyright holder is reinstated (a) 405 provisionally, unless and until the copyright holder explicitly and 406 finally terminates your license, and (b) permanently, if the copyright 407 holder fails to notify you of the violation by some reasonable means 408 prior to 60 days after the cessation. 409 410 Moreover, your license from a particular copyright holder is 411 reinstated permanently if the copyright holder notifies you of the 412 violation by some reasonable means, this is the first time you have 413 received notice of violation of this License (for any work) from that 414 copyright holder, and you cure the violation prior to 30 days after 415 your receipt of the notice. 416 417 Termination of your rights under this section does not terminate the 418 licenses of parties who have received copies or rights from you under 419 this License. If your rights have been terminated and not permanently 420 reinstated, you do not qualify to receive new licenses for the same 421 material under section 10. 422 423 9. Acceptance Not Required for Having Copies. 424 425 You are not required to accept this License in order to receive or 426 run a copy of the Program. Ancillary propagation of a covered work 427 occurring solely as a consequence of using peer-to-peer transmission 428 to receive a copy likewise does not require acceptance. However, 429 nothing other than this License grants you permission to propagate or 430 modify any covered work. These actions infringe copyright if you do 431 not accept this License. Therefore, by modifying or propagating a 432 covered work, you indicate your acceptance of this License to do so. 433 434 10. Automatic Licensing of Downstream Recipients. 435 436 Each time you convey a covered work, the recipient automatically 437 receives a license from the original licensors, to run, modify and 438 propagate that work, subject to this License. You are not responsible 439 for enforcing compliance by third parties with this License. 440 441 An "entity transaction" is a transaction transferring control of an 442 organization, or substantially all assets of one, or subdividing an 443 organization, or merging organizations. If propagation of a covered 444 work results from an entity transaction, each party to that 445 transaction who receives a copy of the work also receives whatever 446 licenses to the work the party's predecessor in interest had or could 447 give under the previous paragraph, plus a right to possession of the 448 Corresponding Source of the work from the predecessor in interest, if 449 the predecessor has it or can get it with reasonable efforts. 450 451 You may not impose any further restrictions on the exercise of the 452 rights granted or affirmed under this License. For example, you may 453 not impose a license fee, royalty, or other charge for exercise of 454 rights granted under this License, and you may not initiate litigation 455 (including a cross-claim or counterclaim in a lawsuit) alleging that 456 any patent claim is infringed by making, using, selling, offering for 457 sale, or importing the Program or any portion of it. 458 459 11. Patents. 460 461 A "contributor" is a copyright holder who authorizes use under this 462 License of the Program or a work on which the Program is based. The 463 work thus licensed is called the contributor's "contributor version". 464 465 A contributor's "essential patent claims" are all patent claims 466 owned or controlled by the contributor, whether already acquired or 467 hereafter acquired, that would be infringed by some manner, permitted 468 by this License, of making, using, or selling its contributor version, 469 but do not include claims that would be infringed only as a 470 consequence of further modification of the contributor version. For 471 purposes of this definition, "control" includes the right to grant 472 patent sublicenses in a manner consistent with the requirements of 195 473 this License. 196 474 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 475 Each contributor grants you a non-exclusive, worldwide, royalty-free 476 patent license under the contributor's essential patent claims, to 477 make, use, sell, offer for sale, import and otherwise run, modify and 478 propagate the contents of its contributor version. 479 480 In the following three paragraphs, a "patent license" is any express 481 agreement or commitment, however denominated, not to enforce a patent 482 (such as an express permission to practice a patent or covenant not to 483 sue for patent infringement). To "grant" such a patent license to a 484 party means to make such an agreement or commitment not to enforce a 485 patent against the party. 486 487 If you convey a covered work, knowingly relying on a patent license, 488 and the Corresponding Source of the work is not available for anyone 489 to copy, free of charge and under the terms of this License, through a 490 publicly available network server or other readily accessible means, 491 then you must either (1) cause the Corresponding Source to be so 492 available, or (2) arrange to deprive yourself of the benefit of the 493 patent license for this particular work, or (3) arrange, in a manner 494 consistent with the requirements of this License, to extend the patent 495 license to downstream recipients. "Knowingly relying" means you have 496 actual knowledge that, but for the patent license, your conveying the 497 covered work in a country, or your recipient's use of the covered work 498 in a country, would infringe one or more identifiable patents in that 499 country that you have reason to believe are valid. 500 501 If, pursuant to or in connection with a single transaction or 502 arrangement, you convey, or propagate by procuring conveyance of, a 503 covered work, and grant a patent license to some of the parties 504 receiving the covered work authorizing them to use, propagate, modify 505 or convey a specific copy of the covered work, then the patent license 506 you grant is automatically extended to all recipients of the covered 507 work and works based on it. 508 509 A patent license is "discriminatory" if it does not include within 510 the scope of its coverage, prohibits the exercise of, or is 511 conditioned on the non-exercise of one or more of the rights that are 512 specifically granted under this License. You may not convey a covered 513 work if you are a party to an arrangement with a third party that is 514 in the business of distributing software, under which you make payment 515 to the third party based on the extent of your activity of conveying 516 the work, and under which the third party grants, to any of the 517 parties who would receive the covered work from you, a discriminatory 518 patent license (a) in connection with copies of the covered work 519 conveyed by you (or copies made from those copies), or (b) primarily 520 for and in connection with specific products or compilations that 521 contain the covered work, unless you entered into that arrangement, 522 or that patent license was granted, prior to 28 March 2007. 523 524 Nothing in this License shall be construed as excluding or limiting 525 any implied license or other defenses to infringement that may 526 otherwise be available to you under applicable patent law. 527 528 12. No Surrender of Others' Freedom. 529 530 If conditions are imposed on you (whether by court order, agreement or 200 531 otherwise) that contradict the conditions of this License, they do not 201 excuse you from the conditions of this License. If you cannot 202 distribute so as to satisfy simultaneously your obligations under this 203 License and any other pertinent obligations, then as a consequence you 204 may not distribute the Program at all. For example, if a patent 205 license would not permit royalty-free redistribution of the Program by 206 all those who receive copies directly or indirectly through you, then 207 the only way you could satisfy both it and this License would be to 208 refrain entirely from distribution of the Program. 209 210 If any portion of this section is held invalid or unenforceable under 211 any particular circumstance, the balance of the section is intended to 212 apply and the section as a whole is intended to apply in other 213 circumstances. 214 215 It is not the purpose of this section to induce you to infringe any 216 patents or other property right claims or to contest validity of any 217 such claims; this section has the sole purpose of protecting the 218 integrity of the free software distribution system, which is 219 implemented by public license practices. Many people have made 220 generous contributions to the wide range of software distributed 221 through that system in reliance on consistent application of that 222 system; it is up to the author/donor to decide if he or she is willing 223 to distribute software through any other system and a licensee cannot 224 impose that choice. 225 226 This section is intended to make thoroughly clear what is believed to 227 be a consequence of the rest of this License. 228 229 8. If the distribution and/or use of the Program is restricted in 230 certain countries either by patents or by copyrighted interfaces, the 231 original copyright holder who places the Program under this License 232 may add an explicit geographical distribution limitation excluding 233 those countries, so that distribution is permitted only in or among 234 countries not thus excluded. In such case, this License incorporates 235 the limitation as if written in the body of this License. 236 237 9. The Free Software Foundation may publish revised and/or new versions 238 of the General Public License from time to time. Such new versions will 239 be similar in spirit to the present version, but may differ in detail to 532 excuse you from the conditions of this License. If you cannot convey a 533 covered work so as to satisfy simultaneously your obligations under this 534 License and any other pertinent obligations, then as a consequence you may 535 not convey it at all. For example, if you agree to terms that obligate you 536 to collect a royalty for further conveying from those to whom you convey 537 the Program, the only way you could satisfy both those terms and this 538 License would be to refrain entirely from conveying the Program. 539 540 13. Remote Network Interaction; Use with the GNU General Public License. 541 542 Notwithstanding any other provision of this License, if you modify the 543 Program, your modified version must prominently offer all users 544 interacting with it remotely through a computer network (if your version 545 supports such interaction) an opportunity to receive the Corresponding 546 Source of your version by providing access to the Corresponding Source 547 from a network server at no charge, through some standard or customary 548 means of facilitating copying of software. This Corresponding Source 549 shall include the Corresponding Source for any work covered by version 3 550 of the GNU General Public License that is incorporated pursuant to the 551 following paragraph. 552 553 Notwithstanding any other provision of this License, you have 554 permission to link or combine any covered work with a work licensed 555 under version 3 of the GNU General Public License into a single 556 combined work, and to convey the resulting work. The terms of this 557 License will continue to apply to the part which is the covered work, 558 but the work with which it is combined will remain governed by version 559 3 of the GNU General Public License. 560 561 14. Revised Versions of this License. 562 563 The Free Software Foundation may publish revised and/or new versions of 564 the GNU Affero General Public License from time to time. Such new versions 565 will be similar in spirit to the present version, but may differ in detail to 240 566 address new problems or concerns. 241 567 242 Each version is given a distinguishing version number. If the Program 243 specifies a version number of this License which applies to it and "any 244 later version", you have the option of following the terms and conditions 245 either of that version or of any later version published by the Free 246 Software Foundation. If the Program does not specify a version number of 247 this License, you may choose any version ever published by the Free Software 248 Foundation. 249 250 10. If you wish to incorporate parts of the Program into other free 251 programs whose distribution conditions are different, write to the author 252 to ask for permission. For software which is copyrighted by the Free 253 Software Foundation, write to the Free Software Foundation; we sometimes 254 make exceptions for this. Our decision will be guided by the two goals 255 of preserving the free status of all derivatives of our free software and 256 of promoting the sharing and reuse of software generally. 257 258 NO WARRANTY 259 260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 REPAIR OR CORRECTION. 269 270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 POSSIBILITY OF SUCH DAMAGES. 568 Each version is given a distinguishing version number. If the 569 Program specifies that a certain numbered version of the GNU Affero General 570 Public License "or any later version" applies to it, you have the 571 option of following the terms and conditions either of that numbered 572 version or of any later version published by the Free Software 573 Foundation. If the Program does not specify a version number of the 574 GNU Affero General Public License, you may choose any version ever published 575 by the Free Software Foundation. 576 577 If the Program specifies that a proxy can decide which future 578 versions of the GNU Affero General Public License can be used, that proxy's 579 public statement of acceptance of a version permanently authorizes you 580 to choose that version for the Program. 581 582 Later license versions may give you additional or different 583 permissions. However, no additional obligations are imposed on any 584 author or copyright holder as a result of your choosing to follow a 585 later version. 586 587 15. Disclaimer of Warranty. 588 589 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 598 16. Limitation of Liability. 599 600 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 SUCH DAMAGES. 609 610 17. Interpretation of Sections 15 and 16. 611 612 If the disclaimer of warranty and limitation of liability provided 613 above cannot be given local legal effect according to their terms, 614 reviewing courts shall apply local law that most closely approximates 615 an absolute waiver of all civil liability in connection with the 616 Program, unless a warranty or assumption of liability accompanies a 617 copy of the Program in return for a fee. 279 618 280 619 END OF TERMS AND CONDITIONS 281 620 282 621 How to Apply These Terms to Your New Programs 283 622 284 623 If you develop a new program, and you want it to be of the greatest 285 624 possible use to the public, the best way to achieve this is to make it … … 287 626 288 627 To do so, attach the following notices to the program. It is safest 289 628 to attach them to the start of each source file to most effectively 290 conveythe exclusion of warranty; and each file should have at least629 state the exclusion of warranty; and each file should have at least 291 630 the "copyright" line and a pointer to where the full notice is found. 292 631 293 632 <one line to give the program's name and a brief idea of what it does.> 294 633 Copyright (C) <year> <name of author> 295 634 296 This program is free software ;you can redistribute it and/or modify297 it under the terms of the GNU General Public License as published by298 the Free Software Foundation ; either version 2of the License, or635 This program is free software: you can redistribute it and/or modify 636 it under the terms of the GNU Affero General Public License as published by 637 the Free Software Foundation, either version 3 of the License, or 299 638 (at your option) any later version. 300 639 301 640 This program is distributed in the hope that it will be useful, 302 641 but WITHOUT ANY WARRANTY; without even the implied warranty of 303 642 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 GNU General Public License for more details.643 GNU Affero General Public License for more details. 305 644 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. 645 You should have received a copy of the GNU Affero General Public License 646 along with this program. If not, see <http://www.gnu.org/licenses/>. 309 647 310 648 Also add information on how to contact you by electronic and paper mail. 311 649 312 If the program is interactive, make it output a short notice like this 313 when it starts in an interactive mode: 314 315 Gnomovision version 69, Copyright (C) year name of author 316 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 This is free software, and you are welcome to redistribute it 318 under certain conditions; type `show c' for details. 319 320 The hypothetical commands `show w' and `show c' should show the appropriate 321 parts of the General Public License. Of course, the commands you use may 322 be called something other than `show w' and `show c'; they could even be 323 mouse-clicks or menu items--whatever suits your program. 324 325 You should also get your employer (if you work as a programmer) or your 326 school, if any, to sign a "copyright disclaimer" for the program, if 327 necessary. Here is a sample; alter the names: 328 329 Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 332 <signature of Ty Coon>, 1 April 1989 333 Ty Coon, President of Vice 334 335 This General Public License does not permit incorporating your program into 336 proprietary programs. If your program is a subroutine library, you may 337 consider it more useful to permit linking proprietary applications with the 338 library. If this is what you want to do, use the GNU Lesser General 339 Public License instead of this License. 650 If your software can interact with users remotely through a computer 651 network, you should also make sure that it provides a way for users to 652 get its source. For example, if your program is a web application, its 653 interface could display a "Source" link that leads users to an archive 654 of the code. There are many ways you could offer source, and different 655 solutions will be better for different programs; see section 13 for the 656 specific requirements. 657 658 You should also get your employer (if you work as a programmer) or school, 659 if any, to sign a "copyright disclaimer" for the program, if necessary. 660 For 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
1 1 ;var MXI_DEBUG = false; 2 2 /** 3 3 * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill 4 * v1. 3.54 * v1.5.8 5 5 * 6 6 * Copyright 2013, Moxiecode Systems AB 7 7 * Released under GPL License. … … 9 9 * License: http://www.plupload.com/license 10 10 * Contributing: http://www.plupload.com/contributing 11 11 * 12 * Date: 2016-05-15 13 */ 14 /** 15 * Compiled inline version. (Library mode) 12 * Date: 2018-02-19 16 13 */ 14 ;(function (global, factory) { 15 var extract = function() { 16 var ctx = {}; 17 factory.apply(ctx, arguments); 18 return ctx.moxie; 19 }; 17 20 18 /** 19 * Modified for WordPress, Silverlight and Flash runtimes support was removed. 20 * See https://core.trac.wordpress.org/ticket/41755. 21 */ 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() { 29 /** 30 * Compiled inline version. (Library mode) 31 */ 22 32 23 /*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */24 /*globals $code */33 /*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */ 34 /*globals $code */ 25 35 26 (function(exports, undefined) {27 "use strict";36 (function(exports, undefined) { 37 "use strict"; 28 38 29 var modules = {};39 var modules = {}; 30 40 31 function require(ids, callback) {32 var module, defs = [];41 function require(ids, callback) { 42 var module, defs = []; 33 43 34 for (var i = 0; i < ids.length; ++i) { 35 module = modules[ids[i]] || resolve(ids[i]); 36 if (!module) { 37 throw 'module definition dependecy not found: ' + ids[i]; 44 for (var i = 0; i < ids.length; ++i) { 45 module = modules[ids[i]] || resolve(ids[i]); 46 if (!module) { 47 throw 'module definition dependecy not found: ' + ids[i]; 48 } 49 50 defs.push(module); 38 51 } 39 52 40 defs.push(module);53 callback.apply(null, defs); 41 54 } 42 55 43 callback.apply(null, defs); 44 } 56 function define(id, dependencies, definition) { 57 if (typeof id !== 'string') { 58 throw 'invalid module definition, module id must be defined and be a string'; 59 } 45 60 46 function define(id, dependencies, definition) { 47 if (typeof id !== 'string') { 48 throw 'invalid module definition, module id must be defined and be a string'; 49 } 61 if (dependencies === undefined) { 62 throw 'invalid module definition, dependencies must be specified'; 63 } 50 64 51 if (dependencies=== undefined) {52 throw 'invalid module definition, dependenciesmust be specified';53 }65 if (definition === undefined) { 66 throw 'invalid module definition, definition function must be specified'; 67 } 54 68 55 if (definition === undefined) { 56 throw 'invalid module definition, definition function must be specified'; 69 require(dependencies, function() { 70 modules[id] = definition.apply(null, arguments); 71 }); 57 72 } 58 73 59 require(dependencies, function() { 60 modules[id] = definition.apply(null, arguments); 61 }); 62 } 74 function defined(id) { 75 return !!modules[id]; 76 } 63 77 64 function defined(id) {65 return !!modules[id];66 }78 function resolve(id) { 79 var target = exports; 80 var fragments = id.split(/[.\/]/); 67 81 68 function resolve(id) { 69 var target = exports; 70 var fragments = id.split(/[.\/]/); 82 for (var fi = 0; fi < fragments.length; ++fi) { 83 if (!target[fragments[fi]]) { 84 return; 85 } 71 86 72 for (var fi = 0; fi < fragments.length; ++fi) { 73 if (!target[fragments[fi]]) { 74 return; 87 target = target[fragments[fi]]; 75 88 } 76 89 77 target = target[fragments[fi]];90 return target; 78 91 } 79 92 80 return target; 81 } 93 function expose(ids) { 94 for (var i = 0; i < ids.length; i++) { 95 var target = exports; 96 var id = ids[i]; 97 var fragments = id.split(/[.\/]/); 82 98 83 function expose(ids) { 84 for (var i = 0; i < ids.length; i++) { 85 var target = exports; 86 var id = ids[i]; 87 var fragments = id.split(/[.\/]/); 99 for (var fi = 0; fi < fragments.length - 1; ++fi) { 100 if (target[fragments[fi]] === undefined) { 101 target[fragments[fi]] = {}; 102 } 88 103 89 for (var fi = 0; fi < fragments.length - 1; ++fi) { 90 if (target[fragments[fi]] === undefined) { 91 target[fragments[fi]] = {}; 104 target = target[fragments[fi]]; 92 105 } 93 106 94 target = target[fragments[fi]];107 target[fragments[fragments.length - 1]] = modules[id]; 95 108 } 96 97 target[fragments[fragments.length - 1]] = modules[id];98 109 } 99 }100 110 101 111 // Included from: src/javascript/core/utils/Basic.js 102 112 103 /**104 * Basic.js105 *106 * Copyright 2013, Moxiecode Systems AB107 * Released under GPL License.108 *109 * License: http://www.plupload.com/license110 * Contributing: http://www.plupload.com/contributing111 */113 /** 114 * Basic.js 115 * 116 * Copyright 2013, Moxiecode Systems AB 117 * Released under GPL License. 118 * 119 * License: http://www.plupload.com/license 120 * Contributing: http://www.plupload.com/contributing 121 */ 112 122 113 define('moxie/core/utils/Basic', [], function() { 114 /** 123 /** 124 @class moxie/core/utils/Basic 125 @public 126 @static 127 */ 128 129 define('moxie/core/utils/Basic', [], function() { 130 /** 115 131 Gets the true type of the built-in object (better version of typeof). 116 132 @author Angus Croll (http://javascriptweblog.wordpress.com/) 117 133 118 134 @method typeOf 119 @for Utils120 135 @static 121 136 @param {Object} o Object to check. 122 137 @return {String} Object [[Class]] 123 */ 124 var typeOf = function(o) { 125 var undef; 126 127 if (o === undef) { 128 return 'undefined'; 129 } else if (o === null) { 130 return 'null'; 131 } else if (o.nodeType) { 132 return 'node'; 133 } 138 */ 139 function typeOf(o) { 140 var undef; 134 141 135 // the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8 136 return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); 137 }; 138 139 /** 140 Extends the specified object with another object. 142 if (o === undef) { 143 return 'undefined'; 144 } else if (o === null) { 145 return 'null'; 146 } else if (o.nodeType) { 147 return 'node'; 148 } 149 150 // the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8 151 return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); 152 } 153 154 /** 155 Extends the specified object with another object(s). 141 156 142 157 @method extend 143 158 @static 144 159 @param {Object} target Object to extend. 145 160 @param {Object} [obj]* Multiple objects to extend with. 146 161 @return {Object} Same as target, the extended object. 147 */ 148 var extend = function(target) { 149 var undef; 150 151 each(arguments, function(arg, i) { 152 if (i > 0) { 153 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 } 162 */ 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) { 219 var undef; 220 var target = args[0]; 221 222 each(args, function(arg, i) { 223 if (i > 0) { 224 each(arg, function(value, key) { 225 var isComplex = inArray(typeOf(value), ['array', 'object']) !== -1; 226 227 if (value === undef || strict && target[key] === undef) { 228 return true; 229 } 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 } 240 }); 160 241 } 161 242 }); 243 244 return target; 162 245 } 163 }); 164 return target; 165 }; 166 167 /** 246 247 248 /** 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 /** 168 289 Executes the callback function for each item in array/object. If you return false in the 169 290 callback it will break the loop. 170 291 … … 172 293 @static 173 294 @param {Object} obj Object to iterate. 174 295 @param {function} callback Callback function to execute for each item. 175 */ 176 var each = function(obj, callback) { 177 var length, key, i, undef; 178 179 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; 296 */ 297 function each(obj, callback) { 298 var length, key, i, undef; 299 300 if (obj) { 301 try { 302 length = obj.length; 303 } catch(ex) { 304 length = undef; 185 305 } 186 } 187 } else if (typeOf(obj) === 'object') { 188 // Loop object items 189 for (key in obj) { 190 if (obj.hasOwnProperty(key)) { 191 if (callback(obj[key], key) === false) { 192 return; 306 307 if (length === undef || typeof(length) !== 'number') { 308 // Loop object items 309 for (key in obj) { 310 if (obj.hasOwnProperty(key)) { 311 if (callback(obj[key], key) === false) { 312 return; 313 } 314 } 315 } 316 } else { 317 // Loop array items 318 for (i = 0; i < length; i++) { 319 if (callback(obj[i], i) === false) { 320 return; 321 } 193 322 } 194 323 } 195 324 } 196 325 } 197 }198 };199 326 200 /**327 /** 201 328 Checks if object is empty. 202 329 203 330 @method isEmptyObj 204 331 @static 205 332 @param {Object} o Object to check. 206 333 @return {Boolean} 207 */208 var isEmptyObj = function(obj) {209 var prop;334 */ 335 function isEmptyObj(obj) { 336 var prop; 210 337 211 if (!obj || typeOf(obj) !== 'object') {212 return true;213 }338 if (!obj || typeOf(obj) !== 'object') { 339 return true; 340 } 214 341 215 for (prop in obj) {216 return false;217 }342 for (prop in obj) { 343 return false; 344 } 218 345 219 return true;220 };346 return true; 347 } 221 348 222 /**349 /** 223 350 Recieve an array of functions (usually async) to call in sequence, each function 224 351 receives a callback as first argument that it should call, when it completes. Finally, 225 352 after everything is complete, main callback is called. Passing truthy value to the … … 230 357 @static 231 358 @param {Array} queue Array of functions to call in sequence 232 359 @param {Function} cb Main callback that is called in the end, or in case of error 233 */234 var inSeries = function(queue, cb) {235 var i = 0, length = queue.length;360 */ 361 function inSeries(queue, cb) { 362 var i = 0, length = queue.length; 236 363 237 if (typeOf(cb) !== 'function') {238 cb = function() {};239 }364 if (typeOf(cb) !== 'function') { 365 cb = function() {}; 366 } 240 367 241 if (!queue || !queue.length) {242 cb();243 }368 if (!queue || !queue.length) { 369 cb(); 370 } 244 371 245 function callNext(i) { 246 if (typeOf(queue[i]) === 'function') { 247 queue[i](function(error) { 248 /*jshint expr:true */ 249 ++i < length && !error ? callNext(i) : cb(error); 250 }); 372 function callNext(i) { 373 if (typeOf(queue[i]) === 'function') { 374 queue[i](function(error) { 375 /*jshint expr:true */ 376 ++i < length && !error ? callNext(i) : cb(error); 377 }); 378 } 379 } 380 callNext(i); 251 381 } 252 }253 callNext(i);254 };255 382 256 383 257 /**384 /** 258 385 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 260 387 everything is complete, main callback is called. Passing truthy value to the 261 388 callback as a first argument will interrupt the process and invoke main callback 262 389 immediately. … … 264 391 @method inParallel 265 392 @static 266 393 @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 erro r268 */269 var inParallel = function(queue, cb) {270 var count = 0, num = queue.length, cbArgs = new Array(num);271 272 each(queue, function(fn, i) {273 fn(function(error) {274 if (error) {275 return cb(error);276 }277 278 var args = [].slice.call(arguments);279 args.shift(); // strip error - undefined or not280 281 cbArgs[i] = args;282 count++;283 284 if (count === num) {285 cbArgs.unshift(null);286 cb.apply(this, cbArgs);287 }288 });289 });290 };291 292 293 /**394 @param {Function} cb Main callback that is called in the end, or in case of erro 395 */ 396 function inParallel(queue, cb) { 397 var count = 0, num = queue.length, cbArgs = new Array(num); 398 399 each(queue, function(fn, i) { 400 fn(function(error) { 401 if (error) { 402 return cb(error); 403 } 404 405 var args = [].slice.call(arguments); 406 args.shift(); // strip error - undefined or not 407 408 cbArgs[i] = args; 409 count++; 410 411 if (count === num) { 412 cbArgs.unshift(null); 413 cb.apply(this, cbArgs); 414 } 415 }); 416 }); 417 } 418 419 420 /** 294 421 Find an element in array and return it's index if present, otherwise return -1. 295 422 296 423 @method inArray 297 424 @static 298 425 @param {Mixed} needle Element to find 299 426 @param {Array} array 300 427 @return {Int} Index of the element, or -1 if not found 301 */ 302 var inArray = function(needle, array) { 303 if (array) { 304 if (Array.prototype.indexOf) { 305 return Array.prototype.indexOf.call(array, needle); 306 } 307 308 for (var i = 0, length = array.length; i < length; i++) { 309 if (array[i] === needle) { 310 return i; 428 */ 429 function inArray(needle, array) { 430 if (array) { 431 if (Array.prototype.indexOf) { 432 return Array.prototype.indexOf.call(array, needle); 433 } 434 435 for (var i = 0, length = array.length; i < length; i++) { 436 if (array[i] === needle) { 437 return i; 438 } 439 } 311 440 } 441 return -1; 312 442 } 313 }314 return -1;315 };316 443 317 444 318 /**445 /** 319 446 Returns elements of first array if they are not present in second. And false - otherwise. 320 447 321 448 @private … … 323 450 @param {Array} needles 324 451 @param {Array} array 325 452 @return {Array|Boolean} 326 */327 var arrayDiff = function(needles, array) {328 var diff = [];453 */ 454 function arrayDiff(needles, array) { 455 var diff = []; 329 456 330 if (typeOf(needles) !== 'array') {331 needles = [needles];332 }457 if (typeOf(needles) !== 'array') { 458 needles = [needles]; 459 } 333 460 334 if (typeOf(array) !== 'array') {335 array = [array];336 }461 if (typeOf(array) !== 'array') { 462 array = [array]; 463 } 337 464 338 for (var i in needles) {339 if (inArray(needles[i], array) === -1) {340 diff.push(needles[i]);341 }342 }343 return diff.length ? diff : false;344 };465 for (var i in needles) { 466 if (inArray(needles[i], array) === -1) { 467 diff.push(needles[i]); 468 } 469 } 470 return diff.length ? diff : false; 471 } 345 472 346 473 347 /**474 /** 348 475 Find intersection of two arrays. 349 476 350 477 @private … … 352 479 @param {Array} array1 353 480 @param {Array} array2 354 481 @return {Array} Intersection of two arrays or null if there is none 355 */ 356 var arrayIntersect = function(array1, array2) { 357 var result = []; 358 each(array1, function(item) { 359 if (inArray(item, array2) !== -1) { 360 result.push(item); 482 */ 483 function arrayIntersect(array1, array2) { 484 var result = []; 485 each(array1, function(item) { 486 if (inArray(item, array2) !== -1) { 487 result.push(item); 488 } 489 }); 490 return result.length ? result : null; 361 491 } 362 }); 363 return result.length ? result : null; 364 }; 365 366 367 /** 492 493 494 /** 368 495 Forces anything into an array. 369 496 370 497 @method toArray 371 498 @static 372 499 @param {Object} obj Object with length field. 373 500 @return {Array} Array object containing all items. 374 */375 var toArray = function(obj) {376 var i, arr = [];501 */ 502 function toArray(obj) { 503 var i, arr = []; 377 504 378 for (i = 0; i < obj.length; i++) {379 arr[i] = obj[i];380 }505 for (i = 0; i < obj.length; i++) { 506 arr[i] = obj[i]; 507 } 381 508 382 return arr;383 };384 385 386 /**509 return arr; 510 } 511 512 513 /** 387 514 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 390 517 to be hit with an asteroid. 391 518 392 519 @method guid 393 520 @static 394 521 @param {String} prefix to prepend (by default 'o' will be prepended). 395 522 @method guid 396 523 @return {String} Virtually unique id. 397 */ 398 var guid = (function() { 399 var counter = 0; 400 401 return function(prefix) { 402 var guid = new Date().getTime().toString(32), i; 403 404 for (i = 0; i < 5; i++) { 405 guid += Math.floor(Math.random() * 65535).toString(32); 406 } 407 408 return (prefix || 'o_') + guid + (counter++).toString(32); 409 }; 410 }()); 411 524 */ 525 var guid = (function() { 526 var counter = 0; 412 527 413 /** 528 return function(prefix) { 529 var guid = new Date().getTime().toString(32), i; 530 531 for (i = 0; i < 5; i++) { 532 guid += Math.floor(Math.random() * 65535).toString(32); 533 } 534 535 return (prefix || 'o_') + guid + (counter++).toString(32); 536 }; 537 }()); 538 539 540 /** 414 541 Trims white spaces around the string 415 542 416 543 @method trim 417 544 @static 418 545 @param {String} str 419 546 @return {String} 420 */421 var trim = function(str) {422 if (!str) {423 return str;424 }425 return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, '');426 };547 */ 548 function trim(str) { 549 if (!str) { 550 return str; 551 } 552 return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, ''); 553 } 427 554 428 555 429 /**556 /** 430 557 Parses the specified size string into a byte value. For example 10kb becomes 10240. 431 558 432 559 @method parseSizeStr 433 560 @static 434 561 @param {String/Number} size String to parse or number to just pass through. 435 562 @return {Number} Size in bytes. 436 */ 437 var parseSizeStr = function(size) { 438 if (typeof(size) !== 'string') { 439 return size; 440 } 441 442 var muls = { 443 t: 1099511627776, 444 g: 1073741824, 445 m: 1048576, 446 k: 1024 447 }, 448 mul; 563 */ 564 function parseSizeStr(size) { 565 if (typeof(size) !== 'string') { 566 return size; 567 } 449 568 569 var muls = { 570 t: 1099511627776, 571 g: 1073741824, 572 m: 1048576, 573 k: 1024 574 }, 575 mul; 450 576 451 size = /^([0-9\.]+)([tmgk]?)$/.exec(size.toLowerCase().replace(/[^0-9\.tmkg]/g, '')); 452 mul = size[2]; 453 size = +size[1]; 454 455 if (muls.hasOwnProperty(mul)) { 456 size *= muls[mul]; 457 } 458 return Math.floor(size); 459 }; 577 size = /^([0-9\.]+)([tmgk]?)$/.exec(size.toLowerCase().replace(/[^0-9\.tmkg]/g, '')); 578 mul = size[2]; 579 size = +size[1]; 460 580 581 if (muls.hasOwnProperty(mul)) { 582 size *= muls[mul]; 583 } 584 return Math.floor(size); 585 } 461 586 462 /**463 * Pseudo sprintf implementation - simple way to replace tokens with specified values.464 *465 * @param {String} str String with tokens466 * @return {String} String with replaced tokens467 */468 var sprintf = function(str) {469 var args = [].slice.call(arguments, 1);470 587 471 return str.replace(/%[a-z]/g, function() { 472 var value = args.shift(); 473 return typeOf(value) !== 'undefined' ? value : ''; 474 }); 475 }; 476 588 /** 589 * Pseudo sprintf implementation - simple way to replace tokens with specified values. 590 * 591 * @param {String} str String with tokens 592 * @return {String} String with replaced tokens 593 */ 594 function sprintf(str) { 595 var args = [].slice.call(arguments, 1); 477 596 478 return { 479 guid: guid, 480 typeOf: typeOf, 481 extend: extend, 482 each: each, 483 isEmptyObj: isEmptyObj, 484 inSeries: inSeries, 485 inParallel: inParallel, 486 inArray: inArray, 487 arrayDiff: arrayDiff, 488 arrayIntersect: arrayIntersect, 489 toArray: toArray, 490 trim: trim, 491 sprintf: sprintf, 492 parseSizeStr: parseSizeStr 493 }; 494 }); 597 return str.replace(/%([a-z])/g, function($0, $1) { 598 var value = args.shift(); 495 599 496 // Included from: src/javascript/core/utils/Env.js 600 switch ($1) { 601 case 's': 602 return value + ''; 497 603 498 /** 499 * Env.js 500 * 501 * Copyright 2013, Moxiecode Systems AB 502 * Released under GPL License. 503 * 504 * License: http://www.plupload.com/license 505 * Contributing: http://www.plupload.com/contributing 506 */ 604 case 'd': 605 return parseInt(value, 10); 507 606 508 define("moxie/core/utils/Env", [ 509 "moxie/core/utils/Basic" 510 ], function(Basic) { 511 512 /** 513 * UAParser.js v0.7.7 514 * Lightweight JavaScript-based User-Agent string parser 515 * https://github.com/faisalman/ua-parser-js 516 * 517 * Copyright © 2012-2015 Faisal Salman <fyzlman@gmail.com> 518 * Dual licensed under GPLv2 & MIT 519 */ 520 var UAParser = (function (undefined) { 607 case 'f': 608 return parseFloat(value); 521 609 522 ////////////// 523 // Constants 524 ///////////// 525 526 527 var EMPTY = '', 528 UNKNOWN = '?', 529 FUNC_TYPE = 'function', 530 UNDEF_TYPE = 'undefined', 531 OBJ_TYPE = 'object', 532 MAJOR = 'major', 533 MODEL = 'model', 534 NAME = 'name', 535 TYPE = 'type', 536 VENDOR = 'vendor', 537 VERSION = 'version', 538 ARCHITECTURE= 'architecture', 539 CONSOLE = 'console', 540 MOBILE = 'mobile', 541 TABLET = 'tablet'; 542 543 544 /////////// 545 // Helper 546 ////////// 547 548 549 var util = { 550 has : function (str1, str2) { 551 return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; 552 }, 553 lowerize : function (str) { 554 return str.toLowerCase(); 555 } 556 }; 557 558 559 /////////////// 560 // Map helper 561 ////////////// 562 563 564 var mapper = { 565 566 rgx : function () { 567 568 // loop through all regexes maps 569 for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) { 570 571 var regex = args[i], // even sequence (0,2,4,..) 572 props = args[i + 1]; // odd sequence (1,3,5,..) 573 574 // construct object barebones 575 if (typeof(result) === UNDEF_TYPE) { 576 result = {}; 577 for (p in props) { 578 q = props[p]; 579 if (typeof(q) === OBJ_TYPE) { 580 result[q[0]] = undefined; 581 } else { 582 result[q] = undefined; 583 } 584 } 585 } 586 587 // try matching uastring with regexes 588 for (j = k = 0; j < regex.length; j++) { 589 matches = regex[j].exec(this.getUA()); 590 if (!!matches) { 591 for (p = 0; p < props.length; p++) { 592 match = matches[++k]; 593 q = props[p]; 594 // check if given property is actually array 595 if (typeof(q) === OBJ_TYPE && q.length > 0) { 596 if (q.length == 2) { 597 if (typeof(q[1]) == FUNC_TYPE) { 598 // assign modified match 599 result[q[0]] = q[1].call(this, match); 600 } else { 601 // assign given value, ignore regex match 602 result[q[0]] = q[1]; 603 } 604 } else if (q.length == 3) { 605 // check whether function or regex 606 if (typeof(q[1]) === FUNC_TYPE && !(q[1].exec && q[1].test)) { 607 // call function (usually string mapper) 608 result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined; 609 } else { 610 // sanitize match using given regex 611 result[q[0]] = match ? match.replace(q[1], q[2]) : undefined; 612 } 613 } else if (q.length == 4) { 614 result[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined; 615 } 616 } else { 617 result[q] = match ? match : undefined; 618 } 619 } 620 break; 621 } 622 } 623 624 if(!!matches) break; // break the loop immediately if match found 625 } 626 return result; 627 }, 628 629 str : function (str, map) { 630 631 for (var i in map) { 632 // check if array 633 if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) { 634 for (var j = 0; j < map[i].length; j++) { 635 if (util.has(map[i][j], str)) { 636 return (i === UNKNOWN) ? undefined : i; 637 } 638 } 639 } else if (util.has(map[i], str)) { 640 return (i === UNKNOWN) ? undefined : i; 641 } 642 } 643 return str; 644 } 645 }; 646 647 648 /////////////// 649 // String map 650 ////////////// 651 652 653 var maps = { 654 655 browser : { 656 oldsafari : { 657 major : { 658 '1' : ['/8', '/1', '/3'], 659 '2' : '/4', 660 '?' : '/' 661 }, 662 version : { 663 '1.0' : '/8', 664 '1.2' : '/1', 665 '1.3' : '/3', 666 '2.0' : '/412', 667 '2.0.2' : '/416', 668 '2.0.3' : '/417', 669 '2.0.4' : '/419', 670 '?' : '/' 671 } 672 } 673 }, 674 675 device : { 676 sprint : { 677 model : { 678 'Evo Shift 4G' : '7373KT' 679 }, 680 vendor : { 681 'HTC' : 'APA', 682 'Sprint' : 'Sprint' 683 } 684 } 685 }, 686 687 os : { 688 windows : { 689 version : { 690 'ME' : '4.90', 691 'NT 3.11' : 'NT3.51', 692 'NT 4.0' : 'NT4.0', 693 '2000' : 'NT 5.0', 694 'XP' : ['NT 5.1', 'NT 5.2'], 695 'Vista' : 'NT 6.0', 696 '7' : 'NT 6.1', 697 '8' : 'NT 6.2', 698 '8.1' : 'NT 6.3', 699 'RT' : 'ARM' 700 } 701 } 702 } 703 }; 704 705 706 ////////////// 707 // Regex map 708 ///////////// 709 710 711 var regexes = { 712 713 browser : [[ 714 715 // Presto based 716 /(opera\smini)\/([\w\.-]+)/i, // Opera Mini 717 /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet 718 /(opera).+version\/([\w\.]+)/i, // Opera > 9.80 719 /(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80 720 721 ], [NAME, VERSION], [ 722 723 /\s(opr)\/([\w\.]+)/i // Opera Webkit 724 ], [[NAME, 'Opera'], VERSION], [ 725 726 // Mixed 727 /(kindle)\/([\w\.]+)/i, // Kindle 728 /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]+)*/i, 729 // Lunascape/Maxthon/Netfront/Jasmine/Blazer 730 731 // Trident based 732 /(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i, 733 // Avant/IEMobile/SlimBrowser/Baidu 734 /(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer 735 736 // Webkit/KHTML based 737 /(rekonq)\/([\w\.]+)*/i, // Rekonq 738 /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi)\/([\w\.-]+)/i 739 // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron 740 ], [NAME, VERSION], [ 741 742 /(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11 743 ], [[NAME, 'IE'], VERSION], [ 744 745 /(edge)\/((\d+)?[\w\.]+)/i // Microsoft Edge 746 ], [NAME, VERSION], [ 747 748 /(yabrowser)\/([\w\.]+)/i // Yandex 749 ], [[NAME, 'Yandex'], VERSION], [ 750 751 /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon 752 ], [[NAME, /_/g, ' '], VERSION], [ 753 754 /(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i, 755 // Chrome/OmniWeb/Arora/Tizen/Nokia 756 /(uc\s?browser|qqbrowser)[\/\s]?([\w\.]+)/i 757 // UCBrowser/QQBrowser 758 ], [NAME, VERSION], [ 759 760 /(dolfin)\/([\w\.]+)/i // Dolphin 761 ], [[NAME, 'Dolphin'], VERSION], [ 762 763 /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS 764 ], [[NAME, 'Chrome'], VERSION], [ 765 766 /XiaoMi\/MiuiBrowser\/([\w\.]+)/i // MIUI Browser 767 ], [VERSION, [NAME, 'MIUI Browser']], [ 768 769 /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)/i // Android Browser 770 ], [VERSION, [NAME, 'Android Browser']], [ 771 772 /FBAV\/([\w\.]+);/i // Facebook App for iOS 773 ], [VERSION, [NAME, 'Facebook']], [ 774 775 /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari 776 ], [VERSION, [NAME, 'Mobile Safari']], [ 777 778 /version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile 779 ], [VERSION, NAME], [ 780 781 /webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0 782 ], [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]], [ 783 784 /(konqueror)\/([\w\.]+)/i, // Konqueror 785 /(webkit|khtml)\/([\w\.]+)/i 786 ], [NAME, VERSION], [ 787 788 // Gecko based 789 /(navigator|netscape)\/([\w\.-]+)/i // Netscape 790 ], [[NAME, 'Netscape'], VERSION], [ 791 /(swiftfox)/i, // Swiftfox 792 /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i, 793 // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror 794 /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/([\w\.-]+)/i, 795 // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix 796 /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla 797 798 // Other 799 /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?([\w\.]+)/i, 800 // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf 801 /(links)\s\(([\w\.]+)/i, // Links 802 /(gobrowser)\/?([\w\.]+)*/i, // GoBrowser 803 /(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser 804 /(mosaic)[\/\s]([\w\.]+)/i // Mosaic 805 ], [NAME, VERSION] 806 ], 807 808 engine : [[ 809 810 /windows.+\sedge\/([\w\.]+)/i // EdgeHTML 811 ], [VERSION, [NAME, 'EdgeHTML']], [ 812 813 /(presto)\/([\w\.]+)/i, // Presto 814 /(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m 815 /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links 816 /(icab)[\/\s]([23]\.[\d\.]+)/i // iCab 817 ], [NAME, VERSION], [ 818 819 /rv\:([\w\.]+).*(gecko)/i // Gecko 820 ], [VERSION, NAME] 821 ], 822 823 os : [[ 824 825 // Windows based 826 /microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes) 827 ], [NAME, VERSION], [ 828 /(windows)\snt\s6\.2;\s(arm)/i, // Windows RT 829 /(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i 830 ], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [ 831 /(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i 832 ], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [ 833 834 // Mobile/Embedded OS 835 /\((bb)(10);/i // BlackBerry 10 836 ], [[NAME, 'BlackBerry'], VERSION], [ 837 /(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry 838 /(tizen)[\/\s]([\w\.]+)/i, // Tizen 839 /(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i, 840 // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki 841 /linux;.+(sailfish);/i // Sailfish OS 842 ], [NAME, VERSION], [ 843 /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian 844 ], [[NAME, 'Symbian'], VERSION], [ 845 /\((series40);/i // Series 40 846 ], [NAME], [ 847 /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS 848 ], [[NAME, 'Firefox OS'], VERSION], [ 849 850 // Console 851 /(nintendo|playstation)\s([wids3portablevu]+)/i, // Nintendo/Playstation 852 853 // GNU/Linux based 854 /(mint)[\/\s\(]?(\w+)*/i, // Mint 855 /(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux 856 /(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?([\w\.-]+)*/i, 857 // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware 858 // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus 859 /(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux 860 /(gnu)\s?([\w\.]+)*/i // GNU 861 ], [NAME, VERSION], [ 862 863 /(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS 864 ], [[NAME, 'Chromium OS'], VERSION],[ 865 866 // Solaris 867 /(sunos)\s?([\w\.]+\d)*/i // Solaris 868 ], [[NAME, 'Solaris'], VERSION], [ 869 870 // BSD based 871 /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly 872 ], [NAME, VERSION],[ 873 874 /(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS 875 ], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [ 876 877 /(mac\sos\sx)\s?([\w\s\.]+\w)*/i, 878 /(macintosh|mac(?=_powerpc)\s)/i // Mac OS 879 ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [ 880 881 // Other 882 /((?:open)?solaris)[\/\s-]?([\w\.]+)*/i, // Solaris 883 /(haiku)\s(\w+)/i, // Haiku 884 /(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX 885 /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i, 886 // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS 887 /(unix)\s?([\w\.]+)*/i // UNIX 888 ], [NAME, VERSION] 889 ] 890 }; 891 892 893 ///////////////// 894 // Constructor 895 //////////////// 896 897 898 var UAParser = function (uastring) { 899 900 var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY); 901 902 this.getBrowser = function () { 903 return mapper.rgx.apply(this, regexes.browser); 904 }; 905 this.getEngine = function () { 906 return mapper.rgx.apply(this, regexes.engine); 907 }; 908 this.getOS = function () { 909 return mapper.rgx.apply(this, regexes.os); 910 }; 911 this.getResult = function() { 912 return { 913 ua : this.getUA(), 914 browser : this.getBrowser(), 915 engine : this.getEngine(), 916 os : this.getOS() 917 }; 918 }; 919 this.getUA = function () { 920 return ua; 921 }; 922 this.setUA = function (uastring) { 923 ua = uastring; 924 return this; 925 }; 926 this.setUA(ua); 927 }; 928 929 return UAParser; 930 })(); 931 932 933 function version_compare(v1, v2, operator) { 934 // From: http://phpjs.org/functions 935 // + original by: Philippe Jausions (http://pear.php.net/user/jausions) 936 // + original by: Aidan Lister (http://aidanlister.com/) 937 // + reimplemented by: Kankrelune (http://www.webfaktory.info/) 938 // + improved by: Brett Zamir (http://brett-zamir.me) 939 // + improved by: Scott Baker 940 // + improved by: Theriault 941 // * example 1: version_compare('8.2.5rc', '8.2.5a'); 942 // * returns 1: 1 943 // * example 2: version_compare('8.2.50', '8.2.52', '<'); 944 // * returns 2: true 945 // * example 3: version_compare('5.3.0-dev', '5.3.0'); 946 // * returns 3: -1 947 // * example 4: version_compare('4.1.0.52','4.01.0.51'); 948 // * returns 4: 1 949 950 // Important: compare must be initialized at 0. 951 var i = 0, 952 x = 0, 953 compare = 0, 954 // vm maps textual PHP versions to negatives so they're less than 0. 955 // PHP currently defines these as CASE-SENSITIVE. It is important to 956 // leave these as negatives so that they can come before numerical versions 957 // and as if no letters were there to begin with. 958 // (1alpha is < 1 and < 1.1 but > 1dev1) 959 // If a non-numerical value can't be mapped to this table, it receives 960 // -7 as its value. 961 vm = { 962 'dev': -6, 963 'alpha': -5, 964 'a': -5, 965 'beta': -4, 966 'b': -4, 967 'RC': -3, 968 'rc': -3, 969 '#': -2, 970 'p': 1, 971 'pl': 1 972 }, 973 // This function will be called to prepare each version argument. 974 // It replaces every _, -, and + with a dot. 975 // It surrounds any nonsequence of numbers/dots with dots. 976 // It replaces sequences of dots with a single dot. 977 // version_compare('4..0', '4.0') == 0 978 // Important: A string of 0 length needs to be converted into a value 979 // even less than an unexisting value in vm (-7), hence [-8]. 980 // It's also important to not strip spaces because of this. 981 // version_compare('', ' ') == 1 982 prepVersion = function (v) { 983 v = ('' + v).replace(/[_\-+]/g, '.'); 984 v = v.replace(/([^.\d]+)/g, '.$1.').replace(/\.{2,}/g, '.'); 985 return (!v.length ? [-8] : v.split('.')); 986 }, 987 // This converts a version component to a number. 988 // Empty component becomes 0. 989 // Non-numerical component becomes a negative number. 990 // Numerical component becomes itself as an integer. 991 numVersion = function (v) { 992 return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10)); 993 }; 994 995 v1 = prepVersion(v1); 996 v2 = prepVersion(v2); 997 x = Math.max(v1.length, v2.length); 998 for (i = 0; i < x; i++) { 999 if (v1[i] == v2[i]) { 1000 continue; 1001 } 1002 v1[i] = numVersion(v1[i]); 1003 v2[i] = numVersion(v2[i]); 1004 if (v1[i] < v2[i]) { 1005 compare = -1; 1006 break; 1007 } else if (v1[i] > v2[i]) { 1008 compare = 1; 1009 break; 1010 } 1011 } 1012 if (!operator) { 1013 return compare; 1014 } 1015 1016 // Important: operator is CASE-SENSITIVE. 1017 // "No operator" seems to be treated as "<." 1018 // Any other values seem to make the function return null. 1019 switch (operator) { 1020 case '>': 1021 case 'gt': 1022 return (compare > 0); 1023 case '>=': 1024 case 'ge': 1025 return (compare >= 0); 1026 case '<=': 1027 case 'le': 1028 return (compare <= 0); 1029 case '==': 1030 case '=': 1031 case 'eq': 1032 return (compare === 0); 1033 case '<>': 1034 case '!=': 1035 case 'ne': 1036 return (compare !== 0); 1037 case '': 1038 case '<': 1039 case 'lt': 1040 return (compare < 0); 1041 default: 1042 return null; 1043 } 1044 } 610 case 'c': 611 return ''; 1045 612 613 default: 614 return value; 615 } 616 }); 617 } 1046 618 1047 var can = (function() {1048 var caps = {1049 define_property: (function() {1050 /* // currently too much extra code required, not exactly worth it1051 try { // as of IE8, getters/setters are supported only on DOM elements1052 var obj = {};1053 if (Object.defineProperty) {1054 Object.defineProperty(obj, 'prop', {1055 enumerable: true,1056 configurable: true1057 });1058 return true;1059 }1060 } catch(ex) {}1061 619 1062 if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) {1063 return true;1064 }*/1065 return false;1066 }()),1067 620 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 }()), 621 function delay(cb, timeout) { 622 var self = this; 623 setTimeout(function() { 624 cb.call(self); 625 }, timeout || 1); 626 } 1075 627 1076 return_response_type: function(responseType) {1077 try {1078 if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) {1079 return true;1080 } else if (window.XMLHttpRequest) {1081 var xhr = new XMLHttpRequest();1082 xhr.open('get', '/'); // otherwise Gecko throws an exception1083 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 }1091 }1092 } catch (ex) {}1093 return false;1094 },1095 628 1096 // ideas for this heavily come from Modernizr (http://modernizr.com/) 1097 use_data_uri: (function() { 1098 var du = new Image(); 629 return { 630 guid: guid, 631 typeOf: typeOf, 632 extend: extend, 633 extendIf: extendIf, 634 extendImmutable: extendImmutable, 635 extendImmutableIf: extendImmutableIf, 636 clone: clone, 637 inherit: inherit, 638 each: each, 639 isEmptyObj: isEmptyObj, 640 inSeries: inSeries, 641 inParallel: inParallel, 642 inArray: inArray, 643 arrayDiff: arrayDiff, 644 arrayIntersect: arrayIntersect, 645 toArray: toArray, 646 trim: trim, 647 sprintf: sprintf, 648 parseSizeStr: parseSizeStr, 649 delay: delay 650 }; 651 }); 1099 652 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 }()), 653 // Included from: src/javascript/core/utils/Encode.js 1109 654 1110 use_data_uri_over32kb: function() { // IE8 1111 return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9); 1112 }, 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 */ 1113 664 1114 use_data_uri_of: function(bytes) { 1115 return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb()); 1116 }, 665 /** 666 @class moxie/core/utils/Encode 667 @public 668 @static 669 */ 1117 670 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 } 671 define('moxie/core/utils/Encode', [], function() { 1122 672 1123 var el = document.createElement('input'); 1124 el.setAttribute('type', 'file'); 1125 return !el.disabled; 1126 } 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)); 1127 683 }; 1128 684 1129 return function(cap) { 1130 var args = [].slice.call(arguments); 1131 args.shift(); // shift of cap 1132 return Basic.typeOf(caps[cap]) === 'function' ? caps[cap].apply(this, args) : !!caps[cap]; 1133 }; 1134 }()); 685 /** 686 Decode UTF-8 encoded string 1135 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 }; 1136 696 1137 var uaResult = new UAParser().getResult(); 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 1138 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); 1139 760 1140 var Env = { 1141 can: can, 761 dec = tmp_arr.join(''); 1142 762 1143 uaParser: UAParser, 1144 1145 browser: uaResult.browser.name, 1146 version: uaResult.browser.version, 1147 os: uaResult.os.name, // everybody intuitively types it in a lowercase for some reason 1148 osVersion: uaResult.os.version, 763 return utf8 ? utf8_decode(dec) : dec; 764 }; 1149 765 1150 verComp: version_compare, 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 1151 769 1152 global_event_dispatcher: "moxie.core.EventTarget.instance.dispatchEvent" 1153 }; 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); 1154 821 1155 // for backward compatibility 1156 // @deprecated Use `Env.os` instead 1157 Env.OS = Env.os; 1158 1159 if (MXI_DEBUG) { 1160 Env.debug = { 1161 runtime: true, 1162 events: false 1163 }; 1164 1165 Env.log = function() { 1166 1167 function logObj(data) { 1168 // TODO: this should recursively print out the object in a pretty way 1169 console.appendChild(document.createTextNode(data + "\n")); 1170 } 1171 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); 1180 } else if (document) { 1181 var console = document.getElementById('moxie-console'); 1182 if (!console) { 1183 console = document.createElement('pre'); 1184 console.id = 'moxie-console'; 1185 //console.style.display = 'none'; 1186 document.body.appendChild(console); 1187 } 822 enc = tmp_arr.join(''); 1188 823 1189 if (Basic.inArray(Basic.typeOf(data), ['object', 'array']) !== -1) { 1190 logObj(data); 1191 } else { 1192 console.appendChild(document.createTextNode(data + "\n")); 1193 } 1194 } 1195 }; 1196 } 824 var r = data.length % 3; 1197 825 1198 return Env;1199 });826 return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3); 827 }; 1200 828 1201 // Included from: src/javascript/core/I18n.js1202 829 1203 /** 1204 * I18n.js 1205 * 1206 * Copyright 2013, Moxiecode Systems AB 1207 * Released under GPL License. 1208 * 1209 * License: http://www.plupload.com/license 1210 * Contributing: http://www.plupload.com/contributing 1211 */ 830 return { 831 utf8_encode: utf8_encode, 832 utf8_decode: utf8_decode, 833 atob: atob, 834 btoa: btoa 835 }; 836 }); 1212 837 1213 define("moxie/core/I18n", [ 1214 "moxie/core/utils/Basic" 1215 ], function(Basic) { 1216 var i18n = {}; 838 // Included from: src/javascript/core/utils/Env.js 1217 839 1218 return {1219 840 /** 1220 * E xtends the language pack object with new items.841 * Env.js 1221 842 * 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 }, 1228 1229 /** 1230 * Translates the specified string by checking for the english string in the language pack lookup. 843 * Copyright 2013, Moxiecode Systems AB 844 * Released under GPL License. 1231 845 * 1232 * @param {String} str String to look for.1233 * @return {String} Translated string or the input string if it wasn't found.846 * License: http://www.plupload.com/license 847 * Contributing: http://www.plupload.com/contributing 1234 848 */ 1235 translate: function(str) {1236 return i18n[str] || str;1237 },1238 849 1239 850 /** 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. 851 @class moxie/core/utils/Env 852 @public 853 @static 1244 854 */ 1245 _: function(str) {1246 return this.translate(str);1247 },1248 855 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); 856 define("moxie/core/utils/Env", [ 857 "moxie/core/utils/Basic" 858 ], function(Basic) { 859 860 /** 861 * UAParser.js v0.7.7 862 * Lightweight JavaScript-based User-Agent string parser 863 * https://github.com/faisalman/ua-parser-js 864 * 865 * Copyright © 2012-2015 Faisal Salman <fyzlman@gmail.com> 866 * Dual licensed under GPLv2 & MIT 867 */ 868 var UAParser = (function (undefined) { 869 870 ////////////// 871 // Constants 872 ///////////// 873 874 875 var EMPTY = '', 876 UNKNOWN = '?', 877 FUNC_TYPE = 'function', 878 UNDEF_TYPE = 'undefined', 879 OBJ_TYPE = 'object', 880 MAJOR = 'major', 881 MODEL = 'model', 882 NAME = 'name', 883 TYPE = 'type', 884 VENDOR = 'vendor', 885 VERSION = 'version', 886 ARCHITECTURE= 'architecture', 887 CONSOLE = 'console', 888 MOBILE = 'mobile', 889 TABLET = 'tablet'; 890 891 892 /////////// 893 // Helper 894 ////////// 895 896 897 var util = { 898 has : function (str1, str2) { 899 return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; 900 }, 901 lowerize : function (str) { 902 return str.toLowerCase(); 903 } 904 }; 1257 905 1258 return str.replace(/%[a-z]/g, function() {1259 var value = args.shift();1260 return Basic.typeOf(value) !== 'undefined' ? value : '';1261 });1262 }1263 };1264 });1265 906 1266 // Included from: src/javascript/core/utils/Mime.js 907 /////////////// 908 // Map helper 909 ////////////// 910 911 912 var mapper = { 913 914 rgx : function () { 915 916 // loop through all regexes maps 917 for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) { 918 919 var regex = args[i], // even sequence (0,2,4,..) 920 props = args[i + 1]; // odd sequence (1,3,5,..) 921 922 // construct object barebones 923 if (typeof(result) === UNDEF_TYPE) { 924 result = {}; 925 for (p in props) { 926 q = props[p]; 927 if (typeof(q) === OBJ_TYPE) { 928 result[q[0]] = undefined; 929 } else { 930 result[q] = undefined; 931 } 932 } 933 } 1267 934 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 */ 935 // try matching uastring with regexes 936 for (j = k = 0; j < regex.length; j++) { 937 matches = regex[j].exec(this.getUA()); 938 if (!!matches) { 939 for (p = 0; p < props.length; p++) { 940 match = matches[++k]; 941 q = props[p]; 942 // check if given property is actually array 943 if (typeof(q) === OBJ_TYPE && q.length > 0) { 944 if (q.length == 2) { 945 if (typeof(q[1]) == FUNC_TYPE) { 946 // assign modified match 947 result[q[0]] = q[1].call(this, match); 948 } else { 949 // assign given value, ignore regex match 950 result[q[0]] = q[1]; 951 } 952 } else if (q.length == 3) { 953 // check whether function or regex 954 if (typeof(q[1]) === FUNC_TYPE && !(q[1].exec && q[1].test)) { 955 // call function (usually string mapper) 956 result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined; 957 } else { 958 // sanitize match using given regex 959 result[q[0]] = match ? match.replace(q[1], q[2]) : undefined; 960 } 961 } else if (q.length == 4) { 962 result[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined; 963 } 964 } else { 965 result[q] = match ? match : undefined; 966 } 967 } 968 break; 969 } 970 } 1277 971 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; 1358 } 1359 }, 1360 1361 1362 extList2mimes: function (filters, addMissingExtensions) { 1363 var self = this, ext, i, ii, type, mimes = []; 1364 1365 // convert extensions to mime types list 1366 for (i = 0; i < filters.length; i++) { 1367 ext = filters[i].extensions.split(/\s*,\s*/); 1368 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 } 1375 1376 type = self.mimes[ext[ii]]; 1377 if (type && Basic.inArray(type, mimes) === -1) { 1378 mimes.push(type); 1379 } 1380 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 } 1389 } 1390 return mimes; 1391 }, 1392 1393 1394 mimes2exts: function(mimes) { 1395 var self = this, exts = []; 1396 1397 Basic.each(mimes, function(mime) { 1398 if (mime === '*') { 1399 exts = []; 1400 return false; 1401 } 972 if(!!matches) break; // break the loop immediately if match found 973 } 974 return result; 975 }, 1402 976 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]); 977 str : function (str, map) { 978 979 for (var i in map) { 980 // check if array 981 if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) { 982 for (var j = 0; j < map[i].length; j++) { 983 if (util.has(map[i][j], str)) { 984 return (i === UNKNOWN) ? undefined : i; 985 } 986 } 987 } else if (util.has(map[i], str)) { 988 return (i === UNKNOWN) ? undefined : i; 1411 989 } 1412 }); 1413 } else if (self.extensions[mime]) { 1414 [].push.apply(exts, self.extensions[mime]); 990 } 991 return str; 1415 992 } 1416 } 1417 }); 1418 return exts; 1419 }, 993 }; 1420 994 1421 995 1422 mimes2extList: function(mimes) { 1423 var accept = [], exts = []; 996 /////////////// 997 // String map 998 ////////////// 1424 999 1425 if (Basic.typeOf(mimes) === 'string') {1426 mimes = Basic.trim(mimes).split(/\s*,\s*/);1427 }1428 1000 1429 exts = this.mimes2exts(mimes); 1430 1431 accept.push({ 1432 title: I18n.translate('Files'), 1433 extensions: exts.length ? exts.join(',') : '*' 1434 }); 1435 1436 // save original mimes string 1437 accept.mimes = mimes; 1001 var maps = { 1002 1003 browser : { 1004 oldsafari : { 1005 major : { 1006 '1' : ['/8', '/1', '/3'], 1007 '2' : '/4', 1008 '?' : '/' 1009 }, 1010 version : { 1011 '1.0' : '/8', 1012 '1.2' : '/1', 1013 '1.3' : '/3', 1014 '2.0' : '/412', 1015 '2.0.2' : '/416', 1016 '2.0.3' : '/417', 1017 '2.0.4' : '/419', 1018 '?' : '/' 1019 } 1020 } 1021 }, 1438 1022 1439 return accept; 1440 }, 1023 device : { 1024 sprint : { 1025 model : { 1026 'Evo Shift 4G' : '7373KT' 1027 }, 1028 vendor : { 1029 'HTC' : 'APA', 1030 'Sprint' : 'Sprint' 1031 } 1032 } 1033 }, 1441 1034 1035 os : { 1036 windows : { 1037 version : { 1038 'ME' : '4.90', 1039 'NT 3.11' : 'NT3.51', 1040 'NT 4.0' : 'NT4.0', 1041 '2000' : 'NT 5.0', 1042 'XP' : ['NT 5.1', 'NT 5.2'], 1043 'Vista' : 'NT 6.0', 1044 '7' : 'NT 6.1', 1045 '8' : 'NT 6.2', 1046 '8.1' : 'NT 6.3', 1047 'RT' : 'ARM' 1048 } 1049 } 1050 } 1051 }; 1442 1052 1443 getFileExtension: function(fileName) {1444 var matches = fileName && fileName.match(/\.([^.]+)$/);1445 if (matches) {1446 return matches[1].toLowerCase();1447 }1448 return '';1449 },1450 1053 1451 getFileMime: function(fileName) { 1452 return this.mimes[this.getFileExtension(fileName)] || ''; 1453 } 1454 }; 1054 ////////////// 1055 // Regex map 1056 ///////////// 1057 1058 1059 var regexes = { 1060 1061 browser : [[ 1062 1063 // Presto based 1064 /(opera\smini)\/([\w\.-]+)/i, // Opera Mini 1065 /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet 1066 /(opera).+version\/([\w\.]+)/i, // Opera > 9.80 1067 /(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80 1068 1069 ], [NAME, VERSION], [ 1070 1071 /\s(opr)\/([\w\.]+)/i // Opera Webkit 1072 ], [[NAME, 'Opera'], VERSION], [ 1073 1074 // Mixed 1075 /(kindle)\/([\w\.]+)/i, // Kindle 1076 /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]+)*/i, 1077 // Lunascape/Maxthon/Netfront/Jasmine/Blazer 1078 1079 // Trident based 1080 /(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i, 1081 // Avant/IEMobile/SlimBrowser/Baidu 1082 /(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer 1083 1084 // Webkit/KHTML based 1085 /(rekonq)\/([\w\.]+)*/i, // Rekonq 1086 /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi)\/([\w\.-]+)/i 1087 // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron 1088 ], [NAME, VERSION], [ 1089 1090 /(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11 1091 ], [[NAME, 'IE'], VERSION], [ 1092 1093 /(edge)\/((\d+)?[\w\.]+)/i // Microsoft Edge 1094 ], [NAME, VERSION], [ 1095 1096 /(yabrowser)\/([\w\.]+)/i // Yandex 1097 ], [[NAME, 'Yandex'], VERSION], [ 1098 1099 /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon 1100 ], [[NAME, /_/g, ' '], VERSION], [ 1101 1102 /(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i, 1103 // Chrome/OmniWeb/Arora/Tizen/Nokia 1104 /(uc\s?browser|qqbrowser)[\/\s]?([\w\.]+)/i 1105 // UCBrowser/QQBrowser 1106 ], [NAME, VERSION], [ 1107 1108 /(dolfin)\/([\w\.]+)/i // Dolphin 1109 ], [[NAME, 'Dolphin'], VERSION], [ 1110 1111 /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS 1112 ], [[NAME, 'Chrome'], VERSION], [ 1113 1114 /XiaoMi\/MiuiBrowser\/([\w\.]+)/i // MIUI Browser 1115 ], [VERSION, [NAME, 'MIUI Browser']], [ 1116 1117 /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)/i // Android Browser 1118 ], [VERSION, [NAME, 'Android Browser']], [ 1119 1120 /FBAV\/([\w\.]+);/i // Facebook App for iOS 1121 ], [VERSION, [NAME, 'Facebook']], [ 1122 1123 /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari 1124 ], [VERSION, [NAME, 'Mobile Safari']], [ 1125 1126 /version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile 1127 ], [VERSION, NAME], [ 1128 1129 /webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0 1130 ], [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]], [ 1131 1132 /(konqueror)\/([\w\.]+)/i, // Konqueror 1133 /(webkit|khtml)\/([\w\.]+)/i 1134 ], [NAME, VERSION], [ 1135 1136 // Gecko based 1137 /(navigator|netscape)\/([\w\.-]+)/i // Netscape 1138 ], [[NAME, 'Netscape'], VERSION], [ 1139 /(swiftfox)/i, // Swiftfox 1140 /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i, 1141 // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror 1142 /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/([\w\.-]+)/i, 1143 // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix 1144 /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla 1145 1146 // Other 1147 /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?([\w\.]+)/i, 1148 // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf 1149 /(links)\s\(([\w\.]+)/i, // Links 1150 /(gobrowser)\/?([\w\.]+)*/i, // GoBrowser 1151 /(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser 1152 /(mosaic)[\/\s]([\w\.]+)/i // Mosaic 1153 ], [NAME, VERSION] 1154 ], 1155 1156 engine : [[ 1157 1158 /windows.+\sedge\/([\w\.]+)/i // EdgeHTML 1159 ], [VERSION, [NAME, 'EdgeHTML']], [ 1160 1161 /(presto)\/([\w\.]+)/i, // Presto 1162 /(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m 1163 /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links 1164 /(icab)[\/\s]([23]\.[\d\.]+)/i // iCab 1165 ], [NAME, VERSION], [ 1166 1167 /rv\:([\w\.]+).*(gecko)/i // Gecko 1168 ], [VERSION, NAME] 1169 ], 1170 1171 os : [[ 1172 1173 // Windows based 1174 /microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes) 1175 ], [NAME, VERSION], [ 1176 /(windows)\snt\s6\.2;\s(arm)/i, // Windows RT 1177 /(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i 1178 ], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [ 1179 /(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i 1180 ], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [ 1181 1182 // Mobile/Embedded OS 1183 /\((bb)(10);/i // BlackBerry 10 1184 ], [[NAME, 'BlackBerry'], VERSION], [ 1185 /(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry 1186 /(tizen)[\/\s]([\w\.]+)/i, // Tizen 1187 /(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i, 1188 // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki 1189 /linux;.+(sailfish);/i // Sailfish OS 1190 ], [NAME, VERSION], [ 1191 /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian 1192 ], [[NAME, 'Symbian'], VERSION], [ 1193 /\((series40);/i // Series 40 1194 ], [NAME], [ 1195 /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS 1196 ], [[NAME, 'Firefox OS'], VERSION], [ 1197 1198 // Console 1199 /(nintendo|playstation)\s([wids3portablevu]+)/i, // Nintendo/Playstation 1200 1201 // GNU/Linux based 1202 /(mint)[\/\s\(]?(\w+)*/i, // Mint 1203 /(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux 1204 /(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?([\w\.-]+)*/i, 1205 // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware 1206 // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus 1207 /(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux 1208 /(gnu)\s?([\w\.]+)*/i // GNU 1209 ], [NAME, VERSION], [ 1210 1211 /(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS 1212 ], [[NAME, 'Chromium OS'], VERSION],[ 1213 1214 // Solaris 1215 /(sunos)\s?([\w\.]+\d)*/i // Solaris 1216 ], [[NAME, 'Solaris'], VERSION], [ 1217 1218 // BSD based 1219 /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly 1220 ], [NAME, VERSION],[ 1221 1222 /(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS 1223 ], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [ 1224 1225 /(mac\sos\sx)\s?([\w\s\.]+\w)*/i, 1226 /(macintosh|mac(?=_powerpc)\s)/i // Mac OS 1227 ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [ 1228 1229 // Other 1230 /((?:open)?solaris)[\/\s-]?([\w\.]+)*/i, // Solaris 1231 /(haiku)\s(\w+)/i, // Haiku 1232 /(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX 1233 /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i, 1234 // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS 1235 /(unix)\s?([\w\.]+)*/i // UNIX 1236 ], [NAME, VERSION] 1237 ] 1238 }; 1455 1239 1456 Mime.addMimeType(mimeData);1457 1240 1458 return Mime; 1459 }); 1241 ///////////////// 1242 // Constructor 1243 //////////////// 1460 1244 1461 // Included from: src/javascript/core/utils/Dom.js1462 1245 1463 /** 1464 * Dom.js 1465 * 1466 * Copyright 2013, Moxiecode Systems AB 1467 * Released under GPL License. 1468 * 1469 * License: http://www.plupload.com/license 1470 * Contributing: http://www.plupload.com/contributing 1471 */ 1246 var UAParser = function (uastring) { 1472 1247 1473 define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) { 1248 var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY); 1474 1249 1475 /** 1476 Get DOM Element by it's id. 1250 this.getBrowser = function () { 1251 return mapper.rgx.apply(this, regexes.browser); 1252 }; 1253 this.getEngine = function () { 1254 return mapper.rgx.apply(this, regexes.engine); 1255 }; 1256 this.getOS = function () { 1257 return mapper.rgx.apply(this, regexes.os); 1258 }; 1259 this.getResult = function() { 1260 return { 1261 ua : this.getUA(), 1262 browser : this.getBrowser(), 1263 engine : this.getEngine(), 1264 os : this.getOS() 1265 }; 1266 }; 1267 this.getUA = function () { 1268 return ua; 1269 }; 1270 this.setUA = function (uastring) { 1271 ua = uastring; 1272 return this; 1273 }; 1274 this.setUA(ua); 1275 }; 1477 1276 1478 @method get 1479 @for Utils 1480 @param {String} id Identifier of the DOM Element 1481 @return {DOMElement} 1482 */ 1483 var get = function(id) { 1484 if (typeof id !== 'string') { 1485 return id; 1486 } 1487 return document.getElementById(id); 1488 }; 1277 return UAParser; 1278 })(); 1489 1279 1490 /**1491 Checks if specified DOM element has specified class.1492 1280 1493 @method hasClass 1494 @static 1495 @param {Object} obj DOM element like object to add handler to. 1496 @param {String} name Class name 1497 */ 1498 var hasClass = function(obj, name) { 1499 if (!obj.className) { 1500 return false; 1501 } 1281 function version_compare(v1, v2, operator) { 1282 // From: http://phpjs.org/functions 1283 // + original by: Philippe Jausions (http://pear.php.net/user/jausions) 1284 // + original by: Aidan Lister (http://aidanlister.com/) 1285 // + reimplemented by: Kankrelune (http://www.webfaktory.info/) 1286 // + improved by: Brett Zamir (http://brett-zamir.me) 1287 // + improved by: Scott Baker 1288 // + improved by: Theriault 1289 // * example 1: version_compare('8.2.5rc', '8.2.5a'); 1290 // * returns 1: 1 1291 // * example 2: version_compare('8.2.50', '8.2.52', '<'); 1292 // * returns 2: true 1293 // * example 3: version_compare('5.3.0-dev', '5.3.0'); 1294 // * returns 3: -1 1295 // * example 4: version_compare('4.1.0.52','4.01.0.51'); 1296 // * returns 4: 1 1297 1298 // Important: compare must be initialized at 0. 1299 var i = 0, 1300 x = 0, 1301 compare = 0, 1302 // vm maps textual PHP versions to negatives so they're less than 0. 1303 // PHP currently defines these as CASE-SENSITIVE. It is important to 1304 // leave these as negatives so that they can come before numerical versions 1305 // and as if no letters were there to begin with. 1306 // (1alpha is < 1 and < 1.1 but > 1dev1) 1307 // If a non-numerical value can't be mapped to this table, it receives 1308 // -7 as its value. 1309 vm = { 1310 'dev': -6, 1311 'alpha': -5, 1312 'a': -5, 1313 'beta': -4, 1314 'b': -4, 1315 'RC': -3, 1316 'rc': -3, 1317 '#': -2, 1318 'p': 1, 1319 'pl': 1 1320 }, 1321 // This function will be called to prepare each version argument. 1322 // It replaces every _, -, and + with a dot. 1323 // It surrounds any nonsequence of numbers/dots with dots. 1324 // It replaces sequences of dots with a single dot. 1325 // version_compare('4..0', '4.0') == 0 1326 // Important: A string of 0 length needs to be converted into a value 1327 // even less than an unexisting value in vm (-7), hence [-8]. 1328 // It's also important to not strip spaces because of this. 1329 // version_compare('', ' ') == 1 1330 prepVersion = function (v) { 1331 v = ('' + v).replace(/[_\-+]/g, '.'); 1332 v = v.replace(/([^.\d]+)/g, '.$1.').replace(/\.{2,}/g, '.'); 1333 return (!v.length ? [-8] : v.split('.')); 1334 }, 1335 // This converts a version component to a number. 1336 // Empty component becomes 0. 1337 // Non-numerical component becomes a negative number. 1338 // Numerical component becomes itself as an integer. 1339 numVersion = function (v) { 1340 return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10)); 1341 }; 1502 1342 1503 var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)"); 1504 return regExp.test(obj.className); 1505 }; 1343 v1 = prepVersion(v1); 1344 v2 = prepVersion(v2); 1345 x = Math.max(v1.length, v2.length); 1346 for (i = 0; i < x; i++) { 1347 if (v1[i] == v2[i]) { 1348 continue; 1349 } 1350 v1[i] = numVersion(v1[i]); 1351 v2[i] = numVersion(v2[i]); 1352 if (v1[i] < v2[i]) { 1353 compare = -1; 1354 break; 1355 } else if (v1[i] > v2[i]) { 1356 compare = 1; 1357 break; 1358 } 1359 } 1360 if (!operator) { 1361 return compare; 1362 } 1506 1363 1507 /** 1508 Adds specified className to specified DOM element. 1364 // Important: operator is CASE-SENSITIVE. 1365 // "No operator" seems to be treated as "<." 1366 // Any other values seem to make the function return null. 1367 switch (operator) { 1368 case '>': 1369 case 'gt': 1370 return (compare > 0); 1371 case '>=': 1372 case 'ge': 1373 return (compare >= 0); 1374 case '<=': 1375 case 'le': 1376 return (compare <= 0); 1377 case '==': 1378 case '=': 1379 case 'eq': 1380 return (compare === 0); 1381 case '<>': 1382 case '!=': 1383 case 'ne': 1384 return (compare !== 0); 1385 case '': 1386 case '<': 1387 case 'lt': 1388 return (compare < 0); 1389 default: 1390 return null; 1391 } 1392 } 1509 1393 1510 @method addClass1511 @static1512 @param {Object} obj DOM element like object to add handler to.1513 @param {String} name Class name1514 */1515 var addClass = function(obj, name) {1516 if (!hasClass(obj, name)) {1517 obj.className = !obj.className ? name : obj.className.replace(/\s+$/, '') + ' ' + name;1518 }1519 };1520 1394 1521 /** 1522 Removes specified className from specified DOM element. 1395 var can = (function() { 1396 var caps = { 1397 access_global_ns: function () { 1398 return !!window.moxie; 1399 }, 1400 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 }); 1410 return true; 1411 } 1412 } catch(ex) {} 1523 1413 1524 @method removeClass 1525 @static 1526 @param {Object} obj DOM element like object to add handler to. 1527 @param {String} name Class name 1528 */ 1529 var removeClass = function(obj, name) { 1530 if (obj.className) { 1531 var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)"); 1532 obj.className = obj.className.replace(regExp, function($0, $1, $2) { 1533 return $1 === ' ' && $2 === ' ' ? ' ' : ''; 1534 }); 1535 } 1536 }; 1414 if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { 1415 return true; 1416 }*/ 1417 return false; 1418 }()), 1537 1419 1538 /** 1539 Returns a given computed style of a DOM element. 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 }, 1540 1429 1541 @method getStyle 1542 @static 1543 @param {Object} obj DOM element like object. 1544 @param {String} name Style you want to get from the DOM element 1545 */ 1546 var getStyle = function(obj, name) { 1547 if (obj.currentStyle) { 1548 return obj.currentStyle[name]; 1549 } else if (window.getComputedStyle) { 1550 return window.getComputedStyle(obj, null)[name]; 1551 } 1552 }; 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 } 1443 return true; 1444 } 1445 } 1446 } catch (ex) {} 1447 return false; 1448 }, 1553 1449 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 }, 1459 1460 // ideas for this heavily come from Modernizr (http://modernizr.com/) 1461 use_data_uri: (function() { 1462 var du = new Image(); 1463 1464 du.onload = function() { 1465 caps.use_data_uri = (du.width === 1 && du.height === 1); 1466 }; 1554 1467 1555 /** 1556 Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields. 1468 setTimeout(function() { 1469 du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="; 1470 }, 1); 1471 return false; 1472 }()), 1557 1473 1558 @method getPos 1559 @static 1560 @param {Element} node HTML element or element id to get x, y position from. 1561 @param {Element} root Optional root element to stop calculations at. 1562 @return {object} Absolute position of the specified element object with x, y fields. 1563 */ 1564 var getPos = function(node, root) { 1565 var x = 0, y = 0, parent, doc = document, nodeRect, rootRect; 1566 1567 node = node; 1568 root = root || doc.body; 1569 1570 // Returns the x, y cordinate for an element on IE 6 and IE 7 1571 function getIEPos(node) { 1572 var bodyElm, rect, x = 0, y = 0; 1573 1574 if (node) { 1575 rect = node.getBoundingClientRect(); 1576 bodyElm = doc.compatMode === "CSS1Compat" ? doc.documentElement : doc.body; 1577 x = rect.left + bodyElm.scrollLeft; 1578 y = rect.top + bodyElm.scrollTop; 1579 } 1474 use_data_uri_over32kb: function() { // IE8 1475 return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9); 1476 }, 1477 1478 use_data_uri_of: function(bytes) { 1479 return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb()); 1480 }, 1580 1481 1581 return { 1582 x : x, 1583 y : y 1584 }; 1585 } 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; 1485 } 1586 1486 1587 // Use getBoundingClientRect on IE 6 and IE 7 but not on IE 8 in standards mode 1588 if (node && node.getBoundingClientRect && Env.browser === 'IE' && (!doc.documentMode || doc.documentMode < 8)) { 1589 nodeRect = getIEPos(node); 1590 rootRect = getIEPos(root); 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) {} 1591 1499 1592 return { 1593 x : nodeRect.x - rootRect.x, 1594 y : nodeRect.y - rootRect.y 1595 }; 1596 } 1500 if (!gl) { // it seems that sometimes it doesn't throw exception, but still fails to get context 1501 gl = null; 1502 } 1597 1503 1598 parent = node;1599 while (parent && parent != root && parent.nodeType) {1600 x += parent.offsetLeft || 0;1601 y += parent.offsetTop || 0;1602 parent = parent.offsetParent;1603 }1504 isSupported = !!gl; 1505 caps.use_webgl = isSupported; // save result of our check 1506 canvas = undefined; 1507 return isSupported; 1508 } 1509 }; 1604 1510 1605 parent = node.parentNode;1606 while (parent && parent != root && parent.nodeType) {1607 x -= parent.scrollLeft || 0;1608 y -= parent.scrollTop || 0;1609 parent = parent.parentNode;1610 }1511 return function(cap) { 1512 var args = [].slice.call(arguments); 1513 args.shift(); // shift of cap 1514 return Basic.typeOf(caps[cap]) === 'function' ? caps[cap].apply(this, args) : !!caps[cap]; 1515 }; 1516 }()); 1611 1517 1612 return {1613 x : x,1614 y : y1615 };1616 };1617 1518 1618 /** 1619 Returns the size of the specified node in pixels. 1519 var uaResult = new UAParser().getResult(); 1620 1520 1621 @method getSize1622 @static1623 @param {Node} node Node to get the size of.1624 @return {Object} Object with a w and h property.1625 */1626 var getSize = function(node) {1627 return {1628 w : node.offsetWidth || node.clientWidth,1629 h : node.offsetHeight || node.clientHeight1630 };1631 };1632 1521 1633 return { 1634 get: get, 1635 hasClass: hasClass, 1636 addClass: addClass, 1637 removeClass: removeClass, 1638 getStyle: getStyle, 1639 getPos: getPos, 1640 getSize: getSize 1641 }; 1642 }); 1522 var Env = { 1523 can: can, 1643 1524 1644 // Included from: src/javascript/core/Exceptions.js 1525 uaParser: UAParser, 1645 1526 1646 /** 1647 * Exceptions.js 1648 * 1649 * Copyright 2013, Moxiecode Systems AB 1650 * Released under GPL License. 1651 * 1652 * License: http://www.plupload.com/license 1653 * Contributing: http://www.plupload.com/contributing 1654 */ 1527 browser: uaResult.browser.name, 1528 version: uaResult.browser.version, 1529 os: uaResult.os.name, // everybody intuitively types it in a lowercase for some reason 1530 osVersion: uaResult.os.version, 1655 1531 1656 define('moxie/core/Exceptions', [ 1657 '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; 1667 } 1532 verComp: version_compare, 1668 1533 1669 return { 1670 RuntimeError: (function() { 1671 var namecodes = { 1672 NOT_INIT_ERR: 1, 1673 NOT_SUPPORTED_ERR: 9, 1674 JS_ERR: 4 1675 }; 1676 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 }()), 1703 1704 ImageError: (function() { 1705 var namecodes = { 1706 WRONG_FORMAT: 1, 1707 MAX_RESOLUTION_ERR: 2, 1708 INVALID_META_ERR: 3 1709 }; 1710 1711 function ImageError(code) { 1712 this.code = code; 1713 this.name = _findKey(namecodes, code); 1714 this.message = this.name + ": ImageError " + this.code; 1715 } 1716 1717 Basic.extend(ImageError, namecodes); 1718 ImageError.prototype = Error.prototype; 1719 1720 return ImageError; 1721 }()), 1722 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 }; 1734 1735 function FileException(code) { 1736 this.code = code; 1737 this.name = _findKey(namecodes, code); 1738 this.message = this.name + ": FileException " + this.code; 1739 } 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 }; 1774 1775 function DOMException(code) { 1776 this.code = code; 1777 this.name = _findKey(namecodes, code); 1778 this.message = this.name + ": DOMException " + this.code; 1779 } 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 }); 1534 swf_url: "../flash/Moxie.swf", 1535 xap_url: "../silverlight/Moxie.xap", 1536 global_event_dispatcher: "moxie.core.EventTarget.instance.dispatchEvent" 1537 }; 1802 1538 1803 // Included from: src/javascript/core/EventTarget.js 1539 // for backward compatibility 1540 // @deprecated Use `Env.os` instead 1541 Env.OS = Env.os; 1542 1543 if (MXI_DEBUG) { 1544 Env.debug = { 1545 runtime: true, 1546 events: false 1547 }; 1804 1548 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 */ 1549 Env.log = function() { 1814 1550 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 1551 function logObj(data) { 1552 // TODO: this should recursively print out the object in a pretty way 1553 console.appendChild(document.createTextNode(data + "\n")); 1554 } 1555 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); 1559 } else if (document) { 1560 var console = document.getElementById('moxie-console'); 1561 if (!console) { 1562 console = document.createElement('pre'); 1563 console.id = 'moxie-console'; 1564 //console.style.display = 'none'; 1565 document.body.appendChild(console); 1566 } 1822 1567 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 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) { 1572 logObj(data); 1573 return; 1574 } 1834 1575 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 1576 console.appendChild(document.createTextNode(data + "\n")); 1577 } 1578 }; 1579 } 1842 1580 1843 @method init 1844 */ 1845 init: function() { 1846 if (!this.uid) { 1847 this.uid = Basic.guid('uid_'); 1848 } 1849 }, 1581 return Env; 1582 }); 1850 1583 1851 /** 1852 Register a handler to a specific event dispatched by the object 1584 // Included from: src/javascript/core/Exceptions.js 1853 1585 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; 1862 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 1586 /** 1587 * Exceptions.js 1588 * 1589 * Copyright 2013, Moxiecode Systems AB 1590 * Released under GPL License. 1591 * 1592 * License: http://www.plupload.com/license 1593 * Contributing: http://www.plupload.com/contributing 1594 */ 1892 1595 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 1596 define('moxie/core/Exceptions', [ 1597 'moxie/core/utils/Basic' 1598 ], function(Basic) { 1904 1599 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 } 1921 } 1922 } else { 1923 list = []; 1924 } 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 } 1600 function _findKey(obj, value) { 1601 var key; 1602 for (key in obj) { 1603 if (obj[key] === value) { 1604 return key; 1934 1605 } 1935 1606 } 1936 }, 1937 1938 /** 1939 Remove all event handlers from the object 1607 return null; 1608 } 1940 1609 1941 @method removeAllEventListeners1942 */1943 removeAllEventListeners: function() {1944 if (eventpool[this.uid]) {1945 delete eventpool[this.uid];1946 }1947 },1948 1949 1610 /** 1950 Dispatch the event 1611 @class moxie/core/Exception 1612 */ 1613 return { 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 }; 1951 1621 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; 1963 1964 if (Basic.typeOf(tmpEvt.type) === 'string') { 1965 type = tmpEvt.type; 1966 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); 1622 function RuntimeError(code, message) { 1623 this.code = code; 1624 this.name = _findKey(namecodes, code); 1625 this.message = this.name + (message || ": RuntimeError " + this.code); 1974 1626 } 1975 }1976 1977 // check if event is meant to be dispatched on an object having specific uid1978 if (type.indexOf('::') !== -1) {1979 (function(arr) {1980 uid = arr[0];1981 &