Ticket #48277: 48277.diff
File 48277.diff, 372.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 6 Everyone is permitted to copy and distribute verbatim copies 7 of this license document, but changing it is not allowed. 4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> 5 Everyone is permitted to copy and distribute verbatim copies 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 your 12 freedom to share and change it. By contrast, the GNU General Public 13 License is intended to guarantee your freedom to share and change free 14 software--to make sure the software is free for all its users. This 15 General Public License applies to most of the Free Software 16 Foundation's software and to any other program whose authors commit to 17 using it. (Some other Free Software Foundation software is covered by 18 the GNU Lesser General Public License instead.) You can apply it to 19 your programs, too. 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. 20 13 21 When we speak of free software, we are referring to freedom, not 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. 19 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 th is service if you wish), that you receive source code or can get it25 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.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. 27 26 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.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. 32 31 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. 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. 38 41 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 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. 42 49 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. 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. 49 55 50 Finally, any free program is threatened constantly by software 51 patents. We wish to avoid the danger that redistributors of a free 52 program will individually obtain patent licenses, in effect making the 53 program proprietary. To prevent this, we have made it clear that any 54 patent must be licensed for everyone's free use or not licensed at all. 55 56 The precise terms and conditions for copying, distribution and 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". 61 0. Definitions. 71 62 72 Activities other than copying, distribution and modification are not 73 covered by this License; they are outside its scope. The act of 74 running the Program is not restricted, and the output from the Program 75 is covered only if its contents constitute a work based on the 76 Program (independent of having been made by running the Program). 77 Whether that is true depends on what the Program does. 63 "This License" refers to version 3 of the GNU Affero General Public License. 78 64 79 1. You may copy and distribute verbatim copies of the Program's 80 source code as you receive it, in any medium, provided that you 81 conspicuously and appropriately publish on each copy an appropriate 82 copyright notice and disclaimer of warranty; keep intact all the 83 notices that refer to this License and to the absence of any warranty; 84 and give any other recipients of the Program a copy of this License 85 along with the Program. 65 "Copyright" also means copyright-like laws that apply to other kinds of 66 works, such as semiconductor masks. 86 67 87 You may charge a fee for the physical act of transferring a copy, and 88 you may at your option offer warranty protection in exchange for a fee. 68 "The Program" refers to any copyrightable work licensed under this 69 License. Each licensee is addressed as "you". "Licensees" and 70 "recipients" may be individuals or organizations. 89 71 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: 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. 94 76 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.77 A "covered work" means either the unmodified Program or a work based 78 on the Program. 97 79 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. 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. 102 86 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.) 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. 113 90 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. 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. 123 99 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. 100 1. Source Code. 128 101 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. 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. 133 105 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: 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. 137 110 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, 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. 141 121 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, 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. 148 134 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.) 135 The Corresponding Source need not include anything that users 136 can regenerate automatically from other parts of the Corresponding 137 Source. 154 138 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. 139 The Corresponding Source for a work in source code form is that 140 same work. 165 141 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. 142 2. Basic Permissions. 171 143 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.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. 179 151 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. 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. 188 162 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 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. 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. 209 539 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. 540 13. Remote Network Interaction; Use with the GNU General Public License. 214 541 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 made220 generous contributions to the wide range of software distributed 221 through that system in reliance on consistent application of that 222 s ystem; it is up to the author/donor to decide if he or she is willing223 to distribute software through any other system and a licensee cannot 224 impose that choice.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. 225 552 226 This section is intended to make thoroughly clear what is believed to 227 be a consequence of the rest of this License. 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. 228 560 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. 561 14. Revised Versions of this License. 236 562 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 to563 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. 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. 249 576 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. 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. 257 581 258 NO WARRANTY 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. 259 586 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. 587 15. Disclaimer of Warranty. 269 588 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. 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. 279 597 280 END OF TERMS AND CONDITIONS 598 16. Limitation of Liability. 281 599 282 How to Apply These Terms to Your New Programs 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. 283 609 284 If you develop a new program, and you want it to be of the greatest 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. 618 619 END OF TERMS AND CONDITIONS 620 621 How to Apply These Terms to Your New Programs 622 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 286 625 free software which everyone can redistribute and change under these terms. 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 294 632 <one line to give the program's name and a brief idea of what it does.> 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 GNUGeneral Public License as published by298 the Free Software Foundation; either version 2of the License, or299 635 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 638 (at your option) any later version. 300 639 301 302 303 304 GNUGeneral Public License for more details.640 This program is distributed in the hope that it will be useful, 641 but WITHOUT ANY WARRANTY; without even the implied warranty of 642 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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: 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. 314 657 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. 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.7 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: 201 6-05-1512 * Date: 2017-11-03 13 13 */ 14 ;(function (global, factory) { 15 var extract = function() { 16 var ctx = {}; 17 factory.apply(ctx, arguments); 18 return ctx.moxie; 19 }; 20 21 if (typeof define === "function" && define.amd) { 22 define("moxie", [], extract); 23 } else if (typeof module === "object" && module.exports) { 24 module.exports = extract(); 25 } else { 26 global.moxie = extract(); 27 } 28 }(this || window, function() { 14 29 /** 15 30 * Compiled inline version. (Library mode) 16 31 */ 17 32 18 /**19 * Modified for WordPress, Silverlight and Flash runtimes support was removed.20 * See https://core.trac.wordpress.org/ticket/41755.21 */22 23 33 /*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */ 24 34 /*globals $code */ 25 35 … … 110 120 * Contributing: http://www.plupload.com/contributing 111 121 */ 112 122 123 /** 124 @class moxie/core/utils/Basic 125 @public 126 @static 127 */ 128 113 129 define('moxie/core/utils/Basic', [], function() { 114 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 138 */ 124 var typeOf = function(o) {139 function typeOf(o) { 125 140 var undef; 126 141 127 142 if (o === undef) { … … 134 149 135 150 // the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8 136 151 return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); 137 } ;138 152 } 153 139 154 /** 140 Extends the specified object with another object .155 Extends the specified object with another object(s). 141 156 142 157 @method extend 143 158 @static … … 145 160 @param {Object} [obj]* Multiple objects to extend with. 146 161 @return {Object} Same as target, the extended object. 147 162 */ 148 var extend = function(target) { 163 function extend() { 164 return merge(false, false, arguments); 165 } 166 167 168 /** 169 Extends the specified object with another object(s), but only if the property exists in the target. 170 171 @method extendIf 172 @static 173 @param {Object} target Object to extend. 174 @param {Object} [obj]* Multiple objects to extend with. 175 @return {Object} Same as target, the extended object. 176 */ 177 function extendIf() { 178 return merge(true, false, arguments); 179 } 180 181 182 function extendImmutable() { 183 return merge(false, true, arguments); 184 } 185 186 187 function extendImmutableIf() { 188 return merge(true, true, arguments); 189 } 190 191 192 function clone(value) { 193 switch (typeOf(value)) { 194 case 'array': 195 return merge(false, true, [[], value]); 196 197 case 'object': 198 return merge(false, true, [{}, value]); 199 200 default: 201 return value; 202 } 203 } 204 205 206 function shallowCopy(obj) { 207 switch (typeOf(obj)) { 208 case 'array': 209 return Array.prototype.slice.call(obj); 210 211 case 'object': 212 return extend({}, obj); 213 } 214 return obj; 215 } 216 217 218 function merge(strict, immutable, args) { 149 219 var undef; 220 var target = args[0]; 150 221 151 each(arg uments, function(arg, i) {222 each(args, function(arg, i) { 152 223 if (i > 0) { 153 224 each(arg, function(value, key) { 154 if (value !== undef) { 155 if (typeOf(target[key]) === typeOf(value) && !!~inArray(typeOf(value), ['array', 'object'])) { 156 extend(target[key], value); 157 } else { 158 target[key] = value; 159 } 225 var isComplex = inArray(typeOf(value), ['array', 'object']) !== -1; 226 227 if (value === undef || strict && target[key] === undef) { 228 return true; 160 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 } 161 240 }); 162 241 } 163 242 }); 243 164 244 return target; 165 }; 166 245 } 246 247 167 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 … … 173 294 @param {Object} obj Object to iterate. 174 295 @param {function} callback Callback function to execute for each item. 175 296 */ 176 var each = function(obj, callback) {297 function each(obj, callback) { 177 298 var length, key, i, undef; 178 299 179 300 if (obj) { 180 if (typeOf(obj.length) === 'number') { // it might be Array, FileList or even arguments object 181 // Loop array items 182 for (i = 0, length = obj.length; i < length; i++) { 183 if (callback(obj[i], i) === false) { 184 return; 185 } 186 } 187 } else if (typeOf(obj) === 'object') { 301 try { 302 length = obj.length; 303 } catch(ex) { 304 length = undef; 305 } 306 307 if (length === undef || typeof(length) !== 'number') { 188 308 // Loop object items 189 309 for (key in obj) { 190 310 if (obj.hasOwnProperty(key)) { … … 193 313 } 194 314 } 195 315 } 316 } else { 317 // Loop array items 318 for (i = 0; i < length; i++) { 319 if (callback(obj[i], i) === false) { 320 return; 321 } 322 } 196 323 } 197 324 } 198 } ;325 } 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 334 */ 208 var isEmptyObj = function(obj) {335 function isEmptyObj(obj) { 209 336 var prop; 210 337 211 338 if (!obj || typeOf(obj) !== 'object') { … … 217 344 } 218 345 219 346 return true; 220 } ;347 } 221 348 222 349 /** 223 350 Recieve an array of functions (usually async) to call in sequence, each function … … 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 360 */ 234 var inSeries = function(queue, cb) {361 function inSeries(queue, cb) { 235 362 var i = 0, length = queue.length; 236 363 237 364 if (typeOf(cb) !== 'function') { … … 251 378 } 252 379 } 253 380 callNext(i); 254 } ;381 } 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 r394 @param {Function} cb Main callback that is called in the end, or in case of erro 268 395 */ 269 var inParallel = function(queue, cb) {396 function inParallel(queue, cb) { 270 397 var count = 0, num = queue.length, cbArgs = new Array(num); 271 398 272 399 each(queue, function(fn, i) { … … 274 401 if (error) { 275 402 return cb(error); 276 403 } 277 404 278 405 var args = [].slice.call(arguments); 279 406 args.shift(); // strip error - undefined or not 280 407 … … 284 411 if (count === num) { 285 412 cbArgs.unshift(null); 286 413 cb.apply(this, cbArgs); 287 } 414 } 288 415 }); 289 416 }); 290 } ;291 292 417 } 418 419 293 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 428 */ 302 var inArray = function(needle, array) {429 function inArray(needle, array) { 303 430 if (array) { 304 431 if (Array.prototype.indexOf) { 305 432 return Array.prototype.indexOf.call(array, needle); 306 433 } 307 434 308 435 for (var i = 0, length = array.length; i < length; i++) { 309 436 if (array[i] === needle) { 310 437 return i; … … 312 439 } 313 440 } 314 441 return -1; 315 } ;442 } 316 443 317 444 318 445 /** … … 324 451 @param {Array} array 325 452 @return {Array|Boolean} 326 453 */ 327 var arrayDiff = function(needles, array) {454 function arrayDiff(needles, array) { 328 455 var diff = []; 329 456 330 457 if (typeOf(needles) !== 'array') { … … 338 465 for (var i in needles) { 339 466 if (inArray(needles[i], array) === -1) { 340 467 diff.push(needles[i]); 341 } 468 } 342 469 } 343 470 return diff.length ? diff : false; 344 } ;471 } 345 472 346 473 347 474 /** … … 353 480 @param {Array} array2 354 481 @return {Array} Intersection of two arrays or null if there is none 355 482 */ 356 var arrayIntersect = function(array1, array2) {483 function arrayIntersect(array1, array2) { 357 484 var result = []; 358 485 each(array1, function(item) { 359 486 if (inArray(item, array2) !== -1) { … … 361 488 } 362 489 }); 363 490 return result.length ? result : null; 364 } ;365 366 491 } 492 493 367 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 501 */ 375 var toArray = function(obj) {502 function toArray(obj) { 376 503 var i, arr = []; 377 504 378 505 for (i = 0; i < obj.length; i++) { … … 380 507 } 381 508 382 509 return arr; 383 } ;384 385 510 } 511 512 386 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). … … 397 524 */ 398 525 var guid = (function() { 399 526 var counter = 0; 400 527 401 528 return function(prefix) { 402 529 var guid = new Date().getTime().toString(32), i; 403 530 … … 404 531 for (i = 0; i < 5; i++) { 405 532 guid += Math.floor(Math.random() * 65535).toString(32); 406 533 } 407 534 408 535 return (prefix || 'o_') + guid + (counter++).toString(32); 409 536 }; 410 537 }()); 411 412 538 539 413 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 547 */ 421 var trim = function(str) {548 function trim(str) { 422 549 if (!str) { 423 550 return str; 424 551 } 425 552 return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, ''); 426 } ;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 563 */ 437 var parseSizeStr = function(size) {564 function parseSizeStr(size) { 438 565 if (typeof(size) !== 'string') { 439 566 return size; 440 567 } 441 568 442 569 var muls = { 443 570 t: 1099511627776, 444 571 g: 1073741824, … … 447 574 }, 448 575 mul; 449 576 450 451 577 size = /^([0-9\.]+)([tmgk]?)$/.exec(size.toLowerCase().replace(/[^0-9\.tmkg]/g, '')); 452 578 mul = size[2]; 453 579 size = +size[1]; 454 580 455 581 if (muls.hasOwnProperty(mul)) { 456 582 size *= muls[mul]; 457 583 } 458 584 return Math.floor(size); 459 } ;585 } 460 586 461 587 462 588 /** … … 465 591 * @param {String} str String with tokens 466 592 * @return {String} String with replaced tokens 467 593 */ 468 var sprintf = function(str) {594 function sprintf(str) { 469 595 var args = [].slice.call(arguments, 1); 470 596 471 return str.replace(/% [a-z]/g, function() {597 return str.replace(/%([a-z])/g, function($0, $1) { 472 598 var value = args.shift(); 473 return typeOf(value) !== 'undefined' ? value : ''; 599 600 switch ($1) { 601 case 's': 602 return value + ''; 603 604 case 'd': 605 return parseInt(value, 10); 606 607 case 'f': 608 return parseFloat(value); 609 610 case 'c': 611 return ''; 612 613 default: 614 return value; 615 } 474 616 }); 475 }; 476 617 } 477 618 619 620 621 function delay(cb, timeout) { 622 var self = this; 623 setTimeout(function() { 624 cb.call(self); 625 }, timeout || 1); 626 } 627 628 478 629 return { 479 630 guid: guid, 480 631 typeOf: typeOf, 481 632 extend: extend, 633 extendIf: extendIf, 634 extendImmutable: extendImmutable, 635 extendImmutableIf: extendImmutableIf, 636 clone: clone, 637 inherit: inherit, 482 638 each: each, 483 639 isEmptyObj: isEmptyObj, 484 640 inSeries: inSeries, … … 489 645 toArray: toArray, 490 646 trim: trim, 491 647 sprintf: sprintf, 492 parseSizeStr: parseSizeStr 648 parseSizeStr: parseSizeStr, 649 delay: delay 493 650 }; 494 651 }); 495 652 653 // Included from: src/javascript/core/utils/Encode.js 654 655 /** 656 * Encode.js 657 * 658 * Copyright 2013, Moxiecode Systems AB 659 * Released under GPL License. 660 * 661 * License: http://www.plupload.com/license 662 * Contributing: http://www.plupload.com/contributing 663 */ 664 665 /** 666 @class moxie/core/utils/Encode 667 @public 668 @static 669 */ 670 671 define('moxie/core/utils/Encode', [], function() { 672 673 /** 674 Encode string with UTF-8 675 676 @method utf8_encode 677 @static 678 @param {String} str String to encode 679 @return {String} UTF-8 encoded string 680 */ 681 var utf8_encode = function(str) { 682 return unescape(encodeURIComponent(str)); 683 }; 684 685 /** 686 Decode UTF-8 encoded string 687 688 @method utf8_decode 689 @static 690 @param {String} str String to decode 691 @return {String} Decoded string 692 */ 693 var utf8_decode = function(str_data) { 694 return decodeURIComponent(escape(str_data)); 695 }; 696 697 /** 698 Decode Base64 encoded string (uses browser's default method if available), 699 from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js 700 701 @method atob 702 @static 703 @param {String} data String to decode 704 @return {String} Decoded string 705 */ 706 var atob = function(data, utf8) { 707 if (typeof(window.atob) === 'function') { 708 return utf8 ? utf8_decode(window.atob(data)) : window.atob(data); 709 } 710 711 // http://kevin.vanzonneveld.net 712 // + original by: Tyler Akins (http://rumkin.com) 713 // + improved by: Thunder.m 714 // + input by: Aman Gupta 715 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 716 // + bugfixed by: Onno Marsman 717 // + bugfixed by: Pellentesque Malesuada 718 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 719 // + input by: Brett Zamir (http://brett-zamir.me) 720 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 721 // * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA=='); 722 // * returns 1: 'Kevin van Zonneveld' 723 // mozilla has this native 724 // - but breaks in 2.0.0.12! 725 //if (typeof this.window.atob == 'function') { 726 // return atob(data); 727 //} 728 var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 729 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, 730 ac = 0, 731 dec = "", 732 tmp_arr = []; 733 734 if (!data) { 735 return data; 736 } 737 738 data += ''; 739 740 do { // unpack four hexets into three octets using index points in b64 741 h1 = b64.indexOf(data.charAt(i++)); 742 h2 = b64.indexOf(data.charAt(i++)); 743 h3 = b64.indexOf(data.charAt(i++)); 744 h4 = b64.indexOf(data.charAt(i++)); 745 746 bits = h1 << 18 | h2 << 12 | h3 << 6 | h4; 747 748 o1 = bits >> 16 & 0xff; 749 o2 = bits >> 8 & 0xff; 750 o3 = bits & 0xff; 751 752 if (h3 == 64) { 753 tmp_arr[ac++] = String.fromCharCode(o1); 754 } else if (h4 == 64) { 755 tmp_arr[ac++] = String.fromCharCode(o1, o2); 756 } else { 757 tmp_arr[ac++] = String.fromCharCode(o1, o2, o3); 758 } 759 } while (i < data.length); 760 761 dec = tmp_arr.join(''); 762 763 return utf8 ? utf8_decode(dec) : dec; 764 }; 765 766 /** 767 Base64 encode string (uses browser's default method if available), 768 from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js 769 770 @method btoa 771 @static 772 @param {String} data String to encode 773 @return {String} Base64 encoded string 774 */ 775 var btoa = function(data, utf8) { 776 if (utf8) { 777 data = utf8_encode(data); 778 } 779 780 if (typeof(window.btoa) === 'function') { 781 return window.btoa(data); 782 } 783 784 // http://kevin.vanzonneveld.net 785 // + original by: Tyler Akins (http://rumkin.com) 786 // + improved by: Bayron Guevara 787 // + improved by: Thunder.m 788 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 789 // + bugfixed by: Pellentesque Malesuada 790 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 791 // + improved by: Rafał Kukawski (http://kukawski.pl) 792 // * example 1: base64_encode('Kevin van Zonneveld'); 793 // * returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA==' 794 // mozilla has this native 795 // - but breaks in 2.0.0.12! 796 var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 797 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, 798 ac = 0, 799 enc = "", 800 tmp_arr = []; 801 802 if (!data) { 803 return data; 804 } 805 806 do { // pack three octets into four hexets 807 o1 = data.charCodeAt(i++); 808 o2 = data.charCodeAt(i++); 809 o3 = data.charCodeAt(i++); 810 811 bits = o1 << 16 | o2 << 8 | o3; 812 813 h1 = bits >> 18 & 0x3f; 814 h2 = bits >> 12 & 0x3f; 815 h3 = bits >> 6 & 0x3f; 816 h4 = bits & 0x3f; 817 818 // use hexets to index into b64, and append result to encoded string 819 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4); 820 } while (i < data.length); 821 822 enc = tmp_arr.join(''); 823 824 var r = data.length % 3; 825 826 return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3); 827 }; 828 829 830 return { 831 utf8_encode: utf8_encode, 832 utf8_decode: utf8_decode, 833 atob: atob, 834 btoa: btoa 835 }; 836 }); 837 496 838 // Included from: src/javascript/core/utils/Env.js 497 839 498 840 /** … … 505 847 * Contributing: http://www.plupload.com/contributing 506 848 */ 507 849 850 /** 851 @class moxie/core/utils/Env 852 @public 853 @static 854 */ 855 508 856 define("moxie/core/utils/Env", [ 509 857 "moxie/core/utils/Basic" 510 858 ], function(Basic) { 511 859 512 860 /** 513 861 * UAParser.js v0.7.7 514 862 * Lightweight JavaScript-based User-Agent string parser … … 711 1059 var regexes = { 712 1060 713 1061 browser : [[ 714 1062 715 1063 // Presto based 716 1064 /(opera\smini)\/([\w\.-]+)/i, // Opera Mini 717 1065 /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet … … 1046 1394 1047 1395 var can = (function() { 1048 1396 var caps = { 1049 define_property: (function() { 1050 /* // currently too much extra code required, not exactly worth it 1051 try { // as of IE8, getters/setters are supported only on DOM elements 1052 var obj = {}; 1053 if (Object.defineProperty) { 1054 Object.defineProperty(obj, 'prop', { 1055 enumerable: true, 1056 configurable: true 1057 }); 1058 return true; 1059 } 1060 } catch(ex) {} 1397 access_global_ns: function () { 1398 return !!window.moxie; 1399 }, 1061 1400 1062 if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { 1401 define_property: (function() { 1402 /* // currently too much extra code required, not exactly worth it 1403 try { // as of IE8, getters/setters are supported only on DOM elements 1404 var obj = {}; 1405 if (Object.defineProperty) { 1406 Object.defineProperty(obj, 'prop', { 1407 enumerable: true, 1408 configurable: true 1409 }); 1063 1410 return true; 1064 }*/ 1065 return false; 1066 }()), 1411 } 1412 } catch(ex) {} 1067 1413 1068 create_canvas: (function() { 1069 // On the S60 and BB Storm, getContext exists, but always returns undefined 1070 // so we actually have to call getContext() to verify 1071 // github.com/Modernizr/Modernizr/issues/issue/97/ 1072 var el = document.createElement('canvas'); 1073 return !!(el.getContext && el.getContext('2d')); 1074 }()), 1414 if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { 1415 return true; 1416 }*/ 1417 return false; 1418 }()), 1075 1419 1076 return_response_type: function(responseType) { 1077 try { 1078 if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) { 1420 create_canvas: function() { 1421 // On the S60 and BB Storm, getContext exists, but always returns undefined 1422 // so we actually have to call getContext() to verify 1423 // github.com/Modernizr/Modernizr/issues/issue/97/ 1424 var el = document.createElement('canvas'); 1425 var isSupported = !!(el.getContext && el.getContext('2d')); 1426 caps.create_canvas = isSupported; 1427 return isSupported; 1428 }, 1429 1430 return_response_type: function(responseType) { 1431 try { 1432 if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) { 1433 return true; 1434 } else if (window.XMLHttpRequest) { 1435 var xhr = new XMLHttpRequest(); 1436 xhr.open('get', '/'); // otherwise Gecko throws an exception 1437 if ('responseType' in xhr) { 1438 xhr.responseType = responseType; 1439 // as of 23.0.1271.64, Chrome switched from throwing exception to merely logging it to the console (why? o why?) 1440 if (xhr.responseType !== responseType) { 1441 return false; 1442 } 1079 1443 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 1444 } 1092 } catch (ex) {} 1093 return false; 1094 }, 1445 } 1446 } catch (ex) {} 1447 return false; 1448 }, 1095 1449 1096 // ideas for this heavily come from Modernizr (http://modernizr.com/) 1097 use_data_uri: (function() { 1098 var du = new Image(); 1450 use_blob_uri: function() { 1451 var URL = window.URL; 1452 caps.use_blob_uri = (URL && 1453 'createObjectURL' in URL && 1454 'revokeObjectURL' in URL && 1455 (Env.browser !== 'IE' || Env.verComp(Env.version, '11.0.46', '>=')) // IE supports createObjectURL, but not fully, for example it fails to use it as a src for the image 1456 ); 1457 return caps.use_blob_uri; 1458 }, 1099 1459 1100 du.onload = function() { 1101 caps.use_data_uri = (du.width === 1 && du.height === 1); 1102 }; 1103 1104 setTimeout(function() { 1105 du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="; 1106 }, 1); 1107 return false; 1108 }()), 1460 // ideas for this heavily come from Modernizr (http://modernizr.com/) 1461 use_data_uri: (function() { 1462 var du = new Image(); 1109 1463 1110 use_data_uri_over32kb: function() { // IE81111 return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9);1112 } ,1464 du.onload = function() { 1465 caps.use_data_uri = (du.width === 1 && du.height === 1); 1466 }; 1113 1467 1114 use_data_uri_of: function(bytes) { 1115 return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb()); 1116 }, 1468 setTimeout(function() { 1469 du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="; 1470 }, 1); 1471 return false; 1472 }()), 1117 1473 1118 use_fileinput: function() { 1119 if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) { 1120 return false; 1121 } 1474 use_data_uri_over32kb: function() { // IE8 1475 return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9); 1476 }, 1122 1477 1123 var el = document.createElement('input'); 1124 el.setAttribute('type', 'file'); 1125 return !el.disabled; 1478 use_data_uri_of: function(bytes) { 1479 return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb()); 1480 }, 1481 1482 use_fileinput: function() { 1483 if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) { 1484 return false; 1126 1485 } 1127 };1128 1486 1487 var el = document.createElement('input'); 1488 el.setAttribute('type', 'file'); 1489 return caps.use_fileinput = !el.disabled; 1490 }, 1491 1492 use_webgl: function() { 1493 var canvas = document.createElement('canvas'); 1494 var gl = null, isSupported; 1495 try { 1496 gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); 1497 } 1498 catch(e) {} 1499 1500 if (!gl) { // it seems that sometimes it doesn't throw exception, but still fails to get context 1501 gl = null; 1502 } 1503 1504 isSupported = !!gl; 1505 caps.use_webgl = isSupported; // save result of our check 1506 canvas = undefined; 1507 return isSupported; 1508 } 1509 }; 1510 1129 1511 return function(cap) { 1130 1512 var args = [].slice.call(arguments); 1131 1513 args.shift(); // shift of cap … … 1141 1523 can: can, 1142 1524 1143 1525 uaParser: UAParser, 1144 1526 1145 1527 browser: uaResult.browser.name, 1146 1528 version: uaResult.browser.version, 1147 1529 os: uaResult.os.name, // everybody intuitively types it in a lowercase for some reason … … 1149 1531 1150 1532 verComp: version_compare, 1151 1533 1534 swf_url: "../flash/Moxie.swf", 1535 xap_url: "../silverlight/Moxie.xap", 1152 1536 global_event_dispatcher: "moxie.core.EventTarget.instance.dispatchEvent" 1153 1537 }; 1154 1538 … … 1163 1547 }; 1164 1548 1165 1549 Env.log = function() { 1166 1550 1167 1551 function logObj(data) { 1168 1552 // TODO: this should recursively print out the object in a pretty way 1169 1553 console.appendChild(document.createTextNode(data + "\n")); 1170 1554 } 1171 1555 1172 var data = arguments[0]; 1173 1174 if (Basic.typeOf(data) === 'string') { 1175 data = Basic.sprintf.apply(this, arguments); 1176 } 1177 1178 if (window && window.console && window.console.log) { 1179 window.console.log(data); 1556 // if debugger present, IE8 might have window.console.log method, but not be able to apply on it (why...) 1557 if (window && window.console && window.console.log && window.console.log.apply) { 1558 window.console.log.apply(window.console, arguments); 1180 1559 } else if (document) { 1181 1560 var console = document.getElementById('moxie-console'); 1182 1561 if (!console) { … … 1186 1565 document.body.appendChild(console); 1187 1566 } 1188 1567 1189 if (Basic.inArray(Basic.typeOf(data), ['object', 'array']) !== -1) { 1568 var data = arguments[0]; 1569 if (Basic.typeOf(data) === 'string') { 1570 data = Basic.sprintf.apply(this, arguments); 1571 } else if (Basic.inArray(Basic.typeOf(data), ['object', 'array']) !== -1) { 1190 1572 logObj(data); 1191 } else { 1192 console.appendChild(document.createTextNode(data + "\n")); 1573 return; 1193 1574 } 1575 1576 console.appendChild(document.createTextNode(data + "\n")); 1194 1577 } 1195 1578 }; 1196 1579 } … … 1198 1581 return Env; 1199 1582 }); 1200 1583 1201 // Included from: src/javascript/core/ I18n.js1584 // Included from: src/javascript/core/Exceptions.js 1202 1585 1203 1586 /** 1204 * I18n.js1587 * Exceptions.js 1205 1588 * 1206 1589 * Copyright 2013, Moxiecode Systems AB 1207 1590 * Released under GPL License. … … 1210 1593 * Contributing: http://www.plupload.com/contributing 1211 1594 */ 1212 1595 1213 define( "moxie/core/I18n", [1214 "moxie/core/utils/Basic"1596 define('moxie/core/Exceptions', [ 1597 'moxie/core/utils/Basic' 1215 1598 ], function(Basic) { 1216 var i18n = {}; 1599 1600 function _findKey(obj, value) { 1601 var key; 1602 for (key in obj) { 1603 if (obj[key] === value) { 1604 return key; 1605 } 1606 } 1607 return null; 1608 } 1217 1609 1610 /** 1611 @class moxie/core/Exception 1612 */ 1218 1613 return { 1219 /** 1220 * Extends the language pack object with new items. 1221 * 1222 * @param {Object} pack Language pack items to add. 1223 * @return {Object} Extended language pack object. 1224 */ 1225 addI18n: function(pack) { 1226 return Basic.extend(i18n, pack); 1227 }, 1614 RuntimeError: (function() { 1615 var namecodes = { 1616 NOT_INIT_ERR: 1, 1617 EXCEPTION_ERR: 3, 1618 NOT_SUPPORTED_ERR: 9, 1619 JS_ERR: 4 1620 }; 1228 1621 1229 /** 1230 * Translates the specified string by checking for the english string in the language pack lookup. 1231 * 1232 * @param {String} str String to look for. 1233 * @return {String} Translated string or the input string if it wasn't found. 1234 */ 1235 translate: function(str) { 1236 return i18n[str] || str; 1237 }, 1238 1239 /** 1240 * Shortcut for translate function 1241 * 1242 * @param {String} str String to look for. 1243 * @return {String} Translated string or the input string if it wasn't found. 1244 */ 1245 _: function(str) { 1246 return this.translate(str); 1247 }, 1248 1249 /** 1250 * Pseudo sprintf implementation - simple way to replace tokens with specified values. 1251 * 1252 * @param {String} str String with tokens 1253 * @return {String} String with replaced tokens 1254 */ 1255 sprintf: function(str) { 1256 var args = [].slice.call(arguments, 1); 1257 1258 return str.replace(/%[a-z]/g, function() { 1259 var value = args.shift(); 1260 return Basic.typeOf(value) !== 'undefined' ? value : ''; 1622 function RuntimeError(code, message) { 1623 this.code = code; 1624 this.name = _findKey(namecodes, code); 1625 this.message = this.name + (message || ": RuntimeError " + this.code); 1626 } 1627 1628 Basic.extend(RuntimeError, namecodes); 1629 RuntimeError.prototype = Error.prototype; 1630 return RuntimeError; 1631 }()), 1632 1633 OperationNotAllowedException: (function() { 1634 1635 function OperationNotAllowedException(code) { 1636 this.code = code; 1637 this.name = 'OperationNotAllowedException'; 1638 } 1639 1640 Basic.extend(OperationNotAllowedException, { 1641 NOT_ALLOWED_ERR: 1 1261 1642 }); 1262 } 1263 }; 1264 }); 1643 1644 OperationNotAllowedException.prototype = Error.prototype; 1645 1646 return OperationNotAllowedException; 1647 }()), 1265 1648 1266 // Included from: src/javascript/core/utils/Mime.js 1649 ImageError: (function() { 1650 var namecodes = { 1651 WRONG_FORMAT: 1, 1652 MAX_RESOLUTION_ERR: 2, 1653 INVALID_META_ERR: 3 1654 }; 1267 1655 1268 /** 1269 * Mime.js 1270 * 1271 * Copyright 2013, Moxiecode Systems AB 1272 * Released under GPL License. 1273 * 1274 * License: http://www.plupload.com/license 1275 * Contributing: http://www.plupload.com/contributing 1276 */ 1277 1278 define("moxie/core/utils/Mime", [ 1279 "moxie/core/utils/Basic", 1280 "moxie/core/I18n" 1281 ], function(Basic, I18n) { 1282 1283 var mimeData = "" + 1284 "application/msword,doc dot," + 1285 "application/pdf,pdf," + 1286 "application/pgp-signature,pgp," + 1287 "application/postscript,ps ai eps," + 1288 "application/rtf,rtf," + 1289 "application/vnd.ms-excel,xls xlb," + 1290 "application/vnd.ms-powerpoint,ppt pps pot," + 1291 "application/zip,zip," + 1292 "application/x-shockwave-flash,swf swfl," + 1293 "application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," + 1294 "application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," + 1295 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," + 1296 "application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," + 1297 "application/vnd.openxmlformats-officedocument.presentationml.template,potx," + 1298 "application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," + 1299 "application/x-javascript,js," + 1300 "application/json,json," + 1301 "audio/mpeg,mp3 mpga mpega mp2," + 1302 "audio/x-wav,wav," + 1303 "audio/x-m4a,m4a," + 1304 "audio/ogg,oga ogg," + 1305 "audio/aiff,aiff aif," + 1306 "audio/flac,flac," + 1307 "audio/aac,aac," + 1308 "audio/ac3,ac3," + 1309 "audio/x-ms-wma,wma," + 1310 "image/bmp,bmp," + 1311 "image/gif,gif," + 1312 "image/jpeg,jpg jpeg jpe," + 1313 "image/photoshop,psd," + 1314 "image/png,png," + 1315 "image/svg+xml,svg svgz," + 1316 "image/tiff,tiff tif," + 1317 "text/plain,asc txt text diff log," + 1318 "text/html,htm html xhtml," + 1319 "text/css,css," + 1320 "text/csv,csv," + 1321 "text/rtf,rtf," + 1322 "video/mpeg,mpeg mpg mpe m2v," + 1323 "video/quicktime,qt mov," + 1324 "video/mp4,mp4," + 1325 "video/x-m4v,m4v," + 1326 "video/x-flv,flv," + 1327 "video/x-ms-wmv,wmv," + 1328 "video/avi,avi," + 1329 "video/webm,webm," + 1330 "video/3gpp,3gpp 3gp," + 1331 "video/3gpp2,3g2," + 1332 "video/vnd.rn-realvideo,rv," + 1333 "video/ogg,ogv," + 1334 "video/x-matroska,mkv," + 1335 "application/vnd.oasis.opendocument.formula-template,otf," + 1336 "application/octet-stream,exe"; 1337 1338 1339 var Mime = { 1340 1341 mimes: {}, 1342 1343 extensions: {}, 1344 1345 // Parses the default mime types string into a mimes and extensions lookup maps 1346 addMimeType: function (mimeData) { 1347 var items = mimeData.split(/,/), i, ii, ext; 1348 1349 for (i = 0; i < items.length; i += 2) { 1350 ext = items[i + 1].split(/ /); 1351 1352 // extension to mime lookup 1353 for (ii = 0; ii < ext.length; ii++) { 1354 this.mimes[ext[ii]] = items[i]; 1355 } 1356 // mime to extension lookup 1357 this.extensions[items[i]] = ext; 1656 function ImageError(code) { 1657 this.code = code; 1658 this.name = _findKey(namecodes, code); 1659 this.message = this.name + ": ImageError " + this.code; 1358 1660 } 1359 },1360 1361 1362 extList2mimes: function (filters, addMissingExtensions) {1363 var self = this, ext, i, ii, type, mimes = [];1364 1661 1365 // convert extensions to mime types list 1366 for (i = 0; i < filters.length; i++) { 1367 ext = filters[i].extensions.split(/\s*,\s*/); 1662 Basic.extend(ImageError, namecodes); 1663 ImageError.prototype = Error.prototype; 1368 1664 1369 for (ii = 0; ii < ext.length; ii++) { 1370 1371 // if there's an asterisk in the list, then accept attribute is not required 1372 if (ext[ii] === '*') { 1373 return []; 1374 } 1665 return ImageError; 1666 }()), 1375 1667 1376 type = self.mimes[ext[ii]]; 1377 if (type && Basic.inArray(type, mimes) === -1) { 1378 mimes.push(type); 1379 } 1668 FileException: (function() { 1669 var namecodes = { 1670 NOT_FOUND_ERR: 1, 1671 SECURITY_ERR: 2, 1672 ABORT_ERR: 3, 1673 NOT_READABLE_ERR: 4, 1674 ENCODING_ERR: 5, 1675 NO_MODIFICATION_ALLOWED_ERR: 6, 1676 INVALID_STATE_ERR: 7, 1677 SYNTAX_ERR: 8 1678 }; 1380 1679 1381 // future browsers should filter by extension, finally 1382 if (addMissingExtensions && /^\w+$/.test(ext[ii])) { 1383 mimes.push('.' + ext[ii]); 1384 } else if (!type) { 1385 // if we have no type in our map, then accept all 1386 return []; 1387 } 1388 } 1680 function FileException(code) { 1681 this.code = code; 1682 this.name = _findKey(namecodes, code); 1683 this.message = this.name + ": FileException " + this.code; 1389 1684 } 1390 return mimes;1391 },1392 1393 1394 mimes2exts: function(mimes) {1395 var self = this, exts = [];1396 1685 1397 Basic.each(mimes, function(mime) { 1398 if (mime === '*') { 1399 exts = []; 1400 return false; 1401 } 1686 Basic.extend(FileException, namecodes); 1687 FileException.prototype = Error.prototype; 1688 return FileException; 1689 }()), 1690 1691 DOMException: (function() { 1692 var namecodes = { 1693 INDEX_SIZE_ERR: 1, 1694 DOMSTRING_SIZE_ERR: 2, 1695 HIERARCHY_REQUEST_ERR: 3, 1696 WRONG_DOCUMENT_ERR: 4, 1697 INVALID_CHARACTER_ERR: 5, 1698 NO_DATA_ALLOWED_ERR: 6, 1699 NO_MODIFICATION_ALLOWED_ERR: 7, 1700 NOT_FOUND_ERR: 8, 1701 NOT_SUPPORTED_ERR: 9, 1702 INUSE_ATTRIBUTE_ERR: 10, 1703 INVALID_STATE_ERR: 11, 1704 SYNTAX_ERR: 12, 1705 INVALID_MODIFICATION_ERR: 13, 1706 NAMESPACE_ERR: 14, 1707 INVALID_ACCESS_ERR: 15, 1708 VALIDATION_ERR: 16, 1709 TYPE_MISMATCH_ERR: 17, 1710 SECURITY_ERR: 18, 1711 NETWORK_ERR: 19, 1712 ABORT_ERR: 20, 1713 URL_MISMATCH_ERR: 21, 1714 QUOTA_EXCEEDED_ERR: 22, 1715 TIMEOUT_ERR: 23, 1716 INVALID_NODE_TYPE_ERR: 24, 1717 DATA_CLONE_ERR: 25 1718 }; 1402 1719 1403 // check if this thing looks like mime type 1404 var m = mime.match(/^(\w+)\/(\*|\w+)$/); 1405 if (m) { 1406 if (m[2] === '*') { 1407 // wildcard mime type detected 1408 Basic.each(self.extensions, function(arr, mime) { 1409 if ((new RegExp('^' + m[1] + '/')).test(mime)) { 1410 [].push.apply(exts, self.extensions[mime]); 1411 } 1412 }); 1413 } else if (self.extensions[mime]) { 1414 [].push.apply(exts, self.extensions[mime]); 1415 } 1416 } 1417 }); 1418 return exts; 1419 }, 1420 1421 1422 mimes2extList: function(mimes) { 1423 var accept = [], exts = []; 1424 1425 if (Basic.typeOf(mimes) === 'string') { 1426 mimes = Basic.trim(mimes).split(/\s*,\s*/); 1720 function DOMException(code) { 1721 this.code = code; 1722 this.name = _findKey(namecodes, code); 1723 this.message = this.name + ": DOMException " + this.code; 1427 1724 } 1428 1429 exts = this.mimes2exts(mimes);1430 1725 1431 accept.push({ 1432 title: I18n.translate('Files'), 1433 extensions: exts.length ? exts.join(',') : '*' 1726 Basic.extend(DOMException, namecodes); 1727 DOMException.prototype = Error.prototype; 1728 return DOMException; 1729 }()), 1730 1731 EventException: (function() { 1732 function EventException(code) { 1733 this.code = code; 1734 this.name = 'EventException'; 1735 } 1736 1737 Basic.extend(EventException, { 1738 UNSPECIFIED_EVENT_TYPE_ERR: 0 1434 1739 }); 1435 1740 1436 // save original mimes string 1437 accept.mimes = mimes; 1438 1439 return accept; 1440 }, 1441 1442 1443 getFileExtension: function(fileName) { 1444 var matches = fileName && fileName.match(/\.([^.]+)$/); 1445 if (matches) { 1446 return matches[1].toLowerCase(); 1447 } 1448 return ''; 1449 }, 1450 1451 getFileMime: function(fileName) { 1452 return this.mimes[this.getFileExtension(fileName)] || ''; 1453 } 1741 EventException.prototype = Error.prototype; 1742 1743 return EventException; 1744 }()) 1454 1745 }; 1455 1456 Mime.addMimeType(mimeData);1457 1458 return Mime;1459 1746 }); 1460 1747 1461 1748 // Included from: src/javascript/core/utils/Dom.js … … 1470 1757 * Contributing: http://www.plupload.com/contributing 1471 1758 */ 1472 1759 1760 /** 1761 @class moxie/core/utils/Dom 1762 @public 1763 @static 1764 */ 1765 1473 1766 define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) { 1474 1767 1475 1768 /** … … 1476 1769 Get DOM Element by it's id. 1477 1770 1478 1771 @method get 1479 @for Utils1480 1772 @param {String} id Identifier of the DOM Element 1481 1773 @return {DOMElement} 1482 1774 */ … … 1641 1933 }; 1642 1934 }); 1643 1935 1644 // Included from: src/javascript/core/E xceptions.js1936 // Included from: src/javascript/core/EventTarget.js 1645 1937 1646 1938 /** 1647 * E xceptions.js1939 * EventTarget.js 1648 1940 * 1649 1941 * Copyright 2013, Moxiecode Systems AB 1650 1942 * Released under GPL License. … … 1653 1945 * Contributing: http://www.plupload.com/contributing 1654 1946 */ 1655 1947 1656 define('moxie/core/Exceptions', [ 1948 define('moxie/core/EventTarget', [ 1949 'moxie/core/utils/Env', 1950 'moxie/core/Exceptions', 1657 1951 'moxie/core/utils/Basic' 1658 ], function(Basic) { 1659 function _findKey(obj, value) { 1660 var key; 1661 for (key in obj) { 1662 if (obj[key] === value) { 1663 return key; 1664 } 1665 } 1666 return null; 1952 ], function(Env, x, Basic) { 1953 1954 // hash of event listeners by object uid 1955 var eventpool = {}; 1956 1957 /** 1958 Parent object for all event dispatching components and objects 1959 1960 @class moxie/core/EventTarget 1961 @constructor EventTarget 1962 */ 1963 function EventTarget() { 1964 /** 1965 Unique id of the event dispatcher, usually overriden by children 1966 1967 @property uid 1968 @type String 1969 */ 1970 this.uid = Basic.guid(); 1667 1971 } 1668 1972 1669 return {1670 RuntimeError: (function() {1671 var namecodes = {1672 NOT_INIT_ERR: 1,1673 NOT_SUPPORTED_ERR: 9,1674 JS_ERR: 41675 };1676 1973 1677 function RuntimeError(code) { 1678 this.code = code; 1679 this.name = _findKey(namecodes, code); 1680 this.message = this.name + ": RuntimeError " + this.code; 1681 } 1682 1683 Basic.extend(RuntimeError, namecodes); 1684 RuntimeError.prototype = Error.prototype; 1685 return RuntimeError; 1686 }()), 1687 1688 OperationNotAllowedException: (function() { 1689 1690 function OperationNotAllowedException(code) { 1691 this.code = code; 1692 this.name = 'OperationNotAllowedException'; 1693 } 1694 1695 Basic.extend(OperationNotAllowedException, { 1696 NOT_ALLOWED_ERR: 1 1697 }); 1698 1699 OperationNotAllowedException.prototype = Error.prototype; 1700 1701 return OperationNotAllowedException; 1702 }()), 1974 Basic.extend(EventTarget.prototype, { 1703 1975 1704 ImageError: (function() { 1705 var namecodes = { 1706 WRONG_FORMAT: 1, 1707 MAX_RESOLUTION_ERR: 2, 1708 INVALID_META_ERR: 3 1709 }; 1976 /** 1977 Can be called from within a child in order to acquire uniqie id in automated manner 1710 1978 1711 function ImageError(code) { 1712 this.code = code; 1713 this.name = _findKey(namecodes, code); 1714 this.message = this.name + ": ImageError " + this.code; 1979 @method init 1980 */ 1981 init: function() { 1982 if (!this.uid) { 1983 this.uid = Basic.guid('uid_'); 1715 1984 } 1716 1717 Basic.extend(ImageError, namecodes); 1718 ImageError.prototype = Error.prototype; 1985 }, 1719 1986 1720 return ImageError;1721 }()),1987 /** 1988 Register a handler to a specific event dispatched by the object 1722 1989 1723 FileException: (function() { 1724 var namecodes = { 1725 NOT_FOUND_ERR: 1, 1726 SECURITY_ERR: 2, 1727 ABORT_ERR: 3, 1728 NOT_READABLE_ERR: 4, 1729 ENCODING_ERR: 5, 1730 NO_MODIFICATION_ALLOWED_ERR: 6, 1731 INVALID_STATE_ERR: 7, 1732 SYNTAX_ERR: 8 1733 }; 1990 @method addEventListener 1991 @param {String} type Type or basically a name of the event to subscribe to 1992 @param {Function} fn Callback function that will be called when event happens 1993 @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first 1994 @param {Object} [scope=this] A scope to invoke event handler in 1995 */ 1996 addEventListener: function(type, fn, priority, scope) { 1997 var self = this, list; 1734 1998 1735 function FileException(code) { 1736 this.code = code; 1737 this.name = _findKey(namecodes, code); 1738 this.message = this.name + ": FileException " + this.code; 1999 // without uid no event handlers can be added, so make sure we got one 2000 if (!this.hasOwnProperty('uid')) { 2001 this.uid = Basic.guid('uid_'); 1739 2002 } 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: 251773 };1774 2003 1775 function DOMException(code) { 1776 this.code = code; 1777 this.name = _findKey(namecodes, code); 1778 this.message = this.name + ": DOMException " + this.code; 2004 type = Basic.trim(type); 2005 2006 if (/\s/.test(type)) { 2007 // multiple event types were passed for one handler 2008 Basic.each(type.split(/\s+/), function(type) { 2009 self.addEventListener(type, fn, priority, scope); 2010 }); 2011 return; 1779 2012 } 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: 01794 });1795 1796 EventException.prototype = Error.prototype;1797 1798 return EventException;1799 }())1800 };1801 });1802 2013 1803 // Included from: src/javascript/core/EventTarget.js 2014 type = type.toLowerCase(); 2015 priority = parseInt(priority, 10) || 0; 1804 2016 1805 /** 1806 * EventTarget.js 1807 * 1808 * Copyright 2013, Moxiecode Systems AB 1809 * Released under GPL License. 1810 * 1811 * License: http://www.plupload.com/license 1812 * Contributing: http://www.plupload.com/contributing 1813 */ 2017 list = eventpool[this.uid] && eventpool[this.uid][type] || []; 2018 list.push({fn : fn, priority : priority, scope : scope || this}); 1814 2019 1815 define('moxie/core/EventTarget', [ 1816 'moxie/core/utils/Env', 1817 'moxie/core/Exceptions', 1818 'moxie/core/utils/Basic' 1819 ], function(Env, x, Basic) { 1820 /** 1821 Parent object for all event dispatching components and objects 2020 if (!eventpool[this.uid]) { 2021 eventpool[this.uid] = {}; 2022 } 2023 eventpool[this.uid][type] = list; 2024 }, 1822 2025 1823 @class EventTarget 1824 @constructor EventTarget 1825 */ 1826 function EventTarget() { 1827 // hash of event listeners by object uid 1828 var eventpool = {}; 1829 1830 Basic.extend(this, { 1831 1832 /** 1833 Unique id of the event dispatcher, usually overriden by children 2026 /** 2027 Check if any handlers were registered to the specified event 1834 2028 1835 @property uid 1836 @type String 1837 */ 1838 uid: null, 1839 1840 /** 1841 Can be called from within a child in order to acquire uniqie id in automated manner 2029 @method hasEventListener 2030 @param {String} [type] Type or basically a name of the event to check 2031 @return {Mixed} Returns a handler if it was found and false, if - not 2032 */ 2033 hasEventListener: function(type) { 2034 var list; 2035 if (type) { 2036 type = type.toLowerCase(); 2037 list = eventpool[this.uid] && eventpool[this.uid][type]; 2038 } else { 2039 list = eventpool[this.uid]; 2040 } 2041 return list ? list : false; 2042 }, 1842 2043 1843 @method init 1844 */ 1845 init: function() { 1846 if (!this.uid) { 1847 this.uid = Basic.guid('uid_'); 1848 } 1849 }, 2044 /** 2045 Unregister the handler from the event, or if former was not specified - unregister all handlers 1850 2046 1851 /** 1852 Register a handler to a specific event dispatched by the object 2047 @method removeEventListener 2048 @param {String} type Type or basically a name of the event 2049 @param {Function} [fn] Handler to unregister 2050 */ 2051 removeEventListener: function(type, fn) { 2052 var self = this, list, i; 1853 2053 1854 @method addEventListener 1855 @param {String} type Type or basically a name of the event to subscribe to 1856 @param {Function} fn Callback function that will be called when event happens 1857 @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first 1858 @param {Object} [scope=this] A scope to invoke event handler in 1859 */ 1860 addEventListener: function(type, fn, priority, scope) { 1861 var self = this, list; 2054 type = type.toLowerCase(); 1862 2055 1863 // without uid no event handlers can be added, so make sure we got one 1864 if (!this.hasOwnProperty('uid')) { 1865 this.uid = Basic.guid('uid_'); 1866 } 1867 1868 type = Basic.trim(type); 1869 1870 if (/\s/.test(type)) { 1871 // multiple event types were passed for one handler 1872 Basic.each(type.split(/\s+/), function(type) { 1873 self.addEventListener(type, fn, priority, scope); 1874 }); 1875 return; 1876 } 1877 1878 type = type.toLowerCase(); 1879 priority = parseInt(priority, 10) || 0; 1880 1881 list = eventpool[this.uid] && eventpool[this.uid][type] || []; 1882 list.push({fn : fn, priority : priority, scope : scope || this}); 1883 1884 if (!eventpool[this.uid]) { 1885 eventpool[this.uid] = {}; 1886 } 1887 eventpool[this.uid][type] = list; 1888 }, 1889 1890 /** 1891 Check if any handlers were registered to the specified event 2056 if (/\s/.test(type)) { 2057 // multiple event types were passed for one handler 2058 Basic.each(type.split(/\s+/), function(type) { 2059 self.removeEventListener(type, fn); 2060 }); 2061 return; 2062 } 1892 2063 1893 @method hasEventListener 1894 @param {String} type Type or basically a name of the event to check 1895 @return {Mixed} Returns a handler if it was found and false, if - not 1896 */ 1897 hasEventListener: function(type) { 1898 var list = type ? eventpool[this.uid] && eventpool[this.uid][type] : eventpool[this.uid]; 1899 return list ? list : false; 1900 }, 1901 1902 /** 1903 Unregister the handler from the event, or if former was not specified - unregister all handlers 2064 list = eventpool[this.uid] && eventpool[this.uid][type]; 1904 2065 1905 @method removeEventListener 1906 @param {String} type Type or basically a name of the event 1907 @param {Function} [fn] Handler to unregister 1908 */ 1909 removeEventListener: function(type, fn) { 1910 type = type.toLowerCase(); 1911 1912 var list = eventpool[this.uid] && eventpool[this.uid][type], i; 1913 1914 if (list) { 1915 if (fn) { 1916 for (i = list.length - 1; i >= 0; i--) { 1917 if (list[i].fn === fn) { 1918 list.splice(i, 1); 1919 break; 1920 } 2066 if (list) { 2067 if (fn) { 2068 for (i = list.length - 1; i >= 0; i--) { 2069 if (list[i].fn === fn) { 2070 list.splice(i, 1); 2071 break; 1921 2072 } 1922 } else {1923 list = [];1924 2073 } 1925 1926 // delete event list if it has become empty 1927 if (!list.length) { 1928 delete eventpool[this.uid][type]; 1929 1930 // and object specific entry in a hash if it has no more listeners attached 1931 if (Basic.isEmptyObj(eventpool[this.uid])) { 1932 delete eventpool[this.uid]; 1933 } 1934 } 2074 } else { 2075 list = []; 1935 2076 } 1936 },1937 1938 /**1939 Remove all event handlers from the object1940 2077 1941 @method removeAllEventListeners 1942 */ 1943 removeAllEventListeners: function() { 1944 if (eventpool[this.uid]) { 1945 delete eventpool[this.uid]; 2078 // delete event list if it has become empty 2079 if (!list.length) { 2080 delete eventpool[this.uid][type]; 2081 2082 // and object specific entry in a hash if it has no more listeners attached 2083 if (Basic.isEmptyObj(eventpool[this.uid])) { 2084 delete eventpool[this.uid]; 2085 } 1946 2086 } 1947 }, 1948 1949 /** 1950 Dispatch the event 2087 } 2088 }, 1951 2089 1952 @method dispatchEvent 1953 @param {String/Object} Type of event or event object to dispatch 1954 @param {Mixed} [...] Variable number of arguments to be passed to a handlers 1955 @return {Boolean} true by default and false if any handler returned false 1956 */ 1957 dispatchEvent: function(type) { 1958 var uid, list, args, tmpEvt, evt = {}, result = true, undef; 1959 1960 if (Basic.typeOf(type) !== 'string') { 1961 // we can't use original object directly (because of Silverlight) 1962 tmpEvt = type; 2090 /** 2091 Remove all event handlers from the object 1963 2092 1964 if (Basic.typeOf(tmpEvt.type) === 'string') { 1965 type = tmpEvt.type; 2093 @method removeAllEventListeners 2094 */ 2095 removeAllEventListeners: function() { 2096 if (eventpool[this.uid]) { 2097 delete eventpool[this.uid]; 2098 } 2099 }, 1966 2100 1967 if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event 1968 evt.total = tmpEvt.total; 1969 evt.loaded = tmpEvt.loaded; 1970 } 1971 evt.async = tmpEvt.async || false; 1972 } else { 1973 throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR); 2101 /** 2102 Dispatch the event 2103 2104 @method dispatchEvent 2105 @param {String/Object} Type of event or event object to dispatch 2106 @param {Mixed} [...] Variable number of arguments to be passed to a handlers 2107 @return {Boolean} true by default and false if any handler returned false 2108 */ 2109 dispatchEvent: function(type) { 2110 var uid, list, args, tmpEvt, evt = {}, result = true, undef; 2111 2112 if (Basic.typeOf(type) !== 'string') { 2113 // we can't use original object directly (because of Silverlight) 2114 tmpEvt = type; 2115 2116 if (Basic.typeOf(tmpEvt.type) === 'string') { 2117 type = tmpEvt.type; 2118 2119 if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event 2120 evt.total = tmpEvt.total; 2121 evt.loaded = tmpEvt.loaded; 1974 2122 } 1975 } 1976 1977 // check if event is meant to be dispatched on an object having specific uid 1978 if (type.indexOf('::') !== -1) { 1979 (function(arr) { 1980 uid = arr[0]; 1981 type = arr[1]; 1982 }(type.split('::'))); 2123 evt.async = tmpEvt.async || false; 1983 2124 } else { 1984 uid = this.uid;2125 throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR); 1985 2126 } 1986 1987 type = type.toLowerCase(); 1988 1989 list = eventpool[uid] && eventpool[uid][type]; 2127 } 1990 2128 1991 if (list) { 1992 // sort event list by prority 1993 list.sort(function(a, b) { return b.priority - a.priority; }); 1994 1995 args = [].slice.call(arguments); 1996 1997 // first argument will be pseudo-event object 1998 args.shift(); 1999 evt.type = type; 2000 args.unshift(evt); 2129 // check if event is meant to be dispatched on an object having specific uid 2130 if (type.indexOf('::') !== -1) { 2131 (function(arr) { 2132 uid = arr[0]; 2133 type = arr[1]; 2134 }(type.split('::'))); 2135 } else { 2136 uid = this.uid; 2137 } 2001 2138 2002 if (MXI_DEBUG && Env.debug.events) { 2003 Env.log("Event '%s' fired on %u", evt.type, uid); 2004 } 2139 type = type.toLowerCase(); 2005 2140 2006 // Dispatch event to all listeners 2007 var queue = []; 2008 Basic.each(list, function(handler) { 2009 // explicitly set the target, otherwise events fired from shims do not get it 2010 args[0].target = handler.scope; 2011 // if event is marked as async, detach the handler 2012 if (evt.async) { 2013 queue.push(function(cb) { 2014 setTimeout(function() { 2015 cb(handler.fn.apply(handler.scope, args) === false); 2016 }, 1); 2017 }); 2018 } else { 2019 queue.push(function(cb) { 2020 cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation 2021 }); 2022 } 2023 }); 2024 if (queue.length) { 2025 Basic.inSeries(queue, function(err) { 2026 result = !err; 2141 list = eventpool[uid] && eventpool[uid][type]; 2142 2143 if (list) { 2144 // sort event list by prority 2145 list.sort(function(a, b) { return b.priority - a.priority; }); 2146 2147 args = [].slice.call(arguments); 2148 2149 // first argument will be pseudo-event object 2150 args.shift(); 2151 evt.type = type; 2152 args.unshift(evt); 2153 2154 if (MXI_DEBUG && Env.debug.events) { 2155 Env.log("%cEvent '%s' fired on %s", 'color: #999;', evt.type, (this.ctorName ? this.ctorName + '::' : '') + uid); 2156 } 2157 2158 // Dispatch event to all listeners 2159 var queue = []; 2160 Basic.each(list, function(handler) { 2161 // explicitly set the target, otherwise events fired from shims do not get it 2162 args[0].target = handler.scope; 2163 // if event is marked as async, detach the handler 2164 if (evt.async) { 2165 queue.push(function(cb) { 2166 setTimeout(function() { 2167 cb(handler.fn.apply(handler.scope, args) === false); 2168 }, 1); 2027 2169 }); 2170 } else { 2171 queue.push(function(cb) { 2172 cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation 2173 }); 2028 2174 } 2175 }); 2176 if (queue.length) { 2177 Basic.inSeries(queue, function(err) { 2178 result = !err; 2179 }); 2029 2180 } 2030 return result; 2031 }, 2032 2033 /** 2034 Alias for addEventListener 2181 } 2182 return result; 2183 }, 2035 2184 2036 @method bind 2037 @protected 2038 */ 2039 bind: function() { 2040 this.addEventListener.apply(this, arguments); 2041 }, 2042 2043 /** 2044 Alias for removeEventListener 2185 /** 2186 Register a handler to the event type that will run only once 2045 2187 2046 @method unbind 2047 @protected 2048 */ 2049 unbind: function() { 2050 this.removeEventListener.apply(this, arguments); 2051 }, 2052 2053 /** 2054 Alias for removeAllEventListeners 2188 @method bindOnce 2189 @since >1.4.1 2190 @param {String} type Type or basically a name of the event to subscribe to 2191 @param {Function} fn Callback function that will be called when event happens 2192 @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first 2193 @param {Object} [scope=this] A scope to invoke event handler in 2194 */ 2195 bindOnce: function(type, fn, priority, scope) { 2196 var self = this; 2197 self.bind.call(this, type, function cb() { 2198 self.unbind(type, cb); 2199 return fn.apply(this, arguments); 2200 }, priority, scope); 2201 }, 2055 2202 2056 @method unbindAll 2057 @protected 2058 */ 2059 unbindAll: function() { 2060 this.removeAllEventListeners.apply(this, arguments); 2061 }, 2062 2063 /** 2064 Alias for dispatchEvent 2203 /** 2204 Alias for addEventListener 2065 2205 2066 @method trigger 2067 @protected 2068 */ 2069 trigger: function() { 2070 return this.dispatchEvent.apply(this, arguments); 2071 }, 2072 2206 @method bind 2207 @protected 2208 */ 2209 bind: function() { 2210 this.addEventListener.apply(this, arguments); 2211 }, 2073 2212 2074 2075 Handle properties of on[event] type.2213 /** 2214 Alias for removeEventListener 2076 2215 2077 @method handleEventProps 2078 @private 2079 */ 2080 handleEventProps: function(dispatches) { 2081 var self = this; 2216 @method unbind 2217 @protected 2218 */ 2219 unbind: function() { 2220 this.removeEventListener.apply(this, arguments); 2221 }, 2082 2222 2083 this.bind(dispatches.join(' '), function(e) { 2084 var prop = 'on' + e.type.toLowerCase(); 2085 if (Basic.typeOf(this[prop]) === 'function') { 2086 this[prop].apply(this, arguments); 2087 } 2088 }); 2223 /** 2224 Alias for removeAllEventListeners 2089 2225 2090 // object must have defined event properties, even if it doesn't make use of them 2091 Basic.each(dispatches, function(prop) { 2092 prop = 'on' + prop.toLowerCase(prop); 2093 if (Basic.typeOf(self[prop]) === 'undefined') { 2094 self[prop] = null; 2095 } 2096 }); 2097 } 2098 2099 }); 2100 } 2226 @method unbindAll 2227 @protected 2228 */ 2229 unbindAll: function() { 2230 this.removeAllEventListeners.apply(this, arguments); 2231 }, 2101 2232 2102 EventTarget.instance = new EventTarget(); 2233 /** 2234 Alias for dispatchEvent 2103 2235 2236 @method trigger 2237 @protected 2238 */ 2239 trigger: function() { 2240 return this.dispatchEvent.apply(this, arguments); 2241 }, 2242 2243 2244 /** 2245 Handle properties of on[event] type. 2246 2247 @method handleEventProps 2248 @private 2249 */ 2250 handleEventProps: function(dispatches) { 2251 var self = this; 2252 2253 this.bind(dispatches.join(' '), function(e) { 2254 var prop = 'on' + e.type.toLowerCase(); 2255 if (Basic.typeOf(this[prop]) === 'function') { 2256 this[prop].apply(this, arguments); 2257 } 2258 }); 2259 2260 // object must have defined event properties, even if it doesn't make use of them 2261 Basic.each(dispatches, function(prop) { 2262 prop = 'on' + prop.toLowerCase(prop); 2263 if (Basic.typeOf(self[prop]) === 'undefined') { 2264 self[prop] = null; 2265 } 2266 }); 2267 } 2268 2269 }); 2270 2271 2272 EventTarget.instance = new EventTarget(); 2273 2104 2274 return EventTarget; 2105 2275 }); 2106 2276 … … 2127 2297 /** 2128 2298 Common set of methods and properties for every runtime instance 2129 2299 2130 @class Runtime2300 @class moxie/runtime/Runtime 2131 2301 2132 2302 @param {Object} options 2133 2303 @param {String} type Sanitized name of the runtime … … 2371 2541 2372 2542 // if no container for shim, create one 2373 2543 if (!shimContainer) { 2374 container = this.options.container ? Dom.get(this.options.container) :document.body;2544 container = Dom.get(this.options.container) || document.body; 2375 2545 2376 2546 // create shim container and insert it at an absolute position into the outer container 2377 2547 shimContainer = document.createElement('div'); … … 2475 2645 @type String 2476 2646 @static 2477 2647 */ 2478 Runtime.order = 'html5, html4';2648 Runtime.order = 'html5,flash,silverlight,html4'; 2479 2649 2480 2650 2481 2651 /** … … 2646 2816 // if cap requires conflicting mode - runtime cannot fulfill required caps 2647 2817 2648 2818 if (MXI_DEBUG && Env.debug.runtime) { 2649 Env.log("\t\t% c: %v (conflicting mode requested: %s)", cap, value, capMode);2819 Env.log("\t\t%s: %s (conflicting mode requested: %s)", cap, value, capMode); 2650 2820 } 2651 2821 2652 2822 return (mode = false); … … 2654 2824 } 2655 2825 2656 2826 if (MXI_DEBUG && Env.debug.runtime) { 2657 Env.log("\t\t% c: %v (compatible modes: %s)", cap, value, mode);2827 Env.log("\t\t%s: %s (compatible modes: %s)", cap, value, mode); 2658 2828 } 2659 2829 }); 2660 2830 … … 2669 2839 2670 2840 2671 2841 /** 2842 * Third party shims (Flash and Silverlight) require global event target against which they 2843 * will fire their events. However when moxie is not loaded to global namespace, default 2844 * event target is not accessible and we have to create artificial ones. 2845 * 2846 * @method getGlobalEventTarget 2847 * @static 2848 * @return {String} Name of the global event target 2849 */ 2850 Runtime.getGlobalEventTarget = function() { 2851 if (/^moxie\./.test(Env.global_event_dispatcher) && !Env.can('access_global_ns')) { 2852 var uniqueCallbackName = Basic.guid('moxie_event_target_'); 2853 2854 window[uniqueCallbackName] = function(e, data) { 2855 EventTarget.instance.dispatchEvent(e, data); 2856 }; 2857 2858 Env.global_event_dispatcher = uniqueCallbackName; 2859 } 2860 2861 return Env.global_event_dispatcher; 2862 }; 2863 2864 2865 /** 2672 2866 Capability check that always returns true 2673 2867 2674 2868 @private … … 2728 2922 /** 2729 2923 Set of methods and properties, required by a component to acquire ability to connect to a runtime 2730 2924 2731 @class RuntimeClient2925 @class moxie/runtime/RuntimeClient 2732 2926 */ 2733 2927 return function RuntimeClient() { 2734 2928 var runtime; … … 2758 2952 type = items.shift().toLowerCase(); 2759 2953 constructor = Runtime.getConstructor(type); 2760 2954 if (!constructor) { 2955 if (MXI_DEBUG && Env.debug.runtime) { 2956 Env.log("Constructor for '%s' runtime is not available.", type); 2957 } 2761 2958 initialize(items); 2762 2959 return; 2763 2960 } … … 2781 2978 // jailbreak ... 2782 2979 setTimeout(function() { 2783 2980 runtime.clients++; 2981 comp.ruid = runtime.uid; 2784 2982 // this will be triggered on component 2785 2983 comp.trigger('RuntimeInit', runtime); 2786 2984 }, 1); … … 2795 2993 initialize(items); 2796 2994 }); 2797 2995 2798 /*runtime.bind('Exception', function() { });*/ 2996 runtime.bind('Exception', function(e, err) { 2997 var message = err.name + "(#" + err.code + ")" + (err.message ? ", from: " + err.message : ''); 2998 2999 if (MXI_DEBUG && Env.debug.runtime) { 3000 Env.log("Runtime '%s' has thrown an exception: %s", this.type, message); 3001 } 3002 comp.trigger('RuntimeError', new x.RuntimeError(x.RuntimeError.EXCEPTION_ERR, message)); 3003 }); 2799 3004 2800 3005 if (MXI_DEBUG && Env.debug.runtime) { 2801 3006 Env.log("\tselected mode: %s", runtime.mode); … … 2820 3025 if (ruid) { 2821 3026 runtime = Runtime.getRuntime(ruid); 2822 3027 if (runtime) { 3028 comp.ruid = ruid; 2823 3029 runtime.clients++; 2824 3030 return runtime; 2825 3031 } else { … … 2871 3077 @return {Mixed} Whatever runtime extension method returns 2872 3078 */ 2873 3079 exec: function() { 2874 if (runtime) { 2875 return runtime.exec.apply(this, arguments); 3080 return runtime ? runtime.exec.apply(this, arguments) : null; 3081 }, 3082 3083 3084 /** 3085 Test runtime client for specific capability 3086 3087 @method can 3088 @param {String} cap 3089 @return {Bool} 3090 */ 3091 can: function(cap) { 3092 return runtime ? runtime.can(cap) : false; 3093 } 3094 3095 }); 3096 }; 3097 3098 3099 }); 3100 3101 // Included from: src/javascript/file/Blob.js 3102 3103 /** 3104 * Blob.js 3105 * 3106 * Copyright 2013, Moxiecode Systems AB 3107 * Released under GPL License. 3108 * 3109 * License: http://www.plupload.com/license 3110 * Contributing: http://www.plupload.com/contributing 3111 */ 3112 3113 define('moxie/file/Blob', [ 3114 'moxie/core/utils/Basic', 3115 'moxie/core/utils/Encode', 3116 'moxie/runtime/RuntimeClient' 3117 ], function(Basic, Encode, RuntimeClient) { 3118 3119 var blobpool = {}; 3120 3121 /** 3122 @class moxie/file/Blob 3123 @constructor 3124 @param {String} ruid Unique id of the runtime, to which this blob belongs to 3125 @param {Object} blob Object "Native" blob object, as it is represented in the runtime 3126 */ 3127 function Blob(ruid, blob) { 3128 3129 function _sliceDetached(start, end, type) { 3130 var blob, data = blobpool[this.uid]; 3131 3132 if (Basic.typeOf(data) !== 'string' || !data.length) { 3133 return null; // or throw exception 3134 } 3135 3136 blob = new Blob(null, { 3137 type: type, 3138 size: end - start 3139 }); 3140 blob.detach(data.substr(start, blob.size)); 3141 3142 return blob; 3143 } 3144 3145 RuntimeClient.call(this); 3146 3147 if (ruid) { 3148 this.connectRuntime(ruid); 3149 } 3150 3151 if (!blob) { 3152 blob = {}; 3153 } else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string 3154 blob = { data: blob }; 3155 } 3156 3157 Basic.extend(this, { 3158 3159 /** 3160 Unique id of the component 3161 3162 @property uid 3163 @type {String} 3164 */ 3165 uid: blob.uid || Basic.guid('uid_'), 3166 3167 /** 3168 Unique id of the connected runtime, if falsy, then runtime will have to be initialized 3169 before this Blob can be used, modified or sent 3170 3171 @property ruid 3172 @type {String} 3173 */ 3174 ruid: ruid, 3175 3176 /** 3177 Size of blob 3178 3179 @property size 3180 @type {Number} 3181 @default 0 3182 */ 3183 size: blob.size || 0, 3184 3185 /** 3186 Mime type of blob 3187 3188 @property type 3189 @type {String} 3190 @default '' 3191 */ 3192 type: blob.type || '', 3193 3194 /** 3195 @method slice 3196 @param {Number} [start=0] 3197 */ 3198 slice: function(start, end, type) { 3199 if (this.isDetached()) { 3200 return _sliceDetached.apply(this, arguments); 2876 3201 } 2877 return null; 3202 return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type); 3203 }, 3204 3205 /** 3206 Returns "native" blob object (as it is represented in connected runtime) or null if not found 3207 3208 @method getSource 3209 @return {Blob} Returns "native" blob object or null if not found 3210 */ 3211 getSource: function() { 3212 if (!blobpool[this.uid]) { 3213 return null; 3214 } 3215 return blobpool[this.uid]; 3216 }, 3217 3218 /** 3219 Detaches blob from any runtime that it depends on and initialize with standalone value 3220 3221 @method detach 3222 @protected 3223 @param {DOMString} [data=''] Standalone value 3224 */ 3225 detach: function(data) { 3226 if (this.ruid) { 3227 this.getRuntime().exec.call(this, 'Blob', 'destroy'); 3228 this.disconnectRuntime(); 3229 this.ruid = null; 3230 } 3231 3232 data = data || ''; 3233 3234 // if dataUrl, convert to binary string 3235 if (data.substr(0, 5) == 'data:') { 3236 var base64Offset = data.indexOf(';base64,'); 3237 this.type = data.substring(5, base64Offset); 3238 data = Encode.atob(data.substring(base64Offset + 8)); 3239 } 3240 3241 this.size = data.length; 3242 3243 blobpool[this.uid] = data; 3244 }, 3245 3246 /** 3247 Checks if blob is standalone (detached of any runtime) 3248 3249 @method isDetached 3250 @protected 3251 @return {Boolean} 3252 */ 3253 isDetached: function() { 3254 return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string'; 3255 }, 3256 3257 /** 3258 Destroy Blob and free any resources it was using 3259 3260 @method destroy 3261 */ 3262 destroy: function() { 3263 this.detach(); 3264 delete blobpool[this.uid]; 2878 3265 } 3266 }); 2879 3267 3268 3269 if (blob.data) { 3270 this.detach(blob.data); // auto-detach if payload has been passed 3271 } else { 3272 blobpool[this.uid] = blob; 3273 } 3274 } 3275 3276 return Blob; 3277 }); 3278 3279 // Included from: src/javascript/core/I18n.js 3280 3281 /** 3282 * I18n.js 3283 * 3284 * Copyright 2013, Moxiecode Systems AB 3285 * Released under GPL License. 3286 * 3287 * License: http://www.plupload.com/license 3288 * Contributing: http://www.plupload.com/contributing 3289 */ 3290 3291 define("moxie/core/I18n", [ 3292 "moxie/core/utils/Basic" 3293 ], function(Basic) { 3294 var i18n = {}; 3295 3296 /** 3297 @class moxie/core/I18n 3298 */ 3299 return { 3300 /** 3301 * Extends the language pack object with new items. 3302 * 3303 * @param {Object} pack Language pack items to add. 3304 * @return {Object} Extended language pack object. 3305 */ 3306 addI18n: function(pack) { 3307 return Basic.extend(i18n, pack); 3308 }, 3309 3310 /** 3311 * Translates the specified string by checking for the english string in the language pack lookup. 3312 * 3313 * @param {String} str String to look for. 3314 * @return {String} Translated string or the input string if it wasn't found. 3315 */ 3316 translate: function(str) { 3317 return i18n[str] || str; 3318 }, 3319 3320 /** 3321 * Shortcut for translate function 3322 * 3323 * @param {String} str String to look for. 3324 * @return {String} Translated string or the input string if it wasn't found. 3325 */ 3326 _: function(str) { 3327 return this.translate(str); 3328 }, 3329 3330 /** 3331 * Pseudo sprintf implementation - simple way to replace tokens with specified values. 3332 * 3333 * @param {String} str String with tokens 3334 * @return {String} String with replaced tokens 3335 */ 3336 sprintf: function(str) { 3337 var args = [].slice.call(arguments, 1); 3338 3339 return str.replace(/%[a-z]/g, function() { 3340 var value = args.shift(); 3341 return Basic.typeOf(value) !== 'undefined' ? value : ''; 3342 }); 3343 } 3344 }; 3345 }); 3346 3347 // Included from: src/javascript/core/utils/Mime.js 3348 3349 /** 3350 * Mime.js 3351 * 3352 * Copyright 2013, Moxiecode Systems AB 3353 * Released under GPL License. 3354 * 3355 * License: http://www.plupload.com/license 3356 * Contributing: http://www.plupload.com/contributing 3357 */ 3358 3359 /** 3360 @class moxie/core/utils/Mime 3361 @public 3362 @static 3363 */ 3364 3365 define("moxie/core/utils/Mime", [ 3366 "moxie/core/utils/Basic", 3367 "moxie/core/I18n" 3368 ], function(Basic, I18n) { 3369 3370 var mimeData = "" + 3371 "application/msword,doc dot," + 3372 "application/pdf,pdf," + 3373 "application/pgp-signature,pgp," + 3374 "application/postscript,ps ai eps," + 3375 "application/rtf,rtf," + 3376 "application/vnd.ms-excel,xls xlb xlt xla," + 3377 "application/vnd.ms-powerpoint,ppt pps pot ppa," + 3378 "application/zip,zip," + 3379 "application/x-shockwave-flash,swf swfl," + 3380 "application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," + 3381 "application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," + 3382 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," + 3383 "application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," + 3384 "application/vnd.openxmlformats-officedocument.presentationml.template,potx," + 3385 "application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," + 3386 "application/x-javascript,js," + 3387 "application/json,json," + 3388 "audio/mpeg,mp3 mpga mpega mp2," + 3389 "audio/x-wav,wav," + 3390 "audio/x-m4a,m4a," + 3391 "audio/ogg,oga ogg," + 3392 "audio/aiff,aiff aif," + 3393 "audio/flac,flac," + 3394 "audio/aac,aac," + 3395 "audio/ac3,ac3," + 3396 "audio/x-ms-wma,wma," + 3397 "image/bmp,bmp," + 3398 "image/gif,gif," + 3399 "image/jpeg,jpg jpeg jpe," + 3400 "image/photoshop,psd," + 3401 "image/png,png," + 3402 "image/svg+xml,svg svgz," + 3403 "image/tiff,tiff tif," + 3404 "text/plain,asc txt text diff log," + 3405 "text/html,htm html xhtml," + 3406 "text/css,css," + 3407 "text/csv,csv," + 3408 "text/rtf,rtf," + 3409 "video/mpeg,mpeg mpg mpe m2v," + 3410 "video/quicktime,qt mov," + 3411 "video/mp4,mp4," + 3412 "video/x-m4v,m4v," + 3413 "video/x-flv,flv," + 3414 "video/x-ms-wmv,wmv," + 3415 "video/avi,avi," + 3416 "video/webm,webm," + 3417 "video/3gpp,3gpp 3gp," + 3418 "video/3gpp2,3g2," + 3419 "video/vnd.rn-realvideo,rv," + 3420 "video/ogg,ogv," + 3421 "video/x-matroska,mkv," + 3422 "application/vnd.oasis.opendocument.formula-template,otf," + 3423 "application/octet-stream,exe"; 3424 3425 3426 /** 3427 * Map of mimes to extensions 3428 * 3429 * @property mimes 3430 * @type {Object} 3431 */ 3432 var mimes = {}; 3433 3434 /** 3435 * Map of extensions to mimes 3436 * 3437 * @property extensions 3438 * @type {Object} 3439 */ 3440 var extensions = {}; 3441 3442 3443 /** 3444 * Parses mimeData string into a mimes and extensions lookup maps. String should have the 3445 * following format: 3446 * 3447 * application/msword,doc dot,application/pdf,pdf, ... 3448 * 3449 * so mime-type followed by comma and followed by space-separated list of associated extensions, 3450 * then comma again and then another mime-type, etc. 3451 * 3452 * If invoked externally will replace override internal lookup maps with user-provided data. 3453 * 3454 * @method addMimeType 3455 * @param {String} mimeData 3456 */ 3457 var addMimeType = function (mimeData) { 3458 var items = mimeData.split(/,/), i, ii, ext; 3459 3460 for (i = 0; i < items.length; i += 2) { 3461 ext = items[i + 1].split(/ /); 3462 3463 // extension to mime lookup 3464 for (ii = 0; ii < ext.length; ii++) { 3465 mimes[ext[ii]] = items[i]; 3466 } 3467 // mime to extension lookup 3468 extensions[items[i]] = ext; 3469 } 3470 }; 3471 3472 3473 var extList2mimes = function (filters, addMissingExtensions) { 3474 var ext, i, ii, type, mimes = []; 3475 3476 // convert extensions to mime types list 3477 for (i = 0; i < filters.length; i++) { 3478 ext = filters[i].extensions.toLowerCase().split(/\s*,\s*/); 3479 3480 for (ii = 0; ii < ext.length; ii++) { 3481 3482 // if there's an asterisk in the list, then accept attribute is not required 3483 if (ext[ii] === '*') { 3484 return []; 3485 } 3486 3487 type = mimes[ext[ii]]; 3488 3489 // future browsers should filter by extension, finally 3490 if (addMissingExtensions && /^\w+$/.test(ext[ii])) { 3491 mimes.push('.' + ext[ii]); 3492 } else if (type && Basic.inArray(type, mimes) === -1) { 3493 mimes.push(type); 3494 } else if (!type) { 3495 // if we have no type in our map, then accept all 3496 return []; 3497 } 3498 } 3499 } 3500 return mimes; 3501 }; 3502 3503 3504 var mimes2exts = function(mimes) { 3505 var exts = []; 3506 3507 Basic.each(mimes, function(mime) { 3508 mime = mime.toLowerCase(); 3509 3510 if (mime === '*') { 3511 exts = []; 3512 return false; 3513 } 3514 3515 // check if this thing looks like mime type 3516 var m = mime.match(/^(\w+)\/(\*|\w+)$/); 3517 if (m) { 3518 if (m[2] === '*') { 3519 // wildcard mime type detected 3520 Basic.each(extensions, function(arr, mime) { 3521 if ((new RegExp('^' + m[1] + '/')).test(mime)) { 3522 [].push.apply(exts, extensions[mime]); 3523 } 3524 }); 3525 } else if (extensions[mime]) { 3526 [].push.apply(exts, extensions[mime]); 3527 } 3528 } 2880 3529 }); 3530 return exts; 2881 3531 }; 2882 3532 2883 3533 3534 var mimes2extList = function(mimes) { 3535 var accept = [], exts = []; 3536 3537 if (Basic.typeOf(mimes) === 'string') { 3538 mimes = Basic.trim(mimes).split(/\s*,\s*/); 3539 } 3540 3541 exts = mimes2exts(mimes); 3542 3543 accept.push({ 3544 title: I18n.translate('Files'), 3545 extensions: exts.length ? exts.join(',') : '*' 3546 }); 3547 3548 return accept; 3549 }; 3550 3551 /** 3552 * Extract extension from the given filename 3553 * 3554 * @method getFileExtension 3555 * @param {String} fileName 3556 * @return {String} File extension 3557 */ 3558 var getFileExtension = function(fileName) { 3559 var matches = fileName && fileName.match(/\.([^.]+)$/); 3560 if (matches) { 3561 return matches[1].toLowerCase(); 3562 } 3563 return ''; 3564 }; 3565 3566 3567 /** 3568 * Get file mime-type from it's filename - will try to match the extension 3569 * against internal mime-type lookup map 3570 * 3571 * @method getFileMime 3572 * @param {String} fileName 3573 * @return File mime-type if found or an empty string if not 3574 */ 3575 var getFileMime = function(fileName) { 3576 return mimes[getFileExtension(fileName)] || ''; 3577 }; 3578 3579 3580 addMimeType(mimeData); 3581 3582 return { 3583 mimes: mimes, 3584 extensions: extensions, 3585 addMimeType: addMimeType, 3586 extList2mimes: extList2mimes, 3587 mimes2exts: mimes2exts, 3588 mimes2extList: mimes2extList, 3589 getFileExtension: getFileExtension, 3590 getFileMime: getFileMime 3591 } 2884 3592 }); 2885 3593 2886 3594 // Included from: src/javascript/file/FileInput.js … … 2911 3619 converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory 2912 3620 with _FileReader_ or uploaded to a server through _XMLHttpRequest_. 2913 3621 2914 @class FileInput3622 @class moxie/file/FileInput 2915 3623 @constructor 2916 3624 @extends EventTarget 2917 3625 @uses RuntimeClient … … 2918 3626 @param {Object|String|DOMElement} options If options is string or node, argument is considered as _browse\_button_. 2919 3627 @param {String|DOMElement} options.browse_button DOM Element to turn into file picker. 2920 3628 @param {Array} [options.accept] Array of mime types to accept. By default accepts all. 2921 @param {String} [options.file='file'] Name of the file field (not the filename).2922 3629 @param {Boolean} [options.multiple=false] Enable selection of multiple files. 2923 3630 @param {Boolean} [options.directory=false] Turn file input into the folder input (cannot be both at the same time). 2924 @param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode 3631 @param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode 2925 3632 for _browse\_button_. 2926 3633 @param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support. 2927 3634 … … 2931 3638 </div> 2932 3639 2933 3640 <script> 2934 var fileInput = new m Oxie.FileInput({3641 var fileInput = new moxie.file.FileInput({ 2935 3642 browse_button: 'file-picker', // or document.getElementById('file-picker') 2936 3643 container: 'container', 2937 3644 accept: [ … … 2958 3665 'ready', 2959 3666 2960 3667 /** 2961 Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked. 3668 Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked. 2962 3669 Check [corresponding documentation entry](#method_refresh) for more info. 2963 3670 2964 3671 @event refresh … … 3012 3719 3013 3720 function FileInput(options) { 3014 3721 if (MXI_DEBUG) { 3015 Env.log("Instantiating FileInput..."); 3722 Env.log("Instantiating FileInput..."); 3016 3723 } 3017 3724 3018 var self = this, 3019 container, browseButton, defaults; 3725 var container, browseButton, defaults; 3020 3726 3021 3727 // if flat argument passed it should be browse_button id 3022 3728 if (Basic.inArray(Basic.typeOf(options), ['string', 'node']) !== -1) { … … 3036 3742 title: I18n.translate('All Files'), 3037 3743 extensions: '*' 3038 3744 }], 3039 name: 'file',3040 3745 multiple: false, 3041 3746 required_caps: false, 3042 3747 container: browseButton.parentNode || document.body 3043 3748 }; 3044 3749 3045 3750 options = Basic.extend({}, defaults, options); 3046 3751 3047 3752 // convert to object representation … … 3048 3753 if (typeof(options.required_caps) === 'string') { 3049 3754 options.required_caps = Runtime.parseCaps(options.required_caps); 3050 3755 } 3051 3756 3052 3757 // normalize accept option (could be list of mime types or array of title/extensions pairs) 3053 3758 if (typeof(options.accept) === 'string') { 3054 3759 options.accept = Mime.mimes2extList(options.accept); … … 3066 3771 } 3067 3772 3068 3773 container = browseButton = null; // IE 3069 3070 RuntimeClient.call( self);3071 3072 Basic.extend( self, {3774 3775 RuntimeClient.call(this); 3776 3777 Basic.extend(this, { 3073 3778 /** 3074 3779 Unique id of the component 3075 3780 … … 3080 3785 @default UID 3081 3786 */ 3082 3787 uid: Basic.guid('uid_'), 3083 3788 3084 3789 /** 3085 3790 Unique id of the connected runtime, if any. 3086 3791 … … 3098 3803 @type {String} 3099 3804 */ 3100 3805 shimid: null, 3101 3806 3102 3807 /** 3103 Array of selected m Oxie.File objects3808 Array of selected moxie.file.File objects 3104 3809 3105 3810 @property files 3106 3811 @type {Array} … … 3114 3819 @method init 3115 3820 */ 3116 3821 init: function() { 3822 var self = this; 3823 3117 3824 self.bind('RuntimeInit', function(e, runtime) { 3118 3825 self.ruid = runtime.uid; 3119 3826 self.shimid = runtime.shimid; … … 3124 3831 3125 3832 // re-position and resize shim container 3126 3833 self.bind('Refresh', function() { 3127 var pos, size, browseButton, shimContainer ;3128 3834 var pos, size, browseButton, shimContainer, zIndex; 3835 3129 3836 browseButton = Dom.get(options.browse_button); 3130 3837 shimContainer = Dom.get(runtime.shimid); // do not use runtime.getShimContainer(), since it will create container if it doesn't exist 3131 3838 … … 3132 3839 if (browseButton) { 3133 3840 pos = Dom.getPos(browseButton, Dom.get(options.container)); 3134 3841 size = Dom.getSize(browseButton); 3842 zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 0; 3135 3843 3136 3844 if (shimContainer) { 3137 3845 Basic.extend(shimContainer.style, { 3138 top : pos.y + 'px', 3139 left : pos.x + 'px', 3140 width : size.w + 'px', 3141 height : size.h + 'px' 3846 top: pos.y + 'px', 3847 left: pos.x + 'px', 3848 width: size.w + 'px', 3849 height: size.h + 'px', 3850 zIndex: zIndex + 1 3142 3851 }); 3143 3852 } 3144 3853 } 3145 3854 shimContainer = browseButton = null; 3146 3855 }); 3147 3856 3148 3857 runtime.exec.call(self, 'FileInput', 'init', options); 3149 3858 }); 3150 3859 … … 3156 3865 })); 3157 3866 }, 3158 3867 3868 3159 3869 /** 3870 * Get current option value by its name 3871 * 3872 * @method getOption 3873 * @param name 3874 * @return {Mixed} 3875 */ 3876 getOption: function(name) { 3877 return options[name]; 3878 }, 3879 3880 3881 /** 3882 * Sets a new value for the option specified by name 3883 * 3884 * @method setOption 3885 * @param name 3886 * @param value 3887 */ 3888 setOption: function(name, value) { 3889 if (!options.hasOwnProperty(name)) { 3890 return; 3891 } 3892 3893 var oldValue = options[name]; 3894 3895 switch (name) { 3896 case 'accept': 3897 if (typeof(value) === 'string') { 3898 value = Mime.mimes2extList(value); 3899 } 3900 break; 3901 3902 case 'container': 3903 case 'required_caps': 3904 throw new x.FileException(x.FileException.NO_MODIFICATION_ALLOWED_ERR); 3905 } 3906 3907 options[name] = value; 3908 this.exec('FileInput', 'setOption', name, value); 3909 3910 this.trigger('OptionChanged', name, value, oldValue); 3911 }, 3912 3913 /** 3160 3914 Disables file-picker element, so that it doesn't react to mouse clicks. 3161 3915 3162 3916 @method disable … … 3165 3919 disable: function(state) { 3166 3920 var runtime = this.getRuntime(); 3167 3921 if (runtime) { 3168 runtime.exec.call(this,'FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state);3922 this.exec('FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state); 3169 3923 } 3170 3924 }, 3171 3925 … … 3176 3930 @method refresh 3177 3931 */ 3178 3932 refresh: function() { 3179 self.trigger("Refresh");3933 this.trigger("Refresh"); 3180 3934 }, 3181 3935 3182 3936 … … 3197 3951 Basic.each(this.files, function(file) { 3198 3952 file.destroy(); 3199 3953 }); 3200 } 3954 } 3201 3955 this.files = null; 3202 3956 3203 3957 this.unbindAll(); … … 3212 3966 return FileInput; 3213 3967 }); 3214 3968 3215 // Included from: src/javascript/core/utils/Encode.js3216 3217 /**3218 * Encode.js3219 *3220 * Copyright 2013, Moxiecode Systems AB3221 * Released under GPL License.3222 *3223 * License: http://www.plupload.com/license3224 * Contributing: http://www.plupload.com/contributing3225 */3226 3227 define('moxie/core/utils/Encode', [], function() {3228 3229 /**3230 Encode string with UTF-83231 3232 @method utf8_encode3233 @for Utils3234 @static3235 @param {String} str String to encode3236 @return {String} UTF-8 encoded string3237 */3238 var utf8_encode = function(str) {3239 return unescape(encodeURIComponent(str));3240 };3241 3242 /**3243 Decode UTF-8 encoded string3244 3245 @method utf8_decode3246 @static3247 @param {String} str String to decode3248 @return {String} Decoded string3249 */3250 var utf8_decode = function(str_data) {3251 return decodeURIComponent(escape(str_data));3252 };3253 3254 /**3255 Decode Base64 encoded string (uses browser's default method if available),3256 from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js3257 3258 @method atob3259 @static3260 @param {String} data String to decode3261 @return {String} Decoded string3262 */3263 var atob = function(data, utf8) {3264 if (typeof(window.atob) === 'function') {3265 return utf8 ? utf8_decode(window.atob(data)) : window.atob(data);3266 }3267 3268 // http://kevin.vanzonneveld.net3269 // + original by: Tyler Akins (http://rumkin.com)3270 // + improved by: Thunder.m3271 // + input by: Aman Gupta3272 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)3273 // + bugfixed by: Onno Marsman3274 // + bugfixed by: Pellentesque Malesuada3275 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)3276 // + input by: Brett Zamir (http://brett-zamir.me)3277 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)3278 // * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');3279 // * returns 1: 'Kevin van Zonneveld'3280 // mozilla has this native3281 // - but breaks in 2.0.0.12!3282 //if (typeof this.window.atob == 'function') {3283 // return atob(data);3284 //}3285 var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";3286 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,3287 ac = 0,3288 dec = "",3289 tmp_arr = [];3290 3291 if (!data) {3292 return data;3293 }3294 3295 data += '';3296 3297 do { // unpack four hexets into three octets using index points in b643298 h1 = b64.indexOf(data.charAt(i++));3299 h2 = b64.indexOf(data.charAt(i++));3300 h3 = b64.indexOf(data.charAt(i++));3301 h4 = b64.indexOf(data.charAt(i++));3302 3303 bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;3304 3305 o1 = bits >> 16 & 0xff;3306 o2 = bits >> 8 & 0xff;3307 o3 = bits & 0xff;3308 3309 if (h3 == 64) {3310 tmp_arr[ac++] = String.fromCharCode(o1);3311 } else if (h4 == 64) {3312 tmp_arr[ac++] = String.fromCharCode(o1, o2);3313 } else {3314 tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);3315 }3316 } while (i < data.length);3317 3318 dec = tmp_arr.join('');3319 3320 return utf8 ? utf8_decode(dec) : dec;3321 };3322 3323 /**3324 Base64 encode string (uses browser's default method if available),3325 from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js3326 3327 @method btoa3328 @static3329 @param {String} data String to encode3330 @return {String} Base64 encoded string3331 */3332 var btoa = function(data, utf8) {3333 if (utf8) {3334 data = utf8_encode(data);3335 }3336 3337 if (typeof(window.btoa) === 'function') {3338 return window.btoa(data);3339 }3340 3341 // http://kevin.vanzonneveld.net3342 // + original by: Tyler Akins (http://rumkin.com)3343 // + improved by: Bayron Guevara3344 // + improved by: Thunder.m3345 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)3346 // + bugfixed by: Pellentesque Malesuada3347 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)3348 // + improved by: Rafał Kukawski (http://kukawski.pl)3349 // * example 1: base64_encode('Kevin van Zonneveld');3350 // * returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='3351 // mozilla has this native3352 // - but breaks in 2.0.0.12!3353 var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";3354 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,3355 ac = 0,3356 enc = "",3357 tmp_arr = [];3358 3359 if (!data) {3360 return data;3361 }3362 3363 do { // pack three octets into four hexets3364 o1 = data.charCodeAt(i++);3365 o2 = data.charCodeAt(i++);3366 o3 = data.charCodeAt(i++);3367 3368 bits = o1 << 16 | o2 << 8 | o3;3369 3370 h1 = bits >> 18 & 0x3f;3371 h2 = bits >> 12 & 0x3f;3372 h3 = bits >> 6 & 0x3f;3373 h4 = bits & 0x3f;3374 3375 // use hexets to index into b64, and append result to encoded string3376 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);3377 } while (i < data.length);3378 3379 enc = tmp_arr.join('');3380 3381 var r = data.length % 3;3382 3383 return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);3384 };3385 3386 3387 return {3388 utf8_encode: utf8_encode,3389 utf8_decode: utf8_decode,3390 atob: atob,3391 btoa: btoa3392 };3393 });3394 3395 // Included from: src/javascript/file/Blob.js3396 3397 /**3398 * Blob.js3399 *3400 * Copyright 2013, Moxiecode Systems AB3401 * Released under GPL License.3402 *3403 * License: http://www.plupload.com/license3404 * Contributing: http://www.plupload.com/contributing3405 */3406 3407 define('moxie/file/Blob', [3408 'moxie/core/utils/Basic',3409 'moxie/core/utils/Encode',3410 'moxie/runtime/RuntimeClient'3411 ], function(Basic, Encode, RuntimeClient) {3412 3413 var blobpool = {};3414 3415 /**3416 @class Blob3417 @constructor3418 @param {String} ruid Unique id of the runtime, to which this blob belongs to3419 @param {Object} blob Object "Native" blob object, as it is represented in the runtime3420 */3421 function Blob(ruid, blob) {3422 3423 function _sliceDetached(start, end, type) {3424 var blob, data = blobpool[this.uid];3425 3426 if (Basic.typeOf(data) !== 'string' || !data.length) {3427 return null; // or throw exception3428 }3429 3430 blob = new Blob(null, {3431 type: type,3432 size: end - start3433 });3434 blob.detach(data.substr(start, blob.size));3435 3436 return blob;3437 }3438 3439 RuntimeClient.call(this);3440 3441 if (ruid) {3442 this.connectRuntime(ruid);3443 }3444 3445 if (!blob) {3446 blob = {};3447 } else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string3448 blob = { data: blob };3449 }3450 3451 Basic.extend(this, {3452 3453 /**3454 Unique id of the component3455 3456 @property uid3457 @type {String}3458 */3459 uid: blob.uid || Basic.guid('uid_'),3460 3461 /**3462 Unique id of the connected runtime, if falsy, then runtime will have to be initialized3463 before this Blob can be used, modified or sent3464 3465 @property ruid3466 @type {String}3467 */3468 ruid: ruid,3469 3470 /**3471 Size of blob3472 3473 @property size3474 @type {Number}3475 @default 03476 */3477 size: blob.size || 0,3478 3479 /**3480 Mime type of blob3481 3482 @property type3483 @type {String}3484 @default ''3485 */3486 type: blob.type || '',3487 3488 /**3489 @method slice3490 @param {Number} [start=0]3491 */3492 slice: function(start, end, type) {3493 if (this.isDetached()) {3494 return _sliceDetached.apply(this, arguments);3495 }3496 return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type);3497 },3498 3499 /**3500 Returns "native" blob object (as it is represented in connected runtime) or null if not found3501 3502 @method getSource3503 @return {Blob} Returns "native" blob object or null if not found3504 */3505 getSource: function() {3506 if (!blobpool[this.uid]) {3507 return null;3508 }3509 return blobpool[this.uid];3510 },3511 3512 /**3513 Detaches blob from any runtime that it depends on and initialize with standalone value3514 3515 @method detach3516 @protected3517 @param {DOMString} [data=''] Standalone value3518 */3519 detach: function(data) {3520 if (this.ruid) {3521 this.getRuntime().exec.call(this, 'Blob', 'destroy');3522 this.disconnectRuntime();3523 this.ruid = null;3524 }3525 3526 data = data || '';3527 3528 // if dataUrl, convert to binary string3529 if (data.substr(0, 5) == 'data:') {3530 var base64Offset = data.indexOf(';base64,');3531 this.type = data.substring(5, base64Offset);3532 data = Encode.atob(data.substring(base64Offset + 8));3533 }3534 3535 this.size = data.length;3536 3537 blobpool[this.uid] = data;3538 },3539 3540 /**3541 Checks if blob is standalone (detached of any runtime)3542 3543 @method isDetached3544 @protected3545 @return {Boolean}3546 */3547 isDetached: function() {3548 return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string';3549 },3550 3551 /**3552 Destroy Blob and free any resources it was using3553 3554 @method destroy3555 */3556 destroy: function() {3557 this.detach();3558 delete blobpool[this.uid];3559 }3560 });3561 3562 3563 if (blob.data) {3564 this.detach(blob.data); // auto-detach if payload has been passed3565 } else {3566 blobpool[this.uid] = blob;3567 }3568 }3569 3570 return Blob;3571 });3572 3573 3969 // Included from: src/javascript/file/File.js 3574 3970 3575 3971 /** … … 3588 3984 'moxie/file/Blob' 3589 3985 ], function(Basic, Mime, Blob) { 3590 3986 /** 3591 @class File3987 @class moxie/file/File 3592 3988 @extends Blob 3593 3989 @constructor 3594 3990 @param {String} ruid Unique id of the runtime, to which this blob belongs to … … 3691 4087 <div id="filelist"></div> 3692 4088 3693 4089 <script type="text/javascript"> 3694 var fileDrop = new m Oxie.FileDrop('drop_zone'), fileList = mOxie.get('filelist');4090 var fileDrop = new moxie.file.FileDrop('drop_zone'), fileList = moxie.utils.Dom.get('filelist'); 3695 4091 3696 4092 fileDrop.ondrop = function() { 3697 m Oxie.each(this.files, function(file) {4093 moxie.utils.Basic.each(this.files, function(file) { 3698 4094 fileList.innerHTML += '<div>' + file.name + '</div>'; 3699 4095 }); 3700 4096 }; … … 3702 4098 fileDrop.init(); 3703 4099 </script> 3704 4100 3705 @class FileDrop4101 @class moxie/file/FileDrop 3706 4102 @constructor 3707 4103 @extends EventTarget 3708 4104 @uses RuntimeClient … … 3855 4251 Utility for preloading o.Blob/o.File objects in memory. By design closely follows [W3C FileReader](http://www.w3.org/TR/FileAPI/#dfn-filereader) 3856 4252 interface. Where possible uses native FileReader, where - not falls back to shims. 3857 4253 3858 @class FileReader4254 @class moxie/file/FileReader 3859 4255 @constructor FileReader 3860 4256 @extends EventTarget 3861 4257 @uses RuntimeClient … … 4118 4514 * Contributing: http://www.plupload.com/contributing 4119 4515 */ 4120 4516 4121 define('moxie/core/utils/Url', [], function() { 4517 /** 4518 @class moxie/core/utils/Url 4519 @public 4520 @static 4521 */ 4522 4523 define('moxie/core/utils/Url', [ 4524 'moxie/core/utils/Basic' 4525 ], function(Basic) { 4122 4526 /** 4123 4527 Parse url into separate components and fill in absent parts with parts from current url, 4124 4528 based on https://raw.github.com/kvz/phpjs/master/functions/url/parse_url.js 4125 4529 4126 4530 @method parseUrl 4127 @for Utils4128 4531 @static 4129 4532 @param {String} url Url to parse (defaults to empty string if undefined) 4130 4533 @return {Object} Hash containing extracted uri components … … 4137 4540 https: 443 4138 4541 } 4139 4542 , uri = {} 4140 , regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@\/]*):?([^:@\/]*))?@)?( [^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/4543 , regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@\/]*):?([^:@\/]*))?@)?(\[[\da-fA-F:]+\]|[^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/ 4141 4544 , m = regex.exec(url || '') 4545 , isRelative 4546 , isSchemeLess = /^\/\/\w/.test(url) 4142 4547 ; 4143 4548 4549 switch (Basic.typeOf(currentUrl)) { 4550 case 'undefined': 4551 currentUrl = parseUrl(document.location.href, false); 4552 break; 4553 4554 case 'string': 4555 currentUrl = parseUrl(currentUrl, false); 4556 break; 4557 } 4558 4144 4559 while (i--) { 4145 4560 if (m[i]) { 4146 4561 uri[key[i]] = m[i]; … … 4147 4562 } 4148 4563 } 4149 4564 4150 // when url is relative, we set the origin and the path ourselves 4151 if (!uri.scheme) { 4152 // come up with defaults 4153 if (!currentUrl || typeof(currentUrl) === 'string') { 4154 currentUrl = parseUrl(currentUrl || document.location.href); 4155 } 4565 isRelative = !isSchemeLess && !uri.scheme; 4156 4566 4567 if (isSchemeLess || isRelative) { 4157 4568 uri.scheme = currentUrl.scheme; 4569 } 4570 4571 // when url is relative, we set the origin and the path ourselves 4572 if (isRelative) { 4158 4573 uri.host = currentUrl.host; 4159 4574 uri.port = currentUrl.port; 4160 4575 … … 4175 4590 4176 4591 if (!uri.port) { 4177 4592 uri.port = ports[uri.scheme] || 80; 4178 } 4179 4593 } 4594 4180 4595 uri.port = parseInt(uri.port, 10); 4181 4596 4182 4597 if (!uri.path) { … … 4211 4626 Check if specified url has the same origin as the current document 4212 4627 4213 4628 @method hasSameOrigin 4629 @static 4214 4630 @param {String|Object} url 4215 4631 @return {Boolean} 4216 4632 */ … … 4218 4634 function origin(url) { 4219 4635 return [url.scheme, url.host, url.port].join('/'); 4220 4636 } 4221 4637 4222 4638 if (typeof url === 'string') { 4223 4639 url = parseUrl(url); 4224 } 4225 4640 } 4641 4226 4642 return origin(parseUrl()) === origin(url); 4227 4643 }; 4228 4644 … … 4254 4670 Instance of this class can be used as a target for the events dispatched by shims, 4255 4671 when allowing them onto components is for either reason inappropriate 4256 4672 4257 @class RuntimeTarget4673 @class moxie/runtime/RuntimeTarget 4258 4674 @constructor 4259 4675 @protected 4260 4676 @extends EventTarget … … 4297 4713 it can be used to read only preloaded blobs/files and only below certain size (not yet sure what that'd be, 4298 4714 but probably < 1mb). Not meant to be used directly by user. 4299 4715 4300 @class FileReaderSync4716 @class moxie/file/FileReaderSync 4301 4717 @private 4302 4718 @constructor 4303 4719 */ … … 4368 4784 /** 4369 4785 FormData 4370 4786 4371 @class FormData4787 @class moxie/xhr/FormData 4372 4788 @constructor 4373 4789 */ 4374 4790 function FormData() { … … 4555 4971 function XMLHttpRequestUpload() { 4556 4972 this.uid = Basic.guid('uid_'); 4557 4973 } 4558 4974 4559 4975 XMLHttpRequestUpload.prototype = EventTarget.instance; 4560 4976 4561 4977 /** 4562 4978 Implementation of XMLHttpRequest 4563 4979 4564 @class XMLHttpRequest4980 @class moxie/xhr/XMLHttpRequest 4565 4981 @constructor 4566 4982 @uses RuntimeClient 4567 4983 @extends EventTarget … … 4582 4998 'loadend' 4583 4999 4584 5000 // readystatechange (for historical reasons) 4585 ]; 4586 5001 ]; 5002 4587 5003 var NATIVE = 1, RUNTIME = 2; 4588 5004 4589 5005 function XMLHttpRequest() { 4590 5006 var self = this, 4591 5007 // this (together with _p() @see below) is here to gracefully upgrade to setter/getter syntax where possible … … 4651 5067 /** 4652 5068 Returns the response type. Can be set to change the response type. Values are: 4653 5069 the empty string (default), "arraybuffer", "blob", "document", "json", and "text". 4654 5070 4655 5071 @property responseType 4656 5072 &nb