jQuery -> $ in admin editor
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
var template_js = '<p class="repo-name">{{{a_tag}}}</p><small>{{address}}</small>';
|
||||
|
||||
function prepareDataForSave(name, data) {
|
||||
var obj = new Object();
|
||||
obj.Name = name;
|
||||
@@ -22,8 +24,8 @@ function prepareMultiPartPOST(data) {
|
||||
}
|
||||
|
||||
function on_error() {
|
||||
jQuery("input[name='saved_on']").attr('style', 'background-color:red');
|
||||
jQuery("input[name='saved_on']").val('communication error');
|
||||
$("input[name='saved_on']").attr('style', 'background-color:red');
|
||||
$("input[name='saved_on']").val('communication error');
|
||||
}
|
||||
|
||||
function doHighlight(highlight) {
|
||||
@@ -36,24 +38,24 @@ function doHighlight(highlight) {
|
||||
|
||||
|
||||
function doClickSave() {
|
||||
var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id');
|
||||
var editor = jQuery(currentTabID + ' textarea').data('editor');
|
||||
var currentTabID = '#' + $('#edit_placeholder div.tab-pane.active').attr('id');
|
||||
var editor = $(currentTabID + ' textarea').data('editor');
|
||||
var data = editor.getValue();
|
||||
var dataForPost = prepareMultiPartPOST(new Array(
|
||||
prepareDataForSave('data', data),
|
||||
prepareDataForSave('file_hash',
|
||||
jQuery(currentTabID + " input[name='file_hash']").val()),
|
||||
$(currentTabID + " input[name='file_hash']").val()),
|
||||
prepareDataForSave('saved_on',
|
||||
jQuery(currentTabID + " input[name='saved_on']").val()),
|
||||
$(currentTabID + " input[name='saved_on']").val()),
|
||||
prepareDataForSave('saved_on',
|
||||
jQuery(currentTabID + " input[name='saved_on']").val()),
|
||||
$(currentTabID + " input[name='saved_on']").val()),
|
||||
prepareDataForSave('from_ajax', 'true')));
|
||||
// console.info(area.textarea.value);
|
||||
jQuery(currentTabID + " input[name='saved_on']").attr('style',
|
||||
$(currentTabID + " input[name='saved_on']").attr('style',
|
||||
'background-color:yellow');
|
||||
jQuery(currentTabID + " input[name='saved_on']").val('saving now...')
|
||||
currentUrl = jQuery(currentTabID + ' form').attr('action');
|
||||
jQuery.ajax({
|
||||
$(currentTabID + " input[name='saved_on']").val('saving now...')
|
||||
currentUrl = $(currentTabID + ' form').attr('action');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
contentType: 'multipart/form-data;boundary="' + dataForPost[1] + '"',
|
||||
url: currentUrl,
|
||||
@@ -67,38 +69,38 @@ function doClickSave() {
|
||||
'doClickSave');
|
||||
},
|
||||
success: function (json, text, xhr) {
|
||||
jQuery(editor).data('saved', true); // Set as saved
|
||||
$(editor).data('saved', true); // Set as saved
|
||||
editor.on("change", store_changes_function); // Re-enable change watcher
|
||||
// reenable disabled submit button
|
||||
var t = jQuery("input[name='save']");
|
||||
var t = $("input[name='save']");
|
||||
t.attr('class', '');
|
||||
t.attr('disabled', '');
|
||||
var flash = xhr.getResponseHeader('web2py-component-flash');
|
||||
if(flash) {
|
||||
jQuery('.flash').html(decodeURIComponent(flash))
|
||||
$('.flash').html(decodeURIComponent(flash))
|
||||
.append('<a href="#" class="close">×</a>')
|
||||
.slideDown();
|
||||
} else jQuery('.flash').hide();
|
||||
} else $('.flash').hide();
|
||||
try {
|
||||
if(json.error) {
|
||||
window.location.href = json.redirect;
|
||||
} else {
|
||||
// console.info( json.file_hash );
|
||||
jQuery(currentTabID + " input[name='file_hash']").val(json.file_hash);
|
||||
jQuery(currentTabID + " input[name='saved_on']").val(json.saved_on);
|
||||
$(currentTabID + " input[name='file_hash']").val(json.file_hash);
|
||||
$(currentTabID + " input[name='saved_on']").val(json.saved_on);
|
||||
if(json.highlight) {
|
||||
doHighlight(json.highlight);
|
||||
} else {
|
||||
jQuery(currentTabID + " input[name='saved_on']").attr('style', 'background-color:#99FF99');
|
||||
//jQuery(".flash").delay(1000).fadeOut('slow');
|
||||
$(currentTabID + " input[name='saved_on']").attr('style', 'background-color:#99FF99');
|
||||
//$(".flash").delay(1000).fadeOut('slow');
|
||||
}
|
||||
// console.info(jQuery("input[name='file_hash']").val());
|
||||
// console.info($("input[name='file_hash']").val());
|
||||
var output = '<b>exposes:</b> ';
|
||||
for(var i in json.functions) {
|
||||
output += ' <a target="_blank" href="/' + json.application + '/' + json.controller + '/' + json.functions[i] + '">' + json.functions[i] + '</a>,';
|
||||
}
|
||||
if(output != '<b>exposes:</b> ') {
|
||||
jQuery(currentTabID + " .exposed").html(output.substring(0, output.length - 1));
|
||||
$(currentTabID + " .exposed").html(output.substring(0, output.length - 1));
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
@@ -113,8 +115,8 @@ function doClickSave() {
|
||||
}
|
||||
|
||||
function getActiveEditor() {
|
||||
var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id');
|
||||
var editor = jQuery(currentTabID + ' textarea').data('editor');
|
||||
var currentTabID = '#' + $('#edit_placeholder div.tab-pane.active').attr('id');
|
||||
var editor = $(currentTabID + ' textarea').data('editor');
|
||||
return editor;
|
||||
}
|
||||
|
||||
@@ -139,7 +141,7 @@ function doToggleBreakpoint(filename, url, sel) {
|
||||
prepareDataForSave('sel_start', sel["start"]),
|
||||
prepareDataForSave('sel_end', sel["end"]),
|
||||
prepareDataForSave('data', sel['data'])));
|
||||
jQuery.ajax({
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
contentType: 'multipart/form-data;boundary="' + dataForPost[1] + '"',
|
||||
url: url,
|
||||
@@ -156,10 +158,10 @@ function doToggleBreakpoint(filename, url, sel) {
|
||||
// show flash message (if any)
|
||||
var flash = xhr.getResponseHeader('web2py-component-flash');
|
||||
if(flash) {
|
||||
jQuery('.flash').html(decodeURIComponent(flash))
|
||||
$('.flash').html(decodeURIComponent(flash))
|
||||
.append('<a href="#" class="close">×</a>')
|
||||
.slideDown();
|
||||
} else jQuery('.flash').hide();
|
||||
} else $('.flash').hide();
|
||||
try {
|
||||
if(json.error) {
|
||||
window.location.href = json.redirect;
|
||||
@@ -189,7 +191,7 @@ function doListBreakpoints(filename, url, editor) {
|
||||
var dataForPost = prepareMultiPartPOST(new Array(
|
||||
prepareDataForSave('filename', filename)
|
||||
));
|
||||
jQuery.ajax({
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
contentType: 'multipart/form-data;boundary="' + dataForPost[1] + '"',
|
||||
url: url,
|
||||
@@ -235,7 +237,7 @@ function makeMarker() {
|
||||
|
||||
|
||||
function keepalive(url) {
|
||||
jQuery.ajax({
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
timeout: 1000,
|
||||
@@ -247,7 +249,7 @@ function keepalive(url) {
|
||||
}
|
||||
|
||||
function load_file(url) {
|
||||
jQuery.ajax({
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
contentType: 'application/json',
|
||||
cache: false,
|
||||
@@ -256,18 +258,18 @@ function load_file(url) {
|
||||
timeout: 1000,
|
||||
success: function (json) {
|
||||
if(typeof (json['plain_html']) !== undefined) {
|
||||
if(jQuery('#' + json['id']).length === 0 || json['force'] === true) {
|
||||
if($('#' + json['id']).length === 0 || json['force'] === true) {
|
||||
// Create a tab and put the code in it
|
||||
var tab_header = '<li><a href="#' + json['id'] + '" data-toggle="tab">' + json['filename'] + '<button type="button" class="close">×</button></a></li>';
|
||||
var tab_body = '<div id="' + json['id'] + '" class="tab-pane fade in " >' + json['plain_html'] + '</div>';
|
||||
if(json['force'] === false) {
|
||||
jQuery('#filesTab').append(jQuery(tab_header));
|
||||
jQuery('#myTabContent').append(jQuery(tab_body));
|
||||
$('#filesTab').append($(tab_header));
|
||||
$('#myTabContent').append($(tab_body));
|
||||
} else {
|
||||
jQuery('#' + json['id']).html(jQuery(tab_body));
|
||||
$('#' + json['id']).html($(tab_body));
|
||||
}
|
||||
}
|
||||
jQuery("a[href='#" + json['id'] + "']").click();
|
||||
$("a[href='#" + json['id'] + "']").click();
|
||||
}
|
||||
},
|
||||
error: function (x) {
|
||||
@@ -279,11 +281,11 @@ function load_file(url) {
|
||||
function set_font(editor, incr) {
|
||||
var fontSize = '';
|
||||
if(incr !== 0) {
|
||||
fontSize = parseInt(jQuery(editor.getWrapperElement()).css('font-size'));
|
||||
fontSize = parseInt($(editor.getWrapperElement()).css('font-size'));
|
||||
fontSize = fontSize + incr + "px";
|
||||
}
|
||||
jQuery(editor.getWrapperElement()).css('font-size', fontSize);
|
||||
$(editor.getWrapperElement()).css('font-size', fontSize);
|
||||
editor.refresh();
|
||||
}
|
||||
|
||||
var template_js = '<p class="repo-name">{{{a_tag}}}</p><small>{{address}}</small>';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user