diff options
| author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-02-19 11:09:26 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-02-19 11:09:26 +0100 |
| commit | d2f705ef0d03a7ace25c78152bf5d7a3d85fa914 (patch) | |
| tree | d780d992b0937ba1b010332c8e623c54cdfbbae1 /chimere/static/bsmSelect | |
| parent | dce6d0499efe505096495b36728eeb8c9fb8ced1 (diff) | |
| parent | 4a5f51d26982fe04eae01ee6ca0bbdb8b3153173 (diff) | |
| download | Chimère-d2f705ef0d03a7ace25c78152bf5d7a3d85fa914.tar.bz2 Chimère-d2f705ef0d03a7ace25c78152bf5d7a3d85fa914.zip | |
Merge branch 'master' of ssh://etienne@daenerys.peacefrogs.net/var/local/git/chimere
Diffstat (limited to 'chimere/static/bsmSelect')
| -rw-r--r-- | chimere/static/bsmSelect/GPL-LICENSE.txt | 278 | ||||
| -rw-r--r-- | chimere/static/bsmSelect/MIT-LICENSE.txt | 21 | ||||
| -rw-r--r-- | chimere/static/bsmSelect/README.md | 191 | ||||
| -rw-r--r-- | chimere/static/bsmSelect/css/jquery.bsmselect.css | 64 | ||||
| -rw-r--r-- | chimere/static/bsmSelect/css/jquery.bsmselect.custom.css | 45 | ||||
| -rw-r--r-- | chimere/static/bsmSelect/js/jquery.bsmselect.compatibility.js | 60 | ||||
| -rw-r--r-- | chimere/static/bsmSelect/js/jquery.bsmselect.js | 381 | ||||
| -rw-r--r-- | chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js | 49 |
8 files changed, 1089 insertions, 0 deletions
diff --git a/chimere/static/bsmSelect/GPL-LICENSE.txt b/chimere/static/bsmSelect/GPL-LICENSE.txt new file mode 100644 index 0000000..76927f5 --- /dev/null +++ b/chimere/static/bsmSelect/GPL-LICENSE.txt @@ -0,0 +1,278 @@ + 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.
\ No newline at end of file diff --git a/chimere/static/bsmSelect/MIT-LICENSE.txt b/chimere/static/bsmSelect/MIT-LICENSE.txt new file mode 100644 index 0000000..908016b --- /dev/null +++ b/chimere/static/bsmSelect/MIT-LICENSE.txt @@ -0,0 +1,21 @@ +Copyright (c) 2008 by Ryan Cramer, http://www.ryancramer.com +Copyright (c) 2010 by Victor Berchet + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file diff --git a/chimere/static/bsmSelect/README.md b/chimere/static/bsmSelect/README.md new file mode 100644 index 0000000..bd14c6a --- /dev/null +++ b/chimere/static/bsmSelect/README.md @@ -0,0 +1,191 @@ +# bsmSelect - Better Select Multiple # + +based on asmSelect - Alternate Select Multiple by Ryan Cramer + + * [Google code project](http://code.google.com/p/jquery-asmselect/) + * [Github page](http://github.com/ryancramerdesign/jquery-asmSelect) + * [Ryan's article about asmSelect](http://www.ryancramer.com/journal/entries/select_multiple/) + * the original README can be found in the project root folder + +## Demo ## + +[bsmSelect demo](http://www.suumit.com/projects/bsmSelect/examples/index.html) + +## Usage ## + +Include jquery, bsmSelect, and css in document head: + + <script type="text/javascript" src="jquery.js"></script> + <script type="text/javascript" src="jquery.bsmselect.js"></script> + <link rel="stylesheet" type="text/css" href="jquery.bsmselect.css" /> + +Use a jQuery selector in your document ready function: + + jQuery(function($) { + $("select[multiple]").bsmSelect(); + }); + +If desired, you can specify options when you call the plugin: + + jQuery(function($) { + $("select[multiple]").bsmSelect({ + addItemTarget: 'top' + }); + }); + +The newly created select default option is the original select title attribute: + + <select name="cities" multiple="multiple" title="Please select a city"> + ... + </select> + +## Requirements ## + +* jQuery 1.4+ (you might need a newer version for IE9 compatibility) + +## Options ## + +### Primary Options ### + +* listType: + + * Specify what list will be created or used as part of the bsmSelect. + * Can accept a callback that accepts the original <select> as an argument and returns a jQuery object with a single list. + * Allowed values: + * 'ol' + * 'ul' + * function(originalSelect) { // your code; return $('<ul>'); } + * Default: 'ol' + +* highlightEffect: + + * Show a quick highlight of what item was added or removed? + * Allowed values: + * an animation function + * Default: $.noop (no effect) + +* showEffect: + + * Animate the addition of an item to the list + * Allowed values: + * an animation function + * Default: $.bsmSelect.effects.show + +* hideEffect: + + * Animate the removal of an items from the list + * Allowed values: + * an animation function + * Default: $.bsmSelect.effects.remove + +* hideWhenAdded: + + * Stop showing in select after item has been added? + * Allowed values: true or false + * Default: false + * Note: Only functional in Firefox 3 at this time. + +* addItemTarget: + + * Where to place new selected items that are added to the list. + * Allowed values: 'top' or 'bottom' or 'original' to keep the original select sort order + * Default: 'bottom' + * Note: When using the 'original' mode, the sort order can be overriden by setting the 'bsm-order' data on each option. + +* debugMode: + + * Keeps original select multiple visible so that you can monitor live changes made to it when debugging. + * Default: false + +* extractLabel: + + * A function to compute the list element name from the option object + * Default: extract the option html + +* plugins + + * An array of plugins objects to enable (they only are required to have an `init` method which is called on init with the Bsmselect instance as single argument). + * Default: an empty array (no plugin enabled by default) + +### Text Labels ### + +* title + + * Text used for the default select label (when original select title attribute is not set) + * Default: 'Select...' + +* removeLabel: + + * Text used for the remove link of each list item. + * Default: 'remove' + +* highlightAddedLabel: + + * Text that precedes highlight of item added. + * Default: 'Added: ' + +* highlightRemovedLabel: + + * Text that precedes highlight of item removed. + * Default: 'Removed: ' + +### Modifiable CSS Classes ### + +* containerClass: + + * Class for container that wraps the entire bsmSelect. + * Default: 'bsmContainer' + +* selectClass: + + * Class for the newly created <select>. + * Default: 'bsmSelect' + +* listClass: + + * Class for the newly created list of listType (ol or ul). + * Default: 'bsmList' + +* listSortableClass: + + * Another class given to the list when sortable is active. + * Default: 'bsmListSortable' + +* listItemClass: + + * Class given to the <li> list items. + * Default: 'bsmListItem' + +* listItemLabelClass: + + * Class for the label text that appears in list items. + * Default: 'bsmListItemLabel' + +* removeClass: + + * Class given to the remove link in each list item. + * Any element found in the <li> with this class will remove it. + * If you give the <li> this class, clicking anywhere on the <li> will remove it. + * Default: 'bsmListItemRemove' + +* highlightClass: + + * Class given to the highlight <span>. + * Default: 'bsmHighlight' + +## Authors and contributors ## + + * [Ryan Cramer](http://www.ryancramer.com/) is the author of the original asmSelect + * [Victor Berchet](http://github.com/vicb) is the author of bsmSelect + * [Andy Fowler](http://github.com/andyfowler) has contributed many enhancements + * [Cracky](https://github.com/Cracky) + * [Marc Busqué](https://github.com/laMarciana) has contributed to fix [issue #21](https://github.com/vicb/bsmSelect/issues/21) and with minimal CSS + +## History ## + +see [history.md](history.md). + +## Related Projects ## + + * [Chosen](https://github.com/harvesthq/chosen/) + diff --git a/chimere/static/bsmSelect/css/jquery.bsmselect.css b/chimere/static/bsmSelect/css/jquery.bsmselect.css new file mode 100644 index 0000000..ad770d0 --- /dev/null +++ b/chimere/static/bsmSelect/css/jquery.bsmselect.css @@ -0,0 +1,64 @@ +.bsmContainer { + /* container that surrounds entire bsmSelect widget */ +} + +.bsmSelect { + /* the newly created regular 'select' */ + display: inline; +} + +.bsmOptionDisabled { + /* disabled options in new select */ + color: #999; +} + +.bsmHighlight { + /* the highlight span */ + float: right; + padding: 0; + margin: 0 0 0 1em; +} + +.bsmList { + /* html list that contains selected items */ + margin: 0.25em 0 1em 0; + position: relative; + display: block; + padding-left: 0; + list-style: none; +} + +.bsmListItem { + /* li item from the html list above */ + position: relative; + margin-left: 0; + padding-left: 0; + list-style: none; + background: #ddd; + border: 1px solid #bbb; + width: 100%; + margin: 0 0 -1px 0; + line-height: 1em; +} + +.bsmListItem:hover { + background-color: #e5e5e5; +} + +.bsmListItemLabel { + /* this is a span that surrounds the text in the item, except for the remove link */ + padding: 5px; + display: block; +} + +.bsmListSortable .bsmListItemLabel { + cursor: move; +} + +.bsmListItemRemove { + /* the remove link in each list item */ + position: absolute; + right: 0; + top: 0; + padding: 5px; +} diff --git a/chimere/static/bsmSelect/css/jquery.bsmselect.custom.css b/chimere/static/bsmSelect/css/jquery.bsmselect.custom.css new file mode 100644 index 0000000..8c48aeb --- /dev/null +++ b/chimere/static/bsmSelect/css/jquery.bsmselect.custom.css @@ -0,0 +1,45 @@ +.bsmListSortableCustom li { + cursor: move; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + margin: 2px 0; +} + +.bsmList-custom { + /* html list that contains selected items */ + margin: 0.25em 0 0.25em 0; + display: block; + padding-left: 0; + list-style: none; +} + +.bsmListItem-custom { + /* li item from the html list above */ + margin: 0 5px 5px 0; + padding: 4px; + list-style: none; + background: #ddd; + border: 1px solid #bbb; + line-height: 1em; + float: left; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; +} + +.bsmListItem-custom:hover { + background-color: #e5e5e5; + box-shadow: 0 0 3px #aaa; + -webkit-box-shadow: 0 0 3px #aaa; + -moz-box-shadow: 0 0 3px #aaa; +} + +.bsmListItemLabel-custom { + padding-right: 5px; +} + +.bsmListItemRemove-custom { + text-decoration: none; +} + diff --git a/chimere/static/bsmSelect/js/jquery.bsmselect.compatibility.js b/chimere/static/bsmSelect/js/jquery.bsmselect.compatibility.js new file mode 100644 index 0000000..a743a07 --- /dev/null +++ b/chimere/static/bsmSelect/js/jquery.bsmselect.compatibility.js @@ -0,0 +1,60 @@ +/* + * Better Select Multiple Compatibility Plugin - jQuery Plugin + * + * Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb + * + * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. + * + * version: v1.0.0 - 2010-09-05 + */ +(function($) { + $.bsmSelect.plugins.compatibility = function() + { + if (!(this instanceof arguments.callee)) { + return new arguments.callee(); + } + } + + $.extend($.bsmSelect.plugins.compatibility.prototype, { + init: function(bsm) { + + var o = bsm.options; + + if (typeof o.animate != 'undefined') + { + if (o.animate === true) { + o.showEffect = $.bsmSelect.effects.verticalListAdd; + o.hideEffect = $.bsmSelect.effects.verticalListRemove; + } else if ($.isFunction(o.animate.add)) { + o.showEffect = o.animate.add; + } else if (typeof(o.animate.add) == 'string' && $.isFunction($.bsmSelect.effects[o.animate.add])) { + o.showEffect = $.bsmSelect.effects[o.animate.add]; + } else { + o.showEffect = $.bsmSelect.effects.show; + } + + if ($.isFunction(o.animate.drop)) { + o.hideEffect = o.animate.drop; + } else if (typeof(o.animate.drop) == 'string' && $.isFunction($.bsmSelect.effects[o.animate.drop])) { + o.hideEffect = $.bsmSelect.effects[o.animate.drop]; + } else { + o.hideEffect = $.bsmSelect.effects.remove; + } + } + + if (typeof o.highlight != 'undefined') + { + if (o.highlight === true) { + o.highlightEffect = $.bsmSelect.effects.highlight; + } else if ($.isFunction(o.highlight)) { + o.highlightEffect = o.highlight; + } else if (typeof(o.highlight) == 'string' && $.isFunction($.bsmSelect.effects[o.highlight])) { + o.highlightEffect = $.bsmSelect.effects[o.highlight]; + } + } + + } + + }); +})(jQuery); + diff --git a/chimere/static/bsmSelect/js/jquery.bsmselect.js b/chimere/static/bsmSelect/js/jquery.bsmselect.js new file mode 100644 index 0000000..25527c6 --- /dev/null +++ b/chimere/static/bsmSelect/js/jquery.bsmselect.js @@ -0,0 +1,381 @@ +/* + * Better Select Multiple - jQuery Plugin + * + * based on Alternate Select Multiple (asmSelect) 1.0.4a beta (http://www.ryancramer.com/projects/asmselect/) + * + * Copyright (c) 2009 by Ryan Cramer - http://www.ryancramer.com + * Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb + * + * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. + * + * bsmSelect version: v1.4.3 - 2011-05-05 + */ + +(function($) { + + function BsmSelect(target, options) + { + this.$original = $(target); // the original select multiple + this.buildingSelect = false; // is the new select being constructed right now? + this.ieClick = false; // in IE, has a click event occurred? ignore if not + this.ignoreOriginalChangeEvent = false; // originalChangeEvent bypassed when this is true + this.options = options; + this.buildDom(); + } + + BsmSelect.prototype = { + /** + * Generate an UID + */ + generateUid: function(index) { + return (this.uid = this.options.containerClass + index); + }, + + /** + * Build the DOM for bsmSelect + */ + buildDom: function() { + var self = this, o = this.options; + + if (o.addItemTarget === 'original') { + $('option', this.$original).each(function(i, o) { + if ($(o).data('bsm-order') === null) { $(o).data('bsm-order', i); } + }); + } + + for (var index = 0; $('#' + this.generateUid(index)).size(); index++) {} + + this.$select = $('<select>', { + 'class': o.selectClass, + name: o.selectClass + this.uid, + id: o.selectClass + this.uid, + change: $.proxy(this.selectChangeEvent, this), + click: $.proxy(this.selectClickEvent, this) + }); + + this.$list = $.isFunction(o.listType) + ? o.listType(this.$original) + : $('<' + o.listType + '>', { id: o.listClass + this.uid }); + + this.$list.addClass(o.listClass); + + this.$container = $('<div>', { 'class': o.containerClass, id: this.uid }); + + this.buildSelect(); + + this.$original.change($.proxy(this.originalChangeEvent, this)).wrap(this.$container).before(this.$select); + + // if the list isn't already in the document, add it (it might be inserted by a custom callback) + if (!this.$list.parent().length) { this.$original.before(this.$list); } + + if (this.$original.attr('id')) { + $('label[for=' + this.$original.attr('id') + ']').attr('for', this.$select.attr('id')); + } + + // set up remove event (may be a link, or the list item itself) + this.$list.delegate('.' + o.removeClass, 'click', function() { + self.dropListItem($(this).closest('li')); + return false; + }); + + $.each(o.plugins, function() { this.init(self); }); + }, + + /** + * Triggered when an item has been selected + * Check to make sure it's not an IE screwup, and add it to the list + */ + selectChangeEvent: function() { + if ($.browser.msie && $.browser.version < 7 && !this.ieClick) { return; } + var bsmOpt = $('option:selected:eq(0)', this.$select); + if (bsmOpt.data('orig-option')) { + this.addListItem(bsmOpt); + this.triggerOriginalChange(bsmOpt.data('orig-option'), 'add'); + } + this.ieClick = false; + }, + + /** + * IE6 lets you scroll around in a select without it being pulled down + * making sure a click preceded the change() event reduces the chance + * if unintended items being added. there may be a better solution? + */ + selectClickEvent: function() { + this.ieClick = true; + }, + + /** + * Rebuild bsmSelect when the 'change' event is triggered on the original select + */ + originalChangeEvent: function() { + if (this.ignoreOriginalChangeEvent) { + // We don't want to rebuild everything when an item is added / droped + this.ignoreOriginalChangeEvent = false; + } else { + this.buildSelect(); + // opera has an issue where it needs a force redraw, otherwise + // the items won't appear until something else forces a redraw + if ($.browser.opera) { this.$list.hide().show(); } + } + }, + + /** + * Build the DOM for the new select + */ + buildSelect: function() { + var self = this; + + this.buildingSelect = true; + + // add a first option to be the home option / default selectLabel + this.$select.empty().prepend($('<option value=""></option>').text(this.$original.attr('title') || this.options.title)); + this.$list.empty(); + + this.$original.children().each(function() { + if ($(this).is('option')) { + self.addSelectOption(self.$select, $(this)); + } else if ($(this).is('optgroup')) { + self.addSelectOptionGroup(self.$select, $(this)); + } + }); + + if (!this.options.debugMode) { this.$original.hide(); } + this.selectFirstItem(); + this.buildingSelect = false; + }, + + /** + * Append an option to the new select + * + * @param {jQuery} $parent Where to append the option + * @param {jQuery} $origOpt Option from the original select + */ + addSelectOption: function ($parent, $origOpt) { + var $bsmOpt = $('<option>', { + text: $origOpt.text(), + val: $origOpt.val() }).appendTo($parent).data('orig-option', $origOpt), + isSelected = $origOpt.is(':selected'), + isDisabled = $origOpt.is(':disabled'); + $origOpt.data('bsm-option', $bsmOpt); + if (isSelected && !isDisabled) { + this.addListItem($bsmOpt); + this.disableSelectOption($bsmOpt); + } else if (!isSelected && isDisabled) { + this.disableSelectOption($bsmOpt); + } + }, + + /** + * Append an option group to the new select + * + * @param {jQuery} $parent Where to append the group + * @param {jQuery} $group Model group from the original select + */ + addSelectOptionGroup: function($parent, $group) + { + var self = this, + $G = $('<optgroup>', { label: $group.attr('label')} ).appendTo($parent); + if ($group.is(':disabled')) { $G.attr('disabled', 'disabled'); } + $('option', $group).each(function() { self.addSelectOption($G, $(this)); }); + }, + + /** + * Select the first item of the new select + */ + selectFirstItem: function() { + $('option:eq(0)', this.$select).attr('selected', 'selected'); + }, + + /** + * Make an option disabled, indicating that it's already been selected + * because safari is the only browser that makes disabled items look 'disabled' + * we apply a class that reproduces the disabled look in other browsers + * + * @param {jQuery} $bsmOpt Option from the new select + */ + disableSelectOption: function($bsmOpt) { + $bsmOpt.addClass(this.options.optionDisabledClass) + .removeAttr('selected') + .attr('disabled', 'disabled') + .toggle(!this.options.hideWhenAdded); + if ($.browser.msie && $.browser.version < 8) { this.$select.hide().show(); } // this forces IE to update display + }, + + /** + * Enable a select option + * + * @param {jQuery} $bsmOpt Option from the new select + */ + enableSelectOption: function($bsmOpt) { + $bsmOpt.removeClass(this.options.optionDisabledClass) + .removeAttr('disabled') + .toggle(!this.options.hideWhenAdded); + if ($.browser.msie && $.browser.version < 8) { this.$select.hide().show(); } // this forces IE to update display + }, + + /** + * Append an item corresponding to the option to the list + * + * @param {jQuery} $bsmOpt Option from the new select + */ + addListItem: function($bsmOpt) { + var $item, + $origOpt = $bsmOpt.data('orig-option'), + o = this.options; + + if (!$origOpt) { return; } // this is the first item, selectLabel + + if (!this.buildingSelect) { + if ($origOpt.is(':selected')) { return; } // already have it + $origOpt.attr('selected', 'selected'); + } + + $item = $('<li>', { 'class': o.listItemClass }) + .append($('<span>', { 'class': o.listItemLabelClass, html: o.extractLabel($bsmOpt, o)})) + .append($('<a>', { href: '#', 'class': o.removeClass, html: o.removeLabel })) + .data('bsm-option', $bsmOpt); + + this.disableSelectOption($bsmOpt.data('item', $item)); + + switch (o.addItemTarget) { + case 'bottom': + this.$list.append($item.hide()); + break; + case 'original': + var order = $origOpt.data('bsm-order'), inserted = false; + $('.' + o.listItemClass, this.$list).each(function() { + if (order < $(this).data('bsm-option').data('orig-option').data('bsm-order')) { + $item.hide().insertBefore(this); + inserted = true; + return false; + } + }); + if (!inserted) { this.$list.append($item.hide()); } + break; + default: + this.$list.prepend($item.hide()); + } + + if (this.buildingSelect) { + $.bsmSelect.effects.show($item); + } else { + o.showEffect($item); + o.highlightEffect(this.$select, $item, o.highlightAddedLabel, this.options); + this.selectFirstItem(); + } + }, + + /** + * Remove an item from the list of selection + * + * @param {jQuey} $item A list item + */ + dropListItem: function($item) { + var $bsmOpt = $item.data('bsm-option'), o = this.options; + $bsmOpt.removeData('item').data('orig-option').removeAttr('selected'); + (this.buildingSelect ? $.bsmSelect.effects.remove : o.hideEffect)($item); + this.enableSelectOption($bsmOpt); + o.highlightEffect(this.$select, $item, o.highlightRemovedLabel, o); + this.triggerOriginalChange($bsmOpt.data('orig-option'), 'drop'); + }, + + /** + * Trigger a change event on the original select multiple + * so that other scripts can pick them up + * + * @param {jQuery} $origOpt The option from the original select + * @param {String} type Event type + */ + triggerOriginalChange: function($origOpt, type) { + this.ignoreOriginalChangeEvent = true; + this.$original.trigger('change', [{ + option: $origOpt, + value: $origOpt.val(), + item: $origOpt.data('bsm-option').data('item'), + type: type + }]); + } + }; + + $.fn.bsmSelect = function(customOptions) { + var options = $.extend({}, $.bsmSelect.conf, customOptions); + return this.each(function() { + var bsm = $(this).data("bsmSelect"); + if (!bsm) { + bsm = new BsmSelect($(this), options); + $(this).data("bsmSelect", bsm); + } + }); + }; + + $.bsmSelect = {}; + $.extend($.bsmSelect, { + effects: { + show: function($el) { $el.show(); }, + + remove: function($el) { $el.remove(); }, + + highlight: function ($select, $item, label, conf) { + var $highlight, + id = $select.attr('id') + conf.highlightClass; + $('#' + id).remove(); + $highlight = $('<span>', { + 'class': conf.highlightClass, + id: id, + html: label + $item.children('.' + conf.listItemLabelClass).first().text() + }).hide(); + $select.after($highlight.fadeIn('fast').delay(50).fadeOut('slow', function() { $(this).remove(); })); + }, + + verticalListAdd: function ($el) { + $el.animate({ opacity: 'show', height: 'show' }, 100, function() { + $(this).animate({ height: '+=2px' }, 100, function() { + $(this).animate({ height: '-=2px' }, 100); + }); + }); + }, + + verticalListRemove: function($el) { + $el.animate({ opacity: 'hide', height: 'hide' }, 100, function() { + $(this).prev('li').animate({ height: '-=2px' }, 100, function() { + $(this).animate({ height: '+=2px' }, 100); + }); + $(this).remove(); + }); + } + }, + plugins: { + } + }); + + // Default configuration + $.bsmSelect.conf = { + listType: 'ol', // Ordered list 'ol', or unordered list 'ul' + + showEffect: $.bsmSelect.effects.show, + hideEffect: $.bsmSelect.effects.remove, + highlightEffect: $.noop, + + addItemTarget: 'bottom', // Where to place new selected items in list: top or bottom + hideWhenAdded: false, // Hide the option when added to the list? works only in FF + debugMode: false, // Debug mode keeps original select visible + + title: 'Select...', // Text used for the default select label + removeLabel: 'remove', // HTML used for the 'remove' link + highlightAddedLabel: 'Added: ', // Text that precedes highlight of added item + highlightRemovedLabel: 'Removed: ', // Text that precedes highlight of removed item + extractLabel: function($o) { return $o.html(); }, + + plugins: [], // An array of plugin objects to enable + + containerClass: 'bsmContainer', // Class for container that wraps this widget + selectClass: 'bsmSelect', // Class for the newly created <select> + optionDisabledClass: 'bsmOptionDisabled', // Class for items that are already selected / disabled + listClass: 'bsmList', // Class for the list ($list) + listItemClass: 'bsmListItem', // Class for the <li> list items + listItemLabelClass: 'bsmListItemLabel', // Class for the label text that appears in list items + removeClass: 'bsmListItemRemove', // Class given to the 'remove' link + highlightClass: 'bsmHighlight' // Class given to the highlight <span> + }; + +})(jQuery); diff --git a/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js b/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js new file mode 100644 index 0000000..3e4b9f8 --- /dev/null +++ b/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js @@ -0,0 +1,49 @@ +/* + * Better Select Multiple Sortable Plugin + * + * Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb + * + * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. + * + * version: v1.1.1 - 2010-11-17 + */ +(function($) { + $.bsmSelect.plugins.sortable = function(sortConfig, options) + { + if (!(this instanceof arguments.callee)) { + return new arguments.callee(sortConfig, options); + } + this.sortConfig = sortConfig; + this.options = $.extend({}, this.defaultOpt, options || {}); + } + + $.extend($.bsmSelect.plugins.sortable.prototype, { + defaultOpt: { + listSortableClass: 'bsmListSortable' + }, + + init: function(bsm) { + var o = $.extend({}, this.options, bsm.options), + config = $.extend({}, this.sortConfig, { items: '.' + o.listItemClass }), + self = this; + bsm.$list.addClass(o.listSortableClass).sortable(config); + bsm.$original.bind('change', function(e, info) { self.onChange.call(self, bsm, e, info); } ); + bsm.$list.bind('sortupdate', function(e, ui) { self.onSort.call(self, bsm, e, ui); } ); + }, + + onChange: function(bsm, e, info) { + if (info && info.type == 'add' && !bsm.buildingSelect) { + info.option.detach()[bsm.options.addItemTarget == 'top' ? 'prependTo' : 'appendTo'](bsm.$original); + bsm.$list.sortable('refresh'); + } + }, + + onSort: function(bsm, e, ui) { + $('.' + bsm.options.listItemClass, bsm.$list).each(function() { + $(this).data('bsm-option').data('orig-option').detach().appendTo(bsm.$original); + }); + bsm.triggerOriginalChange($(ui.item).data('bsm-option').data('orig-option'), 'sort'); + } + }); +})(jQuery); + |
