From ab281b36d7cc10913a77f2f8da9ff7b7c011b3ee Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Fri, 23 May 2008 09:26:18 +0000 Subject: [PATCH] --- ui/source/GPL-LICENSE.txt | 278 ++++++ ui/source/MIT-LICENSE.txt | 20 + ui/source/effects.blind.js | 37 + ui/source/effects.bounce.js | 66 ++ ui/source/effects.clip.js | 41 + ui/source/effects.core.js | 501 +++++++++++ ui/source/effects.drop.js | 38 + ui/source/effects.explode.js | 62 ++ ui/source/effects.fade.js | 35 + ui/source/effects.fold.js | 39 + ui/source/effects.highlight.js | 35 + ui/source/effects.pulsate.js | 43 + ui/source/effects.scale.js | 165 ++++ ui/source/effects.shake.js | 45 + ui/source/effects.slide.js | 38 + ui/source/effects.transfer.js | 46 + ui/source/ui.accordion.js | 303 +++++++ ui/source/ui.core.js | 241 ++++++ ui/source/ui.datepicker.js | 1440 ++++++++++++++++++++++++++++++++ ui/source/ui.dialog.js | 448 ++++++++++ ui/source/ui.draggable.js | 527 ++++++++++++ ui/source/ui.droppable.js | 292 +++++++ ui/source/ui.resizable.js | 736 ++++++++++++++++ ui/source/ui.selectable.js | 272 ++++++ ui/source/ui.slider.js | 417 +++++++++ ui/source/ui.sortable.js | 671 +++++++++++++++ ui/source/ui.tabs.js | 595 +++++++++++++ 27 files changed, 7431 insertions(+) create mode 100644 ui/source/GPL-LICENSE.txt create mode 100644 ui/source/MIT-LICENSE.txt create mode 100644 ui/source/effects.blind.js create mode 100644 ui/source/effects.bounce.js create mode 100644 ui/source/effects.clip.js create mode 100644 ui/source/effects.core.js create mode 100644 ui/source/effects.drop.js create mode 100644 ui/source/effects.explode.js create mode 100644 ui/source/effects.fade.js create mode 100644 ui/source/effects.fold.js create mode 100644 ui/source/effects.highlight.js create mode 100644 ui/source/effects.pulsate.js create mode 100644 ui/source/effects.scale.js create mode 100644 ui/source/effects.shake.js create mode 100644 ui/source/effects.slide.js create mode 100644 ui/source/effects.transfer.js create mode 100644 ui/source/ui.accordion.js create mode 100644 ui/source/ui.core.js create mode 100644 ui/source/ui.datepicker.js create mode 100644 ui/source/ui.dialog.js create mode 100644 ui/source/ui.draggable.js create mode 100644 ui/source/ui.droppable.js create mode 100644 ui/source/ui.resizable.js create mode 100644 ui/source/ui.selectable.js create mode 100644 ui/source/ui.slider.js create mode 100644 ui/source/ui.sortable.js create mode 100644 ui/source/ui.tabs.js diff --git a/ui/source/GPL-LICENSE.txt b/ui/source/GPL-LICENSE.txt new file mode 100644 index 000000000..4f3d3e82c --- /dev/null +++ b/ui/source/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. diff --git a/ui/source/MIT-LICENSE.txt b/ui/source/MIT-LICENSE.txt new file mode 100644 index 000000000..a9b0515ea --- /dev/null +++ b/ui/source/MIT-LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2007 John Resig, http://jquery.com/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/source/effects.blind.js b/ui/source/effects.blind.js new file mode 100644 index 000000000..1681ae286 --- /dev/null +++ b/ui/source/effects.blind.js @@ -0,0 +1,37 @@ +;(function($) { + + $.effects.blind = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['position','top','left']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode + var direction = o.options.direction || 'vertical'; // Default direction + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper + var ref = (direction == 'vertical') ? 'height' : 'width'; + var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width(); + if(mode == 'show') wrapper.css(ref, 0); // Shift + + // Animation + var animation = {}; + animation[ref] = mode == 'show' ? distance : 0; + + // Animate + wrapper.animate(animation, o.duration, o.options.easing, function() { + if(mode == 'hide') el.hide(); // Hide + $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + el.dequeue(); + }); + + }); + + }; + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.bounce.js b/ui/source/effects.bounce.js new file mode 100644 index 000000000..2ce40edd4 --- /dev/null +++ b/ui/source/effects.bounce.js @@ -0,0 +1,66 @@ +;(function($) { + + $.effects.bounce = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['position','top','left']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode + var direction = o.options.direction || 'up'; // Default direction + var distance = o.options.distance || 20; // Default distance + var times = o.options.times || 5; // Default # of times + var speed = o.duration || 250; // Default speed per bounce + if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + $.effects.createWrapper(el); // Create Wrapper + var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; + var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; + var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3); + if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift + if (mode == 'hide') distance = distance / (times * 2); + if (mode != 'hide') times--; + + // Animate + if (mode == 'show') { // Show Bounce + var animation = {opacity: 1}; + animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance; + el.animate(animation, speed / 2, o.options.easing); + distance = distance / 2; + times--; + }; + for (var i = 0; i < times; i++) { // Bounces + var animation1 = {}, animation2 = {}; + animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance; + animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance; + el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing); + distance = (mode == 'hide') ? distance * 2 : distance / 2; + }; + if (mode == 'hide') { // Last Bounce + var animation = {opacity: 0}; + animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance; + el.animate(animation, speed / 2, o.options.easing, function(){ + el.hide(); // Hide + $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + }); + } else { + var animation1 = {}, animation2 = {}; + animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance; + animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance; + el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){ + $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + }); + }; + el.queue('fx', function() { el.dequeue(); }); + el.dequeue(); + }); + + }; + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.clip.js b/ui/source/effects.clip.js new file mode 100644 index 000000000..99951b7ca --- /dev/null +++ b/ui/source/effects.clip.js @@ -0,0 +1,41 @@ +;(function($) { + + $.effects.clip = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['position','top','left','width','height']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode + var direction = o.options.direction || 'vertical'; // Default direction + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper + var ref = { + size: (direction == 'vertical') ? 'height' : 'width', + position: (direction == 'vertical') ? 'top' : 'left' + }; + var distance = (direction == 'vertical') ? el.height() : el.width(); + if(mode == 'show') { el.css(ref.size, 0); el.css(ref.position, distance / 2); } // Shift + + // Animation + var animation = {}; + animation[ref.size] = mode == 'show' ? distance : 0; + animation[ref.position] = mode == 'show' ? 0 : distance / 2; + + // Animate + el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { + if(mode == 'hide') el.hide(); // Hide + $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + el.dequeue(); + }}); + + }); + + }; + +})(jQuery); diff --git a/ui/source/effects.core.js b/ui/source/effects.core.js new file mode 100644 index 000000000..8841cf59b --- /dev/null +++ b/ui/source/effects.core.js @@ -0,0 +1,501 @@ +;(function($) { + + $.effects = $.effects || {}; //Add the 'ec' scope + + $.extend($.effects, { + save: function(el, set) { + for(var i=0;i'); + var wrapper = el.parent(); + if (el.css('position') == 'static'){ + wrapper.css({position: 'relative'}); + el.css({position: 'relative'}); + } else { + var top = parseInt(el.css('top'), 10); if (top.constructor != Number) top = 'auto'; + var left = parseInt(el.css('left'), 10); if (left.constructor != Number) left = 'auto'; + wrapper.css({ position: el.css('position'), top: top, left: left, zIndex: el.css('z-index') }).show(); + el.css({position: 'relative', top:0, left:0}); + } + wrapper.css(props); + return wrapper; + }, + removeWrapper: function(el) { + if (el.parent().attr('id') == 'fxWrapper') + return el.parent().replaceWith(el); + return el; + }, + setTransition: function(el, list, factor, val) { + val = val || {}; + $.each(list,function(i, x){ + unit = el.cssUnit(x); + if (unit[0] > 0) val[x] = unit[0] * factor + unit[1]; + }); + return val; + }, + animateClass: function(value, duration, easing, callback) { + + var cb = (typeof easing == "function" ? easing : (callback ? callback : null)); + var ea = (typeof easing == "object" ? easing : null); + + return this.each(function() { + + var offset = {}; var that = $(this); var oldStyleAttr = that.attr("style") || ''; + if(typeof oldStyleAttr == 'object') oldStyleAttr = oldStyleAttr["cssText"]; /* Stupidly in IE, style is a object.. */ + if(value.toggle) { that.hasClass(value.toggle) ? value.remove = value.toggle : value.add = value.toggle; } + + //Let's get a style offset + var oldStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); + if(value.add) that.addClass(value.add); if(value.remove) that.removeClass(value.remove); + var newStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); + if(value.add) that.removeClass(value.add); if(value.remove) that.addClass(value.remove); + + // The main function to form the object for animation + for(var n in newStyle) { + if( typeof newStyle[n] != "function" && newStyle[n] /* No functions and null properties */ + && n.indexOf("Moz") == -1 && n.indexOf("length") == -1 /* No mozilla spezific render properties. */ + && newStyle[n] != oldStyle[n] /* Only values that have changed are used for the animation */ + && (n.match(/color/i) || (!n.match(/color/i) && !isNaN(parseInt(newStyle[n],10)))) /* Only things that can be parsed to integers or colors */ + && (oldStyle.position != "static" || (oldStyle.position == "static" && !n.match(/left|top|bottom|right/))) /* No need for positions when dealing with static positions */ + ) offset[n] = newStyle[n]; + } + + that.animate(offset, duration, ea, function() { // Animate the newly constructed offset object + // Change style attribute back to original. For stupid IE, we need to clear the damn object. + if(typeof $(this).attr("style") == 'object') { $(this).attr("style")["cssText"] = ""; $(this).attr("style")["cssText"] = oldStyleAttr; } else $(this).attr("style", oldStyleAttr); + if(value.add) $(this).addClass(value.add); if(value.remove) $(this).removeClass(value.remove); + if(cb) cb.apply(this, arguments); + }); + + }); + } + }); + + //Extend the methods of jQuery + $.fn.extend({ + //Save old methods + _show: $.fn.show, + _hide: $.fn.hide, + __toggle: $.fn.toggle, + _addClass: $.fn.addClass, + _removeClass: $.fn.removeClass, + _toggleClass: $.fn.toggleClass, + // New ec methods + effect: function(fx,o,speed,callback) { + return $.effects[fx] ? $.effects[fx].call(this, {method: fx, options: o || {}, duration: speed, callback: callback }) : null; + }, + show: function() { + if(!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0]))) + return this._show.apply(this, arguments); + else { + var o = arguments[1] || {}; o['mode'] = 'show'; + return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]); + } + }, + hide: function() { + if(!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0]))) + return this._hide.apply(this, arguments); + else { + var o = arguments[1] || {}; o['mode'] = 'hide'; + return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]); + } + }, + toggle: function(){ + if(!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])) || (arguments[0].constructor == Function)) + return this.__toggle.apply(this, arguments); + else { + var o = arguments[1] || {}; o['mode'] = 'toggle'; + return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]); + } + }, + addClass: function(classNames,speed,easing,callback) { + return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); + }, + removeClass: function(classNames,speed,easing,callback) { + return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); + }, + toggleClass: function(classNames,speed,easing,callback) { + return speed ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames); + }, + morph: function(remove,add,speed,easing,callback) { + return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); + }, + switchClass: function() { + return this.morph.apply(this, arguments); + }, + // helper functions + cssUnit: function(key) { + var style = this.css(key), val = []; + $.each( ['em','px','%','pt'], function(i, unit){ + if(style.indexOf(unit) > 0) + val = [parseFloat(style), unit]; + }); + return val; + } + }); + + /* + * jQuery Color Animations + * Copyright 2007 John Resig + * Released under the MIT and GPL licenses. + */ + + // We override the animation for all of these color styles + jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){ + jQuery.fx.step[attr] = function(fx){ + if ( fx.state == 0 ) { + fx.start = getColor( fx.elem, attr ); + fx.end = getRGB( fx.end ); + } + + fx.elem.style[attr] = "rgb(" + [ + Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0), + Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0), + Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0) + ].join(",") + ")"; + } + }); + + // Color Conversion functions from highlightFade + // By Blair Mitchelmore + // http://jquery.offput.ca/highlightFade/ + + // Parse strings looking for color tuples [255,255,255] + function getRGB(color) { + var result; + + // Check if we're already dealing with an array of colors + if ( color && color.constructor == Array && color.length == 3 ) + return color; + + // Look for rgb(num,num,num) + if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) + return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])]; + + // Look for rgb(num%,num%,num%) + if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) + return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; + + // Look for #a0b1c2 + if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) + return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; + + // Look for #fff + if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) + return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; + + // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 + if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) + return colors['transparent'] + + // Otherwise, we're most likely dealing with a named color + return colors[jQuery.trim(color).toLowerCase()]; + } + + function getColor(elem, attr) { + var color; + + do { + color = jQuery.curCSS(elem, attr); + + // Keep going until we find an element that has color, or we hit the body + if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") ) + break; + + attr = "backgroundColor"; + } while ( elem = elem.parentNode ); + + return getRGB(color); + }; + + // Some named colors to work with + // From Interface by Stefan Petre + // http://interface.eyecon.ro/ + + var colors = { + aqua:[0,255,255], + azure:[240,255,255], + beige:[245,245,220], + black:[0,0,0], + blue:[0,0,255], + brown:[165,42,42], + cyan:[0,255,255], + darkblue:[0,0,139], + darkcyan:[0,139,139], + darkgrey:[169,169,169], + darkgreen:[0,100,0], + darkkhaki:[189,183,107], + darkmagenta:[139,0,139], + darkolivegreen:[85,107,47], + darkorange:[255,140,0], + darkorchid:[153,50,204], + darkred:[139,0,0], + darksalmon:[233,150,122], + darkviolet:[148,0,211], + fuchsia:[255,0,255], + gold:[255,215,0], + green:[0,128,0], + indigo:[75,0,130], + khaki:[240,230,140], + lightblue:[173,216,230], + lightcyan:[224,255,255], + lightgreen:[144,238,144], + lightgrey:[211,211,211], + lightpink:[255,182,193], + lightyellow:[255,255,224], + lime:[0,255,0], + magenta:[255,0,255], + maroon:[128,0,0], + navy:[0,0,128], + olive:[128,128,0], + orange:[255,165,0], + pink:[255,192,203], + purple:[128,0,128], + violet:[128,0,128], + red:[255,0,0], + silver:[192,192,192], + white:[255,255,255], + yellow:[255,255,0], + transparent: [255,255,255] + }; + + +/* + * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ + * + * Uses the built in easing capabilities added In jQuery 1.1 + * to offer multiple easing options + * + * TERMS OF USE - jQuery Easing + * + * Open source under the BSD License. + * + * Copyright © 2008 George McGinley Smith + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * Neither the name of the author nor the names of contributors may be used to endorse + * or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * +*/ + +// t: current time, b: begInnIng value, c: change In value, d: duration +jQuery.easing['jswing'] = jQuery.easing['swing']; + +jQuery.extend( jQuery.easing, +{ + def: 'easeOutQuad', + swing: function (x, t, b, c, d) { + //alert(jQuery.easing.default); + return jQuery.easing[jQuery.easing.def](x, t, b, c, d); + }, + easeInQuad: function (x, t, b, c, d) { + return c*(t/=d)*t + b; + }, + easeOutQuad: function (x, t, b, c, d) { + return -c *(t/=d)*(t-2) + b; + }, + easeInOutQuad: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t + b; + return -c/2 * ((--t)*(t-2) - 1) + b; + }, + easeInCubic: function (x, t, b, c, d) { + return c*(t/=d)*t*t + b; + }, + easeOutCubic: function (x, t, b, c, d) { + return c*((t=t/d-1)*t*t + 1) + b; + }, + easeInOutCubic: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t*t + b; + return c/2*((t-=2)*t*t + 2) + b; + }, + easeInQuart: function (x, t, b, c, d) { + return c*(t/=d)*t*t*t + b; + }, + easeOutQuart: function (x, t, b, c, d) { + return -c * ((t=t/d-1)*t*t*t - 1) + b; + }, + easeInOutQuart: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t*t*t + b; + return -c/2 * ((t-=2)*t*t*t - 2) + b; + }, + easeInQuint: function (x, t, b, c, d) { + return c*(t/=d)*t*t*t*t + b; + }, + easeOutQuint: function (x, t, b, c, d) { + return c*((t=t/d-1)*t*t*t*t + 1) + b; + }, + easeInOutQuint: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; + return c/2*((t-=2)*t*t*t*t + 2) + b; + }, + easeInSine: function (x, t, b, c, d) { + return -c * Math.cos(t/d * (Math.PI/2)) + c + b; + }, + easeOutSine: function (x, t, b, c, d) { + return c * Math.sin(t/d * (Math.PI/2)) + b; + }, + easeInOutSine: function (x, t, b, c, d) { + return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; + }, + easeInExpo: function (x, t, b, c, d) { + return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; + }, + easeOutExpo: function (x, t, b, c, d) { + return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; + }, + easeInOutExpo: function (x, t, b, c, d) { + if (t==0) return b; + if (t==d) return b+c; + if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; + return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; + }, + easeInCirc: function (x, t, b, c, d) { + return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; + }, + easeOutCirc: function (x, t, b, c, d) { + return c * Math.sqrt(1 - (t=t/d-1)*t) + b; + }, + easeInOutCirc: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; + return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; + }, + easeInElastic: function (x, t, b, c, d) { + var s=1.70158;var p=0;var a=c; + if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; + if (a < Math.abs(c)) { a=c; var s=p/4; } + else var s = p/(2*Math.PI) * Math.asin (c/a); + return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; + }, + easeOutElastic: function (x, t, b, c, d) { + var s=1.70158;var p=0;var a=c; + if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; + if (a < Math.abs(c)) { a=c; var s=p/4; } + else var s = p/(2*Math.PI) * Math.asin (c/a); + return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; + }, + easeInOutElastic: function (x, t, b, c, d) { + var s=1.70158;var p=0;var a=c; + if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); + if (a < Math.abs(c)) { a=c; var s=p/4; } + else var s = p/(2*Math.PI) * Math.asin (c/a); + if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; + return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; + }, + easeInBack: function (x, t, b, c, d, s) { + if (s == undefined) s = 1.70158; + return c*(t/=d)*t*((s+1)*t - s) + b; + }, + easeOutBack: function (x, t, b, c, d, s) { + if (s == undefined) s = 1.70158; + return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; + }, + easeInOutBack: function (x, t, b, c, d, s) { + if (s == undefined) s = 1.70158; + if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; + return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; + }, + easeInBounce: function (x, t, b, c, d) { + return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b; + }, + easeOutBounce: function (x, t, b, c, d) { + if ((t/=d) < (1/2.75)) { + return c*(7.5625*t*t) + b; + } else if (t < (2/2.75)) { + return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; + } else if (t < (2.5/2.75)) { + return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; + } else { + return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; + } + }, + easeInOutBounce: function (x, t, b, c, d) { + if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; + return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; + } +}); + +/* + * + * TERMS OF USE - EASING EQUATIONS + * + * Open source under the BSD License. + * + * Copyright © 2001 Robert Penner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * Neither the name of the author nor the names of contributors may be used to endorse + * or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.drop.js b/ui/source/effects.drop.js new file mode 100644 index 000000000..3e55bdd8c --- /dev/null +++ b/ui/source/effects.drop.js @@ -0,0 +1,38 @@ +;(function($) { + + $.effects.drop = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['position','top','left','opacity']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode + var direction = o.options.direction || 'left'; // Default Direction + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + $.effects.createWrapper(el); // Create Wrapper + var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; + var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; + var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2); + if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift + + // Animation + var animation = {opacity: mode == 'show' ? 1 : 0}; + animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; + + // Animate + el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { + if(mode == 'hide') el.hide(); // Hide + $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + el.dequeue(); + }}); + + }); + + }; + +})(jQuery); diff --git a/ui/source/effects.explode.js b/ui/source/effects.explode.js new file mode 100644 index 000000000..4962c5d93 --- /dev/null +++ b/ui/source/effects.explode.js @@ -0,0 +1,62 @@ +;(function($) { + + $.effects.explode = function(o) { + + return this.queue(function() { + + var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; + var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; + + o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode; + var el = $(this).show().css('visibility', 'hidden'); + var offset = el.offset(); + var width = el.outerWidth(); + var height = el.outerHeight(); + + for(var i=0;i') + .css({ + position: 'absolute', + visibility: 'visible', + left: -j*(width/cells), + top: -i*(height/rows) + }) + .parent() + .addClass('ec-explode') + .css({ + position: 'absolute', + overflow: 'hidden', + width: width/cells, + height: height/rows, + left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0), + top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0), + opacity: o.options.mode == 'show' ? 0 : 1 + }).animate({ + left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)), + top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)), + opacity: o.options.mode == 'show' ? 1 : 0 + }, o.duration || 500); + } + } + + // Set a timeout, to call the callback approx. when the other animations have finished + setTimeout(function() { + + o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide(); + if(o.callback) o.callback.apply(el[0]); // Callback + el.dequeue(); + + $('.ec-explode').remove(); + + }, o.duration || 500); + + + }); + + }; + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.fade.js b/ui/source/effects.fade.js new file mode 100644 index 000000000..2d265bfc5 --- /dev/null +++ b/ui/source/effects.fade.js @@ -0,0 +1,35 @@ +;(function($) { + + $.effects.fade = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['opacity']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode + if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle + var opacity = o.options.opacity || 0; // Default fade opacity + var original_opacity = el.css('opacity'); + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + if(mode == 'show') el.css({opacity: 0}); // Shift + + // Animation + var animation = {opacity: mode == 'show' ? original_opacity : opacity}; + + // Animate + el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { + if(mode == 'hide') el.hide(); // Hide + if(mode == 'hide') $.effects.restore(el, props); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + el.dequeue(); + }}); + + }); + + }; + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.fold.js b/ui/source/effects.fold.js new file mode 100644 index 000000000..f2738c2aa --- /dev/null +++ b/ui/source/effects.fold.js @@ -0,0 +1,39 @@ +;(function($) { + + $.effects.fold = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['position','top','left']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode + var size = o.options.size || 15; // Default fold size + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper + var ref = (mode == 'show') ? ['width', 'height'] : ['height', 'width']; + var distance = (mode == 'show') ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()]; + if(mode == 'show') wrapper.css({height: size, width: 0}); // Shift + + // Animation + var animation1 = {}, animation2 = {}; + animation1[ref[0]] = mode == 'show' ? distance[0] : size; + animation2[ref[1]] = mode == 'show' ? distance[1] : 0; + + // Animate + wrapper.animate(animation1, o.duration / 2, o.options.easing) + .animate(animation2, o.duration / 2, o.options.easing, function() { + if(mode == 'hide') el.hide(); // Hide + $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + el.dequeue(); + }); + + }); + + }; + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.highlight.js b/ui/source/effects.highlight.js new file mode 100644 index 000000000..8eeabe39e --- /dev/null +++ b/ui/source/effects.highlight.js @@ -0,0 +1,35 @@ +;(function($) { + + $.effects.highlight = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['backgroundImage','backgroundColor','opacity']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode + var color = o.options.color || "#ffff99"; // Default highlight color + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + el.css({backgroundImage: 'none', backgroundColor: color}); // Shift + + // Animation + var animation = {backgroundColor: $.data(this, "ec.storage.backgroundColor")}; + if (mode == "hide") animation['opacity'] = 0; + + // Animate + el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { + if(mode == "hide") el.hide(); + $.effects.restore(el, props); + if (mode == "show" && jQuery.browser.msie) this.style.removeAttribute('filter'); + if(o.callback) o.callback.apply(this, arguments); + el.dequeue(); + }}); + + }); + + }; + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.pulsate.js b/ui/source/effects.pulsate.js new file mode 100644 index 000000000..aee1525ff --- /dev/null +++ b/ui/source/effects.pulsate.js @@ -0,0 +1,43 @@ +;(function($) { + + $.effects.pulsate = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this); + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode + var times = o.options.times || 5; // Default # of times + + // Adjust + if (mode != 'hide') times--; + if (el.is(':hidden')) { // Show fadeIn + el.css('opacity', 0); + el.show(); // Show + el.animate({opacity: 1}, o.duration / 2, o.options.easing); + times--; + } + + // Animate + for (var i = 0; i < times; i++) { // Pulsate + el.animate({opacity: 0}, o.duration / 2, o.options.easing).animate({opacity: 1}, o.duration / 2, o.options.easing); + }; + if (mode == 'hide') { // Last Pulse + el.animate({opacity: 0}, o.duration / 2, o.options.easing, function(){ + el.hide(); // Hide + if(o.callback) o.callback.apply(this, arguments); // Callback + }); + } else { + el.animate({opacity: 0}, o.duration / 2, o.options.easing).animate({opacity: 1}, o.duration / 2, o.options.easing, function(){ + if(o.callback) o.callback.apply(this, arguments); // Callback + }); + }; + el.queue('fx', function() { el.dequeue(); }); + el.dequeue(); + }); + + }; + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.scale.js b/ui/source/effects.scale.js new file mode 100644 index 000000000..46d2c1f37 --- /dev/null +++ b/ui/source/effects.scale.js @@ -0,0 +1,165 @@ +;(function($) { + + $.effects.puff = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this); + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode + var percent = parseInt(o.options.percent) || 150; // Set default puff percent + o.options.fade = true; // It's not a puff if it doesn't fade! :) + var original = {height: el.height(), width: el.width()}; // Save original + + // Adjust + var factor = percent / 100; + el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor}; + + // Animation + o.options.from = el.from; + o.options.percent = (mode == 'hide') ? percent : 100; + o.options.mode = mode; + + // Animate + el.effect('scale', o.options, o.duration, o.callback); + el.dequeue(); + }); + + }; + + $.effects.scale = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this); + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode + var percent = parseInt(o.options.percent) || (parseInt(o.options.percent) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent + var direction = o.options.direction || 'both'; // Set default axis + var origin = o.options.origin; // The origin of the scaling + if (mode != 'effect') { // Set default origin and restore for show/hide + origin = origin || ['middle','center']; + o.options.restore = true; + } + var original = {height: el.height(), width: el.width()}; // Save original + el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state + + // Adjust + var factor = { // Set scaling factor + y: direction != 'horizontal' ? (percent / 100) : 1, + x: direction != 'vertical' ? (percent / 100) : 1 + }; + el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state + if (origin) { // Calculate baseline shifts + var baseline = $.effects.getBaseline(origin, original); + el.from.top = (original.height - el.from.height) * baseline.y; + el.from.left = (original.width - el.from.width) * baseline.x; + el.to.top = (original.height - el.to.height) * baseline.y; + el.to.left = (original.width - el.to.width) * baseline.x; + }; + if (o.options.fade) { // Fade option to support puff + if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;}; + if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;}; + }; + + // Animation + o.options.from = el.from; o.options.to = el.to; + + // Animate + el.effect('size', o.options, o.duration, o.callback); + el.dequeue(); + }); + + }; + + $.effects.size = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['position','top','left','width','height','overflow','opacity']; + var props1 = ['position','overflow','opacity']; // Always restore + var props2 = ['width','height','overflow']; // Copy for children + var cProps = ['fontSize']; + var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom']; + var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode + var restore = o.options.restore || false; // Default restore + var scale = o.options.scale || 'both'; // Default scale mode + var original = {height: el.height(), width: el.width()}; // Save original + el.from = o.options.from || original; // Default from state + el.to = o.options.to || original; // Default to state + + // Adjust + var factor = { // Set scaling factor + from: {y: el.from.height / original.height, x: el.from.width / original.width}, + to: {y: el.to.height / original.height, x: el.to.width / original.width} + }; + if (scale == 'box' || scale == 'both') { // Scale the css box + if (factor.from.y != factor.to.y) { // Vertical props scaling + props = props.concat(vProps); + el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from); + el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to); + }; + if (factor.from.x != factor.to.x) { // Horizontal props scaling + props = props.concat(hProps); + el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from); + el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to); + }; + }; + if (scale == 'content' || scale == 'both') { // Scale the content + if (factor.from.y != factor.to.y) { // Vertical props scaling + props = props.concat(cProps); + el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from); + el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to); + }; + }; + $.effects.save(el, restore ? props : props1); el.show(); // Save & Show + $.effects.createWrapper(el); // Create Wrapper + el.css('overflow','hidden').css(el.from); // Shift + + // Animate + if (scale == 'content' || scale == 'both') { // Scale the children + vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size + hProps = hProps.concat(['marginLeft','marginRight']); // Add margins + props2 = props.concat(vProps).concat(hProps); // Concat + el.find("*[width]").each(function(){ + child = $(this); + if (restore) $.effects.save(child, props2); + var c_original = {height: child.height(), width: child.width()}; // Save original + child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x}; + child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x}; + if (factor.from.y != factor.to.y) { // Vertical props scaling + child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from); + child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to); + }; + if (factor.from.x != factor.to.x) { // Horizontal props scaling + child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from); + child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to); + }; + child.css(child.from); // Shift children + child.animate(child.to, o.duration, o.options.easing, function(){ + if (restore) $.effects.restore(child, props2); // Restore children + }); // Animate children + }); + }; + + // Animate + el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { + if(mode == 'hide') el.hide(); // Hide + $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + el.dequeue(); + }}); + + }); + + }; + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.shake.js b/ui/source/effects.shake.js new file mode 100644 index 000000000..ae7635ac3 --- /dev/null +++ b/ui/source/effects.shake.js @@ -0,0 +1,45 @@ +;(function($) { + + $.effects.shake = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['position','top','left']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode + var direction = o.options.direction || 'left'; // Default direction + var distance = o.options.distance || 20; // Default distance + var times = o.options.times || 3; // Default # of times + var speed = o.duration || o.options.duration || 140; // Default speed per shake + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + $.effects.createWrapper(el); // Create Wrapper + var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; + var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; + + // Animation + var animation = {}, animation1 = {}, animation2 = {}; + animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance; + animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2; + animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2; + + // Animate + el.animate(animation, speed, o.options.easing); + for (var i = 1; i < times; i++) { // Shakes + el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing); + }; + el.animate(animation1, speed, o.options.easing). + animate(animation, speed / 2, o.options.easing, function(){ // Last shake + $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + }); + el.queue('fx', function() { el.dequeue(); }); + el.dequeue(); + }); + + }; + +})(jQuery); diff --git a/ui/source/effects.slide.js b/ui/source/effects.slide.js new file mode 100644 index 000000000..80e3f5a8b --- /dev/null +++ b/ui/source/effects.slide.js @@ -0,0 +1,38 @@ +;(function($) { + + $.effects.slide = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['position','top','left']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode + var direction = o.options.direction || 'left'; // Default Direction + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper + var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; + var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; + var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true})); + if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift + + // Animation + var animation = {}; + animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; + + // Animate + el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { + if(mode == 'hide') el.hide(); // Hide + $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore + if(o.callback) o.callback.apply(this, arguments); // Callback + el.dequeue(); + }}); + + }); + + }; + +})(jQuery); \ No newline at end of file diff --git a/ui/source/effects.transfer.js b/ui/source/effects.transfer.js new file mode 100644 index 000000000..f83700c0d --- /dev/null +++ b/ui/source/effects.transfer.js @@ -0,0 +1,46 @@ +;(function($) { + + $.effects.transfer = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this); + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode + var target = $(o.options.to); // Find Target + var position = el.position(); + var transfer = $('
').appendTo(document.body) + + // Set target css + transfer.addClass(o.options.className); + transfer.css({ + top: position['top'], + left: position['left'], + height: el.outerHeight({margin:true}) - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')), + width: el.outerWidth({margin:true}) - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')), + position: 'absolute' + }); + + // Animation + position = target.position(); + animation = { + top: position['top'], + left: position['left'], + height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')), + width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')) + }; + + // Animate + transfer.animate(animation, o.duration, o.options.easing, function() { + transfer.remove(); // Remove div + if(o.callback) o.callback.apply(this, arguments); // Callback + el.dequeue(); + }); + + }); + + }; + +})(jQuery); diff --git a/ui/source/ui.accordion.js b/ui/source/ui.accordion.js new file mode 100644 index 000000000..a4bd59327 --- /dev/null +++ b/ui/source/ui.accordion.js @@ -0,0 +1,303 @@ +/* + * jQuery UI Accordion + * + * Copyright (c) 2007, 2008 Jörn Zaefferer + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Accordion + * + * Depends: + * ui.core.js + * + * Revision: $Id: ui.accordion.js 5656 2008-05-21 19:35:33Z braeker $ + */ + +;(function($) { + + $.widget("ui.accordion", { + init: function() { + var options = this.options; + + if ( options.navigation ) { + var current = this.element.find("a").filter(options.navigationFilter); + if ( current.length ) { + if ( current.filter(options.header).length ) { + options.active = current; + } else { + options.active = current.parent().parent().prev(); + current.addClass("current"); + } + } + } + + // calculate active if not specified, using the first header + options.headers = this.element.find(options.header); + options.active = findActive(options.headers, options.active); + + // IE7-/Win - Extra vertical space in Lists fixed + if ($.browser.msie) { + this.element.find('a').css('zoom', '1'); + } + + if (!this.element.hasClass("ui-accordion")) { + this.element.addClass("ui-accordion"); + $("").insertBefore(options.headers); + $("").appendTo(options.headers); + options.headers.addClass("ui-accordion-header").attr("tabindex", "0"); + } + + var maxHeight; + if ( options.fillSpace ) { + maxHeight = this.element.parent().height(); + options.headers.each(function() { + maxHeight -= $(this).outerHeight(); + }); + var maxPadding = 0; + options.headers.next().each(function() { + maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height()); + }).height(maxHeight - maxPadding); + } else if ( options.autoHeight ) { + maxHeight = 0; + options.headers.next().each(function() { + maxHeight = Math.max(maxHeight, $(this).outerHeight()); + }).height(maxHeight); + } + + options.headers + .not(options.active || "") + .next() + .hide(); + options.active.parent().andSelf().addClass(options.selectedClass); + + if (options.event) { + this.element.bind((options.event) + ".accordion", clickHandler); + } + }, + activate: function(index) { + // call clickHandler with custom event + clickHandler.call(this.element[0], { + target: findActive( this.options.headers, index )[0] + }); + }, + destroy: function() { + this.options.headers.next().css("display", ""); + if ( this.options.fillSpace || this.options.autoHeight ) { + this.options.headers.next().css("height", ""); + } + $.removeData(this.element[0], "accordion"); + this.element.removeClass("ui-accordion").unbind(".accordion"); + } + }); + + function scopeCallback(callback, scope) { + return function() { + return callback.apply(scope, arguments); + }; + }; + + function completed(cancel) { + // if removed while animated data can be empty + if (!$.data(this, "accordion")) { + return; + } + + var instance = $.data(this, "accordion"); + var options = instance.options; + options.running = cancel ? 0 : --options.running; + if ( options.running ) { + return; + } + if ( options.clearStyle ) { + options.toShow.add(options.toHide).css({ + height: "", + overflow: "" + }); + } + $(this).triggerHandler("accordionchange", [options.data], options.change); + } + + function toggle(toShow, toHide, data, clickedActive, down) { + var options = $.data(this, "accordion").options; + options.toShow = toShow; + options.toHide = toHide; + options.data = data; + var complete = scopeCallback(completed, this); + + // count elements to animate + options.running = toHide.size() === 0 ? toShow.size() : toHide.size(); + + if ( options.animated ) { + if ( !options.alwaysOpen && clickedActive ) { + $.ui.accordion.animations[options.animated]({ + toShow: jQuery([]), + toHide: toHide, + complete: complete, + down: down, + autoHeight: options.autoHeight + }); + } else { + $.ui.accordion.animations[options.animated]({ + toShow: toShow, + toHide: toHide, + complete: complete, + down: down, + autoHeight: options.autoHeight + }); + } + } else { + if ( !options.alwaysOpen && clickedActive ) { + toShow.toggle(); + } else { + toHide.hide(); + toShow.show(); + } + complete(true); + } + } + + function clickHandler(event) { + var options = $.data(this, "accordion").options; + if (options.disabled) { + return false; + } + + // called only when using activate(false) to close all parts programmatically + if ( !event.target && !options.alwaysOpen ) { + options.active.parent().andSelf().toggleClass(options.selectedClass); + var toHide = options.active.next(), + data = { + instance: this, + options: options, + newHeader: jQuery([]), + oldHeader: options.active, + newContent: jQuery([]), + oldContent: toHide + }, + toShow = (options.active = $([])); + toggle.call(this, toShow, toHide, data ); + return false; + } + // get the click target + var clicked = $(event.target); + + // due to the event delegation model, we have to check if one + // of the parent elements is our actual header, and find that + if ( clicked.parents(options.header).length ) { + while ( !clicked.is(options.header) ) { + clicked = clicked.parent(); + } + } + + var clickedActive = clicked[0] == options.active[0]; + + // if animations are still active, or the active header is the target, ignore click + if (options.running || (options.alwaysOpen && clickedActive)) { + return false; + } + if (!clicked.is(options.header)) { + return; + } + + // switch classes + options.active.parent().andSelf().toggleClass(options.selectedClass); + if ( !clickedActive ) { + clicked.parent().andSelf().addClass(options.selectedClass); + } + + // find elements to show and hide + var toShow = clicked.next(), + toHide = options.active.next(), + //data = [clicked, options.active, toShow, toHide], + data = { + instance: this, + options: options, + newHeader: clicked, + oldHeader: options.active, + newContent: toShow, + oldContent: toHide + }, + down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] ); + + options.active = clickedActive ? $([]) : clicked; + toggle.call(this, toShow, toHide, data, clickedActive, down ); + + return false; + }; + + function findActive(headers, selector) { + return selector != undefined + ? typeof selector == "number" + ? headers.filter(":eq(" + selector + ")") + : headers.not(headers.not(selector)) + : selector === false + ? $([]) + : headers.filter(":eq(0)"); + } + + $.extend($.ui.accordion, { + defaults: { + selectedClass: "selected", + alwaysOpen: true, + animated: 'slide', + event: "click", + header: "a", + autoHeight: true, + running: 0, + navigationFilter: function() { + return this.href.toLowerCase() == location.href.toLowerCase(); + } + }, + animations: { + slide: function(options, additions) { + options = $.extend({ + easing: "swing", + duration: 300 + }, options, additions); + if ( !options.toHide.size() ) { + options.toShow.animate({height: "show"}, options); + return; + } + var hideHeight = options.toHide.height(), + showHeight = options.toShow.height(), + difference = showHeight / hideHeight; + options.toShow.css({ height: 0, overflow: 'hidden' }).show(); + options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{ + step: function(now) { + var current = (hideHeight - now) * difference; + if ($.browser.msie || $.browser.opera) { + current = Math.ceil(current); + } + options.toShow.height( current ); + }, + duration: options.duration, + easing: options.easing, + complete: function() { + if ( !options.autoHeight ) { + options.toShow.css("height", "auto"); + } + options.complete(); + } + }); + }, + bounceslide: function(options) { + this.slide(options, { + easing: options.down ? "bounceout" : "swing", + duration: options.down ? 1000 : 200 + }); + }, + easeslide: function(options) { + this.slide(options, { + easing: "easeinout", + duration: 700 + }); + } + } + }); + + // deprecated, use accordion("activate", index) instead + $.fn.activate = function(index) { + return this.accordion("activate", index); + }; + +})(jQuery); diff --git a/ui/source/ui.core.js b/ui/source/ui.core.js new file mode 100644 index 000000000..500cbdcbc --- /dev/null +++ b/ui/source/ui.core.js @@ -0,0 +1,241 @@ +/* + * jQuery UI @VERSION + * + * Copyright (c) 2008 Paul Bakaus (ui.jquery.com) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI + * + * $Id: ui.core.js 5634 2008-05-19 20:53:51Z joern.zaefferer $ + */ +;(function($) { + + $.ui = { + plugin: { + add: function(module, option, set) { + var proto = $.ui[module].prototype; + for(var i in set) { + proto.plugins[i] = proto.plugins[i] || []; + proto.plugins[i].push([option, set[i]]); + } + }, + call: function(instance, name, args) { + var set = instance.plugins[name]; + if(!set) { return; } + + for (var i = 0; i < set.length; i++) { + if (instance.options[set[i][0]]) { + set[i][1].apply(instance.element, args); + } + } + } + }, + cssCache: {}, + css: function(name) { + if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; } + var tmp = $('
').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body'); + + //if (!$.browser.safari) + //tmp.appendTo('body'); + + //Opera and Safari set width and height to 0px instead of auto + //Safari returns rgba(0,0,0,0) when bgcolor is not set + $.ui.cssCache[name] = !!( + (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || + !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))) + ); + try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){} + return $.ui.cssCache[name]; + }, + disableSelection: function(e) { + e.unselectable = "on"; + e.onselectstart = function() { return false; }; + if (e.style) { e.style.MozUserSelect = "none"; } + }, + enableSelection: function(e) { + e.unselectable = "off"; + e.onselectstart = function() { return true; }; + if (e.style) { e.style.MozUserSelect = ""; } + }, + hasScroll: function(e, a) { + var scroll = /top/.test(a||"top") ? 'scrollTop' : 'scrollLeft', has = false; + if (e[scroll] > 0) return true; e[scroll] = 1; + has = e[scroll] > 0 ? true : false; e[scroll] = 0; + return has; + } + }; + + + /** jQuery core modifications and additions **/ + + var _remove = $.fn.remove; + $.fn.remove = function() { + $("*", this).add(this).trigger("remove"); + return _remove.apply(this, arguments ); + }; + + // $.widget is a factory to create jQuery plugins + // taking some boilerplate code out of the plugin code + // created by Scott González and Jörn Zaefferer + function getter(namespace, plugin, method) { + var methods = $[namespace][plugin].getter || []; + methods = (typeof methods == "string" ? methods.split(/,?\s+/) : methods); + return ($.inArray(method, methods) != -1); + } + + var widgetPrototype = { + init: function() {}, + destroy: function() { + this.element.removeData(this.widgetName); + }, + + getData: function(key) { + return this.options[key]; + }, + setData: function(key, value) { + this.options[key] = value; + }, + + enable: function() { + this.setData('disabled', false); + }, + disable: function() { + this.setData('disabled', true); + } + }; + + $.widget = function(name, prototype) { + var namespace = name.split(".")[0]; + name = name.split(".")[1]; + // create plugin method + $.fn[name] = function(options) { + var isMethodCall = (typeof options == 'string'), + args = Array.prototype.slice.call(arguments, 1); + + if (isMethodCall && getter(namespace, name, options)) { + var instance = $.data(this[0], name); + return (instance ? instance[options].apply(instance, args) + : undefined); + } + + return this.each(function() { + var instance = $.data(this, name); + if (!instance) { + $.data(this, name, new $[namespace][name](this, options)); + } else if (isMethodCall) { + instance[options].apply(instance, args); + } + }); + }; + + // create widget constructor + $[namespace][name] = function(element, options) { + var self = this; + + this.widgetName = name; + + this.options = $.extend({}, $[namespace][name].defaults, options); + this.element = $(element) + .bind('setData.' + name, function(e, key, value) { + return self.setData(key, value); + }) + .bind('getData.' + name, function(e, key) { + return self.getData(key); + }) + .bind('remove', function() { + return self.destroy(); + }); + this.init(); + }; + + // add widget prototype + $[namespace][name].prototype = $.extend({}, widgetPrototype, prototype); + }; + + + /** Mouse Interaction Plugin **/ + + $.widget("ui.mouse", { + init: function() { + var self = this; + + this.element + .bind('mousedown.mouse', function() { return self.click.apply(self, arguments); }) + .bind('mouseup.mouse', function() { (self.timer && clearTimeout(self.timer)); }) + .bind('click.mouse', function() { if(self.initialized) { self.initialized = false; return false; } }); + //Prevent text selection in IE + if ($.browser.msie) { + this.unselectable = this.element.attr('unselectable'); + this.element.attr('unselectable', 'on'); + } + }, + destroy: function() { + this.element.unbind('.mouse').removeData("mouse"); + ($.browser.msie && this.element.attr('unselectable', this.unselectable)); + }, + trigger: function() { return this.click.apply(this, arguments); }, + click: function(e) { + + if( e.which != 1 //only left click starts dragging + || $.inArray(e.target.nodeName.toLowerCase(), this.options.dragPrevention || []) != -1 // Prevent execution on defined elements + || (this.options.condition && !this.options.condition.apply(this.options.executor || this, [e, this.element])) //Prevent execution on condition + ) { return true; } + + var self = this; + this.initialized = false; + var initialize = function() { + self._MP = { left: e.pageX, top: e.pageY }; // Store the click mouse position + $(document).bind('mouseup.mouse', function() { return self.stop.apply(self, arguments); }); + $(document).bind('mousemove.mouse', function() { return self.drag.apply(self, arguments); }); + + if(!self.initalized && Math.abs(self._MP.left-e.pageX) >= self.options.distance || Math.abs(self._MP.top-e.pageY) >= self.options.distance) { + (self.options.start && self.options.start.call(self.options.executor || self, e, self.element)); + (self.options.drag && self.options.drag.call(self.options.executor || self, e, this.element)); //This is actually not correct, but expected + self.initialized = true; + } + }; + + if(this.options.delay) { + if(this.timer) { clearTimeout(this.timer); } + this.timer = setTimeout(initialize, this.options.delay); + } else { + initialize(); + } + + return false; + + }, + stop: function(e) { + + if(!this.initialized) { + return $(document).unbind('mouseup.mouse').unbind('mousemove.mouse'); + } + + (this.options.stop && this.options.stop.call(this.options.executor || this, e, this.element)); + + $(document).unbind('mouseup.mouse').unbind('mousemove.mouse'); + return false; + + }, + drag: function(e) { + + var o = this.options; + if ($.browser.msie && !e.button) { + return this.stop.call(this, e); // IE mouseup check + } + + if(!this.initialized && (Math.abs(this._MP.left-e.pageX) >= o.distance || Math.abs(this._MP.top-e.pageY) >= o.distance)) { + (o.start && o.start.call(o.executor || this, e, this.element)); + this.initialized = true; + } else { + if(!this.initialized) { return false; } + } + + (o.drag && o.drag.call(this.options.executor || this, e, this.element)); + return false; + + } + }); + +})(jQuery); diff --git a/ui/source/ui.datepicker.js b/ui/source/ui.datepicker.js new file mode 100644 index 000000000..4d49d4a65 --- /dev/null +++ b/ui/source/ui.datepicker.js @@ -0,0 +1,1440 @@ +/* jQuery UI Date Picker v3.4.3 (previously jQuery Calendar) + Written by Marc Grabanski (m@marcgrabanski.com) and Keith Wood (kbwood@virginbroadband.com.au). + + Copyright (c) 2007 Marc Grabanski (http://marcgrabanski.com/code/ui-datepicker) + Dual licensed under the MIT (MIT-LICENSE.txt) + and GPL (GPL-LICENSE.txt) licenses. + Date: 09-03-2007 */ + +;(function($) { // hide the namespace + +/* Date picker manager. + Use the singleton instance of this class, $.datepicker, to interact with the date picker. + Settings for (groups of) date pickers are maintained in an instance object + (DatepickerInstance), allowing multiple different settings on the same page. */ + +function Datepicker() { + this.debug = false; // Change this to true to start debugging + this._nextId = 0; // Next ID for a date picker instance + this._inst = []; // List of instances indexed by ID + this._curInst = null; // The current instance in use + this._disabledInputs = []; // List of date picker inputs that have been disabled + this._datepickerShowing = false; // True if the popup picker is showing , false if not + this._inDialog = false; // True if showing within a "dialog", false if not + this.regional = []; // Available regional settings, indexed by language code + this.regional[''] = { // Default regional settings + clearText: 'Clear', // Display text for clear link + clearStatus: 'Erase the current date', // Status text for clear link + closeText: 'Close', // Display text for close link + closeStatus: 'Close without change', // Status text for close link + prevText: '<Prev', // Display text for previous month link + prevStatus: 'Show the previous month', // Status text for previous month link + nextText: 'Next>', // Display text for next month link + nextStatus: 'Show the next month', // Status text for next month link + currentText: 'Today', // Display text for current month link + currentStatus: 'Show the current month', // Status text for current month link + monthNames: ['January','February','March','April','May','June', + 'July','August','September','October','November','December'], // Names of months for drop-down and formatting + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting + monthStatus: 'Show a different month', // Status text for selecting a month + yearStatus: 'Show a different year', // Status text for selecting a year + weekHeader: 'Wk', // Header for the week of the year column + weekStatus: 'Week of the year', // Status text for the week of the year column + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting + dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday + dayStatus: 'Set DD as first week day', // Status text for the day of the week selection + dateStatus: 'Select DD, M d', // Status text for the date selection + dateFormat: 'mm/dd/yy', // See format options on parseDate + firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... + initStatus: 'Select a date', // Initial Status text on opening + isRTL: false // True if right-to-left language, false if left-to-right + }; + this._defaults = { // Global defaults for all the date picker instances + showOn: 'focus', // 'focus' for popup on focus, + // 'button' for trigger button, or 'both' for either + showAnim: 'show', // Name of jQuery animation for popup + defaultDate: null, // Used when field is blank: actual date, + // +/-number for offset from today, null for today + appendText: '', // Display text following the input box, e.g. showing the format + buttonText: '...', // Text for trigger button + buttonImage: '', // URL for trigger button image + buttonImageOnly: false, // True if the image appears alone, false if it appears on a button + closeAtTop: true, // True to have the clear/close at the top, + // false to have them at the bottom + mandatory: false, // True to hide the Clear link, false to include it + hideIfNoPrevNext: false, // True to hide next/previous month links + // if not applicable, false to just disable them + changeMonth: true, // True if month can be selected directly, false if only prev/next + changeYear: true, // True if year can be selected directly, false if only prev/next + yearRange: '-10:+10', // Range of years to display in drop-down, + // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn) + changeFirstDay: true, // True to click on day name to change, false to remain as set + showOtherMonths: false, // True to show dates in other months, false to leave blank + showWeeks: false, // True to show week of the year, false to omit + calculateWeek: this.iso8601Week, // How to calculate the week of the year, + // takes a Date and returns the number of the week for it + shortYearCutoff: '+10', // Short year values < this are in the current century, + // > this are in the previous century, + // string value starting with '+' for current year + value + showStatus: false, // True to show status bar at bottom, false to not show it + statusForDate: this.dateStatus, // Function to provide status text for a date - + // takes date and instance as parameters, returns display text + minDate: null, // The earliest selectable date, or null for no limit + maxDate: null, // The latest selectable date, or null for no limit + speed: 'normal', // Speed of display/closure + beforeShowDay: null, // Function that takes a date and returns an array with + // [0] = true if selectable, false if not, + // [1] = custom CSS class name(s) or '', e.g. $.datepicker.noWeekends + beforeShow: null, // Function that takes an input field and + // returns a set of custom settings for the date picker + onSelect: null, // Define a callback function when a date is selected + onClose: null, // Define a callback function when the datepicker is closed + numberOfMonths: 1, // Number of months to show at a time + stepMonths: 1, // Number of months to step back/forward + rangeSelect: false, // Allows for selecting a date range on one date picker + rangeSeparator: ' - ' // Text between two dates in a range + }; + $.extend(this._defaults, this.regional['']); + this._datepickerDiv = $('
'); +} + +$.extend(Datepicker.prototype, { + /* Class name added to elements to indicate already configured with a date picker. */ + markerClassName: 'hasDatepicker', + + /* Debug logging (if enabled). */ + log: function () { + if (this.debug) + console.log.apply('', arguments); + }, + + /* Register a new date picker instance - with custom settings. */ + _register: function(inst) { + var id = this._nextId++; + this._inst[id] = inst; + return id; + }, + + /* Retrieve a particular date picker instance based on its ID. */ + _getInst: function(id) { + return this._inst[id] || id; + }, + + /* Override the default settings for all instances of the date picker. + @param settings object - the new settings to use as defaults (anonymous object) + @return the manager object */ + setDefaults: function(settings) { + extendRemove(this._defaults, settings || {}); + return this; + }, + + /* Attach the date picker to a jQuery selection. + @param target element - the target input field or division or span + @param settings object - the new settings to use for this date picker instance (anonymous) */ + _attachDatepicker: function(target, settings) { + // check for settings on the control itself - in namespace 'date:' + var inlineSettings = null; + for (attrName in this._defaults) { + var attrValue = target.getAttribute('date:' + attrName); + if (attrValue) { + inlineSettings = inlineSettings || {}; + try { + inlineSettings[attrName] = eval(attrValue); + } catch (err) { + inlineSettings[attrName] = attrValue; + } + } + } + var nodeName = target.nodeName.toLowerCase(); + var instSettings = (inlineSettings ? + $.extend(settings || {}, inlineSettings || {}) : settings); + if (nodeName == 'input') { + var inst = (inst && !inlineSettings ? inst : + new DatepickerInstance(instSettings, false)); + this._connectDatepicker(target, inst); + } else if (nodeName == 'div' || nodeName == 'span') { + var inst = new DatepickerInstance(instSettings, true); + this._inlineDatepicker(target, inst); + } + }, + + /* Detach a datepicker from its control. + @param target element - the target input field or division or span */ + _destroyDatepicker: function(target) { + var nodeName = target.nodeName.toLowerCase(); + var calId = target._calId; + target._calId = null; + var $target = $(target); + if (nodeName == 'input') { + $target.siblings('.datepicker_append').replaceWith('').end() + .siblings('.datepicker_trigger').replaceWith('').end() + .removeClass(this.markerClassName) + .unbind('focus', this._showDatepicker) + .unbind('keydown', this._doKeyDown) + .unbind('keypress', this._doKeyPress); + var wrapper = $target.parents('.datepicker_wrap'); + if (wrapper) + wrapper.replaceWith(wrapper.html()); + } else if (nodeName == 'div' || nodeName == 'span') + $target.removeClass(this.markerClassName).empty(); + if ($('input[_calId=' + calId + ']').length == 0) + // clean up if last for this ID + this._inst[calId] = null; + }, + + /* Enable the date picker to a jQuery selection. + @param target element - the target input field or division or span */ + _enableDatepicker: function(target) { + target.disabled = false; + $(target).siblings('button.datepicker_trigger').each(function() { this.disabled = false; }).end() + .siblings('img.datepicker_trigger').css({opacity: '1.0', cursor: ''}); + this._disabledInputs = $.map(this._disabledInputs, + function(value) { return (value == target ? null : value); }); // delete entry + }, + + /* Disable the date picker to a jQuery selection. + @param target element - the target input field or division or span */ + _disableDatepicker: function(target) { + target.disabled = true; + $(target).siblings('button.datepicker_trigger').each(function() { this.disabled = true; }).end() + .siblings('img.datepicker_trigger').css({opacity: '0.5', cursor: 'default'}); + this._disabledInputs = $.map($.datepicker._disabledInputs, + function(value) { return (value == target ? null : value); }); // delete entry + this._disabledInputs[$.datepicker._disabledInputs.length] = target; + }, + + /* Is the first field in a jQuery collection disabled as a datepicker? + @param target element - the target input field or division or span + @return boolean - true if disabled, false if enabled */ + _isDisabledDatepicker: function(target) { + if (!target) + return false; + for (var i = 0; i < this._disabledInputs.length; i++) { + if (this._disabledInputs[i] == target) + return true; + } + return false; + }, + + /* Update the settings for a date picker attached to an input field or division. + @param target element - the target input field or division or span + @param name string - the name of the setting to change or + object - the new settings to update + @param value any - the new value for the setting (omit if above is an object) */ + _changeDatepicker: function(target, name, value) { + var settings = name || {}; + if (typeof name == 'string') { + settings = {}; + settings[name] = value; + } + if (inst = this._getInst(target._calId)) { + extendRemove(inst._settings, settings); + this._updateDatepicker(inst); + } + }, + + /* Set the dates for a jQuery selection. + @param target element - the target input field or division or span + @param date Date - the new date + @param endDate Date - the new end date for a range (optional) */ + _setDateDatepicker: function(target, date, endDate) { + if (inst = this._getInst(target._calId)) { + inst._setDate(date, endDate); + this._updateDatepicker(inst); + } + }, + + /* Get the date(s) for the first entry in a jQuery selection. + @param target element - the target input field or division or span + @return Date - the current date or + Date[2] - the current dates for a range */ + _getDateDatepicker: function(target) { + var inst = this._getInst(target._calId); + return (inst ? inst._getDate() : null); + }, + + /* Handle keystrokes. */ + _doKeyDown: function(e) { + var inst = $.datepicker._getInst(this._calId); + if ($.datepicker._datepickerShowing) + switch (e.keyCode) { + case 9: $.datepicker._hideDatepicker(null, ''); + break; // hide on tab out + case 13: $.datepicker._selectDay(inst, inst._selectedMonth, inst._selectedYear, + $('td.datepicker_daysCellOver', inst._datepickerDiv)[0]); + return false; // don't submit the form + break; // select the value on enter + case 27: $.datepicker._hideDatepicker(null, inst._get('speed')); + break; // hide on escape + case 33: $.datepicker._adjustDate(inst, + (e.ctrlKey ? -1 : -inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); + break; // previous month/year on page up/+ ctrl + case 34: $.datepicker._adjustDate(inst, + (e.ctrlKey ? +1 : +inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); + break; // next month/year on page down/+ ctrl + case 35: if (e.ctrlKey) $.datepicker._clearDate(inst); + break; // clear on ctrl+end + case 36: if (e.ctrlKey) $.datepicker._gotoToday(inst); + break; // current on ctrl+home + case 37: if (e.ctrlKey) $.datepicker._adjustDate(inst, -1, 'D'); + break; // -1 day on ctrl+left + case 38: if (e.ctrlKey) $.datepicker._adjustDate(inst, -7, 'D'); + break; // -1 week on ctrl+up + case 39: if (e.ctrlKey) $.datepicker._adjustDate(inst, +1, 'D'); + break; // +1 day on ctrl+right + case 40: if (e.ctrlKey) $.datepicker._adjustDate(inst, +7, 'D'); + break; // +1 week on ctrl+down + } + else if (e.keyCode == 36 && e.ctrlKey) // display the date picker on ctrl+home + $.datepicker._showDatepicker(this); + }, + + /* Filter entered characters - based on date format. */ + _doKeyPress: function(e) { + var inst = $.datepicker._getInst(this._calId); + var chars = $.datepicker._possibleChars(inst._get('dateFormat')); + var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); + return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); + }, + + /* Attach the date picker to an input field. */ + _connectDatepicker: function(target, inst) { + var input = $(target); + if (input.is('.' + this.markerClassName)) + return; + var appendText = inst._get('appendText'); + var isRTL = inst._get('isRTL'); + if (appendText) { + if (isRTL) + input.before('' + appendText); + else + input.after('' + appendText); + } + var showOn = inst._get('showOn'); + if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field + input.focus(this._showDatepicker); + if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked + input.wrap(''); + var buttonText = inst._get('buttonText'); + var buttonImage = inst._get('buttonImage'); + var trigger = $(inst._get('buttonImageOnly') ? + $('').addClass('datepicker_trigger').attr({ src: buttonImage, alt: buttonText, title: buttonText }) : + $('