Permalink
Browse files

gallery-2009.11.02-20 davglass gallery-port

  • Loading branch information...
1 parent 76b1077 commit 105468d0ac24948d3bdb9b0c3a68896cb2e7de58 YUI Builder committed Nov 2, 2009
Showing with 192 additions and 0 deletions.
  1. +21 −0 src/gallery-port/build.properties
  2. +7 −0 src/gallery-port/build.xml
  3. +164 −0 src/gallery-port/js/port.js
@@ -0,0 +1,21 @@
+# Port Base Build Properties
+
+# As long as the 'builder' project is cloned to the default folder
+# next to the 'yui3-gallery' project folder, the 'builddir' property does not
+# need to be changed
+#
+# If the 'builder' project is checked out to an alternate location, this
+# property should be updated to point to the checkout location.
+builddir=../../../builder/componentbuild
+
+# The name of the component. E.g. event, attribute, widget
+component=gallery-port
+
+# The list of files which should be concatenated to create the component.
+# NOTE: For a css component (e.g. cssfonts, cssgrids etc.) use component.cssfiles instead.
+# component.jsfiles=port.js, portHelperClass.js, portSubComponentClass.js
+component.jsfiles=port.js
+
+# The list of modules this component requires. Used to set up the Y.add module call for YUI 3.
+component.requires=base,node
+
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- YUI 3 Gallery Component Build File -->
+<project name="Port Base" default="local">
+ <description>Port Base Build File</description>
+ <property file="build.properties" />
+ <import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" />
+</project>
View
@@ -0,0 +1,164 @@
+ var YAHOO = {
+ lang: Y.Lang,
+ extend: Y.extend,
+ util: {
+ Dom: Y.DOM,
+ Event: {
+ on: Y.Event.nativeAdd,
+ getTarget: function(ev) {
+ return ev.target;
+ },
+ stopEvent: function(ev) {
+ ev.halt();
+ },
+ stopPropagation: function(ev) {
+ ev.stopPropagation();
+ },
+ preventDefault: function(ev) {
+ ev.preventDefault();
+ }
+ },
+ Element: Y.Base
+ },
+ getAttributes: function() {
+ }
+ },
+ Port, PortBase;
+ // HACK
+ // So the build system doesn't remove this line..
+ YAHOO['log'] = Y['log'];
+
+ YAHOO.util.Dom.get = function(id) {
+ if (Y.Lang.isString(id)) {
+ id = '#' + id;
+ }
+ return Y.get(id);
+ };
+ YAHOO.util.Dom.getChildren = function(el) {
+ return Y.Selector.query('> *', el);
+ };
+
+ Port = function(args) {
+ return YAHOO;
+ };
+
+ Y.Port = Port;
+
+ PortBase = function(attrs) {
+ this._lazyAddAttrs = false;
+ this._portAttrs = attrs;
+ PortBase.superclass.constructor.apply(this, arguments);
+ };
+
+ PortBase.NAME = 'PortBase';
+
+ PortBase.ATTRS = {
+ node: {
+ setter: function(node) {
+ var n = Y.get(node);
+ return n.item(0);
+ }
+ },
+ element: {
+ getter: function() {
+ return this.get('node');
+ },
+ setter: function(n) {
+ this.set('node', n);
+ return this.get('node');
+ }
+ }
+ };
+
+ Y.extend(PortBase, Y.Base, {
+ DOM_EVENTS: {
+ 'click': true,
+ 'dblclick': true,
+ 'keydown': true,
+ 'keypress': true,
+ 'keyup': true,
+ 'mousedown': true,
+ 'mousemove': true,
+ 'mouseout': true,
+ 'mouseover': true,
+ 'mouseup': true,
+ 'focus': true,
+ 'blur': true,
+ 'submit': true,
+ 'change': true
+ },
+ initializer: function() {
+ this.initAttributes(this._portAttrs);
+ },
+ initAttributes: function() {
+ },
+ setAttributeConfig: function(name, config) {
+ if (config.method) {
+ config.setter = config.method;
+ delete config.method;
+ }
+ this.addAttr(name, config);
+ },
+ addListener: function(name, fn, ctxt, args) {
+ if (ctxt) {
+ if (args) {
+ fn = Y.rbind(fn, args, ctxt);
+ } else {
+ fn = Y.bind(fn, ctxt);
+ }
+ }
+ if (this.DOM_EVENTS[name]) {
+ this.get('node').on(name, fn);
+ } else {
+ this.on(name, fn);
+ }
+ //console.log('addListener: ', arguments);
+ },
+ getElementsByClassName: function(className, tagName) {
+ var sel = tagName + ' .' + className;
+ //console.log('getElementsByClassName', this.constructor.NAME, arguments, sel);
+ return this.get('node').query(sel) || [];
+ },
+ getElementsByTagName: function(tagName) {
+ var n = this.get('node');
+ return ((n) ? n.query(tagName) : []);
+ },
+ addClass: function(className) {
+ var n = this.get('node');
+ if (!n) { return false; }
+ return n.addClass(className);
+ },
+ removeClass: function(className) {
+ var n = this.get('node');
+ if (!n) { return false; }
+ return n.removeClass(className);
+ },
+ hasClass: function(className) {
+ var n = this.get('node');
+ if (!n) { return false; }
+ return n.hasClass(className);
+ },
+ appendTo: function(el) {
+ Y.get(el).appendChild(this.get('node'));
+ },
+ fireEvent: function(type, args) {
+ if (args.target) {
+ delete args.target;
+ }
+ if (args.ev) {
+ args.ev = new Y.DOMEventFacade(args.ev);
+ }
+ var ret = false, e;
+ this.publish(type, {
+ defaultFn: function() {
+ ret = true;
+ }
+ });
+ e = this.fire(type, args);
+ Y.log('fireEvent: ' + type);
+ return ret;
+ }
+ });
+
+ Y.PortBase = PortBase;
+

0 comments on commit 105468d

Please sign in to comment.