vegas.pin.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Pin compatibility patch
  3. * http://pin.jaysalvat.com
  4. */
  5. /* global Pin: true */
  6. (function ($) {
  7. 'use strict';
  8. if ($ && $.pin) {
  9. $.fn.addClass = function (name) {
  10. return this.set('.' + name);
  11. };
  12. $.fn.hasClass = function (name) {
  13. return this.get('.' + name);
  14. };
  15. $.fn.removeClass = function (name) {
  16. return this.set('.' + name, 'remove');
  17. };
  18. $.fn.css = function (key, value) {
  19. if (value === undefined) {
  20. return this.get(':' + key);
  21. }
  22. return this.set(':' + key, value);
  23. };
  24. $.fn.attr = function (key, value) {
  25. if (value === undefined) {
  26. return this.get('@' + key);
  27. }
  28. return this.set('@' + key, value);
  29. };
  30. $.fn.fadeIn = function (duration) {
  31. return this.each(function () {
  32. var self = this,
  33. start = new Date(),
  34. from = 0,
  35. intvl = setInterval(function() {
  36. var passed = new Date() - start,
  37. progress = passed / duration;
  38. self.style.opacity = from + progress;
  39. if (progress >= 1) {
  40. clearInterval(intvl);
  41. }
  42. }, duration || 100);
  43. });
  44. };
  45. }
  46. })(typeof Pin !== 'undefined' ? Pin : null);