-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- V extension
spinner
se nově neodstraňuje spinner z DOM i v případ…
…ě, že v JSONu AJAXové odpovědi přijde pole `forceReload`. V tu chvíli je chování extension `spinner` totožné s případem, kdy dojde `forceRedirect`. - **Nové extension:** Přidáno extension `forceReload`, které zajistí znovunačtení stránky v případě, že v odpovědi přišlo `forceRedirect: true`. Pokud je v odpovědi i `_fid`, je přidáno do URL pro načtení.
- Loading branch information
Showing
5 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
(function($, undefined) { | ||
|
||
/** | ||
* @author Radek Šerý | ||
* Force reload | ||
* Extension, které reloadne stránku, pokud v odpovědi je "forceReload". V případě, že v JSONu je i _fid, přidá jej | ||
* do URL pro reload. | ||
*/ | ||
$.nette.ext('forceReload', { | ||
success: function(payload, status, xhr, settings) { | ||
if (payload.forceReload) { | ||
var href = window.location.href; | ||
|
||
href = this.removeFid(href); | ||
|
||
if (payload._fid) { | ||
href = this.addFid(href, payload._fid) | ||
} | ||
|
||
window.location.href = href; | ||
} | ||
} | ||
}, { | ||
addFid: function(href, _fid) { | ||
var s = '?'; | ||
|
||
if ((i = href.search(/\?/)) !== -1) { | ||
s = '&'; | ||
} | ||
|
||
href += s + '_fid=' + _fid; | ||
|
||
return href; | ||
}, | ||
removeFid: function(href) { | ||
// je v URL _fid? | ||
var fidStart = href.indexOf('_fid='); | ||
|
||
if (fidStart > -1) { | ||
// Odstranění _fid parametru | ||
var fidEnd = href.indexOf('&', fidStart); | ||
|
||
if (fidEnd === -1) { | ||
href = href.substring(0, fidStart); | ||
} else { | ||
href = href.substring(0, fidStart) + href.substring(fidEnd + 1); | ||
} | ||
|
||
// Ořízneme koncové '?' nebo '&' | ||
if (href[href.length - 1] === '?' || href[href.length - 1] === '&') { | ||
href = href.slice(0, -1); | ||
} | ||
|
||
} | ||
|
||
return href; | ||
} | ||
}); | ||
|
||
|
||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "pd.ajax", | ||
"title": "pd.ajax", | ||
"description": "Collection of nette ajax extensions, including `pd` for creating disabled-by-deafult extensions", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"author": "PeckaDesign, s.r.o <[email protected]>", | ||
"contributors": [ | ||
"Radek Šerý <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters