Minor on Inspector

This commit is contained in:
Pásztor Gábor 2015-11-12 11:25:47 +01:00
parent db5fde4749
commit 00bdd0dc06
16 changed files with 57 additions and 53 deletions

View File

@ -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
}
}

View File

@ -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
}

View File

@ -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 @@
</div> \
<div class="modal-footer"> \
<button type="submit" class="btn btn-primary">OK</button> \
<button type="button" class="btn btn-default"data-dismiss="popup">Cancel</button> \
<button type="button" class="btn btn-default" data-dismiss="popup">Cancel</button> \
</div> \
</form>'
}
@ -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

View File

@ -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() {

View File

@ -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

View File

@ -172,7 +172,7 @@
</div> \
<div class="modal-footer"> \
<button type="submit" class="btn btn-primary">OK</button> \
<button type="button" class="btn btn-default"data-dismiss="popup">Cancel</button> \
<button type="button" class="btn btn-default" data-dismiss="popup">Cancel</button> \
</div> \
</form>'
}
@ -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())
}

View File

@ -49,7 +49,7 @@
</div> \
<div class="modal-footer"> \
<button type="submit" class="btn btn-primary">OK</button> \
<button type="button" class="btn btn-default"data-dismiss="popup">Cancel</button> \
<button type="button" class="btn btn-default" data-dismiss="popup">Cancel</button> \
</div> \
</form>'
}

View File

@ -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) {

View File

@ -51,7 +51,7 @@
</div> \
<div class="modal-footer"> \
<button type="submit" class="btn btn-primary">OK</button> \
<button type="button" class="btn btn-default"data-dismiss="popup">Cancel</button> \
<button type="button" class="btn btn-default" data-dismiss="popup">Cancel</button> \
</div> \
</form>'
}

View File

@ -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
}

View File

@ -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) {

View File

@ -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

View File

@ -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) {

View File

@ -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 ?

View File

@ -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 ?

View File

@ -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 = {