Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

70 řádky
1.7 KiB

  1. /*!
  2. * jQuery UI Labels 1.13.1
  3. * http://jqueryui.com
  4. *
  5. * Copyright jQuery Foundation and other contributors
  6. * Released under the MIT license.
  7. * http://jquery.org/license
  8. */
  9. //>>label: labels
  10. //>>group: Core
  11. //>>description: Find all the labels associated with a given input
  12. //>>docs: http://api.jqueryui.com/labels/
  13. ( function( factory ) {
  14. "use strict";
  15. if ( typeof define === "function" && define.amd ) {
  16. // AMD. Register as an anonymous module.
  17. define( [ "jquery", "./version" ], factory );
  18. } else {
  19. // Browser globals
  20. factory( jQuery );
  21. }
  22. } )( function( $ ) {
  23. "use strict";
  24. return $.fn.labels = function() {
  25. var ancestor, selector, id, labels, ancestors;
  26. if ( !this.length ) {
  27. return this.pushStack( [] );
  28. }
  29. // Check control.labels first
  30. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  31. return this.pushStack( this[ 0 ].labels );
  32. }
  33. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  34. // Above browsers do not support control.labels. Everything below is to support them
  35. // as well as document fragments. control.labels does not work on document fragments
  36. labels = this.eq( 0 ).parents( "label" );
  37. // Look for the label based on the id
  38. id = this.attr( "id" );
  39. if ( id ) {
  40. // We don't search against the document in case the element
  41. // is disconnected from the DOM
  42. ancestor = this.eq( 0 ).parents().last();
  43. // Get a full set of top level ancestors
  44. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  45. // Create a selector for the label based on the id
  46. selector = "label[for='" + $.escapeSelector( id ) + "']";
  47. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  48. }
  49. // Return whatever we have found for labels
  50. return this.pushStack( labels );
  51. };
  52. } );