diff --git a/ui/index.html b/ui/index.html
index b4790a1d..ef2566d0 100755
--- a/ui/index.html
+++ b/ui/index.html
@@ -20,6 +20,7 @@
+
diff --git a/ui/lib/editor.js b/ui/lib/editor.js
index 8cd54dc7..938bd78b 100755
--- a/ui/lib/editor.js
+++ b/ui/lib/editor.js
@@ -246,101 +246,6 @@ function makeLogRange(text, filter, target){
}
-function makePanel(title, open, editable_title){
- title = title == null ? ' ' : title
-
- // tool panel...
- var panel = $(' ')
- .prop('open', open == null ? true : open)
- .addClass('panel noScroll')
- .css({
- position: 'absolute',
- top: '100px',
- left: '100px',
- })
- .append($(''+title+'')
- .attr({
- contenteditable: editable_title == null ? 'false' : 'true',
- })
- // XXX add a '+' button to create a new panel...
- .append($('')
- .addClass('close-button')
- .click(function(){
- panel
- .trigger('panelClosing')
- .hide()
- return false
- })
- .html('×')))
- .draggable({
- containment: 'parent',
- scroll: false,
- // XXX this makes things quite a bit slower...
- stack: '.panel',
- })
-
- var _outside = false
-
- // wrapper for sub-panels...
- var content = $('')
- .sortable({
- forcePlaceholderSize: true,
- opacity: 0.7,
- connectWith: '.panel-content',
- zIndex: 9999,
-
- start: function(e, ui){
- _outside = false
- ui.placeholder.height(ui.helper.outerHeight());
- ui.placeholder.width(ui.helper.outerWidth());
- },
- // XXX this is not done...
- // create a new panel when dropping outside of curent panel...
- stop: function(e, ui){
- // do this only when dropping putside the panel...
- if(_outside){
- makePanel()
- // XXX adjust this to scale...
- .css(ui.position)
- .appendTo(panel.parent())
- .find('.panel-content')
- .append(ui.item)
- }
- },
- // XXX are these the correct events???
- over: function(e, ui){
- _outside = false
- },
- out: function(e, ui){
- _outside = true
- },
- })
- .appendTo(panel)
- return panel
-}
-
-
-function makeSubPanel(title, open, parent){
- title = title == null ? ' ' : title
-
- var sub_panel = $(' ')
- .addClass('sub-panel noScroll')
- .prop('open', open == null ? true : open)
- .append($(''+title+''))
- .append($(''))
-
- if(parent != null){
- if(parent.hasClass('panel-content')){
- sub_panel.appendTo(parent)
- } else {
- sub_panel.appendTo(parent.find('.panel-content'))
- }
- }
-
- return sub_panel
-}
-
-
function makeFilterPanel(parent, target){
return makeSubPanel('Filters', true, parent)
.find('.sub-panel-content')
diff --git a/ui/lib/panels.js b/ui/lib/panels.js
new file mode 100755
index 00000000..2aea779f
--- /dev/null
+++ b/ui/lib/panels.js
@@ -0,0 +1,111 @@
+/**********************************************************************
+*
+*
+*
+**********************************************************************/
+
+//var DEBUG = DEBUG != null ? DEBUG : true
+
+
+/*********************************************************************/
+
+function makePanel(title, open, editable_title){
+ title = title == null ? ' ' : title
+
+ // tool panel...
+ var panel = $(' ')
+ .prop('open', open == null ? true : open)
+ .addClass('panel noScroll')
+ .css({
+ position: 'absolute',
+ top: '100px',
+ left: '100px',
+ })
+ .append($(''+title+'')
+ .attr({
+ contenteditable: editable_title == null ? 'false' : 'true',
+ })
+ // XXX add a '+' button to create a new panel...
+ .append($('')
+ .addClass('close-button')
+ .click(function(){
+ panel
+ .trigger('panelClosing')
+ .hide()
+ return false
+ })
+ .html('×')))
+ .draggable({
+ containment: 'parent',
+ scroll: false,
+ // XXX this makes things quite a bit slower...
+ stack: '.panel',
+ })
+
+ var _outside = false
+
+ // wrapper for sub-panels...
+ var content = $('')
+ .sortable({
+ forcePlaceholderSize: true,
+ opacity: 0.7,
+ connectWith: '.panel-content',
+ zIndex: 9999,
+
+ start: function(e, ui){
+ _outside = false
+ ui.placeholder.height(ui.helper.outerHeight());
+ ui.placeholder.width(ui.helper.outerWidth());
+ },
+ // XXX this is not done...
+ // create a new panel when dropping outside of curent panel...
+ stop: function(e, ui){
+ // do this only when dropping putside the panel...
+ if(_outside){
+ makePanel()
+ // XXX adjust this to scale...
+ .css(ui.position)
+ .appendTo(panel.parent())
+ .find('.panel-content')
+ .append(ui.item)
+ }
+ },
+ // XXX are these the correct events???
+ over: function(e, ui){
+ _outside = false
+ },
+ out: function(e, ui){
+ _outside = true
+ },
+ })
+ .appendTo(panel)
+ return panel
+}
+
+
+function makeSubPanel(title, open, parent){
+ title = title == null ? ' ' : title
+
+ var sub_panel = $(' ')
+ .addClass('sub-panel noScroll')
+ .prop('open', open == null ? true : open)
+ .append($(''+title+''))
+ .append($(''))
+
+ if(parent != null){
+ if(parent.hasClass('panel-content')){
+ sub_panel.appendTo(parent)
+ } else {
+ sub_panel.appendTo(parent.find('.panel-content'))
+ }
+ }
+
+ return sub_panel
+}
+
+
+
+
+
+/**********************************************************************
+* vim:set ts=4 sw=4 : */
diff --git a/ui/tags.js b/ui/tags.js
index f57b0c60..1b26d267 100755
--- a/ui/tags.js
+++ b/ui/tags.js
@@ -18,15 +18,32 @@ TAGS = {
/*********************************************************************/
-function buildTagsFromImages(images){
+function buildTagsFromImages(images, tagset){
+ tagset = tagset == null ? TAGS : tagset
+ images = images == null ? IMAGES : images
+
+ for(gid in images){
+ var tags = images[gid].tags
+ if(tags == null){
+ continue
+ }
+ tags.map(function(tag){
+ if(tagset[tag] == null){
+ tagset[tag] = []
+ }
+ tagset[tag].push(gid)
+ })
+ }
}
+
// XXX
function normalizeTag(tag){
return tag.trim()
}
+
/*********************************************************************/
function addTag(tags, gid, tagset, images){
@@ -137,19 +154,25 @@ function updateTags(tags, gid, tagset, images){
// this implements the AND selector...
// NOTE: do not like this algorithm as it can get O(n^2)-ish
function selectByTags(tags, tagset){
+ tags = typeof(tags) == typeof('str') ? [ tags ] : tags
+ tagset = tagset == null ? TAGS : tagset
+
var subtagset = []
var res = []
// populate the subtagset...
tags.map(function(tag){
+ if(tagset[tag] == null){
+ return
+ }
subtagset.push(tagset[tag])
})
subtagset.sort(function(a, b){
- return a.length - b.length
+ return b.length - a.length
})
// set the res to the shortest subset...
- var cur = subtagset.pop().splice()
+ var cur = subtagset.pop().slice()
// filter out the result...
cur.map(function(gid){