fix javascript errors

This commit is contained in:
Lee Lawlor 2014-08-01 22:10:21 -04:00
parent 28bc4e18e5
commit b598a83e37
5 changed files with 94 additions and 81 deletions

View File

@ -12,20 +12,25 @@
<div id="private_dialog1" class="column" > </div> <div id="private_dialog1" class="column" > </div>
</div> </div>
<script> <script>
$(document).on('page:load ready', function() { // when the document is ready
$("#devInfoLink_private").click( $(document).on('page:load ready', function() {
function(e) {
// when the devinfo link is clicked
$("#devInfoLink_private").click(function(e) {
var element = $("#devInfo"); var element = $("#devInfo");
openDialogCenter(element); openDialogCenter(element);
}); return false;
$("#portletAddLink_private").click( });
function(e) {
$("#addPortlets").load('/channels/<%=@channel.id %>/hidden_windows?visibility_flag=private', // when the add window link is clicked
function(e) { $("#portletAddLink_private").click(function(e) {
$("#addPortlets").load('/channels/<%=@channel.id %>/hidden_windows?visibility_flag=private', function(e) {
var element = $("#addPortlets"); var element = $("#addPortlets");
openDialogCenter(element); openDialogCenter(element);
}) ; });
return false;
}); });
}); });
</script> </script>

View File

@ -31,21 +31,26 @@
</div> </div>
<script> <script>
// when the document is ready
$(document).on('page:load ready', function() {
// when the devinfo link is clicked
$("#devInfoLink_public").click(function() { $("#devInfoLink_public").click(function() {
var element = $("#devInfo"); var element = $("#devInfo");
openDialogCenter(element); openDialogCenter(element);
}); return false;
});
$("#portletAddLink_public").click(function() // when the add window link is clicked
{ $("#portletAddLink_public").click(function() {
$("#addPortlets").load('/channels/<%=@channel.id %>/hidden_windows?visibility_flag=public', function() {
var element = $("#addPortlets");
openDialogCenter(element);
});
return false;
});
$("#addPortlets").load('/channels/<%=@channel.id %>/hidden_windows?visibility_flag=public', });
function() {
var element = $("#addPortlets");
openDialogCenter(element);
})
});
// comment flag function // comment flag function
function commentflag(m_id, user_id) function commentflag(m_id, user_id)

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<script type="text/javascript" src="http<%= 's' if @ssl %>://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript" src="http<%= 's' if @ssl %>://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="<%= @map_domain %>/maps/api/js?sensor=false"></script> <script type="text/javascript" src="<%= @map_domain %>/maps/api/js?sensor=false"></script>
<script type="text/javascript"> <script type="text/javascript">
// when document is ready // when document is ready

View File

@ -1,7 +1,7 @@
<html> <html>
<head> <head>
<%= stylesheet_link_tag 'application' %> <%= stylesheet_link_tag 'application' %>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<%= javascript_include_tag 'application' %> <%= javascript_include_tag 'application' %>
</head> </head>

View File

