Skip to content

Instantly share code, notes, and snippets.

View trevorparscal's full-sized avatar

Trevor Parscal trevorparscal

View GitHub Profile
# Execute this in the root of the mmv repo
# Find and replace script symbols
find resources/mmv -name \*.js -exec sed -i '' \
-e 's/TextInputMenuWidget/TextInputMenuSelectWidget/g' \
-e 's/MenuWidget/MenuSelectWidget/g' \
-e 's/MenuItemWidget/MenuOptionWidget/g' \
-e 's/MenuSectionItemWidget/MenuSectionOptionWidget/g' \
-e 's/OutlineWidget/OutlineSelectWidget/g' \
-e 's/OutlineItemWidget/OutlineOptionWidget/g' \
<?php array(
'help' => 'help.svg',
'next' => array(
'image' => array(
'ltr' => 'next.svg',
'rtl' => 'prev.svg'
),
),
'list' => array(
'image' => array(
@trevorparscal
trevorparscal / example.js
Last active August 29, 2015 14:10
Promisification utilities for OOjs UI
// Sycnhronous before
MyClass.prototype.doSomething = function () {
// do something synchronously after parent method that may or may not return a promise
this.test = 1;
return OO.ui.promisify( MyClass.super.prototype.doSomething ).call( this );
};
// Sycnhronous after
MyClass.prototype.doSomething = function () {
return OO.ui.promisify( MyClass.super.prototype.doSomething ).call( this ).then( function () {
@trevorparscal
trevorparscal / TransplantStyles.js
Last active August 29, 2015 14:14
Transplant the CSS styles from as parent document to a frame's document
/**
* Transplant the CSS styles from as parent document to a frame's document.
*
* This loops over the style sheets in the parent document, and copies their nodes to the
* frame's document. It then polls the document to see when all styles have loaded, and once they
* have, resolves the promise.
*
* If the styles still haven't loaded after a long time (5 seconds by default), we give up waiting
* and resolve the promise anyway. This protects against cases like a display: none; iframe in
* Firefox, where the styles won't load until the iframe becomes visible.