提前定义好的一些必要函数

String.prototype.trim = function() {

   return $.trim(this);

};

(function($) {

$.substitute = function(template, data) {
return template.replace(/\{([\w\.]*)\}/g, function (str, key) {
var keys = key.split("."), value = data[keys.shift()];
$.each(keys, function () { value = value[this]; });
return (value === null || value === undefined) ? "" : value;
});
};
$.log = function(text) {
if (typeof(console) != 'undefined' && console.log) {
console.log(text);
}
};
$.pngfix = function(node) {
if (typeof(DD_belatedPNG) !== 'undefined') {
DD_belatedPNG.fix(node);
}
};
$.isIE6 = function() {
return ($.browser.msie && $.browser.version == '6.0');
};
$.isIE7 = function() {
return ($.browser.msie && $.browser.version == '7.0');
};
$.atopfix = function(node) {
if(typeof document.body.style.maxHeight === "undefined") {
$(node).click( function(e) {
//e.preventDefault();
if(window.top) {
window.top.location = $(this).attr('href');
}
});
}

};

})(jQuery);

 

 

 

// string helpers
(function($) {
String.prototype.trim = function() {
return $.trim(this);
};
String.prototype.endWith=function(s){
if (s == null || s == '' || this.length === 0 || s.length > this.length) {
return false;
}
return (this.substring(this.length - s.length) === s);
};
String.prototype.startWith=function(s) {
if (s == null || s == '' || this.length === 0 || s.length > this.length) {
return false;
}
return (this.substr(0,s.length) === s);
};
})(jQuery);

 

posted @ 2013-01-23 15:54  mabel_on_line  阅读(250)  评论(0编辑  收藏  举报