diff --git a/css/child.css b/css/child.css
deleted file mode 100644
index 608f121..0000000
--- a/css/child.css
+++ /dev/null
@@ -1,10 +0,0 @@
-
-.modalframe-page-wrapper,
-.modalframe-page-container {
- margin: 0;
- padding: 0;
-}
-.modalframe-page-content {
- margin: 0;
- padding: 1em;
-}
diff --git a/css/parent.css b/css/parent.css
deleted file mode 100644
index 1667519..0000000
--- a/css/parent.css
+++ /dev/null
@@ -1,73 +0,0 @@
-
-/**
- * jQuery UI Dialog classes.
- */
-.modalframe {
- color: #000000;
- background-color: #ffffff;
- border: 2px solid #1b5084;
-}
-.modalframe .ui-dialog-titlebar {
- position: relative;
- cursor: move;
- height: 26px;
- background-color: #336699;
- border: 1px solid #6694c6;
- white-space: nowrap;
-}
-.modalframe .ui-dialog-title {
- display: block;
- position: absolute;
- top: 0; left: 0;
- margin: 0.2em 0.5em;
- padding: 0;
- color: #d9d9d9;
-}
-.modalframe .ui-dialog-titlebar-close {
- display: block;
- position: absolute;
- top: 0; right: 0;
- margin: 2px 2px 2px 0.5em;
- padding: 0;
- width: 23px;
- height: 20px;
- background: url(../images/close.gif) no-repeat 0 0;
-}
-.modalframe .ui-dialog-titlebar a.ui-state-hover,
-.modalframe .ui-dialog-titlebar a.ui-state-focus {
- background-position: 0 -20px;
-}
-.modalframe .ui-dialog-titlebar-close span {
- display: none;
-}
-.modalframe .ui-dialog-content {
- color: #292929;
- background-color: #f8f8f8;
-}
-
-/**
- * ui-dialog overlay.
- */
-.ui-widget-overlay {
- position: absolute;
- top: 0; left: 0;
- width: 100%; height: 100%;
- background-color: #aaaaaa;
- opacity: 0.4;
- filter: alpha(opacity=40);
-}
-
-/**
- * Dialog content.
- */
-#modalframe-container {
- margin: 0;
- padding: 0;
- background: url(../images/loading.gif) no-repeat 50% 50%;
-}
-#modalframe-element {
- margin: 0;
- padding: 0;
- border: none;
- border-bottom: 1px solid #1b5084;
-}
diff --git a/js/child.js b/js/child.js
old mode 100644
new mode 100755
index a62d6f9..af5f5b3
--- a/js/child.js
+++ b/js/child.js
@@ -95,4 +95,4 @@ Drupal.modalFrameChild.behaviors.parseLinks = function(context) {
});
};
-})(jQuery);
+})(jQuery132);
\ No newline at end of file
diff --git a/js/parent.js b/js/parent.js
old mode 100644
new mode 100755
index f632a04..ee5ff34
--- a/js/parent.js
+++ b/js/parent.js
@@ -30,6 +30,7 @@ Drupal.modalFrame.open = function(options) {
autoFit: (options.autoFit == undefined || options.autoFit ? true : false),
autoResize: (options.autoResize ? true : false),
draggable: (options.draggable == undefined || options.draggable ? true : false),
+ resizable: (options.resizable == undefined || options.resizable ? true : false),
onSubmit: options.onSubmit
};
@@ -182,6 +183,7 @@ Drupal.modalFrame.load = function(url) {
* Check if the dialog can be closed.
*/
Drupal.modalFrame.canClose = function() {
+//alert('Drupal.modalFrame.canClose');
var self = this;
if (!self.isOpen) {
return false;
@@ -207,6 +209,7 @@ Drupal.modalFrame.canClose = function() {
* Close the modal frame.
*/
Drupal.modalFrame.close = function(args, statusMessages) {
+// alert('Drupal.modalFrame.close');
var self = this;
// Check if the dialog can be closed.
@@ -243,7 +246,8 @@ Drupal.modalFrame.close = function(args, statusMessages) {
*/
Drupal.modalFrame.bindChild = function(iFrameWindow, isClosing) {
var self = this;
- var $iFrameWindow = iFrameWindow.jQuery;
+ // iFrameWindow makes use of jQuery 1.3.2.
+ var $iFrameWindow = iFrameWindow.jQuery132;
var $iFrameDocument = $iFrameWindow(iFrameWindow.document);
self.iframe.Drupal = iFrameWindow.Drupal;
@@ -251,7 +255,6 @@ Drupal.modalFrame.bindChild = function(iFrameWindow, isClosing) {
if (isClosing) {
return;
}
-
// Update the dirty forms warning on the child window.
if (self.isObject(self.iframe.Drupal.dirtyForms)) {
self.iframe.Drupal.dirtyForms.warning = self.dirtyFormsWarning;
@@ -259,10 +262,10 @@ Drupal.modalFrame.bindChild = function(iFrameWindow, isClosing) {
// Update the dialog title with the child window title.
$('.modalframe .ui-dialog-title').html($iFrameDocument.attr('title'));
-
// Setting tabIndex makes the div focusable.
// Setting outline to 0 prevents a border on focus in Mozilla.
// Inspired by ui.dialog initialization code.
+ // TODO: There appears to be a problem with this line of code. Throws error "a.setAttribute is not a function"
$iFrameDocument.attr('tabIndex', -1).css('outline', 0);
// Perform animation to show the iframe element.
@@ -294,7 +297,7 @@ Drupal.modalFrame.bindChild = function(iFrameWindow, isClosing) {
var $iFrameTabbables = $iFrameWindow(':tabbable:not(form)');
var $firstTabbable = $iFrameTabbables.filter(':first');
var $lastTabbable = $iFrameTabbables.filter(':last');
-
+
// Set focus to the first tabbable element in the content area or the
// first button. If there are no tabbable elements, set focus on the
// close button of the dialog itself.
@@ -360,11 +363,12 @@ Drupal.modalFrame.bindChild = function(iFrameWindow, isClosing) {
* Unbind the child window.
*/
Drupal.modalFrame.unbindChild = function(iFrameWindow) {
+// alert('Drupal.modalFrame.unbindChild');
var self = this;
// Prevent memory leaks by explicitly unbinding keyboard event handler
// on the child document.
- iFrameWindow.jQuery(iFrameWindow.document).unbind('keydown.modalframe-event');
+ iFrameWindow.jQuery132(iFrameWindow.document).unbind('keydown.modalframe-event');
// Change the modal dialog title.
$('.modalframe .ui-dialog-title').html(Drupal.t('Please, wait...'));
@@ -499,4 +503,4 @@ Drupal.modalFrame.resize = function(size) {
});
};
-})(jQuery);
+})(jQuery132);
\ No newline at end of file
diff --git a/modalframe-page.tpl.php b/modalframe-page.tpl.php
deleted file mode 100644
index c98c46f..0000000
--- a/modalframe-page.tpl.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/modalframe.info b/modalframe.info
old mode 100644
new mode 100755
index 13d1880..01c461b
--- a/modalframe.info
+++ b/modalframe.info
@@ -1,6 +1,5 @@
name = Modal Frame API
description = Provides an API to render an iframe within a modal dialog based on the jQuery UI Dialog plugin.
-package = User interface
-dependencies[] = jquery_ui
+package = Modal frame
core = 7.x
-files[] = modalframe.module
+files[] = modalframe.module
\ No newline at end of file
diff --git a/modalframe.module b/modalframe.module
old mode 100644
new mode 100755
index 5003724..1148d86
--- a/modalframe.module
+++ b/modalframe.module
@@ -49,14 +49,61 @@
* @ingroup themeable
*/
function modalframe_theme_registry_alter(&$theme_registry) {
- if (isset($theme_registry['page']) && isset($theme_registry['page']['theme paths'])) {
- $module_path = drupal_get_path('module', 'modalframe');
- array_unshift($theme_registry['page']['theme paths'], $module_path);
+ if (isset($theme_registry['page'])) {
+ $theme_registry['page']['theme paths'] = array();
+ $mod_path = drupal_get_path('module', 'modalframe');
+ $theme = list_themes();
+ $theme_registry_copy = $theme_registry; // munge on a copy
+ _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'pow', $mod_path);
+ $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
+ $hooks = array('page', 'html');
+ foreach ($hooks as $h) {
+ _modalframe_insert_after_first_element($theme_registry[$h]['theme paths'], $mod_path);
+ }
+
+ // Add pre-preprocess function for page template.
+ array_unshift($theme_registry['page']['preprocess functions'], 'modalframe_pre_preprocess_page');
+ }
+}
+
+/**
+ * Helper function for modalframe_theme_registry_alter()
+ *
+ * Alters order of elements in theme paths array.
+ *
+ * @param array $a
+ * @param array $element
+ */
+function _modalframe_insert_after_first_element(&$a, $element) {
+ if(is_array($a)) {
+ $first_element = array_shift($a);
+ array_unshift($a, $first_element, $element);
}
}
/**
- * Preprocess template variables for page.tpl.php.
+ * Preprocess template variables for page.tpl.php - step 1.
+ *
+ * Performance enhancement: prevent template_preprocess_page() from generating
+ * sidebar blocks when a modal frame has been requested.
+ */
+function modalframe_pre_preprocess_page(&$variables) {
+ if (!empty($GLOBALS['modalframe_page_template'])) {
+ $variables['show_blocks'] = FALSE;
+ }
+}
+
+/**
+ * Preprocess template variables for html.tpl.php
+ */
+function modalframe_preprocess_html(&$variables) {
+ if (!empty($GLOBALS['modalframe_page_template'])) {
+ $variables['theme_hook_suggestions'][] = 'html__modalframe';
+ }
+}
+
+/**
+ * Preprocess template variables for page.tpl.php - step 2.
*
* Now that we have altered the registry entry for theme('page'), we can tell
* theme() to use a different template file name when we need to render a child
@@ -72,10 +119,7 @@ function modalframe_theme_registry_alter(&$theme_registry) {
*/
function modalframe_preprocess_page(&$variables) {
if (!empty($GLOBALS['modalframe_page_template'])) {
- if (!isset($variables['template_files'])) {
- $variables['template_files'] = array();
- }
- array_unshift($variables['template_files'], 'modalframe-page');
+ $variables['theme_hook_suggestions'][] = 'page__modalframe';
}
}
@@ -112,7 +156,7 @@ function modalframe_preprocess_page(&$variables) {
*
* @ingroup forms
*/
-function modalframe_form_alter(&$form, $form_state, $form_id) {
+function modalframe_form_alter(&$form, &$form_state, $form_id) {
// Here we simply want to install a form after_build callback.
if (!isset($form['#after_build'])) {
$form['#after_build'] = array();
@@ -140,10 +184,10 @@ function modalframe_form_after_build($form, &$form_state) {
// button before after_build callback is invoked. This may have been done
// by _form_builder_handle_input_element().
// If so, the list of submit handlers is stored in the $form_state array
- // which is something we can also alter from here, luckly. :)
- // Rememeber: our goal here is set $form_state['redirect'] is set to FALSE
- // if the API modalframe_close_dialog() has been invoked. That's because we
- // want to tell the parent window to close the modal frame.
+ // which is something we can also alter from here, luckily. :)
+ // Remember: our goal here is to make sure $form_state['redirect'] is set
+ // to FALSE when the modalframe_close_dialog() API is invoked, and that's
+ // because we want to tell the parent window to close the modal frame.
if (!empty($form_state['submit_handlers']) && !in_array('modalframe_form_submit', $form_state['submit_handlers'])) {
$form_state['submit_handlers'][] = 'modalframe_form_submit';
}
@@ -204,10 +248,24 @@ function modalframe_parent_js() {
}
$processed = TRUE;
- jquery_ui_add(array('ui.dialog', 'ui.draggable'));
- $module_path = drupal_get_path('module', 'modalframe');
- drupal_add_css($module_path .'/css/parent.css');
- drupal_add_js($module_path .'/js/parent.js');
+ // Added downgraded jQuery here.
+ $path = drupal_get_path('module', 'modalframe');
+
+ // Load downgraded version of jQuery (1.4.4 or newer -> 1.3.2) and jQuery UI
+ // (1.8.2 or newer -> 1.7.3) for compatability with modal frame API javascript.
+ drupal_add_js($path . '/js/init_downgraded_jquery.js');
+ drupal_add_js($path . '/js/jquery_ui/ui/jquery-1.3.2.js');
+ drupal_add_js($path . '/js/jquery_ui/ui/ui.core.js');
+ drupal_add_js($path . '/js/jquery_ui/ui/ui.draggable.js');
+ drupal_add_js($path . '/js/jquery_ui/ui/ui.resizable.js');
+ drupal_add_js($path . '/js/jquery_ui/ui/ui.dialog.js');
+ // Restore newer version of jQuery (1.3.2 -> 1.4.4 or newer).
+ drupal_add_js($path . '/js/restore_original_jquery.js');
+
+ // Add custom javascript code for Modal Frame API module.
+ drupal_add_js($path . '/js/parent.js');
+ drupal_add_css($path . '/css/modalframe.parent.css');
+// drupal_add_js($path .'/js/test.js');
}
/**
@@ -223,20 +281,30 @@ function modalframe_child_js() {
}
$processed = TRUE;
- // Disable admin_menu, which is something child windows don't need.
- module_invoke('admin_menu', 'suppress');
+ // Disable admin_menu, admin module output and similar modules, which
+ // is something child windows don't need.
+ module_invoke_all('suppress');
- // This is required to get access to jQuery UI extensions to jQuery itself,
- // such as the ':focusable' and ':tabbable' selectors.
- jquery_ui_add(array('ui.core'));
+ // Suppress the Admin Menu, if that module/fuction exists.
+ if (function_exists('admin_menu_suppress')) {
+ admin_menu_suppress();
+ }
- // Add javascript and stylesheets to the child page.
- $module_path = drupal_get_path('module', 'modalframe');
- drupal_add_css($module_path .'/css/child.css');
- drupal_add_js($module_path .'/js/child.js');
+ // Load downgraded version of jQuery (1.4.4 or newer -> 1.3.2) and jQuery UI
+ // (1.8.2 or newer -> 1.7.3) for compatability with modal frame API javascript.
+ $path = drupal_get_path('module', 'modalframe');
+ drupal_add_js($path . '/js/init_downgraded_jquery.js');
+ drupal_add_js($path . '/js/jquery_ui/ui/jquery-1.3.2.js');
+ drupal_add_js($path . '/js/jquery_ui/ui/ui.core.js');
if (module_exists('onbeforeunload')) {
onbeforeunload_add_js();
}
+ // Restore newer version of jQuery (1.3.2 -> 1.4.4 or newer).
+ drupal_add_js($path . '/js/restore_original_jquery.js');
+
+ // Add custom javascript code for Modal Frame API module.
+ drupal_add_js($path .'/js/child.js');
+ drupal_add_css($path .'/css/modalframe.child.css');
// Tell Drupal's theme system to use the Modal Frame template.
$GLOBALS['modalframe_page_template'] = TRUE;
@@ -264,7 +332,8 @@ function modalframe_close_dialog($args = NULL) {
// client side.
$child_js_settings = array(
'closeModal' => 1,
- 'statusMessages' => theme('status_messages'),
+// 'statusMessages' => theme('status_messages', array()),
+ 'statusMessages' => '',
'args' => (isset($args) && is_array($args) ? $args : array()),
);
drupal_add_js(array('modalFrameChild' => $child_js_settings), 'setting');