Skip to content

Commit

Permalink
3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipskevin committed May 19, 2017
1 parent 41637ff commit 3b00925
Show file tree
Hide file tree
Showing 3 changed files with 383 additions and 0 deletions.
90 changes: 90 additions & 0 deletions dist/amd/can-stache-converters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*can-stache-converters@3.0.7#can-stache-converters*/
define(function (require, exports, module) {
var stache = require('can-stache');
var stringToAny = require('can-util/js/string-to-any');
var makeArray = require('can-util/js/make-array');
require('can-stache-bindings');
stache.registerConverter('boolean-to-inList', {
get: function (item, list) {
if (!list) {
return false;
} else {
return list.indexOf(item) !== -1;
}
},
set: function (newVal, item, list) {
if (!list) {
return;
}
if (!newVal) {
var idx = list.indexOf(item);
if (idx !== -1) {
list.splice(idx, 1);
}
} else {
list.push(item);
}
}
});
stache.registerConverter('string-to-any', {
get: function (compute) {
return '' + compute();
},
set: function (newVal, compute) {
var converted = stringToAny(newVal);
compute(converted);
}
});
stache.registerConverter('not', {
get: function (compute) {
return !compute();
},
set: function (newVal, compute) {
compute(!newVal);
}
});
stache.registerConverter('index-to-selected', {
get: function (item, list) {
var val = item.isComputed ? item() : item;
var idx = list.indexOf(val);
return idx;
},
set: function (idx, item, list) {
var newVal = list[idx];
if (newVal !== -1 && item.isComputed) {
item(newVal);
}
}
});
stache.registerConverter('either-or', {
get: function (chosen, a, b) {
return b !== chosen();
},
set: function (newVal, chosen, a, b) {
chosen(newVal ? a : b);
}
});
stache.registerConverter('equal', {
get: function () {
var args = makeArray(arguments);
if (args.length > 1) {
var comparer = args.pop();
return args.every(function (compute) {
return (compute && compute.isComputed ? compute() : compute) === comparer;
});
}
},
set: function () {
var args = makeArray(arguments);
if (args.length > 2) {
var b = args.shift();
var comparer = args.pop();
if (b) {
for (var i = 0; i < args.length; i++) {
args[i](comparer);
}
}
}
}
});
});
88 changes: 88 additions & 0 deletions dist/cjs/can-stache-converters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*can-stache-converters@3.0.7#can-stache-converters*/
var stache = require('can-stache');
var stringToAny = require('can-util/js/string-to-any/string-to-any');
var makeArray = require('can-util/js/make-array/make-array');
require('can-stache-bindings');
stache.registerConverter('boolean-to-inList', {
get: function (item, list) {
if (!list) {
return false;
} else {
return list.indexOf(item) !== -1;
}
},
set: function (newVal, item, list) {
if (!list) {
return;
}
if (!newVal) {
var idx = list.indexOf(item);
if (idx !== -1) {
list.splice(idx, 1);
}
} else {
list.push(item);
}
}
});
stache.registerConverter('string-to-any', {
get: function (compute) {
return '' + compute();
},
set: function (newVal, compute) {
var converted = stringToAny(newVal);
compute(converted);
}
});
stache.registerConverter('not', {
get: function (compute) {
return !compute();
},
set: function (newVal, compute) {
compute(!newVal);
}
});
stache.registerConverter('index-to-selected', {
get: function (item, list) {
var val = item.isComputed ? item() : item;
var idx = list.indexOf(val);
return idx;
},
set: function (idx, item, list) {
var newVal = list[idx];
if (newVal !== -1 && item.isComputed) {
item(newVal);
}
}
});
stache.registerConverter('either-or', {
get: function (chosen, a, b) {
return b !== chosen();
},
set: function (newVal, chosen, a, b) {
chosen(newVal ? a : b);
}
});
stache.registerConverter('equal', {
get: function () {
var args = makeArray(arguments);
if (args.length > 1) {
var comparer = args.pop();
return args.every(function (compute) {
return (compute && compute.isComputed ? compute() : compute) === comparer;
});
}
},
set: function () {
var args = makeArray(arguments);
if (args.length > 2) {
var b = args.shift();
var comparer = args.pop();
if (b) {
for (var i = 0; i < args.length; i++) {
args[i](comparer);
}
}
}
}
});
205 changes: 205 additions & 0 deletions dist/global/can-stache-converters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
/*[global-shim-start]*/
(function(exports, global, doEval){ // jshint ignore:line
var origDefine = global.define;

var get = function(name){
var parts = name.split("."),
cur = global,
i;
for(i = 0 ; i < parts.length; i++){
if(!cur) {
break;
}
cur = cur[parts[i]];
}
return cur;
};
var set = function(name, val){
var parts = name.split("."),
cur = global,
i, part, next;
for(i = 0; i < parts.length - 1; i++) {
part = parts[i];
next = cur[part];
if(!next) {
next = cur[part] = {};
}
cur = next;
}
part = parts[parts.length - 1];
cur[part] = val;
};
var useDefault = function(mod){
if(!mod || !mod.__esModule) return false;
var esProps = { __esModule: true, "default": true };
for(var p in mod) {
if(!esProps[p]) return false;
}
return true;
};
var modules = (global.define && global.define.modules) ||
(global._define && global._define.modules) || {};
var ourDefine = global.define = function(moduleName, deps, callback){
var module;
if(typeof deps === "function") {
callback = deps;
deps = [];
}
var args = [],
i;
for(i =0; i < deps.length; i++) {
args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) );
}
// CJS has no dependencies but 3 callback arguments
if(!deps.length && callback.length) {
module = { exports: {} };
var require = function(name) {
return exports[name] ? get(exports[name]) : modules[name];
};
args.push(require, module.exports, module);
}
// Babel uses the exports and module object.
else if(!args[0] && deps[0] === "exports") {
module = { exports: {} };
args[0] = module.exports;
if(deps[1] === "module") {
args[1] = module;
}
} else if(!args[0] && deps[0] === "module") {
args[0] = { id: moduleName };
}

global.define = origDefine;
var result = callback ? callback.apply(null, args) : undefined;
global.define = ourDefine;

// Favor CJS module.exports over the return value
result = module && module.exports ? module.exports : result;
modules[moduleName] = result;

// Set global exports
var globalExport = exports[moduleName];
if(globalExport && !get(globalExport)) {
if(useDefault(result)) {
result = result["default"];
}
set(globalExport, result);
}
};
global.define.orig = origDefine;
global.define.modules = modules;
global.define.amd = true;
ourDefine("@loader", [], function(){
// shim for @@global-helpers
var noop = function(){};
return {
get: function(){
return { prepareGlobal: noop, retrieveGlobal: noop };
},
global: global,
__exec: function(__load){
doEval(__load.source, global);
}
};
});
}
)({},window,function(__$source__, __$global__) { // jshint ignore:line
eval("(function() { " + __$source__ + " \n }).call(__$global__);");
}
)
/*can-stache-converters@3.0.7#can-stache-converters*/
define('can-stache-converters', function (require, exports, module) {
var stache = require('can-stache');
var stringToAny = require('can-util/js/string-to-any/string-to-any');
var makeArray = require('can-util/js/make-array/make-array');
require('can-stache-bindings');
stache.registerConverter('boolean-to-inList', {
get: function (item, list) {
if (!list) {
return false;
} else {
return list.indexOf(item) !== -1;
}
},
set: function (newVal, item, list) {
if (!list) {
return;
}
if (!newVal) {
var idx = list.indexOf(item);
if (idx !== -1) {
list.splice(idx, 1);
}
} else {
list.push(item);
}
}
});
stache.registerConverter('string-to-any', {
get: function (compute) {
return '' + compute();
},
set: function (newVal, compute) {
var converted = stringToAny(newVal);
compute(converted);
}
});
stache.registerConverter('not', {
get: function (compute) {
return !compute();
},
set: function (newVal, compute) {
compute(!newVal);
}
});
stache.registerConverter('index-to-selected', {
get: function (item, list) {
var val = item.isComputed ? item() : item;
var idx = list.indexOf(val);
return idx;
},
set: function (idx, item, list) {
var newVal = list[idx];
if (newVal !== -1 && item.isComputed) {
item(newVal);
}
}
});
stache.registerConverter('either-or', {
get: function (chosen, a, b) {
return b !== chosen();
},
set: function (newVal, chosen, a, b) {
chosen(newVal ? a : b);
}
});
stache.registerConverter('equal', {
get: function () {
var args = makeArray(arguments);
if (args.length > 1) {
var comparer = args.pop();
return args.every(function (compute) {
return (compute && compute.isComputed ? compute() : compute) === comparer;
});
}
},
set: function () {
var args = makeArray(arguments);
if (args.length > 2) {
var b = args.shift();
var comparer = args.pop();
if (b) {
for (var i = 0; i < args.length; i++) {
args[i](comparer);
}
}
}
}
});
});
/*[global-shim-end]*/
(function(){ // jshint ignore:line
window._define = window.define;
window.define = window.define.orig;
}
)();

0 comments on commit 3b00925

Please sign in to comment.