openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit c3af456ed7c5652a1a84f0f6b681f1a693d85a46
parent 48f40860feb9218f73024ea64243dd36089109da
Author: Jan Dankert <devnull@localhost>
Date:   Fri, 10 Nov 2017 23:25:22 +0100

Automatisches Minifizieren von Javascripten im Development-Mode. Im Production-Mode wird aufgrund der Laufzeit nicht minifiziert und nur die minifizierte Version gelesen (sofern verfügbar, sonst die normale).

Diffstat:
action/IndexAction.class.php | 108++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
script/create-output-files.sh | 0
themes/default/include/html/form/form.js | 1+
themes/default/include/html/form/form.min.js | 4++++
themes/default/include/html/group/group.min.js | 7+++++++
themes/default/include/html/qrcode/qrcode.min.js | 15+++++++++++++++
themes/default/include/html/table/table.min.js | 41+++++++++++++++++++++++++++++++++++++++++
themes/default/include/html/upload/upload.min.js | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
themes/default/js/editor.min.js | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
themes/default/js/jquery.mjs.nestedSortable.min.js | 427+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
themes/default/js/jquery.scrollTo.min.js | 217+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
themes/default/js/mark.min.js | 27+++++++++++++++++++++++++++
themes/default/js/openrat.js | 2+-
themes/default/js/openrat.min.js | 20++++++++++++++++++++
themes/default/js/plugin/jquery-plugin-orAutoheight.min.js | 23+++++++++++++++++++++++
themes/default/js/plugin/jquery-plugin-orHint.min.js | 23+++++++++++++++++++++++
themes/default/js/plugin/jquery-plugin-orLinkify.min.js | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
themes/default/js/plugin/jquery-plugin-orLoadView.min.js | 21+++++++++++++++++++++
themes/default/js/plugin/jquery-plugin-orSearch.min.js | 39+++++++++++++++++++++++++++++++++++++++
themes/default/js/plugin/jquery-plugin-orTree.min.js | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20 files changed, 1266 insertions(+), 35 deletions(-)

