New method in plone.app.textfield.widget.py - plone

I have to extend the
class RichTextWidget(TextAreaWidget):
from the package plone.app.textfield.widget.py
I need an additional method:
def new_method(self):
do_anything...
How can I achieve this?
I added some code in my existing overrides.zcml, but this has no effect:
<z3c:widgetTemplate
layer="z3c.form.interfaces.IFormLayer"
mode="display"
template="widget_display.pt"
widget=".widget.RichTextWidget"
/>
In my custom widget.py I tried this:
from plone.app.textfield.widget import RichTextWidget as DefaultView
class RichTextWidget(DefaultView):
def new_method(self):
return 'foo'

Related

Extending React Types for CSS custom attributes

I'm converting my React project to TypeScript, but can't figure out how to extend React.HTMLPorps to accept custom CSS data-attributes.
A common pattern that I use in my project is:
const MyComponent = ( ) => <div mycustomattr="true"/>;
I've tried creating an interface like so:
interface ExtendedDiv extends HTMLProps<HTMLDivElement> {
mycutomattr: "true" | "false";
};
However, I'm not sure how to apply this to JSX div element.
I can see 2 ways:
easiest way is to rename atribut - custom => data-custom. But this will results in:
<div data-custom="true" />
extend react interface HTMLAttributes but it will allow this attribute to all elements
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
// extends React's HTMLAttributes
custom?: boolean;
}

is there a way to add class from module css with variable? in react

see example below:
import React, { Component } from 'react';
import styles from './Button.module.css';
class Button extends Component {
let classNameVariable= "error-button"
render() {
return <button className={styles.classNameVariable}>Button</button>;
}
}
as you saw above example, I need to use variable instead of className, to add className.
so is there a way to do it?
Take a look at bracket notation: https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Operators/Property_Accessors
Instead of styles.clasNameVariable make it styles[classNameVariable]

Css Selector in Framework7 vue

i try to build an Cordova/Phonegap application using vue.js and the Framework7.
I find out how to use functions like "onClick" using the "v-on:click="OnClick" attribute in an html element. Framework7 has jquery already implemented in the dom.
But there is one question. How can i access the dom directly, so that i can select whole css classes with the jquery selector. Like:
$('.likeButton'). ?
In the offical framework7 i found something like this to access the dom with its functions:
this.$$ or this.Dom7
This is what i have already written down in the home.vue file:
<script>
//import Fonts-awesome Icons
import FontAwesomeIcon from '#fortawesome/vue-fontawesome'
import {} from '#fortawesome/fontawesome-free-solid'
import F7Icon from "framework7-vue/src/components/icon";
import F7PageContent from "framework7-vue/src/components/page-content";
import * as Framework7 from "framework7";
export default {
name: 'FAExample',
components: {
F7PageContent,
F7Icon,
FontAwesomeIcon
},
methods: {
clickit: function () {
console.log("hi");
//this is what i have tested, looking if i have access to dom
let $$ = this.$$;
console.log($$);
},
//this is what i want to use
$('.likebutton').on('click',function () {
})
}
}
</script>
Did any of you have an idea how this works?
I hope you can help me. I'm new with vue.js in combination with the framework7.
Thank's for your help :)
We can use all the DOM functions just like
this.$$('.classname)
for example, if you want to hide something by jquery you can use as:
this.$$('.classname).hide()
To check all the DOM functions you can check the official documentation.
https://framework7.io/docs/dom7.html
But make sure that your DOM function should not in any Window function.
If you get the error to implemented it, just make the 'this' instance first.
Just like:
var self=this; // a global variable with this instance
use
self.$$('.classname).hide()
for any framework7 help, just ping me on skyp: sagardhiman5_1
Have you tried using Vue's $refs? You can set a reference to a specific DOM element and then access that in Vue.
A simple example:
<template>
<div class="some-item" ref="itemRef">Some item</div>
</template>
Then in the component:
var myItem = this.$refs.myItem;
// do what you want with that DOM item...
You can also access $refs from the parent. The example in the link below gives details on that.
More on $refs: https://v2.vuejs.org/v2/guide/components.html#Child-Component-Refs

How to add a css class to a z3c.form button

I want to add the css class allowMultiSubmit to a zrc.form button to avoid multi-submit alert. The button is defined like this:
from z3c.form import form
from plone.app.z3cform.layout import wrap_form
class MyForm(form.Form):
...
#button.buttonAndHandler(_(u"Search"))
def handleSearch(self, action):
...
MyWrappedFormView = wrap_form(MyForm)
The result that I want to achieve is this:
<input id="form-buttons-search"
class="submit-widget button-field allowMultiSubmit"
type="submit"
value="Search"
name="form.buttons.search">
There must be an easy way but I can't figure out how.
You can override the updateActions method of your z3c.form class and use the addClass method to add a css class to your button:
from z3c.form import form
from plone.app.z3cform.layout import wrap_form
class MyForm(form.Form):
...
#button.buttonAndHandler(_(u"Search"))
def handleSearch(self, action):
...
def updateActions(self):
super(MyForm, self).updateActions()
self.actions['submit'].addClass("allowMultiSubmit")
MyWrappedFormView = wrap_form(MyForm)

Flex bug trying to import actionscript files

The "import "Player.as" line throws the error: 1084: Syntax error: expecting rightbrace before semicolon.
package {
import "Player.as"; //ERROR
import "Card.as";
public class Game {
I was going great with Flex, until I tried to split up my code into separate files. Now I'm struggling.
Here are my files and their dependencies:
**poker.mxml**
include "fb.as";
<mx:Script source="Game.as"/>
**Game.as**
import "Player.as";
import "Card.as";
**fb.as**
**Card.as**
**Player.as**
I'm guessing Player.as and Card.as are in the same package as Game.as?
If they're in the same package, you don't need to import them. Also, import statements don't usually have the .as extension.
When importing, you don't use the file name, but the package and class, and no quotes needed:
package
{
import Player;
import Card;
public class Game {}
}
You don't actually have to import them if they're in the top level or the same package as the class you're editing, though. If your Player and Card classes are in packages other than the top level, then you need to include the package. Here's an example with some arbitrary package names that came off the top of my head:
package
{
import com.example.Player;
import com.example.deck.Card;
public class Game {}
}
In MXML, you don't include classes using the element's source parameter. You can import them in the same way, actually.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
applicationComplete="applicationCompleteHandler(event)">
<mx:Script><![CDATA[
import com.example.Player;
import mx.events.FlexEvent;
private var _player:Player;
//this event handler is called once the application is fully created
//and drawn for the first time.
private function applicationCompleteHandler(event:FlexEvent):void
{
_player = new Player();
}
]]></mx:Script>
</mx:Application>
import declarations come before the package, IIRC.

Resources