Sha256: 219f4fe1521e4ce65ed503c274e1007d59c0e48820e42136813be411d8c8783c
Contents?: true
Size: 1.33 KB
Versions: 7
Compression:
Stored size: 1.33 KB
Contents
define -> defaults = context: null beforeSend: (xhr) -> xhr.setRequestHeader 'X-XHR-Referer', document.location.href type: 'Base' version: '0.0.1' options: autoload: true initialize: (options) -> @sandbox.logger.log "initialized!" throw new TypeError "content.initialize: No uri provided to load content" unless options.uri? throw new TypeError "content.initialize: Multiple before sends are not supported yet" if options.beforeSend defaults.context = @ options.url = options.uri delete options.uri if options.autoload delete options.autoload @load() else @sandbox.once "content.#{@identifier}.load", @, @load @$el.addClass "content" @$el.attr 'id', @identifier load: -> options = @sandbox.util._.omit @options, 'el', 'ref', '_ref', 'name', 'require', 'baseUrl' options = $.extend {}, defaults, options # TODO remove jQuery dependency $.ajax(options).done(@loaded).fail(@failed) loaded: (response) -> # Will also initialize sandbox! @html response failed: (xhr) -> if @sandbox.debug.enabled html = "<h2>Content Widget: Failed to load Content</h2>" html += xhr.responseText html = html.replace /\n/g, '<br/>' @html html else # TODO prettier message html = "Failed to load content."
Version data entries
7 entries across 7 versions & 1 rubygems