diff --git a/src/classes/sqlitedb.ts b/src/classes/sqlitedb.ts
index d2e88d5d2..6b718eca8 100644
--- a/src/classes/sqlitedb.ts
+++ b/src/classes/sqlitedb.ts
@@ -298,7 +298,6 @@ export class SQLiteDB {
}
return this.execute(`DELETE FROM ${table} ${select}`, params);
-
}
/**
diff --git a/src/components/components.module.ts b/src/components/components.module.ts
index 781ea29ba..33b38d327 100644
--- a/src/components/components.module.ts
+++ b/src/components/components.module.ts
@@ -20,13 +20,15 @@ import { CoreLoadingComponent } from './loading/loading';
import { CoreMarkRequiredComponent } from './mark-required/mark-required';
import { CoreInputErrorsComponent } from './input-errors/input-errors';
import { CoreShowPasswordComponent } from './show-password/show-password';
+import { CoreIframeComponent } from './iframe/iframe';
@NgModule({
declarations: [
CoreLoadingComponent,
CoreMarkRequiredComponent,
CoreInputErrorsComponent,
- CoreShowPasswordComponent
+ CoreShowPasswordComponent,
+ CoreIframeComponent
],
imports: [
IonicModule,
@@ -37,7 +39,8 @@ import { CoreShowPasswordComponent } from './show-password/show-password';
CoreLoadingComponent,
CoreMarkRequiredComponent,
CoreInputErrorsComponent,
- CoreShowPasswordComponent
+ CoreShowPasswordComponent,
+ CoreIframeComponent
]
})
export class CoreComponentsModule {}
diff --git a/src/components/iframe/iframe.html b/src/components/iframe/iframe.html
new file mode 100644
index 000000000..75cea2664
--- /dev/null
+++ b/src/components/iframe/iframe.html
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/components/iframe/iframe.scss b/src/components/iframe/iframe.scss
new file mode 100644
index 000000000..12c75ceb3
--- /dev/null
+++ b/src/components/iframe/iframe.scss
@@ -0,0 +1,5 @@
+core-iframe {
+ > div {
+ height: 100%;
+ }
+}
diff --git a/src/components/iframe/iframe.ts b/src/components/iframe/iframe.ts
new file mode 100644
index 000000000..6658ffa31
--- /dev/null
+++ b/src/components/iframe/iframe.ts
@@ -0,0 +1,260 @@
+// (C) Copyright 2015 Martin Dougiamas
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { Component, Input, OnInit, ViewChild, ElementRef } from '@angular/core';
+import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
+import { Platform } from 'ionic-angular';
+import { CoreFileProvider } from '../../providers/file';
+import { CoreLoggerProvider } from '../../providers/logger';
+import { CoreSitesProvider } from '../../providers/sites';
+import { CoreDomUtilsProvider } from '../../providers/utils/dom';
+import { CoreTextUtilsProvider } from '../../providers/utils/text';
+import { CoreUrlUtilsProvider } from '../../providers/utils/url';
+import { CoreUtilsProvider } from '../../providers/utils/utils';
+
+/**
+ */
+@Component({
+ selector: 'core-iframe',
+ templateUrl: 'iframe.html'
+})
+export class CoreIframeComponent implements OnInit {
+
+ @ViewChild('iframe') iframe: ElementRef;
+ @Input() src: string;
+ @Input() iframeWidth: string;
+ @Input() iframeHeight: string;
+ loading: boolean;
+ safeUrl: SafeResourceUrl;
+
+ protected logger;
+ protected tags = ['iframe', 'frame', 'object', 'embed'];
+ protected IFRAME_TIMEOUT = 15000;
+
+ constructor(logger: CoreLoggerProvider, private fileProvider: CoreFileProvider, private urlUtils: CoreUrlUtilsProvider,
+ private textUtils: CoreTextUtilsProvider, private utils: CoreUtilsProvider, private domUtils: CoreDomUtilsProvider,
+ private sitesProvider: CoreSitesProvider, private platform: Platform, private sanitizer: DomSanitizer) {
+ this.logger = logger.getInstance('CoreIframe');
+ }
+
+ /**
+ * Component being initialized.
+ */
+ ngOnInit() {
+ let iframe: HTMLIFrameElement = this.iframe && this.iframe.nativeElement;
+
+ this.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
+ this.iframeWidth = this.domUtils.formatPixelsSize(this.iframeWidth) || '100%';
+ this.iframeHeight = this.domUtils.formatPixelsSize(this.iframeHeight) || '100%';
+
+ // Show loading only with external URLs.
+ this.loading = !!this.src.match(/^https?:\/\//i);
+
+ this.treatFrame(iframe);
+
+ if (this.loading) {
+ iframe.addEventListener('load', () => {
+ this.loading = false;
+ });
+
+ iframe.addEventListener('error', () => {
+ this.loading = false;
+ this.domUtils.showErrorModal('mm.core.errorloadingcontent', true);
+ });
+
+ setTimeout(() => {
+ this.loading = false;
+ }, this.IFRAME_TIMEOUT);
+ }
+ }
+
+ /**
+ * Given an element, return the content window and document.
+ *
+ * @param {any} element Element to treat.
+ * @return {{ window: Window, document: Document }} Window and Document.
+ */
+ protected getContentWindowAndDocument(element: any) : { window: Window, document: Document } {
+ let contentWindow: Window = element.contentWindow,
+ contentDocument: Document = element.contentDocument || (contentWindow && contentWindow.document);
+
+ if (!contentWindow && contentDocument) {
+ // It's probably an