...

Hi! I’m Starx

experienced Software Developer. And this is my blog
Start Reading About me
Blog Page
March 2, 2012

Arial Black – Websafe Font?

Question by User123

Is Arial Black web safe?

I have read it is but when I put it in my font declaration, I am being given Times New Roman back.

Does anyone know why?

Kind Regards,

Ben

Answer by Starx

I dont know how you declared your font. Normally, it should not happen the way you are saying it did.

Make sure you are declaring the font in this way

font-family: 'Arial Black', Gadget, sans-serif;

Here are some other common patterns on web safe fonts, for you to choose from.

font-family: Arial, Helvetica, sans-serif;
font-family: 'Arial Black', Gadget, sans-serif;
font-family: 'Bookman Old Style', serif;
font-family: 'Comic Sans MS', cursive;
font-family: Courier, monospace;
font-family: 'Courier New', Courier, monospace;
font-family: Garamond, serif;
font-family: Georgia, serif;
font-family: Impact, Charcoal, sans-serif;
font-family: 'Lucida Console', Monaco, monospace;
font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
font-family: 'MS Sans Serif', Geneva, sans-serif;
font-family: 'MS Serif', 'New York', sans-serif;
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
font-family: Symbol, sans-serif;
font-family: Tahoma, Geneva, sans-serif;
font-family: 'Times New Roman', Times, serif;
font-family: 'Trebuchet MS', Helvetica, sans-serif;
font-family: Verdana, Geneva, sans-serif;
font-family: Webdings, sans-serif;
font-family: Wingdings, 'Zapf Dingbats', sans-serif; 

Source

Read more

frustrated db query and getvalue in a view after failure

Question by Pablov Ivanov

After I print out a query of a list of user satisty some condition from my database I have got the following array

Array ([0]=>Array([users]=>Array([id]=>6 [username]=>sam [fullname]=>Sam Ho)))

But when I try to get the value in a view like
someone['fullname'] I have got nothing then

<?php
    foreach($users as $row)
    {
        ?>
        <h1>His name is <?php echo strtoupper($row['fullname']);?></h1>
        <?php
    }
?>

Answer by Starx

In your case, the following should work perfectly.

foreach($array as $key => $val) {
   echo $val['users']['id'];
   // and so on
}

I am assuming $array as your main array of records.

Read more

how to read the object value in jquery

Question by user1195292

I want to read the object value in jquery but if am trying to use text function it shows me blank.The code is as below :

var param = $(this).find('parameter');

                  if(param.attr('pathvar')){
                    var pathvar=param.attr('pathvar');
                    url=url+'/'+pathvar
                    alert(url);
                  }
                  var numLow = 0;
                  var numHigh = (param.length-1);                  
                  var adjustedHigh = (parseFloat(numHigh) - parseFloat(numLow)) + 1;
                  var numRand = Math.floor(Math.random()*adjustedHigh) + parseFloat(numLow);   
                      alert(numRand); 
                      alert("here");  
                      alert(param);   
                  var selParamVal = param.eq((numRand)).text();
                   alert(param.eq((numRand)).text());
makeAPIRequest(selParamVal,requestType,url);                                 
                }
          });

        } 
    }  

function makeAPIRequest(reqjson,reqType,url){
    var json = JSON.stringify(reqjson); 

    $.ajax({
         url:url,    
         type:reqType,
         processData: false,  
         contentType:"application/json; charset=utf-8",
             data:reqjson,
         headers:{sm_user:'999999300'},
         success:function(data){
           var resp = JSON.stringify(data);
           var textarea = jQuery('#responseEl');
           textarea.text(resp);  
        },
       error:function(jqXHR, textStatus, errorThrown){
            var textarea = jQuery('#responseEl');
            textarea.text(jqXHR.responseText);
     }
    });

  }

The selParamVal is blank.And if even if i add numRand as [numRand] it does not make an ajax call
Trying to read this xml :I am able to get upto url but fails in parameter

<?xml version="1.0" encoding="UTF-8"?>
<apis xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
    <api name="getFieldType" requesttype ="GET">
         <url>/fieldtype/</url>       
         <parameters>
             <parameter><![CDATA[fieldtype=textbox&fieldId=8668376496495]]></parameter>
             <parameter><![CDATA[fieldtype=number&fieldId=93468613046610]]></parameter>
             <parameter><![CDATA[fieldtype=multiline&fieldId=1367537832000]]></parameter>
          </parameters>
    </api>
