Skip to content
Browse files

death to tabs

  • Loading branch information...
1 parent ef9a1c1 commit cc43696a6a46b104a7ee9487d38cfd211daadc62 @statianzo statianzo committed Sep 23, 2012
Showing with 1,799 additions and 1,763 deletions.
  1. +133 −125 src/jquip.ajax.js
  2. +307 −297 src/jquip.css.js
  3. +64 −57 src/jquip.custom.js
  4. +73 −62 src/jquip.docready.js
  5. +134 −134 src/jquip.events.js
  6. +1,026 −1,026 src/jquip.js
  7. +62 −62 src/jquip.q-min.js
View
258 src/jquip.ajax.js
@@ -1,140 +1,148 @@
$['plug']("ajax", function ($) {
- var xhrs = [
+ var xhrs = [
function () { return new XMLHttpRequest(); },
function () { return new ActiveXObject("Microsoft.XMLHTTP"); },
function () { return new ActiveXObject("MSXML2.XMLHTTP.3.0"); },
function () { return new ActiveXObject("MSXML2.XMLHTTP"); }
- ],
- _xhrf = null;
- function _xhr() {
- if (_xhrf != null) return _xhrf();
- for (var i = 0, l = xhrs.length; i < l; i++) {
- try {
- var f = xhrs[i], req = f();
- if (req != null) {
- _xhrf = f;
- return req;
- }
- } catch (e){}
- }
- return function () { };
- } $['xhr'] = _xhr;
- function _xhrResp(xhr, dataType) {
- dataType = (dataType || xhr.getResponseHeader("Content-Type").split(";")[0]).toLowerCase();
- if (dataType.indexOf("json") >= 0){
- var j = false;
- if(window.JSON){
- j = window.JSON['parse'](xhr.responseText);
- }else{
- j = eval(xhr.responseText);
- }
- return j;
+ ],
+ _xhrf = null;
+
+ function _xhr() {
+ if (_xhrf != null) return _xhrf();
+ for (var i = 0, l = xhrs.length; i < l; i++) {
+ try {
+ var f = xhrs[i], req = f();
+ if (req != null) {
+ _xhrf = f;
+ return req;
}
- if (dataType.indexOf("script") >= 0)
- return eval(xhr.responseText);
- if (dataType.indexOf("xml") >= 0)
- return xhr.responseXML;
- return xhr.responseText;
- } $['_xhrResp'] = _xhrResp;
- $['formData'] = function formData(o) {
- var kvps = [], regEx = /%20/g;
- for (var k in o) kvps.push(encodeURIComponent(k).replace(regEx, "+") + "=" + encodeURIComponent(o[k].toString()).replace(regEx, "+"));
- return kvps.join('&');
+ } catch (e){}
+ }
+ return function () { };
+ } $['xhr'] = _xhr;
+
+ function _xhrResp(xhr, dataType) {
+ dataType = (dataType || xhr.getResponseHeader("Content-Type").split(";")[0]).toLowerCase();
+ if (dataType.indexOf("json") >= 0){
+ var j = false;
+ if(window.JSON){
+ j = window.JSON['parse'](xhr.responseText);
+ }else{
+ j = eval(xhr.responseText);
+ }
+ return j;
+ }
+ if (dataType.indexOf("script") >= 0)
+ return eval(xhr.responseText);
+ if (dataType.indexOf("xml") >= 0)
+ return xhr.responseXML;
+ return xhr.responseText;
+ } $['_xhrResp'] = _xhrResp;
+
+ $['formData'] = function formData(o) {
+ var kvps = [], regEx = /%20/g;
+ for (var k in o) kvps.push(encodeURIComponent(k).replace(regEx, "+") + "=" + encodeURIComponent(o[k].toString()).replace(regEx, "+"));
+ return kvps.join('&');
+ };
+
+ $['each']("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function(i,o){
+ $['fn'][o] = function(f){
+ return this['bind'](o, f);
};
- $['each']("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function(i,o){
- $['fn'][o] = function(f){
- return this['bind'](o, f);
- };
- });
+ });
- function ajax(url, o) {
- var xhr = _xhr(), timer, n = 0;
- if (typeof url === "object") o = url;
- else o['url'] = url;
- o = $['_defaults'](o, { 'userAgent': "XMLHttpRequest", 'lang': "en", 'type': "GET", 'data': null, 'contentType': "application/x-www-form-urlencoded", 'dataType': null, 'processData': true, 'headers': {"X-Requested-With": "XMLHttpRequest" }});
- if (o.timeout) timer = setTimeout(function () { xhr.abort(); if (o.timeoutFn) o.timeoutFn(o.url); }, o.timeout);
- var cbCtx = $(o['context'] || document), evtCtx = cbCtx;
- xhr.onreadystatechange = function() {
- if (xhr.readyState == 4){
- if (timer) clearTimeout(timer);
- if (xhr.status < 300){
- var res, decode = true, dt = o.dataType || "";
- try{
- res = _xhrResp(xhr, dt, o);
- }catch(e){
- decode = false;
- if (o.error)
- o.error(xhr, xhr.status, xhr.statusText);
- evtCtx['trigger'](cbCtx, "ajaxError", [xhr, xhr.statusText, o]);
- }
- if (o['success'] && decode && (dt.indexOf('json')>=0 || !!res))
- o['success'](res);
- evtCtx['trigger'](cbCtx,"ajaxSuccess", [xhr, res, o]);
+ function ajax(url, o) {
+ var xhr = _xhr(), timer, n = 0;
+ if (typeof url === "object") o = url;
+ else o['url'] = url;
+ o = $['_defaults'](o, { 'userAgent': "XMLHttpRequest", 'lang': "en", 'type': "GET", 'data': null, 'contentType': "application/x-www-form-urlencoded", 'dataType': null, 'processData': true, 'headers': {"X-Requested-With": "XMLHttpRequest" }});
+ if (o.timeout) timer = setTimeout(function () { xhr.abort(); if (o.timeoutFn) o.timeoutFn(o.url); }, o.timeout);
+ var cbCtx = $(o['context'] || document), evtCtx = cbCtx;
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4){
+ if (timer) clearTimeout(timer);
+ if (xhr.status < 300){
+ var res, decode = true, dt = o.dataType || "";
+ try{
+ res = _xhrResp(xhr, dt, o);
+ }catch(e){
+ decode = false;
+ if (o.error)
+ o.error(xhr, xhr.status, xhr.statusText);
+ evtCtx['trigger'](cbCtx, "ajaxError", [xhr, xhr.statusText, o]);
+ }
+ if (o['success'] && decode && (dt.indexOf('json')>=0 || !!res))
+ o['success'](res);
+ evtCtx['trigger'](cbCtx,"ajaxSuccess", [xhr, res, o]);
- }
- else {
- if (o.error)
- o.error(xhr, xhr.status, xhr.statusText);
- evtCtx['trigger'](cbCtx, "ajaxError", [xhr, xhr.statusText, o]);
- }
- if (o['complete'])
- o['complete'](xhr, xhr.statusText);
- evtCtx['trigger'](cbCtx, "ajaxComplete", [xhr, o]);
- }
- else if (o['progress']) o['progress'](++n);
- };
- var url = o['url'], data = null;
- var isPost = o['type'] == "POST" || o['type'] == "PUT";
- if( o['data'] && o['processData'] && typeof o['data'] == 'object' )
- data = $['formData'](o['data']);
+ }
+ else {
+ if (o.error)
+ o.error(xhr, xhr.status, xhr.statusText);
+ evtCtx['trigger'](cbCtx, "ajaxError", [xhr, xhr.statusText, o]);
+ }
+ if (o['complete'])
+ o['complete'](xhr, xhr.statusText);
+ evtCtx['trigger'](cbCtx, "ajaxComplete", [xhr, o]);
+ }
+ else if (o['progress']) o['progress'](++n);
+ };
+ var url = o['url'], data = null;
+ var isPost = o['type'] == "POST" || o['type'] == "PUT";
+ if( o['data'] && o['processData'] && typeof o['data'] == 'object' )
+ data = $['formData'](o['data']);
- if (!isPost && data) {
- url += "?" + data;
- data = null;
- }
- xhr.open(o['type'], url);
+ if (!isPost && data) {
+ url += "?" + data;
+ data = null;
+ }
+ xhr.open(o['type'], url);
- try {
- for (var i in o.headers)
- xhr.setRequestHeader(i, o.headers[i]);
- } catch(_) { console.log(_) }
+ try {
+ for (var i in o.headers)
+ xhr.setRequestHeader(i, o.headers[i]);
+ } catch(_) { console.log(_) }
- if (isPost) {
- if(o['contentType'].indexOf('json')>=0)
- data = o['data'];
- xhr.setRequestHeader("Content-Type", o['contentType']);
- }
+ if (isPost) {
+ if(o['contentType'].indexOf('json')>=0)
+ data = o['data'];
+ xhr.setRequestHeader("Content-Type", o['contentType']);
+ }
+
+ xhr.send(data);
+ } $['ajax'] = ajax;
+
+ $['getJSON'] = function (url, data, success, error) {
+ if ($['isFunction'](data)){
+ error = success;
+ success = data;
+ data = null;
+ }
+ ajax({'url': url, 'data': data, 'success': success, 'dataType': 'json'});
+ };
+
+ $['get'] = function (url, data, success, dataType) {
+ if ($['isFunction'](data)) {
+ dataType = success;
+ success = data;
+ data = null;
+ }
+ ajax({'url': url, 'type': "GET", 'data': data, 'success': success, 'dataType': dataType || "text/plain"});
+ };
+
+ $['post'] = function (url, data, success, dataType) {
+ if ($['isFunction'](data)) {
+ dataType = success;
+ success = data;
+ data = null;
+ }
+ ajax({'url': url, 'type': "POST", 'data': data, 'success': success, 'dataType': dataType || "text/plain"});
+ };
- xhr.send(data);
- } $['ajax'] = ajax;
- $['getJSON'] = function (url, data, success, error) {
- if ($['isFunction'](data)){
- error = success;
- success = data;
- data = null;
- }
- ajax({'url': url, 'data': data, 'success': success, 'dataType': 'json'});
- };
- $['get'] = function (url, data, success, dataType) {
- if ($['isFunction'](data)) {
- dataType = success;
- success = data;
- data = null;
- }
- ajax({'url': url, 'type': "GET", 'data': data, 'success': success, 'dataType': dataType || "text/plain"});
- };
- $['post'] = function (url, data, success, dataType) {
- if ($['isFunction'](data)) {
- dataType = success;
- success = data;
- data = null;
- }
- ajax({'url': url, 'type': "POST", 'data': data, 'success': success, 'dataType': dataType || "text/plain"});
- };
- $['getScript'] = function (url, success) {
- return $['get'](url, undefined, success, "script");
- };
+ $['getScript'] = function (url, success) {
+ return $['get'](url, undefined, success, "script");
+ };
- if (!window.JSON)
- $['loadAsync']("http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js");
+ if (!window.JSON)
+ $['loadAsync']("http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js");
});
View
604 src/jquip.css.js
@@ -1,314 +1,324 @@
$['plug']("css", function ($) {
- var doc = document,
- docEl = doc.documentElement,
- ralpha = /alpha\([^)]*\)/i,
- ropacity = /opacity=([^)]*)/,
- rdashAlpha = /-([a-z])/ig,
- rupper = /([A-Z])/g,
- rnumpx = /^-?\d+(?:px)?$/i,
- rnum = /^-?\d/,
- rroot = /^(?:body|html)$/i,
- cssShow = { position: "absolute", visibility: "hidden", display: "block" },
- cssWidth = [ "Left", "Right" ],
- cssHeight = [ "Top", "Bottom" ],
- curCSS,
- getComputedStyle,
- currentStyle,
- fcamelCase = function (all, l) { return l.toUpperCase(); };
-
- $['cssHooks'] = {
- 'opacity': {
- 'get': function (el, comp) {
- if (!comp) return el.style.opacity;
- var ret = curCSS(el, "opacity", "opacity");
- return ret === "" ? "1" : ret;
- }
- }
- };
- $['_each'](["height", "width"], function(k) {
- $['cssHooks'][k] = {
- get: function(el, comp, extra) {
- var val;
- if (comp) {
- if (el.offsetWidth !== 0)
- return getWH(el, k, extra);
+ var doc = document,
+ docEl = doc.documentElement,
+ ralpha = /alpha\([^)]*\)/i,
+ ropacity = /opacity=([^)]*)/,
+ rdashAlpha = /-([a-z])/ig,
+ rupper = /([A-Z])/g,
+ rnumpx = /^-?\d+(?:px)?$/i,
+ rnum = /^-?\d/,
+ rroot = /^(?:body|html)$/i,
+ cssShow = { position: "absolute", visibility: "hidden", display: "block" },
+ cssWidth = [ "Left", "Right" ],
+ cssHeight = [ "Top", "Bottom" ],
+ curCSS,
+ getComputedStyle,
+ currentStyle,
+ fcamelCase = function (all, l) { return l.toUpperCase(); };
- swap(el, cssShow, function() {
- val = getWH( el, k, extra );
- });
- return val;
- }
- },
- set: function(el, val) {
- if (rnumpx.test(val)) {
- val = parseFloat( val );
+ $['cssHooks'] = {
+ 'opacity': {
+ 'get': function (el, comp) {
+ if (!comp) return el.style.opacity;
+ var ret = curCSS(el, "opacity", "opacity");
+ return ret === "" ? "1" : ret;
+ }
+ }
+ };
- if (val >= 0)
- return val + "px";
- } else
- return val;
- }
- };
- });
- function getWH(el, name, extra) {
- var val = name === "width" ? el.offsetWidth : el.offsetHeight,
- which = name === "width" ? cssWidth : cssHeight;
- if (val > 0) {
- if (extra !== "border") {
- $['each']( which, function() {
- if ( !extra )
- val -= parseFloat(css(el, "padding" + this) ) || 0;
- if ( extra === "margin" )
- val += parseFloat(css(el, extra + this) ) || 0;
- else
- val -= parseFloat(css(el, "border" + this + "Width") ) || 0;
- });
- }
- return val + "px";
- }
- return "";
- }
+ $['_each'](["height", "width"], function(k) {
+ $['cssHooks'][k] = {
+ get: function(el, comp, extra) {
+ var val;
+ if (comp) {
+ if (el.offsetWidth !== 0)
+ return getWH(el, k, extra);
- if (!$['support']['opacity']) {
- $['support']['opacity'] = {
- get: function (el, computed) {
- return ropacity.test((computed && el.currentStyle ? el.currentStyle.filter : el.style.filter) || "")
- ? (parseFloat(RegExp.$1) / 100) + ""
- : computed ? "1" : "";
- },
- set: function (el, value) {
- var s = el.style;
- s.zoom = 1;
- var opacity = $['isNaN'](value) ? "" : "alpha(opacity=" + value * 100 + ")", filter = s.filter || "";
- s.filter = ralpha.test(filter) ?
- filter.replace(ralpha, opacity) :
- s.filter + ' ' + opacity;
- }
- };
- }
- if (doc.defaultView && doc.defaultView.getComputedStyle) {
- getComputedStyle = function (el, newName, name) {
- var ret, defaultView, computedStyle;
- name = name.replace(rupper, "-$1").toLowerCase();
- if (!(defaultView = el.ownerDocument.defaultView)) return undefined;
- if ((computedStyle = defaultView.getComputedStyle(el, null))) {
- ret = computedStyle.getPropertyValue(name);
- if (ret === "" && !$['contains'](el.ownerDocument.documentElement, el))
- ret = $['style'](el, name);
- }
- return ret;
- };
- }
- if (doc.documentElement.currentStyle) {
- currentStyle = function (el, name) {
- var left,
- ret = el.currentStyle && el.currentStyle[name],
- rsLeft = el.runtimeStyle && el.runtimeStyle[name],
- style = el.style;
- if (!rnumpx.test(ret) && rnum.test(ret)) {
- left = style.left;
- if (rsLeft) el.runtimeStyle.left = el.currentStyle.left;
- style.left = name === "fontSize" ? "1em" : (ret || 0);
- ret = style.pixelLeft + "px";
- style.left = left;
- if (rsLeft) el.runtimeStyle.left = rsLeft;
- }
- return ret === "" ? "auto" : ret;
- };
- }
- curCSS = getComputedStyle || currentStyle;
+ swap(el, cssShow, function() {
+ val = getWH( el, k, extra );
+ });
+ return val;
+ }
+ },
+ set: function(el, val) {
+ if (rnumpx.test(val)) {
+ val = parseFloat( val );
- $['fn']['css'] = function (name, value) {
- if (arguments.length === 2 && value === undefined) return this;
+ if (val >= 0)
+ return val + "px";
+ } else
+ return val;
+ }
+ };
+ });
- return access(this, name, value, true, function (el, name, value) {
- return value !== undefined ? style(el, name, value) : css(el, name);
+ function getWH(el, name, extra) {
+ var val = name === "width" ? el.offsetWidth : el.offsetHeight,
+ which = name === "width" ? cssWidth : cssHeight;
+ if (val > 0) {
+ if (extra !== "border") {
+ $['each']( which, function() {
+ if ( !extra )
+ val -= parseFloat(css(el, "padding" + this) ) || 0;
+ if ( extra === "margin" )
+ val += parseFloat(css(el, extra + this) ) || 0;
+ else
+ val -= parseFloat(css(el, "border" + this + "Width") ) || 0;
});
+ }
+ return val + "px";
+ }
+ return "";
+ }
+
+ if (!$['support']['opacity']) {
+ $['support']['opacity'] = {
+ get: function (el, computed) {
+ return ropacity.test((computed && el.currentStyle ? el.currentStyle.filter : el.style.filter) || "")
+ ? (parseFloat(RegExp.$1) / 100) + ""
+ : computed ? "1" : "";
+ },
+ set: function (el, value) {
+ var s = el.style;
+ s.zoom = 1;
+ var opacity = $['isNaN'](value) ? "" : "alpha(opacity=" + value * 100 + ")", filter = s.filter || "";
+ s.filter = ralpha.test(filter) ?
+ filter.replace(ralpha, opacity) :
+ s.filter + ' ' + opacity;
+ }
+ };
+ }
+
+ if (doc.defaultView && doc.defaultView.getComputedStyle) {
+ getComputedStyle = function (el, newName, name) {
+ var ret, defaultView, computedStyle;
+ name = name.replace(rupper, "-$1").toLowerCase();
+ if (!(defaultView = el.ownerDocument.defaultView)) return undefined;
+ if ((computedStyle = defaultView.getComputedStyle(el, null))) {
+ ret = computedStyle.getPropertyValue(name);
+ if (ret === "" && !$['contains'](el.ownerDocument.documentElement, el))
+ ret = $['style'](el, name);
+ }
+ return ret;
};
- $['cssNumber'] = { "zIndex": true, "fontWeight": true, "opacity": true, "zoom": true, "lineHeight": true };
- $['cssProps'] = { "float": $['support']['cssFloat'] ? "cssFloat" : "styleFloat" };
- function style(el, name, value, extra) {
- if (!el || el.nodeType === 3 || el.nodeType === 8 || !el.style) return;
- var ret, origName = camelCase(name), style = el.style, hooks = $['cssHooks'][origName];
- name = $['cssProps'][origName] || origName;
- if (value !== undefined) {
- if (typeof value === "number" && isNaN(value) || value == null) return;
- if (typeof value === "number" && !$['cssNumber'][origName]) value += "px";
- if (!hooks || !("set" in hooks) || (value = hooks.set(el, value)) !== undefined) {
- try {
- style[name] = value;
- } catch (e) { }
- }
- } else {
- if (hooks && "get" in hooks && (ret = hooks.get(el, false, extra)) !== undefined)
- return ret;
- return style[name];
- }
- } $['style'] = style;
- function css(el, name, extra) {
- var ret, origName = camelCase(name), hooks = $['cssHooks'][origName];
- name = $['cssProps'][origName] || origName;
- if (hooks && "get" in hooks && (ret = hooks.get(el, true, extra)) !== undefined) return ret;
- else if (curCSS) return curCSS(el, name, origName);
- }$['css'] = css;
- function swap(el, opt, cb) {
- var old = {},k;
- for (var k in opt) {
- old[k] = el.style[k];
- el.style[k] = opt[k];
- }
- cb.call(el);
- for (k in opt) el.style[k] = old[k];
- }$['swap'] = swap;
- function camelCase(s) { return s.replace(rdashAlpha, fcamelCase); } $['camelCase'] = camelCase;
- function access(els, key, value, exec, fn, pass) {
- var l = els.length;
- if (typeof key === "object") {
- for (var k in key) {
- access(els, k, key[k], exec, fn, value);
- }
- return els;
- }
- if (value !== undefined) {
- exec = !pass && exec && $['isFunction'](value);
- for (var i = 0; i < l; i++)
- fn(els[i], key, exec ? value.call(els[i], i, fn(els[i], key)) : value, pass);
- return els;
+ }
+
+ if (doc.documentElement.currentStyle) {
+ currentStyle = function (el, name) {
+ var left,
+ ret = el.currentStyle && el.currentStyle[name],
+ rsLeft = el.runtimeStyle && el.runtimeStyle[name],
+ style = el.style;
+ if (!rnumpx.test(ret) && rnum.test(ret)) {
+ left = style.left;
+ if (rsLeft) el.runtimeStyle.left = el.currentStyle.left;
+ style.left = name === "fontSize" ? "1em" : (ret || 0);
+ ret = style.pixelLeft + "px";
+ style.left = left;
+ if (rsLeft) el.runtimeStyle.left = rsLeft;
+ }
+ return ret === "" ? "auto" : ret;
+ };
+ }
+ curCSS = getComputedStyle || currentStyle;
+
+ $['fn']['css'] = function (name, value) {
+ if (arguments.length === 2 && value === undefined) return this;
+
+ return access(this, name, value, true, function (el, name, value) {
+ return value !== undefined ? style(el, name, value) : css(el, name);
+ });
+ };
+ $['cssNumber'] = { "zIndex": true, "fontWeight": true, "opacity": true, "zoom": true, "lineHeight": true };
+ $['cssProps'] = { "float": $['support']['cssFloat'] ? "cssFloat" : "styleFloat" };
+ function style(el, name, value, extra) {
+ if (!el || el.nodeType === 3 || el.nodeType === 8 || !el.style) return;
+ var ret, origName = camelCase(name), style = el.style, hooks = $['cssHooks'][origName];
+ name = $['cssProps'][origName] || origName;
+ if (value !== undefined) {
+ if (typeof value === "number" && isNaN(value) || value == null) return;
+ if (typeof value === "number" && !$['cssNumber'][origName]) value += "px";
+ if (!hooks || !("set" in hooks) || (value = hooks.set(el, value)) !== undefined) {
+ try {
+ style[name] = value;
+ } catch (e) { }
+ }
+ } else {
+ if (hooks && "get" in hooks && (ret = hooks.get(el, false, extra)) !== undefined)
+ return ret;
+ return style[name];
+ }
+ } $['style'] = style;
+
+ function css(el, name, extra) {
+ var ret, origName = camelCase(name), hooks = $['cssHooks'][origName];
+ name = $['cssProps'][origName] || origName;
+ if (hooks && "get" in hooks && (ret = hooks.get(el, true, extra)) !== undefined) return ret;
+ else if (curCSS) return curCSS(el, name, origName);
+ }$['css'] = css;
+
+ function swap(el, opt, cb) {
+ var old = {},k;
+ for (var k in opt) {
+ old[k] = el.style[k];
+ el.style[k] = opt[k];
+ }
+ cb.call(el);
+ for (k in opt) el.style[k] = old[k];
+ }$['swap'] = swap;
+
+ function camelCase(s) { return s.replace(rdashAlpha, fcamelCase); } $['camelCase'] = camelCase;
+
+ function access(els, key, value, exec, fn, pass) {
+ var l = els.length;
+ if (typeof key === "object") {
+ for (var k in key) {
+ access(els, k, key[k], exec, fn, value);
+ }
+ return els;
+ }
+ if (value !== undefined) {
+ exec = !pass && exec && $['isFunction'](value);
+ for (var i = 0; i < l; i++)
+ fn(els[i], key, exec ? value.call(els[i], i, fn(els[i], key)) : value, pass);
+ return els;
+ }
+ return l ? fn(els[0], key) : undefined;
+ }
+
+ var init, noMarginBodyOff, subBorderForOverflow, suppFixedPos, noAddBorder, noAddBorderForTables,
+ initialize = function() {
+ if (init) return;
+ var body = doc.body, c = doc.createElement("div"), iDiv, cDiv , table, td, bodyMarginTop = parseFloat(css(body, "marginTop")) || 0,
+ html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+ $['extend'](c.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" });
+ c.innerHTML = html;
+ body.insertBefore(c, body.firstChild);
+ iDiv = c.firstChild;
+ cDiv = iDiv.firstChild;
+ td = iDiv.nextSibling.firstChild.firstChild;
+ noAddBorder = (cDiv .offsetTop !== 5);
+ noAddBorderForTables = (td.offsetTop === 5);
+ cDiv .style.position = "fixed";
+ cDiv .style.top = "20px";
+ suppFixedPos = (cDiv .offsetTop === 20 || cDiv .offsetTop === 15);
+ cDiv .style.position = cDiv .style.top = "";
+ iDiv.style.overflow = "hidden";
+ iDiv.style.position = "relative";
+ subBorderForOverflow = (cDiv .offsetTop === -5);
+ noMarginBodyOff = (body.offsetTop !== bodyMarginTop);
+ body.removeChild(c);
+ init = true;
+ },
+ bodyOffset = function(body){
+ var top = body.offsetTop, left = body.offsetLeft;
+ initialize();
+ if (noMarginBodyOff){
+ top += parseFloat( css(body, "marginTop") ) || 0;
+ left += parseFloat( css(body, "marginLeft") ) || 0;
}
- return l ? fn(els[0], key) : undefined;
- }
+ return { top: top, left: left };
+ };
- var init, noMarginBodyOff, subBorderForOverflow, suppFixedPos, noAddBorder, noAddBorderForTables,
- initialize = function() {
- if (init) return;
- var body = doc.body, c = doc.createElement("div"), iDiv, cDiv , table, td, bodyMarginTop = parseFloat(css(body, "marginTop")) || 0,
- html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
- $['extend'](c.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" });
- c.innerHTML = html;
- body.insertBefore(c, body.firstChild);
- iDiv = c.firstChild;
- cDiv = iDiv.firstChild;
- td = iDiv.nextSibling.firstChild.firstChild;
- noAddBorder = (cDiv .offsetTop !== 5);
- noAddBorderForTables = (td.offsetTop === 5);
- cDiv .style.position = "fixed";
- cDiv .style.top = "20px";
- suppFixedPos = (cDiv .offsetTop === 20 || cDiv .offsetTop === 15);
- cDiv .style.position = cDiv .style.top = "";
- iDiv.style.overflow = "hidden";
- iDiv.style.position = "relative";
- subBorderForOverflow = (cDiv .offsetTop === -5);
- noMarginBodyOff = (body.offsetTop !== bodyMarginTop);
- body.removeChild(c);
- init = true;
- },
- bodyOffset = function(body){
- var top = body.offsetTop, left = body.offsetLeft;
- initialize();
- if (noMarginBodyOff){
- top += parseFloat( css(body, "marginTop") ) || 0;
- left += parseFloat( css(body, "marginLeft") ) || 0;
- }
- return { top: top, left: left };
- };
+ $['fn']['offset'] = function(){
+ var el = this[0], box;
+ if (!el || !el.ownerDocument) return null;
+ if (el === el.ownerDocument.body) return bodyOffset(el);
+ try {
+ box = el.getBoundingClientRect();
+ } catch(e) {}
+ if (!box || !$['contains'](docEl, el))
+ return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
+ var body = doc.body,
+ win = getWin(doc),
+ clientTop = docEl.clientTop || body.clientTop || 0,
+ clientLeft = docEl.clientLeft || body.clientLeft || 0,
+ scrollTop = win['pageYOffset'] || $['support']['boxModel'] && docEl.scrollTop || body.scrollTop,
+ scrollLeft = win['pageXOffset'] || $['support']['boxModel'] && docEl.scrollLeft || body.scrollLeft,
+ top = box.top + scrollTop - clientTop,
+ left = box.left + scrollLeft - clientLeft;
+ return { top: top, left: left };
+ };
- $['fn']['offset'] = function(){
- var el = this[0], box;
- if (!el || !el.ownerDocument) return null;
- if (el === el.ownerDocument.body) return bodyOffset(el);
- try {
- box = el.getBoundingClientRect();
- } catch(e) {}
- if (!box || !$['contains'](docEl, el))
- return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
- var body = doc.body,
- win = getWin(doc),
- clientTop = docEl.clientTop || body.clientTop || 0,
- clientLeft = docEl.clientLeft || body.clientLeft || 0,
- scrollTop = win['pageYOffset'] || $['support']['boxModel'] && docEl.scrollTop || body.scrollTop,
- scrollLeft = win['pageXOffset'] || $['support']['boxModel'] && docEl.scrollLeft || body.scrollLeft,
- top = box.top + scrollTop - clientTop,
- left = box.left + scrollLeft - clientLeft;
- return { top: top, left: left };
- };
- $['fn']['position'] = function() {
- if (!this[0]) return null;
- var el = this[0],
- offPar = this['offsetParent'](),
- off = this['offset'](),
- parOff = rroot.test(offPar[0].nodeName) ? { top: 0, left: 0 } : offPar['offset']();
- off.top -= parseFloat(css(el, "marginTop")) || 0;
- off.left -= parseFloat(css(el, "marginLeft")) || 0;
- parOff.top += parseFloat(css(offPar[0], "borderTopWidth")) || 0;
- parOff.left += parseFloat(css(offPar[0], "borderLeftWidth")) || 0;
- return { top: off.top - parOff.top, left: off.left - parOff.left };
- };
- $['fn']['offsetParent'] = function(){
- return this['map'](function(){
- var op = this.offsetParent || doc.body;
- while (op && (!rroot.test(op.nodeName) && css(op,"position") === "static"))
- op = op.offsetParent;
- return op;
- });
- };
+ $['fn']['position'] = function() {
+ if (!this[0]) return null;
+ var el = this[0],
+ offPar = this['offsetParent'](),
+ off = this['offset'](),
+ parOff = rroot.test(offPar[0].nodeName) ? { top: 0, left: 0 } : offPar['offset']();
+ off.top -= parseFloat(css(el, "marginTop")) || 0;
+ off.left -= parseFloat(css(el, "marginLeft")) || 0;
+ parOff.top += parseFloat(css(offPar[0], "borderTopWidth")) || 0;
+ parOff.left += parseFloat(css(offPar[0], "borderLeftWidth")) || 0;
+ return { top: off.top - parOff.top, left: off.left - parOff.left };
+ };
- $['_each'](["Height", "Width"], function (name, i) {
- var type = name.toLowerCase();
- $['fn']["inner" + name] = function () {
- var el = this[0];
- return el && el.style ? parseFloat(css(el, type, "padding")) : null;
- };
- $['fn']["outer" + name] = function (margin) {
- var el = this[0];
- return el && el.style ? parseFloat(css(el, type, margin ? "margin" : "border")) : null;
- };
- $['fn'][type] = function (size) {
- var el = this[0];
- if (!el) return size == null ? null : this;
- if ($['isFunction'](size))
- return this['each'](function (i) {
- var self = $(this);
- self[type](size.call(this, i, self[type]()));
- });
- if ($['isWindow'](el)) {
- var docElProp = el.document.documentElement["client" + name], body = el.document.body;
- return el.document.compatMode === "CSS1Compat" && docElProp || body && body["client" + name] || docElProp;
- } else if (el.nodeType === 9) {
- return Math.max(
- el.documentElement["client" + name],
- el.body["scroll" + name], el.documentElement["scroll" + name],
- el.body["offset" + name], el.documentElement["offset" + name]);
- } else if (size === undefined) {
- var orig = css(el, type),
- ret = parseFloat(orig);
- return $['isNaN'](ret) ? orig : ret;
- }
- else return this['css'](type, typeof size === "string" ? size : size + "px");
- };
+ $['fn']['offsetParent'] = function(){
+ return this['map'](function(){
+ var op = this.offsetParent || doc.body;
+ while (op && (!rroot.test(op.nodeName) && css(op,"position") === "static"))
+ op = op.offsetParent;
+ return op;
});
+ };
- function getWin(el) { return $['isWindow'](el) ? el : el.nodeType === 9 ? el.defaultView || el.parentWindow : false; }
+ $['_each'](["Height", "Width"], function (name, i) {
+ var type = name.toLowerCase();
+ $['fn']["inner" + name] = function () {
+ var el = this[0];
+ return el && el.style ? parseFloat(css(el, type, "padding")) : null;
+ };
+ $['fn']["outer" + name] = function (margin) {
+ var el = this[0];
+ return el && el.style ? parseFloat(css(el, type, margin ? "margin" : "border")) : null;
+ };
+ $['fn'][type] = function (size) {
+ var el = this[0];
+ if (!el) return size == null ? null : this;
+ if ($['isFunction'](size))
+ return this['each'](function (i) {
+ var self = $(this);
+ self[type](size.call(this, i, self[type]()));
+ });
+ if ($['isWindow'](el)) {
+ var docElProp = el.document.documentElement["client" + name], body = el.document.body;
+ return el.document.compatMode === "CSS1Compat" && docElProp || body && body["client" + name] || docElProp;
+ } else if (el.nodeType === 9) {
+ return Math.max(
+ el.documentElement["client" + name],
+ el.body["scroll" + name], el.documentElement["scroll" + name],
+ el.body["offset" + name], el.documentElement["offset" + name]);
+ } else if (size === undefined) {
+ var orig = css(el, type),
+ ret = parseFloat(orig);
+ return $['isNaN'](ret) ? orig : ret;
+ }
+ else return this['css'](type, typeof size === "string" ? size : size + "px");
+ };
+ });
- $['_each'](["Left", "Top"], function (name, i) {
- var method = "scroll" + name;
- $['fn'][method] = function (val) {
- var el, win;
- if (val === undefined) {
- el = this[0];
- if (!el) return null;
- win = getWin(el);
- return win ? ("pageXOffset" in win)
- ? win[i ? "pageYOffset" : "pageXOffset"]
- : $['support']['boxModel'] && win.document.documentElement[method] || win.document.body[method] : el[method];
- }
- return this['each'](function() {
- win = getWin(this);
- if (win)
- win['scrollTo'](!i ? val : $(win)['scrollLeft'](), i ? val : $(win)['scrollTop']());
- else
- this[method] = val;
- });
- };
- });
+ function getWin(el) { return $['isWindow'](el) ? el : el.nodeType === 9 ? el.defaultView || el.parentWindow : false; }
+
+ $['_each'](["Left", "Top"], function (name, i) {
+ var method = "scroll" + name;
+ $['fn'][method] = function (val) {
+ var el, win;
+ if (val === undefined) {
+ el = this[0];
+ if (!el) return null;
+ win = getWin(el);
+ return win ? ("pageXOffset" in win)
+ ? win[i ? "pageYOffset" : "pageXOffset"]
+ : $['support']['boxModel'] && win.document.documentElement[method] || win.document.body[method] : el[method];
+ }
+ return this['each'](function() {
+ win = getWin(this);
+ if (win)
+ win['scrollTo'](!i ? val : $(win)['scrollLeft'](), i ? val : $(win)['scrollTop']());
+ else
+ this[method] = val;
+ });
+ };
+ });
});
View
121 src/jquip.custom.js
@@ -1,61 +1,68 @@
$['plug']("custom", function($){
- var win=window, doc=document, qsMap = {},
- vars = win.location.search.substring(1).split("&");
+ var win=window, doc=document, qsMap = {},
+ vars = win.location.search.substring(1).split("&"),
+ Key = $['Key'] = function (keyCode) { this.keyCode = keyCode; };
- for (var i = 0; i < vars.length; i++) {
- var kvp = vars[i].split("=");
- qsMap[kvp[0]] = unescape(kvp[1]);
+ for (var i = 0; i < vars.length; i++) {
+ var kvp = vars[i].split("=");
+ qsMap[kvp[0]] = unescape(kvp[1]);
+ }
+
+ $['queryString'] = function (name) { return qsMap[name]; };
+
+ Key.namedKeys = {
+ Backspace: 8, Tab: 9, Enter: 13, Shift: 16, Ctrl: 17, Alt: 18, Pause: 19, Capslock: 20, Escape: 27, PageUp: 33,
+ PageDown: 34, End: 35, Home: 36, LeftArrow: 37, UpArrow: 38, RightArrow: 39, DownArrow: 40, Insert: 45, Delete: 46
+ };
+
+ $['_each'](Key.namedKeys, function (val, key) {
+ var keyCode = val;
+ Key.prototype['is' + key] = function () { return this.keyCode === keyCode; };
+ });
+
+ $.key = function (e) {
+ e = e || window.event;
+ return new Key(e.keyCode || e.which);
+ };
+
+ $['cancelEvent'] = function (e) {
+ if (!e) e = window.event;
+ e.cancelBubble = true;
+ e.returnValue = false;
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ e.preventDefault();
}
- $['queryString'] = function (name) { return qsMap[name]; };
- var Key = $['Key'] = function (keyCode) { this.keyCode = keyCode; };
- Key.namedKeys = {
- Backspace: 8, Tab: 9, Enter: 13, Shift: 16, Ctrl: 17, Alt: 18, Pause: 19, Capslock: 20, Escape: 27, PageUp: 33,
- PageDown: 34, End: 35, Home: 36, LeftArrow: 37, UpArrow: 38, RightArrow: 39, DownArrow: 40, Insert: 45, Delete: 46
- };
- $['_each'](Key.namedKeys, function (val, key) {
- var keyCode = val;
- Key.prototype['is' + key] = function () { return this.keyCode === keyCode; };
- });
- $.key = function (e) {
- e = e || window.event;
- return new Key(e.keyCode || e.which);
- };
- $['cancelEvent'] = function (e) {
- if (!e) e = window.event;
- e.cancelBubble = true;
- e.returnValue = false;
- if (e.stopPropagation) {
- e.stopPropagation();
- e.preventDefault();
- }
- return false;
- };
- $['templateSettings'] = {
- evaluate : /<%([\s\S]+?)%>/g,
- interpolate : /<%=([\s\S]+?)%>/g,
- escape : /<%-([\s\S]+?)%>/g
- };
- $['_template'] = function(str, data) {
- var c = $['templateSettings'];
- var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
- 'with(obj||{}){__p.push(\'' +
- str.replace(/\\/g, '\\\\')
- .replace(/'/g, "\\'")
- .replace(c.escape, function(match, code) {
- return "',_.escape(" + code.replace(/\\'/g, "'") + "),'";
- })
- .replace(c.interpolate, function(match, code) {
- return "'," + code.replace(/\\'/g, "'") + ",'";
- })
- .replace(c.evaluate || null, function(match, code) {
- return "');" + code.replace(/\\'/g, "'")
- .replace(/[\r\n\t]/g, ' ') + ";__p.push('";
- })
- .replace(/\r/g, '\\r')
- .replace(/\n/g, '\\n')
- .replace(/\t/g, '\\t')
- + "');}return __p.join('');";
- var func = new Function('obj', '$', tmpl);
- return data ? func(data, $) : function(data) { return func(data, $) };
- };
+ return false;
+ };
+
+ $['templateSettings'] = {
+ evaluate : /<%([\s\S]+?)%>/g,
+ interpolate : /<%=([\s\S]+?)%>/g,
+ escape : /<%-([\s\S]+?)%>/g
+ };
+
+ $['_template'] = function(str, data) {
+ var c = $['templateSettings'];
+ var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
+ 'with(obj||{}){__p.push(\'' +
+ str.replace(/\\/g, '\\\\')
+ .replace(/'/g, "\\'")
+ .replace(c.escape, function(match, code) {
+ return "',_.escape(" + code.replace(/\\'/g, "'") + "),'";
+ })
+ .replace(c.interpolate, function(match, code) {
+ return "'," + code.replace(/\\'/g, "'") + ",'";
+ })
+ .replace(c.evaluate || null, function(match, code) {
+ return "');" + code.replace(/\\'/g, "'")
+ .replace(/[\r\n\t]/g, ' ') + ";__p.push('";
+ })
+ .replace(/\r/g, '\\r')
+ .replace(/\n/g, '\\n')
+ .replace(/\t/g, '\\t')
+ + "');}return __p.join('');";
+ var func = new Function('obj', '$', tmpl);
+ return data ? func(data, $) : function(data) { return func(data, $) };
+ };
});
View
135 src/jquip.docready.js
@@ -1,68 +1,79 @@
$['plug']("docready", function ($) {
- var win = window, doc = document, DOMContentLoaded, readyBound, readyList = [], isReady = false, readyWait = 1;
- $['hook'](function (sel, ctx) {
- if (typeof sel == "function") {
- this['ready'](sel);
- return true;
- }
- });
- function doScrollCheck() {
- if (isReady) return;
- try {
- doc.documentElement.doScroll("left");
- } catch (e) {
- setTimeout(doScrollCheck, 1);
- return;
- }
- ready();
+ var win = window,
+ doc = document,
+ DOMContentLoaded,
+ readyBound,
+ readyList = [],
+ isReady = false,
+ readyWait = 1;
+
+ $['hook'](function (sel, ctx) {
+ if (typeof sel == "function") {
+ this['ready'](sel);
+ return true;
+ }
+ });
+
+ function doScrollCheck() {
+ if (isReady) return;
+ try {
+ doc.documentElement.doScroll("left");
+ } catch (e) {
+ setTimeout(doScrollCheck, 1);
+ return;
+ }
+ ready();
+ }
+
+ function ready(wait) {
+ if (wait === true) readyWait--;
+ if (!readyWait || (wait !== true && !isReady)) {
+ if (!doc.body) return setTimeout(ready, 1);
+ isReady = true;
+ if (wait !== true && --readyWait > 0) return;
+ if (readyList) {
+ var fn, i = 0, ready = readyList;
+ readyList = null;
+ while ((fn = ready[i++])) fn.call(doc, $);
+ if ($['fn']['trigger']) $(doc)['trigger']("ready")['unbind']("ready");
+ }
}
- function ready(wait) {
- if (wait === true) readyWait--;
- if (!readyWait || (wait !== true && !isReady)) {
- if (!doc.body) return setTimeout(ready, 1);
- isReady = true;
- if (wait !== true && --readyWait > 0) return;
- if (readyList) {
- var fn, i = 0, ready = readyList;
- readyList = null;
- while ((fn = ready[i++])) fn.call(doc, $);
- if ($['fn']['trigger']) $(doc)['trigger']("ready")['unbind']("ready");
- }
- }
- } $['ready'] = ready;
- DOMContentLoaded = doc.addEventListener
- ? function () {
- doc.removeEventListener("DOMContentLoaded", DOMContentLoaded, false);
- ready(); }
- : function () {
- if (doc.readyState === "complete") {
- doc.detachEvent("onreadystatechange", DOMContentLoaded);
- ready();
- }
- };
- $['bindReady'] = function() {
- if (readyBound) return;
- readyBound = true;
- if (doc.readyState === "complete") return setTimeout(ready, 1);
+ } $['ready'] = ready;
- if (doc.addEventListener) {
- doc.addEventListener("DOMContentLoaded", DOMContentLoaded, false);
- win.addEventListener("load", ready, false);
- } else if (doc.attachEvent) {
- doc.attachEvent("onreadystatechange", DOMContentLoaded);
- win.attachEvent("onload", ready);
- var toplevel = false;
- try { toplevel = window.frameElement == null; } catch (e) { }
- if (doc.documentElement.doScroll && toplevel) doScrollCheck();
- }
- };
+ DOMContentLoaded = doc.addEventListener
+ ? function () {
+ doc.removeEventListener("DOMContentLoaded", DOMContentLoaded, false);
+ ready(); }
+ : function () {
+ if (doc.readyState === "complete") {
+ doc.detachEvent("onreadystatechange", DOMContentLoaded);
+ ready();
+ }
+ };
+
+ $['bindReady'] = function() {
+ if (readyBound) return;
+ readyBound = true;
+ if (doc.readyState === "complete") return setTimeout(ready, 1);
+
+ if (doc.addEventListener) {
+ doc.addEventListener("DOMContentLoaded", DOMContentLoaded, false);
+ win.addEventListener("load", ready, false);
+ } else if (doc.attachEvent) {
+ doc.attachEvent("onreadystatechange", DOMContentLoaded);
+ win.attachEvent("onload", ready);
+ var toplevel = false;
+ try { toplevel = window.frameElement == null; } catch (e) { }
+ if (doc.documentElement.doScroll && toplevel) doScrollCheck();
+ }
+ };
- $['fn']['ready'] = function (fn) {
- $['bindReady']();
- if (isReady) fn.call(doc, $);
- else if (readyList) readyList.push(fn);
- return this;
- };
+ $['fn']['ready'] = function (fn) {
+ $['bindReady']();
+ if (isReady) fn.call(doc, $);
+ else if (readyList) readyList.push(fn);
+ return this;
+ };
- if (!$['init']) $(document)['ready']($['onload']);
+ if (!$['init']) $(document)['ready']($['onload']);
});
View
268 src/jquip.events.js
@@ -1,139 +1,139 @@
$['plug']("events", function($){
- var doc = document, handlers = {}, _jquid = 1;
- function jquid(el){
- return el._jquid || (el._jquid = _jquid++);
- }
- function bind(o, type, fn){
- if (o.addEventListener)
- o.addEventListener(type, fn, false);
- else {
- o['e' + type + fn] = fn;
- o[type + fn] = function(){
- o['e' + type + fn](window.event);
- };
- o.attachEvent('on' + type, o[type + fn]);
- }
- } $['bind'] = bind;
- function unbind(o, type, fn){
- if (o.removeEventListener)
- o.removeEventListener(type, fn, false);
- else {
- o.detachEvent('on' + type, o[type + fn]);
- o[type + fn] = null;
- }
- } $['unbind'] = unbind;
- function parseEvt(evt){
- var parts = ('' + evt).split('.');
- return {e: parts[0], ns: parts.slice(1).sort().join(' ')};
- }
- function matcherFor(ns){
- return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)');
- }
- function findHdls(el, evt, fn, sel){
- evt = parseEvt(evt);
- if (evt.ns) var m = matcherFor(evt.ns);
- return $['_filter'](handlers[jquid(el)] || [], function(hdl){
- return hdl
- && (!evt.e || hdl.e == evt.e)
- && (!evt.ns || m.test(hdl.ns))
- && (!fn || hdl.fn == fn)
- && (!sel || hdl.sel == sel);
- });
- }
- function addEvt(el, evts, fn, sel, delegate){
- var id = jquid(el), set = (handlers[id] || (handlers[id] = []));
- $['_each'](evts.split(/\s/), function(evt){
- var handler = $['extend'](parseEvt(evt), {fn: fn, sel: sel, del: delegate, i: set.length});
- set.push(handler);
- bind(el, handler.e, delegate || fn);
- });
- el = null;
- }
- function remEvt(el, evts, fn, sel){
- var id = jquid(el);
- $['_each']((evts || '').split(/\s/), function(evt){
- $['_each'](findHdls(el, evt, fn, sel), function(hdl){
- delete handlers[id][hdl.i];
- unbind(el, hdl.e, hdl.del || hdl.fn);
- });
- });
- }
- var evtMethods = ['preventDefault', 'stopImmediatePropagation', 'stopPropagation'];
- function createProxy(evt){
- var proxy = $['extend']({originalEvent: evt}, evt);
- $['_each'](evtMethods, function(key){
- if(evt[key]){
- proxy[key] = function(){
- return evt[key].apply(evt, arguments);
- };
- }
- });
- return proxy;
- }
- var p = $['fn'];
- $['_each'](("blur focus focusin focusout load resize scroll unload click dblclick " +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup error").split(" "),
- function(name){
- p[name] = function(fn, data){
- return arguments.length > 0 ? this['bind'](name, fn, data) : this['trigger'](name);
- };
- }
- );
- p['bind'] = function(type, cb){
- return this['each'](function(){
- addEvt(this, type, cb);
- });
- };
- p['unbind'] = function(type, cb){
- return this['each'](function(){
- remEvt(this, type, cb);
- });
- };
- p['one'] = function(evt, cb){
- return this['each'](function(){
- var self = this;
- addEvt(this, evt, function wrapper(){
- cb.apply(self, arguments);
- remEvt(self, evt, arguments.callee);
- });
- });
- };
- p['delegate'] = function(sel, evt, cb){
- return this['each'](function(i, el){
- addEvt(el, evt, cb, sel, function(e){
- var target = e.target||e.srcElement, nodes = $['$$'](sel, el);
- while (target && nodes.indexOf(target) < 0)
- target = target.parentNode;
- if (target && !(target === el) && !(target === document)){
- cb.call(target, $['extend'](createProxy(e||window.event), {
- currentTarget: target, liveFired: el
- }));
- }
- });
- });
- };
- p['undelegate'] = function(sel, evt, cb){
- return this['each'](function(){
- remEvt(this, evt, cb, sel);
- });
- };
- p['live'] = function(evt, cb){
- $(doc.body)['delegate'](this['selector'], evt, cb);
- return this;
- };
- p['die'] = function(evt, cb){
- $(doc.body)['undelegate'](this['selector'], evt, cb);
- return this;
- };
+ var doc = document, handlers = {}, _jquid = 1;
+ function jquid(el){
+ return el._jquid || (el._jquid = _jquid++);
+ }
+ function bind(o, type, fn){
+ if (o.addEventListener)
+ o.addEventListener(type, fn, false);
+ else {
+ o['e' + type + fn] = fn;
+ o[type + fn] = function(){
+ o['e' + type + fn](window.event);
+ };
+ o.attachEvent('on' + type, o[type + fn]);
+ }
+ } $['bind'] = bind;
+ function unbind(o, type, fn){
+ if (o.removeEventListener)
+ o.removeEventListener(type, fn, false);
+ else {
+ o.detachEvent('on' + type, o[type + fn]);
+ o[type + fn] = null;
+ }
+ } $['unbind'] = unbind;
+ function parseEvt(evt){
+ var parts = ('' + evt).split('.');
+ return {e: parts[0], ns: parts.slice(1).sort().join(' ')};
+ }
+ function matcherFor(ns){
+ return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)');
+ }
+ function findHdls(el, evt, fn, sel){
+ evt = parseEvt(evt);
+ if (evt.ns) var m = matcherFor(evt.ns);
+ return $['_filter'](handlers[jquid(el)] || [], function(hdl){
+ return hdl
+ && (!evt.e || hdl.e == evt.e)
+ && (!evt.ns || m.test(hdl.ns))
+ && (!fn || hdl.fn == fn)
+ && (!sel || hdl.sel == sel);
+ });
+ }
+ function addEvt(el, evts, fn, sel, delegate){
+ var id = jquid(el), set = (handlers[id] || (handlers[id] = []));
+ $['_each'](evts.split(/\s/), function(evt){
+ var handler = $['extend'](parseEvt(evt), {fn: fn, sel: sel, del: delegate, i: set.length});
+ set.push(handler);
+ bind(el, handler.e, delegate || fn);
+ });
+ el = null;
+ }
+ function remEvt(el, evts, fn, sel){
+ var id = jquid(el);
+ $['_each']((evts || '').split(/\s/), function(evt){
+ $['_each'](findHdls(el, evt, fn, sel), function(hdl){
+ delete handlers[id][hdl.i];
+ unbind(el, hdl.e, hdl.del || hdl.fn);
+ });
+ });
+ }
+ var evtMethods = ['preventDefault', 'stopImmediatePropagation', 'stopPropagation'];
+ function createProxy(evt){
+ var proxy = $['extend']({originalEvent: evt}, evt);
+ $['_each'](evtMethods, function(key){
+ if(evt[key]){
+ proxy[key] = function(){
+ return evt[key].apply(evt, arguments);
+ };
+ }
+ });
+ return proxy;
+ }
+ var p = $['fn'];
+ $['_each'](("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "),
+ function(name){
+ p[name] = function(fn, data){
+ return arguments.length > 0 ? this['bind'](name, fn, data) : this['trigger'](name);
+ };
+ }
+ );
+ p['bind'] = function(type, cb){
+ return this['each'](function(){
+ addEvt(this, type, cb);
+ });
+ };
+ p['unbind'] = function(type, cb){
+ return this['each'](function(){
+ remEvt(this, type, cb);
+ });
+ };
+ p['one'] = function(evt, cb){
+ return this['each'](function(){
+ var self = this;
+ addEvt(this, evt, function wrapper(){
+ cb.apply(self, arguments);
+ remEvt(self, evt, arguments.callee);
+ });
+ });
+ };
+ p['delegate'] = function(sel, evt, cb){
+ return this['each'](function(i, el){
+ addEvt(el, evt, cb, sel, function(e){
+ var target = e.target||e.srcElement, nodes = $['$$'](sel, el);
+ while (target && nodes.indexOf(target) < 0)
+ target = target.parentNode;
+ if (target && !(target === el) && !(target === document)){
+ cb.call(target, $['extend'](createProxy(e||window.event), {
+ currentTarget: target, liveFired: el
+ }));
+ }
+ });
+ });
+ };
+ p['undelegate'] = function(sel, evt, cb){
+ return this['each'](function(){
+ remEvt(this, evt, cb, sel);
+ });
+ };
+ p['live'] = function(evt, cb){
+ $(doc.body)['delegate'](this['selector'], evt, cb);
+ return this;
+ };
+ p['die'] = function(evt, cb){
+ $(doc.body)['undelegate'](this['selector'], evt, cb);
+ return this;
+ };
- p['on'] = function(evt, sel, cb){
- return typeof sel === 'function' ? this.bind(evt, sel) : this.delegate(evt, sel, cb);
- };
+ p['on'] = function(evt, sel, cb){
+ return typeof sel === 'function' ? this.bind(evt, sel) : this.delegate(evt, sel, cb);
+ };
- p['off'] = function(evt, sel, cb){
- return typeof sel === 'string' ? this.undelegate(evt, sel, cb) : this.unbind(evt, cb);
- };
+ p['off'] = function(evt, sel, cb){
+ return typeof sel === 'string' ? this.undelegate(evt, sel, cb) : this.unbind(evt, cb);
+ };
p['trigger'] = function (evt) {
return this['each'](function () {
if ((evt == "click" || evt == "blur" || evt == "focus") && this[evt])
@@ -149,5 +149,5 @@ $['plug']("events", function($){
} catch (e) { }
});
};
- if (!$['init']) $(window)['bind']("load",$['onload']);
+ if (!$['init']) $(window)['bind']("load",$['onload']);
});
View
2,052 src/jquip.js
1,026 additions, 1,026 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
124 src/jquip.q-min.js
@@ -1,68 +1,68 @@
$['plug'](function($){
- var doc = document,
- $id = function(id, ctx){ return (ctx || doc).getElementById(id); },
- $tag = function(tag, ctx){ return (ctx || doc).getElementsByTagName(tag); },
- $cls = doc.getElementsByClassName //&& false
- ? function(cls, ctx){
- return (ctx || doc).getElementsByClassName(cls); }
- : function(cls, ctx){
- var ret = $['walk'](function(el){
- return el.className && el.className.indexOf(cls) >= 0;
- }, (ctx || doc));
- return $['unique'](ret);
- };
+ var doc = document,
+ $id = function(id, ctx){ return (ctx || doc).getElementById(id); },
+ $tag = function(tag, ctx){ return (ctx || doc).getElementsByTagName(tag); },
+ $cls = doc.getElementsByClassName //&& false
+ ? function(cls, ctx){
+ return (ctx || doc).getElementsByClassName(cls); }
+ : function(cls, ctx){
+ var ret = $['walk'](function(el){
+ return el.className && el.className.indexOf(cls) >= 0;
+ }, (ctx || doc));
+ return $['unique'](ret);
+ };
- function childSel(sel, ctx){
- var el = $['$$'](ctx)[0], cls = sel.split('.'), tag = cls.shift(), fPos = tag.indexOf('['), fName, fValue, parts,
- firstChar = tag.charAt(0);
- if (firstChar == "#") return $id(tag.substring(1), el);
- if (fPos >= 0){
- parts = tag.substring(fPos + 1, tag.length - 1).split('=');
- fName = parts[0];
- fValue = parts.length == 2 && parts[1];
- if (fValue && fValue.charAt(0) == "'")
- fValue = fValue.substring(1, fValue.length - 1);
- tag = tag.substring(0, fPos);
- }
- var tagWithId = tag.split('#');
- if (tagWithId.length == 2){
- el = $id(tagWithId[1], el);
- if (!el) return [];
- if (!$['eqSI'](el.tagName, tagWithId[0])) return [];
- if (cls.length == 1) return [el];
- }
- var els = tag ? $tag(tag, el) : $cls(cls.shift(), el);
- if (!cls.length && !fName) return els;
- var ret = [];
- for(var i = 0, l = els.length; i < l; i++){
- var subEl = els[i], j = cls.length, matches = true;
- if (cls.length) while (j--) if (!$['hasClass']([subEl], cls[j])) matches = false;
- if (matches && (!fName || (!fValue || subEl[fName] == fValue)))
- ret.push(subEl);
- }
- return ret;
- }
+ function childSel(sel, ctx){
+ var el = $['$$'](ctx)[0], cls = sel.split('.'), tag = cls.shift(), fPos = tag.indexOf('['), fName, fValue, parts,
+ firstChar = tag.charAt(0);
+ if (firstChar == "#") return $id(tag.substring(1), el);
+ if (fPos >= 0){
+ parts = tag.substring(fPos + 1, tag.length - 1).split('=');
+ fName = parts[0];
+ fValue = parts.length == 2 && parts[1];
+ if (fValue && fValue.charAt(0) == "'")
+ fValue = fValue.substring(1, fValue.length - 1);
+ tag = tag.substring(0, fPos);
+ }
+ var tagWithId = tag.split('#');
+ if (tagWithId.length == 2){
+ el = $id(tagWithId[1], el);
+ if (!el) return [];
+ if (!$['eqSI'](el.tagName, tagWithId[0])) return [];
+ if (cls.length == 1) return [el];
+ }
+ var els = tag ? $tag(tag, el) : $cls(cls.shift(), el);
+ if (!cls.length && !fName) return els;
+ var ret = [];
+ for(var i = 0, l = els.length; i < l; i++){
+ var subEl = els[i], j = cls.length, matches = true;
+ if (cls.length) while (j--) if (!$['hasClass']([subEl], cls[j])) matches = false;
+ if (matches && (!fName || (!fValue || subEl[fName] == fValue)))
+ ret.push(subEl);
+ }
+ return ret;
+ }
- $['setQuery'](function(selector, ctx){
- if (doc.querySelectorAll)
- return (ctx || doc).querySelectorAll(selector);
+ $['setQuery'](function(selector, ctx){
+ if (doc.querySelectorAll)
+ return (ctx || doc).querySelectorAll(selector);
- var els, resSet = [
- [(ctx || doc)]
- ], heir = selector.split(' '), ret = [];
- for(var i = 0, l = heir.length; i < l; i++){
- var parentSet = resSet[i];
- if (parentSet.length == 0) return ret;
- var sel = heir[i], res = [];
+ var els, resSet = [
+ [(ctx || doc)]
+ ], heir = selector.split(' '), ret = [];
+ for(var i = 0, l = heir.length; i < l; i++){
+ var parentSet = resSet[i];
+ if (parentSet.length == 0) return ret;
+ var sel = heir[i], res = [];
- for(var j = 0, jlen = parentSet.length; j < jlen; j++){
- els = childSel(sel, parentSet[j]);
- for(var k = 0, klen = els.length; k < klen; k++)
- res.push(els[k]);
- }
- resSet.push(res);
+ for(var j = 0, jlen = parentSet.length; j < jlen; j++){
+ els = childSel(sel, parentSet[j]);
+ for(var k = 0, klen = els.length; k < klen; k++)
+ res.push(els[k]);
+ }
+ resSet.push(res);
- }
- return resSet.length > 1 ? resSet.pop() : [];
- });
-});
+ }
+ return resSet.length > 1 ? resSet.pop() : [];
+ });
+});

0 comments on commit cc43696

Please sign in to comment.
Something went wrong with that request. Please try again.