o: ActiveSupport::Cache::Entry :@compressedF:@created_atf1359331686.773054:@expires_in0:@value"�%{I" class:EFI"BundledAsset;�FI"logical_path;�FI"anjlab/uploads/dnd.js;�TI" pathname;�FI"Q/Users/yury/Work/uploads/app/assets/javascripts/anjlab/uploads/dnd.js.coffee;�TI"content_type;�FI"application/javascript;�FI" mtime;�FI"2013-01-28T04:07:45+04:00;�FI"length;�Fi�#I"digest;�F"%780ab4909dbad52de149c3df81ec2283I"source;�FI"�#(function() { var utils, _collection, _dropOutsideDisabled, __hasProp = {}.hasOwnProperty; utils = this.AnjLab.Uploads.Utils; this.AnjLab.Uploads.DragAndDrop = (function() { function DragAndDrop(zones, options) { this.droppedFiles = []; this.droppedEntriesCount = 0; this.droppedEntriesParsedCount = 0; this.options = options; this.setupDragDrop(zones); } DragAndDrop.prototype.maybeUploadDroppedFiles = function() { if (this.droppedEntriesCount === this.droppedEntriesParsedCount && !this.dirPending) { this.options.callbacks.log("Grabbed " + this.droppedFiles.length + " files after tree traversal."); this.zones.each(function() { return $(this).data('dropZone').dropDisabled(false); }); return this.options.callbacks.dropProcessing(false, this.droppedFiles); } }; DragAndDrop.prototype.addDroppedFile = function(file) { this.droppedFiles.push(file); this.droppedEntriesParsedCount += 1; return this.maybeUploadDroppedFiles(); }; DragAndDrop.prototype.traverseFileTree = function(entry) { var dirPending, dirReader, _this = this; dirPending = false; this.droppedEntriesCount += 1; if (entry.isFile) { return entry.file(function(file) { return _this.addDroppedFile(file); }); } else if (entry.isDirectory) { dirPending = true; dirReader = entry.createReader(); return dirReader.readEntries(function(entries) { var e, _i, _len; _this.droppedEntriesParsedCount += 1; for (_i = 0, _len = entries.length; _i < _len; _i++) { e = entries[_i]; _this.traverseFileTree(e); } dirPending = false; if (!entries.length) { return _this.maybeUploadDroppedFiles(); } }); } }; DragAndDrop.prototype.isFileDrag = function(dragEvent) { var key, val, _ref; _ref = dragEvent.dataTransfer.types; for (key in _ref) { if (!__hasProp.call(_ref, key)) continue; val = _ref[key]; if (val === 'Files') { return true; } } return false; }; DragAndDrop.prototype.handleDataTransfer = function(dataTransfer) { var entry, i, item, items, _i, _len, _results; this.options.callbacks.dropProcessing(true); this.zones.each(function() { return $(this).data('dropZone').dropDisabled(true); }); if (dataTransfer.files.length > 1 && !this.options.multiple) { this.options.callbacks.dropProcessing(false); this.options.callbacks.error('tooManyFilesError', ""); return this.zones.each(function() { return $(this).data('dropZone').dropDisabled(false); }); } else { this.droppedFiles = []; this.droppedEntriesCount = 0; this.droppedEntriesParsedCount = 0; if (utils.isFolderDropSupported(dataTransfer)) { items = dataTransfer.items; i = 0; _results = []; for (_i = 0, _len = items.length; _i < _len; _i++) { item = items[_i]; entry = item.webkitGetAsEntry(); if (entry) { if (entry.isFile) { this.droppedFiles.push(items[i].getAsFile()); if (i === items.length - 1) { this.maybeUploadDroppedFiles(); } else { this.traverseFileTree(entry); } } } _results.push(i += 1); } return _results; } else { this.options.callbacks.dropProcessing(false, dataTransfer.files); return this.zones.each(function() { return $(this).data('dropZone').dropDisabled(false); }); } } }; DragAndDrop.prototype.setupDragDrop = function(zones) { var dnd; dnd = this; this.zones = $(zones).each(function() { var $zone, zoneOpts, _this = this; $zone = $(this); zoneOpts = $.extend(true, {}, { onEnter: function(e) { $zone.toggleClass(dnd.options.classes.dropActive, true); return e.stopPropagation(); }, onLeaveNotDescendants: function(e) { return $zone.toggleClass(dnd.options.classes.dropActive, false); }, onDrop: function(e) { $zone.toggleClass(dnd.options.classes.dropActive, false); return dnd.handleDataTransfer(e.originalEvent.dataTransfer); } }, dnd.options); return $zone.data('dropZone', new AnjLab.Uploads.UploadDropZone(this, zoneOpts)); }); return $(document).on('drop', function(e) { return e.preventDefault(); }); }; return DragAndDrop; })(); _dropOutsideDisabled = false; _collection = $(); this.AnjLab.Uploads.UploadDropZone = (function() { function UploadDropZone(element, options) { var defaultOptions; this.$element = $(element); defaultOptions = { onEnter: function(e) { return null; }, onLeave: function(e) { return null; }, onLeaveNotDescendants: function(e) { return null; }, onDrop: function(e) { return null; } }; this.options = $.extend(true, {}, defaultOptions, options); this.disableDropOutside(); this.attachEvents(); } UploadDropZone.prototype.docDragEnter = function(e) { if (_collection.size() === 0) { $('body').toggleClass(this.options.classes.bodyDragover, true); } return _collection = _collection.add(e.target); }; UploadDropZone.prototype.docDragLeave = function(e) { var _this = this; return setTimeout(function() { _collection = _collection.not(e.target); if (_collection.size() === 0) { return $('body').toggleClass(_this.options.classes.bodyDragover, false); } }, 1); }; UploadDropZone.prototype.disableDropOutside = function(e) { var _this = this; if (!_dropOutsideDisabled) { $(document).on('dragover', function(e) { if (e.originalEvent.dataTransfer) { e.originalEvent.dataTransfer.dropEffect = 'none'; e.preventDefault(); return false; } }); $(document).on('dragenter', function(e) { return _this.docDragEnter(e); }); $(document).on('dragleave drop', function(e) { return _this.docDragLeave(e); }); } return _dropOutsideDisabled = true; }; UploadDropZone.prototype.isValidFileDrag = function(e) { var dt, effectTest, isSafari; if (utils.ie() && !utils.ie10()) { return false; } dt = e.originalEvent.dataTransfer; isSafari = utils.safari(); effectTest = utils.ie10() ? true : dt.effectAllowed !== 'none'; return dt && effectTest && (dt.files || (!isSafari && dt.types.contains && dt.types.contains('Files'))); }; UploadDropZone.prototype.isOrSetDropDisabled = function(isDisabled) { if (isDisabled !== void 0) { this.preventDrop = isDisabled; } return this.preventDrop; }; UploadDropZone.prototype.attachEvents = function() { var _this = this; this.$element.on('dragover', function(e) { var effect, _ref; if (!_this.isValidFileDrag(e)) { return; } effect = ((_ref = utils.ie()) != null ? _ref : null) ? void 0 : e.originalEvent.dataTransfer.effectAllowed; if (effect === 'move' || effect === 'linkMove') { e.originalEvent.dataTransfer.dropEffect = 'move'; } else { e.originalEvent.dataTransfer.dropEffect = 'copy'; } e.stopPropagation(); e.preventDefault(); return false; }); this.$element.on('dragenter', function(e) { _this.docDragEnter(e); if (!_this.isOrSetDropDisabled()) { if (!_this.isValidFileDrag(e)) { return; } return _this.options.onEnter(e); } }); this.$element.on('dragleave', function(e) { var relatedTarget; _this.docDragLeave(e); if (!_this.isValidFileDrag(e)) { return; } _this.options.onLeave(e); relatedTarget = document.elementFromPoint(e.clientX, e.clientY); if ($.contains(_this, relatedTarget)) { return; } return _this.options.onLeaveNotDescendants(e); }); return this.$element.on('drop', function(e) { _this.docDragLeave(e); if (!_this.isOrSetDropDisabled()) { if (!_this.isValidFileDrag(e)) { return; } e.preventDefault(); _this.options.onDrop(e); return false; } }); }; UploadDropZone.prototype.dropDisabled = function(isDisabled) { return this.isOrSetDropDisabled(isDisabled); }; return UploadDropZone; })(); }).call(this); ;�FI"required_assets_digest;�F"%c23ea8e9fb62b6dc65c7775706e281bfI" _version;�F"%6776f581a4329e299531e1d52aa59832