User:Shyamal/common.js: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
importScript('User:Harej/citation-watchlist.js'); |
importScript('User:Harej/citation-watchlist.js'); |
||
importScript('User:NKohli_(WMF)/megawatch.js'); |
importScript('User:NKohli_(WMF)/megawatch.js'); |
||
// Add a "Codex Widgets" portlet to the main menu |
|||
mw.util.addPortlet( 'p-codex', 'Codex Widgets', '#p-interaction' ); |
|||
const dialogTrigger = mw.util.addPortletLink( 'p-codex', '#', 'Example Dialog Widget', 'p-codex-dialog' ); |
|||
mw.loader.using( '@wikimedia/codex' ).then( function( require ) { |
|||
const Vue = require( 'vue' ); |
|||
const Codex = require( '@wikimedia/codex' ); |
|||
const mountPoint = document.body.appendChild( document.createElement( 'div' ) ); |
|||
Vue.createMwApp( { |
|||
data: function() { |
|||
return { |
|||
showDialog: false, |
|||
count: 0, |
|||
codexLink: 'https://doc.wikimedia.org/codex/latest/' |
|||
}; |
|||
}, |
|||
template: ` |
|||
<cdx-dialog v-model:open="showDialog" |
|||
title="Hello from Codex" |
|||
close-button-label="Close" |
|||
:default-action="defaultAction" |
|||
@default="open = false" |
|||
> |
|||
<p>This Dialog component comes from Codex, the new design system for Wikimedia.</p> |
|||
<p>To learn more about Codex, check out the documentation <a :href="codexLink" target="_blank">here.</a></p> |
|||
<hr /> |
|||
<p>Click these buttons to update the reactive count value:</p> |
|||
<p>Count: {{ count }}</p> |
|||
<p> |
|||
<cdx-button action="destructive" @click="decrement">Decrease</cdx-button> |
|||
<cdx-button action="progressive" @click="increment">Increase</cdx-button> |
|||
</p> |
|||
</cdx-dialog> |
|||
`, |
|||
methods: { |
|||
openDialog () { |
|||
this.showDialog = true; |
|||
}, |
|||
increment() { |
|||
this.count++; |
|||
}, |
|||
decrement() { |
|||
this.count--; |
|||
} |
|||
}, |
|||
mounted() { |
|||
dialogTrigger.addEventListener( 'click', this.openDialog ); |
|||
}, |
|||
unMounted() { |
|||
dialogTrigger.removeEventListener( this.openDialog ); |
|||
} |
|||
} ) |
|||
.component( 'cdx-button', Codex.CdxButton ) |
|||
.component( 'cdx-dialog', Codex.CdxDialog ) |
|||
.mount( mountPoint ); |
|||
} ); |
Revision as of 16:01, 10 December 2024
importScript('User:Ucucha/HarvErrors.js');
/*importScript('User:William Avery/taxoboxalyzer.js');*/
/* importScript( 'meta:User:SuperHamster/view-it.js' ); */
importScript('User:Jts1882/taxonomybrowser2.js');
importScript('User:Harej/citation-watchlist.js');
importScript('User:NKohli_(WMF)/megawatch.js');
// Add a "Codex Widgets" portlet to the main menu
mw.util.addPortlet( 'p-codex', 'Codex Widgets', '#p-interaction' );
const dialogTrigger = mw.util.addPortletLink( 'p-codex', '#', 'Example Dialog Widget', 'p-codex-dialog' );
mw.loader.using( '@wikimedia/codex' ).then( function( require ) {
const Vue = require( 'vue' );
const Codex = require( '@wikimedia/codex' );
const mountPoint = document.body.appendChild( document.createElement( 'div' ) );
Vue.createMwApp( {
data: function() {
return {
showDialog: false,
count: 0,
codexLink: 'https://doc.wikimedia.org/codex/latest/'
};
},
template: `
<cdx-dialog v-model:open="showDialog"
title="Hello from Codex"
close-button-label="Close"
:default-action="defaultAction"
@default="open = false"
>
<p>This Dialog component comes from Codex, the new design system for Wikimedia.</p>
<p>To learn more about Codex, check out the documentation <a :href="codexLink" target="_blank">here.</a></p>
<hr />
<p>Click these buttons to update the reactive count value:</p>
<p>Count: {{ count }}</p>
<p>
<cdx-button action="destructive" @click="decrement">Decrease</cdx-button>
<cdx-button action="progressive" @click="increment">Increase</cdx-button>
</p>
</cdx-dialog>
`,
methods: {
openDialog () {
this.showDialog = true;
},
increment() {
this.count++;
},
decrement() {
this.count--;
}
},
mounted() {
dialogTrigger.addEventListener( 'click', this.openDialog );
},
unMounted() {
dialogTrigger.removeEventListener( this.openDialog );
}
} )
.component( 'cdx-button', Codex.CdxButton )
.component( 'cdx-dialog', Codex.CdxDialog )
.mount( mountPoint );
} );