Example #1
0
    SF.controller().on("query_tile_clicked", function(query) {

      // TODO: this should be better encapsulated into a modal hider/shower
      // thats shared across modules
      $("#user_dialog").modal('hide');
      this.toggle_pane(false);

      this.set_dom_from_input(query.input);

      var client_id, server_id;


      if (query.hashid) {
        server_id = query.hashid;
        client_id = query.clientid || ResultsStore.to_client(server_id);
      } else {
        client_id = query.clientid || query.id;
        server_id = ResultsStore.to_server(client_id);
      }

      SF.go("/query?table=" + this.table + "&h=" + server_id);
      set_query(query);

      views.redraw(client_id, query);
    });
Example #2
0
    SF.subscribe("popstate", function() {
      var form_str = window.location.search.substring(1);
      var data = $.deparam(form_str);
      var id = data.c;

      var server_id;
      if (!id) {
        server_id = data.h;
        if (server_id) {
          id = ResultsStore.to_client(server_id);
        }
      }

      server_id = ResultsStore.to_server(id);



      var input = ResultsStore.get_input(server_id);
      if (input) {
        that.set_dom_from_input(input);
      } else {
        that.set_dom_from_query(form_str);
      }

      if (server_id !== _query_id) {
        // if we dont have a local cache of the ID, then we should probably
        // re-run the query, huh?
        if (!views.redraw(id)) {
          that.run_query(form_str, true);
          // run this query again?
          // TODO: show 'save' button
        }
        // need to restore the old query
      }

      set_query({
        hashid: server_id,
        clientid: id
      });

    });