mirror of
https://github.com/eldarion/eldarion-ajax-demo.git
synced 2026-01-08 21:47:56 -05:00
Update for eldarion-ajax 0.7.0
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
bootstrap-ajax demo
|
||||
eldarion-ajax demo
|
||||
===================
|
||||
|
||||
This is a quick and simple demo project to show how many of the features of bootstrap-ajax (http://github.com/eldarion/bootstrap-ajax) work.
|
||||
This is a quick and simple demo project to show how many of the features of eldarion-ajax (http://github.com/eldarion/eldarion-ajax) work.
|
||||
|
||||
You can find this online at a Gondor (https://gondor.io) instance here:
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
This directory is used to store static assets for your project. User media files
|
||||
(FileFields/ImageFields) are not stored here.
|
||||
|
||||
The convention for this directory is:
|
||||
|
||||
* css/ — stores CSS files
|
||||
* js/ — stores Javascript files
|
||||
* img/ — stores image files
|
||||
32
demo/static/js/eldarion-ajax.min.js
vendored
Normal file
32
demo/static/js/eldarion-ajax.min.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* ====================================================================
|
||||
* eldarion-ajax.min.js v0.7.0
|
||||
* ====================================================================
|
||||
* Copyright (c) 2013, Eldarion, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Eldarion, Inc. nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ==================================================================== */
|
||||
!function(e){"use strict";var t=function(){};t.prototype.click=function(t){var a=e(this),o=a.attr("href"),r=a.attr("data-method");r||(r="get"),a.trigger("eldarion-ajax:begin",[a]),t.preventDefault(),e.ajax({url:o,type:r,dataType:"json",statusCode:{200:function(e){a.trigger("eldarion-ajax:success",[a,e])},500:function(){a.trigger("eldarion-ajax:error",[a,500])},404:function(){a.trigger("eldarion-ajax:error",[a,404])}}})},t.prototype.submit=function(t){var a=e(this),o=a.attr("action"),r=a.attr("method"),n=a.serialize();a.trigger("eldarion-ajax:begin",[a]),t.preventDefault(),e.ajax({url:o,type:r,data:n,dataType:"json",statusCode:{200:function(e){a.trigger("eldarion-ajax:success",[a,e])},500:function(){a.trigger("eldarion-ajax:error",[a,500])},404:function(){a.trigger("eldarion-ajax:error",[a,404])}}})},t.prototype.cancel=function(t){var a=e(this),o=a.attr("data-cancel-closest");t.preventDefault(),a.closest(o).remove()},e(function(){e("body").on("click","a.ajax",t.prototype.click),e("body").on("submit","form.ajax",t.prototype.submit),e("body").on("click","a[data-cancel-closest]",t.prototype.cancel)})}(window.jQuery),!function(e){"use strict";var t=function(){};t.prototype.redirect=function(e,t,a){return a.location?(window.location.href=a.location,!1):void 0},t.prototype.replace=function(t,a,o){e(a.data("replace")).replaceWith(o.html)},t.prototype.replaceClosest=function(e,t,a){t.closest(t.data("replace-closest")).replaceWith(a.html)},t.prototype.replaceInner=function(t,a,o){e(a.data("replace-inner")).html(o.html)},t.prototype.replaceClosestInner=function(e,t,a){t.closest(t.data("replace-closest-inner")).html(a.html)},t.prototype.append=function(t,a,o){e(a.data("append")).append(o.html)},t.prototype.prepend=function(t,a,o){e(a.data("prepend")).prepend(o.html)},t.prototype.refresh=function(t,a){e.each(e(a.data("refresh")),function(t,a){e.getJSON(e(a).data("refresh-url"),function(t){e(a).replaceWith(t.html)})})},t.prototype.refreshClosest=function(t,a){e.each(e(a.data("refresh-closest")),function(t,o){e.getJSON(e(o).data("refresh-url"),function(t){a.closest(e(o)).replaceWith(t.html)})})},t.prototype.clear=function(t,a){e(a.data("clear")).html("")},t.prototype.remove=function(t,a){e(a.data("remove")).remove()},t.prototype.clearClosest=function(e,t){t.closest(t.data("clear-closest")).html("")},t.prototype.removeClosest=function(e,t){t.closest(t.data("remove-closest")).remove()},t.prototype.fragments=function(t,a,o){if(o.fragments)for(var r in o.fragments)e(r).replaceWith(o.fragments[r]);if(o["inner-fragments"])for(var n in o["inner-fragments"])e(n).html(o["inner-fragments"][n]);if(o["append-fragments"])for(var c in o["append-fragments"])e(c).append(o["append-fragments"][c]);if(o["prepend-fragments"])for(var s in o["prepend-fragments"])e(s).prepend(o["prepend-fragments"][s])},e(function(){e(document).on("eldarion-ajax:success",t.prototype.redirect),e(document).on("eldarion-ajax:success",t.prototype.fragments),e(document).on("eldarion-ajax:success","[data-replace]",t.prototype.replace),e(document).on("eldarion-ajax:success","[data-replace-closest]",t.prototype.replaceClosest),e(document).on("eldarion-ajax:success","[data-replace-inner]",t.prototype.replaceInner),e(document).on("eldarion-ajax:success","[data-replace-closest-inner]",t.prototype.replaceClosestInner),e(document).on("eldarion-ajax:success","[data-append]",t.prototype.append),e(document).on("eldarion-ajax:success","[data-prepend]",t.prototype.prepend),e(document).on("eldarion-ajax:success","[data-refresh]",t.prototype.refresh),e(document).on("eldarion-ajax:success","[data-refresh-closest]",t.prototype.refreshClosest),e(document).on("eldarion-ajax:success","[data-clear]",t.prototype.clear),e(document).on("eldarion-ajax:success","[data-remove]",t.prototype.remove),e(document).on("eldarion-ajax:success","[data-clear-closest]",t.prototype.clearClosest),e(document).on("eldarion-ajax:success","[data-remove-closest]",t.prototype.removeClosest)})}(window.jQuery);
|
||||
@@ -15,8 +15,8 @@
|
||||
<h1>Tasks</h1>
|
||||
<p class="lead">
|
||||
A sample tasks app to demonstrate how to use
|
||||
<a href="https://github.com/eldarion/bootstrap-ajax/">
|
||||
bootstrap-ajax
|
||||
<a href="https://github.com/eldarion/eldarion-ajax/">
|
||||
eldarion-ajax
|
||||
</a>
|
||||
</p>
|
||||
<form class="form-inline ajax" method="post" action="{% url "task_add" %}" data-append="#tasks">
|
||||
@@ -36,3 +36,14 @@
|
||||
<div class="span4"></div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block extra_body %}
|
||||
<script>
|
||||
$(function() {
|
||||
$("form").on("eldarion-ajax:success", function(e, $el, data) {
|
||||
$el.find("input[type=text]").val("");
|
||||
});
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -1,5 +1,6 @@
|
||||
{% extends "theme_base.html" %}
|
||||
|
||||
{% load staticfiles %}
|
||||
{% load metron_tags %}
|
||||
|
||||
{% block extra_head_base %}
|
||||
@@ -20,7 +21,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_body_base %}
|
||||
<script src="https://raw.github.com/eldarion/bootstrap-ajax/master/js/bootstrap-ajax.js"></script>
|
||||
<script src="{% static "js/eldarion-ajax.min.js" %}"></script>
|
||||
{% analytics %}
|
||||
{% block extra_body %}{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user