Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert renaming to camelCase functions used in ERB - doesn't work #1044

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint camelcase: ["error", {properties: "never", ignoreGlobals: true}] */

module.exports = {
env: {
browser: true,
Expand Down Expand Up @@ -35,15 +37,15 @@ module.exports = {
},
globals: {
ADMIN_TRANSLATIONS: true,
CamaGetTinymceSettings: true,
cama_get_tinymce_settings: true,
CURRENT_LOCALE: true,
define: true,
I18n: true,
InitFormValidations: true,
init_form_validations: true,
hideLoading: true,
introJs: true,
ModalFixMultiple: true,
OpenModal: true,
modal_fix_multiple: true,
open_modal: true,
root_admin_url: true,
showLoading: true,
slugFunc: true,
Expand Down
18 changes: 10 additions & 8 deletions app/assets/javascripts/camaleon_cms/admin/_actions.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/* eslint-env jquery */
jQuery(document).on('ready page:changed', function() {
// initialize all validations for forms
InitFormValidations()
init_form_validations()
setTimeout(PageActions, 1000)
if (!$('body').attr('data-intro')) setTimeout(InitIntro, 500)
if (!$('body').attr('data-intro')) setTimeout(init_intro, 500)
})

// show admin intro presentation
function InitIntro() {
// eslint-disable-next-line camelcase
function init_intro() {
const finish = function() {
$.get(root_admin_url + '/ajax', { mode: 'save_intro' })
const layer = $('.introjs-overlay').clone()
const of = $('.introjs-tooltip').offset()
const c = $('.introjs-tooltip')
.clone().css($.extend({}, { 'min-width': '0', position: 'absolute', overflow: 'hidden', zIndex: 9999999 }, of))
const introTooptip = $('.introjs-tooltip')
const of = introTooptip.offset()
const c = introTooptip.clone()
.css($.extend({}, { 'min-width': '0', position: 'absolute', overflow: 'hidden', zIndex: 9999999 }, of))

$('html, body').animate({ scrollTop: $('body').height() }, 0)
setTimeout(function() {
Expand Down Expand Up @@ -99,8 +101,8 @@ Object.size = function(obj) {

// this is a fix for multiples modals when a modal was closed (reactivate scroll for next modal)
// fix for boostrap multiple modals problem
// eslint-disable-next-line no-unused-vars
function ModalFixMultiple() {
// eslint-disable-next-line no-unused-vars,camelcase
function modal_fix_multiple() {
const activeModal = $('.modal.in:last', 'body').data('bs.modal')

if (activeModal) {
Expand Down
81 changes: 41 additions & 40 deletions app/assets/javascripts/camaleon_cms/admin/_custom_fields.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// build custom field groups with values recovered from DB received in field_values
/* eslint-env jquery */
// eslint-disable-next-line no-unused-vars
function BuildCustomFieldGroup(fieldValues, groupId, fieldsData, isRepeat, fieldNameGroup) {

// eslint-disable-next-line no-unused-vars,camelcase
function build_custom_field_group(fieldValues, groupId, fieldsData, isRepeat, fieldNameGroup) {
if (fieldValues.length === 0)
fieldValues = [{}]

Expand Down Expand Up @@ -143,21 +144,21 @@ function CustomFieldColorpicker($field) {
$field.find('.my-colorpicker').colorpicker()
}

// eslint-disable-next-line no-unused-vars
function CustomFieldColorpickerVal($field, value) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_colorpicker_val($field, value) {
if ($field)
$field.find('.my-colorpicker').attr('data-color', value || '').colorpicker()
}

// eslint-disable-next-line no-unused-vars
function CustomFieldCheckboxVal($field, values) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_checkbox_val($field, values) {
if (values === 't') values = 1 // fix for values saved as true
if ($field)
$field.find('input[value="' + values + '"]').prop('checked', true)
}

// eslint-disable-next-line no-unused-vars
function CustomFieldCheckboxesVal($field, values) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_checkboxs_val($field, values) {
if ($field) {
const selector = values.map(function(value) {
return "input[value='" + value + "']"
Expand All @@ -166,8 +167,8 @@ function CustomFieldCheckboxesVal($field, values) {
}
}

// eslint-disable-next-line no-unused-vars
function CustomFieldDate($field) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_date($field) {
if ($field) {
const box = $field.find('.date-input-box')
if (box.hasClass('is_datetimepicker'))
Expand All @@ -177,8 +178,8 @@ function CustomFieldDate($field) {
}
}

// eslint-disable-next-line no-unused-vars
function CustomFieldEditor($field) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_editor($field) {
if ($field) {
const id = 't_' + Math.floor((Math.random() * 100000) + 1) + '_area'
const textarea = $field.find('textarea').attr('id', id)
Expand All @@ -188,23 +189,23 @@ function CustomFieldEditor($field) {
const inputs = textarea.data('translation_inputs')
if (inputs) { // multiples languages
for (const lang in inputs) {
tinymce.init(CamaGetTinymceSettings({
tinymce.init(cama_get_tinymce_settings({
selector: '#' + inputs[lang].attr('id'),
height: 120
}))
}
return
}
}
tinymce.init(CamaGetTinymceSettings({
tinymce.init(cama_get_tinymce_settings({
selector: '#' + id,
height: 120
}))
}
}

// eslint-disable-next-line no-unused-vars
function CustomFieldFieldAttrsVal($field, value) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_field_attrs_val($field, value) {
if ($field) {
value = value || '{}'
const data = typeof (value) === 'object' ? value : $.parseJSON(value)
Expand All @@ -214,43 +215,43 @@ function CustomFieldFieldAttrsVal($field, value) {
}
}

// eslint-disable-next-line no-unused-vars
function CustomFieldRadioVal($field, value) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_radio_val($field, value) {
if ($field) {
$field.find('input').prop('checked', false)
$field.find("input[value='" + value + "']").prop('checked', true)
}
}

// eslint-disable-next-line no-unused-vars
function CustomFieldTextArea($field) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_text_area($field) {
if ($field && $field.find('textarea').hasClass('is_translate'))
$field.find('textarea').addClass('translatable').Translatable(ADMIN_TRANSLATIONS)
}

// eslint-disable-next-line no-unused-vars
function CustomFieldTextBox($field) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_text_box($field) {
if ($field && $field.find('input').hasClass('is_translate'))
$field.find('input').addClass('translatable').Translatable(ADMIN_TRANSLATIONS)
}

// eslint-disable-next-line no-unused-vars
function CustomFieldUrlCallback($field) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_url_callback($field) {
if ($field && $field.find('input').hasClass('is_translate'))
$field.find('input').addClass('translatable').Translatable(ADMIN_TRANSLATIONS)
}

// eslint-disable-next-line no-unused-vars
function CustomFieldSelectCallback($field, val) {
// eslint-disable-next-line no-unused-vars,camelcase
function custom_field_select_callback($field, val) {
if ($field) {
const sel = $field.find('select.input-value')
if (!val) sel.data('value', sel.val()) // fix for select translator
if (sel.hasClass('is_translate')) sel.addClass('translatable').Translatable(ADMIN_TRANSLATIONS)
}
}

// eslint-disable-next-line no-unused-vars
function LoadUploadAudioField(thiss) {
// eslint-disable-next-line no-unused-vars,camelcase
function load_upload_audio_field(thiss) {
const $input = $(thiss).prev()

$.fn.upload_filemanager({
Expand All @@ -261,8 +262,8 @@ function LoadUploadAudioField(thiss) {
})
}

// eslint-disable-next-line no-unused-vars
function LoadUploadFileField(thiss) {
// eslint-disable-next-line no-unused-vars,camelcase
function load_upload_file_field(thiss) {
const $input = $(thiss).prev()

$.fn.upload_filemanager({
Expand All @@ -273,8 +274,8 @@ function LoadUploadFileField(thiss) {
})
}

// eslint-disable-next-line no-unused-vars
function LoadUploadPrivateFileField(thiss) {
// eslint-disable-next-line no-unused-vars,camelcase
function load_upload_private_file_field(thiss) {
const $input = $(thiss).prev()

$.fn.upload_filemanager({
Expand All @@ -286,8 +287,8 @@ function LoadUploadPrivateFileField(thiss) {
})
}

// eslint-disable-next-line no-unused-vars
function LoadUploadImageField($input) {
// eslint-disable-next-line no-unused-vars,camelcase
function load_upload_image_field($input) {
$.fn.upload_filemanager({
formats: 'image',
dimension: $input.attr('data-dimension') || '',
Expand All @@ -300,8 +301,8 @@ function LoadUploadImageField($input) {
}

// permit to show preview image of image custom fields
// eslint-disable-next-line no-unused-vars
function CamaCustomFieldImageChanged(field) {
// eslint-disable-next-line no-unused-vars,camelcase
function cama_custom_field_image_changed(field) {
if (field.val()) {
field.closest('.input-group')
.append(
Expand All @@ -315,14 +316,14 @@ function CamaCustomFieldImageChanged(field) {
field.closest('.input-group').find('.custom_field_image_preview').remove()
}

// eslint-disable-next-line no-unused-vars
function CamaCustomFieldImageRemove(field) {
// eslint-disable-next-line no-unused-vars,camelcase
function cama_custom_field_image_remove(field) {
field.val('')
field.closest('.input-group').find('.custom_field_image_preview').remove()
}

// eslint-disable-next-line no-unused-vars
function LoadUploadVideoField(thiss) {
// eslint-disable-next-line no-unused-vars,camelcase
function load_upload_video_field(thiss) {
const $input = $(thiss).prev()
$.fn.upload_filemanager({
formats: 'video',
Expand Down
3 changes: 2 additions & 1 deletion app/assets/javascripts/camaleon_cms/admin/_data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env jquery */
/* eslint camelcase: ["error", {properties: "never", ignoreGlobals: true, allow: ["cama_get_tinymce_settings"]}] */
// eslint-disable-next-line no-unused-vars
function CamaGetTinymceSettings(settings) {
function cama_get_tinymce_settings(settings) {
if (!settings) settings = {}
const def = {
selector: '.tinymce_textarea',
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/camaleon_cms/admin/_libraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jQuery(function() {
// panel can be a object: $("#my_form")
// if panel is null, then this will be replaced by body
// args: {validate_settings}
/* eslint-disable-next-line no-unused-vars */
const InitFormValidations = function(form, args) {
/* eslint-disable-next-line no-unused-vars,camelcase */
const init_form_validations = function(form, args) {
args = args || {};
// slug management
// you need to add class no_translate to avoid translations in slugs
Expand Down
11 changes: 6 additions & 5 deletions app/assets/javascripts/camaleon_cms/admin/_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* add events to links for open their content by ajax into modal
* use: <a class='my_link' href='mylink' title='my title' data-show_footer='true'>
* $(".my_link").ajax_modal({settings});
* settings: check OpenModal(settings)
* settings: check open_modal(settings)
*/
/* eslint-env jquery */
jQuery(function() {
Expand All @@ -14,7 +14,7 @@ jQuery(function() {
const def = { title: title || $(this).data('title'), mode: 'ajax', url: $(this).attr('href'), show_footer: $(this).data('show_footer') }
if ($(this).attr('data-modal_size')) def.modal_size = $(this).attr('data-modal_size')
const cSettings = $.extend({}, def, settings)
OpenModal(cSettings)
open_modal(cSettings)
e.preventDefault()
})
return this
Expand All @@ -39,7 +39,7 @@ jQuery(function() {
options.content = options.title
options.title = ''
}
OpenModal(options)
open_modal(options)
}
})

Expand All @@ -60,7 +60,8 @@ jQuery(function() {
* on_close: function executed after modal closed
* return modal object
*/
function OpenModal(settings) {
// eslint-disable-next-line camelcase
function open_modal(settings) {
const def = {
title: '',
content: null,
Expand Down Expand Up @@ -102,7 +103,7 @@ function OpenModal(settings) {
modal.on('hidden.bs.modal', function(e) {
settings.on_close(modal)
if (!$(e.currentTarget).attr('data-skip_destroy')) $(e.currentTarget).remove()
ModalFixMultiple()
modal_fix_multiple()
})

if (settings.zindex) modal.css('z-index', settings.zindex)
Expand Down
Loading