update to latest oxjs api

This commit is contained in:
j 2014-09-24 15:30:23 +02:00
parent 0c11681de3
commit b5bc56d075
3 changed files with 80 additions and 100 deletions

View File

@ -25,7 +25,6 @@ limitations under the License.
<link rel="stylesheet" href="/static/pdf.js/viewer.css"/>
<script type="text/javascript" src="/static/oxjs/build/Ox.js"></script>
<script type="text/javascript" src="/static/oxjs/source/Ox.UI/js/Core/Message.js"></script>
<script type="text/javascript" src="/static/pdf.js/compatibility.js"></script>

View File

@ -286,7 +286,6 @@ oml.ui.mainMenu = function() {
}
]
})
.bindKeyboard()
.bindEvent({
change: function(data) {
var id = data.id,
@ -447,69 +446,6 @@ oml.ui.mainMenu = function() {
Ox.print('MAIN MENU DOES NOT YET HANDLE', id);
}
},
key_backtick: function() {
changeFocus(1);
},
key_control_comma: function() {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({page: 'preferences'});
}
},
key_control_f: function() {
if (!oml.hasDialogOrScreen()) {
if (ui._findState.key != 'advanced') {
setTimeout(function() {
oml.$ui.findInput.focusInput(true);
});
} else {
oml.$ui.filterDialog = oml.ui.filterDialog().open();
}
}
},
key_control_m: function() {
if (!oml.hasDialogOrScreen() && !that.isSelected()) {
that.options('menus')[0].element.trigger('click');
}
},
key_control_shift_f: function() {
Ox.print('FIXME: NOT IMPLEMENTED')
},
key_control_shift_w: function() {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({
find: oml.config.user.ui.find,
item: ''
});
}
},
key_control_shift_z: function() {
oml.redoHistory();
},
key_control_slash: function() {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({page: 'help'});
}
},
key_control_w: function() {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({item: ''});
}
},
key_control_z: function() {
oml.undoHistory();
},
key_shift_b: function() {
ui.item && oml.UI.set({showBrowser: !ui.showBrowser});
},
key_shift_f: function() {
!ui.item && oml.UI.set({showFilters: !ui.showFilters});
},
key_shift_i: function() {
ui.showSidebar && oml.UI.set({showInfo: !ui.showInfo});
},
key_shift_s: function() {
oml.UI.set({showSidebar: !ui.showSidebar});
},
oml_find: function() {
that.replaceMenu('listMenu', getListMenu());
that.replaceMenu('editMenu', getEditMenu());
@ -565,6 +501,59 @@ oml.ui.mainMenu = function() {
that[data.value ? 'enableItem' : 'disableItem']('showinfo');
},
});
Ox.Event.bind('key', function(data, event, element) {
var key = event.replace(/^key\./, '');
if (key == 'backtick') {
changeFocus(1);
} else if (key == 'control_comma') {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({page: 'preferences'});
}
} else if (key == 'control_f') {
if (!oml.hasDialogOrScreen()) {
if (ui._findState.key != 'advanced') {
setTimeout(function() {
oml.$ui.findInput.focusInput(true);
});
} else {
oml.$ui.filterDialog = oml.ui.filterDialog().open();
}
}
} else if (key == 'control_m') {
if (!oml.hasDialogOrScreen() && !that.isSelected()) {
that.options('menus')[0].element.trigger('click');
}
} else if (key == 'control_shift_f') {
Ox.print('FIXME: NOT IMPLEMENTED')
} else if (key == 'control_shift_w') {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({
find: oml.config.user.ui.find,
item: ''
});
}
} else if (key == 'control_shift_z') {
oml.redoHistory();
} else if (key == 'control_slash') {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({page: 'help'});
}
} else if (key == 'control_w') {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({item: ''});
}
} else if (key == 'control_z') {
oml.undoHistory();
} else if (key == 'shift_b') {
ui.item && oml.UI.set({showBrowser: !ui.showBrowser});
} else if (key == 'shift_f') {
!ui.item && oml.UI.set({showFilters: !ui.showFilters});
} else if (key == 'shift_i') {
ui.showSidebar && oml.UI.set({showInfo: !ui.showInfo});
} else if (key == 'shift_s') {
oml.UI.set({showSidebar: !ui.showSidebar});
}
});
function getEditMenu() {
var listData = oml.getListData(),

View File

@ -1,27 +1,30 @@
Ox.load(function() {
Ox.load({
UI: {
loadCSS: false
}
}, function() {
var currentPage = PDFView.page;
window.addEventListener('pagechange', function (evt) {
var page = evt.pageNumber;
if (page && page != currentPage) {
currentPage = page;
Ox.$parent.postMessage('page', {
Ox.parent.postMessage('page', {
page: Math.round(page)
});
}
});
Ox.$parent.onMessage(function(event, data, oxid) {
if (event == 'page' && Ox.isUndefined(oxid)) {
Ox.parent.bindMessage({
page: function(data) {
if (data.page != PDFView.page) {
PDFView.page = data.page;
}
}
if (event == 'pdf' && Ox.isUndefined(oxid)) {
},
pdf: function(data) {
if (PDFView.url != data.pdf) {
PDFView.open(data.pdf);
}
}
});
Ox.$parent.postMessage('init', {});
});
function getVideoOverlay(page) {
@ -72,15 +75,10 @@ function getVideoOverlay(page) {
enableVideoUI();
}
this.div.appendChild($interface[0]);
Ox.Message.bind(function(event, data, oxid) {
if (event == 'update') {
if(Ox.isUndefined(oxid)
&& video
&& data.id == video.id
&& data.page == video.page) {
video.src = data.src;
video.src !== '' ? enableVideoUI() : disableVideoUI();
}
Ox.parent.bindMessage('update', function(data) {
if (video && data.id == video.id && data.page == video.page) {
video.src = data.src;
video.src !== '' ? enableVideoUI() : disableVideoUI();
}
});
}
@ -88,7 +86,7 @@ function getVideoOverlay(page) {
e.preventDefault();
e.stopPropagation();
var videoId = 'video' + page + id + Ox.uid(),
$iframe = Ox.$('<iframe>')
$iframe = Ox.Element('<iframe>')
.attr({
id: videoId,
src: video.src
@ -98,25 +96,19 @@ function getVideoOverlay(page) {
height: '100%',
frameborder: 0
})
.bindMessage({
close: function(data) {
if(!closed) {
closed = true;
$iframe.remove();
delete $iframe;
$playButton.show();
$editButton.show();
}
}
})
.appendTo($interface),
closed = false;
$iframe.postMessage = function(event, data) {
Ox.Message.post($iframe, event, data);
return $iframe;
};
Ox.Message.bind(function(event, data, oxid) {
if(!closed && event == 'loaded') {
$iframe.postMessage('init', {id: videoId});
} else if(event == 'close') {
if(!closed && !Ox.isUndefined(oxid) && videoId == oxid) {
closed = true;
$iframe.remove();
delete $iframe;
$playButton.show();
$editButton.show();
}
}
});
$playButton.hide();
$editButton.hide();
return false;
@ -131,7 +123,7 @@ function getVideoOverlay(page) {
src: '',
type: 'inline'
};
Ox.$parent.postMessage('edit', video);
Ox.parent.postMessage('edit', video);
return false;
}
function enableVideoUI() {