You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.5 KiB

  1. semantic.shape = {};
  2. // ready event
  3. semantic.shape.ready = function() {
  4. // selector cache
  5. var
  6. $demo = $('.demo'),
  7. $dogDemo = $('.dog.shape'),
  8. $directionButton = $('.direction .button'),
  9. $shapeButton = $('.type.buttons .button'),
  10. // alias
  11. handler
  12. ;
  13. // event handlers
  14. handler = {
  15. rotate: function() {
  16. var
  17. $shape = $(this).closest('.example').find('.ui.shape'),
  18. direction = $(this).data('direction') || false,
  19. animation = $(this).data('animation') || false
  20. ;
  21. if(direction && animation) {
  22. $shape
  23. .shape(animation + '.' + direction)
  24. ;
  25. }
  26. },
  27. removeShape: function(){
  28. var
  29. shape = $(this).data('shape') || false
  30. ;
  31. if(shape) {
  32. $demo
  33. .removeClass(shape)
  34. ;
  35. }
  36. },
  37. changeShape: function() {
  38. var
  39. $shape = $(this),
  40. $otherShapes = $shape.siblings(),
  41. shape = $shape.data('shape')
  42. ;
  43. $shape
  44. .addClass('active')
  45. ;
  46. $otherShapes
  47. .removeClass('active')
  48. .each(handler.removeShape)
  49. ;
  50. $demo
  51. .addClass(shape)
  52. ;
  53. }
  54. };
  55. // attach events
  56. $demo
  57. .shape({
  58. debug: true,
  59. verbose: true
  60. })
  61. ;
  62. $directionButton
  63. .on('click', handler.rotate)
  64. .popup({
  65. position : 'bottom center'
  66. })
  67. ;
  68. $shapeButton
  69. .on('click', handler.changeShape)
  70. ;
  71. $dogDemo
  72. .shape()
  73. ;
  74. };
  75. // attach ready event
  76. $(document)
  77. .ready(semantic.shape.ready)
  78. ;