From cb09edeb9a4066584b3acd9655a6987062d9a887 Mon Sep 17 00:00:00 2001 From: jofemodo Date: Thu, 10 Mar 2022 10:43:40 +0100 Subject: [PATCH] + Little CSS adjustments, specially for mobile. Hide product search. + Add JS adjustments from production server. --- .../static/src/css/website_zynthian.css | 28 +- theme_zynthian/static/src/js/website.js | 286 ------------------ .../static/src/js/website_zynthian.js | 14 +- 3 files changed, 31 insertions(+), 297 deletions(-) delete mode 100644 theme_zynthian/static/src/js/website.js diff --git a/theme_zynthian/static/src/css/website_zynthian.css b/theme_zynthian/static/src/css/website_zynthian.css index 4a3d256..9a35307 100644 --- a/theme_zynthian/static/src/css/website_zynthian.css +++ b/theme_zynthian/static/src/css/website_zynthian.css @@ -269,9 +269,9 @@ ul.wizard li.text-primary { display: block; } .form-control:focus { - border-color: rgba(192, 1, 39, 0.6); - -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(192, 1, 39, 0.6); - box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(192, 1, 39, 0.6); + border-color: rgba(192, 1, 39, 0.6); + -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(192, 1, 39, 0.6); + box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(192, 1, 39, 0.6); } .nav-pills.nav-stacked > li > a{ background: #EDEDED; @@ -282,8 +282,23 @@ ul.wizard li.text-primary { background: #000000; color: #FFFFFF; } + +@media only screen and (max-width: 768px) { + section.parallax { + height: 0px !important; + } + .img.padding-xl { + padding: 0px; + } +} + +ul.mt16 { + margin-top: 0px !important; +} + .pagination{ - margin-top: 30px; + display: none; + margin-top: 0px; } .pagination > li > a, .pagination > li > span { @@ -328,8 +343,9 @@ footer .container.mt16.mb8 .text-muted{ } footer .container.mt16.mb8 a{ color: #FFFFFF; - text-decoration: underline; + /*text-decoration: underline;*/ } footer .container.mt16.mb8 a:hover{ color: #C00127; - text-decoration: none; \ No newline at end of file + text-decoration: none; +} diff --git a/theme_zynthian/static/src/js/website.js b/theme_zynthian/static/src/js/website.js deleted file mode 100644 index a9dcfde..0000000 --- a/theme_zynthian/static/src/js/website.js +++ /dev/null @@ -1,286 +0,0 @@ -odoo.define('website.website', function (require) { -"use strict"; - -var ajax = require('web.ajax'); -var core = require('web.core'); -var Widget = require('web.Widget'); -var session = require('web.session'); -var base = require('web_editor.base'); -var Tour = require('web.Tour'); - -var qweb = core.qweb; -var _t = core._t; -base.url_translations = '/website/translations'; - -/* --- Set the browser into the dom for css selectors --- */ -var browser; -if ($.browser.webkit) browser = "webkit"; -else if ($.browser.safari) browser = "safari"; -else if ($.browser.opera) browser = "opera"; -else if ($.browser.msie || ($.browser.mozilla && +$.browser.version.replace(/^([0-9]+\.[0-9]+).*/, '\$1') < 20)) browser = "msie"; -else if ($.browser.mozilla) browser = "mozilla"; -browser += ","+$.browser.version; -if (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())) browser += ",mobile"; -document.documentElement.setAttribute('data-browser', browser); - -/* --- Locate the "[!]" string and show the alert banner --- */ - -if ($('h1:contains("[!]")').length>0 || $('table#cart_products:contains("[!]")').length>0) { - $('.zynthian_alert_message').fadeIn(1000); -} - -/* ---------------------------------------------------- - Helpers - ---------------------------------------------------- */ - -var get_context = base.get_context; -base.get_context = base.get_context = function (dict) { - var html = document.documentElement; - return _.extend({ - 'website_id': html.getAttribute('data-website-id')|0 - }, get_context(dict), dict); -}; - -/* ---------------------------------------------------- - Widgets - ---------------------------------------------------- */ - -var prompt = function (options, _qweb) { - /** - * A bootstrapped version of prompt() albeit asynchronous - * This was built to quickly prompt the user with a single field. - * For anything more complex, please use editor.Dialog class - * - * Usage Ex: - * - * website.prompt("What... is your quest ?").then(function (answer) { - * arthur.reply(answer || "To seek the Holy Grail."); - * }); - * - * website.prompt({ - * select: "Please choose your destiny", - * init: function() { - * return [ [0, "Sub-Zero"], [1, "Robo-Ky"] ]; - * } - * }).then(function (answer) { - * mame_station.loadCharacter(answer); - * }); - * - * @param {Object|String} options A set of options used to configure the prompt or the text field name if string - * @param {String} [options.window_title=''] title of the prompt modal - * @param {String} [options.input] tell the modal to use an input text field, the given value will be the field title - * @param {String} [options.textarea] tell the modal to use a textarea field, the given value will be the field title - * @param {String} [options.select] tell the modal to use a select box, the given value will be the field title - * @param {Object} [options.default=''] default value of the field - * @param {Function} [options.init] optional function that takes the `field` (enhanced with a fillWith() method) and the `dialog` as parameters [can return a deferred] - */ - if (typeof options === 'string') { - options = { - text: options - }; - } - if (_.isUndefined(_qweb)) { - _qweb = 'website.prompt'; - } - options = _.extend({ - window_title: '', - field_name: '', - 'default': '', // dict notation for IE<9 - init: function() {}, - }, options || {}); - - var type = _.intersection(Object.keys(options), ['input', 'textarea', 'select']); - type = type.length ? type[0] : 'input'; - options.field_type = type; - options.field_name = options.field_name || options[type]; - - var def = $.Deferred(); - var dialog = $(qweb.render(_qweb, options)).appendTo("body"); - options.$dialog = dialog; - var field = dialog.find(options.field_type).first(); - field.val(options['default']); // dict notation for IE<9 - field.fillWith = function (data) { - if (field.is('select')) { - var select = field[0]; - data.forEach(function (item) { - select.options[select.options.length] = new Option(item[1], item[0]); - }); - } else { - field.val(data); - } - }; - var init = options.init(field, dialog); - $.when(init).then(function (fill) { - if (fill) { - field.fillWith(fill); - } - dialog.modal('show'); - field.focus(); - dialog.on('click', '.btn-primary', function () { - var backdrop = $('.modal-backdrop'); - def.resolve(field.val(), field, dialog); - dialog.modal('hide').remove(); - backdrop.remove(); - }); - }); - dialog.on('hidden.bs.modal', function () { - var backdrop = $('.modal-backdrop'); - def.reject(); - dialog.remove(); - backdrop.remove(); - }); - if (field.is('input[type="text"], select')) { - field.keypress(function (e) { - if (e.which == 13) { - e.preventDefault(); - dialog.find('.btn-primary').trigger('click'); - } - }); - } - return def; -}; - -var error = function(data, url) { - var $error = $(qweb.render('website.error_dialog', { - 'title': data.data ? data.data.arguments[0] : "", - 'message': data.data ? data.data.arguments[1] : data.statusText, - 'backend_url': url - })); - $error.appendTo("body"); - $error.modal('show'); -}; - -function _add_input(form, name, value) { - var param = document.createElement('input'); - param.setAttribute('type', 'hidden'); - param.setAttribute('name', name); - param.setAttribute('value', value); - form.appendChild(param); -} -var form = function (url, method, params) { - var form = document.createElement('form'); - form.setAttribute('action', url); - form.setAttribute('method', method); - - if (core.csrf_token) { - _add_input(form, 'csrf_token', core.csrf_token); - } - _.each(params, function (v, k) { - _add_input(form, k, v); - }); - document.body.appendChild(form); - form.submit(); -}; - - -ajax.loadXML('/website/static/src/xml/website.xml', qweb); -ajax.loadXML('/web/static/src/xml/base_common.xml', qweb); - -/** - * Cancel the auto run of Tour (test) and launch the tour after tob bar all bind events - */ - -base.ready().then(function () { - data.topBar = new TopBar(); - data.topBar.attachTo($("#oe_main_menu_navbar")); -}); - -/** - * Returns a deferred resolved when the templates are loaded - * and the Widgets can be instanciated. - */ - - /* ----- PUBLISHING STUFF ---- */ - $(document).on('click', '.js_publish_management .js_publish_btn', function (e) { - e.preventDefault(); - - var $data = $(this).parents(".js_publish_management:first"); - ajax.jsonRpc($data.data('controller') || '/website/publish', 'call', {'id': +$data.data('id'), 'object': $data.data('object')}) - .then(function (result) { - $data.toggleClass("css_unpublished css_published"); - $data.parents("[data-publish]").attr("data-publish", +result ? 'on' : 'off'); - }).fail(function (err, data) { - error(data, '/web#return_label=Website&model='+$data.data('object')+'&id='+$data.data('id')); - }); - }); - - if (!$('.js_change_lang').length) { - // in case template is not up to date... - var links = $('ul.js_language_selector li a:not([data-oe-id])'); - var m = $(_.min(links, function(l) { return $(l).attr('href').length; })).attr('href'); - links.each(function() { - var t = $(this).attr('href'); - var l = (t === m) ? "default" : t.split('/')[1]; - $(this).data('lang', l).addClass('js_change_lang'); - }); - } - - $(document).on('click', '.js_change_lang', function(e) { - e.preventDefault(); - - var self = $(this); - // retrieve the hash before the redirect - var redirect = { - lang: self.data('lang'), - url: encodeURIComponent(self.attr('href').replace(/[&?]edit_translations[^&?]+/, '')), - hash: encodeURIComponent(location.hash) - }; - location.href = _.str.sprintf("/website/lang/%(lang)s?r=%(url)s%(hash)s", redirect); - }); - - /* ----- KANBAN WEBSITE ---- */ - $('.js_kanban').each(function () { - init_kanban(this); - }); - - $('body').on('submit', '.js_website_submit_form', function() { - var $buttons = $(this).find('button[type="submit"], a.a-submit'); - _.each($buttons, function(btn) { - $(btn).attr('data-loading-text', ' ' + $(btn).text()).button('loading'); - }); - }); - - setTimeout(function () { - if (window.location.hash.indexOf("scrollTop=") > -1) { - window.document.body.scrollTop = +location.hash.match(/scrollTop=([0-9]+)/)[1]; - } - },0); - -// display image thumbnail -$(".o_image[data-mimetype^='image']").each(function () { - var $img = $(this); - if (/gif|jpe|jpg|png/.test($img.data('mimetype')) && $img.data('src')) { - $img.css('background-image', "url('" + $img.data('src') + "')"); - } -}); - -/** - * Object who contains all method and bind for the top bar, the template is create server side. - */ - -var TopBar = Widget.extend({ - start: function () { - var $collapse = this.$('#oe_applications ul.dropdown-menu').clone() - .attr("id", "oe_applications_collapse") - .attr("class", "nav navbar-nav navbar-left navbar-collapse collapse"); - this.$('#oe_applications').before($collapse); - $collapse.wrap('
'); - this.$('[data-target="#oe_applications"]').attr("data-target", "#oe_applications_collapse"); - - return this._super(); - } -}); - - -var data = { - prompt: prompt, - form: form, - TopBar: TopBar, - ready: function () { - console.warn("website.ready is deprecated: Please use require('web_editor.base').ready()"); - return base.ready(); - } -}; -return data; - -}); diff --git a/theme_zynthian/static/src/js/website_zynthian.js b/theme_zynthian/static/src/js/website_zynthian.js index fc83bce..16f7afc 100644 --- a/theme_zynthian/static/src/js/website_zynthian.js +++ b/theme_zynthian/static/src/js/website_zynthian.js @@ -4,16 +4,20 @@ odoo.define('website.website', function (require) { console.log("ZYNTHIAN DIRTY TRICKS!"); $(window).on('load',function() { /* --- Locate the "[!]" string and show the alert banner --- */ - if ($('h1:contains("[!]")').length>0 || -$('table#cart_products:contains("[!]")').length>0) { + if ($('h1:contains("[!]")').length>0 || $('table#cart_products:contains("[!]")').length>0) { $('.zynthian_alert_message').fadeIn(1000); } - /* --- Locate the "[*]" string and remove "AddToCart button, replacing -by "SOLD OUT" warning --- */ + /* --- Locate the "[*]" string and remove "AddToCart button, replacing by "SOLD OUT" warning --- */ if ($('h1:contains("[*]")').length>0) { $('#add_to_cart').hide(); $('#sold_out_warning').show(); } + $('div.oe_product_cart').each(function() { + if ($(this).find("a[itemprop='name']:contains('[*]')").length>0) { + $(this).find("a.btn").hide() + } + }); +}); + }); -}); \ No newline at end of file