.dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.5",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery);
--------------------------------------------------------------------------------
/app/js/clean-blog.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Clean Blog v1.0.0 (http://startbootstrap.com)
3 | * Copyright 2014 Start Bootstrap
4 | * Licensed under Apache 2.0 (https://github.com/IronSummitMedia/startbootstrap/blob/gh-pages/LICENSE)
5 | */
6 |
7 | // Contact Form Scripts
8 |
9 | $(function() {
10 |
11 | $("input,textarea").jqBootstrapValidation({
12 | preventSubmit: true,
13 | submitError: function($form, event, errors) {
14 | // additional error messages or events
15 | },
16 | submitSuccess: function($form, event) {
17 | event.preventDefault(); // prevent default submit behaviour
18 | // get values from FORM
19 | var name = $("input#name").val();
20 | var email = $("input#email").val();
21 | var phone = $("input#phone").val();
22 | var message = $("textarea#message").val();
23 | var firstName = name; // For Success/Failure Message
24 | // Check for white space in name for Success/Fail message
25 | if (firstName.indexOf(' ') >= 0) {
26 | firstName = name.split(' ').slice(0, -1).join(' ');
27 | }
28 | $.ajax({
29 | url: "././mail/contact_me.php",
30 | type: "POST",
31 | data: {
32 | name: name,
33 | phone: phone,
34 | email: email,
35 | message: message
36 | },
37 | cache: false,
38 | success: function() {
39 | // Success message
40 | $('#success').html("");
41 | $('#success > .alert-success').html("");
43 | $('#success > .alert-success')
44 | .append("Your message has been sent. ");
45 | $('#success > .alert-success')
46 | .append('
');
47 |
48 | //clear all fields
49 | $('#contactForm').trigger("reset");
50 | },
51 | error: function() {
52 | // Fail message
53 | $('#success').html("");
54 | $('#success > .alert-danger').html("");
56 | $('#success > .alert-danger').append("Sorry " + firstName + ", it seems that my mail server is not responding. Please try again later!");
57 | $('#success > .alert-danger').append('
');
58 | //clear all fields
59 | $('#contactForm').trigger("reset");
60 | },
61 | })
62 | },
63 | filter: function() {
64 | return $(this).is(":visible");
65 | },
66 | });
67 |
68 | $("a[data-toggle=\"tab\"]").click(function(e) {
69 | e.preventDefault();
70 | $(this).tab("show");
71 | });
72 | });
73 |
74 |
75 | /*When clicking on Full hide fail/success boxes */
76 | $('#name').focus(function() {
77 | $('#success').html('');
78 | });
79 |
80 | // jqBootstrapValidation
81 | // * A plugin for automating validation on Twitter Bootstrap formatted forms.
82 | // *
83 | // * v1.3.6
84 | // *
85 | // * License: MIT - see LICENSE file
86 | // *
87 | // * http://ReactiveRaven.github.com/jqBootstrapValidation/
88 |
89 |
90 | (function( $ ){
91 |
92 | var createdElements = [];
93 |
94 | var defaults = {
95 | options: {
96 | prependExistingHelpBlock: false,
97 | sniffHtml: true, // sniff for 'required', 'maxlength', etc
98 | preventSubmit: true, // stop the form submit event from firing if validation fails
99 | submitError: false, // function called if there is an error when trying to submit
100 | submitSuccess: false, // function called just before a successful submit event is sent to the server
101 | semanticallyStrict: false, // set to true to tidy up generated HTML output
102 | autoAdd: {
103 | helpBlocks: true
104 | },
105 | filter: function () {
106 | // return $(this).is(":visible"); // only validate elements you can see
107 | return true; // validate everything
108 | }
109 | },
110 | methods: {
111 | init : function( options ) {
112 |
113 | var settings = $.extend(true, {}, defaults);
114 |
115 | settings.options = $.extend(true, settings.options, options);
116 |
117 | var $siblingElements = this;
118 |
119 | var uniqueForms = $.unique(
120 | $siblingElements.map( function () {
121 | return $(this).parents("form")[0];
122 | }).toArray()
123 | );
124 |
125 | $(uniqueForms).bind("submit", function (e) {
126 | var $form = $(this);
127 | var warningsFound = 0;
128 | var $inputs = $form.find("input,textarea,select").not("[type=submit],[type=image]").filter(settings.options.filter);
129 | $inputs.trigger("submit.validation").trigger("validationLostFocus.validation");
130 |
131 | $inputs.each(function (i, el) {
132 | var $this = $(el),
133 | $controlGroup = $this.parents(".form-group").first();
134 | if (
135 | $controlGroup.hasClass("warning")
136 | ) {
137 | $controlGroup.removeClass("warning").addClass("error");
138 | warningsFound++;
139 | }
140 | });
141 |
142 | $inputs.trigger("validationLostFocus.validation");
143 |
144 | if (warningsFound) {
145 | if (settings.options.preventSubmit) {
146 | e.preventDefault();
147 | }
148 | $form.addClass("error");
149 | if ($.isFunction(settings.options.submitError)) {
150 | settings.options.submitError($form, e, $inputs.jqBootstrapValidation("collectErrors", true));
151 | }
152 | } else {
153 | $form.removeClass("error");
154 | if ($.isFunction(settings.options.submitSuccess)) {
155 | settings.options.submitSuccess($form, e);
156 | }
157 | }
158 | });
159 |
160 | return this.each(function(){
161 |
162 | // Get references to everything we're interested in
163 | var $this = $(this),
164 | $controlGroup = $this.parents(".form-group").first(),
165 | $helpBlock = $controlGroup.find(".help-block").first(),
166 | $form = $this.parents("form").first(),
167 | validatorNames = [];
168 |
169 | // create message container if not exists
170 | if (!$helpBlock.length && settings.options.autoAdd && settings.options.autoAdd.helpBlocks) {
171 | $helpBlock = $('');
172 | $controlGroup.find('.controls').append($helpBlock);
173 | createdElements.push($helpBlock[0]);
174 | }
175 |
176 | // =============================================================
177 | // SNIFF HTML FOR VALIDATORS
178 | // =============================================================
179 |
180 | // *snort sniff snuffle*
181 |
182 | if (settings.options.sniffHtml) {
183 | var message = "";
184 | // ---------------------------------------------------------
185 | // PATTERN
186 | // ---------------------------------------------------------
187 | if ($this.attr("pattern") !== undefined) {
188 | message = "Not in the expected format";
189 | if ($this.data("validationPatternMessage")) {
190 | message = $this.data("validationPatternMessage");
191 | }
192 | $this.data("validationPatternMessage", message);
193 | $this.data("validationPatternRegex", $this.attr("pattern"));
194 | }
195 | // ---------------------------------------------------------
196 | // MAX
197 | // ---------------------------------------------------------
198 | if ($this.attr("max") !== undefined || $this.attr("aria-valuemax") !== undefined) {
199 | var max = ($this.attr("max") !== undefined ? $this.attr("max") : $this.attr("aria-valuemax"));
200 | message = "Too high: Maximum of '" + max + "'";
201 | if ($this.data("validationMaxMessage")) {
202 | message = $this.data("validationMaxMessage");
203 | }
204 | $this.data("validationMaxMessage", message);
205 | $this.data("validationMaxMax", max);
206 | }
207 | // ---------------------------------------------------------
208 | // MIN
209 | // ---------------------------------------------------------
210 | if ($this.attr("min") !== undefined || $this.attr("aria-valuemin") !== undefined) {
211 | var min = ($this.attr("min") !== undefined ? $this.attr("min") : $this.attr("aria-valuemin"));
212 | message = "Too low: Minimum of '" + min + "'";
213 | if ($this.data("validationMinMessage")) {
214 | message = $this.data("validationMinMessage");
215 | }
216 | $this.data("validationMinMessage", message);
217 | $this.data("validationMinMin", min);
218 | }
219 | // ---------------------------------------------------------
220 | // MAXLENGTH
221 | // ---------------------------------------------------------
222 | if ($this.attr("maxlength") !== undefined) {
223 | message = "Too long: Maximum of '" + $this.attr("maxlength") + "' characters";
224 | if ($this.data("validationMaxlengthMessage")) {
225 | message = $this.data("validationMaxlengthMessage");
226 | }
227 | $this.data("validationMaxlengthMessage", message);
228 | $this.data("validationMaxlengthMaxlength", $this.attr("maxlength"));
229 | }
230 | // ---------------------------------------------------------
231 | // MINLENGTH
232 | // ---------------------------------------------------------
233 | if ($this.attr("minlength") !== undefined) {
234 | message = "Too short: Minimum of '" + $this.attr("minlength") + "' characters";
235 | if ($this.data("validationMinlengthMessage")) {
236 | message = $this.data("validationMinlengthMessage");
237 | }
238 | $this.data("validationMinlengthMessage", message);
239 | $this.data("validationMinlengthMinlength", $this.attr("minlength"));
240 | }
241 | // ---------------------------------------------------------
242 | // REQUIRED
243 | // ---------------------------------------------------------
244 | if ($this.attr("required") !== undefined || $this.attr("aria-required") !== undefined) {
245 | message = settings.builtInValidators.required.message;
246 | if ($this.data("validationRequiredMessage")) {
247 | message = $this.data("validationRequiredMessage");
248 | }
249 | $this.data("validationRequiredMessage", message);
250 | }
251 | // ---------------------------------------------------------
252 | // NUMBER
253 | // ---------------------------------------------------------
254 | if ($this.attr("type") !== undefined && $this.attr("type").toLowerCase() === "number") {
255 | message = settings.builtInValidators.number.message;
256 | if ($this.data("validationNumberMessage")) {
257 | message = $this.data("validationNumberMessage");
258 | }
259 | $this.data("validationNumberMessage", message);
260 | }
261 | // ---------------------------------------------------------
262 | // EMAIL
263 | // ---------------------------------------------------------
264 | if ($this.attr("type") !== undefined && $this.attr("type").toLowerCase() === "email") {
265 | message = "Not a valid email address";
266 | if ($this.data("validationValidemailMessage")) {
267 | message = $this.data("validationValidemailMessage");
268 | } else if ($this.data("validationEmailMessage")) {
269 | message = $this.data("validationEmailMessage");
270 | }
271 | $this.data("validationValidemailMessage", message);
272 | }
273 | // ---------------------------------------------------------
274 | // MINCHECKED
275 | // ---------------------------------------------------------
276 | if ($this.attr("minchecked") !== undefined) {
277 | message = "Not enough options checked; Minimum of '" + $this.attr("minchecked") + "' required";
278 | if ($this.data("validationMincheckedMessage")) {
279 | message = $this.data("validationMincheckedMessage");
280 | }
281 | $this.data("validationMincheckedMessage", message);
282 | $this.data("validationMincheckedMinchecked", $this.attr("minchecked"));
283 | }
284 | // ---------------------------------------------------------
285 | // MAXCHECKED
286 | // ---------------------------------------------------------
287 | if ($this.attr("maxchecked") !== undefined) {
288 | message = "Too many options checked; Maximum of '" + $this.attr("maxchecked") + "' required";
289 | if ($this.data("validationMaxcheckedMessage")) {
290 | message = $this.data("validationMaxcheckedMessage");
291 | }
292 | $this.data("validationMaxcheckedMessage", message);
293 | $this.data("validationMaxcheckedMaxchecked", $this.attr("maxchecked"));
294 | }
295 | }
296 |
297 | // =============================================================
298 | // COLLECT VALIDATOR NAMES
299 | // =============================================================
300 |
301 | // Get named validators
302 | if ($this.data("validation") !== undefined) {
303 | validatorNames = $this.data("validation").split(",");
304 | }
305 |
306 | // Get extra ones defined on the element's data attributes
307 | $.each($this.data(), function (i, el) {
308 | var parts = i.replace(/([A-Z])/g, ",$1").split(",");
309 | if (parts[0] === "validation" && parts[1]) {
310 | validatorNames.push(parts[1]);
311 | }
312 | });
313 |
314 | // =============================================================
315 | // NORMALISE VALIDATOR NAMES
316 | // =============================================================
317 |
318 | var validatorNamesToInspect = validatorNames;
319 | var newValidatorNamesToInspect = [];
320 |
321 | do // repeatedly expand 'shortcut' validators into their real validators
322 | {
323 | // Uppercase only the first letter of each name
324 | $.each(validatorNames, function (i, el) {
325 | validatorNames[i] = formatValidatorName(el);
326 | });
327 |
328 | // Remove duplicate validator names
329 | validatorNames = $.unique(validatorNames);
330 |
331 | // Pull out the new validator names from each shortcut
332 | newValidatorNamesToInspect = [];
333 | $.each(validatorNamesToInspect, function(i, el) {
334 | if ($this.data("validation" + el + "Shortcut") !== undefined) {
335 | // Are these custom validators?
336 | // Pull them out!
337 | $.each($this.data("validation" + el + "Shortcut").split(","), function(i2, el2) {
338 | newValidatorNamesToInspect.push(el2);
339 | });
340 | } else if (settings.builtInValidators[el.toLowerCase()]) {
341 | // Is this a recognised built-in?
342 | // Pull it out!
343 | var validator = settings.builtInValidators[el.toLowerCase()];
344 | if (validator.type.toLowerCase() === "shortcut") {
345 | $.each(validator.shortcut.split(","), function (i, el) {
346 | el = formatValidatorName(el);
347 | newValidatorNamesToInspect.push(el);
348 | validatorNames.push(el);
349 | });
350 | }
351 | }
352 | });
353 |
354 | validatorNamesToInspect = newValidatorNamesToInspect;
355 |
356 | } while (validatorNamesToInspect.length > 0)
357 |
358 | // =============================================================
359 | // SET UP VALIDATOR ARRAYS
360 | // =============================================================
361 |
362 | var validators = {};
363 |
364 | $.each(validatorNames, function (i, el) {
365 | // Set up the 'override' message
366 | var message = $this.data("validation" + el + "Message");
367 | var hasOverrideMessage = (message !== undefined);
368 | var foundValidator = false;
369 | message =
370 | (
371 | message
372 | ? message
373 | : "'" + el + "' validation failed "
374 | )
375 | ;
376 |
377 | $.each(
378 | settings.validatorTypes,
379 | function (validatorType, validatorTemplate) {
380 | if (validators[validatorType] === undefined) {
381 | validators[validatorType] = [];
382 | }
383 | if (!foundValidator && $this.data("validation" + el + formatValidatorName(validatorTemplate.name)) !== undefined) {
384 | validators[validatorType].push(
385 | $.extend(
386 | true,
387 | {
388 | name: formatValidatorName(validatorTemplate.name),
389 | message: message
390 | },
391 | validatorTemplate.init($this, el)
392 | )
393 | );
394 | foundValidator = true;
395 | }
396 | }
397 | );
398 |
399 | if (!foundValidator && settings.builtInValidators[el.toLowerCase()]) {
400 |
401 | var validator = $.extend(true, {}, settings.builtInValidators[el.toLowerCase()]);
402 | if (hasOverrideMessage) {
403 | validator.message = message;
404 | }
405 | var validatorType = validator.type.toLowerCase();
406 |
407 | if (validatorType === "shortcut") {
408 | foundValidator = true;
409 | } else {
410 | $.each(
411 | settings.validatorTypes,
412 | function (validatorTemplateType, validatorTemplate) {
413 | if (validators[validatorTemplateType] === undefined) {
414 | validators[validatorTemplateType] = [];
415 | }
416 | if (!foundValidator && validatorType === validatorTemplateType.toLowerCase()) {
417 | $this.data("validation" + el + formatValidatorName(validatorTemplate.name), validator[validatorTemplate.name.toLowerCase()]);
418 | validators[validatorType].push(
419 | $.extend(
420 | validator,
421 | validatorTemplate.init($this, el)
422 | )
423 | );
424 | foundValidator = true;
425 | }
426 | }
427 | );
428 | }
429 | }
430 |
431 | if (! foundValidator) {
432 | $.error("Cannot find validation info for '" + el + "'");
433 | }
434 | });
435 |
436 | // =============================================================
437 | // STORE FALLBACK VALUES
438 | // =============================================================
439 |
440 | $helpBlock.data(
441 | "original-contents",
442 | (
443 | $helpBlock.data("original-contents")
444 | ? $helpBlock.data("original-contents")
445 | : $helpBlock.html()
446 | )
447 | );
448 |
449 | $helpBlock.data(
450 | "original-role",
451 | (
452 | $helpBlock.data("original-role")
453 | ? $helpBlock.data("original-role")
454 | : $helpBlock.attr("role")
455 | )
456 | );
457 |
458 | $controlGroup.data(
459 | "original-classes",
460 | (
461 | $controlGroup.data("original-clases")
462 | ? $controlGroup.data("original-classes")
463 | : $controlGroup.attr("class")
464 | )
465 | );
466 |
467 | $this.data(
468 | "original-aria-invalid",
469 | (
470 | $this.data("original-aria-invalid")
471 | ? $this.data("original-aria-invalid")
472 | : $this.attr("aria-invalid")
473 | )
474 | );
475 |
476 | // =============================================================
477 | // VALIDATION
478 | // =============================================================
479 |
480 | $this.bind(
481 | "validation.validation",
482 | function (event, params) {
483 |
484 | var value = getValue($this);
485 |
486 | // Get a list of the errors to apply
487 | var errorsFound = [];
488 |
489 | $.each(validators, function (validatorType, validatorTypeArray) {
490 | if (value || value.length || (params && params.includeEmpty) || (!!settings.validatorTypes[validatorType].blockSubmit && params && !!params.submitting)) {
491 | $.each(validatorTypeArray, function (i, validator) {
492 | if (settings.validatorTypes[validatorType].validate($this, value, validator)) {
493 | errorsFound.push(validator.message);
494 | }
495 | });
496 | }
497 | });
498 |
499 | return errorsFound;
500 | }
501 | );
502 |
503 | $this.bind(
504 | "getValidators.validation",
505 | function () {
506 | return validators;
507 | }
508 | );
509 |
510 | // =============================================================
511 | // WATCH FOR CHANGES
512 | // =============================================================
513 | $this.bind(
514 | "submit.validation",
515 | function () {
516 | return $this.triggerHandler("change.validation", {submitting: true});
517 | }
518 | );
519 | $this.bind(
520 | [
521 | "keyup",
522 | "focus",
523 | "blur",
524 | "click",
525 | "keydown",
526 | "keypress",
527 | "change"
528 | ].join(".validation ") + ".validation",
529 | function (e, params) {
530 |
531 | var value = getValue($this);
532 |
533 | var errorsFound = [];
534 |
535 | $controlGroup.find("input,textarea,select").each(function (i, el) {
536 | var oldCount = errorsFound.length;
537 | $.each($(el).triggerHandler("validation.validation", params), function (j, message) {
538 | errorsFound.push(message);
539 | });
540 | if (errorsFound.length > oldCount) {
541 | $(el).attr("aria-invalid", "true");
542 | } else {
543 | var original = $this.data("original-aria-invalid");
544 | $(el).attr("aria-invalid", (original !== undefined ? original : false));
545 | }
546 | });
547 |
548 | $form.find("input,select,textarea").not($this).not("[name=\"" + $this.attr("name") + "\"]").trigger("validationLostFocus.validation");
549 |
550 | errorsFound = $.unique(errorsFound.sort());
551 |
552 | // Were there any errors?
553 | if (errorsFound.length) {
554 | // Better flag it up as a warning.
555 | $controlGroup.removeClass("success error").addClass("warning");
556 |
557 | // How many errors did we find?
558 | if (settings.options.semanticallyStrict && errorsFound.length === 1) {
559 | // Only one? Being strict? Just output it.
560 | $helpBlock.html(errorsFound[0] +
561 | ( settings.options.prependExistingHelpBlock ? $helpBlock.data("original-contents") : "" ));
562 | } else {
563 | // Multiple? Being sloppy? Glue them together into an UL.
564 | $helpBlock.html("- " + errorsFound.join("
- ") + "
" +
565 | ( settings.options.prependExistingHelpBlock ? $helpBlock.data("original-contents") : "" ));
566 | }
567 | } else {
568 | $controlGroup.removeClass("warning error success");
569 | if (value.length > 0) {
570 | $controlGroup.addClass("success");
571 | }
572 | $helpBlock.html($helpBlock.data("original-contents"));
573 | }
574 |
575 | if (e.type === "blur") {
576 | $controlGroup.removeClass("success");
577 | }
578 | }
579 | );
580 | $this.bind("validationLostFocus.validation", function () {
581 | $controlGroup.removeClass("success");
582 | });
583 | });
584 | },
585 | destroy : function( ) {
586 |
587 | return this.each(
588 | function() {
589 |
590 | var
591 | $this = $(this),
592 | $controlGroup = $this.parents(".form-group").first(),
593 | $helpBlock = $controlGroup.find(".help-block").first();
594 |
595 | // remove our events
596 | $this.unbind('.validation'); // events are namespaced.
597 | // reset help text
598 | $helpBlock.html($helpBlock.data("original-contents"));
599 | // reset classes
600 | $controlGroup.attr("class", $controlGroup.data("original-classes"));
601 | // reset aria
602 | $this.attr("aria-invalid", $this.data("original-aria-invalid"));
603 | // reset role
604 | $helpBlock.attr("role", $this.data("original-role"));
605 | // remove all elements we created
606 | if (createdElements.indexOf($helpBlock[0]) > -1) {
607 | $helpBlock.remove();
608 | }
609 |
610 | }
611 | );
612 |
613 | },
614 | collectErrors : function(includeEmpty) {
615 |
616 | var errorMessages = {};
617 | this.each(function (i, el) {
618 | var $el = $(el);
619 | var name = $el.attr("name");
620 | var errors = $el.triggerHandler("validation.validation", {includeEmpty: true});
621 | errorMessages[name] = $.extend(true, errors, errorMessages[name]);
622 | });
623 |
624 | $.each(errorMessages, function (i, el) {
625 | if (el.length === 0) {
626 | delete errorMessages[i];
627 | }
628 | });
629 |
630 | return errorMessages;
631 |
632 | },
633 | hasErrors: function() {
634 |
635 | var errorMessages = [];
636 |
637 | this.each(function (i, el) {
638 | errorMessages = errorMessages.concat(
639 | $(el).triggerHandler("getValidators.validation") ? $(el).triggerHandler("validation.validation", {submitting: true}) : []
640 | );
641 | });
642 |
643 | return (errorMessages.length > 0);
644 | },
645 | override : function (newDefaults) {
646 | defaults = $.extend(true, defaults, newDefaults);
647 | }
648 | },
649 | validatorTypes: {
650 | callback: {
651 | name: "callback",
652 | init: function ($this, name) {
653 | return {
654 | validatorName: name,
655 | callback: $this.data("validation" + name + "Callback"),
656 | lastValue: $this.val(),
657 | lastValid: true,
658 | lastFinished: true
659 | };
660 | },
661 | validate: function ($this, value, validator) {
662 | if (validator.lastValue === value && validator.lastFinished) {
663 | return !validator.lastValid;
664 | }
665 |
666 | if (validator.lastFinished === true)
667 | {
668 | validator.lastValue = value;
669 | validator.lastValid = true;
670 | validator.lastFinished = false;
671 |
672 | var rrjqbvValidator = validator;
673 | var rrjqbvThis = $this;
674 | executeFunctionByName(
675 | validator.callback,
676 | window,
677 | $this,
678 | value,
679 | function (data) {
680 | if (rrjqbvValidator.lastValue === data.value) {
681 | rrjqbvValidator.lastValid = data.valid;
682 | if (data.message) {
683 | rrjqbvValidator.message = data.message;
684 | }
685 | rrjqbvValidator.lastFinished = true;
686 | rrjqbvThis.data("validation" + rrjqbvValidator.validatorName + "Message", rrjqbvValidator.message);
687 | // Timeout is set to avoid problems with the events being considered 'already fired'
688 | setTimeout(function () {
689 | rrjqbvThis.trigger("change.validation");
690 | }, 1); // doesn't need a long timeout, just long enough for the event bubble to burst
691 | }
692 | }
693 | );
694 | }
695 |
696 | return false;
697 |
698 | }
699 | },
700 | ajax: {
701 | name: "ajax",
702 | init: function ($this, name) {
703 | return {
704 | validatorName: name,
705 | url: $this.data("validation" + name + "Ajax"),
706 | lastValue: $this.val(),
707 | lastValid: true,
708 | lastFinished: true
709 | };
710 | },
711 | validate: function ($this, value, validator) {
712 | if (""+validator.lastValue === ""+value && validator.lastFinished === true) {
713 | return validator.lastValid === false;
714 | }
715 |
716 | if (validator.lastFinished === true)
717 | {
718 | validator.lastValue = value;
719 | validator.lastValid = true;
720 | validator.lastFinished = false;
721 | $.ajax({
722 | url: validator.url,
723 | data: "value=" + value + "&field=" + $this.attr("name"),
724 | dataType: "json",
725 | success: function (data) {
726 | if (""+validator.lastValue === ""+data.value) {
727 | validator.lastValid = !!(data.valid);
728 | if (data.message) {
729 | validator.message = data.message;
730 | }
731 | validator.lastFinished = true;
732 | $this.data("validation" + validator.validatorName + "Message", validator.message);
733 | // Timeout is set to avoid problems with the events being considered 'already fired'
734 | setTimeout(function () {
735 | $this.trigger("change.validation");
736 | }, 1); // doesn't need a long timeout, just long enough for the event bubble to burst
737 | }
738 | },
739 | failure: function () {
740 | validator.lastValid = true;
741 | validator.message = "ajax call failed";
742 | validator.lastFinished = true;
743 | $this.data("validation" + validator.validatorName + "Message", validator.message);
744 | // Timeout is set to avoid problems with the events being considered 'already fired'
745 | setTimeout(function () {
746 | $this.trigger("change.validation");
747 | }, 1); // doesn't need a long timeout, just long enough for the event bubble to burst
748 | }
749 | });
750 | }
751 |
752 | return false;
753 |
754 | }
755 | },
756 | regex: {
757 | name: "regex",
758 | init: function ($this, name) {
759 | return {regex: regexFromString($this.data("validation" + name + "Regex"))};
760 | },
761 | validate: function ($this, value, validator) {
762 | return (!validator.regex.test(value) && ! validator.negative)
763 | || (validator.regex.test(value) && validator.negative);
764 | }
765 | },
766 | required: {
767 | name: "required",
768 | init: function ($this, name) {
769 | return {};
770 | },
771 | validate: function ($this, value, validator) {
772 | return !!(value.length === 0 && ! validator.negative)
773 | || !!(value.length > 0 && validator.negative);
774 | },
775 | blockSubmit: true
776 | },
777 | match: {
778 | name: "match",
779 | init: function ($this, name) {
780 | var element = $this.parents("form").first().find("[name=\"" + $this.data("validation" + name + "Match") + "\"]").first();
781 | element.bind("validation.validation", function () {
782 | $this.trigger("change.validation", {submitting: true});
783 | });
784 | return {"element": element};
785 | },
786 | validate: function ($this, value, validator) {
787 | return (value !== validator.element.val() && ! validator.negative)
788 | || (value === validator.element.val() && validator.negative);
789 | },
790 | blockSubmit: true
791 | },
792 | max: {
793 | name: "max",
794 | init: function ($this, name) {
795 | return {max: $this.data("validation" + name + "Max")};
796 | },
797 | validate: function ($this, value, validator) {
798 | return (parseFloat(value, 10) > parseFloat(validator.max, 10) && ! validator.negative)
799 | || (parseFloat(value, 10) <= parseFloat(validator.max, 10) && validator.negative);
800 | }
801 | },
802 | min: {
803 | name: "min",
804 | init: function ($this, name) {
805 | return {min: $this.data("validation" + name + "Min")};
806 | },
807 | validate: function ($this, value, validator) {
808 | return (parseFloat(value) < parseFloat(validator.min) && ! validator.negative)
809 | || (parseFloat(value) >= parseFloat(validator.min) && validator.negative);
810 | }
811 | },
812 | maxlength: {
813 | name: "maxlength",
814 | init: function ($this, name) {
815 | return {maxlength: $this.data("validation" + name + "Maxlength")};
816 | },
817 | validate: function ($this, value, validator) {
818 | return ((value.length > validator.maxlength) && ! validator.negative)
819 | || ((value.length <= validator.maxlength) && validator.negative);
820 | }
821 | },
822 | minlength: {
823 | name: "minlength",
824 | init: function ($this, name) {
825 | return {minlength: $this.data("validation" + name + "Minlength")};
826 | },
827 | validate: function ($this, value, validator) {
828 | return ((value.length < validator.minlength) && ! validator.negative)
829 | || ((value.length >= validator.minlength) && validator.negative);
830 | }
831 | },
832 | maxchecked: {
833 | name: "maxchecked",
834 | init: function ($this, name) {
835 | var elements = $this.parents("form").first().find("[name=\"" + $this.attr("name") + "\"]");
836 | elements.bind("click.validation", function () {
837 | $this.trigger("change.validation", {includeEmpty: true});
838 | });
839 | return {maxchecked: $this.data("validation" + name + "Maxchecked"), elements: elements};
840 | },
841 | validate: function ($this, value, validator) {
842 | return (validator.elements.filter(":checked").length > validator.maxchecked && ! validator.negative)
843 | || (validator.elements.filter(":checked").length <= validator.maxchecked && validator.negative);
844 | },
845 | blockSubmit: true
846 | },
847 | minchecked: {
848 | name: "minchecked",
849 | init: function ($this, name) {
850 | var elements = $this.parents("form").first().find("[name=\"" + $this.attr("name") + "\"]");
851 | elements.bind("click.validation", function () {
852 | $this.trigger("change.validation", {includeEmpty: true});
853 | });
854 | return {minchecked: $this.data("validation" + name + "Minchecked"), elements: elements};
855 | },
856 | validate: function ($this, value, validator) {
857 | return (validator.elements.filter(":checked").length < validator.minchecked && ! validator.negative)
858 | || (validator.elements.filter(":checked").length >= validator.minchecked && validator.negative);
859 | },
860 | blockSubmit: true
861 | }
862 | },
863 | builtInValidators: {
864 | email: {
865 | name: "Email",
866 | type: "shortcut",
867 | shortcut: "validemail"
868 | },
869 | validemail: {
870 | name: "Validemail",
871 | type: "regex",
872 | regex: "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\.[A-Za-z]{2,4}",
873 | message: "Not a valid email address"
874 | },
875 | passwordagain: {
876 | name: "Passwordagain",
877 | type: "match",
878 | match: "password",
879 | message: "Does not match the given password"
880 | },
881 | positive: {
882 | name: "Positive",
883 | type: "shortcut",
884 | shortcut: "number,positivenumber"
885 | },
886 | negative: {
887 | name: "Negative",
888 | type: "shortcut",
889 | shortcut: "number,negativenumber"
890 | },
891 | number: {
892 | name: "Number",
893 | type: "regex",
894 | regex: "([+-]?\\\d+(\\\.\\\d*)?([eE][+-]?[0-9]+)?)?",
895 | message: "Must be a number"
896 | },
897 | integer: {
898 | name: "Integer",
899 | type: "regex",
900 | regex: "[+-]?\\\d+",
901 | message: "No decimal places allowed"
902 | },
903 | positivenumber: {
904 | name: "Positivenumber",
905 | type: "min",
906 | min: 0,
907 | message: "Must be a positive number"
908 | },
909 | negativenumber: {
910 | name: "Negativenumber",
911 | type: "max",
912 | max: 0,
913 | message: "Must be a negative number"
914 | },
915 | required: {
916 | name: "Required",
917 | type: "required",
918 | message: "This is required"
919 | },
920 | checkone: {
921 | name: "Checkone",
922 | type: "minchecked",
923 | minchecked: 1,
924 | message: "Check at least one option"
925 | }
926 | }
927 | };
928 |
929 | var formatValidatorName = function (name) {
930 | return name
931 | .toLowerCase()
932 | .replace(
933 | /(^|\s)([a-z])/g ,
934 | function(m,p1,p2) {
935 | return p1+p2.toUpperCase();
936 | }
937 | )
938 | ;
939 | };
940 |
941 | var getValue = function ($this) {
942 | // Extract the value we're talking about
943 | var value = $this.val();
944 | var type = $this.attr("type");
945 | if (type === "checkbox") {
946 | value = ($this.is(":checked") ? value : "");
947 | }
948 | if (type === "radio") {
949 | value = ($('input[name="' + $this.attr("name") + '"]:checked').length > 0 ? value : "");
950 | }
951 | return value;
952 | };
953 |
954 | function regexFromString(inputstring) {
955 | return new RegExp("^" + inputstring + "$");
956 | }
957 |
958 | /**
959 | * Thanks to Jason Bunting via StackOverflow.com
960 | *
961 | * http://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string#answer-359910
962 | * Short link: http://tinyurl.com/executeFunctionByName
963 | **/
964 | function executeFunctionByName(functionName, context /*, args*/) {
965 | var args = Array.prototype.slice.call(arguments).splice(2);
966 | var namespaces = functionName.split(".");
967 | var func = namespaces.pop();
968 | for(var i = 0; i < namespaces.length; i++) {
969 | context = context[namespaces[i]];
970 | }
971 | return context[func].apply(this, args);
972 | }
973 |
974 | $.fn.jqBootstrapValidation = function( method ) {
975 |
976 | if ( defaults.methods[method] ) {
977 | return defaults.methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
978 | } else if ( typeof method === 'object' || ! method ) {
979 | return defaults.methods.init.apply( this, arguments );
980 | } else {
981 | $.error( 'Method ' + method + ' does not exist on jQuery.jqBootstrapValidation' );
982 | return null;
983 | }
984 |
985 | };
986 |
987 | $.jqBootstrapValidation = function (options) {
988 | $(":input").not("[type=image],[type=submit]").jqBootstrapValidation.apply(this,arguments);
989 | };
990 |
991 | })( jQuery );
992 |
993 | // Floating label headings for the contact form
994 | $(function() {
995 | $("body").on("input propertychange", ".floating-label-form-group", function(e) {
996 | $(this).toggleClass("floating-label-form-group-with-value", !!$(e.target).val());
997 | }).on("focus", ".floating-label-form-group", function() {
998 | $(this).addClass("floating-label-form-group-with-focus");
999 | }).on("blur", ".floating-label-form-group", function() {
1000 | $(this).removeClass("floating-label-form-group-with-focus");
1001 | });
1002 | });
1003 |
1004 | // Navigation Scripts to Show Header on Scroll-Up
1005 | jQuery(document).ready(function($) {
1006 | var MQL = 1170;
1007 |
1008 | //primary navigation slide-in effect
1009 | if ($(window).width() > MQL) {
1010 | var headerHeight = $('.navbar-custom').height();
1011 | $(window).on('scroll', {
1012 | previousTop: 0
1013 | },
1014 | function() {
1015 | var currentTop = $(window).scrollTop();
1016 | //check if user is scrolling up
1017 | if (currentTop < this.previousTop) {
1018 | //if scrolling up...
1019 | if (currentTop > 0 && $('.navbar-custom').hasClass('is-fixed')) {
1020 | $('.navbar-custom').addClass('is-visible');
1021 | } else {
1022 | $('.navbar-custom').removeClass('is-visible is-fixed');
1023 | }
1024 | } else {
1025 | //if scrolling down...
1026 | $('.navbar-custom').removeClass('is-visible');
1027 | if (currentTop > headerHeight && !$('.navbar-custom').hasClass('is-fixed')) $('.navbar-custom').addClass('is-fixed');
1028 | }
1029 | this.previousTop = currentTop;
1030 | });
1031 | }
1032 | });
1033 |
--------------------------------------------------------------------------------
/app/js/clean-blog.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Clean Blog v1.0.0 (http://startbootstrap.com)
3 | * Copyright 2014 Start Bootstrap
4 | * Licensed under Apache 2.0 (https://github.com/IronSummitMedia/startbootstrap/blob/gh-pages/LICENSE)
5 | */
6 |
7 | $(function(){$("input,textarea").jqBootstrapValidation({preventSubmit:!0,submitError:function(){},submitSuccess:function(a,b){b.preventDefault();var c=$("input#name").val(),d=$("input#email").val(),e=$("input#phone").val(),f=$("textarea#message").val(),g=c;g.indexOf(" ")>=0&&(g=c.split(" ").slice(0,-1).join(" ")),$.ajax({url:"././mail/contact_me.php",type:"POST",data:{name:c,phone:e,email:d,message:f},cache:!1,success:function(){$("#success").html(""),$("#success > .alert-success").html(""),$("#success > .alert-success").append("Your message has been sent. "),$("#success > .alert-success").append("
"),$("#contactForm").trigger("reset")},error:function(){$("#success").html(""),$("#success > .alert-danger").html(""),$("#success > .alert-danger").append("Sorry "+g+", it seems that my mail server is not responding. Please try again later!"),$("#success > .alert-danger").append("
"),$("#contactForm").trigger("reset")}})},filter:function(){return $(this).is(":visible")}}),$('a[data-toggle="tab"]').click(function(a){a.preventDefault(),$(this).tab("show")})}),$("#name").focus(function(){$("#success").html("")}),function(a){function b(a){return new RegExp("^"+a+"$")}function c(a,b){for(var c=Array.prototype.slice.call(arguments).splice(2),d=a.split("."),e=d.pop(),f=0;f'),e.find(".controls").append(h),d.push(h[0])),c.options.sniffHtml){var k="";if(void 0!==b.attr("pattern")&&(k="Not in the expected format",b.data("validationPatternMessage")&&(k=b.data("validationPatternMessage")),b.data("validationPatternMessage",k),b.data("validationPatternRegex",b.attr("pattern"))),void 0!==b.attr("max")||void 0!==b.attr("aria-valuemax")){var l=b.attr(void 0!==b.attr("max")?"max":"aria-valuemax");k="Too high: Maximum of '"+l+"'",b.data("validationMaxMessage")&&(k=b.data("validationMaxMessage")),b.data("validationMaxMessage",k),b.data("validationMaxMax",l)}if(void 0!==b.attr("min")||void 0!==b.attr("aria-valuemin")){var m=b.attr(void 0!==b.attr("min")?"min":"aria-valuemin");k="Too low: Minimum of '"+m+"'",b.data("validationMinMessage")&&(k=b.data("validationMinMessage")),b.data("validationMinMessage",k),b.data("validationMinMin",m)}void 0!==b.attr("maxlength")&&(k="Too long: Maximum of '"+b.attr("maxlength")+"' characters",b.data("validationMaxlengthMessage")&&(k=b.data("validationMaxlengthMessage")),b.data("validationMaxlengthMessage",k),b.data("validationMaxlengthMaxlength",b.attr("maxlength"))),void 0!==b.attr("minlength")&&(k="Too short: Minimum of '"+b.attr("minlength")+"' characters",b.data("validationMinlengthMessage")&&(k=b.data("validationMinlengthMessage")),b.data("validationMinlengthMessage",k),b.data("validationMinlengthMinlength",b.attr("minlength"))),(void 0!==b.attr("required")||void 0!==b.attr("aria-required"))&&(k=c.builtInValidators.required.message,b.data("validationRequiredMessage")&&(k=b.data("validationRequiredMessage")),b.data("validationRequiredMessage",k)),void 0!==b.attr("type")&&"number"===b.attr("type").toLowerCase()&&(k=c.builtInValidators.number.message,b.data("validationNumberMessage")&&(k=b.data("validationNumberMessage")),b.data("validationNumberMessage",k)),void 0!==b.attr("type")&&"email"===b.attr("type").toLowerCase()&&(k="Not a valid email address",b.data("validationValidemailMessage")?k=b.data("validationValidemailMessage"):b.data("validationEmailMessage")&&(k=b.data("validationEmailMessage")),b.data("validationValidemailMessage",k)),void 0!==b.attr("minchecked")&&(k="Not enough options checked; Minimum of '"+b.attr("minchecked")+"' required",b.data("validationMincheckedMessage")&&(k=b.data("validationMincheckedMessage")),b.data("validationMincheckedMessage",k),b.data("validationMincheckedMinchecked",b.attr("minchecked"))),void 0!==b.attr("maxchecked")&&(k="Too many options checked; Maximum of '"+b.attr("maxchecked")+"' required",b.data("validationMaxcheckedMessage")&&(k=b.data("validationMaxcheckedMessage")),b.data("validationMaxcheckedMessage",k),b.data("validationMaxcheckedMaxchecked",b.attr("maxchecked")))}void 0!==b.data("validation")&&(j=b.data("validation").split(",")),a.each(b.data(),function(a){var b=a.replace(/([A-Z])/g,",$1").split(",");"validation"===b[0]&&b[1]&&j.push(b[1])});var n=j,o=[];do a.each(j,function(a,b){j[a]=f(b)}),j=a.unique(j),o=[],a.each(n,function(d,e){if(void 0!==b.data("validation"+e+"Shortcut"))a.each(b.data("validation"+e+"Shortcut").split(","),function(a,b){o.push(b)});else if(c.builtInValidators[e.toLowerCase()]){var g=c.builtInValidators[e.toLowerCase()];"shortcut"===g.type.toLowerCase()&&a.each(g.shortcut.split(","),function(a,b){b=f(b),o.push(b),j.push(b)})}}),n=o;while(n.length>0);var p={};a.each(j,function(d,e){var g=b.data("validation"+e+"Message"),h=void 0!==g,i=!1;if(g=g?g:"'"+e+"' validation failed ",a.each(c.validatorTypes,function(c,d){void 0===p[c]&&(p[c]=[]),i||void 0===b.data("validation"+e+f(d.name))||(p[c].push(a.extend(!0,{name:f(d.name),message:g},d.init(b,e))),i=!0)}),!i&&c.builtInValidators[e.toLowerCase()]){var j=a.extend(!0,{},c.builtInValidators[e.toLowerCase()]);h&&(j.message=g);var k=j.type.toLowerCase();"shortcut"===k?i=!0:a.each(c.validatorTypes,function(c,d){void 0===p[c]&&(p[c]=[]),i||k!==c.toLowerCase()||(b.data("validation"+e+f(d.name),j[d.name.toLowerCase()]),p[k].push(a.extend(j,d.init(b,e))),i=!0)})}i||a.error("Cannot find validation info for '"+e+"'")}),h.data("original-contents",h.data("original-contents")?h.data("original-contents"):h.html()),h.data("original-role",h.data("original-role")?h.data("original-role"):h.attr("role")),e.data("original-classes",e.data("original-clases")?e.data("original-classes"):e.attr("class")),b.data("original-aria-invalid",b.data("original-aria-invalid")?b.data("original-aria-invalid"):b.attr("aria-invalid")),b.bind("validation.validation",function(d,e){var f=g(b),h=[];return a.each(p,function(d,g){(f||f.length||e&&e.includeEmpty||c.validatorTypes[d].blockSubmit&&e&&e.submitting)&&a.each(g,function(a,e){c.validatorTypes[d].validate(b,f,e)&&h.push(e.message)})}),h}),b.bind("getValidators.validation",function(){return p}),b.bind("submit.validation",function(){return b.triggerHandler("change.validation",{submitting:!0})}),b.bind(["keyup","focus","blur","click","keydown","keypress","change"].join(".validation ")+".validation",function(d,f){var j=g(b),k=[];e.find("input,textarea,select").each(function(c,d){var e=k.length;if(a.each(a(d).triggerHandler("validation.validation",f),function(a,b){k.push(b)}),k.length>e)a(d).attr("aria-invalid","true");else{var g=b.data("original-aria-invalid");a(d).attr("aria-invalid",void 0!==g?g:!1)}}),i.find("input,select,textarea").not(b).not('[name="'+b.attr("name")+'"]').trigger("validationLostFocus.validation"),k=a.unique(k.sort()),k.length?(e.removeClass("success error").addClass("warning"),h.html(c.options.semanticallyStrict&&1===k.length?k[0]+(c.options.prependExistingHelpBlock?h.data("original-contents"):""):'"+(c.options.prependExistingHelpBlock?h.data("original-contents"):""))):(e.removeClass("warning error success"),j.length>0&&e.addClass("success"),h.html(h.data("original-contents"))),"blur"===d.type&&e.removeClass("success")}),b.bind("validationLostFocus.validation",function(){e.removeClass("success")})})},destroy:function(){return this.each(function(){var b=a(this),c=b.parents(".form-group").first(),e=c.find(".help-block").first();b.unbind(".validation"),e.html(e.data("original-contents")),c.attr("class",c.data("original-classes")),b.attr("aria-invalid",b.data("original-aria-invalid")),e.attr("role",b.data("original-role")),d.indexOf(e[0])>-1&&e.remove()})},collectErrors:function(){var b={};return this.each(function(c,d){var e=a(d),f=e.attr("name"),g=e.triggerHandler("validation.validation",{includeEmpty:!0});b[f]=a.extend(!0,g,b[f])}),a.each(b,function(a,c){0===c.length&&delete b[a]}),b},hasErrors:function(){var b=[];return this.each(function(c,d){b=b.concat(a(d).triggerHandler("getValidators.validation")?a(d).triggerHandler("validation.validation",{submitting:!0}):[])}),b.length>0},override:function(b){e=a.extend(!0,e,b)}},validatorTypes:{callback:{name:"callback",init:function(a,b){return{validatorName:b,callback:a.data("validation"+b+"Callback"),lastValue:a.val(),lastValid:!0,lastFinished:!0}},validate:function(a,b,d){if(d.lastValue===b&&d.lastFinished)return!d.lastValid;if(d.lastFinished===!0){d.lastValue=b,d.lastValid=!0,d.lastFinished=!1;var e=d,f=a;c(d.callback,window,a,b,function(a){e.lastValue===a.value&&(e.lastValid=a.valid,a.message&&(e.message=a.message),e.lastFinished=!0,f.data("validation"+e.validatorName+"Message",e.message),setTimeout(function(){f.trigger("change.validation")},1))})}return!1}},ajax:{name:"ajax",init:function(a,b){return{validatorName:b,url:a.data("validation"+b+"Ajax"),lastValue:a.val(),lastValid:!0,lastFinished:!0}},validate:function(b,c,d){return""+d.lastValue==""+c&&d.lastFinished===!0?d.lastValid===!1:(d.lastFinished===!0&&(d.lastValue=c,d.lastValid=!0,d.lastFinished=!1,a.ajax({url:d.url,data:"value="+c+"&field="+b.attr("name"),dataType:"json",success:function(a){""+d.lastValue==""+a.value&&(d.lastValid=!!a.valid,a.message&&(d.message=a.message),d.lastFinished=!0,b.data("validation"+d.validatorName+"Message",d.message),setTimeout(function(){b.trigger("change.validation")},1))},failure:function(){d.lastValid=!0,d.message="ajax call failed",d.lastFinished=!0,b.data("validation"+d.validatorName+"Message",d.message),setTimeout(function(){b.trigger("change.validation")},1)}})),!1)}},regex:{name:"regex",init:function(a,c){return{regex:b(a.data("validation"+c+"Regex"))}},validate:function(a,b,c){return!c.regex.test(b)&&!c.negative||c.regex.test(b)&&c.negative}},required:{name:"required",init:function(){return{}},validate:function(a,b,c){return!(0!==b.length||c.negative)||!!(b.length>0&&c.negative)},blockSubmit:!0},match:{name:"match",init:function(a,b){var c=a.parents("form").first().find('[name="'+a.data("validation"+b+"Match")+'"]').first();return c.bind("validation.validation",function(){a.trigger("change.validation",{submitting:!0})}),{element:c}},validate:function(a,b,c){return b!==c.element.val()&&!c.negative||b===c.element.val()&&c.negative},blockSubmit:!0},max:{name:"max",init:function(a,b){return{max:a.data("validation"+b+"Max")}},validate:function(a,b,c){return parseFloat(b,10)>parseFloat(c.max,10)&&!c.negative||parseFloat(b,10)<=parseFloat(c.max,10)&&c.negative}},min:{name:"min",init:function(a,b){return{min:a.data("validation"+b+"Min")}},validate:function(a,b,c){return parseFloat(b)=parseFloat(c.min)&&c.negative}},maxlength:{name:"maxlength",init:function(a,b){return{maxlength:a.data("validation"+b+"Maxlength")}},validate:function(a,b,c){return b.length>c.maxlength&&!c.negative||b.length<=c.maxlength&&c.negative}},minlength:{name:"minlength",init:function(a,b){return{minlength:a.data("validation"+b+"Minlength")}},validate:function(a,b,c){return b.length=c.minlength&&c.negative}},maxchecked:{name:"maxchecked",init:function(a,b){var c=a.parents("form").first().find('[name="'+a.attr("name")+'"]');return c.bind("click.validation",function(){a.trigger("change.validation",{includeEmpty:!0})}),{maxchecked:a.data("validation"+b+"Maxchecked"),elements:c}},validate:function(a,b,c){return c.elements.filter(":checked").length>c.maxchecked&&!c.negative||c.elements.filter(":checked").length<=c.maxchecked&&c.negative},blockSubmit:!0},minchecked:{name:"minchecked",init:function(a,b){var c=a.parents("form").first().find('[name="'+a.attr("name")+'"]');return c.bind("click.validation",function(){a.trigger("change.validation",{includeEmpty:!0})}),{minchecked:a.data("validation"+b+"Minchecked"),elements:c}},validate:function(a,b,c){return c.elements.filter(":checked").length=c.minchecked&&c.negative},blockSubmit:!0}},builtInValidators:{email:{name:"Email",type:"shortcut",shortcut:"validemail"},validemail:{name:"Validemail",type:"regex",regex:"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}",message:"Not a valid email address"},passwordagain:{name:"Passwordagain",type:"match",match:"password",message:"Does not match the given password"},positive:{name:"Positive",type:"shortcut",shortcut:"number,positivenumber"},negative:{name:"Negative",type:"shortcut",shortcut:"number,negativenumber"},number:{name:"Number",type:"regex",regex:"([+-]?\\d+(\\.\\d*)?([eE][+-]?[0-9]+)?)?",message:"Must be a number"},integer:{name:"Integer",type:"regex",regex:"[+-]?\\d+",message:"No decimal places allowed"},positivenumber:{name:"Positivenumber",type:"min",min:0,message:"Must be a positive number"},negativenumber:{name:"Negativenumber",type:"max",max:0,message:"Must be a negative number"},required:{name:"Required",type:"required",message:"This is required"},checkone:{name:"Checkone",type:"minchecked",minchecked:1,message:"Check at least one option"}}},f=function(a){return a.toLowerCase().replace(/(^|\s)([a-z])/g,function(a,b,c){return b+c.toUpperCase()})},g=function(b){var c=b.val(),d=b.attr("type");return"checkbox"===d&&(c=b.is(":checked")?c:""),"radio"===d&&(c=a('input[name="'+b.attr("name")+'"]:checked').length>0?c:""),c};a.fn.jqBootstrapValidation=function(b){return e.methods[b]?e.methods[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?(a.error("Method "+b+" does not exist on jQuery.jqBootstrapValidation"),null):e.methods.init.apply(this,arguments)},a.jqBootstrapValidation=function(){a(":input").not("[type=image],[type=submit]").jqBootstrapValidation.apply(this,arguments)}}(jQuery),$(function(){$("body").on("input propertychange",".floating-label-form-group",function(a){$(this).toggleClass("floating-label-form-group-with-value",!!$(a.target).val())}).on("focus",".floating-label-form-group",function(){$(this).addClass("floating-label-form-group-with-focus")}).on("blur",".floating-label-form-group",function(){$(this).removeClass("floating-label-form-group-with-focus")})}),jQuery(document).ready(function(a){var b=1170;if(a(window).width()>b){var c=a(".navbar-custom").height();a(window).on("scroll",{previousTop:0},function(){var b=a(window).scrollTop();b0&&a(".navbar-custom").hasClass("is-fixed")?a(".navbar-custom").addClass("is-visible"):a(".navbar-custom").removeClass("is-visible is-fixed"):(a(".navbar-custom").removeClass("is-visible"),b>c&&!a(".navbar-custom").hasClass("is-fixed")&&a(".navbar-custom").addClass("is-fixed")),this.previousTop=b})}});
--------------------------------------------------------------------------------
/app/less/clean-blog.less:
--------------------------------------------------------------------------------
1 | @import "variables.less";
2 | @import "mixins.less";
3 |
4 | // Global Components
5 |
6 | body {
7 | .serif;
8 | font-size: 20px;
9 | color: @gray-dark;
10 | }
11 |
12 | // -- Typography
13 |
14 | p {
15 | line-height: 1.5;
16 | margin: 30px 0;
17 | a {
18 | text-decoration: underline;
19 | }
20 | }
21 |
22 | h1,
23 | h2,
24 | h3,
25 | h4,
26 | h5,
27 | h6 {
28 | .sans-serif;
29 | font-weight: 800;
30 | }
31 |
32 | a {
33 | color: @gray-dark;
34 | &:hover,
35 | &:focus {
36 | color: @brand-primary;
37 | }
38 | }
39 |
40 | a img {
41 | &:hover,
42 | &:focus {
43 | cursor: zoom-in;
44 | }
45 | }
46 |
47 | blockquote {
48 | color: @gray;
49 | font-style: italic;
50 | }
51 |
52 | hr.small {
53 | max-width: 100px;
54 | margin: 15px auto;
55 | border-width: 4px;
56 | border-color: white;
57 | }
58 |
59 | // Navigation
60 |
61 | .navbar-custom {
62 | position: absolute;
63 | top: 0;
64 | left: 0;
65 | width: 100%;
66 | z-index: 3;
67 | .sans-serif;
68 | .navbar-brand {
69 | font-weight: 800;
70 | }
71 | .nav {
72 | li {
73 | a {
74 | text-transform: uppercase;
75 | font-size: 12px;
76 | font-weight: 800;
77 | letter-spacing: 1px;
78 | }
79 | }
80 | }
81 | @media only screen and (min-width: 768px) {
82 | background: transparent;
83 | border-bottom: 1px solid transparent;
84 | .navbar-brand {
85 | color: white;
86 | padding: 20px;
87 | &:hover,
88 | &:focus {
89 | color: @white-faded;
90 | }
91 | }
92 | .nav {
93 | li {
94 | a {
95 | color: white;
96 | padding: 20px;
97 | &:hover,
98 | &:focus {
99 | color: @white-faded;
100 | }
101 | }
102 | }
103 | }
104 | }
105 | @media only screen and (min-width: 1170px) {
106 | -webkit-transition: background-color 0.3s;
107 | -moz-transition: background-color 0.3s;
108 | transition: background-color 0.3s;
109 | /* Force Hardware Acceleration in WebKit */
110 | -webkit-transform: translate3d(0, 0, 0);
111 | -moz-transform: translate3d(0, 0, 0);
112 | -ms-transform: translate3d(0, 0, 0);
113 | -o-transform: translate3d(0, 0, 0);
114 | transform: translate3d(0, 0, 0);
115 | -webkit-backface-visibility: hidden;
116 | backface-visibility: hidden;
117 | &.is-fixed {
118 | /* when the user scrolls down, we hide the header right above the viewport */
119 | position: fixed;
120 | top: -61px;
121 | background-color: fade(white, 90%);
122 | border-bottom: 1px solid darken(white, 5%);
123 | -webkit-transition: -webkit-transform 0.3s;
124 | -moz-transition: -moz-transform 0.3s;
125 | transition: transform 0.3s;
126 | .navbar-brand {
127 | color: @gray-dark;
128 | &:hover,
129 | &:focus {
130 | color: @brand-primary;
131 | }
132 | }
133 | .nav {
134 | li {
135 | a {
136 | color: @gray-dark;
137 | &:hover,
138 | &:focus {
139 | color: @brand-primary;
140 | }
141 | }
142 | }
143 | }
144 | }
145 | &.is-visible {
146 | /* if the user changes the scrolling direction, we show the header */
147 | -webkit-transform: translate3d(0, 100%, 0);
148 | -moz-transform: translate3d(0, 100%, 0);
149 | -ms-transform: translate3d(0, 100%, 0);
150 | -o-transform: translate3d(0, 100%, 0);
151 | transform: translate3d(0, 100%, 0);
152 | }
153 | }
154 | }
155 |
156 | // Header
157 |
158 | .intro-header {
159 | background-color: @gray;
160 | background: no-repeat center center;
161 | background-attachment: scroll;
162 | .background-cover;
163 | // NOTE: Background images are set within the HTML using inline CSS!
164 | margin-bottom: 50px;
165 | .site-heading,
166 | .post-heading,
167 | .page-heading {
168 | padding: 100px 0 50px;
169 | color: white;
170 | @media only screen and (min-width: 768px) {
171 | padding: 150px 0;
172 | }
173 | }
174 | .site-heading,
175 | .page-heading {
176 | text-align: center;
177 | h1 {
178 | margin-top: 0;
179 | font-size: 50px;
180 | }
181 | .subheading {
182 | font-size: 24px;
183 | line-height: 1.1;
184 | display: block;
185 | .sans-serif;
186 | font-weight: 300;
187 | margin: 10px 0 0;
188 | }
189 | @media only screen and (min-width: 768px) {
190 | h1 {
191 | font-size: 80px;
192 | }
193 | }
194 | }
195 | .post-heading {
196 | h1 {
197 | font-size: 35px;
198 | }
199 | .subheading,
200 | .meta {
201 | line-height: 1.1;
202 | display: block;
203 | }
204 | .subheading {
205 | .sans-serif;
206 | font-size: 24px;
207 | margin: 10px 0 30px;
208 | font-weight: 600;
209 | }
210 | .meta {
211 | .serif;
212 | font-style: italic;
213 | font-weight: 300;
214 | font-size: 20px;
215 | a {
216 | color: white;
217 | }
218 | }
219 | @media only screen and (min-width: 768px) {
220 | h1 {
221 | font-size: 55px;
222 | }
223 | .subheading {
224 | font-size: 30px;
225 | }
226 | }
227 | }
228 | }
229 |
230 | // Post Preview Pages
231 |
232 | .post-preview {
233 | > a {
234 | color: @gray-dark;
235 | &:hover,
236 | &:focus {
237 | text-decoration: none;
238 | color: @brand-primary;
239 | }
240 | > .post-title {
241 | font-size: 30px;
242 | margin-top: 30px;
243 | margin-bottom: 10px;
244 | }
245 | > .post-subtitle {
246 | margin: 0;
247 | font-weight: 300;
248 | margin-bottom: 10px;
249 | }
250 | }
251 | > .post-meta {
252 | color: @gray;
253 | font-size: 18px;
254 | font-style: italic;
255 | margin-top: 0;
256 | > a {
257 | text-decoration: none;
258 | color: @gray-dark;
259 | &:hover,
260 | &:focus {
261 | color: @brand-primary;
262 | text-decoration: underline;
263 | }
264 | }
265 | }
266 | @media only screen and (min-width: 768px) {
267 | > a {
268 | > .post-title {
269 | font-size: 36px;
270 | }
271 | }
272 | }
273 | }
274 |
275 | // Sections
276 |
277 | .section-heading {
278 | font-size: 36px;
279 | margin-top: 60px;
280 | font-weight: 700;
281 | }
282 |
283 | .caption {
284 | text-align: center;
285 | font-size: 14px;
286 | padding: 10px;
287 | font-style: italic;
288 | margin: 0;
289 | display: block;
290 | border-bottom-right-radius: 5px;
291 | border-bottom-left-radius: 5px;
292 | }
293 |
294 | footer {
295 | padding: 50px 0 65px;
296 | .list-inline {
297 | margin: 0;
298 | padding: 0;
299 | }
300 | .copyright {
301 | font-size: 14px;
302 | text-align: center;
303 | margin-bottom: 0;
304 | }
305 | }
306 |
307 | // Contact Form Styles
308 |
309 | .floating-label-form-group {
310 | font-size: 14px;
311 | position: relative;
312 | margin-bottom: 0;
313 | padding-bottom: 0.5em;
314 | border-bottom: 1px solid @gray-light;
315 | input,
316 | textarea {
317 | z-index: 1;
318 | position: relative;
319 | padding-right: 0;
320 | padding-left: 0;
321 | border: none;
322 | border-radius: 0;
323 | font-size: 1.5em;
324 | background: none;
325 | box-shadow: none !important;
326 | resize: none;
327 | }
328 | label {
329 | display: block;
330 | z-index: 0;
331 | position: relative;
332 | top: 2em;
333 | margin: 0;
334 | font-size: 0.85em;
335 | line-height: 1.764705882em;
336 | vertical-align: middle;
337 | vertical-align: baseline;
338 | opacity: 0;
339 | -webkit-transition: top 0.3s ease,opacity 0.3s ease;
340 | -moz-transition: top 0.3s ease,opacity 0.3s ease;
341 | -ms-transition: top 0.3s ease,opacity 0.3s ease;
342 | transition: top 0.3s ease,opacity 0.3s ease;
343 | }
344 | &::not(:first-child) {
345 | padding-left: 14px;
346 | border-left: 1px solid @gray-light;
347 | }
348 | }
349 |
350 | .floating-label-form-group-with-value {
351 | label {
352 | top: 0;
353 | opacity: 1;
354 | }
355 | }
356 |
357 | .floating-label-form-group-with-focus {
358 | label {
359 | color: @brand-primary;
360 | }
361 | }
362 |
363 | form .row:first-child .floating-label-form-group {
364 | border-top: 1px solid @gray-light;
365 | }
366 |
367 | // Button Styles
368 |
369 | .btn {
370 | .sans-serif;
371 | text-transform: uppercase;
372 | font-size: 14px;
373 | font-weight: 800;
374 | letter-spacing: 1px;
375 | border-radius: 0;
376 | padding: 15px 25px;
377 | }
378 |
379 | .btn-lg {
380 | font-size: 16px;
381 | padding: 25px 35px;
382 | }
383 |
384 | .btn-default {
385 | &:hover,
386 | &:focus {
387 | background-color: @brand-primary;
388 | border: 1px solid @brand-primary;
389 | color: white;
390 | }
391 | }
392 |
393 | // Pager Styling
394 |
395 | .pager {
396 |
397 | margin: 20px 0 0;
398 |
399 | li {
400 | > a,
401 | > span {
402 | .sans-serif;
403 | text-transform: uppercase;
404 | font-size: 14px;
405 | font-weight: 800;
406 | letter-spacing: 1px;
407 | padding: 15px 25px;
408 | background-color: white;
409 | border-radius: 0;
410 | }
411 |
412 | > a:hover,
413 | > a:focus {
414 | color: white;
415 | background-color: @brand-primary;
416 | border: 1px solid @brand-primary;
417 | }
418 | }
419 |
420 | .disabled {
421 | > a,
422 | > a:hover,
423 | > a:focus,
424 | > span {
425 | color: @gray;
426 | background-color: @gray-dark;
427 | cursor: not-allowed;
428 | }
429 | }
430 | }
431 |
432 | // -- Highlight Color Customization
433 |
434 | ::-moz-selection {
435 | color: white;
436 | text-shadow: none;
437 | background: @brand-primary;
438 | }
439 |
440 | ::selection {
441 | color: white;
442 | text-shadow: none;
443 | background: @brand-primary;
444 | }
445 |
446 | img::selection {
447 | color: white;
448 | background: transparent;
449 | }
450 |
451 | img::-moz-selection {
452 | color: white;
453 | background: transparent;
454 | }
455 |
456 | body {
457 | webkit-tap-highlight-color: @brand-primary;
458 | }
--------------------------------------------------------------------------------
/app/less/mixins.less:
--------------------------------------------------------------------------------
1 | // Mixins
2 |
3 | .transition-all() {
4 | -webkit-transition: all 0.5s;
5 | -moz-transition: all 0.5s;
6 | transition: all 0.5s;
7 | }
8 |
9 | .background-cover() {
10 | -webkit-background-size: cover;
11 | -moz-background-size: cover;
12 | background-size: cover;
13 | -o-background-size: cover;
14 | }
15 |
16 | .serif() {
17 | font-family: 'Lora', 'Times New Roman', serif;
18 | }
19 |
20 | .sans-serif () {
21 | font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
22 | }
--------------------------------------------------------------------------------
/app/less/variables.less:
--------------------------------------------------------------------------------
1 | // Variables
2 |
3 | @brand-primary: #0085A1;
4 | @gray-dark: lighten(black, 25%);
5 | @gray: lighten(black, 50%);
6 | @white-faded: fade(white, 80%);
7 | @gray-light: #eee;
--------------------------------------------------------------------------------
/app/main.js:
--------------------------------------------------------------------------------
1 | import {bootstrap} from 'angular2/angular2'
2 | import {BlogComponent} from 'blogcomponent'
3 |
4 |
5 | bootstrap(BlogComponent);
6 |
--------------------------------------------------------------------------------
/app/myblogservice.js:
--------------------------------------------------------------------------------
1 | export class BlogService {
2 |
3 | getBlogDetails(page):any {
4 |
5 | return Zone.bindPromiseFn(fetch)('http://gokhankaradas.com/wp-json/posts?filter[post_status]=publish&filter[posts_per_page]=25&page='+page+'&filter[orderby]=date&filter[order]=desc')
6 | .then(function(response) {
7 | return response.json();
8 | });
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "emitDecoratorMetadata": true,
4 | "module": "amd",
5 | "target": "es5",
6 | "noImplicitAny": true,
7 | "removeComments": false,
8 | "preserveConstEnums": true,
9 | "sourceMap": true
10 | }
11 | }
--------------------------------------------------------------------------------
/app/tsd.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Angular2-Blog",
3 | "version": "1.0.0",
4 | "description": "This is simple blog post for angular2",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "author": "Gokhan Karadas",
9 | "devDependencies": {
10 | "yargs": "^3.10.0"
11 | },
12 | "dependencies": {
13 | "angular2": "^2.0.0-alpha.27",
14 | "systemjs": "^0.18.1",
15 | "typescript": "^1.5.0-beta"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/typings/es6-promise/es6-promise.d.ts:
--------------------------------------------------------------------------------
1 | // Type definitions for es6-promise
2 | // Project: https://github.com/jakearchibald/ES6-Promise
3 | // Definitions by: François de Campredon , vvakame
4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped
5 |
6 | interface Thenable {
7 | then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable;
8 | then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable;
9 | }
10 |
11 | declare class Promise implements Thenable {
12 | /**
13 | * If you call resolve in the body of the callback passed to the constructor,
14 | * your promise is fulfilled with result object passed to resolve.
15 | * If you call reject your promise is rejected with the object passed to resolve.
16 | * For consistency and debugging (eg stack traces), obj should be an instanceof Error.
17 | * Any errors thrown in the constructor callback will be implicitly passed to reject().
18 | */
19 | constructor(callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void);
20 |
21 | /**
22 | * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
23 | * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
24 | * Both callbacks have a single parameter , the fulfillment value or rejection reason.
25 | * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
26 | * If an error is thrown in the callback, the returned promise rejects with that error.
27 | *
28 | * @param onFulfilled called when/if "promise" resolves
29 | * @param onRejected called when/if "promise" rejects
30 | */
31 | then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise;
32 | then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise;
33 |
34 | /**
35 | * Sugar for promise.then(undefined, onRejected)
36 | *
37 | * @param onRejected called when/if "promise" rejects
38 | */
39 | catch(onRejected?: (error: any) => U | Thenable): Promise;
40 | }
41 |
42 | declare module Promise {
43 | /**
44 | * Make a new promise from the thenable.
45 | * A thenable is promise-like in as far as it has a "then" method.
46 | */
47 | function resolve(value?: R | Thenable): Promise;
48 |
49 | /**
50 | * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
51 | */
52 | function reject(error: any): Promise;
53 |
54 | /**
55 | * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
56 | * the array passed to all can be a mixture of promise-like objects and other objects.
57 | * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
58 | */
59 | function all(promises: (R | Thenable)[]): Promise;
60 |
61 | /**
62 | * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
63 | */
64 | function race(promises: (R | Thenable)[]): Promise;
65 | }
66 |
67 | declare module 'es6-promise' {
68 | var foo: typeof Promise; // Temp variable to reference Promise in local context
69 | module rsvp {
70 | export var Promise: typeof foo;
71 | }
72 | export = rsvp;
73 | }
74 |
--------------------------------------------------------------------------------
/typings/rx/rx-lite.d.ts:
--------------------------------------------------------------------------------
1 | // DefinitelyTyped: partial
2 |
3 | // This file contains common part of defintions for rx.d.ts and rx.lite.d.ts
4 | // Do not include the file separately.
5 |
6 | declare module Rx {
7 | export module internals {
8 | function isEqual(left: any, right: any): boolean;
9 | function addRef(xs: Observable, r: { getDisposable(): IDisposable; }): Observable;
10 |
11 | // Priority Queue for Scheduling
12 | export class PriorityQueue {
13 | constructor(capacity: number);
14 |
15 | length: number;
16 |
17 | isHigherPriority(left: number, right: number): boolean;
18 | percolate(index: number): void;
19 | heapify(index: number): void;
20 | peek(): ScheduledItem;
21 | removeAt(index: number): void;
22 | dequeue(): ScheduledItem;
23 | enqueue(item: ScheduledItem): void;
24 | remove(item: ScheduledItem): boolean;
25 |
26 | static count: number;
27 | }
28 |
29 | export class ScheduledItem {
30 | constructor(scheduler: IScheduler, state: any, action: (scheduler: IScheduler, state: any) => IDisposable, dueTime: TTime, comparer?: (x: TTime, y: TTime) => number);
31 |
32 | scheduler: IScheduler;
33 | state: TTime;
34 | action: (scheduler: IScheduler, state: any) => IDisposable;
35 | dueTime: TTime;
36 | comparer: (x: TTime, y: TTime) => number;
37 | disposable: SingleAssignmentDisposable;
38 |
39 | invoke(): void;
40 | compareTo(other: ScheduledItem): number;
41 | isCancelled(): boolean;
42 | invokeCore(): IDisposable;
43 | }
44 | }
45 |
46 | export module config {
47 | export var Promise: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; };
48 | }
49 |
50 | export module helpers {
51 | function noop(): void;
52 | function notDefined(value: any): boolean;
53 | function isScheduler(value: any): boolean;
54 | function identity(value: T): T;
55 | function defaultNow(): number;
56 | function defaultComparer(left: any, right: any): boolean;
57 | function defaultSubComparer(left: any, right: any): number;
58 | function defaultKeySerializer(key: any): string;
59 | function defaultError(err: any): void;
60 | function isPromise(p: any): boolean;
61 | function asArray(...args: T[]): T[];
62 | function not(value: any): boolean;
63 | function isFunction(value: any): boolean;
64 | }
65 |
66 | export interface IDisposable {
67 | dispose(): void;
68 | }
69 |
70 | export class CompositeDisposable implements IDisposable {
71 | constructor (...disposables: IDisposable[]);
72 | constructor (disposables: IDisposable[]);
73 |
74 | isDisposed: boolean;
75 | length: number;
76 |
77 | dispose(): void;
78 | add(item: IDisposable): void;
79 | remove(item: IDisposable): boolean;
80 | toArray(): IDisposable[];
81 | }
82 |
83 | export class Disposable implements IDisposable {
84 | constructor(action: () => void);
85 |
86 | static create(action: () => void): IDisposable;
87 | static empty: IDisposable;
88 |
89 | dispose(): void;
90 | }
91 |
92 | // Single assignment
93 | export class SingleAssignmentDisposable implements IDisposable {
94 | constructor();
95 |
96 | isDisposed: boolean;
97 | current: IDisposable;
98 |
99 | dispose(): void ;
100 | getDisposable(): IDisposable;
101 | setDisposable(value: IDisposable): void ;
102 | }
103 |
104 | // SerialDisposable it's an alias of SingleAssignmentDisposable
105 | export class SerialDisposable extends SingleAssignmentDisposable {
106 | constructor();
107 | }
108 |
109 | export class RefCountDisposable implements IDisposable {
110 | constructor(disposable: IDisposable);
111 |
112 | dispose(): void;
113 |
114 | isDisposed: boolean;
115 | getDisposable(): IDisposable;
116 | }
117 |
118 | export interface IScheduler {
119 | now(): number;
120 |
121 | schedule(action: () => void): IDisposable;
122 | scheduleWithState(state: TState, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable;
123 | scheduleWithAbsolute(dueTime: number, action: () => void): IDisposable;
124 | scheduleWithAbsoluteAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) =>IDisposable): IDisposable;
125 | scheduleWithRelative(dueTime: number, action: () => void): IDisposable;
126 | scheduleWithRelativeAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) =>IDisposable): IDisposable;
127 |
128 | scheduleRecursive(action: (action: () =>void ) =>void ): IDisposable;
129 | scheduleRecursiveWithState(state: TState, action: (state: TState, action: (state: TState) =>void ) =>void ): IDisposable;
130 | scheduleRecursiveWithAbsolute(dueTime: number, action: (action: (dueTime: number) => void) => void): IDisposable;
131 | scheduleRecursiveWithAbsoluteAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) => void) => void): IDisposable;
132 | scheduleRecursiveWithRelative(dueTime: number, action: (action: (dueTime: number) =>void ) =>void ): IDisposable;
133 | scheduleRecursiveWithRelativeAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) =>void ) =>void ): IDisposable;
134 |
135 | schedulePeriodic(period: number, action: () => void): IDisposable;
136 | schedulePeriodicWithState(state: TState, period: number, action: (state: TState) => TState): IDisposable;
137 | }
138 |
139 | export interface Scheduler extends IScheduler {
140 | }
141 |
142 | export interface SchedulerStatic {
143 | new (
144 | now: () => number,
145 | schedule: (state: any, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable,
146 | scheduleRelative: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable,
147 | scheduleAbsolute: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable): Scheduler;
148 |
149 | normalize(timeSpan: number): number;
150 |
151 | immediate: IScheduler;
152 | currentThread: ICurrentThreadScheduler;
153 | timeout: IScheduler;
154 | }
155 |
156 | export var Scheduler: SchedulerStatic;
157 |
158 | // Current Thread IScheduler
159 | interface ICurrentThreadScheduler extends IScheduler {
160 | scheduleRequired(): boolean;
161 | }
162 |
163 | // Notifications
164 | export class Notification {
165 | accept(observer: IObserver): void;
166 | accept(onNext: (value: T) => TResult, onError?: (exception: any) => TResult, onCompleted?: () => TResult): TResult;
167 | toObservable(scheduler?: IScheduler): Observable;
168 | hasValue: boolean;
169 | equals(other: Notification): boolean;
170 | kind: string;
171 | value: T;
172 | exception: any;
173 |
174 | static createOnNext(value: T): Notification;
175 | static createOnError(exception: any): Notification;
176 | static createOnCompleted(): Notification;
177 | }
178 |
179 | /**
180 | * Promise A+
181 | */
182 | export interface IPromise {
183 | then(onFulfilled: (value: T) => IPromise, onRejected: (reason: any) => IPromise): IPromise;
184 | then(onFulfilled: (value: T) => IPromise, onRejected?: (reason: any) => R): IPromise;
185 | then(onFulfilled: (value: T) => R, onRejected: (reason: any) => IPromise): IPromise;
186 | then(onFulfilled?: (value: T) => R, onRejected?: (reason: any) => R): IPromise;
187 | }
188 |
189 | // Observer
190 | export interface IObserver {
191 | onNext(value: T): void;
192 | onError(exception: any): void;
193 | onCompleted(): void;
194 | }
195 |
196 | export interface Observer extends IObserver {
197 | toNotifier(): (notification: Notification) => void;
198 | asObserver(): Observer;
199 | }
200 |
201 | interface ObserverStatic {
202 | create(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer;
203 | fromNotifier(handler: (notification: Notification, thisArg?: any) => void): Observer;
204 | }
205 |
206 | export var Observer: ObserverStatic;
207 |
208 | export interface IObservable {
209 | subscribe(observer: Observer): IDisposable;
210 | subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable;
211 |
212 | subscribeOnNext(onNext: (value: T) => void, thisArg?: any): IDisposable;
213 | subscribeOnError(onError: (exception: any) => void, thisArg?: any): IDisposable;
214 | subscribeOnCompleted(onCompleted: () => void, thisArg?: any): IDisposable;
215 | }
216 |
217 | export interface Observable extends IObservable {
218 | forEach(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; // alias for subscribe
219 | toArray(): Observable;
220 |
221 | catch(handler: (exception: any) => Observable): Observable;
222 | catchException(handler: (exception: any) => Observable): Observable; // alias for catch
223 | catch(handler: (exception: any) => IPromise): Observable;
224 | catchException(handler: (exception: any) => IPromise): Observable; // alias for catch
225 | catch(second: Observable): Observable;
226 | catchException(second: Observable): Observable; // alias for catch
227 | combineLatest(second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable;
228 | combineLatest(second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable;
229 | combineLatest(second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable;
230 | combineLatest(second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable;
231 | combineLatest(second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable;
232 | combineLatest(second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable;
233 | combineLatest(second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable;
234 | combineLatest(second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable;
235 | combineLatest(second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable;
236 | combineLatest(second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable;
237 | combineLatest(second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable;
238 | combineLatest(second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable;
239 | combineLatest(second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable;
240 | combineLatest(second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable;
241 | combineLatest(second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable;
242 | combineLatest(souces: Observable[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable;
243 | combineLatest(souces: IPromise[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable;
244 | concat(...sources: Observable[]): Observable;
245 | concat(...sources: IPromise[]): Observable;
246 | concat(sources: Observable[]): Observable;
247 | concat(sources: IPromise[]): Observable;
248 | concatAll(): T;
249 | concatObservable(): T; // alias for concatAll
250 | concatMap(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat
251 | concatMap(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat
252 | concatMap(selector: (value: T, index: number) => Observable): Observable; // alias for selectConcat
253 | concatMap(selector: (value: T, index: number) => IPromise): Observable; // alias for selectConcat
254 | concatMap(sequence: Observable): Observable; // alias for selectConcat
255 | merge(maxConcurrent: number): T;
256 | merge(other: Observable): Observable;
257 | merge(other: IPromise): Observable;
258 | mergeAll(): T;
259 | mergeObservable(): T; // alias for mergeAll
260 | skipUntil(other: Observable): Observable;
261 | skipUntil(other: IPromise): Observable;
262 | switch(): T;
263 | switchLatest(): T; // alias for switch
264 | takeUntil(other: Observable): Observable;
265 | takeUntil(other: IPromise): Observable;
266 | zip(second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable;
267 | zip(second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable;
268 | zip(second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable;
269 | zip(second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable;
270 | zip(second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable;
271 | zip(second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable;
272 | zip(second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable