1 line
20 KiB
JavaScript
1 line
20 KiB
JavaScript
|
(function(){window.jProton=function(selector,context){return new jProton.Set().select(selector,context)};window.$=jProton;jProton.namespace=function(ns){if(!ns){return }var n=ns.split(".");var target=window,o;for(var i=0,ni;ni=n[i];i++){target=(o=target[ni])?o:target[ni]={}}return target};jProton.extend=function(){var target=this,t=target,source,p,o,a0=arguments[0],ai=0,al=arguments.length;if(al>1){ai++;target=t=a0}for(;source=arguments[ai];ai++){for(var prop in source){p=source[prop];if(prop.charAt(0)!="@"){if(p&&p.splice){var tp=t[prop];t[prop]=tp&&tp.splice?tp.concat(p):new Array().concat(p)}else{if(p&&typeof p=="object"){t[prop]=jProton.extend(t[prop]||{},p)}else{t[prop]=p}}}else{if(prop=="@init"){p.call(t)}else{if(prop=="@require"){for(var ext in p){var v=p[ext];o=t.extensions[ext]||null;if(!o){throw'A extensão "'+ext+'" deve estar instalada.'}else{if(o<v&&v!="all"){throw'A extensão "'+ext+'" deve ter a versão '+v+" ou superior."}}}}else{if(prop=="@extension"){o=t.extensions||(t.extensions={});for(var name in p){o[name]=p[name]}}}}}}}return target};jProton.extend({"@extension":{core:"0.3.0a"},id:function(id){return document.getElementById(id)},each:function(a,fn){for(var i=0,ai;ai=a[i];i++){fn.call(ai,i,ai)}},trim:function(s){return s.replace(/^\s*|\s*$/g,"")},emptyFn:function(){}});jProton.Set=function(){};jProton.Set.prototype=new Array();jProton.set=jProton.Set.prototype;var set=jProton.set;set.extend=jProton.extend;set.extend({"@extension":{core:"0.3.0a"},_lastSet:null,jproton:"jProton.0.3.9a",_chain:function(e){var r=new jProton().copy(e);r._lastSet=this;return r},select:function(selector,context){var type=typeof selector;if(type=="string"){return this.copy(query.select(selector,context))}else{if(type=="object"){if(selector.nodeName){this.push(selector)}else{if(selector.length){return this.copy(selector)}}}}return this},add:function(selector,context){return this._chain(this).select(selector,context)},find:function(selector){return this._chain().select(selector,this)},filter:function(selector){return this._chain().copy(query.filter(this,selector))},not:function(selector){return this._chain().copy(query.filter(this,selector,true))},next:function(selector){for(var i=0,l=this.length;i<l;i++){while((this[i]=this[i].nextSibling)&&this[i].nodeType!=1){}}return selector?this.filter(selector):this},prev:function(selector){for(var i=0,l=this.length;i<l;i++){while((this[i]=this[i].previousSibling)&&this[i].nodeType!=1){}}return selector?this.filter(selector):this},end:function(){return this._lastSet||new jProton.Set()},each:function(fn){for(var i=0,ei;ei=this[i];i++){fn.call(ei,i)}return this},copy:function(a){if(a){if(a.splice){this.push.apply(this,a)}else{for(var i=0,ai;ai=a[i];i++){this.push(ai)}}}return this}});jProton.namespace("jProton.element");var element=jProton.element;jProton.extend(element,{"@extension":{dom:"0.3.0a"},attr:function(e,key,val){return e?val?e[key]=val:e[key]:undefined},val:function(e,val){if(e){if(val){var valType=typeof val;if(valType=="string"){e.value=val}else{if(valType=="object"){var vl=val.length,tag,type;if((tag=e.nodeName.toLowerCase())=="input"&&((type=e.type)=="checkbox"||type=="radio")){e.checked=false;for(var j=0;j<vl;j++){if(e.value==val[j]){e.checked=true}}}else{if(tag=="select"){for(var o=0,op,op=e.options,ol=o.length;o<ol;o++){if(e.multiple){op[o].selected=false}for(var j=0;j<vl;j++){if(op[o].value==val[j]){op[o].selected=true}}}}}}}}else{if(e.nodeName.toLowerCase()!="select"){return e.value}else{var r=new Array();for(var i=0,o=e.options,ol=o.length;i<ol;i++){if(o[i].selected){r.push(o[i].value)}}return e.multiple?r:r[0]}}}else{return undefined}},text:(function(){var txt=typeof document.textContent!="undefined"?"textContent":"innerText";var text=function(e,val){return e?val?e[txt]=val:e[txt]:undefined};return text})()});set.extend({"@extension":{dom:"0.3.0a"},attr:function(key,val){if(val){for(var i=0,ei;ei=this[i];i++){element.attr(ei,key,val)}return this}else{return element.attr(this[0],key)}},val:function(val){if(val){for(var i=0,ei;ei=this[i];i++){element.val(ei,val)}retu
|