NOTE: If you are a developer, please use a private wiki based on foswiki/trunk on a daily base ...or use trunk.foswiki.org to view this page for some minimal testing.
Use Item11383 for general documentation changes for release 1.1.5. Use Item9693 for docu changes for release 2.0.

Item9124: NatSkin + NatEditPlugin should use foswiki.getPreference() in js

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal Closed Extension NatSkin, NatEditPlugin  
Recent changes to trunk JQueryPlugin break some js that assumed foswiki.foo vars were automatically populated from <meta> tags.

I've done some changes for NatSkin, Michael, what is your opinion? NatEditPlugin would probably justify creation of some local alias variables instead of using foswiki.preferences[''] array? What do you think?

Error: no such plugin chili
diff --git a/trunk/NatSkin/templates/javascript.nat.tmpl b/trunk/NatSkin/templates/javascript.nat.tmpl
index bdf2fa2..61fe759 100755
--- a/trunk/NatSkin/templates/javascript.nat.tmpl
+++ b/trunk/NatSkin/templates/javascript.nat.tmpl
@@ -10,5 +10,11 @@
 %TMPL:DEF{"initAutoComplete"}%<meta name='foswiki.NatSkin.initAutocomplete' content='true' />%TMPL:END%
 %TMPL:DEF{"initSearchBox"}%<meta name='foswiki.NatSkin.initSearchBox' content='true' />%TMPL:END%
 %TMPL:DEF{"initRedDot"}%<meta name='foswiki.NatSkin.initRedDot' content='true' />%TMPL:END%
+%TMPL:DEF{"javascript"}%%TMPL:P{"meta:preferences"}%%TMPL:P{"script"}%%TMPL:P{"defaultjavascript"}%%TMPL:END%
 
-%TMPL:DEF{"javascript"}%%TMPL:P{"defaultjavascript"}%%TMPL:END%
+%TMPL:DEF{"meta:preferences"}%%FOREACH{"%EXPORTEDPREFERENCES%" 
+  format="<meta name='foswiki.$topic' content='$percnt$topic$percnt' />"
+    separator="
+"
+}%
+%TMPL:END%
diff --git a/trunk/NatSkin/pub/System/NatSkin/natskin.uncompressed.js b/trunk/NatSkin/pub/System/NatSkin/natskin.u
index a5f2b87..0f43e38 100644
--- a/trunk/NatSkin/pub/System/NatSkin/natskin.uncompressed.js
+++ b/trunk/NatSkin/pub/System/NatSkin/natskin.uncompressed.js
@@ -2,7 +2,34 @@
 
 // document ready
 (function($) {$(function() {
-
+  var myPreferences =[ 
+    'NatSkin.initWebButtons',
+    'NatSkin.initOverflows',
+    'NatSkin.initTopicActions',
+    'NatSkin.initSideBar',
+    'NatSkin.initRedDot',
+    'NatSkin.initAutocomplete',
+    'NatSkin.initSearchBox',
+    'NatSkin.fixRevisionPosition'
+    ];
+
+  if (typeof(foswiki.getPreference) === 'function') {
+    $.each(myPreferences, 
+      function (index, element) {
+        foswiki.getPreference(element);
+      }
+    );
+  } else {
+    if (typeof(foswiki) === 'object' && typeof(foswiki.preferences) === 'undefined') {
+      foswiki.preferences = [];
+    }
+    $.each(myPreferences, 
+      function (index, element) {
+        foswiki.preferences[element] = foswiki[element];
+      }
+    );
+  }
+  
   /* ie6 png transperency fix for img tags */
   if ($.browser.msie && $.browser.version < 7) {
     window.setTimeout(function() {
@@ -16,13 +43,13 @@
           "height": height, 
           "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.attr("src") + "', sizingMeth
         });
-        img.attr("src", foswiki.pubUrlPath+"/"+foswiki.systemWebName+"/NatSkin/blank.gif");
+        img.attr("src", foswiki.preferences['PUBURLPATH']+"/"+foswiki.preferences['SYSTEMWEB']+"/NatSkin/blank.gi
       });
     }, 10);
   }
 
   /* move revinfo */
-  if (foswiki.NatSkin.fixRevisionPosition) {
+  if (foswiki.preferences['NatSkin.fixRevisionPosition']) {
     var target = $(".natMain h1:first");
     if (target.length) { 
       $(".natRevision").remove().insertAfter(target);
@@ -30,7 +57,7 @@
   }
 
   /* horiz menu */
-  if (foswiki.NatSkin.initWebButtons) {
+  if (foswiki.preferences['NatSkin.initWebButtons']) {
     var $container = $(".natWebButtonsContents");
     $container.children("ul").superfish({
       autoArrows: false
@@ -39,13 +66,13 @@
   }
 
   /* add overflow div for tables */
-  if (foswiki.NatSkin.initOverflows) { 
+  if (foswiki.preferences['NatSkin.initOverflows']) { 
     $(".natMainContents .foswikiTable")
       .not($(".foswikiTable .foswikiTable", this))
       .wrap("<div class='overflow foswikiTableOverflow'></div>");
   }
 
-  if (foswiki.NatSkin.initTopicActions) { // topicaction tooltips 
+  if (foswiki.preferences['NatSkin.initTopicActions']) { // topicaction tooltips 
     var $tipContainer = $("#natTopicActionTooltip");
     var $topicActions = $("#natTopicActions");
     //$tipContainer.width($topicActions.width());
@@ -104,7 +131,7 @@
     });
   }
 
-  if (foswiki.NatSkin.initSideBar) { // typographic improvements in sidebar
+  if (foswiki.preferences['NatSkin.initSideBar']) { // typographic improvements in sidebar
     $('.natSideBar h2 + h2').not(".jqInited").each(function() {
       var $this = $(this);
       $this.addClass('.jqInited');
@@ -112,7 +139,7 @@
-- PaulHarvey - 08 Jun 2010

The diff has been updated to work on 1.0.x and 1.1.x. However, scriptUrlPath and a couple of others still need some special handling coded in for 1.0.x.

-- PaulHarvey - 08 Jun 2010

I've already fixed these and a few more to use foswiki.getPreferences(). I deliberately did not release JQueryPlugin because the process of fixing all of these plugins needs to be finished so that all of these plugins are released at one consistent state. All plugins depending on JQueryPlugin are still consistent as they are released in the Extensions web.

So please do not check in your fixes as they clash with mine.

-- MichaelDaum - 08 Jun 2010
 

ItemTemplate edit

Summary NatSkin + NatEditPlugin should use foswiki.getPreference() in js
ReportedBy PaulHarvey
Codebase trunk
SVN Range
AppliesTo Extension
Component NatSkin, NatEditPlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins Foswikirev:10388 Foswikirev:10389
TargetRelease n/a
ReleasedIn n/a
Topic revision: r3 - 22 Dec 2010 - 11:10:03 - MichaelDaum
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads