diff --git a/ui (gen4)/css/layout.css b/ui (gen4)/css/layout.css index de5f8a56..2efe5c95 100644 --- a/ui (gen4)/css/layout.css +++ b/ui (gen4)/css/layout.css @@ -293,8 +293,8 @@ stretching in width... */ .shadow { position: absolute; overflow: visible; - width: 300px; - height: 300px; + width: auto; + height: auto; background: black; -webkit-transition: all 0.1s ease-in; -moz-transition: all 0.1s ease-in; diff --git a/ui (gen4)/lib/keyboard.js b/ui (gen4)/lib/keyboard.js index 2d3005db..d780960f 100755 --- a/ui (gen4)/lib/keyboard.js +++ b/ui (gen4)/lib/keyboard.js @@ -361,6 +361,7 @@ function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys, action } else if(handler in keybindings){ handler = keybindings[handler] + /* // action name... } else if(handler in actions){ // build a handler... @@ -375,25 +376,57 @@ function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys, action // make this doc-generator compatible -- inherit all // the docs from the actual action... f.__proto__ = actions[n] + // tell the doc generator about the action stuff... + f.action = n + return f }(handler) + */ - // action name with '!' -- prevent default... - } else if(handler.slice(-1) == '!' - && handler.slice(0, -1) in actions){ - // build a handler... - // ...for the reasons why this is like it is see notes - // for the previous if... - handler = function(n){ - var f = function(){ - event.preventDefault() - return actions[n]() + // actions... + // + // supported action format: + // [!][: ] + // + // can contain space seporated: + // - numbers + // - strings + // - non-nested arrays or arrays + } else if(handler in actions + || handler.split(/!?\s*:\s*|!/)[0].trim() in actions){ + var c = handler.split(':') + + handler = c[0].trim() + var no_default = handler.slice(-1) == '!' + handler = no_default ? handler.slice(0, -1) : handler + + var args = JSON.parse('['+( + ((c[1] || '') + .match(/"[^"]*"|'[^']*'|\{[^\}]*\}|\[[^\]]*\]|\d+|\d+\.\d*/gm) + || []) + .join(','))+']') + + handler = function(n, no_default, args){ + if(no_default){ + var f = function(){ + event.preventDefault() + return actions[n].apply(actions, args) + } + } else { + var f = function(){ + return actions[n].apply(actions, args) + } } // make this doc-generator compatible -- inherit all // the docs from the actual action... f.__proto__ = actions[n] + // tell the doc generator about the action stuff... + f.action = n + f.args = args + f.no_default = no_default + return f - }(handler.slice(0, -1)) + }(handler, no_default, args.slice()) // key code... } else if(typeof(handler) == typeof(1)) { @@ -549,6 +582,18 @@ function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys, action * will be matched to key definitions in sections and in the key * binding object itself and in an actions object if given. * + * syntax examples: + * actionName - simple alias / action name + * actionName! - same as above but calls event.preventDefault() + * actionNmae: 1 "2" [3, 4] {5:6, 7:8} + * - action with arguments. + * arguments can be: + * - numbers + * - strings + * - non-nested arrays and/or objects + * actionNmae!: 1 "2" [3, 4] {5:6, 7:8} + * - same as above but calls event.preventDefault() + * * * * NOTE: The handler will be called with keybindings as context (this). diff --git a/ui (gen4)/ribbons.js b/ui (gen4)/ribbons.js index 8a114d62..1c3e8991 100755 --- a/ui (gen4)/ribbons.js +++ b/ui (gen4)/ribbons.js @@ -234,6 +234,8 @@ module.RibbonsPrototype = { // -> // // NOTE: this will also set origin... + // + // XXX if chrome 38 renders images blurry uncomment the fix... setScale: function(scale, t, l){ var ribbon_set = this.viewer.find('.ribbon-set') diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index cb486b77..6b3fbe07 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -135,10 +135,10 @@ module.GLOBAL_KEYBOARD = { shift: 'fitRibbon', ctrl: 'fitOrig!', }, - '#2': 'fitTwo', + '#2': 'fitImage: 2', '#3': { - default: 'fitThree', - shift: 'fitThreeRibbons', + default: 'fitImage: 3', + shift: 'fitRibbons: 3', }, '#4': 'fitFour', '#5': { @@ -176,8 +176,8 @@ $(function(){ window.a = testing.setupActions() // setup features... - // XXX I do not full understand it yet, but PartialRibbons must be - // setup BEFORE RibbonAlignToFirst, otherwise the later will break + // XXX I do not fully understand it yet, but PartialRibbons must be + // setup BEFORE AlignRibbonsTo*, otherwise the later will break // on shifting an image to a new ribbon... // To reproduce: // - setupe RibbonAlignToFirst first