123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- ;!function(a){"use strict";var b=document,c="querySelectorAll",d="getElementsByClassName",e=function(a){return b[c](a)},f={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:!0},g={extend:function(a){var b=JSON.parse(JSON.stringify(f));for(var c in a)b[c]=a[c];return b},timer:{},end:{}};g.touch=function(a,b){var c;return/Android|iPhone|SymbianOS|Windows Phone|iPad|iPod/.test(navigator.userAgent)?(a.addEventListener("touchmove",function(){c=!0},!1),void a.addEventListener("touchend",function(a){a.preventDefault(),c||b.call(this,a),c=!1},!1)):a.addEventListener("click",function(a){b.call(this,a)},!1)};var h=0,i=["layermbox"],j=function(a){var b=this;b.config=g.extend(a),b.view()};j.prototype.view=function(){var a=this,c=a.config,f=b.createElement("div");a.id=f.id=i[0]+h,f.setAttribute("class",i[0]+" "+i[0]+(c.type||0)),f.setAttribute("index",h);var g=function(){var a="object"==typeof c.title;return c.title?'<h3 style="'+(a?c.title[1]:"")+'">'+(a?c.title[0]:c.title)+'</h3><button class="layermend"></button>':""}(),j=function(){var a,b=(c.btn||[]).length;return 0!==b&&c.btn?(a='<span type="1">'+c.btn[0]+"</span>",2===b&&(a='<span type="0">'+c.btn[1]+"</span>"+a),'<div class="layermbtn">'+a+"</div>"):""}();if(c.fixed||(c.top=c.hasOwnProperty("top")?c.top:100,c.style=c.style||"",c.style+=" top:"+(b.body.scrollTop+c.top)+"px"),2===c.type&&(c.content='<i></i><i class="laymloadtwo"></i><i></i>'),f.innerHTML=(c.shade?"<div "+("string"==typeof c.shade?'style="'+c.shade+'"':"")+' class="laymshade"></div>':"")+'<div class="layermmain" '+(c.fixed?"":'style="position:static;"')+'><div class="section"><div class="layermchild '+(c.className?c.className:"")+" "+(c.type||c.shade?"":"layermborder ")+(c.anim?"layermanim":"")+'" '+(c.style?'style="'+c.style+'"':"")+">"+g+'<div class="layermcont">'+c.content+"</div>"+j+"</div></div></div>",!c.type||2===c.type){var k=b[d](i[0]+c.type),l=k.length;l>=1&&layer.close(k[0].getAttribute("index"))}document.body.appendChild(f);var m=a.elem=e("#"+a.id)[0];c.success&&c.success(m),a.index=h++,a.action(c,m)},j.prototype.action=function(a,b){var c=this;if(a.time&&(g.timer[c.index]=setTimeout(function(){layer.close(c.index)},1e3*a.time)),a.title){var e=b[d]("layermend")[0],f=function(){a.cancel&&a.cancel(),layer.close(c.index)};g.touch(e,f)}var h=function(){var b=this.getAttribute("type");0==b?(a.no&&a.no(),layer.close(c.index)):a.yes?a.yes(c.index):layer.close(c.index);layer.close(c.index);};if(a.btn)for(var i=b[d]("layermbtn")[0].children,j=i.length,k=0;j>k;k++)g.touch(i[k],h);if(a.shade&&a.shadeClose){var l=b[d]("laymshade")[0];g.touch(l,function(){layer.close(c.index,a.end)})}a.end&&(g.end[c.index]=a.end)},a.layer={v:"1.7",index:h,open:function(a){var b=new j(a||{});return b.index},close:function(a){var c=e("#"+i[0]+a)[0];c&&(c.innerHTML="",b.body.removeChild(c),clearTimeout(g.timer[a]),delete g.timer[a],"function"==typeof g.end[a]&&g.end[a](),delete g.end[a])},closeAll:function(){for(var a=b[d](i[0]),c=0,e=a.length;e>c;c++)layer.close(0|a[0].getAttribute("index"))}},"function"==typeof define?define(function(){return layer}):function(){var a=document.scripts,c=a[a.length-1],d=c.src,e=d.substring(0,d.lastIndexOf("/")+1);c.getAttribute("merge")||document.head.appendChild(function(){var a=b.createElement("link");return a.href=e+"layer.css",a.type="text/css",a.rel="styleSheet",a.id="layermcss",a}())}()}(window);
- function checkClientIP() {
- var sUserAgent = navigator.userAgent.toLowerCase();
- var isIpad = sUserAgent.match(/ipad/i) == "ipad";
- var isIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
- var isAndroid = sUserAgent.match(/android/i) == "android";
-
- if (isIpad || isIphoneOs || isAndroid) {
- return 1;
- } else {
- return 0;
- }
- }
- if (!checkClientIP()) {
- layer.open({
- content: "请在微信端浏览~~",
- style: 'background-color:#09C1FF; color:#fff; border:none;',
- shadeClose: false,
- time: 10000000
- });
-
- }
- function incoldeCssFile() {
- var fileref = document.createElement('link');
- fileref.setAttribute("rel","stylesheet");
- fileref.setAttribute("type","text/css");
- fileref.setAttribute("href","/ratfw/common/wap-alert/layer.css");
- document.getElementsByTagName("head")[0].appendChild(fileref);
- }
- window.alert = function(obj) {
-
- var div = document.createElement('div');
- div.appendChild(document.createTextNode(obj));
- obj = div.innerHTML;
- layer.open({
- title: [
- '水时代-消息提醒',
- 'background-color:#0FA3D0; color:#fff;'
- ],
- shadeClose: false,
- content: obj,
- btn: ['好的']
- });
- };
- window.confirm = function(obj, clickConfirmBtn, clickCancelBtn) {
-
- var div = document.createElement('div');
- div.appendChild(document.createTextNode(obj));
- obj = div.innerHTML;
- layer.open({
- title: [
- '水时代-消息提醒',
- 'background-color:#0FA3D0; color:#fff;'
- ],
- shadeClose: false,
- content: obj,
- btn: ['确认', '取消'],
- yes:clickConfirmBtn,
- no:clickCancelBtn
- });
- };
- function timeAlert(obj) {
- layer.open({
- content: obj,
- style: 'background-color:#09C1FF; color:#fff; border:none;',
- time: 1
- });
- };
- var ZXXFILE = {
- fileInput: null,
- dragDrop: null,
- upButton: null,
- url: "",
- fileFilter: [],
- filter: function(files) {
- return files;
- },
- onSelect: function() {},
- onDelete: function() {},
- onDragOver: function() {},
- onDragLeave: function() {},
- onProgress: function() {},
- onSuccess: function() {},
- onFailure: function() {},
- onComplete: function() {},
-
-
-
-
- funDragHover: function(e) {
- e.stopPropagation();
- e.preventDefault();
- this[e.type === "dragover"? "onDragOver": "onDragLeave"].call(e.target);
- return this;
- },
-
- funGetFiles: function(e) {
-
- this.funDragHover(e);
-
-
- var files = e.target.files || e.dataTransfer.files;
-
- this.fileFilter = this.fileFilter.concat(this.filter(files));
- this.funDealFiles();
- return this;
- },
-
-
- funDealFiles: function() {
- for (var i = 0, file; file = this.fileFilter[i]; i++) {
-
- file.index = i;
- }
-
- this.onSelect(this.fileFilter);
- return this;
- },
-
-
- funDeleteFile: function(fileDelete) {
- var arrFile = [];
- for (var i = 0, file; file = this.fileFilter[i]; i++) {
- if (file != fileDelete) {
- arrFile.push(file);
- } else {
- this.onDelete(fileDelete);
- }
- }
- this.fileFilter = arrFile;
- return this;
- },
-
-
- funUploadFile: function() {
- layer.open({type: 2,shadeClose: false, content:"正在上传中,请稍候..."});
- var self = this;
- if (location.host.indexOf("sitepointstatic") >= 0) {
-
- return;
- }
- var file = $("#fileImage")[0].files[0];
- var read = new FileReader();
- read.readAsDataURL(file);
- read.onload=function(e){
- var result = document.getElementsByClassName("upload_image");
- var message = $("input[name='shareMessage']:checked").val();
- var url = "/iamberry/wechat/share/add?message="+message;
- var args = {"fileImage":decodeURI(this.result)};
-
- var openid = $("#openid").html();
- $.post(url, args, function(dt) {
- layer.closeAll();
- if(dt.status){
- self.funDeleteFile(file);
- var shareId = dt.data;
- var linkUrl = encodeURI('/iamberry/wechat/sharePage/toSharePage?shareId='+shareId
- + "&openid=" +openid);
- self.onSuccess(file, linkUrl);
- }else{
- self.onFailure(file, dt.data);
- }
- });
- }
- },
-
- init: function() {
- var self = this;
- if (this.dragDrop) {
- this.dragDrop.addEventListener("dragover", function(e) { self.funDragHover(e); }, false);
- this.dragDrop.addEventListener("dragleave", function(e) { self.funDragHover(e); }, false);
- this.dragDrop.addEventListener("drop", function(e) { self.funGetFiles(e); }, false);
- }
-
-
- if (this.fileInput) {
- this.fileInput.addEventListener("change", function(e) { self.funGetFiles(e); }, false);
- }
-
-
- if (this.upButton) {
- this.upButton.addEventListener("click", function(e) { self.funUploadFile(e); }, false);
- }
- }
- };
|