Commit fd80c674 authored by Thomas Lechauve's avatar Thomas Lechauve

First working version with jqm default routing

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