Skip to content

Commit 9d0be39

Browse files
author
Tim Berners-Lee
committed
Alt-click on tab brings up tab settings pane to adjust values or delete the tab
1 parent 3273eef commit 9d0be39

4 files changed

Lines changed: 75 additions & 26 deletions

File tree

lib/signin.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ UI.widgets.selectWorkspace = function(dom, appDetails, callbackWS) {
758758
newBase = ws.uri.split('#')[0];
759759
} else {
760760
newBase = newBase.value;
761-
}
761+
}
762762
if (newBase.slice(-1) !== '/') {
763763
console.log(appPathSegment + ": No / at end of uriPrefix " + newBase ); // @@ paramater?
764764
newBase = newBase + '/';
@@ -789,7 +789,9 @@ UI.widgets.selectWorkspace = function(dom, appDetails, callbackWS) {
789789
if (w.length == 1) {
790790

791791
say( "Workspace used: " + w[0].uri); // @@ allow user to see URI
792-
figureOutBase(w[0]);
792+
var newBase = figureOutBase(w[0]);
793+
callbackWS(ws, newBase);
794+
793795

794796
} else if (w.length == 0 ) {
795797
say("You don't seem to have any workspaces. You have "+storages.length +" storages.");
@@ -889,9 +891,11 @@ UI.widgets.selectWorkspace = function(dom, appDetails, callbackWS) {
889891
var button = dom.createElement('button');
890892
button.textContent = "Continue";
891893
// button.setAttribute('style', style);
894+
var newBase = figureOutBase(selectedWorkspace);
895+
// @@ show the user the URI
892896
button.addEventListener('click', function(e){
893897
button.disabled = true;
894-
figureOutBase(selectedWorkspace);
898+
callbackWS(selectedWorkspace, newBase);
895899
button.textContent = '---->';
896900
}, true); // capture vs bubble
897901
return button;

lib/tabs.js

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ var UI = {
2424
// options.subject
2525
// options.orientation 0 top, 1 left, 2 bottom, 3 right
2626
// options.showMain(div, subject) function to show subject in div when tab selected
27-
// options.showMain function(subject, domContainer)
27+
// options.renderTabSettings function(subject, domContainer)
28+
// options.renderTabSettings like showMain but when user has held Alt down
2829
//
2930

3031
UI.tabs.tabWidget = function(options){
@@ -39,12 +40,14 @@ UI.tabs.tabWidget = function(options){
3940

4041
var tabContainer, tabElement, mainDiv, tabBar
4142
//var bodyDiv = dom.createElement('div')
42-
var bodyDivStyle = 'resize: both; margin:0; border: 0.5em; border-style: solid; border-color: #eed; padding: 1em; min-width: 30em; min-height: 450px; width:100%;'
43+
var bodyDivStyle = 'resize: both; overflow: scroll; margin:0; border: 0.5em; border-style: solid; border-color: #eed; padding: 1em; min-width: 30em; min-height: 450px; width:100%;'
4344
//bodyDiv.setAttribute('style', )
4445
if (vertical){
4546
var onlyTR = wholetable.appendChild(dom.createElement('tr'))
4647
var mainTD = dom.createElement('td')
48+
mainTD.setAttribute('style', 'margin: 0;') // override tabbedtab.css
4749
var tabTD = dom.createElement('td')
50+
tabTD.setAttribute('style', 'margin: 0;')
4851
if (flipped){
4952
onlyTR.appendChild(mainTD)
5053
onlyTR.appendChild(tabTD)
@@ -88,9 +91,14 @@ UI.tabs.tabWidget = function(options){
8891
var corners = ["2em", "2em", "0", "0"] // top left, TR, BR, BL
8992
corners = corners.concat(corners).slice(orientation, orientation + 4)
9093
corners = 'border-radius: ' + corners.join(' ') + ';'
91-
var tabStyle = corners + 'margin: 0.3em; padding: 0.7em;'
92-
var unselectedStyle = tabStyle + ' background-color: #eed; border: 0.05em 0 0.5em 0.05em; border-color: grey;' // @@ rotate border
93-
var selectedStyle = tabStyle + ' background-color: #ddc;'
94+
95+
var margins = ["0.3em", "0.3em", "0", "0.3em"] // top, right, bottom, left
96+
margins = margins.concat(margins).slice(orientation, orientation + 4)
97+
margins = 'margin: ' + margins.join(' ') + ';'
98+
99+
var tabStyle = corners + 'padding: 0.7em;' // border: 0.05em 0 0.5em 0.05em; border-color: grey;
100+
var unselectedStyle = tabStyle + 'opacity: 50%; margin: 0.3em; background-color: #ddc;' // @@ rotate border
101+
var selectedStyle = tabStyle + margins + ' background-color: #eed;'
94102
var shownStyle = ''
95103
var hiddenStyle = shownStyle + 'display: none;'
96104

@@ -111,22 +119,39 @@ UI.tabs.tabWidget = function(options){
111119
ele.subject = item
112120
var div = ele.appendChild(dom.createElement('div'))
113121
div.setAttribute('style', unselectedStyle)
122+
114123
div.addEventListener('click', function(e){
115-
var bodyDiv
116-
if (!e.altKey){
124+
if (!e.metaKey){
117125
resetTabStyle()
118126
resetBodyStyle()
119127
}
120128
div.setAttribute('style', selectedStyle)
121129
ele.bodyTR.setAttribute('style', shownStyle)
122-
if (!ele.bodyTR.firstChild) {
123-
bodyDiv = ele.bodyTR.appendChild(dom.createElement('div'))
130+
var bodyDiv = ele.bodyTR.firstChild
131+
if (!bodyDiv){
132+
bodyDiv = ele.bodyTR.appendChild(dom.createElement('div'))
124133
bodyDiv.setAttribute('style', bodyDivStyle)
125-
bodyDiv.innerHTML = 'loading item ...' + item
126-
options.showMain(bodyDiv, ele.subject)
134+
}
135+
if (options.renderTabSettings && e.altKey){
136+
if (bodyDiv.asSetttings !== true){
137+
bodyDiv.innerHTML = 'loading settings ...' + item
138+
options.renderTabSettings(bodyDiv, ele.subject)
139+
bodyDiv.asSetttings = true
140+
}
141+
} else {
142+
if (bodyDiv.asSetttings !== false){
143+
bodyDiv.innerHTML = 'loading item ...' + item
144+
options.showMain(bodyDiv, ele.subject)
145+
bodyDiv.asSetttings = false
146+
}
127147
}
128148
})
129-
div.textContent = UI.utils.label(item)
149+
150+
if (options.renderTab){
151+
options.renderTab(div, item)
152+
} else {
153+
div.textContent = UI.utils.label(item)
154+
}
130155
return ele
131156
}
132157

@@ -231,5 +256,9 @@ UI.tabs.tabWidget = function(options){
231256
}
232257
box.refresh = sync
233258
sync()
259+
260+
if (!options.startEmpty && tabContainer.children.length){
261+
tabContainer.children[0].firstChild.click() // Open first tab
262+
}
234263
return box
235264
}

lib/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ UI.utils.label = function (x, initialCap) { // x is an object
420420
kb.any(x, UI.ns.rss('title')) ||
421421
kb.any(x, UI.ns.contact('fullName')) ||
422422
kb.any(x, kb.sym('http://www.w3.org/2001/04/roadmap/org#name')) ||
423+
kb.any(x, UI.ns.cal('summary')) ||
423424
kb.any(x, UI.ns.foaf('nick')) ||
424425
kb.any(x, UI.ns.rdfs('label'))
425426

@@ -437,6 +438,7 @@ UI.utils.label = function (x, initialCap) { // x is an object
437438
}
438439
var s = x.uri
439440
if (typeof s == 'undefined') return x.toString(); // can't be a symbol
441+
s = decodeURI(s)
440442
if (s.slice(-5) == '#this') s = s.slice(0, -5)
441443
else if (s.slice(-3) == '#me') s = s.slice(0, -3)
442444

lib/widgets.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ widgetModule.deleteButtonWithCheck = function (dom, container, noun, deleteFunct
190190
deleteFunction()
191191
}, false)
192192
}, false)
193+
return delButton
193194
}
194195

195196
// A TR to repreent a draggable person, etc in a list
@@ -500,7 +501,8 @@ widgetModule.fieldParams[UI.ns.ui('FloatField').uri] = {
500501
widgetModule.fieldParams[UI.ns.ui('FloatField').uri].pattern =
501502
/^\s*-?[0-9]*(\.[0-9]*)?((e|E)-?[0-9]*)?\s*$/
502503

503-
widgetModule.fieldParams[UI.ns.ui('SingleLineTextField').uri] = { }
504+
widgetModule.fieldParams[UI.ns.ui('SingleLineTextField').uri] = { }
505+
widgetModule.fieldParams[UI.ns.ui('NamedNodeURIField').uri] = { namedNode: true}
504506
widgetModule.fieldParams[UI.ns.ui('TextField').uri] = { }
505507

506508
widgetModule.fieldParams[UI.ns.ui('PhoneField').uri] = { 'size': 12, 'uriPrefix': 'tel:' }
@@ -522,7 +524,8 @@ widgetModule.field[UI.ns.ui('PhoneField').uri] =
522524
widgetModule.field[UI.ns.ui('DecimalField').uri] =
523525
widgetModule.field[UI.ns.ui('FloatField').uri] =
524526
widgetModule.field[UI.ns.ui('TextField').uri] =
525-
widgetModule.field[UI.ns.ui('SingleLineTextField').uri] = function (
527+
widgetModule.field[UI.ns.ui('SingleLineTextField').uri] =
528+
widgetModule.field[UI.ns.ui('NamedNodeURIField').uri] = function (
526529
dom, container, already, subject, form, store, callback) {
527530
var ui = UI.ns.ui
528531
var kb = UI.store
@@ -557,16 +560,16 @@ widgetModule.field[UI.ns.ui('PhoneField').uri] =
557560
var maxLength = kb.any(form, ui('maxLength'))
558561
field.setAttribute('maxLength', maxLength ? '' + maxLength : '4096')
559562

560-
store = widgetModule.fieldStore(subject, property, store)
563+
store = store || widgetModule.fieldStore(subject, property, store)
561564

562-
var obj = kb.any(subject, property)
565+
var obj = kb.any(subject, property, undefined, store)
563566
if (!obj) {
564567
obj = kb.any(form, ui('default'))
565-
if (obj !== undefined) kb.add(subject, property, obj, store)
568+
if (obj) kb.add(subject, property, obj, store)
569+
}
570+
if (obj) {
571+
field.value = obj.value || obj.uri
566572
}
567-
if (obj !== undefined && obj.value !== undefined) { field.value = obj.value.toString() }
568-
if (obj !== undefined && obj.uri !== undefined) { field.value = obj.uri.split(':')[1]} // @@ URI encoding/decoding
569-
570573
field.addEventListener('keyup', function (e) {
571574
if (params.pattern) {
572575
field.setAttribute('style', style + (
@@ -580,8 +583,13 @@ widgetModule.field[UI.ns.ui('PhoneField').uri] =
580583
var ds = kb.statementsMatching(subject, property) // remove any multiple values
581584
// var newObj = params.uriPrefix ? kb.sym(params.uriPrefix + field.value.replace(/ /g, ''))
582585
// : kb.literal(field.value, params.dt)
583-
var is = $rdf.st(subject, property,
584-
params.parse ? params.parse(field.value) : field.value, store) // @@ Explicitly put the datatype in.
586+
var result
587+
if (params.namedNode) {
588+
result = kb.sym(field.value)
589+
} else {
590+
result = params.parse ? params.parse(field.value) : field.value
591+
}
592+
var is = $rdf.st(subject, property, result , store) // @@ Explicitly put the datatype in.
585593
kb.updater.update(ds, is, function (uri, ok, body) {
586594
if (ok) {
587595
field.disabled = false
@@ -803,7 +811,13 @@ widgetModule.openHrefInOutlineMode = function (e) {
803811
if (!uri) console.log('No href found \n')
804812
// subject term, expand, pane, solo, referrer
805813
// dump('click on link to:' +uri+'\n')
806-
UI.outline.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
814+
if (UI.outline){
815+
UI.outline.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
816+
} else if (window || window.UI || window.UI.outline ){
817+
window.UI.outline.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
818+
}
819+
console.log("ERROR: Can't acces outline manager in this config")
820+
//UI.outline.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
807821
}
808822

809823
// We make a URI in the annotation store out of the URI of the thing to be annotated.

0 commit comments

Comments
 (0)