index.js: refactor & fix bugs
This commit is contained in:
parent
d9141095f4
commit
67df31a83d
1 changed files with 19 additions and 32 deletions
51
index.js
51
index.js
|
@ -8,9 +8,7 @@ Ox.load(function() {
|
||||||
var home = app.url.get().page == '';
|
var home = app.url.get().page == '';
|
||||||
app.state.animating = true;
|
app.state.animating = true;
|
||||||
if (home) {
|
if (home) {
|
||||||
app.$ui.logo.attr({
|
app.$ui.logo.attr({src: app.getSRC('logo')});
|
||||||
src: app.getSRC('logo')
|
|
||||||
});
|
|
||||||
app.$ui.screen.show();
|
app.$ui.screen.show();
|
||||||
app.$ui.label.show();
|
app.$ui.label.show();
|
||||||
app.$ui.menu.options({value: ''}).show();
|
app.$ui.menu.options({value: ''}).show();
|
||||||
|
@ -26,10 +24,10 @@ Ox.load(function() {
|
||||||
1000,
|
1000,
|
||||||
element == 'screen' ? function() {
|
element == 'screen' ? function() {
|
||||||
if (!home) {
|
if (!home) {
|
||||||
app.$ui.logo.attr({
|
app.$ui.logo.attr({src: app.getSRC('logo')});
|
||||||
src: app.getSRC('logo')
|
app.$ui.panel.find('.OxButtonGroup').css({
|
||||||
|
opacity: 1
|
||||||
});
|
});
|
||||||
app.$ui.panel.find('.OxButtonGroup').css({opacity: 1});
|
|
||||||
app.$ui.screen.hide();
|
app.$ui.screen.hide();
|
||||||
app.$ui.label.hide();
|
app.$ui.label.hide();
|
||||||
app.$ui.menu.hide().options({value: ''});
|
app.$ui.menu.hide().options({value: ''});
|
||||||
|
@ -123,22 +121,12 @@ Ox.load(function() {
|
||||||
return css;
|
return css;
|
||||||
},
|
},
|
||||||
getSRC: function(element) {
|
getSRC: function(element) {
|
||||||
var src,
|
return 'source/Ox.UI/themes/' + app.user.theme + '/' + {
|
||||||
home = app.url.get().page == '',
|
icon: 'png/icon16.png',
|
||||||
theme = app.user.theme || 'classic';
|
loading: 'svg/symbolLoading.svg',
|
||||||
if (element == 'icon') {
|
logo: 'png/logo128.png'
|
||||||
src = 'source/Ox.UI/themes/' + theme
|
}[element];
|
||||||
+ '/png/icon16.png';
|
|
||||||
} else if (element == 'loading') {
|
|
||||||
src = 'source/Ox.UI/themes/' + theme
|
|
||||||
+ '/svg/symbolLoading.svg'
|
|
||||||
} else if (element == 'logo') {
|
|
||||||
src = 'source/Ox.UI/themes/' + theme
|
|
||||||
+ '/png/logo128.png'
|
|
||||||
}
|
|
||||||
return src;
|
|
||||||
},
|
},
|
||||||
html: {},
|
|
||||||
init: function() {
|
init: function() {
|
||||||
app.user = Ox.extend(app.data.user, app.db());
|
app.user = Ox.extend(app.data.user, app.db());
|
||||||
app.loadScreen(function() {
|
app.loadScreen(function() {
|
||||||
|
@ -220,14 +208,15 @@ Ox.load(function() {
|
||||||
app.state.loaded = true;
|
app.state.loaded = true;
|
||||||
},
|
},
|
||||||
loadData: function(callback) {
|
loadData: function(callback) {
|
||||||
var url = 'https://oxjs.org/downloads/downloads.json';
|
var q = '?' + Ox.random(100000),
|
||||||
Ox.getJSON('index.json?' + Ox.random(1000000), function(data) {
|
url = 'https://oxjs.org/downloads/downloads.json' + q;
|
||||||
|
Ox.getJSON('index.json' + q, function(data) {
|
||||||
app.data = Ox.extend(app.data, data);
|
app.data = Ox.extend(app.data, data);
|
||||||
app.data.pages.forEach(function(page) {
|
app.data.pages.forEach(function(page) {
|
||||||
var id = page.id == 'doc' ? 'documentation' : page.id;
|
var id = page.id == 'doc' ? 'documentation' : page.id;
|
||||||
Ox.get('readme/html/_' + (id) + '.html', function(html) {
|
Ox.get('readme/html/_' + id + '.html' + q, function(html) {
|
||||||
app.html[id] = html;
|
app.data.html[id] = html;
|
||||||
if (Ox.len(app.html) == app.data.pages.length) {
|
if (Ox.len(app.data.html) == app.data.pages.length) {
|
||||||
if (navigator.onLine) {
|
if (navigator.onLine) {
|
||||||
Ox.getJSON(url, function(data) {
|
Ox.getJSON(url, function(data) {
|
||||||
app.data.downloads = data;
|
app.data.downloads = data;
|
||||||
|
@ -372,6 +361,7 @@ Ox.load(function() {
|
||||||
loaded: false
|
loaded: false
|
||||||
},
|
},
|
||||||
toggle: function() {
|
toggle: function() {
|
||||||
|
Ox.print('TOGGLE', app.state.animating, app.user.previousPage, app.user.item)
|
||||||
!app.state.animating && app.url.set(
|
!app.state.animating && app.url.set(
|
||||||
app.url.get().page ? {
|
app.url.get().page ? {
|
||||||
page: '',
|
page: '',
|
||||||
|
@ -392,7 +382,7 @@ Ox.load(function() {
|
||||||
margin: '32px',
|
margin: '32px',
|
||||||
width: window.innerWidth - 640 + 'px'
|
width: window.innerWidth - 640 + 'px'
|
||||||
})
|
})
|
||||||
.html(app.html.documentation),
|
.html(app.data.html.documentation),
|
||||||
examples: app.data.docItems ? void 0 : app.data.examples,
|
examples: app.data.docItems ? void 0 : app.data.examples,
|
||||||
examplesPath: app.data.docItems ? void 0 : 'examples/',
|
examplesPath: app.data.docItems ? void 0 : 'examples/',
|
||||||
files: app.data.docItems ? void 0 : app.data.documentation,
|
files: app.data.docItems ? void 0 : app.data.documentation,
|
||||||
|
@ -442,7 +432,7 @@ Ox.load(function() {
|
||||||
margin: '32px',
|
margin: '32px',
|
||||||
width: window.innerWidth - 640 + 'px'
|
width: window.innerWidth - 640 + 'px'
|
||||||
})
|
})
|
||||||
.html(app.html.examples),
|
.html(app.data.html.examples),
|
||||||
examples: app.data.examples,
|
examples: app.data.examples,
|
||||||
path: 'examples/',
|
path: 'examples/',
|
||||||
references: /\b(Ox\.[\w\$]+(?=\W))/g,
|
references: /\b(Ox\.[\w\$]+(?=\W))/g,
|
||||||
|
@ -469,9 +459,6 @@ Ox.load(function() {
|
||||||
paddingTop: '4px',
|
paddingTop: '4px',
|
||||||
paddingBottom: '4px',
|
paddingBottom: '4px',
|
||||||
borderRadius: '6px'
|
borderRadius: '6px'
|
||||||
})
|
|
||||||
.on({
|
|
||||||
click: app.toggle
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loading: function() {
|
loading: function() {
|
||||||
|
@ -508,7 +495,7 @@ Ox.load(function() {
|
||||||
$('<div>')
|
$('<div>')
|
||||||
.addClass('OxSelectable page')
|
.addClass('OxSelectable page')
|
||||||
.html(
|
.html(
|
||||||
app.html[page]
|
app.data.html[page]
|
||||||
.replace(app.re.size[0], app.re.size[1])
|
.replace(app.re.size[0], app.re.size[1])
|
||||||
.replace(app.re.version[0], app.re.version[1])
|
.replace(app.re.version[0], app.re.version[1])
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue