ylbtech-笔记-JS:Window
1.返回顶部
1、happy.js
;
(function () {
var happyUi = {
initHappy: function (type) {
utils.isLogin(type, function () {
utils.getRequest("tag", {type: "kx", _type: "query"}, function (d) {
$("[category]").empty().html('<a class="mui-control-item mui-active" href="javascript:void(0)">全部</a>');
$(d.Data.Collection).each(function (i, item) {
$("[category]").append('<a class="mui-control-item" href="javascript:void(0)" category-id="' + item.Id + '">' + item.Name + '</a>');
});
var pullRefresh = utils.pullRefresh($("#pullrefresh"), $("#dataList"), "happytimes", "happytimes/list", function () {
var params = {};
params.tagId = $("#top-tabs a.mui-active").attr("category-id");
return params;
}); $(document).on("tap", "#top-tabs a", function () {
$("#top-tabs a").removeClass("mui-active");
$(this).addClass("mui-active");
pullRefresh.opts.loadUpFn(pullRefresh);
});
})
}); //点击跳转到详情
$(document).on("tap", "[data-id]", function (event) {
event.stopPropagation();
event.preventDefault();
var id = $(this).attr("data-id");
var href = "/m/service/happytimes/detail.html?id=" + id;
mui.openWindow(href, href);
}); //记录当前点击的位置
$("#pullrefresh").unbind("scroll").on("scroll", function () {
if ($("#pullrefresh").scrollTop() > 10) {
sessionStorage.setItem("offsetTop", $("#pullrefresh").scrollTop());//保存滚动位置
}
});
//返回的时候获取位置信息
window.onload = function () {
var _offset = sessionStorage.getItem("offsetTop");
if (_offset > 10) {
setTimeout(function () {
$("#pullrefresh").scrollTop(_offset);
}, 10);
}
};
},
initDetail: function (type) {
utils.isLogin(type, function () {
var id = $.getUrlParam("id");
if (!id) {
return;
}
utils.getRequest('happytimes/{0}'.format(id), {}, function (d) {
$("#dataDetail").html(template("happytimes/detail", d.Data || {}));
var comment = $.cookie("comment");
if(!utils.isNull(comment)){
$("#reply").val(comment);
}
}); $("#reply").on("tap", function () {
var href = "/m/service/happytimes/comment.html";
mui.openWindow(href, href);
}); $("[data-evt='send']").unbind("tap").bind("tap", function () {
$.cookie("comment", "");
mui.toast("评论成功");
$("#reply").val("");
});
});
},
initComment: function () {
$("#btnSave").unbind("tap").bind("tap", function () {
$.cookie("comment", $("#comment").val());
mui.toast("保存成功");
setTimeout(function () {
mui.back();
}, 500);
});
}
};
window.happyUi = happyUi;
})();
2、
2. 添加监听事件返回顶部
1、
            document.getElementById("search").addEventListener('change', function () {
pageIndex = 0;
$("#pullrefresh").find(".mui-table-view").html("");
pulldownRefresh(pullRefresh);
});
2、
3. 微信端上传图片返回顶部
1、
1.1、
<div style="text-align: center;">
<a href="javascript:void(0)" class="btn btn-success fileinput-button">
<img style="width: 270px;height: 270px;" id="facepic" class="mui-media-object" src="/img/mfsczp.jpg">
<input id="upfacepic" type="file" name="files[]">
</a>
</div>
1.2、
// --begion--上传图片--
// 1/2,必须先通讯 个人信息获取
utils.getRequest("member/GetCurrent", {}, function (d) {
//$("#memberId").html(d.Data.Id);
});
// 2/2, 上传图片才能启用
utils.uploader({
browse_button: "upfacepic",
completeCallback: function (pic) {
$("#facepic").attr("src", pic);
}
});
// --end--上传图片--
2、
3、
4.返回顶部
 
5.返回顶部
 
 
6.返回顶部
 
7.返回顶部
 
8.返回顶部
 
9.返回顶部
 
