I tried many times and searched this board, but I can't do a simple thing like this:
http://xs.to/xs.php?h=xs139&d=09201&f=menu676.gif
I want to render a menu like this:
item 1 | item 2 | item 3 | .... etc...
"item 1" AND pipe character "|" = sIFR rendered text
HTML:
<div id="menu"> item 1 <span class="pipe"> | </span> item 2 <span class="pipe"> | </span> </div>
This part is within my HTML at the very bottom:
<script type="text/javascript">
var metaroman2 =
{ src: 'shared/sifr/metaroman2.swf' , ratios:[....7, 1.32....] };
sIFR.activate(metaroman2);
sIFR.replace(metaroman2, {
selector: '#menu', css: ['.sIFR-root { background-color: #F9F9F9; color: #1F2956; font-weight:bold;}'], wmode: "transparent" });
sIFR.replace(metaroman2, {
selector: '.pipe', css: ['.sIFR-root { background-color: #F9F9F9; color: #1F2956;}'], wmode: "transparent" });
</script>
CSS:
.sIFR-active .pipe {
visibility : hidden; line-height : 1em; margin-left : 5px; margin-right : 5 px;
}
.sIFR-active #menu {
visibility : hidden; line-height : 1em;
}
The problem is, that the "|" character is beeing put right at the end of the word with no spacing between (5px).
How i want it:
item 1 [5px space] | [5px space] item 2
What i get:
item 1|item 2
OTHER METHOD:
If I try it with an image, the image doesnt get displayed at all. ("sIFR.fitExactly = true" has been set in sifr-config)
What I mean with "image": in stead of the pipe sign, an image which represents the pipe sign.
html:
<div id="menu"> item 1 <img src=...> item 2 <img src=...> </div>
css:
.sIFR-active #menu {
visibility : hidden; line-height : 1em;
}
script:
This part is within my HTML at the very bottom:
<script type="text/javascript">
var metaroman2 =
{ src: 'shared/sifr/metaroman2.swf' , ratios:[....7, 1.32....] };
sIFR.activate(metaroman2);
sIFR.replace(metaroman2, {
selector: '#menu', css: ['.sIFR-root { background-color: #F9F9F9; color: #1F2956; font-weight:bold;}'], wmode: "transparent" });
</script>
I'm sorry for the messy code, but I hope you can make some sense of it.
(edit: have been using sIFR for a few days, simple heading replacing with ratio's work perfectly but the above is beating me up)
wrap every menu item into separate element, and replace that with sIFR selector, don't replace pipes. wrap them into span and style only with CSS.
those replaced items and spans should all be floating block elements.
html:
<div id="menu">Item 1<span>|<span>Item2...
css:
#menu a , #menu span {
display: block;
float: left;
}
Related
i want to create tags for input data.(http://textextjs.com/manual/examples/ajax-with-filter-tags-and-autocomplete.html hear they creating tags using auto complete text box, but i don't want auto complete one)
hear is my code
<!DOCTYPE html>
<html>
<head>
<script src="jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#textBox").keyup(function() {
$("#message").val($(this).val());
});
});
</script>
</head>
<body>
<div>
TextBox 1 : <input type="textbox" id="textBox"></input>
TextBox 2 : <input type="textarea" id="message"></input>
</div>
</body>
</html>
hear it reflect data of textbox1 to textbox2.
now what i want is : if user enter any data(words) in textbox1 followed by space then that word should convert into tags in textbox2
First of all type=textarea is wrong. There's no such input like that. You must be using <textarea> instead of that. Secondly, why dont you use contentditable attribute? It works just like a text area but can take HTML, is supported in all browsers, and you can use it on any block element! So replace your second input with this:
TextBox 2 : <div class="target" contenteditable="true"></div>
Then, in your code,
$("#textBox").keypress(function (e) {
if (e.which === 32) {
$(".target").append("<a href='#' class='tag'>" + this.value + "</a>");
this.value = "";
}
});
(Disclaimer) I used the styles from SO's tags, like this :
body {
font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;
}
.tag {
color: #3E6D8E;
background-color: #E0EAF1;
border-bottom: 1px solid #b3cee1;
border-right: 1px solid #b3cee1;
padding: 3px 4px 3px 4px;
margin: 2px 2px 2px 0;
text-decoration: none;
font-size: 90%;
line-height: 2.4;
white-space: nowrap;
}
.tag:hover {
background-color: #c4dae9;
border-bottom: 1px solid #c4dae9;
border-right: 1px solid #c4dae9;
text-decoration: none;
}
Demo : http://jsfiddle.net/hungerpain/Wky2Z/
To add the tags to an array, have a variable called tags outside the keypress function :
var tags = [];
Then, in the keypress, you've got this if loop right? Push the new value into the array :
if (e.which === 32) {
$(".target").append("<a href='#' class='tag'>" + this.value + "</a>");
tags.push(this.value); //push the value in array
this.value = "";
}
Then, when you need to save it to DB, just join them :
tags.join("");
Then later, when you to retrieve them from DB next time, you could wrap those with the a (what we did in the keypress function)
Demo : http://jsfiddle.net/hungerpain/Wky2Z/1/
Try This:
$(document).ready(function () {
$("#textBox").keyup(function (e) {
if (e.keyCode == 32) {
$("#message").val($(this).val());
}
if ($(this).val() == '') {
$("#message").val('');
}
});
});
JSFIDDLE DEMO
I'm pretty new when it comes to jQuery so I need someone with a little more experience to help me out. I have a Nav with 3 items - Work About Contact
By default I have work selected but I would like it to change the active class to which ever is clicked. I have anchor scrolling working but I would like to have it highlight to the correct nav item when clicked. Also if it is possible when scrolling down the page and getting to the next section for it to change highlight automatically.
This is the jQuery I am using for the anchor scrolling.
<script>$(function() {
var main-nav = $("#main-nav"), pos = main-nav.offset();
$(window).scroll(function() {
if($(this).scrollTop() > (pos.top + 10) && $(this).scrollTop() < 15000 && main-nav.css('position') == 'static') { main-nav.addClass('fixed'); }
else if($(this).scrollTop() <= pos.top && main-nav.hasClass('fixed')){ main-nav.removeClass('fixed'); }
else if($(this).scrollTop() > 15000 && main-nav.hasClass('fixed')){ main-nav.removeClass('fixed'); }
})
});
</script>
<script>$(function() {
$('ul.nav a').bind('click',function(event){
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500,'easeInOutExpo');
/*
if you don't want to use the easing effects:
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1000);
*/
event.preventDefault();
});
});
</script>
Here is the CSS
#main-nav{
font: bold 12px 'Bitter', serif;
width: 145px;
float: right;
}
#main-nav li{
float: left;
list-style: none;
margin: 10px 2px 0 2px;
color: #c4c5c5;
}
#main-nav li:last-child{
margin-right: 0;
}
#main-nav a{
text-decoration: none;
color: #c4c5c5;
}
#main-nav a:hover{
text-decoration: none;
color: #919292;
}
#main-nav a.active{
color: #919292;
}
Here is the HTML
<div id="main-nav" class="">
<ul class="nav">
<li><a class="active" href="#work">Work</a></li>
<li>/</li>
<li>About</li>
<li>/</li>
<li>Contact</li>
</ul>
</div>
If someone could help me out I would really really appreciate it!
Since you are using the active class to specify which anchor should be highlighted, you just need to make sure that the correct anchor has that class. Fixing that when the nav items are clicked is straightforward, in your $('ul.nav a').bind add:
$('ul.nav a').removeClass('active');
$(this).addClass('active');
Here is a jsbin.
To highlight the nav's as the page is scrolled you would just compare the scrollTop for the page with the offsets of elements in the DOM...similar to your current code in $(window).scroll.
I am using jquery dialog with query ui 1.8.7.custom.min.js
I need to customize the buttons on the the dialog and the location where they show up on the dialog. I was able for the most part to customize my dialog box but customizing buttons and its location had been tough cookie so far.
Please find screen shots and code below
HTML:
<style>
.ui-dialog, .ui-dialog-content {
border:1px solid #cde68c;
border-bottom:0px;
background-color: white !important;
color: #333;
font: 12px/180% Arial, Helvetica, sans-serif;
}
.ui-dialog-titlebar {
display:none;
}
#ui-dialog-title-dialog {
color: yellow !important;
text-shadow: none;
}
.ui-dialog-buttonpane {
border:1px solid #cde68c;
border-top:0px;
margin-bottom: 1%;
}
</style>
<div id="dialog">
<p><span id="emailNotice"></span></p>
</div>
Javascript:
$j(document).ready(function() {
$j('#dialog').dialog('open');
$j('#emailNotice').html('show some notice text abcd');
$j('#dialog').dialog({
modal:true,
autoOpen: false,
width: 600,
buttons: {
"Ok": function() {
$j(this).dialog("close");
},
"Cancel": function() {
className: 'cancelButtonClass',
$j(this).dialog("close");
}
}
});
});
I want to be able to position buttons left , right , top / bottom etc
You can always pass an empty object for the buttons property. You would then add your buttons directly in your "dialog" div. Of course, this would mean you'd have to handle the button click events manually.
Rough example:
<div id="dialog">
<p><span id="emailNotice"></span></p>
<button id="myButton">Submit</button>
</div>
Javascript:
$j('#dialog').dialog({
modal:true,
autoOpen: false,
width: 600,
buttons: {}
}
});
<!-- language: lang-js -->
buttons: [
{
text: "Delete that",
className: 'deleteButtonClass',
click: function() {
alert('foobar');
}
}
Find in jquery-ui-1.10.0.custom.css the class bellow and remove float: right;
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
float: right;
}
Tested in jquery-ui-1.10.0.custom.css not in jquery-ui-1.8.7.custom.css
I have a line like this in my view:
<div class="contact">
<h6>#Model.Salutation</h6><h3>#Model.FirstName #Model.LastName</h3>
</div>
I am trying to achieve a Mr Tommy Jones, while Mr in a different formatting.
Such as below:
.contact h3 {
font-size: 1.1em;
}
.contact h6 {
font-size: 0.85em;
color: gray;
}
However I get a line break between Mr and rest, what do I have to do?
You have h6 tag followed by h3 tag. I'm thinking...is this a true header text? Are you using tags because of formatting instead of meaning?
Try to write:
<div class="contact">
<span class="title">#Model.Salutation</span><span class="name">#Model.FirstName #Model.LastName</span>
</div>
With following CSS (update to match required formatting):
.contact .title
{
font-size: 0.85em;
color: gray;
}
.contact .name
{
font-size: 0.85em;
font-weight: bold;
}
If you're using HTML 5 tags you may include microdata informations and use different tags too. Look this example (just updated with microdata):
<div class="contact" itemscope itemtype="http://schema.org/Person">
<span itemprop="title">#Model.Salutation</span>
<span itemprop="name">#Model.FirstName #Model.LastName</span>
</div>
Your CSS may be changed to:
div[itemtype="http://schema.org/Person"] > span[itemprop="title"]
{
font-size: 0.85em;
color: gray;
}
div[itemtype="http://schema.org/Person"] > span[itemprop="name"]
{
font-size: 0.85em;
font-weight: bold;
}
All h* are by default block elements, simply meaning that they will occupy a whole width of the container, pushing things to the left and right of it.
try adding display:inline to your h6 and h3
.contact h6, .contact h3 { display:inline }
h3 and h6 are both blocking elements, so either you change the display property of both to inline (which I don't recommend) or change your markup like this:
<div class="contact">
<h3><span class="salutation">#Model.Salutation</span> #Model.FirstName #Model.LastName</h3>
</div>
Styling only the span element.
Another possibility - if the information about «salutation» is not particular relevant in the context but it's just used to introduce the name for visualization purpose - is to use pseudoelements and place there that information like so:
<div class="contact">
<h3 data-salutation="#Model.Salutation">#Model.FirstName #Model.LastName</h3>
</div>
and the CSS
.contact h3 {
font-weight: bold;
}
.contact h3:before {
content: attr(data-salutation);
padding-right: 1em;
font-weight : normal;
}
I'm trying to get a link in a truetype fornt with sIFR3. It's working fine for all ordinary <h1> and <h2> items, but not for links within a <h2>. sIFR is replacing the <a> correctly, but the result is invisible. When I click the area where the text should be, it follows the link. Even with a pointer cursor. But where's my text?
Replacer:
sIFR.replace(vagroundbtf, {
selector: '#summary_normalx h2'
, css: [
'.sIFR-root { color:#000000; font-weight : bold;} a {color:#333333; text-decoration: none;} '
]
,wmode: 'transparent'
});
HTML-snippet:
<div id="summary_normal">
<div id="article_92" class="entry clearing">
<div id="summary_normalx">
<h2>
This is the title
</h2>
:
BTW: when I remove the css-clause, links are visible in the right font but in default look (blue underlined).
Any ideas?
Roel
try this:
sIFR.replace(vagroundbtf, {
selector: '#summary_normalx h2'
, css: [
'.sIFR-root { color:#000000; font-weight : bold;}',
'a {color:#333333; text-decoration: none;}'
]
,wmode: 'transparent'
});
btw. I do prefer Cufón over sIFR nowadays