@ -1,77 +1,80 @@
<script> <script>
$(document).on('page:load ready', function() { $("#tabs").tabs({
$("#tabs").tabs({ ajaxOptions: {
ajaxOptions: { error: function( xhr, status, index, anchor ) {
error: function( xhr, status, index, anchor ) { $( anchor.hash ).html(
$( anchor.hash ).html( "Couldn't load this tab. We'll try to fix this as soon as possible. " +
"Couldn't load this tab. We'll try to fix this as soon as possible. " + "If this wouldn't be a demo." );
"If this wouldn't be a demo." );
}
} }
}); }
});
//Need to turn this into an ID so it doesn't run on more than one object // remove handler if it already exists
$(".ioplugin").off(); $(document).off('click', '.ioplugin');
$("body").on("click", ".ioplugin", function() {
var plugins = $(".plugin"); // add click handler
var addPlugin = $(this); $(document).on('click', '.ioplugin', function() {
var ids = addPlugin.attr('id').split("-");
var channelId = <%= params[:channel_id] %>;
var windowId =ids[1];
//Need to add data to this request to identify it as a plugin request
var data = {plugin:true, visibility_flag:"<%= @visibility %>"};
$.update("/channels/" + channelId + "/windows/"+ windowId + "/display" , data,
function(response) {
var window = response.window; var plugins = $(".plugin");
var window_type = window.window_type; var addPlugin = $(this);
var colId = window.col; var ids = addPlugin.attr('id').split("-");
var channelId = <%= params[:channel_id] %>;
var windowId =ids[1];
//Need to add data to this request to identify it as a plugin request
var data = {plugin:true, visibility_flag:"<%= @visibility %>"};
$.update("/channels/" + channelId + "/windows/"+ windowId + "/display" , data,
function(response) {
var colName = (window.private_flag == true) ? "private" : "public"; var window = response.window;
var window_type = window.window_type;
var colId = window.col;
addPlugin.hide(); var colName = (window.private_flag == true) ? "private" : "public";
var portlet = addWindow(colName,colId, window.id, window_type, window.title, window.html ); addPlugin.hide();
//for each portlet
portlet.each ( decoratePortlet("true") ); var portlet = addWindow(colName,colId, window.id, window_type, window.title, window.html );
//for each portlet
portlet.find( ".ui-toggle" ).click( uiToggleClick ); portlet.each ( decoratePortlet("true") );
portlet.find( ".ui-view" ).click( uiViewClick (channelId) );
portlet.find( ".ui-edit" ).click( uiEditClick (channelId) );
portlet.find( ".ui-close" ).click( uiCloseClick (channelId) );
}) ;
});
$(".ioportlet").click( portlet.find( ".ui-toggle" ).click( uiToggleClick );
function() { portlet.find( ".ui-view" ).click( uiViewClick (channelId) );
portlet.find( ".ui-edit" ).click( uiEditClick (channelId) );
portlet.find( ".ui-close" ).click( uiCloseClick (channelId) );
}) ;
});
var addPortlet = $(this); // remove handler if it already exists
var ids = addPortlet.attr('id').split("-"); $(document).off('click', '.ioportlet');
var channelId = ids[1];
var windowId =ids[2];
$.update("/channels/" + channelId +"/windows/"+ windowId + "/display" ,
function(response) {
var window = response.window;
var window_type = window.window_type;
var colId = window.col;
var colName = (window.private_flag == true) ? "private" : "public";
addPortlet.hide();
var portlet = addWindow(colName,colId, window.id, window_type, window.title, window.html );
//for each portlet
portlet.each ( decoratePortlet("true") ); // add click handler
$(document).on('click', '.ioportlet', function() {
portlet.find( ".ui-toggle" ).click( uiToggleClick ); var addPortlet = $(this);
portlet.find( ".ui-view" ).click( uiViewClick (channelId) ); var ids = addPortlet.attr('id').split("-");
portlet.find( ".ui-edit" ).click( uiEditClick (channelId) ); var channelId = ids[1];
portlet.find( ".ui-close" ).click( uiCloseClick (channelId) ); var windowId =ids[2];
}) ; $.update("/channels/" + channelId +"/windows/"+ windowId + "/display" ,
}); function(response) {
var window = response.window;
var window_type = window.window_type;
var colId = window.col;
var colName = (window.private_flag == true) ? "private" : "public";
addPortlet.hide();
var portlet = addWindow(colName,colId, window.id, window_type, window.title, window.html );
//for each portlet
portlet.each ( decoratePortlet("true") );
portlet.find( ".ui-toggle" ).click( uiToggleClick );
portlet.find( ".ui-view" ).click( uiViewClick (channelId) );
portlet.find( ".ui-edit" ).click( uiEditClick (channelId) );
portlet.find( ".ui-close" ).click( uiCloseClick (channelId) );
}) ;
});
});
</script> </script>
<div id="tabs"> <div id="tabs">
<ul> <ul>