1. Osiloke Emoekpere
  2. mezzanine_widgets

Commits

Osiloke Emoekpere  committed 540c2af

fixed editform popup

  • Participants
  • Parent commits 22528cb
  • Branches enhancements

Comments (0)

Files changed (6)

File README.rst

View file
 * Easy and full frontend modification of widgets i.e Adding, Editing and Deleting widgets
 * Configuration options for each widget
 * Multisite support
+* Sortable Widgets
+* Mutual exclusivity from django app loader
 * Bootstrap theme integration
 
 Requirements
 ============
+
+Python
+~~~~~~
 mezzanine 1.x.x
 django-classy-tags
 
+Javascript 
+~~~~~~~~~~
+Bootstrap Tooltip
+Jquery Django Admin Form
+underscore
+jQuery UI
+
+Please use widget/widget_loader.html as a reference to add the neccessary js if you do not want to use the {% widget_loader %} tag.
+
 METHODOLOGY
 ===========
 Widgets are placed in the specified slot. Slots are just placeholders inside django templates where widgets are rendered.
 TODO
 ====
 * Better presentation of widget list in frontend.
-* More render options, like provide template for widget list wrap
+* More render options, like provide template for widget list wrap
+* Bootstrap theme integration

File widget/static/widget/js/widget.coffee

View file
 
         )
     #some neccessary jq config
-    # $(".widget-edit-link, .widget-delete-link").tooltip {placement:"right"}
+    $(".widget-edit-link, .widget-delete-link").tooltip {placement:"right"}
     @setupAdmin()
     @setupWidgetForms()
     @setupSortableWidgets()
     #Setup Edit Form for ajax post submission
     $("#edit-widget-form").adminForm({resultParsed: @onEditData})
 
+    that = this
     #Setup Edit Form Triggers
