mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
add/remove_class now can accept a list of classes
This commit is contained in:
parent
2600913067
commit
696a6e4c28
@ -393,35 +393,41 @@ class Widget(BaseWidget):
|
|||||||
raise Exception('set_css only accepts 1-3 arguments')
|
raise Exception('set_css only accepts 1-3 arguments')
|
||||||
|
|
||||||
|
|
||||||
def add_class(self, class_name, selector=""):
|
def add_class(self, class_names, selector=""):
|
||||||
"""Add class[es] to a DOM element
|
"""Add class[es] to a DOM element
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
class_name: unicode
|
class_names: unicode or list
|
||||||
Class name(s) to add to the DOM element(s). Multiple class names
|
Class name(s) to add to the DOM element(s).
|
||||||
must be space separated.
|
|
||||||
selector: unicode (optional)
|
selector: unicode (optional)
|
||||||
JQuery selector to select the DOM element(s) that the class(es) will
|
JQuery selector to select the DOM element(s) that the class(es) will
|
||||||
be added to.
|
be added to.
|
||||||
"""
|
"""
|
||||||
|
class_list = class_names
|
||||||
|
if isinstance(list, class_list):
|
||||||
|
class_list = ' '.join(class_list)
|
||||||
|
|
||||||
self.send({"msg_type": "add_class",
|
self.send({"msg_type": "add_class",
|
||||||
"class_list": class_name,
|
"class_list": class_list,
|
||||||
"selector": selector})
|
"selector": selector})
|
||||||
|
|
||||||
|
|
||||||
def remove_class(self, class_name, selector=""):
|
def remove_class(self, class_names, selector=""):
|
||||||
"""Remove class[es] from a DOM element
|
"""Remove class[es] from a DOM element
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
class_name: unicode
|
class_names: unicode or list
|
||||||
Class name(s) to remove from the DOM element(s). Multiple class
|
Class name(s) to remove from the DOM element(s).
|
||||||
names must be space separated.
|
|
||||||
selector: unicode (optional)
|
selector: unicode (optional)
|
||||||
JQuery selector to select the DOM element(s) that the class(es) will
|
JQuery selector to select the DOM element(s) that the class(es) will
|
||||||
be removed from.
|
be removed from.
|
||||||
"""
|
"""
|
||||||
|
class_list = class_names
|
||||||
|
if isinstance(list, class_list):
|
||||||
|
class_list = ' '.join(class_list)
|
||||||
|
|
||||||
self.send({"msg_type": "remove_class",
|
self.send({"msg_type": "remove_class",
|
||||||
"class_list": class_name,
|
"class_list": class_list,
|
||||||
"selector": selector})
|
"selector": selector})
|
||||||
|
Loading…
Reference in New Issue
Block a user