if (typeof Object.create !== "function") { Object.create = function (obj) { function F() {} F.prototype = obj; return new F(); }; } /* IE鐗堟湰 */ function versionIE(){ if(navigator.appName=="Microsoft Internet Explorer"){ var b_version=navigator.appVersion, version=b_version.split(";"), trim_Version=version[1].replace(/[ ]/g,""); if(trim_Version=="MSIE8.0"){ return 'IE8'; }else if(trim_Version=="MSIE7.0"){ return 'IE7'; }else if(trim_Version=="MSIE6.0"){ return 'IE6'; } return true; } return false; } /* 娑堟伅瀵硅瘽妗 */ var msgTimer; var bodyOverflow; function msgDialog(options){ if(document.getElementById("msgDialog")){ msgClose(); } var defaults = { text : "", time : 0, type : "success", callback : function(){} }, opts = $.extend(defaults,options), style = "display:block;float:left;font-size:40px;line-height:1;", html = ""; html += "
"; switch(opts.type){ case 'success': html += ""; break; case 'error': html += ""; break; case 'warning': html += ""; break; case 'loading': html += ""; break; case 'confirm': html += ""; break; } html += "
"+opts.text+"
"; var strStyle = " cursor:pointer; padding:4px 15px; margin-right:20px; background:#0084e9; color:#fff; border-radius:3px; border:1px solid #0078d4;"; if(opts.type == "confirm"){ html += "
"; }else if(opts.type != "loading" && opts.type != "success"){ html += "
"; } html += "
"; var $body = $(document.body); bodyOverflow = $body.css("overflow"); if(!$body.hasClass("bodyOverflowHiddenByMsg")){ $body.addClass("bodyOverflowHiddenByMsg"); } $body.append(html); var msgDialog = $("#msgDialog"); var divCenter = function (){ var windowWidth = $(window).width(); var windowHeight = $(window).height(); var popupHeight = msgDialog.height(); var popupWidth = msgDialog.width(); msgDialog.css({ "top": (windowHeight-popupHeight)/2, "left": (windowWidth-popupWidth)/2 }); } divCenter(); if(opts.time>0){ msgTimer = setTimeout(msgClose,opts.time) ; } $(".msgBtns .msgBtn").on("click",function(){ msgClose(); if($(this).attr("rel")=="true"){ opts.callback(); } }); } /* 鍏抽棴瀵硅瘽妗 */ function msgClose(){ clearTimeout(msgTimer); $("#msgLock").remove(); $('#msgDialog').remove(); $(document.body).removeClass("bodyOverflowHiddenByMsg"); } /* 閿欒妗 */ function msgError(tip){ msgDialog({text:tip,type:'error'}); } /* 璀﹀憡妗 */ function msgAlter(tip){ msgDialog({text:tip,type:'warning'}); } /* 鍔犺浇锛岀瓑寰 */ function msgLoading(tip){ msgDialog({text:tip,type:'loading'}); } /* 鎴愬姛 */ function msgSuccess(tip){ msgDialog({text:tip,type:'success',time:1600}); } /* 閫夋嫨瀵硅瘽妗 */ function msgConfirm(tip,callback){ msgDialog({text:tip,type:'confirm',callback:callback}); } /* 浣庣増鏈祻瑙堝櫒鎻愰啋 */ function lowBrowser() { var lowVersion = versionIE(); var lowBrowserHtml = '鏈夐儴鍒嗗姛鑳芥偍鐨勬祻瑙堝櫒涓嶆敮鎸侊紝璇锋洿鎹㈤珮绾ф祻瑙堝櫒锛屽缓璁娇鐢?a href="http://www.firefox.com" target="_blank" title="涓嬭浇firefox娴忚鍣?>firefox,0){ dd.css({"visibility":"visible","height":(dc.height()+15)+"px"}); } dc.addClass("on"); },function(){ var $this = $(this), dd = $box.find(".dropdown"); $this.children().removeClass('active'); dd.css({"visibility":"hidden","height":0}); dd.children(":eq("+$this.index()+")").removeClass("on"); }); $(".dd-row",$box).hover(function(){ var $this = $(this); $this.addClass('on'); if($this.height()>0){ $this.parent().css({"visibility":"visible","height":($this.height()+15)+"px"}); } $box.find(".ul-one").children(":eq("+$this.index()+")").children().addClass("active"); },function(){ var $this = $(this); $this.removeClass('on'); $this.parent().css({"visibility":"hidden","height":0}); $box.find(".ul-one").children(":eq("+$this.index()+")").children().removeClass("active"); }); } function jsPlaceholder(){ if(!('placeholder' in document.createElement('input'))){ var $elements = $("input[type=text],textarea"); for(var i=0,len=$elements.length;iambit){ if(menu.hasClass("small")){ for(var i=0,l=els.length;i"+ "
"+ "×
"; $("body").append(html); var render = base.versionIE() ? "table" : "canvas"; $("#js_qrcode").qrcode({ render:render, width:160, height:160, text: base.options.url }); $("#share_qrcode_close").on("click",function(){ $(this).parent().remove(); }) } }else{ var su = base.options.media[shareCode]; su = su.replace("{url}",encodeURIComponent(base.options.url)); su = su.replace("{title}",encodeURIComponent(base.options.title)); su = su.replace("{summary}",encodeURIComponent(base.options.summary)); su = su.replace("{desc}",encodeURIComponent(base.options.desc)); su = su.replace("{pic}",encodeURIComponent(base.options.pic)); window.open(su,"_blank"); } }); }, versionIE: function(){ if(navigator.appName=="Microsoft Internet Explorer"){ var b_version=navigator.appVersion, version=b_version.split(";"), trim_Version=version[1].replace(/[ ]/g,""); if(trim_Version=="MSIE8.0"){ return true; }else if(trim_Version=="MSIE7.0"){ return true; }else if(trim_Version=="MSIE6.0"){ return true; } } return false; } }; $.fn.lmShare = function (options) { return this.each(function () { if ($(this).data("lm-init") === true) { return false; } $(this).data("lm-init", true); var share = Object.create(Share); share.init(options, this); $.data(this, "lmShare", share); }); }; $.fn.lmShare.options = { url: window.location.href, title: document.title, summary: document.querySelector('meta[name="description"]').getAttribute('content'), desc: "", pic: "", media: { "qqim": "http://connect.qq.com/widget/shareqq/index.html?url={url}&desc={desc}&title={title}&summary={summary}&pics={pic}", "qzone": "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={url}&desc={desc}&summary={summary}&title={title}&pics={pic}&otype=share", "qqmb": "http://share.v.t.qq.com/index.php?c=share&a=index&url={url}&title={summary}&appkey=801cf76d3cfc44ada52ec13114e84a96&pic={pic}", "tsina": "http://service.weibo.com/share/share.php?url={url}&title={summary}&appkey=1343713053&pic={pic}&searchPic=false" } }; })(jQuery,window); /* 鑷畾涔夋ā鎬佸璇濇 */ function modalDialog(options){ var defaults = { isTitle: true, title: "瀵硅瘽妗?, maxWidth: 600, maxHeight: 400, data: { type: "html", content: "" }, ok: { text: "纭", func: function() {} }, cancel: { text: "鍙栨秷", func: function() {} } }, opts = $.extend(defaults,options), $body = $("body"), bodyDialogOverflow, dId = "", dEl, dLk, setSize = function(){ var $size = { width : $(window).width()*0.8, height : $(window).height()*0.8 }; if($size.width > opts.maxWidth){ $size.width = opts.maxWidth; } if($size.height > opts.maxHeight){ $size.height = opts.maxHeight; } dEl.css({width:$size.width, height:$size.height}); dEl.find(".dialogMain").css({height:$size.height-80}); return $size; }, showCenter = function (){ var $size = setSize(), $left = ($(window).width()-$size.width)/2, $top = ($(window).height()-$size.height)/2 + $(document).scrollTop(), $zIndex = $(".modalDialog").length*2 + 600; dEl.css({top:$top, left:$left, zIndex:$zIndex+1}); dLk.css({zIndex:$zIndex}); }, loadData = function(){ switch(opts.data.type){ case "url": $.ajax({ type: "get", url: opts.data.content, dataType:"html", beforeSend: function(){ dEl.find(".dialogMain").html("
"); }, success: function(html){ dEl.find(".dialogMain").html(html); } }); break; case "html": dEl.find(".dialogMain").html(opts.data.content); break; } }, init = function(){ for(var i = 0; i < 4; i++){ dId = parseInt(Math.random()*(900-100)+100)+""; } var $html = "
"; if(opts.isTitle){ $html += "
"+opts.title+"
"; } $html += "
"; $html += ""+opts.ok.text+""; $html += ""+opts.cancel.text+""; $html += "
"; bodyDialogOverflow = $body.css("overflow"); if(!$body.hasClass("bodyOverflowHidden")){ $body.addClass("bodyOverflowHidden"); } $body.append($html); dEl = $("#md_"+dId); dLk = $("#ls_"+dId); dEl.find(".dialogButtons").children().on("click",function(){ switch($(this).attr("role")){ case "ok": var result = opts.ok.func(); if(result) return false; break; case "cancel": var result = opts.cancel.func(); if(result) return false; break; } colse(); }); showCenter(); loadData(); }, colse = function(){ if($(".modalDialog").length==1){ $body.removeClass("bodyOverflowHidden"); } dEl.remove(); dLk.remove(); }; init(); return dEl; }; /** * 鍥剧墖涓婁笓-鏀寔鏈湴鍥剧墖棰勮锛屽吋瀹筰e[6-9]銆佺伀鐙愩€丆hrome17+銆丱pera11+銆丮axthon3 * fileObj - input[type=file]瀵硅薄 * imgPreviewId - 鍥剧墖瀹瑰櫒ID * divPreviewId - 棰勮瀹瑰櫒ID **/ function PreviewImage(fileObj,imgPreviewId,divPreviewId){ var imgObj = document.getElementById(imgPreviewId); if(fileObj.value == ""){ imgObj.src=""; return false; } var allowExtention=".jpg,jpeg,.bmp,.gif,.png,.ico";//鍏佽涓婁紶鏂囦欢鐨勫悗缂€鍚峝ocument.getElementById("hfAllowPicSuffix").value; var extention=fileObj.value.substring(fileObj.value.lastIndexOf(".")+1).toLowerCase(); var browserVersion= window.navigator.userAgent.toUpperCase(); if(allowExtention.indexOf(extention)>-1){ if(fileObj.files){//HTML5瀹炵幇棰勮锛屽吋瀹筩hrome銆佺伀鐙?+绛 if(window.FileReader){ var reader = new FileReader(); reader.onload = function(e){ imgObj.setAttribute("src",e.target.result); } reader.readAsDataURL(fileObj.files[0]); }else if(browserVersion.indexOf("SAFARI")>-1){ alert("涓嶆敮鎸丼afari6.0浠ヤ笅娴忚鍣ㄧ殑鍥剧墖棰勮!"); } }else if (browserVersion.indexOf("MSIE")>-1){ if(browserVersion.indexOf("MSIE 6")>-1){//ie6 imgObj.setAttribute("src",fileObj.value); }else{//ie[7-9] fileObj.select(); //if(browserVersion.indexOf("MSIE 9")>-1) fileObj.blur();//涓嶅姞涓奷ocument.selection.createRange().text鍦╥e9浼氭嫆缁濊闂 var newPreview =document.getElementById(divPreviewId+"New"); if(newPreview==null){ newPreview =document.createElement("div"); newPreview.setAttribute("id",divPreviewId+"New"); newPreview.style.width = imgObj.width+"px"; newPreview.style.height = imgObj.height+"px"; newPreview.style.border="solid 1px #d2e2e2"; } newPreview.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale',src='" + document.selection.createRange().text + "')"; var tempDivPreview=document.getElementById(divPreviewId); tempDivPreview.parentNode.insertBefore(newPreview,tempDivPreview); tempDivPreview.style.display="none"; } }else if(browserVersion.indexOf("FIREFOX")>-1){//firefox var firefoxVersion= parseFloat(browserVersion.toLowerCase().match(/firefox\/([\d.]+)/)[1]); if(firefoxVersion<7){//firefox7浠ヤ笅鐗堟湰 imgObj.setAttribute("src",fileObj.files[0].getAsDataURL()); }else{//firefox7.0+ imgObj.setAttribute("src",window.URL.createObjectURL(fileObj.files[0])); } }else{ imgObj.setAttribute("src",fileObj.value); } }else{ alert("浠呮敮鎸?+allowExtention+"涓哄悗缂€鍚嶇殑鏂囦欢!"); fileObj.value="";//娓呯┖閫変腑鏂囦欢 if(browserVersion.indexOf("MSIE")>-1){ fileObj.select(); document.selection.clear(); } fileObj.outerHTML=fileObj.outerHTML; } } /* 鐧婚檰寮圭獥 */ function popSignin(callback){ if($(".signin-pop-box").length){ return false;} var $popSignin = $(''), $close = $('
×').appendTo($popSignin), $form = $('
' +'
' +'
' +'
' +'' +'
').appendTo($popSignin); $btn = $('').appendTo($form); $msg = $('
').appendTo($popSignin); $("body").append($popSignin); $("input[placeholder],textarea[placeholder]",$popSignin).placeholder(); $close.on("click", function(){ $popSignin.remove(); }); $btn.on("click",function(){ if(!$btn.hasClass("disabled")){ $form.ajaxSubmit({ dataType: "json", beforeSubmit: function(){ $btn.addClass("disabled").html("正在登陆..."); }, success: function(data){ $btn.removeClass("disabled").html("登 陆"); if(data.success){ $msg.html(""); if("function" == typeof callback){ callback(); } $popSignin.remove(); }else{ $msg.html(data.info); } }, error: function(a,b){ $msg.html("登陆失败!"); $btn.removeClass("disabled").html("登 陆"); } }); } }); } jQuery.fn.placeholder = function(){ var i = document.createElement('input'), placeholdersupport = 'placeholder' in i; if(!placeholdersupport){ var inputs = jQuery(this); inputs.each(function(){ var input = jQuery(this), text = input.attr('placeholder'), height = input.outerHeight(), placeholder = jQuery(''+text+''); if(input[0].tagName == "TEXTAREA"){ placeholder.css({'left':"10px",'top':"10px",'position':'absolute', 'color':"#999", 'font-size':"12px"}); }else{ placeholder.css({'left':"10px",'line-height':height+"px",'position':'absolute', 'color':"#999", 'font-size':"12px"}); } placeholder.on("mousedown", function(){ input.focus(); }); if(input.val() != ""){ placeholder.css({display:'none'}); }else{ placeholder.css({display:'inline'}); } placeholder.insertAfter(input); input.on("focus",function(e){ placeholder.css({display:'none'}); }); input.on("blur",function(e){ if(jQuery(this).val() != ""){ placeholder.css({display:'none'}); }else{ placeholder.css({display:'inline'}); } }); }); } return this; }; /* jiathis 鍒嗕韩 - 鐐瑰嚮寮瑰嚭 */ function jiathisShare(el){ var $this = $(el), e = event || window.event; e.preventDefault(); window.$sharebox; if($this.data('init')==undefined || $this.data('init') !== true){ $this.data('init', true); var html = '
鍒嗕韩
'+ ''+ ''+ '
'; $sharebox = $('
').html(html); $('body').append($sharebox); var jia = document.createElement('script'); jia.src = 'http://v3.jiathis.com/code/jia.js'; document.body.appendChild(jia); setTimeout(function(){ $sharebox.addClass('on'); }, 100); $sharebox.find(".lm-close").on("click", function(){ $sharebox.removeClass('on'); }); }else if(!$sharebox.hasClass("on")){ $sharebox.addClass('on'); } }