summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js
diff options
context:
space:
mode:
authorbth-openerp <bth@tinyerp.com>2013-10-22 16:47:24 +0530
committerbth-openerp <bth@tinyerp.com>2013-10-22 16:47:24 +0530
commit2c77c2c78ab93d66f75dfc8c39e2a3aedb6de5a6 (patch)
tree384db70b1b05c24de03cc575e9b4e8c7f6869a27 /addons/website/static/src/js
parent5dfad90298085250294193987c824058a7f55f51 (diff)
parent3c87025227567778c87698155e6d5b92aaf75771 (diff)
[MERGE]Merge lp:~openerp-dev/openobject-addons/trunk-website-al.
bzr revid: bth@tinyerp.com-20131022111724-327ql1yk8s5ivfvv
Diffstat (limited to 'addons/website/static/src/js')
-rw-r--r--addons/website/static/src/js/website.ace.js16
-rw-r--r--addons/website/static/src/js/website.snippets.js22
-rw-r--r--addons/website/static/src/js/website.tour.basic.js161
-rw-r--r--addons/website/static/src/js/website.tour.js167
4 files changed, 189 insertions, 177 deletions
diff --git a/addons/website/static/src/js/website.ace.js b/addons/website/static/src/js/website.ace.js
index faf3e8f7e04..02f5eb68d5e 100644
--- a/addons/website/static/src/js/website.ace.js
+++ b/addons/website/static/src/js/website.ace.js
@@ -100,6 +100,13 @@
self.aceEditor.resize();
self.$el.width(width);
}
+ function storeEditorWidth() {
+ window.localStorage.setItem('ace_editor_width', self.$el.width());
+ }
+ function readEditorWidth() {
+ var width = window.localStorage.getItem('ace_editor_width');
+ return parseInt(width || 720, 10);
+ }
function startResizing (e) {
self.refX = e.pageX;
self.resizing = true;
@@ -113,16 +120,23 @@
var width = self.$el.width() - offset;
self.refX = e.pageX;
resizeEditor(width);
+ storeEditorWidth();
}
}
document.body.addEventListener('mouseup', stopResizing, true);
self.$('.ace_gutter').mouseup(stopResizing).mousedown(startResizing).click(stopResizing);
$(document).mousemove(updateWidth);
+ $('button[data-action=edit]').click(function () {
+ self.close();
+ });
+ resizeEditor(readEditorWidth());
},
loadViews: function (views) {
var self = this;
- var activeViews = _.filter(views, function (view) {
+ var activeViews = _.uniq(_.filter(views, function (view) {
return view.active;
+ }), false, function (view) {
+ return view.id;
});
var $viewList = self.$('#ace-view-list');
_.each(activeViews, function (view) {
diff --git a/addons/website/static/src/js/website.snippets.js b/addons/website/static/src/js/website.snippets.js
index 32d1ef9f55a..f497563d8c5 100644
--- a/addons/website/static/src/js/website.snippets.js
+++ b/addons/website/static/src/js/website.snippets.js
@@ -341,13 +341,13 @@
});
},
stop: function(ev, ui){
- if (action === 'insert' && ! dropped) {
- var el = $('.oe_drop_zone').nearest({x: ui.position.left, y: ui.position.top}).first()
- if (el) {
- el.after($toInsert)
- dropped = true;
- }
- }
+ if (action === 'insert' && ! dropped) {
+ var el = $('.oe_drop_zone').nearest({x: ui.position.left, y: ui.position.top}).first()
+ if (el) {
+ el.after($toInsert)
+ dropped = true;
+ }
+ }
$('.oe_drop_zone').droppable('destroy').remove();
if (dropped) {
@@ -1077,14 +1077,6 @@
self.$target.carousel();
});
- this.$target.on('dblclick', '.item.active .carousel-image img', function (event) {
- var $img = $(event.currentTarget);
- var editor = new website.editor.ImageDialog();
- editor.on('start', self, function (o) {o.url = $img.attr("src");});
- editor.on('save', self, function (o) {$img.attr("src", o.url);});
- editor.appendTo($('body'));
- });
-
this.rebind_event();
},
// rebind event to active carousel on edit mode
diff --git a/addons/website/static/src/js/website.tour.basic.js b/addons/website/static/src/js/website.tour.basic.js
new file mode 100644
index 00000000000..82ad4790c25
--- /dev/null
+++ b/addons/website/static/src/js/website.tour.basic.js
@@ -0,0 +1,161 @@
+(function () {
+ 'use strict';
+
+ var website = openerp.website;
+
+ var render = website.tour.render;
+
+ website.EditorBasicTour = website.EditorTour.extend({
+ id: 'add_banner_tour',
+ name: "Insert a banner",
+ init: function (editor) {
+ var self = this;
+ self.steps = [
+ {
+ stepId: 'welcome',
+ orphan: true,
+ backdrop: true,
+ title: "Welcome to your website!",
+ content: "This tutorial will guide you to build your first page. We will start by adding a banner.",
+ template: render('website.tour_popover', { next: "Start Tutorial", end: "Skip It" }),
+ },
+ {
+ stepId: 'edit-page',
+ element: 'button[data-action=edit]',
+ placement: 'bottom',
+ reflex: true,
+ title: "Edit this page",
+ content: "Every page of your website can be modified through the <i>Edit</i> button.",
+ template: render('website.tour_popover'),
+ },
+ {
+ stepId: 'add-block',
+ element: 'button[data-action=snippet]',
+ placement: 'bottom',
+ title: "Insert building blocks",
+ content: "To add content in a page, you can insert building blocks.",
+ template: render('website.tour_popover'),
+ onShow: function () {
+ function refreshAddBlockStep () {
+ self.tour.showStep(self.indexOfStep('add-block'));
+ editor.off('rte:ready', editor, refreshAddBlockStep);
+ }
+ editor.on('rte:ready', editor, refreshAddBlockStep);
+ $('button[data-action=snippet]').click(function () {
+ self.movetoStep('drag-banner');
+ });
+ }
+ },
+ {
+ stepId: 'drag-banner',
+ element: '#website-top-navbar [data-snippet-id=carousel].ui-draggable',
+ placement: 'bottom',
+ title: "Drag & Drop a Banner",
+ content: "Drag the <em>Banner</em> block and drop it in your page. <p class='text-muted'>Tip: release the mouse button when you are in a valid zone, with a preview of the banner.</p>",
+ template: render('website.tour_popover'),
+ onShow: function () {
+ function beginDrag () {
+ $('.popover.tour').remove();
+ $('body').off('mousedown', beginDrag);
+ function goToNextStep () {
+ $('#oe_snippets').hide();
+ self.movetoStep('edit-title');
+ $('body').off('mouseup', goToNextStep);
+ }
+ $('body').on('mouseup', goToNextStep);
+ }
+ $('body').on('mousedown', beginDrag);
+ },
+ },
+ {
+ stepId: 'edit-title',
+ element: '#wrap [data-snippet-id=carousel]:first .carousel-caption',
+ placement: 'left',
+ title: "Customize banner's text",
+ content: "Click in the text and start editing it. Click continue once it's done.",
+ template: render('website.tour_popover', { next: "Continue" }),
+ onHide: function () {
+ var $banner = $("#wrap [data-snippet-id=carousel]:first");
+ if ($banner.length) {
+ $banner.click();
+ }
+ },
+ },
+ {
+ stepId: 'customize-banner',
+ element: '.oe_overlay_options .oe_options',
+ placement: 'left',
+ title: "Customize the banner",
+ content: "You can customize components of your page through the <em>Customize</em> menu. Try to change the background of your banner.",
+ template: render('website.tour_popover', { next: "Continue" }),
+ onShow: function () {
+ $('.dropdown-menu [name=carousel-background]').click(function () {
+ self.movetoStep('save-changes');
+ });
+ },
+ },
+ {
+ stepId: 'save-changes',
+ element: 'button[data-action=save]',
+ placement: 'right',
+ reflex: true,
+ title: "Save your modifications",
+ content: "Once you click on save, your website page is updated.",
+ template: render('website.tour_popover'),
+ onHide: function () {
+ self.saveStep('part-2');
+ },
+
+ },
+ {
+ stepId: 'part-2',
+ orphan: true,
+ title: "Congratulation!",
+ content: "Your homepage have been updated. Now, we suggest you to insert others building blocks like texts and images to structure your page.",
+ template: render('website.tour_popover', { next: "Continue" }),
+ },
+ {
+ stepId: 'show-tutorials',
+ element: '#help-menu-button',
+ placement: 'left',
+ title: "Help is always available",
+ content: "But you can always click here if you want more tutorials.",
+ template: render('website.tour_popover', { end: "Close" }),
+ },
+ ];
+ return this._super();
+ },
+ startOfPart2: function () {
+ var currentStepIndex = this.currentStepIndex();
+ var secondPartIndex = this.indexOfStep('part-2');
+ var showTutorialsIndex = this.indexOfStep('show-tutorials');
+ return (currentStepIndex === secondPartIndex || currentStepIndex === showTutorialsIndex) && !this.tour.ended();
+ },
+ canResume: function () {
+ return this.startOfPart2() || this._super();
+ },
+ });
+
+ website.EditorBar.include({
+ start: function () {
+ var menu = $('#help-menu');
+ var basicTour = new website.EditorBasicTour(this);
+ var $menuItem = $($.parseHTML('<li><a href="#">'+basicTour.name+'</a></li>'));
+ $menuItem.click(function () {
+ basicTour.reset();
+ basicTour.start();
+ });
+ menu.append($menuItem);
+ var url = new website.UrlParser(window.location.href);
+ if (url.search.indexOf('?tutorial=true') === 0 || basicTour.startOfPart2()) {
+ basicTour.start();
+ }
+ $('.tour-backdrop').click(function (e) {
+ e.stopImmediatePropagation();
+ e.preventDefault();
+ });
+ return this._super();
+ },
+ });
+
+}()); \ No newline at end of file
diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js
index bfb9a0461d9..f5d3237c28d 100644
--- a/addons/website/static/src/js/website.tour.js
+++ b/addons/website/static/src/js/website.tour.js
@@ -4,9 +4,11 @@
var website = openerp.website;
website.templates.push('/website/static/src/xml/website.tour.xml');
- function render (template, dict) {
- return openerp.qweb.render(template, dict);
- }
+ website.tour = {
+ render: function render (template, dict) {
+ return openerp.qweb.render(template, dict);
+ }
+ };
website.EditorTour = openerp.Class.extend({
tour: undefined,
@@ -19,7 +21,7 @@
keyboard: false,
});
this.tour.addSteps(_.map(this.steps, function (step) {
- step.title = render('website.tour_popover_title', { title: step.title });
+ step.title = website.tour.render('website.tour_popover_title', { title: step.title });
return step;
}));
this.monkeyPatchTour();
@@ -81,137 +83,6 @@
},
});
- website.EditorBasicTour = website.EditorTour.extend({
- id: 'add_banner_tour',
- name: "Insert a banner",
- init: function (editor) {
- var self = this;
- self.steps = [
- {
- stepId: 'welcome',
- orphan: true,
- backdrop: true,
- title: "Welcome to your website!",
- content: "This tutorial will guide you to build your first page. We will start by adding a banner.",
- template: render('website.tour_popover', { next: "Start Tutorial", end: "Skip It" }),
- },
- {
- stepId: 'edit-page',
- element: 'button[data-action=edit]',
- placement: 'bottom',
- reflex: true,
- title: "Edit this page",
- content: "Every page of your website can be modified through the <i>Edit</i> button.",
- template: render('website.tour_popover'),
- },
- {
- stepId: 'add-block',
- element: 'button[data-action=snippet]',
- placement: 'bottom',
- title: "Insert building blocks",
- content: "To add content in a page, you can insert building blocks.",
- template: render('website.tour_popover'),
- onShow: function () {
- function refreshAddBlockStep () {
- self.tour.showStep(self.indexOfStep('add-block'));
- editor.off('rte:ready', editor, refreshAddBlockStep);
- }
- editor.on('rte:ready', editor, refreshAddBlockStep);
- $('button[data-action=snippet]').click(function () {
- self.movetoStep('drag-banner');
- });
- }
- },
- {
- stepId: 'drag-banner',
- element: '#website-top-navbar [data-snippet-id=carousel].ui-draggable',
- placement: 'bottom',
- title: "Drag & Drop a Banner",
- content: "Drag the <em>Banner</em> block and drop it in your page. <p class='text-muted'>Tip: release the mouse button when you are in a valid zone, with a preview of the banner.</p>",
- template: render('website.tour_popover'),
- onShow: function () {
- function beginDrag () {
- $('.popover.tour').remove();
- $('body').off('mousedown', beginDrag);
- function goToNextStep () {
- $('#oe_snippets').hide();
- self.movetoStep('edit-title');
- $('body').off('mouseup', goToNextStep);
- }
- $('body').on('mouseup', goToNextStep);
- }
- $('body').on('mousedown', beginDrag);
- },
- },
- {
- stepId: 'edit-title',
- element: '#wrap [data-snippet-id=carousel]:first .carousel-caption',
- placement: 'left',
- title: "Customize banner's text",
- content: "Click in the text and start editing it. Click continue once it's done.",
- template: render('website.tour_popover', { next: "Continue" }),
- onHide: function () {
- var $banner = $("#wrap [data-snippet-id=carousel]:first");
- if ($banner.length) {
- $banner.click();
- }
- },
- },
- {
- stepId: 'customize-banner',
- element: '.oe_overlay_options .oe_options',
- placement: 'left',
- title: "Customize the banner",
- content: "You can customize components of your page through the <em>Customize</em> menu. Try to change the background of your banner.",
- template: render('website.tour_popover', { next: "Continue" }),
- onShow: function () {
- $('.dropdown-menu [name=carousel-background]').click(function () {
- self.movetoStep('save-changes');
- });
- },
- },
- {
- stepId: 'save-changes',
- element: 'button[data-action=save]',
- placement: 'right',
- reflex: true,
- title: "Save your modifications",
- content: "Once you click on save, your website page is updated.",
- template: render('website.tour_popover'),
- onHide: function () {
- self.saveStep('part-2');
- },
-
- },
- {
- stepId: 'part-2',
- orphan: true,
- title: "Congratulation!",
- content: "Your homepage have been updated. Now, we suggest you to insert others building blocks like texts and images to structure your page.",
- template: render('website.tour_popover', { next: "Continue" }),
- },
- {
- stepId: 'show-tutorials',
- element: '#help-menu-button',
- placement: 'left',
- title: "Help is always available",
- content: "But you can always click here if you want more tutorials.",
- template: render('website.tour_popover', { end: "Close" }),
- },
- ];
- return this._super();
- },
- startOfPart2: function () {
- var currentStepIndex = this.currentStepIndex();
- var secondPartIndex = this.indexOfStep('part-2');
- var showTutorialsIndex = this.indexOfStep('show-tutorials');
- return (currentStepIndex === secondPartIndex || currentStepIndex === showTutorialsIndex) && !this.tour.ended();
- },
- canResume: function () {
- return this.startOfPart2() || this._super();
- },
- });
-
website.UrlParser = openerp.Class.extend({
init: function (url) {
var a = document.createElement('a');
@@ -227,30 +98,4 @@
},
});
- website.EditorBar.include({
- start: function () {
- website.tutorials = {
- basic: new website.EditorBasicTour(this),
- };
- var menu = $('#help-menu');
- _.each(website.tutorials, function (tutorial) {
- var $menuItem = $($.parseHTML('<li><a href="#">'+tutorial.name+'</a></li>'));
- $menuItem.click(function () {
- tutorial.reset();
- tutorial.start();
- });
- menu.append($menuItem);
- });
- var url = new website.UrlParser(window.location.href);
- if (url.search.indexOf('?tutorial=true') === 0 || website.tutorials.basic.startOfPart2()) {
- website.tutorials.basic.start();
- }
- $('.tour-backdrop').click(function (e) {
- e.stopImmediatePropagation();
- e.preventDefault();
- });
- return this._super();
- },
- });
-
}());