Releases: jNetFramework/jNet
v2.0.1.6
10/6/16, 18:15
Implement tests for methods jNetObject/jNet (Feature #23)
Implement parents (Feature #3)
Implement parent (Feature #2)
now the get method at the undefined index returns array
Fixed more bugs
- parent
- parents
Example (parents):
<div>
<p>hello</p>
<ul id="test1">
<li class="boo"><a href="">1</a></li>
<li class="foo"><a href="">2</a></li>
<li class="bar"><a href="">3</a></li>
</ul>
<div>
<p>hello</p>
<ul id="test2">
<li class="boo"><a href="">1</a></li>
<li class="foo"><a href="">2</a></li>
<li class="bar"><a href="">3</a></li>
</ul>
</div>
</div>
jNet('li').parents('ul'); // #test1, #test2
jNet('li').parents('div'); // div, div
jNet('li').parents(); // ul#test2, div, ul#test1, div, body, html
jNet('li').parents('*', 2); // ul#test2, div, ul#test1, div
jNet('li').parents('*', 3); // ul#test2, div, ul#test1, div, body
jNet('li').parents('*', 4); // ul#test2, div, ul#test1, div, body, html
jNet('div').parents(); // div, body, html
Example (parent):
<div>
<p>hello</p>
<ul id="test1">
<li class="boo"><a href="">1</a></li>
<li class="foo"><a href="">2</a></li>
<li class="bar"><a href="">3</a></li>
</ul>
<div>
<p>hello</p>
<ul id="test2">
<li class="boo"><a href="">1</a></li>
<li class="foo"><a href="">2</a></li>
<li class="bar"><a href="">3</a></li>
</ul>
</div>
</div>
jNet('li').parent(); // #test1, #test2
jNet('li').parent('p'); // jNetObject {length: 0}
jNet('div').parent(); // body, div
jNet('div').parent('div'); // div
10/6/16, 16:40
remove alias jNet.oFn
add global jNetObject
add new method jNet.addMethod
(author: John Resig, http://ejohn.org/blog/javascript-method-overloading/)
test toString is fixed
Example (Overload method jNetObject):
jNetObject.fn.append = (function () {
var parentMethod = jNetObject.fn.append;
return function (selector) {
console.log([this, selector]);
return parentMethod.call(this, selector);
};
})();
Example (jNet.Event):
<ul id="test1">
<li class="boo"><a href="">1</a></li>
<li class="foo"><a href="">2</a></li>
<li class="bar"><a href="">3</a></li>
</ul>
var $ = jNet;
// modification, add method from jNet.Event
$.Event(jNetObject);
jNetObject.fn.append = (function () {
var parentMethod = jNetObject.fn.append;
return function (selector) {
this.trigger('append:selector', selector);
return parentMethod.call(this, selector);
};
})();
var $ul = $('ul');
var index = $ul.find('li').length + 1;
$ul.bind('append:selector', (function () {
var consoleMethods = ['info', 'warn'];
return function (selector) {
console[consoleMethods[index % consoleMethods.length]](
'the element "' + selector + '" has been added to the "ul" element'
);
}
})());
setInterval(function () {
var newLi = $('<li>' + ++index + '</li>');
newLi.hide(0);
newLi.show(450);
$ul.append(newLi);
}, 900);
Example (jNet.addMethod):
// Here’s the function in question:
jNet.addMethod
// and here is how you might use it:
function Users(){
jNet.addMethod(this, "find", function(){
// Find all users...
});
jNet.addMethod(this, "find", function(name){
// Find a user by name
});
jNet.addMethod(this, "find", function(first, last){
// Find a user by first and last name
});
}
// Or, if you wanted to use it with an object prototype:
function Users(){}
jNet.addMethod(Users.prototype, "find", function(){
// Find all users...
});
jNet.addMethod(Users.prototype, "find", function(name){
// Find a user by name
});
jNet.addMethod(Users.prototype, "find", function(first, last){
// Find a user by first and last name
});
var users = new Users();
users.find(); // Finds all
users.find("John"); // Finds users by name
users.find("John", "Resig"); // Finds users by first and last name
users.find("John", "E", "Resig"); // Does nothing
10/6/16, 15:44
Implement jNet.Event
Example:
var Model = jNet.Event(function (options) {
this.id = null;
this.firstname = null;
this.lastname = null;
if (typeof options !== "undefined") {
var self = this;
jNet.each(options, function (key, value) {
self[key] = value;
});
}
return this;
});
var man = new Model({
firstname: 'Alex',
lastname: 'Ivanov',
changeId: function (id) {
this.id = id;
this.trigger('change:id', id);
}
});
man.bind('change:id', function (id) {
console.warn('ID changed to: ' + id);
});
man.changeId(1); // ID changed to: 1
man.changeId(2); // ID changed to: 2
man.changeId(3); // ID changed to: 3
man.changeId(4); // ID changed to: 4
console.info(man);
10/6/16, 15:40
jNet.each is Fixed for Object's. { a: "hello", b: "world" }
if key in object is finite, then callback in first parameter
get number, else string
start developer box
start developer laoder
start developer event (bind, unbind, trigger, one)
test jNet.each added
8/6/16, 22:20
I have replaced "superagent" with "fetch-polyfill" as there
was a naydna a big mistake in work of a framework
https://github.com/undozen/fetch
8/6/16, 10:15
closest is fixed bug
added method matchesSelector
8/6/16, 09:33
the method prepend is fixed
the method prependTo is fixed
new build
8/6/16, 08:51
Implement offsetHeight, offsetWidth
Implement isHidden (used offsetHeight, offsetWidth)
add test for hide method (used isHidden)
add test for show method (used isHidden, css)
returnList is fixed
- offsetHeight
- offsetWidth
- isHidden
Example (offsetHeight):
jNet('div').offsetHeight() // int or array [10, 10, 10..]..
Example (offsetWidth):
jNet('div').offsetWidth() // int or array [10, 10, 10..]..
Example (isHidden):
jNet('div').isHidden() // true or false, or array [true, false, false]...
7/6/16, 16:45
Optimization indexOf
7/6/16, 13:08
add method get
fixed small bugs
- get
7/6/16, 12:56
Implement index (Feature #22)
- index
Example:
%ul
%li 1
%li.foo 2
%li 3
jNet('.foo').index() // 1
jNet('li').index() // [0, 1, 2]
6/6/16, 22:55
Implement appendTo (Feature #18)
Implement prepend (Feature #17)
- appendTo
- prependTo
Example (appendTo):
%ul
%li 1
%li 2
%li 3
jNet('body').append('<hr/>')
// jNetObject {0: body, length: 1}
jNet('body').append('<ul/>')
// jNetObject {0: body, length: 1}
jNet('li').appendTo(jNet('ul').last())
// jNetObject {0: ul, length: 1}
%ul
%hr
%ul
%li 1
%li 2
%li 3
jNet('<li>4</li>').appendTo(jNet('ul').last())
// jNetObject {0: ul, length: 1}
%ul
%hr
%ul
%li 1
%li 2
%li 3
%li 4
Example (prependTo):
%ul
%li 1
%li 2
%li 3
jNet('<li>0</li>').prependTo(jNet('ul'))
// jNetObject {0: ul, length: 1}
%ul
%li 0
%li 1
%li 2
%li 3
6/6/16, 22:15
Implement clientHeight, clientWidth (Feature #21)
- clientHeight
- clientWidth
fixed height, width (Feature #20)
fixed off (Feature #19)
Example (clientHeight, clientWidth):
%nav
%ul
%li 1
%li 2
%li 3
jNet('nav').clientHeight(); // element
jNet('nav').clientWidth(); // element
jNet('li').clientHeight(); // returns array
jNet('li').clientWidth(); // returns array
6/6/16, 19:49
Implement prepend (Feature #16)
Implement append (Feature #15)
Implement text (Feature #13)
Implement insertAfter, insertBefore (Feature #14)
- prepend
- append
- text
- after (old name is insertAfter)
- before (old name is insertBefore)
rename insertAfter to after
rename insertBefore to before
Example (prepend):
<div id="myProjects">
<a href="https://fktpm.ru">fktpm.ru</a>
</div>
jNet('#myProjects').prepend('<a href="https://babichev.net">Babichev</a>');
<div id="myProjects">
<a href="https://babichev.net">Babichev</a>
<a href="https://fktpm.ru">fktpm.ru</a>
</div>
Example (text):
<div id="myProjects">
<a href="https://babichev.net">Babichev</a>
<a href="https://fktpm.ru">fktpm.ru</a>
</div>
jNet('#myProjects').text(); // Babichev fktpm.ru
jNet('#myProjects a').text(); // ["Babichev", "fktpm.ru"]
jNet('#myProjects a').text(function (content, element) {
console.log([content, element]); // no modification text in element a
});
jNet('#myProjects a').text(function (content, element) {
return content + '!'; // result: "Babichev!", "fktpm.ru!"
});
Example (after):
<ul id="test1">
<li><a href="">1</a></li>
<li><a href="">2</a></li>
<li><a href="">3</a></li>
</ul>
jNet('li').after('<li>' + jNet('ul').outerHTML() + '</li>')
<ul id="test1">
<li><a href="">1</a></li>
<li>
<ul id="test1">
<li><a href="">1</a></li>
<li><a href="">2</a></li>
<li><a href="">3</a></li>
</ul>
</li>
<li><a href="">2</a></li>
<li>
<ul id="test1">
<li><a href="">1</a></li>
<li><a href="">2</a></li>
<li><a href="">3</a></li>
</ul>
</li>
<li><a href="">3</a></li>
<li>
<ul id="test1">
<li><a href="">1</a></li>
<li><a href="">2</a></li>
<li><a href="">3</a></li>
</ul>
</li>
</ul>
Example (before):
<ul id="test1">
<li><a href="">1</a></li>
<...