Beispiel #1
0
    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
Beispiel #2
0
    def get_container(my, xml):
        # handle the container

        element_node = xml.get_node("config/tmp/element")
        attrs = Xml.get_attributes(element_node)
        element_name = attrs.get("name")

        show_resize_scroll = attrs.get("show_resize_scroll")
        if not show_resize_scroll:
            show_resize_scroll = my.kwargs.get("show_resize_scroll")
        if not show_resize_scroll:
            show_resize_scroll = "false"


        # look for attributes in the element tag for specifying a title action button to plug
        # into the title bar of the custom section ...
        #
        title_action_icon = attrs.get("title_action_icon")
        title_action_script = attrs.get("title_action_script")
        title_action_label = attrs.get("title_action_label")
        if title_action_script and not title_action_label:
            title_action_label = '[action]'


        # get the width and height for the element content ...
        width = attrs.get("width")
        height = attrs.get("height")


        if width and height:
            container = ContainerWdg( inner_width=width, inner_height=height, show_resize_scroll=show_resize_scroll )
        else:
            container = ContainerWdg(show_resize_scroll=show_resize_scroll)

        # create the title
        title = attrs.get("title")
        if not title:
            title = Common.get_display_title(element_name)
        title_wdg = DivWdg()
        SmartMenu.assign_as_local_activator( title_wdg, 'HEADER_CTX' )
        title_wdg.add_style("margin: 0px 0px 5px 0px")
        title_wdg.add_gradient("background", "background", 0)
        title_wdg.add_color("color", "color")
        title_wdg.add_style("padding", "5px")


        if title_action_script:
            # add an action button if an action script code was found in the attributes of the element
            proj = Project.get_project_code()
            script_search = Search("config/custom_script")
            script_sobj = script_search.get_by_search_key( "config/custom_script?project=%s&code=%s" %
                                                           (proj, title_action_script) )
            script = script_sobj.get_value('script')
            icon_str = "HELP"
            if title_action_icon:
                icon_str = title_action_icon
            action_btn = HtmlElement.img( IconWdg.get_icon_path(icon_str) )
            action_btn.set_attr('title',title_action_label)
            # action_btn = IconWdg( title_action_label, icon=icon)
            action_btn.add_behavior( {'type': 'click_up', 'cbjs_action':  script } )
            action_btn.add_styles( "cursor: pointer; float: right;" )

            title_wdg.add( action_btn )


        title_wdg.add(title)
        container.add(title_wdg)

        return container
Beispiel #3
0
    def get_display(self):

        web = WebContainer.get_web()
        skin = web.get_skin()

        # default to 'small' size ...
        h = 16
        fnt_sz = 11

        if self.size == 'medium':
            h = 18
            fnt_sz = 13
        elif self.size == 'large':
            h = 20
            fnt_sz = 15

        w = (h / 2) - 1

        self.top_el.add_styles("height: %spx;" % (h))

        t_styles = "color: #c2c2c2; border: 0px; border-collapse: collapse; padding: 0px"
        bgi_open = "background-image: url(/context/themes/%(skin)s/images/text_btn/%(skin)s_btn_h%(h)s_" % \
                    {'skin': skin, 'h': h}
        bgi_close = ".png)"

        # pos_list = [ 'left', 'middle', 'right' ]
        spacer = HtmlElement.img(IconWdg.get_icon_path("TRANSPARENT"))
        spacer.add_styles("width: 2px;")

        div_left = DivWdg()
        div_left.add_styles("%(bgi_open)s%(pos)s%(bgi_close)s;" % {
            'bgi_open': bgi_open,
            'pos': 'left',
            'bgi_close': bgi_close
        })
        div_left.add_styles("float: left; height: %spx; width: %spx;" % (h, w))

        div_mid = DivWdg()
        div_mid.add_styles("%(bgi_open)s%(pos)s%(bgi_close)s;" % {
            'bgi_open': bgi_open,
            'pos': 'middle',
            'bgi_close': bgi_close
        })
        div_mid.add_styles("float: left; height: %spx; width: auto;" % (h))
        div_mid.add_styles("color: #c2c2c2;")
        div_mid.add_styles("vertical-align: middle")
        # move the text lower by 1 px
        div_mid.add_style('padding-top: 1px')

        div_mid.add_styles(
            "font-family: Arial, Helvetica, sans-serif; font-size: %spx;" %
            fnt_sz)
        div_mid.add(spacer)
        span = SpanWdg(self.label)

        # this is better fixed. Bold fonts don't look good
        span.add_style('font-weight: 100')
        span.add_style('vertical-align: middle')

        div_mid.add(span)
        div_mid.add(spacer)

        if self.show_option:
            bgi_close = '_options.png)'
            w += 10

        self.div_right.add_styles("%(bgi_open)s%(pos)s%(bgi_close)s;" % {
            'bgi_open': bgi_open,
            'pos': 'right',
            'bgi_close': bgi_close
        })
        self.div_right.add_styles("float: left; height: %spx; width: %spx;" %
                                  (h, w))
        self.top_el.add(div_left)
        self.top_el.add(div_mid)
        self.top_el.add(self.div_right)

        self.top_el.add_styles("overflow: hidden;")
        if self.horiz_align == 'center':
            self.top_el.add_styles(
                "margin: auto;"
            )  # margin: auto -- used for centering in non-IE brwsrs
        elif self.horiz_align == 'left':
            self.top_el.add_styles("margin-left: %s;" % self.horiz_offset)

        if self.vert_offset:
            self.top_el.add_styles("margin-top: %s;" % self.vert_offset)

        if self.width:
            if type(self.width) == str:
                self.width.replace("px", "")
            self.top_el.add_styles("width: %spx" % self.width)
        else:
            self.top_el.add_behavior({
                'type':
                'load',
                'cbjs_action':
                'spt.widget.btn_wdg.set_btn_width( bvr.src_el );'
            })

        return self.top_el
Beispiel #4
0
    def get_display(self):

        if self.is_popup:
            icon_chooser_popup_id = "IconChooserPopup"
            icon_chooser_popup = PopupWdg(id=icon_chooser_popup_id,
                                          allow_page_activity=False,
                                          width="760px")
            icon_chooser_popup.add("Icon Chooser", "title")

        orig_icon_list = IconWdg.icons.keys()
        icon_list = ['-- No Icon --']
        do_not_list = [
            'MAYA', 'HOUDINI', 'PROGRESS', 'CLIP_PLAY', 'XSI', 'CLIP_PAUSE',
            'CHECK_OUT_LG', 'CHECK_OUT', 'PUBLISH_LG'
        ]

        for k in orig_icon_list:
            if k in do_not_list:
                continue
            icon_list.append(k)

        icon_list.sort()
        icon_list_len = float(len(icon_list))

        num_cols = 5
        num_rows = int(math.ceil(icon_list_len / float(num_cols)))

        chooser_wrapper_div = DivWdg()
        chooser_wrapper_div.add_class("SPT_ICON_CHOOSER_WRAPPER_DIV")

        chooser_bkg_rc = RoundedCornerDivWdg(hex_color_code="949494",
                                             corner_size="10")
        chooser_bkg_rc.set_dimensions(width_str='740px',
                                      content_height_str='520px')

        table = Table()
        for r in range(num_rows):
            table.add_row()
            for c in range(num_cols):
                td = table.add_cell()
                td.add_styles(
                    "color: black; overflow: hidden; width: 140px; max-width: 140px; height: 20px;"
                )
                td.add_styles(
                    "border: 1px solid transparent; cursor: pointer;")
                td.add_behavior({
                    'type': 'hover',
                    'mod_styles': 'background-color: #555555;'
                })

                if c > 0:
                    td.add_styles("border-left-color: black;")

                idx = int(c * num_rows + r)
                if idx < icon_list_len:
                    icon_name = icon_list[idx]
                    icon_path = ''
                    if icon_name != '-- No Icon --':
                        icon_path = IconWdg.get_icon_path(icon_name)
                        icon = IconWdg(icon_name, icon_path)
                        td.add(icon)
                    text_span = SpanWdg()
                    text_span.add_looks("fnt_code")
                    text_span.add_styles("font-size: 10px")
                    if len(icon_name) > 16:
                        text_span.add("%s..." % icon_name[:15])
                    else:
                        text_span.add(icon_name)
                    td.add(text_span)
                    if icon_name == '-- No Icon --':
                        icon_name = ''
                    td.add_class("SPT_ICON_SELECT_%s" % icon_name)
                    if self.is_popup:
                        cbjs_action = '''
                            var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV");
                            cwd.setProperty("spt_icon_selected", "%s");
                            cwd.setProperty("spt_icon_path", "%s");
                            spt.popup.close( spt.popup.get_popup( bvr.src_el ) );
                            spt.named_events.fire_event("%s",bvr);
                        ''' % (icon_name, icon_path,
                               "ICON_CHOOSER_SELECTION_MADE")
                    else:
                        cbjs_action = '''
                            var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV");
                            cwd.setProperty("spt_icon_selected", "%s");
                            cwd.setProperty("spt_icon_path", "%s");
                            spt.hide( cwd );
                            spt.named_events.fire_event("%s",bvr);
                        ''' % (icon_name, icon_path,
                               "ICON_CHOOSER_SELECTION_MADE")
                        pass
                    td.add_behavior({
                        'type': 'click_up',
                        'cbjs_action': cbjs_action
                    })

        chooser_bkg_rc.add(table)
        chooser_wrapper_div.add(chooser_bkg_rc)

        if self.is_popup:
            icon_chooser_popup.add(chooser_wrapper_div, "content")
            return icon_chooser_popup

        return div
Beispiel #5
0
    def get_display(my): 

        web = WebContainer.get_web()
        skin = web.get_skin()

        # default to 'small' size ...
        h = 16
        fnt_sz = 11

        if my.size == 'medium':
            h = 18
            fnt_sz = 13
        elif my.size == 'large':
            h = 20
            fnt_sz = 15

        w = (h / 2) - 1

        my.top_el.add_styles( "height: %spx;" % (h) )

        t_styles = "color: #c2c2c2; border: 0px; border-collapse: collapse; padding: 0px"
        bgi_open = "background-image: url(/context/themes/%(skin)s/images/text_btn/%(skin)s_btn_h%(h)s_" % \
                    {'skin': skin, 'h': h}
        bgi_close = ".png)"

        # pos_list = [ 'left', 'middle', 'right' ]
        spacer = HtmlElement.img( IconWdg.get_icon_path("TRANSPARENT") )
        spacer.add_styles( "width: 2px;" )

        div_left = DivWdg()
        div_left.add_styles( "%(bgi_open)s%(pos)s%(bgi_close)s;" %
                                    {'bgi_open': bgi_open, 'pos': 'left', 'bgi_close': bgi_close} )
        div_left.add_styles("float: left; height: %spx; width: %spx;" % (h, w) )

        div_mid = DivWdg()
        div_mid.add_styles( "%(bgi_open)s%(pos)s%(bgi_close)s;" %
                                    {'bgi_open': bgi_open, 'pos': 'middle', 'bgi_close': bgi_close} )
        div_mid.add_styles("float: left; height: %spx; width: auto;" % (h) )
        div_mid.add_styles("color: #c2c2c2;")
        div_mid.add_styles("vertical-align: middle")
        # move the text lower by 1 px
        div_mid.add_style('padding-top: 1px')

        div_mid.add_styles( "font-family: Arial, Helvetica, sans-serif; font-size: %spx;" % fnt_sz )
        div_mid.add( spacer )
        span = SpanWdg(my.label)

        # this is better fixed. Bold fonts don't look good 
        span.add_style('font-weight: 100')
        span.add_style('vertical-align: middle')

        div_mid.add( span )
        div_mid.add( spacer )

        if my.show_option:
            bgi_close = '_options.png)'
            w += 10
        
        my.div_right.add_styles( "%(bgi_open)s%(pos)s%(bgi_close)s;" %
                                    {'bgi_open': bgi_open, 'pos': 'right', 'bgi_close': bgi_close} )
        my.div_right.add_styles("float: left; height: %spx; width: %spx;" % (h, w) )
        my.top_el.add( div_left )
        my.top_el.add( div_mid )
        my.top_el.add( my.div_right )

        my.top_el.add_styles("overflow: hidden;")
        if my.horiz_align == 'center':
            my.top_el.add_styles("margin: auto;")   # margin: auto -- used for centering in non-IE brwsrs
        elif my.horiz_align == 'left':
            my.top_el.add_styles("margin-left: %s;" % my.horiz_offset)

        if my.vert_offset:
            my.top_el.add_styles("margin-top: %s;" % my.vert_offset)

        if my.width:
            if type(my.width) == str:
                my.width.replace("px","")
            my.top_el.add_styles("width: %spx" % my.width)
        else:
            my.top_el.add_behavior({'type': 'load', 'cbjs_action': 'spt.widget.btn_wdg.set_btn_width( bvr.src_el );' })

        return my.top_el
Beispiel #6
0
    def get_link_wdg(self, element_name, config, options, info):
        attributes = config.get_element_attributes(element_name)
        if attributes.get("is_visible") == "false":
            return

        if options.get("popup") in [True, 'true']:
            popup = True
        else:
            popup = False

        #display_options = config.get_display_options(element_name)
        #class_name = display_options.get("class_name")
        #print element_name
        #print display_options
        #print class_name
        #print "---"


        li = HtmlElement.li()
        li.add_class("spt_side_bar_link")

        level = info.get("level")
        if level == 1:
            li.add_class("menu_header")
            li.add_class("main_link unselectable")
        else:
            li.add_class("sub_li")


        title = self._get_title(config, element_name)

        show_icons = self.kwargs.get("show_icons")
        if show_icons in [True, 'true']:
            icon = attributes.get("icon")
            if not icon:
                icon = "view"
            icon_path = IconWdg.get_icon_path(icon.upper())
            li.add(HtmlElement.img(icon_path))
            li.add(" ")


        link_mode = self.kwargs.get("link_mode")
        if not link_mode:
            use_href = self.kwargs.get("use_href")
            if use_href in ['true', True]:
                link_mode = 'href'
            link_mode = 'tab'



        target = self.kwargs.get("target")
        if not target:
            target = ".spt_content"
        else:
            if target[0] in ["."]:
                target = target[1:]

        #link = "/link/%s" % (element_name)
        link = "/tab/%s" % (element_name)
        li.add_attr("spt_link", link)




        if link_mode == 'href':
            project_code = Project.get_project_code()
            #li.add("<a href='/tactic/%s/#/tab/%s'>%s</a>" % (project_code, element_name, title) )
            li.add("<a>%s</a>" % title)
            li.add_behavior( {
                'type': 'click_up',
                'bvr_repeat_interval': 3,
                'title': title,
                'link': link,
                'target': target,
                'cbjs_action': '''

                var target_class = bvr.target;

                if (target_class.indexOf("#") != -1) {
                    var target = $(document.body).getElement(target_class);
                }
                else if (target_class.indexOf(".") != -1) {
                    var parts = target_class.split(".");
                    var top = bvr.src_el.getParent("."+parts[0]);
                    var target = top.getElement("."+parts[1]);  
                }
                else {
                    var target = $(document.body).getElement("."+target_class);
                }

                //var content = $(document).getElement(bvr.target);
                var content = target;
                spt.app_busy.show("Loading link "+bvr.title);
                spt.panel.load_link(content, bvr.link);
                spt.app_busy.hide();
                '''
            } )
        elif link_mode == 'tab':
            # find the tab below the target

            li.add("<a>%s</a>" % title)
            li.add_behavior( {
                'type': 'click',
                'bvr_repeat_interval': 3,
                'title': title,
                'link': link,
                'element_name': element_name,
                'popup': popup,
                'target': target,
                'cbjs_action': '''

                var target_class = bvr.target;

                if (target_class.indexOf("#") != -1) {
                    var target = $(document.body).getElement(target_class);
                }
                else if (target_class.indexOf(".") != -1) {
                    var parts = target_class.split(".");
                    var top = bvr.src_el.getParent("."+parts[0]);
                    var target = top.getElement("."+parts[1]);  
                }
                else {
                    var target = $(document.body).getElement("."+target_class);
                }


                //var content = $(document).getElement(bvr.target);
                var content = target;

                var tab_top = null;;
                // check if there even is a tab
                if (spt.tab) {
                    tab_top = spt.tab.set_tab_top(content);
                }
                if (tab_top) {

                    var link = bvr.src_el.getAttribute("spt_link");
                    var class_name = 'tactic.ui.panel.HashPanelWdg';
                    var kwargs = {
                        hash: link
                    }
                    // Note: hash is different from link
                    hash = "/link/" + bvr.element_name;

                    if (bvr.popup) {
                        spt.panel.load_popup(bvr.title, class_name, kwargs)
                    }
                    else {
                        spt.tab.add_new(bvr.element_name,bvr.title,class_name,kwargs, null, hash);
                    }
                }
                else {
                    spt.panel.load_link(content, bvr.link);
                }

                '''
            } )
 


        elif link_mode == 'custom':
            li.add("<a>%s</a>" % title)
            li.add_attr('spt_title', title)
            li.add_attr('spt_element_name', element_name)

        else:

            li.add(title)

            li.add_attr("spt_title", title)
            li.add_attr("spt_element_name", element_name)
            li.add_attr("spt_icon", attributes.get("icon"))
            li.add_attr("spt_view", config.get_view() )
            li.add_attr("spt_path", options['path'])
            li.add_attr("spt_view", config.get_view() )
            li.add_class("spt_side_bar_element")

            self.add_link_behavior(li, element_name, config, options)


        return li
    def get_link_wdg(my, element_name, config, options, info):
        li = HtmlElement.li()
        li.add_class("spt_side_bar_link")

        level = info.get("level")
        if level == 1:
            li.add_class("menu_header")
            li.add_class("main_link")
        else:
            li.add_class("sub_li")

        title = my._get_title(config, element_name)
        attributes = config.get_element_attributes(element_name)

        show_icons = my.kwargs.get("show_icons")
        if show_icons in [True, 'true']:
            icon = attributes.get("icon")
            if not icon:
                icon = "view"
            icon_path = IconWdg.get_icon_path(icon.upper())
            li.add(HtmlElement.img(icon_path))
            li.add(" ")


        link_mode = my.kwargs.get("link_mode")
        if not link_mode:
            use_href = my.kwargs.get("use_href")
            if use_href in ['true', True]:
                link_mode = 'href'
            link_mode = 'tab'



        target = my.kwargs.get("target")
        if not target:
            target = ".spt_content"
        else:
            if target[0] not in [".", "#"]:
                target = ".%s" % target

        link = "/tab/%s" % (element_name)
        #link = "/link/%s" % (element_name)
        li.add_attr("spt_link", link)

        if link_mode == 'href':
            project_code = Project.get_project_code()
            #li.add("<a href='/tactic/%s/#/tab/%s'>%s</a>" % (project_code, element_name, title) )
            li.add("<a>%s</a>" % title)
            li.add_behavior( {
                'type': 'click_up',
                'bvr_repeat_interval': 3,
                'title': title,
                'link': link,
                'target': target,
                'cbjs_action': '''
                var content = $(document).getElement(bvr.target);
                spt.app_busy.show("Loading link "+bvr.title);
                spt.panel.load_link(content, bvr.link);
                spt.app_busy.hide();
                '''
            } )
        elif link_mode == 'tab':
            # find the tab below the target
            li.add("<a>%s</a>" % title)
            li.add_behavior( {
                'type': 'click_up',
                'bvr_repeat_interval': 3,
                'title': title,
                'link': link,
                'element_name': element_name,
                'target': target,
                'cbjs_action': '''

                var content = $(document).getElement(bvr.target);
                var tab_top = null;;
                // check if there even is a tab
                if (spt.tab) {
                    tab_top = spt.tab.set_tab_top(content);
                }
                if (tab_top) {
                    setTimeout( function() {
                    spt.app_busy.show("Loading link "+bvr.title);
                    }, 0 );



                    var link = bvr.src_el.getAttribute("spt_link");
                    var class_name = 'tactic.ui.panel.HashPanelWdg';
                    var kwargs = {
                        hash: link
                    }
                    spt.tab.add_new(bvr.element_name,bvr.title,class_name,kwargs);
                }
                else {
                    spt.app_busy.show("Loading link "+bvr.title);
                    spt.panel.load_link(content, bvr.link);
                }

                spt.app_busy.hide();
                '''
            } )
 


        elif link_mode == 'custom':
            li.add("<a>%s</a>" % title)
            li.add_attr('spt_title', title)
            li.add_attr('spt_element_name', element_name)

        else:

            li.add(title)

            li.add_attr("spt_title", title)
            li.add_attr("spt_element_name", element_name)
            li.add_attr("spt_icon", attributes.get("icon"))
            li.add_attr("spt_view", config.get_view() )
            li.add_attr("spt_path", options['path'])
            li.add_attr("spt_view", config.get_view() )
            li.add_class("spt_side_bar_element")

            my.add_link_behavior(li, element_name, config, options)


        return li
Beispiel #8
0
    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 )


        # 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 content
        if my.widgets:
            content_wdg = my.get_widget('content')
        else:
            content_wdg = Widget()
            my.add(content_wdg)
        body.add( content_wdg )

        body.add_event('onload', 'spt.onload_startup(this)')


        if web.is_admin_page():
            from tactic_branding_wdg import TacticCopyrightNoticeWdg
            branding = TacticCopyrightNoticeWdg(show_license_info=True)
            body.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()
            body.add(div)
            body.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.POPUP_WIN_CLOSE)
            icon_div.add(icon_button)
            icon_button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var parent = bvr.src_el.getParent(".spt_admin_bar");
                spt.behavior.destroy_element(parent);
                $(document.body).setStyle("padding-top", "0px");
                '''
            } )



            div.add("<b>ADMIN >></b>")


            div.add_behavior( {
                'type': 'listen',
                'event_name': 'close_admin_bar',
                'cbjs_action': '''
                spt.behavior.destroy_element(bvr.src_el);
                $(document.body).setStyle("padding-top", "0px");
                '''
            } )

            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/link/_startup";
                window.open(url);

                ''' % project_code
            } )





        # Add the script editor listener
        load_div = DivWdg()
        body.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)
                )
                body.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))
        body.add(script)


        # add a global container for commonly used widgets
        div = DivWdg()
        body.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)


        # popup parent
        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
Beispiel #9
0
    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
Beispiel #10
0
    def get_container(my, xml):
        # handle the container

        element_node = xml.get_node("config/tmp/element")
        attrs = Xml.get_attributes(element_node)
        element_name = attrs.get("name")

        show_resize_scroll = attrs.get("show_resize_scroll")
        if not show_resize_scroll:
            show_resize_scroll = my.kwargs.get("show_resize_scroll")
        if not show_resize_scroll:
            show_resize_scroll = "false"


        # look for attributes in the element tag for specifying a title action button to plug
        # into the title bar of the custom section ...
        #
        title_action_icon = attrs.get("title_action_icon")
        title_action_script = attrs.get("title_action_script")
        title_action_label = attrs.get("title_action_label")
        if title_action_script and not title_action_label:
            title_action_label = '[action]'


        # get the width and height for the element content ...
        width = attrs.get("width")
        height = attrs.get("height")


        if width and height:
            container = ContainerWdg( inner_width=width, inner_height=height, show_resize_scroll=show_resize_scroll )
        else:
            container = ContainerWdg(show_resize_scroll=show_resize_scroll)

        # create the title
        title = attrs.get("title")
        if not title:
            title = Common.get_display_title(element_name)
        title_wdg = DivWdg()
        SmartMenu.assign_as_local_activator( title_wdg, 'HEADER_CTX' )
        title_wdg.add_style("margin: 0px 0px 5px 0px")
        title_wdg.add_gradient("background", "background", 0)
        title_wdg.add_color("color", "color")
        title_wdg.add_style("padding", "5px")


        if title_action_script:
            # add an action button if an action script code was found in the attributes of the element
            proj = Project.get_project_code()
            script_search = Search("config/custom_script")
            script_sobj = script_search.get_by_search_key( "config/custom_script?project=%s&code=%s" %
                                                           (proj, title_action_script) )
            script = script_sobj.get_value('script')
            icon_str = "HELP"
            if title_action_icon:
                icon_str = title_action_icon
            action_btn = HtmlElement.img( IconWdg.get_icon_path(icon_str) )
            action_btn.set_attr('title',title_action_label)
            # action_btn = IconWdg( title_action_label, icon=icon)
            action_btn.add_behavior( {'type': 'click_up', 'cbjs_action':  script } )
            action_btn.add_styles( "cursor: pointer; float: right;" )

            title_wdg.add( action_btn )


        title_wdg.add(title)
        container.add(title_wdg)

        return container
Beispiel #11
0
    def get_link_wdg(my, element_name, config, options, info):
        attributes = config.get_element_attributes(element_name)
        if attributes.get("is_visible") == "false":
            return


        li = HtmlElement.li()
        li.add_class("spt_side_bar_link")

        level = info.get("level")
        if level == 1:
            li.add_class("menu_header")
            li.add_class("main_link unselectable")
        else:
            li.add_class("sub_li")


        title = my._get_title(config, element_name)

        show_icons = my.kwargs.get("show_icons")
        if show_icons in [True, 'true']:
            icon = attributes.get("icon")
            if not icon:
                icon = "view"
            icon_path = IconWdg.get_icon_path(icon.upper())
            li.add(HtmlElement.img(icon_path))
            li.add(" ")


        link_mode = my.kwargs.get("link_mode")
        if not link_mode:
            use_href = my.kwargs.get("use_href")
            if use_href in ['true', True]:
                link_mode = 'href'
            link_mode = 'tab'



        target = my.kwargs.get("target")
        if not target:
            target = ".spt_content"
        else:
            if target[0] not in [".", "#"]:
                target = ".%s" % target

        #link = "/link/%s" % (element_name)
        link = "/tab/%s" % (element_name)
        li.add_attr("spt_link", link)

        if link_mode == 'href':
            project_code = Project.get_project_code()
            #li.add("<a href='/tactic/%s/#/tab/%s'>%s</a>" % (project_code, element_name, title) )
            li.add("<a>%s</a>" % title)
            li.add_behavior( {
                'type': 'click_up',
                'bvr_repeat_interval': 3,
                'title': title,
                'link': link,
                'target': target,
                'cbjs_action': '''
                var content = $(document).getElement(bvr.target);
                spt.app_busy.show("Loading link "+bvr.title);
                spt.panel.load_link(content, bvr.link);
                spt.app_busy.hide();
                '''
            } )
        elif link_mode == 'tab':
            # find the tab below the target
            li.add("<a>%s</a>" % title)
            li.add_behavior( {
                'type': 'click_up',
                'bvr_repeat_interval': 3,
                'title': title,
                'link': link,
                'element_name': element_name,
                'target': target,
                'cbjs_action': '''

                var content = $(document).getElement(bvr.target);
                var tab_top = null;;
                // check if there even is a tab
                if (spt.tab) {
                    tab_top = spt.tab.set_tab_top(content);
                }
                if (tab_top) {
                    setTimeout( function() {
                    spt.app_busy.show("Loading link "+bvr.title);
                    }, 0 );



                    var link = bvr.src_el.getAttribute("spt_link");
                    var class_name = 'tactic.ui.panel.HashPanelWdg';
                    var kwargs = {
                        hash: link
                    }
                    // Note: hash is different from link
                    hash = "/link/" + bvr.element_name;
                    spt.tab.add_new(bvr.element_name,bvr.title,class_name,kwargs, null, hash);
                }
                else {
                    spt.app_busy.show("Loading link "+bvr.title);
                    spt.panel.load_link(content, bvr.link);
                }

                spt.app_busy.hide();
                '''
            } )
 


        elif link_mode == 'custom':
            li.add("<a>%s</a>" % title)
            li.add_attr('spt_title', title)
            li.add_attr('spt_element_name', element_name)

        else:

            li.add(title)

            li.add_attr("spt_title", title)
            li.add_attr("spt_element_name", element_name)
            li.add_attr("spt_icon", attributes.get("icon"))
            li.add_attr("spt_view", config.get_view() )
            li.add_attr("spt_path", options['path'])
            li.add_attr("spt_view", config.get_view() )
            li.add_class("spt_side_bar_element")

            my.add_link_behavior(li, element_name, config, options)


        return li
