Mathijs den Burger pushed to branch bugfix/CHANNELMGR-677 at cms-community / 
hippo-addon-channel-manager


Commits:
be8a3c07 by Mathijs den Burger at 2016-06-14T09:37:58+02:00
CHANNELMGR-677 fix Container.performClose(), rename to close()

While the 'close handshake' is not used anymore, some apps still do
want to close the containing window.

- - - - -


2 changed files:

- angularjs-api/src/angularjs/services/ContainerService.js
- 
frontend-api/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/IFrameWindow.js


Changes:

=====================================
angularjs-api/src/angularjs/services/ContainerService.js
=====================================
--- a/angularjs-api/src/angularjs/services/ContainerService.js
+++ b/angularjs-api/src/angularjs/services/ContainerService.js
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2015 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2014-2016 Hippo B.V. (http://www.onehippo.com)
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,30 +30,10 @@
             '$log',
             '$rootScope',
             '_hippo.channel.IFrameService',
-            'hippo.channel.FormStateService',
-            function($log, $rootScope, IFrameService, FormStateService) {
+            function($log, $rootScope, IFrameService) {
 
-                function performClose() {
-                    IFrameService.publish('close-reply');
-                }
-
-                function handleClose() {
-                    IFrameService.subscribe('close-request', function() {
-
-                        $rootScope.$broadcast('container:before-close');
-
-                        var closeEvent = 
$rootScope.$broadcast('container:close');
-                        if (!closeEvent.defaultPrevented) {
-                            performClose();
-                        }
-                    });
-
-                    $rootScope.$on('container:close', function(event) {
-                        if (!FormStateService.isValid()) {
-                            event.preventDefault();
-                            $rootScope.$broadcast('close-confirmation:show');
-                        }
-                    });
+                function close() {
+                    IFrameService.publish('close');
                 }
 
                 function showPage(path, mountId) {
@@ -61,8 +41,7 @@
                 }
 
                 return {
-                    handleClose: handleClose,
-                    performClose: performClose,
+                    close: close,
                     showPage: showPage
                 };
             }


=====================================
frontend-api/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/IFrameWindow.js
=====================================
--- 
a/frontend-api/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/IFrameWindow.js
+++ 
b/frontend-api/src/main/resources/org/onehippo/cms7/channelmanager/channeleditor/IFrameWindow.js
@@ -44,6 +44,18 @@
             iframeConfig: config.iframeConfig
           }
         ],
+        listeners: {
+          'afterrender': function (self) {
+            var messageBus = self.getIFramePanel().iframeToHost;
+            messageBus.subscribe('close', function () {
+              // make sure AngularJS in the iframe is properly destroyed by 
changing the
+              // location to about:blank before removing the iframe element 
from the DOM
+              var iframePanel = Ext.getCmp(self.iframePanelId);
+              iframePanel.on('locationchanged', self.close, self, { single: 
true });
+              iframePanel.setLocation('about:blank');
+            });
+          }
+        }
       });
 
       
Hippo.ChannelManager.ChannelEditor.IFrameWindow.superclass.constructor.call(this,
 config);



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/be8a3c078ac25f139226cf55922c0ec983296790
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to