def _isEnabled(self, imageContext): en = ZBlogPostEditableImageActionBase._isEnabled(self, imageContext) if en: attrs = imageContext.getImageAttributes() style = None if attrs.has_key(u"border"): #$NON-NLS-1$ (width, style, zcssColor) = parseCssBorderProperty( getSafeString( attrs[u"border"])) #$NON-NLS-1$ @UnusedVariable return style is None or style != self.borderStyle else: return False
def _parseBorder(self, imageEle): # return: "length style color". Eg "1px dotted #FFDDAA". cssStr = None cssAttrs = self._getStyleMap(imageEle) keys = u"border,border-left,border-right,border-top,border-bottom" #$NON-NLS-1$ for key in keys.split(u","): #$NON-NLS-1$ if cssAttrs.has_key(key) and getNoneString(cssAttrs[key]) is not None: cssStr = cssAttrs[key] break if cssStr: (width, style, cssColor) = parseCssBorderProperty(cssStr) hexColor = u"" #$NON-NLS-1$ if cssColor: hexColor = cssColor.getCssColor() return u"%s %s %s" %(width, style, hexColor) #$NON-NLS-1$ return None
def runAction(self, izblogPostEditorActionContext): #@UnusedVariable imageContext = self._getImageContext(izblogPostEditorActionContext) (width, style, zcssColor) = (None, None, None) #@UnusedVariable attrs = imageContext.getImageAttributes() if attrs.has_key(u"border"): #$NON-NLS-1$ (width, style, zcssColor) = parseCssBorderProperty( getSafeString(attrs[u"border"])) #$NON-NLS-1$ @UnusedVariable border = None if self.borderStyle and self.borderStyle != u"none": #$NON-NLS-1$ if not width: width = u"1px" #$NON-NLS-1$ if not zcssColor: zcssColor = ZCssColor() border = u"%s %s %s" % ( width, self.borderStyle, zcssColor.getCssColor()) #$NON-NLS-1$ attrs = {u"border": border} #$NON-NLS-1$ + imageContext.setImageAttributes(attrs)
def getBorder(self): # returns tuple(stringWidth, stringStyle, cssColor) border = getSafeString(self.getAttribute(u"border")) #$NON-NLS-1$ return parseCssBorderProperty(border)