From 7cbd4406e839791105fe363aac51a79ae7981c0b Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Sat, 1 Jun 2019 16:23:07 +0530 Subject: [PATCH 1/2] Task : Gulp automation & linting for com_tjvendors --- .gitignore | 2 + gulpfile.js | 26 ++ htmlhint.conf | 25 ++ package.json | 48 +++ src/com_tjvendors/media/css/style.css | 1 + src/com_tjvendors/media/js/script-min.js | 1 + src/com_tjvendors/media/js/script.js | 347 ++++++++++++++++++ src/com_tjvendors/media/scss/_tjvendors.scss | 74 ++++ src/com_tjvendors/media/scss/_variables.scss | 1 + src/com_tjvendors/media/scss/style.css | 3 + .../media/scss/vendors/_no-more-tables.scss | 47 +++ src/com_tjvendors/media/ts/tjvendors.js | 347 ++++++++++++++++++ tslint.json | 143 ++++++++ 13 files changed, 1065 insertions(+) create mode 100644 .gitignore create mode 100644 gulpfile.js create mode 100644 htmlhint.conf create mode 100644 package.json create mode 100644 src/com_tjvendors/media/css/style.css create mode 100644 src/com_tjvendors/media/js/script-min.js create mode 100644 src/com_tjvendors/media/js/script.js create mode 100644 src/com_tjvendors/media/scss/_tjvendors.scss create mode 100644 src/com_tjvendors/media/scss/_variables.scss create mode 100644 src/com_tjvendors/media/scss/style.css create mode 100755 src/com_tjvendors/media/scss/vendors/_no-more-tables.scss create mode 100644 src/com_tjvendors/media/ts/tjvendors.js create mode 100644 tslint.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1b5604b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.sass-cache/ +node_modules/ diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..b1948a78 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,26 @@ +const gulp = require('gulp'); +const concat = require('gulp-concat'); +const minify = require('gulp-minify'); +const sass = require('gulp-sass'); +sass.compiler = require('node-sass'); + +gulp.task('scss', function () { + return gulp.src('./src/com_tjvendors/media/scss/style.css') + .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) + .pipe(gulp.dest('./src/com_tjvendors/media/css')); +}); + +gulp.task('js', async function() { + gulp.src(['./src/com_tjvendors/media/ts/tjvendors.js']) + .pipe(concat('script.js')) + .pipe(minify()) + .pipe(gulp.dest('./src/com_tjvendors/media/js')) +}); + +gulp.task('watch', function() { + gulp.watch('./src/com_tjvendors/media/scss/**/*.scss', gulp.series('scss')); + + gulp.watch('./src/com_tjvendors/media/ts/*.js', gulp.series('js')); +}); + +gulp.task('default', gulp.parallel(['scss','js','watch'])); diff --git a/htmlhint.conf b/htmlhint.conf new file mode 100644 index 00000000..74da7186 --- /dev/null +++ b/htmlhint.conf @@ -0,0 +1,25 @@ + { + "tagname-lowercase": true, + "attr-lowercase": true, + "attr-value-double-quotes": true, + "attr-value-not-empty": false, + "attr-no-duplication": true, + "doctype-first": false, + "tag-pair": true, + "empty-tag-not-self-closed": true, + "spec-char-escape": true, + "id-unique": true, + "src-not-empty": true, + "title-require": true, + "alt-require": true, + "doctype-html5": false, + "id-class-value": false, + "style-disabled": false, + "inline-style-disabled": false, + "inline-script-disabled": false, + "space-tab-mixed-disabled": "space", + "id-class-ad-disabled": false, + "href-abs-or-rel": false, + "attr-unsafe-chars": true, + "head-script-disabled": true +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..61754354 --- /dev/null +++ b/package.json @@ -0,0 +1,48 @@ +{ + "name": "com_tjvendors", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/anupamk09/com_tjvendors.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/anupamk09/com_tjvendors/issues" + }, + "homepage": "https://github.com/anupamk09/com_tjvendors#readme", + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "./src/com_tjvendors/media/ts/**/*.js": "tslint", + "./src/com_tjvendors/**/*.html": "htmlhint --config htmlhint.conf", + "./src/com_tjvendors/media/css/**/*.css": "stylelint", + "./src/com_tjvendors/media/scss/**/*.scss": "stylelint --syntax=scss" + }, + "dependencies": {}, + "devDependencies": { + "codelyzer": "^5.0.0", + "gulp": "^4.0.2", + "gulp-concat": "^2.6.1", + "gulp-minify": "^3.1.0", + "gulp-sass": "^4.0.2", + "htmlhint": "^0.11.0", + "husky": "^1.3.1", + "imagemin-lint-staged": "^0.4.0", + "lint-staged": "^8.1.0", + "node-sass": "^4.12.0", + "prettier": "1.16.1", + "stylelint": "^9.10.1", + "stylelint-config-standard": "^18.2.0", + "tslint": "^5.7.0", + "typescript": "~3.2.4" + } +} diff --git a/src/com_tjvendors/media/css/style.css b/src/com_tjvendors/media/css/style.css new file mode 100644 index 00000000..c6a87860 --- /dev/null +++ b/src/com_tjvendors/media/css/style.css @@ -0,0 +1 @@ +#tjv-wrapper .date .input-group-btn{width:auto}#tjv-wrapper .date__field{min-width:100px}#tjv-wrapper .search .search__icon{background-color:#ddd;padding:12px}#tjv-wrapper ul.tabs li.active{border-bottom:2px solid #999}#tjv-wrapper .date .icon-calendar:before{content:"\f073";font:normal normal normal 14px/1 FontAwesome}#tjv-wrapper .date .input-append,#tjv-wrapper .search__field{display:inline-flex;margin-right:4px}#tjv-wrapper #jform_payment_gateway_chzn,#tjv-wrapper .vendorForm .chzn-container{width:200px !important}#tjv-wrapper .vendor-report .btn{padding:6px 10px}#tjv-wrapper .mt-0{margin-top:0}#tjv-wrapper .mt-10{margin-top:10px}#tjv-wrapper .mb-15{margin-bottom:15px}#tjv-wrapper .pr-0{padding-right:0}#tjv-wrapper .p-10{padding:10px}.d-flex{display:flex}@media (max-width: 576px){.vendorForm__nav{white-space:nowrap;overflow-x:auto;overflow-y:hidden}}@media only screen and (max-width: 768px){.no-more-tables table,.no-more-tables thead,.no-more-tables tbody,.no-more-tables th,.no-more-tables td,.no-more-tables tr{display:block}.no-more-tables thead tr{position:absolute;top:-9999px;left:-9999px}.no-more-tables tr{border:1px solid #ccc}.no-more-tables td{border:none;border-bottom:1px solid #eee !important;position:relative;padding-left:55% !important;white-space:normal;text-align:left}.no-more-tables td:before{position:absolute;top:6px;left:6px;width:55%;padding-right:10px;white-space:nowrap;text-align:left;font-weight:bold}.no-more-tables td:before{content:attr(data-title);overflow:auto}.no-more-tables td{width:auto}.no-more-tables tr .wordbreak{word-wrap:break-word}} diff --git a/src/com_tjvendors/media/js/script-min.js b/src/com_tjvendors/media/js/script-min.js new file mode 100644 index 00000000..892f58e1 --- /dev/null +++ b/src/com_tjvendors/media/js/script-min.js @@ -0,0 +1 @@ +var tjVAdmin={vendor:{readMore:function(){var e=Joomla.JText._("COM_TJVENDOR_DESCRIPTION_READ_MORE"),o=Joomla.JText._("COM_TJVENDOR_DESCRIPTION_READ_LESS");jQuery(".profile__content").each(function(){var o=jQuery(this).html();if(o.length>300){var t=o.substr(0,300)+''+o.substr(300,o.length-300)+'  '+e+"";jQuery(this).html(t)}}),jQuery(".morelink").click(function(){return jQuery(this).hasClass("less")?(jQuery(this).removeClass("less"),jQuery(this).html(e)):(jQuery(this).addClass("less"),jQuery(this).html(o)),jQuery(this).parent().prev().toggle(),jQuery(this).prev().toggle(),!1})},initVendorJs:function(){jQuery(document).ready(function(){jQuery(document).on("change","#jform_user_id",function(){tjVAdmin.vendor.checkVendor()})}),jQuery(window).load(function(){tjCommon.vendorLogoValidation(),tjCommon.initVendorFields()}),Joomla.submitbutton=function(e){if("vendor.apply"==e||"vendor.save"==e||"vendor.save2new"==e){var o=document.formvalidator.isValid(document.getElementById("adminForm"));if(""==document.getElementById("jform_user_id").value){var t=[Joomla.JText._("COM_TJVENDOR_USER_ERROR")];Joomla.renderMessages({warning:t})}else 1==o&&Joomla.submitform(e,document.getElementById("adminForm"))}else Joomla.submitform(e,document.getElementById("adminForm"))}},changePayoutStatus:function(e,o){document.getElementById("paidUnpaid").value;var t={};t.payout_id=e,t.paidUnpaid=jQuery(o).val(),JSON.stringify(t),jQuery.ajax({type:"POST",dataType:"json",data:t,url:"index.php?option=com_tjvendors&task=payout.changePayoutStatus",success:function(e){e&&(document.location="index.php?option=com_tjvendors&view=reports&client="+client)}})},checkVendor:function(){var e=document.getElementById("jform_user_id_id").value,o={};o.user=e,o.vendor_id=vendor_id,JSON.stringify(o),jQuery.ajax({type:"POST",dataType:"json",data:o,url:"index.php?option=com_tjvendors&task=vendor.checkDuplicateUser",success:function(e){if(e){if("update"===layout){var o=[Joomla.JText._("COM_TJVENDOR_DUPLICARE_VENDOR_ERROR")];return Joomla.renderMessages({warning:o}),vendorCheck="exists"}document.location="index.php?option=com_tjvendors&view=vendor&layout=edit&client="+client+"&vendor_id="+e.vendor_id}}})}},vendors:{vendorApprove:function(e,o){vendorApprove=jQuery(o).val();var t={};t.vendor_id=e,t.vendorApprove=vendorApprove,t.client=client,JSON.stringify(t),jQuery.ajax({type:"POST",dataType:"json",data:t,url:"index.php?option=com_tjvendors&task=vendor.vendorApprove",success:function(e){if(alert(e),jQuery("#system-message-container").empty(),"1"==vendorApprove){var o=[Joomla.JText._("COM_TJVENDOR_VENDOR_APPROVAL")];Joomla.renderMessages({success:o})}else o=[Joomla.JText._("COM_TJVENDOR_VENDOR_DENIAL")],Joomla.renderMessages({success:o})}})}},fee:{initFeeJs:function(){Joomla.submitbutton=function(e){if("vendorfee.apply"==e||"vendorfee.save"==e){var o=document.getElementById("jform_percent_commission").value,t=document.getElementById("jform_flat_commission").value;if(o>100){var n=[Joomla.JText._("COM_TJVENDORS_FEES_PERCENT_ERROR")];Joomla.renderMessages({error:n})}else if(o<0||t<0){n=[Joomla.JText._("COM_TJVENDORS_FEES_NEGATIVE_NUMBER_ERROR")];Joomla.renderMessages({error:n})}else Joomla.submitform(e,document.getElementById("vendorfee-form"))}else"vendorfee.cancel"==e&&Joomla.submitform(e,document.getElementById("vendorfee-form"))}}},reports:{initReportsJs:function(){jQuery(document).ready(function(){jQuery("#dates").blur(function(){document.adminForm.submit()}),jQuery("#date").blur(function(){document.adminForm.submit()})})}}},tjVSite={vendor:{initVendorJs:function(){jQuery(document).ready(function(){jQuery(document).on("change","#jform_payment_gateway",function(){})}),jQuery(window).load(function(){tjCommon.vendorLogoValidation(),tjCommon.initVendorFields()}),Joomla.submitbutton=function(e){"vendor.save"==e?1==document.formvalidator.isValid(document.getElementById("adminForm"))&&Joomla.submitform(e,document.getElementById("adminForm")):Joomla.submitform(e,document.getElementById("adminForm"))}}},vendors:{initVendorsJs:function(){jQuery(document).ready(function(){jQuery("#dates, #date").blur(function(){jQuery("#adminForm").submit()})})},toggleDiv:function(e){jQuery(window).width()<767?jQuery("#"+e).toggle("slow"):jQuery("#"+e).toggle(),jQuery(".report_search_input").toggleClass("active")}}},tjCommon={vendorLogoValidation:function(){jQuery("#jform_vendor_logo").change(function(e){var o,t;(o=this.files[0])&&((t=new Image).onload=function(){if(o.size>vendorAllowedMediaSize)return alert(allowedMediaSizeErrorMessage),jQuery("#jform_vendor_logo").val(""),!1;(this.width<445||this.height<265)&&alert(allowedImageDimensionErrorMessage+this.width+"px X "+this.height+"px")},t.onerror=function(){return alert(allowedImageTypeErrorMessage+o.type),jQuery("#jform_vendor_logo").val(""),!1},t.src=_URL.createObjectURL(o))})},initVendorFields:function(){jQuery(".subform-repeatable-group .gateway_name").on("focus",function(){previous=this.value}),jQuery(".subform-repeatable-group .gateway_name").each(function(){jQuery(this).trigger("change")})},getGatewayFields:function(e){let o=0;if(jQuery(".subform-repeatable-group .gateway_name").each(function(){this.value===e.value&&o++}),o>1)return jQuery(e).val(),!1;let t={payment_gateway:e.value,parent_tag:e.name.replace("[payment_gateways]","")};tjCommon.generateGatewayFields(t,e.id)},generateGatewayFields:function(e,o){JSON.stringify(e),jQuery.ajax({type:"POST",dataType:"json",data:e,url:Joomla.getOptions("system.paths").base+"/index.php?option=com_tjvendors&task=vendor.generateGatewayFields",success:function(t){let n=jQuery("#"+o);if(n.closest(".subform-repeatable-group").find(".payment-gateway-parent").empty(),t)t.forEach(function(e){n.closest(".subform-repeatable-group").append("
"+e+"
")});else if(!t&&""!=e.payment_gateway){var r=Joomla.JText._("COM_TJVENDOR_PAYMENTGATEWAY_NO_FIELD_MESSAGE");n.closest(".subform-repeatable-group").append("
"+r+"
")}}})}}; \ No newline at end of file diff --git a/src/com_tjvendors/media/js/script.js b/src/com_tjvendors/media/js/script.js new file mode 100644 index 00000000..1e03513d --- /dev/null +++ b/src/com_tjvendors/media/js/script.js @@ -0,0 +1,347 @@ +/* + * @version SVN: + * @package Tjvendors + * @author Techjoomla + * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later. + */ +var tjVAdmin = { + vendor: { + /*For Read More/Read Less*/ + readMore: function() { + var showChar = 300; + var ellipsestext = ""; + var moretext = Joomla.JText._('COM_TJVENDOR_DESCRIPTION_READ_MORE'); + var lesstext = Joomla.JText._('COM_TJVENDOR_DESCRIPTION_READ_LESS'); + + jQuery('.profile__content').each(function() { + var content = jQuery(this).html(); + + if (content.length > showChar) { + var show_content = content.substr(0, showChar); + var hide_content = content.substr(showChar, content.length - showChar); + var html = show_content + '' + ellipsestext + '' + hide_content + '  ' + moretext + ''; + jQuery(this).html(html); + } + }); + + jQuery(".morelink").click(function() { + if (jQuery(this).hasClass("less")) { + jQuery(this).removeClass("less"); + jQuery(this).html(moretext); + } + else { + jQuery(this).addClass("less"); + jQuery(this).html(lesstext); + } + + jQuery(this).parent().prev().toggle(); + jQuery(this).prev().toggle(); + + return false; + }); + }, + + /*Initialize event js*/ + initVendorJs: function() { + jQuery(document).ready(function() { + jQuery(document).on("change", "#jform_user_id", function() { + tjVAdmin.vendor.checkVendor(); + }); + }); + + jQuery(window).load(function() { + tjCommon.vendorLogoValidation(); + tjCommon.initVendorFields(); + }); + + Joomla.submitbutton = function(task) { + if (task == 'vendor.apply' || task == 'vendor.save' || task == 'vendor.save2new') { + var validData = document.formvalidator.isValid(document.getElementById('adminForm')); + var username = document.getElementById("jform_user_id").value; + + if (username == '') { + var jmsgs = [Joomla.JText._('COM_TJVENDOR_USER_ERROR')]; + Joomla.renderMessages({ + 'warning': jmsgs + }); + } + else if (validData == true) { + Joomla.submitform(task, document.getElementById('adminForm')); + } + } + else if (task == 'vendor.cancel') { + Joomla.submitform(task, document.getElementById('adminForm')); + } + else { + Joomla.submitform(task, document.getElementById('adminForm')); + } + } + }, + + changePayoutStatus: function(payout_id, ele) { + var paidUnpaid1 = document.getElementById('paidUnpaid').value; + var userObject = {}; + userObject["payout_id"] = payout_id; + userObject["paidUnpaid"] = jQuery(ele).val(); + + JSON.stringify(userObject); + jQuery.ajax({ + type: "POST", + dataType: "json", + data: userObject, + url: "index.php?option=com_tjvendors&task=payout.changePayoutStatus", + success: function(data) { + if (data) { + document.location = 'index.php?option=com_tjvendors&view=reports&client=' + client; + } + }, + }); + }, + + checkVendor: function() { + var user = document.getElementById('jform_user_id_id').value; + var userObject = {}; + userObject["user"] = user; + userObject["vendor_id"] = vendor_id; + JSON.stringify(userObject); + jQuery.ajax({ + type: "POST", + dataType: "json", + data: userObject, + url: "index.php?option=com_tjvendors&task=vendor.checkDuplicateUser", + success: function(data) { + + if (data) { + if (layout === "update") { + var jmsgs = [Joomla.JText._('COM_TJVENDOR_DUPLICARE_VENDOR_ERROR')]; + Joomla.renderMessages({ + 'warning': jmsgs + }); + + return vendorCheck = "exists"; + } + else { + document.location = 'index.php?option=com_tjvendors&view=vendor&layout=edit&client=' + client + '&vendor_id=' + data.vendor_id; + } + } + }, + }); + } + }, + + vendors: { + vendorApprove: function(vendor_id, ele) { + vendorApprove = jQuery(ele).val(); + var userObject = {}; + userObject["vendor_id"] = vendor_id; + userObject["vendorApprove"] = vendorApprove; + userObject["client"] = client; + + JSON.stringify(userObject); + jQuery.ajax({ + type: "POST", + dataType: "json", + data: userObject, + url: "index.php?option=com_tjvendors&task=vendor.vendorApprove", + success: function(data) { + alert(data); + jQuery('#system-message-container').empty(); + if (vendorApprove == '1') { + var jmsgs = [Joomla.JText._('COM_TJVENDOR_VENDOR_APPROVAL')]; + Joomla.renderMessages({ + 'success': jmsgs + }); + } + else { + jmsgs = [Joomla.JText._('COM_TJVENDOR_VENDOR_DENIAL')]; + Joomla.renderMessages({ + 'success': jmsgs + }); + } + }, + }); + }, + }, + + fee: { + /*Initialize event js*/ + initFeeJs: function() { + Joomla.submitbutton = function(task) { + if (task == 'vendorfee.apply' || task == 'vendorfee.save') { + var percent_commission = document.getElementById("jform_percent_commission").value; + var flat_commission = document.getElementById("jform_flat_commission").value; + + if (percent_commission > 100) { + var jmsgs = [Joomla.JText._('COM_TJVENDORS_FEES_PERCENT_ERROR')]; + Joomla.renderMessages({ + 'error': jmsgs + }); + } + else if (percent_commission < 0 || flat_commission < 0) { + var jmsgs = [Joomla.JText._('COM_TJVENDORS_FEES_NEGATIVE_NUMBER_ERROR')]; + Joomla.renderMessages({ + 'error': jmsgs + }); + } + else { + Joomla.submitform(task, document.getElementById('vendorfee-form')); + } + } + else if (task == 'vendorfee.cancel') { + Joomla.submitform(task, document.getElementById('vendorfee-form')); + } + } + } + }, + + reports: { + /*Initialize event js*/ + initReportsJs: function() { + jQuery(document).ready(function() { + jQuery("#dates").blur(function() { + document.adminForm.submit(); + }); + jQuery("#date").blur(function() { + document.adminForm.submit(); + }); + }); + }, + } +} +var tjVSite = { + vendor: { + /*Initialize event js*/ + initVendorJs: function() { + jQuery(document).ready(function() { + jQuery(document).on("change", "#jform_payment_gateway", function() {}); + }); + + jQuery(window).load(function() { + tjCommon.vendorLogoValidation(); + tjCommon.initVendorFields(); + }); + + Joomla.submitbutton = function(task) { + if (task == 'vendor.save') { + var validData = document.formvalidator.isValid(document.getElementById('adminForm')); + if (validData == true) { + Joomla.submitform(task, document.getElementById('adminForm')); + } + } + else if (task == 'vendor.cancel') { + Joomla.submitform(task, document.getElementById('adminForm')); + } + else { + Joomla.submitform(task, document.getElementById('adminForm')); + } + } + } + }, + + vendors: { + /*Initialize event js*/ + initVendorsJs: function() { + jQuery(document).ready(function() { + jQuery("#dates, #date").blur(function() { + jQuery('#adminForm').submit(); + }); + }); + }, + + toggleDiv: function(spanId) { + if (jQuery(window).width() < 767) { + jQuery("#" + spanId).toggle("slow"); + } + else { + jQuery("#" + spanId).toggle(); + } + jQuery(".report_search_input").toggleClass("active"); + }, + } +} + +var tjCommon = { + vendorLogoValidation: function() { + jQuery("#jform_vendor_logo").change(function(e) { + var file, img; + if ((file = this.files[0])) { + img = new Image(); + img.onload = function() { + + if (file.size > vendorAllowedMediaSize) { + alert(allowedMediaSizeErrorMessage); + jQuery("#jform_vendor_logo").val(''); + return false; + } + + if (this.width < 445 || this.height < 265) { + alert(allowedImageDimensionErrorMessage + this.width + "px X " + this.height + "px"); + } + }; + + img.onerror = function() { + alert(allowedImageTypeErrorMessage + file.type); + jQuery("#jform_vendor_logo").val(''); + return false; + }; + + img.src = _URL.createObjectURL(file); + } + }); + }, + + initVendorFields: function() { + jQuery('.subform-repeatable-group .gateway_name').on('focus', function() { + previous = this.value; + }); + jQuery('.subform-repeatable-group .gateway_name').each(function() { + jQuery(this).trigger("change"); + }); + }, + + getGatewayFields: function(ele) { + let count = 0; + jQuery('.subform-repeatable-group .gateway_name').each(function() { + if (this.value === ele.value) { + count++; + } + }); + + if (count > 1) { + jQuery(ele).val(); + return false; + } + + let userObject = { + 'payment_gateway': ele.value, + 'parent_tag': ele.name.replace('[payment_gateways]', "") + }; + + tjCommon.generateGatewayFields(userObject, ele.id); + }, + + generateGatewayFields: function (userObject, eleId) { + JSON.stringify(userObject); + jQuery.ajax({ + type: "POST", + dataType: "json", + data: userObject, + url: Joomla.getOptions('system.paths').base + "/index.php?option=com_tjvendors&task=vendor.generateGatewayFields", + success: function (response) { + let $thisId = jQuery('#' + eleId); + $thisId.closest('.subform-repeatable-group').find('.payment-gateway-parent').empty(); + + if (response) { + response.forEach(function(data) { + $thisId.closest('.subform-repeatable-group').append("
" + data + "
"); + }); + } + else if (!response && userObject.payment_gateway != "") { + var error_html = Joomla.JText._('COM_TJVENDOR_PAYMENTGATEWAY_NO_FIELD_MESSAGE'); + $thisId.closest('.subform-repeatable-group').append("
" + error_html + "
"); + } + } + }); + } +} diff --git a/src/com_tjvendors/media/scss/_tjvendors.scss b/src/com_tjvendors/media/scss/_tjvendors.scss new file mode 100644 index 00000000..94c7d231 --- /dev/null +++ b/src/com_tjvendors/media/scss/_tjvendors.scss @@ -0,0 +1,74 @@ +/* BEM Format + Page cover Ex: pin-cover + Block: Ex: pin + Element: Ex: pin__input + Modifier: Ex: pin__input--btn */ + +/*----TJvendor css---*/ +#tjv-wrapper .date .input-group-btn { +width:auto; +} + +#tjv-wrapper .date__field { +min-width:100px; +} + +#tjv-wrapper .search .search__icon { +background-color:#ddd; +padding:12px; +} + +#tjv-wrapper ul.tabs li.active { +border-bottom:2px solid #999; +} + +/*--Bootstrap Overrides-- */ +#tjv-wrapper .date .icon-calendar:before { +content:"\f073"; +font: normal normal normal 14px/1 FontAwesome; +} + +#tjv-wrapper .date .input-append,#tjv-wrapper .search__field { +display:inline-flex; +margin-right:4px; +} + +#tjv-wrapper #jform_payment_gateway_chzn, +#tjv-wrapper .vendorForm .chzn-container{ +width:200px !important; +} + +/*----Uber Template----*/ +#tjv-wrapper .vendor-report .btn{ +padding:6px 10px; +} + +/*----Reusable css--*/ +#tjv-wrapper .mt-0{ +margin-top:0; +} +#tjv-wrapper .mt-10{ +margin-top:10px; +} +#tjv-wrapper .mb-15{ +margin-bottom:15px;; +} +#tjv-wrapper .pr-0{ +padding-right:0; +} +#tjv-wrapper .p-10{ +padding:10px; +} +.d-flex { +display: flex; +} + +/*----Media Query for Tab css--*/ +@media (max-width: 576px){ + .vendorForm__nav { + white-space: nowrap; + overflow-x: auto; + overflow-y: hidden; + } +} + diff --git a/src/com_tjvendors/media/scss/_variables.scss b/src/com_tjvendors/media/scss/_variables.scss new file mode 100644 index 00000000..136d0638 --- /dev/null +++ b/src/com_tjvendors/media/scss/_variables.scss @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/com_tjvendors/media/scss/style.css b/src/com_tjvendors/media/scss/style.css new file mode 100644 index 00000000..603a33e4 --- /dev/null +++ b/src/com_tjvendors/media/scss/style.css @@ -0,0 +1,3 @@ +@import "./variables"; +@import "./tjvendors"; +@import "./vendors/no-more-tables"; diff --git a/src/com_tjvendors/media/scss/vendors/_no-more-tables.scss b/src/com_tjvendors/media/scss/vendors/_no-more-tables.scss new file mode 100755 index 00000000..08133c8a --- /dev/null +++ b/src/com_tjvendors/media/scss/vendors/_no-more-tables.scss @@ -0,0 +1,47 @@ +/* http://elvery.net/demo/responsive-tables/ */ +@media only screen and (max-width: 768px) { + /* Force table to not be like tables anymore */ + .no-more-tables table, + .no-more-tables thead, + .no-more-tables tbody, + .no-more-tables th, + .no-more-tables td, + .no-more-tables tr { + display: block; + } + /* Hide table headers (but not display: none;, for accessibility) */ + .no-more-tables thead tr { + position: absolute; + top: -9999px; + left: -9999px; + } + .no-more-tables tr { border: 1px solid #ccc; } + .no-more-tables td { + /* Behave like a "row" */ + border: none; + border-bottom: 1px solid #eee !important; + position: relative; + padding-left: 55% !important; + white-space: normal; + text-align:left; + } + .no-more-tables td:before { + /* Now like a table header */ + position: absolute; + /* Top/left values mimic padding */ + top: 6px; + left: 6px; + width: 55%; + padding-right: 10px; + white-space: nowrap; + text-align:left; + font-weight: bold; + } + /* Label the data */ + .no-more-tables td:before { content: attr(data-title); overflow:auto; } + /* Added by manoj*/ + .no-more-tables td { width:auto; } + + .no-more-tables tr .wordbreak {word-wrap:break-word;} + +} diff --git a/src/com_tjvendors/media/ts/tjvendors.js b/src/com_tjvendors/media/ts/tjvendors.js new file mode 100644 index 00000000..1e03513d --- /dev/null +++ b/src/com_tjvendors/media/ts/tjvendors.js @@ -0,0 +1,347 @@ +/* + * @version SVN: + * @package Tjvendors + * @author Techjoomla + * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later. + */ +var tjVAdmin = { + vendor: { + /*For Read More/Read Less*/ + readMore: function() { + var showChar = 300; + var ellipsestext = ""; + var moretext = Joomla.JText._('COM_TJVENDOR_DESCRIPTION_READ_MORE'); + var lesstext = Joomla.JText._('COM_TJVENDOR_DESCRIPTION_READ_LESS'); + + jQuery('.profile__content').each(function() { + var content = jQuery(this).html(); + + if (content.length > showChar) { + var show_content = content.substr(0, showChar); + var hide_content = content.substr(showChar, content.length - showChar); + var html = show_content + '' + ellipsestext + '' + hide_content + '  ' + moretext + ''; + jQuery(this).html(html); + } + }); + + jQuery(".morelink").click(function() { + if (jQuery(this).hasClass("less")) { + jQuery(this).removeClass("less"); + jQuery(this).html(moretext); + } + else { + jQuery(this).addClass("less"); + jQuery(this).html(lesstext); + } + + jQuery(this).parent().prev().toggle(); + jQuery(this).prev().toggle(); + + return false; + }); + }, + + /*Initialize event js*/ + initVendorJs: function() { + jQuery(document).ready(function() { + jQuery(document).on("change", "#jform_user_id", function() { + tjVAdmin.vendor.checkVendor(); + }); + }); + + jQuery(window).load(function() { + tjCommon.vendorLogoValidation(); + tjCommon.initVendorFields(); + }); + + Joomla.submitbutton = function(task) { + if (task == 'vendor.apply' || task == 'vendor.save' || task == 'vendor.save2new') { + var validData = document.formvalidator.isValid(document.getElementById('adminForm')); + var username = document.getElementById("jform_user_id").value; + + if (username == '') { + var jmsgs = [Joomla.JText._('COM_TJVENDOR_USER_ERROR')]; + Joomla.renderMessages({ + 'warning': jmsgs + }); + } + else if (validData == true) { + Joomla.submitform(task, document.getElementById('adminForm')); + } + } + else if (task == 'vendor.cancel') { + Joomla.submitform(task, document.getElementById('adminForm')); + } + else { + Joomla.submitform(task, document.getElementById('adminForm')); + } + } + }, + + changePayoutStatus: function(payout_id, ele) { + var paidUnpaid1 = document.getElementById('paidUnpaid').value; + var userObject = {}; + userObject["payout_id"] = payout_id; + userObject["paidUnpaid"] = jQuery(ele).val(); + + JSON.stringify(userObject); + jQuery.ajax({ + type: "POST", + dataType: "json", + data: userObject, + url: "index.php?option=com_tjvendors&task=payout.changePayoutStatus", + success: function(data) { + if (data) { + document.location = 'index.php?option=com_tjvendors&view=reports&client=' + client; + } + }, + }); + }, + + checkVendor: function() { + var user = document.getElementById('jform_user_id_id').value; + var userObject = {}; + userObject["user"] = user; + userObject["vendor_id"] = vendor_id; + JSON.stringify(userObject); + jQuery.ajax({ + type: "POST", + dataType: "json", + data: userObject, + url: "index.php?option=com_tjvendors&task=vendor.checkDuplicateUser", + success: function(data) { + + if (data) { + if (layout === "update") { + var jmsgs = [Joomla.JText._('COM_TJVENDOR_DUPLICARE_VENDOR_ERROR')]; + Joomla.renderMessages({ + 'warning': jmsgs + }); + + return vendorCheck = "exists"; + } + else { + document.location = 'index.php?option=com_tjvendors&view=vendor&layout=edit&client=' + client + '&vendor_id=' + data.vendor_id; + } + } + }, + }); + } + }, + + vendors: { + vendorApprove: function(vendor_id, ele) { + vendorApprove = jQuery(ele).val(); + var userObject = {}; + userObject["vendor_id"] = vendor_id; + userObject["vendorApprove"] = vendorApprove; + userObject["client"] = client; + + JSON.stringify(userObject); + jQuery.ajax({ + type: "POST", + dataType: "json", + data: userObject, + url: "index.php?option=com_tjvendors&task=vendor.vendorApprove", + success: function(data) { + alert(data); + jQuery('#system-message-container').empty(); + if (vendorApprove == '1') { + var jmsgs = [Joomla.JText._('COM_TJVENDOR_VENDOR_APPROVAL')]; + Joomla.renderMessages({ + 'success': jmsgs + }); + } + else { + jmsgs = [Joomla.JText._('COM_TJVENDOR_VENDOR_DENIAL')]; + Joomla.renderMessages({ + 'success': jmsgs + }); + } + }, + }); + }, + }, + + fee: { + /*Initialize event js*/ + initFeeJs: function() { + Joomla.submitbutton = function(task) { + if (task == 'vendorfee.apply' || task == 'vendorfee.save') { + var percent_commission = document.getElementById("jform_percent_commission").value; + var flat_commission = document.getElementById("jform_flat_commission").value; + + if (percent_commission > 100) { + var jmsgs = [Joomla.JText._('COM_TJVENDORS_FEES_PERCENT_ERROR')]; + Joomla.renderMessages({ + 'error': jmsgs + }); + } + else if (percent_commission < 0 || flat_commission < 0) { + var jmsgs = [Joomla.JText._('COM_TJVENDORS_FEES_NEGATIVE_NUMBER_ERROR')]; + Joomla.renderMessages({ + 'error': jmsgs + }); + } + else { + Joomla.submitform(task, document.getElementById('vendorfee-form')); + } + } + else if (task == 'vendorfee.cancel') { + Joomla.submitform(task, document.getElementById('vendorfee-form')); + } + } + } + }, + + reports: { + /*Initialize event js*/ + initReportsJs: function() { + jQuery(document).ready(function() { + jQuery("#dates").blur(function() { + document.adminForm.submit(); + }); + jQuery("#date").blur(function() { + document.adminForm.submit(); + }); + }); + }, + } +} +var tjVSite = { + vendor: { + /*Initialize event js*/ + initVendorJs: function() { + jQuery(document).ready(function() { + jQuery(document).on("change", "#jform_payment_gateway", function() {}); + }); + + jQuery(window).load(function() { + tjCommon.vendorLogoValidation(); + tjCommon.initVendorFields(); + }); + + Joomla.submitbutton = function(task) { + if (task == 'vendor.save') { + var validData = document.formvalidator.isValid(document.getElementById('adminForm')); + if (validData == true) { + Joomla.submitform(task, document.getElementById('adminForm')); + } + } + else if (task == 'vendor.cancel') { + Joomla.submitform(task, document.getElementById('adminForm')); + } + else { + Joomla.submitform(task, document.getElementById('adminForm')); + } + } + } + }, + + vendors: { + /*Initialize event js*/ + initVendorsJs: function() { + jQuery(document).ready(function() { + jQuery("#dates, #date").blur(function() { + jQuery('#adminForm').submit(); + }); + }); + }, + + toggleDiv: function(spanId) { + if (jQuery(window).width() < 767) { + jQuery("#" + spanId).toggle("slow"); + } + else { + jQuery("#" + spanId).toggle(); + } + jQuery(".report_search_input").toggleClass("active"); + }, + } +} + +var tjCommon = { + vendorLogoValidation: function() { + jQuery("#jform_vendor_logo").change(function(e) { + var file, img; + if ((file = this.files[0])) { + img = new Image(); + img.onload = function() { + + if (file.size > vendorAllowedMediaSize) { + alert(allowedMediaSizeErrorMessage); + jQuery("#jform_vendor_logo").val(''); + return false; + } + + if (this.width < 445 || this.height < 265) { + alert(allowedImageDimensionErrorMessage + this.width + "px X " + this.height + "px"); + } + }; + + img.onerror = function() { + alert(allowedImageTypeErrorMessage + file.type); + jQuery("#jform_vendor_logo").val(''); + return false; + }; + + img.src = _URL.createObjectURL(file); + } + }); + }, + + initVendorFields: function() { + jQuery('.subform-repeatable-group .gateway_name').on('focus', function() { + previous = this.value; + }); + jQuery('.subform-repeatable-group .gateway_name').each(function() { + jQuery(this).trigger("change"); + }); + }, + + getGatewayFields: function(ele) { + let count = 0; + jQuery('.subform-repeatable-group .gateway_name').each(function() { + if (this.value === ele.value) { + count++; + } + }); + + if (count > 1) { + jQuery(ele).val(); + return false; + } + + let userObject = { + 'payment_gateway': ele.value, + 'parent_tag': ele.name.replace('[payment_gateways]', "") + }; + + tjCommon.generateGatewayFields(userObject, ele.id); + }, + + generateGatewayFields: function (userObject, eleId) { + JSON.stringify(userObject); + jQuery.ajax({ + type: "POST", + dataType: "json", + data: userObject, + url: Joomla.getOptions('system.paths').base + "/index.php?option=com_tjvendors&task=vendor.generateGatewayFields", + success: function (response) { + let $thisId = jQuery('#' + eleId); + $thisId.closest('.subform-repeatable-group').find('.payment-gateway-parent').empty(); + + if (response) { + response.forEach(function(data) { + $thisId.closest('.subform-repeatable-group').append("
" + data + "
"); + }); + } + else if (!response && userObject.payment_gateway != "") { + var error_html = Joomla.JText._('COM_TJVENDOR_PAYMENTGATEWAY_NO_FIELD_MESSAGE'); + $thisId.closest('.subform-repeatable-group').append("
" + error_html + "
"); + } + } + }); + } +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000..2453fb4c --- /dev/null +++ b/tslint.json @@ -0,0 +1,143 @@ +{ + "rulesDirectory": [ + "node_modules/codelyzer" + ], + "rules": { + "arrow-return-shorthand": true, + "callable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "deprecation": { + "severity": "warn" + }, + "eofline": true, + "forin": true, + "import-blacklist": [ + true, + "rxjs/Rx" + ], + "import-spacing": true, + "indent": [ + true, + "spaces" + ], + "interface-over-type-literal": true, + "label-position": true, + "max-line-length": [ + true, + 140 + ], + "member-access": false, + "member-ordering": [ + true, + { + "order": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-super": true, + "no-empty": false, + "no-empty-interface": true, + "no-eval": true, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-misused-new": true, + "no-non-null-assertion": true, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unnecessary-initializer": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "prefer-const": false, + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "typeof-compare": true, + "unified-signatures": true, + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], + "no-output-on-prefix": true, + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true + } +} From 6e149ab9e74d0f7c0872af2ac7d8880eb0162541 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Sat, 1 Jun 2019 16:24:49 +0530 Subject: [PATCH 2/2] Task : Gulp automation & linting for com_tjvendors --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 61754354..62808661 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,10 @@ } }, "lint-staged": { - "./src/com_tjvendors/media/ts/**/*.js": "tslint", + "./src/com_tjvendors/media/ts/*.js": "tslint", "./src/com_tjvendors/**/*.html": "htmlhint --config htmlhint.conf", - "./src/com_tjvendors/media/css/**/*.css": "stylelint", - "./src/com_tjvendors/media/scss/**/*.scss": "stylelint --syntax=scss" + "./src/com_tjvendors/media/css/*.css": "stylelint", + "./src/com_tjvendors/media/scss/*.scss": "stylelint --syntax=scss" }, "dependencies": {}, "devDependencies": {