[FIX] website: test tour and website_sale tour. Add ajax trigger to display popover when the ajax is complete and hmlt is loaded
bzr revid: chm@openerp.com-20140129160839-ijdcnuiny6ys8z6p
This commit is contained in:
parent
f31ddba8b3
commit
876b61f42c
|
@ -55,7 +55,7 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||||
return werkzeug.wrappers.Response(url, mimetype='text/plain')
|
return werkzeug.wrappers.Response(url, mimetype='text/plain')
|
||||||
return werkzeug.utils.redirect(url)
|
return werkzeug.utils.redirect(url)
|
||||||
|
|
||||||
@http.route('/website/theme_change', type='http', auth="public", website=True)
|
@http.route('/website/theme_change', type='http', auth="user", website=True)
|
||||||
def theme_change(self, theme_id=False, **kwargs):
|
def theme_change(self, theme_id=False, **kwargs):
|
||||||
imd = request.registry['ir.model.data']
|
imd = request.registry['ir.model.data']
|
||||||
view = request.registry['ir.ui.view']
|
view = request.registry['ir.ui.view']
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
},
|
},
|
||||||
registerStep: function (step) {
|
registerStep: function (step) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
step.tour = self;
|
||||||
step.title = openerp.qweb.render('website.tour_popover_title', { title: step.title });
|
step.title = openerp.qweb.render('website.tour_popover_title', { title: step.title });
|
||||||
if (!step.element) {
|
if (!step.element) {
|
||||||
step.orphan = true;
|
step.orphan = true;
|
||||||
|
@ -37,15 +38,21 @@
|
||||||
};
|
};
|
||||||
} else if (step.trigger === 'reload') {
|
} else if (step.trigger === 'reload') {
|
||||||
step.triggers = function (callback) {
|
step.triggers = function (callback) {
|
||||||
var stack = JSON.parse(localStorage.getItem("website-reloads")) || [];
|
var stack = JSON.parse(step.tour.tourStorage.getItem("website-reloads")) || [];
|
||||||
var index = stack.indexOf(step.stepId);
|
var index = stack.indexOf(step.stepId);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
stack.splice(index,1);
|
setTimeout(function () {
|
||||||
(callback || self.moveToNextStep).apply(self);
|
$(step.element).popover("destroy");
|
||||||
|
setTimeout(function () {
|
||||||
|
stack.splice(index,1);
|
||||||
|
(callback || self.moveToNextStep).apply(self);
|
||||||
|
step.tour.tourStorage.setItem("website-reloads", JSON.stringify(stack));
|
||||||
|
},10);
|
||||||
|
},0);
|
||||||
} else {
|
} else {
|
||||||
stack.push(step.stepId);
|
stack.push(step.stepId);
|
||||||
|
step.tour.tourStorage.setItem("website-reloads", JSON.stringify(stack));
|
||||||
}
|
}
|
||||||
localStorage.setItem("website-reloads", JSON.stringify(stack));
|
|
||||||
};
|
};
|
||||||
} else if (step.trigger === 'drag') {
|
} else if (step.trigger === 'drag') {
|
||||||
step.triggers = function (callback) {
|
step.triggers = function (callback) {
|
||||||
|
@ -70,7 +77,7 @@
|
||||||
}
|
}
|
||||||
} else if (step.trigger.url) {
|
} else if (step.trigger.url) {
|
||||||
step.triggers = function (callback) {
|
step.triggers = function (callback) {
|
||||||
var stack = JSON.parse(localStorage.getItem("website-geturls")) || [];
|
var stack = JSON.parse(step.tour.tourStorage.getItem("website-geturls")) || [];
|
||||||
var id = step.trigger.url.toString();
|
var id = step.trigger.url.toString();
|
||||||
var index = stack.indexOf(id);
|
var index = stack.indexOf(id);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
|
@ -79,12 +86,18 @@
|
||||||
step.trigger.url == url.pathname+url.search :
|
step.trigger.url == url.pathname+url.search :
|
||||||
step.trigger.url.test(url.pathname+url.search);
|
step.trigger.url.test(url.pathname+url.search);
|
||||||
if (!test) return;
|
if (!test) return;
|
||||||
stack.splice(index,1);
|
setTimeout(function () {
|
||||||
(callback || self.moveToNextStep).apply(self);
|
$(step.element).popover("destroy");
|
||||||
|
setTimeout(function () {
|
||||||
|
stack.splice(index,1);
|
||||||
|
(callback || self.moveToNextStep).apply(self);
|
||||||
|
step.tour.tourStorage.setItem("website-geturls", JSON.stringify(stack));
|
||||||
|
},10);
|
||||||
|
},0);
|
||||||
} else {
|
} else {
|
||||||
stack.push(id);
|
stack.push(id);
|
||||||
|
step.tour.tourStorage.setItem("website-geturls", JSON.stringify(stack));
|
||||||
}
|
}
|
||||||
localStorage.setItem("website-geturls", JSON.stringify(stack));
|
|
||||||
return index !== -1;
|
return index !== -1;
|
||||||
};
|
};
|
||||||
} else if (step.trigger.modal) {
|
} else if (step.trigger.modal) {
|
||||||
|
@ -99,7 +112,6 @@
|
||||||
$doc.one('shown.bs.modal', function () {
|
$doc.one('shown.bs.modal', function () {
|
||||||
$('.modal button.btn-primary').one('click', function () {
|
$('.modal button.btn-primary').one('click', function () {
|
||||||
$doc.off('hide.bs.modal', onStop);
|
$doc.off('hide.bs.modal', onStop);
|
||||||
console.log(callback);
|
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
self.moveToStep(step.trigger.modal.afterSubmit);
|
self.moveToStep(step.trigger.modal.afterSubmit);
|
||||||
}
|
}
|
||||||
|
@ -107,6 +119,30 @@
|
||||||
(callback || self.moveToNextStep).apply(self);
|
(callback || self.moveToNextStep).apply(self);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
} else if (step.trigger === 'ajax') {
|
||||||
|
step.triggers = function (callback) {
|
||||||
|
$( document ).ajaxSuccess(function(event, xhr, settings) {
|
||||||
|
$( document ).unbind('ajaxSuccess');
|
||||||
|
xhr.then(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
$(step.element).popover("destroy");
|
||||||
|
setTimeout(function () {
|
||||||
|
(callback || self.moveToNextStep).apply(self);
|
||||||
|
},10);
|
||||||
|
},0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
step.triggers = function (callback) {
|
||||||
|
var emitter = $(step.element);
|
||||||
|
if (!emitter.size()) throw "Emitter is undefined";
|
||||||
|
var trigger = function () {
|
||||||
|
emitter.off(step.trigger, trigger);
|
||||||
|
(callback || self.moveToNextStep).apply(self, arguments);
|
||||||
|
};
|
||||||
|
emitter.on(step.trigger, trigger);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
step.onShow = (function () {
|
step.onShow = (function () {
|
||||||
|
@ -130,10 +166,15 @@
|
||||||
reset: function () {
|
reset: function () {
|
||||||
this.tourStorage.removeItem(this.id+'_current_step');
|
this.tourStorage.removeItem(this.id+'_current_step');
|
||||||
this.tourStorage.removeItem(this.id+'_end');
|
this.tourStorage.removeItem(this.id+'_end');
|
||||||
|
this.tourStorage.removeItem("website-reloads");
|
||||||
|
this.tourStorage.removeItem("website-geturls");
|
||||||
this.tour._current = 0;
|
this.tour._current = 0;
|
||||||
$('.popover.tour').remove();
|
$('.popover.tour').remove();
|
||||||
},
|
},
|
||||||
start: function () {
|
start: function () {
|
||||||
|
window.Tour.prototype._isOrphan = function(step) {
|
||||||
|
return (step.element == null) || !$(step.element).length;
|
||||||
|
};
|
||||||
if (this.resume() || ((this.currentStepIndex() === 0) && !this.tour.ended())) {
|
if (this.resume() || ((this.currentStepIndex() === 0) && !this.tour.ended())) {
|
||||||
this.tour.start();
|
this.tour.start();
|
||||||
}
|
}
|
||||||
|
@ -160,12 +201,8 @@
|
||||||
this.stop();
|
this.stop();
|
||||||
} else if (index >= 0) {
|
} else if (index >= 0) {
|
||||||
var self = this;
|
var self = this;
|
||||||
setTimeout(function () {
|
$('.popover.tour').remove();
|
||||||
$('.popover.tour').remove();
|
self.tour.goto(index);
|
||||||
setTimeout(function () {
|
|
||||||
self.tour.goto(index);
|
|
||||||
}, 0);
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
moveToNextStep: function () {
|
moveToNextStep: function () {
|
||||||
|
@ -319,13 +356,16 @@
|
||||||
_.each(this.tours, function (tour) {
|
_.each(this.tours, function (tour) {
|
||||||
var $menuItem = $($.parseHTML('<li><a href="#">'+tour.name+'</a></li>'));
|
var $menuItem = $($.parseHTML('<li><a href="#">'+tour.name+'</a></li>'));
|
||||||
$menuItem.click(function () {
|
$menuItem.click(function () {
|
||||||
tour.redirect(new website.UrlParser(window.location.href));
|
|
||||||
tour.reset();
|
tour.reset();
|
||||||
tour.start();
|
tour.redirect(new website.UrlParser(window.location.href));
|
||||||
});
|
});
|
||||||
menu.append($menuItem);
|
menu.append($menuItem);
|
||||||
if (tour.trigger()) {
|
if (tour.trigger()) {
|
||||||
tour.start();
|
setTimeout(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
tour.start();
|
||||||
|
},100);
|
||||||
|
},0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return this._super();
|
return this._super();
|
||||||
|
@ -335,63 +375,63 @@
|
||||||
var testId = 'test_'+tour.id+'_tour';
|
var testId = 'test_'+tour.id+'_tour';
|
||||||
this.tours.push(tour);
|
this.tours.push(tour);
|
||||||
var defaultDelay = 250; //ms
|
var defaultDelay = 250; //ms
|
||||||
var defaultDelayReload = 1500; //ms
|
|
||||||
var overlapsCrash;
|
var overlapsCrash;
|
||||||
var test = {
|
var test = {
|
||||||
id: tour.id,
|
id: tour.id,
|
||||||
run: function (force) {
|
run: function (force) {
|
||||||
if (force === true) {
|
if (force === true) {
|
||||||
this.reset();
|
this.reset();
|
||||||
|
tour.reset();
|
||||||
}
|
}
|
||||||
var actionSteps = _.filter(tour.steps, function (step) {
|
var actionSteps = _.filter(tour.steps, function (step) {
|
||||||
return step.trigger || step.sampleText;
|
return step.trigger || step.triggers || step.sampleText;
|
||||||
});
|
});
|
||||||
window.onbeforeunload = function () {
|
window.onbeforeunload = function () {
|
||||||
clearTimeout(overlapsCrash);
|
clearTimeout(overlapsCrash);
|
||||||
};
|
};
|
||||||
function throwError (message) {
|
function throwError (message) {
|
||||||
console.log(window.localStorage.getItem("test-report"));
|
console.log(tour.tourStorage.getItem("test-report"));
|
||||||
test.reset();
|
test.reset();
|
||||||
|
tour.reset();
|
||||||
throw message;
|
throw message;
|
||||||
}
|
}
|
||||||
function initReport () {
|
function initReport () {
|
||||||
// set last time for report
|
// set last time for report
|
||||||
if (!window.localStorage.getItem("test-last-time")) {
|
if (!tour.tourStorage.getItem("test-last-time")) {
|
||||||
window.localStorage.setItem("test-last-time", new Date().getTime());
|
tour.tourStorage.setItem("test-last-time", new Date().getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function setReport (step) {
|
function setReport (step) {
|
||||||
var report = JSON.parse(window.localStorage.getItem("test-report")) || {};
|
var report = JSON.parse(tour.tourStorage.getItem("test-report")) || {};
|
||||||
report[step.stepId] = (new Date().getTime() - window.localStorage.getItem("test-last-time")) + " ms";
|
report[step.stepId] = (new Date().getTime() - tour.tourStorage.getItem("test-last-time")) + " ms";
|
||||||
window.localStorage.setItem("test-report", JSON.stringify(report));
|
tour.tourStorage.setItem("test-report", JSON.stringify(report));
|
||||||
}
|
}
|
||||||
function testCycling (step) {
|
function testCycling (step) {
|
||||||
var lastStep = window.localStorage.getItem(testId);
|
var lastStep = tour.tourStorage.getItem(testId);
|
||||||
var tryStep = lastStep != step.stepId ? 0 : (+(window.localStorage.getItem("test-last-"+testId) || 0) + 1);
|
var tryStep = lastStep != step.stepId ? 0 : (+(tour.tourStorage.getItem("test-last-"+testId) || 0) + 1);
|
||||||
window.localStorage.setItem("test-last-"+testId, tryStep);
|
tour.tourStorage.setItem("test-last-"+testId, tryStep);
|
||||||
if (tryStep > 2) {
|
if (tryStep > 2) {
|
||||||
throwError("Test: '" + testId + "' cycling step: '" + step.stepId + "'");
|
throwError("Test: '" + testId + "' cycling step: '" + step.stepId + "'");
|
||||||
}
|
}
|
||||||
return tryStep;
|
return tryStep;
|
||||||
}
|
}
|
||||||
function getDelay (step) {
|
function getDelay (step) {
|
||||||
return step.delay ||
|
return step.delay || defaultDelay;
|
||||||
((step.trigger === 'reload' || (step.trigger && step.trigger.url))
|
|
||||||
? defaultDelayReload
|
|
||||||
: defaultDelay);
|
|
||||||
}
|
}
|
||||||
function executeStep (step) {
|
function executeStep (step) {
|
||||||
if (testCycling(step) === 0) initReport();
|
if (testCycling(step) === 0) initReport();
|
||||||
|
|
||||||
|
tour.tourStorage.setItem(testId, step.stepId);
|
||||||
|
|
||||||
var delay = getDelay (step);
|
var delay = getDelay (step);
|
||||||
|
|
||||||
overlapsCrash = setTimeout(function () {
|
overlapsCrash = setTimeout(function () {
|
||||||
throwError("Test: '" + testId + "' can't resolve step: '" + step.stepId + "'");
|
throwError("Test: '" + testId + "' can't resolve step: '" + step.stepId + "'");
|
||||||
}, delay + 1000);
|
}, delay + 3000);
|
||||||
|
|
||||||
|
|
||||||
var _next = false;
|
var _next = false;
|
||||||
window.localStorage.setItem(testId, step.stepId);
|
tour.tourStorage.setItem(testId, step.stepId);
|
||||||
function next () {
|
function next () {
|
||||||
_next = true;
|
_next = true;
|
||||||
clearTimeout(overlapsCrash);
|
clearTimeout(overlapsCrash);
|
||||||
|
@ -401,16 +441,15 @@
|
||||||
var nextStep = actionSteps.shift();
|
var nextStep = actionSteps.shift();
|
||||||
|
|
||||||
if (nextStep) {
|
if (nextStep) {
|
||||||
setTimeout(function () {
|
executeStep(nextStep);
|
||||||
executeStep(nextStep);
|
|
||||||
}, delay);
|
|
||||||
} else {
|
} else {
|
||||||
window.localStorage.removeItem(testId);
|
tour.tourStorage.removeItem(testId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
var $element = $(step.element);
|
var $element = $(step.element);
|
||||||
|
|
||||||
var flag = step.triggers && (!step.trigger || !step.trigger.modal);
|
var flag = step.triggers && (!step.trigger || !step.trigger.modal);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
try {
|
try {
|
||||||
|
@ -420,34 +459,41 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((step.trigger === 'reload' || (step.trigger && step.trigger.url)) && _next) return;
|
if ((step.trigger === 'reload' || (step.trigger && step.trigger.url)) && _next) return;
|
||||||
|
|
||||||
if (step.snippet && step.trigger === 'drag') {
|
if (step.snippet && step.trigger === 'drag') {
|
||||||
website.TestConsole.dragAndDropSnippet(step.snippet);
|
website.TestConsole.dragAndDropSnippet(step.snippet);
|
||||||
} else if (step.trigger && step.trigger.id === 'change') {
|
} else if (step.trigger && step.trigger.id === 'change') {
|
||||||
$element.trigger($.Event("change", { srcElement: $element }));
|
$element.trigger($.Event("change", { srcElement: $element }));
|
||||||
} else if (step.sampleText) {
|
} else if (step.sampleText) {
|
||||||
$element.val(step.sampleText);
|
$element.trigger($.Event("keydown", { srcElement: $element }));
|
||||||
$element.trigger($.Event("change", { srcElement: $element }));
|
if ($element.is("select") || $element.is("input") ) {
|
||||||
} else if ($element.is(":visible")) { // Click by default
|
$element.val(step.sampleText);
|
||||||
if (step.trigger.id === 'mousedown') {
|
} else {
|
||||||
$element.trigger($.Event("mousedown", { srcElement: $element }));
|
$element.html(step.sampleText);
|
||||||
}
|
}
|
||||||
|
$element.trigger($.Event("change", { srcElement: $element }));
|
||||||
|
$element.trigger($.Event("keyup", { srcElement: $element }));
|
||||||
|
} else if ($element.is(":visible")) { // Click by default
|
||||||
|
$element.trigger($.Event("mouseenter", { srcElement: $element }));
|
||||||
|
$element.trigger($.Event("mousedown", { srcElement: $element }));
|
||||||
var evt = document.createEvent("MouseEvents");
|
var evt = document.createEvent("MouseEvents");
|
||||||
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||||
$element[0].dispatchEvent(evt);
|
$element[0].dispatchEvent(evt);
|
||||||
if (step.trigger.id === 'mouseup') {
|
$element.trigger($.Event("mouseup", { srcElement: $element }));
|
||||||
$element.trigger($.Event("mouseup", { srcElement: $element }));
|
$element.trigger($.Event("mouseleave", { srcElement: $element }));
|
||||||
}
|
|
||||||
|
// trigger after for step like: mouseenter, next step click on button display with mouseenter
|
||||||
|
$element.trigger($.Event("mouseenter", { srcElement: $element }));
|
||||||
}
|
}
|
||||||
if (!flag) next();
|
if (!flag) next();
|
||||||
},0);
|
},delay);
|
||||||
}
|
}
|
||||||
var url = new website.UrlParser(window.location.href);
|
var url = new website.UrlParser(window.location.href);
|
||||||
if (tour.path && url.pathname !== tour.path && !window.localStorage.getItem(testId)) {
|
if (tour.path && url.pathname !== tour.path && !tour.tourStorage.getItem(testId)) {
|
||||||
window.localStorage.setItem(testId, actionSteps[0].stepId);
|
tour.tourStorage.setItem(testId, actionSteps[0].stepId);
|
||||||
window.location.href = tour.path;
|
window.location.href = tour.path;
|
||||||
} else {
|
} else {
|
||||||
var lastStepId = window.localStorage.getItem(testId);
|
var lastStepId = tour.tourStorage.getItem(testId);
|
||||||
var currentStep = actionSteps.shift();
|
var currentStep = actionSteps.shift();
|
||||||
if (lastStepId) {
|
if (lastStepId) {
|
||||||
while (currentStep && lastStepId !== currentStep.stepId) {
|
while (currentStep && lastStepId !== currentStep.stepId) {
|
||||||
|
@ -459,16 +505,18 @@
|
||||||
executeStep(currentStep);
|
executeStep(currentStep);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
executeStep(currentStep);
|
setTimeout(function () {
|
||||||
|
executeStep(currentStep);
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reset: function () {
|
reset: function () {
|
||||||
window.localStorage.removeItem(testId);
|
tour.tourStorage.removeItem(testId);
|
||||||
window.localStorage.removeItem("test-report");
|
tour.tourStorage.removeItem("test-report");
|
||||||
for (var k in window.localStorage) {
|
for (var k in tour.tourStorage) {
|
||||||
if (window.localStorage[k].indexOf("test-last")) {
|
if (tour.tourStorage[k].indexOf("test-last")) {
|
||||||
window.localStorage.removeItem(k);
|
tour.tourStorage.removeItem(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
trigger: {
|
trigger: {
|
||||||
modal: {
|
modal: {
|
||||||
stopOnClose: true,
|
stopOnClose: true,
|
||||||
afterSubmit: 'event-page',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -53,6 +52,7 @@
|
||||||
placement: 'right',
|
placement: 'right',
|
||||||
title: "Create an Event Name",
|
title: "Create an Event Name",
|
||||||
content: "Create a name for your new event and click <em>'Continue'</em>. e.g: Technical Training",
|
content: "Create a name for your new event and click <em>'Continue'</em>. e.g: Technical Training",
|
||||||
|
trigger: 'keyup',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'continue-name',
|
stepId: 'continue-name',
|
||||||
|
@ -60,9 +60,7 @@
|
||||||
placement: 'right',
|
placement: 'right',
|
||||||
title: "Create Event",
|
title: "Create Event",
|
||||||
content: "Click <em>Continue</em> to create the event.",
|
content: "Click <em>Continue</em> to create the event.",
|
||||||
trigger: {
|
trigger: 'reload',
|
||||||
url: /event\/[0-9]+\/register/
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'event-page',
|
stepId: 'event-page',
|
||||||
|
@ -139,7 +137,7 @@
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
title: "Publish your event",
|
title: "Publish your event",
|
||||||
content: "Click to publish your event.",
|
content: "Click to publish your event.",
|
||||||
trigger: 'click',
|
trigger: 'ajax'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'customize-event',
|
stepId: 'customize-event',
|
||||||
|
|
|
@ -31,9 +31,11 @@ class Website(osv.Model):
|
||||||
project_obj = request.registry['project.project']
|
project_obj = request.registry['project.project']
|
||||||
project_ids = project_obj.search(cr, uid, [('privacy_visibility', "=", "public")], context=request.context)
|
project_ids = project_obj.search(cr, uid, [('privacy_visibility', "=", "public")], context=request.context)
|
||||||
|
|
||||||
request.context['website_project_ids'] = project_obj.browse(cr, uid, project_ids, request.context)
|
request.context.update({
|
||||||
|
'website_project_ids': project_obj.browse(cr, uid, project_ids, context=request.context)
|
||||||
|
})
|
||||||
|
|
||||||
return super(Website, self).preprocess_request(cr, uid, ids, request, context)
|
return super(Website, self).preprocess_request(cr, uid, ids, request, context=None)
|
||||||
|
|
||||||
|
|
||||||
class website_project(http.Controller):
|
class website_project(http.Controller):
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
<!-- Layout add nav and footer -->
|
<!-- Layout add nav and footer -->
|
||||||
<template id="footer_custom" inherit_id="website.layout" name="Footer Project's Links">
|
<template id="footer_custom" inherit_id="website.layout" name="Footer Project's Links">
|
||||||
<xpath expr="//footer//ul[@name='products']" position="inside">
|
<xpath expr="//footer//ul[@name='products']" position="inside">
|
||||||
<li t-foreach="website_project_ids" t-as="project"><a t-attf-href="/project/#{ project.id }/"><span t-field="project.name"/></a></li>
|
<li t-foreach="website_project_ids" t-as="project">
|
||||||
|
<a t-attf-href="/project/#{ project.id }/"><span t-field="project.name"/></a>
|
||||||
|
</li>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -44,27 +44,36 @@
|
||||||
trigger: {
|
trigger: {
|
||||||
modal: {
|
modal: {
|
||||||
stopOnClose: true,
|
stopOnClose: true,
|
||||||
afterSubmit: 'product-page',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'enter-name',
|
stepId: 'enter-name',
|
||||||
element: '.modal input[type=text]',
|
element: '.modal input[type=text]',
|
||||||
|
sampleText: 'New Product',
|
||||||
placement: 'right',
|
placement: 'right',
|
||||||
title: "Choose name",
|
title: "Choose name",
|
||||||
content: "Enter a name for your new product then click 'Continue'.",
|
content: "Enter a name for your new product then click 'Continue'.",
|
||||||
|
trigger: 'keyup',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stepId: 'continue-name',
|
||||||
|
element: '.modal button.btn-primary',
|
||||||
|
placement: 'right',
|
||||||
|
title: "Create Product",
|
||||||
|
content: "Click <em>Continue</em> to create the product.",
|
||||||
|
trigger: 'reload',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'product-page',
|
stepId: 'product-page',
|
||||||
title: "New product created",
|
title: "New product created",
|
||||||
content: "This page contains all the information related to the new product.",
|
content: "This page contains all the information related to the new product.",
|
||||||
template: self.popover({ next: "OK" }),
|
template: self.popover({ next: "OK" }),
|
||||||
backdrop: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'edit-price',
|
stepId: 'edit-price-cke',
|
||||||
element: '.product_price',
|
element: '.product_price .oe_currency_value',
|
||||||
|
sampleText: '20.50',
|
||||||
placement: 'left',
|
placement: 'left',
|
||||||
title: "Change the price",
|
title: "Change the price",
|
||||||
content: "Edit the price of this product by clicking on the amount.",
|
content: "Edit the price of this product by clicking on the amount.",
|
||||||
|
@ -76,17 +85,24 @@
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
title: "Update image",
|
title: "Update image",
|
||||||
content: "Click here to set an image describing your product.",
|
content: "Click here to set an image describing your product.",
|
||||||
triggers: function () {
|
triggers: function (callback) {
|
||||||
function registerClick () {
|
var self = this;
|
||||||
$('button.hover-edition-button').one('click', function () {
|
$(self.element).on('mouseenter', function () {
|
||||||
$('#wrap img.img:first').off('hover', registerClick);
|
$(this).off('mouseenter');
|
||||||
self.moveToNextStep();
|
setTimeout(function () {
|
||||||
});
|
(callback || self.tour.moveToNextStep).apply(self.tour);
|
||||||
}
|
},0);
|
||||||
$('#wrap img.img:first').on('hover', registerClick);
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
stepId: 'update-image-button',
|
||||||
|
element: 'button.hover-edition-button:visible',
|
||||||
|
placement: 'top',
|
||||||
|
title: "Update image",
|
||||||
|
content: "Click here to set an image describing your product.",
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
stepId: 'upload-image',
|
stepId: 'upload-image',
|
||||||
element: '.well a.pull-right',
|
element: '.well a.pull-right',
|
||||||
|
@ -94,7 +110,7 @@
|
||||||
title: "Select an Image",
|
title: "Select an Image",
|
||||||
content: "Let's select an existing image.",
|
content: "Let's select an existing image.",
|
||||||
template: self.popover({ fixed: true }),
|
template: self.popover({ fixed: true }),
|
||||||
trigger: 'click',
|
trigger: 'ajax'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'select-image',
|
stepId: 'select-image',
|
||||||
|
@ -103,7 +119,16 @@
|
||||||
title: "Select an Image",
|
title: "Select an Image",
|
||||||
content: "Let's select an imac image.",
|
content: "Let's select an imac image.",
|
||||||
template: self.popover({ fixed: true }),
|
template: self.popover({ fixed: true }),
|
||||||
trigger: 'click',
|
triggers: function (callback) {
|
||||||
|
var self = this;
|
||||||
|
var click = function () {
|
||||||
|
$('.modal-dialog.select-image img').off('click', click);
|
||||||
|
setTimeout(function () {
|
||||||
|
(callback || self.tour.moveToNextStep).apply(self.tour);
|
||||||
|
},0);
|
||||||
|
};
|
||||||
|
$('.modal-dialog.select-image img').on('click', click);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'save-image',
|
stepId: 'save-image',
|
||||||
|
@ -139,7 +164,7 @@
|
||||||
title: "Save your modifications",
|
title: "Save your modifications",
|
||||||
content: "Once you click on save, your product is updated.",
|
content: "Once you click on save, your product is updated.",
|
||||||
template: self.popover({ fixed: true }),
|
template: self.popover({ fixed: true }),
|
||||||
trigger: 'click',
|
trigger: 'reload',
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -148,7 +173,7 @@
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
title: "Publish your product",
|
title: "Publish your product",
|
||||||
content: "Click to publish your product so your customers can see it.",
|
content: "Click to publish your product so your customers can see it.",
|
||||||
trigger: 'click',
|
trigger: 'ajax'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'congratulations',
|
stepId: 'congratulations',
|
||||||
|
@ -212,9 +237,7 @@
|
||||||
{
|
{
|
||||||
stepId: 'choose-ipod',
|
stepId: 'choose-ipod',
|
||||||
element: 'input[name="product_id"]:not([checked])',
|
element: 'input[name="product_id"]:not([checked])',
|
||||||
trigger: {
|
trigger: 'mouseup',
|
||||||
id: 'mouseup',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'add-ipod',
|
stepId: 'add-ipod',
|
||||||
|
@ -231,7 +254,7 @@
|
||||||
{
|
{
|
||||||
stepId: 'more-product',
|
stepId: 'more-product',
|
||||||
element: '.oe_mycart a.js_add_cart_json:eq(1)',
|
element: '.oe_mycart a.js_add_cart_json:eq(1)',
|
||||||
trigger: 'click',
|
trigger: 'ajax',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'less-product',
|
stepId: 'less-product',
|
||||||
|
@ -241,17 +264,8 @@
|
||||||
{
|
{
|
||||||
stepId: 'number-product',
|
stepId: 'number-product',
|
||||||
element: '.oe_mycart input.js_quantity',
|
element: '.oe_mycart input.js_quantity',
|
||||||
|
sampleText: '1',
|
||||||
trigger: 'reload',
|
trigger: 'reload',
|
||||||
beforeTrigger: function (tour) {
|
|
||||||
if (parseInt($(".oe_mycart input.js_quantity").val(),10) !== 1)
|
|
||||||
$(".oe_mycart input.js_quantity").val("1").change();
|
|
||||||
},
|
|
||||||
afterTrigger: function (tour) {
|
|
||||||
if ($(".oe_mycart input.js_quantity").size() !== 1)
|
|
||||||
throw "Can't remove suggested item from my cart";
|
|
||||||
if (parseInt($(".oe_mycart input.js_quantity").val(),10) !== 1)
|
|
||||||
throw "Can't defined number of items in my cart";
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stepId: 'go-checkout-product',
|
stepId: 'go-checkout-product',
|
||||||
|
|
Loading…
Reference in New Issue