checkStates: function()

in jspwiki-war/src/main/scripts/wiki-wysiwyg/Source/MooEditable/MooEditable.js [687:741]


	checkStates: function(){
		var element = this.selection.getNode();
		if (!element) return;
		if (typeOf(element) != 'element') return;

		this.actions.each(function(action){
			var item = this.toolbar.getItem(action);
			if (!item) return;
			item.deactivate();

			var states = MooEditable.Actions[action]['states'];
			if (!states) return;

			// custom checkState
			if (typeOf(states) == 'function'){
				states.attempt([document.id(element), item], this);
				return;
			}

			try{
				if (this.doc.queryCommandState(action)){
					item.activate();
					return;
				}
			} catch(e){}

			if (states.tags){
				var el = element;
				do {
					var tag = el.tagName.toLowerCase();
					if (states.tags.contains(tag)){
						item.activate(tag);
						break;
					}
				}
				while ((el = Element.getParent(el)) != null);
			}

			if (states.css){
				var el = element;
				do {
					var found = false;
					for (var prop in states.css){
						var css = states.css[prop];
						if (el.style[prop.camelCase()].contains(css)){
							item.activate(css);
							found = true;
						}
					}
					if (found || el.tagName.test(blockEls)) break;
				}
				while ((el = Element.getParent(el)) != null);
			}
		}.bind(this));
	},