10.返回顶部
 
 
11. 上传图片返回顶部
1、
<div class="Fileupload col-sm-9">
<div class="imgView image">
<span class="delete-b" id="delete-a" style=" float:right; color:red;">[删除]</span>
<div class="pic mypic">
<img style="margin-left:10px;max-width:145px;max-height:130px" alt="" data-img="" src="/doc/x_bgimg/2018/03-20/240d463fa50e45e38886d238dc8fddc5.jpg">
</div>
</div>
<a class="upload btn-pic"> <input id="addimg25645" type="file" name="files[]" class="change">添加图片</a>
</div>
2、
12.返回顶部
1、更改头像
 <div id="modifyPic" class="mui-page">
<header class="mui-bar mui-bar-nav">
<button type="button" class="mui-left mui-action-back mui-btn mui-btn-link mui-btn-nav mui-pull-left">
<span class="mui-icon mui-icon-left-nav" style="color: white;"></span><span style="color: white;">更改头像</span>
</button>
</header>
<div class="mui-scroll-wrapper">
<div style="text-align: center; margin-top: 60px;">
<a href="javascript:void(0)" class="btn btn-success fileinput-button">
<img style="width: 270px;height: 270px;" id="facepic" class="mui-media-object" src="/img/mfsczp.jpg">
<input id="upfacepic" type="file" name="files[]">
</a>
</div> <div style="position: relative;min-height: 1px;padding-right: 15px;padding-left: 15px;">
<p style="text-align: center; margin-top: 20px;">
<a class="btn hvr-grow" id="btnImg" style="padding:5px 15px;font-size:18px;box-shadow:none;background-color:#c83728;color:#fff;width:30%;border-radius: 0px;"><strong>保存头像</strong></a>
</p>
</div>
</div> </div>
2、
//更改头像
if (!utils.isNull($.cookie("memberface"))) {
$("#head-img").attr("src", $.cookie("memberface"));
$("#facepic").attr("src", $.cookie("memberface"));
}
utils.uploader({
browse_button: "upfacepic",
completeCallback: function (pic) {
$("#facepic").attr("src", pic);
}
}); $(document).on("tap", "#btnImg", function () {
if ($("#facepic").attr("src") == "/img/mfsczp.jpg") {
mui.toast("请上传头像!");
return false;
}
var btnObj = this;
utils.postRequest("member/updateface", { facepic: $("#facepic").attr("src") }, function (d) {
$.cookie("memberface", $("#facepic").attr("src"));
$("#head-img").attr("src", $.cookie("memberface"));
mui.toast("保存成功");
setTimeout(function () {
mui.back();
}, 500);
}).always(function (d) {
mui(btnObj).button("reset");
});
})
3、
initUpload();
function initUpload() {
utils.uploader({
browse_button: 'FileSrc', completeCallback: function (d) {
$('#OriginalSrc').attr('href', d);
$('[data-FileSrc]').attr('src', d);
}
});
};
4、
 initUpload();
function initUpload() {
utils.uploader({
browse_button: 'FileSrc', completeCallback: function (d) {
$('#OriginalSrc').attr('href', d);
$('[data-FileSrc]').attr('src', d);
}
});
};
5、
13. 搜索返回顶部
1、
 utils.isLogin(type, function () {
var vague = $.getUrlParam("vague");
if (vague) {
$("#vague").val(vague);
}
var pullRefresh = utils.pullRefresh($("#pullrefresh"), $("#dataList"), "mystory", "mystory/list", function () {
var params = {};
params.vague = $.trim($("#vague").val());
params.Status = 1;
return params;
}); $(document).on("tap", "#top-tabs a", function () {
$("#top-tabs a").removeClass("mui-active");
$(this).addClass("mui-active");
pullRefresh.opts.loadUpFn(pullRefresh);
});
}); // 搜索
$("[data-evt='search']").unbind("click").click(function () {
var vague = $.trim($("#vague").val());
if (vague.length > 0)
{
var href = "/m/service/mystory/index.html?vague=" + vague;
mui.openWindow(href, href);
}
else {
var href = "/m/service/mystory/index.html";
mui.openWindow(href, href);
}
});
2、
14. 日期返回顶部
1、日期格式
{{dateFormat(CreateTime, 'yyyy年MM月dd日')}}
2、时间段
{{dateDiff(item.CreateTime)}}
3、
15.返回顶部
 
 
16.返回顶部
 
作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

