Created
April 27, 2010 14:49
-
-
Save apipkin/380803 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Button = Y.Base.create('toolbar-button',Y.Widget,[Y.WidgetChild],{ | |
BOUNDING_TEMPLATE : '<li/>', | |
CONTENT_TEMPLATE : '<button/>', | |
_clickHandle : null, | |
className : '', | |
initializer : function(config) { | |
this.className = this.getClassName(); | |
}, | |
renderUI : function(){ | |
var cb = this.get('contentBox'); | |
cb.set('text',this.get('label')); | |
}, | |
bindUI : function(){ | |
var cb = this.get('contentBox'), | |
callback = this.get('callback'); | |
this._bindClick(); | |
this.after('callbackChange',Y.bind(this._callbackChange,this)); | |
cb.on('mouseenter', Y.bind(function(e){ cb.addClass(this.className + '-hover'); }, this)); | |
cb.on('mouseleave', Y.bind(function(e){ cb.removeClass(this.className + '-hover'); }, this)); | |
}, | |
syncUI : function(){ | |
}, | |
_bindClick : function() { | |
var callback = this.get('callback'); | |
if(this._clickHandle) { | |
this._clickHandle.detach(); | |
} | |
if(callback) { | |
this._clickHandle = this.on('click',Y.bind(callback,this)); | |
} | |
}, | |
_callbackChange : function(e) { | |
this._bindClick(); | |
} | |
},{ | |
ATTRS : { | |
label : { | |
value : null, | |
validator : Y.Lang.isString | |
}, | |
callback : { | |
validator : Y.Lang.isFunction | |
} | |
} | |
}); |
This file contains hidden or 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
YUI.add('file-manager',function(Y){ | |
var File, | |
NAME = 'fileManager', | |
NS = 'files' | |
; | |
File = function(config) { | |
File.superclass.constructor.apply(this,arguments); | |
}; | |
Y.extend(File, Y.Plugin.Base, { | |
initializer : function() { | |
this.bindUI(); | |
}, | |
bindUI : function() { | |
var buttons = this.get('host').toolbar.get('buttons'); | |
if(buttons.save) { | |
var btn = buttons.save; | |
btn.set('callback',Y.bind(function(e){ | |
e.preventDefault(); | |
Y.log('UPLOAD!!'); | |
},btn)); | |
} | |
} | |
},{ | |
NAME : NAME, | |
NS : NS, | |
ATTRS : {} | |
}); | |
Y.FileManager = File; | |
},'0.1',{requires:['plugin']}); | |
YUI({ | |
modules: { | |
'file-manager' : { | |
fullpath : '/lib/cms/js/components/file-manager.js', | |
requires : ['plugin'] | |
} | |
} | |
}).use('file-manager',function(Y){ | |
CMS.plug(Y.FileManager); | |
CMS.addPlugin('files'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment