def init(self): #print "DEPRECATED" #raise TacticException("Use of GeneralAppletWdg is Deprecated") # it's generated thru JS in IE if WebContainer.get_web().is_IE(): return context_url = WebContainer.get_web().get_context_url() print "-" * 20 print self.APPLET_CLASS # create applet applet = HtmlElement("applet") applet.set_attr("code", self.APPLET_CLASS) applet.set_attr("codebase", "%s/java" % context_url.get_url()) applet.set_attr("archive", self.APPLET_JAR) applet.set_attr("width", "1") applet.set_attr("height", "1") applet.set_attr("id", self.APPLET_ID) # create param for applet param = HtmlElement("param") param.set_attr("name", "scriptable") param.set_attr("value", "true") applet.add(param) self.add(applet)
def add_no_option(my, sel_el): option = HtmlElement('option') option.set_attr( "value", "" ) option.add( "-- No Options Found --" ) sel_el.add( option ) option = HtmlElement('option') option.set_attr( "value", "" ) no_value_label = "-- No Filter Value Found --" if my.kwargs.get('no_value_found_label'): no_value_label = my.kwargs.get('no_value_found_label') option.add( no_value_label ) sel_el.add( option )
def init(my): list_item_table = '' my.full_item_list = [] if my.kwargs.has_key( 'list_item_table' ): list_item_table = my.kwargs.get( 'list_item_table' ) expr = '@SOBJECT(MMS/%s)' % list_item_table parser = ExpressionParser() my.full_item_list = parser.eval(expr) my.el_name = '' if my.kwargs.has_key( 'element_name' ): my.el_name = my.kwargs.get( 'element_name' ) my.input_el_name = '' if my.kwargs.has_key( 'input_element_to_find' ): my.input_el_name = my.kwargs.get( 'input_element_to_find' ) my.col_to_match = '' if my.kwargs.has_key( 'column_to_match_value' ): my.col_to_match = my.kwargs.get( 'column_to_match_value' ) my.col_for_label = '' if my.kwargs.has_key( 'column_for_label' ): my.col_for_label = my.kwargs.get( 'column_for_label' ) my.select_element = HtmlElement('select')
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")
def init(self): div_main = DivWdg(css='module') if self.width != None: widthstr = "width: %sem" % (self.width) div_main.add_style(widthstr) # reset self.name, create the content widget if not self.shad_name: self.shad_name = "ShadowBox%s" % (self.generate_unique_id()) div_main.set_id(self.shad_name) div_main.center() div_head = DivWdg(css='boxhead') # HACK to compensate for IE weird handling of CSS if WebContainer.get_web().is_IE() and 'password' in self.shad_name: div_head.add_style('left', '-242px') div_head.add_style('padding-bottom: 2px') empty_header = Widget(name=self.HEADER) div_head.add(empty_header, empty_header.get_name()) div_head.add(self.title_wdg, self.title_wdg.get_name()) div_control = DivWdg(css='control') empty_control = Widget(name=self.CONTROL) div_control.add(empty_header, empty_control.get_name()) div_container = DivWdg(css='container') ie_rect = HtmlElement('v:roundrect') ie_rect.set_attr("arcsize", "1966f") ie_rect.set_attr("fillcolor", "white") ie_rect.set_attr("strokecolor", "#555") ie_rect.set_attr("strokeweight", "2pt") div_body = DivWdg(css='content') div_body.set_id("%s_cont" % self.shad_name) div_body.center() div_body.add(div_head) div_body.add(div_control) self.content = div_main self.head = div_head self.control = div_control self.body = div_body div_container.add(ie_rect) ie_rect.add(div_body) #div_main.add(div_head) div_main.add(div_container)
def init(my): my.body = HtmlElement("body") web = WebContainer.get_web() my.body.add_color("color", "color") if web.is_title_page(): my.body.add_gradient("background", "background", 0, -20) else: my.body.add_gradient("background", "background", 0, -15) my.body.add_style("background-attachment: fixed !important") #my.body.add_style("min-height: 1200px") my.body.add_style("height: 100%") my.body.add_style("margin: 0px")
def init(my): my.body = HtmlElement("body") Container.put("TopWdg::body", my.body) my.top = DivWdg() my.body.add(my.top) my.top.add_class("spt_top") Container.put("TopWdg::top", my.top) click_div = DivWdg() my.top.add(click_div) click_div.add_behavior({ 'type': 'load', 'cbjs_action': ''' spt.body = {}; spt.body.focus_elements = []; spt.body.add_focus_element = function(el) { spt.body.focus_elements.push(el); } // 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; } } target = target.parentNode; if (count == 100) { alert("Too many to close."); break; } } // find out if any of the parents of target is the focus element for (var i = 0; i < spt.body.focus_elements.length; i++) { var el = spt.body.focus_elements[i]; var hit = false; for (var j = 0; j < targets.length; j++) { var target = targets[j]; if (target == el) { hit = true; break; } } if (hit) break; else{ spt.hide(el); } } if (!hit) spt.body.focus_elements = []; } //bvr.src_el.addEvent("mousedown", spt.body.hide_focus_elements); document.body.addEvent("mousedown", spt.body.hide_focus_elements); ''' }) web = WebContainer.get_web() my.body.add_color("color", "color") if web.is_title_page(): my.body.add_gradient("background", "background", 0, -20) else: my.body.add_gradient("background", "background", 0, -15) my.body.add_style("background-attachment: fixed !important") #my.body.add_style("min-height: 1200px") #my.body.add_style("height: 100%") my.body.add_style("margin: 0px") my.body.add_style("padding: 0px") # ensure that any elements that force the default menu over any TACTIC right-click context menus has the # 'force_default_context_menu' flag reset for the next right click that occurs ... # my.body.add_event("oncontextmenu", "spt.force_default_context_menu = false;")
def get_display(my): web = WebContainer.get_web() widget = Widget() html = HtmlElement("html") 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 web.is_admin_page(): is_admin = " - Admin" else: is_admin = "" if project_code == 'admin': head.add("<title>TACTIC Site Admin</title>\n") else: head.add("<title>%s%s</title>\n" % (project_title, is_admin)) # add the javascript libraries head.add(JavascriptImportWdg()) # add the body body = my.body html.add(body) body.add_event('onload', 'spt.onload_startup(this)') top = my.top # 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 top.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 content content_div = DivWdg() top.add(content_div) Container.put("TopWdg::content", content_div) # add a dummy button for global behaviors from tactic.ui.widget import ButtonNewWdg, IconButtonWdg ButtonNewWdg(title="DUMMY", icon=IconWdg.FILM) IconButtonWdg(title="DUMMY", icon=IconWdg.FILM) # NOTE: it does not need to be in the DOM. Just needs to be # instantiated #content_div.add(button) if my.widgets: content_wdg = my.get_widget('content') else: content_wdg = Widget() my.add(content_wdg) content_div.add(content_wdg) # add a calendar wdg from tactic.ui.widget import CalendarWdg cal_wdg = CalendarWdg(css_class='spt_calendar_template_top') cal_wdg.top.add_style('display: none') content_div.add(cal_wdg) if web.is_admin_page(): from tactic_branding_wdg import TacticCopyrightNoticeWdg branding = TacticCopyrightNoticeWdg(show_license_info=True) top.add(branding) # add the admin bar security = Environment.get_security() if not web.is_admin_page() and security.check_access( "builtin", "view_site_admin", "allow"): div = DivWdg() top.add(div) top.add_style("padding-top: 21px") div.add_class("spt_admin_bar") div.add_style("height: 15px") div.add_style("padding: 3px 0px 3px 15px") #div.add_style("margin-bottom: -5px") div.add_style("position: fixed") div.add_style("top: 0px") div.add_style("left: 0px") div.add_style("opacity: 0.7") div.add_style("width: 100%") #div.add_gradient("background", "background2", 20, 10) div.add_style("background-color", "#000") div.add_style("color", "#FFF") div.add_style("z-index", "1000") div.add_class("hand") div.set_box_shadow("0px 5px 5px") # remove icon_div = DivWdg() div.add(icon_div) icon_div.add_style("float: right") icon_div.add_style("margin-right: 10px") icon_div.add_style("margin-top: -3px") icon_button = IconButtonWdg(title="Remove Admin Bar", icon=IconWdg.G_CLOSE) icon_div.add(icon_button) icon_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var parent = bvr.src_el.getParent(".spt_admin_bar"); bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(parent); ''' }) div.add("<b>ADMIN >></b>") div.add_behavior({ 'type': 'listen', 'event_name': 'close_admin_bar', 'cbjs_action': ''' bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(bvr.src_el); ''' }) div.add_behavior({ 'type': 'mouseover', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.85) //new Fx.Tween(bvr.src_el).start('height', "30px"); ''' }) div.add_behavior({ 'type': 'mouseout', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.7) //new Fx.Tween(bvr.src_el).start('height', "15px"); ''' }) project_code = Project.get_project_code() div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var url = "/tactic/%s/admin/link/_startup"; window.open(url); ''' % project_code }) # Add the script editor listener load_div = DivWdg() top.add(load_div) load_div.add_behavior({ 'type': 'listen', 'event_name': 'show_script_editor', 'cbjs_action': ''' var js_popup_id = "TACTIC Script Editor"; var js_popup = $(js_popup_id); if( js_popup ) { spt.popup.toggle_display( js_popup_id, false ); } else { spt.panel.load_popup(js_popup_id, "tactic.ui.app.ShelfEditWdg", {}, {"load_once": true} ); } ''' }) # deal with the palette defined in /index which can override the palette if my.kwargs.get("hash") == (): key = "index" search = Search("config/url") search.add_filter("url", "/%s/%%" % key, "like") search.add_filter("url", "/%s" % key) search.add_where("or") url = search.get_sobject() if url: xml = url.get_xml_value("widget") palette_key = xml.get_value("element/@palette") # look up palette the expression for index from pyasm.web import Palette palette = Palette.get() palette.set_palette(palette_key) colors = palette.get_colors() colors = jsondumps(colors) script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_colors(%s); env.set_palette('%s'); ''' % (colors, palette_key)) top.add(script) env = Environment.get() client_handoff_dir = env.get_client_handoff_dir(include_ticket=False, no_exception=True) client_asset_dir = env.get_client_repo_dir() login = Environment.get_login() user_name = login.get_value("login") user_id = login.get_id() login_groups = Environment.get_group_names() # add environment information script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_project('%s'); env.set_user('%s'); env.set_user_id('%s'); var login_groups = '%s'.split('|'); env.set_login_groups(login_groups); env.set_client_handoff_dir('%s'); env.set_client_repo_dir('%s'); ''' % (Project.get_project_code(), user_name, user_id, '|'.join(login_groups), client_handoff_dir, client_asset_dir)) top.add(script) # add a global container for commonly used widgets div = DivWdg() top.add(div) div.set_id("global_container") # add in the app busy widget # find out if there is an override for this search = Search("config/url") search.add_filter("url", "/app_busy") url = search.get_sobject() if url: busy_div = DivWdg() div.add(busy_div) busy_div.add_class("SPT_PUW") busy_div.add_styles( "display: none; position: absolute; z-index: 1000") busy_div.add_class("app_busy_msg_block") busy_div.add_style("width: 300px") busy_div.add_style("height: 100px") busy_div.add_style("padding: 20px") busy_div.add_color("background", "background3") busy_div.add_border() busy_div.set_box_shadow() busy_div.set_round_corners(20) busy_div.set_attr("id", "app_busy_msg_block") # put the custom url here title_wdg = DivWdg() busy_div.add(title_wdg) title_wdg.add_style("font-size: 20px") title_wdg.add_class("spt_app_busy_title") busy_div.add("<hr/>") msg_div = DivWdg() busy_div.add(msg_div) msg_div.add_class("spt_app_busy_msg") else: from page_header_wdg import AppBusyWdg div.add(AppBusyWdg()) # popup parent popup = DivWdg() popup.set_id("popup") div.add(popup) # create another general popup popup_div = DivWdg() popup_div.set_id("popup_container") popup_div.add_class("spt_panel") popup = PopupWdg(id="popup_template", destroy_on_close=True) popup_div.add(popup) div.add(popup_div) inner_html_div = DivWdg() inner_html_div.set_id("inner_html") div.add(inner_html_div) # add in a global color from tactic.ui.input import ColorWdg color = ColorWdg() div.add(color) # add in a global notify wdg from notify_wdg import NotifyWdg widget.add(NotifyWdg()) return widget
def get_display(self): # self.sobjects is preferred, otherwise use # search_key. search_key = self.kwargs.get('search_key') message = None if not self.sobjects and search_key: message = Search.get_by_search_key(search_key) elif self.sobjects: message = self.sobjects[0] if not message: return DivWdg() 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 = self.kwargs.get('subscription') show_preview = self.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( self.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 = self.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 = self.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 else: description = message_value.get("description") else: if category == "chat": login = message.get("login") timestamp = message.get("timestamp") message_value = message.get("message") message_value = message_value.replace("\n", "<br/>") description = ''' <b>%s</b><br/> %s ''' % (login, message_value) else: description = message_value div = DivWdg() div.add(description) table.add_cell(div) return table
def get_display(my): smenu_div = DivWdg() smenu_div.add_class("SPT_SMENU") smenu_div.add_class("SPT_SMENU_%s" % my.menu_tag_suffix) smenu_div.set_box_shadow() smenu_div.add_border() smenu_div.add_color("background", "background") smenu_div.add_color("color", "color") smenu_div.add_behavior({ 'type': 'load', 'cbjs_action': ''' spt.dom.load_js( ["ctx_menu.js"], function() { spt.dom.load_js( ["smart_menu.js"], function() { } ) } ); ''' }) if my.setup_cbfn: smenu_div.set_attr("SPT_SMENU_SETUP_CBFN", my.setup_cbfn) smenu_div.set_z_start(300) #smenu_div.add_looks( "smenu border curs_default" ) # smenu_div.add_styles( "padding-top: 3px; padding-bottom: 5px;" ) m_width = my.width - 2 smenu_div.add_style(("width: %spx" % m_width)) smenu_div.add_style("overflow-x: hidden") icon_width = 16 icon_col_width = 0 if my.allow_icons: icon_col_width = icon_width + 2 label_width = m_width - icon_col_width - icon_width menu_table = Table() menu_table.add_styles( "text-align: left; text-indent: 3px; border-collapse: collapse;") #menu_table.add_color("background", "background") menu_table.add_color("color", "color") options = my.opt_spec_list opt_count = 0 if options[0].get('type') != 'title': my._add_spacer_row(menu_table, 3, icon_width, icon_col_width, label_width) """ menu_table.add_relay_behavior( { 'type': 'mouseenter', 'bvr_match_class': 'SPT_SMENU_ENTRY', 'bgcolor': menu_table.get_color("side_bar_title", -15, default="background3"), 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); bvr.src_el.setStyle("color", bvr.bgcolor); spt.smenu.entry_over( evt, bvr ); ''' } ) menu_table.add_relay_behavior( { 'type': 'mouseleave', 'bvr_match_class': 'SPT_SMENU_ENTRY', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ""); spt.smenu.entry_out( evt, bvr ); ''' } ) """ for opt in options: # if entry is a title, then add a spacer before if opt.get('type') == 'title' and opt_count: my._add_spacer_row(menu_table, 6, icon_width, icon_col_width, label_width) tbody = menu_table.add_tbody() tbody.add_style("display", "table-row-group") tr = menu_table.add_row() #tr.add_looks( "smenu" ) tr.add_class("SPT_SMENU_ENTRY") tr.add_class("SPT_SMENU_ENTRY_%s" % opt['type'].upper()) if opt.has_key('enabled_check_setup_key'): tr.set_attr("SPT_ENABLED_CHECK_SETUP_KEY", opt.get('enabled_check_setup_key')) if opt.has_key('hide_when_disabled') and opt.get( 'hide_when_disabled'): tr.set_attr("SPT_HIDE_WHEN_DISABLED", "true") if opt['type'] in ['action', 'toggle']: hover_bvr = { 'type': 'hover', 'add_looks': 'smenu_hilite', 'cbjs_action_over': 'spt.smenu.entry_over( evt, bvr );', 'cbjs_action_out': 'spt.smenu.entry_out( evt, bvr );' } if opt.has_key('hover_bvr_cb'): hover_bvr.update(opt.get('hover_bvr_cb')) tr.add_behavior(hover_bvr) tr.add_class("hand") if opt['type'] == 'action': if opt.has_key('bvr_cb') and type(opt['bvr_cb']) == dict: bvr = {} bvr.update(opt['bvr_cb']) bvr['cbjs_action_for_menu_item'] = bvr['cbjs_action'] bvr['cbjs_action'] = 'spt.smenu.cbjs_action_wrapper( evt, bvr );' bvr.update({'type': 'click_up'}) tr.add_behavior(bvr) if opt['type'] == 'submenu': hover_bvr = { 'type': 'hover', 'add_looks': 'smenu_hilite', 'cbjs_action_over': 'spt.smenu.submenu_entry_over( evt, bvr );', 'cbjs_action_out': 'spt.smenu.submenu_entry_out( evt, bvr );', 'submenu_tag': "SPT_SMENU_%s" % opt['submenu_tag_suffix'], } if opt.has_key('hover_bvr_cb'): hover_bvr.update(opt.get('hover_bvr_cb')) tr.add_behavior(hover_bvr) # now trap click on submenu, so that it doesn't make the current menu disappear ... tr.add_behavior({ 'type': 'click', 'cbjs_action': ';', 'activator_type': 'smart_menu' }) tr.add_looks("curs_default") # Left icon cell ... if my.allow_icons: td = menu_table.add_cell() td.add_styles( "text-align: center; vertical-align: middle; width: %spx;" % icon_col_width) #td.add_looks("smenu_icon_column") td.add_color("color", "color3") td.add_color("background", "background3") if opt.has_key('icon'): icon_wdg = IconWdg("", opt['icon']) icon_wdg.add_class("SPT_ENABLED_ICON_LOOK") td.add(icon_wdg) # if disabled: # icon_wdg.add_style( "opacity: .4" ) # icon_wdg.add_style( "filter: alpha(opacity=40)" ) # Menu option label cell ... td = menu_table.add_cell() td.add_style("width", ("%spx" % label_width)) td.add_style("height", ("%spx" % icon_col_width)) if opt.get('type') != 'title': td.add_style("padding-left: 6px") td.add_style("padding-top: 2px") if opt.has_key('label'): label_str = opt.get('label').replace('"', '"') td.add_class("SPT_LABEL") td.add(label_str) td.set_attr("SPT_ORIG_LABEL", label_str) #td.add_looks("fnt_text") td.add_style("font-size: 11px") if opt.get('type') == 'title': #td.add_looks("smenu_title") td.add_color("background", "background2") td.add_color("color", "color2") td.add_style("font-weight", "bold") td.add_style("padding", "3px") elif opt.get('type') == 'separator': hr = HtmlElement("hr") hr.add_looks("smenu_separator") td.add(hr) td.add_class("SPT_ENABLED_LOOK") # if disabled: # td.add_style( "opacity: .2" ) # td.add_style( "filter: alpha(opacity=20)" ) # Submenu arrow icon cell ... td = menu_table.add_cell() td.add_style("width", ("%spx" % icon_width)) if opt['type'] == 'submenu': icon_wdg = IconWdg("", IconWdg.ARROWHEAD_DARK_RIGHT) td.add(icon_wdg) td.add_class("SPT_ENABLED_ICON_LOOK") # extend title entry styling into the submenu arrow cell and add some spacing after if opt.get('type') == 'title': #td.add_looks("smenu_title") td.add_color("background", "background2") td.add_color("color", "color2") td.add_style("font-weight", "bold") td.add_style("padding", "3px") my._add_spacer_row(menu_table, 3, icon_width, icon_col_width, label_width) # if disabled: # td.add_style( "opacity: .4" ) # td.add_style( "filter: alpha(opacity=40)" ) opt_count += 1 my._add_spacer_row(menu_table, 5, icon_width, icon_col_width, label_width) smenu_div.add(menu_table) smenu_div.add_style("display: none") smenu_div.add_style("position: absolute") return smenu_div
def get_display(self): top = self.top sources = self.kwargs.get("sources") if sources and isinstance(sources, basestring): sources = sources.split("|") source_types = self.kwargs.get("source_types") if not source_types: source_types = [] poster = self.kwargs.get("poster") width = self.kwargs.get("width") height = self.kwargs.get("height") preload = self.kwargs.get("preload") controls = self.kwargs.get("controls") autoplay = self.kwargs.get("autoplay") video = self.video top.add(video) self.video_id = self.kwargs.get("video_id") if not self.video_id: self.video_id = video.set_unique_id() else: video.set_attr("id", self.video_id) top.add_behavior({'type': 'load', 'cbjs_action': self.get_onload_js()}) top.add_behavior({ 'type': 'load', 'video_id': self.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) else: video.add_attr("height", "auto") 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
def get_display(self): top = self.top sources = self.kwargs.get("sources") if sources and isinstance(sources, basestring): sources = sources.split("|") source_types = self.kwargs.get("source_types") if not source_types: source_types = [] poster = self.kwargs.get("poster") width = self.kwargs.get("width") height = self.kwargs.get("height") preload = self.kwargs.get("preload") controls = self.kwargs.get("controls") autoplay = self.kwargs.get("autoplay") is_test = self.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 = self.video video.add_class("video-js") video.add_class("vjs-default-skin") top.add(video) self.video_id = self.kwargs.get("video_id") if not self.video_id: self.video_id = video.set_unique_id() else: video.set_attr("id", self.video_id) # FIXME: this has refereneces to the Gallery ....! if self.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', '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
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) 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
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; } target = target.parentNode; if (count == 100) { alert("Too many to close."); break; } } var dialog = evt.target.getParent(".MooDialog"); if (dialog) { targets.push(dialog); } // find out if any of the parents of target is the focus element for (var i = 0; i < spt.body.focus_elements.length; i++) { var el = spt.body.focus_elements[i]; var hit = false; for (var j = 0; j < targets.length; j++) { var target = targets[j]; if (target == el) { hit = true; break; } } if (hit) break; else { if ( el.isVisible() && el.on_complete ) { el.on_complete(); } else { spt.hide(el); } } } if (!hit) spt.body.focus_elements = []; } //bvr.src_el.addEvent("mousedown", spt.body.hide_focus_elements); document.body.addEvent("mousedown", spt.body.hide_focus_elements); ''' }) web = WebContainer.get_web() self.body.add_color("color", "color") #if web.is_title_page(): # self.body.add_gradient("background", "background", 0, -20) #else: # self.body.add_gradient("background", "background", 0, -15) self.body.add_color("background", "background") self.body.add_style("background-attachment: fixed !important") self.body.add_style("margin: 0px") self.body.add_style("padding: 0px") # ensure that any elements that force the default menu over any TACTIC right-click context menus has the # 'force_default_context_menu' flag reset for the next right click that occurs ... # self.body.add_event("oncontextmenu", "spt.force_default_context_menu = false;")
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