inline-editable.html 6.83 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
<section>
	<h1 class="blue" data-id="#custom/inline-editable"><i class="ace-icon fa fa-desktop grey"></i> Inline Editable Addons</h1>

	<div class="hr hr-double hr32"></div>


	<!-- #section:custom/inline-editable -->
	<div class="help-content">
		<h3 class="info-title smaller">Overview</h3>
		<div class="info-section">
		 <ul class="info-list list-unstyled">
			<li>
				Based on <a href="#plugins/misc.inline-editable">Inline editable</a> plugin,
				five additional editables have been defined which you can use by including
				the following scripts:
<pre data-language="html">
 &lt;script src="dist/js/x-editable/bootstrap-editable.min.js" /&gt;
 &lt;script src="dist/js/x-editable/ace-editable.min.js" /&gt;
</pre>
			</li>
 		 </ul>
		</div>
		
		
		<h3 class="info-title smaller" data-id="#custom/inline-editable.image">Image editable</h3>
		<!-- #section:custom/inline-editable.image -->
		<div class="info-section">
		 <ul class="info-list list-unstyled">
			<li>
				Image editable is based on <a href="#custom/file-input" class="help-more">custom file input</a>
			</li>
		 
			<li>
				You should do some extra work for uploading the image.
				<br />
				A working example is available at <code>examples/profile-update.html</code>.
				<br />
				The backend (server side) code is written in PHP at <code>examples/file-upload.php</code>.
			</li>
			
			<li>
				Inside <code>image</code> parapmeter which takes custom file input options,
				there is also <code>on_error</code> and <code>on_success</code> callbacks that are called
				when an invalid file is selected or if files are successfully selected.
			</li>
			
			<li>
				An example of image editable's usage:
<pre data-language="javascript">
//first let's add a fake appendChild for Image element for browsers that have a problem with this
//because it seems that editable plugin calls appendChild, and it causes errors on IE at unpredicted points
try {
   document.createElement('IMG').appendChild(document.createElement('B'));
} catch(e) {
   Image.prototype.appendChild = function(el){}
}

$('#avatar').editable({
  type: 'image',
  name: 'avatar',
  value: null,
  image: {
    name: 'avatar',//name should be here as well
	
    //custom file input options
    btn_choose: 'Change Avatar',
    droppable: true,
    maxSize: 110000,//~100kb
	
    //inline editable callback option
    on_error : function(error_type) {
	  //invalid file selected, for example display an error message
      if(error_type == 1) {
        //file format error
      } else if(error_type == 2) {
        //file size rror
      }
      else {
        //other error
      }
    },
    on_success : function() {
      //valid file selected, for example remove error messages
    }
  },
  url: function(params) {
    //actual file upload happens here
    //see "examples/profile-avatar-update.js"
  }
});
</pre>
			</li>
			
			<li>
				If you want the editable image displayed in edit mode at first, you can use something like this:
<pre data-language="javascript">
$('#avatar').editable('show').on('hidden', function(e, reason) {
  if(reason == 'onblur') {
     $('#avatar').editable('show');
     return;
  }
  $('#avatar').off('hidden');
})
</pre>
			</li>
 		 </ul>
		</div>
		<!-- /section:custom/inline-editable.image -->

		
		<h3 class="info-title smaller" data-id="#custom/inline-editable.slider">Slider</h3>
		<!-- #section:custom/inline-editable.slider -->
		<div class="info-section">
		 <ul class="info-list list-unstyled">
			<li>
				For this addon 
				<a href="#plugins/jquery.slider" class="help-more">jQuery UI</a>
				is required and should be included first
			</li>
			<li>
<pre data-language="javascript">
$('#element').editable({
   type : 'slider',
   name : 'element-name',

   //jQuery UI slider options
   slider : {
       min: 1,
       max: 50,

	 //and slider's width (default is 200)
	 width: 100
	 
	 //,nativeUI: true //this will use browser's built-in range control if available
   },
   
   success: function(response, newValue) {
      alert(parseInt(newValue));
   }
});
</pre>
			</li>
			
			<li>
				Using <code>nativeUI</code> option will switch to browser's built-in range control if available
			</li>
 		 </ul>
		</div>
		<!-- /section:custom/inline-editable.slider -->
		
		
		<h3 class="info-title smaller" data-id="#custom/inline-editable.spinner">Spinner</h3>
		<!-- #section:custom/inline-editable.spinner -->
		<div class="info-section">
		 <ul class="info-list list-unstyled">
			<li>
				For this addon,
				<a href="#plugins/fuelux.spinner" class="help-more">FuelUX spinner</a>
				is required and should be included first
			</li>
			<li>
<pre data-language="javascript">
$('#element').editable({
   type: 'spinner',
   name: 'element-name',
   
   //spinner options
   spinner : {
      min: 16,
      max: 99,
     step: 1
	 
	 //,nativeUI: true //this will use browser's built-in number input if available
   }
});
</pre>
			</li>
			
			<li>
				Using <code>nativeUI</code> option will switch to browser's built-in number input if available
			</li>
 		 </ul>
		</div>
		<!-- /section:custom/inline-editable.spinner -->
		
		
		
		<h3 class="info-title smaller" data-id="#custom/inline-editable.wysiwyg">Wysiwyg</h3>
		<!-- #section:custom/inline-editable.wysiwyg -->
		<div class="info-section">
		 <ul class="info-list list-unstyled">
			<li>
				For this addon <a href="#plugins/editor.wysiwyg" class="help-more">Wysiwyg plugin</a>
				is required and should be included first
			</li>
			<li>
<pre data-language="javascript">
$('#element').editable({
   mode: 'inline',
   type: 'wysiwyg',
   name: 'element-name',

  //wysiwyg plugin options, such as buttons, etc
  wysiwyg : {
  
    //optional max-width
    //css : {'max-width':'300px'}
  },
  success: function(response, newValue) {
  }
});
</pre>
			</li>
 		 </ul>
		</div>
		<!-- /section:custom/inline-editable.wysiwyg -->
		
		
		
		
		<h3 class="info-title smaller" data-id="#custom/inline-editable.date">Date</h3>
		<!-- #section:custom/inline-editable.date -->
		<div class="info-section">
		 <ul class="info-list list-unstyled">
			<li>
				Latest version of inline editable plugin does not support date picker
			</li>
			<li>
				I added a custom one which requires
				<a href="#plugins/date-time.datepicker" class="help-more">date picker</a>
				and it should be included first.
				<br />
				The type name is <code>adate</code>
			</li>
			<li>
<pre data-language="javascript">
$('#element').editable({
  type: 'adate',
  
  //datepicker plugin options
  date: {
        format: 'dd/mm/yyyy',
    viewformat: 'dd/mm/yyyy',
     weekStart: 1
	 
     //,nativeUI: true //this will use browser's built-in date picker if available
  }
})
</pre>
			</li>
			
			<li>
				Using <code>nativeUI</code> option will switch to browser's built-in date picker if available
			</li>
 		 </ul>
		</div>
		<!-- /section:custom/inline-editable.date -->
		

	</div>
	<!-- /section:custom/inline-editable -->
	
</section>