Solved

Help to customize jQuery icon position

Posted on 2014-01-24
5
920 Views
Last Modified: 2014-01-29
I'm working on the UI/UX for a listing/index landing page for audio files and using jQuery accordion to deal with what will eventually be an index of nearly 2000 titles or more spanning from 1958 to 2014.

see: http://dev.himalayanacademy.com/looklisten/inspired-talks

the top level headers are by year that the audio files were posted, these are the Accordion disclosure selectors.

I am not able to get the disclosure triangles

class="ui-icon ui-icon-triangle-1-s  
  # pointing down if the div is open and visible
class="ui-icon ui-icon-triangle-1-e  
  # pointing to the right when the div is collapsed by default

to align to the left of the header element.

Note that I'm not loading any jQuery UI scripts or UI CSS... which may be my problem, We don't use it that much so I'm thinking to keep the weight of the page down to just add just enough CSS to do the job.. but I'm missing something. even minified the ui is over 200k of js.

For now I'm running the styles in line for testing purposes...and to make sure I override the main styles.js for the site. later I'll put the css into the main style sheet.

Aside from the solution needed to get the triangle over to the left of the H3 element, I'll be all ears for any thoughts you have on the UX... I decided to avoid JS for the disclosure of the description of the audio file... and went with css-hover... as I'm not sure forcing users to click on a "More.." button to hide and show that div is any better than hover; and hover works with touch on smart phones... so seems like as good a UX as using JS to do the job... It also makes it simpler for me to generate the lists from the database later on, because I won't have to dynamically apply unique div ID's throughout the index which I think would be required to make the JS work using a button onclick trigger. OTHO if you have a better idea  then I'm all ears... I should probably make that a separate question once I get the triangle position solved.
0
Comment
Question by:Brahmanatha
  • 2
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39808637
>Note that I'm not loading any jQuery UI scripts or UI CSS
I think you are when looking at your code
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
	<!-- script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> -->
	<link rel="stylesheet" href="/assets/css/ui-lightness/jquery-ui-1.8.18.custom.css" type="text/css" media="screen, projection" />
	<link rel="stylesheet" href="/assets/css/ddd-banner.css" type="text/css" media="screen, projection" />
	<script src="/assets/js/jquery-1.7.1.min.js"></script>
	<script src="/assets/js/jquery-ui-1.8.18.custom.min.js"></script>
	 <!-- <script src="/assets/js/jquery-1.9.1.min.js"></script>-->
	 <!-- <script src="/assets/js/jquery-ui.min.js"></script>-->

Open in new window


Many sites use jquery and jquery ui without issue or other libraries.  Think of all the sites run with wordpress and those are plenty bulked up well beyond what you are talking about.   If you are talking about using hover working only for smart phones, then you are excluding older versions of ie.  If that is the case, you use jquery 2.x which is only about 85k plus whatever the accordion requires.
0
 
LVL 25

Accepted Solution

by:
Kyle Hamilton earned 500 total points
ID: 39808705
to see the triangle, override the following class, by giving the h3 some padding:

.ui-accordion .ui-accordion-header {
cursor: pointer;
position: relative;
margin-top: 1px;
zoom: 1;
padding-left: 30px;
}

Open in new window


I find those hovers incredibly annoying. It makes it very difficult to scroll through the titles. I would either provide some delay, or make them open on click. You do not need ids for each one.

To make them open on click you can do this:
$(".audio-index-list").on("click", "li", function(){
  $(this).addClass("open").siblings().removeClass("open"));
});

Open in new window

remove the hover class (#accordion li:hover), and add this instead:
.open{
   white-space: normal;
   overflow: visible;
   display: block;
}

Open in new window

0
 

Author Comment

by:Brahmanatha
ID: 39818646
Duh!  my code was OK but had an extra parenthesis! I need to learn how to use JSlint.
0
 

Author Closing Comment

by:Brahmanatha
ID: 39818650
Thanks Kyle!
0
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 39818666
:)
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question