Revision: 1ba72406afc0
Author: Matthew Perry <perryg...@gmail.com>
Date: Tue Oct 18 15:32:18 2011
Log: Preliminary work on bookmark UI refactor
http://code.google.com/p/marinemap/source/detail?r=1ba72406afc0
Revision: 09aa119ba948
Author: Matthew Perry <perryg...@gmail.com>
Date: Tue Oct 18 16:37:33 2011
Log: Now we're getting somewhere...
http://code.google.com/p/marinemap/source/detail?r=09aa119ba948
==============================================================================
Revision: 1ba72406afc0
Author: Matthew Perry <perryg...@gmail.com>
Date: Tue Oct 18 15:32:18 2011
Log: Preliminary work on bookmark UI refactor
http://code.google.com/p/marinemap/source/detail?r=1ba72406afc0
Added:
/media/bookmarks/images/bookmark-menu.png
Modified:
/lingcod/common/templates/common/map.html
/lingcod/common/views.py
/media/common/css/menu_items.css
=======================================
--- /dev/null
+++ /media/bookmarks/images/bookmark-menu.png Tue Oct 18 15:32:18 2011
Binary file, no diff available.
=======================================
--- /lingcod/common/templates/common/map.html Tue Sep 6 12:40:15 2011
+++ /lingcod/common/templates/common/map.html Tue Oct 18 15:32:18 2011
@@ -71,6 +71,123 @@
$(document).ready(function(){
lingcod.init(options);
{% block js_ready %}{% endblock %}
+
+ {% if user.is_authenticated and bookmarks_as_feature %}
+ $('#bookmark-menu-link').click( function(e) {
+ e.preventDefault();
+ var url = "/features/bookmark/form/";
+ var panelOpts = {
+ loading_msg: 'Loading Bookmark Form',
+ showClose: true
+ };
+ var panel = lingcod.editors[0].panel;
+
+ function setupForm(form, options){
+ options = options || {};
+ var el = panel.getEl();
+ el.find('.close').hide();
+ el.find('input[type=submit]').hide();
+ var manipulator;
+
+ opts = {
+ // Forcing submission of content thru iframe all
the time, no
+ // matter whether a file upload field is
associated with the
+ // feature. I hate using iframes for this, but
they are
+ // necessary for uploads so we may as well be
consistent in
+ // their use with all forms.
+ iframe: true,
+ beforeSubmit: function(a,b,c) {
+ panel.spin('Please wait while we save your
bookmark.');
+ $(that).trigger('saving', ["Saving changes"]);
+ return true;
+ },
+ success: function(text, status, req, formel){
+ $(that).trigger('doneSaving');
+ if(text.match('<form') ||
text.match('<FORM')){ // for ie8
+ // Validation error
+ // Set default panel options. panel is an
instance var
+ var panelOpts = {
+ loading_msg: 'Loading form',
+ // loading_msg: 'Loading ' +
action.title,
+ // ^^^ action.title was causing js
error and stalling the app
+ // when a form was returned with
validation errors
+ showClose: true
+ };
+ panelOpts['showCloseButton'] = false;
+ panelOpts['success'] = function(){
+ lingcod.setupForm = function(){
+ alert('error:setupForm called
after clearing?');
+ };
+ }
+ // set a setupForm function that can be
called by content
+ // of the panel
+ lingcod.setupForm = function(form){
+ setupForm(form);
+ }
+ panel.close();
+ panel.stopSpinning();
+ panel.showText(text, panelOpts);
+ }else{
+ panel.close();
+ panel.stopSpinning();
+ var info = jQuery.parseJSON(text);
+ if(info['status'] != 200 &&
info['status'] != 201){
+ tree.refresh();
+ alert('There was an error saving your
feature.');
+ }else{
+ $(lingcod.editors[0]).trigger('edit',
[text, status, req, this]);
+ }
+ }
+ }
+ };
+ var a = $(form).attr('action');
+ if(typeof a !== 'undefined') {
+ if(a[a.length - 1] !== '/'){
+ // For the benefit of IE
+ $(form).attr('action', a + '/');
+ }
+ }
+ $(form).ajaxForm(opts);
+
+ el.find('.submit_button').click(function(){
+ form.trigger('submit');
+ });
+ el.find('.cancel_button').click(function(){
+ panel.close();
+ if(options.cancel){
+ options.cancel();
+ }
+ });
+ var tabs = el.find('.tabs');
+ tabs.bind('tabsshow', function(e){
+ var div = $(this).parent().parent().parent();
+ // scroll to 1, then 0 for the benefit of dumb
firefox
+ div.scrollTop(1);
+ div.scrollTop(0);
+ });
+ tabs.tabs('select', '#PanelAttributes');
+ tabs.tabs('disable', 0);
+ tabs.find('> .ui-tabs-nav').hide();
+ if(tabs && tabs.length && $('.errorlist').length){
+ tabs.tabs('select', '#PanelAttributes');
+ }
+ panel.show();
+ if($('#PanelAttributes').length){
+
$('#PanelAttributes').parent().parent().parent().parent().scrollTop(1).scrollTop(0);
+ }
+
+ $(that).trigger('form_shown', [panel, null]);
+ };
+ ///////////////////////////END
setupForm///////////////////////
+
+ // bind the setupForm function that can be called by
content of the panel
+ lingcod.setupForm = function(form){
+ setupForm(form);
+ }
+ panel.showUrl(url, panelOpts);
+ });
+ {% endif %}
+
{% if camera and publicstate %}
$(lingcod).bind('geReady', function() {
var camera =
ge.getView().copyAsCamera(ge.ALTITUDE_RELATIVE_TO_GROUND);
@@ -127,6 +244,24 @@
{% block menu_icons %}
<ul class="menu_items" id="header_buttons">
+ <li class="divider"><img
src="{{MEDIA_URL}}/common/images/header_divider.gif" height="32" width="2"
/></li>
+ {% if user.is_authenticated and bookmarks_as_feature %}
+ <li id="bookmarks_menuitem" class="item">
+ <span>
+ <a id="bookmark-menu-link" title="Bookmark"
href="#Bookmark">
+ <img
src="{{MEDIA_URL}}/bookmarks/images/bookmark-menu.png" style="padding: 6px;
padding-top:10px;" width="32" height="32" />
+ </a>
+ </span>
+ </li>
+ {% else %}
+ <li id="bookmarks_menuitem" class="item">
+ <span>
+ <a title="Bookmark" href="#Bookmark">
+ <img
src="{{MEDIA_URL}}/bookmarks/images/bookmark-menu.png" style="padding: 6px;
padding-top:10px;" width="32" height="32" />
+ </a>
+ </span>
+ </li>
+ {% endif %}
<li class="divider"><img
src="{{MEDIA_URL}}/common/images/header_divider.gif" height="32" width="2"
/></li>
<li id="layers_menu" class="item">
<span>
@@ -217,23 +352,27 @@
<li class="visible" id="atm"><span class="toggler"><img
width="16" height="16" src="{{MEDIA_URL}}common/images/transparent.gif"
/></span>Atmosphere</li>
</ul>
</div>
- {% block bookmark %}
- <div id="bookmark">
- <h3>Bookmark</h3>
- <a id="create_bookmark" href="#" class="button"
onclick="this.blur(); return false;">
- <span>Bookmark this view</span>
- </a>
- <br/>
- <div id="bookmark_results" style="display:none;">
- <p> Copy and paste this URL to get back to this location
</p>
- <div id="bookmark_url" style="border:1px #333 solid;
background-color: white; padding: 8px; font-family:monospace; font-size:
8pt; color: grey;">
- </div>
- </div>
- </div>
- {% endblock bookmark %}
</div>
{% endblock tools %}
+
+ {% block bookmark %}
+ <div id="Bookmark">
+ <h1>Bookmark</h1>
+ <p> You can create a bookmark to remember your location, camera
angle and data layers. Your bookmark will have a unique URL that you can
share with others. </p>
+ <br/>
+ <a id="create_bookmark" href="#" class="button"
onclick="this.blur(); return false;">
+ <span>Create Bookmark</span>
+ </a>
+ <br/>
+ <br/>
+ <div id="bookmark_results" style="display:none;">
+ <p> Copy and paste this URL to get back to this bookmark. </p>
+ <div id="bookmark_url" style="border:1px #333 solid;
background-color: white; padding: 8px; font-family:monospace; font-size:
8pt; color: grey;">
+ </div>
+ </div>
+ </div>
+ {% endblock bookmark %}
{% block datalayers %}
<div id="DataLayers">
=======================================
--- /lingcod/common/views.py Thu Aug 25 10:20:36 2011
+++ /lingcod/common/views.py Tue Oct 18 15:32:18 2011
@@ -98,6 +98,7 @@
'has_features': has_features(user),
'camera': parse_camera(request),
'publicstate': get_publicstate(request),
+ 'bookmarks_as_feature': settings.BOOKMARK_FEATURE,
})
context.update(extra_context)
=======================================
--- /media/common/css/menu_items.css Thu Jul 7 12:47:20 2011
+++ /media/common/css/menu_items.css Tue Oct 18 15:32:18 2011
@@ -44,7 +44,7 @@
#header_buttons {
position:absolute;
- left:400px;
+ left:350px;
top:0px;
}
==============================================================================
Revision: 09aa119ba948
Author: Matthew Perry <perryg...@gmail.com>
Date: Tue Oct 18 16:37:33 2011
Log: Now we're getting somewhere...
http://code.google.com/p/marinemap/source/detail?r=09aa119ba948
Modified:
/lingcod/common/templates/common/map.html
/media/common/js/layout/menu_items.js
/media/features/js/kmlEditor.js
=======================================
--- /lingcod/common/templates/common/map.html Tue Oct 18 15:32:18 2011
+++ /lingcod/common/templates/common/map.html Tue Oct 18 16:37:33 2011
@@ -73,7 +73,13 @@
{% block js_ready %}{% endblock %}
{% if user.is_authenticated and bookmarks_as_feature %}
+ $('#bookmark-close').click(function(){
+ $('.cancel_button').click();
+ return false;
+ });
+
$('#bookmark-menu-link').click( function(e) {
+ $('#bookmark-close').show();
e.preventDefault();
var url = "/features/bookmark/form/";
var panelOpts = {
@@ -82,6 +88,7 @@
};
var panel = lingcod.editors[0].panel;
+
function setupForm(form, options){
options = options || {};
var el = panel.getEl();
@@ -90,11 +97,7 @@
var manipulator;
opts = {
- // Forcing submission of content thru iframe all
the time, no
- // matter whether a file upload field is
associated with the
- // feature. I hate using iframes for this, but
they are
- // necessary for uploads so we may as well be
consistent in
- // their use with all forms.
+ // Forcing submission of content thru iframe all
the time
iframe: true,
beforeSubmit: function(a,b,c) {
panel.spin('Please wait while we save your
bookmark.');
@@ -150,9 +153,11 @@
$(form).ajaxForm(opts);
el.find('.submit_button').click(function(){
+ $('#bookmark-close').hide();
form.trigger('submit');
});
el.find('.cancel_button').click(function(){
+ $('#bookmark-close').hide();
panel.close();
if(options.cancel){
options.cancel();
@@ -246,18 +251,21 @@
<ul class="menu_items" id="header_buttons">
<li class="divider"><img
src="{{MEDIA_URL}}/common/images/header_divider.gif" height="32" width="2"
/></li>
{% if user.is_authenticated and bookmarks_as_feature %}
- <li id="bookmarks_menuitem" class="item">
+ <li>
<span>
<a id="bookmark-menu-link" title="Bookmark"
href="#Bookmark">
- <img
src="{{MEDIA_URL}}/bookmarks/images/bookmark-menu.png" style="padding: 6px;
padding-top:10px;" width="32" height="32" />
+ <img
src="{{MEDIA_URL}}bookmarks/images/bookmark-menu.png" style="padding: 6px;"
width="32" height="32" />
</a>
</span>
+ <div style="position:relative; top: -12px; left: 10px;">
+ <a id="bookmark-close" style="display:none;" href="#"><img
src="{{MEDIA_URL}}common/images/tool_window_pointer.png" width="23"
height="36" /></a>
+ </div>
</li>
{% else %}
<li id="bookmarks_menuitem" class="item">
<span>
<a title="Bookmark" href="#Bookmark">
- <img
src="{{MEDIA_URL}}/bookmarks/images/bookmark-menu.png" style="padding: 6px;
padding-top:10px;" width="32" height="32" />
+ <img
src="{{MEDIA_URL}}bookmarks/images/bookmark-menu.png" style="padding: 6px;
padding-top:10px;" width="32" height="32" />
</a>
</span>
</li>
=======================================
--- /media/features/js/kmlEditor.js Tue Jun 21 10:47:16 2011
+++ /media/features/js/kmlEditor.js Tue Oct 18 16:37:33 2011
@@ -216,8 +216,14 @@
// button.setEnabled(true);
jQuery.each(createActions, function(i, action){
var item = new goog.ui.MenuItem(action.title);
- item.action = action;
- menu.addItem(item);
+ // SPECIAL CASE
+ // Bookmarks, though they can be registered as a
feature,
+ // should not show up in the Create New menu since
there is
+ // a built-in UI element to create them
+ if (item.content_ != 'Bookmark'){
+ item.action = action;
+ menu.addItem(item);
+ }
});
}
}