From c23df60e1b9cf09262e81e0448217075db973aa5 Mon Sep 17 00:00:00 2001 From: FrissDieGurke Date: Sun, 4 May 2014 12:34:22 +0200 Subject: [PATCH] removed unnecessary method + doc within Settings Framework --- public/src/modules/settings.js | 93 ---------------------------------- src/settings.js | 18 +------ 2 files changed, 1 insertion(+), 110 deletions(-) diff --git a/public/src/modules/settings.js b/public/src/modules/settings.js index 177a685137..af330fc598 100644 --- a/public/src/modules/settings.js +++ b/public/src/modules/settings.js @@ -13,79 +13,6 @@ define(function () { waitingJobs = 0, helper; - /* - * Attributes of HTML-tags that get used by default plugins: - * + data-key: the key to save/load the value within configuration-object - * + data-type: highest priority type-definition to determine what kind of element it is or which plugin to hook - * + type: normal priority type-definition - * + data-empty: if 'false' or '0' then values that are assumed as empty turn into null. data-empty of arrays affect - * their child-elements - * + data-trim: if not 'false' or '0' then values will get trimmed as defined by the elements type - * + data-split: if set and the element doesn't belong to any plugin, it's value will get split and joined by its - * value into the input-field - * array-elements: - * + data-split: separator (HTML allowed) between the elements, defaults to ', ' - * + data-new: value to insert into new created elements - * + data-attributes: an object to set the attributes of the child HTML-elements. tagName as special key will set - * the tag-name of the child HTML-elements - * key-fields: - * + data-trim: if 'false' or '0' then the value will get saved as string else as object providing following - * properties: ctrl, alt, shift, meta, code, char - * + data-split: separator between different modifiers and the key-code of the value that gets saved - * (only takes effect if trimming) - * + data-short: if not 'false' or '0' then modifier-keys get saved as first uppercase character - * (only takes effect if trimming) - * select: - * + data-options: an array of {"text":"Displayed Text","value":"some_value"}-like objects - * - * The name of the HTML-tag is lowest priority type-definition - * - * Examples-HTML: - No! -
- Yes! -
- An array of checkboxes that are selected by default: -

- A simple input-field of any common type: -
- A simple textarea: -
- Array of textareas: -

- 2D-Array of numbers that persist even when empty (but not empty rows): -

- Same with persisting empty rows, but not empty numbers, if no row is given null will get saved: -

- Array of Key-shortcuts (new: Ctrl+Shift+7): -

- Array of numbers (new: 42, step: 21): -

- Select with dynamic options: -
- Select that loads faster: - - * - * Matching configuration: - { - cfg1: false, - cfg2: true, - cfg3: [false, false, true], - cfg4: 'hello world', - cfg5: 'some\nlong\ntext', - cfg6: ['some\nlong\ntexts', 'and another one'], - cfg7: [[]], - cfg8: [[]], - cfg9: [], - cfg10: [], - cfg11: 3, - cfg12: 2 - } - */ - /** Returns the hook of given name that matches the given type or element. @param type The type of the element to get the matching hook for, or the element itself. @@ -404,26 +331,6 @@ define(function () { }, /** Registers a new plugin and calls its use-hook. - A plugin is an object containing a types-property to define its default bindings. - A plugin may also provide the following properties of type function with [return-value] (parameters): - use [void] - gets called when the Settings initializes the plugin. - init [void] (element) - gets called on page-load and every time after the create-hook. - ; element: The element to initialize. - create [JQuery-Object] (type, tagName, data) - gets called when a new HTML-instance needs to get created. - ; type: A string that identifies the plugin itself within this Settings-instance if set as data-type. - ; tagName: The tag-name that gets requested. - ; data: Additional data, plugin-dependent meaning. - destruct [void] (element) - gets called after a HTML-instance got removed from DOM - ; element: The element that got removed. - set [void] (element, value, trim) - gets called when the value of the element should be set to the given value. - ; element: The element to set its value. - ; value: The value to set. - ; trim: Whether the value is considered as trimmed. - get [value] (element, trim, empty) - gets called when the value of the given instance is needed. - ; element: The element to get its value. - ; trim: Whether the result should be trimmed. - ; empty: Whether considered as empty values should get saved too. - All passed elements are JQuery-Objects. @param service The plugin to register. @param types The types to bind the plugin to. */ diff --git a/src/settings.js b/src/settings.js index a8d8594658..b18635d4ff 100644 --- a/src/settings.js +++ b/src/settings.js @@ -27,7 +27,7 @@ function trim(obj1, obj2) { function mergeSettings(cfg, defCfg) { if (typeof cfg._settings !== typeof defCfg || typeof defCfg !== 'object') { - return cfg._settings = defCfg; + cfg._settings = defCfg; } else { expandObjBy(cfg._settings, defCfg); trim(cfg._settings, defCfg); @@ -103,22 +103,6 @@ Settings.prototype.persist = function (callback) { return this; }; -/** - Persists the settings if no settings are saved. - @param callback Gets called when done. - */ -Settings.prototype.persistOnEmpty = function (callback) { - var _this = this; - meta.settings.get(this.hash, function (err, settings) { - if (!settings._settings) { - _this.persist(callback); - } else if (typeof callback === 'function') { - callback.call(_this); - } - }); - return this; -}; - /** Returns the setting of given key or default value if not set. @param key The key of the setting to return.