JS:Window的更多相关文章

  1. JS window对象 返回前一个浏览的页面 back()方法,加载 history 列表中的前一个 URL。 语法: window.history.back();

    返回前一个浏览的页面 back()方法,加载 history 列表中的前一个 URL. 语法: window.history.back(); 比如,返回前一个浏览的页面,代码如下: window.hi ...

  2. JS window对象 screen对象 screen对象用于获取用户的屏幕信息。 语法: window.screen.属性

    screen对象 screen对象用于获取用户的屏幕信息. 语法: window.screen.属性 对象属性:

  3. JS window对象 返回浏览历史中的其他页面 go()方法,根据当前所处的页面,加载 history 列表中的某个具体的页面。 语法: window.history.go(number);

    返回浏览历史中的其他页面 go()方法,根据当前所处的页面,加载 history 列表中的某个具体的页面. 语法: window.history.go(number); 参数: 浏览器中,返回当前页面 ...

  4. JS window对象 History 对象 history对象记录了用户曾经浏览过的页面(URL),并可以实现浏览器前进与后退相似导航的功能。语法: window.history.[属性|方法]

    History 对象 history对象记录了用户曾经浏览过的页面(URL),并可以实现浏览器前进与后退相似导航的功能. 注意:从窗口被打开的那一刻开始记录,每个浏览器窗口.每个标签页乃至每个框架,都 ...

  5. 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法

    "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...

  6. nw.js FrameLess Window下的窗口拖拽与窗口大小控制

    nw.js FrameLess Window下的窗口拖拽与窗口大小控制 很多时候,我们觉得系统的Frame框很难看,于是想自定义. 自定义Frame的第一步是在package.config文件中将fr ...

  7. 无废话ExtJs 入门教程三[窗体:Window组件]

    无废话ExtJs 入门教程三[窗体:Window组件] extjs技术交流,欢迎加群(201926085) 1.代码如下: 1 <!DOCTYPE html PUBLIC "-//W3 ...

  8. 为什么这样写js:(function ($) { })(jQuery);

    很多时候,会这样写js,比如公司的项目里面的js页面都这样,所以我就想搞清楚意思: <script language="javascript" type="text ...

  9. 第十二章:window对象

    第十一章介绍了window对象及其客户端javascript所扮演的核心角色:它是客户端javascript程序的全局对象.本章介绍window对象的属性和方法,这些属性定义了不同的API,但是只有一 ...

随机推荐

  1. each方法的简单使用

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/stric ...

  2. Spark总结1

    安装jdk 下载spark安装包 解压 重点来了: 配置 spark: 进入 conf   ----> spark-env.sh.template文件 cd conf/ mv spark-env ...

  3. 【P2052】道路修建(树形+搜索)

    这个题看上去高大上,实际上就是一个大水题.怎么说呢,这个题思路可能比较难搞,代码实现难度几乎为0. 首先我们可以发现这是一棵树,然后问其中任意一条边左右两边的点的数量之差的绝对值,实际上,无论两边的点 ...

  4. streambase service 变为 window service启动

    1.配置出.sbdeploy文件 2.安装streambase服务 streambase command line :--install-service 即可安装对应的的window service ...

  5. java应用线上CPU过高问题排查

    1.top 命令,查看占用CPU最高的PID.ps aux|grep PID 进一步确定tomcat进程出现问题.2.ps -mp pid -o THREAD,tid,time显示线程列表3.prin ...

  6. ASPX一句话爆破工具

    #include "stdafx.h" #include <stdio.h> #include <Windows.h> #include <stdli ...

  7. Linux嵌入式 -- Bootloader , Uboot

    1. Bootloader作用 PC机中的引导加载程序由BIOS(其本质是一段固件程序)和GRUB或LILO一起组成.BIOS在完成硬件检测和资源分配后,将硬盘中的引导程序读到系统内存中然后将控制权交 ...

  8. Java中使用注释

    在编写程序时,经常需要添加一些注释,用以描述某段代码的作用. 一般来说,对于一份规范的程序源代码而言,注释应该占到源代码的 1/3 以上.因此,注释是程序源代码的重要组成部分,一定要加以重视哦! Ja ...

  9. C++(零)— 提高程序运行效率

    1.尽量减少值传递,多用引用来传递参数. 2.++i和i++引申出的效率问题,使用++i. 3.避免过大的循环,由计算机的硬件决定的. 4.局部变量VS静态变量,尽量使用局部变量. 5.减少除法运算的 ...

  10. hdu 5238 Calculator(线段树,中国剩余定理¥)

    Calculator Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tot ...