Skip to content

Commit 117a761

Browse files
committed
Merge pull request #54 from jdm135/master
init data updated with nathans provided data
2 parents 992219b + 7950093 commit 117a761

File tree

6 files changed

+139
-49
lines changed

6 files changed

+139
-49
lines changed

control/content/content.controller.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
3232
return;
3333
}
3434

35+
if(!result.id){
36+
result.data=folderPluginShared.getDefaultScopeData();
37+
}
38+
3539
if (result && result.data && !angular.equals({}, result.data)) {
3640

3741
$scope.data = result.data;
@@ -43,13 +47,13 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
4347
if ($scope.data._buildfire && $scope.data._buildfire.plugins && $scope.data._buildfire.plugins.result) {
4448
var pluginsData = folderPluginShared.getPluginDetails($scope.data._buildfire.plugins.result, $scope.data._buildfire.plugins.data);
4549
if ($scope.data.content && $scope.data.content.loadAllPlugins) {
46-
if(pluginsData.length){
47-
plugins.loadItems(pluginsData, "loadAll");
48-
$("#plugins").find(".carousel-items").hide();
49-
}else{
50-
plugins.loadAllItems();
51-
$("#plugins").find(".carousel-items").hide();
52-
}
50+
if(pluginsData.length){
51+
plugins.loadItems(pluginsData, "loadAll");
52+
$("#plugins").find(".carousel-items").hide();
53+
}else{
54+
plugins.loadAllItems();
55+
$("#plugins").find(".carousel-items").hide();
56+
}
5357
} else {
5458
plugins.loadItems(pluginsData, "selected");
5559
$("#plugins").find(".carousel-items").show();
@@ -76,6 +80,7 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
7680
if (tmrDelay) clearTimeout(tmrDelay);
7781
}
7882

83+
7984
/*
8085
* watch for changes in data and trigger the saveDataWithDelay function on change
8186
* */
@@ -109,8 +114,14 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
109114
* create an artificial delay so api isnt called on every character entered
110115
* */
111116
var saveDataWithDelay = function (newObj, oldObj) {
117+
112118
if (tmrDelay) clearTimeout(tmrDelay);
113119
if (angular.equals(newObj, oldObj)) return;
120+
if(newObj.default){
121+
newObj=folderPluginShared.getDefaultScopeBlankData();
122+
editor.loadItems([]);
123+
$scope.data.content.text=""
124+
}
114125
tmrDelay = setTimeout(function () {
115126
saveData(newObj);
116127
}, 500);

control/design/design.controller.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', function ($scope) {
6464
if (newObj == undefined) return;
6565
if (angular.equals(newObj, oldObj)) return;
6666

67+
if(newObj.default){
68+
newObj=folderPluginShared.getDefaultScopeBlankData();
69+
}
70+
6771
if ($scope.frmMain.$invalid) {
6872
console.warn('invalid data, details will not be saved');
6973
return;

control/shared.js

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,51 @@ folderPluginShared.getPluginDetails = function (pluginsInfo, pluginIds) {
2828

2929
folderPluginShared.getDefaultScopeData = function () {
3030
return {
31-
_buildfire: {
32-
plugins: {
33-
dataType: "pluginInstance",
34-
data: []
31+
"_buildfire": {
32+
"plugins": {
33+
"dataType": "pluginInstance",
34+
"data": []
3535
}
3636
},
37-
content: {
38-
carouselImages: [],
39-
text: "",
40-
loadAllPlugins: false
37+
"content": {
38+
"carouselImages": [{
39+
"action": "noAction",
40+
"iconUrl": "http://buildfire.imgix.net/b55ee984-a8e8-11e5-88d3-124798dea82d/7ef5f050-134f-11e6-bd0b-2511d1715baa.jpeg",
41+
"title": "image"
42+
}, {
43+
"action": "noAction",
44+
"iconUrl": "http://buildfire.imgix.net/b55ee984-a8e8-11e5-88d3-124798dea82d/7e028fa0-134f-11e6-b7ce-51a0b9ba84fd.jpg",
45+
"title": "image"
46+
}],
47+
"text": "<p>With the Folder plugin you can categorize existing plugins so that you can easily direct your users to the proper content. Check out our tutorial in our knowledge base for more information. HINT: You'll also want to check out our article on the WYSIWYG</p>",
48+
"loadAllPlugins": false
4149
},
42-
design: {
43-
backgroundImage: null,
44-
selectedLayout: 1,
45-
backgroundblur: 0
50+
"design": {
51+
"backgroundImage": null,
52+
"selectedLayout": 1,
53+
"backgroundblur": 0
54+
},
55+
"default" : true
56+
};
57+
};
58+
59+
folderPluginShared.getDefaultScopeBlankData= function () {
60+
return {
61+
"_buildfire": {
62+
"plugins": {
63+
"dataType": "pluginInstance",
64+
"data": []
65+
}
66+
},
67+
"content": {
68+
"carouselImages": [],
69+
"text": "",
70+
"loadAllPlugins": false
71+
},
72+
"design": {
73+
"backgroundImage": null,
74+
"selectedLayout": 1,
75+
"backgroundblur": 0
4676
}
4777
};
4878
};

js/shared.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,33 @@ folderPluginShared.getPluginDetails = function (pluginsInfo, pluginIds) {
2828

2929
folderPluginShared.getDefaultScopeData = function () {
3030
return {
31-
_buildfire: {
32-
plugins: {
33-
dataType: "pluginInstance",
34-
data: []
31+
"_buildfire": {
32+
"plugins": {
33+
"dataType": "pluginInstance",
34+
"data": []
3535
}
3636
},
37-
content: {
38-
carouselImages: [],
39-
text: "",
40-
loadAllPlugins: false
37+
"content": {
38+
"carouselImages": [{
39+
"action": "noAction",
40+
"iconUrl": "http://imageserver.prod.s3.amazonaws.com/1462345136293-07379761438351125/e5c4ac80-11c5-11e6-ad08-375cc71b6ca7.jpg",
41+
"title": "image"
42+
}, {
43+
"action": "noAction",
44+
"iconUrl": "http://imageserver.prod.s3.amazonaws.com/1462345136293-07379761438351125/e667f160-11c5-11e6-ad08-375cc71b6ca7.jpg",
45+
"title": "image"
46+
}, {
47+
"action": "noAction",
48+
"iconUrl": "http://imageserver.prod.s3.amazonaws.com/1462345136293-07379761438351125/e6f627a0-11c5-11e6-92ea-27ed66023d52.jpg",
49+
"title": "image"
50+
}],
51+
"text": "<p>Folder plugin allow user to add plugin inside and arrange them as per preference</p>",
52+
"loadAllPlugins": false
4153
},
42-
design: {
43-
backgroundImage: null,
44-
selectedLayout: 1,
45-
backgroundblur: 0
54+
"design": {
55+
"backgroundImage": null,
56+
"selectedLayout": 1,
57+
"backgroundblur": 0
4658
}
4759
};
4860
};

widget/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<div ng-class="{ 'hidden': data.content.carouselImages.length == 0 }" class="plugin-banner clearfix" ng-hide="data.design.selectedLayout == 12">
7272
<div id="carousel" class="plugin-slider text-center" ng-style="data.content.carouselImages.length > 0 ? {'min-height': (9 * deviceWidth / 16) + 'px' } : {}"></div>
7373
</div>
74-
<div class="text-left padded padding-bottom-zero clearfix folder-plugin-text hide-empty " ng-bind-html="data.content.text" ng-hide="data.design.selectedLayout == 12"></div>
74+
<div class="text-left padded padding-bottom-zero clearfix folder-plugin-text hide-empty " ng-bind-html="safeHtml(data.content.text)" ng-hide="data.design.selectedLayout == 12"></div>
7575
<div ng-if="data.design.selectedLayout && data.plugins.length > 0" ng-class="{'fullHeight': data.design.selectedLayout == 12}" infinite-scroll="paging()"
7676
data-infinite-container=".infinite-scroll-parent">
7777
<!-- Layout 1 -->

widget/widget.controller.js

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,31 @@ folderPluginShared.getPluginDetails = function (pluginsInfo, pluginIds) {
4040

4141
folderPluginShared.getDefaultScopeData = function () {
4242
return {
43-
_buildfire: {
44-
plugins: {
45-
dataType: "pluginInstance",
46-
data: []
43+
"_buildfire": {
44+
"plugins": {
45+
"dataType": "pluginInstance",
46+
"data": []
4747
}
4848
},
49-
content: {
50-
carouselImages: [],
51-
text: "",
52-
loadAllPlugins: false
49+
"content": {
50+
"carouselImages": [{
51+
"action": "noAction",
52+
"iconUrl": "http://buildfire.imgix.net/b55ee984-a8e8-11e5-88d3-124798dea82d/7ef5f050-134f-11e6-bd0b-2511d1715baa.jpeg",
53+
"title": "image"
54+
}, {
55+
"action": "noAction",
56+
"iconUrl": "http://buildfire.imgix.net/b55ee984-a8e8-11e5-88d3-124798dea82d/7e028fa0-134f-11e6-b7ce-51a0b9ba84fd.jpg",
57+
"title": "image"
58+
}],
59+
"text": "<p>With the Folder plugin you can categorize existing plugins so that you can easily direct your users to the proper content. Check out our tutorial in our knowledge base for more information. HINT: You'll also want to check out our article on the WYSIWYG</p>",
60+
"loadAllPlugins": false
5361
},
54-
design: {
55-
backgroundImage: null,
56-
selectedLayout: 1,
57-
backgroundblur: 0
58-
}
62+
"design": {
63+
"backgroundImage": null,
64+
"selectedLayout": 1,
65+
"backgroundblur": 0
66+
},
67+
"default" : true
5968
};
6069
};
6170
/*
@@ -252,7 +261,10 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', '$sce','$timeout','$ro
252261
backgroundblur: 0
253262
};
254263
}
255-
var currentCount =Number(data.plugins.length);
264+
if(data.plugins){
265+
var currentCount =Number(data.plugins.length);
266+
}
267+
256268

257269
preparePluginsData(data.plugins);
258270

@@ -262,7 +274,7 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', '$sce','$timeout','$ro
262274
}
263275

264276
$scope.data.content = data.content;
265-
if (data && data.content && data.content.text) {
277+
/* if (data && data.content && data.content.text) {
266278
var $html = $('<div />', {html: data.content.text});
267279
$html.find('iframe').each(function (index, element) {
268280
var src = element.src;
@@ -271,7 +283,7 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', '$sce','$timeout','$ro
271283
element.src = src && src.indexOf('http') != -1 ? src : 'http:' + src;
272284
});
273285
$scope.data.content.text = $sce.trustAsHtml($html.html());
274-
}
286+
}*/
275287

276288
if ($scope.data.content && $scope.data.content.carouselImages) {
277289
initDeviceSize(function () {
@@ -290,6 +302,19 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', '$sce','$timeout','$ro
290302
}
291303
}
292304

305+
$scope.safeHtml = function (html) {
306+
if (html) {
307+
var $html = $('<div />', {html: html});
308+
$html.find('iframe').each(function (index, element) {
309+
var src = element.src;
310+
console.log('element is: ', src, src.indexOf('http'));
311+
src = src && src.indexOf('file://') != -1 ? src.replace('file://', 'http://') : src;
312+
element.src = src && src.indexOf('http') != -1 ? src : 'http:' + src;
313+
});
314+
return $sce.trustAsHtml($html.html());
315+
}
316+
};
317+
293318
var searchOptions = {pageIndex:0,pageSize:10};
294319

295320
function dataLoadedHandler(result) {
@@ -332,7 +357,15 @@ folderPluginApp.controller('folderPluginCtrl', ['$scope', '$sce','$timeout','$ro
332357
console.error("Error: ", err);
333358
return;
334359
}
335-
dataLoadedHandler(result);
360+
if(result.id){
361+
dataLoadedHandler(result);
362+
}else{
363+
var obj={
364+
data:folderPluginShared.getDefaultScopeData()
365+
}
366+
dataLoadedHandler(obj);
367+
}
368+
336369
});
337370
}
338371

0 commit comments

Comments
 (0)