TopReminder.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * EnterpriseSheet
  3. * Copyright (c) FeyaSoft Inc 2014. All right reserved.
  4. * http://www.enterpriseSheet.com
  5. *
  6. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  7. * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  8. * WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE
  9. * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  10. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  12. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  13. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  14. */
  15. Ext.define('Ext.ux.TopReminder', {
  16. singleton: true,
  17. createBox : function(t, s){
  18. return '<div class="top-reminder">'+
  19. (t ? '<h3>' + t + '</h3>' : '')+
  20. '<p>' + s + '</p></div>';
  21. },
  22. showMsg : function(title, msg, stayTime){
  23. if(!this.msgCt){
  24. this.msgCt = Ext.DomHelper.insertFirst(document.body, {id:'top-reminder'}, true);
  25. }
  26. var m = Ext.DomHelper.append(this.msgCt, this.createBox(title, msg), true);
  27. m.hide();
  28. stayTime = stayTime || 4000;
  29. m.slideIn('t').ghost("t", { delay: stayTime, remove: true});
  30. },
  31. init : function(){
  32. if(!this.msgCt){
  33. // It's better to create the msg-div here in order to avoid re-layouts
  34. // later that could interfere with the HtmlEditor and reset its iFrame.
  35. this.msgCt = Ext.DomHelper.insertFirst(document.body, {id:'top-reminder'}, true);
  36. }
  37. }
  38. }, function(){
  39. TOPMINDER = Ext.ux.TopReminder;
  40. Ext.onReady(TOPMINDER.init, TOPMINDER);
  41. });