o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325695617.932205: @value{I" class:EFI"BundledAsset; FI"id; F"%e01f1933a5de5f5b1741d03facf2ea6aI"logical_path; F"umlaut/update_html.jsI" pathname; F"G/home/rochkind/umlaut/app/assets/javascripts/umlaut/update_html.jsI"content_type; FI"application/javascript; FI" mtime; FI"2011-12-12T15:39:19-05:00; FI" body; FI"©/* update_html.js: Provide functions to update content on page with background responses from Umlaut. Used by Umlaut itself, as well as by third party callers.*/ (function($) { function SectionTarget(config) { //Add properties from config to ourself $.extend(this, config); //Defaults if (this.selector == undefined) this.selector = "#" + this.umlaut_section_id; if (this.position == undefined) this.position = "html"; } //Callback default to no-op function please. var noop = function() {}; SectionTarget.prototype.before_update = noop; SectionTarget.prototype.after_update = noop; SectionTarget.prototype.complete = noop; SectionTarget.prototype.ensure_placement_destination = function() { if ( this.selector == undefined) { return null; } //Already have it cached? if ( this.host_div_element ) { return this.host_div_element; } var new_div = $(''); // Find the first thing matched by selector, and call the // method specified in "action" string on it, giving it our // HTML to replace. This works because our actions are // all arguments that will take one method: html, before, after, append, // prepend. $(this.selector).eq(0)[ this.position ]( new_div ); //Cache for later this.host_div_element = new_div; return this.host_div_element; }; // Define an object constructor on the global window object // For our UmlautHtmlUpdater object. function HtmlUpdater(umlaut_base, context_object) { if (context_object == undefined) context_object = ""; umlaut_base = umlaut_base.replace(/\/$/,''); this.umlaut_uri = umlaut_base + '/resolve/partial_html_sections?umlaut.response_format=json&' + context_object; this.section_targets = []; this.add_section_target = function(config) { this.section_targets.push( new SectionTarget(config) ); }; //default no-op call-backs this.complete = function() {}; //Code for seeing if a URI is same origin or not borrowed from jQuery this.is_remote_url = function(url) { var regexp = /^(\w+:)?\/\/([^\/?#]+)/; var parts = regexp.exec( url ); return (parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host)); } this.update = function() { // Need to capture because we won't have 'this' inside the ajax // success handler. var myself = this; var dataType = this.is_remote_url( this.umlaut_uri ) ? "jsonp" : "json"; $.ajax({ url: myself.umlaut_uri, dataType: dataType, jsonp: "umlaut.jsonp", error: function() { $.error("Problem loading background elements."); }, success: function(umlaut_response) { for (var i = 0; i < myself.section_targets.length; i++) { var section_target = myself.section_targets[i]; var umlaut_html_section = myself.find_umlaut_response_section(umlaut_response, section_target.umlaut_section_id); if (umlaut_html_section == undefined) { continue; } var count = null; if (typeof umlaut_html_section.response_count != "undefined") { count = parseInt(umlaut_html_section.response_count.value); } var existing_element = section_target.ensure_placement_destination(); var new_element = $(''); new_element.html(umlaut_html_section.html_content); var should_continue = section_target.before_update(new_element, count, section_target); if (should_continue != false) { existing_element.replaceWith(new_element); section_target.host_div_element = new_element; new_element.show(); section_target.after_update(new_element, count, section_target) } } //Do we need to update again? if (umlaut_response.partial_html_sections.in_progress) { //Fix our update URI to be the one umlaut suggests //Except strip out the umlaut.jsonp parameter, jquery is //going to add that back in as desired. myself.umlaut_uri = umlaut_response.partial_html_sections.in_progress.refresh_url.replace(/[?;&]umlaut\.jsonp=[^;&]+/, ''); var refresh_seconds = umlaut_response.partial_html_sections.in_progress.requested_wait_seconds; window.setTimeout(function() { myself.update(); }, refresh_seconds * 1000); } else { myself.complete(); for (var i = 0; i < myself.section_targets.length; i++) { var section_target = myself.section_targets[i]; section_target.complete(section_target); } } } }); }; this.find_umlaut_response_section = function(response, id) { return $.grep(response.partial_html_sections.html_section, function(section) { return section.id == id; })[0]; }; }; //Put it in a global object, leave space for other things in "Umlaut" later. if (window.Umlaut == undefined) window.Umlaut = new Object(); window.Umlaut.HtmlUpdater = HtmlUpdater; })(jQuery); ; FI"asset_paths; F["G/home/rochkind/umlaut/app/assets/javascripts/umlaut/update_html.jsI"dependency_paths; F[{I" path; F"G/home/rochkind/umlaut/app/assets/javascripts/umlaut/update_html.jsI" mtime; FIu: Time ”í€0: @_zoneI"EST; T: offsetiþ°¹I"hexdigest; F"%c4e7ce249985076cd95b16cd773ca941I" _version; F"%46dde6621c301f4928e3b34efee9e3b5