initial commit of starter install drupal 7
This commit is contained in:
@@ -0,0 +1,274 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
|
||||
Cambridge, MA 02139, 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 Library 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
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
Enhanced autocomplete widget for drupal 7.x
|
||||
+54
@@ -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;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
@CHARSET "UTF-8";
|
||||
|
||||
/* Theme the button */
|
||||
span.autocomplete-deluxe-button {
|
||||
top: 0.6em;
|
||||
height: 1.75em;
|
||||
overflow: hidden;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
ul.ui-autocomplete {
|
||||
overflow: scroll;
|
||||
min-height: 3em;
|
||||
max-height: 250px;
|
||||
}
|
||||
|
||||
div.autocomplete-deluxe-values {
|
||||
width: 528px;
|
||||
/*border: solid 1px #CCCCCC;*/
|
||||
}
|
||||
|
||||
span.autocomplete-deluxe-value {
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
margin-top: 5px;
|
||||
padding: 2px;
|
||||
border: solid 1px #CCCCCC;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
name = Autocomplete Deluxe
|
||||
description = Enhanced autocomplete using Jquery UI autocomplete.
|
||||
package = User interface
|
||||
version = VERSION
|
||||
core = 7.x
|
||||
files[] = autocomplete_deluxe.module
|
||||
dependencies[] = options
|
||||
dependencies[] = taxonomy
|
||||
; Information added by drupal.org packaging script on 2011-08-08
|
||||
version = "7.x-1.0-beta5"
|
||||
core = "7.x"
|
||||
project = "autocomplete_deluxe"
|
||||
datestamp = "1312796515"
|
||||
|
||||
+581
@@ -0,0 +1,581 @@
|
||||
|
||||
/**
|
||||
* @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() {
|
||||
new Drupal.autocomplete_deluxe(this, autocomplete_settings[$(this).attr('id')]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Autocomplete deluxe object.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe = function(input, settings) {
|
||||
this.id = settings.input_id;
|
||||
this.jqObject = $('#' + this.id);
|
||||
this.jqObject.addClass('ui-corner-left');
|
||||
this.type = settings.type;
|
||||
this.minLength = settings.min_length;
|
||||
|
||||
this.multiple = settings.multiple;
|
||||
|
||||
this.opendByFocus = false;
|
||||
this.keyPress = false;
|
||||
|
||||
if (settings.select_input !== undefined) {
|
||||
this.selectInput = $('#' + settings.select_input);
|
||||
this.selectInput.hide();
|
||||
this.jqObject.show();
|
||||
}
|
||||
|
||||
this.button = $('<span> </span>');
|
||||
this.button.attr({
|
||||
'tabIndex': -1,
|
||||
'title': 'Show all items'
|
||||
});
|
||||
this.button.insertAfter(this.jqObject);
|
||||
|
||||
this.button.button({
|
||||
icons: {
|
||||
primary: 'ui-icon-triangle-1-s'
|
||||
},
|
||||
text: false
|
||||
});
|
||||
|
||||
// Don't round the left corners.
|
||||
this.button.removeClass('ui-corner-all');
|
||||
this.button.addClass('ui-corner-right ui-button-icon autocomplete-deluxe-button');
|
||||
|
||||
this.jqObject.autocomplete();
|
||||
this.jqObject.autocomplete("option", "minLength", this.minLength);
|
||||
// Add a custom class, so we can style the autocomplete box without
|
||||
// interfering with other jquery autocomplete widgets.
|
||||
this.jqObject.autocomplete("widget").addClass('autocomplete-deluxe-widget');
|
||||
|
||||
this.hasFocus = false;
|
||||
|
||||
// Save the current autocomplete object, so it can be used in
|
||||
// handlers.
|
||||
var instance = this;
|
||||
|
||||
// Override enter keypress for the form, but only when the input hasn't
|
||||
// the focus and it isn\t empty.
|
||||
$('form').keypress(function(event) {
|
||||
if (event.keyCode == 13 && instance.hasFocus && instance.jqObject.val() !== "") return false;
|
||||
});
|
||||
|
||||
// Event handlers.
|
||||
this.jqObject.focus( function(eventObject) {
|
||||
// Overlay causes a second focus, wich has to be instance.catched.
|
||||
if (eventObject.originalEvent === undefined) {
|
||||
return false;
|
||||
}
|
||||
instance.open();
|
||||
instance.opendByFocus = true;
|
||||
});
|
||||
|
||||
this.jqObject.focusin(function(){
|
||||
instance.hasFocus = true;
|
||||
})
|
||||
|
||||
this.jqObject.focusout(function(){
|
||||
instance.hasFocus = false;
|
||||
})
|
||||
|
||||
// Needed when the window is closed but the textfield has the focus.
|
||||
this.jqObject.click( function() {
|
||||
if (!instance.opendByFocus) {
|
||||
instance.toggle();
|
||||
}
|
||||
else {
|
||||
instance.opendByFocus = false;
|
||||
}
|
||||
});
|
||||
|
||||
// Create the source item, set its options and elements and initialize it.
|
||||
switch (this.type) {
|
||||
case 'ajax':
|
||||
var uri = settings.uri;
|
||||
this.source = new Drupal.autocomplete_deluxe.ajaxSource(uri);
|
||||
break;
|
||||
case 'list':
|
||||
this.source = new Drupal.autocomplete_deluxe.listSource(settings.data, this.selectInput);
|
||||
break;
|
||||
}
|
||||
this.source.autocomplete = this;
|
||||
this.source.multiple = settings.multiple;
|
||||
if (this.multiple) {
|
||||
this.source.container = this.jqObject.parent().parent().children('.autocomplete-deluxe-values');
|
||||
}
|
||||
this.source.init();
|
||||
|
||||
this.jqObject.autocomplete("option", "source", function(request, response) {
|
||||
instance.source.setResponse(request, response);
|
||||
});
|
||||
this.jqObject.bind("autocompletesearch", function(event, ui) {
|
||||
instance.jqObject.addClass('throbbing');
|
||||
return ui;
|
||||
});
|
||||
// Don't set the value input when autocomplete window has focus.
|
||||
this.jqObject.bind("autocompletefocus", function(event, ui) {
|
||||
return false;
|
||||
});
|
||||
this.jqObject.bind("autocompletechange", function(event, ui) {
|
||||
instance.source.change(event, ui);
|
||||
});
|
||||
this.jqObject.bind("autocompleteselect", function(event, ui) {
|
||||
instance.close();
|
||||
instance.opendByFocus = false;
|
||||
var ret = instance.source._select(this, ui);
|
||||
if (instance.keyPress === false) {
|
||||
this.blur();
|
||||
} else {
|
||||
instance.keyPress = false;
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
this.jqObject.blur(function() {
|
||||
if (!instance.jqObject.autocomplete("widget").is(":visible")) {
|
||||
var val = instance.jqObject.val();
|
||||
if (val.substring(val.length, val.length - 2) == ', ') {
|
||||
instance.jqObject.val(val.substring(0, val.length - 2));
|
||||
}
|
||||
}
|
||||
});
|
||||
this.jqObject.keypress(function(event) {
|
||||
instance.keyPress = true;
|
||||
instance.source.keypress(event);
|
||||
});
|
||||
this.jqObject.keyup(function(event) {
|
||||
if (instance.multiple && event.which == 188 || event.which == 13) {
|
||||
instance.jqObject.val('');
|
||||
instance.close();
|
||||
}
|
||||
});
|
||||
|
||||
// Since jquery autocomplete by default strips html text by using .text()
|
||||
// we need our own _renderItem function to display html content.
|
||||
this.jqObject.data("autocomplete")._renderItem = function(ul, item) {
|
||||
return $("<li></li>").data("item.autocomplete", item).append("<a>" + item.label + "</a>").appendTo(ul);
|
||||
};
|
||||
|
||||
// Costume response callback to delete the throbbing class. Could be deleted
|
||||
// once the ui-autocomplete-loading css class is implemented in seven theme.
|
||||
this.jqObject.data("autocomplete")._response = function(content) {
|
||||
if (content && content.length) {
|
||||
content = this._normalize(content);
|
||||
this._suggest(content);
|
||||
this._trigger("open");
|
||||
}
|
||||
else {
|
||||
this.close();
|
||||
}
|
||||
this.element.removeClass('throbbing');
|
||||
};
|
||||
|
||||
this.button.click( function() {
|
||||
instance.jqObject.blur();
|
||||
instance.toggle(true);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 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);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Open the autocomplete window.
|
||||
* @param emptySearch If true it will perform an empty search.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.prototype.open = function(emptySearch) {
|
||||
if ( emptySearch !== undefined) {
|
||||
var item = this.jqObject.val();
|
||||
var searchFor = item.substring(0, this.minLength);
|
||||
}
|
||||
else {
|
||||
var searchFor = this.jqObject.val();
|
||||
}
|
||||
this.jqObject.autocomplete("search", searchFor);
|
||||
this.button.addClass("ui-state-focus");
|
||||
};
|
||||
|
||||
/**
|
||||
* Close the autocomplete window.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.prototype.close = function() {
|
||||
this.jqObject.autocomplete("close");
|
||||
this.button.removeClass("ui-state-focus");
|
||||
this.opendByFocus = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle the autcomplete window.
|
||||
* @param emptySearch If true and autocomplete is opening, it will perform an
|
||||
* empty search.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.prototype.toggle = function(emptySearch) {
|
||||
if (this.jqObject.autocomplete("widget").is(":visible")) {
|
||||
this.close();
|
||||
}
|
||||
else {
|
||||
this.open(emptySearch);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles value elements for multiple entries.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.value = function(value, source) {
|
||||
this.removeLink = $('<span class="autocomplete-deluxe-value-delete"> </span>')
|
||||
this.span = $('<span class="autocomplete-deluxe-value ui-corner-all ui-button ui-state-default">' + value + '</span>');
|
||||
this.value = value;
|
||||
this.source = source;
|
||||
source.container.append(this.span);
|
||||
this.span.append(this.removeLink);
|
||||
|
||||
var object = this;
|
||||
|
||||
this.removeLink.click(function(){
|
||||
object.span.remove();
|
||||
object.source.removeValue(object.value)
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.autocomplete_deluxe.value.prototype.value = null;
|
||||
Drupal.autocomplete_deluxe.value.prototype.span = null;
|
||||
Drupal.autocomplete_deluxe.value.prototype.source = null;
|
||||
|
||||
/**
|
||||
* Main abstract source object.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.source = function() {
|
||||
};
|
||||
|
||||
// Some base settings for all source objects.
|
||||
Drupal.autocomplete_deluxe.source.prototype.autocomplete = null;
|
||||
Drupal.autocomplete_deluxe.source.prototype.multiple = false;
|
||||
Drupal.autocomplete_deluxe.source.prototype.container = undefined;
|
||||
|
||||
Drupal.autocomplete_deluxe.source.prototype.highlight = function(term, data) {
|
||||
// If no term is entered, we want to return the data as it is.
|
||||
if (term == '') {
|
||||
return data;
|
||||
}
|
||||
else {
|
||||
// Create a new data array, so we can keep our original data clean
|
||||
// (without <strong> tags).
|
||||
var newData = new Array();
|
||||
var regex = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term + ")(?![^<>]*>)(?![^&;]+;)", "gi");
|
||||
for ( var i in data) {
|
||||
var nterm = data[i].label.replace(regex, "<strong>$1</strong>");
|
||||
newData.push({
|
||||
label: nterm,
|
||||
value: data[i].value
|
||||
});
|
||||
}
|
||||
return newData;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the source element from the autocomplete deluxe object.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.source.prototype.response = function(request, response, data) {
|
||||
response(this.highlight(request.term, data));
|
||||
};
|
||||
|
||||
/**
|
||||
* Select super function. Super because, in contrary to the .select()
|
||||
* function this function will be always called, not depending on the source
|
||||
* objects type.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.source.prototype._select = function(input, ui) {
|
||||
// Strip the strong tags from the label.
|
||||
ui.item.label = $("<span>" + ui.item.label + "</span>").text();
|
||||
this.select(input, ui);
|
||||
if (this.multiple) {
|
||||
this.addValue(this.autocomplete.jqObject.val());
|
||||
input.value = '';
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialization function for setting the default states.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.source.prototype.init = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Select event function.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.source.prototype.select = function(input, ui) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Change event function.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.source.prototype.change = function(input, ui) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Keypress event function.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.source.prototype.keypress = function(event) {
|
||||
if (this.multiple && event.which == 44 || event.which == 13) {
|
||||
var val = this.autocomplete.jqObject.val();
|
||||
if (val != '') {
|
||||
this.addValue(val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a new value.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.source.prototype.addValue = function(value) {
|
||||
new Drupal.autocomplete_deluxe.value(value, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be called if a value is removed.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.source.prototype.removeValue = function(value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* List Source Object
|
||||
*
|
||||
* @param data
|
||||
* The data for the autocomplete object.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.listSource = function(data, select) {
|
||||
this.list = new Array();
|
||||
var instance = this;
|
||||
this.selectbox = select;
|
||||
jQuery.each(data, function(index, value) {
|
||||
instance.list.push({
|
||||
label: $.trim(value),
|
||||
value: index
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sort function for the list entries.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.listSource.sortList = function(itemA, itemB) {
|
||||
if (itemA.value < itemB.value)
|
||||
return -1;
|
||||
if (itemA.value > itemB.value)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set base class.
|
||||
Drupal.autocomplete_deluxe.listSource.prototype = new Drupal.autocomplete_deluxe.source();
|
||||
|
||||
/**
|
||||
* Override init function,
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.listSource.prototype.init = function(data, select) {
|
||||
if (this.multiple) {
|
||||
var instance = this;
|
||||
// Add all selected(probably by #default_value) to the selected list.
|
||||
this.selectbox.children("option:selected").each( function() {
|
||||
instance.addValue($(this).text());
|
||||
});
|
||||
} else {
|
||||
this.autocomplete.jqObject.val(this.selectbox.children("option:selected").text());
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.autocomplete_deluxe.listSource.prototype.selectbox = null;
|
||||
|
||||
/**
|
||||
* Will be called by the JQuery autocomplete source function to retrieve the
|
||||
* data.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.listSource.prototype.setResponse = function(request, response) {
|
||||
var filtered = Drupal.autocomplete_deluxe.filter(this.list, request.term);
|
||||
this.response(request, response, filtered);
|
||||
};
|
||||
|
||||
/**
|
||||
* Override select event function.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.listSource.prototype.select = function(input, ui) {
|
||||
input.value = ui.item.label;
|
||||
if (!this.multiple) {
|
||||
this.selectbox.children('option:contains("' + input.value + '")').attr("selected", true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Overrides the add new value function.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.listSource.prototype.addValue = function(value) {
|
||||
for (var i=0; i < this.list.length; i++) {
|
||||
if (value == this.list[i].label) {
|
||||
this.selectbox.children('option:contains("' + value + '")').attr("selected", true);
|
||||
new Drupal.autocomplete_deluxe.value(value, this);
|
||||
this.list.splice(i, 1);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Overrides the remove item event function.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.listSource.prototype.removeValue = function(value) {
|
||||
this.selectbox.children('option:contains("' + value + '")').attr("selected", false);
|
||||
this.list.push({
|
||||
label: $.trim(value),
|
||||
value: this.selectbox.children('option:contains("' + value + '")').val()
|
||||
});
|
||||
this.list.sort(Drupal.autocomplete_deluxe.listSource. sortList);
|
||||
};
|
||||
|
||||
/**
|
||||
* Ajax Source Object for selection
|
||||
*
|
||||
* @param uri
|
||||
* URI to server with the data.
|
||||
* @param dataType
|
||||
* If nothing is passed, json will be used as default.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.ajaxSource = function(uri, dataType) {
|
||||
this.cache = new Array();
|
||||
this.uri = uri;
|
||||
if (dataType === undefined) {
|
||||
this.dataType = 'json';
|
||||
}
|
||||
else {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
};
|
||||
|
||||
// Set base class.
|
||||
Drupal.autocomplete_deluxe.ajaxSource.prototype = new Drupal.autocomplete_deluxe.source();
|
||||
Drupal.autocomplete_deluxe.ajaxSource.prototype.valueField = null;
|
||||
Drupal.autocomplete_deluxe.ajaxSource.prototype.values = null;
|
||||
|
||||
/**
|
||||
* Initialization function for setting the default states.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.ajaxSource.prototype.init = function() {
|
||||
if (this.multiple) {
|
||||
this.valueField = this.autocomplete.jqObject.parent().parent().children('div.autocomplete-deluxe-value-container').children().children();
|
||||
this.valueField.hide();
|
||||
this.autocomplete.jqObject.show();
|
||||
this.values = (this.valueField.val().split(',') != "") ? this.valueField.val().split(',') : new Array();
|
||||
for (var i in this.values) {
|
||||
if (this.values[i] != "" && this.values[i] != " ") {
|
||||
new Drupal.autocomplete_deluxe.value(this.values[i], this);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Will be called by the JQuery autocomplete source function to retrieve the
|
||||
* data.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.ajaxSource.prototype.setResponse = function(request, response) {
|
||||
var instance = this;
|
||||
if (request.term in this.cache) {
|
||||
var instance = this;
|
||||
var terms = this.cache[request.term].filter(function(val) {
|
||||
for (var i in instance.values) {
|
||||
if (instance.values[i] == val.value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
instance.response(request, response, (terms));
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: this.uri + '/' + request.term,
|
||||
dataType: this.dataType,
|
||||
success: function(data) {
|
||||
instance.response(request, response, instance.success(data, request));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Success function for the autocomplete object.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.ajaxSource.prototype.success = function(data, request) {
|
||||
var instance = this;
|
||||
this.cache[request.term] = new Array();
|
||||
jQuery.each(data, function(index, value) {
|
||||
instance.cache[request.term].push({
|
||||
label: value,
|
||||
value: index
|
||||
});
|
||||
});
|
||||
|
||||
var terms = this.cache[request.term].filter(function(val) {
|
||||
for (var i in instance.values) {
|
||||
if (instance.values[i] == val.value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return terms;
|
||||
};
|
||||
|
||||
/**
|
||||
* Override select event function.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.ajaxSource.prototype.select = function(input, ui) {
|
||||
input.value = ui.item.value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Overrides the add new value function.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.ajaxSource.prototype.addValue = function(value) {
|
||||
new Drupal.autocomplete_deluxe.value(value, this);
|
||||
this.values.push(value);
|
||||
this.valueField.val(this.values.join(','))
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the remove item event function.
|
||||
*/
|
||||
Drupal.autocomplete_deluxe.ajaxSource.prototype.removeValue = function(value) {
|
||||
var idx = this.values.indexOf(value);
|
||||
if (idx >-1) {
|
||||
this.values.splice(idx, 1);
|
||||
}
|
||||
this.valueField.val(this.values.join(','))
|
||||
}
|
||||
})(jQuery);
|
||||
+400
@@ -0,0 +1,400 @@
|
||||
<?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,
|
||||
),
|
||||
),
|
||||
'autocomplete_deluxe_list' => array(
|
||||
'label' => t('Autocomplete Deluxe'),
|
||||
'field types' => array('list', 'list_text', 'list_number'),
|
||||
'settings' => array(
|
||||
'size' => 60,
|
||||
),
|
||||
'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 = '') {
|
||||
$field = field_info_field($field_name);
|
||||
|
||||
// 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) {
|
||||
$vids[] = $vocabularies[$tree['vocabulary']]->vid;
|
||||
}
|
||||
|
||||
$query = db_select('taxonomy_term_data', 't');
|
||||
$query->addTag('translatable');
|
||||
$query->addTag('term_access');
|
||||
$query->addTag('autocomplete_deluxe_taxonomy_autocomplete');
|
||||
$query->addMetadata('field_name', $field_name);
|
||||
|
||||
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.
|
||||
$tags_return = $query
|
||||
->fields('t', array('tid', 'name'))
|
||||
->condition('t.vid', $vids)
|
||||
->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
|
||||
->execute()
|
||||
->fetchAllKeyed();
|
||||
}
|
||||
else {
|
||||
$tags_return = $query
|
||||
->fields('t', array('tid', 'name'))
|
||||
->condition('t.vid', $vids)
|
||||
->execute()
|
||||
->fetchAllKeyed();
|
||||
}
|
||||
|
||||
$prefix = count($tags_typed) ? implode(', ', $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) . '"';
|
||||
}
|
||||
else {
|
||||
$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'];
|
||||
$type = str_replace('autocomplete_deluxe_', '', $widget['type']);
|
||||
|
||||
$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,
|
||||
);
|
||||
|
||||
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) {
|
||||
$type = str_replace('autocomplete_deluxe_', '', $instance['widget']['type']);
|
||||
$element += array(
|
||||
'#type' => 'autocomplete_deluxe',
|
||||
'#size' => $instance['widget']['settings']['size'],
|
||||
);
|
||||
|
||||
$multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED ? TRUE : FALSE;
|
||||
|
||||
switch ($type) {
|
||||
case 'taxonomy':
|
||||
$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');
|
||||
if (isset($instance['widget']['settings']['content_taxonomy_autocomplete_new_terms']) && $instance['widget']['settings']['content_taxonomy_autocomplete_new_terms'] == 'deny') {
|
||||
$options = autocomplete_deluxe_allowed_terms($field);
|
||||
$default_values = array();
|
||||
foreach ($tags as $tag) {
|
||||
$default_values[$tag->name] = $tag->name;
|
||||
}
|
||||
$element += array(
|
||||
'#autocomplete_options' => $options,
|
||||
'#multiple' => $multiple && count($options) > 1,
|
||||
'#default_value' => $default_values,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$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),
|
||||
);
|
||||
}
|
||||
$form_state['autocomplete_deluxe']['terms'] = TRUE;
|
||||
break;
|
||||
case 'list':
|
||||
$value_key = key($field['columns']);
|
||||
|
||||
$type = str_replace('options_', '', $instance['widget']['type']);
|
||||
$required = $element['#required'];
|
||||
$has_value = isset($items[0][$value_key]);
|
||||
$properties = _options_properties($type, $multiple, $required, $has_value);
|
||||
|
||||
// Prepare the list of options.
|
||||
$options = _options_get_options($field, $instance, $properties);
|
||||
$default_value = _options_storage_to_form($items, $options, $value_key, $properties);
|
||||
|
||||
$element += array(
|
||||
'#autocomplete_options' => $options,
|
||||
'#autocomplete_min_length' => 0,
|
||||
'#multiple' => $multiple && count($options) > 1,
|
||||
'#value_key' => $value_key,
|
||||
'#element_validate' => array('options_field_widget_validate'),
|
||||
'#properties' => $properties,
|
||||
'#default_value' => $default_value,
|
||||
);
|
||||
break;
|
||||
};
|
||||
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['#prefix'] = '<div class="clearfix autocomplete-container">';
|
||||
$element['#suffix'] = '</div>';
|
||||
|
||||
$element['values'] = array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array('autocomplete-deluxe-values'),
|
||||
),
|
||||
);
|
||||
|
||||
$element['textfield'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#size' => isset($element['#size']) ? $element['#size'] : '',
|
||||
'#required' => isset($element['#required']) ? $element['#required'] : '',
|
||||
'#attributes' => array('class' => array('autocomplete-deluxe-form', 'form-autocomplete'), 'id' => array($html_id)),
|
||||
'#default_value' => '',
|
||||
);
|
||||
|
||||
$js_settings['autocomplete_deluxe'][$html_id] = array(
|
||||
'input_id' => $html_id,
|
||||
'min_length' => isset($element['#autocomplete_min_length']) ? $element['#autocomplete_min_length'] : 0,
|
||||
'multiple' => $element['#multiple'],
|
||||
);
|
||||
|
||||
if (isset($element['#autocomplete_deluxe_path'])) {
|
||||
if ($element['#multiple']) {
|
||||
$element['value_field'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#attributes' => array('class' => array('autocomplete-deluxe-value-field')),
|
||||
'#default_value' => isset($element['#default_value']) ? $element['#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'],
|
||||
);
|
||||
}
|
||||
elseif (isset($element['#autocomplete_options'])) {
|
||||
$js_settings['autocomplete_deluxe'][$html_id] += array(
|
||||
'type' => 'list',
|
||||
'data' => $element['#autocomplete_options'],
|
||||
);
|
||||
|
||||
$html_id_select = drupal_html_id('autocomplete-deluxe-input-select');
|
||||
$element['list_value'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $element['#autocomplete_options'],
|
||||
'#multiple' => $element['#multiple'],
|
||||
'#attributes' => array('class' => array('autocomplete-deluxe-form', 'form-autocomplete'), 'id' => array($html_id_select)),
|
||||
'#default_value' => isset($element['#default_value']) ? $element['#default_value'] : '',
|
||||
);
|
||||
|
||||
// Hide textfield so that, in case javascript is deactivated
|
||||
$element['textfield']['#attributes']['style'] = 'display: none;';
|
||||
$js_settings['autocomplete_deluxe'][$html_id]['select_input'] = $html_id_select;
|
||||
}
|
||||
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');
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for array_filter.
|
||||
*/
|
||||
function autocomplete_deluxe_value_filter($var) {
|
||||
$string = trim($var);
|
||||
if (empty($string)) {
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
if (!isset($element['list_value'])) {
|
||||
$element['#value'] = isset($element['value_field']) ? $element['value_field']['#value'] : $element['textfield']['#value'];
|
||||
}
|
||||
else {
|
||||
if (!empty($form_state['autocomplete_deluxe']['terms']) && !empty($element['#multiple'])) {
|
||||
$element['#value'] = (!empty($element['list_value']['#value'])) ? implode(',', $element['list_value']['#value']) : "";
|
||||
}
|
||||
else {
|
||||
$element['#value'] = $element['list_value']['#value'];
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
+89
@@ -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: 498 B |
Reference in New Issue
Block a user