r2394 - Widget factory: Fixed $4266 - Add custom selectors for widgets.

r2394 - Widget factory: Fixed $4266 - Add custom selectors for widgets.


Author: scott.gonzalez
Date: Fri Mar 27 17:52:56 2009
New Revision: 2394
Modified:
trunk/ui/ui.core.js
Log:
Widget factory: Fixed $4266 - Add custom selectors for widgets.
Modified: trunk/ui/ui.core.js
==============================================================================
--- trunk/ui/ui.core.js    (original)
+++ trunk/ui/ui.core.js    Fri Mar 27 17:52:56 2009
@@ -217,9 +217,16 @@
}
$.widget = function(name, prototype) {
-    var namespace = name.split(".")[0];
+    var namespace = name.split(".")[0],
+        fullName;
    name = name.split(".")[1];
+    fullName = namespace + '-' + name;
+    // create selector for plugin
+    $.expr[':'][fullName] = function(elem) {
+        return !!$.data(elem, name);
+    };
+    
    // create plugin method
    $.fn[name] = function(options) {
        var isMethodCall = (typeof options == 'string'),
@@ -259,7 +266,7 @@
        this.namespace = namespace;
        this.widgetName = name;
        this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
-        this.widgetBaseClass = namespace + '-' + name;
+        this.widgetBaseClass = fullName;
        this.options = $.extend(true, {},
            $.widget.defaults,