From 7e209dd4f22d4f4e99bf9cd951bbece7a431ebef Mon Sep 17 00:00:00 2001 From: Anthony Blackshaw Date: Mon, 30 May 2016 13:39:42 +0100 Subject: [PATCH] Added main value to package.json --- build/content-select.min.js | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/content-select.min.js b/build/content-select.min.js index bfa80b6..35590d4 100644 --- a/build/content-select.min.js +++ b/build/content-select.min.js @@ -1,2 +1,2 @@ -/*! ContentSelect v1.0.1 by Anthony Blackshaw (https://github.com/anthonyjb) */ +/*! ContentSelect v1.0.2 by Anthony Blackshaw (https://github.com/anthonyjb) */ (function(){var SELF_CLOSING_NODE_NAMES,_containedBy,_getChildNodeAndOffset,_getNodeRange,_getOffsetOfChildNode,__indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};window.ContentSelect={},ContentSelect.Range=function(){function Range(from,to){this.set(from,to)}return Range.prototype.isCollapsed=function(){return this._from===this._to},Range.prototype.span=function(){return this._to-this._from},Range.prototype.collapse=function(){return this._to=this._from},Range.prototype.eq=function(range){return this.get()[0]===range.get()[0]&&this.get()[1]===range.get()[1]},Range.prototype.get=function(){return[this._from,this._to]},Range.prototype.select=function(element){var docRange,endNode,endNodeLen,endOffset,startNode,startNodeLen,startOffset,_ref,_ref1;return ContentSelect.Range.unselectAll(),docRange=document.createRange(),_ref=_getChildNodeAndOffset(element,this._from),startNode=_ref[0],startOffset=_ref[1],_ref1=_getChildNodeAndOffset(element,this._to),endNode=_ref1[0],endOffset=_ref1[1],startNodeLen=startNode.length||0,endNodeLen=endNode.length||0,docRange.setStart(startNode,Math.min(startOffset,startNodeLen)),docRange.setEnd(endNode,Math.min(endOffset,endNodeLen)),window.getSelection().addRange(docRange)},Range.prototype.set=function(from,to){return from=Math.max(0,from),to=Math.max(0,to),this._from=Math.min(from,to),this._to=Math.max(from,to)},Range.prepareElement=function(element){var i,node,selfClosingNodes,_i,_len,_results;for(selfClosingNodes=element.querySelectorAll(SELF_CLOSING_NODE_NAMES.join(", ")),_results=[],i=_i=0,_len=selfClosingNodes.length;_len>_i;i=++_i)node=selfClosingNodes[i],node.parentNode.insertBefore(document.createTextNode(""),node),_results.push(i_i;_i++)n=_ref[_i],_results.push(n);return _results}();childStack.length>0;)switch(childNode=childStack.shift(),childNode.nodeType){case Node.TEXT_NODE:if(childNode.textContent.length>=childOffset)return[childNode,childOffset];childOffset-=childNode.textContent.length;break;case Node.ELEMENT_NODE:if(_ref=childNode.nodeName.toLowerCase(),__indexOf.call(SELF_CLOSING_NODE_NAMES,_ref)>=0){if(0===childOffset)return[childNode,0];childOffset=Math.max(0,childOffset-1)}else childNode.childNodes&&Array.prototype.unshift.apply(childStack,function(){var _i,_len,_ref1,_results;for(_ref1=childNode.childNodes,_results=[],_i=0,_len=_ref1.length;_len>_i;_i++)n=_ref1[_i],_results.push(n);return _results}())}return[childNode,childOffset]},_getOffsetOfChildNode=function(parentNode,childNode){var childStack,n,offset,otherChildNode,_ref,_ref1;if(0===parentNode.childNodes.length)return 0;for(offset=0,childStack=function(){var _i,_len,_ref,_results;for(_ref=parentNode.childNodes,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)n=_ref[_i],_results.push(n);return _results}();childStack.length>0;){if(otherChildNode=childStack.shift(),otherChildNode===childNode)return _ref=otherChildNode.nodeName.toLowerCase(),__indexOf.call(SELF_CLOSING_NODE_NAMES,_ref)>=0?offset+1:offset;switch(otherChildNode.nodeType){case Node.TEXT_NODE:offset+=otherChildNode.textContent.length;break;case Node.ELEMENT_NODE:_ref1=otherChildNode.nodeName.toLowerCase(),__indexOf.call(SELF_CLOSING_NODE_NAMES,_ref1)>=0?offset+=1:otherChildNode.childNodes&&Array.prototype.unshift.apply(childStack,function(){var _i,_len,_ref2,_results;for(_ref2=otherChildNode.childNodes,_results=[],_i=0,_len=_ref2.length;_len>_i;_i++)n=_ref2[_i],_results.push(n);return _results}())}}return offset},_getNodeRange=function(element,docRange){var childNode,childNodes,endNode,endOffset,endRange,i,startNode,startOffset,startRange,_i,_j,_len,_len1,_ref;if(childNodes=element.childNodes,startRange=docRange.cloneRange(),startRange.collapse(!0),endRange=docRange.cloneRange(),endRange.collapse(!1),startNode=startRange.startContainer,startOffset=startRange.startOffset,endNode=endRange.endContainer,endOffset=endRange.endOffset,!startRange.comparePoint)return[startNode,startOffset,endNode,endOffset];if(startNode===element)for(startNode=childNodes[childNodes.length-1],startOffset=startNode.textContent.length,i=_i=0,_len=childNodes.length;_len>_i;i=++_i)if(childNode=childNodes[i],1===startRange.comparePoint(childNode,0)){0===i?(startNode=childNode,startOffset=0):(startNode=childNodes[i-1],startOffset=childNode.textContent.length),_ref=startNode.nodeName.toLowerCase,__indexOf.call(SELF_CLOSING_NODE_NAMES,_ref)>=0&&(startOffset=1);break}if(docRange.collapsed)return[startNode,startOffset,startNode,startOffset];if(endNode===element)for(endNode=childNodes[childNodes.length-1],endOffset=endNode.textContent.length,i=_j=0,_len1=childNodes.length;_len1>_j;i=++_j)childNode=childNodes[i],1===endRange.comparePoint(childNode,0)&&(endNode=0===i?childNode:childNodes[i-1],endOffset=childNode.textContent.length+1);return[startNode,startOffset,endNode,endOffset]}}).call(this); \ No newline at end of file diff --git a/package.json b/package.json index c4cb0e1..cfef5c2 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,13 @@ { "name": "ContentSelect", "description": "A JavaScript library providing cross-browser support for content selection.", - "version": "1.0.1", + "version": "1.0.2", "author": { "name": "Anthony Blackshaw", "email": "ant@getme.co.uk", "url": "https://github.com/anthonyjb" }, + "main": "build/content-select.js", "keywords": [ "selection", "content",