Last active
January 4, 2016 12:29
-
-
Save wasbazi/8622044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// env.js | |
_documentSetter: function(document){ | |
this.document = document; | |
// if this is a document model it will have the watch function, | |
// if not it will throw an error and everything dies, but I doubt | |
// a non doc-model will be passed | |
if (this._constrainedProductsWatch) { | |
this._constrainedProductsWatch.remove(); | |
} | |
this._constrainedProductsWatch = this.document.watch('constrainedProducts', lang.hitch(this, function(name, oldValue, newValue){ | |
if (newValue.length) { | |
topic.publish('showCQM'); | |
} | |
})); | |
} | |
/// builder.js | |
topic.subscribe('constrainedProducts', lang.hitch(this, function(){ | |
if (this._constrainedProductsTimeout) { | |
clearTimeout(this._constrainedProductsTimeout); | |
} | |
this._constrainedProductsTimeout = setTimeout(lang.hitch(this, function(){ | |
this._constrainedProductsTimeout = null; | |
this.CQM.show(); | |
}), 300); | |
})); | |
/// models/document/PageItem.js | |
_atsInfoSetter: function(atsInfo){ | |
this.atsInfo = atsInfo; | |
if (atsInfo.availableQuantity < this.quantity) { | |
// something like this | |
topic.publish('tooMuchQty', this.stockItem); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment