/* nContent ClientAPI v1.0 */ function ajaxFormSubmit(id, url) { if(!url) { url = $("#"+id).attr("action"); } var Data = {}; var Form = $("#"+id); formData = Form.serializeArray(); $.each(formData, function(){ Data[this.name] = this.value; }); ncModuleInternalAjax(id, url, Data); return false; } function ajaxModuleInternalLink(id, url) { ncModuleInternalAjax(id, url); return false; } function ncModuleInternalAjax(id, url, data) { $.ajax({ type: "POST", url: url, data: data, beforeSend: function() { var height = $("#"+id).height(); $("#"+id).prepend(loading($("#"+id).width(), height)); }, complete: function(xhr) { var Redirect = xhr.getResponseHeader("Content-Location"); if(Redirect) { window.location = Redirect; } $("#loading").remove(); }, success: function(response) { $("#"+id).replaceWith(response); ncLoadGeneral(); } }); } function doCallBack(context, func, data, success, error, beforeSend, complete) { $.ajax({ type: "POST", url: "/", data: { callBackContext: context, callBackFunc: func, callBackData: data }, success: success, beforeSend: beforeSend, compete: complete }); } function loading(width, height) { var loading = $("
", { id: "loading", css: { background: "#ffffff url('/Images/loading.gif') no-repeat center", height: height, width: width, position: "absolute", opacity: "0.7" } }); loading.css("z-index", "1000"); return loading; } function ncConfirmDialog(text, url) { var Div = $("
", { id: "ncConfirmDialog" }).appendTo("body"); Div.html(text); $(Div).dialog({ title: "Aktion bestätigen", modal: true, resizeable: false, close: function() { $(this).remove(); }, buttons: { "Ja": function() { $(this).remove(); if(url) { window.location = url; } return true; }, "Nein": function() { $(this).remove(); return false; } } }); return false; } function ncConfirmDialogAjax(id, text, url) { var Div = $("
", { id: "ncConfirmDialog" }).appendTo("body"); Div.html(text); $(Div).dialog({ title: "Aktion bestätigen", modal: true, resizeable: false, close: function() { $(this).remove(); }, buttons: { "Ja": function() { $(this).remove(); ajaxModuleInternalLink(id, url); }, "Nein": function() { $(this).remove(); } } }); return false; } function ncLoadEditor() { if(jQuery().ckeditor) { $.each(CKEDITOR.instances, function(i) { CKEDITOR.remove(CKEDITOR.instances[i]); } ); var config = { extraPlugins : 'uicolor', toolbar: [['Source','-','Preview','-','Templates'],['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],'/',['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink'],['Image','Table','HorizontalRule','Smiley','SpecialChar'],'/',['Styles','Format','Font','FontSize'],['TextColor','BGColor']], } $(".ncEditor").ckeditor(config); } } function ncLoadTabs() { $(".ncTabs").each(function(i){ if($.cookie("ncTabs_"+i)) { var active = $.cookie("ncTabs_"+i); }else{ var active = 0; } $(this).tabs({ select: active, cookie: { name: "ncTabs_"+i } }); }); } function ncLoadDatePicker() { $(".ncDatePicker").datepicker({ showOn: "button", buttonImage: "/Images/Calendar.png", buttonImageOnly: true, buttonText: 'Kalender', dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'], monthNames: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], dateFormat: "dd.mm.yy" }); $(".ncDatePicker").attr("style", "width: 150px; margin-right: 5px;"); } function ncLoadGeneral() { ncLoadTabs(); ncLoadDatePicker(); ncLoadEditor(); } $(document).ready(function(){ ncLoadGeneral(); }); /** * jQuery Cookie plugin * * Copyright (c) 2010 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * */ jQuery.cookie = function (key, value, options) { // key and at least value given, set cookie... if (arguments.length > 1 && String(value) !== "[object Object]") { options = jQuery.extend({}, options); if (value === null || value === undefined) { options.expires = -1; } if (typeof options.expires === 'number') { var days = options.expires, t = options.expires = new Date(); t.setDate(t.getDate() + days); } value = String(value); return (document.cookie = [ encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : '' ].join('')); } // key and possibly options given, get cookie... options = value || {}; var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; };