Skip to content

Commit

Permalink
dev build
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Oct 10, 2013
1 parent ad3c8f5 commit 7191240
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 21 deletions.
2 changes: 2 additions & 0 deletions dist/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ X-editable changelog

Version 1.5.1 wip
----------------------------
[enh #400] allow `validate` to change submitted value (vitalets)
[enh #396] bs3 popover: placement `auto` (vitalets)
[bug #357] select2: tags mode with space separator (vitalets)
[bug #374] dateui: clear button does not submit (vitalets)

Expand Down
15 changes: 13 additions & 2 deletions dist/bootstrap-editable/js/bootstrap-editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,18 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
//get new value from input
var newValue = this.input.input2value();

// validation: if validate returns truthy value - means error
//validation: if validate returns string or truthy value - means error
//if returns object like {newValue: '...'} => submitted value is reassigned to it
var error = this.validate(newValue);
if (error) {
if ($.type(error) === 'object' && error.newValue !== undefined) {
newValue = error.newValue;
this.input.value2input(newValue);
if(typeof error.msg === 'string') {
this.error(error.msg);
this.showForm();
return;
}
} else if (error) {
this.error(error);
this.showForm();
return;
Expand Down Expand Up @@ -504,6 +513,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
send: 'auto',
/**
Function for client-side validation. If returns string - means validation not passed and string showed as error.
Since 1.5.1 you can modify submitted value by returning object from `validate`:
`{newValue: '...'}` or `{newValue: '...', msg: '...'}`
@property validate
@type function
Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-editable/js/bootstrap-editable.min.js

Large diffs are not rendered by default.

46 changes: 42 additions & 4 deletions dist/bootstrap3-editable/js/bootstrap-editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,18 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
//get new value from input
var newValue = this.input.input2value();

// validation: if validate returns truthy value - means error
//validation: if validate returns string or truthy value - means error
//if returns object like {newValue: '...'} => submitted value is reassigned to it
var error = this.validate(newValue);
if (error) {
if ($.type(error) === 'object' && error.newValue !== undefined) {
newValue = error.newValue;
this.input.value2input(newValue);
if(typeof error.msg === 'string') {
this.error(error.msg);
this.showForm();
return;
}
} else if (error) {
this.error(error);
this.showForm();
return;
Expand Down Expand Up @@ -504,6 +513,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
send: 'auto',
/**
Function for client-side validation. If returns string - means validation not passed and string showed as error.
Since 1.5.1 you can modify submitted value by returning object from `validate`:
`{newValue: '...'}` or `{newValue: '...', msg: '...'}`
@property validate
@type function
Expand Down Expand Up @@ -4774,16 +4785,43 @@ Editableform based on Twitter Bootstrap 3
var placement = typeof this.options.placement == 'function' ?
this.options.placement.call(this, $tip[0], this.$element[0]) :
this.options.placement;

var autoToken = /\s?auto?\s?/i;
var autoPlace = autoToken.test(placement);
if (autoPlace) {
placement = placement.replace(autoToken, '') || 'top';
}


var pos = this.getPosition();
var actualWidth = $tip[0].offsetWidth;
var actualHeight = $tip[0].offsetHeight;

if (autoPlace) {
var $parent = this.$element.parent();

var orgPlacement = placement;
var docScroll = document.documentElement.scrollTop || document.body.scrollTop;
var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth();
var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight();
var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left;

placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' :
placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' :
placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' :
placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' :
placement;

$tip
.removeClass(orgPlacement)
.addClass(placement);
}


var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight);

this.applyPlacement(calculatedOffset, placement);




}).call(this.container());
/*jshint laxcomma: false, eqeqeq: true*/
Expand Down
6 changes: 3 additions & 3 deletions dist/bootstrap3-editable/js/bootstrap-editable.min.js

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions dist/jquery-editable/js/jquery-editable-poshytip.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,18 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
//get new value from input
var newValue = this.input.input2value();

// validation: if validate returns truthy value - means error
//validation: if validate returns string or truthy value - means error
//if returns object like {newValue: '...'} => submitted value is reassigned to it
var error = this.validate(newValue);
if (error) {
if ($.type(error) === 'object' && error.newValue !== undefined) {
newValue = error.newValue;
this.input.value2input(newValue);
if(typeof error.msg === 'string') {
this.error(error.msg);
this.showForm();
return;
}
} else if (error) {
this.error(error);
this.showForm();
return;
Expand Down Expand Up @@ -504,6 +513,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
send: 'auto',
/**
Function for client-side validation. If returns string - means validation not passed and string showed as error.
Since 1.5.1 you can modify submitted value by returning object from `validate`:
`{newValue: '...'}` or `{newValue: '...', msg: '...'}`
@property validate
@type function
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery-editable/js/jquery-editable-poshytip.min.js

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions dist/jqueryui-editable/js/jqueryui-editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,18 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
//get new value from input
var newValue = this.input.input2value();

// validation: if validate returns truthy value - means error
//validation: if validate returns string or truthy value - means error
//if returns object like {newValue: '...'} => submitted value is reassigned to it
var error = this.validate(newValue);
if (error) {
if ($.type(error) === 'object' && error.newValue !== undefined) {
newValue = error.newValue;
this.input.value2input(newValue);
if(typeof error.msg === 'string') {
this.error(error.msg);
this.showForm();
return;
}
} else if (error) {
this.error(error);
this.showForm();
return;
Expand Down Expand Up @@ -504,6 +513,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
send: 'auto',
/**
Function for client-side validation. If returns string - means validation not passed and string showed as error.
Since 1.5.1 you can modify submitted value by returning object from `validate`:
`{newValue: '...'}` or `{newValue: '...', msg: '...'}`
@property validate
@type function
Expand Down
4 changes: 2 additions & 2 deletions dist/jqueryui-editable/js/jqueryui-editable.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/editable-form/editable-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
//get new value from input
var newValue = this.input.input2value();

// validation: if validate returns string or truthy value - means error
// if returns object like {newValue: '...'} => submitted value is reassigned to it
//validation: if validate returns string or truthy value - means error
//if returns object like {newValue: '...'} => submitted value is reassigned to it
var error = this.validate(newValue);
if ($.type(error) === 'object' && error.newValue !== undefined) {
newValue = error.newValue;
Expand Down

0 comments on commit 7191240

Please sign in to comment.