Ticket #22670: betterjs.diff

File betterjs.diff, 806 bytes (added by tw2113, 5 months ago)

revised js for the key tracking

Line 
1Index: wp-admin/js/post.js
2===================================================================
3--- wp-admin/js/post.js (revision 23132)
4+++ wp-admin/js/post.js (working copy)
5@@ -765,4 +765,33 @@
6                        });
7                });
8        }
9+       neededkeys = [38,38,40,40,37,39,37,39,66,65], started = false, count = 0;
10+       $(document).keydown(function(e){
11+               key = e.keyCode;
12+               if(!started){
13+                       if(key == 38){
14+                               started = true;
15+                       }
16+               }
17+               if(started){
18+                       if(neededkeys[count] == key){
19+                               count++;
20+                       } else {
21+                               reset();
22+                       }
23+                       if(count == 10){
24+                               var $this = $(this), editor = $this.data('editor');
25+                               $this.blur();
26+                               wp.media.editor.open( editor );
27+                               //Reset to do it all again.
28+                               reset();
29+                       }
30+               } else {
31+                       reset();
32+               }
33+       });
34+       function reset() {
35+               started = false; count = 0;
36+               return;
37+       }
38 });