module.exports = function destGet($el, destStr) { // reference to the bbmv var bbmvInstance = this.bbmvInstance; // parse out dest string using the method // in order to get the in-cache version // GET ONLY THE FIRST :) var dest = this.parseDestStr(destStr)[0]; // dest: // - method // - args // - format // - selector (to be ignored) /////////////////////// // element retrieval // /////////////////////// // if selector is defined, // ge tthe right $el $el = dest.selector ? $el.find(dest.selector) : $el; ////////////////////// // method retrieval // // and execution // ////////////////////// // get the method var methodName = dest.method, methodArgs = _.clone(dest.args), value = pipeAux.executeMethod(bbmvInstance, $el, methodName, methodArgs); //////////////// // formatting // //////////////// // check if a format was defined value = dest.format ? pipeAux.format(bbmvInstance, $el, 'in', dest.format, value) : value; return value; };
/** * [destSetSingle description] * @param {[type]} bbmvInstance * The instance of bbmv to which this pipe is * attached. * @param {[type]} $el * Destination element on which set the value * @param {[type]} dest [description] * @param {[type]} value [description] * @return {[type]} [description] */ function destSetSingle(bbmvInstance, $el, dest, value) { // bb // if $el is active, do not set it. if ($el.is(':focus')) { return; } // dest: // - method // - args // - format // - selector (to be ignored) ////////////////////// // value formatting // ////////////////////// value = dest.format ? pipeAux.format(bbmvInstance, $el, 'out', dest.format, value) : value; /////////////////////// // element retrieval // /////////////////////// // if therer is a selector defined, // call the find method on the dest object. $el = dest.selector ? $el.find(dest.selector) : $el; ////////////////////// // method execution // ////////////////////// // clone the args array, so that the original one remains untouched // AND add the value to the arguments array var methodArgs = _.clone(dest.args); methodArgs.push(value); // execute the method var methodName = dest.method; return pipeAux.executeMethod(bbmvInstance, $el, methodName, methodArgs); }