Class: Docs::DomEvents::EntriesFilter

Inherits:
EntriesFilter show all
Defined in:
lib/docs/filters/dom_events/entries.rb

Constant Summary collapse

TYPE_BY_INFO =
{
'applicationCache' => 'Application Cache',
'Clipboard'        => 'Clipboard',
'CSS'              => 'CSS',
'Drag'             => 'Drag & Drop',
'Focus'            => 'Focus',
'Fullscreen'       => 'Fullscreen',
'HashChange'       => 'History',
'IndexedDB'        => 'IndexedDB',
'Keyboard'         => 'Keyboard',
'edia'             => 'Media',
'Mouse'            => 'Mouse',
'Offline'          => 'Offline',
'Orientation'      => 'Device',
'Sensor'           => 'Device',
'Page Visibility'  => 'Page Visibility',
'Pointer'          => 'Mouse',
'PopState'         => 'History',
'Progress'         => 'Progress',
'Proximity'        => 'Device',
'Server Sent'      => 'Server Sent Events',
'Storage'          => 'Web Storage',
'Touch'            => 'Touch',
'Transition'       => 'CSS',
'PageTransition'   => 'History',
'WebSocket'        => 'WebSocket',
'Web Audio'        => 'Web Audio',
'Web Messaging'    => 'Web Messaging',
'Wheel'            => 'Mouse',
'Worker'           => 'Web Workers' }
FORM_SLUGS =
%w(change compositionend compositionstart compositionupdate
input invalid reset select submit)
LOAD_SLUGS =
%w(abort beforeunload DOMContentLoaded error load
readystatechange unload)
APPEND_TYPE =
%w(Application\ Cache IndexedDB Progress
Server\ Sent\ Events WebSocket Web\ Messaging Web\ Workers)

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from EntriesFilter

#additional_entries, #build_entries, #build_entry, #call, #default_entry, #entries, #include_default_entry?, #name, #path, #type

Methods inherited from Filter

#absolute_url_string?, #at_css, #at_xpath, #base_url, #css, #current_url, #fragment_url_string?, #initial_page?, #parse_html, #relative_url_string?, #root_page?, #root_path, #root_url, #slug, #subpath, #subpath_to, #xpath

Instance Method Details

#get_nameObject


43
44
45
46
47
# File 'lib/docs/filters/dom_events/entries.rb', line 43

def get_name
  name = super.split.first
  name << " (#{type})" if APPEND_TYPE.include?(type)
  name
end

#get_typeObject


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/docs/filters/dom_events/entries.rb', line 49

def get_type
  if FORM_SLUGS.include?(slug)
    'Form'
  elsif LOAD_SLUGS.include?(slug)
    'Load'
  else
    if info = at_css('.eventinfo').try(:content)
      TYPE_BY_INFO.each_pair do |key, value|
        return value if info.include?(key)
      end
    end

    'Miscellaneous'
  end
end