diff --git a/action/IndexAction.class.php b/action/IndexAction.class.php @@ -221,45 +221,34 @@ class IndexAction extends Action header('Content-Type: text/javascript'); - function minifyJS( $source ) { - $jz = new JSqueeze(); - - return $jz->squeeze( - $source, - true, // $singleLine - true, // $keepImportantComments - false // $specialVarRx - ); - } - $js = array(); - $js[] = OR_THEMES_EXT_DIR.'default/js/jquery-1.12.4.min.js'; - $js[] = OR_THEMES_EXT_DIR.'default/js/jquery-ui/js/jquery-ui-1.8.16.custom.min.js'; - $js[] = OR_THEMES_EXT_DIR.'default/js/jquery.scrollTo.js'; + $js[] = OR_THEMES_EXT_DIR.'default/js/jquery-1.12.4'; + $js[] = OR_THEMES_EXT_DIR.'default/js/jquery-ui/js/jquery-ui-1.8.16.custom'; + $js[] = OR_THEMES_EXT_DIR.'default/js/jquery.scrollTo'; //$js[] = OR_THEMES_EXT_DIR default/js/jquery.mjs.nestedSortable.js"></script> //<!-- OpenRat internal JS --> - $js[] = OR_THEMES_EXT_DIR.'default/js/openrat.js'; - $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orHint.js'; - $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orSearch.js'; - $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orLinkify.js'; - $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orTree.js'; - $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orLoadView.js'; - $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orAutoheight.js'; - $js[] = OR_THEMES_EXT_DIR.'default/js/jquery-qrcode.min.js'; + $js[] = OR_THEMES_EXT_DIR.'default/js/openrat'; + $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orHint'; + $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orSearch'; + $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orLinkify'; + $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orTree'; + $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orLoadView'; + $js[] = OR_THEMES_EXT_DIR.'default/js/plugin/jquery-plugin-orAutoheight'; + $js[] = OR_THEMES_EXT_DIR.'default/js/jquery-qrcode'; // $js[] = OR_THEMES_EXT_DIR.'../editor/wymeditor/wymeditor/jquery.wymeditor.min.js"></script> --> - $js[] = OR_THEMES_EXT_DIR.'../editor/markitup/markitup/jquery.markitup.js'; - $js[] = OR_THEMES_EXT_DIR.'../editor/editor/ckeditor.js'; - $js[] = OR_THEMES_EXT_DIR.'../editor/ace/src-min-noconflict/ace.js'; - $js[] = OR_THEMES_EXT_DIR.'../editor/editor/adapters/jquery.js'; + $js[] = OR_THEMES_EXT_DIR.'../editor/markitup/markitup/jquery.markitup'; + $js[] = OR_THEMES_EXT_DIR.'../editor/editor/ckeditor'; + $js[] = OR_THEMES_EXT_DIR.'../editor/ace/src-min-noconflict/ace'; + $js[] = OR_THEMES_EXT_DIR.'../editor/editor/adapters/jquery'; // Komponentenbasiertes Javascript $elements = parse_ini_file( OR_THEMES_DIR.config('interface','theme').'/include/elements.ini.'.PHP_EXT); foreach( array_keys($elements) as $c ) { - $componentJsFile = OR_THEMES_DIR.config('interface','theme').'/include/html/'.$c.'/'.$c.'.js'; - if ( is_file($componentJsFile) ) + $componentJsFile = OR_THEMES_DIR.config('interface','theme').'/include/html/'.$c.'/'.$c; + if ( is_file($componentJsFile.'.js') ) $js[] = $componentJsFile; } @@ -269,17 +258,68 @@ class IndexAction extends Action foreach( $js as $jsFile ) { - echo "\n// JS source file: $jsFile\n"; - readFile($jsFile); + $jsFileMin = $jsFile.'.min.js'; + $jsFileNormal = $jsFile.'.js'; + + if ( !is_file($jsFileMin) && is_file($jsFileMin)) + { + // Es gibt nur eine minifizierte JS. Das ist ok, z.B. bei externen Bibliotheken. + echo "\n// JS-Source: $jsFileMin\n"; + readfile($jsFileMin); + } + elseif ( !is_file($jsFileNormal)) + { + echo "\n// File $jsFileNormal is missing!"; + Logger::warn("No Javascript file found for $jsFileNormal"); + } + elseif ( !is_file($jsFileMin)) + { + echo "\n// File $jsFileMin is missing!"; + Logger::warn("No Javascript file found for $jsFileMin"); + echo "\n// JS-Source: $jsFileNormal\n"; + readfile($jsFileNormal); + } + else + { + if( filemtime($jsFileNormal) > filemtime($jsFileMin) ) + { + // Java-Source wurde geändert, minifizierte Version muss aktualisiert werden. + if ( !is_writable($jsFileMin)) + { + echo "// File $jsFileMin is not writable!"; + Logger::warn("No Javascript file found for $jsFileMin"); + } + else + { + $jz = new JSqueeze(); + + file_put_contents( $jsFileMin, $jz->squeeze( + file_get_contents($jsFileNormal), + true, // $singleLine + true, // $keepImportantComments + false // $specialVarRx + ) + ); + } + } + + echo "\n// JS-Source: $jsFileNormal\n"; + readfile($jsFileNormal); + } } } else - { + { // PRODUCTION foreach( $js as $jsFile ) { - ob_start('minifyJS'); - echo minifyJS( file_get_contents($jsFile)); - ob_end_flush(); + $jsFileMin = $jsFile.'.min.js'; + $jsFileNormal = $jsFile.'.js'; + if ( is_file($jsFileMin)) + readfile($jsFileMin); + elseif( is_file($jsFileNormal)) + readfile($jsFileNormal); + else + Logger::warn("No Javascript file found for $jsFile(.js|.min.js)"); } } diff --git a/script/create-output-files.sh b/script/create-output-files.sh diff --git a/themes/default/include/html/form/form.js b/themes/default/include/html/form/form.js @@ -1,3 +1,4 @@ +// $(document).on('orViewLoaded',function(event, data) { if ( $('div.panel form input[type=password]').length>0 && $('#uname').attr('value')!='' ) diff --git a/themes/default/include/html/form/form.min.js b/themes/default/include/html/form/form.min.js @@ -0,0 +1,3 @@ +;$(document).on('orViewLoaded',function(e,t){if($('div.panel form input[type=password]').length>0&&$('#uname').attr('value')!=''){$('div.panel form input[name=login_name] ').attr('value',$('#uname').attr('value'));$('div.panel form input[name=login_password]').attr('value',$('#upassword').attr('value'))};$(e.target).find('form[data-autosave="true"] input[type="checkbox"]').click(function(){formSubmit($(this).closest('form'))})});function formSubmit(e){if($('div.panel form input[type=password]').length>0){$('#uname').attr('value',$('div.panel form input[name=login_name]').attr('value'));$('#upassword').attr('value',$('div.panel form input[name=login_password]').attr('value'));$('#uname').closest('form').submit()};if($('#pageelement_edit_editor').length>0){var r=CKEDITOR.instances['pageelement_edit_editor'];if(r){var l=r.getData();$('#pageelement_edit_editor').html(l)}};var t=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(t);$(t).show();$(e).find('.error').removeClass('error');var a=$(e).serializeArray(),o='./dispatcher.php',d=$(e).attr('method').toUpperCase();if(d=='GET'){var i=$(e).data('action'),n=$(e).data('method'),s=$(e).data('id');loadView($(e).closest('div.content'),i,n,s,a)} +else{$(e).closest('div.content').addClass('loader');o+='?output=json';a['output']='json';if($(e).data('async')||$(e).data('async')=='true'){$('div#dialog').html('').hide();$('div#filler').fadeOut(500)};$.ajax({'type':'POST',url:o,data:a,success:function(a,o,r){$(e).closest('div.content').removeClass('loader');$(t).remove();doResponse(a,o,e)},error:function(a,o,n){$(e).closest('div.content').removeClass('loader');$(t).remove();var i;try{var r=jQuery.parseJSON(a.responseText);i=r.error+'/'+r.description+': '+r.reason}catch(s){i=a.responseText};notify('error',i)}});$(e).fadeIn()}};function doResponse(e,t,a){if(t!='success'){alert('Server error: '+t);return};$.each(e['notices'],function(t,e){var o=$('<div class="notice '+e.status+'"><div class="text">'+e.text+'</div></div>');notifyBrowser(e.text);$.each(e.log,function(e,t){$(o).append('<div class="log">'+t+'</div>')});$('#noticebar').prepend(o);$(o).fadeIn().click(function(){$(this).fadeOut('fast',function(){$(this).remove()})});var r;if(e.status=='ok'){r=3;if($(a).data('async')!='true'){$('div#dialog').html('').hide();$('div#filler').fadeOut(500);$(a).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')}} +else{r=8};setTimeout(function(){$(o).fadeOut('slow').remove()},r*1000)});$.each(e['errors'],function(e,t){$('input[name='+t+']').addClass('error').parent().addClass('error').parents('fieldset').addClass('show').addClass('open')});if(!e.control){};if(e.control.redirect)window.location.href=e.control.redirect;if(e.control.new_style)setUserStyle(e.control.new_style);if(e.control.refresh)refreshAll();else if(e.control.next_view)startView($(a).closest('div.content'),e.control.next_view);else if(e.errors.length==0)$(a).closest('div.panel').find('li.action.active').orLoadView()};+ \ No newline at end of file diff --git a/themes/default/include/html/group/group.min.js b/themes/default/include/html/group/group.min.js @@ -0,0 +1,6 @@ +$(document).on('orViewLoaded',function(event, data) { + + $(event.target).find('fieldset > legend').click( function() { + $(this).parent().toggleClass('open'); + }); +});+ \ No newline at end of file diff --git a/themes/default/include/html/qrcode/qrcode.min.js b/themes/default/include/html/qrcode/qrcode.min.js @@ -0,0 +1,14 @@ + +$(document).on('orViewLoaded',function(event, data) { + + // QR-Code anzeigen. + $(event.target).find('[data-qrcode]').each( function() { + + var qrcodetext = $(this).attr('data-qrcode'); + $(this).removeAttr('data-qrcode'); + + $(this).qrcode( { render : 'div', + text : qrcodetext, + fill : 'currentColor' } ); + } ); +} );+ \ No newline at end of file diff --git a/themes/default/include/html/table/table.min.js b/themes/default/include/html/table/table.min.js @@ -0,0 +1,40 @@ +$(document).on('orViewLoaded',function(event, data) { + +// Sortieren von Tabellen + $(event.target).find('table.sortable > tbody').sortable({ + update: function(event, ui) + { + $(ui).addClass('loader'); + var order = []; + $(ui.item).closest('table.sortable').find('tbody > tr.data').each( function() { + var objectid = $(this).data('id'); + order.push( objectid ); + }); + var url = './dispatcher.php'; + var params = {}; + params.action = 'folder'; + params.subaction = 'order'; + params.token = $('div.action-folder.method-order input[name=token]').attr('value'); + params.order = order.join(','); + params.id = $('div#dialog').data('id'); + params.output = 'json'; + + $.ajax( { 'type':'POST',url:url, data:params, success:function(data, textStatus, jqXHR) + { + $(ui).removeClass('loader'); + doResponse(data,textStatus,ui); + }, + error:function(jqXHR, textStatus, errorThrown) { + alert( errorThrown ); + } + + } ); + } + }); + + // Alle Checkboxen setzen oder nicht setzen. + $(event.target).find('tr.headline > td > input.checkbox').click( function() { + $(this).closest('table').find('tr.data > td > input.checkbox').attr('checked',Boolean( $(this).attr('checked') ) ); + }); + +});+ \ No newline at end of file diff --git a/themes/default/include/html/upload/upload.min.js b/themes/default/include/html/upload/upload.min.js @@ -0,0 +1,85 @@ +$(document).on('orViewLoaded',function(event, data) { + + var form = $(event.target).find('form'); + + // Dateiupload über Drag and Drop + var dropzone = $(event.target).find('div.filedropzone > div.input'); + dropzone.on('dragenter', function (e) + { + e.stopPropagation(); + e.preventDefault(); + $(this).css('border', '1px dotted gray'); + }); + dropzone.on('dragover', function (e) + { + e.stopPropagation(); + e.preventDefault(); + }); + dropzone.on('drop', function (e) + { + $(this).css('border','1px dotted red'); + e.preventDefault(); + var files = e.originalEvent.dataTransfer.files; + + //We need to send dropped files to Server + handleFileUpload(form,files); + }); + + + // Dateiupload über File-Input-Button + $(event.target).find('input[type=file]').change( function() { + + var files = $(this).prop('files'); + + handleFileUpload(form,files); + }); + +}); + + + + + + +function handleFileUpload(form,files) +{ + for (var i = 0, f; f = files[i]; i++) + { + var form_data = new FormData(); + form_data.append('file' , f); + form_data.append('action' ,'folder'); + form_data.append('subaction','createfile'); + form_data.append('output' ,'json'); + form_data.append('token' ,$(form).find('input[name=token]').val() ); + form_data.append('id' ,$(form).find('input[name=id]' ).val() ); + + var status = $('<div class="notice info"><div class="text loader"></div></div>'); + $('#noticebar').prepend(status); // Notice anhängen. + $(status).show(); + + $.ajax( { 'type':'POST',url:'dispatcher.php', cache:false,contentType: false, processData: false, data:form_data, success:function(data, textStatus, jqXHR) + { + $(status).remove(); + doResponse(data,textStatus,form); + }, + error:function(jqXHR, textStatus, errorThrown) { + $(form).closest('div.content').removeClass('loader'); + $(status).remove(); + + var msg; + try + { + var error = jQuery.parseJSON( jqXHR.responseText ); + msg = error.error + '/' + error.description + ': ' + error.reason; + } + catch( e ) + { + msg = jqXHR.responseText; + } + + notify('error',msg); + } + + } ); + } +} diff --git a/themes/default/js/editor.min.js b/themes/default/js/editor.min.js @@ -0,0 +1,64 @@ + +// Quelle: +// http://aktuell.de.selfhtml.org/tippstricks/javascript/bbcode/ +function insert(tagName, aTag, eTag) +{ + var input = document.forms[0].elements[tagName]; + input.focus(); + /* IE */ + if(typeof document.selection != 'undefined') { + /* Einfuegen des Formatierungscodes */ +// alert('IE'); + var range = document.selection.createRange(); + var insText = range.text; + range.text = aTag + insText + eTag; + /* Anpassen der Cursorposition */ + range = document.selection.createRange(); + if (insText.length == 0) { + range.move('character', -eTag.length); + } else { + range.moveStart('character', aTag.length + insText.length + eTag.length); + } + range.select(); + } + /* Gecko */ + else if(typeof input.selectionStart != 'undefined') + { +// alert('Gecko'); + /* Einfuegen des Formatierungscodes */ + var start = input.selectionStart; + var end = input.selectionEnd; + var insText = input.value.substring(start, end); + input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end); + /* Anpassen der Cursorposition */ + var pos; + if (insText.length == 0) { + pos = start + aTag.length; + } else { + pos = start + aTag.length + insText.length + eTag.length; + } + input.selectionStart = pos; + input.selectionEnd = pos; + } + /* uebrige Browser */ + else + { + /* Abfrage der Einfuegeposition */ + + /* + var pos; + var re = new RegExp('^[0-9]{0,3}$'); + while(!re.test(pos)) { + pos = prompt("Position (0.." + input.value.length + "):", "0"); + } + if(pos > input.value.length) { + pos = input.value.length; + } + */ + pos = input.value.length; + + /* Einfuegen des Formatierungscodes */ + var insText = prompt("Text"); + input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos); + } +} diff --git a/themes/default/js/jquery.mjs.nestedSortable.min.js b/themes/default/js/jquery.mjs.nestedSortable.min.js @@ -0,0 +1,426 @@ +/* + * jQuery UI Nested Sortable + * v 1.3.5 / 21 jun 2012 + * http://mjsarfatti.com/code/nestedSortable + * + * Depends on: + * jquery.ui.sortable.js 1.8+ + * + * Copyright (c) 2010-2012 Manuele J Sarfatti + * Licensed under the MIT License + * http://www.opensource.org/licenses/mit-license.php + */ + +(function($) { + + $.widget("mjs.nestedSortable", $.extend({}, $.ui.sortable.prototype, { + + options: { + tabSize: 20, + disableNesting: 'mjs-nestedSortable-no-nesting', + errorClass: 'mjs-nestedSortable-error', + listType: 'ol', + maxLevels: 0, + protectRoot: false, + rootID: null, + rtl: false, + isAllowed: function(item, parent) { return true; } + }, + + _create: function() { + this.element.data('sortable', this.element.data('nestedSortable')); + + if (!this.element.is(this.options.listType)) + throw new Error('nestedSortable: Please check the listType option is set to your actual list type'); + + return $.ui.sortable.prototype._create.apply(this, arguments); + }, + + destroy: function() { + this.element + .removeData("nestedSortable") + .unbind(".nestedSortable"); + return $.ui.sortable.prototype.destroy.apply(this, arguments); + }, + + _mouseDrag: function(event) { + + //Compute the helpers position + this.position = this._generatePosition(event); + this.positionAbs = this._convertPositionTo("absolute"); + + if (!this.lastPositionAbs) { + this.lastPositionAbs = this.positionAbs; + } + + //Do scrolling + if(this.options.scroll) { + var o = this.options, scrolled = false; + if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') { + + if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) + this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; + else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) + this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; + + if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) + this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; + else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) + this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; + + } else { + + if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) + scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); + else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) + scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); + + if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) + scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); + else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) + scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); + + } + + if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) + $.ui.ddmanager.prepareOffsets(this, event); + } + + //Regenerate the absolute position used for position checks + this.positionAbs = this._convertPositionTo("absolute"); + + // Find the top offset before rearrangement, + var previousTopOffset = this.placeholder.offset().top; + + //Set the helper position + if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; + if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; + + //Rearrange + for (var i = this.items.length - 1; i >= 0; i--) { + + //Cache variables and intersection, continue if no intersection + var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item); + if (!intersection) continue; + + if(itemElement != this.currentItem[0] //cannot intersect with itself + && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before + && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked + && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true) + //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container + ) { + + $(itemElement).mouseenter(); + + this.direction = intersection == 1 ? "down" : "up"; + + if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) { + $(itemElement).mouseleave(); + this._rearrange(event, item); + } else { + break; + } + + // Clear emtpy ul's/ol's + this._clearEmpty(itemElement); + + this._trigger("change", event, this._uiHash()); + break; + } + } + + var parentItem = (this.placeholder[0].parentNode.parentNode && + $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length) + ? $(this.placeholder[0].parentNode.parentNode) + : null, + level = this._getLevel(this.placeholder), + childLevels = this._getChildLevels(this.helper); + + // To find the previous sibling in the list, keep backtracking until we hit a valid list item. + var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null; + if (previousItem != null) { + while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) { + if (previousItem[0].previousSibling) { + previousItem = $(previousItem[0].previousSibling); + } else { + previousItem = null; + break; + } + } + } + + // To find the next sibling in the list, keep stepping forward until we hit a valid list item. + var nextItem = this.placeholder[0].nextSibling ? $(this.placeholder[0].nextSibling) : null; + if (nextItem != null) { + while (nextItem[0].nodeName.toLowerCase() != 'li' || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) { + if (nextItem[0].nextSibling) { + nextItem = $(nextItem[0].nextSibling); + } else { + nextItem = null; + break; + } + } + } + + var newList = document.createElement(o.listType); + + this.beyondMaxLevels = 0; + + // If the item is moved to the left, send it to its parent's level unless there are siblings below it. + if (parentItem != null && nextItem == null && + (o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) || + !o.rtl && (this.positionAbs.left < parentItem.offset().left))) { + parentItem.after(this.placeholder[0]); + this._clearEmpty(parentItem[0]); + this._trigger("change", event, this._uiHash()); + } + // If the item is below a sibling and is moved to the right, make it a child of that sibling. + else if (previousItem != null && + (o.rtl && (this.positionAbs.left + this.helper.outerWidth() < previousItem.offset().left + previousItem.outerWidth() - o.tabSize) || + !o.rtl && (this.positionAbs.left > previousItem.offset().left + o.tabSize))) { + this._isAllowed(previousItem, level, level+childLevels+1); + if (!previousItem.children(o.listType).length) { + previousItem[0].appendChild(newList); + } + // If this item is being moved from the top, add it to the top of the list. + if (previousTopOffset && (previousTopOffset <= previousItem.offset().top)) { + previousItem.children(o.listType).prepend(this.placeholder); + } + // Otherwise, add it to the bottom of the list. + else { + previousItem.children(o.listType)[0].appendChild(this.placeholder[0]); + } + this._trigger("change", event, this._uiHash()); + } + else { + this._isAllowed(parentItem, level, level+childLevels); + } + + //Post events to containers + this._contactContainers(event); + + //Interconnect with droppables + if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); + + //Call callbacks + this._trigger('sort', event, this._uiHash()); + + this.lastPositionAbs = this.positionAbs; + return false; + + }, + + _mouseStop: function(event, noPropagation) { + + // If the item is in a position not allowed, send it back + if (this.beyondMaxLevels) { + + this.placeholder.removeClass(this.options.errorClass); + + if (this.domPosition.prev) { + $(this.domPosition.prev).after(this.placeholder); + } else { + $(this.domPosition.parent).prepend(this.placeholder); + } + + this._trigger("revert", event, this._uiHash()); + + } + + // Clean last empty ul/ol + for (var i = this.items.length - 1; i >= 0; i--) { + var item = this.items[i].item[0]; + this._clearEmpty(item); + } + + $.ui.sortable.prototype._mouseStop.apply(this, arguments); + + }, + + serialize: function(options) { + + var o = $.extend({}, this.options, options), + items = this._getItemsAsjQuery(o && o.connected), + str = []; + + $(items).each(function() { + var res = ($(o.item || this).attr(o.attribute || 'id') || '') + .match(o.expression || (/(.+)[-=_](.+)/)), + pid = ($(o.item || this).parent(o.listType) + .parent(o.items) + .attr(o.attribute || 'id') || '') + .match(o.expression || (/(.+)[-=_](.+)/)); + + if (res) { + str.push(((o.key || res[1]) + '[' + (o.key && o.expression ? res[1] : res[2]) + ']') + + '=' + + (pid ? (o.key && o.expression ? pid[1] : pid[2]) : o.rootID)); + } + }); + + if(!str.length && o.key) { + str.push(o.key + '='); + } + + return str.join('&'); + + }, + + toHierarchy: function(options) { + + var o = $.extend({}, this.options, options), + sDepth = o.startDepthCount || 0, + ret = []; + + $(this.element).children(o.items).each(function () { + var level = _recursiveItems(this); + ret.push(level); + }); + + return ret; + + function _recursiveItems(item) { + var id = ($(item).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); + if (id) { + var currentItem = {"id" : id[2]}; + if ($(item).children(o.listType).children(o.items).length > 0) { + currentItem.children = []; + $(item).children(o.listType).children(o.items).each(function() { + var level = _recursiveItems(this); + currentItem.children.push(level); + }); + } + return currentItem; + } + } + }, + + toArray: function(options) { + + var o = $.extend({}, this.options, options), + sDepth = o.startDepthCount || 0, + ret = [], + left = 2; + + ret.push({ + "item_id": o.rootID, + "parent_id": 'none', + "depth": sDepth, + "left": '1', + "right": ($(o.items, this.element).length + 1) * 2 + }); + + $(this.element).children(o.items).each(function () { + left = _recursiveArray(this, sDepth + 1, left); + }); + + ret = ret.sort(function(a,b){ return (a.left - b.left); }); + + return ret; + + function _recursiveArray(item, depth, left) { + + var right = left + 1, + id, + pid; + + if ($(item).children(o.listType).children(o.items).length > 0) { + depth ++; + $(item).children(o.listType).children(o.items).each(function () { + right = _recursiveArray($(this), depth, right); + }); + depth --; + } + + id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/)); + + if (depth === sDepth + 1) { + pid = o.rootID; + } else { + var parentItem = ($(item).parent(o.listType) + .parent(o.items) + .attr(o.attribute || 'id')) + .match(o.expression || (/(.+)[-=_](.+)/)); + pid = parentItem[2]; + } + + if (id) { + ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right}); + } + + left = right + 1; + return left; + } + + }, + + _clearEmpty: function(item) { + + var emptyList = $(item).children(this.options.listType); + if (emptyList.length && !emptyList.children().length) { + emptyList.remove(); + } + + }, + + _getLevel: function(item) { + + var level = 1; + + if (this.options.listType) { + var list = item.closest(this.options.listType); + while (list && list.length > 0 && + !list.is('.ui-sortable')) { + level++; + list = list.parent().closest(this.options.listType); + } + } + + return level; + }, + + _getChildLevels: function(parent, depth) { + var self = this, + o = this.options, + result = 0; + depth = depth || 0; + + $(parent).children(o.listType).children(o.items).each(function (index, child) { + result = Math.max(self._getChildLevels(child, depth + 1), result); + }); + + return depth ? result + 1 : result; + }, + + _isAllowed: function(parentItem, level, levels) { + var o = this.options, + isRoot = $(this.domPosition.parent).hasClass('ui-sortable') ? true : false, + maxLevels = this.placeholder.closest('.ui-sortable').nestedSortable('option', 'maxLevels'); // this takes into account the maxLevels set to the recipient list + + // Is the root protected? + // Are we trying to nest under a no-nest? + // Are we nesting too deep? + if (!o.isAllowed(parentItem, this.placeholder) || + parentItem && parentItem.hasClass(o.disableNesting) || + o.protectRoot && (parentItem == null && !isRoot || isRoot && level > 1)) { + this.placeholder.addClass(o.errorClass); + if (maxLevels < levels && maxLevels != 0) { + this.beyondMaxLevels = levels - maxLevels; + } else { + this.beyondMaxLevels = 1; + } + } else { + if (maxLevels < levels && maxLevels != 0) { + this.placeholder.addClass(o.errorClass); + this.beyondMaxLevels = levels - maxLevels; + } else { + this.placeholder.removeClass(o.errorClass); + this.beyondMaxLevels = 0; + } + } + } + + })); + + $.mjs.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.mjs.nestedSortable.prototype.options); +})(jQuery);+ \ No newline at end of file diff --git a/themes/default/js/jquery.scrollTo.min.js b/themes/default/js/jquery.scrollTo.min.js @@ -0,0 +1,216 @@ +/*! + * jQuery.ScrollTo + * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com + * Dual licensed under MIT and GPL. + * Date: 06/05/2009 + * + * @projectDescription Easy element scrolling using jQuery. + * http://flesler.blogspot.com/2007/10/jqueryscrollto.html + * Works with jQuery +1.2.6. Tested on FF 2/3, IE 6/7/8, Opera 9.5/6, Safari 3, Chrome 1 on WinXP. + * + * @author Ariel Flesler + * @version 1.4.2 + * + * @id jQuery.scrollTo + * @id jQuery.fn.scrollTo + * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements. + * The different options for target are: + * - A number position (will be applied to all axes). + * - A string position ('44', '100px', '+=90', etc ) will be applied to all axes + * - A jQuery/DOM element ( logically, child of the element to scroll ) + * - A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc ) + * - A hash { top:x, left:y }, x and y can be any kind of number/string like above. + * - A percentage of the container's dimension/s, for example: 50% to go to the middle. + * - The string 'max' for go-to-end. + * @param {Number, Function} duration The OVERALL length of the animation, this argument can be the settings object instead. + * @param {Object,Function} settings Optional set of settings or the onAfter callback. + * @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'. + * @option {Number, Function} duration The OVERALL length of the animation. + * @option {String} easing The easing method for the animation. + * @option {Boolean} margin If true, the margin of the target element will be deducted from the final position. + * @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }. + * @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes. + * @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends. + * @option {Function} onAfter Function to be called after the scrolling ends. + * @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends. + * @return {jQuery} Returns the same jQuery object, for chaining. + * + * @desc Scroll to a fixed position + * @example $('div').scrollTo( 340 ); + * + * @desc Scroll relatively to the actual position + * @example $('div').scrollTo( '+=340px', { axis:'y' } ); + * + * @desc Scroll using a selector (relative to the scrolled element) + * @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } ); + * + * @desc Scroll to a DOM element (same for jQuery object) + * @example var second_child = document.getElementById('container').firstChild.nextSibling; + * $('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){ + * alert('scrolled!!'); + * }}); + * + * @desc Scroll on both axes, to different values + * @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } ); + */ + +;(function( $ ){ + + var $scrollTo = $.scrollTo = function( target, duration, settings ){ + $(window).scrollTo( target, duration, settings ); + }; + + $scrollTo.defaults = { + axis:'xy', + duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1, + limit:true + }; + + // Returns the element that needs to be animated to scroll the window. + // Kept for backwards compatibility (specially for localScroll & serialScroll) + $scrollTo.window = function( scope ){ + return $(window)._scrollable(); + }; + + // Hack, hack, hack :) + // Returns the real elements to scroll (supports window/iframes, documents and regular nodes) + $.fn._scrollable = function(){ + return this.map(function(){ + var elem = this, + isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1; + + if( !isWin ) + return elem; + + var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem; + + return $.browser.safari || doc.compatMode == 'BackCompat' ? + doc.body : + doc.documentElement; + }); + }; + + $.fn.scrollTo = function( target, duration, settings ){ + if( typeof duration == 'object' ){ + settings = duration; + duration = 0; + } + if( typeof settings == 'function' ) + settings = { onAfter:settings }; + + if( target == 'max' ) + target = 9e9; + + settings = $.extend( {}, $scrollTo.defaults, settings ); + // Speed is still recognized for backwards compatibility + duration = duration || settings.duration; + // Make sure the settings are given right + settings.queue = settings.queue && settings.axis.length > 1; + + if( settings.queue ) + // Let's keep the overall duration + duration /= 2; + settings.offset = both( settings.offset ); + settings.over = both( settings.over ); + + return this._scrollable().each(function(){ + var elem = this, + $elem = $(elem), + targ = target, toff, attr = {}, + win = $elem.is('html,body'); + + switch( typeof targ ){ + // A number will pass the regex + case 'number': + case 'string': + if( /^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ) ){ + targ = both( targ ); + // We are done + break; + } + // Relative selector, no break! + targ = $(targ,this); + case 'object': + // DOMElement / jQuery + if( targ.is || targ.style ) + // Get the real position of the target + toff = (targ = $(targ)).offset(); + } + $.each( settings.axis.split(''), function( i, axis ){ + var Pos = axis == 'x' ? 'Left' : 'Top', + pos = Pos.toLowerCase(), + key = 'scroll' + Pos, + old = elem[key], + max = $scrollTo.max(elem, axis); + + if( toff ){// jQuery / DOMElement + attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] ); + + // If it's a dom element, reduce the margin + if( settings.margin ){ + attr[key] -= parseInt(targ.css('margin'+Pos)) || 0; + attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0; + } + + attr[key] += settings.offset[pos] || 0; + + if( settings.over[pos] ) + // Scroll to a fraction of its width/height + attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos]; + }else{ + var val = targ[pos]; + // Handle percentage values + attr[key] = val.slice && val.slice(-1) == '%' ? + parseFloat(val) / 100 * max + : val; + } + + // Number or 'number' + if( settings.limit && /^\d+$/.test(attr[key]) ) + // Check the limits + attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max ); + + // Queueing axes + if( !i && settings.queue ){ + // Don't waste time animating, if there's no need. + if( old != attr[key] ) + // Intermediate animation + animate( settings.onAfterFirst ); + // Don't animate this axis again in the next iteration. + delete attr[key]; + } + }); + + animate( settings.onAfter ); + + function animate( callback ){ + $elem.animate( attr, duration, settings.easing, callback && function(){ + callback.call(this, target, settings); + }); + }; + + }).end(); + }; + + // Max scrolling position, works on quirks mode + // It only fails (not too badly) on IE, quirks mode. + $scrollTo.max = function( elem, axis ){ + var Dim = axis == 'x' ? 'Width' : 'Height', + scroll = 'scroll'+Dim; + + if( !$(elem).is('html,body') ) + return elem[scroll] - $(elem)[Dim.toLowerCase()](); + + var size = 'client' + Dim, + html = elem.ownerDocument.documentElement, + body = elem.ownerDocument.body; + + return Math.max( html[scroll], body[scroll] ) + - Math.min( html[size] , body[size] ); + }; + + function both( val ){ + return typeof val == 'object' ? val : { top:val, left:val }; + }; + +})( jQuery );+ \ No newline at end of file diff --git a/themes/default/js/mark.min.js b/themes/default/js/mark.min.js @@ -0,0 +1,27 @@ + +function mark() +{ + for( i=0; i<document.forms[0].elements.length; i++ ) + { + if (document.forms[0].elements[i].type=='checkbox') + document.forms[0].elements[i].checked=true; + } +} + +function unmark() +{ + for( i=0; i<document.forms[0].elements.length; i++ ) + { + if (document.forms[0].elements[i].type=='checkbox') + document.forms[0].elements[i].checked=false; + } +} + +function flip() +{ + for( i=0; i<document.forms[0].elements.length; i++ ) + { + if (document.forms[0].elements[i].type=='checkbox') + document.forms[0].elements[i].checked=!document.forms[0].elements[i].checked; + } +} diff --git a/themes/default/js/openrat.js b/themes/default/js/openrat.js @@ -12,7 +12,7 @@ $(document).ready(function() }); - + /** * Ping den Server. Führt keine Aktion aus, aber sorgt dafür, dass die Sitzung erhalten bleibt. * diff --git a/themes/default/js/openrat.min.js b/themes/default/js/openrat.min.js @@ -0,0 +1,19 @@ +;var DEFAULT_CONTENT_ACTION='edit';$(document).ready(function(){refreshAll();window.setInterval('ping()',300000)});function ping(){$.ajax(createUrl('title','ping',0))};function refreshAll(){refreshTitleBar();refreshWorkbench();$('div#filler').click(function(){if($('div#dialog').hasClass('modal')){} +else{$('div#dialog').html('').hide();$('div#filler').fadeOut(500)}})};function refreshAllRefreshables(){$('div#workbench div.panel > div.header > ul.views > li.active').each(function(){if($(this).hasClass('static'))return;var e=$(this).attr('data-method'),i=$(this).attr('data-action'),t=$(this).attr('data-id'),a=$(this).attr('data-extra');loadView($(this).closest('div.panel').find('div.content'),i,e,t)})};function refreshActualView(e){$(e).closest('div.panel').find('li.active').each(function(){var e=$(this).attr('data-method'),i=$(this).attr('data-action'),t=$(this).attr('data-id');loadView($(this).closest('div.panel').find('div.content'),i,e,t)})};function refreshWorkbench(){$('ul#history').empty();$('div#workbench').empty().fadeOut('fast').load(createUrl('workbench','show',0),null,function(){resizeWorkbench();$('div.modaldialog').fadeOut(500);$('div#workbench').removeClass('modal');$('div#filler').fadeOut(500);$(this).fadeIn(750).find('li.active').each(function(){var i=$(this).attr('data-method'),e=$(this).attr('data-action');if(e)loadView($(this).closest('div.panel').find('div.content'),e,i,0)});$('div.backward_link').click(function(){var e=$(this).closest('div.header').find('ul.views'),i=e.find('li.action.active').prev();e.scrollTo(i,500,{'axis':'x'});i.click()});$('div.forward_link').click(function(){var e=$(this).closest('div.header').find('ul.views'),i=e.find('li.action.active').next();e.scrollTo(i,500,{'axis':'x'});i.click()});registerWorkbenchEvents()});loadTree();$(window).resize(function(){resizeWorkbench()})};function registerWorkbenchEvents(){$('ul.views > li.action').draggable({cursor:'move',revert:'invalid'});$('ul.views').droppable({accept:'li.action',hoverClass:'drophover',activeClass:'dropactive',drop:function(e,i){var a=i.draggable,n=$(this),s=a.parent();if($(a).closest('div.panel').attr('id')==$(n).closest('div.panel').attr('id'))$(a).css({top:0,left:0});else $(a).detach().css({top:0,left:0}).appendTo(n).click();if(s.find('li').size()==0){var t=s.closest('div.container');s.closest('div.panel').remove();if(t.hasClass('autosize'))t.children('div.panel').addClass('autosize').removeClass('resizable');else t.children('div.panel').addClass('resizable').removeClass('autosize');t.replaceWith(t.children('div.panel'));resizeWorkbench()}}});$('div.content').droppable({accept:'li.action',hoverClass:'drophover',activeClass:'dropactive',drop:function(e,i){var s=i.draggable,n=$(this),r=s.parent(),d=s.offset(),l=n.offset(),h=d.left-l.left,v=l.left+n.width()-d.left,o=d.top-l.top,c=l.top+n.height()-d.top,t=$('<div class="container"><div class="first" /><div class="divider" /><div class="second"></div>');if(h<Math.min(v,Math.min(o,c))){t.addClass('axle-x');t.children('div.divider').addClass('to-right');t.children('div.first').removeClass('first').addClass('resizable');t.children('div.second').removeClass('first').addClass('autosize')} +else if(v<Math.min(o,c)){t.addClass('axle-x');t.children('div.divider').addClass('to-left');t.children('div.first').removeClass('first').addClass('autosize');t.children('div.second').removeClass('first').addClass('resizable')} +else if(o<c){t.addClass('axle-y');t.children('div.divider').addClass('to-bottom');t.children('div.first').removeClass('first').addClass('resizable');t.children('div.second').removeClass('first').addClass('autosize')} +else{t.addClass('axle-y');t.children('div.divider').addClass('to-top');t.children('div.first').removeClass('first').addClass('autosize');t.children('div.second').removeClass('first').addClass('resizable')};t.children('div.resizable').addClass('bar').data('size-factor',0.4);$(s).closest('div.panel').clone().addClass('resizable').removeClass('autosize').replaceAll(t.children('div.resizable'));t.find('ul.views > li').remove();$(s).detach().css({top:0,left:0}).appendTo(t.find('ul.views')).click();var a=$(n).closest('div.panel').replaceWith(t);t.children('div.autosize').replaceWith(a);if(a.hasClass('autosize')){t.addClass('autosize').removeClass('resizable')};if(a.hasClass('resizable')){t.addClass('resizable').removeClass('autosize')};a.addClass('autosize').removeClass('resizable');if(r.find('li').size()==0){var a=r.closest('div.container');r.closest('div.panel').remove();if(a.hasClass('autosize'))a.children('div.panel').addClass('autosize').removeClass('resizable');else a.children('div.panel').addClass('resizable').removeClass('autosize');a.replaceWith(a.children('div.panel'));resizeWorkbench()};resizeWorkbench();registerWorkbenchEvents()}});if($('div#workbench div.panel.modal').size()>0){$('div#workbench div.panel.modal').parent().addClass('modal');$('div#filler').fadeTo(500,0.5);$('div#workbench').addClass('modal')};$('div.container.axle-x > div.divider').draggable({stop:function(e,i){var t=i.position.left,a=$(this).hasClass('to-right')?1:-1;$(this).parent().children('div.resizable').each(function(){var e=((a*t)+$(this).width())/($(this).parent().width());e=Math.min(0.5,Math.max(0.1,e));$(this).data('size-factor',e)});resizeWorkbenchContainer($(this).parent())},axis:'x',revert:!0,revertDuration:0});$('div.container.axle-y > div.divider').draggable({stop:function(e,i){var t=i.position.top,a=$(this).hasClass('to-bottom')?1:-1;$(this).parent().children('div.resizable').each(function(){var e=((a*t)+$(this).height())/($(this).parent().height());e=Math.min(0.5,Math.max(0.1,e));$(this).data('size-factor',e)});resizeWorkbenchContainer($(this).parent())},axis:'y',revert:!0,revertDuration:0});$('ul.views > li.action').click(function(){$(this).orLoadView()});$('div.header').dblclick(function(){fullscreen(this)})};function refreshTitleBar(){$('div#header').load(createUrl('title','show',0),function(){$(this).fadeIn('slow');$('div.clickable.filtered').addClass('inactive');registerHeaderEvents()})};function loadViewByName(e,i){alert('loadViewByName');loadView($('div#'+e),i)};function loadView(e,i,t,s,n){var a=$(e).children('div.sheet.action-'+i+'.method-'+t+'.id-'+s);if(a.size()==0){$(e).children('div.sheet').hide();a=$('<div class="sheet action-'+i+' method-'+t+' id-'+s+'" />');$(e).append(a)} +else{if(a.is(':visible')){return} +else{$(e).children('div.sheet').hide();a.show();return}};var d=createUrl(i,t,s,n);$(a).empty().fadeTo(1,0.7).addClass('loader').html('').load(d,function(e,i,t){$(a).fadeTo(350,1);if(i=='error'){$(a).html('');$(a).removeClass('loader');notify('error',e);return};$(a).removeClass('loader');registerViewEvents(a)})};function registerViewEvents(e){$(e).trigger('orViewLoaded');$(e).find('input[data-hint]').orHint();$(e).closest('div.panel').find('div.header div.dropdown div.entry.perview').remove();$(e).find('div.headermenu > a').each(function(e,i){});$(e).find('div.header > a.back').each(function(i,t){$(t).removeClass('button').wrap('<div class="entry perview" />').parent().appendTo($(e).closest('div.panel').find('div.header div.dropdown').first())});$(e).closest('div.panel').find('.clickable').orLinkify();$(e).find('div.selector.tree').each(function(){var e=this;$(this).orTree({type:'project',selectable:$(e).attr('data-types').split(','),id:$(e).attr('data-init-folderid'),onSelect:function(i,t,a){var s=$(e).parent();$(s).find('input[type=text]').attr('value',i);$(s).find('input[type=hidden]').attr('value',a)}})});$('div.content li.object').draggable({cursor:'move',revert:'invalid'});$('div.content li.object > div.entry[data-type=\'folder\']').droppable({accept:'li.object',hoverClass:'drophover',activeClass:'dropactive',drop:function(e,i){var t=i.draggable,a=$(this).parent();startDialog($(this).text(),$(t).attr('data-type'),'copy',$(a).attr('data-id'),{'action':$(t).attr('data-type'),'subaction':'copy','id':$(t).attr('data-id'),'targetFolderId':$(a).attr('data-id')});$(t).detach().css({top:0,left:0}).appendTo(a).click()}});$(e).find('input').change(function(){$(this).closest('div.panel').find('ul.views li.action.active').addClass('dirty')})};function registerHeaderEvents(){$('div#header .clickable').orLinkify();$('div.search input').blur(function(){$('div.search input div.dropdown').fadeOut()});$('div.search input').orHint();$('div.search input').orSearch({dropdown:'div.search div.dropdown'})};function fullscreen(e){$(e).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};function loadTree(){if($('div#panel-tree li.action').data('action')=='tree'){$('div#panel-tree div.content > div.sheet.action-tree.method-tree').html('&nbsp;');$('div#panel-tree div.content > div.sheet.action-tree.method-tree').orTree({type:'root',id:0,onSelect:function(e,i,t){openNewAction(e,i,t,'')}});$('div#panel-tree div.content > div.sheet.action-tree.method-tree > ul.tree > div.tree').delay(500).click();$('div#panel-tree div.content > div.sheet.action-tree.method-tree > ul.tree > div.tree').delay(500).click()}};function submitUrl(e,i){postUrl(i,e);refreshAllRefreshables()};function postUrl(e,i){e+='&output=json';$.ajax({'type':'POST',url:e,data:{},success:function(e,t,a){$('div.panel div.status div.loader').html('&nbsp;');doResponse(e,t,i)}})};function startView(e,i){var t=$('#panel-content').find('li.active').data('action'),a=$('#panel-content').find('li.active').data('id');loadView($(e).closest('div.panel').find('div.content'),t,i,a)};function startDialog(e,i,t,a,s){if(i==null)i=$('#panel-content').find('li.active').data('action');if(a==null)a=$('#panel-content').find('li.active').data('id');$('div#filler').fadeTo(500,0.5);$('div#dialog').html('<div class="header"><ul class="views"><li class="action active"><img class="icon" title="" src="./themes/default/images/icon/'+t+'.png" /><div class="tabname" style="width:100px;">'+e+'</div></li></ul></div><div class="content" />');$('div#dialog').data('id',a);$('div#dialog').show();loadView($('div#dialog div.content'),i,t,a,s)};function modalView(e,i){var t=$(e).closest('div.panel').find('li.active').attr('data-action'),a=$(e).closest('div.panel').find('li.active').attr('data-method'),s=$(e).closest('div.panel').find('li.active').attr('data-id');$(e).closest('div.content').modal({'overlayClose':'true','xxxonClose':function(){alert('close)')}});loadView($(e).closest('div.content'),t,a,s)};function setTitle(e){if(e)$('head > title').text(e+' - '+$('head > title').data('default'));else $('head > title').text($('head > title').data('default'))};function openNewAction(e,i,t,a){setTitle(e);$('ul#history li.active').removeClass('active');if($('ul#history li.'+i+'.id'+t).length>0){$('ul#history li.'+i+'.id'+t).addClass('active')} +else{$('ul#history').append('<li class="action active '+i+' id'+t+'"><img src="'+OR_THEMES_EXT_DIR+'default/images/icon_'+i+'.png" title="" />'+e+'</li>');$('ul#history li.active').click(function(){$('ul#history li.active').removeClass('active');$(this).addClass('active');setNewAction(i,t,a)})};$('div#panel-content > div.header > ul.views li.active').removeClass('active');if($('div#panel-content > div.header > ul.views > li.'+i+'.id'+t).length>0){$('div#panel-content > div.header > ul.views > li.'+i+'.id'+t).addClass('active')} +else{$('div#panel-content > div.header > ul.views > li.active').removeClass('active');var s=7;if($('div#panel-content > div.header > ul.views > li.action').size()>=s)$('div#panel-content > div.header > ul.views > li.action').first().remove();$('div#panel-content > div.header > ul.views').append('<li class="action active '+i+' id'+t+'" title="'+e+'" data-action="'+i+'" data-id="'+t+'" data-method="'+DEFAULT_CONTENT_ACTION+'"><img class="icon" src="'+OR_THEMES_EXT_DIR+'default/images/icon_'+i+'.png" title="" /><div class="tabname">'+e+'</div><img class="close icon" src="'+OR_THEMES_EXT_DIR+'default/images/icon/close.gif" title="" /></li>');resizeTabs($('div#contentbar'),!0);$('div#panel-content > div.header > ul.views').scrollLeft(9999);$('div#panel-content > div.header > ul.views img.close').click(function(){setTitle('');var i=$(this).closest('li.action').data('action'),t=$(this).closest('li.action').data('id');$('div#workbench div.content > div.sheet.action-'+i+'.id-'+t).remove();if($(this).closest('li.action').hasClass('active')){$('div#workbench div.refreshable div.content').html('');var e=$(this).closest('ul.views');$(this).parent().remove();$(e).find('li.action').last().click()} +else{$(this).parent().remove()};resizeTabs($('div#panel-content'),!0)});$('div#panel-content > div.header > ul.views > li.active').click(function(){$('div#panel-content > div.header > ul.views li.active').removeClass('active');$(this).addClass('active');setTitle($(this).children('div.tabname').text());setNewAction(i,t,a)});resizeTabs($('div#panel-content '))};setNewAction(i,t,a)};function filterMenus(e){$('div.clickable.filtered').addClass('inactive');$('div.clickable.filtered.on-action-'+e).removeClass('inactive')};function setNewAction(e,i,t){filterMenus(e);$('div#workbench ul.views > li.action.dependent').attr('data-action',e).attr('data-id',i).attr('data-extra',JSON.stringify(t));refreshAllRefreshables()};function setNewId(e){$('div#workbench div.refreshable').attr('data-id',e);refreshAllRefreshables()};function submitLink(e,i){var t=jQuery.parseJSON(i),a='./dispatcher.php';t.output='json';$.ajax({'type':'POST',url:a,data:t,success:function(i,t,a){$('div.panel div.status div.loader').html('&nbsp;');doResponse(i,t,e)}})};function notifyBrowser(e){if(!('Notification' in window)){return} +else if(Notification.permission==='granted'){var i=new Notification(e)} +else if(Notification.permission!=='denied'){Notification.requestPermission(function(i){if(i==='granted'){var t=new Notification(e)}})}};function setUserStyle(e){var i=$('html'),t=i.attr('class').split(/\s+/);$.each(t,function(e,t){if(t.startsWith('theme-')){i.removeClass(t)}});i.addClass('theme-'+e.toLowerCase())};function insert(e,i,t){var a=document.forms[0].elements[e];a.focus();if(typeof document.selection!='undefined'){var d=document.selection.createRange(),s=d.text;d.text=i+s+t;d=document.selection.createRange();if(s.length==0){d.move('character',-t.length)} +else{d.moveStart('character',i.length+s.length+t.length)};d.select()} +else if(typeof a.selectionStart!='undefined'){var l=a.selectionStart,r=a.selectionEnd,s=a.value.substring(l,r);a.value=a.value.substr(0,l)+i+s+t+a.value.substr(r);var n;if(s.length==0){n=l+i.length} +else{n=l+i.length+s.length+t.length};a.selectionStart=n;a.selectionEnd=n} +else{n=a.value.length;var s=prompt('Text');a.value=a.value.substr(0,n)+i+s+t+a.value.substr(n)}};function loadSubaction(e,i,t,a){alert('nobody should call loadSubaction()');var n={skin:'v2',baseHref:OR_THEMES_EXT_DIR+'../editor/editor/',customConfig:'config-openrat.js',filebrowserUploadUrl:'./dispatcher.php?action=filebrowser&subaction=directupload&name=upload',filebrowserBrowseUrl:'./dispatcher.php?action=filebrowser&subaction=browse'};var s=$(e).parent().parent().parent('div.panel').children('div.content').first();$(s).load(createUrl(i,t,a)+' div.content',null,function(){var e=CKEDITOR.instances[$('textarea.editor').attr('name')];if(e)e.destroy();CKEDITOR.replace('text',{customConfig:'config-openrat.js'})});$(e).parent().parent().find('.active').removeClass('active');$(e).parent().addClass('active')};function createUrl(e,i,t,s){var a='./dispatcher.php';if(typeof s==='string'){a+='?action='+e+'&subaction='+i+'&id='+t;jQuery.each(jQuery.parseJSON(s),function(e,i){a=a+'&'+e+'='+i})} +else if(typeof s==='object'){a+='?0=0';jQuery.each(s,function(e,i){a=a+'&'+e+'='+i})} +else{a+='?action='+e+'&subaction='+i+'&id='+t};console.log('URL='+a);return a};function resizeWorkbenchContainer(e){var t=e.width(),a=e.height(),s=e.children('div.resizable').data('size-factor');if(!s)s=0.3;var n=e.hasClass('axle-x');if(n){var i=Math.floor(t*s);e.find('div.panel.resizable').css('width',''+i+'px');e.find('div.panel.resizable > div.content').css('height',''+(a-26)+'px');e.find('div.panel.autosize ').css('width',''+(t-i-9)+'px');e.find('div.panel.autosize > div.content').css('height',''+(a-26)+'px');e.children('div.resizable').css('width',''+i+'px');e.children('div.resizable').css('height',''+a+'px');e.children('div.autosize').css('width',''+(t-i-9)+'px');e.children('div.autosize').css('height',''+a+'px');e.children('div.divider').css('height',''+a+'px')} +else{var i=Math.floor(a*s);e.find('div.panel.resizable ').css('width',''+t+'px');e.find('div.panel.resizable > div.content').css('height',''+(i-26)+'px');e.find('div.panel.autosize ').css('width',''+t+'px');e.find('div.panel.autosize > div.content').css('height',''+(a-i-26)+'px');e.children('div.resizable').css('width',''+t+'px');e.children('div.resizable').css('height',''+i+'px');e.children('div.autosize').css('width',''+t+'px');e.children('div.autosize').css('height',''+(a-i-5)+'px');e.children('div.divider').css('width',''+t+'px')};e.children('div.panel').each(function(){resizeTabs($(this))});$(e).children('div.container').each(function(){resizeWorkbenchContainer($(this))})};function resizeWorkbench(){var i=$(window).width(),t=$(window).height(),a=40,e=$('div#workbench > div.container');e.css('width',''+(i-6)+'px');e.css('height',''+(t-a-6)+'px');resizeWorkbenchContainer(e)};function resizeTabs(e){var t=$(e).find('div.header li.action').size(),i=Math.floor((($(e).width()-18)/t)-39);if($(e).is('#panel-content'))i-=24;i=Math.min(90,Math.max(5,i));$(e).find('li.action div.tabname').width(i)};function help(e,i,t){var a=$(e).closest('div.panel').find('li.action.active').attr('data-action'),s=$(e).closest('div.panel').find('li.action.active').attr('data-method');window.open(i+a+'/'+s+t,'OpenRat_Help','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')};function notify(e,i){var t=$('<div class="notice '+e+'"><div class="text">'+i+'</div></div>');$('#noticebar').prepend(t);notifyBrowser(i);$(t).fadeIn().click(function(){$(this).fadeOut('fast',function(){$(this).remove()})})};+ \ No newline at end of file diff --git a/themes/default/js/plugin/jquery-plugin-orAutoheight.min.js b/themes/default/js/plugin/jquery-plugin-orAutoheight.min.js @@ -0,0 +1,22 @@ +/** + * Input-Hints + */ +jQuery.fn.orAutoheight = function() +{ + + var resize = function( element ) + { + var lines = $(element).val().split("\n").length; + $(element).attr('rows',lines+3); + }; + + $(this).each(function(i) + { + resize(this); + }); + + return $(this).keypress(function() + { + resize(this); + }); +};+ \ No newline at end of file diff --git a/themes/default/js/plugin/jquery-plugin-orHint.min.js b/themes/default/js/plugin/jquery-plugin-orHint.min.js @@ -0,0 +1,22 @@ +/** + * Input-Hints + */ +jQuery.fn.orHint = function() +{ + + $(this).each(function(i) + { + if ($(this).val() == '') + $(this).val($(this).attr('data-hint')).addClass('hint'); + }); + + return $(this).focus(function() + { + if ($(this).val() == $(this).attr('data-hint')) + $(this).val('').removeClass('hint'); + }).blur(function() + { + if ($(this).val() == '') + $(this).val($(this).attr('data-hint')).addClass('hint'); + }); +};+ \ No newline at end of file diff --git a/themes/default/js/plugin/jquery-plugin-orLinkify.min.js b/themes/default/js/plugin/jquery-plugin-orLinkify.min.js @@ -0,0 +1,74 @@ +/** + * Input-Hints + */ +jQuery.fn.orLinkify = function() +{ + + return $(this).click(function() + { + $(this).find('a').first().each( function() { + + var type = $(this).attr('data-type'); + + // Inaktive Menüpunkte sind natürlich nicht anklickbar. + if ( $(this).parent().hasClass('inactive') ) + return; + + if ( type == 'post' ) + { + //alert('data: '+$(this).attr('data-data')) + submitLink(this,$(this).attr('data-data') ); + } + + else if ( type == 'view' ) + { + startView(this, $(this).attr('data-method') ); + } + + else if ( type == 'modal' ) + { + startDialog($(this).attr('data-name'),null,$(this).attr('data-method') ); + } + + else if ( type == 'dialog' ) + { + startDialog($(this).attr('data-name'),null,$(this).attr('data-method') ); + } + + else if ( type == 'url' ) + { + submitUrl(this,$(this).attr('data-url') ); + } + + else if ( type == 'external' ) + { + window.open( $(this).attr('data-url'),' _blank' ); + } + + else if ( type == 'popup' ) + { + window.open( $(this).attr('data-url'), 'Popup', 'location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes'); + } + + else if ( type == 'help' ) + { + help(this,$(this).attr('data-url'),$(this).attr('data-suffix') ); + } + + else if ( type == 'fullscreen' ) + { + //alert('fullscreen fuer: '+$(this).html() ); + fullscreen(this); + } + + else if ( type == 'open' ) + { + openNewAction( $(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-id'),0); + } + else + { + alert('Fatal: Cannot open link: '+$(this).html() ); + } + } ); + }); +};+ \ No newline at end of file diff --git a/themes/default/js/plugin/jquery-plugin-orLoadView.min.js b/themes/default/js/plugin/jquery-plugin-orLoadView.min.js @@ -0,0 +1,20 @@ +/** + * Laden einer View. + */ +jQuery.fn.orLoadView = function() +{ + $(this).each(function(idx,treeEl) + { + var method = $(this).data('method'); + var action = $(this).data('action'); + var id = $(this).data('id'); + + var panel = $(this).closest('div.panel'); + panel.find('ul.views li.active').removeClass('active'); + $(this).addClass('active'); + + loadView( panel.find('div.content'),action,method,id); + }); + + +};+ \ No newline at end of file diff --git a/themes/default/js/plugin/jquery-plugin-orSearch.min.js b/themes/default/js/plugin/jquery-plugin-orSearch.min.js @@ -0,0 +1,38 @@ +/** + * Suche mit Dropdown + */ +jQuery.fn.orSearch = function( options ) +{ + // Create some defaults, extending them with any options that were provided + var settings = $.extend( { + 'dropdown': 'unknown' + }, options); + + + return $(this).keyup( function() + { + var val = $(this).val(); + if ( val.length > 3 ) + { + $(settings.dropdown).html(''); + $.ajax( { 'type':'GET',url:'./dispatcher.php?action=search&subaction=quicksearch&output=json&search='+val, data:null, success:function(data, textStatus, jqXHR) + { + for( id in data.output.result ) + { + var result = data.output.result[id]; + + // Suchergebnis-Zeile in das Ergebnis schreiben. + $(settings.dropdown).append('<div class="entry clickable" title="'+result.desc+'"><a href="javascript:void(0);" data-type="open" data-name="'+result.name+'" data-action="'+result.type+'" data-id="'+id+'"><img src="'+OR_THEMES_EXT_DIR+'default/images/icon_'+result.type+'.png" />'+result.name+'</a></div>'); + } + $(settings.dropdown).orLinkify(); + } } ); + $(settings.dropdown).fadeIn(); + + + } + else + { + $(settings.dropdown).fadeOut(); + } + }); +};+ \ No newline at end of file diff --git a/themes/default/js/plugin/jquery-plugin-orTree.min.js b/themes/default/js/plugin/jquery-plugin-orTree.min.js @@ -0,0 +1,101 @@ +/** + * Baum darstellen. + */ +jQuery.fn.orTree = function( options ) +{ + // Create some defaults, extending them with any options that were provided + var settings = $.extend( { + 'onSelect': function(){}, + 'type':'root', + 'id':0, + 'selectable':Array() + }, options); + + $(this).each(function(idxx,treeEl) + { + $(treeEl).closest('div.content').addClass('loader'); + $.getJSON('./dispatcher.php?action=tree&subaction=loadBranch&id='+settings.id+'&type='+settings.type+'&output=json', function(json) { + $(treeEl).append('<ul class="tree" style="display:none;"/>'); + var ul = $(treeEl).children('ul').first(); + var output = json['output']; + $.each(output['branch'],function(idx,line) + { + if ( !line.action || line.action=='folder' || settings.selectable.length==0 || settings.selectable[0]=='' || jQuery.inArray(line.action, settings.selectable)!=-1 ) + { + //var img = (line.url!==undefined?'tree_plus':'tree_none'); + $(ul).append( '<li class="object" data-id="'+line.internalId+'" data-type="'+line.type+'"><div class="tree">&nbsp;</div><div class="entry" data-id="'+line.internalId+'" data-type="'+line.type+'" title="'+ line.description + '"><img src="'+OR_THEMES_EXT_DIR+'default/images/icon_'+line['icon']+'.png" />'+ line.text + '</div></li>' ); + var new_li = $(ul).children('li').last(); + //$(new_li).children('div').unbind('click'); + if ( line.type ) + { + $(new_li).children('div.tree').addClass('closed'); + $(new_li).children('div.tree').click( function() { $(this).parent().orTree( {type:line.type,id:line.internalId,onSelect:settings.onSelect,selectable:settings.selectable} );} ); // Zweig öffnen + } + + if ( line.action && ( settings.selectable.length==0 || settings.selectable[0]=='' || jQuery.inArray(line.action, settings.selectable)!=-1 )) + { + // Onclick-Handler für auswählbare Objekte setzen + $(new_li).children('div.entry').click( function() { + //loadViewByName('content',line.url.replace(/&amp;/g,'&')); + //var url = './dispatcher.php'; + //$.ajax( { 'type':'POST',url:url, data:{'action':'tree','subaction':'select','id':line.id,'type':line.type},success:function(data, textStatus, jqXHR) + // { + // doResponse(data,textStatus); + // } } ); + // Den Objekt-Typ und die Objekt-Id für alle Views setzen (die dies zulassen) + + // Neue Action starten. + $(this).closest('div.content').find('div.entry').removeClass('selected'); + $(this).addClass('selected'); + + settings.onSelect( $(this).text(), line.action, line.id ); + }); + + // Drag and drop für die Baum-Inhalte. + //$(new_li).children('div.entry').draggable( {cursor:'move',revert: 'invalid' }); + } + + if ($(new_li).parents('ul.tree').size() <= 2 ) + { + // Falls eine bestimmte Tiefe nicht erreicht ist, dann + // den Pfad auch gleich öffnen. + $(new_li).children('div.tree').click(); + } + } + + }); + //$(ul).children('li:last-child').addClass('last'); + $(ul).slideDown('fast'); // Einblenden + + }).fail( function() { + // + }).always( function() { + $(treeEl).closest('div.content').removeClass('loader'); + }); + + $(treeEl).children('div.tree').unbind('click'); + $(treeEl).children('div.tree').removeClass('closed').addClass('open'); + $(treeEl).children('div.tree').click( function(e) { closeBranch($(e.target).parent(),settings.type,settings.id); } ); + }); + + + /** + * + * @param li JQuery-Objekt + * @return + */ + function closeBranch(li,type,id) + { + //alert("schließen:"+$(li).html() ); + $(li).children('ul').slideUp('fast', function() { + + $(li).children('ul').remove(); + $(li).children('div.tree').unbind('click'); + $(li).children('div.tree').removeClass('open').addClass('closed'); + //alert( "wieder öffnen: "+$(li).children('div').first().html()); + $(li).children('div.tree').click( function() { $(this).parent().orTree( {type:type,id:id,onSelect:settings.onSelect,selectable:settings.selectable}); }); + //$(li).children('img.tree').attr('src',OR_THEMES_EXT_DIR+'default/images/tree_plus.gif'); + } ); + } + +};+ \ No newline at end of file