2015-09-11 14:41:01 +05:30
|
|
|
require 'task_list/filter'
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
module Banzai
|
|
|
|
module Filter
|
2015-09-11 14:41:01 +05:30
|
|
|
# Work around a bug in the default TaskList::Filter that adds a `task-list`
|
|
|
|
# class to every list element, regardless of whether or not it contains a
|
|
|
|
# task list.
|
|
|
|
#
|
|
|
|
# This is a (hopefully) temporary fix, pending a new release of the
|
|
|
|
# task_list gem.
|
|
|
|
#
|
|
|
|
# See https://github.com/github/task_list/pull/60
|
|
|
|
class TaskListFilter < TaskList::Filter
|
2016-01-14 18:37:52 +05:30
|
|
|
def add_css_class_with_fix(node, *new_class_names)
|
2015-09-11 14:41:01 +05:30
|
|
|
if new_class_names.include?('task-list')
|
2016-01-14 18:37:52 +05:30
|
|
|
# Don't add class to all lists
|
|
|
|
return
|
|
|
|
elsif new_class_names.include?('task-list-item')
|
|
|
|
add_css_class_without_fix(node.parent, 'task-list')
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
2016-01-14 18:37:52 +05:30
|
|
|
|
|
|
|
add_css_class_without_fix(node, *new_class_names)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
2016-01-14 18:37:52 +05:30
|
|
|
|
|
|
|
alias_method_chain :add_css_class, :fix
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|