{I" class:ETI"ProcessedAsset; FI"logical_path; TI"&translation_engine/screenshots.js; FI" pathname; TI"z/Users/bartas/local_work/blueberry/translation_engine/app/assets/javascripts/translation_engine/screenshots.js.coffee; FI"content_type; TI"application/javascript; TI" mtime; Tl+^UI"length; Ti"I"digest; TI"%da953fc91442909b281fa8e9d0cbe5d1; FI"source; TI""(function() { var TranslationEngine, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; TranslationEngine = (function() { TranslationEngine.prototype.submitButton = ''; TranslationEngine.prototype.translationsQueue = []; TranslationEngine.prototype.screenshots = []; TranslationEngine.prototype.screenshotsCaptured = {}; TranslationEngine.prototype.translationIndex = 0; TranslationEngine.prototype.highlights = []; TranslationEngine.prototype.variant = 'desktop'; function TranslationEngine(startButton) { this.nextTranslationScreeshot = bind(this.nextTranslationScreeshot, this); this.startButton = $(startButton); this.lookupDom(); this.bindStartButton(); if ($('body').hasClass('mobile')) { this.variant = 'mobile'; } } TranslationEngine.prototype.start = function() { return setTimeout(this.nextTranslationScreeshot, 100); }; TranslationEngine.prototype.appendScreenshotsOverlay = function() { if ($('body').find('.screenshots-overlay').length === 0) { $('body').append('
'); return $('body').append(''); } }; TranslationEngine.prototype.dismissScreenshotsOverlay = function() { return setTimeout(function() { $('body').find('.screenshots-overlay').detach(); return $('body').find('.screenshots-status').detach(); }, 1000); }; TranslationEngine.prototype.bindStartButton = function() { return this.startButton.click((function(_this) { return function() { if (_this.translationsQueue.length > _this.translationIndex) { return setTimeout(_this.nextTranslationScreeshot, 100); } else { _this.appendScreenshotsOverlay(); _this.setStatusText('Screenshots already send'); return _this.dismissScreenshotsOverlay(); } }; })(this)); }; TranslationEngine.prototype.nextTranslationScreeshot = function() { console.log(this.translationsQueue); console.log(this.translationIndex); if (this.translationsQueue.length > this.translationIndex) { return this.renderHighlight(); } else { return this.sendTranslations(); } }; TranslationEngine.prototype.lookupDom = function() { this.lookupTextDom(); this.lookupAttributesDom(); return this.lookupMissingTranslationDom(); }; TranslationEngine.prototype.lookupTextDom = function() { var results; results = []; while ($(':contains("--TRANSLATION--")').length > 0) { results.push($(':contains("--TRANSLATION--")').each((function(_this) { return function(i, element) { var matched, text; element = $(element); if (element.find(':contains("--TRANSLATION--")').length === 0) { text = element.html(); matched = _this.findTranslationFromText(text); element.html(text.replace(matched[0], '')); return _this.translationsQueue.push({ key: matched[1], element: element }); } }; })(this))); } return results; }; TranslationEngine.prototype.lookupAttributesDom = function() { return $('*').each((function(_this) { return function(i, element) { return $.each(element.attributes, function(i, attribute) { var matched, text; if (attribute.value.match('--TRANSLATION--')) { element = $(element); text = attribute.value; matched = _this.findTranslationFromText(text); element.attr(attribute.name, text.replace(matched[0], '')); return _this.translationsQueue.push({ key: matched[1], element: element }); } }); }; })(this)); }; TranslationEngine.prototype.lookupMissingTranslationDom = function() { return $('[class^="translation"]').each((function(_this) { return function(i, element) { element = $(element); if (element.attr('title') !== void 0 && element.attr('title').match('translation')) { return _this.translationsQueue.push({ element: element, key: element.attr('title').replace('translation missing: ', '') }); } }; })(this)); }; TranslationEngine.prototype.findTranslationFromText = function(text) { var translations_regexp; translations_regexp = /--TRANSLATION--([\w\_.]*)--/g; return translations_regexp.exec(text); }; TranslationEngine.prototype.setStatusText = function(text) { return $('body').find('.screenshots-status').text(text); }; TranslationEngine.prototype.sendTranslations = function() { var data; data = { location: window.location.pathname, images: this.screenshots, highlights: this.highlights }; this.setStatusText('Sending translations'); return $.ajax({ url: '/translation_engine', type: 'POST', data: JSON.stringify(data), contentType: 'json' }).done((function(_this) { return function(response) { _this.setStatusText(response.message); return _this.dismissScreenshotsOverlay(); }; })(this)); }; TranslationEngine.prototype.renderHighlight = function() { var dropdown, height, image_name, main_element, modal, new_value, offset, original_selected_value, translation, type, width; this.appendScreenshotsOverlay(); translation = this.translationsQueue[this.translationIndex]; this.setStatusText("Capturing " + translation.key + " (" + this.translationIndex + "/" + this.translationsQueue.length + ")"); image_name = window.location.pathname; type = 'span'; if (translation.element.parent('select').length > 0) { main_element = translation.element.parent('select'); type = 'select'; original_selected_value = main_element.val(); new_value = translation.element.val(); image_name += "#select_" + (main_element.attr('id')) + "_" + new_value; main_element.val(new_value); } else if (translation.element.closest('.dropdown').length > 0) { main_element = translation.element; dropdown = main_element.closest('.dropdown'); dropdown.addClass('open'); image_name += "#dropdown_" + (dropdown.attr('id')); type = 'dropdown'; } else if (translation.element.closest('.modal').length > 0) { main_element = translation.element; modal = main_element.closest('.modal'); modal.css({ height: $(document).height() }).removeClass('fade in').modal('show'); $('.modal-backdrop').css({ height: $(document).height() }); image_name += "#modal_" + (modal.attr('id')); type = 'modal'; } else { main_element = translation.element; } offset = main_element.offset(); width = main_element.outerWidth(); height = main_element.outerHeight(); this.highlights.push({ key: translation.key, image_name: image_name, x: offset.left, y: offset.top, width: width, height: height }); return setTimeout((function(_this) { return function() { if (_this.screenshotsCaptured[image_name] === true) { if (type === 'select') { main_element.val(original_selected_value); } else if (type === 'dropdown') { main_element.closest('.dropdown').removeClass('open'); } else if (type === 'modal') { main_element.closest('.modal').modal('hide'); } _this.translationIndex += 1; return _this.nextTranslationScreeshot(); } else { return html2canvas([document.body], { onrendered: function(canvas) { _this.screenshots.push({ location: document.URL, name: image_name, variant: _this.variant, image: canvas.toDataURL() }); _this.screenshotsCaptured[image_name] = true; _this.translationIndex += 1; return _this.nextTranslationScreeshot(); } }); } }; })(this), 1); }; return TranslationEngine; })(); $(document).ready(function() { return window.TranslationEngine = new TranslationEngine('.translation_engine_start'); }); }).call(this); ; TI"dependency_digest; TI"%b81904a5eb122e1eede8b04781c82f8f; FI"required_paths; T[I"/Users/bartas/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-assets-html2canvas-0.4.1/app/assets/javascripts/html2canvas/html2canvas.js; FI"/Users/bartas/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-assets-html2canvas-0.4.1/app/assets/javascripts/html2canvas.js; FI"z/Users/bartas/local_work/blueberry/translation_engine/app/assets/javascripts/translation_engine/screenshots.js.coffee; FI"dependency_paths; T[{I" path; TI"z/Users/bartas/local_work/blueberry/translation_engine/app/assets/javascripts/translation_engine/screenshots.js.coffee; FI" mtime; TI"2015-03-12T10:38:16+01:00; TI"digest; TI"%3602ee78f68d44d0c841a433e2e49baa; F{@I"/Users/bartas/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-assets-html2canvas-0.4.1/app/assets/javascripts/html2canvas.js; F@!I"2015-02-27T12:34:44+01:00; T@#I"%4c8ffba51ac07d3cd6ff43d41bdaca46; F{@I"/Users/bartas/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-assets-html2canvas-0.4.1/app/assets/javascripts/html2canvas/html2canvas.js; F@!I"2015-02-27T12:34:44+01:00; T@#I"%621402bfa09001e7c9dc5e76f8ec1be2; FI" _version; TI"%64e62ddc273c2f5847f30d698ca14b67; F