Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php |
— | — | @@ -162,8 +162,8 @@ |
163 | 163 | elseif ( $param_name == 'target' ) |
164 | 164 | $inTargetName = $value; |
165 | 165 | elseif ( $param_name == null && $value == 'popup' ) { |
166 | | - self::loadScriptsForFloatWindow( $parser ); |
167 | | - $popupClassString = 'class="floatlink"'; |
| 166 | + self::loadScriptsForPopupForm( $parser ); |
| 167 | + $popupClassString = 'class="popupformlink"'; |
168 | 168 | } |
169 | 169 | elseif ( $i == 0 ) |
170 | 170 | $inFormName = $param; |
— | — | @@ -257,8 +257,8 @@ |
258 | 258 | $inAutocompletionSource = $value; |
259 | 259 | $autocompletion_type = 'namespace'; |
260 | 260 | } elseif ( $param_name == null && $value == 'popup' ) { |
261 | | - self::loadScriptsForFloatWindow( $parser ); |
262 | | - $popupClassString = 'class="floatinput"'; |
| 261 | + self::loadScriptsForPopupForm( $parser ); |
| 262 | + $popupClassString = 'class="popupforminput"'; |
263 | 263 | } |
264 | 264 | elseif ( $i == 0 ) |
265 | 265 | $inFormName = $param; |
— | — | @@ -500,17 +500,15 @@ |
501 | 501 | return implode( $new_delimiter, $results_array ); |
502 | 502 | } |
503 | 503 | |
504 | | - static function loadScriptsForFloatWindow ( &$parser ) { |
| 504 | + static function loadScriptsForPopupForm ( &$parser ) { |
505 | 505 | |
506 | 506 | global $sfgScriptPath; |
507 | 507 | |
508 | | - wfDebug( "loadScriptsForFloatWindow \n" ); |
509 | | - |
510 | 508 | if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
511 | 509 | |
512 | 510 | // on MW 1.17+ just request the ResourceLoader to include modules |
513 | 511 | |
514 | | - $parser->getOutput()->addModules( 'ext.semanticforms.floatedit' ); |
| 512 | + $parser->getOutput()->addModules( 'ext.semanticforms.popupformedit' ); |
515 | 513 | |
516 | 514 | } else { |
517 | 515 | |
— | — | @@ -524,13 +522,13 @@ |
525 | 523 | // load extensions JavaScript |
526 | 524 | $parser->getOutput()->addHeadItem( |
527 | 525 | '<script type="text/javascript" src="' . $sfgScriptPath |
528 | | - . '/libs/SF_floatedit.js"></script> ' . "\n" |
| 526 | + . '/libs/SF_popupform.js"></script> ' . "\n" |
529 | 527 | ); |
530 | 528 | |
531 | 529 | // load extensions style sheet |
532 | 530 | $parser->getOutput()->addHeadItem( |
533 | 531 | '<link rel="stylesheet" href="' . $sfgScriptPath |
534 | | - . '/skins/SF_floatedit.css"/> ' . "\n" |
| 532 | + . '/skins/SF_popupform.css"/> ' . "\n" |
535 | 533 | ); |
536 | 534 | |
537 | 535 | $loaded = true; |
Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php |
— | — | @@ -147,9 +147,9 @@ |
148 | 148 | 'ext.semanticforms.autogrow' => $sfgResourceTemplate + array( |
149 | 149 | 'scripts' => 'libs/SF_autogrow.js', |
150 | 150 | ), |
151 | | - 'ext.semanticforms.floatedit' => $sfgResourceTemplate + array( |
152 | | - 'scripts' => 'libs/SF_floatedit.js', |
153 | | - 'styles' => 'skins/SF_floatedit.css', |
| 151 | + 'ext.semanticforms.popupformedit' => $sfgResourceTemplate + array( |
| 152 | + 'scripts' => 'libs/SF_popupform.js', |
| 153 | + 'styles' => 'skins/SF_popupform.css', |
154 | 154 | 'dependencies' => array( 'jquery' ), |
155 | 155 | ), |
156 | 156 | ); |
Index: trunk/extensions/SemanticForms/skins/SF_floatedit.css |
— | — | @@ -1,93 +0,0 @@ |
2 | | -/* |
3 | | - Document : floatedit.css |
4 | | - Created on : 05.01.2011, 20:56:24 |
5 | | - Author : fox |
6 | | - Description: |
7 | | - Purpose of the stylesheet follows. |
8 | | -*/ |
9 | | - |
10 | | -/* |
11 | | - TODO customize this sample style |
12 | | - Syntax recommendation http://www.w3.org/TR/REC-CSS2/ |
13 | | -*/ |
14 | | - |
15 | | -div.floatlink, div.floatinput, |
16 | | -div.floatlink form, div.floatinput form { |
17 | | - display: inline; |
18 | | -} |
19 | | - |
20 | | -div.floatedit-wrapper { |
21 | | - position: fixed; |
22 | | - left: 0px; |
23 | | - top: 0px; |
24 | | - height: 100%; |
25 | | - width: 100%; |
26 | | -} |
27 | | - |
28 | | -div.floatedit-background { |
29 | | - left: 0px; |
30 | | - top: 0px; |
31 | | - height: 100%; |
32 | | - width: 100%; |
33 | | - background: black; |
34 | | - z-index: 4; |
35 | | - |
36 | | -} |
37 | | - |
38 | | -div.floatedit-anchor { |
39 | | - position: fixed; |
40 | | - left: 50%; |
41 | | - top: 50%; |
42 | | - width: 0; |
43 | | - height: 0; |
44 | | - z-index: 6; |
45 | | -} |
46 | | - |
47 | | -div.floatedit-container { |
48 | | - position: absolute; |
49 | | - background-color: white; |
50 | | - border: 2px solid midnightblue; |
51 | | -} |
52 | | - |
53 | | -iframe.floatedit-innerdocument { |
54 | | - width: 100%; |
55 | | - height: 100%; |
56 | | - border: none; |
57 | | -} |
58 | | - |
59 | | -div.floatedit-close { |
60 | | - position: absolute; |
61 | | - right: -25px; |
62 | | - top: -25px; |
63 | | - width: 30px; |
64 | | - height: 30px; |
65 | | - cursor: pointer; |
66 | | - background-image: url('../skins/fancy_close.png'); |
67 | | -} |
68 | | - |
69 | | -div.floatedit-loading { |
70 | | - position: fixed; |
71 | | - left: 50%; |
72 | | - top: 50%; |
73 | | - z-index: 5; |
74 | | -} |
75 | | - |
76 | | -div.floatedit-loadingbg { |
77 | | - position: absolute; |
78 | | - left: -63px; |
79 | | - top: -63px; |
80 | | - width: 127px; |
81 | | - height: 127px; |
82 | | - background-color: transparent; |
83 | | - background-image: url('../skins/loadingbg.png'); |
84 | | -} |
85 | | - |
86 | | -div.floatedit-loadingfg { |
87 | | - position: absolute; |
88 | | - left: -15px; |
89 | | - top: -15px; |
90 | | - width: 30px; |
91 | | - height: 30px; |
92 | | - background-color: transparent; |
93 | | - background-image: url('../skins/loading.gif'); |
94 | | -} |
Index: trunk/extensions/SemanticForms/skins/SF_popupform.css |
— | — | @@ -0,0 +1,83 @@ |
| 2 | +/** |
| 3 | + * Styles for popup forms |
| 4 | + */ |
| 5 | + |
| 6 | +.popupformlink, .popupforminput { |
| 7 | + display: inline; |
| 8 | +} |
| 9 | + |
| 10 | +div.popupform-wrapper { |
| 11 | + position: fixed; |
| 12 | + left: 0px; |
| 13 | + top: 0px; |
| 14 | + height: 100%; |
| 15 | + width: 100%; |
| 16 | +} |
| 17 | + |
| 18 | +div.popupform-background { |
| 19 | + left: 0px; |
| 20 | + top: 0px; |
| 21 | + height: 100%; |
| 22 | + width: 100%; |
| 23 | + background: black; |
| 24 | + z-index: 4; |
| 25 | + |
| 26 | +} |
| 27 | + |
| 28 | +div.popupform-anchor { |
| 29 | + position: fixed; |
| 30 | + left: 50%; |
| 31 | + top: 50%; |
| 32 | + width: 0; |
| 33 | + height: 0; |
| 34 | + z-index: 6; |
| 35 | +} |
| 36 | + |
| 37 | +div.popupform-container { |
| 38 | + position: absolute; |
| 39 | + background-color: white; |
| 40 | + border: 2px solid midnightblue; |
| 41 | +} |
| 42 | + |
| 43 | +iframe.popupform-innerdocument { |
| 44 | + width: 100%; |
| 45 | + height: 100%; |
| 46 | + border: none; |
| 47 | +} |
| 48 | + |
| 49 | +div.popupform-close { |
| 50 | + position: absolute; |
| 51 | + right: -25px; |
| 52 | + top: -25px; |
| 53 | + width: 30px; |
| 54 | + height: 30px; |
| 55 | + cursor: pointer; |
| 56 | + background-image: url('../skins/fancy_close.png'); |
| 57 | +} |
| 58 | + |
| 59 | +div.popupform-loading { |
| 60 | + position: fixed; |
| 61 | + left: 50%; |
| 62 | + top: 50%; |
| 63 | + z-index: 5; |
| 64 | +} |
| 65 | + |
| 66 | +div.popupform-loadingbg { |
| 67 | + position: absolute; |
| 68 | + left: -63px; |
| 69 | + top: -63px; |
| 70 | + width: 127px; |
| 71 | + height: 127px; |
| 72 | + background-color: transparent; |
| 73 | + background-image: url('../skins/loadingbg.png'); |
| 74 | +} |
| 75 | + |
| 76 | +div.popupform-loadingfg { |
| 77 | + position: absolute; |
| 78 | + left: -15px; |
| 79 | + top: -15px; |
| 80 | + width: 30px; |
| 81 | + height: 30px; |
| 82 | + background-color: transparent; |
| 83 | + background-image: url('../skins/loading.gif'); |
| 84 | +} |
Property changes on: trunk/extensions/SemanticForms/skins/SF_popupform.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 85 | + native |
Index: trunk/extensions/SemanticForms/libs/SF_floatedit.js |
— | — | @@ -1,588 +0,0 @@ |
2 | | -/** |
3 | | - * Javascript code to be used with extension FloatEdit. |
4 | | - * |
5 | | - * @author Stephan Gambke |
6 | | - * @version 0.1 alpha |
7 | | - * |
8 | | - */ |
9 | | - |
10 | | -// initialise |
11 | | -jQuery(function(){ |
12 | | - |
13 | | - // register eventhandlers on 'edit' links and buttons |
14 | | - |
15 | | - // register formlink with link |
16 | | - jQuery('a.floatlink').click(function(evt){ |
17 | | - return ext.floatedit.handleFloatLink( evt.target.getAttribute('href'), this ); |
18 | | - }); |
19 | | - |
20 | | - // register formlink with button |
21 | | - jQuery( 'form.floatlink[method!="post"] input' ).each(function() { |
22 | | - |
23 | | - var input = jQuery(this); |
24 | | - |
25 | | - // Yay, IE 4 lines, FF 0 lines |
26 | | - var target = String (this.getAttribute("onclick")); |
27 | | - var start = target.indexOf("window.location.href='") + 22; |
28 | | - var stop = target.indexOf("'", start); |
29 | | - target = target.substring( start, stop ); |
30 | | - |
31 | | - input.data( "target", target ) // extract link target from event handler |
32 | | - .attr( "onclick", null ) // and remove event handler |
33 | | - .click( function( evt ){ |
34 | | - return ext.floatedit.handleFloatLink( jQuery( this ).data( "target" ), this); |
35 | | - }); |
36 | | - }) |
37 | | - |
38 | | - // register formlink with post button |
39 | | - jQuery( 'form.floatlink[method="post"]' ).submit(function(evt){ |
40 | | - return ext.floatedit.handleFloatLink( this.getAttribute( 'action' ), this ); |
41 | | - }); |
42 | | - |
43 | | - |
44 | | - // register forminput |
45 | | - jQuery( 'form.floatinput' ).submit(function(evt){ |
46 | | - return ext.floatedit.handleFloatInput( this.getAttribute( 'action' ), this ); |
47 | | - }); |
48 | | - |
49 | | -}); |
50 | | - |
51 | | -// create ext if it does not exist yet |
52 | | -if ( typeof( window[ 'ext' ] ) == "undefined" ) { |
53 | | - window[ 'ext' ] = {}; |
54 | | -} |
55 | | - |
56 | | -window.ext.floatedit = new function() { |
57 | | - |
58 | | - var wrapper; |
59 | | - var background; |
60 | | - var container; |
61 | | - var iframe; |
62 | | - var waitIndicator; |
63 | | - var instance = 0; |
64 | | - |
65 | | - var doc; |
66 | | - var docWidth; |
67 | | - var docHeight; |
68 | | - |
69 | | - var brokenBrowser, brokenChrome; |
70 | | - |
71 | | - function handleFloatInput( ptarget, elem ) { |
72 | | - |
73 | | - showForm(); |
74 | | - |
75 | | - iframe.one( 'load', function(){ |
76 | | - // attach event handler to iframe |
77 | | - iframe.bind( 'load', handleLoadFrame ); |
78 | | - return false; |
79 | | - }) |
80 | | - |
81 | | - elem.target = 'floatedit-iframe' + instance; |
82 | | - return true; |
83 | | - } |
84 | | - |
85 | | - function handleFloatLink( ptarget, elem ) { |
86 | | - |
87 | | - showForm(); |
88 | | - |
89 | | - // attach event handler to iframe |
90 | | - iframe.bind( 'load', handleLoadFrame ); |
91 | | - |
92 | | - if ( elem.tagName == 'FORM' ) { |
93 | | - |
94 | | - elem.target = 'floatedit-iframe' + instance; |
95 | | - return true; |
96 | | - |
97 | | - } else { |
98 | | - |
99 | | - var delim = ptarget.indexOf( '?' ); |
100 | | - var form = document.createElement("form"); |
101 | | - |
102 | | - form.target = 'floatedit-iframe' + instance; |
103 | | - |
104 | | - // Do we have parameters? |
105 | | - if ( delim > 0 ) { |
106 | | - form.action = ptarget.substr( 0, delim ); |
107 | | - var params = String( ptarget.substr( delim + 1 ) ).split("&"); |
108 | | - for ( var i = 0; i < params.length; ++i ) { |
109 | | - |
110 | | - var input = document.createElement("input"); |
111 | | - var param = String( params[i] ).split('='); |
112 | | - input.type = 'hidden'; |
113 | | - input.name = decodeURIComponent( param[0] ); |
114 | | - input.value = decodeURIComponent( param[1] ); |
115 | | - form.appendChild( input ); |
116 | | - |
117 | | - } |
118 | | - } else { |
119 | | - form.action = ptarget; |
120 | | - } |
121 | | - |
122 | | - document.getElementsByTagName('body')[0].appendChild(form); |
123 | | - form.submit(); |
124 | | - document.getElementsByTagName('body')[0].removeChild(form); |
125 | | - |
126 | | - return false; |
127 | | - } |
128 | | - } |
129 | | - |
130 | | - function showForm() { |
131 | | - |
132 | | - instance++; |
133 | | - |
134 | | - brokenChrome = |
135 | | - ( navigator.userAgent.indexOf("Chrome") >= 0 && |
136 | | - navigator.platform.indexOf("Linux x86_64") >= 0 ); |
137 | | - |
138 | | - brokenBrowser= jQuery.browser.msie ||brokenChrome; |
139 | | - |
140 | | - wrapper = jQuery( "<div class='floatedit-wrapper' >" ); |
141 | | - background = jQuery( "<div class='floatedit-background' >" ); |
142 | | - |
143 | | - var waitIndicatorWrapper = jQuery( "<div class='floatedit-loading'>" ); |
144 | | - |
145 | | - waitIndicator = jQuery( "<div class='floatedit-loadingbg'></div><div class='floatedit-loadingfg'></div>" ); |
146 | | - |
147 | | - var anchor = jQuery( "<div class='floatedit-anchor' >" ); |
148 | | - |
149 | | - container = jQuery( "<div class='floatedit-container' >" ); |
150 | | - iframe = jQuery( "<iframe class='floatedit-innerdocument' name='floatedit-iframe" + instance + "' id='floatedit-iframe" + instance + "' >"); |
151 | | - |
152 | | - var closeBtn = jQuery( "<div class='floatedit-close'></div> " ); |
153 | | - |
154 | | - // initially hide background and waitIndicator |
155 | | - if (brokenChrome) background.css("background", "transparent"); |
156 | | - else background.css("opacity", 0.0); |
157 | | - |
158 | | - waitIndicator.hide(); |
159 | | - container.hide() |
160 | | - |
161 | | - // insert background and wait indicator into wrapper and all into document |
162 | | - waitIndicatorWrapper |
163 | | - .append( waitIndicator ); |
164 | | - |
165 | | - container |
166 | | - .append( closeBtn ) |
167 | | - .append( iframe ); |
168 | | - |
169 | | - anchor |
170 | | - .append(container); |
171 | | - |
172 | | - wrapper |
173 | | - .append( background ) |
174 | | - .append( waitIndicatorWrapper ) |
175 | | - .append( anchor ) |
176 | | - .appendTo( "body" ); |
177 | | - |
178 | | - // fade background in |
179 | | - if ( !brokenChrome ) background.fadeTo( 400, 0.3 ); |
180 | | - fadeIn( waitIndicator ); |
181 | | - |
182 | | - // attach event handler to close button |
183 | | - closeBtn.click( handleCloseFrame ); |
184 | | - |
185 | | - // TODO: wrapper must be set to max z-index; |
186 | | - |
187 | | - } |
188 | | - |
189 | | - function handleLoadFrame( event ){ |
190 | | - |
191 | | - var iframe = jQuery( event.target ); |
192 | | - var iframecontents = iframe.contents(); |
193 | | - |
194 | | - if ( brokenChrome ) container[0].style.visibility = "hidden"; |
195 | | - else container[0].style.opacity = 0; |
196 | | - |
197 | | - container.show(); |
198 | | - |
199 | | - // GuMaxDD has #content but keeps headlines in #gumax-content-body |
200 | | - var content = iframecontents.find("#gumax-content-body"); |
201 | | - |
202 | | - // normal skins use #content (e.g. Vector, Monobook) |
203 | | - if ( content.length == 0 ) content = iframecontents.find("#content"); |
204 | | - |
205 | | - // some skins use #mw_content (e.g. Modern) |
206 | | - if ( content.length == 0 ) content = iframecontents.find("#mw_content"); |
207 | | - |
208 | | - // this is not a normal MW page (or it uses an unknown skin) |
209 | | - if ( content.length == 0 ) content = iframecontents.find("body"); |
210 | | - |
211 | | - // the huge left margin looks ugly in Vector, reduce it |
212 | | - // (How does this look for other skins?) |
213 | | - var siblings = content |
214 | | - .css( { |
215 | | - margin: 0, |
216 | | - padding: "1em", |
217 | | - width: "auto", |
218 | | - height: "auto", |
219 | | - minWidth: "0px", |
220 | | - minHeight:"0px" |
221 | | - } ) |
222 | | - .parents().css( { |
223 | | - margin: 0, |
224 | | - padding: 0, |
225 | | - width: "auto", |
226 | | - height: "auto", |
227 | | - minWidth: "0px", |
228 | | - minHeight:"0px" |
229 | | - }) |
230 | | - .andSelf().siblings(); |
231 | | - |
232 | | - if ( jQuery.browser.msie && jQuery.browser.version < "6" ) { |
233 | | - siblings.hide(); |
234 | | - } else { |
235 | | - siblings |
236 | | - .each( function(){ |
237 | | - var elem = jQuery(this); |
238 | | -// if ( ( elem.outerWidth(true) > 0 && elem.outerHeight(true) > 0 ) && |
239 | | - if ( getStyle(this, "display") != "none" |
240 | | - && ( getStyle( this, "width") != "0px" || getStyle( this, "height") != "0px" ) |
241 | | - && ! ( |
242 | | - ( this.offsetLeft + elem.outerWidth(true) < 0 ) || // left of document |
243 | | - ( this.offsetTop + elem.outerHeight(true) < 0 ) || // above document |
244 | | - ( this.offsetLeft > 100000 ) || // right of document |
245 | | - ( this.offsetTop > 100000 ) // below document |
246 | | - ) |
247 | | - ) { |
248 | | - |
249 | | - jQuery(this).hide(); |
250 | | - // css({ |
251 | | - // height : "0px", |
252 | | - // width : "0px", |
253 | | - // minWidth : "0px", |
254 | | - // minHeight : "0px", |
255 | | - // margin : "0px", |
256 | | - // padding : "0px" |
257 | | - // border : "none", |
258 | | - // overflow: "hidden" |
259 | | - // //position: "static" |
260 | | - // }); |
261 | | - } |
262 | | - if ( ( this.offsetLeft + elem.outerWidth() < 0 ) || |
263 | | - ( this.offsetTop + elem.outerHeight() < 0 ) |
264 | | - ) { |
265 | | - this.style.left = (-elem.outerWidth(true)) + "px"; |
266 | | - this.style.top = (-elem.outerHeight(true)) + "px"; |
267 | | - } |
268 | | - }); |
269 | | - //.children().css("position", "static"); |
270 | | - } |
271 | | - |
272 | | - // find content document |
273 | | - doc = iframe[0].contentWindow || iframe[0].contentDocument; |
274 | | - |
275 | | - if (doc.document) { |
276 | | - doc = doc.document; |
277 | | - } |
278 | | - |
279 | | - // first try if the content enforces its dimensions (e.g. GuMaxDD) |
280 | | - docWidth = content.outerWidth(true); |
281 | | - docHeight = content.outerHeight(true); |
282 | | - |
283 | | - // then try if it grows to its dimensions given enough space (e.g. Vector) |
284 | | - var origPos = content[0].style.position; |
285 | | - content[0].style.position = "fixed"; |
286 | | - |
287 | | - if ( content.outerWidth(true) > docWidth || content.outerHeight(true) > docHeight ) { |
288 | | - docWidth = content.outerWidth(true); |
289 | | - docHeight = content.outerHeight(true); |
290 | | - } |
291 | | - |
292 | | - content[0].style.position = origPos; |
293 | | - |
294 | | - // default for broken browsers |
295 | | - if ( docWidth == 0 || docHeight == 0 ) { |
296 | | - |
297 | | - docWidth = jQuery(window).width(); |
298 | | - docHeight = jQuery(window).height(); |
299 | | - |
300 | | - } |
301 | | - |
302 | | - |
303 | | - // adjust frame size to dimensions just calculated |
304 | | - adjustFrameSize(); |
305 | | - |
306 | | - // and attach event handler to adjust frame size every time the window |
307 | | - // size changes |
308 | | - jQuery( window ).resize( adjustFrameSize ); |
309 | | - |
310 | | - var form = content.find("#sfForm"); |
311 | | - var innerwdw = window.frames['floatedit-iframe' + instance]; |
312 | | - |
313 | | - if (form.length > 0) { |
314 | | - |
315 | | - var submitok = false; |
316 | | - var innersubmitprocessed = false; |
317 | | - |
318 | | - // catch form submit event |
319 | | - form |
320 | | - .bind( "submit", function( event ){ |
321 | | - |
322 | | - var interval = setInterval(function(){ |
323 | | - |
324 | | - if ( innersubmitprocessed ) { |
325 | | - clearInterval( interval ); |
326 | | - innersubmitprocessed = false; |
327 | | - if ( submitok ) handleSubmitData( event ); |
328 | | - } |
329 | | - |
330 | | - }, 10) |
331 | | - event.stopPropagation(); |
332 | | - return false; |
333 | | - |
334 | | - }); |
335 | | - |
336 | | - // catch inner form submit event |
337 | | - innerwdw.jQuery(form[0]) |
338 | | - .bind( "submit", function( event ) { |
339 | | - submitok = event.result; |
340 | | - innersubmitprocessed = true; |
341 | | - return false; |
342 | | - }) |
343 | | - } |
344 | | - |
345 | | - innerwdw.jQuery( innerwdw[0] ).unload(function (event) { |
346 | | - return false; |
347 | | - }); |
348 | | - |
349 | | - // find all links. Have to use inner jQuery so event.result below |
350 | | - // reflects the result of inner event handlers. We (hopefully) come last |
351 | | - // in the chain of event handlers as we only attach when the frame is |
352 | | - // already completely loaded, i.e. every inner event handler is already |
353 | | - // attached. |
354 | | - var allLinks = innerwdw.jQuery("a[href]"); |
355 | | - |
356 | | - // catch 'Cancel'-Link (and other 'back'-links) and close frame instead of going back |
357 | | - var backlinks = allLinks.filter('a[href="javascript:history.go(-1);"]'); |
358 | | - backlinks.click(handleCloseFrame); |
359 | | - |
360 | | - // promote any other links to open in main window, prevent nested browsing |
361 | | - allLinks |
362 | | - .not('a[href*="javascript:"]') // scripted links |
363 | | - .not('a[target]') // targeted links |
364 | | - .not('a[href^="#"]') // local links |
365 | | - .click(function(event){ |
366 | | - if ( event.result != false ) { // if not already caught by somebody else |
367 | | - closeFrameAndFollowLink( event.target.getAttribute('href') ) |
368 | | - } |
369 | | - return false; |
370 | | - }); |
371 | | - |
372 | | - // finally show the frame |
373 | | - fadeOut ( waitIndicator, function(){ |
374 | | - fadeTo( container, 400, 1 ); |
375 | | - }); |
376 | | - |
377 | | - return false; |
378 | | - |
379 | | - } |
380 | | - |
381 | | - function handleSubmitData( event ){ |
382 | | - |
383 | | - fadeOut( container, function() { |
384 | | - fadeIn( waitIndicator ); |
385 | | - }); |
386 | | - |
387 | | - var form = jQuery( event.target ); |
388 | | - var formdata = form.serialize() + "&wpSave=" + escape(form.find("#wpSave").attr("value")); |
389 | | - |
390 | | - // Send form data off. SF will send back a fake edit page |
391 | | - // |
392 | | - // Normally we should check this.action first and only if it is empty |
393 | | - // revert to this.ownerDocument.URL. Tough luck, IE does not return an |
394 | | - // empty action but fills in some bogus |
395 | | - jQuery.post( event.target.ownerDocument.URL , formdata, handleInnerSubmit); |
396 | | - |
397 | | - return false; |
398 | | - |
399 | | - |
400 | | - function handleInnerSubmit ( returnedData, textStatus, XMLHttpRequest ) { |
401 | | - |
402 | | - |
403 | | - // find form in fake edit page |
404 | | - var innerform = jQuery("<div>" + returnedData + "</div>").find("form"); |
405 | | - |
406 | | - // check if we got an error page |
407 | | - if ( innerform.length == 0 ) { |
408 | | - |
409 | | - form.unbind( event ); |
410 | | - |
411 | | - var iframe = container.find("iframe"); |
412 | | - var doc = iframe[0].contentWindow || iframe[0].contentDocument; |
413 | | - if (doc.document) { |
414 | | - doc = doc.document; |
415 | | - } |
416 | | - |
417 | | - doc.open(); |
418 | | - doc.write(returnedData); |
419 | | - doc.close(); |
420 | | - |
421 | | - return false; |
422 | | - } |
423 | | - |
424 | | - // Send the form data off, we do not care for the returned data |
425 | | - var innerformdata = innerform.serialize(); |
426 | | - jQuery.post( innerform.attr("action"), innerformdata ); |
427 | | - |
428 | | - // build new url for outer page (we have to ask for a purge) |
429 | | - |
430 | | - var url = location.href; |
431 | | - |
432 | | - // does a querystring exist? |
433 | | - var start = url.indexOf("action="); |
434 | | - |
435 | | - if ( start >= 0 ) { |
436 | | - |
437 | | - var stop = url.indexOf("&", start); |
438 | | - |
439 | | - if ( stop >= 0 ) url = url.substr( 0, start - 1 ) + url.substr(stop + 1); |
440 | | - else url = url.substr( 0, start - 1 ); |
441 | | - |
442 | | - } |
443 | | - |
444 | | - var form = jQuery('<form action="' + url + '" method="POST"><input type="hidden" name="action" value="purge"></form>') |
445 | | - .appendTo('body'); |
446 | | - |
447 | | - form |
448 | | - .submit(); |
449 | | - |
450 | | - fadeOut( container, function(){ |
451 | | - fadeIn( waitIndicator ); |
452 | | - }); |
453 | | - |
454 | | - return false; |
455 | | - |
456 | | - } |
457 | | - } |
458 | | - |
459 | | - function adjustFrameSize() { |
460 | | - |
461 | | - var availW = jQuery(window).width(); |
462 | | - var availH = jQuery(window).height(); |
463 | | - |
464 | | - var w, h; |
465 | | - |
466 | | - // Standard max height/width is 80% of viewport, but we will allow |
467 | | - // up to 85% to avoid scrollbars with nearly nothing to scroll |
468 | | - if ( docWidth > availW * .85 || docHeight > availH * .85 ) { |
469 | | - |
470 | | - iframe[0].style.overflow = "auto"; |
471 | | - |
472 | | - if ( docWidth > availW * .85 ) { |
473 | | - w = ( availW * .8 ); |
474 | | - } else { |
475 | | - w = docWidth + 20; |
476 | | - } |
477 | | - |
478 | | - if ( docHeight > availH * .85 ) { |
479 | | - h = ( availH * .8 ); |
480 | | - } else { |
481 | | - h = docHeight + 20; |
482 | | - } |
483 | | - |
484 | | - } else { |
485 | | - iframe[0].style.overflow = "hidden"; |
486 | | - w = docWidth; |
487 | | - h = docHeight; |
488 | | - } |
489 | | - |
490 | | - with ( container[0].style ) { |
491 | | - width = ( w ) + "px"; |
492 | | - height = ( h ) + "px"; |
493 | | - top = (( - h ) / 2) + "px"; |
494 | | - left = (( - w ) / 2) + "px"; |
495 | | - } |
496 | | - |
497 | | - } |
498 | | - |
499 | | - function closeFrameAndFollowLink( link ){ |
500 | | - |
501 | | - fadeOut( container, function(){ |
502 | | - fadeIn ( waitIndicator ); |
503 | | - window.location.href = link; |
504 | | - }); |
505 | | - |
506 | | - } |
507 | | - |
508 | | - function handleCloseFrame( event ){ |
509 | | - |
510 | | - jQuery(window).unbind( "resize", adjustFrameSize ) |
511 | | - |
512 | | - fadeOut( container, function(){ |
513 | | - background.fadeOut( function(){ |
514 | | - wrapper.remove(); |
515 | | - }); |
516 | | - }); |
517 | | - return false; |
518 | | - } |
519 | | - |
520 | | - // Saw it on http://robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element |
521 | | - // and liked it |
522 | | - function getStyle(oElm, strCssRule){ |
523 | | - var strValue = ""; |
524 | | - if(document.defaultView && document.defaultView.getComputedStyle){ |
525 | | - strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); |
526 | | - } |
527 | | - else if(oElm.currentStyle){ |
528 | | - strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){ |
529 | | - return p1.toUpperCase(); |
530 | | - }); |
531 | | - strValue = oElm.currentStyle[strCssRule]; |
532 | | - } |
533 | | - return strValue; |
534 | | - } |
535 | | - |
536 | | - function fadeIn(elem, callback ) { |
537 | | - // no fading for broken browsers |
538 | | - if ( brokenBrowser ){ |
539 | | - |
540 | | - elem.show(); |
541 | | - if ( callback ) callback(); |
542 | | - |
543 | | - } else { |
544 | | - |
545 | | - // what an ugly hack |
546 | | - if ( elem === waitIndicator ) elem.fadeIn( 200, callback ); |
547 | | - else elem.fadeIn( callback ); |
548 | | - |
549 | | - } |
550 | | - } |
551 | | - |
552 | | - function fadeOut(elem, callback ) { |
553 | | - // no fading for broken browsers |
554 | | - if ( brokenBrowser ){ |
555 | | - |
556 | | - elem.hide(); |
557 | | - if ( callback ) callback(); |
558 | | - |
559 | | - } else { |
560 | | - |
561 | | - // what an ugly hack |
562 | | - if ( elem === waitIndicator ) elem.fadeOut( 200, callback ); |
563 | | - else elem.fadeOut( callback ); |
564 | | - |
565 | | - } |
566 | | - } |
567 | | - |
568 | | - function fadeTo(elem, time, target, callback) { |
569 | | - // no fading for broken browsers |
570 | | - if ( brokenBrowser ){ |
571 | | - |
572 | | - if (target > 0) elem[0].style.visibility = "visible"; |
573 | | - else elem[0].style.visibility = "hidden"; |
574 | | - |
575 | | - if ( callback ) callback(); |
576 | | - |
577 | | - } else { |
578 | | - |
579 | | - elem.fadeTo(time, target, callback); |
580 | | - |
581 | | - } |
582 | | - |
583 | | - } |
584 | | - |
585 | | - // export public funcitons |
586 | | - this.handleFloatInput = handleFloatInput; |
587 | | - this.handleFloatLink = handleFloatLink; |
588 | | - |
589 | | -} |
\ No newline at end of file |
Index: trunk/extensions/SemanticForms/libs/SF_popupform.js |
— | — | @@ -0,0 +1,587 @@ |
| 2 | +/** |
| 3 | + * Javascript code to be used with extension SemanticForms for popup forms. |
| 4 | + * |
| 5 | + * @author Stephan Gambke |
| 6 | + * |
| 7 | + */ |
| 8 | + |
| 9 | +// initialise |
| 10 | +jQuery(function(){ |
| 11 | + |
| 12 | + // register eventhandlers on 'edit' links and buttons |
| 13 | + |
| 14 | + // register formlink with link |
| 15 | + jQuery('a.popupformlink').click(function(evt){ |
| 16 | + return ext.popupform.handlePopupFormLink( evt.target.getAttribute('href'), this ); |
| 17 | + }); |
| 18 | + |
| 19 | + // register formlink with button |
| 20 | + jQuery( 'form.popupformlink[method!="post"] input' ).each(function() { |
| 21 | + |
| 22 | + var input = jQuery(this); |
| 23 | + |
| 24 | + // Yay, IE 4 lines, FF 0 lines |
| 25 | + var target = String (this.getAttribute("onclick")); |
| 26 | + var start = target.indexOf("window.location.href='") + 22; |
| 27 | + var stop = target.indexOf("'", start); |
| 28 | + target = target.substring( start, stop ); |
| 29 | + |
| 30 | + input.data( "target", target ) // extract link target from event handler |
| 31 | + .attr( "onclick", null ) // and remove event handler |
| 32 | + .click( function( evt ){ |
| 33 | + return ext.popupform.handlePopupFormLink( jQuery( this ).data( "target" ), this); |
| 34 | + }); |
| 35 | + }) |
| 36 | + |
| 37 | + // register formlink with post button |
| 38 | + jQuery( 'form.popupformlink[method="post"]' ).submit(function(evt){ |
| 39 | + return ext.popupform.handlePopupFormLink( this.getAttribute( 'action' ), this ); |
| 40 | + }); |
| 41 | + |
| 42 | + |
| 43 | + // register forminput |
| 44 | + jQuery( 'form.popupforminput' ).submit(function(evt){ |
| 45 | + return ext.popupform.handlePopupFormInput( this.getAttribute( 'action' ), this ); |
| 46 | + }); |
| 47 | + |
| 48 | +}); |
| 49 | + |
| 50 | +// create ext if it does not exist yet |
| 51 | +if ( typeof( window[ 'ext' ] ) == "undefined" ) { |
| 52 | + window[ 'ext' ] = {}; |
| 53 | +} |
| 54 | + |
| 55 | +window.ext.popupform = new function() { |
| 56 | + |
| 57 | + var wrapper; |
| 58 | + var background; |
| 59 | + var container; |
| 60 | + var iframe; |
| 61 | + var waitIndicator; |
| 62 | + var instance = 0; |
| 63 | + |
| 64 | + var doc; |
| 65 | + var docWidth; |
| 66 | + var docHeight; |
| 67 | + |
| 68 | + var brokenBrowser, brokenChrome; |
| 69 | + |
| 70 | + function handlePopupFormInput( ptarget, elem ) { |
| 71 | + |
| 72 | + showForm(); |
| 73 | + |
| 74 | + iframe.one( 'load', function(){ |
| 75 | + // attach event handler to iframe |
| 76 | + iframe.bind( 'load', handleLoadFrame ); |
| 77 | + return false; |
| 78 | + }) |
| 79 | + |
| 80 | + elem.target = 'popupform-iframe' + instance; |
| 81 | + return true; |
| 82 | + } |
| 83 | + |
| 84 | + function handlePopupFormLink( ptarget, elem ) { |
| 85 | + |
| 86 | + showForm(); |
| 87 | + |
| 88 | + // attach event handler to iframe |
| 89 | + iframe.bind( 'load', handleLoadFrame ); |
| 90 | + |
| 91 | + if ( elem.tagName == 'FORM' ) { |
| 92 | + |
| 93 | + elem.target = 'popupform-iframe' + instance; |
| 94 | + return true; |
| 95 | + |
| 96 | + } else { |
| 97 | + |
| 98 | + var delim = ptarget.indexOf( '?' ); |
| 99 | + var form = document.createElement("form"); |
| 100 | + |
| 101 | + form.target = 'popupform-iframe' + instance; |
| 102 | + |
| 103 | + // Do we have parameters? |
| 104 | + if ( delim > 0 ) { |
| 105 | + form.action = ptarget.substr( 0, delim ); |
| 106 | + var params = String( ptarget.substr( delim + 1 ) ).split("&"); |
| 107 | + for ( var i = 0; i < params.length; ++i ) { |
| 108 | + |
| 109 | + var input = document.createElement("input"); |
| 110 | + var param = String( params[i] ).split('='); |
| 111 | + input.type = 'hidden'; |
| 112 | + input.name = decodeURIComponent( param[0] ); |
| 113 | + input.value = decodeURIComponent( param[1] ); |
| 114 | + form.appendChild( input ); |
| 115 | + |
| 116 | + } |
| 117 | + } else { |
| 118 | + form.action = ptarget; |
| 119 | + } |
| 120 | + |
| 121 | + document.getElementsByTagName('body')[0].appendChild(form); |
| 122 | + form.submit(); |
| 123 | + document.getElementsByTagName('body')[0].removeChild(form); |
| 124 | + |
| 125 | + return false; |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | + function showForm() { |
| 130 | + |
| 131 | + instance++; |
| 132 | + |
| 133 | + brokenChrome = |
| 134 | + ( navigator.userAgent.indexOf("Chrome") >= 0 && |
| 135 | + navigator.platform.indexOf("Linux x86_64") >= 0 ); |
| 136 | + |
| 137 | + brokenBrowser= jQuery.browser.msie ||brokenChrome; |
| 138 | + |
| 139 | + wrapper = jQuery( "<div class='popupform-wrapper' >" ); |
| 140 | + background = jQuery( "<div class='popupform-background' >" ); |
| 141 | + |
| 142 | + var waitIndicatorWrapper = jQuery( "<div class='popupform-loading'>" ); |
| 143 | + |
| 144 | + waitIndicator = jQuery( "<div class='popupform-loadingbg'></div><div class='popupform-loadingfg'></div>" ); |
| 145 | + |
| 146 | + var anchor = jQuery( "<div class='popupform-anchor' >" ); |
| 147 | + |
| 148 | + container = jQuery( "<div class='popupform-container' >" ); |
| 149 | + iframe = jQuery( "<iframe class='popupform-innerdocument' name='popupform-iframe" + instance + "' id='popupform-iframe" + instance + "' >"); |
| 150 | + |
| 151 | + var closeBtn = jQuery( "<div class='popupform-close'></div> " ); |
| 152 | + |
| 153 | + // initially hide background and waitIndicator |
| 154 | + if (brokenChrome) background.css("background", "transparent"); |
| 155 | + else background.css("opacity", 0.0); |
| 156 | + |
| 157 | + waitIndicator.hide(); |
| 158 | + container.hide() |
| 159 | + |
| 160 | + // insert background and wait indicator into wrapper and all into document |
| 161 | + waitIndicatorWrapper |
| 162 | + .append( waitIndicator ); |
| 163 | + |
| 164 | + container |
| 165 | + .append( closeBtn ) |
| 166 | + .append( iframe ); |
| 167 | + |
| 168 | + anchor |
| 169 | + .append(container); |
| 170 | + |
| 171 | + wrapper |
| 172 | + .append( background ) |
| 173 | + .append( waitIndicatorWrapper ) |
| 174 | + .append( anchor ) |
| 175 | + .appendTo( "body" ); |
| 176 | + |
| 177 | + // fade background in |
| 178 | + if ( !brokenChrome ) background.fadeTo( 400, 0.3 ); |
| 179 | + fadeIn( waitIndicator ); |
| 180 | + |
| 181 | + // attach event handler to close button |
| 182 | + closeBtn.click( handleCloseFrame ); |
| 183 | + |
| 184 | + // TODO: wrapper must be set to max z-index; |
| 185 | + |
| 186 | + } |
| 187 | + |
| 188 | + function handleLoadFrame( event ){ |
| 189 | + |
| 190 | + var iframe = jQuery( event.target ); |
| 191 | + var iframecontents = iframe.contents(); |
| 192 | + |
| 193 | + if ( brokenChrome ) container[0].style.visibility = "hidden"; |
| 194 | + else container[0].style.opacity = 0; |
| 195 | + |
| 196 | + container.show(); |
| 197 | + |
| 198 | + // GuMaxDD has #content but keeps headlines in #gumax-content-body |
| 199 | + var content = iframecontents.find("#gumax-content-body"); |
| 200 | + |
| 201 | + // normal skins use #content (e.g. Vector, Monobook) |
| 202 | + if ( content.length == 0 ) content = iframecontents.find("#content"); |
| 203 | + |
| 204 | + // some skins use #mw_content (e.g. Modern) |
| 205 | + if ( content.length == 0 ) content = iframecontents.find("#mw_content"); |
| 206 | + |
| 207 | + // this is not a normal MW page (or it uses an unknown skin) |
| 208 | + if ( content.length == 0 ) content = iframecontents.find("body"); |
| 209 | + |
| 210 | + // the huge left margin looks ugly in Vector, reduce it |
| 211 | + // (How does this look for other skins?) |
| 212 | + var siblings = content |
| 213 | + .css( { |
| 214 | + margin: 0, |
| 215 | + padding: "1em", |
| 216 | + width: "auto", |
| 217 | + height: "auto", |
| 218 | + minWidth: "0px", |
| 219 | + minHeight:"0px" |
| 220 | + } ) |
| 221 | + .parents().css( { |
| 222 | + margin: 0, |
| 223 | + padding: 0, |
| 224 | + width: "auto", |
| 225 | + height: "auto", |
| 226 | + minWidth: "0px", |
| 227 | + minHeight:"0px" |
| 228 | + }) |
| 229 | + .andSelf().siblings(); |
| 230 | + |
| 231 | + if ( jQuery.browser.msie && jQuery.browser.version < "6" ) { |
| 232 | + siblings.hide(); |
| 233 | + } else { |
| 234 | + siblings |
| 235 | + .each( function(){ |
| 236 | + var elem = jQuery(this); |
| 237 | +// if ( ( elem.outerWidth(true) > 0 && elem.outerHeight(true) > 0 ) && |
| 238 | + if ( getStyle(this, "display") != "none" |
| 239 | + && ( getStyle( this, "width") != "0px" || getStyle( this, "height") != "0px" ) |
| 240 | + && ! ( |
| 241 | + ( this.offsetLeft + elem.outerWidth(true) < 0 ) || // left of document |
| 242 | + ( this.offsetTop + elem.outerHeight(true) < 0 ) || // above document |
| 243 | + ( this.offsetLeft > 100000 ) || // right of document |
| 244 | + ( this.offsetTop > 100000 ) // below document |
| 245 | + ) |
| 246 | + ) { |
| 247 | + |
| 248 | + jQuery(this).hide(); |
| 249 | + // css({ |
| 250 | + // height : "0px", |
| 251 | + // width : "0px", |
| 252 | + // minWidth : "0px", |
| 253 | + // minHeight : "0px", |
| 254 | + // margin : "0px", |
| 255 | + // padding : "0px" |
| 256 | + // border : "none", |
| 257 | + // overflow: "hidden" |
| 258 | + // //position: "static" |
| 259 | + // }); |
| 260 | + } |
| 261 | + if ( ( this.offsetLeft + elem.outerWidth() < 0 ) || |
| 262 | + ( this.offsetTop + elem.outerHeight() < 0 ) |
| 263 | + ) { |
| 264 | + this.style.left = (-elem.outerWidth(true)) + "px"; |
| 265 | + this.style.top = (-elem.outerHeight(true)) + "px"; |
| 266 | + } |
| 267 | + }); |
| 268 | + //.children().css("position", "static"); |
| 269 | + } |
| 270 | + |
| 271 | + // find content document |
| 272 | + doc = iframe[0].contentWindow || iframe[0].contentDocument; |
| 273 | + |
| 274 | + if (doc.document) { |
| 275 | + doc = doc.document; |
| 276 | + } |
| 277 | + |
| 278 | + // first try if the content enforces its dimensions (e.g. GuMaxDD) |
| 279 | + docWidth = content.outerWidth(true); |
| 280 | + docHeight = content.outerHeight(true); |
| 281 | + |
| 282 | + // then try if it grows to its dimensions given enough space (e.g. Vector) |
| 283 | + var origPos = content[0].style.position; |
| 284 | + content[0].style.position = "fixed"; |
| 285 | + |
| 286 | + if ( content.outerWidth(true) > docWidth || content.outerHeight(true) > docHeight ) { |
| 287 | + docWidth = content.outerWidth(true); |
| 288 | + docHeight = content.outerHeight(true); |
| 289 | + } |
| 290 | + |
| 291 | + content[0].style.position = origPos; |
| 292 | + |
| 293 | + // default for broken browsers |
| 294 | + if ( docWidth == 0 || docHeight == 0 ) { |
| 295 | + |
| 296 | + docWidth = jQuery(window).width(); |
| 297 | + docHeight = jQuery(window).height(); |
| 298 | + |
| 299 | + } |
| 300 | + |
| 301 | + |
| 302 | + // adjust frame size to dimensions just calculated |
| 303 | + adjustFrameSize(); |
| 304 | + |
| 305 | + // and attach event handler to adjust frame size every time the window |
| 306 | + // size changes |
| 307 | + jQuery( window ).resize( adjustFrameSize ); |
| 308 | + |
| 309 | + var form = content.find("#sfForm"); |
| 310 | + var innerwdw = window.frames['popupform-iframe' + instance]; |
| 311 | + |
| 312 | + if (form.length > 0) { |
| 313 | + |
| 314 | + var submitok = false; |
| 315 | + var innersubmitprocessed = false; |
| 316 | + |
| 317 | + // catch form submit event |
| 318 | + form |
| 319 | + .bind( "submit", function( event ){ |
| 320 | + |
| 321 | + var interval = setInterval(function(){ |
| 322 | + |
| 323 | + if ( innersubmitprocessed ) { |
| 324 | + clearInterval( interval ); |
| 325 | + innersubmitprocessed = false; |
| 326 | + if ( submitok ) handleSubmitData( event ); |
| 327 | + } |
| 328 | + |
| 329 | + }, 10) |
| 330 | + event.stopPropagation(); |
| 331 | + return false; |
| 332 | + |
| 333 | + }); |
| 334 | + |
| 335 | + // catch inner form submit event |
| 336 | + innerwdw.jQuery(form[0]) |
| 337 | + .bind( "submit", function( event ) { |
| 338 | + submitok = event.result; |
| 339 | + innersubmitprocessed = true; |
| 340 | + return false; |
| 341 | + }) |
| 342 | + } |
| 343 | + |
| 344 | + innerwdw.jQuery( innerwdw[0] ).unload(function (event) { |
| 345 | + return false; |
| 346 | + }); |
| 347 | + |
| 348 | + // find all links. Have to use inner jQuery so event.result below |
| 349 | + // reflects the result of inner event handlers. We (hopefully) come last |
| 350 | + // in the chain of event handlers as we only attach when the frame is |
| 351 | + // already completely loaded, i.e. every inner event handler is already |
| 352 | + // attached. |
| 353 | + var allLinks = innerwdw.jQuery("a[href]"); |
| 354 | + |
| 355 | + // catch 'Cancel'-Link (and other 'back'-links) and close frame instead of going back |
| 356 | + var backlinks = allLinks.filter('a[href="javascript:history.go(-1);"]'); |
| 357 | + backlinks.click(handleCloseFrame); |
| 358 | + |
| 359 | + // promote any other links to open in main window, prevent nested browsing |
| 360 | + allLinks |
| 361 | + .not('a[href*="javascript:"]') // scripted links |
| 362 | + .not('a[target]') // targeted links |
| 363 | + .not('a[href^="#"]') // local links |
| 364 | + .click(function(event){ |
| 365 | + if ( event.result != false ) { // if not already caught by somebody else |
| 366 | + closeFrameAndFollowLink( event.target.getAttribute('href') ) |
| 367 | + } |
| 368 | + return false; |
| 369 | + }); |
| 370 | + |
| 371 | + // finally show the frame |
| 372 | + fadeOut ( waitIndicator, function(){ |
| 373 | + fadeTo( container, 400, 1 ); |
| 374 | + }); |
| 375 | + |
| 376 | + return false; |
| 377 | + |
| 378 | + } |
| 379 | + |
| 380 | + function handleSubmitData( event ){ |
| 381 | + |
| 382 | + fadeOut( container, function() { |
| 383 | + fadeIn( waitIndicator ); |
| 384 | + }); |
| 385 | + |
| 386 | + var form = jQuery( event.target ); |
| 387 | + var formdata = form.serialize() + "&wpSave=" + escape(form.find("#wpSave").attr("value")); |
| 388 | + |
| 389 | + // Send form data off. SF will send back a fake edit page |
| 390 | + // |
| 391 | + // Normally we should check this.action first and only if it is empty |
| 392 | + // revert to this.ownerDocument.URL. Tough luck, IE does not return an |
| 393 | + // empty action but fills in some bogus |
| 394 | + jQuery.post( event.target.ownerDocument.URL , formdata, handleInnerSubmit); |
| 395 | + |
| 396 | + return false; |
| 397 | + |
| 398 | + |
| 399 | + function handleInnerSubmit ( returnedData, textStatus, XMLHttpRequest ) { |
| 400 | + |
| 401 | + |
| 402 | + // find form in fake edit page |
| 403 | + var innerform = jQuery("<div>" + returnedData + "</div>").find("form"); |
| 404 | + |
| 405 | + // check if we got an error page |
| 406 | + if ( innerform.length == 0 ) { |
| 407 | + |
| 408 | + form.unbind( event ); |
| 409 | + |
| 410 | + var iframe = container.find("iframe"); |
| 411 | + var doc = iframe[0].contentWindow || iframe[0].contentDocument; |
| 412 | + if (doc.document) { |
| 413 | + doc = doc.document; |
| 414 | + } |
| 415 | + |
| 416 | + doc.open(); |
| 417 | + doc.write(returnedData); |
| 418 | + doc.close(); |
| 419 | + |
| 420 | + return false; |
| 421 | + } |
| 422 | + |
| 423 | + // Send the form data off, we do not care for the returned data |
| 424 | + var innerformdata = innerform.serialize(); |
| 425 | + jQuery.post( innerform.attr("action"), innerformdata ); |
| 426 | + |
| 427 | + // build new url for outer page (we have to ask for a purge) |
| 428 | + |
| 429 | + var url = location.href; |
| 430 | + |
| 431 | + // does a querystring exist? |
| 432 | + var start = url.indexOf("action="); |
| 433 | + |
| 434 | + if ( start >= 0 ) { |
| 435 | + |
| 436 | + var stop = url.indexOf("&", start); |
| 437 | + |
| 438 | + if ( stop >= 0 ) url = url.substr( 0, start - 1 ) + url.substr(stop + 1); |
| 439 | + else url = url.substr( 0, start - 1 ); |
| 440 | + |
| 441 | + } |
| 442 | + |
| 443 | + var form = jQuery('<form action="' + url + '" method="POST"><input type="hidden" name="action" value="purge"></form>') |
| 444 | + .appendTo('body'); |
| 445 | + |
| 446 | + form |
| 447 | + .submit(); |
| 448 | + |
| 449 | + fadeOut( container, function(){ |
| 450 | + fadeIn( waitIndicator ); |
| 451 | + }); |
| 452 | + |
| 453 | + return false; |
| 454 | + |
| 455 | + } |
| 456 | + } |
| 457 | + |
| 458 | + function adjustFrameSize() { |
| 459 | + |
| 460 | + var availW = jQuery(window).width(); |
| 461 | + var availH = jQuery(window).height(); |
| 462 | + |
| 463 | + var w, h; |
| 464 | + |
| 465 | + // Standard max height/width is 80% of viewport, but we will allow |
| 466 | + // up to 85% to avoid scrollbars with nearly nothing to scroll |
| 467 | + if ( docWidth > availW * .85 || docHeight > availH * .85 ) { |
| 468 | + |
| 469 | + iframe[0].style.overflow = "auto"; |
| 470 | + |
| 471 | + if ( docWidth > availW * .85 ) { |
| 472 | + w = ( availW * .8 ); |
| 473 | + } else { |
| 474 | + w = docWidth + 20; |
| 475 | + } |
| 476 | + |
| 477 | + if ( docHeight > availH * .85 ) { |
| 478 | + h = ( availH * .8 ); |
| 479 | + } else { |
| 480 | + h = docHeight + 20; |
| 481 | + } |
| 482 | + |
| 483 | + } else { |
| 484 | + iframe[0].style.overflow = "hidden"; |
| 485 | + w = docWidth; |
| 486 | + h = docHeight; |
| 487 | + } |
| 488 | + |
| 489 | + with ( container[0].style ) { |
| 490 | + width = ( w ) + "px"; |
| 491 | + height = ( h ) + "px"; |
| 492 | + top = (( - h ) / 2) + "px"; |
| 493 | + left = (( - w ) / 2) + "px"; |
| 494 | + } |
| 495 | + |
| 496 | + } |
| 497 | + |
| 498 | + function closeFrameAndFollowLink( link ){ |
| 499 | + |
| 500 | + fadeOut( container, function(){ |
| 501 | + fadeIn ( waitIndicator ); |
| 502 | + window.location.href = link; |
| 503 | + }); |
| 504 | + |
| 505 | + } |
| 506 | + |
| 507 | + function handleCloseFrame( event ){ |
| 508 | + |
| 509 | + jQuery(window).unbind( "resize", adjustFrameSize ) |
| 510 | + |
| 511 | + fadeOut( container, function(){ |
| 512 | + background.fadeOut( function(){ |
| 513 | + wrapper.remove(); |
| 514 | + }); |
| 515 | + }); |
| 516 | + return false; |
| 517 | + } |
| 518 | + |
| 519 | + // Saw it on http://robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element |
| 520 | + // and liked it |
| 521 | + function getStyle(oElm, strCssRule){ |
| 522 | + var strValue = ""; |
| 523 | + if(document.defaultView && document.defaultView.getComputedStyle){ |
| 524 | + strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); |
| 525 | + } |
| 526 | + else if(oElm.currentStyle){ |
| 527 | + strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){ |
| 528 | + return p1.toUpperCase(); |
| 529 | + }); |
| 530 | + strValue = oElm.currentStyle[strCssRule]; |
| 531 | + } |
| 532 | + return strValue; |
| 533 | + } |
| 534 | + |
| 535 | + function fadeIn(elem, callback ) { |
| 536 | + // no fading for broken browsers |
| 537 | + if ( brokenBrowser ){ |
| 538 | + |
| 539 | + elem.show(); |
| 540 | + if ( callback ) callback(); |
| 541 | + |
| 542 | + } else { |
| 543 | + |
| 544 | + // what an ugly hack |
| 545 | + if ( elem === waitIndicator ) elem.fadeIn( 200, callback ); |
| 546 | + else elem.fadeIn( callback ); |
| 547 | + |
| 548 | + } |
| 549 | + } |
| 550 | + |
| 551 | + function fadeOut(elem, callback ) { |
| 552 | + // no fading for broken browsers |
| 553 | + if ( brokenBrowser ){ |
| 554 | + |
| 555 | + elem.hide(); |
| 556 | + if ( callback ) callback(); |
| 557 | + |
| 558 | + } else { |
| 559 | + |
| 560 | + // what an ugly hack |
| 561 | + if ( elem === waitIndicator ) elem.fadeOut( 200, callback ); |
| 562 | + else elem.fadeOut( callback ); |
| 563 | + |
| 564 | + } |
| 565 | + } |
| 566 | + |
| 567 | + function fadeTo(elem, time, target, callback) { |
| 568 | + // no fading for broken browsers |
| 569 | + if ( brokenBrowser ){ |
| 570 | + |
| 571 | + if (target > 0) elem[0].style.visibility = "visible"; |
| 572 | + else elem[0].style.visibility = "hidden"; |
| 573 | + |
| 574 | + if ( callback ) callback(); |
| 575 | + |
| 576 | + } else { |
| 577 | + |
| 578 | + elem.fadeTo(time, target, callback); |
| 579 | + |
| 580 | + } |
| 581 | + |
| 582 | + } |
| 583 | + |
| 584 | + // export public funcitons |
| 585 | + this.handlePopupFormInput = handlePopupFormInput; |
| 586 | + this.handlePopupFormLink = handlePopupFormLink; |
| 587 | + |
| 588 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticForms/libs/SF_popupform.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 589 | + native |