From 66a35294993a3fc55477a3c496939d26f512203a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 18 Jun 2015 23:18:12 +0200 Subject: [PATCH] Added {js} template function and reorganized some 3rdParty JS --- .../templates/headIncludeJavaScript.tpl | 66 +- .../install/files/acp/templates/header.tpl | 4 +- .../install/files/js/3rdParty/jquery-ui.js | 18764 +++++----------- .../files/js/3rdParty/jquery-ui.min.js | 18 +- .../nestedSortable.js} | 0 .../nestedSortable.min.js} | 0 .../touchPunch.js} | 0 .../touchPunch.min.js} | 0 wcfsetup/install/files/js/3rdParty/jquery.js | 4096 ++-- .../install/files/js/3rdParty/jquery.min.js | 9 +- .../plugin/JsFunctionTemplatePlugin.class.php | 79 + 11 files changed, 7930 insertions(+), 15106 deletions(-) rename wcfsetup/install/files/js/3rdParty/{jquery-ui.nestedSortable.js => jquery-ui/nestedSortable.js} (100%) rename wcfsetup/install/files/js/3rdParty/{jquery-ui.nestedSortable.min.js => jquery-ui/nestedSortable.min.js} (100%) rename wcfsetup/install/files/js/3rdParty/{jquery.ui.touch-punch.js => jquery-ui/touchPunch.js} (100%) rename wcfsetup/install/files/js/3rdParty/{jquery.ui.touch-punch.min.js => jquery-ui/touchPunch.min.js} (100%) create mode 100644 wcfsetup/install/files/lib/system/template/plugin/JsFunctionTemplatePlugin.class.php diff --git a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl index fb4568c9d8..580f9c5fc2 100644 --- a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl +++ b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl @@ -11,12 +11,8 @@ var URL_LEGACY_MODE = {if URL_LEGACY_MODE}true{else}false{/if}; -{if ENABLE_DEBUG_MODE} - - -{else} - -{/if} +{js application='wcf' file='require' bundle='WCF.Core' core='true'} +{js application='wcf' file='require.config' bundle='WCF.Core' core='true'} {if JQUERY_SOURCE == 'google'} - - + {elseif JQUERY_SOURCE == 'microsoft'} - - + {elseif JQUERY_SOURCE == 'cloudflare'} - - + {else} - - +{js application='wcf' lib='jquery'} {/if} {if JQUERY_SOURCE != 'local'} {/if} -{if ENABLE_DEBUG_MODE} - - - - -{else} - -{/if} +{js application='wcf' lib='jquery-ui'} +{js application='wcf' lib='jquery-ui' file='touchPunch' bundle='WCF.Combined'} +{js application='wcf' lib='jquery-ui' file='nestedSortable' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Assets' bundle='WCF.Combined'} +{js application='wcf' file='WCF' bundle='WCF.Combined'} -{if ENABLE_DEBUG_MODE} - - - - - - - - - - - - - - -{/if} +{js application='wcf' file='WCF.Like' bundle='WCF.Combined'} +{js application='wcf' file='WCF.ACL' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Attachment' bundle='WCF.Combined'} +{js application='wcf' file='WCF.ColorPicker' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Comment' bundle='WCF.Combined'} +{js application='wcf' file='WCF.ImageViewer' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Label' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Location' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Message' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Poll' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Search.Message' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Tagging' bundle='WCF.Combined'} +{js application='wcf' file='WCF.User' bundle='WCF.Combined'} +{js application='wcf' file='WCF.Moderation' bundle='WCF.Combined'} {event name='javascriptInclude'} diff --git a/wcfsetup/install/files/acp/templates/header.tpl b/wcfsetup/install/files/acp/templates/header.tpl index 7afbca4d2d..188eb73359 100644 --- a/wcfsetup/install/files/acp/templates/header.tpl +++ b/wcfsetup/install/files/acp/templates/header.tpl @@ -20,8 +20,8 @@ - - + + diff --git a/wcfsetup/install/files/js/3rdParty/jquery-ui.js b/wcfsetup/install/files/js/3rdParty/jquery-ui.js index ce8731b07a..c3e8b7ea39 100644 --- a/wcfsetup/install/files/js/3rdParty/jquery-ui.js +++ b/wcfsetup/install/files/js/3rdParty/jquery-ui.js @@ -1,7 +1,7 @@ -/*! jQuery UI - v1.11.2 - 2014-10-16 +/*! jQuery UI - v1.11.4 - 2015-06-18 * http://jqueryui.com -* Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js -* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */ +* Includes: core.js, widget.js, mouse.js, position.js, draggable.js, droppable.js, resizable.js, selectable.js, sortable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js +* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ (function( factory ) { if ( typeof define === "function" && define.amd ) { @@ -15,10 +15,10 @@ } }(function( $ ) { /*! - * jQuery UI Core 1.11.2 + * jQuery UI Core 1.11.4 * http://jqueryui.com * - * Copyright 2014 jQuery Foundation and other contributors + * Copyright jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * @@ -30,7 +30,7 @@ $.ui = $.ui || {}; $.extend( $.ui, { - version: "1.11.2", + version: "1.11.4", keyCode: { BACKSPACE: 8, @@ -103,7 +103,7 @@ function focusable( element, isTabIndexNotNaN ) { img = $( "img[usemap='#" + mapName + "']" )[ 0 ]; return !!img && visible( img ); } - return ( /input|select|textarea|button|object/.test( nodeName ) ? + return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ? !element.disabled : "a" === nodeName ? element.href || isTabIndexNotNaN : @@ -309,10 +309,10 @@ $.ui.plugin = { /*! - * jQuery UI Widget 1.11.2 + * jQuery UI Widget 1.11.4 * http://jqueryui.com * - * Copyright 2014 jQuery Foundation and other contributors + * Copyright jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * @@ -490,11 +490,6 @@ $.widget.bridge = function( name, object ) { args = widget_slice.call( arguments, 1 ), returnValue = this; - // allow multiple hashes to be passed on init - options = !isMethodCall && args.length ? - $.widget.extend.apply( null, [ options ].concat(args) ) : - options; - if ( isMethodCall ) { this.each(function() { var methodValue, @@ -519,6 +514,12 @@ $.widget.bridge = function( name, object ) { } }); } else { + + // Allow multiple hashes to be passed on init + if ( args.length ) { + options = $.widget.extend.apply( null, [ options ].concat(args) ); + } + this.each(function() { var instance = $.data( this, fullName ); if ( instance ) { @@ -856,10 +857,10 @@ var widget = $.widget; /*! - * jQuery UI Mouse 1.11.2 + * jQuery UI Mouse 1.11.4 * http://jqueryui.com * - * Copyright 2014 jQuery Foundation and other contributors + * Copyright jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * @@ -873,7 +874,7 @@ $( document ).mouseup( function() { }); var mouse = $.widget("ui.mouse", { - version: "1.11.2", + version: "1.11.4", options: { cancel: "input,textarea,button,select,option", distance: 1, @@ -1042,10 +1043,10 @@ var mouse = $.widget("ui.mouse", { /*! - * jQuery UI Position 1.11.2 + * jQuery UI Position 1.11.4 * http://jqueryui.com * - * Copyright 2014 jQuery Foundation and other contributors + * Copyright jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * @@ -1481,12 +1482,12 @@ $.ui.position = { newOverBottom; if ( overTop < 0 ) { newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; - if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) { + if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { position.top += myOffset + atOffset + offset; } } else if ( overBottom > 0 ) { newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; - if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) { + if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { position.top += myOffset + atOffset + offset; } } @@ -1549,15033 +1550,6648 @@ var position = $.ui.position; /*! - * jQuery UI Accordion 1.11.2 + * jQuery UI Draggable 1.11.4 * http://jqueryui.com * - * Copyright 2014 jQuery Foundation and other contributors + * Copyright jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * - * http://api.jqueryui.com/accordion/ + * http://api.jqueryui.com/draggable/ */ -var accordion = $.widget( "ui.accordion", { - version: "1.11.2", +$.widget("ui.draggable", $.ui.mouse, { + version: "1.11.4", + widgetEventPrefix: "drag", options: { - active: 0, - animate: {}, - collapsible: false, - event: "click", - header: "> li > :first-child,> :not(li):even", - heightStyle: "auto", - icons: { - activeHeader: "ui-icon-triangle-1-s", - header: "ui-icon-triangle-1-e" - }, + addClasses: true, + appendTo: "parent", + axis: false, + connectToSortable: false, + containment: false, + cursor: "auto", + cursorAt: false, + grid: false, + handle: false, + helper: "original", + iframeFix: false, + opacity: false, + refreshPositions: false, + revert: false, + revertDuration: 500, + scope: "default", + scroll: true, + scrollSensitivity: 20, + scrollSpeed: 20, + snap: false, + snapMode: "both", + snapTolerance: 20, + stack: false, + zIndex: false, // callbacks - activate: null, - beforeActivate: null - }, - - hideProps: { - borderTopWidth: "hide", - borderBottomWidth: "hide", - paddingTop: "hide", - paddingBottom: "hide", - height: "hide" - }, - - showProps: { - borderTopWidth: "show", - borderBottomWidth: "show", - paddingTop: "show", - paddingBottom: "show", - height: "show" + drag: null, + start: null, + stop: null }, - _create: function() { - var options = this.options; - this.prevShow = this.prevHide = $(); - this.element.addClass( "ui-accordion ui-widget ui-helper-reset" ) - // ARIA - .attr( "role", "tablist" ); - // don't allow collapsible: false and active: false / null - if ( !options.collapsible && (options.active === false || options.active == null) ) { - options.active = 0; + if ( this.options.helper === "original" ) { + this._setPositionRelative(); } - - this._processPanels(); - // handle negative values - if ( options.active < 0 ) { - options.active += this.headers.length; + if (this.options.addClasses){ + this.element.addClass("ui-draggable"); } - this._refresh(); - }, - - _getCreateEventData: function() { - return { - header: this.active, - panel: !this.active.length ? $() : this.active.next() - }; - }, - - _createIcons: function() { - var icons = this.options.icons; - if ( icons ) { - $( "" ) - .addClass( "ui-accordion-header-icon ui-icon " + icons.header ) - .prependTo( this.headers ); - this.active.children( ".ui-accordion-header-icon" ) - .removeClass( icons.header ) - .addClass( icons.activeHeader ); - this.headers.addClass( "ui-accordion-icons" ); + if (this.options.disabled){ + this.element.addClass("ui-draggable-disabled"); } - }, + this._setHandleClassName(); - _destroyIcons: function() { - this.headers - .removeClass( "ui-accordion-icons" ) - .children( ".ui-accordion-header-icon" ) - .remove(); + this._mouseInit(); }, - _destroy: function() { - var contents; - - // clean up main element - this.element - .removeClass( "ui-accordion ui-widget ui-helper-reset" ) - .removeAttr( "role" ); - - // clean up headers - this.headers - .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " + - "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" ) - .removeAttr( "role" ) - .removeAttr( "aria-expanded" ) - .removeAttr( "aria-selected" ) - .removeAttr( "aria-controls" ) - .removeAttr( "tabIndex" ) - .removeUniqueId(); - - this._destroyIcons(); - - // clean up content panels - contents = this.headers.next() - .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " + - "ui-accordion-content ui-accordion-content-active ui-state-disabled" ) - .css( "display", "" ) - .removeAttr( "role" ) - .removeAttr( "aria-hidden" ) - .removeAttr( "aria-labelledby" ) - .removeUniqueId(); - - if ( this.options.heightStyle !== "content" ) { - contents.css( "height", "" ); + _setOption: function( key, value ) { + this._super( key, value ); + if ( key === "handle" ) { + this._removeHandleClassName(); + this._setHandleClassName(); } }, - _setOption: function( key, value ) { - if ( key === "active" ) { - // _activate() will handle invalid values and update this.options - this._activate( value ); + _destroy: function() { + if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) { + this.destroyOnClear = true; return; } + this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ); + this._removeHandleClassName(); + this._mouseDestroy(); + }, - if ( key === "event" ) { - if ( this.options.event ) { - this._off( this.headers, this.options.event ); - } - this._setupEvents( value ); - } + _mouseCapture: function(event) { + var o = this.options; - this._super( key, value ); + this._blurActiveElement( event ); - // setting collapsible: false while collapsed; open first panel - if ( key === "collapsible" && !value && this.options.active === false ) { - this._activate( 0 ); + // among others, prevent a drag on a resizable-handle + if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) { + return false; } - if ( key === "icons" ) { - this._destroyIcons(); - if ( value ) { - this._createIcons(); - } + //Quit if we're not on a valid handle + this.handle = this._getHandle(event); + if (!this.handle) { + return false; } - // #5332 - opacity doesn't cascade to positioned elements in IE - // so we need to add the disabled class to the headers and panels - if ( key === "disabled" ) { - this.element - .toggleClass( "ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); - this.headers.add( this.headers.next() ) - .toggleClass( "ui-state-disabled", !!value ); - } - }, + this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix ); - _keydown: function( event ) { - if ( event.altKey || event.ctrlKey ) { - return; - } + return true; - var keyCode = $.ui.keyCode, - length = this.headers.length, - currentIndex = this.headers.index( event.target ), - toFocus = false; + }, - switch ( event.keyCode ) { - case keyCode.RIGHT: - case keyCode.DOWN: - toFocus = this.headers[ ( currentIndex + 1 ) % length ]; - break; - case keyCode.LEFT: - case keyCode.UP: - toFocus = this.headers[ ( currentIndex - 1 + length ) % length ]; - break; - case keyCode.SPACE: - case keyCode.ENTER: - this._eventHandler( event ); - break; - case keyCode.HOME: - toFocus = this.headers[ 0 ]; - break; - case keyCode.END: - toFocus = this.headers[ length - 1 ]; - break; - } + _blockFrames: function( selector ) { + this.iframeBlocks = this.document.find( selector ).map(function() { + var iframe = $( this ); - if ( toFocus ) { - $( event.target ).attr( "tabIndex", -1 ); - $( toFocus ).attr( "tabIndex", 0 ); - toFocus.focus(); - event.preventDefault(); - } + return $( "
" ) + .css( "position", "absolute" ) + .appendTo( iframe.parent() ) + .outerWidth( iframe.outerWidth() ) + .outerHeight( iframe.outerHeight() ) + .offset( iframe.offset() )[ 0 ]; + }); }, - _panelKeyDown: function( event ) { - if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) { - $( event.currentTarget ).prev().focus(); + _unblockFrames: function() { + if ( this.iframeBlocks ) { + this.iframeBlocks.remove(); + delete this.iframeBlocks; } }, - refresh: function() { - var options = this.options; - this._processPanels(); - - // was collapsed or no panel - if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) { - options.active = false; - this.active = $(); - // active false only when collapsible is true - } else if ( options.active === false ) { - this._activate( 0 ); - // was active, but active panel is gone - } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { - // all remaining panel are disabled - if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) { - options.active = false; - this.active = $(); - // activate previous panel - } else { - this._activate( Math.max( 0, options.active - 1 ) ); - } - // was active, active panel still exists - } else { - // make sure active index is correct - options.active = this.headers.index( this.active ); + _blurActiveElement: function( event ) { + var document = this.document[ 0 ]; + + // Only need to blur if the event occurred on the draggable itself, see #10527 + if ( !this.handleElement.is( event.target ) ) { + return; } - this._destroyIcons(); + // support: IE9 + // IE9 throws an "Unspecified error" accessing document.activeElement from an