title.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Created by Administrator on 2017/11/6.
  3. * 标题功能类
  4. */
  5. define([''], function () {
  6. var title = {
  7. addTitle: function (id) { //根据功能添加对应ID的标题标签
  8. var height = 72;
  9. var height2 = $('.meteo-title-box').height();
  10. if(height2 == 0){
  11. }else{
  12. height = height + height2/2;
  13. }
  14. var content = "<li id='meteo-title-" + id + "'></li>";
  15. $('#meteo-title-box').append(content);
  16. $('.meteo-title-box').css('top', height);
  17. $('.meteo-title-box').show();
  18. $('#meteo-title-' + id).hide();
  19. },
  20. removeTitle: function (id) { //根据功能寻找对应ID删除标签
  21. var height = 72;
  22. var height1 = $('#meteo-title-' + id).height();
  23. $('#meteo-title-' + id).remove();
  24. var height2 = $('.meteo-title-box').height();
  25. height = height + height2/2 - height1/2;
  26. $('.meteo-title-box').css('top', height);
  27. if ($('#meteo-title-box').children().length == 0)
  28. $('.meteo-title-box').hide();
  29. },
  30. updateTitle: function (id, title) {
  31. $('#meteo-title-' + id).html(title);
  32. $('#meteo-title-' + id).show();
  33. },
  34. init: function () { //初始化,准备标题存放的div
  35. var content = "<div class='meteo-title-box'>" +
  36. "<iframe frameborder='0' class='cover-iframe'></iframe>" +
  37. "<ul id='meteo-title-box' style='width: 285px;'></ul></div>";
  38. $('#standardTime').append(content);
  39. }
  40. }
  41. title.init();
  42. return title;
  43. })