diff --git a/main.js b/main.js index e69de29..666fc84 100644 --- a/main.js +++ b/main.js @@ -0,0 +1 @@ +require('./src/Plugin'); \ No newline at end of file diff --git a/package.json b/package.json index 3b1bb12..c3963ba 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,9 @@ "scripts": { "test": "npm run-script build-test", "build-test": "browserify -t html2js-browserify test/test.js -o bundle.test.js && npm run-script sass", - "build-prod": "npm run-script sass && minify --output protip.min.js bundle.js && minify --output protip.min.css css/protip.css", + "build-prod": "browserify -t html2js-browserify main.js -o bundle.js && npm run-script sass && minify --output protip.min.js bundle.js && minify --output protip.min.css css/protip.css", "build": "npm run build-prod", + "build-all": "npm run build-test && npm run build-prod", "sass": "node_modules/.bin/scss-cli css/protip.scss", "changelog": "github-changes -o DoclerLabs -r Protip -a" }, @@ -49,6 +50,6 @@ ] }, "browserify-shim": { - "jquery2": "global:jQuery" + "jquery": "global:jQuery" } } diff --git a/protip.min.js b/protip.min.js index 6770605..7a87fda 100644 --- a/protip.min.js +++ b/protip.min.js @@ -1,34 +1,34 @@ -!function t(e,i,s){function o(r,a){if(!i[r]){if(!e[r]){var h="function"==typeof require&&require -if(!a&&h)return h(r,!0) +!function t(e,i,s){function o(r,h){if(!i[r]){if(!e[r]){var f="function"==typeof require&&require +if(!h&&f)return f(r,!0) if(n)return n(r,!0) -throw new Error("Cannot find module '"+r+"'")}var f=i[r]={exports:{}} -e[r][0].call(f.exports,function(t){var i=e[r][1][t] -return o(i?i:t)},f,f.exports,t,e,i,s)}return i[r].exports}for(var n="function"==typeof require&&require,r=0;r{arrow}{icon}
{content}
',TEMPLATE_ICON:'',ATTR_WIDTH:"width",ATTR_MAX_WIDTH:"max-width",SKIN_DEFAULT:"default"} -return t.TEMPLATE_ARROW='',t})},{}],3:[function(t,e,i){(function(s){!function(o,n){"use strict" +var t={POSITION_TOP_LEFT:"top-left",POSITION_TOP:"top",POSITION_TOP_RIGHT:"top-right",POSITION_RIGHT_TOP:"right-top",POSITION_RIGHT:"right",POSITION_RIGHT_BOTTOM:"right-bottom",POSITION_BOTTOM_LEFT:"bottom-left",POSITION_BOTTOM:"bottom",POSITION_BOTTOM_RIGHT:"bottom-right",POSITION_LEFT_TOP:"left-top",POSITION_LEFT:"left",POSITION_LEFT_BOTTOM:"left-bottom",POSITION_CORNER_LEFT_TOP:"corner-left-top",POSITION_CORNER_RIGHT_TOP:"corner-right-top",POSITION_CORNER_LEFT_BOTTOM:"corner-left-bottom",POSITION_CORNER_RIGHT_BOTTOM:"corner-right-bottom",TRIGGER_CLICK:"click",TRIGGER_HOVER:"hover",TRIGGER_STICKY:"sticky",PROP_ACTION:"action",PROP_TITLE:"title",PROP_STICKY:"sticky",PROP_INITED:"inited",PROP_DELAY_IN:"delayIn",PROP_DELAY_OUT:"delayOut",PROP_GRAVITY:"gravity",PROP_OFFSET:"offset",PROP_OFFSET_TOP:"offsetTop",PROP_OFFSET_LEFT:"offsetLeft",PROP_POSITION:"position",PROP_CLASS:"class",PROP_ARROW:"arrow",PROP_WIDTH:"width",PROP_IDENTIFIER:"identifier",PROP_ICON:"icon",PROP_AUTO:"auto",PROP_TARGET:"target",EVENT_MOUSEOVER:"mouseover",EVENT_MOUSEOUT:"mouseout",EVENT_MOUSEENTER:"mouseenter",EVENT_MOUSELEAVE:"mouseleave",EVENT_CLICK:"click",EVENT_RESIZE:"resize",DEFAULT_SELECTOR:".protip",DEFAULT_NAMESPACE:"pt",DEFAULT_DELAY_OUT:250,SELECTOR_PREFIX:"protip-",SELECTOR_BODY:"body",SELECTOR_ARROW:"arrow",SELECTOR_CONTAINER:"container",SELECTOR_SHOW:"protip-show",SELECTOR_CLOSE:".protip-close",SELECTOR_SKIN_PREFIX:"protip-skin-",SELECTOR_SIZE_PREFIX:"--size-",SELECTOR_SCHEME_PREFIX:"--scheme-",SELECTOR_ANIMATE:"animated",TEMPLATE_PROTIP:'
{arrow}{icon}
{content}
',TEMPLATE_ICON:'',ATTR_WIDTH:"width",ATTR_MAX_WIDTH:"max-width",SKIN_DEFAULT:"default",SIZE_DEFAULT:"normal",SCHEME_DEFAULT:"pro"} +return t.TEMPLATE_ARROW='',t})},{}],4:[function(t,e,i){(function(s){!function(o,n){"use strict" "function"==typeof define&&define.amd?define(["jquery","./Constants"],n):"object"==typeof i?e.exports=n("undefined"!=typeof window?window.jQuery:"undefined"!=typeof s?s.jQuery:null,t("./Constants")):o.ProtipGravityParser=n(o.jQuery,o.ProtipConstants)}(this,function(t,e){"use strict" var i=function(t,e){return this._Construct(t,e)} return t.extend(!0,i.prototype,{_Construct:function(t,i){return this._positionsList=[{lvl:1,key:i,top:0,left:0},{lvl:3,key:e.POSITION_CORNER_LEFT_TOP,top:0,left:0},{lvl:2,key:e.POSITION_TOP_LEFT,top:0,left:0},{lvl:1,key:e.POSITION_TOP,top:0,left:0},{lvl:2,key:e.POSITION_TOP_RIGHT,top:0,left:0},{lvl:3,key:e.POSITION_CORNER_RIGHT_TOP,top:0,left:0},{lvl:2,key:e.POSITION_RIGHT_TOP,top:0,left:0},{lvl:1,key:e.POSITION_RIGHT,top:0,left:0},{lvl:2,key:e.POSITION_RIGHT_BOTTOM,top:0,left:0},{lvl:2,key:e.POSITION_BOTTOM_LEFT,top:0,left:0},{lvl:1,key:e.POSITION_BOTTOM,top:0,left:0},{lvl:2,key:e.POSITION_BOTTOM_RIGHT,top:0,left:0},{lvl:3,key:e.POSITION_CORNER_RIGHT_BOTTOM,top:0,left:0},{lvl:2,key:e.POSITION_LEFT_TOP,top:0,left:0},{lvl:1,key:e.POSITION_LEFT,top:0,left:0},{lvl:2,key:e.POSITION_LEFT_BOTTOM,top:0,left:0},{lvl:3,key:e.POSITION_CORNER_LEFT_BOTTOM,top:0,left:0}],this._input=t,this._finals=[],this._parse(),this._finals},_parse:function(){if(this._input===!0||3===this._input)this._finals=this._positionsList else if(isNaN(this._input)){var t=[],e=!1 this._finals=this._input.split(";").map(function(i){if(i=i.trim(),"..."===i)e=!0 else if(i){var s=i.split(" ").map(function(t){return t.trim()}) -return t.push(s[0]),{lvl:1,key:s[0],left:parseInt(s[1],10)||0,top:parseInt(s[2],10)||0}}}).filter(function(t){return!!t}),e&&this._positionsList.forEach(function(e){-1===t.indexOf(e.key)&&this._finals.push(e)}.bind(this))}else this._finals=this._positionsList.filter(function(t){return t.lvl<=this._input}.bind(this))}}),i})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Constants":2}],4:[function(t,e,i){(function(s){!function(o,n){"use strict" +return t.push(s[0]),{lvl:1,key:s[0],left:parseInt(s[1],10)||0,top:parseInt(s[2],10)||0}}}).filter(function(t){return!!t}),e&&this._positionsList.forEach(function(e){-1===t.indexOf(e.key)&&this._finals.push(e)}.bind(this))}else this._finals=this._positionsList.filter(function(t){return t.lvl<=this._input}.bind(this))}}),i})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Constants":3}],5:[function(t,e,i){(function(s){!function(o,n){"use strict" "function"==typeof define&&define.amd?define(["jquery","./Constants","./GravityParser","./PositionCalculator"],n):"object"==typeof i?e.exports=n("undefined"!=typeof window?window.jQuery:"undefined"!=typeof s?s.jQuery:null,t("./Constants"),t("./GravityParser"),t("./PositionCalculator")):o.ProtipGravityTester=n(o.jQuery,o.ProtipConstants,o.ProtipGravityParser,o.ProtipPositionCalculator)}(this,function(t,e,i,s){"use strict" var o=function(t){return this._Construct(t)} return t.extend(!0,o.prototype,{_Construct:function(t){this._item=t,this._result=void 0,this._setWindowDimensions(),this._positionList=new i(this._item.data.gravity,this._item.data.position) @@ -36,44 +36,27 @@ var e for(e=0;e0},_rightOk:function(){return this._dimensions.offset.left+this._dimensions.width0},_setProtipDimensions:function(){if(this._dimensions={width:this._item.el.protip.outerWidth(),height:this._item.el.protip.outerHeight(),offset:this._item.el.protip.offset()},this._item.data.target!==e.SELECTOR_BODY){var t=this._item.el.source.offset() this._dimensions.offset.top+=t.top,this._dimensions.offset.left+=t.left}},_setWindowDimensions:function(){var t=window,e=document,i=e.documentElement,s=e.getElementsByTagName("body")[0],o=t.innerWidth||i.clientWidth||s.clientWidth,n=t.innerHeight||i.clientHeight||s.clientHeight -this._windowDimensions={width:parseInt(o),height:parseInt(n),scrollTop:window.pageYOffset||document.documentElement.scrollTop||document.getElementsByTagName("body")[0].scrollTop||0}}}),o})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Constants":2,"./GravityParser":3,"./PositionCalculator":9}],5:[function(t,e,i){(function(i){e.exports=function(){window.$="undefined"!=typeof window?window.jQuery:"undefined"!=typeof i?i.jQuery:null,t("./Plugin")}()}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Plugin":8}],6:[function(t,e,i){(function(s){!function(o,n){"use strict" +this._windowDimensions={width:parseInt(o),height:parseInt(n),scrollTop:window.pageYOffset||document.documentElement.scrollTop||document.getElementsByTagName("body")[0].scrollTop||0}}}),o})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Constants":3,"./GravityParser":4,"./PositionCalculator":8}],6:[function(t,e,i){(function(s){!function(o,n){"use strict" "function"==typeof define&&define.amd?define(["jquery","./Constants","./GravityTester","./PositionCalculator"],n):"object"==typeof i?e.exports=n("undefined"!=typeof window?window.jQuery:"undefined"!=typeof s?s.jQuery:null,t("./Constants"),t("./GravityTester"),t("./PositionCalculator")):o.ProtipItemClass=n(o.jQuery,o.ProtipConstants,o.ProtipGravityTester,o.ProtipPositionCalculator)}(this,function(t,e,i,s){"use strict" function o(t,e){return t.replace(/\{([\w\.]*)}/g,function(t,i){for(var s=i.split("."),o=e[s.shift()],n=0,r=s.length;r>n;n++)o=o[s[n]] return"undefined"!=typeof o&&null!==o?o:""})}var n=function(t,e,i){return this._Construct(t,e,i)} -return t.extend(!0,n.prototype,{_prop:{trigger:e.TRIGGER_HOVER,title:null,inited:!1,delayIn:0,delayOut:0,interactive:!1,gravity:!0,offsetTop:0,offsetLeft:0,position:e.POSITION_BOTTOM,classes:null,arrow:!0,width:300,identifier:!1,icon:!1,observer:!1,target:e.SELECTOR_BODY,skin:void 0},_Construct:function(t,i,s){return this.el={},this.el.source=i,this._prop.identifier=t,this.data={},this.classInstance=s,this._isVisible=!1,this._task={delayIn:void 0,delayOut:void 0},this._fetchData(),this._prepareInternals(),this._appendProtip(),this._initSticky(),this._bind(),this.el.source.data(this._namespaced(e.PROP_INITED),!0),this},actionHandler:function(t){if(this.data.trigger===e.TRIGGER_STICKY);else if(t===e.EVENT_CLICK&&this.data.trigger===e.TRIGGER_CLICK)this.toggle() +return t.extend(!0,n.prototype,{_Construct:function(t,i,s){return this._prop={trigger:e.TRIGGER_HOVER,title:null,inited:!1,delayIn:0,delayOut:0,interactive:!1,gravity:!0,offsetTop:0,offsetLeft:0,position:e.POSITION_BOTTOM,classes:null,arrow:!0,width:300,identifier:!1,icon:!1,observer:!1,target:e.SELECTOR_BODY,skin:void 0,size:void 0,animate:void 0},this.el={},this.el.source=i,this._prop.identifier=t,this.data={},this.classInstance=s,this._isVisible=!1,this._task={delayIn:void 0,delayOut:void 0},this._fetchData(),this._prepareInternals(),this._appendProtip(),this._initSticky(),this._bind(),this.el.source.data(this._namespaced(e.PROP_INITED),!0),this},actionHandler:function(t){if(this.data.trigger===e.TRIGGER_STICKY);else if(t===e.EVENT_CLICK&&this.data.trigger===e.TRIGGER_CLICK)this.toggle() else if(this.data.trigger!==e.TRIGGER_CLICK)switch(t){case e.EVENT_MOUSEOUT:this.hide() break case e.EVENT_MOUSEOVER:this.show()}},destroy:function(){this.el.source.removeData(),this.hide(!0),this._unbind(),this.el.protip.remove()},isVisible:function(){return this._isVisible},toggle:function(){this._isVisible?this.hide():this.show()},show:function(t){if(this._task.delayOut&&clearTimeout(this._task.delayOut),this._task.delayIn&&clearTimeout(this._task.delayIn),!t&&this.data.delayIn)return void(this._task.delayIn=setTimeout(function(){this.show(!0)}.bind(this),this.data.delayIn)) -var o,n -this.data.gravity?(o=new i(this),n=o.position||this.data.position,delete o.position):(o=new s(this),n=this.data.position),this.el.protip.css(o).addClass(e.SELECTOR_SHOW).attr("data-"+e.DEFAULT_NAMESPACE+"-"+e.PROP_POSITION,n),this._isVisible=!0},hide:function(t){return this._task.delayOut&&clearTimeout(this._task.delayOut),this._task.delayIn&&clearTimeout(this._task.delayIn),!t&&this.data.delayOut?void(this._task.delayOut=setTimeout(function(){this.hide(!0)}.bind(this),this.data.delayOut)):(this.el.protip.removeClass(e.SELECTOR_SHOW),void(this._isVisible=!1))},getArrowOffset:function(){return{width:this.el.protipArrow.outerWidth(),height:this.el.protipArrow.outerHeight()}},_fetchData:function(){t.each(this._prop,t.proxy(function(t){this.data[t]=this.el.source.data(this._namespaced(t))},this)),this.data=t.extend({},this._prop,this.data),t.each(this.data,t.proxy(function(t,e){this.el.source.data(this._namespaced(t),e)},this))},_prepareInternals:function(){this._setTarget(),this._detectTitle(),this._checkInteractive()},_checkInteractive:function(){this.data.interactive&&(this.data.delayOut=this.data.delayOut||e.DEFAULT_DELAY_OUT)},_initSticky:function(){this.data.trigger===e.TRIGGER_STICKY&&this.show()},_appendProtip:function(){this.el.protip=o(this.classInstance.settings.protipTemplate,{classes:this._getClassList(),widthType:this._getWidthType(),width:this._getWidth(),content:this.data.title,icon:this._getIconTemplate(),arrow:this.data.arrow?e.TEMPLATE_ARROW:"",identifier:this.data.identifier}),this.el.protip=t(this.el.protip),this.el.protipArrow=this.el.protip.find("."+e.SELECTOR_PREFIX+e.SELECTOR_ARROW),this.el.target.append(this.el.protip)},_getClassList:function(){var t=[] -return t.push(e.SELECTOR_PREFIX+e.SELECTOR_CONTAINER),t.push(e.SELECTOR_SKIN_PREFIX+(this.data.skin||this.classInstance.settings.skin)),this.data.classes&&t.push(this.data.classes),t.join(" ")},_getWidthType:function(){return isNaN(this.data.width)?e.ATTR_WIDTH:e.ATTR_MAX_WIDTH},_getWidth:function(){return parseInt(this.data.width,10)},_getIconTemplate:function(){return this.data.icon?o(this.classInstance.settings.iconTemplate,{icon:this.data.icon}):""},_detectTitle:function(){"#"===this.data.title.charAt(0)&&(this.data.titleSource=this.data.titleSource||this.data.title,this.data.title=t(this.data.title).html())},_setTarget:function(){var i=this._getData(e.PROP_TARGET) -i=i===!0?this.el.source:t(i?i:e.SELECTOR_BODY),"static"===i.css("position")&&i.css({position:"relative"}),this.el.target=i},_getData:function(t){return this.el.source.data(this._namespaced(t))},_namespaced:function(t){return this.classInstance.namespaced(t)},_onProtipMouseenter:function(){clearTimeout(this._task.delayOut)},_onProtipMouseleave:function(){this.data.trigger===e.TRIGGER_HOVER&&this.hide()},_bind:function(){this.data.interactive&&this.el.protip.on(e.EVENT_MOUSEENTER,t.proxy(this._onProtipMouseenter,this)).on(e.EVENT_MOUSELEAVE,t.proxy(this._onProtipMouseleave,this)),this.data.observer&&(this._observerInstance=new MutationObserver(function(){this.classInstance.reloadItemInstance(this.el.source)}.bind(this)),this._observerInstance.observe(this.el.source.get(0),{attributes:!0,childList:!1,characterData:!1,subtree:!1}))},_unbind:function(){this.data.interactive&&this.el.protip.off(e.EVENT_MOUSEENTER,t.proxy(this._onProtipMouseenter,this)).off(e.EVENT_MOUSELEAVE,t.proxy(this._onProtipMouseleave,this)),this.data.observer&&this._observerInstance.disconnect()}}),n})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Constants":2,"./GravityTester":4,"./PositionCalculator":9}],7:[function(t,e,i){window.MutationObserver=window.MutationObserver||function(t){"use strict" -function e(t){this._watched=[],this._listener=t}function i(t){!function i(){var s=t.takeRecords() -s.length&&t._listener(s,t),t._timeout=setTimeout(i,e._period)}()}function s(e){var i={type:null,target:null,addedNodes:[],removedNodes:[],previousSibling:null,nextSibling:null,attributeName:null,attributeNamespace:null,oldValue:null} -for(var s in e)l(i,s)&&e[s]!==t&&(i[s]=e[s]) -return i}function o(t,e){var i=a(t,e) -return function(s){var o,h=s.length -e.attr&&i.attr&&n(s,t,i.attr,e.afilter),(e.kids||e.descendents)&&(o=r(s,t,i,e)),(o||s.length!==h)&&(i=a(t,e))}}function n(t,e,i,o){for(var n,r,a={},h=e.attributes,f=h.length;f--;)n=h[f],r=n.name,(!o||l(o,r))&&(n.value!==i[r]&&t.push(s({type:"attributes",target:e,attributeName:r,oldValue:i[r],attributeNamespace:n.namespaceURI})),a[r]=!0) -for(r in i)a[r]||t.push(s({target:e,type:"attributes",attributeName:r,oldValue:i[r]}))}function r(e,i,o,r){function a(t,i,o,a,h){for(var f,c,u,l=t.length-1,d=-~((l-h)/2);u=t.pop();)f=o[u.i],c=a[u.j],r.kids&&d&&Math.abs(u.i-u.j)>=l&&(e.push(s({type:"childList",target:i,addedNodes:[f],removedNodes:[f],nextSibling:f.nextSibling,previousSibling:f.previousSibling})),d--),r.attr&&c.attr&&n(e,f,c.attr,r.afilter),r.charData&&3===f.nodeType&&f.nodeValue!==c.charData&&e.push(s({type:"characterData",target:f})),r.descendents&&_(f,c)}function _(i,o){for(var l,d,p,T,O,I,E,g=i.childNodes,y=o.kids,P=g.length,R=y?y.length:0,m=0,C=0,w=0;P>C||R>w;)I=g[C],O=y[w],E=O&&O.node,I===E?(r.attr&&O.attr&&n(e,I,O.attr,r.afilter),r.charData&&O.charData!==t&&I.nodeValue!==O.charData&&e.push(s({type:"characterData",target:I})),d&&a(d,i,g,y,m),r.descendents&&(I.childNodes.length||O.kids&&O.kids.length)&&_(I,O),C++,w++):(c=!0,l||(l={},d=[]),I&&(l[p=f(I)]||(l[p]=!0,-1===(T=h(y,I,w))?r.kids&&(e.push(s({type:"childList",target:i,addedNodes:[I],nextSibling:I.nextSibling,previousSibling:I.previousSibling})),m++):d.push({i:C,j:T})),C++),E&&E!==g[C]&&(l[p=f(E)]||(l[p]=!0,-1===(T=u(g,E,C))?r.kids&&(e.push(s({type:"childList",target:o.node,removedNodes:[E],nextSibling:y[w+1],previousSibling:y[w-1]})),m--):d.push({i:T,j:w})),w++)) -d&&a(d,i,g,y,m)}var c -return _(i,o),c}function a(t,e){var i=!0 -return function s(t){var o={node:t} -return!e.charData||3!==t.nodeType&&8!==t.nodeType?(e.attr&&i&&1===t.nodeType&&(o.attr=c(t.attributes,function(t,i){return(!e.afilter||e.afilter[i.name])&&(t[i.name]=i.value),t},{})),i&&(e.kids||e.charData||e.attr&&e.descendents)&&(o.kids=_(t.childNodes,s)),i=e.descendents):o.charData=t.nodeValue,o}(t)}function h(t,e,i){return u(t,e,i,d("node"))}function f(t){try{return t.id||(t[T]=t[T]||p++)}catch(e){try{return t.nodeValue}catch(i){return p++}}}function _(t,e){for(var i=[],s=0;s