/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define([
  'app',
  'text!sorting.html!strip',
  'css!sorting'
],
  function (App, source) {
    "use strict";

    var response = {}, def;

    response.data = source;
    response.after = function (self) {
      if (App === undefined) {
        def = new $.Deferred();

        def.done(function (gadget) {
          // prefix instance-ids, pass JSON
          App.renderGadgets(gadget);
        });

        window.fallbackLoader.deferreds.push(def);
        window.fallbackLoader.args.push(self);
      } else {
        // prefix instance-ids, pass JSON
        App.renderGadgets(self);
      }
    };

    // return response object
    return response;
  }
  );
