FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
339
sites/all/modules/contrib/fields/autocomplete_deluxe/LICENSE.txt
Normal file
339
sites/all/modules/contrib/fields/autocomplete_deluxe/LICENSE.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 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.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
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 Program or any portion
|
||||
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
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 Program, 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 Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) 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; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, 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 executable. However, as a
|
||||
special exception, the source code 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.
|
||||
|
||||
If distribution of executable or 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 counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program 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.
|
||||
|
||||
5. 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 Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program 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 to
|
||||
this License.
|
||||
|
||||
7. 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 Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program 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 Program.
|
||||
|
||||
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.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program 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.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies 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 Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, 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
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. 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 PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; 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.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Enhanced autocomplete widget for drupal 7.x
|
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This contains documentation only.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Using the Autocomplete Deluxe element.
|
||||
*
|
||||
* When you want to use the Autocomplete Deluxe element, you have to choose
|
||||
* between two types sources for the suggestion data: Ajax Callbacks or Lists.
|
||||
* You can set the source type by using the appropriate options:
|
||||
* - #autocomplete_deluxe_path expects a string with an url, that points to the ajax
|
||||
* callback. The response should be encoded as json(like for the core
|
||||
* autocomplete).
|
||||
* - #autocomplete_options needs an array in the form of an array(similar to #options in core
|
||||
* for selects or checkboxes): array('a', 'b', 'c') or array(1 => 'a', 2 =>
|
||||
* 'b', 3 => 'c').
|
||||
*
|
||||
* Besides this two, there are three other options, wich autocomplete deluxe
|
||||
* accepts:
|
||||
* - #multiple Indicates whether the user may select more than one item. Expects
|
||||
* TRUE or FALSE, by default it is set to FALSE.
|
||||
* - #autocomplete_multiple_delimiter If #multiple is TRUE, then you can use
|
||||
* this option to set a seperator for multiple values. By default a string
|
||||
* with the follwing content will be used: ', '.
|
||||
* - #autocomplete_min_length Indicates how many characters must be entered
|
||||
* until, the suggesion list can be opened. Especially helpfull, when your
|
||||
* ajax callback returns only valid suggestion for a minimum characters.
|
||||
* The default is 0.
|
||||
*/
|
||||
function somefunction() {
|
||||
switch ($type) {
|
||||
case 'list':
|
||||
$element = array(
|
||||
'#type' => 'autocomplete_deluxe',
|
||||
'#autocomplete_options' => $options,
|
||||
'#multiple' => FALSE,
|
||||
'#autocomplete_min_length' => 0,
|
||||
);
|
||||
break;
|
||||
case 'ajax':
|
||||
$element = array(
|
||||
'#type' => 'autocomplete_deluxe',
|
||||
'#autocomplete_deluxe_path' => url('some_uri', array('absolute' => TRUE)),
|
||||
'#multiple' => TRUE,
|
||||
'#autocomplete_min_length' => 1,
|
||||
'#autocomplete_multiple_delimiter' => '|',
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
@@ -0,0 +1,184 @@
|
||||
@CHARSET "UTF-8";
|
||||
|
||||
|
||||
ul.ui-autocomplete {
|
||||
max-height: 240px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
a.autocomplete-deluxe-single:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.ui-autocomplete .ui-state-hover {
|
||||
background-color: #3875d7;
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
|
||||
background-image: -webkit-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
background-image: -moz-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
background-image: -o-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
background-image: -ms-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
background-image: linear-gradient(top, #3875d7 20%, #2a62bc 90%);
|
||||
color: #fff;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.autocomplete-deluxe-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
padding: 0;
|
||||
border: 1px solid #CCCCCC;
|
||||
background: no-repeat -38px -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background: no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
}
|
||||
div.autocomplete-deluxe-container input.autocomplete-deluxe-form {
|
||||
background: #fff no-repeat -38px -22px;
|
||||
padding: 4px 5px 4px 5px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
div.autocomplete-deluxe-container input.autocomplete-deluxe-form-single {
|
||||
width: 90%;
|
||||
border: none;
|
||||
background: no-repeat -38px -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background: no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
}
|
||||
|
||||
.autocomplete-deluxe-search {
|
||||
margin: 0px 0px 4px 0px;
|
||||
padding: 3px 4px;
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
z-index: 1010;
|
||||
}
|
||||
|
||||
span.autocomplete-deluxe-value-delete {
|
||||
display: inline-block;
|
||||
float: right;
|
||||
background:url('x.gif') no-repeat center;
|
||||
width: 18px;
|
||||
width: 18px;
|
||||
|
||||
/* Prevent text selection. */
|
||||
-moz-user-select: -moz-none;
|
||||
-khtml-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.autocomplete-deluxe-single-open {
|
||||
border: 1px solid #aaa;
|
||||
-webkit-box-shadow: 0 1px 0 #fff inset;
|
||||
-moz-box-shadow : 0 1px 0 #fff inset;
|
||||
-o-box-shadow : 0 1px 0 #fff inset;
|
||||
box-shadow : 0 1px 0 #fff inset;
|
||||
background-color: #eee;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0 );
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
|
||||
background-image: -webkit-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
background-image: -moz-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
background-image: -o-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
background-image: -ms-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
background-image: linear-gradient(top, #eeeeee 20%, #ffffff 80%);
|
||||
-webkit-border-bottom-left-radius : 0;
|
||||
-webkit-border-bottom-right-radius: 0;
|
||||
-moz-border-radius-bottomleft : 0;
|
||||
-moz-border-radius-bottomright: 0;
|
||||
border-bottom-left-radius : 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
input.autocomplete-deluxe-closed {
|
||||
}
|
||||
|
||||
div.autocomplete-deluxe-multiple {
|
||||
display: inline-block;
|
||||
font-size: 13px;
|
||||
position: relative;
|
||||
background-color: #FFFFFF;
|
||||
background: #fff no-repeat -38px -22px;
|
||||
background: no-repeat -38px -22px, -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background: no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, -ms-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
background: no-repeat -38px -22px, linear-gradient(top, #eeeeee 1%, #ffffff 15%);
|
||||
padding: 4px 5px 4px 20px;
|
||||
border: 1px solid #AAAAAA;
|
||||
cursor: text;
|
||||
height: auto !important;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
padding: 5px;
|
||||
position: relative;
|
||||
line-height:15pt;
|
||||
width: 503px;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
input.autocomplete-deluxe-form.autocomplete-deluxe-multiple {
|
||||
border: 3px none;
|
||||
width: 25px;
|
||||
margin-left: 5px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
div.autocomplete-deluxe-throbber {
|
||||
width: 16px;
|
||||
float: right;
|
||||
height: 50%;
|
||||
}
|
||||
|
||||
.autocomplete-deluxe-closed {
|
||||
background: url(throbber.gif) no-repeat 100% 6px;
|
||||
}
|
||||
|
||||
.autocomplete-deluxe-open {
|
||||
background: url(throbber.gif) no-repeat 100% -14px;
|
||||
}
|
||||
|
||||
.autocomplete-deluxe-item {
|
||||
float: left;
|
||||
background-clip: padding-box;
|
||||
background-color: #E4E4E4;
|
||||
background-image: -moz-linear-gradient(center top , #F4F4F4 20%, #F0F0F0 50%, #E8E8E8 52%, #EEEEEE 100%);
|
||||
border: 1px solid #AAAAAA;
|
||||
border-radius: 3px 3px 3px 3px;
|
||||
box-shadow: 0 0 2px #FFFFFF inset, 0 1px 0 rgba(0, 0, 0, 0.05);
|
||||
color: #333333;
|
||||
cursor: default;
|
||||
line-height: 13px;
|
||||
margin: 3px 0 3px 5px;
|
||||
padding: 3px 20px 3px 5px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.autocomplete-deluxe-item-delete {
|
||||
background: url("x.gif");
|
||||
display: block;
|
||||
font-size: 1px;
|
||||
height: 13px;
|
||||
position: absolute;
|
||||
right: 3px;
|
||||
top: 3px;
|
||||
width: 12px;
|
||||
}
|
||||
.autocomplete-deluxe-item-focus {
|
||||
background: none repeat scroll 0 0 #D4D4D4;
|
||||
}
|
||||
|
||||
.autocomplete-deluxe-highlight-char {
|
||||
color: blue;
|
||||
font-weight: bold;
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
name = Autocomplete Deluxe
|
||||
description = Enhanced autocomplete using Jquery UI autocomplete.
|
||||
package = User interface
|
||||
core = 7.x
|
||||
files[] = autocomplete_deluxe.module
|
||||
dependencies[] = taxonomy
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-05
|
||||
version = "7.x-2.0-beta3"
|
||||
core = "7.x"
|
||||
project = "autocomplete_deluxe"
|
||||
datestamp = "1375695669"
|
||||
|
@@ -0,0 +1,444 @@
|
||||
|
||||
/**
|
||||
* @file:
|
||||
* Converts textfield to a autocomplete deluxe widget.
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
Drupal.autocomplete_deluxe = Drupal.autocomplete_deluxe || {};
|
||||
|
||||
Drupal.behaviors.autocomplete_deluxe = {
|
||||
attach: function(context) {
|
||||
var autocomplete_settings = Drupal.settings.autocomplete_deluxe;
|
||||
|
||||
$('input.autocomplete-deluxe-form').once( function() {
|
||||
if (autocomplete_settings[$(this).attr('id')].multiple === true) {
|
||||
new Drupal.autocomplete_deluxe.MultipleWidget(this, autocomplete_settings[$(this).attr('id')]);
|
||||
} else {
|
||||
new Drupal.autocomplete_deluxe.SingleWidget(autocomplete_settings[$(this).attr('id')]);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Autogrow plugin which auto resizes the input of the multiple value.
|
||||
*
|
||||
* http://stackoverflow.com/questions/931207/is-there-a-jquery-autogrow-plugin-for-text-fields
|
||||
*
|
||||
*/
|
||||
$.fn.autoGrowInput = function(o) {
|
||||
|
||||
o = $.extend({
|
||||
maxWidth: 1000,
|
||||
minWidth: 0,
|
||||
comfortZone: 70
|
||||
}, o);
|
||||
|
||||
this.filter('input:text').each(function(){
|
||||
|
||||
var minWidth = o.minWidth || $(this).width(),
|
||||
val = '',
|
||||
input = $(this),
|
||||
testSubject = $('<tester/>').css({
|
||||
position: 'absolute',
|
||||
top: -9999,
|
||||
left: -9999,
|
||||
width: 'auto',
|
||||
fontSize: input.css('fontSize'),
|
||||
fontFamily: input.css('fontFamily'),
|
||||
fontWeight: input.css('fontWeight'),
|
||||
letterSpacing: input.css('letterSpacing'),
|
||||
whiteSpace: 'nowrap'
|
||||
}),
|
||||
check = function() {
|
||||
|
||||
if (val === (val = input.val())) {return;}
|
||||
|
||||
// Enter new content into testSubject
|
||||
var escaped = val.replace(/&/g, '&').replace(/\s/g,' ').replace(/</g, '<').replace(/>/g, '>');
|
||||
testSubject.html(escaped);
|
||||
|
||||
// Calculate new width + whether to change
|
||||
var testerWidth = testSubject.width(),
|
||||
newWidth = (testerWidth + o.comfortZone) >= minWidth ? testerWidth + o.comfortZone : minWidth,
|
||||
currentWidth = input.width(),
|
||||
isValidWidthChange = (newWidth < currentWidth && newWidth >= minWidth)
|
||||
|| (newWidth > minWidth && newWidth < o.maxWidth);
|
||||
|
||||
// Animate width
|
||||
if (isValidWidthChange) {
|
||||
input.width(newWidth);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
testSubject.insertAfter(input);
|
||||
|
||||
$(this).bind('keyup keydown blur update', check);
|
||||
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
Drupal.autocomplete_deluxe.empty = {label: '- ' + Drupal.t('None') + ' -', value: "" };
|
||||
|
||||
/**
|
||||
* EscapeRegex function from jquery autocomplete, is not included in drupal.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.escapeRegex = function(value) {
|
||||
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/gi, "\\$&");
|
||||
};
|
||||
|
||||
/**
|
||||
* Filter function from jquery autocomplete, is not included in drupal.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.filter = function(array, term) {
|
||||
var matcher = new RegExp(Drupal.autocomplete_deluxe.escapeRegex(term), "i");
|
||||
return $.grep(array, function(value) {
|
||||
return matcher.test(value.label || value.value || value);
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.Widget = function() {
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.Widget.prototype.uri = null;
|
||||
|
||||
/**
|
||||
* Allows widgets to filter terms.
|
||||
* @param term
|
||||
* A term that should be accepted or not.
|
||||
* @return {Boolean}
|
||||
* True if the term should be accepted.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.Widget.prototype.acceptTerm = function(term) {
|
||||
return true;
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.Widget.prototype.init = function(settings) {
|
||||
if ($.browser.msie && $.browser.version === "6.0") {
|
||||
return;
|
||||
}
|
||||
|
||||
this.id = settings.input_id;
|
||||
this.jqObject = $('#' + this.id);
|
||||
|
||||
this.uri = settings.uri;
|
||||
this.multiple = settings.multiple;
|
||||
this.required = settings.required;
|
||||
this.limit = settings.limit;
|
||||
this.synonyms = typeof settings.use_synonyms == 'undefined' ? false : settings.use_synonyms;
|
||||
|
||||
this.wrapper = '""';
|
||||
|
||||
if (typeof settings.delimiter == 'undefined') {
|
||||
this.delimiter = true;
|
||||
} else {
|
||||
this.delimiter = settings.delimiter.charCodeAt(0);
|
||||
}
|
||||
|
||||
|
||||
this.items = {};
|
||||
|
||||
var self = this;
|
||||
var parent = this.jqObject.parent();
|
||||
var parents_parent = this.jqObject.parent().parent();
|
||||
|
||||
parents_parent.append(this.jqObject);
|
||||
parent.remove();
|
||||
parent = parents_parent;
|
||||
|
||||
var generateValues = function(data, term) {
|
||||
var result = new Array();
|
||||
for (var terms in data) {
|
||||
if (self.acceptTerm(terms)) {
|
||||
result.push({
|
||||
label: data[terms],
|
||||
value: terms
|
||||
});
|
||||
}
|
||||
}
|
||||
if ($.isEmptyObject(result)) {
|
||||
result.push({
|
||||
label: Drupal.t("The term '@term' will be added.", {'@term' : term}),
|
||||
value: term,
|
||||
newTerm: true
|
||||
});
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var cache = {}
|
||||
var lastXhr = null;
|
||||
|
||||
this.source = function(request, response) {
|
||||
var term = request.term;
|
||||
if (term in cache) {
|
||||
response(generateValues(cache[term], term));
|
||||
return;
|
||||
}
|
||||
|
||||
// Some server collapse two slashes if the term is empty, so insert at
|
||||
// least a whitespace. This whitespace will later on be trimmed in the
|
||||
// autocomplete callback.
|
||||
if (!term) {
|
||||
term = " ";
|
||||
}
|
||||
request.synonyms = self.synonyms;
|
||||
var url = settings.uri + '/' + term +'/' + self.limit;
|
||||
lastXhr = $.getJSON(url, request, function(data, status, xhr) {
|
||||
cache[term] = data;
|
||||
if (xhr === lastXhr) {
|
||||
response(generateValues(data, term));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.jqObject.autocomplete({
|
||||
'source' : this.source,
|
||||
'minLength': settings.min_length
|
||||
});
|
||||
|
||||
var jqObject = this.jqObject;
|
||||
var throbber = $('<div class="autocomplete-deluxe-throbber autocomplete-deluxe-closed"> </div>').insertAfter(jqObject);
|
||||
|
||||
this.jqObject.bind("autocompletesearch", function(event, ui) {
|
||||
throbber.removeClass('autocomplete-deluxe-closed');
|
||||
throbber.addClass('autocomplete-deluxe-open');
|
||||
});
|
||||
|
||||
this.jqObject.bind("autocompleteopen", function(event, ui) {
|
||||
throbber.addClass('autocomplete-deluxe-closed');
|
||||
throbber.removeClass('autocomplete-deluxe-open');
|
||||
});
|
||||
|
||||
// Monkey patch the _renderItem function jquery so we can highlight the
|
||||
// text, that we already entered.
|
||||
$.ui.autocomplete.prototype._renderItem = function( ul, item) {
|
||||
var t = item.label;
|
||||
if (this.term != "") {
|
||||
var escapedValue = Drupal.autocomplete_deluxe.escapeRegex( this.term );
|
||||
var re = new RegExp('()*""' + escapedValue + '""|' + escapedValue + '()*', 'gi');
|
||||
var t = item.label.replace(re,"<span class='autocomplete-deluxe-highlight-char'>$&</span>");
|
||||
}
|
||||
return $( "<li></li>" )
|
||||
.data( "item.autocomplete", item )
|
||||
.append( "<a>" + t + "</a>" )
|
||||
.appendTo( ul );
|
||||
};
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.Widget.prototype.generateValues = function(data) {
|
||||
var result = new Array();
|
||||
for (var index in data) {
|
||||
result.push(data[index]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates a single selecting widget.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.SingleWidget = function(settings) {
|
||||
this.init(settings);
|
||||
this.setup();
|
||||
this.jqObject.addClass('autocomplete-deluxe-form-single');
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.SingleWidget.prototype = new Drupal.autocomplete_deluxe.Widget();
|
||||
|
||||
Drupal.autocomplete_deluxe.SingleWidget.prototype.setup = function() {
|
||||
var jqObject = this.jqObject;
|
||||
var parent = jqObject.parent();
|
||||
|
||||
parent.mousedown(function() {
|
||||
if (parent.hasClass('autocomplete-deluxe-single-open')) {
|
||||
jqObject.autocomplete('close');
|
||||
} else {
|
||||
jqObject.autocomplete('search', '');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a multiple selecting widget.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.MultipleWidget = function(input, settings) {
|
||||
this.init(settings);
|
||||
this.setup();
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.MultipleWidget.prototype = new Drupal.autocomplete_deluxe.Widget();
|
||||
Drupal.autocomplete_deluxe.MultipleWidget.prototype.items = new Object();
|
||||
|
||||
|
||||
Drupal.autocomplete_deluxe.MultipleWidget.prototype.acceptTerm = function(term) {
|
||||
// Accept only terms, that are not in our items list.
|
||||
return !(term in this.items);
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.MultipleWidget.Item = function (widget, item) {
|
||||
if (item.newTerm === true) {
|
||||
item.label = item.value;
|
||||
}
|
||||
|
||||
this.value = item.value;
|
||||
this.element = $('<span class="autocomplete-deluxe-item">' + item.label + '</span>');
|
||||
this.widget = widget;
|
||||
this.item = item;
|
||||
var self = this;
|
||||
|
||||
var close = $('<a class="autocomplete-deluxe-item-delete" href="javascript:void(0)"></a>').appendTo(this.element);
|
||||
// Use single quotes because of the double quote encoded stuff.
|
||||
var input = $('<input type="hidden" value=\'' + this.value + '\'/>').appendTo(this.element);
|
||||
|
||||
close.mousedown(function() {
|
||||
self.remove(item);
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.MultipleWidget.Item.prototype.remove = function() {
|
||||
this.element.remove();
|
||||
var values = this.widget.valueForm.val();
|
||||
var escapedValue = Drupal.autocomplete_deluxe.escapeRegex( this.item.value );
|
||||
var regex = new RegExp('()*""' + escapedValue + '""|' + escapedValue + '()*', 'gi');
|
||||
this.widget.valueForm.val(values.replace(regex, ''));
|
||||
delete this.widget.items[this.value];
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.MultipleWidget.prototype.setup = function() {
|
||||
var jqObject = this.jqObject;
|
||||
var parent = jqObject.parent();
|
||||
var value_container = jqObject.parent().parent().children('.autocomplete-deluxe-value-container');
|
||||
var value_input = value_container.children().children();
|
||||
var items = this.items;
|
||||
var self = this;
|
||||
this.valueForm = value_input;
|
||||
|
||||
// Override the resize function, so that the suggestion list doesn't resizes
|
||||
// all the time.
|
||||
jqObject.data("autocomplete")._resizeMenu = function() {};
|
||||
|
||||
jqObject.show();
|
||||
|
||||
value_container.hide();
|
||||
|
||||
// Add the default values to the box.
|
||||
var default_values = value_input.val();
|
||||
default_values = $.trim(default_values);
|
||||
default_values = default_values.substr(2, default_values.length-4);
|
||||
default_values = default_values.split('"" ""');
|
||||
|
||||
for (var index in default_values) {
|
||||
var value = default_values[index];
|
||||
if (value != '') {
|
||||
// If a terms is encoded in double quotes, then the label should have
|
||||
// no double quotes.
|
||||
var label = value.match(/["][\w|\s|\D|]*["]/gi) !== null ? value.substr(1, value.length-2) : value;
|
||||
var item = {
|
||||
label : label,
|
||||
value : value
|
||||
};
|
||||
var item = new Drupal.autocomplete_deluxe.MultipleWidget.Item(self, item);
|
||||
item.element.insertBefore(jqObject);
|
||||
items[item.value] = item;
|
||||
}
|
||||
}
|
||||
|
||||
jqObject.addClass('autocomplete-deluxe-multiple');
|
||||
parent.addClass('autocomplete-deluxe-multiple');
|
||||
|
||||
|
||||
// Adds a value to the list.
|
||||
this.addValue = function(ui_item) {
|
||||
var item = new Drupal.autocomplete_deluxe.MultipleWidget.Item(self, ui_item);
|
||||
item.element.insertBefore(jqObject);
|
||||
items[ui_item.value] = item;
|
||||
var new_value = ' ' + self.wrapper + ui_item.value + self.wrapper;
|
||||
var values = value_input.val();
|
||||
value_input.val(values + new_value);
|
||||
jqObject.val('');
|
||||
};
|
||||
|
||||
parent.mouseup(function() {
|
||||
jqObject.autocomplete('search', '');
|
||||
jqObject.focus();
|
||||
});
|
||||
|
||||
jqObject.bind("autocompleteselect", function(event, ui) {
|
||||
self.addValue(ui.item);
|
||||
jqObject.width(25);
|
||||
// Return false to prevent setting the last term as value for the jqObject.
|
||||
return false;
|
||||
});
|
||||
|
||||
jqObject.bind("autocompletechange", function(event, ui) {
|
||||
jqObject.val('');
|
||||
});
|
||||
|
||||
jqObject.blur(function() {
|
||||
var last_element = jqObject.parent().children('.autocomplete-deluxe-item').last();
|
||||
last_element.removeClass('autocomplete-deluxe-item-focus');
|
||||
});
|
||||
|
||||
var clear = false;
|
||||
|
||||
jqObject.keypress(function (event) {
|
||||
var value = jqObject.val();
|
||||
// If a comma was entered and there is none or more then one comma,or the
|
||||
// enter key was entered, then enter the new term.
|
||||
if ((event.which == self.delimiter && (value.split('"').length - 1) != 1) || (event.which == 13 && jqObject.val() != "")) {
|
||||
value = value.substr(0, value.length);
|
||||
if (typeof self.items[value] == 'undefined' && value != '') {
|
||||
var ui_item = {
|
||||
label: value,
|
||||
value: value
|
||||
};
|
||||
self.addValue(ui_item);
|
||||
}
|
||||
clear = true;
|
||||
if (event.which == 13) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If the Backspace key was hit and the input is empty
|
||||
if (event.which == 8 && value == '') {
|
||||
var last_element = jqObject.parent().children('.autocomplete-deluxe-item').last();
|
||||
// then mark the last item for deletion or deleted it if already marked.
|
||||
if (last_element.hasClass('autocomplete-deluxe-item-focus')) {
|
||||
var value = last_element.children('input').val();
|
||||
self.items[value].remove(self.items[value]);
|
||||
jqObject.autocomplete('search', '');
|
||||
} else {
|
||||
last_element.addClass('autocomplete-deluxe-item-focus');
|
||||
}
|
||||
} else {
|
||||
// Remove the focus class if any other key was hit.
|
||||
var last_element = jqObject.parent().children('.autocomplete-deluxe-item').last();
|
||||
last_element.removeClass('autocomplete-deluxe-item-focus');
|
||||
}
|
||||
});
|
||||
|
||||
jqObject.autoGrowInput({
|
||||
comfortZone: 50,
|
||||
minWidth: 10,
|
||||
maxWidth: 460
|
||||
});
|
||||
|
||||
|
||||
jqObject.keyup(function (event) {
|
||||
if (clear) {
|
||||
// Trigger the search, so it display the values for an empty string.
|
||||
jqObject.autocomplete('search', '');
|
||||
jqObject.val('');
|
||||
clear = false;
|
||||
// Return false to prevent entering the last character.
|
||||
return false;
|
||||
}
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
@@ -0,0 +1,392 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Define enhanced autocomplete wdiget.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_info().
|
||||
*/
|
||||
function autocomplete_deluxe_field_widget_info() {
|
||||
return array(
|
||||
'autocomplete_deluxe_taxonomy' => array(
|
||||
'label' => t('Autocomplete Deluxe'),
|
||||
'field types' => array('taxonomy_term_reference'),
|
||||
'settings' => array(
|
||||
'size' => 60,
|
||||
'autocomplete_deluxe_path' => 'autocomplete_deluxe/taxonomy',
|
||||
),
|
||||
'behaviors' => array(
|
||||
'multiple values' => FIELD_BEHAVIOR_CUSTOM,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom taxonomy callback, which also accepts an empty string search.
|
||||
*/
|
||||
function taxonomy_autocomplete_deluxe($field_name, $tags_typed = '', $limit = 10) {
|
||||
$field = field_info_field($field_name);
|
||||
$use_synonyms = !empty($_GET['synonyms']);
|
||||
|
||||
// The user enters a comma-separated list of tags. We only autocomplete the last tag.
|
||||
$tags_typed = drupal_explode_tags($tags_typed);
|
||||
$tag_last = drupal_strtolower(array_pop($tags_typed));
|
||||
|
||||
$matches = array();
|
||||
|
||||
// Part of the criteria for the query come from the field's own settings.
|
||||
$vids = array();
|
||||
$vocabularies = taxonomy_vocabulary_get_names();
|
||||
foreach ($field['settings']['allowed_values'] as $tree) {
|
||||
// If the content taxonomy setting content_taxonomy_ignore_in_suggestions
|
||||
// is set, then the vocabulary is ignored.
|
||||
if (empty($tree['content_taxonomy_ignore_in_suggestions'])) {
|
||||
$vids[] = $vocabularies[$tree['vocabulary']]->vid;
|
||||
}
|
||||
}
|
||||
|
||||
$query = db_select('taxonomy_term_data', 't');
|
||||
$query->addTag('translatable');
|
||||
$query->addTag('term_access');
|
||||
|
||||
if (module_exists('synonyms') && !empty($use_synonyms)) {
|
||||
$query->leftJoin('field_data_synonyms_synonym', 'fdss', 'fdss.entity_id = t.tid');
|
||||
}
|
||||
|
||||
if ($tag_last != '') {
|
||||
// Do not select already entered terms.
|
||||
if (!empty($tags_typed)) {
|
||||
$query->condition('t.name', $tags_typed, 'NOT IN');
|
||||
}
|
||||
// Select rows that match by term name.
|
||||
$query
|
||||
->fields('t', array('tid', 'name'))
|
||||
->condition('t.vid', $vids);
|
||||
|
||||
if (module_exists('synonyms') && !empty($use_synonyms)) {
|
||||
$or = db_or();
|
||||
$or->condition('fdss.synonyms_synonym_value', '%' . db_like($tag_last) . '%', 'LIKE');
|
||||
$or->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE');
|
||||
$query->condition($or);
|
||||
}
|
||||
else {
|
||||
$query->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE');
|
||||
}
|
||||
|
||||
if (isset($limit) && $limit > 0) {
|
||||
$query->range(0, $limit);
|
||||
}
|
||||
|
||||
$tags_return = $query->execute()
|
||||
->fetchAllKeyed();
|
||||
}
|
||||
else {
|
||||
$query
|
||||
->fields('t', array('tid', 'name'))
|
||||
->condition('t.vid', $vids);
|
||||
|
||||
if (isset($limit) && $limit > 0) {
|
||||
$query->range(0, $limit);
|
||||
}
|
||||
|
||||
$tags_return = $query->execute()
|
||||
->fetchAllKeyed();
|
||||
}
|
||||
|
||||
$prefix = count($tags_typed) ? drupal_implode_tags($tags_typed) . ', ' : '';
|
||||
|
||||
$term_matches = array();
|
||||
foreach ($tags_return as $tid => $name) {
|
||||
$n = $name;
|
||||
// Term names containing commas or quotes must be wrapped in quotes.
|
||||
if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) {
|
||||
$n = '"' . str_replace('"', '""', $name) . '"';
|
||||
}
|
||||
$term_matches[$prefix . $n] = check_plain($name);
|
||||
}
|
||||
|
||||
drupal_json_output($term_matches);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all allowed terms for a field without any prefix.
|
||||
*/
|
||||
function autocomplete_deluxe_allowed_terms($field) {
|
||||
$options = array();
|
||||
foreach ($field['settings']['allowed_values'] as $tree) {
|
||||
if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
|
||||
if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
|
||||
foreach ($terms as $term) {
|
||||
$options[$term->name] = $term->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_settings_form().
|
||||
*/
|
||||
function autocomplete_deluxe_field_widget_settings_form($field, $instance) {
|
||||
$widget = $instance['widget'];
|
||||
$settings = $widget['settings'];
|
||||
|
||||
$form['size'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Size of textfield'),
|
||||
'#default_value' => isset($settings['size']) ? $settings['size'] : 6,
|
||||
'#element_validate' => array('_element_validate_integer_positive'),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$form['limit'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Limit of the output.'),
|
||||
'#description' => t('If set to zero no limit will be used'),
|
||||
'#default_value' => isset($settings['limit']) ? $settings['limit'] : 10,
|
||||
'#element_validate' => array('_element_validate_integer'),
|
||||
);
|
||||
$form['min_length'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Mininum length.'),
|
||||
'#description' => t('The minimum length of characters to enter to open the suggestion list.'),
|
||||
'#default_value' => isset($settings['min_length']) ? $settings['min_length'] : 0,
|
||||
'#element_validate' => array('_element_validate_integer'),
|
||||
);
|
||||
$form['delimiter'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Delimiter.'),
|
||||
'#description' => t('A character which should be used beside the enter key, to seperate terms.'),
|
||||
'#default_value' => isset($settings['delimiter']) ? $settings['delimiter'] : '',
|
||||
'#size' => 1,
|
||||
);
|
||||
|
||||
if (module_exists('synonyms')) {
|
||||
$form['use_synonyms'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow synonyms'),
|
||||
'#description' => t('Should users be able to search for synonyms of terms?'),
|
||||
'#default_value' => isset($settings['use_synonyms']) ? $settings['use_synonyms'] : FALSE,
|
||||
);
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implodes the tags from the taxonomy module.
|
||||
*
|
||||
* This function is essentially the same as axonomy_implode_tags, with the
|
||||
* difference, that it uses only a comma instead of a comma and a space to
|
||||
* implode the tags. It will help keep problems with delimiters to a minimum.
|
||||
*/
|
||||
function autocomplete_deluxe_taxonomy_implode_tags($tags, $vid = NULL) {
|
||||
$typed_tags = array();
|
||||
foreach ($tags as $tag) {
|
||||
// Extract terms belonging to the vocabulary in question.
|
||||
if (!isset($vid) || $tag->vid == $vid) {
|
||||
// Make sure we have a completed loaded taxonomy term.
|
||||
if (isset($tag->name)) {
|
||||
// Commas and quotes in tag names are special cases, so encode 'em.
|
||||
if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
|
||||
$tag->name = '"' . str_replace('"', '""', $tag->name) . '"';
|
||||
}
|
||||
|
||||
$typed_tags[] = $tag->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return implode(',', $typed_tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_error().
|
||||
*/
|
||||
function autocomplete_deluxe_field_widget_error($element, $error, $form, &$form_state) {
|
||||
form_error($element, $error['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_form().
|
||||
*/
|
||||
function autocomplete_deluxe_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||
$element += array(
|
||||
'#type' => 'autocomplete_deluxe',
|
||||
'#size' => $instance['widget']['settings']['size'],
|
||||
'#limit' => isset($instance['widget']['settings']['limit']) ? $instance['widget']['settings']['limit'] : 10,
|
||||
'#min_length' => isset($instance['widget']['settings']['min_length']) ? $instance['widget']['settings']['min_length'] : 0,
|
||||
'#use_synonyms' =>isset($instance['widget']['settings']['use_synonyms']) ? $instance['widget']['settings']['use_synonyms'] : 0,
|
||||
'#delimiter' =>isset($instance['widget']['settings']['delimiter']) ? $instance['widget']['settings']['delimiter'] : '',
|
||||
);
|
||||
|
||||
$multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED ? TRUE : FALSE;
|
||||
|
||||
$tags = array();
|
||||
foreach ($items as $item) {
|
||||
$tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']);
|
||||
}
|
||||
|
||||
$element['#element_validate'] = array('taxonomy_autocomplete_validate');
|
||||
$element += array(
|
||||
'#multiple' => $multiple,
|
||||
'#autocomplete_deluxe_path' => url($instance['widget']['settings']['autocomplete_deluxe_path'] . '/' . $field['field_name'], array('absolute' => TRUE)),
|
||||
'#default_value' => autocomplete_deluxe_taxonomy_implode_tags($tags),
|
||||
);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the basic form elements and javascript settings.
|
||||
*/
|
||||
function autocomplete_deluxe_element_process($element) {
|
||||
$element['#attached'] = array(
|
||||
'library' => array(array('system', 'ui.autocomplete'), array('system', 'ui.button')),
|
||||
'js' => array(drupal_get_path('module', 'autocomplete_deluxe') . '/autocomplete_deluxe.js'),
|
||||
'css' => array(drupal_get_path('module', 'autocomplete_deluxe') . '/autocomplete_deluxe.css'),
|
||||
);
|
||||
// Workaround for problems with jquery css in seven theme.
|
||||
if ($GLOBALS['theme'] == 'seven') {
|
||||
$element['#attached']['css'][] = drupal_get_path('module', 'autocomplete_deluxe') . '/autocomplete_deluxe.seven.css';
|
||||
}
|
||||
|
||||
$html_id = drupal_html_id('autocomplete-deluxe-input');
|
||||
|
||||
$element['#after_build'][] = 'autocomplete_deluxe_after_build';
|
||||
|
||||
// Set default options for multiple values.
|
||||
$element['#multiple'] = isset($element['#multiple']) ? $element['#multiple'] : FALSE;
|
||||
|
||||
$element['textfield'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#size' => isset($element['#size']) ? $element['#size'] : '',
|
||||
'#attributes' => array('class' => array('autocomplete-deluxe-form'), 'id' => array($html_id)),
|
||||
'#default_value' => '',
|
||||
'#prefix' => '<div class="autocomplete-deluxe-container">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$js_settings['autocomplete_deluxe'][$html_id] = array(
|
||||
'input_id' => $html_id,
|
||||
'multiple' => $element['#multiple'],
|
||||
'required' => $element['#required'],
|
||||
'limit' => isset($element['#limit']) ? $element['#limit'] : 10,
|
||||
'min_length' => isset($element['#min_length']) ? $element['#min_length'] : 0,
|
||||
'use_synonyms' => isset($element['#use_synonyms']) ? $element['#use_synonyms'] : 0,
|
||||
'delimiter' => isset($element['#delimiter']) ? $element['#delimiter'] : '',
|
||||
);
|
||||
|
||||
if (isset($element['#autocomplete_deluxe_path'])) {
|
||||
if (isset($element['#default_value'])) {
|
||||
// Split on the comma only if that comma has zero, or an even number of
|
||||
// quotes in ahead of it.
|
||||
// http://stackoverflow.com/questions/1757065/java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes
|
||||
$default_value = preg_replace('/,(?=([^\"]*\"[^\"]*\")*[^\"]*$)/i', '"" ""', $element['#default_value']);
|
||||
$default_value = '""' . $default_value . '""';
|
||||
}
|
||||
else {
|
||||
$default_value = '';
|
||||
}
|
||||
|
||||
if ($element['#multiple']) {
|
||||
$element['value_field'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#attributes' => array('class' => array('autocomplete-deluxe-value-field')),
|
||||
'#default_value' => $default_value,
|
||||
'#prefix' => '<div class="autocomplete-deluxe-value-container">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
$element['textfield']['#attributes']['style'] = array('display:none');
|
||||
}
|
||||
else {
|
||||
$element['textfield']['#default_value'] = isset($element['#default_value']) ? $element['#default_value'] : '';
|
||||
}
|
||||
|
||||
$js_settings['autocomplete_deluxe'][$html_id] += array(
|
||||
'type' => 'ajax',
|
||||
'uri' => $element['#autocomplete_deluxe_path'],
|
||||
);
|
||||
}
|
||||
else {
|
||||
// If there is no source (path or data), we don't want to add the js
|
||||
// settings and so the functions will be abborted.
|
||||
return $element;
|
||||
}
|
||||
$element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting');
|
||||
$element['#tree'] = TRUE;
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for a autocomplete deluxe form
|
||||
* element.
|
||||
*/
|
||||
function autocomplete_deluxe_value(&$element, $input = FALSE, $form_state = NULL) {
|
||||
// This runs before child elements are processed, so we cannot calculate the
|
||||
// value here. But we have to make sure the value is an array, so the form
|
||||
// API is able to proccess the children to set their values in the array. Thus
|
||||
// once the form API has finished processing the element, the value is an
|
||||
// array containing the child element values. Then finally the after build
|
||||
// callback converts it back to the numeric value and sets that.
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* FAPI after build callback for the duration parameter type form.
|
||||
* Fixes up the form value by applying the multiplier.
|
||||
*/
|
||||
function autocomplete_deluxe_after_build($element, &$form_state) {
|
||||
// By default drupal sets the maxlength to 128 if the property isn't
|
||||
// specified, but since the limit isn't useful in some cases,
|
||||
// we unset the property.
|
||||
unset($element['textfield']['#maxlength']);
|
||||
|
||||
// Set the elements value from either the value field or text field input.
|
||||
$element['#value'] = isset($element['value_field']) ? $element['value_field']['#value'] : $element['textfield']['#value'];
|
||||
|
||||
if (isset($element['value_field'])) {
|
||||
$element['#value'] = trim($element['#value']);
|
||||
// Replace all double double quotes and space with a comma. This will allows
|
||||
// us to keep entries in double quotes.
|
||||
$element['#value'] = str_replace('"" ""', ',', $element['#value']);
|
||||
$element['#value'] = str_replace('"" ""', ',', $element['#value']);
|
||||
// Remove the double quotes at the beginning and the end from the first and
|
||||
// the last term.
|
||||
$element['#value'] = substr($element['#value'], 2, strlen($element['#value']) - 4);
|
||||
|
||||
unset($element['value_field']['#maxlength']);
|
||||
}
|
||||
|
||||
|
||||
form_set_value($element, $element['#value'], $form_state);
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_element_info().
|
||||
*/
|
||||
function autocomplete_deluxe_element_info() {
|
||||
$types['autocomplete_deluxe'] = array(
|
||||
'#input' => TRUE,
|
||||
'#value_callback' => 'autocomplete_deluxe_value',
|
||||
'#pre_render' => array('form_pre_render_conditional_form_element'),
|
||||
'#process' => array('autocomplete_deluxe_element_process'),
|
||||
);
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function autocomplete_deluxe_menu() {
|
||||
$items['autocomplete_deluxe/taxonomy'] = array(
|
||||
'title' => 'Autocomplete deluxe taxonomy',
|
||||
'page callback' => 'taxonomy_autocomplete_deluxe',
|
||||
'access arguments' => array('access content'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
return $items;
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
@CHARSET "UTF-8";
|
||||
|
||||
/**
|
||||
* JQuery UI style sheet fix for seven.
|
||||
*/
|
||||
|
||||
.ui-button {
|
||||
border: 1px solid #cccccc;
|
||||
background: #e6e6e6;
|
||||
}
|
||||
|
||||
.ui-state-hover,
|
||||
.ui-state-focus {
|
||||
border: 1px solid #bbbbbb;
|
||||
}
|
||||
|
||||
.ui-button.ui-state-active {
|
||||
border: 1px solid #777777;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Corner radius
|
||||
*/
|
||||
.ui-corner-tl {
|
||||
-moz-border-radius-topleft: 4px;
|
||||
-webkit-border-top-left-radius: 4px;
|
||||
border-top-left-radius: 4px;
|
||||
}
|
||||
|
||||
.ui-corner-tr {
|
||||
-moz-border-radius-topright: 4px;
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
|
||||
.ui-corner-bl {
|
||||
-moz-border-radius-bottomleft: 4px;
|
||||
-webkit-border-bottom-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
|
||||
.ui-corner-br {
|
||||
-moz-border-radius-bottomright: 4px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
|
||||
.ui-corner-top {
|
||||
-moz-border-radius-topleft: 4px;
|
||||
-moz-border-radius-topright: 4px;
|
||||
-webkit-border-top-left-radius: 4px;
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
|
||||
.ui-corner-bottom {
|
||||
-moz-border-radius-bottomleft: 4px;
|
||||
-moz-border-radius-bottomright: 4px;
|
||||
-webkit-border-bottom-left-radius: 4px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
|
||||
.ui-corner-right {
|
||||
-moz-border-radius-bottomright: 4px;
|
||||
-moz-border-radius-topright: 4px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
|
||||
.ui-corner-left {
|
||||
-moz-border-radius-bottomleft: 4px;
|
||||
-moz-border-radius-topleft: 4px;
|
||||
-webkit-border-bottom-left-radius: 4px;
|
||||
-webkit-border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-top-left-radius: 4px;
|
||||
}
|
||||
|
||||
.ui-corner-all {
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
sites/all/modules/contrib/fields/autocomplete_deluxe/x.gif
Normal file
BIN
sites/all/modules/contrib/fields/autocomplete_deluxe/x.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 498 B |
Reference in New Issue
Block a user