sIFR 3 changeCSS problem - sifr

I just have a short question about switching the color of sifr objects on the fly with changeCSS:
The point is, that I'd like to change the color of the two headers whenever the user clicks on the "Switch style to..." on the upper right corner. Check the example page: www.capsule.hu/index2.html - and after clicking on the link nothing happens with sifr objects. Version is: sIFR, version 3, revision 436.
I'm using Kelvin Lucks styleswitcher script with some modifications (the script is hardly the same as here: http://www.digital-campaign.com/dc-example/) - on my current page I'm calling the sIFR.replace method whenever user changes the style (www.capsule.hu), but it seems a little bit slow for me, that's why I'd like to change.
Thanks for every help in forth,
Csongor

You can place the following in the body of the switchSifrColor function on your site:
$('h2').removeClass("sIFR-replaced");
sIFR.replace(helvetica, {
selector: 'h2',
wmode: 'transparent',
css: [ '.sIFR-root { color: #' + color + '; }' ]
});
The main change is that the css property is an array of strings, unlike the object that you were passing.
And a side-note: great work! The site looks very nice.
[Edit]
I guess this will prove more useful than calling replace again.
var css = '.sIFR-root {color:#ff1ff1;}';
$.each(sIFR.replacements['h2'], function() {
this.changeCSS(css);
});
I just tried it through Firebug and it looks great :)
[/Edit]

Related

ROR action-text. How to add text-align options to trix rich-text editor?

Im working on a project in ruby on rails (rails 6), that include a blog working with action-text and trix. I have to add few option to my rich-text editor and there is one that block me for few days.
I added buttons in my trix toolbar, for add more title tag options following this issue and everything worked fine.
But when i try to add text-align options (left, right, center) it dont work
I tried many thing, but i would expect this to work:
in application.js
Trix.config.textAttributes.alignLeft = {
style: { textAlign: "left" },
parser: function(element) {
return element.style.alignLeft === "left"
},
inheritable: true
}
then i insert it in the toolbar like this:
in application.js also
addEventListener("trix-initialize", function(event) {
var buttonHTML = '<button type="button" data-trix-attribute="alignLeft">RED</button>'
event.target.toolbarElement.
querySelector(".trix-button-group").
insertAdjacentHTML("beforeend", buttonHTML)
})
I tried both, with blockAttributes and textAttributes but dont work.
The button appear but does nothing.
What i want is that the div where my text is embed get style=" text-align: left"
Do you have an idea of how i could make it work? or maybe ideas, advices or lectures propositions?
(i saw somes issues in basecamp/trix github that speak about that(this one is really interesting), but its appear that the customized tag option, is not a good option and i didnt managed to make anything else work.
Thanks a lot

Is there any way to control the layout of the close button on a jQuery Mobile custom select menu?

I have a custom select menu (multiple) defined as follows:
<select name="DanceStyles" id="DanceStyles" multiple="multiple" data-native-menu="false">
Everything works fine except that I want to move the header's button icon over to the right AND display the Close text. (I have found some mobile users have a problem either realising what the X icon is for or they have trouble clicking it, so I want it on the right with the word 'Close' making too big to miss.) There don't seem to be any options for doing that on the select since its options apply to the select bar itself.
I have tried intercepting the create event and in there, finding the button anchor and adding a create handler for that, doing something like this (I have tried several variations, as you can see by the commenting out):
$('#search').live('pagecreate', function (event) {
$("#DanceStyles").selectmenu({
create: function (event, ui) {
$('ul#DanceStyles-menu').prev().find('a.ui-btn').button({
create: function (event, ui) {
var $btn = $(this);
$btn.attr('class', $btn.attr('class').replace('ui-btn-left', 'ui-btn-right'));
$btn.attr('class', $btn.attr('class').replace('ui-btn-icon-notext', 'ui-btn-icon-left'));
// $(this).button({ iconpos: 'right' });
// $btn.attr('class', $btn.attr('class').replace('ui-btn-icon-notext', 'ui-btn-icon-left'));
// // $btn.attr('data-iconpos', 'left');
$(this).button('refresh');
}
});
}
});
});
So I have tried resetting the button options and calling refresh (didn't work), and changing the CSS. Neither worked and I got weird formatting issues with the close icon having a line break.
Anyone know the right way to do this?
I got this to work cleanly after looking at the source code for the selectmenu plugin. It is not in fact using a button; the anchor tag is the source for the buttonMarkup plugin, which has already been created (natch) before the Create event fires.
This means that the markup has already been created. My first attempt (see my question) where I try to mangle the existing markup is too messy. It is cleaner and more reliable to remove the buttonMarkup and recreate it with my desired options. Note that the '#search' selector is the id of the JQ page-div, and '#DanceStyles' is the id of my native select element. I could see the latter being used for the id of the menu, which is why I select it first and navigate back up and down to the anchor; I couldn't see any other reliable way to get to the anchor.
$('#search').live('pagecreate', function (event) {
$("#DanceStyles").selectmenu({
create: function (event, ui) {
$('ul#DanceStyles-menu').prev().find('a.ui-btn')
.empty()
.text('Done')
.attr('class', 'ui-btn-right')
.attr("data-" + $.mobile.ns + "iconpos", '')
.attr("data-" + $.mobile.ns + "icon", '')
.attr("title", 'Done')
.buttonMarkup({ iconpos: 'left', icon: 'arrow-l' });
}
});
});
The buttonMarkup plugin uses the A element's text and class values when creating itself but the other data- attributes result from the previous buttonMarkup and have to be removed, as does the inner html that the buttonMarkup creates (child span, etc). The title attribute was not recreated, for some reason, so I set it myself.
PS If anyone knows of a better way to achieve this (buttonMarkup('remove')? for example), please let us know.
the way i achieved it was changing a bit of the jquery mobile code so that the close button always came to the right, without an icon and with the text, "Close"
not the best way i agree. but works..
I got a similar case, and I did some dirty hack about this :P
$("#DanceStyles-button").click(function() {
setTimeout(function(){
$("#DanceStyles-dialog a[role=button]").removeClass("ui-icon-delete").addClass("ui-icon-check");
$("#DanceStyles-dialog .ui-title").html("<span style='float:left;margin-left:25px' id='done'>Done</span>Dance Styles");
$("#DanceStyles-dialog .ui-title #done").click(function() {
$("#DanceStyles").selectmenu("close")
});
},1);
} );

Does sIFR support pseudo elements like :first-child?

I have the following in my sifr-config.js file:
sIFR.replace(avenir_book, {
selector: 'p:first-child',
css: '.sIFR-root { color: #782221; font-size:22px; }',
wmode: 'transparent'
});
But it doesn't work. I've verified that the same CSS works by testing it in my normal stylesheet. Does sIFR not understand this pseudo element, or does it need to be called in a special way?
Assuming you are using sIFR 3, :first-child is not supported as indicated by this page. However, sIFR can be made jQuery compatible, read more here.
Steps to replace parseSelector with
jQuery:
1 - Make sure you include the jQuery
JavaScript file.
2 - Remove all of the parseSelector
code at the bottom of sifr.js
3 - Add the following line:
var parseSelector = $;

can't get sIFR to work

I have tried using sIFR on a test page http://www.irwinassociates.eu/test.php without success. I have checked and re-checked but can't find what's wrong. I figure it's something simple. Can anyone help please? Thanks guys
I looked at the source of the page you linked to and didn't see any javascript code in place that calls the sIFR activate() or replace() functions. Follow the methods used on the official sIFR 3 demo page (view source) http://dev.novemberborn.net/sifr3/beta2/demo/
var font = { src: 'gillsans.swf' };
sIFR.activate(font);
sIFR.replace(font, {
selector: 'h1'
, css: ['.sIFR-root { color: #CCCCCC; }' ]
});

text-align syntax for sifr?

I'm having trouble finding usage/syntax for the text-align feature of sifr. This feature goes inside the flashvars parameter correct? So would it be something like:
sIFR.replace(fontname, {
selector: 'h1',
wmode: 'transparent',
flashvars: 'textalign=center'
});
I tried the above with no luck using r436 build.
Apparently you only need to edit the all.css file. Here's someone talking about this.
If you don't want to change the css styling of a root element, then you can specify what CSS selection you are applying your sifr is referring to with the sSelector
You're confusing sIFR 2 and 3 syntax. flashvars no longer exists, for sIFR 3 specify it in the replacement CSS:
sIFR.replace(fontname, { selector: 'h1', css: '.sIFR-root { textalign: center; }' });
You can also specify background-color here, so you don't need to use transparency.

Resources