yavsc/web/Scripts/yavsc.js

120 lines
3.1 KiB
JavaScript

var Yavsc = (function(apiBaseUrl){
var self = {};
self.dumpprops = function (obj) {
var str = "";
for(var k in obj)
if (obj.hasOwnProperty(k))
str += k + " = " + obj[k] + "\n";
return (str); }
self.apiBaseUrl = (apiBaseUrl || '/api');
self.showHide = function () {
var id = $(this).attr('did');
var target = $('#'+id);
if (target.hasClass('hidden')) {
target.removeClass('hidden');
if (typeof this.oldhtml == "undefined")
this.oldhtml = $(this).html();
$(this).html('['+this.oldhtml+']');
}
else {
target.addClass('hidden');
$(this).html(this.oldhtml);
}
};
self.dimiss = function () {
$(this).parent().remove();
};
self.ajax = function (method,data,callback) {
$.ajax({
url: self.apiBaseUrl+method,
type: "POST",
data: data,
success: function (response) {
if (callback) callback(response);
},
statusCode: {
400: Yavsc.onAjaxBadInput
},
error: Yavsc.onAjaxError});
};
9 years ago
self.onScroll = function() {
var $notifications = $('#notifications');
9 years ago
if ($notifications.has('*').length>0) {
if ($(window).scrollTop()>100) {
$notifications.addClass("dispmodal");
9 years ago
}
else {
$notifications.removeClass("dispmodal");
9 years ago
}}
};
self.notice = function (msg, callback, msgok) {
if (!msgok) msgok='Ok';
var note = $('<div class="notification">'+msg+'<br></div>');
var btn = $('<a class="actionlink"><i class="fa fa-check">'+msgok+'</i></a>');
if (callback) btn.click(callback);
btn.click(self.dimiss).appendTo(note);
note.appendTo("#notifications");
9 years ago
self.onScroll();
};
* mdd_help.htm: * mdd_styles.css: * LocalizedText.resx: * all.css: * jquery-ui-1.11.4.js: * tabs.css: * menu.css: * core.css: * base.css: * LocalizedText.fr.resx: * theme.css: * slider.css: * button.css: * dialog.css: * spinner.css: * tooltip.css: * jquery-ui-1.11.4.min.js: * sortable.css: * LocalizedText.Designer.cs: * resizable.css: * accordion.css: * draggable.css: * selectmenu.css: * selectable.css: * datepicker.css: * progressbar.css: * LocalizedText.fr.Designer.cs: * autocomplete.css: * ui-icons_888888_256x240.png: * ui-icons_cd0a0a_256x240.png: * ui-icons_454545_256x240.png: * ui-icons_2e83ff_256x240.png: * ui-icons_222222_256x240.png: * ui-bg_flat_0_aaaaaa_40x100.png: * ui-bg_glass_95_fef1ec_1x400.png: * ui-bg_flat_75_ffffff_40x100.png: * ui-bg_glass_55_fbf9ee_1x400.png: * ui-bg_glass_65_ffffff_1x400.png: * ui-bg_glass_75_dadada_1x400.png: * ui-bg_glass_75_e6e6e6_1x400.png: * ui-bg_highlight-soft_75_cccccc_1x100.png: * BlogsController.cs: implements the access control on file upload to blog entries * style.css: nicer appmenu * BlogsController.cs: Enables the input validation at posting blog entries * MarkdownHelper.cs: enables ExtraMode transformation parameter * App.master: Error and message html divisions must exist in the DOM to display Ajax messages and errors * yavsc.js: * yavsc.circles.js: refactoring * Circles.aspx: removes a DOM element that already exists in the mastyer page : the message box * Edit.aspx: submits files for import as Markdown text * Web.config: Disables the local trace * Web.csproj: jQuery.UI addition * packages.config: adds a ref to jQuery.UI Combined
9 years ago
self.onAjaxBadInput = function (data)
* mdd_help.htm: * mdd_styles.css: * LocalizedText.resx: * all.css: * jquery-ui-1.11.4.js: * tabs.css: * menu.css: * core.css: * base.css: * LocalizedText.fr.resx: * theme.css: * slider.css: * button.css: * dialog.css: * spinner.css: * tooltip.css: * jquery-ui-1.11.4.min.js: * sortable.css: * LocalizedText.Designer.cs: * resizable.css: * accordion.css: * draggable.css: * selectmenu.css: * selectable.css: * datepicker.css: * progressbar.css: * LocalizedText.fr.Designer.cs: * autocomplete.css: * ui-icons_888888_256x240.png: * ui-icons_cd0a0a_256x240.png: * ui-icons_454545_256x240.png: * ui-icons_2e83ff_256x240.png: * ui-icons_222222_256x240.png: * ui-bg_flat_0_aaaaaa_40x100.png: * ui-bg_glass_95_fef1ec_1x400.png: * ui-bg_flat_75_ffffff_40x100.png: * ui-bg_glass_55_fbf9ee_1x400.png: * ui-bg_glass_65_ffffff_1x400.png: * ui-bg_glass_75_dadada_1x400.png: * ui-bg_glass_75_e6e6e6_1x400.png: * ui-bg_highlight-soft_75_cccccc_1x100.png: * BlogsController.cs: implements the access control on file upload to blog entries * style.css: nicer appmenu * BlogsController.cs: Enables the input validation at posting blog entries * MarkdownHelper.cs: enables ExtraMode transformation parameter * App.master: Error and message html divisions must exist in the DOM to display Ajax messages and errors * yavsc.js: * yavsc.circles.js: refactoring * Circles.aspx: removes a DOM element that already exists in the mastyer page : the message box * Edit.aspx: submits files for import as Markdown text * Web.config: Disables the local trace * Web.csproj: jQuery.UI addition * packages.config: adds a ref to jQuery.UI Combined
9 years ago
{
if (!data) { Yavsc.notice('no data'); return; }
if (!data.responseJSON) { Yavsc.notice('no json data:'+data); return; }
if (!Array.isArray(data.responseJSON)) { Yavsc.notice('Bad Input: '+data.responseJSON); return; }
* mdd_help.htm: * mdd_styles.css: * LocalizedText.resx: * all.css: * jquery-ui-1.11.4.js: * tabs.css: * menu.css: * core.css: * base.css: * LocalizedText.fr.resx: * theme.css: * slider.css: * button.css: * dialog.css: * spinner.css: * tooltip.css: * jquery-ui-1.11.4.min.js: * sortable.css: * LocalizedText.Designer.cs: * resizable.css: * accordion.css: * draggable.css: * selectmenu.css: * selectable.css: * datepicker.css: * progressbar.css: * LocalizedText.fr.Designer.cs: * autocomplete.css: * ui-icons_888888_256x240.png: * ui-icons_cd0a0a_256x240.png: * ui-icons_454545_256x240.png: * ui-icons_2e83ff_256x240.png: * ui-icons_222222_256x240.png: * ui-bg_flat_0_aaaaaa_40x100.png: * ui-bg_glass_95_fef1ec_1x400.png: * ui-bg_flat_75_ffffff_40x100.png: * ui-bg_glass_55_fbf9ee_1x400.png: * ui-bg_glass_65_ffffff_1x400.png: * ui-bg_glass_75_dadada_1x400.png: * ui-bg_glass_75_e6e6e6_1x400.png: * ui-bg_highlight-soft_75_cccccc_1x100.png: * BlogsController.cs: implements the access control on file upload to blog entries * style.css: nicer appmenu * BlogsController.cs: Enables the input validation at posting blog entries * MarkdownHelper.cs: enables ExtraMode transformation parameter * App.master: Error and message html divisions must exist in the DOM to display Ajax messages and errors * yavsc.js: * yavsc.circles.js: refactoring * Circles.aspx: removes a DOM element that already exists in the mastyer page : the message box * Edit.aspx: submits files for import as Markdown text * Web.config: Disables the local trace * Web.csproj: jQuery.UI addition * packages.config: adds a ref to jQuery.UI Combined
9 years ago
$.each(data.responseJSON, function (key, value) {
var errspanid = "Err_" + value.key;
* mdd_help.htm: * mdd_styles.css: * LocalizedText.resx: * all.css: * jquery-ui-1.11.4.js: * tabs.css: * menu.css: * core.css: * base.css: * LocalizedText.fr.resx: * theme.css: * slider.css: * button.css: * dialog.css: * spinner.css: * tooltip.css: * jquery-ui-1.11.4.min.js: * sortable.css: * LocalizedText.Designer.cs: * resizable.css: * accordion.css: * draggable.css: * selectmenu.css: * selectable.css: * datepicker.css: * progressbar.css: * LocalizedText.fr.Designer.cs: * autocomplete.css: * ui-icons_888888_256x240.png: * ui-icons_cd0a0a_256x240.png: * ui-icons_454545_256x240.png: * ui-icons_2e83ff_256x240.png: * ui-icons_222222_256x240.png: * ui-bg_flat_0_aaaaaa_40x100.png: * ui-bg_glass_95_fef1ec_1x400.png: * ui-bg_flat_75_ffffff_40x100.png: * ui-bg_glass_55_fbf9ee_1x400.png: * ui-bg_glass_65_ffffff_1x400.png: * ui-bg_glass_75_dadada_1x400.png: * ui-bg_glass_75_e6e6e6_1x400.png: * ui-bg_highlight-soft_75_cccccc_1x100.png: * BlogsController.cs: implements the access control on file upload to blog entries * style.css: nicer appmenu * BlogsController.cs: Enables the input validation at posting blog entries * MarkdownHelper.cs: enables ExtraMode transformation parameter * App.master: Error and message html divisions must exist in the DOM to display Ajax messages and errors * yavsc.js: * yavsc.circles.js: refactoring * Circles.aspx: removes a DOM element that already exists in the mastyer page : the message box * Edit.aspx: submits files for import as Markdown text * Web.config: Disables the local trace * Web.csproj: jQuery.UI addition * packages.config: adds a ref to jQuery.UI Combined
9 years ago
var errspan = document.getElementById(errspanid);
if (errspan==null)
alert('enoent '+errspanid);
else
errspan.innerHTML=value.errors.join("<br/>");
});
};
* mdd_help.htm: * mdd_styles.css: * LocalizedText.resx: * all.css: * jquery-ui-1.11.4.js: * tabs.css: * menu.css: * core.css: * base.css: * LocalizedText.fr.resx: * theme.css: * slider.css: * button.css: * dialog.css: * spinner.css: * tooltip.css: * jquery-ui-1.11.4.min.js: * sortable.css: * LocalizedText.Designer.cs: * resizable.css: * accordion.css: * draggable.css: * selectmenu.css: * selectable.css: * datepicker.css: * progressbar.css: * LocalizedText.fr.Designer.cs: * autocomplete.css: * ui-icons_888888_256x240.png: * ui-icons_cd0a0a_256x240.png: * ui-icons_454545_256x240.png: * ui-icons_2e83ff_256x240.png: * ui-icons_222222_256x240.png: * ui-bg_flat_0_aaaaaa_40x100.png: * ui-bg_glass_95_fef1ec_1x400.png: * ui-bg_flat_75_ffffff_40x100.png: * ui-bg_glass_55_fbf9ee_1x400.png: * ui-bg_glass_65_ffffff_1x400.png: * ui-bg_glass_75_dadada_1x400.png: * ui-bg_glass_75_e6e6e6_1x400.png: * ui-bg_highlight-soft_75_cccccc_1x100.png: * BlogsController.cs: implements the access control on file upload to blog entries * style.css: nicer appmenu * BlogsController.cs: Enables the input validation at posting blog entries * MarkdownHelper.cs: enables ExtraMode transformation parameter * App.master: Error and message html divisions must exist in the DOM to display Ajax messages and errors * yavsc.js: * yavsc.circles.js: refactoring * Circles.aspx: removes a DOM element that already exists in the mastyer page : the message box * Edit.aspx: submits files for import as Markdown text * Web.config: Disables the local trace * Web.csproj: jQuery.UI addition * packages.config: adds a ref to jQuery.UI Combined
9 years ago
self.onAjaxError = function (xhr, ajaxOptions, thrownError) {
if (xhr.status!=400)
Yavsc.notice(xhr.status+" : "+xhr.responseText);
};
9 years ago
$(document).ready(function(){
$('.maskable').each( function() {
var $mobj = $(this);
var $btnshow = $('#'+$mobj.data('btn-show'));
var $btnhide = $('#'+$mobj.data('btn-hide'));
var onClickHide = function(){
$mobj.addClass('hidden');
$btnshow.removeClass('hidden');
$btnhide.addClass('hidden');
};
$btnhide.click(onClickHide);
onClickHide();
$btnshow.click(function(){
$mobj.removeClass('hidden');
$btnshow.addClass('hidden');
$btnhide.removeClass('hidden');
});
});
});
$(document).ready(function(){
$body = $("body");
$(document).on({
ajaxStart: function() { $body.addClass("loading"); },
ajaxStop: function() { $body.removeClass("loading"); }
});
9 years ago
$(window).scroll(self.onScroll);
});
9 years ago
return self;
})();