browser-sync
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -32,2 +32,4 @@ 'use strict'; | ||
var notifyElem; | ||
var browserSync = { | ||
@@ -45,3 +47,34 @@ /** | ||
} | ||
if (options.notify) { | ||
this.createNotifyElem(); | ||
} | ||
}, | ||
createNotifyElem: function () { | ||
notifyElem = document.createElement("DIV"); | ||
notifyElem.style.backgroundColor = "black"; | ||
notifyElem.style.color = "white"; | ||
notifyElem.style.padding = "10px"; | ||
notifyElem.style.display = "none"; | ||
notifyElem.style.fontFamily = "sans-serif"; | ||
notifyElem.style.position = "absolute"; | ||
notifyElem.style.zIndex = "1000"; | ||
notifyElem.style.right = "0px"; | ||
document.getElementsByTagName('body')[0].appendChild(notifyElem); | ||
}, | ||
notify: function (message) { | ||
if (notifyElem) { | ||
notifyElem.innerHTML = message; | ||
notifyElem.style.top = ghost.getScrollTop() + "px"; | ||
notifyElem.style.display = "block"; | ||
window.setTimeout(function () { | ||
notifyElem.style.display = "none"; | ||
}, 1000); | ||
} | ||
}, | ||
/** | ||
@@ -105,2 +138,4 @@ * @param {object} ghostMode | ||
browserSync.notify("Injected: " + data.assetFileName); | ||
var domData = this.getElems(data.fileExtension); | ||
@@ -520,2 +555,3 @@ var elem = this.getMatches(domData.elems, data.assetFileName, domData.attr); | ||
socket.on("scroll:update", function (data) { | ||
if (data.url === window.location.host + window.location.pathname) { | ||
@@ -522,0 +558,0 @@ scope.ghostMode.enabled = false; |
@@ -1,1 +0,1 @@ | ||
"use strict";!function(a,b){var c={ghostMode:{enabled:!0,cache:{}}},d={tagNames:{css:"link",jpg:"img",png:"img",svg:"img",gif:"img",js:"script"},attrs:{link:"href",img:"src",script:"src"}},e={processOptions:function(a,b,c,d){a.options=b,b.ghostMode&&this.initGhostMode(b.ghostMode,c,d)},initGhostMode:function(a,b,d){if(a.links&&g.initClickEvents(c,b,d.click),a.scroll&&g.initEvents(c,["scroll"],b,d),a.forms)for(var e=g.getInputs(),f=[[e.texts,"keyup","keyup"],[e.radios,"click","forceChange"],[e.radios,"change","radioChange"],[e.checkboxes,"click","forceChange"],[e.checkboxes,"change","checkboxChange"],["textarea","keyup","keyup"],["select","change","selectChange"],["form","submit","formSubmit"],["form","reset","formReset"]],h=0,i=f.length;i>h;h+=1)g.addBrowserEvents(f[h][0],f[h][1],d[f[h][2]],b)},reloadEvent:function(a,b,c){var d;if(b.url&&c.reloadBrowser(!0),b.assetFileName&&b.fileExtension){var e=this.getElems(b.fileExtension),f=this.getMatches(e.elems,b.assetFileName,e.attr);"undefined"!=typeof f&&(d=c.swapFile(f,e.attr))}return d},getElems:function(a){var b=this.getTagName(a),c=this.getAttr(b);return{elems:document.getElementsByTagName(b),attr:c}},getTagName:function(a){return d.tagNames[a]},getAttr:function(a){return d.attrs[a]},getMatches:function(a,b,c){for(var d,e=0,f=a.length;f>e;e+=1)-1!==a[e][c].indexOf(b)&&(d=e);return a[d]}},f={reloadBrowser:function(a){a&&location.reload()},swapFile:function(a,b){var c=a[b],d=/^[^\?]+(?=\?)/.exec(c);d&&(c=d[0]);var e=(new Date).getTime();return a[b]=c+"?rel="+e,{elem:a,timeStamp:e}}},g={getScroll:function(){if(void 0!==a.pageYOffset)return[a.pageXOffset,a.pageYOffset];var b,c,d=document,e=d.documentElement,f=d.body;return b=e.scrollLeft||f.scrollLeft||0,c=e.scrollTop||f.scrollTop||0,[b,c]},getScrollTop:function(){return this.getScroll()[1]},setScrollTop:function(b,c){b.enabled=!1,a.scrollTo(0,c)},checkCache:function(a,b){var c;return a[b]?a[b].elem:(a.called=a.called?a.called+=1:1,c=document.getElementById(b),c?(a[b]={},a[b].elem=c,c):!1)},initClickEvents:function(a,b,c){for(var d=document.getElementsByTagName("a"),e=0,f=d.length;f>e;e+=1)this.composeElementEvent(d[e],b,"click",c)},initEvents:function(a,b,c,d){for(var e="scroll",f=0,g=b.length;g>f;f+=1)b[f]===e&&this.composeSingleEvent(c,e,d[e])},composeSingleEvent:function(b,c,d){a[b.eventListener](b.prefix+c,d,!1)},composeElementEvent:function(a,b,c,d){a[b.eventListener](b.prefix+"click",d,!1)},emitEvent:function(a,c){b.emit(a,c)},addBrowserEvents:function(a,b,c,d){"string"==typeof a&&(a=document.getElementsByTagName(a));for(var e=0,f=a.length;f>e;e+=1)a[e][d.eventListener](d.prefix+b,c,!1)},getHref:function(a,b){var c,d=a.tagName;return c=b&&b.href?b.href:"A"===d?a.href:this.getParentHref(a,5)},getParentHref:function(a,b){for(var c,d=function(a){return"A"===a.parentNode.tagName?a.parentNode.href:a.parentNode},e=a,f=0;b>f;f+=1){if(c=d(e),"string"==typeof c)return c;e=c}return!1},getInputs:function(){for(var a=document.getElementsByTagName("input"),b=[],c=[],d=[],e=["text","email","url","tel"],f=0,g=a.length;g>f;f+=1){for(var h=a[f].type,i=0,j=e.length;j>i;i+=1)if(h===e[i]){b.push(a[f]);break}"radio"===a[f].type&&c.push(a[f]),"checkbox"===a[f].type&&d.push(a[f])}return{texts:b,radios:c,checkboxes:d}},listeners:{scroll:function(){var b,d=g.getScrollTop(),e=(new Date).getTime();c.ghostMode.lastScroll||(c.ghostMode.scrollTop=d[0],c.ghostMode.lastScroll=(new Date).getTime()),e>c.ghostMode.lastScroll+50&&c.ghostMode.enabled&&(c.ghostMode.lastScroll=e,b=a.location.host+a.location.pathname,g.emitEvent("scroll",{pos:d,url:b})),c.ghostMode.enabled=!0},click:function(a){var b={url:g.getHref(a.target||a.srcElement,this)};g.emitEvent("location",b)},keyup:function(a){var b=a.target||a.srcElement;b.id&&g.emitEvent("input:type",{id:b.id,value:b.value})},forceChange:function(){this.blur(),this.focus()},radioChange:function(a){var b=a.target||a.srcElement;g.emitEvent("input:radio",{id:b.id,value:b.value})},checkboxChange:function(a){var b=a.target||a.srcElement;g.emitEvent("input:checkbox",{id:b.id,checked:b.checked})},selectChange:function(a){var b=a.target||a.srcElement;g.emitEvent("input:select",{id:b.id,value:b.value})},formSubmit:function(a){var b=a.target||a.srcElement;g.emitEvent("form:submit",{id:b.id})},formReset:function(a){var b=a.target||a.srcElement;g.emitEvent("form:reset",{id:b.id})}},utils:{eventListener:a.addEventListener?"addEventListener":"attachEvent",removeEventListener:a.removeEventListener?"removeEventListener":"detachEvent",prefix:a.addEventListener?"":"on"}};a.__karma__&&(a.browserSync=e,a.browserSyncActions=f,a.ghost=g,a.scope=c,b.on=function(){}),b.on("connection",function(a){e.processOptions(c,a,g.utils,g.listeners)}),b.on("reload",function(a){a&&e.reloadEvent(c,a,f)}),b.on("location:update",function(b){b.url&&(a.location=b.url)}),b.on("scroll:update",function(b){b.url===a.location.host+a.location.pathname&&(c.ghostMode.enabled=!1,a.scrollTo(0,b.position))}),b.on("input:update",function(a){c.ghostMode.enabled=!1;var b=g.checkCache(c.ghostMode.cache,a.id);b.value=a.value}),b.on("input:update:radio",function(a){c.ghostMode.enabled=!1;var b=g.checkCache(c.ghostMode.cache,a.id);b.checked=!0}),b.on("input:update:checkbox",function(a){c.ghostMode.enabled=!1;var b=g.checkCache(c.ghostMode.cache,a.id);b.checked=a.checked}),b.on("form:submit",function(a){c.ghostMode.enabled=!1,document.forms[a.id].submit()}),b.on("form:reset",function(a){c.ghostMode.enabled=!1,document.forms[a.id].reset()})}(window,"undefined"==typeof ___socket___?{}:___socket___); | ||
"use strict";!function(a,b){var c,d={ghostMode:{enabled:!0,cache:{}}},e={tagNames:{css:"link",jpg:"img",png:"img",svg:"img",gif:"img",js:"script"},attrs:{link:"href",img:"src",script:"src"}},f={processOptions:function(a,b,c,d){a.options=b,b.ghostMode&&this.initGhostMode(b.ghostMode,c,d),b.notify&&this.createNotifyElem()},createNotifyElem:function(){c=document.createElement("DIV"),c.style.backgroundColor="black",c.style.color="white",c.style.padding="10px",c.style.display="none",c.style.fontFamily="sans-serif",c.style.position="absolute",c.style.zIndex="1000",c.style.right="0px",document.getElementsByTagName("body")[0].appendChild(c)},notify:function(b){c&&(c.innerHTML=b,c.style.top=h.getScrollTop()+"px",c.style.display="block",a.setTimeout(function(){c.style.display="none"},1e3))},initGhostMode:function(a,b,c){if(a.links&&h.initClickEvents(d,b,c.click),a.scroll&&h.initEvents(d,["scroll"],b,c),a.forms)for(var e=h.getInputs(),f=[[e.texts,"keyup","keyup"],[e.radios,"click","forceChange"],[e.radios,"change","radioChange"],[e.checkboxes,"click","forceChange"],[e.checkboxes,"change","checkboxChange"],["textarea","keyup","keyup"],["select","change","selectChange"],["form","submit","formSubmit"],["form","reset","formReset"]],g=0,i=f.length;i>g;g+=1)h.addBrowserEvents(f[g][0],f[g][1],c[f[g][2]],b)},reloadEvent:function(a,b,c){var d;if(b.url&&c.reloadBrowser(!0),b.assetFileName&&b.fileExtension){f.notify("Injected: "+b.assetFileName);var e=this.getElems(b.fileExtension),g=this.getMatches(e.elems,b.assetFileName,e.attr);"undefined"!=typeof g&&(d=c.swapFile(g,e.attr))}return d},getElems:function(a){var b=this.getTagName(a),c=this.getAttr(b);return{elems:document.getElementsByTagName(b),attr:c}},getTagName:function(a){return e.tagNames[a]},getAttr:function(a){return e.attrs[a]},getMatches:function(a,b,c){for(var d,e=0,f=a.length;f>e;e+=1)-1!==a[e][c].indexOf(b)&&(d=e);return a[d]}},g={reloadBrowser:function(a){a&&location.reload()},swapFile:function(a,b){var c=a[b],d=/^[^\?]+(?=\?)/.exec(c);d&&(c=d[0]);var e=(new Date).getTime();return a[b]=c+"?rel="+e,{elem:a,timeStamp:e}}},h={getScroll:function(){if(void 0!==a.pageYOffset)return[a.pageXOffset,a.pageYOffset];var b,c,d=document,e=d.documentElement,f=d.body;return b=e.scrollLeft||f.scrollLeft||0,c=e.scrollTop||f.scrollTop||0,[b,c]},getScrollTop:function(){return this.getScroll()[1]},setScrollTop:function(b,c){b.enabled=!1,a.scrollTo(0,c)},checkCache:function(a,b){var c;return a[b]?a[b].elem:(a.called=a.called?a.called+=1:1,c=document.getElementById(b),c?(a[b]={},a[b].elem=c,c):!1)},initClickEvents:function(a,b,c){for(var d=document.getElementsByTagName("a"),e=0,f=d.length;f>e;e+=1)this.composeElementEvent(d[e],b,"click",c)},initEvents:function(a,b,c,d){for(var e="scroll",f=0,g=b.length;g>f;f+=1)b[f]===e&&this.composeSingleEvent(c,e,d[e])},composeSingleEvent:function(b,c,d){a[b.eventListener](b.prefix+c,d,!1)},composeElementEvent:function(a,b,c,d){a[b.eventListener](b.prefix+"click",d,!1)},emitEvent:function(a,c){b.emit(a,c)},addBrowserEvents:function(a,b,c,d){"string"==typeof a&&(a=document.getElementsByTagName(a));for(var e=0,f=a.length;f>e;e+=1)a[e][d.eventListener](d.prefix+b,c,!1)},getHref:function(a,b){var c,d=a.tagName;return c=b&&b.href?b.href:"A"===d?a.href:this.getParentHref(a,5)},getParentHref:function(a,b){for(var c,d=function(a){return"A"===a.parentNode.tagName?a.parentNode.href:a.parentNode},e=a,f=0;b>f;f+=1){if(c=d(e),"string"==typeof c)return c;e=c}return!1},getInputs:function(){for(var a=document.getElementsByTagName("input"),b=[],c=[],d=[],e=["text","email","url","tel"],f=0,g=a.length;g>f;f+=1){for(var h=a[f].type,i=0,j=e.length;j>i;i+=1)if(h===e[i]){b.push(a[f]);break}"radio"===a[f].type&&c.push(a[f]),"checkbox"===a[f].type&&d.push(a[f])}return{texts:b,radios:c,checkboxes:d}},listeners:{scroll:function(){var b,c=h.getScrollTop(),e=(new Date).getTime();d.ghostMode.lastScroll||(d.ghostMode.scrollTop=c[0],d.ghostMode.lastScroll=(new Date).getTime()),e>d.ghostMode.lastScroll+50&&d.ghostMode.enabled&&(d.ghostMode.lastScroll=e,b=a.location.host+a.location.pathname,h.emitEvent("scroll",{pos:c,url:b})),d.ghostMode.enabled=!0},click:function(a){var b={url:h.getHref(a.target||a.srcElement,this)};h.emitEvent("location",b)},keyup:function(a){var b=a.target||a.srcElement;b.id&&h.emitEvent("input:type",{id:b.id,value:b.value})},forceChange:function(){this.blur(),this.focus()},radioChange:function(a){var b=a.target||a.srcElement;h.emitEvent("input:radio",{id:b.id,value:b.value})},checkboxChange:function(a){var b=a.target||a.srcElement;h.emitEvent("input:checkbox",{id:b.id,checked:b.checked})},selectChange:function(a){var b=a.target||a.srcElement;h.emitEvent("input:select",{id:b.id,value:b.value})},formSubmit:function(a){var b=a.target||a.srcElement;h.emitEvent("form:submit",{id:b.id})},formReset:function(a){var b=a.target||a.srcElement;h.emitEvent("form:reset",{id:b.id})}},utils:{eventListener:a.addEventListener?"addEventListener":"attachEvent",removeEventListener:a.removeEventListener?"removeEventListener":"detachEvent",prefix:a.addEventListener?"":"on"}};a.__karma__&&(a.browserSync=f,a.browserSyncActions=g,a.ghost=h,a.scope=d,b.on=function(){}),b.on("connection",function(a){f.processOptions(d,a,h.utils,h.listeners)}),b.on("reload",function(a){a&&f.reloadEvent(d,a,g)}),b.on("location:update",function(b){b.url&&(a.location=b.url)}),b.on("scroll:update",function(b){b.url===a.location.host+a.location.pathname&&(d.ghostMode.enabled=!1,a.scrollTo(0,b.position))}),b.on("input:update",function(a){d.ghostMode.enabled=!1;var b=h.checkCache(d.ghostMode.cache,a.id);b.value=a.value}),b.on("input:update:radio",function(a){d.ghostMode.enabled=!1;var b=h.checkCache(d.ghostMode.cache,a.id);b.checked=!0}),b.on("input:update:checkbox",function(a){d.ghostMode.enabled=!1;var b=h.checkCache(d.ghostMode.cache,a.id);b.checked=a.checked}),b.on("form:submit",function(a){d.ghostMode.enabled=!1,document.forms[a.id].submit()}),b.on("form:reset",function(a){d.ghostMode.enabled=!1,document.forms[a.id].reset()})}(window,"undefined"==typeof ___socket___?{}:___socket___); |
@@ -22,3 +22,4 @@ #! /usr/bin/env node | ||
server: false, | ||
open: true | ||
open: true, | ||
notify: true | ||
}; | ||
@@ -25,0 +26,0 @@ |
{ | ||
"name": "browser-sync", | ||
"description": "Live CSS Reload & Browser Syncing", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"homepage": "https://github.com/shakyshane/browser-sync", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -215,3 +215,13 @@ # browser-sync [![Build Status](https://travis-ci.org/shakyShane/browser-sync.png?branch=master)](https://travis-ci.org/shakyShane/browser-sync) | ||
``` | ||
###notify - (default: true) | ||
Browser-sync will flash a quick message in all connected browsers to confirm that CSS injection has taken place (useful when you're not sure whether the injection worked, or whether your CSS didn't make a difference) | ||
``` | ||
// Tell me when a CSS file was injected | ||
notify: true | ||
// Don't show any notifications in the browser. | ||
notify: false | ||
``` | ||
#Full config file example with Server | ||
@@ -233,3 +243,4 @@ Save this as `anything-you-like.js` | ||
}, | ||
open: false | ||
open: false, | ||
notify: true | ||
}; | ||
@@ -253,3 +264,4 @@ ``` | ||
}, | ||
open: false | ||
open: true, | ||
notify: true | ||
}; | ||
@@ -256,0 +268,0 @@ ``` |
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
852569
19701
314