123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- var hkclient = new Object();
- var errorbox = null;
- var errorInfo = null;
- //显示加载器
- function showLoader() {
- //显示加载器.for jQuery Mobile 1.2.0
- $.mobile.loading('show', {
- text: "", //加载器中显示的文字
- textVisible: true, //是否显示文字
- theme: 'a', //加载器主题样式a-e
- textonly: false, //是否只显示文字
- html: "" //要显示的html内容,如图片等
- });
- }
- //隐藏加载器.for jQuery Mobile 1.2.0
- function hideLoader() {
- //隐藏加载器
- $.mobile.loading('hide');
- }
- hkclient.loadMobilePage = function (id, url, param, callback) {
- var obj = $("#" + id);
- //showLoader();
- var loadDivObj = jQuery('<div><table cellspacing="0" cellpadding="0" height="60"><tr><td width="29%" ><div align="right"><img src="images/progress.gif" /><div><td><td></td></tr></table></div>');
- obj.empty().append(loadDivObj);
- if (typeof(param) == 'undefined') {
- jQuery.ajaxSetup({
- cache: false
- });
- }
- obj.load(url, param, function () {
- //hideLoader();
- loadDivObj.hide("slow");
- if (callback) {
- callback();
- }
- });
- };
- hkclient.showError = function (errorMsg) {
- if (errorbox != null && errorInfo != null) {
- errorInfo.empty();
- jQuery('<div align="right"><img onclick="huimv.closeError();" src="images/close.gif" width="44" height="20"></div>')
- .appendTo(errorInfo);
- jQuery(errorMsg).appendTo(errorInfo);
- errorInfo.show();
- errorbox.show();
- return;
- }
- var errorDiv = document.createElement("div");
- errorDiv.id = "errorBox";
- errorDiv.style.cssText = "position:absolute;left:0px;display:none;top:0px;width:100%;background:#dddddd;text-align:center;filter:Alpha(Opacity=50,Style=0);opacity:0.4";
- errorDiv.style.height = ((document.documentElement.clientHeight > document.documentElement.scrollHeight)
- ? document.documentElement.clientHeight
- : document.documentElement.scrollHeight)
- + "px";
- var errorInfoDiv = document.createElement("div");
- errorInfoDiv.id = "errorInfoDiv";
- errorInfoDiv.style.cssText = "position:absolute;width:800px;height:auto;text-align:center;z-index:10001;border: 1px #1fa700 solid;top:"
- + (+50 + document.documentElement.scrollTop)
- + "px"
- + ";left:10%;font-size: 14px;background: url(images/load_bg.gif) repeat-x #ffffff;";
- jQuery('<div align="right"><img onclick="huimv.closeError();" src="images/close.gif" width="44" height="20"></div>')
- .appendTo(errorInfoDiv);
- jQuery(errorMsg).appendTo(errorInfoDiv);
- // 解决遮住下拉框
- var iframeHTML = '<IFRAME style="DISPLAY: block; Z-INDEX: -1; FILTER: alpha(opacity=0); LEFT: 0px; WIDTH: 100%; ZOOM: 1; POSITION: absolute; TOP: 0px; HEIGHT: 100%" src="javascript:false;document.write(\'\')" frameborder="0" scrolling="no"></IFRAME>';
- document.body.appendChild(errorInfoDiv);
- document.body.appendChild(errorDiv);
- errorbox = jQuery(errorDiv);
- errorbox.css('zIndex', (++huimvMaxIndex));
- errorInfo = jQuery(errorInfoDiv);
- errorbox.append(iframeHTML);
- errorInfo.show();
- errorbox.show();
- };
- hkclient.closeError = function () {
- errorbox.hide();
- errorInfo.hide();
- };
- hkclient.alertBanner = {
- alertTimer: undefined,
- alertFragment: document.createDocumentFragment(),
- t: 3000,
- /**
- * @description rise the alertBanner and then vanish
- * @param {string} status 状态
- * @param {number} t 定时时长,可选,默认3秒
- * @param msg 警告栏的内容
- * @return 浮现警告栏并自动消失
- */
- riseAlert: function (status, t, msg) {
- clearTimeout(this.alertTimer);
- $('.alert').remove();
- var alertDiv = document.createElement('DIV');
- alertDiv.id = 'alertBanner';
- if (!msg) {
- if (status) {
- msg = "保存成功";
- } else {
- msg = "保存失败";
- }
- }
- if (status) {
- alertDiv.className = 'alert alert-success fade in';
- alertDiv.innerHTML = msg;
- } else {
- alertDiv.className = 'alert alert-danger fade in';
- alertDiv.innerHTML = msg;
- }
- this.alertFragment.appendChild(alertDiv);
- document.body.appendChild(this.alertFragment);
- if (!t) {
- t = this.t;
- }
- this.alertTimer = setTimeout(function () {
- $('.alert').remove();
- }, t);
- }
- };
|