本文整理汇总了Python中pyasm.web.HtmlElement.add_attr方法的典型用法代码示例。如果您正苦于以下问题:Python HtmlElement.add_attr方法的具体用法?Python HtmlElement.add_attr怎么用?Python HtmlElement.add_attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.web.HtmlElement
的用法示例。
在下文中一共展示了HtmlElement.add_attr方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_attr [as 别名]
def get_display(my):
web = WebContainer.get_web()
widget = Widget()
html = HtmlElement("html")
html.add_attr("xmlns:v", 'urn:schemas-microsoft-com:vml')
is_xhtml = False
if is_xhtml:
web.set_content_type("application/xhtml+xml")
widget.add('''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
''')
html.add_attr("xmlns", "http://www.w3.org/1999/xhtml")
#html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg")
# add the copyright
widget.add( my.get_copyright_wdg() )
widget.add(html)
# create the header
head = HtmlElement("head")
html.add(head)
head.add('<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n')
head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n')
# Add the tactic favicon
head.add('<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>')
# add the css styling
head.add(my.get_css_wdg())
# add the title in the header
try:
project = Project.get()
except Exception, e:
print "ERROR: ", e
# if the project doesn't exist, then use the admin project
project = Project.get_by_code("admin")
示例2: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_attr [as 别名]
#.........这里部分代码省略.........
if not my.video_id:
my.video_id = video.set_unique_id()
else:
video.set_attr("id", my.video_id)
if my.index == 0:
overlay = DivWdg()
overlay.add_class('video_overlay')
overlay.add_styles('background: transparent; z-index: 300; position: fixed; top: 38%; left: 12%;\
margin-left: auto; margin-right: auto; width: 75%; height: 45%' )
overlay.add_behavior({'type':'click_up',
'cbjs_action': '''
var overlay = bvr.src_el;
var idx = spt.gallery.index;
var video_id = spt.gallery.videos[idx];
if (!video_id) return;
var player = videojs(video_id, {"nativeControlsForTouch": false});
if (player.paused()) {
player.play();
//console.log("play " + video_id)
}
else
player.pause();
'''
})
top.add(overlay)
top.add_behavior( {
'type': 'load',
'index' : my.index,
'video_id': my.video_id,
'cbjs_action': '''
if (!bvr.index) bvr.index = 0;
var video_id = bvr.video_id;
spt.dom.load_js(["video/video.js"], function() {
var player = videojs(video_id, {"nativeControlsForTouch": false}, function() {
} );
//videojs(bvr.video_id).play();
});
if (spt.gallery) {
spt.gallery.videos[bvr.index] = video_id;
if (!spt.gallery.portrait) {
var overlay = bvr.src_el.getElement('.video_overlay');
if (overlay)
overlay.setStyles({'top': '4%', 'left': '5%',
'width': '90%', 'height':'87%'});
}
}
'''
} )
#video.add_attr("data-setup", "{}")
if width:
video.add_attr("width", width)
if height:
video.add_attr("height", height)
if poster:
video.add_attr("poster", poster)
if not preload:
preload = "none"
video.add_attr("preload", preload)
if not controls:
controls = "true"
if controls not in [False, 'false']:
video.add_attr("controls", controls)
for i, src in enumerate(sources):
source = HtmlElement(type="source")
source.add_attr("src", src)
if len(source_types) > i:
source_type = source_types[i]
source.add_attr("type", source_type)
video.add(source)
#print top.get_buffer_display()
return top
示例3: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_attr [as 别名]
def get_display(my):
top = my.top
sources = my.kwargs.get("sources")
if sources and isinstance(sources, basestring):
sources = sources.split("|")
source_types = my.kwargs.get("source_types")
if not source_types:
source_types = []
poster = my.kwargs.get("poster")
width = my.kwargs.get("width")
height = my.kwargs.get("height")
preload = my.kwargs.get("preload")
controls = my.kwargs.get("controls")
autoplay = my.kwargs.get("autoplay")
video = my.video
top.add(video)
my.video_id = my.kwargs.get("video_id")
if not my.video_id:
my.video_id = video.set_unique_id()
else:
video.set_attr("id", my.video_id)
top.add_behavior( {
'type': 'load',
'cbjs_action': my.get_onload_js()
} )
top.add_behavior( {
'type': 'load',
'video_id': my.video_id,
'cbjs_action': '''
spt.video.init_video(bvr.video_id);
'''
} )
if width:
video.add_attr("width", width)
if height:
video.add_attr("height", height)
if poster:
video.add_attr("poster", poster)
if preload == None:
preload = "auto"
elif preload == False:
preload = "none"
autoplay = "false"
video.add_attr("preload", preload)
#video.add_attr("autoplay", autoplay)
if controls:
video.add_attr("controls", controls)
for i, src in enumerate(sources):
source = HtmlElement(type="source")
source.add_attr("src", src)
if len(source_types) > i:
source_type = source_types[i]
source.add_attr("type", source_type)
video.add(source)
#print top.get_buffer_display()
return top
示例4: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_attr [as 别名]
def get_display(my):
web = WebContainer.get_web()
widget = Widget()
html = HtmlElement("html")
html.add_attr("xmlns:v", 'urn:schemas-microsoft-com:vml')
is_xhtml = False
if is_xhtml:
web.set_content_type("application/xhtml+xml")
widget.add('''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
''')
html.add_attr("xmlns", "http://www.w3.org/1999/xhtml")
#html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg")
# add the copyright
widget.add( my.get_copyright_wdg() )
widget.add(html)
# create the header
head = HtmlElement("head")
html.add(head)
head.add('<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n')
head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n')
# Add the tactic favicon
head.add('<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>')
# add the css styling
head.add(my.get_css_wdg())
# add the title in the header
project = Project.get()
project_code = project.get_code()
project_title = project.get_value("title")
if project_code == 'admin':
head.add("<title>TACTIC</title>\n" )
else:
head.add("<title>%s</title>\n" % project_title )
# add the body
body = my.body
html.add( body )
# Add a NOSCRIPT tag block here to provide a warning message on browsers where 'Enable JavaScript'
# is not checked ... TODO: clean up and re-style to make look nicer
body.add( """
<NOSCRIPT>
<div style="border: 2px solid black; background-color: #FFFF99; color: black; width: 600px; height: 70px; padding: 20px;">
<img src="%s" style="border: none;" /> <b>Javascript is not enabled on your browser!</b>
<p>This TACTIC powered, web-based application requires JavaScript to be enabled in order to function. In your browser's options/preferences, please make sure that the 'Enable JavaScript' option is checked on, click OK to accept the settings change, and then refresh this web page.</p>
</div>
</NOSCRIPT>
""" % ( IconWdg.get_icon_path("ERROR") ) )
# add the javascript libraries
#head.add( JavascriptImportWdg() )
body.add("<form id='form' name='form' method='post' enctype='multipart/form-data'>\n")
for content in my.widgets:
body.add(content)
body.add("</form>\n")
from tactic_branding_wdg import TacticCopyrightNoticeWdg
copyright = TacticCopyrightNoticeWdg()
body.add(copyright)
return widget
示例5: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_attr [as 别名]
def get_display(my):
# my.sobjects is preferred, otherwise use
# search_key.
search_key = my.kwargs.get('search_key')
if not my.sobjects and search_key:
message = Search.get_by_search_key(search_key)
elif my.sobjects:
message = my.sobjects[0]
if message.get_search_type() == 'sthpw/message':
message_code = message.get_value("code")
else:
message_code = message.get_value("message_code")
category = message.get_value("category")
table = Table()
table.add_row()
td = table.add_cell()
subscription = my.kwargs.get('subscription')
show_preview = my.kwargs.get('show_preview')
if show_preview in ['',None]:
show_preview = True
show_preview_category_list = ['sobject','chat']
if (category in show_preview_category_list and show_preview not in ['False','false',False]) or show_preview in ["True" ,"true",True]:
td.add( my.get_preview_wdg(subscription, category=category, message_code=message_code ))
message_value = message.get_value("message")
message_login = message.get_value("login")
#TODO: implement short_format even for closing html tags properly while truncating
short_format = my.kwargs.get('short_format') in ['true', True]
if message_value.startswith('{') and message_value.endswith('}'):
#message_value = message_value.replace(r"\\", "\\");
message_value = jsonloads(message_value)
# that doesn't support delete
if category == "sobject":
update_data = message_value.get("update_data")
sobject_data = message_value.get("sobject")
sobject_code = sobject_data.get('code')
search_type = message_value.get("search_type")
if search_type == "sthpw/note":
description = "<b>Note added:</b><br/>%s" % update_data.get("note")
elif search_type == "sthpw/task":
description = "<b>Task modified:</b><br/>%s" % update_data.get("process")
elif search_type == "sthpw/snapshot":
sobject = message_value.get("sobject")
description = "<b>Files checked in:</b><br/>%s" % sobject.get("process")
else:
display = []
if update_data:
for key, val in update_data.items():
display.append('%s – %s'%(key, val))
else:
if message_value.get('mode') == 'retire':
display.append('Retired')
base_search_type = Project.extract_base_search_type(search_type)
description = DivWdg()
title = DivWdg("<b>%s</b> - %s modified by %s:"%(base_search_type, sobject_code, message_login))
title.add_style('margin-bottom: 6px')
content = DivWdg()
content.add_style('padding-left: 2px')
content.add('<br>'.join(display))
description.add(title)
description.add(content)
elif category == 'progress':
description = DivWdg()
message = message_value.get('message')
message_div = DivWdg()
message_div.add(message)
description.add(message_div)
percent = message_value.get('progress')
if not percent:
percent = 0.0
progress = HtmlElement('progress')
progress.add_attr('value', percent)
progress.add_attr('max', '100')
progress.add_styles('''width: 280px; border-radius: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.75) inset''')
progress_size = my.kwargs.get("progress_size")
if progress_size == "large":
progress.add_styles("height: 16px; margin-top: 9px;")
else:
progress.add_styles("height: 5px; margin-top: 4px;")
description.add(progress)
else:
message = message_value.get('message')
if message:
description = message
#.........这里部分代码省略.........
示例6: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_attr [as 别名]
#.........这里部分代码省略.........
var idx = spt.gallery.index;
var video_id = spt.gallery.videos[idx];
if (!video_id) return;
var player = videojs(video_id, {"nativeControlsForTouch": false});
if (player.paused()) {
player.play();
//console.log("play " + video_id)
}
else
player.pause();
'''
})
top.add(overlay)
top.add_behavior( {
'type': 'load',
'cbjs_action': self.get_onload_js()
} )
top.add_behavior( {
'type': 'load',
'index' : self.index,
'video_id': self.video_id,
'cbjs_action': '''
if (!bvr.index) bvr.index = 0;
var video_id = bvr.video_id;
spt.video.init_videojs(video_id);
if (spt.gallery) {
spt.gallery.videos[bvr.index] = video_id;
if (!spt.gallery.portrait) {
var overlay = bvr.src_el.getElement('.video_overlay');
if (overlay)
overlay.setStyles({'top': '4%', 'left': '5%',
'width': '90%', 'height':'87%'});
}
}
'''
} )
#video.add_attr("data-setup", "{}")
if width:
video.add_attr("width", width)
if height:
video.add_attr("height", height)
if poster:
video.add_attr("poster", poster)
if preload == None:
preload = "none"
if controls == None:
controls = True
autoplay = False
# videojs uses a json data structre
data = {
'preload': preload,
'controls': controls,
'autoplay': autoplay
}
from pyasm.common import jsondumps
data_str = jsondumps(data)
video.add_attr("data-setup", data_str)
for i, src in enumerate(sources):
source = HtmlElement(type="source")
source.add_attr("src", src)
if len(source_types) > i:
source_type = source_types[i]
source.add_attr("type", source_type)
video.add(source)
#print top.get_buffer_display()
return top
示例7: TopWdg
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_attr [as 别名]
class TopWdg(Widget):
def __init__(self, **kwargs):
self.kwargs = kwargs
super(TopWdg, self).__init__()
def init(self):
self.body = HtmlElement("body")
Container.put("TopWdg::body", self.body)
self.top = DivWdg()
self.body.add(self.top)
self.top.add_class("spt_top")
Container.put("TopWdg::top", self.top)
self.body.add_attr("ondragover", "return false;")
self.body.add_attr("ondragleave", "return false;")
self.body.add_attr("ondrop", "return false;")
self.body.add_behavior( {
'type': 'load',
'cbjs_action': '''
var el = bvr.src_el;
el.spt_window_active = true;
if (document.addEventListener) {
document.addEventListener("visibilitychange", function() {
el.spt_window_active = ! document.hidden;
} );
}
else {
window.onfocus = function() {
bvr.src_el.spt_window_active = true;
}
window.onblur = function() {
bvr.src_el.spt_window_active = false;
}
}
'''
} )
self.add_top_behaviors()
click_div = DivWdg()
self.top.add(click_div)
click_div.add_behavior( {
'type': 'load',
'cbjs_action': '''
spt.body = {};
spt.body.is_active = function() {
return $(document.body).spt_window_active;
}
spt.body.focus_elements = [];
spt.body.add_focus_element = function(el) {
spt.body.focus_elements.push(el);
}
spt.body.remove_focus_element = function(el) {
var index = spt.body.focus_elements.indexOf(el);
if (index != -1) {
spt.body.focus_elements.splice(index, 1);
}
}
// find all of the registered popups and close them
// NOTE: logic can handle more than 1 focus element should it happen ...
spt.body.hide_focus_elements = function(evt) {
var mouse = evt.client;
var target = evt.target;
var targets = [];
var count = 0;
while (target) {
targets.push(target);
if (spt.has_class(target, 'spt_activator')) {
act_el = target.dialog;
if (act_el) {
targets.push(act_el);
break;
}
}
// if target is an smenu, then return
if (spt.has_class(target, 'SPT_SMENU')) {
return;
#.........这里部分代码省略.........
示例8: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_attr [as 别名]
def get_display(self):
web = WebContainer.get_web()
widget = Widget()
html = HtmlElement("html")
html.add_attr("xmlns:v", 'urn:schemas-microsoft-com:vml')
is_xhtml = False
if is_xhtml:
web.set_content_type("application/xhtml+xml")
widget.add('''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
''')
html.add_attr("xmlns", "http://www.w3.org/1999/xhtml")
#html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg")
# add the copyright
widget.add( self.get_copyright_wdg() )
widget.add(html)
# create the header
head = HtmlElement("head")
html.add(head)
head.add('<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n')
head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n')
# Add the tactic favicon
head.add('<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>')
# add the css styling
head.add(self.get_css_wdg())
# add the title in the header
try:
project = Project.get()
except Exception as e:
print("ERROR: ", e)
# if the project doesn't exist, then use the admin project
project = Project.get_by_code("admin")
project_code = project.get_code()
project_title = project.get_value("title")
if project_code == 'admin':
head.add("<title>TACTIC</title>\n" )
else:
head.add("<title>%s</title>\n" % project_title )
# add the body
body = self.body
html.add( body )
body.add("<form id='form' name='form' method='post' enctype='multipart/form-data'>\n")
for content in self.widgets:
body.add(content)
body.add("</form>\n")
if web.is_admin_page():
from tactic_branding_wdg import TacticCopyrightNoticeWdg
copyright = TacticCopyrightNoticeWdg()
body.add(copyright)
return widget
示例9: get_display
# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_attr [as 别名]
def get_display(my):
top = my.top
sources = my.kwargs.get("sources")
if sources and isinstance(sources, basestring):
sources = sources.split("|")
source_types = my.kwargs.get("source_types")
if not source_types:
source_types = []
poster = my.kwargs.get("poster")
width = my.kwargs.get("width")
height = my.kwargs.get("height")
preload = my.kwargs.get("preload")
controls = my.kwargs.get("controls")
is_test = my.kwargs.get("is_test")
is_test = False
if is_test in [True, 'true']:
poster = "http://video-js.zencoder.com/oceans-clip.png"
sources = ["http://video-js.zencoder.com/oceans-clip.mp4"]
sources = ["http://video-js.zencoder.com/oceans-clip.mp4"]
sources = ["http://techslides.com/demos/sample-videos/small.ogv"]
video = my.video
video.add_class("video-js")
video.add_class("vjs-default-skin")
top.add(video)
my.video_id = my.kwargs.get("video_id")
if not my.video_id:
my.video_id = video.set_unique_id()
else:
video.set_attr("id", my.video_id)
print "my.video_id: ", my.video_id
video.add_behavior( {
'type': 'load',
'video_id': my.video_id,
'cbjs_action': '''
spt.dom.load_js(["video/video.js"], function() {
//videojs(bvr.src_el, {}, function() {
//} );
//videojs(bvr.video_id).play();
});
'''
} )
#video.add_attr("data-setup", "{}")
if width:
video.add_attr("width", width)
if height:
video.add_attr("height", height)
if poster:
video.add_attr("poster", poster)
if not preload:
preload = "none"
video.add_attr("preload", preload)
if not controls:
controls = "true"
if controls not in [False, 'false']:
video.add_attr("controls", controls)
for i, src in enumerate(sources):
source = HtmlElement(type="source")
source.add_attr("src", src)
if len(source_types) > i:
source_type = source_types[i]
source.add_attr("type", source_type)
video.add(source)
#print top.get_buffer_display()
return top