merging changes

This commit is contained in:
rolux 2011-10-07 03:19:00 +02:00
commit 02c12f542c
14 changed files with 115017 additions and 104 deletions

View file

@ -4438,7 +4438,7 @@
"dissolved": [], "dissolved": [],
"east": 7.2271405, "east": 7.2271405,
"flagURL": "http://upload.wikimedia.org/wikipedia/commons/2/20/Flag_of_the_Netherlands.svg", "flagURL": "http://upload.wikimedia.org/wikipedia/commons/2/20/Flag_of_the_Netherlands.svg",
"googleName": "Netherlands", "googleName": "The Netherlands",
"imdbCode": "nl", "imdbCode": "nl",
"imdbName": "Netherlands", "imdbName": "Netherlands",
"languages": [ "languages": [

View file

@ -1255,15 +1255,37 @@ Maps
border-radius: 0; border-radius: 0;
} }
input[type=image].OxMapButton { .OxMap .OxButton.OxMapControl {
position: absolute; position: absolute;
width: 10px; width: 10px;
height: 10px; height: 10px;
padding: 1px; padding: 1px;
border-width: 2px; border-width: 2px;
} }
.OxMapLabel { .OxMap .OxButton.OxMapControl.OxMapButtonCenter {
left: 24px;
top: 24px;
}
.OxMap .OxButton.OxMapControl.OxMapButtonEast {
left: 44px;
top: 24px;
}
.OxMap .OxButton.OxMapControl.OxMapButtonNorth {
left: 24px;
top: 4px;
}
.OxMap .OxButton.OxMapControl.OxMapButtonSouth {
left: 24px;
top: 44px;
}
.OxMap .OxButton.OxMapControl.OxMapButtonWest {
left: 4px;
top: 24px;
}
.OxMap .OxLabel.OxMapControl {
position: absolute; position: absolute;
right: 4px;
top: 4px;
height: 12px; height: 12px;
font-size: 10px; font-size: 10px;
border-width: 2px; border-width: 2px;

View file

@ -105,8 +105,8 @@ Ox.Select = function(options, self) {
)) + 'px' )) + 'px'
}) })
.html( .html(
self.options.title ? self.options.title : self.options.title ? self.options.title
self.options.items[self.checked[0]].title : self.options.items[self.checked[0]].title
) )
.click(showMenu) .click(showMenu)
.appendTo(that.$element); .appendTo(that.$element);

View file

@ -118,8 +118,9 @@ Ox.Map = function(options, self) {
}) })
.bindEvent({ .bindEvent({
key_0: function() { key_0: function() {
that.panToPlace() panToPlace()
}, },
key_c: toggleControls,
key_down: function() { key_down: function() {
pan(0, 1); pan(0, 1);
}, },
@ -158,7 +159,7 @@ Ox.Map = function(options, self) {
pan(0, 2); pan(0, 2);
}, },
key_shift_0: function() { key_shift_0: function() {
that.zoomToPlace(); zoomToPlace();
}, },
key_shift_equal: function() { key_shift_equal: function() {
zoom(2); zoom(2);
@ -211,18 +212,41 @@ Ox.Map = function(options, self) {
}) })
.appendTo(that); .appendTo(that);
self.$select = Ox.Select({ self.$select = Ox.Select({
items: [ items: Ox.merge(
{id: 'new Place', title: 'New Place...', keyboard: 'n'}, self.options.editable
{}, ? [{id: 'new Place', title: 'New Place...', keyboard: 'n'}, {}]
{id: 'toggleLabels', title: 'Show Labels', keyboard: 'l', checked: self.options.showLabels}, : [],
{id: 'toggleControls', title: 'Show Controls', keyboard: 'c', checked: self.options.showControls}, [
], {
min: 0, id: 'toggleLabels',
max: 2, title: self.options.showLabels
? ['Hide Labels', 'Show Labels']
: ['Show Labels', 'Hide Labels'],
keyboard: 'l'
},
{
id: 'toggleControls',
title: self.options.showControls
? ['Hide Controls', 'Show Controls']
: ['Show Controls', 'Hide Controls'],
keyboard: 'c'
}
]
),
selectable: false,
title: 'Options...', title: 'Options...',
width: 96 width: 96
}) })
.css({float: 'left', margin: '4px'}) .css({float: 'left', margin: '4px'})
.bindEvent({
click: function(data) {
if (data.id == 'toggleLabels') {
toggleLabels();
} else if (data.id == 'toggleControls') {
toggleControls();
}
}
})
.appendTo(self.$toolbar); .appendTo(self.$toolbar);
/* /*
self.$labelsButton = Ox.Checkbox({ self.$labelsButton = Ox.Checkbox({
@ -306,66 +330,82 @@ Ox.Map = function(options, self) {
.appendTo(self.$statusbar); .appendTo(self.$statusbar);
} }
self.$navigationButtons = { self.$controls = {
'center': Ox.Button({ 'center': Ox.Button({
title: 'close', title: 'center',
type: 'image' type: 'image'
}) })
.addClass('OxMapButton') .addClass('OxMapControl OxMapButtonCenter')
.css({ .bindEvent({
left: '24px', singleclick: function() {
top: '24px' panToPlace();
},
doubleclick: function() {
zoomToPlace();
}
}), }),
'east': Ox.Button({ 'east': Ox.Button({
title: 'right', title: 'right',
type: 'image' type: 'image'
}) })
.addClass('OxMapButton') .addClass('OxMapControl OxMapButtonEast')
.css({ .bindEvent({
left: '44px', singleclick: function() {
top: '24px', pan(1, 0);
},
doubleclick: function() {
pan(2, 0);
}
}), }),
'north': Ox.Button({ 'north': Ox.Button({
title: 'up', title: 'up',
type: 'image' type: 'image'
}) })
.addClass('OxMapButton') .addClass('OxMapControl OxMapButtonNorth')
.css({ .bindEvent({
left: '24px', singleclick: function() {
top: '4px', pan(0, -1);
},
doubleclick: function() {
pan(0, -2);
}
}), }),
'south': Ox.Button({ 'south': Ox.Button({
title: 'down', title: 'down',
type: 'image' type: 'image'
}) })
.addClass('OxMapButton') .addClass('OxMapControl OxMapButtonSouth')
.css({ .bindEvent({
left: '24px', singleclick: function() {
top: '44px', pan(0, 1);
},
doubleclick: function() {
pan(0, 2);
}
}), }),
'west': Ox.Button({ 'west': Ox.Button({
title: 'left', title: 'left',
type: 'image' type: 'image'
}) })
.addClass('OxMapButton') .addClass('OxMapControl OxMapButtonWest')
.css({ .bindEvent({
left: '4px', singleclick: function() {
top: '24px', pan(-1, 0);
},
doubleclick: function() {
pan(-2, 0);
}
}),
'scale': Ox.Label({
textAlign: 'center',
title: '...' // fixme ???
}) })
.addClass('OxMapControl')
}; };
Ox.forEach(self.$navigationButtons, function($button) { !self.options.showControls && Ox.forEach(self.$controls, function($control) {
$button.attr({ $control.css({opacity: 0}).hide();
src: $button.attr('src').replace('/classic/', '/modern/')
});
}); });
self.$scaleLabel = Ox.Label({
textAlign: 'center',
title: '...' // fixme ???
})
.addClass('OxMapLabel')
.css({right: '4px', top: '4px'});
if (!self.isAsync) { if (!self.isAsync) {
self.options.places.forEach(function(place) { self.options.places.forEach(function(place) {
if (Ox.isUndefined(place.id)) { if (Ox.isUndefined(place.id)) {
@ -755,10 +795,9 @@ Ox.Map = function(options, self) {
function tilesLoaded() { function tilesLoaded() {
// fixme: can add earlier, use don't replace map contents option // fixme: can add earlier, use don't replace map contents option
Ox.forEach(self.$navigationButtons, function(button) { Ox.forEach(self.$controls, function($control) {
button.appendTo(self.$map); $control.appendTo(self.$map);
}); });
self.$scaleLabel.appendTo(self.$map);
} }
} }
@ -862,6 +901,11 @@ Ox.Map = function(options, self) {
self.map.panBy(x * self.$map.width() / 2, y * self.$map.height() / 2); self.map.panBy(x * self.$map.width() / 2, y * self.$map.height() / 2);
}; };
function panToPlace() {
var place = getSelectedPlace();
place && self.map.panTo(place.center);
}
function parseGeodata(data) { function parseGeodata(data) {
var bounds = data.geometry.bounds || data.geometry.viewport, var bounds = data.geometry.bounds || data.geometry.viewport,
northEast = bounds.getNorthEast(), northEast = bounds.getNorthEast(),
@ -1043,7 +1087,7 @@ Ox.Map = function(options, self) {
}, result.data.items[0])).add(); }, result.data.items[0])).add();
self.places.push(place); self.places.push(place);
select(); select();
that.zoomToPlace(); zoomToPlace();
} }
}); });
} }
@ -1066,7 +1110,7 @@ Ox.Map = function(options, self) {
Ox.forEach(self.scaleMeters, function(meters) { Ox.forEach(self.scaleMeters, function(meters) {
var scaleWidth = Math.round(meters / metersPerPixel); var scaleWidth = Math.round(meters / metersPerPixel);
if (scaleWidth <= self.options.width / 2 - 4) { if (scaleWidth <= self.options.width / 2 - 4) {
self.$scaleLabel self.$controls.scale
.options({ .options({
title: '\u2190 ' + ( title: '\u2190 ' + (
meters > 1000 ? Ox.formatNumber(meters / 1000) + ' k' : meters + ' ' meters > 1000 ? Ox.formatNumber(meters / 1000) + ' k' : meters + ' '
@ -1123,16 +1167,28 @@ Ox.Map = function(options, self) {
}); });
} }
function toggleLabels() { function toggleControls() {
self.options.showLabels = !self.options.showLabels // fixme: that.find() doesn't work here
//Ox.print('toggle', getMapType()) var $controls = that.$element.find('.OxMapControl');
self.map.setMapTypeId(google.maps.MapTypeId[getMapType()]); self.options.showControls = !self.options.showControls;
/* if (self.options.showControls) {
self.$labelsButton.options({ $controls.show().animate({opacity: 1}, 250);
title: self.$labelsButton.options('title') == 'Show Labels' ? } else {
'Hide Labels' : 'Show Labels' $controls.animate({opacity: 0}, 250, function() {
$controls.hide();
});
}
that.triggerEvent('togglecontrols', {
visible: self.options.showControls
});
}
function toggleLabels() {
self.options.showLabels = !self.options.showLabels;
self.map.setMapTypeId(google.maps.MapTypeId[getMapType()]);
that.triggerEvent('togglelabels', {
visible: self.options.showLabels
}); });
*/
} }
function triggerGeocodeEvent(data) { function triggerGeocodeEvent(data) {
@ -1209,10 +1265,8 @@ Ox.Map = function(options, self) {
} }
function zoomToPlace() { function zoomToPlace() {
Ox.print('zoomToPlace') var place = getSelectedPlace();
if (self.options.selected !== null) { place && self.map.fitBounds(place.bounds);
self.map.fitBounds(getPlaceById(self.options.selected).bounds);
}
} }
self.setOption = function(key, value) { self.setOption = function(key, value) {
@ -1276,9 +1330,7 @@ Ox.Map = function(options, self) {
}; };
that.panToPlace = function() { that.panToPlace = function() {
Ox.print('panToPlace:', self.options.selected) panToPlace();
var place = getSelectedPlace();
place && self.map.panTo(place.center);
return that; return that;
}; };
@ -1348,9 +1400,7 @@ Ox.Map = function(options, self) {
} }
that.zoomToPlace = function() { that.zoomToPlace = function() {
Ox.print('zoomToPlace') zoomToPlace();
var place = getSelectedPlace();
place && self.map.fitBounds(place.bounds);
return that; return that;
}; };

View file

@ -135,7 +135,7 @@ Ox.MenuItem = function(options, self) {
toggleTitle <f> toggleTitle toggleTitle <f> toggleTitle
@*/ @*/
that.toggleTitle = function() { that.toggleTitle = function() {
that.options({title: self.options.title.reverse()}); that.options({title: Ox.clone(self.options.title).reverse()});
return that; return that;
}; };

View file

@ -331,7 +331,7 @@ Ox.VideoEditor = function(options, self) {
{key: '\\', action: 'Select Current Annotation'}, {key: '\\', action: 'Select Current Annotation'},
{key: '<', action: 'Go to Previous Cut'}, {key: '<', action: 'Go to Previous Cut'},
{key: '>', action: 'Go to Next Cut'}, {key: '>', action: 'Go to Next Cut'},
{key: '/', action: 'Select Current Cuts'}, {key: '/', action: 'Select Current Cut'},
{key: 'F', action: 'Find'}, {key: 'F', action: 'Find'},
{key: Ox.UI.symbols.shift + 'G', action: 'Go to Previous Result'}, {key: Ox.UI.symbols.shift + 'G', action: 'Go to Previous Result'},
{key: 'G', action: 'Go to Next Result'}, {key: 'G', action: 'Go to Next Result'},
@ -360,21 +360,24 @@ Ox.VideoEditor = function(options, self) {
}); });
self.$videoMenuButton = Ox.Select({ self.$videoMenuButton = Ox.Select({
items: Ox.merge([ items: Ox.merge(
{id: 'toggleSize', title: 'Large Player', selected: self.options.playerSize == 'large', keyboard: 'shift +'}, [
{} {id: 'toggleSize', title: 'Large Player', selected: self.options.playerSize == 'large', keyboard: 'shift +'},
], self.resolutions, [ {}
{}, ],
{id: 'largeTimeline', title: 'Hide Large Timeline'}, self.resolutions,
{id: 'subtitlesTimeline', title: 'Hide Subtitles on Large Timeline'}, [
{}, {},
{id: 'linkSelection', title: 'Link to Selection...'}, {id: 'largeTimeline', title: 'Hide Large Timeline'},
{id: 'embed', title: 'Embed Selection...'}, {id: 'subtitlesTimeline', title: 'Hide Subtitles on Large Timeline'},
{id: 'downloadSelection', title: 'Download Selection...'}, {},
{}, {id: 'linkSelection', title: 'Link to Selection...'},
{id: 'keyboard', title: 'Keyboard Shortcuts...', keyboard: 'h'} {id: 'embed', title: 'Embed Selection...'},
{id: 'downloadSelection', title: 'Download Selection...'},
]), {},
{id: 'keyboard', title: 'Keyboard Shortcuts...', keyboard: 'h'}
]
),
selectable: false, selectable: false,
title: $('<img>').attr({ title: $('<img>').attr({
src: Ox.UI.getImageURL('symbolSet') src: Ox.UI.getImageURL('symbolSet')

View file

@ -443,14 +443,10 @@ Maps
================================================================================ ================================================================================
*/ */
.OxThemeClassic .OxMapButton { .OxThemeClassic .OxMapControl {
border-color: rgb(255, 255, 255); border-color: rgb(64, 64, 64);
background: rgba(0, 0, 0, 0.5); background: rgba(255, 255, 255, 0.75);
} color: rgb(64, 64, 64);
.OxThemeClassic .OxMapLabel {
border-color: rgb(255, 255, 255);
background: rgba(0, 0, 0, 0.5);
color: rgb(255, 255, 255);
} }
/* /*

View file

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256">
<circle cx="128" cy="128" r="80" fill="#404040"/>
</svg>

After

Width:  |  Height:  |  Size: 126 B

View file

@ -430,14 +430,10 @@ Maps
================================================================================ ================================================================================
*/ */
.OxThemeModern .OxMapButton { .OxThemeModern .OxMapControl {
border-color: rgb(255, 255, 255); border-color: rgb(192, 192, 192);
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
} color: rgb(192, 192, 192);
.OxThemeModern .OxMapLabel {
border-color: rgb(255, 255, 255);
background: rgba(0, 0, 0, 0.5);
color: rgb(255, 255, 255);
} }
/* /*

View file

@ -0,0 +1,97 @@
Ox.load.Unicode = function(options, callback) {
Ox.getJSON(Ox.PATH + 'Ox.Unicode/json/Ox.Unicode.json', function(chars) {
//@ Ox.UNICODE_CHARACTERS <o> Unicode characters
Ox.UNICODE_CHARACTERS = chars;
var byASCII = {}, byName = {}, bySection = [], byType = {};
Ox.forEach(chars, function(data, char) {
if (data.ascii) {
byASCII[data.ascii] = byASCII[data.ascii] || [];
byASCII[data.ascii].push(char);
}
data.names.forEach(function(name) {
byName[name] = char;
});
bySection[data.section] = bySection[data.section] || [];
bySection[data.section].push(char);
byType[data.type] = byType[data.type] || [];
byType[data.type].push(char);
});
/*@
Ox.getCharactersByASCII <f> Returns all unicode equivalents of a given ASCII string
(ascii) -> <[s]> Unicode Characters
ascii <s> ASCII string
> Ox.getCharactersByASCII('A').length
36
@*/
Ox.getCharactersByASCII = function(ascii) {
return byASCII[ascii] || '';
};
/*@
Ox.getCharacterByName <f> Returns a character for a given unicode name
(name) -> <s> Character
> Ox.getCharacterByName('Skull and Crossbones')
'\u2620'
@*/
Ox.getCharacterByName = function(name) {
return byName[name.toUpperCase()] || '';
};
/*@
Ox.getCharactersBySection <f> Returns all characters in a given section
(section) -> <[s]> Characters
section <s> Unicode section name
> Ox.getCharactersBySection('Arabic').length
252
@*/
Ox.getCharactersBySection = function(section) {
return bySection[section.toUpperCase()] || '';
};
/*@
Ox.getCharactersByType <f> Returns all characters of a given type
(type) -> <[s]> Characters
type <s> Unicode character type
> Ox.getCharactersByType('Uppercase Latin Alphabet').join('')
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
@*/
Ox.getCharactersByType = function(type) {
return byType[type.toUpperCase()] || '';
};
/*@
Ox.sortASCII <f> Sorts an array of unicode strings
(arr) -> <[s]> Sorted array
> Ox.sortASCII(['å', 'b', 'ç', 'd', 'é'])
['å', 'b', 'ç', 'd', 'é']
@*/
Ox.sortASCII = function(arr) {
return Ox.sort(arr, function(str) {
return Ox.toASCII(str);
});
};
/*@
Ox.toASCII <f> Replaces a unicode string with its ASCII equivalent
(unicode) -> <s> ASCII string
> Ox.toASCII('Åbçdé')
'Abcde'
> Ox.toASCII('\u2162 \u33a6')
'3 km3'
@*/
Ox.toASCII = function(str) {
return Ox.map(str, function(chr) {
return chars[chr].ascii || chr;
}).join('');
};
callback(true);
});
}

File diff suppressed because it is too large Load diff

12
tests/css/tests.css Normal file
View file

@ -0,0 +1,12 @@
div {
font-family: Consolas;
font-size: 12px;
}
.success {
color: rgb(0, 128, 0);
}
.failure {
color: rgb(192, 0, 0);
}

106
tests/js/tests.js Normal file
View file

@ -0,0 +1,106 @@
Ox.load({Geo: {}, UI: {}, Unicode: {}}, function() {
Ox.getJSON('../dev/Ox/json/Ox.json', function(files) {
var $body = $('body')
.css({
overflowY: 'auto'
}),
$tests = new Ox.Bar({
size: 20
})
.css({
padding: '6px 0 6px 8px',
fontSize: '16px',
fontWeight: 'bold'
})
.appendTo($body);
colors = [
['255, 64, 64', '224, 32, 32', '240, 16, 16'],
['64, 192, 64', '32, 160, 32', '40, 176, 48'],
['96, 96, 255', '64, 64, 224', '80, 80, 240']
];
setBackground($tests, true);
tests(Ox.merge(Ox.merge.apply(null, files).map(function(file) {
return '../dev/' + file;
}), [
'../dev/Ox.Geo/Ox.Geo.js',
'../dev/Ox.Image/Ox.Image.js',
'../dev/Ox.Unicode/Ox.Unicode.js'
]));
function tests() {
Ox.print('!!!!!!', arguments)
var passed = 0, failed = 0,
lines, spaces, command, expected, result, passed,
replace = ['', ''], fns = [], $test
Ox.forEach(Ox.isArray(arguments[0]) ? arguments[0] : arguments, function(script, i) {
Ox.test(script, function(results) {
var tests = {};
results.forEach(function(result) {
tests[result.section] = tests[result.section] || {};
tests[result.section][result.name] = tests[result.section][result.name] || [];
tests[result.section][result.name].push(result);
});
Ox.forEach(tests, function(functions, section) {
Ox.Bar({size: 14})
.css({padding: '1px 0 1px 4px'})
.html(Ox.basename(script) + ' ' + section)
.appendTo($body);
Ox.forEach(functions, function(arr, fn) {
var $test = Ox.CollapsePanel({
collapsed: true,
title: fn + '()'
})
.appendTo($body);
setBackground($test.find('.OxBar'), true);
arr.forEach(function(test) {
passed += test.passed;
failed += !test.passed;
$tests.html(
(passed + failed) + ' tests, '
+ passed + ' passed, ' + failed + ' failed'
);
if (!test.passed) {
setBackground($tests, false);
setBackground($test.find('.OxBar'), false);
}
Ox.Element()
.css({
padding: '2px 0 2px 4px',
background: 'rgb(' + colors[+test.passed][2] + ')'
})
.html(
'<span style="font-family: Monaco">'
+ Ox.encodeHTML(test.statement) + ' '
+ (test.passed ? '=' : '!') + '=&gt; '
+ Ox.encodeHTML(test.expected)
+ (test.passed ? '' : ' ==&gt; ' + Ox.encodeHTML(test.actual))
+ '</tt>'
)
.appendTo($test.$content);
});
$test.$content.css({
marginTop: -$test.$content.height() + 'px'
});
});
});
})
});
}
function setBackground($element, passed) {
['-moz-linear-gradient', '-webkit-linear-gradient'].forEach(function(v) {
$element.css({
background: v + '(top, rgb(' +
colors[+passed][0] + '), rgb(' +
colors[+passed][1] + '))'
});
});
}
});
});

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
#vim: et:ts=4:sw=4:sts=4 #vim: et:ts=4:sw=4:sts=4
import base64 import base64
import json import json
import os import os
@ -10,6 +11,7 @@ import sys
def build_oxjs(geo): def build_oxjs(geo):
base_path = os.path.dirname(__file__) base_path = os.path.dirname(__file__)
if base_path: if base_path:
os.chdir(base_path) os.chdir(base_path)