Skip to content

Commit

Permalink
support for links blocked in iframe (#110)
Browse files Browse the repository at this point in the history
* support for links blocked in iframe

* travis fix

* testing traving fix
  • Loading branch information
hariszupcevic authored Jul 7, 2020
1 parent 52d7be2 commit 3ec308b
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 209 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"angular-route": "~1.4.3",
"angular-ui-sortable": "~0.14.2",
"jquery": "~2.1.4",
"owlcarousel": "~1.3.2",
"owl.carousel": "~2.3.4",
"tinymce": "~4.2.3"
}
}
6 changes: 5 additions & 1 deletion control/content/assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
.mapSize{
height: 200px;
position: relative;
}
}

.mce-window.mce-container.mce-floatpanel {
top:34px !important;
}
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function(config) {
'test/assets/bower_components/angular-animate/angular-animate.min.js',
'test/assets/bower_components/angular-route/angular-route.min.js',
'test/assets/bower_components/angular-bootstrap/ui-bootstrap.min.js',
'test/assets/bower_components/owlcarousel/owl-carousel/owl.carousel.min.js',
'test/assets/bower_components/owl.carousel/owl-carousel/owl.carousel.min.js',
'test/assets/bower_components/tinymce/tinymce.min.js',
'test/assets/bower_components/angular-mocks/angular-mocks.js',
'test/assets/bower_components/angular-ui-sortable/sortable.min.js',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "contactusplugin",
"version": "1.0.0",
"description": "",
"supportSite":"http://learn.appdocumentation.com/plugin-tutorials/contact-us-plugin",
"supportSite": "http://learn.appdocumentation.com/plugin-tutorials/contact-us-plugin",
"scripts": {
"postinstall": "./node_modules/.bin/bower install",
"build": "cd .. && rm -rf contactUsPlugin.zip && zip -r contactUsPlugin.zip contactUsPlugin/ -x *node_modules* *.git*",
Expand Down
167 changes: 0 additions & 167 deletions test/widget/widget.home.controller.spec.js

This file was deleted.

95 changes: 57 additions & 38 deletions widget/controllers/widget.home.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
iconUrl: "http://buildfire.imgix.net/1462345835888-04866688400506973/6ac49110-11c7-11e6-92ea-27ed66023d52.jpeg?fit=crop&w=342&h=193",
title: "image"
},
{
action: "noAction",
iconUrl: "http://buildfire.imgix.net/1462345835888-04866688400506973/6bf3c240-11c7-11e6-ad08-375cc71b6ca7.jpg?fit=crop&w=342&h=193",
title: "image"
}],
{
action: "noAction",
iconUrl: "http://buildfire.imgix.net/1462345835888-04866688400506973/6bf3c240-11c7-11e6-ad08-375cc71b6ca7.jpg?fit=crop&w=342&h=193",
title: "image"
}],
description: "<p>With the wysiwyg, you can include text and lists, embed images, embed videos, and link to webpages, emails, phone numbers and more. Check out the tutorial on the wysiwyg for detailed information.</p>",
addressTitle: "",
address: {
Expand All @@ -52,7 +52,7 @@
"title": "Call",
"action": "callNumber",
"phoneNumber": "6195551234"
}, {"title": "Email", "action": "sendEmail"}]
}, { "title": "Email", "action": "sendEmail" }]
},
design: {
listLayout: "Layout_1",
Expand Down Expand Up @@ -100,47 +100,66 @@
}
};

var changeTarget = function (description) {

var tempElement = document.createElement('html');
tempElement.innerHTML = description;

var links = tempElement.getElementsByTagName('a');

[...links].forEach(link => {
link.removeAttribute("target");
link.setAttribute("target", "_system");
});

return tempElement.innerHTML;

}

/*
* Fetch user's data from datastore
*/
var init = function (cb) {
var success = function (result) {
if (!result.id) {
console.log('NO DATA AVAILABLE');
WidgetHome.data = _dummyData;
} else {
WidgetHome.data = result.data;
}
if (!WidgetHome.data.design) {
WidgetHome.data.design = {};
}
if (!WidgetHome.data.design.listLayout) {
WidgetHome.data.design.listLayout = LAYOUTS.listLayouts[0].name;
}
currentListLayout = WidgetHome.data.design.listLayout;
if (WidgetHome.data.design.backgroundImage) {
$rootScope.backgroundImage = WidgetHome.data.design.backgroundImage;
}
else {
$rootScope.backgroundImage = "";
}
var getDevice = function (error, data) {
if (data)
WidgetHome.device = data.device;
else
console.log("Error while getting the device context data", error)
};
buildfire.getContext(getDevice);
cb();
if (!result.id) {
console.log('NO DATA AVAILABLE');
WidgetHome.data = _dummyData;
} else {
WidgetHome.data = result.data;
}

WidgetHome.data.content.description = changeTarget(WidgetHome.data.content.description);

if (!WidgetHome.data.design) {
WidgetHome.data.design = {};
}
if (!WidgetHome.data.design.listLayout) {
WidgetHome.data.design.listLayout = LAYOUTS.listLayouts[0].name;
}
currentListLayout = WidgetHome.data.design.listLayout;
if (WidgetHome.data.design.backgroundImage) {
$rootScope.backgroundImage = WidgetHome.data.design.backgroundImage;
}
else {
$rootScope.backgroundImage = "";
}
var getDevice = function (error, data) {
if (data)
WidgetHome.device = data.device;
else
console.log("Error while getting the device context data", error)
};
buildfire.getContext(getDevice);
cb();

}
, error = function (err) {
console.error('Error while getting data', err);
cb(err);
};
DataStore.get(TAG_NAMES.CONTACT_INFO).then(success, error);
};
init(function(){});
init(function () { });
$scope.$on('$viewContentLoaded', function () {
$rootScope.$on("Carousel:LOADED", function () {
if (!WidgetHome.view) {
Expand Down Expand Up @@ -195,7 +214,7 @@
});
WidgetHome.safeHtml = function (html) {
if (html) {
var $html = $('<div />', {html: html});
var $html = $('<div />', { html: html });
$html.find('iframe').each(function (index, element) {
var src = element.src;
console.log('element is: ', src, src.indexOf('http'));
Expand All @@ -215,8 +234,8 @@
}
};
$event.preventDefault();
$timeout(function(){
Buildfire.actionItems.list(actionItems, options, callback);
$timeout(function () {
Buildfire.actionItems.list(actionItems, options, callback);
});
}
};
Expand All @@ -228,7 +247,7 @@
buildfire.navigation.openWindow("http://maps.google.com/maps?daddr=" + lat + "," + long, '_system');
};

WidgetHome.executeOperation = function(item){
WidgetHome.executeOperation = function (item) {
buildfire.actionItems.execute(item, function (err, result) {
if (err) {
console.warn('Error opening slider action: ', err);
Expand Down

0 comments on commit 3ec308b

Please sign in to comment.