A tumblelog CMS built on AJAX, PHP and MySQL.

template_add_photo.htm 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <div id="photo_upload">
  2. <label for="description">Photo</label>
  3. <br /><input type="file" name="photo" id="photo" accept="image/gif,image/jpeg,image/jpg,image/png"/>
  4. <div style="font-size:11px; color:#666; margin-top:5px;">
  5. Supports JPEG, GIF and PNG.&nbsp; <strong>Max size is 10 MB.</strong>
  6. </div>
  7. <div style="font-size:11px; color:#666; margin-top:5px;">
  8. <a href="#" class="linkFrm">Use a URL instead</a>
  9. </div>
  10. </div>
  11. <div id="photo_url">
  12. <label for="description">Photo URL</label>
  13. <br /><input class="input-text" type="text" name="url" id="url" value="{editUrl}" style="width:400px"/>
  14. <div style="font-size:11px; color:#666; margin-top:5px;">
  15. <a href="#" class="linkFrm">Use a upload form instead</a>
  16. </div>
  17. </div>
  18. <div>
  19. <label for="description" style="display:block;">Caption <span class="option">(optional)</span></label>
  20. <textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
  21. </div>
  22. <input type="hidden" name="title" id="title" value="" />
  23. <input type="hidden" name="MAX_FILE_SIZE" value="10485760" />
  24. <input type="hidden" name="type" id="type" value="{type}" />
  25. <input type="hidden" name="date" id="date" value="{date}" />
  26. <input type="hidden" name="id_user" id="id_user" value="{id_user}" />
  27. <script>
  28. $('#photo_url').css('display','none');
  29. $("#autosave").validate({
  30. rules: {
  31. photo: {
  32. required: function() {
  33. return ($('#photo_upload').css('display')!= 'none') ? true : false;
  34. },
  35. accept: "(jpe?g|gif|png)"
  36. },
  37. url: {
  38. required: function() {
  39. return ($('#photo_url').css('display')!= 'none') ? true : false;
  40. },
  41. url: true
  42. }
  43. },
  44. errorElement: "span",
  45. errorClass: "validate_span",
  46. errorPlacement: function(label, element) {
  47. label.prependTo(element.prev())
  48. }
  49. });
  50. $("#photo_upload a.linkFrm").click( function() {
  51. $('#photo_upload').css('display','none');
  52. $('#photo_url').css('display','block');
  53. $('#photo').val('');
  54. return false;
  55. }
  56. );
  57. $("#photo_url a.linkFrm").click( function() {
  58. $('#photo_url').css('display','none');
  59. $('#photo_upload').css('display','block');
  60. $('#url').val('');
  61. return false;
  62. }
  63. );
  64. </script>