本文整理汇总了TypeScript中@providers/utils/dom.CoreDomUtilsProvider类的典型用法代码示例。如果您正苦于以下问题:TypeScript CoreDomUtilsProvider类的具体用法?TypeScript CoreDomUtilsProvider怎么用?TypeScript CoreDomUtilsProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CoreDomUtilsProvider类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: resetPassword
/**
* Request to reset the password.
*
* @param {Event} e Event.
*/
resetPassword(e: Event): void {
e.preventDefault();
e.stopPropagation();
const field = this.myForm.value.field,
value = this.myForm.value.value;
if (!value) {
this.domUtils.showErrorModal('core.login.usernameoremail', true);
return;
}
const modal = this.domUtils.showModalLoading('core.sending', true),
isMail = field == 'email';
this.loginHelper.requestPasswordReset(this.siteUrl, isMail ? '' : value, isMail ? value : '').then((response) => {
if (response.status == 'dataerror') {
// Error in the data sent.
this.showError(isMail, response.warnings);
} else if (response.status == 'emailpasswordconfirmnotsent' || response.status == 'emailpasswordconfirmnoemail') {
// Error, not found.
this.domUtils.showErrorModal(response.notice);
} else {
// Success.
this.domUtils.showAlert(this.translate.instant('core.success'), response.notice);
this.navCtrl.pop();
}
}).catch((error) => {
this.domUtils.showErrorModal(error);
}).finally(() => {
modal.dismiss();
});
}
示例2: if
this.loginHelper.requestPasswordReset(this.siteUrl, isMail ? '' : value, isMail ? value : '').then((response) => {
if (response.status == 'dataerror') {
// Error in the data sent.
this.showError(isMail, response.warnings);
} else if (response.status == 'emailpasswordconfirmnotsent' || response.status == 'emailpasswordconfirmnoemail') {
// Error, not found.
this.domUtils.showErrorModal(response.notice);
} else {
// Success.
this.domUtils.showAlert(this.translate.instant('core.success'), response.notice);
this.navCtrl.pop();
}
}).catch((error) => {
示例3: login
/**
* Tries to authenticate the user.
*
* @param {Event} e Event.
*/
login(e: Event): void {
e.preventDefault();
e.stopPropagation();
this.appProvider.closeKeyboard();
// Get input data.
const siteUrl = this.siteUrl,
username = this.username,
password = this.credForm.value.password;
if (!password) {
this.domUtils.showErrorModal('core.login.passwordrequired', true);
return;
}
if (!this.appProvider.isOnline()) {
this.domUtils.showErrorModal('core.networkerrormsg', true);
return;
}
const modal = this.domUtils.showModalLoading();
// Start the authentication process.
this.sitesProvider.getUserToken(siteUrl, username, password).then((data) => {
return this.sitesProvider.updateSiteToken(this.infoSiteUrl, username, data.token, data.privateToken).then(() => {
// Update site info too because functions might have changed (e.g. unisntall local_mobile).
return this.sitesProvider.updateSiteInfoByUrl(this.infoSiteUrl, username).then(() => {
// Reset fields so the data is not in the view anymore.
this.credForm.controls['password'].reset();
if (this.pageName) {
// Page defined, go to that page instead of site initial page.
return this.navCtrl.setRoot(this.pageName, this.pageParams);
} else {
return this.loginHelper.goToSiteInitialPage();
}
}).catch((error) => {
// Error, go back to login page.
this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true);
this.cancel();
});
});
}).catch((error) => {
this.loginHelper.treatUserTokenError(siteUrl, error, username, password);
}).finally(() => {
modal.dismiss();
});
}
示例4: parseInt
this.element.addEventListener('click', (ev: Event): void => {
if (!this.module && !this.moduleId) {
return;
}
ev.preventDefault();
ev.stopPropagation();
const modal = this.domUtils.showModalLoading(),
courseId = typeof this.courseId == 'string' ? parseInt(this.courseId, 10) : this.courseId;
let promise;
if (this.module) {
// We already have the module.
promise = Promise.resolve(this.module);
} else {
// Try to get the module from cache.
this.moduleId = typeof this.moduleId == 'string' ? parseInt(this.moduleId, 10) : this.moduleId;
promise = this.courseProvider.getModule(this.moduleId, courseId);
}
promise.then((module) => {
const componentId = this.componentId || module.id;
return this.courseHelper.downloadModuleAndOpenFile(module, courseId, this.component, componentId, this.files);
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.errordownloading', true);
}).finally(() => {
modal.dismiss();
});
});
示例5: resolve
modal.onDidDismiss((data) => {
if (typeof data != 'undefined') {
resolve(data);
} else {
reject(this.domUtils.createCanceledError());
}
});
示例6: completionClicked
/**
* Completion clicked.
*
* @param {Event} e The click event.
*/
completionClicked(e: Event): void {
if (this.completion) {
if (typeof this.completion.cmid == 'undefined' || this.completion.tracking !== 1) {
return;
}
e.preventDefault();
e.stopPropagation();
const modal = this.domUtils.showModalLoading(),
params = {
cmid: this.completion.cmid,
completed: this.completion.state === 1 ? 0 : 1
},
currentSite = this.sitesProvider.getCurrentSite();
currentSite.write('core_completion_update_activity_completion_status_manually', params).then((response) => {
if (!response.status) {
return Promise.reject(null);
}
this.completionChanged.emit();
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.errorchangecompletion', true);
}).finally(() => {
modal.dismiss();
});
}
}
示例7: ngOnInit
/**
* Component being initialized.
*/
ngOnInit(): void {
if (!this.filePath) {
this.domUtils.showErrorModal('Error reading file.');
this.navCtrl.pop();
return;
}
const fileAndDir = this.fileProvider.getFileAndDirectoryFromPath(this.filePath);
this.fileName = fileAndDir.name;
// Get the file.
this.fileProvider.getExternalFile(this.filePath).then((fe) => {
this.fileEntry = fe;
this.fileName = this.fileEntry.name;
}).catch(() => {
this.domUtils.showErrorModal('Error reading file.');
this.navCtrl.pop();
});
// Get the sites.
this.sitesProvider.getSites().then((sites) => {
this.sites = sites;
}).finally(() => {
this.loaded = true;
});
}
示例8: completionClicked
/**
* Completion clicked.
*
* @param {Event} e The click event.
*/
completionClicked(e: Event): void {
if (this.completion) {
if (typeof this.completion.cmid == 'undefined' || this.completion.tracking !== 1) {
return;
}
e.preventDefault();
e.stopPropagation();
const modal = this.domUtils.showModalLoading();
this.courseProvider.markCompletedManually(this.completion.cmid, this.completion.state === 1 ? 0 : 1,
this.completion.courseId, this.completion.courseName).then((response) => {
if (!response.status) {
return Promise.reject(null);
}
this.completionChanged.emit();
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.errorchangecompletion', true);
}).finally(() => {
modal.dismiss();
});
}
}
示例9: showError
// Show an error from the warnings.
protected showError(isMail: boolean, warnings: any[]): void {
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i];
if ((warning.item == 'email' && isMail) || (warning.item == 'username' && !isMail)) {
this.domUtils.showErrorModal(warning.message);
break;
}
}
}
示例10: open
/**
* Opens a URL.
*
* @param {string} url The URL to go to.
*/
open(url: string): void {
const modal = this.domUtils.showModalLoading();
this.contentLinksHelper.handleLink(url).then((treated) => {
if (!treated) {
return this.sitesProvider.getCurrentSite().openInBrowserWithAutoLoginIfSameSite(url);
}
}).finally(() => {
modal.dismiss();
});
}