toloframework
Version:
Javascript/HTML/CSS compiler for Firefox OS or nodewebkit apps using modules in the nodejs style.
2 lines • 3.35 kB
JavaScript
require("wdg.modal",function(t,e,o){function n(t){var e=this,o=a.div();o.addEventListener("scroll",i.bind(this,o));var n=function(){window.setTimeout(function(){i(o)})},r=a.tag("header","thm-ele8","thm-bgPD"),c=a.tag("footer"),d=a.div("cell","thm-ele24","thm-bg0",[r,o,c]);a.elem(this,"div","wdg-modal",[a.div([d])]);s.prop(this,"content")(function(t){a.clear(o),Array.isArray(t)?t.forEach(function(t){a.add(o,t)}):void 0!==t&&null!==t&&a.add(o,t),n()}),s.prop(this,"header")(function(t){a.clear(r),Array.isArray(t)?t.forEach(function(t){a.add(r,t)}):void 0!==t&&null!==t&&a.add(r,t),n()}),s.prop(this,"footer")(function(t){if(void 0===t||null===t||0===t.length)return void a.addClass(c,"hide");a.removeClass(c,"hide"),a.clear(c),Array.isArray(t)?t.forEach(function(t){a.add(c,t)}):a.add(c,t),n()}),s.propString(this,"width")(function(t){a.css(o,{"max-width":t}),n()}),s.propAddClass(this,"fullscreen"),s.propAddClass(this,"padding"),s.propAddClass(this,"scroll"),s.propAddClass(this,"wide"),s.propBoolean(this,"visible")(function(t){t?e.attach():e.detach()}),t=s.extend({visible:!1,header:[],content:[],footer:[],padding:!0,scroll:!0,wide:!1,fullscreen:!1,width:"auto"},t,this)}function i(t,e){t.scrollTop>0?a.addClass(t,"top"):a.removeClass(t,"top"),t.scrollHeight-t.scrollTop>t.clientHeight?a.addClass(t,"bottom"):a.removeClass(t,"bottom")}var r=function(){function e(){return n(o,arguments)}var o={en:{cancel:"Cancel",close:"Got it",confirm:"Confirm",ok:"Accept"},fr:{cancel:"Annuler",close:"J'ai compris",confirm:"Confirmation",ok:"Accepter"}},n=t("$").intl;return e.all=o,e}(),a=t("dom"),s=t("tfw.data-binding"),c=(t("wdg.flex"),t("wdg.button"));n.prototype.refresh=function(){return s.fire(this,"content"),this},n.prototype.attach=function(){var t=this;this._timeoutDetach&&(window.clearTimeout(this._timeoutDetach),delete this._timeoutDetach),document.body.appendChild(this.element),s.set(this,"visible",!0),a.addClass(this,"fadeout"),window.setTimeout(function(){a.removeClass(t,"fadeout")})},n.prototype.detach=function(){var t=this;window.setTimeout(function(){a.addClass(t,"fadeout")}),this._timeoutDetach=window.setTimeout(function(){delete this._timeoutDetach,s.set(t,"visible",!1),a.detach(t.element)},250)},n.confirm=function(t,e,o){"function"==typeof e&&(t={content:t,onYes:e,onNo:o}),void 0===t.title&&(t.title=r("confirm")),void 0===t.yes&&(t.yes=r("ok")),void 0===t.no&&(t.no=r("cancel")),void 0===t.onYes&&(t.onYes=function(){}),void 0===t.onNo&&(t.onNo=function(){}),e=t.onYes,o=t.onNo;var i=new c({text:t.yes,flat:!0}),s=new c({text:t.no,flat:!0});if(Array.isArray(t.content)&&(t.content=a.div(t.content)),"string"==typeof t.content&&"<html>"==t.content.substr(0,6)){var d=t.content.substr(6);t.content=a.div(),t.content.innerHTML=d}var l=new n({header:t.title,footer:[s,i],content:t.content});return l.attach(),s.on(function(){l.detach(),"function"==typeof o&&o()}),i.on(function(){if("function"==typeof e){var t=e();"string"!=typeof t?l.detach():(s.visible=!1,i.waitOn(t))}else l.detach()}),l},n.alert=function(t,e){var o=new c({text:r("close"),flat:!0});if("string"==typeof t&&"<html>"==t.substr(0,6)){var i=t.substr(6);t=a.div(),t.innerHTML=i}var s=new n({footer:o,content:t});return s.attach(),o.on(function(){s.detach(),"function"==typeof e&&e()}),s},e.exports=n,e.exports._=r});
//# sourceMappingURL=wdg.modal.js.map