Skip to content

Commit

Permalink
input, textarea: disallow to provide custom content (close #1103)
Browse files Browse the repository at this point in the history
  • Loading branch information
mishanga authored and hcodes committed Nov 27, 2014
1 parent a35a04e commit 310dfdd
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 76 deletions.
5 changes: 1 addition & 4 deletions common.blocks/attach/attach.bemhtml
Expand Up @@ -29,9 +29,6 @@ block('attach')(
content : this.ctx.noFileText
}
];
},
match(function() { return typeof this.ctx.content !== 'undefined'; })(function() {
return this.ctx.content;
})
}
)
);
40 changes: 18 additions & 22 deletions common.blocks/attach/attach.bh.js
Expand Up @@ -3,33 +3,29 @@ module.exports = function(bh) {
bh.match('attach', function(ctx, json) {
ctx
.tParam('_attach', json)

.tag('span')

.js(true);

if(typeof ctx.content() === 'undefined') {
var button = json.button;
typeof button === 'object' || (button = {
block : 'button',
tag : 'span',
text : button
});
var button = json.button;
typeof button === 'object' || (button = {
block : 'button',
tag : 'span',
text : button
});

var attachMods = ctx.mods(),
buttonMods = button.mods || (button.mods = {});
['size', 'theme', 'disabled', 'focused'].forEach(function(mod) {
buttonMods[mod] || (buttonMods[mod] = attachMods[mod]);
});
var attachMods = ctx.mods(),
buttonMods = button.mods || (button.mods = {});
['size', 'theme', 'disabled', 'focused'].forEach(function(mod) {
buttonMods[mod] || (buttonMods[mod] = attachMods[mod]);
});

ctx.content([
button,
{
elem : 'no-file',
content : json.noFileText
}
]);
}
ctx.content([
button,
{
elem : 'no-file',
content : json.noFileText
}
], true);
});

};
7 changes: 0 additions & 7 deletions common.blocks/attach/attach.tmpl-specs/30-content.bemjson.js

This file was deleted.

1 change: 0 additions & 1 deletion common.blocks/attach/attach.tmpl-specs/30-content.html

This file was deleted.

1 change: 0 additions & 1 deletion common.blocks/input/__control/input__control.bemhtml
@@ -1,5 +1,4 @@
block('input').elem('control')(

tag()('input'),

attrs()(function() {
Expand Down
2 changes: 0 additions & 2 deletions common.blocks/input/_has-clear/input_has-clear.bh.js
@@ -1,7 +1,5 @@
module.exports = function(bh) {

bh.match('input_has-clear__box', function(ctx) {
ctx.content([ctx.content(), { elem : 'clear' }], true);
});

};
9 changes: 1 addition & 8 deletions common.blocks/input/input.bemhtml
Expand Up @@ -4,12 +4,5 @@ block('input')(
def()(function() {
applyNext({ _input : this.ctx });
}),
content()(
function() {
return { elem : 'box', content : { elem : 'control' } };
},
match(function() { return typeof this.ctx.content !== 'undefined'; })(function() {
return this.ctx.content;
})
)
content()({ elem : 'box', content : { elem : 'control' } })
);
10 changes: 4 additions & 6 deletions common.blocks/input/input.bh.js
@@ -1,13 +1,11 @@
module.exports = function(bh) {

bh.match('input', function(ctx, json) {
ctx.tag('span')
ctx
.tag('span')
.js(true)
.tParam('_input', json);

if(typeof ctx.content() === 'undefined') {
ctx.content({ elem : 'box', content : { elem : 'control' } });
}
.tParam('_input', json)
.content({ elem : 'box', content : { elem : 'control' } }, true);
});

};
5 changes: 5 additions & 0 deletions common.blocks/input/input.tmpl-specs/40-content.bemjson.js
@@ -0,0 +1,5 @@
({
block : 'input',
val : 'input',
content : 'foobar'
});
1 change: 1 addition & 0 deletions common.blocks/input/input.tmpl-specs/40-content.html
@@ -0,0 +1 @@
<span class="input i-bem" data-bem="{&quot;input&quot;:{}}"><span class="input__box"><input class="input__control" value="input"/></span></span>
5 changes: 1 addition & 4 deletions common.blocks/textarea/textarea.bemhtml
Expand Up @@ -3,8 +3,5 @@ block('textarea')(
def()(function() {
applyNext({ _textarea : this.ctx });
}),

content().match(function() {
return typeof this.ctx.content === 'undefined';
})({ elem : 'control' })
content()({ elem : 'control' })
);
2 changes: 1 addition & 1 deletion common.blocks/textarea/textarea.bh.js
Expand Up @@ -4,7 +4,7 @@ module.exports = function(bh) {
ctx
.js(true)
.tParam('_textarea', json)
.content({ elem : 'control' });
.content({ elem : 'control' }, true);
});

};
@@ -1,8 +1,5 @@
({
block : 'textarea',
val : 'textarea',
content : [
{ elem : 'control' },
{ block : 'icon', mods : { action : 'download' } }
]
content : 'foobar'
});
2 changes: 1 addition & 1 deletion common.blocks/textarea/textarea.tmpl-specs/40-content.html
@@ -1 +1 @@
<div class="textarea i-bem" data-bem="{&quot;textarea&quot;:{}}"><textarea class="textarea__control">textarea</textarea><i class="icon icon_action_download"></i></div>
<div class="textarea i-bem" data-bem="{&quot;textarea&quot;:{}}"><textarea class="textarea__control">textarea</textarea></div>

This file was deleted.

@@ -1 +1 @@
<span class="input input_type_search i-bem" data-bem="{&quot;input&quot;:{}}"><input class="input__control" autocomplete="on" autocorrect="on" autocapitalize="on" spellcheck="true" type="search"/></span>
<span class="input input_type_search i-bem" data-bem="{&quot;input&quot;:{}}"><span class="input__box"><input class="input__control" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" type="search"/></span></span>
1 change: 1 addition & 0 deletions touch.blocks/input/input.tmpl-specs/40-content.html
@@ -0,0 +1 @@
<span class="input i-bem" data-bem="{&quot;input&quot;:{}}"><span class="input__box"><input class="input__control" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" value="input"/></span></span>

This file was deleted.

0 comments on commit 310dfdd

Please sign in to comment.