Sha256: ac8cb3e9326e272e54eec4eefbf67a106be8f5576b03659d14dcdb26eda3cf94
Contents?: true
Size: 1.33 KB
Versions: 18
Compression:
Stored size: 1.33 KB
Contents
'use strict'; (function () { /* * Display a placeholder for empty CMS attributes. The placeholder can be overwritten by * defining a +data-scrivito-editors-placeholder+ HTML attribute on the DOM element generated * by +scrivito_tag+. * * For example: * scrivito_tag(:div, @obj, :my_attribute, data: { scrivito_editors_placeholder: 'My text' }) */ scrivito.editors.applyPlaceholder = function ($cmsField) { if (!$cmsField.is('data-scrivito-editors-placeholder')) { var fieldName = $cmsField.attr('data-scrivito-field-name'); var defaultPlaceholder = 'Click to edit the “' + fieldName + '” attribute ...'; $cmsField.attr('data-scrivito-editors-placeholder', defaultPlaceholder); } applyBrowserWorkarounds($cmsField); }; // Chrome: fixes span element issue: sometimes the focus is set, but the element receives no input // Firefox: in combination with CSS, helps positioning the cursor at the correct position function applyBrowserWorkarounds($cmsField) { $cmsField.on('focus', function () { if ($cmsField.is(':empty')) { $cmsField.text('_'); window.getSelection().selectAllChildren($cmsField.get(0)); $cmsField.text(''); // needed for IE11: make cursor blink window.getSelection().collapseToStart($cmsField.get(0)); } }); } })();
Version data entries
18 entries across 18 versions & 1 rubygems