From 00bdd0dc061fe95a39efa3fa9181332a8805a923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1sztor=20G=C3=A1bor?= Date: Thu, 12 Nov 2015 11:25:47 +0100 Subject: [PATCH] Minor on Inspector --- .../assets/ui/js/inspector.datainteraction.js | 11 +++++++---- .../assets/ui/js/inspector.editor.checkbox.js | 5 +++-- .../assets/ui/js/inspector.editor.dictionary.js | 12 ++++++------ .../assets/ui/js/inspector.editor.dropdown.js | 3 ++- .../assets/ui/js/inspector.editor.object.js | 2 +- .../assets/ui/js/inspector.editor.objectlist.js | 8 +++++--- .../assets/ui/js/inspector.editor.popupbase.js | 2 +- .../system/assets/ui/js/inspector.editor.set.js | 3 ++- .../assets/ui/js/inspector.editor.text.js | 2 +- modules/system/assets/ui/js/inspector.groups.js | 3 ++- .../system/assets/ui/js/inspector.manager.js | 13 +++---------- .../system/assets/ui/js/inspector.surface.js | 12 ++++++++---- .../assets/ui/js/inspector.validator.base.js | 8 ++------ .../ui/js/inspector.validator.basenumber.js | 6 ++++-- .../assets/ui/js/inspector.validator.length.js | 3 ++- .../assets/ui/js/inspector.wrapper.base.js | 17 ++++++++--------- 16 files changed, 57 insertions(+), 53 deletions(-) diff --git a/modules/system/assets/ui/js/inspector.datainteraction.js b/modules/system/assets/ui/js/inspector.datainteraction.js index 3881fb4ed..90de00a5a 100644 --- a/modules/system/assets/ui/js/inspector.datainteraction.js +++ b/modules/system/assets/ui/js/inspector.datainteraction.js @@ -53,7 +53,8 @@ try { return valuesStr.length === 0 ? {} : $.parseJSON(valuesStr) - } catch (err) { + } + catch (err) { throw new Error('Error parsing Inspector field values. ' + err) } } @@ -113,7 +114,7 @@ self = this $.oc.stripeLoadIndicator.show() - var request = $form.request('onGetInspectorConfiguration', { + $form.request('onGetInspectorConfiguration', { data: data }).done(function inspectorConfigurationRequestDoneClosure(data) { self.configurartionRequestDone(data, onComplete, result) @@ -134,10 +135,12 @@ try { return $.parseJSON(configuration) - } catch(err) { + } + catch(err) { throw new Error('Error parsing Inspector configuration. ' + err) } - } else { + } + else { return configuration } } diff --git a/modules/system/assets/ui/js/inspector.editor.checkbox.js b/modules/system/assets/ui/js/inspector.editor.checkbox.js index b842e7045..fb7e676f2 100644 --- a/modules/system/assets/ui/js/inspector.editor.checkbox.js +++ b/modules/system/assets/ui/js/inspector.editor.checkbox.js @@ -60,8 +60,9 @@ } CheckboxEditor.prototype.normalizeCheckedValue = function(value) { - if (value == '0' || value == 'false') - return false + if (value == '0' || value == 'false') { + return false + } return value } diff --git a/modules/system/assets/ui/js/inspector.editor.dictionary.js b/modules/system/assets/ui/js/inspector.editor.dictionary.js index 0981434b7..4e0352897 100644 --- a/modules/system/assets/ui/js/inspector.editor.dictionary.js +++ b/modules/system/assets/ui/js/inspector.editor.dictionary.js @@ -59,13 +59,11 @@ } } else { - var itemCount = 0 - if (typeof value !== 'object') { this.throwError('Object list value should be an object.') } - itemCount = this.getValueKeys(value).length + var itemCount = this.getValueKeys(value).length $.oc.foundation.element.removeClass(link, 'placeholder') link.textContent = 'Items: ' + itemCount @@ -117,7 +115,7 @@ \ \ ' } @@ -440,10 +438,12 @@ } DictionaryEditor.prototype.onKeyDown = function(ev) { - if (ev.keyCode == 40) + if (ev.keyCode == 40) { return this.navigateDown(ev) - else if (ev.keyCode == 38) + } + else if (ev.keyCode == 38) { return this.navigateUp(ev) + } } $.oc.inspector.propertyEditors.dictionary = DictionaryEditor diff --git a/modules/system/assets/ui/js/inspector.editor.dropdown.js b/modules/system/assets/ui/js/inspector.editor.dropdown.js index 6a2bf5337..b9e692c42 100644 --- a/modules/system/assets/ui/js/inspector.editor.dropdown.js +++ b/modules/system/assets/ui/js/inspector.editor.dropdown.js @@ -158,8 +158,9 @@ var dependencyValues = this.getDependencyValues() - if (this.prevDependencyValues === undefined || this.prevDependencyValues != dependencyValues) + if (this.prevDependencyValues === undefined || this.prevDependencyValues != dependencyValues) { this.loadDynamicOptions() + } } DropdownEditor.prototype.onExternalPropertyEditorHidden = function() { diff --git a/modules/system/assets/ui/js/inspector.editor.object.js b/modules/system/assets/ui/js/inspector.editor.object.js index 31ffe2c3c..a8922111b 100644 --- a/modules/system/assets/ui/js/inspector.editor.object.js +++ b/modules/system/assets/ui/js/inspector.editor.object.js @@ -121,7 +121,7 @@ } ObjectEditor.prototype.validate = function() { - var values = values = this.childInspector.getValues() + var values = this.childInspector.getValues() if (this.cleanUpValue(values) === $.oc.inspector.removedProperty) { // Ignore any validation rules if the object's required diff --git a/modules/system/assets/ui/js/inspector.editor.objectlist.js b/modules/system/assets/ui/js/inspector.editor.objectlist.js index 10b7f7557..6c1114907 100644 --- a/modules/system/assets/ui/js/inspector.editor.objectlist.js +++ b/modules/system/assets/ui/js/inspector.editor.objectlist.js @@ -172,7 +172,7 @@ \ \ ' } @@ -338,7 +338,8 @@ if (value.length === 0) { value = '[No title]' $.oc.foundation.element.addClass(selectedRow, 'disabled') - } else { + } + else { $.oc.foundation.element.removeClass(selectedRow, 'disabled') } @@ -415,7 +416,8 @@ if (newSelectedRow) { this.selectRow(newSelectedRow) - } else { + } + else { tbody.appendChild(this.buildEmptyRow()) } diff --git a/modules/system/assets/ui/js/inspector.editor.popupbase.js b/modules/system/assets/ui/js/inspector.editor.popupbase.js index 4f9133068..99be673c6 100644 --- a/modules/system/assets/ui/js/inspector.editor.popupbase.js +++ b/modules/system/assets/ui/js/inspector.editor.popupbase.js @@ -49,7 +49,7 @@ \ \ ' } diff --git a/modules/system/assets/ui/js/inspector.editor.set.js b/modules/system/assets/ui/js/inspector.editor.set.js index a28d0e304..a26f6da08 100644 --- a/modules/system/assets/ui/js/inspector.editor.set.js +++ b/modules/system/assets/ui/js/inspector.editor.set.js @@ -88,7 +88,8 @@ text = '[' + textValues.join(', ') + ']' $.oc.foundation.element.removeClass(link, 'placeholder') - } else { + } + else { text = this.propertyDefinition.placeholder if ((typeof text === 'string' && text.length == 0) || text === undefined) { diff --git a/modules/system/assets/ui/js/inspector.editor.text.js b/modules/system/assets/ui/js/inspector.editor.text.js index 28dc74026..bbcf5d505 100644 --- a/modules/system/assets/ui/js/inspector.editor.text.js +++ b/modules/system/assets/ui/js/inspector.editor.text.js @@ -51,7 +51,7 @@ \ \ ' } diff --git a/modules/system/assets/ui/js/inspector.groups.js b/modules/system/assets/ui/js/inspector.groups.js index 1fec16adb..c9054157e 100644 --- a/modules/system/assets/ui/js/inspector.groups.js +++ b/modules/system/assets/ui/js/inspector.groups.js @@ -49,8 +49,9 @@ var groupIndex = this.getGroupIndex(group), statuses = this.readGroupStatuses() - if (statuses[groupIndex] !== undefined) + if (statuses[groupIndex] !== undefined) { return statuses[groupIndex] + } return false } diff --git a/modules/system/assets/ui/js/inspector.manager.js b/modules/system/assets/ui/js/inspector.manager.js index ce2c4e732..9b49db512 100644 --- a/modules/system/assets/ui/js/inspector.manager.js +++ b/modules/system/assets/ui/js/inspector.manager.js @@ -5,6 +5,7 @@ * and containers. */ +function ($) { "use strict"; + var Base = $.oc.foundation.base, BaseProto = Base.prototype @@ -146,22 +147,14 @@ var applyEvent = $.Event('apply.oc.inspector') $container.trigger(applyEvent) - if (applyEvent.isDefaultPrevented()) { - return false - } - - return true + return applyEvent.isDefaultPrevented() ? false : true; } InspectorManager.prototype.containerHidingAllowed = function($container) { var allowedEvent = $.Event('beforeContainerHide.oc.inspector') $container.trigger(allowedEvent) - if (allowedEvent.isDefaultPrevented()) { - return false - } - - return true + return !allowedEvent.isDefaultPrevented(); } InspectorManager.prototype.onInspectableClicked = function(ev) { diff --git a/modules/system/assets/ui/js/inspector.surface.js b/modules/system/assets/ui/js/inspector.surface.js index 6b9ca3824..ab273fb40 100644 --- a/modules/system/assets/ui/js/inspector.surface.js +++ b/modules/system/assets/ui/js/inspector.surface.js @@ -374,7 +374,8 @@ if (property.itemType == 'group' || isGroupedControl) { row.setAttribute('data-group-index', this.getGroupManager().getGroupIndex(group)) row.setAttribute('data-parent-group-index', this.getGroupManager().getGroupIndex(group.parentGroup)) - } else { + } + else { if (group.parentGroup) { row.setAttribute('data-parent-group-index', this.getGroupManager().getGroupIndex(group)) } @@ -444,7 +445,8 @@ self.expandOrCollapseRows(rows, collapse, duration, noAnimation) }, duration) - } else { + } + else { $.oc.foundation.element.toggleClass(row, 'collapsed', collapse) $.oc.foundation.element.toggleClass(row, 'expanded', !collapse) @@ -581,8 +583,9 @@ Surface.prototype.findPropertyEditor = function(property) { for (var i = 0, len = this.editors.length; i < len; i++) { - if (this.editors[i].getPropertyName() == property) + if (this.editors[i].getPropertyName() == property) { return this.editors[i] + } } return null @@ -590,8 +593,9 @@ Surface.prototype.findExternalParameterEditor = function(property) { for (var i = 0, len = this.externalParameterEditors.length; i < len; i++) { - if (this.externalParameterEditors[i].getPropertyName() == property) + if (this.externalParameterEditors[i].getPropertyName() == property) { return this.externalParameterEditors[i] + } } return null diff --git a/modules/system/assets/ui/js/inspector.validator.base.js b/modules/system/assets/ui/js/inspector.validator.base.js index 8d7d41a61..758cdbd47 100644 --- a/modules/system/assets/ui/js/inspector.validator.base.js +++ b/modules/system/assets/ui/js/inspector.validator.base.js @@ -6,7 +6,7 @@ // NAMESPACES // ============================ - if ($.oc.inspector.validators === undefined) + if ($.oc.inspector.validators === undefined) $.oc.inspector.validators = {} // CLASS DEFINITION @@ -48,11 +48,7 @@ return true } - if (typeof value === 'string' || typeof value == 'number' || typeof value == 'boolean') { - return true - } - - return false + return !!(typeof value === 'string' || typeof value == 'number' || typeof value == 'boolean'); } BaseValidator.prototype.isValid = function(value) { diff --git a/modules/system/assets/ui/js/inspector.validator.basenumber.js b/modules/system/assets/ui/js/inspector.validator.basenumber.js index c0074e408..b47841572 100644 --- a/modules/system/assets/ui/js/inspector.validator.basenumber.js +++ b/modules/system/assets/ui/js/inspector.validator.basenumber.js @@ -16,8 +16,9 @@ BaseNumber.prototype.doCommonChecks = function(value) { if (this.options.min !== undefined || this.options.max !== undefined) { if (this.options.min !== undefined) { - if (this.options.min.value === undefined) + if (this.options.min.value === undefined) { throw new Error('The min.value parameter is not defined in the Inspector validator configuration') + } if (value < this.options.min.value) { return this.options.min.message !== undefined ? @@ -27,8 +28,9 @@ } if (this.options.max !== undefined) { - if (this.options.max.value === undefined) + if (this.options.max.value === undefined) { throw new Error('The max.value parameter is not defined in the table Inspector validator configuration') + } if (value > this.options.max.value) { return this.options.max.message !== undefined ? diff --git a/modules/system/assets/ui/js/inspector.validator.length.js b/modules/system/assets/ui/js/inspector.validator.length.js index ab2c0900c..f23b26516 100644 --- a/modules/system/assets/ui/js/inspector.validator.length.js +++ b/modules/system/assets/ui/js/inspector.validator.length.js @@ -34,8 +34,9 @@ if (this.options.min !== undefined || this.options.max !== undefined) { if (this.options.min !== undefined) { - if (this.options.min.value === undefined) + if (this.options.min.value === undefined) { throw new Error('The min.value parameter is not defined in the Length Inspector validator configuration.') + } if (length < this.options.min.value) { return this.options.min.message !== undefined ? diff --git a/modules/system/assets/ui/js/inspector.wrapper.base.js b/modules/system/assets/ui/js/inspector.wrapper.base.js index d3d020062..46510ec5d 100644 --- a/modules/system/assets/ui/js/inspector.wrapper.base.js +++ b/modules/system/assets/ui/js/inspector.wrapper.base.js @@ -158,7 +158,8 @@ try { return valuesStr.length === 0 ? {} : $.parseJSON(valuesStr) - } catch (err) { + } + catch (err) { throw new Error('Error parsing Inspector field values. ' + err) } } @@ -254,7 +255,7 @@ self = this $.oc.stripeLoadIndicator.show() - var request = $form.request('onGetInspectorConfiguration', { + $form.request('onGetInspectorConfiguration', { data: data }).done(function inspectorConfigurationRequestDoneClosure(data) { self.onConfigurartionRequestDone(data, result) @@ -271,10 +272,12 @@ try { return $.parseJSON(configuration) - } catch(err) { + } + catch(err) { throw new Error('Error parsing Inspector configuration. ' + err) } - } else { + } + else { return configuration } } @@ -326,11 +329,7 @@ values = this.surface.getValues() this.$element.trigger(hidingEvent, [{values: values}]) - if (hidingEvent.isDefaultPrevented()) { - return false - } - - return true + return !hidingEvent.isDefaultPrevented(); } BaseWrapper.DEFAULTS = {