started integrating widgets and actions...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-09-08 01:01:06 +03:00
parent f00aebe3d5
commit 16e264eddf
8 changed files with 85 additions and 10 deletions

View File

@ -48,10 +48,12 @@
...need a way to go around this... ...need a way to go around this...
*/ */
.blur>* { .blur>* {
-webkit-filter: blur(2px); -webkit-filter: blur(2px) saturate(0.5);
filter: blur(2px); filter: blur(2px) saturate(0.5);
} }
.blur>.overlay-widget { .blur>.overlay-widget {
-webkit-filter: none; -webkit-filter: none;
filter: none; filter: none;
} }

View File

@ -4,6 +4,8 @@
<link rel="stylesheet" href="css/layout.css"> <link rel="stylesheet" href="css/layout.css">
<link rel="stylesheet" href="css/editor.css"> <link rel="stylesheet" href="css/editor.css">
<link rel="stylesheet" href="css/widget/browse.css">
<link rel="stylesheet" href="css/widget/overlay.css">
<!-- XXX remove before use... --> <!-- XXX remove before use... -->
<style> <style>

View File

@ -306,10 +306,12 @@ module.MetaActions = {
: arguments.length > 1 ? args2array(arguments) : arguments.length > 1 ? args2array(arguments)
: typeof(actions) == typeof('str') ? [actions] : typeof(actions) == typeof('str') ? [actions]
: actions : actions
// get the first defined set of docs in the inheritance chain... // get the first defined set of docs in the inheritance chain...
actions.forEach(function(n){ actions.forEach(function(n){
var cur = that var cur = that
res[n] = [] res[n] = []
// go up the proto chain...
while(cur.__proto__ != null){ while(cur.__proto__ != null){
if(cur[n] != null && cur[n].doc != null){ if(cur[n] != null && cur[n].doc != null){
res[n] = [ cur[n].doc, cur[n].long_doc ] res[n] = [ cur[n].doc, cur[n].long_doc ]
@ -321,6 +323,33 @@ module.MetaActions = {
return res return res
}, },
getPath: function(actions){
var res = {}
var that = this
actions = actions == null ? this.actions
: arguments.length > 1 ? args2array(arguments)
: typeof(actions) == typeof('str') ? [actions]
: actions
// get the first defined set of docs in the inheritance chain...
actions.forEach(function(n){
var cur = that
// go up the proto chain...
while(cur.__proto__ != null){
if(cur[n] != null && cur[n].doc != null){
var doc = cur[n].doc
var long_doc = cur[n].long_doc
break
}
cur = cur.__proto__
}
res[(doc && doc.replace(/[\\\/]$/, '/'+n)) || n] = [n, doc, long_doc]
})
return res
},
// Get action handlers from the inheritance chain... // Get action handlers from the inheritance chain...
// //
// NOTE: this collects both the event handlers (in order of hierarchy, // NOTE: this collects both the event handlers (in order of hierarchy,

View File

@ -19,6 +19,7 @@ define(function(require){ var module = {}
console.log('>>> browse') console.log('>>> browse')
var keyboard = require('../keyboard')
// XXX // XXX
var object = require('../../object') var object = require('../../object')
var widget = require('./widget') var widget = require('./widget')
@ -135,6 +136,8 @@ var BrowserPrototype = {
'update', 'update',
'select', 'select',
'deselect', 'deselect',
'keydown',
], ],
}, },

View File

@ -20,7 +20,7 @@ var OverlayClassPrototype = {
var that = this var that = this
var overlay = $('<div>') var overlay = $('<div>')
.addClass('overlay-widget') .addClass('overlay-widget')
.click(function(){ .on(options.nonPropagatedEvents.join(' '), function(){
event.stopPropagation() event.stopPropagation()
}) })
.append($('<div>') .append($('<div>')
@ -37,6 +37,12 @@ var OverlayClassPrototype = {
var OverlayPrototype = { var OverlayPrototype = {
dom: null, dom: null,
options: {
nonPropagatedEvents: [
'clik',
//'keydown',
],
},
// XXX triggering events from here and from jQuery/dom has a // XXX triggering events from here and from jQuery/dom has a
// different effect... // different effect...
@ -70,6 +76,12 @@ var OverlayPrototype = {
__init__: function(parent, client, options){ __init__: function(parent, client, options){
var that = this var that = this
parent = this.parent = $(parent || 'body') parent = this.parent = $(parent || 'body')
options = options || {}
// merge options...
var opts = Object.create(this.options)
Object.keys(options).forEach(function(n){ opts[n] = options[n] })
options = this.options = opts
var dom = this.dom = this.constructor.make(client, options) var dom = this.dom = this.constructor.make(client, options)
.click(function(){ .click(function(){

View File

@ -11,7 +11,7 @@ console.log('>>> ribbons')
//var DEBUG = DEBUG != null ? DEBUG : true //var DEBUG = DEBUG != null ? DEBUG : true
// XXX is this correct... // XXX is this correct...
require('ext-lib/jquery') //require('ext-lib/jquery')
var object = require('object') var object = require('object')

View File

@ -4,6 +4,7 @@
* *
**********************************************************************/ **********************************************************************/
window.nodejs = (typeof(process) === 'object' && process.features.uv) window.nodejs = (typeof(process) === 'object' && process.features.uv)
? { ? {
require: window.require, require: window.require,
@ -54,6 +55,7 @@ var viewer = require('viewer')
// widgets... // widgets...
var browse = require('lib/widget/browse') var browse = require('lib/widget/browse')
var overlay = require('lib/widget/overlay')
@ -204,6 +206,8 @@ module.GLOBAL_KEYBOARD = {
default: 'toggleMark', default: 'toggleMark',
}, },
A: { A: {
// XXX STUB...
alt: function(){ browseActions() },
ctrl: 'toggleMark!: "ribbon" "on"', ctrl: 'toggleMark!: "ribbon" "on"',
}, },
D: { D: {
@ -229,6 +233,29 @@ module.GLOBAL_KEYBOARD = {
$(function(){ $(function(){
window.browse = browse
window.overlay = overlay
window.browseActions = function(){
var paths = a.getPath()
var actions = {}
Object.keys(paths).forEach(function(k){
var n = paths[k][0]
actions[k] = function(){
return a[n].apply(a)
}
})
var b = browse.makePathList(null, actions)
var o = overlay.Overlay($('body'), b.dom)
b.open(function(){ o.close() })
b.focus()
}
// XXX // XXX
window.a = testing.setupActions() window.a = testing.setupActions()
.load({ .load({

View File

@ -2421,23 +2421,23 @@ var ImageBookmarkActions = actions.Actions({
return this.data.tags['bookmark'].slice() return this.data.tags['bookmark'].slice()
}, },
toggleBookmark: ['', toggleBookmark: ['Bookmark/',
makeTagTogglerAction('bookmark')], makeTagTogglerAction('bookmark')],
// action can be: // action can be:
// 'on' - toggle all on // 'on' - toggle all on
// 'off' - toggle all off // 'off' - toggle all off
// 'next' - toggle each image to next state // 'next' - toggle each image to next state
toggleBookmarkOnMarked: ['', toggleBookmarkOnMarked: ['Bookmark|Mark/',
function(action){ function(action){
return this.toggleBookmark(this.data.getTaggedByAny('selected'), action) return this.toggleBookmark(this.data.getTaggedByAny('selected'), action)
}], }],
prevBookmarked: ['', prevBookmarked: ['Bookmark|Navigate/',
function(mode){ this.prevTagged('bookmark', mode) }], function(mode){ this.prevTagged('bookmark', mode) }],
nextBookmarked: ['', nextBookmarked: ['Bookmark|Navigate/',
function(mode){ this.nextTagged('bookmark', mode) }], function(mode){ this.nextTagged('bookmark', mode) }],
cropBookmarked: ['', cropBookmarked: ['Bookmark|Crop/',
function(flatten){ this.cropTagged('bookmark', 'any', flatten) }], function(flatten){ this.cropTagged('bookmark', 'any', flatten) }],
}) })