comparison popups.js @ 2:c076d54409cb

Popus: Version RF
author Franck Deroche <franck@defr.org>
date Fri, 31 Dec 2010 13:46:12 +0100
parents 76f9b43738f2
children
comparison
equal deleted inserted replaced
0:76f9b43738f2 2:c076d54409cb
75 * Each popup object gets it's own set of options. 75 * Each popup object gets it's own set of options.
76 * These are the defaults. 76 * These are the defaults.
77 */ 77 */
78 Popups.defaultOptions = { 78 Popups.defaultOptions = {
79 doneTest: null, // null, *path*, *regexp*. how do we know when a multiform flow is done? 79 doneTest: null, // null, *path*, *regexp*. how do we know when a multiform flow is done?
80 updateMethod: 'ajax', // none, ajax, reload, *callback* 80 updateMethod: 'ajax', // none, ajax, reload, callback
81 updateSource: 'initial', // initial, final. Only used if updateMethod != none. 81 updateSource: 'initial', // initial, final. Only used if updateMethod != none.
82 href: null, 82 href: null,
83 width: null, // Override the width specified in the css. 83 width: null, // Override the width specified in the css.
84 targetSelectors: null, // Hash of jQuery selectors that define the content to be swapped out. 84 targetSelectors: null, // Hash of jQuery selectors that define the content to be swapped out.
85 titleSelectors: null, // Array of jQuery selectors to place the new page title. 85 titleSelectors: null, // Array of jQuery selectors to place the new page title.
86 reloadOnError: false, // Force the entire page to reload if the popup href is unaccessable. 86 reloadOnError: false, // Force the entire page to reload if the popup href is unaccessable.
87 noMessage: false, // Don't show drupal_set_message messages. 87 noMessage: false, // Don't show drupal_set_message messages.
88 skipDirtyCheck: false, // If true, this popup will not check for edits on the originating page. 88 skipDirtyCheck: false, // If true, this popup will not check for edits on the originating page.
89 hijackDestination: true // Use the destiination param to force a form submit to return to the originating page. 89 hijackDestination: true, // Use the destiination param to force a form submit to return to the originating page.
90 onUpdate: null // Callback used for the updateMethod: 'callback' type
90 }; 91 };
91 92
92 // *************************************************************************** 93 // ***************************************************************************
93 // Popups.Popup Object ******************************************************* 94 // Popups.Popup Object *******************************************************
94 // *************************************************************************** 95 // ***************************************************************************
602 popup = Popups.activePopup(); 603 popup = Popups.activePopup();
603 } 604 }
604 if (popup) { 605 if (popup) {
605 // console.log('removing '+popup.id); 606 // console.log('removing '+popup.id);
606 popup.$popup().remove(); 607 popup.$popup().remove();
607 Popups.popupStack.splice(Popups.popupStack.indexOf(popup), 1); // Remove popup from stack. Probably should rework into .pop() 608 // Popups.popupStack.splice(Popups.popupStack.indexOf(popup), 1); // Remove popup from stack. Probably should rework into .pop()
609 Popups.popupStack.pop();
608 } 610 }
609 // else { 611 // else {
610 // console.log("Popups.removePopup - there is no popup to remove."); 612 // console.log("Popups.removePopup - there is no popup to remove.");
611 // } 613 // }
612 }; 614 };
757 // console.log('js.setting...'); 759 // console.log('js.setting...');
758 // console.log(js.setting); 760 // console.log(js.setting);
759 761
760 for (var i in scripts) { 762 for (var i in scripts) {
761 var src = scripts[i]; 763 var src = scripts[i];
762 if (!$('script[src='+ src + ']').length && !Popups.addedJS[src]) { 764 if (!$("script[src='"+ src + "']").length && !Popups.addedJS[src]) {
763 // Get the script from the server and execute it. 765 // Get the script from the server and execute it.
764 $.ajax({ 766 $.ajax({
765 type: 'GET', 767 type: 'GET',
766 url: src, 768 url: src,
767 dataType: 'script', 769 dataType: 'script',
801 803
802 /** 804 /**
803 * Do before the form in the popups is submitted. 805 * Do before the form in the popups is submitted.
804 */ 806 */
805 Popups.beforeSubmit = function(formData, $form, options) { 807 Popups.beforeSubmit = function(formData, $form, options) {
808 if ($form.hasClass('views-processed') && $form.parents('div.view-filters').size()) {
809 return false;
810 }
806 Popups.removePopup(); // Remove just the dialog, but not the overlay. 811 Popups.removePopup(); // Remove just the dialog, but not the overlay.
807 Popups.addLoading(); 812 Popups.addLoading();
808 }; 813 };
809 814
810 815
920 Drupal.attachBehaviors(popup.$popupBody()); 925 Drupal.attachBehaviors(popup.$popupBody());
921 // Adding collapse moves focus. 926 // Adding collapse moves focus.
922 popup.refocus(); 927 popup.refocus();
923 928
924 // If the popups contains a form, capture submits. 929 // If the popups contains a form, capture submits.
925 var $form = $('form', popup.$popupBody()); 930 var $form = $('form:not(.no-popup)', popup.$popupBody());
926 if ($form.length) { 931 if ($form.length) {
927 $form.ajaxForm({ 932 $form.ajaxForm({
928 dataType: 'json', 933 dataType: 'json',
934 iframe: false,
929 beforeSubmit: Popups.beforeSubmit, 935 beforeSubmit: Popups.beforeSubmit,
930 beforeSend: Popups.beforeSend, 936 beforeSend: Popups.beforeSend,
931 success: function(json, status) { 937 success: function(json, status) {
932 Popups.formSuccess(popup, json); 938 Popups.formSuccess(popup, json);
933 }, 939 },
934 error: function() { 940 error: function() {
935 Popups.message("Bad Response form submission"); 941 Popups.message(Drupal.t("Bad Response form submission"));
936 } 942 }
937 }); 943 });
938 } 944 }
939 return popup; 945 return popup;
940 }; 946 };