var util = function() { $.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; }; function inURL(url, str) { var exists = false; if ( url.indexOf( str ) > -1 ) { exists = true; } return exists; } function show( thing ) { $('.' + thing ).show(); $('.' + thing + '-overlay').show(); } function hide( thing ) { $('.' + thing ).hide(); $('.' + thing + '-overlay').hide(); } function position( thing, elem, offset ) { var position = $(elem.target).offset(); if (offset) { if (offset.top) position.top += offset.top; if (offset.left) position.left += offset.left; } $('.' + thing + '-overlay').show().click(function(e) { $(e.target).hide(); $('.' + thing).hide(); }); $('.' + thing).show().css({top: position.top + $(elem.target).height(), left: position.left}); } function render( template, target, options ) { if ( !options ) options = {data: {}}; if ( !options.data ) options = {data: options}; var html = $.mustache( $( "." + template + "Template:first" ).html(), options.data ); if (target instanceof jQuery) { var targetDom = target; } else { var targetDom = $( "." + target + ":first" ); } if( options.append ) { targetDom.append( html ); } else { targetDom.html( html ); } if (template in app.after) app.after[template](); } function notify( message, options ) { if (!options) var options = {}; $('#notification-container').show(); $('#notification-message').text(message); if (!options.loader) $('.notification-loader').hide(); if (options.loader) $('.notification-loader').show(); if (!options.persist) setTimeout(function() { $('#notification-container').hide() }, 3000); } function formatMetadata(data) { out = '