</apis>

Answer by Starx

I think your problem is this

$(this).find('parameter');

It is neither an identifier nor a class selector, or an element name

Changes it to appropriate selector. Like the attribute below will select class parameter

$(this).find('.parameter');

Update: I got your code working. The problem seems to be when $(this) was not referencing to the xml data.

Check Here

Read more

How to remove blue border around the button in Firefox?

Question by masato-san

I’m using Firefox 10, Windows 7 and not sure older version but when I clicked the button, the blue border appears around the button.

I created the example below.

http://jsfiddle.net/dEvKb/58/

I removed the dotted line with css below but I also do not want blue border. I can’t figure how to remove it or is it even possible to remove?

button::-moz-focus-inner,
input[type="button"]::-moz-focus-inner
{
    border: none;
    outline: none;
}

below didn’t work…

input[type="button"]:visited
{
    outline: none;
    border: none;
}

This is evil blue border I’m talking about.

enter image description here

Answer by Starx

That is the UI of Firefox, whether themed or none. Not something you got from coding.

If it is troubling you so much you can reset it and define your own style. Here is a reset rule for that.

button { background: none transparent; border: none; }

Check here

And you can add your styling on it later on. Here is a demo for that. You can define custom states for hover, visited , active like the way you want.

Read more

Press button to "Bold" & press again to "Unbold"

Question by Jhon

I am new to javascript. I want to make a button in html using javascript. When user try to press the button
the specific <#id> is going to be “Bold” and press again to “Unbold”.

How can I do this ? please refer any helping material.
Thanks !

Answer by Purmou

Since the learning experience is vital, especially for Javascript, I’ll guide you in the right direction.

First, you should look into event binding and mouse event handling with jQuery. You can do some powerful stuff with this knowledge, including what you would like to do.

Second, look into basic jQuery selectors. It’s not hard to learn the simple CSS-based selectors that you can use to select your desired id.

Third, look at the css() function of jQuery, which falls under jQuery’s CSS category. You can use this to set different properties of elements, including font weight.

Answer by Starx

I am guessing, you are trying to build something like RTE, So, applying class to give bold effect would be better and efficient solution to this.

It can be done as simple as this

$(".boldtrigger").click(function() { //boldTrigger being the element initiating the trigger
    $(".text").toggleClass("bold");  //text being the element to where applied to it.
});

CSS

.bold { font-weight: bold; }

Demo

Read more
March 1, 2012

setting overflow hides li bullets (overflow property conflict with list-style)

Question by missybecks

setting overflow and text-overflow property makes the li hide bullets. I’ve tried putting the bullets “inside” but it still didn’t show bullets. Plus I’d prefer to put it “outside”

ul.hbox_poplist {
    list-style: circle url('/img/bpt_clear.png');
}

ul.hbox_poplist li {
    margin: 0 0 8px;
    max-height:32px;
    text-overflow: ellipsis;
    overflow-y: hidden;
}

does anyone know any solution to this?

Answer by Diodeus

Using a CSS background is much more dependable across browsers than using list-style-image for custom bullets. Controlling the position of a list-image is quite difficult on its own.

Something like:

.bullets {
  background-image:url(/img/bpt_clear.png); 
  background-repeat:no-repeat; 
  padding-left:30px; 
  margin-left:-30px;
}

See: http://preview.moveable.com/JM/ilovelists/

Answer by Starx

I remember this problem long before. Yes, its better to follow to what @Diodeus suggests, but adding padding-left to the ul, miraculously solved my problem a couple of times.

Read more

Displaying elements inline with HTML?

Question by Shahab

I am trying to create a web application and in it I want these two fields to display inline(check the Image below). Now the BugID is an <input> element and the Description is a <textarea>. Currently I have this:

<div class="some">
  <h3 id="title1">Bug ID:<span class="required">*</span></h3>
  <h3 id="title">Enter Description:<span class="required">*</span></h3>
  <br/>
  <div class="inputs">
  <input size="8" maxlength="8" name="BugID" type="text" id="BugID" placeholder="Bug ID" style="width:100px" />
  <textarea rows="5" id="Summary" name="summary" placeholder="Please Enter a Summary of the Bug" ></textarea>
   </div>
   </div>

And the CSS:

.inputs input, textarea{
      display:inline;
}

Is this wrong? How should I be doing this?

Current Implementation

Answer by JJS

