diff --git a/README.md b/README.md index e77a613..13a39f8 100755 --- a/README.md +++ b/README.md @@ -523,7 +523,7 @@ Eg: If you run the `.show()` manipulator on an item that is already visible, the | Method | Returns | Event Fired | Description | |--------|---------|-------------| ------------| | `.set( [boolean\|int] value)` | `ClayItem` | `change` | Check/uncheck the state of this item. | -| `.get()` | `boolean` | | `true` if checked, `false` if not. **NOTE** this will be converted to a `1` or `0` when sent to the watch. See [`ClayConfig.getSettings()`](#methods) | +| `.get()` | `boolean` | | `true` if checked, `false` if not. **NOTE** this will be converted to a `1` or `0` when sent to the watch. See [`Clay.getSettings()`](#methods) | | `.disable()` | `ClayItem` | `disabled` | Prevents this item from being edited by the user. | | `.enable()` | `ClayItem` | `enabled` | Allows this item to be edited by the user. | | `.hide()` | `ClayItem` | `hide` | Hides the item | @@ -556,7 +556,7 @@ Eg: If you run the `.show()` manipulator on an item that is already visible, the | Method | Returns | Event Fired | Description | |--------|---------|-------------| ------------| | `.set( [array] value)` | `ClayItem` | `change` | Checks the checkboxes that corresponds to the provided list of values. | -| `.get()` | `Array.` | | Gets an array of strings representing the list of the values of the checked items. **NOTE:** each item in the array will be separated by a zero when sent to the watch. See [`ClayConfig.getSettings()`](#methods) | +| `.get()` | `Array.` | | Gets an array of strings representing the list of the values of the checked items. **NOTE:** each item in the array will be separated by a zero when sent to the watch. See [`Clay.getSettings()`](#methods) | | `.disable()` | `ClayItem` | `disabled` | Prevents this item from being edited by the user. | | `.enable()` | `ClayItem` | `enabled` | Allows this item to be edited by the user. | | `.hide()` | `ClayItem` | `hide` | Hides the item | diff --git a/src/scripts/config-page.js b/src/scripts/config-page.js index 1f5b1c4..af4f3f5 100755 --- a/src/scripts/config-page.js +++ b/src/scripts/config-page.js @@ -28,7 +28,7 @@ var clayConfig = new ClayConfig(settings, config, $mainForm, clayMeta); $mainForm.on('submit', function() { // Set the return URL depending on the runtime environment location.href = returnTo + - encodeURIComponent(JSON.stringify(clayConfig.getSettings())); + encodeURIComponent(JSON.stringify(clayConfig.serialize())); }); // Run the custom function in the context of the ClayConfig diff --git a/src/scripts/lib/clay-config.js b/src/scripts/lib/clay-config.js index 750e700..b8622b8 100644 --- a/src/scripts/lib/clay-config.js +++ b/src/scripts/lib/clay-config.js @@ -155,8 +155,8 @@ function ClayConfig(settings, config, $rootContainer, meta) { /** * @returns {Object} */ - self.getSettings = function() { - _checkBuilt('getSettings'); + self.serialize = function() { + _checkBuilt('serialize'); _.eachObj(_itemsByAppKey, function(appKey, item) { _settings[appKey] = item.get(); }); diff --git a/test/spec/lib/clay-config.js b/test/spec/lib/clay-config.js index 887186a..4594f74 100644 --- a/test/spec/lib/clay-config.js +++ b/test/spec/lib/clay-config.js @@ -15,7 +15,7 @@ describe('ClayConfig', function() { 'getItemByAppKey', 'getItemById', 'getItemsByType', - 'getSettings', + 'serialize', 'registerComponent', 'build', 'on', @@ -39,7 +39,7 @@ describe('ClayConfig', function() { 'getItemByAppKey', 'getItemById', 'getItemsByType', - 'getSettings' + 'serialize' ].forEach(function(method) { it('.' + method + '()', function() { var clayConfig = fixtures.clayConfig(['input', 'text'], false); @@ -99,7 +99,7 @@ describe('ClayConfig', function() { }); }); - describe('.getSettings()', function() { + describe('.serialize()', function() { it('returns the correct settings', function() { var config = [ {type: 'input', appKey: 'test1', defaultValue: 'default val'}, @@ -120,7 +120,7 @@ describe('ClayConfig', function() { var clayConfig = fixtures.clayConfig(config, true, true, settings); - assert.deepEqual(clayConfig.getSettings(), { + assert.deepEqual(clayConfig.serialize(), { test1: 'default val', test2: 'val-2', test3: false, @@ -131,17 +131,17 @@ describe('ClayConfig', function() { clayConfig.getItemByAppKey('test3').set(true); clayConfig.getItemByAppKey('test4').set(['cb-1', 'cb-3']); - assert.deepEqual(clayConfig.getSettings(), { + assert.deepEqual(clayConfig.serialize(), { test1: 'val-1', test2: 'val-2', test3: true, test4: ['cb-1', 'cb-3'] }); - // make sure the result of getSettings() can actually be fed back in to + // make sure the result of serialize() can actually be fed back in to // a new instance of ClayConfig assert.doesNotThrow(function() { - settings = clayConfig.getSettings(); + settings = clayConfig.serialize(); fixtures.clayConfig(config, true, true, settings); }); });