Added feature #15745: Integrate generic notification methods to show windows and...
authorSteffen Kamper <info@sk-typo3.de>
Wed, 29 Sep 2010 11:16:22 +0000 (11:16 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Wed, 29 Sep 2010 11:16:22 +0000 (11:16 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8930 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/js/extjs/notifications.js [new file with mode: 0644]
typo3/backend.php

index 6f28795..88fad14 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-09-29  Steffen Kamper  <steffen@typo3.org>
+
+       * Added feature #15745: Integrate generic notification methods to show windows and dialogs based on ExtJS
+
 2010-09-28  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Added feature #15075: [Install] make a pre-check for required php-extensions (Thanks to Jigal van Hemert)
diff --git a/t3lib/js/extjs/notifications.js b/t3lib/js/extjs/notifications.js
new file mode 100644 (file)
index 0000000..0544c4e
--- /dev/null
@@ -0,0 +1,264 @@
+/***************************************************************\r
+ *  Copyright notice\r
+ *\r
+ *  (c) 2010 Oliver Hader <oliver@typo3.org>\r
+ *  (c) 2010 Steffen Kamper <steffen@typo3.org>\r
+ *  All rights reserved\r
+ *\r
+ *  This script is part of the TYPO3 project. The TYPO3 project is\r
+ *  free software; you can redistribute it and/or modify\r
+ *  it under the terms of the GNU General Public License as published by\r
+ *  the Free Software Foundation; either version 2 of the License, or\r
+ *  (at your option) any later version.\r
+ *\r
+ *  The GNU General Public License can be found at\r
+ *  http://www.gnu.org/copyleft/gpl.html.\r
+ *  A copy is found in the textfile GPL.txt and important notices to the license\r
+ *  from the author is found in LICENSE.txt distributed with these scripts.\r
+ *\r
+ *\r
+ *  This script is distributed in the hope that it will be useful,\r
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *  GNU General Public License for more details.\r
+ *\r
+ *  This copyright notice MUST APPEAR in all copies of the script!\r
+ ***************************************************************/\r
+\r
+Ext.ns('TYPO3', 'TYPO3.components');\r
+\r
+/**\r
+ * TYPO3window - General TYPO3 window component\r
+ */\r
+TYPO3.components.Window = Ext.extend(Ext.Window, {\r
+       width: 450,\r
+       autoHeight: true,\r
+       closable: true,\r
+       resizable: false,\r
+       plain: true,\r
+       border: false,\r
+       modal: true,\r
+       draggable: true,\r
+       closeAction: 'hide',\r
+       cls: 't3-window',\r
+\r
+       constructor: function(config) {\r
+               config = config || {};\r
+               Ext.apply(this, config);\r
+               TYPO3.components.Window.superclass.constructor.call(this, config);\r
+       }\r
+});\r
+Ext.reg('TYPO3window', TYPO3.components.Window);\r
+\r
+\r
+/**\r
+ * Helper class for managing windows.\r
+ * Once a window is created, it is permanent until you close\r
+ * [TYPO3.Windows.close(id)] or remove all [TYPO3.Windows.closeAll()]\r
+ *\r
+ * Example usage:\r
+ *\r
+ * var w = TYPO3.Windows.getWindow({\r
+ *             title: 'Testwindow',\r
+ *             html: 'some content!',\r
+ *             width: 400\r
+ *     }).show();\r
+ */\r
+TYPO3.Windows = function() {\r
+       /** @private */\r
+       var windowCollection = new Ext.util.MixedCollection(true);\r
+\r
+       return {\r
+               /** @public */\r
+\r
+               /**\r
+                * Get a window. If already in collection return it, otherwise create a new one\r
+                *\r
+                * @param (Object) configuration\r
+                * @return (Object) window\r
+                */\r
+               getWindow: function(configuration) {\r
+                       var id = configuration.id || '', window;\r
+\r
+                       if (id) {\r
+                               window = this.getById(id);\r
+                       }\r
+                       if (window) {\r
+                               return window;\r
+                       } else {\r
+                               window = new TYPO3.components.Window(configuration);\r
+                               windowCollection.add(window);\r
+                               return window;\r
+                       }\r
+               },\r
+\r
+               /**\r
+                * Get a window and show. If already in collection return it, otherwise create a new one\r
+                *\r
+                * @param (Object) configuration\r
+                * @return (Object) window\r
+                */\r
+               showWindow: function(configuration) {\r
+                       var window = this.getWindow(configuration);\r
+                       window.show();\r
+                       return window;\r
+               },\r
+\r
+               /**\r
+                * Shows window with id and return reference. If not exist return false\r
+                *\r
+                * @param (String) id\r
+                * @return (Object) window false if not found\r
+                */\r
+               show: function(id) {\r
+                       var window = this.getById(id);\r
+                       if (window) {\r
+                               window.show();\r
+                               return window;\r
+                       }\r
+                       return false;\r
+               },\r
+\r
+               /**\r
+                * Shows window with id and return reference. If not exist return false\r
+                *\r
+                * @param (String) id\r
+                * @return (Object) window or false if not found\r
+                */\r
+               getById: function(id) {\r
+                       return windowCollection.key(id);\r
+               },\r
+\r
+               /**\r
+                * Get the window collection\r
+                *\r
+                * @return (Ext.util.MixedCollection) windowCollection\r
+                */\r
+               getCollection: function () {\r
+                       return windowCollection;\r
+               },\r
+\r
+               /**\r
+                * Get count of windows\r
+                *\r
+                * @return (Int) count\r
+                */\r
+               getCount: function() {\r
+                       return windowCollection.length;\r
+               },\r
+\r
+               /**\r
+                * Each for windowCollection\r
+                *\r
+                * @param (Function) function\r
+                * @param (Object) scope\r
+                * @return void\r
+                */\r
+               each : function(fn, scope) {\r
+                       windowCollection.each(fn, scope);\r
+               },\r
+\r
+               /**\r
+                * Close window and remove from stack\r
+                *\r
+                * @param (Int) id\r
+                * @return void\r
+                */\r
+               close: function(id) {\r
+                       var window = this.getById(id);\r
+                       if (window) {\r
+                               window.close();\r
+                               windowCollection.remove(id);\r
+                       }\r
+               },\r
+\r
+               /**\r
+                * Close all windows and clear stack\r
+                *\r
+                * @return void\r
+                */\r
+               closeAll: function() {\r
+                       windowCollection.each(function(window) {\r
+                               window.close();\r
+                       });\r
+                       windowCollection.clear();\r
+               }\r
+       }\r
+}();\r
+\r
+/**\r
+ * Helper class for dialog windows\r
+ *\r
+ * Example usage:\r
+ *\r
+ * TYPO3.Dialog.InformationDialog({\r
+ *             title: 'Test',\r
+ *             msg: 'some information'\r
+ *     });\r
+\r
+ */\r
+TYPO3.Dialog = function() {\r
+       /** @private functions */\r
+       var informationDialogConfiguration = {\r
+               buttons: Ext.MessageBox.OK,\r
+               icon: Ext.MessageBox.INFO,\r
+               fn: Ext.emptyFn\r
+       };\r
+\r
+       var questionDialogConfiguration = {\r
+               buttons: Ext.MessageBox.YESNO,\r
+               icon: Ext.MessageBox.QUESTION\r
+       };\r
+\r
+       var warningDialogConfiguration = {\r
+               buttons: Ext.MessageBox.OK,\r
+               icon: Ext.MessageBox.WARNING,\r
+               fn: Ext.emptyFn\r
+       };\r
+\r
+       var errorDialogConfiguration = {\r
+               buttons: Ext.MessageBox.OK,\r
+               icon: Ext.MessageBox.ERROR,\r
+               fn: Ext.emptyFn\r
+       };\r
+\r
+\r
+       return {\r
+               /** @public functions */\r
+               InformationDialog: function(configuration) {\r
+                       configuration = configuration || {};\r
+                       configuration = Ext.apply(\r
+                                       informationDialogConfiguration,\r
+                                       configuration\r
+                                       );\r
+                       Ext.Msg.show(configuration);\r
+               },\r
+\r
+               QuestionDialog: function(configuration) {\r
+                       configuration = configuration || {};\r
+                       configuration = Ext.apply(\r
+                                       questionDialogConfiguration,\r
+                                       configuration\r
+                                       );\r
+                       Ext.Msg.show(configuration);\r
+               },\r
+\r
+               WarningDialog: function(configuration) {\r
+                       configuration = configuration || {};\r
+                       configuration = Ext.apply(\r
+                                       warningDialogConfiguration,\r
+                                       configuration\r
+                                       );\r
+                       Ext.Msg.show(configuration);\r
+               },\r
+\r
+               ErrorDialog: function(configuration) {\r
+                       configuration = configuration || {};\r
+                       configuration = Ext.apply(\r
+                                       errorDialogConfiguration,\r
+                                       configuration\r
+                                       );\r
+                       Ext.Msg.show(configuration);\r
+               }\r
+       }\r
+}();\r
index 585966b..0036924 100644 (file)
@@ -129,6 +129,7 @@ class TYPO3backend {
                        '../t3lib/jsfunc.evalfield.js',
                        '../t3lib/js/extjs/ux/flashmessages.js',
                        '../t3lib/js/extjs/ux/ext.ux.tabclosemenu.js',
+                       '../t3lib/js/extjs/notifications.js',
                        'js/backend.js',
                        'js/loginrefresh.js',
                        'js/extjs/debugPanel.js',