Permalink
Browse files

Expander Widget

  • Loading branch information...
1 parent 1d2611b commit fa44ab05fbe3711e4cf5e919a609dab2227a583f @kpdecker committed May 9, 2010
Showing with 29 additions and 11 deletions.
  1. +4 −11 border-image-generator.js
  2. +24 −0 expander.js
  3. +1 −0 index.html
@@ -171,33 +171,26 @@ $(document).ready(function() {
imageEl[0].src = state.src;
});
- // TODO : Check to see what sort of cool options jQuery allows for unifying some of this functionality
- $("#borderOptionsExpander").toggle(
+ $("#borderOptionsExpander").expander(
+ "#borderOptions",
function() {
- $("#borderOptionsExpander > span").removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");
- $("#borderOptions").show();
state.linkBorder = false;
updateCSS();
updateHash();
},
function() {
- $("#borderOptionsExpander > span").removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
- $("#borderOptions").hide();
state.linkBorder = true;
updateCSS();
updateHash();
});
- $("#fitOptionsExpander").toggle(
+ $("#fitOptionsExpander").expander(
+ "#fitOptions",
function() {
- $("#fitOptionsExpander > span").removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");
- $("#fitOptions").show();
state.setFit = true;
updateCSS();
updateHash();
},
function() {
- $("#fitOptionsExpander > span").removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
- $("#fitOptions").hide();
state.setFit = false;
updateCSS();
updateHash();
View
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010 Kevin Decker (http://www.incaseofstairs.com/)
+ * See LICENSE for license information
+ */
+(function($) {
+ // Helper method that implements the expander UI
+ $.fn.expander = function(child, onShow, onHide) {
+ var self = this;
+
+ self.toggle(
+ function() {
+ self.children("span").removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");
+ $(child).show();
+
+ onShow();
+ },
+ function() {
+ self.children("span").removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
+ $(child).hide();
+
+ onHide();
+ });
+ };
+})(jQuery);
View
@@ -90,6 +90,7 @@
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<script type="text/javascript" src="lib/jquery.ui.resizable.min.js"></script>
<script type="text/javascript" src="history-handler.js"></script>
+ <script type="text/javascript" src="expander.js"></script>
<script type="text/javascript" src="border-image-generator.js"></script>
</body>
</html>

0 comments on commit fa44ab0

Please sign in to comment.