Skip to content

Instantly share code, notes, and snippets.

@lsmith
Forked from apipkin/gist:380803
Created April 27, 2010 17:04
Show Gist options
  • Save lsmith/381000 to your computer and use it in GitHub Desktop.
Save lsmith/381000 to your computer and use it in GitHub Desktop.
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');
this._uiBindCallback( this.get('callback') );
this.after('callbackChange', this._afterCallbackChange);
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(){
},
_uiBindCallback : function(callback) {
if(this._clickHandle) {
this._clickHandle.detach();
}
if(callback) {
this._clickHandle = this.on('click',Y.bind(callback,this));
}
},
_afterCallbackChange : function(e) {
this._bindClick(e.newVal);
}
},{
ATTRS : {
label : {
value : null,
validator : Y.Lang.isString
},
callback : {
value: function () {},
validator : Y.Lang.isFunction
}
}
});
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