Handle settings passed in as JSON from new data model.
authorJason Skomorowski <jason@indexdata.com>
Thu, 17 Mar 2011 06:06:07 +0000 (07:06 +0100)
committerJason Skomorowski <jason@indexdata.com>
Tue, 22 Mar 2011 03:40:55 +0000 (03:40 +0000)
mkdru.client.js

index 5638dd1..daa95b0 100644 (file)
@@ -1,7 +1,6 @@
 // Set up namespace and some state.
 var mkdru = {
-  // Settings to pass to pz2.js
-  useSessions: Drupal.settings.mkdru.use_sessions === '1',
+  settings: JSON.parse(Drupal.settings.mkdru.settings),
   // Variables
   active: false,
   pz2: null,
@@ -9,31 +8,6 @@ var mkdru = {
   pagerRange: 6,
   pazpar2Path: Drupal.settings.mkdru.pz2_path,
   facetContainerSelector: Drupal.settings.mkdru.facetContainerSelector,
-  // Facets
-  facets: {
-    source: {
-      displayName: Drupal.settings.mkdru.source_dname || "Source",
-      orderWeight: Drupal.settings.mkdru.source_weight || 1,
-      pz2Name: 'xtargets',
-      max: Drupal.settings.mkdru.source_max || 10
-    },
-    subject: {
-      displayName: Drupal.settings.mkdru.subject_dname || "Subject",
-      orderWeight: Drupal.settings.mkdru.source_weight || 2,
-      pz2Name: 'subject',
-      max: Drupal.settings.mkdru.subject_max || 10,
-      multiLimit: true,
-      limiter: 'su'
-    },
-    author: {
-      displayName: Drupal.settings.mkdru.author_dname || "Author",
-      orderWeight: Drupal.settings.mkdru.source_weight || 3,
-      pz2Name: 'author',
-      max: Drupal.settings.mkdru.author_max || 10,
-      multiLimit: false,
-      limiter: 'au'
-    }
-  },
   // State; Keys limit_{facet key} will also be initialised
   defaultState: {
     page: 1,
@@ -45,8 +19,8 @@ var mkdru = {
   state: {},
   realm: ''
 };
-
-
+// Convenient references
+mkdru.facets = mkdru.settings.facets;
 
 // Wrapper for jQuery
 (function ($) {
@@ -412,7 +386,7 @@ $(document).ready(function () {
               "onstat": mkdru.pz2Status,
               "onterm": mkdru.pz2Term,
               "termlist": termlist.join(','),
-              "usesessions" : mkdru.useSessions,
+              "usesessions" : mkdru.settings.useSessions,
               "showResponseType": mkdru.showResponseType,
               "onrecord": mkdru.pz2Record,
               "autoInit": false } );
@@ -431,7 +405,7 @@ $(document).ready(function () {
   }
 
   //not running against SP? init, otherwise authenticate
-  if (mkdru.useSessions) {
+  if (mkdru.settings.use_sessions) {
     mkdru.pz2.init();
   } else {
     //runnin against SP