browser-sync-client
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -766,14 +766,15 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
if (document.createEvent) { | ||
evObj = document.createEvent("MouseEvents"); | ||
evObj.initEvent("click", true, true); | ||
elem.dispatchEvent(evObj); | ||
window.setTimeout(function () { | ||
evObj = document.createEvent("MouseEvents"); | ||
evObj.initEvent("click", true, true); | ||
elem.dispatchEvent(evObj); | ||
}, 0); | ||
} else { | ||
if (document.createEventObject) { | ||
evObj = document.createEventObject(); | ||
evObj.cancelBubble = true; | ||
elem.fireEvent("on" + "click", evObj); | ||
} | ||
window.setTimeout(function () { | ||
if (document.createEventObject) { | ||
evObj = document.createEventObject(); | ||
evObj.cancelBubble = true; | ||
elem.fireEvent("on" + "click", evObj); | ||
} | ||
}, 0); | ||
} | ||
@@ -780,0 +781,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function t(e,n,o){function i(s,c){if(!n[s]){if(!e[s]){var a="function"==typeof require&&require;if(!c&&a)return a(s,!0);if(r)return r(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=n[s]={exports:{}};e[s][0].call(u.exports,function(t){var n=e[s][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(t,e){"use strict";function n(t){return"undefined"==typeof t}function o(t,e){for(var n=0,o=e.split("."),i=o.length;i>n;n++){if(!t||"object"!=typeof t)return!1;t=t[o[n]]}return"undefined"==typeof t?!1:t}var i=t("./socket"),r=t("./emitter"),s=(t("./notify"),t("./browser.utils")),c=function(t){this.options=t,this.socket=i,this.emitter=r,this.utils=s.utils;var e=this;i.on("options:set",function(t){r.emit("notify","Setting options..."),e.options=t.options})};c.prototype.canSync=function(t,e){t=t||{};var n=!0;return e&&(n=this.getOption(e)),n&&t.url===window.location.pathname},c.prototype.getOption=function(t){if(t&&t.match(/\./))return o(this.options,t);var e=this.options[t];return n(e)?!1:e},e.exports=c},{"./browser.utils":2,"./emitter":5,"./notify":16,"./socket":17}],2:[function(t,e,n){"use strict";n.getWindow=function(){return window},n.getDocument=function(){return document},n.utils={getBrowserScrollPosition:function(){var t,e,o=n.getWindow(),i=n.getDocument(),r=i.documentElement,s=i.body;return void 0!==o.pageYOffset?(t=o.pageXOffset,e=o.pageYOffset):(t=r.scrollLeft||s.scrollLeft||0,e=r.scrollTop||s.scrollTop||0),{x:t,y:e}},getScrollSpace:function(){var t=n.getDocument(),e=t.documentElement,o=t.body;return{x:o.scrollHeight-e.clientWidth,y:o.scrollHeight-e.clientHeight}},saveScrollPosition:function(){var t=n.utils.getBrowserScrollPosition();t=[t.x,t.y],document.cookie="bs_scroll_pos="+t.join(",")},restoreScrollPosition:function(){var t=document.cookie.replace(/(?:(?:^|.*;\s*)bs_scroll_pos\s*\=\s*([^;]*).*$)|^.*$/,"$1").split(",");window.scrollTo(t[0],t[1])},getElementIndex:function(t,e){var n=document.getElementsByTagName(t);return Array.prototype.indexOf.call(n,e)},forceChange:function(t){t.blur(),t.focus()},getElementData:function(t){var e=t.tagName,o=n.utils.getElementIndex(e,t);return{tagName:e,index:o}},getSingleElement:function(t,e){var n=document.getElementsByTagName(t);return n[e]},getBody:function(){return document.getElementsByTagName("body")[0]},reloadBrowser:function(){n.getWindow().location.reload(!0)},getWindow:n.getWindow,getDocument:n.getDocument,isOldIe:function(){return"undefined"!=typeof window.attachEvent}}},{}],3:[function(){"indexOf"in Array.prototype||(Array.prototype.indexOf=function(t,e){void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0);for(var n=this.length;n>e;e+=1)if(e in this&&this[e]===t)return e;return-1})},{}],4:[function(t,e,n){"use strict";var o,i=t("./events"),r=t("./browser.utils").utils,s={tagNames:{css:"link",jpg:"img",jpeg:"img",png:"img",svg:"img",gif:"img",js:"script"},attrs:{link:"href",img:"src",script:"src"}},c="codeSync",a=function(){return window.location.pathname};n.init=function(t){n.saveScroll(r.getWindow(),r.getDocument()),t.socket.on("file:reload",n.reload(t)),t.socket.on("browser:reload",function(){t.canSync({url:a()},c)&&n.reloadBrowser(!0)})},n.saveScroll=function(t,e){r.isOldIe()&&("complete"===e.readyState?r.restoreScrollPosition():i.manager.addEvent(e,"readystatechange",function(){"complete"===e.readyState&&r.restoreScrollPosition()}),i.manager.addEvent(window,"beforeunload",r.saveScrollPosition))},n.swapFile=function(t,e,n){var i=t[e],r=(new Date).getTime(),s="?rel="+r,c=/^[^\?]+(?=\?)/.exec(i);c&&(i=c[0]),n&&(n.timestamps||(s="")),t[e]=i+s;var a=document.body;return setTimeout(function(){o?(o.style.display="none",o.style.display="block"):(o=document.createElement("DIV"),a.appendChild(o))},200),{elem:t,timeStamp:r}},n.reload=function(t){return function(e){if(t.canSync({url:a()},c)){var o,i=t.options,r=t.emitter;if((e.url||!i.injectChanges)&&n.reloadBrowser(!0),e.assetFileName&&e.fileExtension){var s=n.getElems(e.fileExtension),u=n.getMatches(s.elems,e.assetFileName,s.attr);u.length&&i.notify&&r.emit("notify",{message:"Injected: "+e.assetFileName});for(var l=0,f=u.length;f>l;l+=1)o=n.swapFile(u[l],s.attr,i)}return o}}},n.getTagName=function(t){return s.tagNames[t]},n.getAttr=function(t){return s.attrs[t]},n.getMatches=function(t,e,n){for(var o=[],i=0,r=t.length;r>i;i+=1)-1!==t[i][n].indexOf(e)&&o.push(t[i]);return o},n.getElems=function(t){var e=n.getTagName(t),o=n.getAttr(e);return{elems:document.getElementsByTagName(e),attr:o}},n.getWindow=function(){return window},n.reloadBrowser=function(t){var e=n.getWindow();t&&e.location.reload(!0)}},{"./browser.utils":2,"./events":6}],5:[function(t,e,n){"use strict";n.events={},n.emit=function(t,e){var o,i=n.events[t];if(i&&i.listeners){o=i.listeners;for(var r=0,s=o.length;s>r;r+=1)o[r](e)}},n.on=function(t,e){var o=n.events;o[t]?o[t].listeners.push(e):o[t]={listeners:[e]}}},{}],6:[function(t,e,n){n._ElementCache=function(){var t={},e=1,n="data"+(new Date).getTime();this.getData=function(o){var i=o[n];return i||(i=o[n]=e++,t[i]={}),t[i]},this.removeData=function(e){var o=e[n];if(o){delete t[o];try{delete e[n]}catch(i){e.removeAttribute&&e.removeAttribute(n)}}}},n._fixEvent=function(t){function e(){return!0}function n(){return!1}if(!t||!t.stopPropagation){var o=t||window.event;t={};for(var i in o)t[i]=o[i];if(t.target||(t.target=t.srcElement||document),t.relatedTarget=t.fromElement===t.target?t.toElement:t.fromElement,t.preventDefault=function(){t.returnValue=!1,t.isDefaultPrevented=e},t.isDefaultPrevented=n,t.stopPropagation=function(){t.cancelBubble=!0,t.isPropagationStopped=e},t.isPropagationStopped=n,t.stopImmediatePropagation=function(){this.isImmediatePropagationStopped=e,this.stopPropagation()},t.isImmediatePropagationStopped=n,null!=t.clientX){var r=document.documentElement,s=document.body;t.pageX=t.clientX+(r&&r.scrollLeft||s&&s.scrollLeft||0)-(r&&r.clientLeft||s&&s.clientLeft||0),t.pageY=t.clientY+(r&&r.scrollTop||s&&s.scrollTop||0)-(r&&r.clientTop||s&&s.clientTop||0)}t.which=t.charCode||t.keyCode,null!=t.button&&(t.button=1&t.button?0:4&t.button?1:2&t.button?2:0)}return t},n._EventManager=function(t){function e(e,n){function o(t){for(var e in t)return!1;return!0}var i=t.getData(e);0===i.handlers[n].length&&(delete i.handlers[n],document.removeEventListener?e.removeEventListener(n,i.dispatcher,!1):document.detachEvent&&e.detachEvent("on"+n,i.dispatcher)),o(i.handlers)&&(delete i.handlers,delete i.dispatcher),o(i)&&t.removeData(e)}var o=1;this.addEvent=function(e,i,r){var s=t.getData(e);s.handlers||(s.handlers={}),s.handlers[i]||(s.handlers[i]=[]),r.guid||(r.guid=o++),s.handlers[i].push(r),s.dispatcher||(s.disabled=!1,s.dispatcher=function(t){if(!s.disabled){t=n._fixEvent(t);var o=s.handlers[t.type];if(o)for(var i=0;i<o.length;i++)o[i].call(e,t)}}),1==s.handlers[i].length&&(document.addEventListener?e.addEventListener(i,s.dispatcher,!1):document.attachEvent&&e.attachEvent("on"+i,s.dispatcher))},this.removeEvent=function(n,o,i){var r=t.getData(n);if(r.handlers){var s=function(t){r.handlers[t]=[],e(n,t)};if(o){var c=r.handlers[o];if(c){if(!i)return void s(o);if(i.guid)for(var a=0;a<c.length;a++)c[a].guid===i.guid&&c.splice(a--,1);e(n,o)}}else for(var u in r.handlers)s(u)}},this.proxy=function(t,e){e.guid||(e.guid=o++);var n=function(){return e.apply(t,arguments)};return n.guid=e.guid,n}},n.triggerClick=function(t){var e;document.createEvent?(e=document.createEvent("MouseEvents"),e.initEvent("click",!0,!0),t.dispatchEvent(e)):document.createEventObject&&(e=document.createEventObject(),e.cancelBubble=!0,t.fireEvent("onclick",e))};var o=new n._ElementCache,i=new n._EventManager(o);i.triggerClick=n.triggerClick,n.manager=i},{}],7:[function(t,e,n){"use strict";var o=t("./socket"),i=(t("./client-shims"),t("./notify")),r=t("./code-sync"),s=t("./browser-sync"),c=t("./ghostmode"),a=(t("./emitter"),t("./events"),t("./browser.utils").utils),u=!1;n.init=function(t){u&&a.reloadBrowser();var e=window.___browserSync___||{};if(!e.client){e.client=!0;var n=new s(t);c.init(n),r.init(n),t.notify&&(i.init(n),i.flash("Connected to BrowserSync"))}},o.on("connection",n.init),o.on("disconnect",function(){i.flash("Disconnected From BrowserSync"),u=!0})},{"./browser-sync":1,"./browser.utils":2,"./client-shims":3,"./code-sync":4,"./emitter":5,"./events":6,"./ghostmode":13,"./ghostmode.clicks":8,"./ghostmode.forms":10,"./ghostmode.forms.input":9,"./ghostmode.forms.submit":11,"./ghostmode.forms.toggles":12,"./ghostmode.location":14,"./ghostmode.scroll":15,"./notify":16,"./socket":17}],8:[function(t,e,n){"use strict";var o="click",i="ghostMode.clicks";n.canEmitEvents=!0,n.init=function(t,e){e.addEvent(document.body,o,n.browserEvent(t)),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i=e.target||e.srcElement;if("checkbox"===i.type||"radio"===i.type)return void t.utils.forceChange(i);t.socket.emit(o,t.utils.getElementData(i))}else n.canEmitEvents=!0}},n.socketEvent=function(t,e){return function(o){if(t.canSync(o,i)){var r=t.utils.getSingleElement(o.tagName,o.index);r&&(n.canEmitEvents=!1,e.triggerClick(r))}}}},{}],9:[function(t,e,n){"use strict";var o="input:text",i="ghostMode.forms.inputs";n.canEmitEvents=!0,n.init=function(t,e){e.addEvent(document.body,"keyup",n.browserEvent(t)),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){var i,r=e.target||e.srcElement;n.canEmitEvents?("INPUT"===r.tagName||"TEXTAREA"===r.tagName)&&(i=t.utils.getElementData(r),i.value=r.value,t.socket.emit(o,i)):n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e,i)){var n=t.utils.getSingleElement(e.tagName,e.index);if(n)return n.value=e.value,n}return!1}}},{}],10:[function(t,e,n){"use strict";n.plugins={inputs:t("./ghostmode.forms.input"),toggles:t("./ghostmode.forms.toggles"),submit:t("./ghostmode.forms.submit")},n.init=function(t,e){function o(o){n.plugins[o].init(t,e)}var i=!0,r=t.options.ghostMode.forms;r===!0&&(i=!1);for(var s in n.plugins)i?r[s]&&o(s):o(s)}},{"./ghostmode.forms.input":9,"./ghostmode.forms.submit":11,"./ghostmode.forms.toggles":12}],11:[function(t,e,n){"use strict";var o="form:submit",i="ghostMode.forms.submit";n.canEmitEvents=!0,n.init=function(t,e){var i=n.browserEvent(t);e.addEvent(document.body,"submit",i),e.addEvent(document.body,"reset",i),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i=e.target||e.srcElement,r=t.utils.getElementData(i);r.type=e.type,t.socket.emit(o,r)}else n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e,i)){var o=t.utils.getSingleElement(e.tagName,e.index);return n.canEmitEvents=!1,o&&"submit"===e.type&&o.submit(),o&&"reset"===e.type&&o.reset(),!1}return!1}}},{}],12:[function(t,e,n){"use strict";var o="input:toggles",i="ghostMode.forms.toggles";n.canEmitEvents=!0,n.init=function(t,e){var i=n.browserEvent(t);n.addEvents(e,i),t.socket.on(o,n.socketEvent(t,e))},n.addEvents=function(t,e){function n(n){for(var o=0,i=n.length;i>o;o+=1)t.addEvent(n[o],"change",e)}var o=document.getElementsByTagName("select"),i=document.getElementsByTagName("input");n(o),n(i)},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i,r=e.target||e.srcElement;("radio"===r.type||"checkbox"===r.type||"SELECT"===r.tagName)&&(i=t.utils.getElementData(r),i.type=r.type,i.value=r.value,i.checked=r.checked,t.socket.emit(o,i))}else n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e,i)){n.canEmitEvents=!1;var o=t.utils.getSingleElement(e.tagName,e.index);return o?("radio"===e.type&&(o.checked=!0),"checkbox"===e.type&&(o.checked=e.checked),"SELECT"===e.tagName&&(o.value=e.value),o):!1}return!1}}},{}],13:[function(t,e,n){"use strict";var o=t("./events").manager;n.plugins={scroll:t("./ghostmode.scroll"),clicks:t("./ghostmode.clicks"),forms:t("./ghostmode.forms"),location:t("./ghostmode.location")},n.init=function(t){for(var e in n.plugins)n.plugins[e].init(t,o)}},{"./events":6,"./ghostmode.clicks":8,"./ghostmode.forms":10,"./ghostmode.location":14,"./ghostmode.scroll":15}],14:[function(t,e,n){"use strict";var o="browser:location",i="ghostMode.location";n.canEmitEvents=!0,n.init=function(t){t.socket.on(o,n.socketEvent())},n.socketEvent=function(t){return function(e){(e.override||t.canSync(e,i))&&(e.path?n.setPath(e.path):n.setUrl(e.url))}},n.setUrl=function(t){window.location=t},n.setPath=function(t){window.location.pathname=t}},{}],15:[function(t,e,n){"use strict";var o,i="scroll",r="ghostMode.scroll";n.canEmitEvents=!0,n.init=function(t,e){o=t.utils,e.addEvent(window,i,n.browserEvent(t)),t.socket.on(i,n.socketEvent(t))},n.socketEvent=function(t){return function(e){var i=o.getScrollSpace();return n.canEmitEvents=!1,t.canSync(e,r)?t.options&&t.options.scrollProportionally?window.scrollTo(0,i.y*e.position.proportional):window.scrollTo(0,e.position.raw):!1}},n.browserEvent=function(t){return function(){var e=n.canEmitEvents;e&&t.socket.emit(i,{position:n.getScrollPosition()}),n.canEmitEvents=!0}},n.getScrollPosition=function(){var t=o.getBrowserScrollPosition();return{raw:t,proportional:n.getScrollTopPercentage(t)}},n.getScrollPercentage=function(t,e){var n=e.x/t.x,o=e.y/t.y;return{x:n||0,y:o}},n.getScrollTopPercentage=function(t){var e=o.getScrollSpace(),i=n.getScrollPercentage(e,t);return i.y}},{}],16:[function(t,e,n){"use strict";var o,i,r,s,c=(t("./ghostmode.scroll"),["display: none","padding: 15px","font-family: sans-serif","position: fixed","font-size: 0.9em","z-index: 9999","right: 0px","top: 0px","border-bottom-left-radius: 5px","background-color: #1B2032","margin: 0","color: white","text-align: center"]);n.init=function(t){o=t,r=t.options;var e=c;r.notify.styles&&(e=r.notify.styles),i=document.createElement("DIV"),i.id="__bs_notify__",i.style.cssText=e.join(";"),document.getElementsByTagName("body")[0].appendChild(i);var s=n.watchEvent();return o.emitter.on("notify",s),o.socket.on("browser:notify",s),i},n.watchEvent=function(){return function(t){return"string"==typeof t?n.flash(t):void n.flash(t.message,t.timeout)}},n.getElem=function(){return i},n.getScrollTop=function(){return o.utils.getBrowserScrollPosition().y},n.flash=function(t,e){var o=n.getElem();return o?(o.innerHTML=t,o.style.display="block",s&&(clearTimeout(s),s=void 0),s=window.setTimeout(function(){o.style.display="none"},e||2e3),o):!1}},{"./ghostmode.scroll":15}],17:[function(t,e,n){"use strict";var o=window.___browserSync___||{};n.socket=o.socket||{emit:function(){},on:function(){}},n.getPath=function(){return window.location.pathname},n.emit=function(t,e){var o=n.socket;o&&o.emit&&(e.url=n.getPath(),o.emit(t,e))},n.on=function(t,e){n.socket.on(t,e)}},{}]},{},[7]); | ||
!function t(e,n,o){function i(s,c){if(!n[s]){if(!e[s]){var a="function"==typeof require&&require;if(!c&&a)return a(s,!0);if(r)return r(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=n[s]={exports:{}};e[s][0].call(u.exports,function(t){var n=e[s][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(t,e){"use strict";function n(t){return"undefined"==typeof t}function o(t,e){for(var n=0,o=e.split("."),i=o.length;i>n;n++){if(!t||"object"!=typeof t)return!1;t=t[o[n]]}return"undefined"==typeof t?!1:t}var i=t("./socket"),r=t("./emitter"),s=(t("./notify"),t("./browser.utils")),c=function(t){this.options=t,this.socket=i,this.emitter=r,this.utils=s.utils;var e=this;i.on("options:set",function(t){r.emit("notify","Setting options..."),e.options=t.options})};c.prototype.canSync=function(t,e){t=t||{};var n=!0;return e&&(n=this.getOption(e)),n&&t.url===window.location.pathname},c.prototype.getOption=function(t){if(t&&t.match(/\./))return o(this.options,t);var e=this.options[t];return n(e)?!1:e},e.exports=c},{"./browser.utils":2,"./emitter":5,"./notify":16,"./socket":17}],2:[function(t,e,n){"use strict";n.getWindow=function(){return window},n.getDocument=function(){return document},n.utils={getBrowserScrollPosition:function(){var t,e,o=n.getWindow(),i=n.getDocument(),r=i.documentElement,s=i.body;return void 0!==o.pageYOffset?(t=o.pageXOffset,e=o.pageYOffset):(t=r.scrollLeft||s.scrollLeft||0,e=r.scrollTop||s.scrollTop||0),{x:t,y:e}},getScrollSpace:function(){var t=n.getDocument(),e=t.documentElement,o=t.body;return{x:o.scrollHeight-e.clientWidth,y:o.scrollHeight-e.clientHeight}},saveScrollPosition:function(){var t=n.utils.getBrowserScrollPosition();t=[t.x,t.y],document.cookie="bs_scroll_pos="+t.join(",")},restoreScrollPosition:function(){var t=document.cookie.replace(/(?:(?:^|.*;\s*)bs_scroll_pos\s*\=\s*([^;]*).*$)|^.*$/,"$1").split(",");window.scrollTo(t[0],t[1])},getElementIndex:function(t,e){var n=document.getElementsByTagName(t);return Array.prototype.indexOf.call(n,e)},forceChange:function(t){t.blur(),t.focus()},getElementData:function(t){var e=t.tagName,o=n.utils.getElementIndex(e,t);return{tagName:e,index:o}},getSingleElement:function(t,e){var n=document.getElementsByTagName(t);return n[e]},getBody:function(){return document.getElementsByTagName("body")[0]},reloadBrowser:function(){n.getWindow().location.reload(!0)},getWindow:n.getWindow,getDocument:n.getDocument,isOldIe:function(){return"undefined"!=typeof window.attachEvent}}},{}],3:[function(){"indexOf"in Array.prototype||(Array.prototype.indexOf=function(t,e){void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0);for(var n=this.length;n>e;e+=1)if(e in this&&this[e]===t)return e;return-1})},{}],4:[function(t,e,n){"use strict";var o,i=t("./events"),r=t("./browser.utils").utils,s={tagNames:{css:"link",jpg:"img",jpeg:"img",png:"img",svg:"img",gif:"img",js:"script"},attrs:{link:"href",img:"src",script:"src"}},c="codeSync",a=function(){return window.location.pathname};n.init=function(t){n.saveScroll(r.getWindow(),r.getDocument()),t.socket.on("file:reload",n.reload(t)),t.socket.on("browser:reload",function(){t.canSync({url:a()},c)&&n.reloadBrowser(!0)})},n.saveScroll=function(t,e){r.isOldIe()&&("complete"===e.readyState?r.restoreScrollPosition():i.manager.addEvent(e,"readystatechange",function(){"complete"===e.readyState&&r.restoreScrollPosition()}),i.manager.addEvent(window,"beforeunload",r.saveScrollPosition))},n.swapFile=function(t,e,n){var i=t[e],r=(new Date).getTime(),s="?rel="+r,c=/^[^\?]+(?=\?)/.exec(i);c&&(i=c[0]),n&&(n.timestamps||(s="")),t[e]=i+s;var a=document.body;return setTimeout(function(){o?(o.style.display="none",o.style.display="block"):(o=document.createElement("DIV"),a.appendChild(o))},200),{elem:t,timeStamp:r}},n.reload=function(t){return function(e){if(t.canSync({url:a()},c)){var o,i=t.options,r=t.emitter;if((e.url||!i.injectChanges)&&n.reloadBrowser(!0),e.assetFileName&&e.fileExtension){var s=n.getElems(e.fileExtension),u=n.getMatches(s.elems,e.assetFileName,s.attr);u.length&&i.notify&&r.emit("notify",{message:"Injected: "+e.assetFileName});for(var l=0,f=u.length;f>l;l+=1)o=n.swapFile(u[l],s.attr,i)}return o}}},n.getTagName=function(t){return s.tagNames[t]},n.getAttr=function(t){return s.attrs[t]},n.getMatches=function(t,e,n){for(var o=[],i=0,r=t.length;r>i;i+=1)-1!==t[i][n].indexOf(e)&&o.push(t[i]);return o},n.getElems=function(t){var e=n.getTagName(t),o=n.getAttr(e);return{elems:document.getElementsByTagName(e),attr:o}},n.getWindow=function(){return window},n.reloadBrowser=function(t){var e=n.getWindow();t&&e.location.reload(!0)}},{"./browser.utils":2,"./events":6}],5:[function(t,e,n){"use strict";n.events={},n.emit=function(t,e){var o,i=n.events[t];if(i&&i.listeners){o=i.listeners;for(var r=0,s=o.length;s>r;r+=1)o[r](e)}},n.on=function(t,e){var o=n.events;o[t]?o[t].listeners.push(e):o[t]={listeners:[e]}}},{}],6:[function(t,e,n){n._ElementCache=function(){var t={},e=1,n="data"+(new Date).getTime();this.getData=function(o){var i=o[n];return i||(i=o[n]=e++,t[i]={}),t[i]},this.removeData=function(e){var o=e[n];if(o){delete t[o];try{delete e[n]}catch(i){e.removeAttribute&&e.removeAttribute(n)}}}},n._fixEvent=function(t){function e(){return!0}function n(){return!1}if(!t||!t.stopPropagation){var o=t||window.event;t={};for(var i in o)t[i]=o[i];if(t.target||(t.target=t.srcElement||document),t.relatedTarget=t.fromElement===t.target?t.toElement:t.fromElement,t.preventDefault=function(){t.returnValue=!1,t.isDefaultPrevented=e},t.isDefaultPrevented=n,t.stopPropagation=function(){t.cancelBubble=!0,t.isPropagationStopped=e},t.isPropagationStopped=n,t.stopImmediatePropagation=function(){this.isImmediatePropagationStopped=e,this.stopPropagation()},t.isImmediatePropagationStopped=n,null!=t.clientX){var r=document.documentElement,s=document.body;t.pageX=t.clientX+(r&&r.scrollLeft||s&&s.scrollLeft||0)-(r&&r.clientLeft||s&&s.clientLeft||0),t.pageY=t.clientY+(r&&r.scrollTop||s&&s.scrollTop||0)-(r&&r.clientTop||s&&s.clientTop||0)}t.which=t.charCode||t.keyCode,null!=t.button&&(t.button=1&t.button?0:4&t.button?1:2&t.button?2:0)}return t},n._EventManager=function(t){function e(e,n){function o(t){for(var e in t)return!1;return!0}var i=t.getData(e);0===i.handlers[n].length&&(delete i.handlers[n],document.removeEventListener?e.removeEventListener(n,i.dispatcher,!1):document.detachEvent&&e.detachEvent("on"+n,i.dispatcher)),o(i.handlers)&&(delete i.handlers,delete i.dispatcher),o(i)&&t.removeData(e)}var o=1;this.addEvent=function(e,i,r){var s=t.getData(e);s.handlers||(s.handlers={}),s.handlers[i]||(s.handlers[i]=[]),r.guid||(r.guid=o++),s.handlers[i].push(r),s.dispatcher||(s.disabled=!1,s.dispatcher=function(t){if(!s.disabled){t=n._fixEvent(t);var o=s.handlers[t.type];if(o)for(var i=0;i<o.length;i++)o[i].call(e,t)}}),1==s.handlers[i].length&&(document.addEventListener?e.addEventListener(i,s.dispatcher,!1):document.attachEvent&&e.attachEvent("on"+i,s.dispatcher))},this.removeEvent=function(n,o,i){var r=t.getData(n);if(r.handlers){var s=function(t){r.handlers[t]=[],e(n,t)};if(o){var c=r.handlers[o];if(c){if(!i)return void s(o);if(i.guid)for(var a=0;a<c.length;a++)c[a].guid===i.guid&&c.splice(a--,1);e(n,o)}}else for(var u in r.handlers)s(u)}},this.proxy=function(t,e){e.guid||(e.guid=o++);var n=function(){return e.apply(t,arguments)};return n.guid=e.guid,n}},n.triggerClick=function(t){var e;document.createEvent?window.setTimeout(function(){e=document.createEvent("MouseEvents"),e.initEvent("click",!0,!0),t.dispatchEvent(e)},0):window.setTimeout(function(){document.createEventObject&&(e=document.createEventObject(),e.cancelBubble=!0,t.fireEvent("onclick",e))},0)};var o=new n._ElementCache,i=new n._EventManager(o);i.triggerClick=n.triggerClick,n.manager=i},{}],7:[function(t,e,n){"use strict";var o=t("./socket"),i=(t("./client-shims"),t("./notify")),r=t("./code-sync"),s=t("./browser-sync"),c=t("./ghostmode"),a=(t("./emitter"),t("./events"),t("./browser.utils").utils),u=!1;n.init=function(t){u&&a.reloadBrowser();var e=window.___browserSync___||{};if(!e.client){e.client=!0;var n=new s(t);c.init(n),r.init(n),t.notify&&(i.init(n),i.flash("Connected to BrowserSync"))}},o.on("connection",n.init),o.on("disconnect",function(){i.flash("Disconnected From BrowserSync"),u=!0})},{"./browser-sync":1,"./browser.utils":2,"./client-shims":3,"./code-sync":4,"./emitter":5,"./events":6,"./ghostmode":13,"./ghostmode.clicks":8,"./ghostmode.forms":10,"./ghostmode.forms.input":9,"./ghostmode.forms.submit":11,"./ghostmode.forms.toggles":12,"./ghostmode.location":14,"./ghostmode.scroll":15,"./notify":16,"./socket":17}],8:[function(t,e,n){"use strict";var o="click",i="ghostMode.clicks";n.canEmitEvents=!0,n.init=function(t,e){e.addEvent(document.body,o,n.browserEvent(t)),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i=e.target||e.srcElement;if("checkbox"===i.type||"radio"===i.type)return void t.utils.forceChange(i);t.socket.emit(o,t.utils.getElementData(i))}else n.canEmitEvents=!0}},n.socketEvent=function(t,e){return function(o){if(t.canSync(o,i)){var r=t.utils.getSingleElement(o.tagName,o.index);r&&(n.canEmitEvents=!1,e.triggerClick(r))}}}},{}],9:[function(t,e,n){"use strict";var o="input:text",i="ghostMode.forms.inputs";n.canEmitEvents=!0,n.init=function(t,e){e.addEvent(document.body,"keyup",n.browserEvent(t)),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){var i,r=e.target||e.srcElement;n.canEmitEvents?("INPUT"===r.tagName||"TEXTAREA"===r.tagName)&&(i=t.utils.getElementData(r),i.value=r.value,t.socket.emit(o,i)):n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e,i)){var n=t.utils.getSingleElement(e.tagName,e.index);if(n)return n.value=e.value,n}return!1}}},{}],10:[function(t,e,n){"use strict";n.plugins={inputs:t("./ghostmode.forms.input"),toggles:t("./ghostmode.forms.toggles"),submit:t("./ghostmode.forms.submit")},n.init=function(t,e){function o(o){n.plugins[o].init(t,e)}var i=!0,r=t.options.ghostMode.forms;r===!0&&(i=!1);for(var s in n.plugins)i?r[s]&&o(s):o(s)}},{"./ghostmode.forms.input":9,"./ghostmode.forms.submit":11,"./ghostmode.forms.toggles":12}],11:[function(t,e,n){"use strict";var o="form:submit",i="ghostMode.forms.submit";n.canEmitEvents=!0,n.init=function(t,e){var i=n.browserEvent(t);e.addEvent(document.body,"submit",i),e.addEvent(document.body,"reset",i),t.socket.on(o,n.socketEvent(t,e))},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i=e.target||e.srcElement,r=t.utils.getElementData(i);r.type=e.type,t.socket.emit(o,r)}else n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e,i)){var o=t.utils.getSingleElement(e.tagName,e.index);return n.canEmitEvents=!1,o&&"submit"===e.type&&o.submit(),o&&"reset"===e.type&&o.reset(),!1}return!1}}},{}],12:[function(t,e,n){"use strict";var o="input:toggles",i="ghostMode.forms.toggles";n.canEmitEvents=!0,n.init=function(t,e){var i=n.browserEvent(t);n.addEvents(e,i),t.socket.on(o,n.socketEvent(t,e))},n.addEvents=function(t,e){function n(n){for(var o=0,i=n.length;i>o;o+=1)t.addEvent(n[o],"change",e)}var o=document.getElementsByTagName("select"),i=document.getElementsByTagName("input");n(o),n(i)},n.browserEvent=function(t){return function(e){if(n.canEmitEvents){var i,r=e.target||e.srcElement;("radio"===r.type||"checkbox"===r.type||"SELECT"===r.tagName)&&(i=t.utils.getElementData(r),i.type=r.type,i.value=r.value,i.checked=r.checked,t.socket.emit(o,i))}else n.canEmitEvents=!0}},n.socketEvent=function(t){return function(e){if(t.canSync(e,i)){n.canEmitEvents=!1;var o=t.utils.getSingleElement(e.tagName,e.index);return o?("radio"===e.type&&(o.checked=!0),"checkbox"===e.type&&(o.checked=e.checked),"SELECT"===e.tagName&&(o.value=e.value),o):!1}return!1}}},{}],13:[function(t,e,n){"use strict";var o=t("./events").manager;n.plugins={scroll:t("./ghostmode.scroll"),clicks:t("./ghostmode.clicks"),forms:t("./ghostmode.forms"),location:t("./ghostmode.location")},n.init=function(t){for(var e in n.plugins)n.plugins[e].init(t,o)}},{"./events":6,"./ghostmode.clicks":8,"./ghostmode.forms":10,"./ghostmode.location":14,"./ghostmode.scroll":15}],14:[function(t,e,n){"use strict";var o="browser:location",i="ghostMode.location";n.canEmitEvents=!0,n.init=function(t){t.socket.on(o,n.socketEvent())},n.socketEvent=function(t){return function(e){(e.override||t.canSync(e,i))&&(e.path?n.setPath(e.path):n.setUrl(e.url))}},n.setUrl=function(t){window.location=t},n.setPath=function(t){window.location.pathname=t}},{}],15:[function(t,e,n){"use strict";var o,i="scroll",r="ghostMode.scroll";n.canEmitEvents=!0,n.init=function(t,e){o=t.utils,e.addEvent(window,i,n.browserEvent(t)),t.socket.on(i,n.socketEvent(t))},n.socketEvent=function(t){return function(e){var i=o.getScrollSpace();return n.canEmitEvents=!1,t.canSync(e,r)?t.options&&t.options.scrollProportionally?window.scrollTo(0,i.y*e.position.proportional):window.scrollTo(0,e.position.raw):!1}},n.browserEvent=function(t){return function(){var e=n.canEmitEvents;e&&t.socket.emit(i,{position:n.getScrollPosition()}),n.canEmitEvents=!0}},n.getScrollPosition=function(){var t=o.getBrowserScrollPosition();return{raw:t,proportional:n.getScrollTopPercentage(t)}},n.getScrollPercentage=function(t,e){var n=e.x/t.x,o=e.y/t.y;return{x:n||0,y:o}},n.getScrollTopPercentage=function(t){var e=o.getScrollSpace(),i=n.getScrollPercentage(e,t);return i.y}},{}],16:[function(t,e,n){"use strict";var o,i,r,s,c=(t("./ghostmode.scroll"),["display: none","padding: 15px","font-family: sans-serif","position: fixed","font-size: 0.9em","z-index: 9999","right: 0px","top: 0px","border-bottom-left-radius: 5px","background-color: #1B2032","margin: 0","color: white","text-align: center"]);n.init=function(t){o=t,r=t.options;var e=c;r.notify.styles&&(e=r.notify.styles),i=document.createElement("DIV"),i.id="__bs_notify__",i.style.cssText=e.join(";"),document.getElementsByTagName("body")[0].appendChild(i);var s=n.watchEvent();return o.emitter.on("notify",s),o.socket.on("browser:notify",s),i},n.watchEvent=function(){return function(t){return"string"==typeof t?n.flash(t):void n.flash(t.message,t.timeout)}},n.getElem=function(){return i},n.getScrollTop=function(){return o.utils.getBrowserScrollPosition().y},n.flash=function(t,e){var o=n.getElem();return o?(o.innerHTML=t,o.style.display="block",s&&(clearTimeout(s),s=void 0),s=window.setTimeout(function(){o.style.display="none"},e||2e3),o):!1}},{"./ghostmode.scroll":15}],17:[function(t,e,n){"use strict";var o=window.___browserSync___||{};n.socket=o.socket||{emit:function(){},on:function(){}},n.getPath=function(){return window.location.pathname},n.emit=function(t,e){var o=n.socket;o&&o.emit&&(e.url=n.getPath(),o.emit(t,e))},n.on=function(t,e){n.socket.on(t,e)}},{}]},{},[7]); |
@@ -255,14 +255,15 @@ exports._ElementCache = function () { | ||
if (document.createEvent) { | ||
evObj = document.createEvent("MouseEvents"); | ||
evObj.initEvent("click", true, true); | ||
elem.dispatchEvent(evObj); | ||
window.setTimeout(function () { | ||
evObj = document.createEvent("MouseEvents"); | ||
evObj.initEvent("click", true, true); | ||
elem.dispatchEvent(evObj); | ||
}, 0); | ||
} else { | ||
if (document.createEventObject) { | ||
evObj = document.createEventObject(); | ||
evObj.cancelBubble = true; | ||
elem.fireEvent("on" + "click", evObj); | ||
} | ||
window.setTimeout(function () { | ||
if (document.createEventObject) { | ||
evObj = document.createEventObject(); | ||
evObj.cancelBubble = true; | ||
elem.fireEvent("on" + "click", evObj); | ||
} | ||
}, 0); | ||
} | ||
@@ -269,0 +270,0 @@ }; |
{ | ||
"name": "browser-sync-client", | ||
"description": "Client-side scripts for BrowserSync", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"homepage": "https://github.com/shakyshane/browser-sync-client", | ||
@@ -6,0 +6,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166607
2560