[riot-mui] Add riot-mui in change tag (#17)

This commit is contained in:
Joxit 2017-09-27 20:52:52 +02:00
parent 4d1db1f884
commit 91497a06c3

View file

@ -15,47 +15,39 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<change> <change>
<dialog ref="change-server-dialog" class="mdl-dialog"> <material-popup>
<h4 class="mdl-dialog__title">Change your Server ?</h4> <div class="material-popup-title">Change your Server ?</div>
<div class="mdl-dialog__content"> <div class="material-popup-content">
<div class="mdl-textfield mdl-js-textfield"> <select class="mdl-textfield__input mdl-textfield__select" name="server-list" ref="server-list">
<select class="mdl-textfield__input mdl-textfield__select" name="server-list" ref="server-list"> <option each="{ url in registryUI.getRegistryServer() }" value={url}>{url}</option>
<option each="{ url in registryUI.getRegistryServer() }" value={url}>{url}</option> </select>
</select> </div>
</div> <div class="material-popup-action">
</div> <material-button class="dialog-button" waves-color="rgba(158,158,158,.4)" onClick="registryUI.changeTag.change();">Change</material-button>
<div class="mdl-dialog__actions"> <material-button class="dialog-button" waves-color="rgba(158,158,158,.4)" onClick="registryUI.changeTag.close();">Cancel</material-button>
<button type="button" class="mdl-button change" onClick="registryUI.changeTag.change();">Change</button> </div>
<button type="button" class="mdl-button close" onClick="registryUI.changeTag.close();">Cancel</button> </material-popup>
</div>
</dialog> </dialog>
<script type="text/javascript"> <script type="text/javascript">
registryUI.changeTag = registryUI.changeTag || {}; registryUI.changeTag = registryUI.changeTag || {};
registryUI.changeTag.update = this.update; this.one('mount', function () {
this.on('updated', function () { registryUI.changeTag.dialog = this.tags['material-popup'];
componentHandler.upgradeElements(this.refs['change-server-dialog']); registryUI.changeTag.dialog.getServerUrl = function() {
registryUI.changeTag.dialog = registryUI.changeTag.dialog || this.refs['change-server-dialog']; return this.refs['server-list'] ? this.refs['server-list'].value : '';
registryUI.changeTag.serverList = registryUI.changeTag.serverList || this.refs['server-list'];
if (!registryUI.changeTag.dialog.showModal) {
dialogPolyfill.registerDialog(registryUI.changeTag.dialog);
}
this.refs['server-list'].onkeyup = function (e) {
// if keyCode is Enter
if (e.keyCode == 13) {
registryUI.changeTag.change();
}
}; };
registryUI.changeTag.dialog.on('updated', function() {
if (this.refs['server-list']) {
this.refs['server-list'].value = registryUI.url();
}
});
}); });
registryUI.changeTag.show = function () { registryUI.changeTag.show = function () {
registryUI.changeTag.update(); registryUI.changeTag.dialog.open();
registryUI.changeTag.serverList.value = registryUI.url();;
registryUI.changeTag.dialog.showModal();
}; };
registryUI.changeTag.change = function () { registryUI.changeTag.change = function () {
if (registryUI.changeTag.serverList.value && registryUI.changeTag.serverList.value.length > 0) { if (registryUI.changeTag.dialog.getServerUrl().length > 0) {
registryUI.changeServer(registryUI.changeTag.serverList.value); registryUI.changeServer(registryUI.changeTag.dialog.getServerUrl());
} }
registryUI.changeTag.serverList.value = '';
rg.router.go('home'); rg.router.go('home');
registryUI.changeTag.dialog.close(); registryUI.changeTag.dialog.close();
}; };