toloframework
Version:
Javascript/HTML/CSS compiler for Firefox OS or nodewebkit apps using modules in the nodejs style.
2 lines • 3.46 kB
JavaScript
require("wdg.button",function(t,e,i){function n(t,e){return void 0===e&&(e={}),new c(r.extend(t,e))}function s(t){if(this.element.className="wdg-button",this.visible||a.addClass(this,"hide"),this.flat)switch(a.addClass(this,"flat"),this.type){case"primary":case"undef":a.addClass(this,"thm-fgP");break;case"secondary":a.addClass(this,"thm-fgS")}else switch(a.addClass(this,"thm-ele2"),this.type){case"primary":a.addClass(this,"thm-bgP");break;case"secondary":a.addClass(this,"thm-bgS");break;default:a.addClass(this,"thm-bg3")}(this.text||"").trim().length>0?(t.text.textContent=this.text,a.removeClass(this,"no-text")):a.addClass(this,"no-text"),this.wait?(t.icon.visible=!0,t.icon.content="wait",t.icon.rotate=!0):!this.icon||"string"==typeof this.icon&&0===this.icon.trim().length?(t.icon.visible=!1,a.removeClass(this,"responsive")):(t.icon.visible=!0,t.icon.content=this.icon,t.icon.rotate=this.anim,this.responsive&&a.addClass(this,"responsive")),this.enabled&&!this.wait||a.addClass(this,"disabled"),this.wide&&a.addClass(this,"wide"),this.inverted||a.addClass(this,"iconToLeft")}var o=function(){function e(){return n(i,arguments)}var i={en:{cancel:"Cancel",close:"Close",delete:"Delete",edit:"Edit",gotit:"Got it",no:"No",ok:"OK",save:"Save",yes:"Yes"},fr:{cancel:"Annuler",close:"Fermer",delete:"Supprimer",edit:"Editer",gotit:"J'ai compris",no:"Non",ok:"Valider",save:"Sauver",yes:"Oui"}},n=t("$").intl;return e.all=i,e}();t("font.roboto");var a=t("dom"),r=t("tfw.data-binding"),l=t("wdg.icon"),d=t("tfw.touchable"),h=["undef","default","standard","primary","secondary"],c=function(t){var e=this,i=new l({size:"24px"}),n=a.div("text"),o=a.elem(this,"button","wdg-button",[i,n]),c=s.bind(this,{icon:i,text:n});r.prop(this,"value"),r.propEnum(h)(this,"type"),r.prop(this,"icon"),r.propBoolean(this,"responsive"),r.propBoolean(this,"anim"),r.propBoolean(this,"wait"),r.propString(this,"text");var p=new d(o,{classToAdd:"thm-ele8"});r.propBoolean(this,"enabled")(function(t){p.enabled=t,c()}),r.propBoolean(this,"inverted"),r.propBoolean(this,"flat"),r.prop(this,"action",0),r.propBoolean(this,"wide"),r.propBoolean(this,"visible"),t=r.extend({inverted:!1,type:"undef",text:"",href:null,target:null,value:"action",action:0,responsive:!1,anim:!1,flat:!1,small:!1,enabled:!0,wait:!1,icon:null,wide:!1,visible:!0},t,this,c),a.on(this.element,{keydown:function(t){13!=t.keyCode&&32!=t.keyCode||(t.preventDefault(),t.stopPropagation(),e.fire())}}),p.tap.add(e.fire.bind(e))};c.prototype.on=function(t){return r.bind(this,"action",t),this},c.prototype.fire=function(){if(this.enabled){var t=this.href;"string"!=typeof t||0===t.trim().length?r.fire(this,"action",this.value):"string"==typeof this.target&&this.target.trim().length>0?window.open(t,this.target):window.location=t}},c.Cancel=function(t){return n({text:o("cancel"),flat:!0},t)},c.Close=function(t){return n({text:o("close"),flat:!0},t)},c.GotIt=function(t){return n({text:o("gotit"),flat:!0},t)},c.Delete=function(t){return n({text:o("delete"),type:"secondary",icon:"delete"},t)},c.No=function(t){return n({text:o("no"),flat:!0},t)},c.Ok=function(t){return n({text:o("ok"),flat:!0},t)},c.Edit=function(t){return n({text:o("edit"),type:"primary",icon:"edit"},t)},c.Save=function(t){return n({text:o("save"),type:"primary",icon:"save"},t)},c.Yes=function(t){return n({text:o("yes"),flat:!0},t)},c.default={caption:"OK",type:null},e.exports=c,e.exports._=o});
//# sourceMappingURL=wdg.button.js.map