123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>The source code</title>
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
- <style type="text/css">
- .highlight { display: block; background-color: #ddd; }
- </style>
- <script type="text/javascript">
- function highlight() {
- document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
- }
- </script>
- </head>
- <body onload="prettyPrint(); highlight();">
- <pre class="prettyprint lang-js"><span id='Ext-direct-RemotingMethod'>/**
- </span> * Small utility class used internally to represent a Direct method.
- * @private
- */
- Ext.define('Ext.direct.RemotingMethod', {
- constructor: function(config){
- var me = this,
- params = Ext.isDefined(config.params) ? config.params : config.len,
- name, pLen, p, param;
- me.name = config.name;
- me.formHandler = config.formHandler;
- if (Ext.isNumber(params)) {
- // given only the number of parameters
- me.len = params;
- me.ordered = true;
- } else {
- /*
- * Given an array of either
- * a) String
- * b) Objects with a name property. We may want to encode extra info in here later
- */
- me.params = [];
- pLen = params.length;
- for (p = 0; p < pLen; p++) {
- param = params[p];
- name = Ext.isObject(param) ? param.name : param;
- me.params.push(name);
- }
- }
- },
-
- getArgs: function(params, paramOrder, paramsAsHash){
- var args = [],
- i,
- len;
-
- if (this.ordered) {
- if (this.len > 0) {
- // If a paramOrder was specified, add the params into the argument list in that order.
- if (paramOrder) {
- for (i = 0, len = paramOrder.length; i < len; i++) {
- args.push(params[paramOrder[i]]);
- }
- } else if (paramsAsHash) {
- // If paramsAsHash was specified, add all the params as a single object argument.
- args.push(params);
- }
- }
- } else {
- args.push(params);
- }
-
- return args;
- },
- <span id='Ext-direct-RemotingMethod-method-getCallData'> /**
- </span> * Takes the arguments for the Direct function and splits the arguments
- * from the scope and the callback.
- * @param {Array} args The arguments passed to the direct call
- * @return {Object} An object with 3 properties, args, callback & scope.
- */
- getCallData: function(args){
- var me = this,
- data = null,
- len = me.len,
- params = me.params,
- callback,
- scope,
- name;
- if (me.ordered) {
- callback = args[len];
- scope = args[len + 1];
- if (len !== 0) {
- data = args.slice(0, len);
- }
- } else {
- data = Ext.apply({}, args[0]);
- callback = args[1];
- scope = args[2];
- // filter out any non-existent properties
- for (name in data) {
- if (data.hasOwnProperty(name)) {
- if (!Ext.Array.contains(params, name)) {
- delete data[name];
- }
- }
- }
- }
- return {
- data: data,
- callback: callback,
- scope: scope
- };
- }
- });
- </pre>
- </body>
- </html>
|