jquery待办事项实用工具代码

所属分类: 网页特效-实用工具    2024-12-05 01:17:27

jquery待办事项实用工具代码 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery待办事项实用工具代码(共3个文件)

    • index.html

使用方法

/* Submit on Enter */
$("#addNewItemInput").on("keydown", (e) => {
  if (e.keyCode === 13) {
    $("#addNewItemBtn").click()
    $("#addNewItemInput").val("")
  }
})

$("#titleInput").on("keydown", (e) => {
  if (e.keyCode == 13) {
    $("#titleInput").blur();
  }
})

/* Add a new item */
$("#addNewItemBtn").on("click", (e) => {
  if ($("#addNewItemInput").val() == "") {
    gsap.to("#addNewItemInput", .1, {x: -4})
    gsap.to("#addNewItemInput", .1, {delay: .1, x: 4})
    gsap.to("#addNewItemInput", .1, {delay: .2, x: -4})
    gsap.to("#addNewItemInput", .1, {delay: .3, x: 4})
    gsap.to("#addNewItemInput", .1, {delay: .4, x: 0})
  } else {
    const newItemInput = $("#addNewItemInput").val()
  
  $(".item").append(
    `<div class="itemInner">
      <i class="far fa-hand-point-right"></i>
      <p>${newItemInput}</p>
      <button class="removeItemBtn">
       <i class="fas fa-trash-alt"></i>
      </button>
     </div>`)
  
  $("#addNewItemInput").val("")
  
  const newItem = e.target

  gsap.to(".itemsWrapper, .item", .3, {paddingBottom: 30, ease: Back.easeOut})
  gsap.to(".itemsWrapper, .item", .3, {delay: .15, paddingBottom: 8, y: 0, ease: Back.easeOut})
  }
})

/* Completed item line through */
$(".item").on("click", "i.fa-hand-point-right", (e) => {
  const handPoint = e.target
  const completedItem = e.target.parentElement
  const text = completedItem.getElementsByTagName('p')
  
  $(text).css({"text-decoration": "line-through"})
  gsap.to(handPoint, .3, {rotate: -30, transformOrigin: "center", ease: Back.easeOut})
  gsap.to(handPoint, .3, {delay: .15, rotate: 0, transformOrigin: "center", ease: Back.easeOut})
})

/* Remove item */
$(".item").on("click", "button.removeItemBtn", (e) => {
    const removeItem = e.target
    const itemInner = removeItem.parentElement    
    $(itemInner).remove()
  
  gsap.to(".itemsWrapper, .item", 0, {paddingBottom: 52})
  gsap.to(".itemsWrapper, .item", .3, {paddingBottom: 8, ease: Back.easeOut})
})

/* Edit list title animation */
gsap.set(".fa-pencil-alt", {opacity: 0, rotate: -180, transformOrigin: "center"})
gsap.set("#titleInput, #addNewItemInput", {border: "1px solid transparent", boxShadow: "0 0 0 rgba(211, 220, 248, .3)"})

$("#titleInput").on("mouseenter", () => {
    gsap.to(".fa-pencil-alt", .3, {rotate: 0, opacity: 1, transformOrigin: "center", ease: Back.easeOut})
})

$("#titleInput").on("mouseleave", () => {
  if ($("#titleInput").is(":focus")) {
    gsap.to(".fa-pencil-alt", .3, {rotate: 0, opacity: 1, transformOrigin: "center", ease: Back.easeOut})
  } else if (!($("#titleInput").is(":focus"))) {
    gsap.to(".fa-pencil-alt", .3, {rotate: -180, opacity: 0, transformOrigin: "center", ease: Back.easeOut})
  }
})

$("#titleInput").on("focus", () => {
  gsap.to(".fa-pencil-alt", .3, {rotate: 0, opacity: 1, transformOrigin: "center", ease: Back.easeOut})
  gsap.to("#titleInput", .3, {border: "1px solid #e7ecfb", boxShadow: "0 0 12px rgba(211, 220, 248, .3)"})
})

$("#titleInput").on("focusout", () => {
  gsap.to(".fa-pencil-alt", .3, {rotate: -180, opacity: 0, transformOrigin: "center", ease: Back.easeOut})
  gsap.to("#titleInput", .3, {border: "1px solid transparent", boxShadow: "0 0 12px rgba(211, 220, 248, 0)"})
})

/* Trash fade on item hover */
$(".item").on("mouseenter", ".itemInner", (e) => {
  const trashBtn = $(e.target.querySelector(".removeItemBtn"))
  gsap.to(trashBtn, .3, {opacity: 1})
})

$(".itemInner").on("mouseenter", ".removeItemBtn", (e) => {
  const trashBtn = e.target
  gsap.to(trashBtn, .3, {opacity: 1})
})

$(".innerItem").on("mouseleave", ".removeItemBtn", (e) => {
  gsap.to(trashBtn, .3, {opacity: 0})
})

$(".item").on("mouseleave", ".itemInner", (e) => {
  const trashBtn = $(e.target.querySelector(".removeItemBtn"))
  gsap.to(trashBtn, .3, {opacity: 0})
})

$(".itemInner").on("mouseleave", ".removeItemBtn", (e) => {
  const trashBtn = e.target
  gsap.to(trashBtn, .3, {opacity: 0})
})

/* Add a new item animation */
$("#addNewItemInput").on("focus", () => {
  gsap.to("#addNewItemInput", .3, {border: "1px solid #e7ecfb", boxShadow: "0 0 12px rgba(211, 220, 248, .3)"})
})

$("#addNewItemInput").on("focusout", () => {
  gsap.to("#addNewItemInput", .3, {border: "1px solid transparent", boxShadow: "0 0 12px rgba(211, 220, 248, 0)"})
})

$("#addNewItemBtn").on("mouseenter", () => {
  gsap.to(".fa-plus", .3, {rotate: 90, ease: Back.easeOut})
})

$("#addNewItemBtn").on("mouseleave", () => {
  gsap.to(".fa-plus", .3, {rotate: 0, ease: Back.easeOut})
})

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 实用工具

jquery支持自定义的16进制颜色选择器

这是一款基于Vue.js创建的带有混合器十六进制颜色选择器插件,支持同时拾取两种颜色,并生成一组渐变递进的颜色值。可对生成的两个颜色通过左侧工具垂直滑块调整颜色间隔密度,非常的方便。此插件有助于前端设计师方便快速的选择颜色组合。
  实用工具
 71137  0

CSS3带点击复制的颜色选取十六进制值

一款分组颜色值选取器插件,可选择某一色系中的几种常用颜色,且可以将对应颜色的十六进制值鼠标点击复制。
  实用工具
 2867  0

javascript创建的在线头像DIY生成器工具

一款头像图片在线生成实用工具,用户可以为头像设置不同的肤色、眉毛、嘴巴、发型、发色、胡须、配饰、衣服面料颜色等。还可设置眼睛镜片不透明度、纹身和头像背景颜色,可下载头像图片。
  实用工具
 9751  0

jquery创建的windows文件窗口视图特效

Desktopify是一个用于创建类似Microsoft Windows的桌面插件,包含使用HTML、JavaScript和CSS的快捷方式、文件和文件夹视图。支持鼠标拖拽拖动文件,移动窗口等操作。
  实用工具
 9706  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论