';
var imgCount = this.$items.length;
for (var i = 0; i < imgCount; i++) {
if (this.options.navstyle == 1) {
if (i === this.curIndex) {
html += '
' + (i + 1) + ' ';
} else {
html += '
' + (i + 1) + ' ';
}
} else if (this.options.navstyle == 2) {
var item = $(this.$items[i]);
item = item.find('img.slide-img');
if (i === this.curIndex) {
html += '
 + ')
';
} else {
html += '
 + ')
';
}
}
}
html += '
';
return html;
},
//配置
option: function (key, value) {
if (typeof (this.options[key]) == 'number')
value = parseInt(value);
this.options[key] = value;
if (key == 'ratio')
this._setSize();
if (key == 'autoplay' || key == 'speend') {
this._closeAutoPlay();
this._autoPlay();
}
if (key == 'showcotrols')
this._setShowCotrols();
if (key == 'navstyle' || key == 'navlocation')
this._setNavigation();
this._setCaptionPos();
return this.options[key];
}
};
/** 封装 */
$.fn.slide = function (options) {
var args = arguments;
if (options === undefined || typeof options === 'object') {
return this.each(function () {
if (!$.data(this, 'slide')) {
$.data(this, 'slide', new slide(this, options));
}
});
} else if (typeof options === 'string' && options[0] !== '_') {
return this.each(function () {
var instance = $.data(this, 'slide');
if (instance instanceof slide && typeof instance[options] === 'function') {
instance[options].apply(instance, Array.prototype.slice.call(args, 1));
}
//清除缓存
if (options === 'destroy') {
$.data(this, 'slide', null);
}
});
}
};
}(jQuery, window));
// 判断图片加载的函数
function isImgLoad(callback) {
var isLoad = true;
$('.g-cover').each(function () {
if ($(this).height() === 0) {
isLoad = false;
}
});
if (isLoad) {
callback();
// 为false,因为找到了没有加载完成的图,将调用定时器递归
} else {
var t_img;
t_img = setInterval(function () {
clearInterval(t_img);
isImgLoad(callback);
}, 100);
}
}
// 判断图片加载的函数
var allIsImgLoad = function (_obj, callBack) {
var imgLoad = new Array;
_obj.each(function (key) {
$(this).on('load',function () {
imgLoad[key] = true;
if (imgLoad.length == _obj.length) {
callBack();
}
});
if (window.navigator.userAgent.indexOf("Chrome/42.0") > 0) {
var src = $(this).attr("src") + "?" + Date.parse(new Date());
} else {
var src = $(this).attr("src");
}
$(this).attr("src", src);
});
}