Is this what you want?

   .inputs input, textarea{
          display:inline;
          float:left;

    }

Answer by Starx

I will suggest a better option. Update your markup structure to a more structure one. May be something like this

<div class="some">
    <div class="input">
      <h3 id="title1">Bug ID:<span class="required">*</span></h3>
      <input size="8" maxlength="8" name="BugID" type="text" id="BugID" placeholder="Bug ID" style="width:100px" />
    </div>
    <div class="input">
      <h3 id="title">Enter Description:<span class="required">*</span></h3>
      <textarea rows="5" id="Summary" name="summary" placeholder="Please Enter a Summary of the Bug" ></textarea>
    </div>
</div>​

Now the fix: One liner CSS

.input { display: inline-block; display: table-cell; vertical-align: top; }​

DEMO

Read more

Place tipsy in place where every div occure

Question by Cameleon

Javascript:

    <script type="text/javascript">
  $(function() { $('.cat_name').tipsy({gravity: 's'}); });
</script>   

TPL Smarty:

<div id="content_inside">
<a href="#" title="Test" id="1" class="cat_name">
<div class="box">
</div>
</a>
<a href="#" title="Test2" id="2" class="cat_name">
<div class="box">
</div>
</a>
</div><!-- content end -->

CSS:
#content_inside {
    height: 500px;
    width: 950px;
    padding:5px;
}

.box {
    width: 300px;
    height: 261px;
    padding: 5px;
    float: left;
}

.box {
    margin: auto;
    background: url(../images/box1.jpg) no-repeat top left;
}

I need to place tipsy in upper center of every div link, how to do that?, for now tipsy are shown always at left side. Example of how is, and how need to be in img: http://oi43.tinypic.com/adka3t.jpg

Answer by Starx

There is an offset options in tipsy, which offsets from the elements.

$('.cat_name').tipsy({gravity: 's', offset: 20 });
Read more

Confusion about Transparent Background in CSS

Question by sandbox

I know the transparency can be attained using value rgba(221, 221, 221, 0.6). I want to know what does 221,221,221,0.6 denotes??

Answer by BoltClock

The rgba() color notation allows you to specify the red, green, blue and alpha values for a color respectively. That means 221 red, 221 green, 221 blue and 0.6 (60%) alpha.

The RGB values have a range of 0 to 255; this is the standard range for the RGB color model and notation (this is explained in the preceding section for the rgb() notation). The higher the value for a color component, the more that color component will be blended into the resulting color.

The alpha value has a range of 0 to 1, with decimal values. It is what determines the opacity (or transparency) of the color. The higher the value, the more opaque the resulting color will be.

Answer by Starx

Seems, like you are not clear about the concept of color values.

Every color values is represented by 8bit length. That is 11111111 which translates to 256, but since 0 is the starting digit. The max value in 255.

Whenever defining color, there are 3 major colors, red,green and blue, which is what rgb stands for. Since, CSS3 it give us the possibility of transparency, by implementing one more property alpha which represent the opacity of the color value. So, the new command become rgba

Now,

r: 255 stands for max red color

g: 255 stands for max green color

b: 255 stands for max green color

When all the color values have maximum values, the resulting color is white, which is exactly what happens, when you are spinning a color wheel.

Now, comes the alpha part. It is represent in percentage/100. So 1 would be completely opaque and 0 would be completely transparent.

Read more

Zendframework project shows xyz.com/public/ so how to remove public

Question by Zuber Surya

My zendFramework application on server shows

xyz.com/public/login

i want it like

xyz.com/login

how to achieve this ? is it possible to do with .htaccess file.

Thanks in advance

Answer by Starx

This is my answer from another question, but seems to fit in this question too. In the case you already have a .htaccess file inside public, use the htaccess solution from below.

The problem seems to be due to the root not being routed to /public.

  1. The proper way: You need to setup a vhost and point the root to the public directory.

  2. Another Way: You need to redirect every request inside public directory. The .htaccess for this file would be

    RewriteRule ^.htaccess$ - [F]
    
    RewriteCond %{REQUEST_URI} =""
    RewriteRule ^.*$ /public/index.php [NC,L]
    
    RewriteCond %{REQUEST_URI} !^/public/.*$
    RewriteRule ^(.*)$ /public/$1
    
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^.*$ - [NC,L]
    
    RewriteRule ^public/.*$ /public/index.php [NC,L]
    
Read more
...

Please fill the form - I will response as fast as I can!