Author: hsaputra
Date: Wed Apr 25 18:44:08 2012
New Revision: 1330481

URL: http://svn.apache.org/viewvc?rev=1330481&view=rev
Log:
SHINDIG-1757 Defer getting the singleton user prefs in opensocial-templates 
feature until inline execution of gadgets.Prefs.setDefaultPrefs_ is called.

Modified:
    
shindig/trunk/features/src/main/javascript/features/opensocial-templates/base.js
    
shindig/trunk/features/src/main/javascript/features/opensocial-templates/compiler.js

Modified: 
shindig/trunk/features/src/main/javascript/features/opensocial-templates/base.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-templates/base.js?rev=1330481&r1=1330480&r2=1330481&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/opensocial-templates/base.js
 (original)
+++ 
shindig/trunk/features/src/main/javascript/features/opensocial-templates/base.js
 Wed Apr 25 18:44:08 2012
@@ -239,8 +239,13 @@ os.createNodeAccessor_ = function(node) 
  * @private
  */
 os.gadgetPrefs_ = null;
-if (window['gadgets'] && window['gadgets']['Prefs']) {
-  os.gadgetPrefs_ = new window['gadgets']['Prefs']();
+os.getGadgetPrefs = function() {
+  if(os.gadgetPrefs === null) {
+    if (window['gadgets'] && window['gadgets']['Prefs']) {
+      os.gadgetPrefs_ = new window['gadgets']['Prefs']();
+    }
+  }
+  return os.gadgetPrefs_;
 }
 
 /**
@@ -251,7 +256,7 @@ if (window['gadgets'] && window['gadgets
  * found, or not in the gadgets environment.
  */
 os.getPrefMessage = function(key) {
-  if (!os.gadgetPrefs_) {
+  if (!os.getGadgetPrefs()) {
     return null;
   }
   return os.gadgetPrefs_.getMsg(key);

Modified: 
shindig/trunk/features/src/main/javascript/features/opensocial-templates/compiler.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-templates/compiler.js?rev=1330481&r1=1330480&r2=1330481&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/opensocial-templates/compiler.js
 (original)
+++ 
shindig/trunk/features/src/main/javascript/features/opensocial-templates/compiler.js
 Wed Apr 25 18:44:08 2012
@@ -858,7 +858,7 @@ os.wrapIdentifiersInToken = function(tok
   // TODO: This is inefficient for times when the message contains no markup -
   // such cases should be optimized.
   if (token.substring(0, os.VAR_msg.length + 1) == (os.VAR_msg + '.') &&
-      os.gadgetPrefs_) {
+      os.getGadgetPrefs()) {
     var key = token.split('.')[1];
     var msg = os.getPrefMessage(key) || '';
     return os.parseAttribute_(msg) || os.transformLiteral_(msg);


Reply via email to