Skip to content

Instantly share code, notes, and snippets.

@alivedise
Created November 19, 2015 03:53
Show Gist options
  • Save alivedise/3ca775229e83a3376715 to your computer and use it in GitHub Desktop.
Save alivedise/3ca775229e83a3376715 to your computer and use it in GitHub Desktop.
SoftKey in SystemDialog
// H5SystemDialog
// For value selector to override.
H5SystemDialog.prototype.overrideSoftKeys = function(key) {
SoftKeysHelper.registerKeys(key, this.element);
}
// For value selector to restore
H5SystemDialog.prototype.registerSoftKeys = function(keys) {
SoftKeysHelper.registerKeys(this.registeredKeys, this.element);
};
H5SystemDialog.prototype.registerEvents = function() {
window.addEventListener('message', this._handle_message.bind(this));
};
// For inner iframe to update.
H5SystemDialog.prototype._handle_message = function(message) {
switch (message.data.type) {
case 'softkey':
this.registerSoftKeys(message.data.keys);
break;
}
};
H5SystemDialog.prototype.registerSoftKeys = function(keys) {
this.registeredKeys = keys;
SoftKeysHelper.registerKeys(keys, this.element);
};
// In H5Account, inside the iframe
H5AccountUpdateSoftKeys = function(keys) {
window.parent.postMessage({
type: 'softkey',
keys: keys
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment