Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. <div class="container">
  2. <input type="text" class="main_activity" id="main_activity" name="main_activity" placeholder="Main activity">
  3. <div class="parentToDelegate">
  4. <a href="#" id="privacy" class="privacy" data-type="select" data-pk="1" data-value="1" data-original-title="Select visibility">public</a>
  5. <input type="text" id="privacy_result" class="privacy_result" value="1"/>
  6. </div>
  7.  
  8. <div class="row">
  9. <div id="InputsWrapper">
  10. </div>
  11. </div>
  12. <div class="row">
  13. <span id="AddMoreBox" class="btn btn-info pull-right"><i class="icon-plus"></i>Add More</span>
  14. </div>
  15.  
  16. //x-editable
  17. $('.privacy').editable({
  18. showbuttons: false,
  19. unsavedclass: null,
  20. type: 'select',
  21. inputclass: 'input-medium privacy-select',
  22. source: [
  23. {value: 1, text: 'public'},
  24. {value: 2, text: 'approved contacts only'},
  25. {value: 3, text: 'matching contacts'},
  26. {value: 4, text: 'invisible'}
  27. ],
  28.  
  29. });
  30.  
  31. $(function(){
  32. $('.parentToDelegate').on('change keyup blur', ".privacy-select", function(){
  33. $('.privacy_result').val($('.privacy-select').val());
  34. }).blur();
  35. });
  36.  
  37. //dynamic fields
  38. $(document).ready(function() {
  39.  
  40. var MaxInputs = 5; //maximum input boxes allowed
  41. var InputsWrapper = $("#InputsWrapper"); //Input boxes wrapper ID
  42. var AddButton = $("#AddMoreBox"); //Add button ID
  43.  
  44. var x = InputsWrapper.length; //initlal text box count
  45. var FieldCount=1; //to keep track of text box added
  46.  
  47. $(AddButton).click(function (e) //on add input button click
  48. {
  49. // if(x <= MaxInputs) //max input box allowed
  50. // {
  51. FieldCount++; //text box added increment
  52. //add input box
  53. $(InputsWrapper).append('
  54. <div>
  55. <input type="text" class="other_activity"
  56. name="other_activity" id="other_activity"
  57. placeholder="Other activity" style="margin:0px 15px 10px 0px"/>
  58. <a href="#" class="removeclass"><i class="icon-remove icon-remove-add"></i></a>
  59. <div class="parentToDelegate-dynamic'+ FieldCount +' parent-dynamic">
  60. <a href="#" id="privacy-dynamic" class="privacy-dynamic'+ FieldCount +'" data-type="select" data-pk="1" data-value="1" data-original-title="Select visibility">public</a>
  61. <input type="text" id="privacy-result-dynamic'+ FieldCount +'" name="privacy-result-dynamic'+ FieldCount +'" class="privacy-result-dynamic'+ FieldCount +' privacy_dynamic" value="1"/>
  62. </div>
  63. </div>');
  64. x++; //text box increment
  65. // }
  66. return false;
  67. });
  68.  
  69. $("body").on("click",".removeclass", function(e){ //user click on remove text
  70. if( x > 1 ) {
  71. $(this).parent('div').remove(); //remove text box
  72. x--; //decrement textbox
  73. }
  74.  
  75. $('.income_count').trigger('change');
  76. return false;
  77. });
  78.  
  79. });
  80.  
  81. .container{
  82. padding-top:100px
  83. }
  84.  
  85. .privacy_result, .privacy_dynamic{
  86. width: 40px;
  87. }
  88.  
  89. .main_activity, .other_activity{
  90. width: 140px;
  91. }
  92.  
  93. .parentToDelegate{
  94. display:inline;
  95. }
  96.  
  97. .icon-remove-add{
  98. margin-left: -10px;
  99. margin-top: -8px;
  100. }
  101.  
  102. .parent-dynamic{
  103. display: inline;
  104. top: -5px;
  105. left: 10px;
  106. position: relative;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement