コード例 #1
0
ファイル: css.py プロジェクト: appmode/openW3
	def compileWidget(self, strWidget):
		
		# get widget
		objWidget = filesystem.getWidget(strWidget, self.bolSafeMode)
		
		# return css
		return objWidget.css
コード例 #2
0
ファイル: css.py プロジェクト: appmode/openW3
    def compileWidget(self, strWidget):

        # get widget
        objWidget = filesystem.getWidget(strWidget, self.bolSafeMode)

        # return css
        return objWidget.css
コード例 #3
0
ファイル: javascript.py プロジェクト: appmode/openW3
    def compileWidget(self, strWidget, strDefaultExtends='w3/base/style'):

        # get widget
        objWidget = filesystem.getWidget(strWidget, self.bolSafeMode)

        strReturn = ''

        # use a pre-compiled widget if we have one
        if objWidget.jsc:
            return objWidget.jsc
        else:
            # by default we use the default extends
            if strWidget != strDefaultExtends:
                if objWidget.name != "base":
                    objWidget.extends = strDefaultExtends

            # send the header
            strReturn += 'var $objConstructor = function(){\n'

            # Add Widget Definition
            if objWidget.js:
                strReturn += objWidget.js

                # parse js
                objJs = widgetJs.parse(objWidget.js)
                objWidget.command = objJs.command
                objWidget.dynCommand = objJs.dynCommand
                objWidget.event = objJs.event
                #objWidget.method		= objJs.method
                if 'extends' in objJs:
                    objWidget.extends = objJs.extends

            # build style objects (from widget .phtml files)
            if objWidget.phtml:
                objPhtml = widgetPhtml.parse(objWidget.phtml)
                strReturn += "this._objElementsByStyleGroup = %s;" % objPhtml.styleGroup
                strReturn += "this._objElementsByStyle = %s;" % objPhtml.style

            # extends
            if objWidget.extends:
                strExtends = ", \"%s\"" % objWidget.extends
            else:
                strExtends = ''

            # add the footer
            strReturn += '};\n'
            strReturn += 'w3.ui.register("' + strWidget + '", $objConstructor' + strExtends + ');\n'

            # cache the compiled widget constructor
#			objWidget.jsc = strReturn

        return strReturn
コード例 #4
0
    def getWidget(self, strType, objDef=None):
        strType = strType.lower().replace('.', '/')

        if strType not in self.objWidgetTypes:
            objWidget = filesystem.getWidget(strType, self.bolSafeMode)

            # defaults
            if 'objDefault' not in objWidget:
                objWidget.objDefault = json.loads(objWidget.default,
                                                  object_pairs_hook=dotDict)

            # compile widget js if it's not already compiled
            if not objWidget.jsc:
                self.compiler.js.compileWidget(strType)

            # command
            if not objWidget.command:
                objWidget.command = []

            # dynCommand
            if not objWidget.dynCommand:
                objWidget.dynCommand = []

            # event
            if not objWidget.event:
                objWidget.event = {}

            # methods
            #do we need them????

            # extends
            if objWidget.extends:
                objExtends = self.getWidget(objWidget.extends)
                # add extended events
                for i in objExtends.event:
                    if i not in objWidget.event:
                        objWidget.event[i] = objExtends.event[i]

            # py events
            #TODO!!!!

            # cache the widget (we do this at the end so widgets we extend from are cached before us)
            self.objWidgetTypes[strType] = objWidget

        return self.objWidgetTypes[strType]