From b5bc56d07509078e25893647b75ffe1b7fc5adc7 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 24 Sep 2014 15:30:23 +0200 Subject: [PATCH] update to latest oxjs api --- static/html/pdf.html | 1 - static/js/mainMenu.js | 117 ++++++++++++++++++---------------------- static/pdf.js/embeds.js | 62 ++++++++++----------- 3 files changed, 80 insertions(+), 100 deletions(-) diff --git a/static/html/pdf.html b/static/html/pdf.html index 2c6ecdf..b86ac36 100644 --- a/static/html/pdf.html +++ b/static/html/pdf.html @@ -25,7 +25,6 @@ limitations under the License. - diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js index 456d0eb..adec538 100644 --- a/static/js/mainMenu.js +++ b/static/js/mainMenu.js @@ -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(), diff --git a/static/pdf.js/embeds.js b/static/pdf.js/embeds.js index 95a6b52..88c1e06 100644 --- a/static/pdf.js/embeds.js +++ b/static/pdf.js/embeds.js @@ -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.$('