Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add toggle tag

  • Loading branch information...
commit 1ad18c0e96c77169d19c5be39eb858be9e5e072b 1 parent 6890b3a
@bryanlarsen bryanlarsen authored
View
27 hobo_jquery_ui/taglibs/toggle.dryml
@@ -0,0 +1,27 @@
+<%#
+
+This is a simple click-to-expand type widget with the same styling as
+the jquery-ui accordion.
+
+### Example
+
+ <toggle open>
+ <heading:>Click me</heading:>
+ <content:>inner content</content:>
+ <toggle>
+
+### Attributes
+
+`open`: if supplied, the content is initially displayed. Otherwise
+it is initially hidden
+
+%>
+<def tag="toggle" attrs="open">
+ <div class="toggle ui-accordion ui-widget ui-helper-reset ui-accordion-icons" data-rapid="&data_rapid('toggle')" param="outer">
+ <h3 class="ui-accordion-header ui-state-default ui-helper-reset #{open ? 'ui-state-active ui-corner-top' : 'ui-corner-all'}" param>
+ <span class="ui-icon #{open ? 'ui-icon-triangle-1-s' : 'ui-icon-triangle-1-e'}" param></span>
+ <a href="#" param="heading"/>
+ </h3>
+ <div class="ui-accordion-content ui-widget-content ui-corner-bottom ui-helper-reset #{open ? 'ui-accordion-content-active' : 'hidden'}" param="content"/>
+ </div>
+</def>
View
11 hobo_jquery_ui/vendor/assets/javascripts/hobo-jquery-ui/hjq-toggle.js
@@ -0,0 +1,11 @@
+/* toggle */
+(function($) {
+ $.fn.hjq_toggle = function(annotations) {
+ this.on("click", "div.toggle > h3", function(event) {
+ $this = $(this)
+ $this.toggleClass('ui-state-active ui-corner-top ui-corner-all');
+ $this.next().toggleClass('hidden ui-accordion-content-active');
+ $this.children("span.ui-icon").toggleClass('ui-icon-triangle-1-s ui-icon-triangle-1-e')
+ });
+ }
+})( jQuery );
Please sign in to comment.
Something went wrong with that request. Please try again.