@@ -40,22 +40,31 @@ folderPluginShared.getPluginDetails = function (pluginsInfo, pluginIds) {
4040
4141folderPluginShared . 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