Commits

salvator committed 4418451

icons in admin_tools.menu.items.MenuItem

Comments (0)

Files changed (4)

 and `admintools_bootstrap.context_processors.site` to `TEMPLATE_CONTEXT_PROCESSORS` list.
 
 Set site name and domain in `django.contrib.sites` admin.
+
+
+Icons in menu items
+-------------------
+
+You can display icon from JQuery UI icon set on menu items. Add icon argument to MenuItem definition::
+
+ items.AppList(
+        _('Users'),
+        models=('django.contrib.auth.*',),
+        icon='ui-icon-person'
+ )
+
+
+Used software:
+--------------
+
+* http://addyosmani.github.com/jquery-ui-bootstrap/

admintools_bootstrap/models.py

 
 # using jquery ui do display .vDateField
 widgets.AdminDateWidget.media = None
+
+# patching admintools menu item
+
+from admin_tools.menu import items
+
+# addming icon argument to base MenuItem class
+items.MenuItem.icon = None

admintools_bootstrap/static/admintools_bootstrap/lib/style.less

 
 	h2 {
 		font-size: 14pt;
-		padding-top: 0px;
-		padding-bottom: 10px;
+		line-height: 12pt;
+	}
+
+	h3 {
+		font-size: 12pt;
+		line-height: 15pt;
+
+		a {
+			margin-left: -15px;
+			color: @green !important;
+			font-weight: bold !important;
+		}
+	}
+	li {
+		a {
+			margin-left: 10px;
+		}
 	}
 }
 
 		padding-right: 0;
 		margin-right: 0;
 	}
+}
+
+.nav, .secondary-nav {
 	.ui-icon {
 		float: left;
 		margin: 0 8px 0 0px;

admintools_bootstrap/templates/admin_tools/menu/item.html

 {% if not item.is_empty %}
 <li class="{% if not item.enabled %} disabled{% endif %}{% if selected %} active{% endif %}{% if item.css_classes %} {{ item.css_classes|join:' ' }}{% endif %}{% if item.children %} dropdown{% endif %}">
 <a href="{% if item.url and item.enabled %}{{ item.url }}{% else %}#{% endif %}"{% if item.description %} title="{{ item.description }}"{% endif %}{% if item.accesskey %} accesskey="{{ item.accesskey }}"{% endif %}
-  {% if item.children and item.enabled %}class="dropdown-toggle"{% endif %}>{{ item.title }}
+  {% if item.children and item.enabled %}class="dropdown-toggle"{% endif %}>
+    {% if item.icon %}<span class="ui-icon {{ item.icon }} ui-state-default"></span>{% endif %}
+  {{ item.title }}
   </a>
     {% if item.children and item.enabled %}
     <ul class="{% if index == 'submenu' %}submenu open{% else %}dropdown-menu{% endif %}">
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.