Skip to content

Commit

Permalink
Merge pull request #4 from gnarf37/master
Browse files Browse the repository at this point in the history
Made a few more changes...
  • Loading branch information
ajpiano committed Mar 2, 2013
2 parents 8207e51 + efc6dc7 commit 3c8b794
Showing 1 changed file with 61 additions and 69 deletions.
130 changes: 61 additions & 69 deletions index.html
Expand Up @@ -77,7 +77,7 @@ <h1 class="middleGuy">ajpiano.com/widgetfactory</h1>
<header>
<h1>Easy Plugins Are Easy</h1>
</header>
<section class="text">
<section class="text smallerCode">
<p>It's easy to extend the jQuery prototype (<code>jQuery.fn</code>) to make a <a href="http://docs.jquery.com/Plugins/Authoring">&ldquo;plugin&rdquo;</a> that operates on sets of elements.</p>
<pre class="brush: js; toolbar: false;">
(function( $ ) {
Expand Down Expand Up @@ -511,33 +511,34 @@ <h1>State + Events = Extensibility</h1>
<p>A good widget provides a solid base with callbacks for customisation.</p>
<pre class="brush: js; toolbar: false;">
var total = $("#total"), cheeses = $("#cheeses"), register = $("#register"), price = $("&lt;span&gt;"),
activation = $("#activation").button({icons:{primary:"ui-icon-search"}}).toggle(function() {
cheeses.filterable({
className: "cheese",
create: function() { register.addClass("ui-widget-header cheese").show(); },
filtered: function(e, ui) {
var t = 0;
ui.visible.each(function() { t = t + $(this).data("price"); });
total.text(t.toFixed(2));
},
setOption: function(e, ui) {
ui.option == "className" &amp;&amp; register.toggleClass([ui.original, ui.current].join(" "));
},
hover: function(e, ui) {
if (e.originalEvent.type == "mouseenter") {
price.text(" - " + ui.hovered.data("price") + " per lb").appendTo(ui.hovered);
} else {
price.detach();
}
activation = $("#activation").button({icons:{primary:"ui-icon-search"}});
activation.click(function() {
if ( cheeses.is(":aj-filterable") ) {
return cheeses.filterable("destroy");
}
cheeses.filterable({
className: "cheese",
create: function() { register.addClass("ui-widget-header cheese").show(); },
filtered: function(e, ui) {
var t = 0;
ui.visible.each(function() { t = t + parseFloat( $(this).data("price") ); });
total.text( t.toFixed( 2 ) );
},
setOption: function(e, ui) {
ui.option === "className" &amp;&amp; register.toggleClass([ui.original, ui.current].join(" "));
},
hover: function(e, ui) {
if (e.originalEvent.type === "mouseenter") {
price.text(" - " + ui.hovered.data("price") + " per lb").appendTo(ui.hovered);
} else {
price.detach();
}
}).bind("filterabledestroy", function(e,ui) {
register.removeClass("ui-widget-header "+ui.options.className).hide();
}).filterable("filter");
setTimeout(function() { cheeses.filterable("option", "className", "cheesePlease"); },3000);
},
function() {
cheeses.filterable("destroy");
});
}
}).on("filterabledestroy", function(e,ui) {
register.removeClass("ui-widget-header "+ui.options.className).hide();
}).filterable("filter");
setTimeout(function() { cheeses.filterable("option", "className", "cheesePlease"); },3000);
});
</pre>
</section>
</div>
Expand Down Expand Up @@ -603,6 +604,7 @@ <h1>More Resources</h1>
<section class="text">
<ul>
<li><a href="http://learn.jquery.com/jquery-ui/widget-factory/">Learning Center: Widget Factory</a></li>
<li><a href="http://api.jqueryui.com/jQuery.widget/">jQuery UI API: Widget Factory</a></li>
<li><a href="http://learn.jquery.com/jquery-ui/theming/api/">jQuery UI CSS Framework</a></li>
<li><a href="http://www.erichynds.com/jquery/tips-for-developing-jquery-ui-widgets/">Tips for Developing UI Widgets</a></li>
<li><a href="http://net.tutsplus.com/tutorials/javascript-ajax/coding-your-first-jquery-ui-plugin/">Coding Your First jQuery UI Plugin</a></li>
Expand Down Expand Up @@ -1059,7 +1061,8 @@ <h1>Revisionist History</h1>
SyntaxHighlighter.config.strings.alert = 'SyntaxHighlighter\n\n';
SyntaxHighlighter.config.strings.noBrush = 'Can\'t find brush for: ';
SyntaxHighlighter.config.strings.brushNotHtmlScript = 'Brush wasn\'t configured for html-script option: ';
SyntaxHighlighter.defaults['tab-size'] = 2;
SyntaxHighlighter.defaults["quick-code"] = false;
SyntaxHighlighter.defaults['tab-size'] = 4;
SyntaxHighlighter.all();


Expand All @@ -1086,48 +1089,37 @@ <h1>Revisionist History</h1>

// !this.activeSlide && this.intro();
$(function() {
var total = $("#total"),
cheeses = $("#cheeses"),
register = $("#register"),
price = $("<span>"),
activation = $("#activation")
.button({icons:{primary:"ui-icon-search"}})
.click(function() {
if ( cheeses.data("aj-filterable") ) {
cheeses.filterable("destroy");
return;
var total = $("#total"), cheeses = $("#cheeses"), register = $("#register"), price = $("<span>"),
activation = $("#activation").button({icons:{primary:"ui-icon-search"}});
activation.click(function() {
if (cheeses.is(":aj-filterable")) {
return cheeses.filterable("destroy");
}
cheeses.filterable({
className: "cheese",
create: function() { register.addClass("ui-widget-header cheese").show(); },
filtered: function(e, ui) {
var t = 0;
ui.visible.each(function() { t = t + parseFloat($(this).data("price")); });
console.log( t );
total.text(t.toFixed(2));
},
setOption: function(e, ui) {
ui.option == "className" && register.toggleClass([ui.original, ui.current].join(" "));
},
hover: function(e, ui) {
if (e.originalEvent.type == "mouseenter") {
price.text(" - " + ui.hovered.data("price") + " per lb").appendTo(ui.hovered);
} else {
price.detach();
}
cheeses.filterable({
className: "cheese",
create: function() {
register.addClass("ui-widget-header cheese").show();
},
filtered: function(e, ui) {
var t = 0;
ui.visible.each(function() {
t = t + parseFloat($(this).data("price"));
});
total.text(t.toFixed(2));
},
setOption: function(e, ui) {
if (ui.option == "className") {
register.toggleClass([ui.original, ui.current].join(" "));
}
},
hover: function(e, ui) {
if (e.originalEvent.type == "mouseenter") {
price.text(" - " + ui.hovered.data("price") + " per lb").appendTo(ui.hovered);
} else {
price.detach();
}
}
}).bind("filterabledestroy", function(e,ui) {
register.removeClass("ui-widget-header "+ui.options.className).hide();
}).filterable("filter");
setTimeout(function() {
cheeses.filterable("option", "className", "cheesePlease");
},3000);
});
}
}).on("filterabledestroy", function(e,ui) {
register.removeClass("ui-widget-header "+ui.options.className).hide();
}).filterable("filter");
setTimeout(function() { cheeses.filterable("option", "className", "cheesePlease"); },3000);
});

});

},
Expand Down

0 comments on commit 3c8b794

Please sign in to comment.