From b28fe024a1748f1b6be8d75adbefb5c60ad4db15 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Thu, 26 Apr 2012 21:31:50 +0100 Subject: [PATCH] [#46,refactor,util][xs]: remove util functions (e.g. show, hide, observeExit) which are now no longer used after recent commits. --- src/util.js | 56 +----------------------------------------------- src/view-grid.js | 12 ----------- 2 files changed, 1 insertion(+), 67 deletions(-) diff --git a/src/util.js b/src/util.js index cd0086be..c6b00097 100644 --- a/src/util.js +++ b/src/util.js @@ -60,55 +60,6 @@ var util = function() { return o; }; - function registerEmitter() { - var Emitter = function(obj) { - this.emit = function(obj, channel) { - if (!channel) channel = 'data'; - this.trigger(channel, obj); - }; - }; - MicroEvent.mixin(Emitter); - return new Emitter(); - } - - function listenFor(keys) { - var shortcuts = { // from jquery.hotkeys.js - 8: "backspace", 9: "tab", 13: "return", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause", - 20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home", - 37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del", - 96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7", - 104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/", - 112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8", - 120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 191: "/", 224: "meta" - }; - window.addEventListener("keyup", function(e) { - var pressed = shortcuts[e.keyCode]; - if(_.include(keys, pressed)) app.emitter.emit("keyup", pressed); - }, false); - } - - function observeExit(elem, callback) { - var cancelButton = elem.find('.cancelButton'); - // TODO: remove (commented out as part of Backbon-i-fication - // app.emitter.on('esc', function() { - // cancelButton.click(); - // app.emitter.clear('esc'); - // }); - cancelButton.click(callback); - } - - function show( thing ) { - $('.' + thing ).show(); - $('.' + thing + '-overlay').show(); - } - - function hide( thing ) { - $('.' + thing ).hide(); - $('.' + thing + '-overlay').hide(); - // TODO: remove or replace (commented out as part of Backbon-i-fication - // if (thing === "dialog") app.emitter.clear('esc'); // todo more elegant solution - } - function position( thing, elem, offset ) { var position = $(elem.target).position(); if (offset) { @@ -142,12 +93,7 @@ var util = function() { } return { - registerEmitter: registerEmitter, - listenFor: listenFor, - show: show, - hide: hide, position: position, - render: render, - observeExit: observeExit + render: render }; }(); diff --git a/src/view-grid.js b/src/view-grid.js index fa407538..74f4a5f9 100644 --- a/src/view-grid.js +++ b/src/view-grid.js @@ -35,18 +35,6 @@ my.Grid = Backbone.View.extend({ 'click .data-table-menu li a': 'onMenuClick' }, - // TODO: delete or re-enable (currently this code is not used from anywhere except deprecated or disabled methods (see above)). - // showDialog: function(template, data) { - // if (!data) data = {}; - // util.show('dialog'); - // util.render(template, 'dialog-content', data); - // util.observeExit($('.dialog-content'), function() { - // util.hide('dialog'); - // }) - // $('.dialog').draggable({ handle: '.dialog-header', cursor: 'move' }); - // }, - - // ====================================================== // Column and row menus