diff options
author | Fabio Bas <ctrlaltca@gmail.com> | 2013-10-03 22:33:09 +0200 |
---|---|---|
committer | Fabio Bas <ctrlaltca@gmail.com> | 2013-10-03 22:33:09 +0200 |
commit | bbeb1b968f5234a62c32681c2ed9e4a7a189bd34 (patch) | |
tree | 1b4103c885fd1bfc555fb93313c1dd2c3a20a603 /framework/Web/Javascripts/source | |
parent | a5d1b481a09c14d2e1459648efdeae4b8371ed01 (diff) |
During callback, separate loading of stylesheet files and code snippets; fixes #480
Diffstat (limited to 'framework/Web/Javascripts/source')
-rw-r--r-- | framework/Web/Javascripts/source/prado/activecontrols/ajax3.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js index 55ef64cb..e19f5d49 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js @@ -176,6 +176,10 @@ Object.extend(Prado.CallbackRequest, */ SCRIPTLIST_HEADER : 'X-PRADO-SCRIPTLIST', /** + * Stylesheet code header name. + */ + STYLESHEET_HEADER : 'X-PRADO-STYLESHEET', + /** * Stylesheet list header name. */ STYLESHEETLIST_HEADER : 'X-PRADO-STYLESHEETLIST', @@ -431,6 +435,22 @@ Object.extend(Prado.CallbackRequest, } }, + loadStyleSheetsCode : function(request, transport) + { + var self = Prado.CallbackRequest; + var data = request.getBodyContentPart(self.STYLESHEET_HEADER); + if (typeof(data) == "string" && data.length > 0) + { + json = Prado.CallbackRequest.decode(data); + if(typeof(json) != "object") + Logger.warn("Invalid stylesheet list:"+data); + else + for(var key in json) + if (/^\d+$/.test(key)) + Prado.StyleSheetManager.createStyleSheetCode(json[key],null); + } + }, + loadStyleSheetsAsync : function(request, transport) { var self = Prado.CallbackRequest; @@ -520,6 +540,8 @@ Object.extend(Prado.CallbackRequest, */ + this.loadStyleSheetsCode(request,transport); + this.loadStyleSheetsAsync(request,transport); this.loadScripts(request,transport,callback); @@ -1127,6 +1149,15 @@ if (typeof(Prado.AssetManagerClass)=="undefined") { asset.href = url; // asset.async = false; // HTML5 only return asset; + }, + + createStyleSheetCode: function(code) { + var asset = document.createElement('style'); + asset.setAttribute('type', 'text/css'); + asset.innerText = code; + + var head = document.getElementsByTagName('head')[0]; + head.appendChild(asset); } }); |