123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- /*var isDrag = false;
- var tx, x, dwc, dwsl;*/
- $(function () {
- /* dwsl = $("#dwsl").val();*/
- /* 滚动事件 */
- var mScroll = new IScroll(".kzyxcsIscrollBig",{
- scrollbars: true,
- fadeScrollbars:true,
- shrinkScrollbars:'clip',
- scrollbars: 'custom',
- click:true,
- tap:true
- });
- setTimeout(function () {
- mScroll.refresh();
- }, 100);
- var mScrol1 = new IScroll(".iscrollCenter",{
- scrollbars: true,
- fadeScrollbars:true,
- shrinkScrollbars:'clip',
- scrollbars: 'custom',
- click:true,
- tap:true
- });
- selectDw(1);
- /* loadLeft();
- for (var i = 1; i <= dwsl; i++) {
- document.getElementById("circle" + i).addEventListener('touchend', function () {
- isDrag = false;
- });
- document.getElementById("circle" + i).addEventListener('touchstart', selectMouse);
- document.getElementById("circle" + i).addEventListener('touchmove', moveMouse);
- }*/
- /**
- * 拖拽
- */
- var block = document.getElementById("tb");
- var oW,oH;
- // 绑定touchstart事件
- block.addEventListener("touchstart", function(e) {
- var touches = e.touches[0];
- oW = touches.clientX - block.offsetLeft;
- oH = touches.clientY - block.offsetTop;
- //阻止页面的滑动默认事件
- document.addEventListener("touchmove",defaultEvent,false);
- },false);
- // 绑定touchmove事件
- block.addEventListener("touchmove", function(e) {
- var touches = e.touches[0];
- var oLeft = touches.clientX - oW;
- var oTop = touches.clientY - oH;
- //左右碰界判断
- if(oLeft < 0) {
- oLeft = 0;
- }else if(oLeft > document.documentElement.clientWidth - block.offsetWidth) {
- oLeft = (document.documentElement.clientWidth - block.offsetWidth);
- }
- //上下碰界判断
- if(oTop < 0) {
- oTop = 0;
- }else if(oTop > document.documentElement.clientHeight - block.offsetHeight) {
- oTop = (document.documentElement.clientHeight - block.offsetHeight);
- }
- block.style.left = oLeft + "px";
- block.style.top = oTop + "px";
- },false);
- // 绑定touchend事件
- block.addEventListener("touchend",function() {
- document.removeEventListener("touchmove",defaultEvent,false);
- },false);
-
- /**
- * 同步事件
- */
- /* 弹出修改删除框*/
- $("#tb").on("click",function(){
- $(".xgmsgbox").show(showOverlay());
- mScrol1.refresh();
- });
- //点击td选中input
- $(".listcenter>li,.checkBox").on("click",function (e) {
- if (e && e.stopPropagation) {
- e.stopPropagation();
- } else {
- window.event.cancelBubble = true;
- }
- if ($(this).find("input[type='checkbox']").is(":checked")) {
- $(this).find("input[type='checkbox']").removeAttr("checked");
- } else {
- $(this).find("input[type='checkbox']").prop("checked", true);
- }
- });
- /* 点击遮罩层或者取消按钮隐藏弹出框*/
- $("#overlay,.qx,.qd").on("click",function(){
- $(".xgmsgbox").hide(hideOverlay());
- });
- //touchmove的阻止浏览器或者屏幕滚动默认事件
- document.addEventListener('touchmove', defaultEvent, false);
- });
- function defaultEvent(e) {
- e.preventDefault();
- }
- /**
- * 温度变更
- * @param id
- * @param type
- */
- function changeWd(id, type, obj) {
- var gwd = parseFloat($("#gwd" + id).html());
- if (type == 1) {
- var dwd = $("#dwd" + id).html();
- if (parseFloat(dwd) < gwd - 0.5) {
- $("#gwd" + id).html(gwd - 0.5);
- $("#dwd" + (parseInt(id) + 1)).html(gwd - 0.5);
- }
- }
- if (type == 2) {
- var gwd2;
- if ($("#gwd" + (parseInt(id) + 1)).html()) {
- gwd2 = $("#gwd" + (parseInt(id) + 1)).html();
- } else {
- gwd2 = 50.5;
- }
- if (parseFloat(gwd2) > gwd + 0.5) {
- $("#gwd" + id).html(gwd + 0.5);
- $("#dwd" + (parseInt(id) + 1)).html(gwd + 0.5);
- }
- }
- }
- /*function moveMouse(e) {
- if (isDrag) {
- var n = tx + e.touches[0].pageX - x;
- var width = $(window).width() * 0.9 - 15;
- var max,min;
- if (dwc != dwsl) {
- max = $("#circle" + parseInt(dwc + 1)).css("left");
- if ((max + "").indexOf("%") != -1) {
- max = parseInt(max.substring(0, max.length-1)) / 100 * width;
- }
- if ((max + "").indexOf("px") != -1) {
- max = max.replace("px", "");
- }
- } else {
- max = 50;
- }
- if (dwc == 1) {
- min = 0;
- } else {
- min = $("#circle" + parseInt(dwc - 1)).css("left");
- if ((min + "").indexOf("%") != -1) {
- min = parseInt(min.substring(0, min.length-1)) / 100 * width;
- }
- if ((min + "").indexOf("px") != -1) {
- min = min.replace("px", "");
- }
- }
- console.log(min + "-" + max);
- if (n <= min || n > max) {
- return;
- }
- $("#circle" + dwc).css("left", (n / width * 100) + "%");
- $("#gwd" + dwc).html(parseInt(n / width * 50));
- $("#dwd" + (parseInt(dwc) + 1)).html(parseInt(n / width * 50));
- return false;
- }
- }
- function selectMouse(e) {
- isDrag = true;
- tx = parseInt(document.getElementById("circle" + dwc).style.left + 0);
- x = e.touches[0].pageX;
- return false;
- }
- function loadLeft() {
- for (var i = 1; i <= dwsl; i++) {
- var gw = $("#gwd" + i).html();
- var width = $(window).width() * 0.9 - 15;
- var left = parseInt(gw) / 50 * width;
- $("#circle" + i).css("left", left);
- }
- }*/
- /**
- * 返回
- */
- function yxcsBackUrl() {
- var zsid = $("#zsid").val();
- var zsbz = $("#zsbz").val();
- if (zsbz == "2") {
- haifm.loadMobilePage("haifm", "mcZsHjkzView.htm?zsid=" + zsid + "&from=zslist");
- } else {
- haifm.loadMobilePage("haifm", "mcZsView.htm?zsid=" + zsid + "&from=zslist");
- }
- }
- /**
- * 档位切换
- * @param id
- */
- function selectDw(key, val) {
- var dw = parseInt(key);
- if (val != undefined && val != "") {
- var xdw = parseInt(val);
- if (dw + xdw < 1 || dw + xdw > parseInt($("#dwsl").val())) {
- return;
- }
- $("#dw" + dw).hide();
- dw = dw + xdw;
- }
- $("#dw" + dw).show();
- dwc = dw;
- // isDrag = false;
- }
- /**
- * 开关
- */
- function kgbz(obj, id) {
- $("#gzsj" + id).removeAttr("disabled");
- $("#jssj" + id).removeAttr("disabled");
- // var kg = $(obj).parent().parent().find("input");
- // if ($(kg).val() == 1) {
- // $(kg).val("2");
- // $(obj).parent().find("span").attr("style", "background-color:''");
- // $("#gzsj" + id).removeAttr("disabled");
- // $("#jssj" + id).removeAttr("disabled");
- // } else if ($(kg).val() == 2) {
- // $(kg).val("1");
- // $(obj).parent().find("span").attr("style", "background-color:#f0f0f0");
- // $("#gzsj" + id).attr("disabled", "disabled");
- // $("#jssj" + id).attr("disabled", "disabled");
- // }
- }
- /* 显示遮罩层 */
- function showOverlay(){
- $("#overlay").height(pageHeight());
- $("#overlay").width(pageWidth());
- // fadeTo第一个参数为速度,第二个为透明度
- // 多重方式控制透明度,保证兼容性,但也带来修改麻烦的问题
- $("#overlay").fadeTo(200, 0.5);
- };
- /* 隐藏覆盖层 */
- function hideOverlay(){
- $("#overlay").fadeOut(200);
- };
- /* 当前页面高度 */
- function pageHeight(){
- return document.body.scrollHeight;
- };
- /* 当前页面宽度 */
- function pageWidth(){
- return document.body.scrollWidth;
- };
|