Skip to content

Instantly share code, notes, and snippets.

View pnomolos's full-sized avatar

Phil Schalm pnomolos

  • Jane.app
  • British Columbia, BC
  • 12:33 (UTC -12:00)
  • X @pnomolos
View GitHub Profile
module Packs
module Admin
class Grade < Grade
# Stub class extending from the real definition
end
end # Admin
end # Packs
window.addEvent('domready',function(){
if ($('section-menu')) {
$('section-menu').getElements('a.menuitem').each(function(n){
n.addEvent('click',function(ev){
new Event(ev).preventDefault();
})
})
var accordion = new Accordion('a.menuitem', 'ul.submenu', {
opacity: false,
onActive: function(toggler, element){
<!-- The cheater way -->
<a href="javascript:window.history.go(-2);">Go back 2 history</a>
<!-- The more correct way -->
<span id="go-back">Go back</span>
<script type="text/javascript">
document.getElementById('go-back').onclick = function() {
window.history.go(-2);
}
</script>
/*
*
* Copyright (c) 2006-2009 Sam Collett (http://www.texotela.co.uk)
* Modified by Phil Schalm to allow custom sorting via a passed in function
*
*/
$.fn.sortOptions = function(ascending)
{
// get selected values first
$.fn.sortOptions = function(ascending)
{
var _sortFunc;
if ( typeof(ascending) == "function") {
_sortFunc = ascending;
} else if (!!ascending) {
_sortFunc = function(a,b) {
return a.text < b.text ? -1 : 1;
}
} else {
module DataMapper
class Query
alias :old_assert_valid_order :assert_valid_order
def assert_valid_order(order, fields)
old_assert_valid_order(order, fields) unless !order.nil? && order.any? { |p| p.is_a?(Direction) && p.property.name == :sort_order }
end
end
end
# Get all the properties that aren't fulltext (which will cause the query to break)
props = Product.properties.reject{|p| p.type == DataMapper::Types::Text }.map{|p| "`products`.`#{p.name}`" }.join(', ')
# Get categories before hand as it tends to be a little faster.
@categories = Category.all( :name.like => "%#{params[:search]}%" )
# Do the massive query.
# You'll notice the << -1 on the queries. Since @category.id is an autoincrement it'll never be -1 and this is easier than a messey ternary statement. I'd imagine the messy statement could be a little faster, however.
@t_products = Product.find_by_sql(["SELECT " + props + "
FROM products
LEFT JOIN categories_products ON categories_products.product_id = products.id
namespace :admin do
resources :services
end
#26907620 - About 10 minutes from the end. Phar mummies to SS ult
public function add_field($code, $title, $side = 'full', $type = db_text, $just_column = false)
{
$this->custom_columns[$code] = $type;
$this->_columns_def = null;
$col = $this->define_column($code, $title)->validation();
if ( !$just_column ) {
$form_field = $this->add_form_field($code, $side)->optionsMethod('get_added_field_options');
$this->added_fields[$code] = $form_field;
return $form_field;