Beispiel #12
0
    def get_display(my):
        my.icon_string = my.get_value("icon")
        my.icon_label = my.get_value("label")

        top = DivWdg()
        top.add_class("spt_icon_chooser_top")

        # FIXME: this is being generated every time .... where to put is?
        icon_chooser = IconChooserWdg( is_popup=True )
        top.add( icon_chooser )

        icon_entry_text = TextInputWdg(name=my.get_input_name())
        #icon_entry_text.set_attr("disabled", "disabled")
        icon_entry_text.add_class( "SPT_ICON_ENTRY_TEXT" )


        button = ActionButtonWdg(title='Choose', tip='Click to select an icon')

        icon_img = HtmlElement.img()
        icon_img.add_class( "SPT_ICON_IMG" )

        if my.icon_string:
            # icon_path = IconWdg.icons.get(my.icon_string)
            icon_path = IconWdg.get_icon_path(my.icon_string)
            if icon_path:
                # icon = IconWdg( my.icon_string, icon_path, right_margin='0px' )
                icon_img.set_attr("src", icon_path)
            else:
                icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))

            icon_entry_text.set_value( my.icon_string )
        else:
            icon_entry_text.set_value( "" )
            icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))


        named_event_name = "ICON_CHOOSER_SELECTION_MADE"
        icon_entry_text.add_behavior( {'type': 'listen', 'event_name': named_event_name,
           'cbjs_action': '''
                var top = $("IconChooserPopup");
                var chooser = spt.get_element(top, ".SPT_ICON_CHOOSER_WRAPPER_DIV");
                //var chooser = spt.get_cousin( bvr.src_el,
                //    ".spt_icon_chooser_top", ".SPT_ICON_CHOOSER_WRAPPER_DIV" );

                var icon_name = chooser.getProperty("spt_icon_selected");
                var icon_path = chooser.getProperty("spt_icon_path");
                // bvr.src_el.innerHTML = icon_name;
                bvr.src_el.value = icon_name;
                if( spt.is_hidden( bvr.src_el ) ) { spt.show( bvr.src_el ); }
                var img_el = spt.get_cousin( bvr.src_el,
                    ".spt_icon_chooser_top", ".SPT_ICON_IMG" );
                if( icon_path ) {
                    img_el.setProperty("src", icon_path);
                } else {
                    img_el.setProperty("src","/context/icons/common/transparent_pixel.gif");
                }
           ''' } )

        top.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )

        #top.add( my.icon_label )
        spacing = "<img src='%s' style='width: %spx;' />" % (IconWdg.get_icon_path("TRANSPARENT"), 3)

        #button.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )
        #top.add( button )
        #button.add_style("float: right")
        #button.add_style("margin-top: -3px")

        top.add( icon_img )
        top.add( spacing )
        top.add( icon_entry_text )



        return top
Beispiel #13
0
    def get_link_wdg(self, element_name, config, options, info):
        attributes = config.get_element_attributes(element_name)
        if attributes.get("is_visible") == "false":
            return

        if options.get("popup") in [True, 'true']:
            popup = True
        else:
            popup = False

        #display_options = config.get_display_options(element_name)
        #class_name = display_options.get("class_name")
        #print element_name
        #print display_options
        #print class_name
        #print "---"

        li = HtmlElement.li()
        li.add_class("spt_side_bar_link")

        level = info.get("level")
        if level == 1:
            li.add_class("menu_header")
            li.add_class("main_link unselectable")
        else:
            li.add_class("sub_li")

        title = self._get_title(config, element_name)

        show_icons = self.kwargs.get("show_icons")
        if show_icons in [True, 'true']:
            icon = attributes.get("icon")
            if not icon:
                icon = "view"
            icon_path = IconWdg.get_icon_path(icon.upper())
            li.add(HtmlElement.img(icon_path))
            li.add(" ")

        link_mode = self.kwargs.get("link_mode")
        if not link_mode:
            use_href = self.kwargs.get("use_href")
            if use_href in ['true', True]:
                link_mode = 'href'
            link_mode = 'tab'

        target = self.kwargs.get("target")
        if not target:
            target = ".spt_content"
        else:
            if target[0] in ["."]:
                target = target[1:]

        #link = "/link/%s" % (element_name)
        link = "/tab/%s" % (element_name)
        li.add_attr("spt_link", link)

        if link_mode == 'href':
            project_code = Project.get_project_code()
            #li.add("<a href='/tactic/%s/#/tab/%s'>%s</a>" % (project_code, element_name, title) )
            li.add("<a>%s</a>" % title)
            li.add_behavior({
                'type':
                'click_up',
                'bvr_repeat_interval':
                3,
                'title':
                title,
                'link':
                link,
                'target':
                target,
                'cbjs_action':
                '''

                var target_class = bvr.target;

                if (target_class.indexOf("#") != -1) {
                    var target = $(document.body).getElement(target_class);
                }
                else if (target_class.indexOf(".") != -1) {
                    var parts = target_class.split(".");
                    var top = bvr.src_el.getParent("."+parts[0]);
                    var target = top.getElement("."+parts[1]);  
                }
                else {
                    var target = $(document.body).getElement("."+target_class);
                }

                //var content = $(document).getElement(bvr.target);
                var content = target;
                spt.app_busy.show("Loading link "+bvr.title);
                spt.panel.load_link(content, bvr.link);
                spt.app_busy.hide();
                '''
            })
        elif link_mode == 'tab':
            # find the tab below the target

            li.add("<a>%s</a>" % title)
            li.add_behavior({
                'type':
                'click',
                'bvr_repeat_interval':
                3,
                'title':
                title,
                'link':
                link,
                'element_name':
                element_name,
                'popup':
                popup,
                'target':
                target,
                'cbjs_action':
                '''

                var target_class = bvr.target;

                if (target_class.indexOf("#") != -1) {
                    var target = $(document.body).getElement(target_class);
                }
                else if (target_class.indexOf(".") != -1) {
                    var parts = target_class.split(".");
                    var top = bvr.src_el.getParent("."+parts[0]);
                    var target = top.getElement("."+parts[1]);  
                }
                else {
                    var target = $(document.body).getElement("."+target_class);
                }


                //var content = $(document).getElement(bvr.target);
                var content = target;

                var tab_top = null;;
                // check if there even is a tab
                if (spt.tab) {
                    tab_top = spt.tab.set_tab_top(content);
                }
                if (tab_top) {

                    var link = bvr.src_el.getAttribute("spt_link");
                    var class_name = 'tactic.ui.panel.HashPanelWdg';
                    var kwargs = {
                        hash: link
                    }
                    // Note: hash is different from link
                    hash = "/link/" + bvr.element_name;

                    if (bvr.popup) {
                        spt.panel.load_popup(bvr.title, class_name, kwargs)
                    }
                    else {
                        spt.tab.add_new(bvr.element_name,bvr.title,class_name,kwargs, null, hash);
                    }
                }
                else {
                    spt.panel.load_link(content, bvr.link);
                }

                '''
            })

        elif link_mode == 'custom':
            li.add("<a>%s</a>" % title)
            li.add_attr('spt_title', title)
            li.add_attr('spt_element_name', element_name)

        else:

            li.add(title)

            li.add_attr("spt_title", title)
            li.add_attr("spt_element_name", element_name)
            li.add_attr("spt_icon", attributes.get("icon"))
            li.add_attr("spt_view", config.get_view())
            li.add_attr("spt_path", options['path'])
            li.add_attr("spt_view", config.get_view())
            li.add_class("spt_side_bar_element")

            self.add_link_behavior(li, element_name, config, options)

        return li
Beispiel #14
0
    def get_display(my):

        if my.is_popup:
            icon_chooser_popup_id = "IconChooserPopup"
            icon_chooser_popup = PopupWdg(id=icon_chooser_popup_id, allow_page_activity=False, width="760px")
            icon_chooser_popup.add("Icon Chooser", "title")

        orig_icon_list = IconWdg.icons.keys()
        icon_list = ['-- No Icon --']
        do_not_list = [ 'MAYA', 'HOUDINI', 'PROGRESS', 'CLIP_PLAY', 'XSI', 'CLIP_PAUSE', 'CHECK_OUT_LG','CHECK_OUT','PUBLISH_LG' ]

        for k in orig_icon_list:
            if k in do_not_list:
                continue
            icon_list.append(k)

        icon_list.sort()
        icon_list_len = float(len(icon_list))

        num_cols = 5
        num_rows = int( math.ceil( icon_list_len / float(num_cols) ) )

        chooser_wrapper_div = DivWdg()
        chooser_wrapper_div.add_class( "SPT_ICON_CHOOSER_WRAPPER_DIV" )

        chooser_bkg_rc = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10")
        chooser_bkg_rc.set_dimensions( width_str='740px', content_height_str='520px' )

        table = Table()
        for r in range(num_rows):
            table.add_row()
            for c in range(num_cols):
                td = table.add_cell()
                td.add_styles("color: black; overflow: hidden; width: 140px; max-width: 140px; height: 20px;")
                td.add_styles("border: 1px solid transparent; cursor: pointer;")
                td.add_behavior( {'type': 'hover', 'mod_styles': 'background-color: #555555;'} )

                if c > 0:
                    td.add_styles("border-left-color: black;")

                idx = int( c * num_rows + r )
                if idx < icon_list_len:
                    icon_name = icon_list[ idx ]
                    icon_path = ''
                    if icon_name != '-- No Icon --':
                        icon_path = IconWdg.get_icon_path(icon_name)
                        icon = IconWdg( icon_name, icon_path )
                        td.add(icon)
                    text_span = SpanWdg()
                    text_span.add_looks( "fnt_code" )
                    text_span.add_styles( "font-size: 10px" )
                    if len(icon_name) > 16:
                        text_span.add( "%s..." % icon_name[:15] )
                    else:
                        text_span.add( icon_name )
                    td.add( text_span )
                    if icon_name == '-- No Icon --':
                        icon_name = ''
                    td.add_class( "SPT_ICON_SELECT_%s" % icon_name )
                    if my.is_popup:
                        cbjs_action = '''
                            var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV");
                            cwd.setProperty("spt_icon_selected", "%s");
                            cwd.setProperty("spt_icon_path", "%s");
                            spt.popup.close( spt.popup.get_popup( bvr.src_el ) );
                            spt.named_events.fire_event("%s",bvr);
                        ''' % (icon_name, icon_path,"ICON_CHOOSER_SELECTION_MADE")
                    else:
                        cbjs_action = '''
                            var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV");
                            cwd.setProperty("spt_icon_selected", "%s");
                            cwd.setProperty("spt_icon_path", "%s");
                            spt.hide( cwd );
                            spt.named_events.fire_event("%s",bvr);
                        ''' % (icon_name, icon_path,"ICON_CHOOSER_SELECTION_MADE")
                        pass
                    td.add_behavior( {'type': 'click_up', 'cbjs_action': cbjs_action} )

        chooser_bkg_rc.add( table )
        chooser_wrapper_div.add( chooser_bkg_rc )


        if my.is_popup:
            icon_chooser_popup.add(chooser_wrapper_div, "content")
            return icon_chooser_popup


        return div