From 50fa02694d6da3e6ddf98f900298db4caaa88889 Mon Sep 17 00:00:00 2001 From: Jason Skomorowski Date: Thu, 17 Mar 2011 07:06:07 +0100 Subject: [PATCH] Handle settings passed in as JSON from new data model. --- mkdru.client.js | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/mkdru.client.js b/mkdru.client.js index 3fa4414..d624d2b 100644 --- a/mkdru.client.js +++ b/mkdru.client.js @@ -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 ($) { @@ -409,7 +383,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 } ); @@ -428,7 +402,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 -- 1.7.10.4