From 6d7b57b2918d7bb5c6b2976ebfe2e8896eb6db29 Mon Sep 17 00:00:00 2001 From: Mohamed Eltayar <152964073+maltayyar2@users.noreply.github.com> Date: Fri, 29 Aug 2025 00:53:51 +0300 Subject: [PATCH] Simplify JavaScript - remove complex placeholder handling - Remove _ensurePlaceholders() method and related complexity - Remove DOM MutationObserver and event handlers - Remove setTimeout and async handling - Keep only the core functionality for date conversion - Remove all custom placeholder manipulation code - Use simple, standard Odoo approach for placeholders - Focus on core Hijri calendar functionality only --- .../static/src/js/web_hijri_date.js | 95 ------------------- 1 file changed, 95 deletions(-) diff --git a/odex25_base/web_hijri_datepicker/static/src/js/web_hijri_date.js b/odex25_base/web_hijri_datepicker/static/src/js/web_hijri_date.js index a52ae4f8c..f9c1f5b4f 100644 --- a/odex25_base/web_hijri_datepicker/static/src/js/web_hijri_date.js +++ b/odex25_base/web_hijri_datepicker/static/src/js/web_hijri_date.js @@ -37,9 +37,6 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) { this.$input = this.$('input.o_datepicker_input'); this.$input_hijri = this.$('input.o_hijri'); - // ✅ تأكد من عرض الـ placeholder للحقل الميلادي - this._ensurePlaceholders(); - // Enhanced click handler with better UX this.$input_hijri.click(function (e) { e.preventDefault(); @@ -75,64 +72,6 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) { this._setReadonly(false); }, - /** - * ✅ دالة جديدة لضمان عرض الـ placeholder - */ - _ensurePlaceholders: function() { - var self = this; - - // تأكد من عرض placeholder للحقل الميلادي - if (this.$input && this.$input.length) { - if (!this.$input.attr('placeholder')) { - this.$input.attr('placeholder', 'التاريخ الميلادي'); - } - - // معالج للحفاظ على الـ placeholder حتى لو تغير - this.$input.on('focus blur', function() { - if (!$(this).attr('placeholder')) { - $(this).attr('placeholder', 'التاريخ الميلادي'); - } - }); - } - - // تأكد من عرض placeholder للحقل الهجري - if (this.$input_hijri && this.$input_hijri.length) { - if (!this.$input_hijri.attr('placeholder')) { - this.$input_hijri.attr('placeholder', 'التاريخ الهجري'); - } - - // معالج للحفاظ على الـ placeholder - this.$input_hijri.on('focus blur', function() { - if (!$(this).attr('placeholder')) { - $(this).attr('placeholder', 'التاريخ الهجري'); - } - }); - } - - // ✅ معالج إضافي بعد تحميل DOM - setTimeout(function() { - self._ensurePlaceholdersAfterRender(); - }, 100); - }, - - /** - * ✅ دالة إضافية للتأكد من الـ placeholder بعد التحميل - */ - _ensurePlaceholdersAfterRender: function() { - // البحث عن جميع حقول التاريخ في الصفحة وإضافة placeholder إذا لم يكن موجود - this.$el.find('input.o_datepicker_input').each(function() { - if (!$(this).attr('placeholder') || $(this).attr('placeholder') === '') { - $(this).attr('placeholder', 'التاريخ الميلادي'); - } - }); - - this.$el.find('input.o_hijri').each(function() { - if (!$(this).attr('placeholder') || $(this).attr('placeholder') === '') { - $(this).attr('placeholder', 'التاريخ الهجري'); - } - }); - }, - /** * Get modern renderer configuration for better styling */ @@ -248,9 +187,6 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) { } else { this.$input_hijri.val('').addClass('o_input_placeholder'); } - - // ✅ تأكد من الـ placeholder بعد تعيين القيمة - this._ensurePlaceholders(); }, destroy: function () { @@ -345,35 +281,4 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) { }); } - // ✅ معالج شامل للتأكد من الـ placeholder في جميع حقول التاريخ - $(document).ready(function() { - // مراقب DOM للحقول الجديدة - if (window.MutationObserver) { - var observer = new MutationObserver(function(mutations) { - mutations.forEach(function(mutation) { - if (mutation.type === 'childList') { - // البحث عن حقول تاريخ جديدة وإضافة placeholder - $(mutation.target).find('input.o_datepicker_input').each(function() { - if (!$(this).attr('placeholder')) { - $(this).attr('placeholder', 'التاريخ الميلادي'); - } - }); - - $(mutation.target).find('input.o_hijri').each(function() { - if (!$(this).attr('placeholder')) { - $(this).attr('placeholder', 'التاريخ الهجري'); - } - }); - } - }); - }); - - // مراقبة التغييرات في الصفحة - observer.observe(document.body, { - childList: true, - subtree: true - }); - } - }); - });