[ Index ]

PHP Cross Reference of MyBB 1.8.37

title

Body

[close]

/admin/jscripts/ -> theme_properties.js (source)

   1  /**
   2   * functions for stylesheet file/color attachments
   3   */
   4  
   5  var themeProperties = (function() {
   6      /**
   7       * @var number the total attached files for this stylesheet
   8       */
   9      var attachedCount = 0;
  10  
  11      /**
  12       * attach event handlers
  13       *
  14       * @return void
  15       */
  16  	function init() {
  17          for (var i = 0; i < attachedCount; ++i) {
  18              $("#delete_img_" + i).on('click', removeAttachmentBox);
  19          }
  20          $("#new_specific_file").on('click', addAttachmentBox);
  21      }
  22  
  23      /**
  24       * allow external setup
  25       *
  26       * @param  string the count at load time
  27       * @return void
  28       */
  29  	function setup(count) {
  30          attachedCount = count || 0;
  31      }
  32  
  33      /**
  34       * create a new blank attachment box
  35       *
  36       * @param  object the event
  37       * @return void
  38       */
  39  	function addAttachmentBox(e) {
  40          e.preventDefault();
  41  
  42          var next_count = Number(attachedCount) + 1,
  43          contents = "<div id=\"attached_form_" + attachedCount + "\"><div class=\"border_wrapper\">\n<table class=\"general form_container \" cellspacing=\"0\">\n<tbody>\n<tr class=\"first\">\n<td class=\"first\"><div class=\"form_row\"><span style=\"float: right;\"><a href=\"\" id=\"delete_img_" + attachedCount + "\"><img src=\"styles/default/images/icons/cross.png\" alt=\"" + delete_lang_string + "\" title=\"" + delete_lang_string + "\" /></a></span>" + file_lang_string + " &nbsp;<input type=\"text\" name=\"attached_" + attachedCount + "\" value=\"\" class=\"text_input\" style=\"width: 200px;\" id=\"attached_" + attachedCount + "\" /></div>\n</td>\n</tr>\n<tr class=\"last alt_row\">\n<td class=\"first\"><div class=\"form_row\"><dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">\n<dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_" + attachedCount + "\" value=\"0\" checked=\"checked\" class=\"action_" + attachedCount + "s_check\" onclick=\"checkAction('action_" + attachedCount + "');\" style=\"vertical-align: middle;\" /> " + globally_lang_string + "</label></dt>\n<dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_" + attachedCount + "\" value=\"1\"  class=\"action_" + attachedCount + "s_check\" onclick=\"checkAction('action_" + attachedCount + "');\" style=\"vertical-align: middle;\" /> " + specific_actions_lang_string + "</label></dt>\n<dd style=\"margin-top: 4px;\" id=\"action_" + attachedCount + "_1\" class=\"action_" + attachedCount + "s\">\n<small class=\"description\">" + specific_actions_desc_lang_string + "</small>\n<table cellpadding=\"4\">\n<tr>\n<td><input type=\"text\" name=\"action_list_" + attachedCount + "\" value=\"\" class=\"text_input\" style=\"width: 190px;\" id=\"action_list_" + attachedCount + "\" /></td>\n</tr>\n</table>\n</dd>\n</dl></div>\n</td>\n</tr>\n</tbody>\n</table>\n</div></div><div id=\"attach_box_" + next_count + "\"></div>\n";
  44  
  45          // if this is the first attachment, create the first
  46          if (!$("#attach_box_" + attachedCount).attr('id')) {
  47              $("#attach_1").html(contents).show();
  48          } else {
  49              $("#attach_box_" + attachedCount).html(contents).show();
  50          }
  51  
  52          checkAction('action_' + attachedCount);
  53  
  54          if ($("#attached_form_" + attachedCount)) {
  55              $("#delete_img_" + attachedCount).on('click', removeAttachmentBox);
  56          }
  57          ++attachedCount;
  58      }
  59  
  60      /**
  61       * remove an entire attachment box
  62       *
  63       * @param  object the event
  64       * @return void
  65       */
  66  	function removeAttachmentBox(e) {
  67          var idArray, id;
  68  
  69          idArray = e.currentTarget.id.split('_');
  70          if (!idArray.length) {
  71              return;
  72          }
  73          id = idArray[idArray.length - 1];
  74          e.preventDefault();
  75  
  76          if (confirm(delete_confirm_lang_string) == true) {
  77              $("#attached_form_" + id).remove();
  78          }
  79      }
  80  
  81      $(init);
  82  
  83      // the only public method
  84      return {
  85          setup: setup,
  86      };
  87  })();


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref