Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions dist/vue-focus.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ if (!compatible) {

var focus = {
inserted: function(el, binding) {
if (binding.value) el.focus();
if (binding.value) {
el.focus();
if (binding.modifiers.select) {
el.select();
}
}
else el.blur();
},

Expand All @@ -23,7 +28,12 @@ var focus = {
}
}

if (binding.value) el.focus();
if (binding.value) {
el.focus();
if (binding.modifiers.select) {
el.select();
}
}
else el.blur();
},
};
Expand Down
14 changes: 12 additions & 2 deletions dist/vue-focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

var focus = {
inserted: function(el, binding) {
if (binding.value) el.focus();
if (binding.value) {
el.focus();
if (binding.modifiers.select) {
el.select();
}
}
else el.blur();
},

Expand All @@ -22,7 +27,12 @@
}
}

if (binding.value) el.focus();
if (binding.value) {
el.focus();
if (binding.modifiers.select) {
el.select();
}
}
else el.blur();
},
};
Expand Down
2 changes: 1 addition & 1 deletion dist/vue-focus.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ <h3><code>Example 4: Custom label</code></h3>
</p>
<p>NOTE: click on the label to focus the input.</p>
</div>
<hr/>

<h3><code>Example 5: Select Text on Focus</code></h3>
<div id="example5">
<div><pre>{{ $data }}</pre></div>
<p>
<input type="text"
value="Change me"
v-focus.select="focused"
@focus="focused = true"
@blur="focused = false"
>
</p>
<p>NOTE: click text input to focus and select text.</p>
</div>

<script>
new Vue({
Expand Down Expand Up @@ -108,6 +123,15 @@ <h3><code>Example 4: Custom label</code></h3>
focused: false,
},
});


new Vue({
el: '#example5',
mixins: [ VueFocus.mixin ],
data: {
focused: false,
},
});
</script>

</body>
Expand Down
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ if (!compatible) {

export var focus = {
inserted: function(el, binding) {
if (binding.value) el.focus();
if (binding.value) {
el.focus();
if (binding.modifiers.select) {
el.select();
}
}
else el.blur();
},

Expand All @@ -20,7 +25,12 @@ export var focus = {
}
}

if (binding.value) el.focus();
if (binding.value) {
el.focus();
if (binding.modifiers.select) {
el.select();
}
}
else el.blur();
},
};
Expand Down