├── Bootstrap ├── bootstrap-form │ ├── README.md │ ├── bootstrap-form.css │ ├── bootstrap-form.js │ ├── example.png │ └── index.html ├── bootstrap-paginate │ ├── README.md │ └── bootstrap-paginate.js ├── bootstrap-twitter-follow │ ├── README.md │ ├── bootstrap-follow.js │ └── index.html └── bootstrap-wizard │ ├── README.md │ ├── bootstrap-wizard.css │ └── bootstrap-wizard.js ├── README.md ├── jQuery ├── globalization │ ├── README.md │ └── jquery.globalization.js └── serializeObject │ ├── README.md │ └── jquery.serializeObject.js └── prototype ├── README.md └── prototype.js /Bootstrap/bootstrap-form/README.md: -------------------------------------------------------------------------------- 1 | # Form validator plugin for Bootstrap # 2 | 3 | This plugin verifies if the user doesn't write errors in the form field according to the Bootstrap styles. 4 | The form rules are defined with the HTML5 specifications. 5 | 6 | Here is an example which shows a form with all input types. 7 | 8 | Installation 9 | ------------ 10 | 11 | First, to make it works, the following files have to be included. 12 | 13 |
 14 | <link href="bootstrap-default.css" rel="stylesheet">
 15 | <link href="bootstrap-responsive.css" rel="stylesheet">
 16 | <link href="bootstrap-form.css" rel="stylesheet">
 17 | <script src="jquery.js"> </script>
 18 | <script src="bootstrap-tooltip.js"> </script>
 19 | <script src="bootstrap-form.js"> </script>
 20 | 
21 | *Note : Files `bootstrap-form.css` and `bootstrap-form.js` are part of the plugin.* 22 | 23 | Launching 24 | --------- 25 | 26 | Next, the form validator plugin must launch. 27 | 28 |
 29 | <script type="text/javascript">
 30 | 	$(document).ready(function() {
 31 | 		$('form').form();
 32 | 	});
 33 | </script>
 34 | 
35 | 36 | It is possible to specify options when the form is launched : 37 | * asterisk, boolean which print or not the asterisk for obligatory field, `true` ; 38 | * asteriskContent, string which is the asterisk content, `*`. 39 | 40 | Example 41 | ------- 42 | 43 | To finish, in first part, here is a screen for a form example. 44 | 45 | ![](https://github.com/ObjetDirect/javascript/raw/master/Bootstrap/bootstrap-form/example.png) 46 | 47 | And, in second part, the form body with all HTML5 input types which built this example. 48 | 49 |
 50 | <form class="form form-horizontal" action="./">
 51 | 
52 | 53 |
 54 | 	<fieldset class="well">
 55 | 		<h3>Connection informations</h3>
 56 | 		<br/>
 57 | 
58 | 59 | **Input text** 60 | 61 |
 62 | 		<div class="control-group">
 63 | 			<label class="control-label" for="inputLogin">Login</label>
 64 | 			<div class="controls">
 65 | 				<input type="text" id="inputLogin" class="input-medium" required="required"
 66 | 					pattern="[A-Za-z0-9]*" data-error="Please give a correct login.">
 67 | 			</div>
 68 | 		</div>
 69 | 
70 | If the user doesn't want to show an error on this input, 71 | 72 | - he mustn't let the empty field `required="required"` ; 73 | - he has to write letters or numbers `pattern="[A-Za-z0-9]*"`. 74 | 75 | Else, the error defined with `data-error="Please give a correct login."` appears. 76 | 77 | **Input password** 78 | 79 |
 80 | 		<div class="control-group">
 81 | 			<label class="control-label" for="inputPassword">Password</label>
 82 | 			<div class="controls">
 83 | 				<input type="password" id="inputPassword" class="input-medium" required="required"
 84 | 					data-error="Please give a correct password.">
 85 | 			</div>
 86 | 		</div>
 87 | 
88 | If the user doesn't want to show an error on this input, 89 | 90 | - he mustn't let the empty field `required="required"`. 91 | 92 | Else, the error defined with `data-error="Please give a correct password."` appears. 93 | 94 | **Input email** 95 | 96 |
 97 | 		<div class="control-group">
 98 | 			<label class="control-label" for="inputEmail">E-mail address</label>
 99 | 			<div class="controls">
100 | 				<input type="email" id="inputEmail" class="input-medium" required="required"
101 | 					data-error="Please give a correct e-mail address.">
102 | 			</div>
103 | 		</div>
104 | 
105 | If the user doesn't want to show an error on this input, 106 | 107 | - he has to write the email format `type="email"` ; 108 | - he mustn't let the empty field `required="required"`. 109 | 110 | Else, the error defined with `data-error="Please give a correct e-mail address."` appears. 111 | 112 |
113 | 	</fieldset>
114 | 	<fieldset class="well">
115 | 		<h3>General informations</h3>
116 | 		<br/>
117 | 
118 | 119 | **Input radio** 120 | 121 |
122 | 		<div class="control-group">
123 | 			<label class="control-label" for="inputGender">Gender</label>
124 | 			<div class="controls radio input-mini">
125 | 				<input type="radio" value="Man" id="man" name="gender" required="required"
126 | 					data-error="Please check a gender.">
127 | 				<label for="man">Man</label>
128 | 			</div>
129 | 			<div class="controls radio input-mini">
130 | 				<input type="radio" value="Woman" id="woman" name="gender">
131 | 				<label for="woman">Woman</label>
132 | 			</div>
133 | 		</div>
134 | 
135 | If the user doesn't want to show an error on this input, 136 | 137 | - he has to check one of all inputs `required="required"`. 138 | 139 | Else, the error defined with `data-error="Please check a gender."` appears. 140 | 141 | **Input date** 142 | 143 |
144 | 		<div class="control-group">
145 | 			<label class="control-label" for="inputAge">Birth date</label>
146 | 			<div class="controls">
147 | 				<input type="date" id="inputAge" class="input-medium" required="required"
148 | 					data-error="Please give a correct birth date.">
149 | 			</div>
150 | 		</div>
151 | 
152 | If the user doesn't want to show an error on this input, 153 | 154 | - he has to write the date format `type="date"` ; 155 | - he mustn't let the empty field `required="required"`. 156 | 157 | Else, the error defined with `data-error="Please give a correct birth date."` appears. 158 | 159 | **TextArea** 160 | 161 |
162 | 		<div class="control-group">
163 | 			<label class="control-label" for="inputLocation">Locality<br/>ZIP<br/>City</label>
164 | 			<div class="controls">
165 | 				<textarea id="inputLocation" class="input-medium" rows="3"></textarea>
166 | 			</div>
167 | 		</div>
168 | 
169 | The user never watch errors on this input. 170 | 171 | **Input tel** 172 | 173 |
174 | 		<div class="control-group">
175 | 			<label class="control-label" for="inputTel">Phone</label>
176 | 			<div class="controls">
177 | 				<input type="tel" id="inputTel" class="input-medium" pattern="[0-9]{10}"
178 | 					data-error="Please give a correct phone number.">
179 | 			</div>
180 | 		</div>
181 | 
182 | If the user doesn't want to show an error on this input, 183 | 184 | - he has to write the telephone number format `type="tel"`. 185 | 186 | Else, the error defined with `data-error="Please give a correct phone number."` appears. 187 | 188 | **Input url** 189 | 190 |
191 | 		<div class="control-group">
192 | 			<label class="control-label" for="inputWeb">Website</label>
193 | 			<div class="controls">
194 | 				<input type="url" id="inputWeb" class="input-medium" placeholder="http://"
195 | 					data-error="Please give a correct website url.">
196 | 			</div>
197 | 		</div>
198 | 
199 | If the user doesn't want to show an error on this input, 200 | 201 | - he has to write the website url format `type="url"`. 202 | 203 | Else, the error defined with `data-error="Please give a correct website url."` appears. 204 | 205 | **Input file** 206 | 207 |
208 | 		<div class="control-group">
209 | 			<label class="control-label" for="inputImage">Personal image</label>
210 | 			<div class="controls">
211 | 				<input type="file" id="inputImage" class="input-xlarge" accept="image/jpeg, image/png"
212 | 				required="required"
213 | 					data-error="Please give an image with jpg or png format.">
214 | 			</div>
215 | 		</div>
216 | 
217 | If the user doesn't want to show an error on this input, 218 | 219 | - he has to choose good files `type="file"` and `accept="image/jpeg, image/png"` ; 220 | - he mustn't let the empty field `required="required"`. 221 | 222 | Else, the error defined with `data-error="Please give an image with jpg or png format."` appears. 223 | 224 |
225 | 	</fieldset>
226 | 	<fieldset class="well">
227 | 		<h3>Optional informations</h3>
228 | 		<br/>
229 | 
230 | 231 | **Input number** 232 | 233 |
234 | 		<div class="control-group">
235 | 			<label class="control-label" for="inputComputer">Computers number</label>
236 | 			<div class="controls">
237 | 				<input type="number" value="0" min="0" max="10" id="inputComputer" class="input-medium"
238 | 					data-error="Please give a correct computers number.">
239 | 			</div>
240 | 		</div>
241 | 
242 | If the user doesn't want to show an error on this input, 243 | 244 | - he has to choose good number `type="number"`, `min="0"` and `max="10"`. 245 | 246 | Else, the error defined with `data-error="Please give a correct computers number."` appears. 247 | 248 | **Input search** 249 | 250 |
251 | 		<div class="control-group">
252 | 			<label class="control-label" for="inputSearch">Favorite animal</label>
253 | 			<div class="controls">
254 | 				<input type="search" id="inputSearch" list="inputSearchList" class="input-medium">
255 | 				<datalist id="inputSearchList">
256 | 					<option value="Alligator">
257 | 					<option value="Bear">
258 | 					<option value="Cat">
259 | 					<option value="Dolphin">
260 | 					<option value="Elephant">
261 | 					<option value="Fawn">
262 | 					<option value="Gazelle">
263 | 				</datalist>
264 | 			</div>
265 | 		</div>
266 | 
267 | The user never watch errors on this input. 268 | 269 | **Select multiple** 270 | 271 |
272 | 		<div class="control-group">
273 | 			<label class="control-label" for="inputFruit">Favorite fruit<br/>(between 2 and 4)</label>
274 | 			<div class="controls">
275 | 				<select id="inputFruit" class="input-medium" multiple="multiple" data-min="2" data-max="4"
276 | 					data-error="Please choose between two and four fruits.">
277 | 					<option value="apple">Apple</option>
278 | 					<option value="banana">Banana</option>
279 | 					<option value="cherry">Cherry</option>
280 | 					<option value="dewberry">Dewberry</option>
281 | 					<option value="elderberry">Elderberry</option>
282 | 					<option value="fig">Fig</option>
283 | 					<option value="grape">Grape</option>
284 | 				</select>
285 | 			</div>
286 | 		</div>
287 | 
288 | If the user doesn't want to show an error on this input, 289 | 290 | - he has to choose the asked number of all inputs `data-min="2"` and `data-min="4"`. 291 | 292 | Else, the error defined with `data-error="Please choose between two and four fruits."` appears. 293 | 294 | *Note : Tags `data-min` and `data-min` are specific tags for the form validator plugin. 295 | They impose a limit when the user has to make a multiple choice.* 296 | 297 | **Input checkbox** 298 | 299 |
300 | 		<div class="control-group">
301 | 			<label class="control-label" for="inputBrowser">Favorite browser<br/>(at least 1)</label>
302 | 			<div class="controls checkbox input-mini">
303 | 				<input type="checkbox" value="Chrome" id="chrome" name="browser[]" data-min="1"
304 | 					data-error="Please check at least one browser.">
305 | 				<label for="chrome">Chrome</label>
306 | 			</div>
307 | 			<div class="controls checkbox input-mini">
308 | 				<input type="checkbox" value="Firefox" id="firefox" name="browser[]">
309 | 				<label for="firefox">Firefox</label>
310 | 			</div>
311 | 			<div class="controls checkbox input-mini">
312 | 				<input type="checkbox" value="IExplorer" id="iexplorer" name="browser[]">
313 | 				<label for="iexplorer">IExplorer</label>
314 | 			</div>
315 | 			<div class="controls checkbox input-mini">
316 | 				<input type="checkbox" value="Opera" id="opera" name="browser[]">
317 | 				<label for="opera">Opera</label>
318 | 			</div>
319 | 			<div class="controls checkbox input-mini">
320 | 				<input type="checkbox" value="Safari" id="safari" name="browser[]">
321 | 				<label for="safari">Safari</label>
322 | 			</div>
323 | 		</div>
324 | 
325 | If the user doesn't want to show an error on this input, 326 | 327 | - he has to check the asked number of all inputs `data-min="1"` (see **Select Multiple**). 328 | 329 | Else, the error defined with `data-error="Please check at least one browser."` appears. 330 | 331 | **Input color** 332 | 333 |
334 | 		<div class="control-group">
335 | 			<label class="control-label" for="inputColor">Favorite color</label>
336 | 			<div class="controls">
337 | 				<input type="color" id="inputColor" class="input-medium">
338 | 			</div>
339 | 		</div>
340 | 
341 | The user never watch errors on this input. 342 | 343 | **Select** 344 | 345 |
346 | 		<div class="control-group">
347 | 			<label class="control-label" for="inputOS">Favorite OS</label>
348 | 			<div class="controls">
349 | 				<select id="inputOS" class="input-medium">
350 | 					<option>Nothing</option>
351 | 					<option>Linux</option>
352 | 					<option>Mac</option>
353 | 					<option>Windows</option>
354 | 				</select>
355 | 			</div>
356 | 		</div>
357 | 
358 | The user never watch errors on this input. 359 | 360 | **Input range** 361 | 362 |
363 | 		<div class="control-group">
364 | 			<label class="control-label" for="inputNote">Note</br>(on 20)</label>
365 | 			<div class="controls">
366 | 				<input type="range" max="20" id="inputNote" class="input-medium">
367 | 			</div>
368 | 		</div>
369 | 
370 | The user never watch errors on this input. 371 | 372 |
373 | 	</fieldset>
374 | 
375 | 376 | **Input button** 377 | 378 |
379 | 	<div class="form-actions">
380 | 		<button type="submit" class="btn btn-primary">Submit</button>
381 | 		<input type="reset" class="btn" value="Cancel">
382 | 	</div>
383 | 
384 | When the user submit the form whereas fields are empty, the request is not sent and the errors printed. 385 | If he clicks on Cancel, the form resets like to the beginning. 386 | 387 |
388 | </form>
389 | 
-------------------------------------------------------------------------------- /Bootstrap/bootstrap-form/bootstrap-form.css: -------------------------------------------------------------------------------- 1 | 2 | div.tooltip.formInput { 3 | margin: -3px 0 0 20px; 4 | } 5 | 6 | div.tooltip.formOther { 7 | margin: -3px 0 0 0; 8 | } 9 | -------------------------------------------------------------------------------- /Bootstrap/bootstrap-form/bootstrap-form.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Objet Direct - Form validator plugin for Bootstrap 3 | * 4 | * @property {boolean} asterisk Asterisk display status 5 | * @property {string} asteriskContent Content of the printed asterisk 6 | * 7 | * @requires ./docs/assets/css/bootstrap.css 8 | * @requires ./docs/assets/css/bootstrap-responsive.css 9 | * @requires ./docs/assets/js/jquery.js 10 | * @requires ./docs/assets/js/bootstrap-tooltip.js 11 | * 12 | * Here, there is an example that we can make with the formular validator 13 | * @example 14 | * 15 | * 16 | * 17 | * Form 18 | * 19 | * 24 | * 25 | * 26 | * 27 | * 28 | * 29 | * 34 | * 35 | * 36 | *
37 | *
38 | *

Connection information

39 | *
40 | * 41 | *
42 | * 44 | *
45 | *
46 | *
47 | *
48 | * 49 | *
50 | *
51 | * 52 | * 53 | * When the user submit the form, 54 | * if he lets an empty field because of the attribute 'required' 55 | * or he doesn't respect pattern because of the attribute 'pattern', 56 | * then the error from 'data-error' prints 57 | * and the cursor places to the first form error, 58 | * else the form is submited. 59 | * 60 | * Copyright 2012, David Wayntal 61 | * Dual licensed under the MIT or GPL Version 2 licenses. 62 | * http://www.opensource.org/licenses/mit-license.php/ 63 | * http://www.opensource.org/licenses/gpl-license.php 64 | * 65 | * Includes bootstrap.js 66 | * http://twitter.github.com/bootstrap/ 67 | * Copyright 2012, Objet Direct 68 | * Released under the MIT, BSD, and GPL Licenses. 69 | * 70 | * Date: 2012-07-09 71 | */ 72 | 73 | ! function($) { 74 | // ---------------------------------------------------------------------------------------- 75 | // FORM CLASS DEFINITION 76 | // ---------------------------------------------------------------------------------------- 77 | 78 | /** 79 | * Constructor for my form validator plugin 80 | * @constructor 81 | * @param {HTMLFormElement} formElement DOM JavaScript element linked to a form tag 82 | * @param {Object} options Options for my plugin 83 | */ 84 | var Form = function(formElement, options) { 85 | this.$form = $(formElement) 86 | this.options = $.extend({}, $.fn.form.defaults, options) 87 | } 88 | 89 | Form.prototype = { 90 | constructor : Form, 91 | main : function() { 92 | this.$form.attr('novalidate', 'novalidate'); 93 | $('input, textearea, select', this.$form).each(function() { 94 | __createTooltip($(this)); 95 | }); 96 | 97 | printAsterisk.call(this); 98 | submitForm.call(this); 99 | resetForm.call(this); 100 | } 101 | } 102 | 103 | // ---------------------------------------------------------------------------------------- 104 | // FORM CLASS PRIVATE METHODS 105 | // ---------------------------------------------------------------------------------------- 106 | 107 | /** 108 | * Prints an asterisk for form required fields 109 | */ 110 | function printAsterisk() { 111 | if (this.options.asterisk) { 112 | var self = this, jSelf, jParent; 113 | 114 | $('[required=required], [data-min], [data-max]', this.$form).each(function() { 115 | jSelf = $(this); 116 | jParent = jSelf.parent(); 117 | 118 | if (jSelf.attr('type') == 'radio' || jSelf.attr('type') == 'checkbox') { 119 | jParent.find('label').append(self.options.asteriskContent); 120 | 121 | } else { 122 | jParent.append(self.options.asteriskContent); 123 | } 124 | }); 125 | } 126 | } 127 | 128 | /** 129 | * Submits the form when the user clicks 130 | */ 131 | function submitForm() { 132 | var self = this, jWindow = $(window), allVerified, jSubmit; 133 | this.$form.submit(function(event) { 134 | allVerified = allInputVerification.call(self); 135 | 136 | jSubmit = self.$form.find('[type=submit]'); 137 | jSubmit.removeClass('btn-danger'); 138 | 139 | if (!allVerified) { 140 | event.preventDefault(); 141 | event.stopPropagation(); 142 | event.stopImmediatePropagation(); 143 | 144 | $(':invalid', self.$form).first().focus().select().get(0).scrollIntoView(true); 145 | jWindow.scrollTop(jWindow.scrollTop() - jWindow.height() / 2); 146 | jSubmit.addClass('btn-danger'); 147 | } 148 | }); 149 | } 150 | 151 | /** 152 | * Resets all form fields with its styles 153 | */ 154 | function resetForm() { 155 | var self = this; 156 | 157 | $('[type=reset]', this.$form).click(function() { 158 | $('[type=submit]', self.$form).removeClass('btn-success btn-danger'); 159 | $('.control-group', self.$form).removeClass('success error'); 160 | $('input, textearea, select', self.$form).each(function() { 161 | __hideTooltip($(this)); 162 | }); 163 | }); 164 | } 165 | 166 | /** 167 | * Verifies all form fields 168 | * @return {boolean} Fields status, if they are correct or not 169 | */ 170 | function allInputVerification() { 171 | var result = true, self = this; 172 | var marginLeft, min, max; 173 | $(':valid', self.$form).each(function() { 174 | validInput($(this)); 175 | }); 176 | 177 | var jSelf; 178 | $(':valid', self.$form).each(function() { 179 | jSelf = $(this); 180 | min = ((jSelf.attr('data-min')) && (!minInputVerification(jSelf))); 181 | max = ((jSelf.attr('data-max')) && (!maxInputVerification(jSelf))); 182 | if ((min && max) || (min) || (max)) { 183 | invalidInput(jSelf); 184 | result = false; 185 | } 186 | }); 187 | 188 | $(':invalid', self.$form).each(function() { 189 | invalidInput($(this)); 190 | result = false; 191 | }); 192 | return result; 193 | } 194 | 195 | /** 196 | * Counts the field number which are selected by the user 197 | * @param {HTMLFormElement} jElt DOM JavaScript element selected 198 | */ 199 | function countMultipleSelection(jElt) { 200 | var n; 201 | if ((jElt.attr('multiple')) && (jElt.val())) { 202 | n = jElt.val().length; 203 | 204 | } else { 205 | n = $('form.form [name="' + jElt.attr('name') + '"]:checked').length; 206 | } 207 | return n; 208 | } 209 | 210 | /** 211 | * Verifies form fiels which has "data-min" attibute 212 | * @param {HTMLFormElement} jElt DOM JavaScript element to verify 213 | */ 214 | function minInputVerification(jElt) { 215 | return (countMultipleSelection(jElt) >= jElt.attr('data-min')); 216 | } 217 | 218 | /** 219 | * Verifies form fiels which has "data-max" attibute 220 | * @param {HTMLFormElement} jElt DOM JavaScript element to verify 221 | */ 222 | function maxInputVerification(jElt) { 223 | return (countMultipleSelection(jElt) <= jElt.attr('data-max')); 224 | } 225 | 226 | /** 227 | * Renders a valid input 228 | * @param {HTMLFormElement} jElt DOM JavaScript element to valid 229 | */ 230 | function validInput(jElt) { 231 | __hideTooltip(jElt); 232 | printInputVerification(jElt.parent().parent(), true); 233 | } 234 | 235 | /** 236 | * Renders an invalid input 237 | * @param {HTMLFormElement} jElt DOM JavaScript element to invalid 238 | */ 239 | function invalidInput(jElt) { 240 | __showTooltip(jElt); 241 | printInputVerification(jElt.parent().parent(), false); 242 | } 243 | 244 | /** 245 | * Prints verifications maked on form fields 246 | * @param {HTMLFormElement} jElt DOM JavaScript element which will change 247 | * @param {boolean} result Verification result status 248 | */ 249 | function printInputVerification(jElt, result) { 250 | jElt.removeClass('success error').addClass( result ? 'success' : 'error'); 251 | } 252 | 253 | /** 254 | * Gives the input element according to its type (radio, checkbox...) 255 | * @param {HTMLFormElement} jElt DOM JavaScript current element 256 | */ 257 | function __giveElementTooltip(jElt) { 258 | if (jElt.attr('type') == 'radio' || jElt.attr('type') == 'checkbox') { 259 | return $("label[for='" + jElt.attr("id") + "']"); 260 | 261 | } else { 262 | return jElt; 263 | } 264 | } 265 | 266 | /** 267 | * Creates a Bootstrap tooltip on an element 268 | * @param {HTMLFormElement} jElt DOM JavaScript element which will be linked 269 | */ 270 | function __createTooltip(jElt) { 271 | var jDiv = $("
"); 272 | jDiv.text(jElt.attr('data-error')); 273 | 274 | $(__giveElementTooltip(jElt)).tooltip({ 275 | placement : 'right', 276 | title : jDiv.html(), 277 | trigger : 'manual', 278 | template : '
' 279 | }); 280 | } 281 | 282 | /** 283 | * Shows the element Bootstrap tooltip 284 | * @param {HTMLFormElement} jElt DOM JavaScript element which is linked 285 | */ 286 | function __showTooltip(jElt) { 287 | $(__giveElementTooltip(jElt)).tooltip('show'); 288 | } 289 | 290 | /** 291 | * Hides the element Bootstrap tooltip 292 | * @param {HTMLFormElement} jElt DOM JavaScript element which is linked 293 | */ 294 | function __hideTooltip(jElt) { 295 | $(__giveElementTooltip(jElt)).tooltip('hide'); 296 | } 297 | 298 | // ---------------------------------------------------------------------------------------- 299 | // FORM PLUGIN DEFINITION 300 | // ---------------------------------------------------------------------------------------- 301 | 302 | $.fn.form = function(option) { 303 | return this.each(function() { 304 | var $this = $(this), data = $this.data('form'), options = $.extend({}, $.fn.form.defaults, $this.data(), typeof option == 'object' && option) 305 | 306 | !data && $this.data('form', ( data = new Form(this, options))); 307 | 308 | if ( typeof option == 'string') { 309 | data[option](); 310 | 311 | } else { 312 | data.main(); 313 | } 314 | }) 315 | } 316 | 317 | $.fn.form.defaults = { 318 | asterisk : true, 319 | asteriskContent : "*" 320 | } 321 | 322 | $.fn.form.Constructor = Form 323 | 324 | }(window.jQuery); 325 | -------------------------------------------------------------------------------- /Bootstrap/bootstrap-form/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ObjetDirect/javascript/470ffd6df144cd80830f3842ded45e1931f2e701/Bootstrap/bootstrap-form/example.png -------------------------------------------------------------------------------- /Bootstrap/bootstrap-form/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Form 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 24 | 33 |
34 |
35 |
36 |
37 |

Connection informations

38 |
39 | 40 |
41 | 42 |
43 | 45 |
46 |
47 | 48 |
49 | 50 |
51 | 53 |
54 |
55 | 56 |
57 | 58 |
59 | 61 |
62 |
63 |
64 |
65 |

General informations

66 |
67 | 68 |
69 | 70 |
71 | 73 | 74 |
75 |
76 | 77 | 78 |
79 |
80 | 81 |
82 | 83 |
84 | 86 |
87 |
88 | 89 |
90 | 91 |
92 | 93 |
94 |
95 | 96 |
97 | 98 |
99 | 101 |
102 |
103 | 104 |
105 | 106 |
107 | 109 |
110 |
111 | 112 |
113 | 114 |
115 | 118 |
119 |
120 |
121 |
122 |

Optional informations

123 |
124 | 125 |
126 | 127 |
128 | 130 |
131 |
132 | 133 |
134 | 135 |
136 | 137 | 138 | 146 |
147 |
148 | 149 |
150 | 151 |
152 | 162 |
163 |
164 | 165 |
166 | 167 |
168 | 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 | 206 |
207 |
208 | 209 |
210 | 211 |
212 | 213 |
214 |
215 |
216 | 217 |
218 | 219 | 220 |
221 |
222 |
223 |
224 | 225 | 226 | -------------------------------------------------------------------------------- /Bootstrap/bootstrap-paginate/README.md: -------------------------------------------------------------------------------- 1 | # Paginate plugin for Bootstrap # 2 | 3 | This plugin offers the possibility to paginate. 4 | 5 | Installation 6 | ------------ 7 | 8 | First, to make it works, the following files have to be included. 9 | 10 |
11 | <link type="text/css" media="screen" title="no title" rel="stylesheet" href="bootstrap.css" />
12 | 
13 | <script src="jquery.js"> </script>
14 | <script src="bootstrap.js"> </script>
15 | <script src="bootstrap-paginate.js"> </script>
16 | 
17 | 18 | Launching 19 | --------- 20 | 21 | Define in your HTML the content of your Paginate. 22 | 23 |
24 | <div id="paginate">
25 | </div>
26 | 
27 | 28 | And the associated JavaScript: 29 |
30 | $("#paginate").paginate({
31 | 	pages: 5,
32 | 	pageChange: function(index) {
33 | 		$("table tbody").load("/user/paginate/" + index);
34 | 	}
35 | });
36 | 
37 | 38 | It is possible to specify options: 39 |
40 | // Default options
41 | $.fn.paginate.defaults = {
42 | 	align: "centered",						/* values: centered, right, left, null */
43 | 	size: null,											/* values: large, small, mini, null */
44 | 	previousText: "&laquo;",
45 | 	nextText: "&raquo;",
46 | 	detachedPreviousText: "&larr; Older",
47 | 	detachedNextText: "Newer &rarr;",
48 | 	previousPlacement: "normal", 				/* values: normal, detached */
49 | 	nextPlacement: "normal",					/* values: normal, detached */
50 | 	pages: 10, 											/* Nb page max */
51 | 	pageChange: function(index) { }
52 | };
53 | 
54 | -------------------------------------------------------------------------------- /Bootstrap/bootstrap-paginate/bootstrap-paginate.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Paginate plugin for Boostrap 3 | * An example of HTML to use it: 4 | * 5 |
6 | 7 | * And the JavaScript: 8 | * 9 | $("#paginate").paginate({ 10 | pages: 5, 11 | pageChange: function(index) { 12 | $("table tbody").load("/user/paginate/" + index); 13 | } 14 | }); 15 | */ 16 | 17 | !function($) { 18 | "use strict"; 19 | 20 | /* PAGINATE PUBLIC CLASS DEFINITION 21 | * ============================== */ 22 | 23 | var Paginate = function(element, options) { 24 | var self = this; 25 | 26 | // Base 27 | this.$element = $(element); 28 | this.options = $.extend({}, $.fn.paginate.defaults, options); 29 | this.index = 0; 30 | this.maxLink = 10; 31 | this.indexMin = 0; 32 | this.indexMax = this.indexMin + this.maxLink; 33 | 34 | // Decoration 35 | this.$element.addClass("pagination"); 36 | this.options.align && this.$element.addClass("pagination-" + this.options.align); 37 | this.options.size && this.$element.addClass("pagination-" + this.options.size); 38 | 39 | // Childs 40 | this.$ul = $(""); 41 | 42 | if(this.options.previousPlacement == "detached"){ 43 | this.$previous = $(""); 44 | 45 | } else { 46 | this.$previous = $("
  • " + this.options.previousText + "
  • "); 47 | } 48 | 49 | if(this.options.nextPlacement == "detached"){ 50 | this.$next = $(""); 51 | 52 | } else { 53 | this.$next = $("
  • " + this.options.nextText + "
  • "); 54 | } 55 | 56 | this.insertIndexes(); 57 | 58 | // Listeners 59 | this.$element.on("click", "li:not(.disabled) a", function(event){ 60 | event.preventDefault(); 61 | var $a = $(this), index = $a.data("index"); 62 | 63 | switch(index){ 64 | case "previous": 65 | self.index--; 66 | break; 67 | 68 | case "next": 69 | self.index++; 70 | break; 71 | 72 | default: 73 | self.index = window.parseInt(index); 74 | break; 75 | } 76 | 77 | self.update(); 78 | $.isFunction(self.options.pageChange) && self.options.pageChange(self.index); 79 | self.$element.trigger("paginate", [self.index]); 80 | }); 81 | 82 | // Display the element 83 | this.update(); 84 | this.$element.append(this.$ul); 85 | }; 86 | 87 | Paginate.prototype.changePage = function(page, triggerEvent) { 88 | if(page >= 0){ 89 | this.index = page; 90 | this.update(); 91 | 92 | if(triggerEvent == null || triggerEvent == true){ 93 | $.isFunction(this.options.pageChange) && this.options.pageChange(this.index); 94 | this.$element.trigger("paginate", [this.index]); 95 | } 96 | } 97 | }; 98 | 99 | Paginate.prototype.insertIndexes = function(){ 100 | var length = Math.min(this.options.pages, this.indexMax) 101 | 102 | this.$ul.append(this.$previous); 103 | 104 | for(var i = this.indexMin; i < length; i++){ 105 | this.$ul.append("
  • " + (i+1) + "
  • "); 106 | } 107 | 108 | this.$ul.append(this.$next); 109 | 110 | if(length <= 0){ 111 | this.$element.hide(); 112 | 113 | } else { 114 | this.$element.show(); 115 | } 116 | }; 117 | 118 | Paginate.prototype.update = function(){ 119 | if(this.index < this.indexMin || this.indexMax <= this.index + 1){ 120 | // We have to flush the elements 121 | this.$ul.find("li").remove(); 122 | 123 | this.indexMin = this.index < this.indexMin ? this.indexMin + 1 - this.maxLink : this.indexMax - 1; 124 | this.indexMax = this.indexMin + this.maxLink; 125 | this.insertIndexes(); 126 | 127 | } else { 128 | this.$ul.find("li").removeClass("disabled"); 129 | } 130 | 131 | if(this.index <= 0) { 132 | this.$previous.addClass("disabled"); 133 | 134 | } else { 135 | this.$previous.removeClass("disabled"); 136 | } 137 | 138 | this.$ul.find("a[data-index='" + this.index + "']").parents("li:first").addClass("disabled"); 139 | 140 | if(this.index < this.options.pages - 1) { 141 | this.$next.removeClass("disabled"); 142 | 143 | } else { 144 | this.$next.addClass("disabled"); 145 | } 146 | }; 147 | 148 | Paginate.prototype.index = function(){ 149 | return index; 150 | }; 151 | 152 | Paginate.prototype.option = function(options){ 153 | if(!options){ 154 | return; 155 | } 156 | 157 | var changePrevious = false, changeNext = false; 158 | 159 | for(var i in options) { 160 | switch(i){ 161 | case "previousPlacement": 162 | case "previousText": 163 | changePrevious = true; 164 | 165 | case "nextText": 166 | case "detachedNextText": 167 | changeNext = true; 168 | 169 | default: 170 | this.options[i] = options[i]; 171 | break; 172 | } 173 | } 174 | 175 | if(changePrevious){ 176 | this.$previous.find("a").text(this.options.previousPlacement == "detached" ? this.options.detachedPreviousText : this.options.previousText); 177 | } 178 | 179 | if(changeNext){ 180 | this.$next.find("a").text(this.options.nextPlacement == "detached" ? this.options.detachedNextText : this.options.nextText); 181 | } 182 | 183 | this.update(); 184 | }; 185 | 186 | /* PAGINATE PLUGIN DEFINITION 187 | * ======================== */ 188 | 189 | $.fn.paginate = function(opts) { 190 | return this.each(function() { 191 | var $this = $(this), data = $this.data("paginate"), options = typeof opts == "object" && opts; 192 | 193 | if(data){ 194 | data.option(options) 195 | 196 | } else { 197 | $this.data("paginate", new $.fn.paginate.Constructor(this, options)); 198 | } 199 | }); 200 | }; 201 | 202 | $.fn.paginate.defaults = { 203 | align: "centered", /* values: centered, right, left, null */ 204 | size: null, /* values: large, small, mini, null */ 205 | previousText: "«", 206 | nextText: "»", 207 | detachedPreviousText: "← Older", 208 | detachedNextText: "Newer →", 209 | previousPlacement: "normal", /* values: normal, detached */ 210 | nextPlacement: "normal", /* values: normal, detached */ 211 | pages: 10, /* Nb page max */ 212 | pageChange: function(index) { } 213 | }; 214 | 215 | $.fn.paginate.Constructor = Paginate; 216 | 217 | /* PAGINATE DATA-API 218 | * =============== */ 219 | 220 | $(function() { 221 | $("body").find("div[data-role=paginate], div.paginate").paginate(); 222 | }); 223 | 224 | }(window.jQuery); 225 | -------------------------------------------------------------------------------- /Bootstrap/bootstrap-twitter-follow/README.md: -------------------------------------------------------------------------------- 1 | # Twitter follow button plugin for Bootstrap # 2 | 3 | This plugin substitutes the follow button creation on the official Twitter website, by a javascript component where the user changes options. 4 | 5 | Here is an example which shows a follow button. 6 | 7 | Installation 8 | ------------ 9 | 10 | First, to make it works, the following files have to be included. 11 | 12 |
    13 | <script src="jquery.js"> </script>
    14 | <script src="bootstrap-follow.js"> </script>
    15 | 
    16 | 17 | Launching 18 | --------- 19 | 20 | Next, the follow button plugin must launch. 21 | 22 |
    23 | <script type="text/javascript">
    24 | 	$(document).ready(function() {
    25 | 		$('.followTwitter').follow();
    26 | 		$('.followObjetDirect').follow({
    27 | 			login : 'objetdirect',
    28 | 			largeButton : true,
    29 | 			language : 'fr'
    30 | 		});
    31 | 	});
    32 | </script>
    33 | 
    34 | 35 | It is possible to specify options when the follow button is launched : 36 | * login, string which is the user login pointed by the button, `twitter` ; 37 | * showLogin, boolean which prints or not the login, `true` ; 38 | * showSubscribe, boolean which prints or not the subscribe number, `false` ; 39 | * largeButton, boolean which changes the button width, `false` ; 40 | * language, string which is the button text language (en, fr, ...), `en`. 41 | 42 | Example 43 | ------- 44 | 45 | To finish, here is an example to build two follow buttons. 46 | 47 |
    48 | <div class="followTwitter"> </div>
    49 | <div class="followObjetDirect"> </div>
    50 | 
    51 | In the body part, there is simply the html button declaration. -------------------------------------------------------------------------------- /Bootstrap/bootstrap-twitter-follow/bootstrap-follow.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Objet Direct - Twitter follow button plugin for Bootstrap 3 | * 4 | * @property {string} login User login pointed by the button 5 | * @property {boolean} showLogin Login display status 6 | * @property {boolean} showSubscribe Subscribe number display status 7 | * @property {boolean} largeButton Width button display status 8 | * @property {string} language Button text language ('en', 'fr', ...) 9 | * 10 | * @requires ./docs/assets/js/jquery.js 11 | * 12 | * Here, there is an example that we can make with the follow button 13 | * @example 14 | * 15 | * 16 | * 17 | * Follow 18 | * 19 | * 20 | * 30 | * 31 | * 32 | *
    33 | *
    34 | * 35 | * 36 | * This plugin substitutes the follow button creation on the official Twitter website, 37 | * by a javascript component where the user changes options. 38 | * 39 | * Copyright 2012, David Wayntal 40 | * Dual licensed under the MIT or GPL Version 2 licenses. 41 | * http://www.opensource.org/licenses/mit-license.php/ 42 | * http://www.opensource.org/licenses/gpl-license.php 43 | * 44 | * Includes bootstrap.js 45 | * http://twitter.github.com/bootstrap/ 46 | * Copyright 2012, Objet Direct 47 | * Released under the MIT, BSD, and GPL Licenses. 48 | * 49 | * Date: 2012-07-26 50 | */ 51 | 52 | ! function($) { 53 | // ---------------------------------------------------------------------------------------- 54 | // FOLLOW BUTTON CLASS DEFINITION 55 | // ---------------------------------------------------------------------------------------- 56 | 57 | /** 58 | * Constructor for the Twitter follow button 59 | * @constructor 60 | * @param {HTMLFollowElement} followElement DOM JavaScript element linked to a follow button tag 61 | * @param {Object} options Options for my plugin 62 | */ 63 | var Follow = function(followElement, options) { 64 | this.$follow = $(followElement) 65 | this.options = $.extend({}, $.fn.follow.defaults, options) 66 | } 67 | 68 | Follow.prototype = { 69 | constructor : Follow, 70 | main : function() { 71 | printFollow.call(this); 72 | } 73 | } 74 | 75 | // ---------------------------------------------------------------------------------------- 76 | // FOLLOW BUTTON CLASS PRIVATE METHODS 77 | // ---------------------------------------------------------------------------------------- 78 | 79 | /** 80 | * Prints the follow button 81 | */ 82 | function printFollow() { 83 | this.$follow.html( 84 | 'Follow @' + this.options.login + '' 92 | + '' 93 | ); 94 | } 95 | 96 | // ---------------------------------------------------------------------------------------- 97 | // FOLLOW BUTTON PLUGIN DEFINITION 98 | // ---------------------------------------------------------------------------------------- 99 | 100 | $.fn.follow = function(option) { 101 | return this.each(function() { 102 | var $this = $(this), data = $this.data('follow'), options = $.extend({}, $.fn.follow.defaults, $this.data(), typeof option == 'object' && option) 103 | 104 | !data && $this.data('follow', ( data = new Follow(this, options))); 105 | 106 | if ( typeof option == 'string') { 107 | data[option](); 108 | 109 | } else { 110 | data.main(); 111 | } 112 | }) 113 | } 114 | 115 | $.fn.follow.defaults = { 116 | login: 'twitter', 117 | showLogin : true, 118 | showSubscribe : false, 119 | largeButton : false, 120 | language : 'en' 121 | } 122 | 123 | $.fn.follow.Constructor = Follow 124 | 125 | }(window.jQuery); 126 | -------------------------------------------------------------------------------- /Bootstrap/bootstrap-twitter-follow/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Follow Button 6 | 7 | 8 | 18 | 19 | 20 |
    21 |
    22 | 23 | 24 | -------------------------------------------------------------------------------- /Bootstrap/bootstrap-wizard/README.md: -------------------------------------------------------------------------------- 1 | # Wizard plugin for Bootstrap # 2 | 3 | This plugin (based on the carousel) offers the possibility to have a wizard for Bootstrap. 4 | 5 | Installation 6 | ------------ 7 | 8 | First, to make it works, the following files have to be included. 9 | 10 |
    11 | <link type="text/css" media="screen" title="no title" rel="stylesheet" href="bootstrap.css" />
    12 | <link type="text/css" media="screen" title="no title" rel="stylesheet" href="bootstrap-wizard.css" />
    13 | 
    14 | <script src="jquery.js"> </script>
    15 | <script src="bootstrap.js"> </script>
    16 | <script src="bootstrap-wizard.js"> </script>
    17 | 
    18 | 19 | Launching 20 | --------- 21 | 22 | Define in your HTML the content of your Wizard. 23 | 24 |
    25 | <div id="wizard" data-role="wizard">
    26 | 	<div class="active" data-title="step 1">
    27 | 		Your content
    28 | 	</div>
    29 | 	
    30 | 	<div data-title="step 2">
    31 | 		Your content
    32 | 	</div>
    33 | </div>
    34 | 
    35 | 36 | Another one: 37 |
    38 | <div id="wizard" data-role="wizard">
    39 | 	<div class="active" data-title="step 1">
    40 | 		Your content
    41 | 	</div>
    42 | 	
    43 | 	<div data-title="step 2">
    44 | 		Your content
    45 | 	</div>
    46 | </div>
    47 | 
    48 | 49 | And how to use it with JavaScript: 50 |
    51 | $("#wizard").wizard({
    52 | 	validNextStep: function(index) { 
    53 | 		return true; 
    54 | 	},
    55 | 	changeStep: function(index) {
    56 | 		alert("Step " + (index + 1))
    57 | 	},
    58 | 	finish: function(event) {
    59 | 		event.preventDefault();
    60 | 		alert("Finished !")
    61 | 	}
    62 | });
    63 | 
    64 | 65 | It is possible to specify options: 66 |
    67 | // Default options
    68 | $.fn.wizard.defaults = {
    69 | 	nextText: "Next",
    70 | 	previousText: "Previous",
    71 | 	finishText: "Finish",
    72 | 	displayOnJump: false,
    73 | 	validNextStep: function(index) { return true; },
    74 | 	invalidateNextStep: function(index) {},
    75 | 	changeStep: function(index) {},
    76 | 	finish: function(event) {}
    77 | };
    78 | 
    79 | -------------------------------------------------------------------------------- /Bootstrap/bootstrap-wizard/bootstrap-wizard.css: -------------------------------------------------------------------------------- 1 | @CHARSET "UTF-8"; 2 | 3 | .wizard { 4 | background-color: white; 5 | } 6 | 7 | .wizard .carousel-inner { 8 | overflow: visible; 9 | } 10 | 11 | .wizard.animated .carousel-inner { 12 | overflow: hidden; 13 | } 14 | 15 | .wizard-header a { 16 | padding: 10px 12px 10px; 17 | margin-right: 5px; 18 | background: #efefef; 19 | position: relative; 20 | display: inline-block; 21 | } 22 | 23 | .wizard-header a:before { 24 | width: 0; 25 | height: 0; 26 | border-top: 20px inset transparent; 27 | border-bottom: 20px inset transparent; 28 | border-left: 20px solid #fff; 29 | position: absolute; 30 | content: ""; 31 | top: 0; 32 | left: 0; 33 | } 34 | 35 | .wizard-header a:after { 36 | width: 0; 37 | height: 0; 38 | border-top: 20px inset transparent; 39 | border-bottom: 20px inset transparent; 40 | border-left: 20px solid #efefef; 41 | position: absolute; 42 | content: ""; 43 | top: 0; 44 | right: -20px; 45 | z-index: 2; 46 | } 47 | 48 | .wizard-header a.first:before, 49 | .wizard-header a.last:after { 50 | border: none; 51 | } 52 | 53 | .wizard-header a:first-child { 54 | -webkit-border-radius: 4px 0 0 4px; 55 | -moz-border-radius: 4px 0 0 4px; 56 | border-radius: 4px 0 0 4px; 57 | } 58 | 59 | .wizard-header a:last-child { 60 | -webkit-border-radius: 0 4px 4px 0; 61 | -moz-border-radius: 0 4px 4px 0; 62 | border-radius: 0 4px 4px 0; 63 | } 64 | 65 | .wizard-header .badge { 66 | margin: 0 5px 0 18px; 67 | position: relative; 68 | top: -1px; 69 | } 70 | 71 | .wizard-header a:first-child .badge { 72 | margin-left: 0; 73 | } 74 | 75 | .wizard-header .active { 76 | background: #007ACC; 77 | color: #fff; 78 | } 79 | 80 | .wizard-header .active:after { 81 | border-left-color: #007ACC; 82 | } -------------------------------------------------------------------------------- /Bootstrap/bootstrap-wizard/bootstrap-wizard.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Wizard plugin for Boostrap 3 | * Require the carousel plugin 4 | * 5 | * An example of HTML to use it: 6 | * 7 |
    8 |
    9 | Your content 10 |
    11 | 12 |
    13 | Your content 14 |
    15 |
    16 | 17 | * 18 | * Another one: 19 | * 20 |
    21 |
    22 | Your content 23 |
    24 | 25 |
    26 | Your content 27 |
    28 |
    29 | 30 | * 31 | * And an example of JavaScript: 32 | 33 | $("#wizard").wizard({ 34 | validNextStep: function(index) { 35 | return true; 36 | }, 37 | changeStep: function(index) { 38 | alert("Step " + (index + 1)) 39 | }, 40 | finish: function(event) { 41 | event.preventDefault(); 42 | alert("Finished !") 43 | } 44 | }); 45 | 46 | */ 47 | 48 | !function($) { 49 | "use strict"; 50 | 51 | /* WIZARD PUBLIC CLASS DEFINITION 52 | * ============================== */ 53 | 54 | var Wizard = function(element, options) { 55 | var self = this; 56 | 57 | // Base 58 | this.$element = $(element); 59 | this.options = $.extend({}, $.fn.wizard.defaults, options); 60 | this.idx = 0; 61 | this.maxIdx = 0; 62 | 63 | // Get some informations 64 | this.$items = $("> div[data-title]", this.$element); 65 | this.maxIdx = this.$items.length - 1; 66 | 67 | // Initialization 68 | this.$element.find("> *").wrapAll(""); 69 | this.$element.addClass("wizard thumbnail"); 70 | this.$base = this.$element.find("> div.carousel"); 71 | this.$base.carousel({ interval: false }); 72 | 73 | if(this.$element.attr("id")){ 74 | this.$base.attr("id", "wizard-" + this.$element.attr("id")); 75 | 76 | } else { 77 | this.$base.attr("id", "wizard-" + new Date().getTime() + "-" + window.parseInt((Math.random() * 1000))); 78 | } 79 | 80 | // Wizard header 81 | this.$wizardHeader = $("
    "); 82 | this.$items.each(function(index, item){ 83 | var $item = $(item), active = index == 0, classToUse = ""; 84 | 85 | $item.addClass("item"); 86 | active && $item.addClass("active"); 87 | 88 | if(active){ 89 | classToUse += "active "; 90 | } 91 | 92 | if(index == 0){ 93 | classToUse += "first "; 94 | } 95 | 96 | if(index == self.maxIdx){ 97 | classToUse += "last "; 98 | } 99 | 100 | self.$wizardHeader.append("" + (index + 1) + " " + $item.data("title") + ""); 101 | }); 102 | 103 | this.$base.before(this.$wizardHeader); 104 | this.$base.before("
    "); 105 | 106 | // Wizard core 107 | this.$items.wrapAll(""); 108 | this.$base.append("
    "); 109 | 110 | this.$previous = $(" " + this.options.previousText + ""); 111 | this.$previous.attr("href", "#" + this.$base.attr("id")); 112 | this.$previous.css("visibility", "hidden"); 113 | this.$base.append(this.$previous); 114 | 115 | this.$next = $("" + this.options.nextText + ""); 116 | this.$next.attr("href", "#" + this.$base.attr("id")); 117 | this.$base.append(this.$next); 118 | 119 | this.$finish = $(""); 120 | this.$finish.css("visibility", "hidden"); 121 | this.$finish.on("click", function(event){ 122 | if(self.options.validNextStep.call(self, self.idx)){ 123 | $.isFunction(self.options.finish) && self.options.finish.call(self, event); 124 | } 125 | }); 126 | this.$base.append(this.$finish); 127 | this.$base.append("
    "); 128 | 129 | // Listeners 130 | this.$wizardHeader.on("click", "> a", function(event){ 131 | event.preventDefault(); 132 | self.index($(this).data("index")); 133 | }); 134 | 135 | this.$base.on("click", "> a", function(event){ 136 | event.preventDefault(); 137 | $(this).data("index") == "next" ? self.next() : self.prev(); 138 | }); 139 | 140 | this.$base.on("slid", function(event){ 141 | window.setTimeout(function(){ self.$element.removeClass("animated"); }, 50); 142 | }); 143 | }; 144 | 145 | Wizard.prototype.index = function(index){ 146 | if(index != null && index >= 0 && index <= this.maxIdx){ 147 | var i, isValid = true; 148 | 149 | if(this.idx < index){ 150 | if(this.options.displayOnJump){ 151 | for(i = this.idx; i <= index; ++i){ 152 | if(this.options.validNextStep.call(this, i)){ 153 | this.$element.addClass("animated"); 154 | this.$base.carousel(i); 155 | this.idx = i; 156 | this.update(); 157 | 158 | $.isFunction(this.options.changeStep) && this.options.changeStep.call(this, this.idx); 159 | 160 | } else if($.isFunction(this.options.invalidateNextStep)){ 161 | isValid = false; 162 | this.options.invalidateNextStep.call(this, i); 163 | } 164 | } 165 | 166 | } else { 167 | for(i = this.idx; i < index; ++i){ 168 | if(!this.options.validNextStep.call(this, i)){ 169 | isValid = false; 170 | 171 | if($.isFunction(this.options.invalidateNextStep)){ 172 | this.options.invalidateNextStep.call(this, i); 173 | } 174 | 175 | break; 176 | } 177 | } 178 | } 179 | } 180 | 181 | if(isValid){ 182 | this.$element.addClass("animated"); 183 | this.$base.carousel(index); 184 | this.idx = index; 185 | this.update(); 186 | 187 | $.isFunction(this.options.changeStep) && this.options.changeStep.call(this, this.idx); 188 | 189 | } 190 | } 191 | 192 | return this.idx; 193 | }; 194 | 195 | Wizard.prototype.update = function() { 196 | if(this.idx == 0){ 197 | this.$previous.css("visibility", "hidden"); 198 | this.$next.css("visibility", "visible"); 199 | this.$finish.css("visibility", "hidden"); 200 | 201 | } else if(this.idx == this.maxIdx){ 202 | this.$previous.css("visibility", "visible"); 203 | this.$next.css("visibility", "hidden"); 204 | this.$finish.css("visibility", "visible"); 205 | 206 | } else { 207 | this.$previous.css("visibility", "visible"); 208 | this.$next.css("visibility", "visible"); 209 | this.$finish.css("visibility", "hidden"); 210 | } 211 | 212 | $(".active span.badge", this.$wizardHeader).addClass("badge-inverse"); 213 | $(".active", this.$wizardHeader).removeClass("active"); 214 | $("a:eq(" + this.idx + ")", this.$wizardHeader).addClass("active"); 215 | $(".active span.badge", this.$wizardHeader).removeClass("badge-inverse"); 216 | }; 217 | 218 | Wizard.prototype.prev = function() { 219 | if(this.idx > 0){ 220 | this.index(this.idx - 1); 221 | return false; 222 | } 223 | 224 | return true; 225 | }; 226 | 227 | Wizard.prototype.next = function() { 228 | if(this.idx <= this.maxIdx){ 229 | this.index(this.idx+ 1); 230 | return false; 231 | } 232 | 233 | return true; 234 | }; 235 | 236 | Wizard.prototype.option = function(options){ 237 | if(!options){ 238 | return; 239 | } 240 | 241 | for(var i in options) { 242 | switch(i){ 243 | case "nextText": 244 | this.$next.text(options[i]); 245 | 246 | case "previousText": 247 | this.$previous.text(options[i]); 248 | 249 | case "finishText": 250 | this.$finish.text(options[i]); 251 | 252 | case "finish": 253 | this.$finish.off("click", this.options.finish); 254 | this.$finish.on("click", options[i]); 255 | 256 | default: 257 | this.options[i] = options[i]; 258 | break; 259 | } 260 | } 261 | }; 262 | 263 | /* WIZARD PLUGIN DEFINITION 264 | * ======================== */ 265 | 266 | $.fn.wizard = function(opts) { 267 | return this.each(function() { 268 | var $this = $(this), data = $this.data("wizard"), options = typeof opts == "object" && opts; 269 | 270 | if(data){ 271 | data.option(options); 272 | 273 | } else { 274 | $this.data("wizard", new $.fn.wizard.Constructor(this, options)); 275 | } 276 | 277 | }); 278 | }; 279 | 280 | $.fn.wizard.defaults = { 281 | nextText: "Next", 282 | previousText: "Previous", 283 | finishText: "Finish", 284 | displayOnJump: false, 285 | validNextStep: function(index) { return true; }, 286 | invalidateNextStep: function(index) {}, 287 | changeStep: function(index) {}, 288 | finish: function(event) {} 289 | }; 290 | 291 | $.fn.wizard.Constructor = Wizard; 292 | 293 | /* WIZARD DATA-API 294 | * =============== */ 295 | 296 | $(function() { 297 | $("body").find("div[data-role=wizard], div.wizard").wizard(); 298 | }); 299 | 300 | }(window.jQuery); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | javascript 2 | ========== 3 | 4 | JavaScript plugins -------------------------------------------------------------------------------- /jQuery/globalization/README.md: -------------------------------------------------------------------------------- 1 | # jQuery plugin for the globalization # 2 | 3 | This little plugin can load some globalization properties and translate our Web pages. We put on the DOM element the attribute "data-translate". 4 | This attribute can contains one or many properties, and inject these into the content, or into the attribute. 5 | 6 | Examples: 7 |
     8 |   <!-- Inject into the content -->
     9 |   <div data-translate="aProperty">A default text</div>
    10 | 
    11 | 12 |
    13 |   <!-- Inject into the attribute -->
    14 |   <div data-translate="title:aProperty" title="A default title">A text</div>
    15 | 
    16 | 17 |
    18 |   <!-- Inject into the attribute and the content -->
    19 |   <div data-translate="title:aProperty;anotherProperty" title="A default title">A default text</div>
    20 | 
    21 | 22 | You can too retrieve the property manually: 23 |
    24 |   var text = $.translate.properties["aProperty"];
    25 | 
    26 | 27 | --- 28 | 29 | ### The MIT License 30 | 31 | Copyright (c) <2012> 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy 34 | of this software and associated documentation files (the "Software"), to deal 35 | in the Software without restriction, including without limitation the rights 36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 37 | copies of the Software, and to permit persons to whom the Software is 38 | furnished to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included in 41 | all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 49 | THE SOFTWARE. 50 | 51 | -------------------------------------------------------------------------------- /jQuery/globalization/jquery.globalization.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 (c) Objet Direct 3 | * Dual licensed under the MIT or GPL Version 2 licenses. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Plugin to put some globalizations 28 | */ 29 | window.jQuery && (function($){ 30 | if($.translate){ 31 | // Already loaded ? 32 | return; 33 | } 34 | 35 | /** 36 | * Options 37 | */ 38 | $.translate = { 39 | defaultLanguage: navigator.language, 40 | pathLanguage: function(language){ 41 | return language + ".js"; 42 | }, 43 | loadLanguage: function(){ 44 | $("head:first").append($("