core

Core functions of upjs

name up
description selects from document or given context

var el1 = _("#target");
var el2 = _(_.id("role"),"#target");

Comments
name id
description returns the element with given id

var el = _.id("target");

Comments
name tag
description returns html element collection with given tag

var els = _.tag("p");

Comments
name name
description returns html element collection with given name

var el = _.name("username");

Comments
name clss
description returns html element collection with given class

var els = _.clss("content");

Comments
name attr
description returns html element collection with given attribute and value

//returns the elements href equals #goto
var els = _.attr("href","#goto");

Comments
name select
description returns html element collection by applying selector to element

//selects the elements with name equals q from HTMLDIV elements
//and then selects HTMLFORM elements from previous selected set
//and then selects the elements with class equals ede from previous selected set
var els = _.select(document,"name:q@div //selects the elements with name equals q from HTMLDIV elements
//and then selects HTMLFORM elements from previous selected set
//and then selects the elements with class equals ede from previous selected set
var els = _.select(document,"name:q@div form class:ede");

Comments
name create
description returns html element constructing from source

var el = _.create("<div><ul></ul></div>");

Comments
name parent
description returns parent of a dom element

var el = _.parent(_.id("role"));

Comments
name children
description returns children of a dom element

var el = _.children(_.id("role"));

Comments
name next
description returns next dom element

var el = _.next(_.id("role"));

Comments
name prev
description returns previous dom element

var el = _.prev(_.id("role"));

Comments
name first
description returns first child

var el = _.first(_.id("role"));

Comments
name last
description returns last child

var el = _.last(_.id("role"));

Comments
name replace
description replaces old node with new node of element

var el = _.replace(_.id("role"),_.id("old"),_.id("new"));

Comments
name remove
description removes value from element

var el = _.remove(_.id("role"),_.id("child"));

Comments
name append
description appends value to element

var el = _.append(_.id("role"),_.id("child"));

Comments
name insertBefore
description inserts value before the element

var el = _.insertBefore(_.id("role"),"<div><ul></ul></div>");

Comments
name insertAfter
description inserts value after the element

var el = _.insertAfter(_.id("role"),"<div><ul></ul></div>");

Comments
name clone
description returns clone of html element

var el = _.insertAfter(_.id("role"));

Comments
name focus
description focus to element

var el = _.focus(_.id("role"));

Comments
name foreach
description for each list elements applies func

_.foreach(_.children(_.parent(_.id("a"))),function(){
      _.focus(this);
});

Comments
name setAttr
description sets element's name to value

_.setAttr(_.id("role","name","role"));

Comments
name getAttr
description returns element's attribute value

_.getAttr(_.id("role","name"));

Comments
name setStyle
description sets element's style name to value

_.setStyle(_.id("a"),"color : green");

Comments
name getStyle
description returns stle of an element

var el = _.getStyle(_.id("a"));

Comments
name addStyle
description if name is specified replaces with value else adds to style

_.addStyle(_.id("a"),"text-align","right");

Comments
name removeStyle
description removes the style

_.removeStyle(_.id("a"),"text-align");

Comments
name html
description if called with one param returns html string of
an element else replaces html of the element

_.html(_.id("a"),"<div><ul></ul></div>");
var el = _.html(_.id("a"));

Comments
name extend
description extends destination with source

var destination = { foo: "bar", baz: { bang: "zoom" } };
var source = { baz: { thud: "narf" } };
_.extend(destination,source);

Comments
name get
description if called with two params(url,callback) else (url,type,callback)
makes a http get request

_.get("http:yusufaytas.com/upjs/ajax.php",function(data){
     alert(data);
});
_.get("http:yusufaytas.com/upjs/ajax.php","json",function(data){
     alert(data.name);
});

Comments
name post
description if called with two params(url,callback) else if(url,type,callback) or
(url,data,callback) else (url,data,type,callback) makes
a http post request

_.post("http:yusufaytas.com/upjs/ajax.php","name=yusuf",function(data){
     alert(data);
});
_.post("http:yusufaytas.com/upjs/ajax.php","name=yusuf",function(data){
     alert(data);
});
_.post("http:yusufaytas.com/upjs/ajax.php","json",function(data){
     alert(data);
});
_.post("http:yusufaytas.com/upjs/ajax.php","json","name=yusuf",function(data){
     alert(data.name);
});

Comments
name ajax
description makes a ajax request with options

var options = {
     type:'json',success:function(){alert("success!")},
     before:null,asyn:false,callback:function(data){alert(data);}
};
_.ajax("http:yusufaytas.com/upjs/ajax.php",options);

Comments
name attach
description attaches function to events for element

_.attach(_.id("role"),"click mouseover",function(){
     alert("mouseevent");
});

Comments
name loaded
description calls fn when document is loaded

_.loaded(function(){
     alert("window is loaded");
});

Comments
name redirect
description redirects the page to given url

_.redirect("http:www.yusufaytas.com");

Comments
name toggle
description toggles display none with block and vice versa

_.toggle(_("#id"));

Comments
name toggleClass
description toggles display none with clss and vice versa

_.toggle(_("#id"),"myClass");

Comments
name setClass
description sets element class

_.setClass(_("#id"),"myClass");

Comments
name getClass
description returns class name of an element

var clss = _.getClass(_("#id"));

Comments
name removeClass
description removes class of an element

_.removeClass(_("#id"));

Comments

cookie

Extension, provides functions for crud operations on cookie

name cookieEnabled
description checks cookie is enabled or not

if(_.cookie.cookieEnabled())
     alert("Cookies are enabled");

Comments
name setCookie
description sets the cookie

var ch = _.cookie();
ch.setCookie("username","yusufaytas");//or we can give number of day
ch.setCookie("name","yusuf",14);//this cookie will expire within 14 days

Comments
name getCookie
description gets the cookie

var ch = _.cookie();
alert(ch.getCookie("username"));

Comments
name deleteCookie
description deletes the cookie

var ch = _.cookie();
ch.deleteCookie("username");
alert(ch.getCookie("username"));

Comments

effect

Extension, provides events for effects

serializer

Extension, provides functions to serialize objects

name serialize
description serialazes given object

_.redirect("http:www.yusufaytas.com/upjs/form?"+_.validator.serialize(_.tag("form")));

Comments
name serializeForm
description serialazes given form

_.redirect("http:www.yusufaytas.com/upjs/form?"+_.validator.serializeForm(_("#myForm")));

Comments
name serializeJSON
description serialazes given json

var serializedJSON = _.serializer.serializeJSON({
name = "yusuf",
surname = "aytas"
});

Comments
name postJSON
description serialize json and do a post request

//if type is not defined
_.serializer.postJSON("http://www.yusufaytas.com/upjs/ajax.php",{
     name = "yusuf",
     surname = "aytas"
},function(data){
     alert(data);
}); //if type is defined
_.serializer.postJSON("http://www.yusufaytas.com/upjs/ajax.php","xml",{
     name = "yusuf",
     surname = "aytas"
},function(data){
     alert(data);
});

Comments
name postFORM
description serialize form and do a post request

//if type is not defined
_.serializer.postFORM("http://www.yusufaytas.com/upjs/ajax.php",_.tag("FORM"),
function(data){
     alert(data);
}); //if type is defined
_.serializer.postFORM("http://www.yusufaytas.com/upjs/ajax.php","json",
_(".myForm"), function(data){
     alert(data);
});

Comments

styler

Extension, provides functions for styling .

name getStyleSheet
description returns style sheet with given title

_.styler.getStyleSheet("#mysheet");

Comments
name createStyleSheet
description creates style sheet with given content and if
title is specified with a title

_.styler.createStyleSheet("body {border: 2px solid black;
background-color: blue;}","mysheet")

Comments
name addStyleSheet
description adds style sheet to the head of document

_.styler.addStyleSheet(ss);

Comments
name removeStyleSheet
description removes style sheet with given title

_.styler.addStyleSheet("mysheet");

Comments
name setActiveStyleSheet
description activates style sheet with given title
and deactivates others

_.styler.setActiveStyleSheet("mysheet");

Comments
name getActiveStyleSheet
description returns active style sheet

alert(_.styler.getActiveStyleSheet().title);

Comments
name addRule
description adds a rule to style sheet

_.styler.addRule(ss,"div{background-color:pink}");

Comments

util

Extension, provides utility functions

name range
description returns an array by putting ints between start and end

var array = _.util.range(10,29);

Comments
name uniquify
description returns the array by omitting dublicates

var array = {3,2,3}
array = _.util.uniquify(array);

Comments
name copy
description copies an object and returns its copy

var cobj = _.util.copy(obj);

Comments
name indexOf
description looks for an item in the array and returns its location

var loc = _.util.indexOf(array);

Comments
name pushIfNotExist
description if item is not in array, it is pushed

_.util.pushIfNotExist(array,item);

Comments
name endsWith
description returns true if string ends with the text given

_.util.endsWith("if your wish","if");

Comments
name startsWith
description returns true if string starts with the text given

_.util.startsWith("if your wish","wish");

Comments
name trim
description deletes spaces at starts and ends

_util.trim(" upjs "); //returns as "upjs"

Comments

validator

Extension, provides functions for validation

name isInt
description checks the given value is integer or not

alert(_.validator.isInt("8737178adja"));

Comments
name isString
description checks the given value is string or not

alert(_.validator.isString("adjakjda"));

Comments
name isEmail
description checks the given value is email or not

alert(_.validator.isEmail("yusufaytas@gmail.com"));

Comments
name isDate
description checks the given value is date or not

alert(_.validator.isDate("12\11\2011"));

Comments
name isImage
description checks the given value is image or not

alert(_.validator.isImage("http:www.yusufaytas.com/upjs/adada.jpg"));

Comments

plug-ins

Plug-ins developed by using upjs and its extentions

name pager
description returns a div element that contains span collection that handles paging

var probs = {
     10, //maximum page number
     10, //items per page
     101, //number of items
     0, //current page number
     "font-weight:bold", //style of current page
     {
     nxt: _.id("next"), //next page event
     prv: _.id("prev"), //previous page event
     nxtg: _.id("nextG"),//next page group event
     prvg: _.id("prevG") //previous page group event
     },
     fn: function(pageNumber){
     _.redirect("http:www.yusufaytas.com/upjs/pager?pageNumber="+pageNumber);
     } //function to be called when a page is changed
};
_.append(_("#pager"),_.pager(probs));
//if you want to register another object to next event or another
_.pager.nextEvent(_.id("next"));
_.pager.prevEvent(_.id("prev"));
_.pager.nextGEvent(_.id("nextG"));
_.pager.prevGEvent(_.id("prevG"));

Comments