Skip to content

Commit

Permalink
minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
kupriyanenko committed Apr 17, 2014
1 parent 7e85efa commit aed6040
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/attributes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jBone.fn.attr = function(key, value) {
fn.attr = function(key, value) {
var args = arguments,
i = 0,
length = this.length,
Expand Down Expand Up @@ -27,7 +27,7 @@ jBone.fn.attr = function(key, value) {
return this;
};

jBone.fn.val = function(value) {
fn.val = function(value) {
var i = 0,
length = this.length;

Expand All @@ -42,7 +42,7 @@ jBone.fn.val = function(value) {
return this;
};

jBone.fn.css = function(key, value) {
fn.css = function(key, value) {
var args = arguments,
i = 0,
length = this.length,
Expand Down Expand Up @@ -73,7 +73,7 @@ jBone.fn.css = function(key, value) {
return this;
};

jBone.fn.data = function(key, value) {
fn.data = function(key, value) {
var args = arguments, data = {},
i = 0,
length = this.length,
Expand Down
11 changes: 6 additions & 5 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ isFunction = function(el) {
return typeof el === "function";
},
jBone = function(element, data) {
return new jBone.fn.init(element, data);
};
return new fn.init(element, data);
},
fn;

// set previous values and return the instance upon calling the no-conflict mode
jBone.noConflict = function() {
Expand All @@ -39,7 +40,7 @@ jBone.noConflict = function() {
return jBone;
};

jBone.fn = jBone.prototype = {
fn = jBone.fn = jBone.prototype = {
init: function(element, data) {
var elements, tag, wraper, fragment;

Expand Down Expand Up @@ -120,9 +121,9 @@ jBone.fn = jBone.prototype = {
length: 0
};

jBone.fn.constructor = jBone;
fn.constructor = jBone;

jBone.fn.init.prototype = jBone.fn;
fn.init.prototype = fn;

jBone.setId = function(el) {
var jid = el.jid;
Expand Down
8 changes: 4 additions & 4 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jBone.Event = function(event, data) {
}, data);
};

jBone.fn.on = function(event) {
fn.on = function(event) {
var args = arguments,
length = this.length,
i = 0,
Expand Down Expand Up @@ -104,7 +104,7 @@ jBone.fn.on = function(event) {
return this;
};

jBone.fn.one = function(event) {
fn.one = function(event) {
var args = arguments,
i = 0,
length = this.length,
Expand Down Expand Up @@ -138,7 +138,7 @@ jBone.fn.one = function(event) {
return this;
};

jBone.fn.trigger = function(event) {
fn.trigger = function(event) {
var events = [],
i = 0,
length = this.length,
Expand Down Expand Up @@ -174,7 +174,7 @@ jBone.fn.trigger = function(event) {
return this;
};

jBone.fn.off = function(event, fn) {
fn.off = function(event, fn) {
var i = 0,
length = this.length,
removeListener = function(events, eventType, index, el, e) {
Expand Down
10 changes: 5 additions & 5 deletions src/manipulation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jBone.fn.html = function(value) {
fn.html = function(value) {
var args = arguments,
el;

Expand All @@ -14,7 +14,7 @@ jBone.fn.html = function(value) {
return this;
};

jBone.fn.append = function(appended) {
fn.append = function(appended) {
var i = 0,
length = this.length,
setter;
Expand Down Expand Up @@ -48,13 +48,13 @@ jBone.fn.append = function(appended) {
return this;
};

jBone.fn.appendTo = function(to) {
fn.appendTo = function(to) {
jBone(to).append(this);

return this;
};

jBone.fn.empty = function() {
fn.empty = function() {
var i = 0,
length = this.length,
el;
Expand All @@ -70,7 +70,7 @@ jBone.fn.empty = function() {
return this;
};

jBone.fn.remove = function() {
fn.remove = function() {
var i = 0,
length = this.length,
el;
Expand Down
41 changes: 21 additions & 20 deletions src/traversing.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
jBone.fn.find = function(selector) {
fn.find = function(selector) {
var results = [],
i = 0,
length = this.length,
finder;

finder = function(el) {
if (isFunction(el.querySelectorAll)) {
[].forEach.call(el.querySelectorAll(selector), function(found) {
results.push(found);
});
}
};
finder = function(el) {
if (isFunction(el.querySelectorAll)) {
[].forEach.call(el.querySelectorAll(selector), function(found) {
results.push(found);
});
}
};

for (; i < length; i++) {
finder(this[i]);
Expand All @@ -19,39 +17,42 @@ jBone.fn.find = function(selector) {
return jBone(results);
};

jBone.fn.get = function(index) {
fn.get = function(index) {
return this[index];
};

jBone.fn.eq = function(index) {
fn.eq = function(index) {
return jBone(this[index]);
};

jBone.fn.parent = function() {
var results = [], parent;
fn.parent = function() {
var results = [],
parent,
i = 0,
length = this.length;

this.forEach(function(el) {
if (!~results.indexOf(parent = el.parentElement) && parent) {
for (; i < length; i++) {
if (!~results.indexOf(parent = this[i].parentElement) && parent) {
results.push(parent);
}
});
}

return jBone(results);
};

jBone.fn.toArray = function() {
fn.toArray = function() {
return slice.call(this);
};

jBone.fn.is = function() {
fn.is = function() {
var args = arguments;

return this.some(function(el) {
return el.tagName.toLowerCase() === args[0];
});
};

jBone.fn.has = function() {
fn.has = function() {
var args = arguments;

return this.some(function(el) {
Expand Down

0 comments on commit aed6040

Please sign in to comment.