Solved

Help to customize jQuery icon position

Posted on 2014-01-24
5
822 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now