Skip to content

Commit

Permalink
Merge pull request #9 from uxrocket/2.x
Browse files Browse the repository at this point in the history
Input removal and cleanup methods
  • Loading branch information
bcinarli committed Aug 29, 2015
2 parents 4ff9915 + 418447a commit e5d3224
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 28 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: node_js
sudo: false
node_js:
- '0.10'
- '0.12'
before_script:
- npm install -g bower
Expand Down
33 changes: 27 additions & 6 deletions dist/uxrocket.autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
events = {
click: 'click.' + rocketName,
keyup: 'keyup.' + rocketName,
input: 'input.' + rocketName,
blur : 'blur.' + rocketName
},
keys = {
Expand Down Expand Up @@ -186,7 +187,7 @@
this.classList = this.classList.replace(this.selector.substr(1), '');
}

this.classList += ns.wrap + ' ' + utils.getClassname('wrap');
this.classList += ns.wrap + ' ' + utils.getClassname('wrap') + ' ' + utils.getClassname('wrap') + '-' + this._instance;
this.classList = $.trim(this.classList);
},

Expand Down Expand Up @@ -236,6 +237,10 @@
_this.$el.next('.' + utils.getClassname('magnify')).remove();
},

removeContainer: function() {
$('#' + this.id).remove();
},

setTemplate: function() {
this.template = null;

Expand All @@ -250,7 +255,7 @@
bindUIActions: function() {
var _this = this;

_this.$el.on(events.keyup, function(e) {
_this.$el.on(events.keyup + ' ' + events.input, function(e) {
var val = $(this).val(),
_length = val.length;

Expand All @@ -271,6 +276,12 @@
e.preventDefault();
_this.select(e);
});

$('body').on('DOMNodeRemoved', function(e) {
if(e.target === _this.el) {
_this.cleanUp();
}
});
},

select: function($selected) {
Expand Down Expand Up @@ -321,7 +332,7 @@
onBlur: function() {
var _this = this;

setTimeout(function(){
setTimeout(function() {
_this.hideContainer();
}, 150);
},
Expand Down Expand Up @@ -529,6 +540,13 @@

destroy: function() {
return ux.destroy(this.el);
},

cleanUp: function() {
// remove wrapper
$('.' + utils.getClassname('wrap') + '-' + this._instance).remove();

this.removeContainer();
}
});

Expand Down Expand Up @@ -607,7 +625,7 @@
var $el, opts;

// all elements will update according to new options
if(typeof options === 'undefined' && typeof el === 'object'){
if(typeof options === 'undefined' && typeof el === 'object') {
$el = $('.' + utils.getClassname('ready'));
opts = el;
}
Expand All @@ -616,7 +634,7 @@
opts = options;
}

$el.filter('input').each(function(){
$el.filter('input').each(function() {
var _this = $(this),
_instance = _this.data(ns.data),
_opts = _instance.options;
Expand All @@ -625,7 +643,7 @@
_instance.options = $.extend(true, {}, _opts, opts);

// clear cache if cache set to false
if(!_instance.options.cache){
if(!_instance.options.cache) {
ux.clearCache(_this);
}

Expand Down Expand Up @@ -654,6 +672,9 @@
// remove layout
_instance.removeLayout();

// remove container
_instance.removeContainer();

// remove plugin data
_this.removeData(ns.data);

Expand Down
2 changes: 1 addition & 1 deletion dist/uxrocket.autocomplete.min.css

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

2 changes: 1 addition & 1 deletion dist/uxrocket.autocomplete.min.css.map

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

Loading

0 comments on commit e5d3224

Please sign in to comment.