Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

Does this mean to load the "view" in Code Igniter?

accounts.js looks like this:

pf['accounts'] = {
  setParscreenHistory : function(){
    pf.history.Adapter.bind(window,'statechange',function(){
      var State = pf.history.getState();
      if (State.data.accountid && State.data.accountid != pf.data("accountid") && State.data.accountid && State.data.accountid != pf.data("accountkey")) {
        pf.accounts.loadAccount(State.data.accountid);
      } else if (State.data.appurl) {
        State.data.postdata.template = false;
        $(State.data.container).fadeOut(function(){
          pf.ajax({
            url:State.data.appurl,
            type:"post",
            data:State.data.postdata,
            success:function(view){
              $(State.data.container).html(view).fadeIn();
            }
          });
        });
      }
    });
  },
  saveField : function(accountid, input){
    if(input.attr("edit")){
      var newVal = input.val();
      //Validate if provided
      if(pf.util.filters.validate[input.attr("validatefilter")]){
        if(!(pf.util.filters.validate[input.attr("validatefilter")](newVal))){
          input.addClass('invalid');
          return false;
        } else {
          input.removeClass('invalid');
        }
      }
      //Apply submit filter if provided
      if(pf.util.filters.submit[input.attr("submitfilter")]){
        newVal = pf.util.filters.submit[input.attr("submitfilter")](newVal);
      }
      var data = {};
      data[input.attr("edit")] = (newVal);
      pf.ajax({
        url: "/account/edit/"+accountid,
        type: "post",
        data: data,
        dataType: "json",
        success: function(resp){
          if(resp.success){
            //Apply response filter if provided
            var respval = resp.val;
            if(pf.util.filters.response[input.attr('responsefilter')]){
              respval = pf.util.filters.response[input.attr('responsefilter')](respval, input);
            }
            input.val(respval);
            //reset the width
            input.inputWidth(input.val());
          }
        }
      });//End ajax 'account/edit/[accountid]'
    }
  }, //End saveField()
  loadAccount : function(accountid, callback, refresh){
     if(accountid && ((pf.data('accountid') && accountid == pf.data('accountid')) || pf.data('accountkey') && accountid == pf.data('accountkey'))) if(!refresh) return;
     accountid = accountid || false;
    //save current note\
    //if($("#an_newnote textarea.ticket").val()) pf.tickets.saveTicket($("#an_newnote textarea.ticket"));
    /* ELIMINATING THE AUTO NOTE FORWARDING

    if(pf.calls.client.call && $("#an_newnote textarea.ticket").data('callid') && $("#an_newnote textarea.ticket").data('callid') == pf.calls.client.call.callid){
      //If there's an active call, store the active ticket information and transfer to the new call.
      if($("#an_newnote textarea.ticket").length){
        pf.calls.client.call.ticket = {};
        pf.calls.client.call.ticket.id = $("#an_newnote textarea.ticket").data('ticketid');
        pf.calls.client.call.ticket.callid = $("#an_newnote textarea.ticket").data('callid');
        pf.calls.client.call.ticket.val = $("#an_newnote textarea.ticket").val();
      }
    }*/
    //Disable "this account" section in workqueuetasks, if it's active.
    var click_account = false;
    if($('#par_taskqueue ul.queues li.tab[data-queue="acc"]').hasClass('active')){
      click_account = true;
      $('#par_taskqueue ul.queues li.tab[data-queue="acc"]').removeClass('active');
    }

    if(accountid){
      $('#add_txn_form').remove();

      pf.ajax({
        url : "/parscreen/loadAccount/"+accountid,
        dataType : "json",
        name : "load_account",
        //timeout : 4000,
        success : function(views){
          var ai =  views.accountinfo;
          var ch = views.commhist;
          var pending = {
            "E" : false,
            "T" : false,
            "P" : false,
            "S" : false
          };
          if(ai.account.accountid) $('#par_taskqueue li.callbacks, #par_taskqueue li.ins_review').removeAttr('disabled');
          for(var st in ch.comm){
            if(ch.comm[st]["ExportDate"]===null && typeof ch.comm[st] != "function"){
              pending[ch.comm[st]["statementType"]] = ch.comm[st]["StatementID"];
            }
          }
          pf.data({
                  "accountid":ai.account.accountid,
                  "accountkey":ai.account.accountkey,
                  "firstname":ai.account.patientfname,
                  "lastname":ai.account.patientlname,
                  "comm":ai.comm,
                  "ai":ai,
                  "commhist":ch.comm,
                  "pending":pending
          });
          if(click_account) $('#par_taskqueue ul.queues li.tab[data-queue="acc"]').click();
          pf.loadView("#account_details_container",views.details, "html");
          pf.loadView("#par_notes",views.notes, "html");
          pf.loadView("#par_payment",$("#par_payment").data("default"), "html");
          pf.loadView("#par_payment",'/payment/par/'+accountid);
          //pf.loadView("#par_transactions",views.transactions, "html");

          //Transaction pane 
          pf.accounts.getTransactions(views.transactions);

          pf.loadView("#comm_history_container",views.commhistory, "html");
          $('#prc_queue').find('span').remove();

          $('#prc_queue .growl_accounttasks').remove();
          if(views.pastduetasks) $('#prc_queue').append($('<span class="growl_accounttasks">').html(views.pastduetasks));

          $('#prc_queue .growl_mytasks').remove();
          if(views.myduetasks) $('#prc_queue').prepend($('<span class="growl_mytasks">').html(views.myduetasks));

          //console.log(views);
          $('title').html('PatientFocus : '+ ai.account.patientfname + " " + ai.account.patientlname);
          pf.history.pushState({'accountid':accountid}, 'PatientFocus : '+ ai.account.patientfname + " " + ai.account.patientlname, "?accountid="+accountid);
          if(typeof callback == 'function'){
            callback(accountid);
          }
        }
      });/**/
    } else {
      if(click_account) $('#par_taskqueue ul.queues li.tab[data-queue="acc"]').click();
      $('#prc_queue').find('.growl_accounttasks').remove();

      $('#par_taskqueue li.callbacks, #par_taskqueue li.ins_review').attr('disabled', true);
      $("#account_details_container").loadView($("#account_details_container").data("default"), "html");
      $("#par_notes").loadView($("#par_notes").data("default"), "html");
      $("#par_payment").loadView($("#par_payment").data("default"), "html");
      pf.accounts.clearTransactions();
      $("#comm_history_container").loadView($("#comm_history_container").data("default"), "html");
      $("#par_payment").loadView($("#par_payment").data("default"), "html");
      $('title').html('PatientFocus : No account loaded.');
      pf.data({
              "accountid":'',
              "firstname":'',
              "lastname":'',
              "comm":'',
              "ai":'',
              "commhist":'',
              "pending":''
              });
       pf.history.pushState({'accountid':''}, 'PatientFocus : No account loaded.','/parscreen/');
       if(typeof callback == 'function'){
            callback(accountid);
        }
    }

  },
  getTransactions: function(dataset, encfilter, revfilter){
    if(typeof dataset === 'string') dataset = JSON.parse(dataset);
    else if(dataset === false || typeof dataset === 'undefined') dataset = $('#par_transactions').data('dataset');

    var _old_account_key = $('#par_transactions').data('dataset') ? $('#par_transactions').data('dataset').accountkey : false;
    if(typeof dataset === 'object') $('#par_transactions').data('dataset', dataset);

    if(dataset && typeof dataset.requesttime === 'undefined') dataset.requesttime = new Date().getTime();

    var _open_encounters = [];
    $('.tx-table').parents('.claim').each(function(){
      _open_encounters.push($(this).data('claimdata').encountercode || 'z');
    });

    var _last_encfilter = false;
    if($('input[name="open_encounters"]').is(':checked')){
      _last_encfilter = true;
    }

    var _last_revfilter = false;
    if($('input[name="hide_reversals"]').is(':checked')){
      _last_revfilter = true;
    }

    //The header add txn button
    var encounterlist_data = {};
    if(dataset.txntable){
      encounterlist_data.add_txn_id = "add_other_txn";
      encounterlist_data.add_txn_copy = "Add Patient Transaction";
    } else {
      encounterlist_data.add_txn_id = "add_adjustment_control";
      encounterlist_data.add_txn_copy = "Add Transaction";
    }

    _old_scroll = false;
    if(dataset.accountkey == _old_account_key && typeof encfilter === 'undefined'){
      encfilter = _last_encfilter;
      _old_scroll = $('#tx_claims').scrollTop();
    }
    if(dataset.accountkey == _old_account_key && typeof revfilter === 'undefined'){
        _old_scroll = $('#tx_claims').scrollTop();
        revfilter = _last_revfilter;
    }


    if(dataset.full_data_set) encounterlist_data.disabled = '';
    else encounterlist_data.disabled = 'disabled Title="Loading rest of data... Please wait"';

    //The header filter
    if(typeof encfilter != 'undefined'){
      dataset.filter = !encfilter;
    }

    if(typeof revfilter != 'undefined'){
      dataset.revfilter = revfilter;
    }
  
    if(dataset.filter === "" || dataset.filter === false) encounterlist_data.openfilter = "checked";
    else encounterlist_data.closefilter = "checked";

    if(dataset.revfilter === true || dataset.revfilter === undefined) encounterlist_data.revfilter = "checked";

    //Scheduled payments Table
    if(dataset.scheduled.length > 0){
      var schdata = {};
      var dcount = 0;
      schdata.pmts = '';

      for(var i = 0; i < dataset.scheduled.length; i++){
        //Scheduled Payment Row
        var sched = dataset.scheduled[i];

        var d = new Date(sched.ScheduleDate.replace('AM',' AM').replace('PM',' PM'));
        if(sched.VoidedDate === null) dcount ++;

        if(typeof sched.init == 'undefined'){
          //Initialize this row.
          
           if(sched.VoidedDate !== null) sched.voidedclass = 'voided';

          sched.amountformatted = pf.util.toMoney(sched.PaymentAmount);
          if(sched.PaymentMethodCode == 'CK') sched.lastfour = sched.BALastFour;
          else sched.lastfour = sched.CCLastFour;

          switch(sched.PaymentMethodCode){
            case 'CK':
              sched.method = 'Bank Account';
              break;
            case 'VI':
              sched.method = 'Visa';
              break;
            case 'MC':
              sched.method = 'MasterCard';
              break;
            case 'DI':
              sched.method = 'Discover';
              break;
            case 'AX':
              sched.method = 'AmEx';
              break;
            default :
              sched.method = 'Card';
              break;
          }
          sched.scheduleddateformatted = pf.util.formatDate(sched.ScheduleDate);
          sched.init = true;
        }
        
        var viewstring = (sched.VoidedDate !== null) ? 'txn_scheduledrowcancelled' : 'txn_scheduledrow';
        schdata.pmts += jsMVC.views[viewstring].load(sched);
      }

      schdata.displaycount = dcount +' Scheduled Payment' + (dcount === 1? '' : 's');

      encounterlist_data.scheduled = jsMVC.views['txn_scheduled'].load(schdata);
    }

      //Claims listitems
      encounterlist_data.claims = '';
      for(var h = 0; h<dataset.claims.length; h++){
        var claim = dataset.claims[h];

        //Filter open vs all
        if(encounterlist_data.closefilter || (claim.baldue !== 0 && claim.status1 !== 'RT')){

          //Display values
          //Zerobal is the zerobal
          if(claim.baldue === 0) claim.zerobal = 'zerobal';
          else claim.zerobal = '';

          //Claim status 2
          if(claim.status2) claim.status2withdash = '-'+claim.status2;
          else claim.status2withdash = '';

          //BirthOrDeath
          if(claim.pdod){
            claim.birthordeath = 'DECEASED';
            if(claim.pdob != '01/01/5000'){
              claim.birthordeath += ' ('+pf.util.formatDate(claim.pdob)+' to ' + pf.util.formatDate(claim.pdod) +')';
            } else if(claim.pdod != '01/01/5000') claim.birthordeath += ' as of ' + pf.util.formatDate(claim.pdod);
          } else if (claim.pdob && claim.pdob != '01/01/5000') {
            claim.birthordeath = 'DOB - ' + pf.util.formatDate(claim.pdob);
          } else {
            claim.birthordeath = 'DOB Unknown';
          }

          //Formatted Charges
          claim.totalChargedFormatted = pf.util.fromCents(claim.totalCharge);
          claim.baldueFormatted = pf.util.fromCents(claim.baldue);

          //Get notifications
          //console.log(dataset.requesttime);
          for(var j = 0; j<claim.txn.length; j++){
            var txn = claim.txn[j];
            var txndate = pf.util.getDate(txn.createddate);
            //console.log('Txn processing...');
            if(txndate.getTime() > dataset.requesttime - 30000 && (txn.reversedref === null || revfilter === false)){ //the last 30 seconds and still valid
              claim.notification = '<div class="notification"><b class="entypo">⊕</b></div>';
              claim.notify = "notify";
              txn.newrow = "newrow";
            }
            
            //console.log('End txn');
          }

          //Draw the claim
          var claimview = (claim.claimid !== 'z') ? 'txn_encounter' : 'txn_unallocated';
          encounterlist_data.claims += jsMVC.views[claimview].load(claim);
        }
      }
    
    $('#par_transactions').html(jsMVC.views['txn_encounterlist'].load(encounterlist_data));
    initTransactions();
    if(typeof initTransactionsAdmin == 'function') initTransactionsAdmin();

    if(dataset.accountkey == _old_account_key){
      for(var k = 0; k<_open_encounters.length; k++){
        $('#c'+_open_encounters[k]+ ' .min-btn').click();
      }
      if(_old_scroll) $('#tx_claims').scrollTop(_old_scroll);
    }

    if(dataset.full_data_set !== true) pf.accounts.loadTransactions();
  },
  loadTransactions: function(onlyOpen){
    if(typeof onlyOpen == 'undefined') onlyOpen = false;
    pf.ajax({
      url:'/parscreen/transactions/'+pf.data('accountid')+(onlyOpen?'/1':''),
      name:'load_transactions',
      dataType:'json',
      progress:function(p){
        var $prog_indicator = $('#txn_progress_indicator');
        if($prog_indicator.length === 0){
          $prog_indicator = $('<div id="txn_progress_indicator"><div><div></div></div></div>');
          $('#par_transactions').before($prog_indicator);
          $prog_indicator
            .css('display','block')
            .css('position','absolute')
            .css('height','4px')
            .css('width','100%')
            .css('left','0')
            .css('top','0')
            .css('z-index','1000');

          $prog_indicator.children('div')
            .css('display','block')
            .css('position','absolute')
            .css('height','100%')
            .css('width', '0%')
            .css('transition','width .2s')
            .css('left','0')
            .css('top','0')
            .css('background-color','#4adeff')
          .children('div')
            .css('position','absolute')
            .css('height','4px')
            .css('width', '4px')
            .css('right','-2px')
            .css('top','0')
            .css('border-radius', '4px')
            .css('box-shadow','0 0 2px 2px #4adeff')
            .css('background-color','#4adeff');

        }
        if($prog_indicator.data('removeit')){
          clearTimeout($prog_indicator.data('removeit'));
          $prog_indicator.data('removeit', false);
        }

        $prog_indicator
        .css('display','block')
        .children('div').css('width', parseInt(p*100,10)+'%');
        if(p === 1){
          $prog_indicator.data('removeit',setTimeout(function(){
            $prog_indicator.fadeOut();
          },500));
        }
      },
      success:function(txns){
        //console.log(txns);
        if(pf.data('accountid') == txns.accountid) pf.accounts.getTransactions(txns);
      }
    });
  },
  clearTransactions : function(){
    $('#par_transactions').data('dataset', false).data('default','').html('');
  },
  opt : function(type, direction, accountid, callback){
    pf.ajax({
      url:"/admin/communication/opt/"+type+"/"+direction+"/"+accountid,
      //timeout:4000,
      success:function(data){
        if(typeof callback == "function"){
          callback(data);
        }
        var opt = $("#comm_history_opt");
        pf.data("comm").opt[type] = (direction == "in") ? true : false;
        if(opt.data("type")==type){
          if(direction == "in"){
            $("#communications li[data-type="+type+"]").addClass("optin");
            opt.removeClass("in").addClass("out");
            opt.html("Opt Out");
            opt.data("direction","out");
            opt.data("type", type);
          } else {
            $("#communications li[data-type="+type+"]").removeClass("optin");
            opt.removeClass("out").addClass("in");
            opt.html("Opt In");
            opt.data("direction","in");
            opt.data("type", type);
          }
        }
      }
    });
  },
  pref : function(type, direction, accountid, callback){
    pf.ajax({
      url:"/admin/communication/pref/"+type+"/"+direction+"/"+accountid,
      //timeout:4000,
      success:function(data){
        if(typeof callback == "function"){
          callback(data);
        }
        var pref = $("#comm_history_pref input");
        pf.data("comm").pref[type] = (direction == "in") ? true : false;
        if(pref.data("type")==type){
          if(direction == "in"){
            $("#communications li[data-type="+type+"]").addClass("pref");
            pref.data("type", type);
          } else {
            $("#communications li[data-type="+type+"]").removeClass("pref");
            pref.data("type", type);
          }
        }
      }
    });
  },
  openCommHistory : function(type, callback){
    if(!($("#communications li[data-type="+type+"]").hasClass("enabled"))) return;
    var histdrop =  $("#comm_history_table");
    type = type || "all";
    if($("#communications li.active")[0]){
      //There is an open history drop.  Close it first.
      closeHistory();
      setTimeout(function(){
        openHistory(type);
      },300);
    } else {
      openHistory(type);
    }
    function openHistory(type){
      //Reset click handlers
      //Comm Li
      $("#communications li[data-type="+type+"]").addClass("active").off('click.commHistory').on('click.commHistory',function(){
        closeHistory();
      });

      //View comm
      var a = (type == "all") ? "" : (type == "S"? " - <a target='_blank' href='/admin/statement/?accountid="+pf.data("accountid")+"'>View</a>":(type == "P"?" - <a target='_blank' href='/admin/postcard/?accountid="+pf.data("accountid")+"'>View</a>":''));
      $("#comm_history_title").html($("#communications li[data-type="+type+"] .title").html()+a);

      //Send
      //See if there's a pending statement of this type.
      var send=$("#comm_history_send");
      if(pf.data('pending')[type]){
        send.data('method','dequeue');
        send.data('type', type);
        send.html("Unsend").addClass('sent');
      } else {
        send.data('method','queue');
        send.data('type', type);
        send.html("Send").removeClass('sent');
      }

      //Opt
      //Check opt state.
      var opt = $("#comm_history_opt");
      if(pf.data().comm.opt[type]){
        opt.removeClass("in").addClass("out");
        opt.html("Opt Out");
        opt.data("direction","out");
        opt.data("type", type);
      } else {
        opt.removeClass("out").addClass("in");
        opt.html("Opt In");
        opt.data("direction","in");
        opt.data("type", type);
      }

      //Pref
      var pref = $("#comm_history_pref input");
      if(pf.data().comm.pref[type]){
        pref.attr('checked',true);
        pref.siblings('label').html(type==='E'?'Go Green':'Preferred Communication Method');
        pref.data("type",type);
      } else {
        pref.removeAttr('checked');
        pref.siblings('label').html(type==='E'?'Go Green':'Preferred Communication Method');
        pref.data("type",type);
      }

      if(typeof callback == "function") callback();

      //The comm history table's class is what filters its statements list.
      histdrop.removeClass("P E S T all closed");
      histdrop.addClass(type);
      histdrop.outerHeight(pf.util.getHeightByChildren($("#comm_history_table"))+20);
      histdrop.find('.corrected input').attr('checked', false);

      //Things that close the panel
      $(document).off("click.commHistory").on("click.commHistory",function(){
        closeHistory();
      });
      $("#communications li.active").off('click.commHistory').on('click.commHistory',function(){
        closeHistory();
      });
    }
    function closeHistory(){
      $("#comm_history_table").addClass("closed").outerHeight(0);
      $("#communications li").removeClass("active");
      $(document).off("click.commHistory");
      $("#communications li").off('click.commHistory').on('click.commHistory', function(e){
        e.stopPropagation();
        var li = $(this);
        var type = li.data("type");
        pf.accounts.openCommHistory(type);
      });

    }
  },
  queueStatement : function(accountid, type){
    var corrected = $('#comm_history_table .corrected input').is(':checked')&&type.toLowerCase() == 's';
    //Queue the next statement.
    pf.ajax({
      url: "/admin/statement/queue/"+accountid+"/"+type+(corrected?'/5':''),
      dataType: "json",
      //timeout: 4000,
      success: function(data){
        if(data.queued){
           pf.ajax({
             url: "/admin/statement/isqueued/"+accountid,
             //timeout: 4000,
             dataType: "json",
             success: function(qs_data){
               //add Statement to view
               var tbody =  $("#comm_history_table table tbody");
               console.log(qs_data);
               var row = $("<tr class='"+type+"' id='st"+qs_data.queued.statementid+"'><td>"+type+"</td><td>Unsent</td><td>"+qs_data.queued.statementid+'</td><td><a class = "S" href="/admin/statement/r/'+pf.data('accountid')+'/'+qs_data.queued.templateid+'" target="_blank">Preview</a></td></tr>');
               pf.accounts.openCommHistory(type, function(){
                 tbody.prepend(row);
               });
               pf.data("pending")[type]=qs_data.queued.statementid;
               //set send button
               var send = $("#comm_history_send");
               send.data('method','dequeue');
               send.data('type', type);
               send.html("Unsend").addClass('sent');
             }
          });
        }
      }
    });
  },
  dequeueStatement : function(statementid, type){
    pf.ajax({
      url: "/admin/statement/dequeue/"+statementid,
      dataType: "json",
      //timeout: 4000,
      success: function(data){
        if(data){
          pf.data("pending")[type]=false;
          //remove Statement from view
          pf.accounts.openCommHistory(type, function(){
            $("#st"+statementid).remove();
          });
          //set send button
          var send = $("#comm_history_send");
          send.data('method','queue');
          send.data('type', type);
          send.html("Send").removeClass('sent');
        }
      }
    });
  }
};

Open in new window


I am attempting to deconstruct some of the code in an app that I've been asked to work on that's built using the Code Igniter framework.

On line 119-120 of what you see above looks like this:

  pf.loadView("#par_payment",$("#par_payment").data("default"), "html");
          pf.loadView("#par_payment",'/payment/par/'+accountid);

#par_payment is the div on the screen that I'm attempting to pop the hood on. If "loadView" means that we're loading the "view," as per Code Igniter, of the file located in the "views" directory entitled "payment.php," then I am well on my way to breaking this thing down.

I've not been able to figure out any other way that this content is being brought to bear apart from what I see on line 119-120. Am I interpreting correctly?
Avatar of Bruce Gust
Bruce Gust
Flag of United States of America image

ASKER

Thank you, friend!
I think you are on the wrong track - you are looking at JavaScript code, and seem to be thinking in PHP (CodeIgnitor).

I would try and find the "pf" class in javaScript and see what that does. It may well do an AJAX call to your payments.php file.
Avatar of Julian Hansen
We need to see where loadView is defined - can you post the rest of the JavaScript as well as the names of any other JS libraries you are using.

You should also be able to look in the console when the page is active  and see if any calls are being made to the server - what is in the Request and what is in the response - that will give you some clue as to what the code is doing

If we look at the pf.loadView calls on line 119-120 we get
  pf.loadView("#par_payment",$("#par_payment").data("default"), "html");
  pf.loadView("#par_payment",'/payment/par/'+accountid);

Open in new window


If we look at the loadView calls on 149 and 150
  $("#par_notes").loadView($("#par_notes").data("default"), "html");
  $("#par_payment").loadView($("#par_payment").data("default"), "html");

Open in new window

They are not the same - 119 operates off the pf var and takes
- element ID
- the value of the data-default attribute of the ID
- "html" static string

120 takes
- ID
- URL

149 and 150 operate slightly differently. Firstly, they act on a different element and their params
- the value of the data-default attribute of the ID
- "html" static string

I am guessing that the loadView does something similar to the jQuery load - but without seeing the code just a guess
SOLUTION
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here's what I've got so far:

The "par" screen looks like this:

User generated image
In the lower left hand corner, you can see, "Am I making a payment?" When you click "Yes," you get this window:

User generated image
The URL for all of this is: parscreen/?accountid=13130734, which, in the context of Code Igniter, means I'm looking for a controller called "parscreen." On line 61, I've got this:

$this->load->view('parscreen/index', $data');

...that's loading my "view," which is the index file located in the parscreen directory. That file looks like this:

<!DOCTYPE html>
<html class="callbar">
	<head>
		<title>PatientFocus</title>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css" href="/assets/css/views/dialog.css"/>
		<link rel="stylesheet" type="text/css" href="/assets/css/views/parscreen/index.css"/>
        <link rel="stylesheet" type="text/css" href="<?php echo base_url()?>assets/css/pepper-grinder/jquery-ui-1.8.21.custom.css"/>
		<script type="text/javascript" src="/assets/js/util.js"></script>
		<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
		<script type="text/javascript" src="/assets/js/jquery.history.js"></script>
        <script type="text/javascript" src="/assets/js/jquery.sortElements.js"></script>
		<script type="text/javascript" src="/assets/js/jquery.phonefield.js"></script>
		<script type="text/javascript" src="/assets/js/jqueryDynamicInput.js"></script>
		<script type="text/javascript" src="/assets/js/jquery.loadView.js"></script>
        <script type="text/javascript" src="/assets/js/mvc/mvc.js"></script>
		<script type="text/javascript" src="/assets/js/jquery.caret.1.02.min.js"></script>
        <!-- Top version is flash only, bottom will try to use webrtc -->
		<!-- <script type="text/javascript" src="https://static.twilio.com/libs/twiliojs/1.0/twilio.js"></script>-->
        <script type="text/javascript" src="https://static.twilio.com/libs/twiliojs/1.1/twilio.min.js"></script>
		<script type="text/javascript" src="/assets/js/pf/pf.js"></script>
		<script type="text/javascript" src="/assets/js/views/parscreen/index.js"></script>
        <script type="text/javascript" src="/assets/js/creditcard.js"></script>
        <script type="text/javascript" src="/assets/js/abarouting.js"></script>
        <script type="text/javascript" src="/assets/js/views/app2/jquery.dropkick-1.0.0.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
        <script type="text/javascript" src="/assets/js/views/parscreen/transactions.js"></script>

    <? if (hasRole( 'PARAdmin') || hasRole( 'Administrator')){ ?><script type="text/javascript" src="/assets/js/views/parscreen/transactions.admin.js"></script><?}?>

        <script type="text/javascript">
              pf.data('clients',<?=json_encode($clients)?>);
              pf.data('users',<?=json_encode($users)?>);
              pf.data('mainqueue','<?=MAIN_QUEUE?>');
              pf.data('claimstatuses' , <?=json_encode($statuses)?>);
              <?$this->load->model('WorkQueues');?>
              pf.onReady(function(){
                pf.tasks.QUEUE_PARADMIN = <?=WorkQueues::QUEUE_PARADMIN?>;
                pf.tasks.QUEUE_PAR = <?=WorkQueues::QUEUE_PAR?>;
                pf.tasks.QUEUE_PATIENTFOCUS = <?=WorkQueues::QUEUE_PATIENTFOCUS?>;
                pf.tasks.DESCRIPTION_LENGTH_CONSTRAINT = 500;

              });

              jsMVC.config.verbose = false;
              jsMVC.view({
                name : 'add_txn_form',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/addtxn_form", array('paymentmethodref'=>$paymentmethodref,'paymentsourceref'=>$paymentsourceref),true)))?>'
              });
              jsMVC.view({
                name : 'new_note_form',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/notes/new_note",'',true)))?>'
              });
              jsMVC.view({
                name : 'txn_encounterlist',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/transactions",'',true)))?>'
              });
              jsMVC.view({
                name : 'txn_encounter',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/claim",'',true)))?>'
              });
              jsMVC.view({
                name : 'txn_unallocated',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/unallocated_payments.php",'',true)))?>'
              });
              jsMVC.view({
                name : 'txn_table',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/txn_table",'',true)))?>'
              });
              jsMVC.view({
                name : 'txn_row',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/txn",'',true)))?>'
              });
              jsMVC.view({
                name : 'txn_scheduled',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/scheduled",'',true)))?>'
              });
              jsMVC.view({
                name : 'txn_scheduledrow',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/scheduledpayment_row",'',true)))?>'
              });
              jsMVC.view({
                name : 'txn_scheduledrowcancelled',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/scheduledpayment_cancelledrow",'',true)))?>'
              });
              jsMVC.view({
                name : 'txn_addadjustment',
                html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/add_adjustment_btn",'',true)))?>'
              });
              jsMVC.view({
                  name : 'move_txn_form',
                  html : '<?=preg_replace("/[\r\n]/"," ",str_replace("'", "\'", $this->load->view("parscreen/txn/move_txn_form",'',true)))?>'
              });
              pf.onReady(function(){
                pf.user.roles = <?=json_encode($userdata['roles'])?>;
              });
        </script>
	</head>
  <?if (SQL_HOST == 'dev' || SQL_HOST == 'PFWSQLDEV01' || SQL_HOST == '10.0.1.166,1433\WIN-AA42SSGGTJK') {?>
  <body class="<?=$myStatus['class']?> development">
    <div class='devnot'>DEV ENVIRONMENT: Data is not live.</div>
  <?} else {?>
	<body class="<?=$myStatus['class']?>">
  <?}?>
	  <header>
	    <div id="par_tophead">
	      <div id="logo"></div>
	      <div id="search_bar">
	        <span id="search_container">
	          <input id="search" placeholder="Search for a patient"/>
	        </span>
	          <span id="srch_name" data-method="lastfirst" class="button active">Name</span>
	          <span id="srch_acid" data-method="accountid" class="button">Account ID</span>
              <span id="srch_ppid" data-method="practpatientid" class="button">PracticePatient ID</span>
              <select id="srch_multi" class="dropkick" data-dk_minwidth="true">
                <option value="statementpin">Statement PIN</option>
                <option value="claimid">Encounter</option>
                <option value="patientssn">SSN</option>
                <option value="patientdob">DOB</option>
                <option value="email">Email</option>
                <option value="phone">Phone</option>
                <option value="address">Address</option>
              </select>
            <?/*<span id="srch_add" data-method="address" class="button">Address</span>
            <span id="srch_claim" data-method="claimid" class="button">Claim</span>
	          
	          
	          <span id="srch_pssn" data-method="patientssn" class="button">SSN</span>
            <span id="srch_pdob" data-method="patientdob" class="button">DOB</span>
            <span id="srch_phone" data-method="phone" class="button">Phone</span>*/?>
            
	      </div>
	      <div id="callbacks_queue">
  	     <!--   <span id="callbacks">Callbacks</span>--><span id="queue_btn"><span id="qbtn_name" data-clientid=''>All Clients</span><img src="/assets/images/arrowdown.png"/>
  	        <ul id="clientlist">
                <li data-clientid-''>All Clients</li>
  	          <?foreach ($clients as $client) {?>
                <li data-clientid="<?=$client['clientid']?>"><?=$client['clientname']?></li>
              <?}?>
  	        </ul></span><span id="queue_button" class="button">Queue</span>
  	      </div>
  	    </div>
	    <div id="par_subhead">
	      <span id="load_indicator">Loading...</span>
          <span id="collections_info">My Collections - <b><?=pfmoney::toFromCents($collections_today)?></b></span>
        <div id='parstatus_dropdown'>
          <div id='psdd_toggle'>
            <script type='text/javascript'>
              $(function(){
                pf.onReady(function(){
                  pf.user.status = "<?=$myStatus['status']?>";
                });
              });
            </script>
            <span id="employee_info" class='available' data-emp_id="<?= $userdata['id'] ?>" data-emp_fname="<?= $userdata['firstname'] ?>" data-emp_lname="<?= $userdata['lastname'] ?>"><span>(<?=strtolower(str_replace('Not Available - ','',$myStatus['decode']))?>) - <b chron="<?=strtotime($myStatus['createddate'])?>"></b></span><em></em><?= $userdata['firstname'] ?> <?= $userdata['lastname'] ?> <b class='entypo'></b></span>
          </div>
          <ul id='psdd_list'>
            <?foreach($parstatuses as $parstatus){
              if($parstatus['class']=='busy') continue;
              ?>
            <li data-code="<?=$parstatus['code']?>" class="<?=$parstatus['class']?>"><em></em><?=str_replace('Not Available - ', '', $parstatus['decode'])?> <span><?
                foreach($today as $status) {
                    //Let's add the time for each one of these statuses if we've been in it so far.
                    if($status['status'] === $parstatus['code']){
                        ?>(<?=pfutil::toTime($status['total'])?>)<?
                    }
                }
            ?></span></li>
            <?}?>
            <li id="parscreen_logout"><em></em>Log Out</li>
          </ul>
        </div>
        <!--<div id="subhead_tools">
          -
  	      <span id="subhead_wq" class="tool">
  	        <span id="wq_menu_open" class="clickable">Work Queues<span class="orgicon"></span></span>
  	        <div id="work_queue_dropdown" class="dropdown">
  	          <ul id="wq_list">
  	            <li id="wq_myqueue">My Queue</li>
  	            <li id="wq_addtask">Add a task</li>
  	          </ul>
  	        </div>
          </span>
        </div>-->
	    </div>
	  </header>
	  <div id="account_details">
	    <div id="account_details_container" class="default">
	      <div class= 'no_account'>
          No account loaded.
        </div>
      </div>
      <div id="comm_history_container" class="default">
      </div>
    </div>
	  <div id="par_bottom">
	    <div id="par_leftwing">
        <div id="par_leftwing_container">
          <div id="par_notes" class="default"></div>
          <div id="par_payment" class="default"></div>
        </div>
	    </div>
	    <div id="par_centeraisle">
	      <div id="par_transactions" class="default"></div>
	    </div>
	    <div id="par_centeraisle_overlay">
	    	<div id="taskcomments"></div>
	    </div>
	    <div id="par_rightwing">
	      <div id="par_rightwing_controls" class="blaccent">
	        <div id="prc_callbar" class="active">Call Controls</div>
	        <div id="prc_queue">Work Queue</div>
	      </div>
	      <div id="par_rightwing_container" class="default">
	        <div id="par_callbar" class="default">
  	      </div>
          <div id="par_taskqueue" class="default">
  	      </div>
	      </div>
	    </div>
	  </div>
	</body>
</html>

Open in new window


Based on the input y'all have given me thus far, I'm thinking I need to track down where accounts.js is coming from in order to get a better grasp on "loadView."

accounts.js is not listed at all as you can see above, but it is listed as part of the pf.js code. I've got that below. I'm thinking lines 15-19 are a big step in the right direction:

if(typeof pf === 'undefined') {
    pf = {};
}
pf.merge = function (object2) {
    for (var prop in object2) {
        this[prop] = object2[prop];
    }
}

// PatientFocus Javascript Library
pf.merge({

//==PROPERTIES==//

  included : [
  //Add any reference to a file (in the pf folder, or a subdirectory) that should be loaded into the library
  //NOTE: for testing purposes (before you're ready to add a file to the library), you can call pf.include() directly
    "util.js","accounts.js","tickets.js","calls.js","sounds.js", "apps.js",/*"charts.js","filters.js",*/"tasks.js","user.js","transactions.js","tables.js"
    ],
  path : "/assets/js/pf/",
  isReady : false,
  loading : {},
  dataObj : {
    SERVER_TIME_OFFSET : 0
  },
  ready : [],
  viewReady : [],
//==METHODS==//

  init : function(){
    //Fires once the js doc is loaded.
    //$.ajaxSetup({ cache: false });
    pf.include(pf.included, pf.ready);
    pf.onReady(function(){
      for(var k in pf.util.plugins.autoload){
        var plug = pf.util.plugins.autoload[k];
        //run each plugin once.
        if(typeof pf.util.plugins[plug] == "function"){
          pf.util.plugins[plug]();
        }
      }

      $(window).unload(function(){
        pf.user.setStatus('NA',false,false);
      });
    });

    // set up HTML5/4 history module
    pf.history = window.History;
    pf.onReady(function(){
      //run viewReady
      pf._runVR();
    });

    $.ajaxSetup({
      cache:false
    });

    /*pf.ajax({
        url:'/dmz/now',
        success:function(server_timestamp){
            var client_time = new Date().getTime(),
                server_time = new Date(server_timestamp).getTime();

            pf.data('SERVER_TIME_OFFSET', server_time - client_time);
        }
    });*/

  },
  search : function(searchmethod, searchterm, callback){
    pf.ajax({
      url : "/parscreen/searchresults/",
      timeout : 10000,
      type : "POST",
      data : {"method":searchmethod,"term":searchterm},
      dataType : "json",
      success : function(data){
        //console.log(data);
        if(data.loadaccount){
          if(data.accountid){
              //one result
              pf.accounts.loadAccount(data.accountid);
          } else {
            //no results
            pf.accounts.loadAccount();
            $("#par_transactions").loadView(data.searchhtml, "html");
          }
        } else {
          //multiple results
          $("#par_transactions").loadView(data.searchhtml, "html");
        }

        if(callback){
          callback();
        }
      }
    });
  },
  _runVR : function(){
    for(var i in pf.viewReady){
      if(typeof pf.viewReady[i] == "function") pf.viewReady[i]();
    }
  },
  include : function(paths, callback){
    //Include a js file or array of files
    if(typeof require != 'undefined') {

        for(var i = 0; i < paths.length; i++){
            var path = 'pf.' + paths[i].split('.')[0];
            paths[i] = path;
        }

        require(paths, function(){
            if(!pf.isReady){
              //Initial load of library.
              pf.isReady = true;
              for(var i in pf.ready){
                if(typeof pf.ready[i] == "function"){
                  pf.ready[i]();
                }
              }
            }

            if(typeof callback == "function"){
              callback();
            }
        });

    } else {

        if (typeof paths == "string"){
          assetLoad(paths, callback);
        } else {
            var count = 0;
            var len = paths.length;
            var callbackcheck = function(){
              count++;
              if (count == len){
                if(!pf.isReady){
                  //Initial load of library.
                  pf.isReady = true;
                  for(var i in pf.ready){
                    if(typeof pf.ready[i] == "function"){
                      pf.ready[i]();
                    }
                  }
                }
                if(typeof callback == "function"){
                  callback();
                }
              }
            };

            for(var j=0; j<paths.length; j++){
              var path = paths[j];
              assetLoad(paths[j], callbackcheck);
            }
        }

    }

    function assetLoad(loc, callback2){
      // Check if that asset is already loaded
      var ext = loc.split(".")[loc.split(".").length-1];
      var time = new Date().getTime();
      loc = loc + "?" + time;
      //console.log(loc);
      //console.log(ext);
      var tag, attr, attrval, src;
      if(ext=="js"){
        tag = "script";
        attr = "type";
        attrval = "text/javascript";
        src = "src";
      } else if(ext=="css"){
        tag = "style";
        attr = "type";
        attrval = "text/css";
        src = "href";
      } else {
        return;
      }
      var scripts = document.getElementsByTagName(tag);
      for(i=0; i<scripts.length; i++){
        //Delete the current reference, to rerun the javscript.
        if(scripts[i].getAttribute(src)?scripts[i].getAttribute(src).split("?")[0]==loc.split("?")[0]:false) scripts[i].parentNode.removeChild(scripts[i]);
      }
      var e=document.createElement(tag);
      e.setAttribute(attr,attrval);
      e.setAttribute(src,pf.path+loc);
      document.getElementsByTagName('head')[0].appendChild(e);
      if (typeof callback2 == "function"){
        var done = false;
        e.onload = function(){
          if(!done){
            done=true;
            callback2();
          }
        };
        e.onreadystatechange = function(){
           if(!done && (this.readyState === "complete" || this.readyState === "loaded")){
              done=true;
              callback2();
            }
        };
      }
    }
  },
  onReady : function(func){
    if(pf.isReady){
      if(typeof func=="function") func();
    } else {
      pf.ready.push(func);
    }
  },
  onViewReady : function(func){
    pf.viewReady.push(func);
  },
  ajaxinc : 0,
  ajax : function(ajaxObj){
    //This function is to be used just like $.ajax() but it will also register a loading class to the html tag.
    var name = ajaxObj.name || "load" + (pf.ajaxinc);
    pf.ajaxinc++;

    var complete = ajaxObj.complete ? ajaxObj.complete : false;
    var success  = ajaxObj.success  ? ajaxObj.success  : false;
    var error    = ajaxObj.error    ? ajaxObj.error    : false;

    var show_loading = (typeof ajaxObj.showLoading === 'undefined')? true : ajaxObj.showLoading;

    var cache = $.ajaxSettings.cache;
    var directive_checked = false;

    var check_for_directive = function(response) {
        try{

            if(directive_checked === false) {
                directive_checked = true;

                var json_test = typeof response === 'string' ? JSON.parse(response) : response;
                if (typeof json_test != 'object') throw "Must be parseable json to be a directive";

                if(typeof json_test['__SERVER__'] !== 'undefined') {

                    //These are system directives.
                    switch(json_test['__SERVER__']){
                        case 'logout':
                            window.location = '/logout';
                            break;
                        case 'redirect':
                            window.location = json_test['__SERVERDATA__'];
                            break;
                        case 'message':
                            pf.dialog(json_test['__SERVERDATA__']);
                            break;
                    }
                }
            }
        } catch (e) {
            //do nothing
        }
    }

    if (show_loading) $("html").addClass("loading");

    //PROVIDE PROGRESS FUNCTIONALITY :: REQUIRES CONTENT-TYPE TO BE SET IN HEADER.
    var xhr = $.ajaxSettings.xhr();
    
    if(ajaxObj.progress){
      xhr.addEventListener("progress", function(evt){
        //console.log(evt);
          if (evt.lengthComputable) {
              var percentComplete = evt.loaded / evt.total;
                //Do something with download progress
                //console.log('herlo');
              ajaxObj.progress(percentComplete,evt.total, evt.loaded);
            }
         }, false);
    }

    //Store the XHR in a closure.
    function xhrProvider() { return xhr; }
    ajaxObj.xhr = xhrProvider;

    //END PROGRESS FUNCTIONALITY

    //Avoid caching in POST type requests
    if(!cache&&ajaxObj.type&&ajaxObj.type.toLowerCase()==='post'){
      var d = new Date();
      var timestamp = d.getTime();
      if(ajaxObj.url&&ajaxObj.url.match(/[\?]/g)){
        ajaxObj.url = ajaxObj.url+'&_='+timestamp;
      } else if(ajaxObj.url) {
        ajaxObj.url = ajaxObj.url+'?_='+timestamp;
      } else ajaxObj.url = '?_='+timestamp;
    }

    //Completion wrappers
    ajaxObj.complete = function(data){
      if (show_loading) delete pf.loading[name];
      if(pf.util.getKeys(pf.loading).length === 0){
        $("html").removeClass("loading");
      }

      check_for_directive(data.responseText);

      if(complete){
        complete(data);
      }
    };
    ajaxObj.success = function(data){
        check_for_directive(data);
        if(success){
            success(data);
        }
    };

    if(pf.loading[name]){
      pf.loading[name].abort();
    }

    ajaxObj.error = function(x, y, z){

      check_for_directive(x.responseText);

      if(error){
        error(x,y,z);
      }

      if(y=="timeout"){
        mess = ajaxObj.timeoutMessage || "An ajax request has timed out...";
        if(ajaxObj.reportError || ajaxObj.timeoutMessage) pf.dialog(mess,'Ajax Error');
      }
    };

    var resp = $.ajax(ajaxObj);
    if (show_loading) pf.loading[name] = resp;
    return resp;
  },
  data : function(key, value){
    //used to store data in the pf namespace, modelled after $('').data()
    if(typeof value != "undefined"){
      if(typeof key == "string"){
        pf.dataObj[key] = value;
      } else {
        console.error("Illegal pf.data assignment.\nKey : " + key + "\nValue : "+value);
      }
    } else if(typeof key == "object"){
      for (var k in key){
        if(typeof k == "string" && typeof key[k] != "undefined"){
          pf.dataObj[k] = key[k];
        } else {
          console.error("Illegal pf.data assignment.\nKey : " + key + "\nValue : "+value);
        }
      }
    } else {
      if(typeof key == "string"){
        return pf.dataObj[key];
      } else if(typeof key == "undefined"){
        return pf.dataObj;
      } else {
          console.error("Illegal pf.data key.\nKey : " + key);
      }
    }
  },
  removeData : function(key){
    delete pf.dataObj[key];
  },
  dqueue : {},
  dialog : function(message, title, type, callback, clas){
    title='<span class="modal_icon entypo">⚠</span>' + (title||"PatientFocus Dialog");
    type = type || "";
    var container;
    var name = "dialog"+(new Date().getTime());

    if(!$("#pfdialog").length){
      stage = $("<div id='pfdialog' style='display:none;'></div>");
      container = $("<div id='pfdialogcontainer'></div>");
      stage.append(container);
      $("body").append(stage);
      $(window).on('resize.sizeContainer', function(){
        container.css("line-height",window.innerHeight + 'px');
      });
    } else {
      container = $("#pfdialogcontainer");
    }
    container.css("line-height", window.innerHeight + 'px');


    var dialog = $("<div id='pfdialog_window' "+(clas?"class='"+clas+"'":'')+"><div id='pfdialogheader'><div class='closedialog entypo'>❌</div>"+title+"</div><div id='pfdialogbody'></div><div id='pfdialog_buttons'></div></div>");
    dialog.data('name',name);
    dialog.find('.closedialog').click(pf.closeDialog);
    if(message instanceof jQuery){
      //NOTE:: script tags will run BEFORE content loads no matter what if you pass a jQuery object.
      //Just a quirk of jQuery
      dialog.find('#pfdialogbody').append(message);
    } else {
      if(typeof message != 'String' && message.innerHTML){
        var d = document.createElement('div');
        d.appendChild(message);
        message = d.innerHTML;
      }
      dialog.find('#pfdialogbody')[0].innerHTML = message;
    }

    if(typeof type == "object"){
      for(var k in type){
        var fnc = type[k];
        var btn = $("<button type='button' class='"+(fnc===true?'cancel':'ok')+" button'>"+k+"</button>");
        var close = false;
        var closer = '';
        if(typeof fnc === "function"){
          closer = function(){
            if(fnc(dialog)) closeDialog(dialog);
          };
        } else {
          closer = function(){
            if(fnc) closeDialog(dialog);
          };
        }
        btn.on('click.closeDialog',closer);
        dialog.find("#pfdialog_buttons").append(btn);
      }
    } else {
      var ok = false;
      switch(type.toLowerCase()){
        case "choice":
          var cancel =  $("<button type='button' class='cancel button'>Cancel</button>");
          cancel.on('click.closeDialog', function(){
            closeDialog(dialog);
          });
          dialog.find("#pfdialog_buttons").append(cancel);

          ok = $("<button type='button' class='ok button'>Ok</button>");
          ok.on('click.closeDialog', function(){
            closeDialog(dialog);
            if(typeof callback == "function"){
              callback(dialog);
            }
          });
          dialog.find("#pfdialog_buttons").append(ok);
          break;
        case "notification":
            ok = $("<button type='button' class='ok button'>Ok</button>");
            ok.on('click.closeDialog', function(){
              closeDialog(dialog);
              if(typeof callback == "function"){
                callback();
              }
            });
            dialog.find("#pfdialog_buttons").append(ok);
          break;
        default:
            ok = $("<button type='button' class='ok button'>Ok</button>");
            ok.on('click.closeDialog', function(){
              closeDialog(dialog);
              if(typeof callback == "function"){
                callback();
              }
            });
            dialog.find("#pfdialog_buttons").append(ok);
          break;
      }
    }
    pf.dqueue[name] = dialog;
    if(pf.util.getKeys(pf.dqueue).length==1){
      showDialog(dialog);
    }

    function closeDialog(dialog){
      if(pf.util.getKeys(pf.dqueue).length>1){
        container.fadeOut(function(){
          delete pf.dqueue[name];
          container.css('display','block');
          dialog.remove();
          setTimeout(function(){
            showDialog(pf.dqueue[pf.util.getKeys(pf.dqueue)[0]]);
          },1);
        });
      } else {
        stage.fadeOut();
        container.fadeOut(function(){
          delete pf.dqueue[name];
          dialog.remove();
          container.css('display','block');
          if(pf.util.getKeys(pf.dqueue).length) showDialog(pf.dqueue[pf.util.getKeys(pf.dqueue)[0]]);
        });
      }
    }

    function showDialog(dialog){
      stage.fadeIn();
      container.append(dialog).fadeIn();
    }

  },//end dialog
  closeDialog : function(){
    var container = $("#pfdialogcontainer");
    var dialog = $('#pfdialog_window');
    var name = dialog.data('name');
    if(pf.util.getKeys(pf.dqueue).length>1){
      container.fadeOut(function(){
        delete pf.dqueue[name];
        container.css('display','block');
        dialog.remove();
        setTimeout(function(){
          showDialog(pf.dqueue[pf.util.getKeys(pf.dqueue)[0]]);
        },1);
      });
    } else {
      stage.fadeOut();
      container.fadeOut(function(){
        delete pf.dqueue[name];
        dialog.remove();
        container.css('display','block');
        if(pf.util.getKeys(pf.dqueue).length) showDialog(pf.dqueue[pf.util.getKeys(pf.dqueue)[0]]);
      });
    }

    function showDialog(dialog){
      stage.fadeIn();
      container.append(dialog).fadeIn();
    }
  },
  loadView : function(container, view, method, callback){
    if(typeof container == 'string') container = $(container);
    container.loadView(view, method, function(){
      //run viewReady.
      pf._runVR();
      if(typeof callback == "function") callback();
    });
  }
}); //end pf

pf.init();

Open in new window


It looks as though they're "included," so perhaps that's the top button of all this. Thing is, I see "loadView" on lines 86 and 90, but not in a way that "defines" that functionality. I did, however, find this on line 525:

oadView : function(container, view, method, callback){
    if(typeof container == 'string') container = $(container);
    container.loadView(view, method, function(){
      //run viewReady.
      pf._runVR();
      if(typeof callback == "function") callback();
    });
  }

Open in new window


What is that?
That loadView - is just offloading to another loadView
 container.loadView(view, method, function(){

Open in new window

Which is being called on the jQuery container for the element. This explains the lines 49 and 50 implementation that calls loadView outside of the pf class.

We need to track down where the root loadView is coming from.

I am going to guess it is from here

		<script type="text/javascript" src="/assets/js/jquery.loadView.js"></script>

Open in new window

So if we could have a look at that file we might make some progress ...
Here it is:

(function($){
  //jQuery/Codeigniter plugin.  Pass it a path to a controller which builds a view, or a view (and declare the method "html"), 
  $.fn.loadView = function(viewdata, method, callback){
    method = method || "controller";
    var container = $(this);
    //Delete the current view and remove all associated assets
    if(container.data('assets')){
      $.each(container.data('assets'), function(k,v){
        //Assumes k is the class name and v is the type (css or js)
        //$("."+k).remove();
      });
    }
    
    if(!(container.data('default')) && container.hasClass('default')){
      container.data('default', container.html());
      container.removeClass('default');
    }

    //Load new view based on method
    switch(method.toLowerCase()){
      case "controller":
        pf.ajax({
          url:viewdata,
          success: function(data){
            container.fadeOut(200, function(){
              if(data) container.html(data);
              else if(container.data('default')) container.html(container.data('default'));
              else container.html('')

              if(typeof callback == "function") setTimeout(function(){callback(viewdata, container)},1);
              container.fadeIn(200);
            });

          },
          error: function(data){
            container.fadeOut(function(){
              container.html("<div class='loadViewError'><h1>Error</h1><p>Sorry, there has been an issue processing your request. Please try again. If the problem persists, please contact a system administrator.</p><p>"+data+"</p></div>");
              console.error("There's been an error processing your request to " + viewdata + " :");
              console.error(data);
              container.fadeIn();
            });
          }
        });
        break;
      case "html":
        container.fadeOut(200, function(){
          container.html(viewdata);
          container.fadeIn(200);
          if(typeof callback == "function") setTimeout(function(){callback(viewdata, container)},1);
        });
        break;
      default:
        container.fadeOut(200, function(){
          container.html("<div class='loadViewError'><h1>Error</h1><p>Sorry, there has been an issue processing your request. Please try again. If the problem persists, please contact a system administrator.</p><p>Attempted to load view with unknown method: "+method+"</p></div>");
          container.fadeIn(200);
        });
        break;
    }
  }
})(jQuery);

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you!
You are always welcome.