YUI.add('tag-reconcile', function(Y) { var Lang = Y.Lang, Widget = Y.Widget, Node = Y.Node; var NS = Y.namespace('mazzle'); NS.TagReconcile = TagReconcile; /* TagReconcile class constructor */ function TagReconcile(config) { TagReconcile.superclass.constructor.apply(this, arguments); } /* * Required NAME static field, to identify the Widget class and * used as an event prefix, to generate class names etc. (set to the * class name in camel case). */ TagReconcile.NAME = "tag-reconcile"; /* * The attribute configuration for the TagReconcile widget. Attributes can be * defined with default values, get/set functions and validator functions * as with any other class extending Base. */ TagReconcile.ATTRS = { sources: { value: {} }, tags: { value: [] }, tagsPerRequest: { value:5 }, limit: { value:3 } }; /* TagReconcile extends the base Widget class */ Y.extend(TagReconcile, Widget, { initializer: function() { this.reconciled = {}; }, destructor : function() { }, renderUI : function() { var sources = this.get("sources"), content = this.get("contentBox"); content.append('select a source: '); var sourceSelect = content.appendChild(''); for (var key in sources) { sourceSelect.append(''); } this.button = content.appendChild(''); this.status = content.appendChild(''); this.sourceSelect = sourceSelect; }, bindUI : function() { var select = this.sourceSelect, sources = this.get("sources"); this.button.on("click", function(e) { this.reconciled = {}; var index = select.get("selectedIndex"), source = sources[select.get("options").item(index).get("value")], url = source.url + "?callback={callback}" + source.parameters; Y.log('reconcile against '+source.label); this.fire("reconcileStart", {"source":source}); this.reconcile(url, 0); }, this); }, syncUI : function() { }, /* @TBD add handler to cancel the request */ reconcile : function(url, index) { var oSelf = this, tags = this.get("tags"), n = this.get("tagsPerRequest"), limit = this.get("limit"), start = index, last = Math.min(index+n,tags.length), queries = {}; //build the query object for(index;index