changeset 2:c076d54409cb

Popus: Version RF
author Franck Deroche <franck@defr.org>
date Fri, 31 Dec 2010 13:46:12 +0100
parents 76f9b43738f2
children
files .cvsignore .project patches/10-play_nice_with_views_exposed_filters.patch patches/2-careful-with-ahah.patch patches/3-allow-drupal-alter.diff patches/4-allow-form-to-opt-out-of-ajaxform.patch patches/5-ie7-compatibility.patch patches/6-deal-with-onUpdate-correctly.patch patches/7-allow-bad-response-message-translation.patch patches/8-facebook-skin-no-firebug-logging.patch patches/9-fix_warnings_php_fgm.patch patches/check-data-messages.diff popups-popup.tpl.php popups-skin.css popups.js popups.module skins/facebook/facebook.js
diffstat 17 files changed, 251 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/.cvsignore	Fri Dec 31 13:41:08 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-.project
--- a/.project	Fri Dec 31 13:41:08 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>popups62</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-	</buildSpec>
-	<natures>
-	</natures>
-</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/10-play_nice_with_views_exposed_filters.patch	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,14 @@
+Index: popups.js
+===================================================================
+--- popups.js	(révision 2378)
++++ popups.js	(copie de travail)
+@@ -805,6 +805,9 @@
+  * Do before the form in the popups is submitted.
+  */
+ Popups.beforeSubmit = function(formData, $form, options) {
++  if ($form.hasClass('views-processed') && $form.parents('div.view-filters').size()) {
++          return false;
++  }
+   Popups.removePopup(); // Remove just the dialog, but not the overlay.
+   Popups.addLoading();
+ };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/2-careful-with-ahah.patch	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,24 @@
+Index: popups.module
+===================================================================
+--- popups.module	(révision 337)
++++ popups.module	(copie de travail)
+@@ -192,6 +192,10 @@
+  */
+ function popups_add_popups($rules=NULL) { 
+   static $added = FALSE;
++  static $shouldAdd = NULL;
++  if (is_null($shouldAdd)) {
++    $shouldAdd = $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' || $_SESSION['page_override'];
++  }
+   $settings = array('popups' => array());
+   
+   if (is_array($rules)) {
+@@ -224,7 +228,7 @@
+       drupal_add_js( $settings, 'setting' );
+     }
+   }
+-  if (!$added) {
++  if (!$added && $shouldAdd) {
+     drupal_add_css(drupal_get_path('module', 'popups') .'/popups.css');
+     drupal_add_css(drupal_get_path('module', 'popups') .'/popups-skin.css');
+     drupal_add_js(drupal_get_path('module', 'popups') .'/popups.js');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/3-allow-drupal-alter.diff	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,13 @@
+Index: popups.module
+===================================================================
+--- popups.module	(révision 1196)
++++ popups.module	(copie de travail)
+@@ -153,6 +153,8 @@
+   
+   $popup_js = array();
+ 
++  // Allow modules to specifically alter the JS used in a popup.
++  drupal_alter('popups_js', $js);
+   if (module_exists('jquery_update')) {
+     $replacements = jquery_update_get_replacements();
+     $path = drupal_get_path('module', 'jquery_update') .'/replace/';
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/4-allow-form-to-opt-out-of-ajaxform.patch	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,13 @@
+Index: popups.js
+===================================================================
+--- popups.js	(révision 549)
++++ popups.js	(copie de travail)
+@@ -922,7 +922,7 @@
+   popup.refocus();
+ 
+   // If the popups contains a form, capture submits.
+-  var $form = $('form', popup.$popupBody());
++  var $form = $('form:not(.no-popup)', popup.$popupBody());
+   if ($form.length) {
+     $form.ajaxForm({   
+       dataType: 'json',   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/5-ie7-compatibility.patch	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,14 @@
+Index: popups.js
+===================================================================
+--- popups.js	(révision 555)
++++ popups.js	(copie de travail)
+@@ -604,7 +604,8 @@
+   if (popup) {
+ //    console.log('removing '+popup.id);
+     popup.$popup().remove();
+-    Popups.popupStack.splice(Popups.popupStack.indexOf(popup), 1); // Remove popup from stack.  Probably should rework into .pop()
++//    Popups.popupStack.splice(Popups.popupStack.indexOf(popup), 1); // Remove popup from stack.  Probably should rework into .pop()
++    Popups.popupStack.pop();
+   }  
+ //  else {
+ //    console.log("Popups.removePopup - there is no popup to remove.");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/6-deal-with-onUpdate-correctly.patch	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,23 @@
+Index: popups.js
+===================================================================
+--- popups.js	(révision 638)
++++ popups.js	(copie de travail)
+@@ -77,7 +77,7 @@
+  */
+ Popups.defaultOptions = {
+   doneTest: null, // null, *path*, *regexp*. how do we know when a multiform flow is done?
+-  updateMethod: 'ajax', // none, ajax, reload, *callback*
++  updateMethod: 'ajax', // none, ajax, reload, callback
+   updateSource: 'initial', // initial, final. Only used if updateMethod != none.
+   href: null, 
+   width: null, // Override the width specified in the css.
+@@ -86,7 +86,8 @@
+   reloadOnError: false, // Force the entire page to reload if the popup href is unaccessable.
+   noMessage: false, // Don't show drupal_set_message messages.   
+   skipDirtyCheck: false, // If true, this popup will not check for edits on the originating page.  
+-  hijackDestination: true // Use the destiination param to force a form submit to return to the originating page. 
++  hijackDestination: true, // Use the destiination param to force a form submit to return to the originating page. 
++  onUpdate: null // Callback used for the updateMethod: 'callback' type
+ };
+ 
+ // ***************************************************************************
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/7-allow-bad-response-message-translation.patch	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,13 @@
+Index: popups.js
+===================================================================
+--- popups.js	(révision 1439)
++++ popups.js	(copie de travail)
+@@ -934,7 +934,7 @@
+         Popups.formSuccess(popup, json);
+       },
+       error: function() {
+-        Popups.message("Bad Response form submission");
++        Popups.message(Drupal.t("Bad Response form submission"));
+       }
+     });
+   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/8-facebook-skin-no-firebug-logging.patch	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,27 @@
+Index: skins/facebook/facebook.js
+===================================================================
+--- skins/facebook/facebook.js	(révision 2066)
++++ skins/facebook/facebook.js	(copie de travail)
+@@ -3,7 +3,6 @@
+  * Custom theming for the popupsLoading.
+  */
+ Drupal.theme.popupLoading = function() {
+-console.log("Drupal.theme.popupLoading: Facebook");
+   var loading;
+   loading += '<div id="popups-loading">';
+   loading += '  <table>';
+@@ -30,7 +29,6 @@
+ };
+ 
+ Drupal.theme.popupTemplate = function (popupId) {
+-console.log("Drupal.theme.popupTemplate: Facebook");
+   var template;
+   template += '<div id="' + popupId + '" class ="popups-box">';
+   template += '  <table>';
+@@ -85,4 +83,4 @@
+       $popup.height($popup.height() + 20);
+     }
+   }
+-};
+\ No newline at end of file
++};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/9-fix_warnings_php_fgm.patch	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,13 @@
+Index: popups.module
+===================================================================
+--- popups.module	(révision 2370)
++++ popups.module	(copie de travail)
+@@ -295,7 +295,7 @@
+   static $added = FALSE;
+   static $shouldAdd = NULL;
+   if (is_null($shouldAdd)) {
+-    $shouldAdd = $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' || $_SESSION['page_override'];
++    $shouldAdd = !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' || $_SESSION['page_override'];
+   }
+   $settings = array('popups' => array());
+   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/check-data-messages.diff	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,13 @@
+Index: popups.js
+===================================================================
+--- popups.js	(révision 182)
++++ popups.js	(copie de travail)
+@@ -437,7 +437,7 @@
+     }
+     else { // Normal, targeted ajax, reload behavior.
+       // show messages in dialog and embed the results in the original page.
+-      var showMessage = data.messages.length && !options.noMessage;
++      var showMessage = data.messages && data.messages.length && !options.noMessage;
+       if (showMessage) {
+         Drupal.popups.message(data.messages);
+         if (!Drupal.settings.popups.popupFinalMessage) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/popups-popup.tpl.php	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,16 @@
+<?php
+// $Id: popups-popup.tpl.php,v 1.1.2.7 2009/03/05 20:05:44 starbow Exp $
+/**
+ * @file
+ */
+?>
+<div id="popups">
+  <div id="popups-title">
+    <div id="popups-close"><a href="#"><?php print t('Close') ?></a></div>
+    <div class="title">%title</div>
+    <div class="clear-block"></div>
+  </div>
+  <div id="popups-body">%body</div>
+  <div id="popups-buttons">%buttons</div>
+  <div id="popups-footer"></div>
+</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/popups-skin.css	Fri Dec 31 13:46:12 2010 +0100
@@ -0,0 +1,30 @@
+#popups {
+  border: 2px solid #EDF5FA;
+  -moz-border-radius: 8px;
+  -webkit-border-radius: 8px;
+  opacity: 0.9;
+}
+#popups-title {
+  border-bottom: 1px solid #b4d7f0;
+  background-color: #d4e7f3;
+  color: #455067;
+  margin-bottom: 0.25em;
+  padding: 0.25em;
+  -moz-border-radius-topleft: 5px;
+  -webkit-border-radius-topleft: 5px;
+}
+#popups-title #popups-close a {
+  color: red;  
+}
+#popups input {
+  margin: 0.1em;
+}
+#popups input[type="text"]:focus, #popups input[type="password"]:focus, #popups textarea:focus {
+  background-color: #FFA;
+  outline: thin solid grey;
+}
+a.popups-processed:after {
+  content: "\25A1";
+  vertical-align: super;
+  font-size: smaller; 
+}
\ No newline at end of file
--- a/popups.js	Fri Dec 31 13:41:08 2010 +0100
+++ b/popups.js	Fri Dec 31 13:46:12 2010 +0100
@@ -77,7 +77,7 @@
  */
 Popups.defaultOptions = {
   doneTest: null, // null, *path*, *regexp*. how do we know when a multiform flow is done?
-  updateMethod: 'ajax', // none, ajax, reload, *callback*
+  updateMethod: 'ajax', // none, ajax, reload, callback
   updateSource: 'initial', // initial, final. Only used if updateMethod != none.
   href: null, 
   width: null, // Override the width specified in the css.
@@ -86,7 +86,8 @@
   reloadOnError: false, // Force the entire page to reload if the popup href is unaccessable.
   noMessage: false, // Don't show drupal_set_message messages.   
   skipDirtyCheck: false, // If true, this popup will not check for edits on the originating page.  
-  hijackDestination: true // Use the destiination param to force a form submit to return to the originating page. 
+  hijackDestination: true, // Use the destiination param to force a form submit to return to the originating page. 
+  onUpdate: null // Callback used for the updateMethod: 'callback' type
 };
 
 // ***************************************************************************
@@ -604,7 +605,8 @@
   if (popup) {
 //    console.log('removing '+popup.id);
     popup.$popup().remove();
-    Popups.popupStack.splice(Popups.popupStack.indexOf(popup), 1); // Remove popup from stack.  Probably should rework into .pop()
+//    Popups.popupStack.splice(Popups.popupStack.indexOf(popup), 1); // Remove popup from stack.  Probably should rework into .pop()
+    Popups.popupStack.pop();
   }  
 //  else {
 //    console.log("Popups.removePopup - there is no popup to remove.");
@@ -759,7 +761,7 @@
 
   for (var i in scripts) {
     var src = scripts[i];
-    if (!$('script[src='+ src + ']').length && !Popups.addedJS[src]) {
+    if (!$("script[src='"+ src + "']").length && !Popups.addedJS[src]) {
       // Get the script from the server and execute it.
       $.ajax({ 
         type: 'GET',
@@ -803,6 +805,9 @@
  * Do before the form in the popups is submitted.
  */
 Popups.beforeSubmit = function(formData, $form, options) {
+  if ($form.hasClass('views-processed') && $form.parents('div.view-filters').size()) {
+          return false;
+  }
   Popups.removePopup(); // Remove just the dialog, but not the overlay.
   Popups.addLoading();
 };
@@ -922,17 +927,18 @@
   popup.refocus();
 
   // If the popups contains a form, capture submits.
-  var $form = $('form', popup.$popupBody());
+  var $form = $('form:not(.no-popup)', popup.$popupBody());
   if ($form.length) {
     $form.ajaxForm({   
       dataType: 'json',   
+      iframe: false,
       beforeSubmit: Popups.beforeSubmit,
       beforeSend: Popups.beforeSend,
       success: function(json, status) {
         Popups.formSuccess(popup, json);
       },
       error: function() {
-        Popups.message("Bad Response form submission");
+        Popups.message(Drupal.t("Bad Response form submission"));
       }
     });
   }
--- a/popups.module	Fri Dec 31 13:41:08 2010 +0100
+++ b/popups.module	Fri Dec 31 13:46:12 2010 +0100
@@ -153,6 +153,25 @@
   
   $popup_js = array();
 
+  // Allow modules to specifically alter the JS used in a popup.
+  drupal_alter('popups_js', $js);
+  if (module_exists('jquery_update')) {
+    $replacements = jquery_update_get_replacements();
+    $path = drupal_get_path('module', 'jquery_update') .'/replace/';
+    foreach($replacements as $type => $data) {
+      foreach($data as $src => $dst) {
+        $replacements[$type][$src] = $path . $dst;
+      }
+    }
+    // The behavior got called, so we're pretty sure that jQuery is already
+    // loaded.
+    unset($js['core']['misc/jquery.js']);
+    unset($js['core']['misc/drupal.js']);
+  }
+  else {
+    $replacements = array();
+  }
+
   foreach ($js as $type => $data) {
     if (!$data) continue;
     switch ($type) {
@@ -167,6 +186,7 @@
         break;
       default:
         foreach ($data as $path => $info) {
+          $path = isset($replacements[$type][$path]) ? $replacements[$type][$path] : $path;
           $popup_js[$type][$path] = '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .' src="'. base_path() . $path . $query_string ."\"></script>\n";
         }
         break;
@@ -273,6 +293,10 @@
  */
 function popups_add_popups($rules=NULL) { 
   static $added = FALSE;
+  static $shouldAdd = NULL;
+  if (is_null($shouldAdd)) {
+    $shouldAdd = !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' || $_SESSION['page_override'];
+  }
   $settings = array('popups' => array());
   
   if (is_array($rules)) {
@@ -289,7 +313,7 @@
       drupal_add_js( $settings, 'setting' );
     }
   }
-  if (!$added) {
+  if (!$added && $shouldAdd) {
     // Determing if we are showing the default theme or a custom theme.
     global $custom_theme;
     $theme = $custom_theme;
--- a/skins/facebook/facebook.js	Fri Dec 31 13:41:08 2010 +0100
+++ b/skins/facebook/facebook.js	Fri Dec 31 13:46:12 2010 +0100
@@ -3,7 +3,6 @@
  * Custom theming for the popupsLoading.
  */
 Drupal.theme.popupLoading = function() {
-console.log("Drupal.theme.popupLoading: Facebook");
   var loading;
   loading += '<div id="popups-loading">';
   loading += '  <table>';
@@ -30,7 +29,6 @@
 };
 
 Drupal.theme.popupTemplate = function (popupId) {
-console.log("Drupal.theme.popupTemplate: Facebook");
   var template;
   template += '<div id="' + popupId + '" class ="popups-box">';
   template += '  <table>';
@@ -85,4 +83,4 @@
       $popup.height($popup.height() + 20);
     }
   }
-};
\ No newline at end of file
+};