Commit fd80c674 authored by Thomas Lechauve's avatar Thomas Lechauve

First working version with jqm default routing

parent 3fedf9fa
...@@ -56,7 +56,6 @@ $.extend({ ...@@ -56,7 +56,6 @@ $.extend({
level = level || 0; level = level || 0;
i = this.list.length - 1; i = this.list.length - 1;
hash.route = hash.route === "undefined" ? "/" : hash.route; hash.route = hash.route === "undefined" ? "/" : hash.route;
console.log(hash)
while ((stop === false) && (i >= level)) { while ((stop === false) && (i >= level)) {
j = 0; j = 0;
while ((stop === false) && (j < this.list[i].length)) { while ((stop === false) && (j < this.list[i].length)) {
......
...@@ -13,7 +13,7 @@ $.extend(methods, { ...@@ -13,7 +13,7 @@ $.extend(methods, {
{'name': 'Documentation', 'link': '#/documentation'} {'name': 'Documentation', 'link': '#/documentation'}
] ]
}; };
$(this).vifib('render', 'homepage', options); methods.changePage($(this).vifib('getPageRender', 'homepage', options));
if ( Modernizr.csstransforms ) { if ( Modernizr.csstransforms ) {
window.mySwipe = new Swipe(document.getElementById('slider'), { window.mySwipe = new Swipe(document.getElementById('slider'), {
speed: 800, speed: 800,
......
...@@ -2,14 +2,7 @@ ...@@ -2,14 +2,7 @@
$.extend(methods, { $.extend(methods, {
showInstanceList: function (params) { showInstanceList: function (params) {
return this.each(function () { return this.each(function () {
var nextLevel = $.router.routes.current.level + 1, var nextLevel = $.router.routes.current.level + 1;
statusCode = {
401: redirect,
402: payment,
404: notFound,
500: serverError,
503: serverError
},
options = { options = {
'title': 'My Services', 'title': 'My Services',
'mainPanel': $(this).vifib('getRender', 'instance.list'), 'mainPanel': $(this).vifib('getRender', 'instance.list'),
...@@ -24,7 +17,8 @@ $.extend(methods, { ...@@ -24,7 +17,8 @@ $.extend(methods, {
'title': 'add service' 'title': 'add service'
} }
}, },
listview = $(this).vifib('render', 'instance', options).find('#instance-list'); page = $(this).vifib('render', 'instance', options);
listview = $(page).find('#instance-list');
// Routing // Routing
$.router.routes.add('/instance/id/:id', nextLevel, methods.showInstance, $(this)); $.router.routes.add('/instance/id/:id', nextLevel, methods.showInstance, $(this));
if (params.route !== '/instance') { if (params.route !== '/instance') {
...@@ -42,8 +36,7 @@ $.extend(methods, { ...@@ -42,8 +36,7 @@ $.extend(methods, {
//row.vifib('refresh', methods.refreshRowInstance, 30); //row.vifib('refresh', methods.refreshRowInstance, 30);
listview.append(row).listview('refresh'); listview.append(row).listview('refresh');
}); });
}, }
statusCode: statusCode
}); });
} }
}); });
...@@ -75,10 +68,10 @@ $.extend(methods, { ...@@ -75,10 +68,10 @@ $.extend(methods, {
'title': 'Homepage' 'title': 'Homepage'
}, },
'menulinks': [ 'menulinks': [
{'link': '#/instance', 'name': 'All services'} {'link': '#/instance/list', 'name': 'All services'}
], ],
}; };
$(this).vifib('render', 'instance', options); methods.changePage($(this).vifib('getPageRender', 'instance', options));
$.router.routes.add('/instance/list', nextLevel, methods.showInstanceList, $(this).find('.content-primary')); $.router.routes.add('/instance/list', nextLevel, methods.showInstanceList, $(this).find('.content-primary'));
$.router.routes.add('/instance/id/:id', nextLevel, methods.showInstance, $(this).find('.content-primary')); $.router.routes.add('/instance/id/:id', nextLevel, methods.showInstance, $(this).find('.content-primary'));
$.router.routes.add('/instance/id/:id/bang', nextLevel, methods.showBangInstance, $(this).find('.content-primary')); $.router.routes.add('/instance/id/:id/bang', nextLevel, methods.showBangInstance, $(this).find('.content-primary'));
...@@ -90,13 +83,7 @@ $.extend(methods, { ...@@ -90,13 +83,7 @@ $.extend(methods, {
showInstance: function (params) { showInstance: function (params) {
return this.each(function () { return this.each(function () {
var statusCode = { var nextLevel = $.router.routes.current.level + 1;
401: redirect,
402: payment,
404: notFound,
500: serverError
},
nextLevel = $.router.routes.current.level + 1;
$(this).slapos('instanceInfo', params.id, { $(this).slapos('instanceInfo', params.id, {
success: function (response) { success: function (response) {
if (typeof (response) !== "object") { if (typeof (response) !== "object") {
...@@ -119,32 +106,22 @@ $.extend(methods, { ...@@ -119,32 +106,22 @@ $.extend(methods, {
{'name': "Bang", 'url': methods.genBangUrl(decodeURIComponent(params.id))} {'name': "Bang", 'url': methods.genBangUrl(decodeURIComponent(params.id))}
]; ];
$.extend(response, content); $.extend(response, content);
$(this).vifib('render', 'instancePanel', response); var page = $(this).vifib('render', 'instancePanel', response);
//var form = $(this).find("#instance-form"); //var form = $(this).find("#instance-form");
//form.vifib('prepareForm'); //form.vifib('prepareForm');
}, }
statusCode: statusCode
}); });
}) })
}, },
showBangInstance: function (params) { showBangInstance: function (params) {
var statusCode = {
400: bad_request,
401: redirect,
402: payment,
404: notFound,
500: serverError
};
return this.each(function () { return this.each(function () {
console.log("plop")
$(this).vifib('render', 'instance.bangPanel'); $(this).vifib('render', 'instance.bangPanel');
$(this).find('#form-bang').submit(function () { $(this).find('#form-bang').submit(function () {
var data = $(this).serializeObject(), var data = $(this).serializeObject(),
uri = methods.extractInstanceURIFromHashtag(); uri = methods.extractInstanceURIFromHashtag();
$(this).slapos('instanceBang', uri, { $(this).slapos('instanceBang', uri, {
data: data, data: data,
statusCode: statusCode,
success: function () { success: function () {
$.redirect(['instance', encodeURIComponent(uri)]); $.redirect(['instance', encodeURIComponent(uri)]);
} }
......
...@@ -33,8 +33,10 @@ $.extend(methods, { ...@@ -33,8 +33,10 @@ $.extend(methods, {
{'link': '#/library', 'name': 'Library'}, {'link': '#/library', 'name': 'Library'},
{'link': '#/documentation', 'name': 'Documentation'} {'link': '#/documentation', 'name': 'Documentation'}
], ],
}; }
$(this).vifib('render', 'library', options); ;
page = $(this).vifib('getPageRender', 'library', options);
methods.changePage(page);
nextLevel = $.router.routes.current.level + 1; nextLevel = $.router.routes.current.level + 1;
$.router.routes.add('/library/all', nextLevel, methods.showLibraryAll, $(this)); $.router.routes.add('/library/all', nextLevel, methods.showLibraryAll, $(this));
/* FAKE *********/ /* FAKE *********/
...@@ -55,7 +57,9 @@ $.extend(methods, { ...@@ -55,7 +57,9 @@ $.extend(methods, {
'title': 'Homepage' 'title': 'Homepage'
} }
}, },
listview = $(this).vifib('render', 'library.all', options).find('#software-list'); page = $(this).vifib('getPageRender', 'library.all', options),
listview = $(page).find('#software-list');
methods.changePage(page);
$(this).slapos('softwareList', { $(this).slapos('softwareList', {
success: function (response) { success: function (response) {
if (typeof (response) !== "object") { if (typeof (response) !== "object") {
...@@ -104,9 +108,9 @@ $.extend(methods, { ...@@ -104,9 +108,9 @@ $.extend(methods, {
'menuextlinks': [ 'menuextlinks': [
{'link': '#/library/software/html5', 'name': 'Html5 AS'} {'link': '#/library/software/html5', 'name': 'Html5 AS'}
] ]
} };
$.extend(options, response) $.extend(options, response);
$(this).vifib('render', 'software', options); methods.changePage($(this).vifib('getPageRender', 'software', options));
} }
}) })
}); });
......
...@@ -13,7 +13,7 @@ $.extend(methods, { ...@@ -13,7 +13,7 @@ $.extend(methods, {
} }
}, },
nextLevel = $.router.routes.current.level + 1; nextLevel = $.router.routes.current.level + 1;
$(this).vifib('render', 'login', options); methods.changePage($(this).vifib('getPageRender', 'login', options));
}); });
}, },
}); });
...@@ -7,12 +7,12 @@ $(document).ready(function () { ...@@ -7,12 +7,12 @@ $(document).ready(function () {
var appContext = $('body'); var appContext = $('body');
//$.router.routes.add('/homepage', 0, appContext.vifib('showHomepage')); $.router.routes.add('/homepage', 0, methods.showHomepage, appContext);
//$.router.routes.add('/library', 0, appContext.vifib('showLibrary')); $.router.routes.add('/library', 0, methods.showLibrary, appContext);
//$.router.routes.add('/documentation', 0, appContext.vifib('showDocumentation')); $.router.routes.add('/documentation', 0, methods.showDocumentation, appContext);
$.router.routes.add('/dashboard', 0, appContext.vifib('showDashboard')); $.router.routes.add('/dashboard', 0, methods.showDashboard, appContext);
//$.router.routes.add('/instance', 0, appContext.vifib('showInstanceRoot')); $.router.routes.add('/instance', 0, methods.showInstanceRoot, appContext);
//$.router.routes.add('/login', 0, appContext.vifib('showLogin')); $.router.routes.add('/login', 0, methods.showLogin, appContext);
appContext.slapos({'host': 'http://10.8.2.34:12006/erp5/portal_vifib_rest_api_v1'}); appContext.slapos({'host': 'http://10.8.2.34:12006/erp5/portal_vifib_rest_api_v1'});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment