[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1119
  • Last Modified:

Help to customize jQuery icon position

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
Brahmanatha
Asked:
Brahmanatha
  • 2
  • 2
1 Solution
 
Scott Fell, EE MVEDeveloperCommented:
>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
 
Kyle HamiltonData ScientistCommented:
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
 
BrahmanathaAuthor Commented:
Duh!  my code was OK but had an extra parenthesis! I need to learn how to use JSlint.
0
 
BrahmanathaAuthor Commented:
Thanks Kyle!
0
 
Kyle HamiltonData ScientistCommented:
:)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now