Skip to content

Commit

Permalink
Release 2.0.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
simplesmiler committed Sep 22, 2016
1 parent 093e796 commit 9d70022
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 248 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [2.0.0-rc1] - 2016-09-22

## Breaking changes
- Vue 2.0 now required
- `v-focus-model` and `v-focus-auto` are removed

## [1.0.0] - 2016-09-22

## Changed
Expand Down Expand Up @@ -30,3 +36,4 @@ Initial release
[0.1.1]: https://github.com/simplesmiler/vue-focus/compare/0.1.0...0.1.1
[0.1.2]: https://github.com/simplesmiler/vue-focus/compare/0.1.1...0.1.2
[1.0.0]: https://github.com/simplesmiler/vue-focus/compare/0.1.2...1.0.0
[2.0.0-rc1]: https://github.com/simplesmiler/vue-focus/compare/1.0.0...2.0.0-rc1
128 changes: 6 additions & 122 deletions dist/vue-focus.common.js
Original file line number Diff line number Diff line change
@@ -1,138 +1,22 @@
'use strict';

var Vue = require('vue');
var Vue__default = 'default' in Vue ? Vue['default'] : Vue;

// @NOTE: We have to use Vue.nextTick because the element might not be
// present at the time model changes, but will be in the next batch.
// But because we use Vue.nextTick, the directive may already be unbound
// by the time the callback executes, so we have to make sure it was not.

var focus = {
priority: 1000,

bind: function() {
var self = this;
this.bound = true;

this.focus = function() {
if (self.bound === true) {
self.el.focus();
}
};

this.blur = function() {
if (self.bound === true) {
self.el.blur();
}
};
},

update: function(value) {
if (value) {
Vue__default.nextTick(this.focus);
} else {
Vue__default.nextTick(this.blur);
}
inserted: function(el, binding) {
if (binding.value) el.focus();
else el.blur();
},

unbind: function() {
this.bound = false;
},
};

var focusModel = {
twoWay: true,
priority: 1000,

bind: function() {
Vue.util.warn(
this.name + '="' +
this.expression + '" is deprecated, ' +
'use v-focus="' + this.expression + '" @focus="' + this.expression + ' = true" @blur="' + this.expression + ' = false" instead'
);

var self = this;
this.bound = true;

this.focus = function() {
if (self.bound === true) {
self.el.focus();
}
};

this.blur = function() {
if (self.bound === true) {
self.el.blur();
}
};

this.focusHandler = function() {
self.set(true);
};

this.blurHandler = function() {
self.set(false);
};

Vue.util.on(this.el, 'focus', this.focusHandler);
Vue.util.on(this.el, 'blur', this.blurHandler);
},

update: function(value) {
if (value === true) {
Vue__default.nextTick(this.focus);
} else if (value === false) {
Vue__default.nextTick(this.blur);
} else {
if (process.env.NODE_ENV !== 'production') {
Vue.util.warn(
this.name + '="' +
this.expression + '" expects a boolean value, ' +
'got ' + JSON.stringify(value)
);
}
}
},

unbind: function() {
Vue.util.off(this.el, 'focus', this.focusHandler);
Vue.util.off(this.el, 'blur', this.blurHandler);
this.bound = false;
},
};

var focusAuto = {
priority: 100,
bind: function() {
Vue.util.warn(
this.name + ' is deprecated, ' +
'use v-focus="true" instead'
);

var self = this;
this.bound = true;

Vue__default.nextTick(function() {
if (self.bound === true) {
self.el.focus();
}
});
},
unbind: function(){
this.bound = false;
componentUpdated: function(el, binding) {
if (binding.value) el.focus();
else el.blur();
},
};

var mixin = {
directives: {
focus: focus,
focusModel: focusModel,
focusAuto: focusAuto,
},
};

exports.focus = focus;
exports.focusModel = focusModel;
exports.focusAuto = focusAuto;
exports.mixin = mixin;
131 changes: 8 additions & 123 deletions dist/vue-focus.js
Original file line number Diff line number Diff line change
@@ -1,139 +1,24 @@
(function (exports,Vue) { 'use strict';

var Vue__default = 'default' in Vue ? Vue['default'] : Vue;

// @NOTE: We have to use Vue.nextTick because the element might not be
// present at the time model changes, but will be in the next batch.
// But because we use Vue.nextTick, the directive may already be unbound
// by the time the callback executes, so we have to make sure it was not.
(function (exports) { 'use strict';

var focus = {
priority: 1000,

bind: function() {
var self = this;
this.bound = true;

this.focus = function() {
if (self.bound === true) {
self.el.focus();
}
};

this.blur = function() {
if (self.bound === true) {
self.el.blur();
}
};
},

update: function(value) {
if (value) {
Vue__default.nextTick(this.focus);
} else {
Vue__default.nextTick(this.blur);
}
inserted: function(el, binding) {
if (binding.value) el.focus();
else el.blur();
},

unbind: function() {
this.bound = false;
},
};

var focusModel = {
twoWay: true,
priority: 1000,

bind: function() {
Vue.util.warn(
this.name + '="' +
this.expression + '" is deprecated, ' +
'use v-focus="' + this.expression + '" @focus="' + this.expression + ' = true" @blur="' + this.expression + ' = false" instead'
);

var self = this;
this.bound = true;

this.focus = function() {
if (self.bound === true) {
self.el.focus();
}
};

this.blur = function() {
if (self.bound === true) {
self.el.blur();
}
};

this.focusHandler = function() {
self.set(true);
};

this.blurHandler = function() {
self.set(false);
};

Vue.util.on(this.el, 'focus', this.focusHandler);
Vue.util.on(this.el, 'blur', this.blurHandler);
},

update: function(value) {
if (value === true) {
Vue__default.nextTick(this.focus);
} else if (value === false) {
Vue__default.nextTick(this.blur);
} else {
if ('development' !== 'production') {
Vue.util.warn(
this.name + '="' +
this.expression + '" expects a boolean value, ' +
'got ' + JSON.stringify(value)
);
}
}
},

unbind: function() {
Vue.util.off(this.el, 'focus', this.focusHandler);
Vue.util.off(this.el, 'blur', this.blurHandler);
this.bound = false;
},
};

var focusAuto = {
priority: 100,
bind: function() {
Vue.util.warn(
this.name + ' is deprecated, ' +
'use v-focus="true" instead'
);

var self = this;
this.bound = true;

Vue__default.nextTick(function() {
if (self.bound === true) {
self.el.focus();
}
});
},
unbind: function(){
this.bound = false;
componentUpdated: function(el, binding) {
if (binding.value) el.focus();
else el.blur();
},
};

var mixin = {
directives: {
focus: focus,
focusModel: focusModel,
focusAuto: focusAuto,
},
};

exports.focus = focus;
exports.focusModel = focusModel;
exports.focusAuto = focusAuto;
exports.mixin = mixin;

})((this.VueFocus = {}),Vue);
})((this.VueFocus = {}));
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.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-focus",
"description": "A set of reusable focus directives for reusable Vue.js components",
"version": "1.0.0",
"version": "2.0.0-rc1",
"author": "Denis Karabaza <[email protected]>",
"browserify": {
"transform": [
Expand Down Expand Up @@ -36,7 +36,7 @@
"license": "MIT",
"main": "dist/vue-focus.common.js",
"peerDependencies": {
"vue": "^1.0.0"
"vue": "^2.0.0"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 9d70022

Please sign in to comment.