Skip to content

Commit

Permalink
fix bugs in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
xescoder committed Nov 22, 2014
1 parent 7691725 commit a1b3d33
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 40 deletions.
58 changes: 38 additions & 20 deletions examples/js/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,22 @@ $(function () {
$tooltip.hide();
},
check: function (obj) {
var $input = $(this);

if (obj) {
setLabel($(this), obj.type);
setLabel($input, obj.type);
$tooltip.hide();
}
else {
showError($(this), 'Введено неверно');
showError($input, 'Введено неверно');
}
},
checkBefore: function () {
var $input = $(this);

if (!$.trim($input.val())) {
$tooltip.hide();
return false;
}
}
});
Expand Down Expand Up @@ -247,6 +257,16 @@ $(function () {
log(obj);
addressUpdate();
mapUpdate();
},
checkBefore: function () {
var $input = $(this);

if (!$.trim($input.val())) {
log(null);
addressUpdate();
mapUpdate();
return false;
}
}
});

Expand Down Expand Up @@ -288,26 +308,18 @@ $(function () {
function mapUpdate() {
var zoom = 4;

var address = $.kladr.getAddress($container.find('.js-form-address'), function (objs) {
var result = '',
name = '',
type = '';
var address = $.kladr.getAddress('.js-form-address', function (objs) {
var result = '';

for (var i in objs) {
if (objs.hasOwnProperty(i)) {
if ($.type(objs[i]) === 'object') {
name = objs[i].name;
type = ' ' + objs[i].type;
}
else {
name = objs[i];
type = '';
}
$.each(objs, function (i, obj) {
var name = '',
type = '';

if (result) result += ', ';
result += type + name;
if ($.type(obj) === 'object') {
name = obj.name;
type = ' ' + obj.type;

switch (objs[i].contentType) {
switch (obj.contentType) {
case $.kladr.type.region:
zoom = 4;
break;
Expand All @@ -329,7 +341,13 @@ $(function () {
break;
}
}
}
else {
name = obj;
}

if (result) result += ', ';
result += type + name;
});

return result;
});
Expand Down
14 changes: 12 additions & 2 deletions examples/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@ $(function () {
$tooltip.hide();
},
check: function (obj) {
var $input = $(this);

if (obj) {
setLabel($(this), obj.type);
setLabel($input, obj.type);
$tooltip.hide();
}
else {
showError($(this), 'Введено неверно');
showError($input, 'Введено неверно');
}
},
checkBefore: function () {
var $input = $(this);

if (!$.trim($input.val())) {
$tooltip.hide();
return false;
}
}
});
Expand Down
44 changes: 26 additions & 18 deletions examples/js/form_with_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ $(function () {
log(obj);
addressUpdate();
mapUpdate();
},
checkBefore: function () {
var $input = $(this);

if (!$.trim($input.val())) {
log(null);
addressUpdate();
mapUpdate();
return false;
}
}
});

Expand Down Expand Up @@ -100,25 +110,17 @@ $(function () {
var zoom = 4;

var address = $.kladr.getAddress('.js-form-address', function (objs) {
var result = '',
name = '',
type = '';

for (var i in objs) {
if (objs.hasOwnProperty(i)) {
if ($.type(objs[i]) === 'object') {
name = objs[i].name;
type = ' ' + objs[i].type;
}
else {
name = objs[i];
type = '';
}
var result = '';

$.each(objs, function (i, obj) {
var name = '',
type = '';

if (result) result += ', ';
result += type + name;
if ($.type(obj) === 'object') {
name = obj.name;
type = ' ' + obj.type;

switch (objs[i].contentType) {
switch (obj.contentType) {
case $.kladr.type.region:
zoom = 4;
break;
Expand All @@ -140,7 +142,13 @@ $(function () {
break;
}
}
}
else {
name = obj;
}

if (result) result += ', ';
result += type + name;
});

return result;
});
Expand Down

0 comments on commit a1b3d33

Please sign in to comment.