Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.
+ He was an old man who fished alone in a skiff in the Gulf Stream and he
+ had gone eighty-four days now without taking a fish. In the first forty
+ days a boy had been with him. But after forty days without a fish the
+ boy's parents had told him that the old man was now definitely and
+ finally salao, which is the worst form of unlucky, and the boy
+ had gone at their orders in another boat which caught three good fish
+ the first week. It made the boy sad to see the old man come in each day
+ with his skiff empty and he always went down to help him carry either
+ the coiled lines or the gaff and harpoon and the sail that was furled
+ around the mast. The sail was patched with flour sacks and, furled, it
+ looked like the flag of permanent defeat.
+
+
+ The old man was thin and gaunt with deep wrinkles in the back of his
+ neck. The brown blotches of the benevolent skin cancer the sun brings
+ from its reflection on the tropic sea were on his cheeks. The blotches
+ ran well down the sides of his face and his hands had the deep-creased
+ scars from handling heavy fish on the cords. But none of these scars
+ were fresh. They were as old as erosions in a fishless desert.
+
+
+ Everything about him was old except his eyes and they were the same
+ color as the sea and were cheerful and undefeated.
+
+
+ "Santiago," the boy said to him as they climbed the bank from
+ where the skiff was hauled up. "I could go with you again. We've
+ made some money."
+
+
The old man had taught the boy to fish and the boy loved him.
+
+ "No," the old man said. "You're with a lucky boat. Stay
+ with them."
+
+
+ "But remember how you went eighty-seven days without fish and then
+ we caught big ones every day for three weeks."
+
+
+ "I remember," the old man said. "I know you did not leave
+ me because you doubted."
+
+
+ "It was papa made me leave. I am a boy and I must obey him."
+
+
+ "I know," the old man said. "It is quite normal."
+
+
"He hasn't much faith."
+
+ "No," the old man said. "But we have. Haven't we?"
+
+
+ "Yes," the boy said. "Can I offer you a beer on the
+ Terrace and then we'll take the stuff home."
+
+
+ "Why not?" the old man said. "Between fishermen."
+
+
+ They sat on the Terrace and many of the fishermen made fun of the old
+ man and he was not angry. Others, of the older fishermen, looked at him
+ and were sad. But they did not show it and they spoke politely about the
+ current and the depths they had drifted their lines at and the steady
+ good weather and of what they had seen. The successful fishermen of that
+ day were already in and had butchered their marlin out and carried them
+ laid full length across two planks, with two men staggering at the end
+ of each plank, to the fish house where they waited for the ice truck to
+ carry them to the market in Havana. Those who had caught sharks had
+ taken them to the shark factory on the other side of the cove where they
+ were hoisted on a block and tackle, their livers removed, their fins cut
+ off and their hides skinned out and their flesh cut into strips for
+ salting.
+
+
+ When the wind was in the east a smell came across the harbour from the
+ shark factory; but today there was only the faint edge of the odour
+ because the wind had backed into the north and then dropped off and it
+ was pleasant and sunny on the Terrace.
+
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.
+
+
Header Level 2
+
+
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+
Aliquam tincidunt mauris eu risus.
+
+
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.
+
+
Header Level 3
+
+
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+
+
+
+
diff --git a/pkg/plugin/categories/jquery-i18n-master/lib/jasmine-1.2.0/MIT.LICENSE b/pkg/plugin/categories/jquery-i18n-master/lib/jasmine-1.2.0/MIT.LICENSE
new file mode 100644
index 000000000..7c435baae
--- /dev/null
+++ b/pkg/plugin/categories/jquery-i18n-master/lib/jasmine-1.2.0/MIT.LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008-2011 Pivotal Labs
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/pkg/plugin/categories/jquery-i18n-master/package.json b/pkg/plugin/categories/jquery-i18n-master/package.json
new file mode 100644
index 000000000..5f1c7cc92
--- /dev/null
+++ b/pkg/plugin/categories/jquery-i18n-master/package.json
@@ -0,0 +1,17 @@
+{
+ "name": "jquery-i18n",
+ "description": "A jQuery plugin for doing client-side translations in javascript.",
+ "repository": "git@github.com:recurser/jquery-i18n.git",
+ "version": "1.1.1",
+ "main": "Gruntfile.js",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "grunt-contrib-uglify": "~0.2.0",
+ "grunt": "~0.4.0"
+ },
+ "peerDependencies": {
+ "grunt": "~0.4.0"
+ }
+}
+
diff --git a/pkg/plugin/richText/tinymce/langs/readme.md b/pkg/plugin/richText/tinymce/langs/readme.md
new file mode 100644
index 000000000..a52bf03f9
--- /dev/null
+++ b/pkg/plugin/richText/tinymce/langs/readme.md
@@ -0,0 +1,3 @@
+This is where language files should be placed.
+
+Please DO NOT translate these directly use this service: https://www.transifex.com/projects/p/tinymce/
diff --git a/pkg/plugin/richText/tinymce/license.txt b/pkg/plugin/richText/tinymce/license.txt
new file mode 100644
index 000000000..1837b0acb
--- /dev/null
+++ b/pkg/plugin/richText/tinymce/license.txt
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-cool.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-cool.gif
new file mode 100644
index 000000000..ba90cc36f
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-cool.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-cry.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-cry.gif
new file mode 100644
index 000000000..74d897a4f
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-cry.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-embarassed.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-embarassed.gif
new file mode 100644
index 000000000..963a96b8a
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-embarassed.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-foot-in-mouth.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-foot-in-mouth.gif
new file mode 100644
index 000000000..c7cf1011d
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-foot-in-mouth.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-frown.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-frown.gif
new file mode 100644
index 000000000..716f55e16
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-frown.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-innocent.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-innocent.gif
new file mode 100644
index 000000000..334d49e0e
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-innocent.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-kiss.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-kiss.gif
new file mode 100644
index 000000000..4efd549ed
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-kiss.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-laughing.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-laughing.gif
new file mode 100644
index 000000000..82c5b182e
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-laughing.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-money-mouth.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-money-mouth.gif
new file mode 100644
index 000000000..ca2451e10
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-money-mouth.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-sealed.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-sealed.gif
new file mode 100644
index 000000000..fe66220c2
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-sealed.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-smile.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-smile.gif
new file mode 100644
index 000000000..fd27edfaa
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-smile.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-surprised.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-surprised.gif
new file mode 100644
index 000000000..0cc9bb71c
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-surprised.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-tongue-out.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-tongue-out.gif
new file mode 100644
index 000000000..2075dc160
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-tongue-out.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-undecided.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-undecided.gif
new file mode 100644
index 000000000..bef7e2573
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-undecided.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-wink.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-wink.gif
new file mode 100644
index 000000000..0631c7616
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-wink.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-yell.gif b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-yell.gif
new file mode 100644
index 000000000..648e6e879
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/emoticons/img/smiley-yell.gif differ
diff --git a/pkg/plugin/richText/tinymce/plugins/example/dialog.html b/pkg/plugin/richText/tinymce/plugins/example/dialog.html
new file mode 100644
index 000000000..565f06f5e
--- /dev/null
+++ b/pkg/plugin/richText/tinymce/plugins/example/dialog.html
@@ -0,0 +1,8 @@
+
+
+
+
Custom dialog
+ Input some text:
+
+
+
\ No newline at end of file
diff --git a/pkg/plugin/richText/tinymce/plugins/media/moxieplayer.swf b/pkg/plugin/richText/tinymce/plugins/media/moxieplayer.swf
new file mode 100644
index 000000000..19c771bea
Binary files /dev/null and b/pkg/plugin/richText/tinymce/plugins/media/moxieplayer.swf differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.eot b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.eot
new file mode 100644
index 000000000..b144ba0bd
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.eot differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.svg b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.svg
new file mode 100644
index 000000000..a9076ca85
--- /dev/null
+++ b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.svg
@@ -0,0 +1,63 @@
+
+
+
\ No newline at end of file
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.ttf b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.ttf
new file mode 100644
index 000000000..a983e2dc4
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.ttf differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.woff b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.woff
new file mode 100644
index 000000000..d8962df76
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce-small.woff differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.eot b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.eot
new file mode 100644
index 000000000..8838c8dc9
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.eot differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.svg b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.svg
new file mode 100644
index 000000000..d7004a979
--- /dev/null
+++ b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.svg
@@ -0,0 +1,98 @@
+
+
+
\ No newline at end of file
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.ttf b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.ttf
new file mode 100644
index 000000000..ab4487feb
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.ttf differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.woff b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.woff
new file mode 100644
index 000000000..171a2a2df
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/fonts/tinymce.woff differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/img/anchor.gif b/pkg/plugin/richText/tinymce/skins/lightgray/img/anchor.gif
new file mode 100644
index 000000000..606348c7f
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/img/anchor.gif differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/img/loader.gif b/pkg/plugin/richText/tinymce/skins/lightgray/img/loader.gif
new file mode 100644
index 000000000..c69e93723
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/img/loader.gif differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/img/object.gif b/pkg/plugin/richText/tinymce/skins/lightgray/img/object.gif
new file mode 100644
index 000000000..cccd7f023
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/img/object.gif differ
diff --git a/pkg/plugin/richText/tinymce/skins/lightgray/img/trans.gif b/pkg/plugin/richText/tinymce/skins/lightgray/img/trans.gif
new file mode 100644
index 000000000..388486517
Binary files /dev/null and b/pkg/plugin/richText/tinymce/skins/lightgray/img/trans.gif differ
diff --git a/src/annotator.coffee b/src/annotator.coffee
index 766d4cb30..c9ee3d113 100644
--- a/src/annotator.coffee
+++ b/src/annotator.coffee
@@ -1,9 +1,9 @@
# Selection and range creation reference for the following code:
# http://www.quirksmode.org/dom/range_intro.html
-#
+#
# I've removed any support for IE TextRange (see commit d7085bf2 for code)
# for the moment, having no means of testing it.
-
+
# Store a reference to the current Annotator object.
_Annotator = this.Annotator
@@ -12,11 +12,14 @@ class Annotator extends Delegator
events:
".annotator-adder button click": "onAdderClick"
".annotator-adder button mousedown": "onAdderMousedown"
+ ".annotator-dict button click": "onDictClick"
+ ".annotator-dict button mousedown": "onDictMousedown"
".annotator-hl mouseover": "onHighlightMouseover"
".annotator-hl mouseout": "startViewerHideTimer"
html:
- adder: ''
+ adder: ''
+ dict: ''
wrapper: ''
options: # Configuration options
@@ -28,6 +31,8 @@ class Annotator extends Delegator
viewer: null
+ dictionary: null
+
selectedRanges: null
mouseIsDown: false
@@ -66,11 +71,12 @@ class Annotator extends Delegator
# Return early if the annotator is not supported.
return this unless Annotator.supported()
this._setupDocumentEvents() unless @options.readOnly
- this._setupWrapper()._setupViewer()._setupEditor()
+ this._setupWrapper()._setupViewer()._setupEditor()._setupDictionary()
this._setupDynamicStyle()
# Create adder
this.adder = $(this.html.adder).appendTo(@wrapper).hide()
+ this.dict = $(this.html.dict).appendTo(@wrapper).hide()
Annotator._instances.push(this)
@@ -135,6 +141,21 @@ class Annotator extends Delegator
@editor.element.appendTo(@wrapper)
this
+ # Creates an instance of the Annotator.Dictionary and assigns it to @dictionary.
+ # Appends this to the @wrapper and sets up event listeners.
+ #
+ # Returns itself for chaining.
+ _setupDictionary: ->
+ @dictionary = new Annotator.Dictionary()
+ @dictionary.hide()
+ .on('hide', this.onDictionaryHide)
+ .addField({
+ parameter: 'test123'
+ })
+
+ @dictionary.element.appendTo(@wrapper)
+ this
+
# Sets up the selection event listeners to watch mouse actions on the document.
#
# Returns itself for chaining.
@@ -154,7 +175,7 @@ class Annotator extends Delegator
if (!style.length)
style = $('').appendTo(document.head)
- sel = '*' + (":not(.annotator-#{x})" for x in ['adder', 'outer', 'notice', 'filter']).join('')
+ sel = '*' + (":not(.annotator-#{x})" for x in ['adder','dict', 'outer', 'notice', 'filter']).join('')
# use the maximum z-index in the page
max = Util.maxZIndex($(document.body).find(sel))
@@ -165,7 +186,7 @@ class Annotator extends Delegator
max = Math.max(max, 1000)
style.text [
- ".annotator-adder, .annotator-outer, .annotator-notice {"
+ ".annotator-adder, .annotator-dict, .annotator-outer, .annotator-notice {"
" z-index: #{max + 20};"
"}"
".annotator-filter {"
@@ -190,6 +211,7 @@ class Annotator extends Delegator
$('#annotator-dynamic-style').remove()
@adder.remove()
+ @dict.remove()
@viewer.destroy()
@editor.destroy()
@@ -323,6 +345,32 @@ class Annotator extends Delegator
annotation
+ setupSelected: (annotation) ->
+ root = @wrapper[0]
+ annotation.ranges or= @selectedRanges
+
+ normedRanges = []
+ for r in annotation.ranges
+ try
+ normedRanges.push(Range.sniff(r).normalize(root))
+ catch e
+ if e instanceof Range.RangeError
+ this.publish('rangeNormalizeFail', [annotation, r, e])
+ else
+ # Oh Javascript, why you so crap? This will lose the traceback.
+ throw e
+
+ annotation.quote = []
+ annotation.ranges = []
+
+ for normed in normedRanges
+ annotation.quote.push $.trim(normed.text())
+ annotation.ranges.push normed.serialize(@wrapper[0], '.annotator-hl')
+
+ # Join all the quotes into one string.
+ annotation.quote = annotation.quote.join(' / ')
+ annotation
+
# Public: Publishes the 'beforeAnnotationUpdated' and 'annotationUpdated'
# events. Listeners wishing to modify an updated annotation should subscribe
# to 'beforeAnnotationUpdated' while listeners storing annotations should
@@ -553,6 +601,15 @@ class Annotator extends Delegator
this.startViewerHideTimer()
@mouseIsDown = true
+ showDictionary: (annotation, location) =>
+ @dictionary.element.css(location)
+ @dictionary.load(annotation)
+ this
+
+ onDictionaryHide: =>
+ this.publish('annotationDictionaryHidden', [@dictionary])
+ @ignoreMouseup = false
+
# Annotator#element callback. Checks to see if a selection has been made
# on mouseup and if so displays the Annotator#adder. If @ignoreMouseup is
# set will do nothing. Also resets the @mouseIsDown property.
@@ -579,8 +636,12 @@ class Annotator extends Delegator
@adder
.css(Util.mousePosition(event, @wrapper[0]))
.show()
+ @dict
+ .css(Util.mousePosition(event, @wrapper[0]))
+ .show()
else
@adder.hide()
+ @dict.hide()
# Public: Determines if the provided element is part of the annotator plugin.
# Useful for ignoring mouse actions on the annotator elements.
@@ -652,6 +713,7 @@ class Annotator extends Delegator
# Hide the adder
position = @adder.position()
+ @dict.hide()
@adder.hide()
# Show a temporary highlight so the user can see what they selected
@@ -684,6 +746,22 @@ class Annotator extends Delegator
# Display the editor.
this.showEditor(annotation, position)
+ onDictMousedown: (event) =>
+ event?.preventDefault()
+ @ignoreMouseup = true
+
+ onDictClick: (event) =>
+ event?.preventDefault()
+
+ # Hide the adder
+ position = @dict.position()
+ @dict.hide()
+ @adder.hide()
+
+ annotation = this.setupSelected(this.createAnnotation())
+
+ this.showDictionary(annotation, position)
+
# Annotator#viewer callback function. Displays the Annotator#editor in the
# positions of the Annotator#viewer and loads the passed annotation for
# editing.
diff --git a/src/dictionary.coffee b/src/dictionary.coffee
new file mode 100644
index 000000000..2fa8b80ef
--- /dev/null
+++ b/src/dictionary.coffee
@@ -0,0 +1,376 @@
+# Public: Creates an element for dictionary.
+class Annotator.Dictionary extends Annotator.Widget
+
+ # Events to be bound to @element.
+ events:
+ ".annotator-cancel click": "hide"
+ ".annotator-cancel mouseover": "onCancelButtonMouseover"
+
+ # Classes to toggle state.
+ classes:
+ hide: 'annotator-hide'
+ focus: 'annotator-focus'
+
+ # HTML template for @element.
+ html: """
+
+
+
+ """
+
+ options: {} # Configuration options
+
+ # Public: Creates an instance of the Dictionary object. This will create the
+ # @element from the @html string and set up all events.
+ #
+ # options - An Object literal containing options. There are currently no
+ # options implemented.
+ #
+ # Examples
+ #
+ # # Creates a new dictionary, adds a custom field and
+ # # loads an annotation for editing.
+ # dictionary = new Annotator.Dictionary
+ # dictionary.addField({
+ # parameter: 'word'
+ # })
+ # dictionary.load(annotation)
+ #
+ # Returns a new Dictionary instance.
+ constructor: (options) ->
+ super $(@html)[0], options
+
+ @fields = []
+ @annotation = {}
+
+ # Public: Displays the Dictionary and fires a "show" event.
+ # Can be used as an event callback and will call Event#preventDefault()
+ # on the supplied event.
+ #
+ # event - Event object provided if method is called by event
+ # listener (default:undefined)
+ #
+ # Examples
+ #
+ # # Displays the dictionary.
+ # dictionary.show()
+ #
+ # # Displays the dictionary on click (prevents default action).
+ # $('a.show-dictionary').bind('click', dictionary.show)
+ #
+ # Returns itself.
+ show: (event) =>
+ Annotator.Util.preventEventDefault event
+
+ @element.removeClass(@classes.hide)
+
+ # invert if necessary
+ this.checkOrientation()
+
+ # give main textarea focus
+ @element.find(":input:first").focus()
+
+ this.setupDraggables()
+
+ this.publish('show')
+
+
+ # Public: Hides the Dictionary and fires a "hide" event. Can be used as an event
+ # callback and will call Event#preventDefault() on the supplied event.
+ #
+ # event - Event object provided if method is called by event
+ # listener (default:undefined)
+ #
+ # Examples
+ #
+ # # Hides the dictionary.
+ # dictionary.hide()
+ #
+ # # Hide the dictionary on click (prevents default action).
+ # $('a.hide-dictionary').bind('click', dictionary.hide)
+ #
+ # Returns itself.
+ hide: (event) =>
+ Annotator.Util.preventEventDefault event
+
+ @element.addClass(@classes.hide)
+ this.publish('hide')
+
+ # Public: Loads an annotation into the Editor and displays it setting
+ # Editor#annotation to the provided annotation. It fires the "load" event
+ # providing the current annotation subscribers can modify the annotation
+ # before it updates the editor fields.
+ #
+ # annotation - An annotation Object to display for editing.
+ #
+ # Examples
+ #
+ # # Diplays the editor with the annotation loaded.
+ # editor.load({text: 'My Annotation'})
+ #
+ # editor.on('load', (annotation) ->
+ # console.log annotation.text
+ # ).load({text: 'My Annotation'})
+ # # => Outputs "My Annotation"
+ #
+ # Returns itself.
+ load: (annotation) =>
+ @annotation = annotation
+
+ this.publish('load', [@annotation])
+
+ for field in @fields
+ field.load(field.element, @annotation)
+
+ this.show()
+
+ # Public: Hides the Editor and passes the annotation to all registered fields
+ # so they can update its state. It then fires the "save" event so that other
+ # parties can further modify the annotation.
+ # Can be used as an event callback and will call Event#preventDefault() on the
+ # supplied event.
+ #
+ # event - Event object provided if method is called by event
+ # listener (default:undefined)
+ #
+ # Examples
+ #
+ # # Submits the editor.
+ # editor.submit()
+ #
+ # # Submits the editor on click (prevents default action).
+ # $('button.submit-editor').bind('click', editor.submit)
+ #
+ # # Appends "Comment: " to the annotation comment text.
+ # editor.on('save', (annotation) ->
+ # annotation.text = "Comment: " + annotation.text
+ # ).submit()
+ #
+ # Returns itself.
+ submit: (event) =>
+ Annotator.Util.preventEventDefault event
+
+ for field in @fields
+ field.submit(field.element, @annotation)
+
+ this.publish('save', [@annotation])
+
+ this.hide()
+
+ # Public: Adds an addional form field to the editor. Callbacks can be provided
+ # to update the view and anotations on load and submission.
+ #
+ # options - An options Object. Options are as follows:
+ # id - A unique id for the form element will also be set as the
+ # "for" attrubute of a label if there is one. Defaults to
+ # a timestamp. (default: "annotator-field-{timestamp}")
+ # type - Input type String. One of "input", "textarea",
+ # "checkbox", "select" (default: "input")
+ # label - Label to display either in a label Element or as place-
+ # holder text depending on the type. (default: "")
+ # load - Callback Function called when the editor is loaded with a
+ # new annotation. Recieves the field
element and the
+ # annotation to be loaded.
+ # submit - Callback Function called when the editor is submitted.
+ # Recieves the field
element and the annotation to be
+ # updated.
+ #
+ # Examples
+ #
+ # # Add a new input element.
+ # editor.addField({
+ # label: "Tags",
+ #
+ # # This is called when the editor is loaded use it to update your input.
+ # load: (field, annotation) ->
+ # # Do something with the annotation.
+ # value = getTagString(annotation.tags)
+ # $(field).find('input').val(value)
+ #
+ # # This is called when the editor is submitted use it to retrieve data
+ # # from your input and save it to the annotation.
+ # submit: (field, annotation) ->
+ # value = $(field).find('input').val()
+ # annotation.tags = getTagsFromString(value)
+ # })
+ #
+ # # Add a new checkbox element.
+ # editor.addField({
+ # type: 'checkbox',
+ # id: 'annotator-field-my-checkbox',
+ # label: 'Allow anyone to see this annotation',
+ # load: (field, annotation) ->
+ # # Check what state of input should be.
+ # if checked
+ # $(field).find('input').attr('checked', 'checked')
+ # else
+ # $(field).find('input').removeAttr('checked')
+
+ # submit: (field, annotation) ->
+ # checked = $(field).find('input').is(':checked')
+ # # Do something.
+ # })
+ #
+ # Returns the created
"},postRender:function(){var e=this;e._super(),e.settings.activeTab=e.settings.activeTab||0,e.activateTab(e.settings.activeTab),this.on("click",function(t){var n=t.target.parentNode;if(t.target.parentNode.id==e._id+"-head")for(var r=n.childNodes.length;r--;)n.childNodes[r]==t.target&&e.activateTab(r)})},initLayoutRect:function(){var e=this,t,r,i;r=n.getSize(e.getEl("head")).width,r=0>r?0:r,i=0,e.items().each(function(e){r=Math.max(r,e.layoutRect().minW),i=Math.max(i,e.layoutRect().minH)}),e.items().each(function(e){e.settings.x=0,e.settings.y=0,e.settings.w=r,e.settings.h=i,e.layoutRect({x:0,y:0,w:r,h:i})});var o=n.getSize(e.getEl("head")).height;return e.settings.minWidth=r,e.settings.minHeight=i+o,t=e._super(),t.deltaH+=o,t.innerH=t.h-t.deltaH,t}})}),r($t,[ke],function(e){return e.extend({init:function(e){var t=this;t._super(e),t.classes.add("textbox"),e.multiline?t.classes.add("multiline"):(t.on("keydown",function(e){var n;13==e.keyCode&&(e.preventDefault(),t.parents().reverse().each(function(e){return e.toJSON?(n=e,!1):void 0}),t.fire("submit",{data:n.toJSON()}))}),t.on("keyup",function(e){t.state.set("value",e.target.value)}))},repaint:function(){var e=this,t,n,r,i,o=0,a;t=e.getEl().style,n=e._layoutRect,a=e._lastRepaintRect||{};var s=document;return!e.settings.multiline&&s.all&&(!s.documentMode||s.documentMode<=8)&&(t.lineHeight=n.h-o+"px"),r=e.borderBox,i=r.left+r.right+8,o=r.top+r.bottom+(e.settings.multiline?8:0),n.x!==a.x&&(t.left=n.x+"px",a.x=n.x),n.y!==a.y&&(t.top=n.y+"px",a.y=n.y),n.w!==a.w&&(t.width=n.w-i+"px",a.w=n.w),n.h!==a.h&&(t.height=n.h-o+"px",a.h=n.h),e._lastRepaintRect=a,e.fire("repaint",{},!1),e},renderHtml:function(){var e=this,t=e._id,n=e.settings,r=e.encode(e.state.get("value"),!1),i="";return"spellcheck"in n&&(i+=' spellcheck="'+n.spellcheck+'"'),n.maxLength&&(i+=' maxlength="'+n.maxLength+'"'),n.size&&(i+=' size="'+n.size+'"'),n.subtype&&(i+=' type="'+n.subtype+'"'),e.disabled()&&(i+=' disabled="disabled"'),n.multiline?'":'"},value:function(e){return arguments.length?(this.state.set("value",e),this):(this.state.get("rendered")&&this.state.set("value",this.getEl().value),this.state.get("value"))},postRender:function(){var e=this;e._super(),e.$el.on("change",function(t){e.state.set("value",t.target.value),e.fire("change",t)})},bindStates:function(){var e=this;return e.state.on("change:value",function(t){e.getEl().value!=t.value&&(e.getEl().value=t.value)}),e.state.on("change:disabled",function(t){e.getEl().disabled=t.value}),e._super()},remove:function(){this.$el.off(),this._super()}})}),r(qt,[g,he,u],function(e,t,n){return function(r,i){var o=this,a,s=t.classPrefix;o.show=function(t,l){return o.hide(),a=!0,n.setTimeout(function(){a&&(e(r).append(''),l&&l())},t),o},o.hide=function(){var e=r.lastChild;return e&&-1!=e.className.indexOf("throbber")&&e.parentNode.removeChild(e),a=!1,o}}}),a([l,c,u,d,f,h,m,g,v,y,C,w,E,N,T,A,B,D,M,L,P,H,I,F,j,Y,G,J,ee,te,ne,re,oe,se,le,fe,he,pe,me,ge,ve,ye,be,Ce,xe,we,Ee,Ne,_e,Se,ke,Te,Re,Ae,Me,Pe,Ke,Ge,Je,Qe,et,tt,nt,rt,it,ot,at,st,lt,ct,ut,dt,ft,ht,pt,mt,gt,vt,yt,bt,Ct,xt,wt,Et,Nt,_t,St,kt,Tt,Rt,At,Bt,Dt,Mt,Lt,Pt,Ht,Ot,It,Ft,zt,Wt,Vt,Ut,$t,qt])}(this);
\ No newline at end of file
diff --git a/src/plugin/touch.coffee b/src/plugin/touch.coffee
new file mode 100644
index 000000000..74e4401de
--- /dev/null
+++ b/src/plugin/touch.coffee
@@ -0,0 +1,417 @@
+# Plugin for the Annotator to improve the experience on touch devices. In
+# general it wraps the Viewer and Editor elements and increases the hit area
+# of buttons. Getting the selected text is handled by polling the
+# getSelection() method on the window object. This is supported by most
+# devices that implement native text selection tools such as Safari on iOS.
+#
+# Examples
+#
+# jQuery("#annotator").annotator().annotator('addPlugin', 'Touch');
+#
+# Returns a new instance of the Touch plugin.
+class Annotator.Plugin.Touch extends Annotator.Plugin
+ # Export some useful globals into the class scope.
+ _t = Annotator._t
+ jQuery = Annotator.$
+
+ # States for the "data-state" property on the annotator-touch-controls
+ # element. ON means the annotattor is enabled. OFF is disabled.
+ @states: ON: "on", OFF: "off"
+
+ # Template for the Touch annotator controls.
+ template: """
+
+ """
+
+ # Classes to be used to control the state.
+ classes:
+ hide: "annotator-touch-hide"
+
+ # Instance options can be used to configure the annotator at runtime.
+ options:
+ # Forces the touch controls to be loaded into the page. This is useful
+ # for testing or if the annotator will always be used in a touch device
+ # (say when bundled into an application).
+ force: false
+
+ # For devices that do not have support for accessing the browsers selected
+ # text this plugin supports the inclusion of the Highlighter library that
+ # goes someway to implementing these features in JavaScript.
+ useHighlighter: false
+
+ # Initialises the plugin and sets up instance variables.
+ #
+ # element - The root Annotator element.
+ # options - An object of options for the plugin see @options.
+ # force: Should force plugin on desktop (default: false).
+ # useHighlighter: Should use Highlighter (default: false).
+ #
+ # Returns nothing.
+ constructor: (element, options) ->
+ super
+
+ @utils = Annotator.Plugin.Touch.utils
+ @selection = null
+ @document = jQuery(document)
+
+ # Internal: Updates the plugin after the Annotator has been loaded and
+ # attached to the plugin instance. This should be used to register
+ # Editor and Viewer fields.
+ #
+ # Returns nothing.
+ pluginInit: ->
+ return unless Annotator.supported() and (@options.force or Touch.isTouchDevice())
+
+ @_setupControls()
+
+ # Only need this for some Android browsers at the moment. The simulator
+ # fails to select the highlights but the Galaxy Tab running 3.2 works
+ # okay. There is no way to feature detect whether or not the Highlighter
+ # should be used so it must be enabled with @options.useHighlighter.
+ if @options.useHighlighter
+ @showControls()
+ @highlighter = new Highlighter
+ root: @element[0]
+ prefix: "annotator-selection"
+ enable: false
+ highlightStyles: true
+
+ # Bind tap event listeners to the highlight elements. We delegate to the
+ # document rather than the container to prevent WebKit requiring a
+ # double tap to bring up the text selection tool.
+ @document.delegate(".annotator-hl", "tap", preventDefault: false, @_onHighlightTap)
+
+ @subscribe("selection", @_onSelection)
+
+ @_unbindAnnotatorEvents()
+ @_setupAnnotatorEvents()
+ @_watchForSelection()
+
+ # Internal: Method for tearing down a plugin, removing all event listeners
+ # and timers etc that it has created. This should be called when the plugin
+ # is removed from the DOM.
+ #
+ # Examples
+ #
+ # annotator.element.remove()
+ # touch.pluginDestroy()
+ #
+ # Returns nothing.
+ pluginDestroy: ->
+ @controls.remove() if @controls
+ @highlighter.disable() if @highlighter
+ @annotator.editor.unsubscribe "hide", @_watchForSelection if @annotator
+
+ # Public: Enables the highlighter and the annotator button. This is only
+ # used when the highlighter is used to switch between JavaScript and
+ # Native text selection.
+ #
+ # Examples
+ #
+ # touch.startAnnotating()
+ #
+ # Returns itself.
+ startAnnotating: ->
+ @highlighter.enable() if @highlighter
+ @toggle.attr("data-state", Touch.states.ON)
+ @toggle.html("Stop Annotating")
+ this
+
+ # Public: Disables the highlighter and the annotator button.
+ #
+ # Examples
+ #
+ # touch.startAnnotating()
+ #
+ # Returns itself.
+ stopAnnotating: ->
+ @highlighter.disable() if @highlighter
+ @toggle.attr("data-state", Touch.states.OFF)
+ @toggle.html("Start Annotating")
+ this
+
+ # Public: Checks to see if the annotator is currently enabled.
+ #
+ # Examples
+ #
+ # if touch.isAnnotating() then doSomething()
+ #
+ # Returns true if the annotator is enabled.
+ isAnnotating: ->
+ usingHighlighter = @options.useHighlighter
+ not usingHighlighter or @toggle.attr("data-state") is Touch.states.ON
+
+ # Public: Shows the Editor and hides the Touch controls.
+ #
+ # annotation - An annotation object to load into the Editor.
+ #
+ # Returns itself.
+ showEditor: (annotation) ->
+ @annotator.showEditor(annotation, {})
+ @hideControls()
+ this
+
+ # Public: Displays the touch controls.
+ #
+ # Returns itself.
+ showControls: ->
+ @controls.removeClass(@classes.hide)
+ this
+
+ # Public: Hides the touch controls.
+ #
+ # Returns itself.
+ hideControls: ->
+ @controls.addClass(@classes.hide) unless @options.useHighlighter
+ this
+
+ # Sets up the touch controls and binds events, also removes the default
+ # adder. Should only be called in the @pluginInit() method.
+ #
+ # Returns nothing.
+ _setupControls: ->
+ @annotator.adder.remove()
+
+ @controls = jQuery(@template).appendTo("body")
+
+ @adder = @controls.find(".annotator-add")
+ @adder.bind("tap", (onTapDown: (event) -> event.stopPropagation()), @_onAdderTap)
+
+ @toggle = @controls.find(".annotator-touch-toggle")
+ @toggle.bind("tap": @_onToggleTap)
+ @toggle.hide() unless @options.useHighlighter
+
+ # Setup method that creates the @editor and @viewer properties. Should
+ # only be called once by the @pluginInit() method.
+ #
+ # Returns nothing.
+ _setupAnnotatorEvents: ->
+ # Wrap the interface elements with touch controls.
+ @editor = new Touch.Editor(@annotator.editor)
+ @viewer = new Touch.Viewer(@annotator.viewer)
+
+ # Ensure the annotate buttom is hidden when the interface is visible.
+ @annotator.editor.on "show", =>
+ @_clearWatchForSelection()
+ @annotator.onAdderMousedown()
+ @highlighter.disable() if @highlighter
+
+ @annotator.viewer.on "show", =>
+ @highlighter.disable() if @highlighter
+
+ @annotator.editor.on "hide", =>
+ @utils.nextTick =>
+ @highlighter.enable().deselect() if @highlighter
+ @_watchForSelection()
+
+ @annotator.viewer.on "hide", =>
+ @utils.nextTick =>
+ @highlighter.enable().deselect() if @highlighter
+
+ # Removes the default mouse event bindings created by the Annotator.
+ #
+ # Returns nothing.
+ _unbindAnnotatorEvents: ->
+ # Remove mouse events from document.
+ @document.unbind
+ "mouseup": @annotator.checkForEndSelection
+ "mousedown": @annotator.checkForStartSelection
+
+ # Unbind mouse events from the root element to prevent the iPad giving
+ # it a grey selected outline when interacted with.
+ # NOTE: This currently unbinds _all_ events event those set up by
+ # other plugins.
+ @element.unbind("click mousedown mouseover mouseout")
+
+ # Begins a timer stored in @timer that polls the page to see if a selection
+ # has been made. Clear the timer with @_clearWatchForSelection().
+ #
+ # Examples
+ #
+ # jQuery(window).focus(touch._watchForSelection)
+ #
+ # Returns nothing.
+ _watchForSelection: =>
+ return if @timer
+
+ # There are occsions where Android will clear the text selection before
+ # firing touch events. So we slow down the polling to ensure that touch
+ # events get time to read the current selection.
+ interval = if Touch.isAndroid() then 300 else 1000 / 60
+ start = new Date().getTime()
+
+ # Use request animation frame despite the fact it runs to regularly to
+ # take advantage of the fact it stops running when the window is idle.
+ # If this becomes a performance bottleneck consider switching to a
+ # longer setTimeout() and managing the start/stop manually.
+ step = =>
+ progress = (new Date().getTime()) - start
+ if progress > interval
+ start = new Date().getTime()
+ @_checkSelection()
+ @timer = @utils.requestAnimationFrame.call(window, step)
+ step()
+
+ # Clears the @timer that polls for selections in the document. Call this
+ # when the user is idle or selection is not required.
+ #
+ # Returns nothing.
+ _clearWatchForSelection: ->
+ @utils.cancelAnimationFrame.call(window, @timer)
+ @timer = null
+
+ # Checks the current text selection and if changed fires the "selection"
+ # event with the currently selected Range object and the plugin instance
+ # passed in as an argument.
+ #
+ # Returns nothing.
+ _checkSelection: ->
+ selection = window.getSelection()
+ previous = @selectionString
+ string = jQuery.trim(selection + "")
+
+ if selection.rangeCount and string isnt @selectionString
+ @range = selection.getRangeAt(0)
+ @selectionString = string
+
+ if selection.rangeCount is 0 or (@range and @range.collapsed)
+ @range = null
+ @selectionString = ""
+
+ @publish("selection", [@range, this]) unless @selectionString is previous
+
+ # Determines whether or not to show the annotator button depending on the
+ # current text selection.
+ #
+ # Examples
+ #
+ # plugin.subscribe("selection", @_onSelection)
+ #
+ # Returns nothing.
+ _onSelection: =>
+ if @isAnnotating() and @range and @_isValidSelection(@range)
+ @adder.removeAttr("disabled")
+ @showControls()
+ else
+ @adder.attr("disabled", "")
+ @hideControls()
+
+ # Checks to see if any part of the provided Range object falls within the
+ # annotator element.
+ #
+ # range - A native Range instance.
+ #
+ # Examples
+ #
+ # range = window.getSelectedText().rangeAt(0)
+ # if touch._isValidSelection(range) then annotateText()
+ #
+ # Returns true if the annotator element contains selected nodes.
+ _isValidSelection: (range) ->
+ # jQuery.contains() doesn't appear to work with range nodes.
+ inElement = (node) -> jQuery(node).parents('.annotator-wrapper').length
+
+ isStartOffsetValid = range.startOffset < range.startContainer.length
+ isValidStart = isStartOffsetValid and inElement(range.startContainer)
+ isValidEnd = range.endOffset > 0 and inElement(range.endContainer)
+
+ isValidStart or isValidEnd
+
+ # Event callback for the Annotator Start/Stop button.
+ #
+ # event - A jQuery.Event touch event object.
+ #
+ # Returns nohting.
+ _onToggleTap: (event) =>
+ event.preventDefault()
+ if @isAnnotating() then @stopAnnotating() else @startAnnotating()
+
+ # Event callback for the Annotate adder button. Checks the current selection
+ # and displays the editor.
+ #
+ # event - A jQuery.Event touch event object.
+ #
+ # Returns nothing.
+ _onAdderTap: (event) =>
+ event.preventDefault()
+ if @range
+ browserRange = new Annotator.Range.BrowserRange(@range)
+ range = browserRange.normalize().limit(@element[0])
+
+ if range and not @annotator.isAnnotator(range.commonAncestor)
+ # Here we manually apply our captured range to the annotation object
+ # because we cannot rely on @selectedRanges on touch browsers.
+ onAnnotationCreated = (annotation) =>
+ @annotator.unsubscribe('beforeAnnotationCreated', onAnnotationCreated)
+ annotation.quote= range.toString()
+ annotation.ranges = [range]
+
+ @annotator.subscribe('beforeAnnotationCreated', onAnnotationCreated)
+
+ # Trigger the main adder handler which handles displaying the editor
+ # and triggering the correct events for persistance.
+ @annotator.onAdderClick(event)
+
+ # Event callback for tap events on highlights and displays the Viewer.
+ # Allows events on anchor elements and those with the
+ # "data-annotator-clickable" attribute to pass through. Watches the
+ # document for further taps in order to remove the viewer.
+ #
+ # event - A jQuery.Event touch event object.
+ #
+ # Returns nothing.
+ _onHighlightTap: (event) =>
+ # Check to see if clicked element should be ignored.
+ clickable = jQuery(event.currentTarget).parents().filter ->
+ jQuery(this).is('a, [data-annotator-clickable]')
+ return if clickable.length
+
+ if jQuery.contains(@element[0], event.currentTarget)
+ original = event.originalEvent
+ if original and original.touches
+ event.pageX = original.touches[0].pageX
+ event.pageY = original.touches[0].pageY
+
+ @annotator.viewer.hide() if @annotator.viewer.isShown()
+ @annotator.onHighlightMouseover(event)
+
+ @document.unbind("tap", @_onDocumentTap)
+ @document.bind("tap", preventDefault: false, @_onDocumentTap)
+
+ # Event handler for document taps. This is used to hide the viewer when
+ # the document it tapped.
+ #
+ # event - A jQuery.Event touch event object.
+ #
+ # Returns nothing.
+ _onDocumentTap: (event) =>
+ unless @annotator.isAnnotator(event.target)
+ @annotator.viewer.hide()
+ @document.unbind("tap", @_onDocumentTap) unless @annotator.viewer.isShown()
+
+ # Public: Checks to see if the current device is capable of handling
+ # touch events.
+ #
+ # Examples
+ #
+ # if Touch.isTouchDevice()
+ # # Browser handles touch events.
+ # else
+ # # Browser does not handle touch events.
+ #
+ # Returns true if the device appears so support touch events.
+ @isTouchDevice: ->
+ ('ontouchstart' of window) or window.DocumentTouch and document instanceof DocumentTouch
+
+ # Public: Horrible browser sniffing hack for detecting Android, this should
+ # only be used to fix bugs in the browser where feature detection cannot
+ # be used.
+ #
+ # Returns true if the browser's user agent contains the string "Android".
+ @isAndroid: ->
+ (/Android/i).test(window.navigator.userAgent)
diff --git a/src/plugin/touch_editor.coffee b/src/plugin/touch_editor.coffee
new file mode 100644
index 000000000..de6afe66c
--- /dev/null
+++ b/src/plugin/touch_editor.coffee
@@ -0,0 +1,177 @@
+# Wrapper around the Annotator.Editor class. Augments the interface with
+# tap friendly buttons and touch event handlers. Rather than creating a new
+# class or extending the Annotator.Editor class we use the wrapper to
+# change the current interface without having to heavily monkey patch the
+# Annotator core.
+class Annotator.Plugin.Touch.Editor extends Annotator.Delegator
+ # Export local globals. These are only available within the class closure.
+ _t = Annotator._t
+ jQuery = Annotator.$
+ Touch = Annotator.Plugin.Touch
+
+ # DOM event handlers and event subscriptions.
+ events:
+ # Use click for the overlay rather than tap to allow scrolling.
+ "click": "_onOverlayTap"
+ ".annotator-save tap": "_onSubmit"
+ ".annotator-cancel tap": "_onCancel"
+ ".annotator-quote-toggle tap": "_onExpandTap"
+
+ # Classes for managing the state of the application.
+ classes:
+ expand: "annotator-touch-expand"
+
+ # General templates.
+ templates:
+ quote: """
+
+
+ """
+
+ # Sets up a new instance of the editor wrapper and augments the @editor
+ # element with the new interface elements.
+ #
+ # editor - An instance of Annotator.Editor.
+ # options - An object of options.
+ #
+ # Returns nothing.
+ constructor: (@editor, options) ->
+ super @editor.element[0], options
+ @element.addClass("annotator-touch-editor")
+ @element.wrapInner('')
+ @element.find("form").addClass("annotator-touch-widget-inner")
+ @element.find(".annotator-controls a").addClass("annotator-button")
+
+ # Remove the "return to submit" listener.
+ @element.undelegate("textarea", "keydown")
+ @on "hide", => @element.find(":focus").blur()
+
+ @_setupQuoteField()
+ @_setupAndroidRedrawHack()
+
+ # Expands the quote field to display more than one line.
+ #
+ # Examples
+ #
+ # editor.showQuote()
+ #
+ # Returns itself.
+ showQuote: ->
+ @quote.addClass(@classes.expand)
+ @quote.find("button").text _t("Collapse")
+ this
+
+ # Collapses the quote field to display only one line.
+ #
+ # Examples
+ #
+ # editor.hideQuote()
+ #
+ # Returns itself.
+ hideQuote: ->
+ @quote.removeClass(@classes.expand)
+ @quote.find("button").text _t("Expand")
+ this
+
+ # Public: Checks to see if the quote is expanded/collapsed.
+ #
+ # Returns true if the quote is collapsed.
+ isQuoteHidden: ->
+ not @quote.hasClass(@classes.expand)
+
+ # Adds the @quote field to the @editor. Should only be called once in the
+ # constructor.
+ #
+ # Returns nothing.
+ _setupQuoteField: ->
+ @quote = jQuery @editor.addField
+ id: 'quote'
+ load: (field, annotation) =>
+ @hideQuote()
+ @quote.find('span').html Annotator.Util.escape(annotation.quote || '')
+ @quote.find("button").toggle(@_isTruncated())
+
+ @quote.empty().addClass("annotator-item-quote")
+ @quote.append(@templates.quote)
+
+ # Sets up a very spcific hack for android to redraw the view when the
+ # editor is displayed. The Android browser overlays it's own text box
+ # on to of the editor when focused, however this does not scroll with the
+ # rest of the UI. So to trigger this we slighly change the size of the
+ # focused input on scroll so the box is redrawn.
+ #
+ # This was tested on a Galaxy Tab running 3.2, hopeully this will be
+ # resolved in a future release.
+ #
+ # Returns nothing.
+ _setupAndroidRedrawHack: ->
+ if Touch.isAndroid()
+ timer = null
+ check = => timer = null; @_triggerAndroidRedraw()
+ jQuery(window).bind "scroll", ->
+ timer = setTimeout(check, 100) unless timer
+
+ # Forces the Android browser to redraw it's custom text input that it
+ # overlays on top of the webkit fields. See @_setupAndroidRedrawHack()
+ # for details.
+ #
+ # Returns nothing.
+ _triggerAndroidRedraw: =>
+ @_input = @element.find(":input:first") unless @_input
+ @_default = parseFloat(@_input.css "padding-top") unless @_default
+ @_multiplier = (@_multiplier or 1) * -1
+ @_input[0].style.paddingTop = (@_default + @_multiplier) + "px"
+ @_input[0].style.paddingTop = (@_default - @_multiplier) + "px"
+
+ # Determines if the quoted text is larger than the containing element
+ # when collapsed. This can be used to display the expand/collapse button.
+ #
+ # Returns true if the text is larger than the containing element.
+ _isTruncated: ->
+ isHidden = @isQuoteHidden()
+
+ @hideQuote() unless isHidden
+ truncatedHeight = @quote.height()
+ @showQuote()
+ expandedHeight = @quote.height()
+
+ # Restore previous state.
+ if isHidden then @hideQuote() else @showQuote()
+
+ return expandedHeight > truncatedHeight
+
+ # Event handler for the expand button in the quote field.
+ #
+ # event - A jQuery.Event tap event object.
+ #
+ # Returns nothing.
+ _onExpandTap: (event) =>
+ event.preventDefault()
+ event.stopPropagation()
+ if @isQuoteHidden() then @showQuote() else @hideQuote()
+
+ # Event handler for the submit button in the editor.
+ #
+ # event - A jQuery.Event tap event object.
+ #
+ # Returns nothing.
+ _onSubmit: (event) =>
+ event.preventDefault()
+ @editor.submit()
+
+ # Event handler for the cancel button in the editor.
+ #
+ # event - A jQuery.Event tap event object.
+ #
+ # Returns nothing.
+ _onCancel: (event) =>
+ event.preventDefault()
+ @editor.hide()
+
+ # Event handler for the overlay.
+ #
+ # event - A jQuery.Event click event object.
+ #
+ # Returns nothing.
+ _onOverlayTap: (event) =>
+ @editor.hide() if event.target is @element[0]
diff --git a/src/plugin/touch_utils.coffee b/src/plugin/touch_utils.coffee
new file mode 100644
index 000000000..82f756089
--- /dev/null
+++ b/src/plugin/touch_utils.coffee
@@ -0,0 +1,131 @@
+# Adds a new "tap" event to jQuery. This offers improved performance over
+# click for touch devices whcih often have up to a 300ms delay before
+# triggering callbacks. Instead it uses a combination of touchstart and
+# touchend events to to create a fake click. It will also cancel the event
+# after 300ms (to allow the user to perform a "longtap") or if the touchend
+# event is triggered on a different element.
+#
+# Additonal options can be provided as part of the eventData object.
+#
+# preventDefault - If false will not call preventDefault() on the touchstart
+# event (deafult: true).
+# onTapDown - Callback for the "touchstart" incase additonal code needs
+# to be run such as event.stopPropagation().
+# onTapUp - Callabck for the "touchend" event, called after the main
+# event handler.
+# timeout - Time to allow before cancelling the event (default: 300).
+#
+# Example
+#
+# jQuery("a").bind "tap", =>
+# # This is called on "touchend" on the same element.
+#
+# options =
+# preventDefault: false
+# onTapDown: (event) -> event.stopPropagation()
+# jQuery(doument).delegate "button", "tap", options, =>
+# # This is called on "touchend" on the same element.
+jQuery.event.special.tap =
+ add: (eventHandler) ->
+ data = eventHandler.data = eventHandler.data or {}
+ context = this
+
+ onTapStart = (event) ->
+ event.preventDefault() unless data.preventDefault is false
+ data.onTapDown.apply(this, arguments) if data.onTapDown
+
+ data.event = event
+ data.touched = setTimeout ->
+ data.touched = null
+ , data.timeout or 300
+ jQuery(document).bind(touchend: onTapEnd, mouseup: onTapEnd)
+
+ onTapEnd = (event) ->
+ if data.touched?
+ clearTimeout(data.touched)
+ if event.target is context or jQuery.contains(context, event.target)
+ handler = eventHandler.origHandler or eventHandler.handler
+ handler.call(this, data.event)
+ data.touched = null
+
+ data.onTapUp.apply(this, arguments) if data.onTapUp
+
+ jQuery(document).unbind(touchstart: onTapEnd, mousedown: onTapEnd)
+
+ data.tapHandlers = touchstart: onTapStart, mousedown: onTapStart
+ if eventHandler.selector
+ jQuery(context).delegate(eventHandler.selector, data.tapHandlers)
+ else
+ jQuery(context).bind(data.tapHandlers)
+
+ remove: (eventHandler) ->
+ jQuery(this).unbind(eventHandler.data.tapHandlers)
+
+# Add support for "touch" events.
+Annotator.Delegator.natives.push("touchstart", "touchmove", "touchend", "tap")
+
+Annotator.Plugin.Touch.utils = do ->
+ # Pinched from Paul Irish's blog.
+ # See: http://paulirish.com/2011/requestanimationframe-for-smart-animating/
+ vendors = ['ms', 'moz', 'webkit', 'o']
+
+ requestAnimationFrame = window.requestAnimationFrame
+ cancelAnimationFrame = window.cancelAnimationFrame
+
+ for prefix in vendors when !requestAnimationFrame
+ requestAnimationFrame = window["#{prefix}RequestAnimationFrame"]
+ cancelAnimationFrame = window["#{prefix}CancelAnimationFrame"] or
+ window["#{prefix}CancelRequestAnimationFrame"]
+
+ unless requestAnimationFrame
+ lastTime = 0
+ requestAnimationFrame = (callback, element) ->
+ currTime = new Date().getTime()
+ timeToCall = Math.max(0, 16 - (currTime - lastTime))
+ lastTime = currTime + timeToCall
+ window.setTimeout((-> callback(currTime + timeToCall)), timeToCall)
+
+ unless cancelAnimationFrame
+ cancelAnimationFrame = (id) -> clearTimeout(id)
+
+ {
+ # Public: Cross browser compatibile version of requestAnimationFrame().
+ #
+ # callback - A function to be called when the next frame is available.
+ #
+ # Examples
+ #
+ # var id = utils.requestAnimationFrame ->
+ # doSomethingCool()
+ #
+ # Returns a id to cancel the request.
+ requestAnimationFrame: requestAnimationFrame
+
+ # Public: Cross browser compatibile version of cancelAnimationFrame().
+ #
+ # id - A request id.
+ #
+ # Examples
+ #
+ # id = utils.requestAnimationFrame ->
+ # thisWillNeverBeCalled()
+ # utils.cancelAnimationFrame(id)
+ #
+ # Returns nothing.
+ cancelAnimationFrame: cancelAnimationFrame
+
+ # Public: Defer a callback until the next available moment. This is useful
+ # for queuing a function to run in the near future for example to run a
+ # function after the current callback stack has run.
+ #
+ # fn - A function to defer.
+ #
+ # Examples
+ #
+ # annotator.editor.on "show", ->
+ # # Hide viewer after rest of "show" events have fired.
+ # utils.nextTick(annotator.viewer.show)
+ #
+ # Returns nothing.
+ nextTick: (fn) -> setTimeout(fn, 0)
+ }
diff --git a/src/plugin/touch_viewer.coffee b/src/plugin/touch_viewer.coffee
new file mode 100644
index 000000000..e18cecde0
--- /dev/null
+++ b/src/plugin/touch_viewer.coffee
@@ -0,0 +1,77 @@
+# Wrapper around the Annotator.Viewer class. Augments the interface with
+# tap friendly buttons and touch event handlers. Rather than creating a new
+# class or extending the Annotator.Viewer class we use the wrapper to
+# change the current interface without having to heavily monkey patch the
+# Annotator core.
+class Annotator.Plugin.Touch.Viewer extends Annotator.Delegator
+ jQuery = Annotator.$
+
+ # Events bound to the element.
+ events:
+ ".annotator-item tap": "_onTap"
+ ".annotator-edit tap": "_onEdit"
+ ".annotator-delete tap": "_onDelete"
+
+ # Sets up the wrapper and instance methods.
+ #
+ # viewer - An instance of Annotator.Viewer.
+ # options - An object of instance options.
+ #
+ # Returns nothing.
+ constructor: (@viewer, options) ->
+ super @viewer.element[0], options
+
+ @element.unbind("click")
+ @element.addClass("annotator-touch-widget annotator-touch-viewer")
+
+ @on("load", @_onLoad)
+
+ # Public: Hides edit controls for all displayed annotations.
+ #
+ # Examples
+ #
+ # jQuery(document).click ->
+ # viewer.hideAllControls()
+ #
+ # Returns itself.
+ hideAllControls: ->
+ @element.find(".annotator-item").removeClass(@viewer.classes.showControls)
+ this
+
+ # Event handler called when a field is loaded. Augments the field with
+ # additonal classes and event handlers.
+ #
+ # Returns nothing.
+ _onLoad: =>
+ controls = @element.find(".annotator-controls")
+ controls.toggleClass("annotator-controls annotator-touch-controls")
+ controls.find("button").addClass("annotator-button")
+
+ # Callback event called when a field is tapped.
+ #
+ # event - A jQuery.Event touchend event.
+ #
+ # Returns nothing.
+ _onTap: (event) ->
+ target = jQuery(event.currentTarget)
+ isVisible = target.hasClass(@viewer.classes.showControls)
+ @hideAllControls()
+ target.addClass(@viewer.classes.showControls) unless isVisible
+
+ # Callback event called when an edit button is tapped.
+ #
+ # event - A jQuery.Event touchend event.
+ #
+ # Returns nothing.
+ _onEdit: (event) ->
+ event.preventDefault()
+ @viewer.onEditClick(event)
+
+ # Callback event called when an delete button is tapped.
+ #
+ # event - A jQuery.Event touchend event.
+ #
+ # Returns nothing.
+ _onDelete: (event) ->
+ event.preventDefault()
+ @viewer.onDeleteClick(event)
diff --git a/tools/preamble b/tools/preamble
index 42fdc81c9..433abb5bb 100755
--- a/tools/preamble
+++ b/tools/preamble
@@ -1,17 +1,15 @@
+# Change the format of End of Line char
cd "$(dirname "$0")"
-
DATE=$(date -u "+%Y-%m-%d %H:%M:%SZ")
YEAR=$(date -u "+%Y")
-
# ./tools/make_release exports VERSION, so use that if available
if [ -n "$VERSION" ]; then
VERSION="v${VERSION}"
else
VERSION="v$(echo "$(grep version ../package.json | cut -d\" -f4)-dev-$(git describe --always)")"
fi
-
# print preamble, substituting variables
cat ../src/preamble.coffee |
sed -e "s/{{VERSION}}/$VERSION/g" \
-e "s/{{YEAR}}/$YEAR/g" \
- -e "s/{{DATE}}/$DATE/g"
+ -e "s/{{DATE}}/$DATE/g"
\ No newline at end of file