{I" class:ETI"BundledAsset;FI"logical_path;TI"spree/backend/admin.js;FI" pathname;TI"s/usr/local/rvm/gems/ruby-2.0.0-p481/gems/spree_backend-2.2.4/app/assets/javascripts/spree/backend/admin.js.erb;FI"content_type;TI"application/javascript;TI" mtime;Tl+Æ‘TI" length;Tiú2I" digest;TI"%a212f19a68a7b085de217e94a24b2ec1;FI" source;TI"ú2 /** This is a collection of javascript functions and whatnot under the spree namespace that do stuff we find helpful. Hopefully, this will evolve into a propper class. **/ jQuery(function($) { // Vertical align of checkbox fields $('.field.checkbox label').vAlign() $('.main-menu-wrapper ul').AdaptiveMenu({ text: " " + Spree.translations.more + "", klass: "dropdown" }); // Add some tips $('.with-tip').powerTip({ smartPlacement: true, fadeInTime: 50, fadeOutTime: 50, }); $('body') .on('powerTipPreRender', '.with-tip', function() { $('#powerTip').addClass($(this).data('action')); $('#powerTip').addClass($(this).data('tip-color')); }) .on('powerTipClose', '.with-tip', function() { $('#powerTip').removeClass($(this).data('action')); }) // Make flash messages dissapear setTimeout('$(".flash").fadeOut()', 5000); // Highlight hovered table column $('table tbody tr td.actions a').hover(function(){ var tr = $(this).closest('tr'); var klass = 'highlight action-' + $(this).data('action') tr.addClass(klass) tr.prev().addClass('before-' + klass); }, function(){ var tr = $(this).closest('tr'); var klass = 'highlight action-' + $(this).data('action') tr.removeClass(klass) tr.prev().removeClass('before-' + klass); }); // Trunkate text in page_title that didn't fit var truncate_elements = $('.truncate'); truncate_elements.each(function(){ $(this).trunk8(); }); $(window).resize(function (event) { truncate_elements.each(function(){ $(this).trunk8(); }) }); // Make height of dt/dd elements the same $("dl").equalize('outerHeight'); }); $.fn.visible = function(cond) { this[cond ? 'show' : 'hide' ]() }; show_flash = function(type, message) { var flash_div = $('.flash.' + type); if (flash_div.length == 0) { flash_div = $('
'); $('#wrapper').prepend(flash_div); } flash_div.html(message).show().delay(5000).fadeOut(500); } // Apply to individual radio button that makes another element visible when checked $.fn.radioControlsVisibilityOfElement = function(dependentElementSelector){ if(!this.get(0)){ return } showValue = this.get(0).value; radioGroup = $("input[name='" + this.get(0).name + "']"); radioGroup.each(function(){ $(this).click(function(){ $(dependentElementSelector).visible(this.checked && this.value == showValue) }); if(this.checked){ this.click() } }); } handle_date_picker_fields = function(){ $('.datepicker').datepicker({ dateFormat: Spree.translations.date_picker, dayNames: Spree.translations.abbr_day_names, dayNamesMin: Spree.translations.abbr_day_names, firstDay: Spree.translations.first_day, monthNames: Spree.translations.month_names, prevText: Spree.translations.previous, nextText: Spree.translations.next, showOn: "focus" }); // Correctly display range dates $('.date-range-filter .datepicker-from').datepicker('option', 'onSelect', function(selectedDate) { $(".date-range-filter .datepicker-to" ).datepicker( "option", "minDate", selectedDate ); }); $('.date-range-filter .datepicker-to').datepicker('option', 'onSelect', function(selectedDate) { $(".date-range-filter .datepicker-from" ).datepicker( "option", "maxDate", selectedDate ); }); } $(document).ready(function(){ handle_date_picker_fields(); $(".observe_field").on('change', function() { target = $(this).data("update"); ajax_indicator = $(this).data("ajax-indicator") || '#busy_indicator'; $(target).hide(); $(ajax_indicator).show(); $.ajax({ dataType: 'html', url: $(this).data("base-url")+encodeURIComponent($(this).val()), type: 'get', success: function(data){ $(target).html(data); $(ajax_indicator).hide(); $(target).show(); } }); }); $('.spree_add_fields').click(function() { var target = $(this).data("target"); var new_table_row = $(target + ' tr:visible:last').clone(); var new_id = new Date().getTime(); new_table_row.find("input, select").each(function () { var el = $(this); el.val(""); el.prop("id", el.prop("id").replace(/\d+/, new_id)) el.prop("name", el.prop("name").replace(/\d+/, new_id)) }) // When cloning a new row, set the href of all icons to be an empty "#" // This is so that clicking on them does not perform the actions for the // duplicated row new_table_row.find("a").each(function () { var el = $(this); el.prop('href', '#'); }) $(target).prepend(new_table_row); }) $('body').on('click', '.delete-resource', function() { var el = $(this); if (confirm(el.data("confirm"))) { $.ajax({ type: 'POST', url: $(this).prop("href"), data: { _method: 'delete', authenticity_token: AUTH_TOKEN }, dataType: 'script', success: function(response) { el.parents("tr").fadeOut('hide', function() { $(this).remove(); }); }, error: function(response, textStatus, errorThrown) { show_flash('error', response.responseText); } }); } return false; }); $('body').on('click', 'a.spree_remove_fields', function() { el = $(this); el.prev("input[type=hidden]").val("1"); el.closest(".fields").hide(); if (el.prop("href").substr(-1) == '#') { el.parents("tr").fadeOut('hide'); }else if (el.prop("href")) { $.ajax({ type: 'POST', url: el.prop("href"), data: { _method: 'delete', authenticity_token: AUTH_TOKEN }, success: function(response) { el.parents("tr").fadeOut('hide'); }, error: function(response, textStatus, errorThrown) { show_flash('error', response.responseText); } }) } return false; }); $('body').on('click', '.select_properties_from_prototype', function(){ $("#busy_indicator").show(); var clicked_link = $(this); $.ajax({ dataType: 'script', url: clicked_link.prop("href"), type: 'get', success: function(data){ clicked_link.parent("td").parent("tr").hide(); $("#busy_indicator").hide(); } }); return false; }); // Fix sortable helper var fixHelper = function(e, ui) { ui.children().each(function() { $(this).width($(this).width()); }); return ui; }; $('table.sortable').ready(function(){ var td_count = $(this).find('tbody tr:first-child td').length $('table.sortable tbody').sortable( { handle: '.handle', helper: fixHelper, placeholder: 'ui-sortable-placeholder', update: function(event, ui) { $("#progress").show(); positions = {}; $.each($('table.sortable tbody tr'), function(position, obj){ reg = /spree_(\w+_?)+_(\d+)/; parts = reg.exec($(obj).prop('id')); if (parts) { positions['positions['+parts[2]+']'] = position; } }); $.ajax({ type: 'POST', dataType: 'script', url: $(ui.item).closest("table.sortable").data("sortable-link"), data: positions, success: function(data){ $("#progress").hide(); } }); }, start: function (event, ui) { // Set correct height for placehoder (from dragged tr) ui.placeholder.height(ui.item.height()) // Fix placeholder content to make it correct width ui.placeholder.html("") }, stop: function (event, ui) { // Fix odd/even classes after reorder $("table.sortable tr:even").removeClass("odd even").addClass("even"); $("table.sortable tr:odd").removeClass("odd even").addClass("odd"); } }); }); $('a.dismiss').click(function() { $(this).parent().fadeOut(); }); }); // lib/handlebars/base.js /*jshint eqnull:true*/ this.Handlebars = {}; (function(Handlebars) { Handlebars.VERSION = "1.0.rc.1"; Handlebars.helpers = {}; Handlebars.partials = {}; Handlebars.registerHelper = function(name, fn, inverse) { if(inverse) { fn.not = inverse; } this.helpers[name] = fn; }; Handlebars.registerPartial = function(name, str) { this.partials[name] = str; }; Handlebars.registerHelper('helperMissing', function(arg) { if(arguments.length === 2) { return undefined; } else { throw new Error("Could not find property '" + arg + "'"); } }); var toString = Object.prototype.toString, functionType = "[object Function]"; Handlebars.registerHelper('blockHelperMissing', function(context, options) { var inverse = options.inverse || function() {}, fn = options.fn; var ret = ""; var type = toString.call(context); if(type === functionType) { context = context.call(this); } if(context === true) { return fn(this); } else if(context === false || context == null) { return inverse(this); } else if(type === "[object Array]") { if(context.length > 0) { return Handlebars.helpers.each(context, options); } else { return inverse(this); } } else { return fn(context); } }); Handlebars.K = function() {}; Handlebars.createFrame = Object.create || function(object) { Handlebars.K.prototype = object; var obj = new Handlebars.K(); Handlebars.K.prototype = null; return obj; }; Handlebars.registerHelper('each', function(context, options) { var fn = options.fn, inverse = options.inverse; var ret = "", data; if (options.data) { data = Handlebars.createFrame(options.data); } if(context && context.length > 0) { for(var i=0, j=context.length; i 2) { expected.push("'" + this.terminals_[p] + "'"); } if (this.lexer.showPosition) { errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; } else { errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); } this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); } } if (action[0] instanceof Array && action.length > 1) { throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); } switch (action[0]) { case 1: stack.push(symbol); vstack.push(this.lexer.yytext); lstack.push(this.lexer.yylloc); stack.push(action[1]); symbol = null; if (!preErrorSymbol) { yyleng = this.lexer.yyleng; yytext = this.lexer.yytext; yylineno = this.lexer.yylineno; yyloc = this.lexer.yylloc; if (recovering > 0) recovering--; } else { symbol = preErrorSymbol; preErrorSymbol = null; } break; case 2: len = this.productions_[action[1]][1]; yyval.$ = vstack[vstack.length - len]; yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; if (ranges) { yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; } r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); if (typeof r !== "undefined") { return r; } if (len) { stack = stack.slice(0, -1 * len * 2); vstack = vstack.slice(0, -1 * len); lstack = lstack.slice(0, -1 * len); } stack.push(this.productions_[action[1]][0]); vstack.push(yyval.$); lstack.push(yyval._$); newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; stack.push(newState); break; case 3: return true; } } return true; } }; /* Jison generated lexer */ var lexer = (function(){ var lexer = ({EOF:1, parseError:function parseError(str, hash) { if (this.yy.parser) { this.yy.parser.parseError(str, hash); } else { throw new Error(str); } }, setInput:function (input) { this._input = input; this._more = this._less = this.done = false; this.yylineno = this.yyleng = 0; this.yytext = this.matched = this.match = ''; this.conditionStack = ['INITIAL']; this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0}; if (this.options.ranges) this.yylloc.range = [0,0]; this.offset = 0; return this; }, input:function () { var ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; this.match += ch; this.matched += ch; var lines = ch.match(/(?:\r\n?|\n).*/g); if (lines) { this.yylineno++; this.yylloc.last_line++; } else { this.yylloc.last_column++; } if (this.options.ranges) this.yylloc.range[1]++; this._input = this._input.slice(1); return ch; }, unput:function (ch) { var len = ch.length; var lines = ch.split(/(?:\r\n?|\n)/g); this._input = ch + this._input; this.yytext = this.yytext.substr(0, this.yytext.length-len-1); //this.yyleng -= len; this.offset -= len; var oldLines = this.match.split(/(?:\r\n?|\n)/g); this.match = this.match.substr(0, this.match.length-1); this.matched = this.matched.substr(0, this.matched.length-1); if (lines.length-1) this.yylineno -= lines.length-1; var r = this.yylloc.range; this.yylloc = {first_line: this.yylloc.first_line, last_line: this.yylineno+1, first_column: this.yylloc.first_column, last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: this.yylloc.first_column - len }; if (this.options.ranges) { this.yylloc.range = [r[0], r[0] + this.yyleng - len]; } return this; }, more:function () { this._more = true; return this; }, less:function (n) { this.unput(this.match.slice(n)); }, pastInput:function () { var past = this.matched.substr(0, this.matched.length - this.match.length); return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); }, upcomingInput:function () { var next = this.match; if (next.length < 20) { next += this._input.substr(0, 20-next.length); } return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); }, showPosition:function () { var pre = this.pastInput(); var c = new Array(pre.length + 1).join("-"); return pre + this.upcomingInput() + "\n" + c+"^"; }, next:function () { if (this.done) { return this.EOF; } if (!this._input) this.done = true; var token, match, tempMatch, index, col, lines; if (!this._more) { this.yytext = ''; this.match = ''; } var rules = this._currentRules(); for (var i=0;i < rules.length; i++) { tempMatch = this._input.match(this.rules[rules[i]]); if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { match = tempMatch; index = i; if (!this.options.flex) break; } } if (match) { lines = match[0].match(/(?:\r\n?|\n).*/g); if (lines) this.yylineno += lines.length; this.yylloc = {first_line: this.yylloc.last_line, last_line: this.yylineno+1, first_column: this.yylloc.last_column, last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length}; this.yytext += match[0]; this.match += match[0]; this.matches = match; this.yyleng = this.yytext.length; if (this.options.ranges) { this.yylloc.range = [this.offset, this.offset += this.yyleng]; } this._more = false; this._input = this._input.slice(match[0].length); this.matched += match[0]; token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]); if (this.done && this._input) this.done = false; if (token) return token; else return; } if (this._input === "") { return this.EOF; } else { return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), {text: "", token: null, line: this.yylineno}); } }, lex:function lex() { var r = this.next(); if (typeof r !== 'undefined') { return r; } else { return this.lex(); } }, begin:function begin(condition) { this.conditionStack.push(condition); }, popState:function popState() { return this.conditionStack.pop(); }, _currentRules:function _currentRules() { return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; }, topState:function () { return this.conditionStack[this.conditionStack.length-2]; }, pushState:function begin(condition) { this.begin(condition); }}); lexer.options = {}; lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { var YYSTATE=YY_START switch($avoiding_name_collisions) { case 0: if(yy_.yytext.slice(-1) !== "\\") this.begin("mu"); if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu"); if(yy_.yytext) return 14; break; case 1: return 14; break; case 2: if(yy_.yytext.slice(-1) !== "\\") this.popState(); if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1); return 14; break; case 3: return 24; break; case 4: return 16; break; case 5: return 20; break; case 6: return 19; break; case 7: return 19; break; case 8: return 23; break; case 9: return 23; break; case 10: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15; break; case 11: return 22; break; case 12: return 35; break; case 13: return 34; break; case 14: return 34; break; case 15: return 37; break; case 16: /*ignore whitespace*/ break; case 17: this.popState(); return 18; break; case 18: this.popState(); return 18; break; case 19: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 29; break; case 20: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 29; break; case 21: yy_.yytext = yy_.yytext.substr(1); return 27; break; case 22: return 31; break; case 23: return 31; break; case 24: return 30; break; case 25: return 34; break; case 26: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 34; break; case 27: return 'INVALID'; break; case 28: return 5; break; } }; lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[} ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_$-]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/]; lexer.conditions = {"mu":{"rules":[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"INITIAL":{"rules":[0,1,28],"inclusive":true}}; return lexer;})() parser.lexer = lexer; function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; return new Parser; })(); if (typeof require !== 'undefined' && typeof exports !== 'undefined') { exports.parser = handlebars; exports.Parser = handlebars.Parser; exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); } exports.main = function commonjsMain(args) { if (!args[1]) throw new Error('Usage: '+args[0]+' FILE'); var source, cwd; if (typeof process !== 'undefined') { source = require('fs').readFileSync(require('path').resolve(args[1]), "utf8"); } else { source = require("file").path(require("file").cwd()).join(args[1]).read({charset: "utf-8"}); } return exports.parser.parse(source); } if (typeof module !== 'undefined' && require.main === module) { exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args); } }; ; // lib/handlebars/compiler/base.js Handlebars.Parser = handlebars; Handlebars.parse = function(string) { Handlebars.Parser.yy = Handlebars.AST; return Handlebars.Parser.parse(string); }; Handlebars.print = function(ast) { return new Handlebars.PrintVisitor().accept(ast); }; Handlebars.logger = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3, // override in the host environment log: function(level, str) {} }; Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); }; ; // lib/handlebars/compiler/ast.js (function() { Handlebars.AST = {}; Handlebars.AST.ProgramNode = function(statements, inverse) { this.type = "program"; this.statements = statements; if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); } }; Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) { this.type = "mustache"; this.escaped = !unescaped; this.hash = hash; var id = this.id = rawParams[0]; var params = this.params = rawParams.slice(1); // a mustache is an eligible helper if: // * its id is simple (a single part, not `this` or `..`) var eligibleHelper = this.eligibleHelper = id.isSimple; // a mustache is definitely a helper if: // * it is an eligible helper, and // * it has at least one parameter or hash segment this.isHelper = eligibleHelper && (params.length || hash); // if a mustache is an eligible helper but not a definite // helper, it is ambiguous, and will be resolved in a later // pass or at runtime. }; Handlebars.AST.PartialNode = function(id, context) { this.type = "partial"; // TODO: disallow complex IDs this.id = id; this.context = context; }; var verifyMatch = function(open, close) { if(open.original !== close.original) { throw new Handlebars.Exception(open.original + " doesn't match " + close.original); } }; Handlebars.AST.BlockNode = function(mustache, program, inverse, close) { verifyMatch(mustache.id, close); this.type = "block"; this.mustache = mustache; this.program = program; this.inverse = inverse; if (this.inverse && !this.program) { this.isInverse = true; } }; Handlebars.AST.ContentNode = function(string) { this.type = "content"; this.string = string; }; Handlebars.AST.HashNode = function(pairs) { this.type = "hash"; this.pairs = pairs; }; Handlebars.AST.IdNode = function(parts) { this.type = "ID"; this.original = parts.join("."); var dig = [], depth = 0; for(var i=0,l=parts.length; i": ">", '"': """, "'": "'", "`": "`" }; var badChars = /[&<>"'`]/g; var possible = /[&<>"'`]/; var escapeChar = function(chr) { return escape[chr] || "&"; }; Handlebars.Utils = { escapeExpression: function(string) { // don't escape SafeStrings, since they're already safe if (string instanceof Handlebars.SafeString) { return string.toString(); } else if (string == null || string === false) { return ""; } if(!possible.test(string)) { return string; } return string.replace(badChars, escapeChar); }, isEmpty: function(value) { if (typeof value === "undefined") { return true; } else if (value === null) { return true; } else if (value === false) { return true; } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) { return true; } else { return false; } } }; })();; // lib/handlebars/compiler/compiler.js /*jshint eqnull:true*/ Handlebars.Compiler = function() {}; Handlebars.JavaScriptCompiler = function() {}; (function(Compiler, JavaScriptCompiler) { // the foundHelper register will disambiguate helper lookup from finding a // function in a context. This is necessary for mustache compatibility, which // requires that context functions in blocks are evaluated by blockHelperMissing, // and then proceed as if the resulting value was provided to blockHelperMissing. Compiler.prototype = { compiler: Compiler, disassemble: function() { var opcodes = this.opcodes, opcode, out = [], params, param; for (var i=0, l=opcodes.length; i 0) { this.source[1] = this.source[1] + ", " + locals.join(", "); } // Generate minimizer alias mappings if (!this.isChild) { var aliases = []; for (var alias in this.context.aliases) { this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias]; } } if (this.source[1]) { this.source[1] = "var " + this.source[1].substring(2) + ";"; } // Merge children if (!this.isChild) { this.source[1] += '\n' + this.context.programs.join('\n') + '\n'; } if (!this.environment.isSimple) { this.source.push("return buffer;"); } var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"]; for(var i=0, l=this.environment.depths.list.length; i this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); } return "stack" + this.stackSlot; }, popStack: function() { var item = this.compileStack.pop(); if (item instanceof Literal) { return item.value; } else { this.stackSlot--; return item; } }, topStack: function() { var item = this.compileStack[this.compileStack.length - 1]; if (item instanceof Literal) { return item.value; } else { return item; } }, quotedString: function(str) { return '"' + str .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') + '"'; }, setupHelper: function(paramSize, name) { var params = []; this.setupParams(paramSize, params); var foundHelper = this.nameLookup('helpers', name, 'helper'); return { params: params, name: foundHelper, callParams: ["depth0"].concat(params).join(", "), helperMissingParams: ["depth0", this.quotedString(name)].concat(params).join(", ") }; }, // the params and contexts arguments are passed in arrays // to fill in setupParams: function(paramSize, params) { var options = [], contexts = [], param, inverse, program; options.push("hash:" + this.popStack()); inverse = this.popStack(); program = this.popStack(); // Avoid setting fn and inverse if neither are set. This allows // helpers to do a check for `if (options.fn)` if (program || inverse) { if (!program) { this.context.aliases.self = "this"; program = "self.noop"; } if (!inverse) { this.context.aliases.self = "this"; inverse = "self.noop"; } options.push("inverse:" + inverse); options.push("fn:" + program); } for(var i=0; i 0) { window.variantTemplate = Handlebars.compile($('#variant_autocomplete_template').text()); window.variantStockTemplate = Handlebars.compile($('#variant_autocomplete_stock_template').text()); } }); formatVariantResult = function(variant) { if (variant["images"][0] != undefined && variant["images"][0].mini_url != undefined) { variant.image = variant.images[0].mini_url } return variantTemplate({ variant: variant }) } $.fn.variantAutocomplete = function() { this.parent().children(".options_placeholder").prop('id', this.parent().data('index')) this.select2({ placeholder: Spree.translations.variant_placeholder, minimumInputLength: 3, initSelection: function (element, callback) { $.get(Spree.routes.variants_search + '/' + element.val(), {}, function (data) { callback(data) }) }, ajax: { url: Spree.url(Spree.routes.variants_search), datatype: 'json', data: function(term, page) { return { q: { "product_name_or_sku_cont": term } } }, results: function (data, page) { window.variants = data['variants']; return { results: data['variants'] } } }, formatResult: formatVariantResult, formatSelection: function (variant) { $(this.element).parent().children('.options_placeholder').html(variant.options_text) return variant.name; } }) } ; $(document).ready(function () { 'use strict'; if ($('#product_taxon_ids').length > 0) { $('#product_taxon_ids').select2({ placeholder: Spree.translations.taxon_placeholder, multiple: true, initSelection: function (element, callback) { var url = Spree.url(Spree.routes.taxons_search, { ids: element.val() }); return $.getJSON(url, null, function (data) { return callback(data['taxons']); }); }, ajax: { url: Spree.routes.taxons_search, datatype: 'json', data: function (term, page) { return { per_page: 50, page: page, q: { name_cont: term }, token: Spree.api_key }; }, results: function (data, page) { var more = page < data.pages; return { results: data['taxons'], more: more }; } }, formatResult: function (taxon) { return taxon.pretty_name; }, formatSelection: function (taxon) { return taxon.pretty_name; } }); } }); $(document).ready(function () { 'use strict'; if ($('#product_option_type_ids').length > 0) { $('#product_option_type_ids').select2({ placeholder: Spree.translations.option_type_placeholder, multiple: true, initSelection: function (element, callback) { var url = Spree.url(Spree.routes.option_type_search, { ids: element.val() }); return $.getJSON(url, null, function (data) { return callback(data); }); }, ajax: { url: Spree.routes.option_type_search, quietMillis: 200, datatype: 'json', data: function (term) { return { q: { name_cont: term }, token: Spree.api_key }; }, results: function (data) { return { results: data }; } }, formatResult: function (option_type) { return option_type.presentation + ' (' + option_type.name + ')'; }, formatSelection: function (option_type) { return option_type.presentation + ' (' + option_type.name + ')'; } }); } }); $.fn.userAutocomplete = function () { 'use strict'; this.select2({ minimumInputLength: 1, multiple: true, initSelection: function (element, callback) { $.get(Spree.routes.user_search, { ids: element.val() }, function (data) { callback(data); }); }, ajax: { url: Spree.routes.user_search, datatype: 'json', data: function (term) { return { q: term }; }, results: function (data) { return { results: data }; } }, formatResult: function (user) { return user.email; }, formatSelection: function (user) { return user.email; } }); }; $(document).ready(function () { $('.user_picker').userAutocomplete(); }); $.fn.productAutocomplete = function () { 'use strict'; this.select2({ minimumInputLength: 1, multiple: true, initSelection: function (element, callback) { $.get(Spree.routes.product_search, { ids: element.val().split(',') }, function (data) { callback(data.products); }); }, ajax: { url: Spree.routes.product_search, datatype: 'json', data: function (term, page) { return { q: { name_cont: term, sku_cont: term }, m: 'OR', token: Spree.api_key }; }, results: function (data, page) { var products = data.products ? data.products : []; return { results: products }; } }, formatResult: function (product) { return product.name; }, formatSelection: function (product) { return product.name; } }); }; $(document).ready(function () { $('.product_picker').productAutocomplete(); }); (function() { $(document).ready(function() { window.productTemplate = Handlebars.compile($('#product_template').text()); $('#taxon_products').sortable(); $('#taxon_products').on("sortstop", function(event, ui) { return $.ajax({ url: Spree.routes.classifications_api, method: 'PUT', data: { product_id: ui.item.data('product-id'), taxon_id: $('#taxon_id').val(), position: ui.item.index() } }); }); if ($('#taxon_id').length > 0) { $('#taxon_id').select2({ dropdownCssClass: "taxon_select_box", placeholder: Spree.translations.find_a_taxon, ajax: { url: Spree.routes.taxons_search, datatype: 'json', data: function(term, page) { return { per_page: 50, page: page, q: { name_cont: term } }; }, results: function(data, page) { var more; more = page < data.pages; return { results: data['taxons'], more: more }; } }, formatResult: function(taxon) { return taxon.pretty_name; }, formatSelection: function(taxon) { return taxon.pretty_name; } }); } return $('#taxon_id').on("change", function(e) { var el; el = $('#taxon_products'); return $.ajax({ url: Spree.routes.taxon_products_api, data: { id: e.val }, success: function(data) { var product, _i, _len, _ref; el.empty(); if (data.products.length === 0) { $('#sorting_explanation').hide(); return $('#taxon_products').html("

" + Spree.translations.no_results + "

"); } else { _ref = data.products; for (_i = 0, _len = _ref.length; _i < _len; _i++) { product = _ref[_i]; if (product.master.images[0] !== void 0 && product.master.images[0].small_url !== void 0) { product.image = product.master.images[0].small_url; } el.append(productTemplate({ product: product })); } return $('#sorting_explanation').show(); } } }); }); }); }).call(this); ;TI"required_assets_digest;TI"%05bb8182eac28b985840e3f50229d509;FI" _version;TI"%5ef14a844324cba3e114bd0123f88a5e;F