Created
November 19, 2015 03:53
-
-
Save alivedise/3ca775229e83a3376715 to your computer and use it in GitHub Desktop.
SoftKey in SystemDialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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