010.jquery.fixes.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /** This file is part of KCFinder project
  2. *
  3. * @desc My jQuery UI & Uniform fixes
  4. * @package KCFinder
  5. * @version 3.12
  6. * @author Pavel Tzonkov <sunhater@sunhater.com>
  7. * @copyright 2010-2014 KCFinder Project
  8. * @license http://opensource.org/licenses/GPL-3.0 GPLv3
  9. * @license http://opensource.org/licenses/LGPL-3.0 LGPLv3
  10. * @link http://kcfinder.sunhater.com
  11. */
  12. (function($) {
  13. $.fn.oldMenu = $.fn.menu;
  14. $.fn.menu = function(p1, p2, p3) {
  15. var ret = $(this).oldMenu(p1, p2, p3);
  16. $(this).each(function() {
  17. if (!$(this).hasClass('sh-menu')) {
  18. $(this).addClass('sh-menu')
  19. .children().first().addClass('ui-menu-item-first');
  20. $(this).children().last().addClass('ui-menu-item-last');
  21. $(this).find('.ui-menu').addClass('sh-menu').each(function() {
  22. $(this).children().first().addClass('ui-menu-item-first');
  23. $(this).children().last().addClass('ui-menu-item-last');
  24. });
  25. }
  26. });
  27. return ret;
  28. };
  29. $.fn.oldUniform = $.fn.uniform;
  30. $.fn.uniform = function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) {
  31. var ret = $(this).oldUniform(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
  32. $(this).each(function() {
  33. var t = $(this);
  34. if (!t.hasClass('sh-uniform')) {
  35. t.addClass('sh-uniform');
  36. // Fix upload filename width
  37. if (t.is('input[type="file"]')) {
  38. var f = t.parent().find('.filename');
  39. f.css('width', f.innerWidth());
  40. }
  41. // Add an icon into select boxes
  42. if (t.is('select') && !t.attr('multiple')) {
  43. var p = t.parent(),
  44. height = p.height(),
  45. width = p.outerWidth(),
  46. width2 = p.find('span').outerWidth();
  47. $('<div></div>').addClass('ui-icon').css({
  48. 'float': "right",
  49. marginTop: - parseInt((height / 2) + 8),
  50. marginRight: - parseInt((width - width2) / 2) - 7
  51. }).appendTo(p);
  52. }
  53. }
  54. });
  55. return ret;
  56. };
  57. })(jQuery);