Browse Source

note增加on-edit监控

zxlie 6 years ago
parent
commit
ff3b4e3869

+ 1 - 1
apps/manifest.json

@@ -1,6 +1,6 @@
 {
   "name": "WEB前端助手(FeHelper)",
-  "version": "2019.01.0714",
+  "version": "2019.02.1519",
   "manifest_version": 2,
   "default_locale": "zh_CN",
   "description": "FE助手:包括JSON格式化、二维码生成与解码、信息编解码、代码压缩、美化、页面取色、Markdown与HTML互转、网页滚动截屏、正则表达式、时间转换工具、编码规范检测、页面性能检测、Ajax接口调试、密码生成器、JSON比对工具、网页编码设置、便签笔记",

BIN
apps/static/screenshot/wx-qrcode-fehelper-group.png


+ 13 - 0
apps/sticky-notes/index.js

@@ -7,8 +7,19 @@ let StickyNotes = (() => {
 
     // 添加事件监听
     let addListener = () => {
+
+        // 正在编辑中
+        let editing = false;
+
+        window.onbeforeunload = function(e){
+            if(editing) {
+                (e || window.event).returnValue = '当前还有未保存的笔记,确定要离开么?';
+            }
+        };
+
         // add note
         $('#addnote').click(function () {
+            editing = true;
             html5sticky.addNote();
             return false;
         });
@@ -24,10 +35,12 @@ let StickyNotes = (() => {
             html5sticky.deleteNote($(this));
             return false;
         }).delegate('.close_stickynote', 'click', function (e) {
+            editing = false;
             // close enlarged note
             html5sticky.closeNote($(this));
             return false;
         }).delegate('.save_stickynote', 'click', function (e) {
+            editing = false;
             // save the note
             html5sticky.saveNote($(this));
             return false;