Currently, I'm working on a plugin that uses custom formats. Unfortunately, I can't use classes as the output HTML has to use inline styles.
I'm using declarations like:
a.formatter.register("dotted", {
inline : 'span',
styles : {
borderStyle : 'dotted',
borderWidth : '1px',
}
});
a.formatter.register("dashed", {
inline : 'span',
styles : {
borderStyle : 'dashed',
borderWidth : '1px',
}
});
Problem I: I want to use formats that impact each other. What I mean is:
User clicks on option "dashed border"
-> if the selection already has a border-width set, don't touch. If not set, set border-width: 1px;
-> no matter what is currently set, override border-style: dashed;
User clicks on option "dotted border"
-> if the selection already has a border-width set, don't touch. If not set, set border-width: 1px;
-> no matter what is currently set, override border-style: dotted;
User clicks on "thick border"
-> If border-style is already set, don't touch. If not set, set border-style: solid;
-> no matter what is set, override border-width: 3px;
How can I read and filter the current CSS styles that are used for the current selection? In my example, a is the instance of the editor which is passed to the function when clicking a button. Please don't confuse my question with this one because it is no copy & paste action, so I cannot use that objects here.
Problem II: How to remove these styles as it could be a mixture of different combinations?
At the moment, the only idea I have to solve it is to create an array with all possible values and loop thru these, like
for (var i = 0; i < value.length; i++) {
var cssobj = {
inline : 'span',
styles : {
}
}
eval("cssobj.styles." + cssattr + "= \"" + value[i] + "\"");
a.formatter.register("tempformat", cssobj);
a.formatter.remove("tempformat");
a.formatter.unregister("tempformat");
}
which I find is an extremely ugly solution, and also not very performant.
Any other ideas?
Related
As the title, it's possible to to apply a default color to all text of a TextFlow component?
TextFlow textFlow = new TextFlow();
textFlow.setId("supertextflow");
// Somewhere else in the code
textFlow.getChildren()
.add(new Text("Dynamic added text! OMG!"));
I tryed different solution but none of them works
#supertextflow {
-fx-text-fill: red;
}
#supertextflow * .text{
-fx-fill: red;
}
#supertextflow > * > .text {
-fx-fill: red;
}
I know that Text is another component, but why i can't style it from it's parent?
Well you can't do that with Text cause it's style class doesn't have fill css rule if you look at the JavaFX CSS Reference Guide. So I would suggest to leave the Text and use Label instead. If you do then you could use the css rule below :
#supertextflow > .label {
-fx-text-fill: blue;
-fx-font-size : 20px;
}
In case you want to keep using Text you will have to set each element (Text) inside the FlowPane a specific id (ex. #customText) and then use it to set the CSS rule like below :
#supertextflow > #customText {
-fx-fill: red;
-fx-font-size : 20px;
}
Edit : As James_D mentioned on the commends below you should use Type Selector (I am guessing that's the correct term) on the CSS rule in order to style all the Text nodes inside your TextFlow without needed to set any ids on them :
#supertextflow > Text {
-fx-fill: red;
-fx-font-size : 20px;
}
I added a new link class to the TYPO3 (6.2.14) RTE like shown below
RTE {
classesAnchor {
myNewClass {
class = very-long-class additional-class
type = page
}
}
default {
proc.allowedClasses := addToList(very-long-class additional-class)
buttons {
link.properties.class.allowedClasses := addToList(very-long-class additional-class)
}
}
}
Everything works fine and the editor can choose the new link style when he selects some text in the RTE and creates a link (shown below).
My problem is, that the link name is not really understandable. Is it possible to define a name or label for the link (changing the class-name is not an option), so the "Style" field will show a more understandable name?
The names are set in "classes" of the RTE object. The value are any CSS-styles to give a hint, how it looks like.
RTE.classes {
your-class-name {
name = Your Awesome Class Name
value = margin: 2px; padding: 2px; background: #00b5dc; color: #fff; border: 1px solid #3a6674;
}
}
I am using AngularStrap, (TypeAhead), trying to make the substring in the matched items to stand out, like either make them bold (like jquery autocomplete) or change the background of the characters ta different color
California
Technical
I thought this should be possible by changing css (if I know they have a selector for the matched substring) Or use of template/$templatecache
no luck so far
EDIT: In this plnkr I can see the drop down menu items have user input highlighted/bolded but cannot see why and how it happens:
<input type="text" class="span3" ng-model="typeaheadValue" bs-typeahead="typeahead">
plnkr -> http://plnkr.co/edit/Yjff9DiLnGqi2x1E5D2q?p=preview
The typeahead dropdown menu items can be styled through .dropdown-menu a. Matched text is regexed' to <strong>match></strong> i.e style those through .dropdown-menu a strong. Example :
/* style the dropdown items */
.dropdown-menu a {
font-family : 'courier new';
font-size: 110%;
}
/* styling matched text */
.dropdown-menu a strong {
color: white;
background-color: red;
}
forked plnkr -> http://plnkr.co/edit/LpdRiH9DxeRiAib3MOnn?p=preview
I'm using the jeditable plugin for making some values editable. I noticed that when a value is empty the default text 'Click top edit' appears which I don't want. But I still want to make that field editable too. How to manage this?
I noticed a suggestion at http://www.datatables.net/forums/discussion/5865/jeditable-and-default-click-to-edit/p1, but that does not seem to work - at least not for me; when using the placeholder : "" the field is not editable anymore.
My related code:
$('.edit').editable('edit_save.php', {
cancel : 'Cancel',
submit : 'OK'
});//$('.edit').editable('jeditable_save.php', {
Without any text to fill it, the editable element needs to be an inline block with height and width like this:
.edit {
border: 1px solid red;
display: inline-block;
min-height: 20px;
min-width: 100px;
}
and set a blank placeholder like you mentioned:
$('.edit').editable(function (value, settings) {
return value;
}, {
cssclass: 'editing',
placeholder: '',
});
See this fiddle http://jsfiddle.net/chrisdillon/37JqF/
I tried add this row: placeholder:'
&
nbsp;' and it works.
If you can add this row, you see your input is empty.
$('.edit').editable('Something', {
something,...
placeholder:' ',
})
I'm having problems with IE9 ignoring the select borders when printing a multiple select.
Here's how to recreate the problem:
Open IE9 on Windows 7.
Go to w3schools's multiple select edit page.
Now highlight the options and copy/paste until there is a long list of duplicates.
Then remove the size attribute.
Click on "Edit and Click Me" so that the page reloads and you now have your modified select in the second panel.
Now, print the document (even using the XPS viewer).
For me, all of the options are printed on the page, even though the select is only 4 option elements tall. This still happens to some degree if you leave the "size" attribute at the default value of 2, but it's far more obvious when it is changed or removed.
Is anyone else experiencing this? Is this an IE bug? Does anyone know of a workaround?
You can work around this by viewing the site in IE9's compatibility mode. Usually IE will determine that it cannot display a site properly and give you the option to turn on compatibility mode from within the address bar but sometimes you need to explicitly set it.
How to turn on compatibility mode - http://www.sevenforums.com/tutorials/1196-internet-explorer-compatibility-view-turn-off.html - I used the first one in method 2.
There doesn't seem to be any CSS solution for this. Instead, I wrote a small jQuery script that copies the <select multiple> contents into a <div>, so that it can be printed. Then I applied some CSS to make it look like a select, and only show the copy when actually printing.
Script:
//jQuery required
$(function() {
if(!$.browser.msie) return false;
$('select[multiple]').each(function() {
$lPrintableDiv = $('<div data-for="' + this.id + '" />').addClass($(this).attr('class')).addClass('printable');
//update printable on changes
$(this).after($lPrintableDiv).change(function($aEvent){
updatePrintable($aEvent.target);
});
//run once on load
updatePrintable(this);
});
});
function updatePrintable($aTarget) {
var $lSelect = $($aTarget);
var $lSelected = $($aTarget).val();
var $lPrintable = $('[data-for="'+$aTarget.id+'"]');
$($lPrintable).width($lSelect.width()).height($lSelect.height());
$($lPrintable).html('');
$($aTarget).children().each(function($lElm){
$lVal = $(this).val();
$lLabel = $('<label />').text($lVal);
$lOption = $('<input type="checkbox" />').val($lVal);
if($(this).is(':selected'))
$lOption.prop('checked', true);
$lPrintable.append($lOption).append($lLabel);
});
}
CSS:
.printable {
border: 1px solid grey;
display: none;
overflow: auto;
}
.printable label {
display: block;
font: .8em sans-serif;
overflow: hidden;
white-space: nowrap;
}
.printable [type="checkbox"] {
display: none;
}
.printable [type="checkbox"]:checked + label {
background: #3399ff;
color: white;
}
#media print {
select[multiple] { display: none; }
.printable { display: inline-block; }
.printable [type="checkbox"]:checked + label { background: grey; }
}
Also see the jsFiddle and original post about this fix