-    $('.widget-edit-link').click((e) =>
-        widget_id = e.currentTarget.id.split("-")[1]
-        widget_title = e.currentTarget.parentElement.parentElement.parentElement.id
-        @onEditForm(e.currentTarget, widget_id, widget_title)
-        $('#editForm').modal()
-        e.preventDefault();
+    $.each($('.widget-edit-link'), (i) ->
+        $link = $(this)
+        target = $(this)[0]
+        onBeforeLoad = () ->
+          widget_id = target.id.split("-")[1]
+          widget_title = target.parentElement.parentElement.parentElement.id
+          that.onEditForm(target, widget_id, widget_title)
+        overlay = {onBeforeLoad: onBeforeLoad, closeOnEsc: true, expose: expose, closeOnClick: true, close: ':button'}
+        $link.overlay(overlay) 
     )
     @
 

File widget/static/widget/js/widget.js

View file
       if (not_impl.length > 0) {
         not_impl.each(function(i) {});
       }
+      $(".widget-edit-link, .widget-delete-link").tooltip({
+        placement: "right"
+      });
       this.setupAdmin();
       this.setupWidgetForms();
       this.setupSortableWidgets();
     };
 
     WidgetAdmin.prototype.setupWidgetForms = function() {
-      var expose,
-        _this = this;
+      var expose, that;
       $("#widget-form").adminForm({
         preSubmit: this.preSubmit,
         resultParsed: this.resultParsed
       $("#edit-widget-form").adminForm({
         resultParsed: this.onEditData
       });
-      $('.widget-edit-link').click(function(e) {
-        var widget_id, widget_title;
-        widget_id = e.currentTarget.id.split("-")[1];
-        widget_title = e.currentTarget.parentElement.parentElement.parentElement.id;
-        _this.onEditForm(e.currentTarget, widget_id, widget_title);
-        $('#editForm').modal();
-        return e.preventDefault();
+      that = this;
+      $.each($('.widget-edit-link'), function(i) {
+        var $link, onBeforeLoad, overlay, target;
+        $link = $(this);
+        target = $(this)[0];
+        onBeforeLoad = function() {
+          var widget_id, widget_title;
+          widget_id = target.id.split("-")[1];
+          widget_title = target.parentElement.parentElement.parentElement.id;
+          return that.onEditForm(target, widget_id, widget_title);
+        };
+        overlay = {
+          onBeforeLoad: onBeforeLoad,
+          closeOnEsc: true,
+          expose: expose,
+          closeOnClick: true,
+          close: ':button'
+        };
+        return $link.overlay(overlay);
       });
       return this;
     };

File widget/templates/widget/holder.html

View file
 
                         <div class="btn-toolbar widget-item-toolbar btn-group">
                             {% if perms.widget.can_change %}
-                                <a id="ew-{{ w.widget.id }}-edit" class="widget-edit-link" data-target="#editForm" href="#" data-toggle="modal" rel="tooltip" data-original-title="Edit {{ w.meta.name }}"><i class="icon-edit"></i></a>
+                                <a id="ew-{{ w.widget.id }}-edit" class="widget-edit-link" href="#"  rel="#edit-widget-form"  data-original-title="Edit {{ w.meta.name }}"><i class="icon-edit"></i></a>
                                 {% if w.widget.status == 2 %}
-                                    <a id="ew-{{ w.widget.id }}-edit" class="widget-edit-link" data-target="#editForm" href="#" data-toggle="modal" rel="tooltip" data-original-title="Unpublish this {{ w.meta.name }}"><i class="icon-thumbs-down"></i></a>
+                                    <a id="ew-{{ w.widget.id }}-edit" class="widget-edit-link" href="#"   data-original-title="Unpublish this {{ w.meta.name }}"><i class="icon-thumbs-down"></i></a>
                                 {% else %}
-                                    <a id="ew-{{ w.widget.id }}-edit" class="widget-edit-link" data-target="#editForm" href="#" data-toggle="modal" rel="tooltip" data-original-title="Publish this {{ w.meta.name }}" ><i class="icon-thumbs-up"></i></a>
+                                    <a id="ew-{{ w.widget.id }}-edit" class="widget-edit-link" href="#" data-original-title="Publish this {{ w.meta.name }}" ><i class="icon-thumbs-up"></i></a>
                                 {% endif %}
                             {% endif %}
                             {% if perms.widget.can_delete %}

File widget/templates/widget/widget_form.html

View file
 </form>
 {% endwith %}
 
-{# Edit Form #}
-<div class="modal fade" id="editForm">
-    <form
-      {# class="popup-form frontend-admin-form form-vertical" #}
-      method="post"
-      id="edit-widget-form">
-        <div class="modal-header">
-            <a class="close" data-dismiss="modal">&times;</a>
-            <h3 id="title">Configure</h3>
-        </div>
-        <div class="modal-body">
-                {% csrf_token %}
-                <fieldset id="widget-options">
-                    {# <legend >Configure this Widget</legend> #}
-                    <div class="options"></div>
-                </fieldset>
+{# Edit Form #} 
+<form style="display:none;" 
+  class="popup-form frontend-admin-form form-vertical" 
+  method="post"
+  id="edit-widget-form">
+    <div class="modal-header">
+        <a class="close" data-dismiss="modal">&times;</a>
+        <h3 id="title">Configure</h3>
+    </div>
+    <div class="modal-body">
+            {% csrf_token %}
+            <fieldset id="widget-options">
+                {# <legend >Configure this Widget</legend> #}
+                <div class="options"></div>
+            </fieldset>
 
-        </div>
-        <div class="modal-footer">
-            <input type="submit" name="submit" value="{% trans "Save" %}" class="btn" />
-            <a href="#" class="btn" data-dismiss="modal">{% trans "Close" %}</a>
-        </div>
-    </form>
-</div>
+    </div> 
+        <input type="submit" name="submit" value="{% trans "Save" %}" class="btn" />
+        <a href="#" class="btn" data-dismiss="modal">{% trans "Close" %}</a> 
+</form> 

File widget/templates/widget/widget_loader.html

View file
     src="{{ STATIC_URL }}widget/js/jquery-ui-1.8.18.custom.min.js">
 </script>
 <script type="text/javascript"
+    src="{{ STATIC_URL }}widget/js/bootstrap-tooltip.js">
+</script>
+<script type="text/javascript"
     src="{{ STATIC_URL }}widget/js/jquery-django-adminForm.js">
 </script>
 <script type="text/javascript"