A search interface for data from the Politics of Patents case study (part of Copim WP6): this parses data from the archive of RTF files and provides additional data from the European Patent Office API. https://patents.copim.ac.uk
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.

98 lines
3.9KB

  1. /*
  2. * Dropit v1.1.0
  3. * http://dev7studios.com/dropit
  4. *
  5. * Copyright 2012, Dev7studios
  6. * Free to use and abuse under the MIT license.
  7. * http://www.opensource.org/licenses/mit-license.php
  8. */
  9. ;(function($) {
  10. $.fn.dropit = function(method) {
  11. var methods = {
  12. init : function(options) {
  13. this.dropit.settings = $.extend({}, this.dropit.defaults, options);
  14. return this.each(function() {
  15. var $el = $(this),
  16. el = this,
  17. settings = $.fn.dropit.settings;
  18. // Hide initial submenus
  19. $el.addClass('dropit')
  20. .find('>'+ settings.triggerParentEl +':has('+ settings.submenuEl +')').addClass('dropit-trigger')
  21. .find(settings.submenuEl).addClass('dropit-submenu').hide();
  22. // Open on click
  23. $el.off(settings.action).on(settings.action, settings.triggerParentEl +':has('+ settings.submenuEl +') > '+ settings.triggerEl +'', function(){
  24. // Close click menu's if clicked again
  25. if(settings.action == 'click' && $(this).parents(settings.triggerParentEl).hasClass('dropit-open')){
  26. settings.beforeHide.call(this);
  27. $(this).parents(settings.triggerParentEl).removeClass('dropit-open').find(settings.submenuEl).hide();
  28. settings.afterHide.call(this);
  29. return false;
  30. }
  31. // Hide open menus
  32. settings.beforeHide.call(this);
  33. $('.dropit-open').removeClass('dropit-open').find('.dropit-submenu').hide();
  34. settings.afterHide.call(this);
  35. // Open this menu
  36. settings.beforeShow.call(this);
  37. $(this).parents(settings.triggerParentEl).addClass('dropit-open').find(settings.submenuEl).show();
  38. settings.afterShow.call(this);
  39. return false;
  40. });
  41. // Close if outside click
  42. $(document).on('click', function(){
  43. settings.beforeHide.call(this);
  44. $('.dropit-open').removeClass('dropit-open').find('.dropit-submenu').hide();
  45. settings.afterHide.call(this);
  46. });
  47. // If hover
  48. if(settings.action == 'mouseenter'){
  49. $el.on('mouseleave', '.dropit-open', function(){
  50. settings.beforeHide.call(this);
  51. $(this).removeClass('dropit-open').find(settings.submenuEl).hide();
  52. settings.afterHide.call(this);
  53. });
  54. }
  55. settings.afterLoad.call(this);
  56. });
  57. }
  58. };
  59. if (methods[method]) {
  60. return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
  61. } else if (typeof method === 'object' || !method) {
  62. return methods.init.apply(this, arguments);
  63. } else {
  64. $.error( 'Method "' + method + '" does not exist in dropit plugin!');
  65. }
  66. };
  67. $.fn.dropit.defaults = {
  68. action: 'mouseenter', // The open action for the trigger
  69. submenuEl: 'ul', // The submenu element
  70. triggerEl: 'a', // The trigger element
  71. triggerParentEl: 'li', // The trigger parent element
  72. afterLoad: function(){}, // Triggers when plugin has loaded
  73. beforeShow: function(){}, // Triggers before submenu is shown
  74. afterShow: function(){}, // Triggers after submenu is shown
  75. beforeHide: function(){}, // Triggers before submenu is hidden
  76. afterHide: function(){} // Triggers before submenu is hidden
  77. };
  78. $.fn.dropit.settings = {};
  79. })(jQuery);