diff options
Diffstat (limited to 'library')
-rw-r--r--[-rwxr-xr-x] | library/HTMLPurifier/DefinitionCache/Serializer/README | 0 | ||||
-rwxr-xr-x | library/blueimp_upload/server/node/server.js | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | library/font_awesome/src/assets/css/prettify.css | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | library/font_awesome/src/assets/js/ZeroClipboard-1.1.7.swf | bin | 1635 -> 1635 bytes | |||
-rw-r--r-- | library/imagesloaded/imagesloaded.pkgd.js | 487 | ||||
-rw-r--r-- | library/imagesloaded/imagesloaded.pkgd.min.js | 7 | ||||
-rw-r--r-- | library/jgrowl/jquery.jgrowl.map | 0 | ||||
-rwxr-xr-x | library/jqupload/server/node/server.js | 2 | ||||
-rw-r--r-- | library/readmore.js/readmore.js | 168 | ||||
-rw-r--r--[-rwxr-xr-x] | library/stylish_select/stylish-select.css | 0 |
10 files changed, 590 insertions, 76 deletions
diff --git a/library/HTMLPurifier/DefinitionCache/Serializer/README b/library/HTMLPurifier/DefinitionCache/Serializer/README index 2e35c1c3d..2e35c1c3d 100755..100644 --- a/library/HTMLPurifier/DefinitionCache/Serializer/README +++ b/library/HTMLPurifier/DefinitionCache/Serializer/README diff --git a/library/blueimp_upload/server/node/server.js b/library/blueimp_upload/server/node/server.js index 7bab20f59..808d6ffe1 100755 --- a/library/blueimp_upload/server/node/server.js +++ b/library/blueimp_upload/server/node/server.js @@ -1,4 +1,4 @@ -#!/usr/bin/env node +#!/usr/bin/nodejs /* * jQuery File Upload Plugin Node.js Example 2.1.2 * https://github.com/blueimp/jQuery-File-Upload diff --git a/library/font_awesome/src/assets/css/prettify.css b/library/font_awesome/src/assets/css/prettify.css index aedd8d1a9..aedd8d1a9 100755..100644 --- a/library/font_awesome/src/assets/css/prettify.css +++ b/library/font_awesome/src/assets/css/prettify.css diff --git a/library/font_awesome/src/assets/js/ZeroClipboard-1.1.7.swf b/library/font_awesome/src/assets/js/ZeroClipboard-1.1.7.swf Binary files differindex 880e64ee7..880e64ee7 100755..100644 --- a/library/font_awesome/src/assets/js/ZeroClipboard-1.1.7.swf +++ b/library/font_awesome/src/assets/js/ZeroClipboard-1.1.7.swf diff --git a/library/imagesloaded/imagesloaded.pkgd.js b/library/imagesloaded/imagesloaded.pkgd.js new file mode 100644 index 000000000..ef23971be --- /dev/null +++ b/library/imagesloaded/imagesloaded.pkgd.js @@ -0,0 +1,487 @@ +/*! + * imagesLoaded PACKAGED v4.1.0 + * JavaScript is all like "You images are done yet or what?" + * MIT License + */ + +/** + * EvEmitter v1.0.1 + * Lil' event emitter + * MIT License + */ + +/* jshint unused: true, undef: true, strict: true */ + +( function( global, factory ) { + // universal module definition + /* jshint strict: false */ /* globals define, module */ + if ( typeof define == 'function' && define.amd ) { + // AMD - RequireJS + define( 'ev-emitter/ev-emitter',factory ); + } else if ( typeof module == 'object' && module.exports ) { + // CommonJS - Browserify, Webpack + module.exports = factory(); + } else { + // Browser globals + global.EvEmitter = factory(); + } + +}( this, function() { + + + +function EvEmitter() {} + +var proto = EvEmitter.prototype; + +proto.on = function( eventName, listener ) { + if ( !eventName || !listener ) { + return; + } + // set events hash + var events = this._events = this._events || {}; + // set listeners array + var listeners = events[ eventName ] = events[ eventName ] || []; + // only add once + if ( listeners.indexOf( listener ) == -1 ) { + listeners.push( listener ); + } + + return this; +}; + +proto.once = function( eventName, listener ) { + if ( !eventName || !listener ) { + return; + } + // add event + this.on( eventName, listener ); + // set once flag + // set onceEvents hash + var onceEvents = this._onceEvents = this._onceEvents || {}; + // set onceListeners array + var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || []; + // set flag + onceListeners[ listener ] = true; + + return this; +}; + +proto.off = function( eventName, listener ) { + var listeners = this._events && this._events[ eventName ]; + if ( !listeners || !listeners.length ) { + return; + } + var index = listeners.indexOf( listener ); + if ( index != -1 ) { + listeners.splice( index, 1 ); + } + + return this; +}; + +proto.emitEvent = function( eventName, args ) { + var listeners = this._events && this._events[ eventName ]; + if ( !listeners || !listeners.length ) { + return; + } + var i = 0; + var listener = listeners[i]; + args = args || []; + // once stuff + var onceListeners = this._onceEvents && this._onceEvents[ eventName ]; + + while ( listener ) { + var isOnce = onceListeners && onceListeners[ listener ]; + if ( isOnce ) { + // remove listener + // remove before trigger to prevent recursion + this.off( eventName, listener ); + // unset once flag + delete onceListeners[ listener ]; + } + // trigger listener + listener.apply( this, args ); + // get next listener + i += isOnce ? 0 : 1; + listener = listeners[i]; + } + + return this; +}; + +return EvEmitter; + +})); + +/*! + * imagesLoaded v4.1.0 + * JavaScript is all like "You images are done yet or what?" + * MIT License + */ + +( function( window, factory ) { 'use strict'; + // universal module definition + + /*global define: false, module: false, require: false */ + + if ( typeof define == 'function' && define.amd ) { + // AMD + define( [ + 'ev-emitter/ev-emitter' + ], function( EvEmitter ) { + return factory( window, EvEmitter ); + }); + } else if ( typeof module == 'object' && module.exports ) { + // CommonJS + module.exports = factory( + window, + require('ev-emitter') + ); + } else { + // browser global + window.imagesLoaded = factory( + window, + window.EvEmitter + ); + } + +})( window, + +// -------------------------- factory -------------------------- // + +function factory( window, EvEmitter ) { + + + +var $ = window.jQuery; +var console = window.console; + +// -------------------------- helpers -------------------------- // + +// extend objects +function extend( a, b ) { + for ( var prop in b ) { + a[ prop ] = b[ prop ]; + } + return a; +} + +// turn element or nodeList into an array +function makeArray( obj ) { + var ary = []; + if ( Array.isArray( obj ) ) { + // use object if already an array + ary = obj; + } else if ( typeof obj.length == 'number' ) { + // convert nodeList to array + for ( var i=0; i < obj.length; i++ ) { + ary.push( obj[i] ); + } + } else { + // array of single index + ary.push( obj ); + } + return ary; +} + +// -------------------------- imagesLoaded -------------------------- // + +/** + * @param {Array, Element, NodeList, String} elem + * @param {Object or Function} options - if function, use as callback + * @param {Function} onAlways - callback function + */ +function ImagesLoaded( elem, options, onAlways ) { + // coerce ImagesLoaded() without new, to be new ImagesLoaded() + if ( !( this instanceof ImagesLoaded ) ) { + return new ImagesLoaded( elem, options, onAlways ); + } + // use elem as selector string + if ( typeof elem == 'string' ) { + elem = document.querySelectorAll( elem ); + } + + this.elements = makeArray( elem ); + this.options = extend( {}, this.options ); + + if ( typeof options == 'function' ) { + onAlways = options; + } else { + extend( this.options, options ); + } + + if ( onAlways ) { + this.on( 'always', onAlways ); + } + + this.getImages(); + + if ( $ ) { + // add jQuery Deferred object + this.jqDeferred = new $.Deferred(); + } + + // HACK check async to allow time to bind listeners + setTimeout( function() { + this.check(); + }.bind( this )); +} + +ImagesLoaded.prototype = Object.create( EvEmitter.prototype ); + +ImagesLoaded.prototype.options = {}; + +ImagesLoaded.prototype.getImages = function() { + this.images = []; + + // filter & find items if we have an item selector + this.elements.forEach( this.addElementImages, this ); +}; + +/** + * @param {Node} element + */ +ImagesLoaded.prototype.addElementImages = function( elem ) { + // filter siblings + if ( elem.nodeName == 'IMG' ) { + this.addImage( elem ); + } + // get background image on element + if ( this.options.background === true ) { + this.addElementBackgroundImages( elem ); + } + + // find children + // no non-element nodes, #143 + var nodeType = elem.nodeType; + if ( !nodeType || !elementNodeTypes[ nodeType ] ) { + return; + } + var childImgs = elem.querySelectorAll('img'); + // concat childElems to filterFound array + for ( var i=0; i < childImgs.length; i++ ) { + var img = childImgs[i]; + this.addImage( img ); + } + + // get child background images + if ( typeof this.options.background == 'string' ) { + var children = elem.querySelectorAll( this.options.background ); + for ( i=0; i < children.length; i++ ) { + var child = children[i]; + this.addElementBackgroundImages( child ); + } + } +}; + +var elementNodeTypes = { + 1: true, + 9: true, + 11: true +}; + +ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) { + var style = getComputedStyle( elem ); + if ( !style ) { + // Firefox returns null if in a hidden iframe https://bugzil.la/548397 + return; + } + // get url inside url("...") + var reURL = /url\((['"])?(.*?)\1\)/gi; + var matches = reURL.exec( style.backgroundImage ); + while ( matches !== null ) { + var url = matches && matches[2]; + if ( url ) { + this.addBackground( url, elem ); + } + matches = reURL.exec( style.backgroundImage ); + } +}; + +/** + * @param {Image} img + */ +ImagesLoaded.prototype.addImage = function( img ) { + var loadingImage = new LoadingImage( img ); + this.images.push( loadingImage ); +}; + +ImagesLoaded.prototype.addBackground = function( url, elem ) { + var background = new Background( url, elem ); + this.images.push( background ); +}; + +ImagesLoaded.prototype.check = function() { + var _this = this; + this.progressedCount = 0; + this.hasAnyBroken = false; + // complete if no images + if ( !this.images.length ) { + this.complete(); + return; + } + + function onProgress( image, elem, message ) { + // HACK - Chrome triggers event before object properties have changed. #83 + setTimeout( function() { + _this.progress( image, elem, message ); + }); + } + + this.images.forEach( function( loadingImage ) { + loadingImage.once( 'progress', onProgress ); + loadingImage.check(); + }); +}; + +ImagesLoaded.prototype.progress = function( image, elem, message ) { + this.progressedCount++; + this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded; + // progress event + this.emitEvent( 'progress', [ this, image, elem ] ); + if ( this.jqDeferred && this.jqDeferred.notify ) { + this.jqDeferred.notify( this, image ); + } + // check if completed + if ( this.progressedCount == this.images.length ) { + this.complete(); + } + + if ( this.options.debug && console ) { + console.log( 'progress: ' + message, image, elem ); + } +}; + +ImagesLoaded.prototype.complete = function() { + var eventName = this.hasAnyBroken ? 'fail' : 'done'; + this.isComplete = true; + this.emitEvent( eventName, [ this ] ); + this.emitEvent( 'always', [ this ] ); + if ( this.jqDeferred ) { + var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve'; + this.jqDeferred[ jqMethod ]( this ); + } +}; + +// -------------------------- -------------------------- // + +function LoadingImage( img ) { + this.img = img; +} + +LoadingImage.prototype = Object.create( EvEmitter.prototype ); + +LoadingImage.prototype.check = function() { + // If complete is true and browser supports natural sizes, + // try to check for image status manually. + var isComplete = this.getIsImageComplete(); + if ( isComplete ) { + // report based on naturalWidth + this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); + return; + } + + // If none of the checks above matched, simulate loading on detached element. + this.proxyImage = new Image(); + this.proxyImage.addEventListener( 'load', this ); + this.proxyImage.addEventListener( 'error', this ); + // bind to image as well for Firefox. #191 + this.img.addEventListener( 'load', this ); + this.img.addEventListener( 'error', this ); + this.proxyImage.src = this.img.src; +}; + +LoadingImage.prototype.getIsImageComplete = function() { + return this.img.complete && this.img.naturalWidth !== undefined; +}; + +LoadingImage.prototype.confirm = function( isLoaded, message ) { + this.isLoaded = isLoaded; + this.emitEvent( 'progress', [ this, this.img, message ] ); +}; + +// ----- events ----- // + +// trigger specified handler for event type +LoadingImage.prototype.handleEvent = function( event ) { + var method = 'on' + event.type; + if ( this[ method ] ) { + this[ method ]( event ); + } +}; + +LoadingImage.prototype.onload = function() { + this.confirm( true, 'onload' ); + this.unbindEvents(); +}; + +LoadingImage.prototype.onerror = function() { + this.confirm( false, 'onerror' ); + this.unbindEvents(); +}; + +LoadingImage.prototype.unbindEvents = function() { + this.proxyImage.removeEventListener( 'load', this ); + this.proxyImage.removeEventListener( 'error', this ); + this.img.removeEventListener( 'load', this ); + this.img.removeEventListener( 'error', this ); +}; + +// -------------------------- Background -------------------------- // + +function Background( url, element ) { + this.url = url; + this.element = element; + this.img = new Image(); +} + +// inherit LoadingImage prototype +Background.prototype = Object.create( LoadingImage.prototype ); + +Background.prototype.check = function() { + this.img.addEventListener( 'load', this ); + this.img.addEventListener( 'error', this ); + this.img.src = this.url; + // check if image is already complete + var isComplete = this.getIsImageComplete(); + if ( isComplete ) { + this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); + this.unbindEvents(); + } +}; + +Background.prototype.unbindEvents = function() { + this.img.removeEventListener( 'load', this ); + this.img.removeEventListener( 'error', this ); +}; + +Background.prototype.confirm = function( isLoaded, message ) { + this.isLoaded = isLoaded; + this.emitEvent( 'progress', [ this, this.element, message ] ); +}; + +// -------------------------- jQuery -------------------------- // + +ImagesLoaded.makeJQueryPlugin = function( jQuery ) { + jQuery = jQuery || window.jQuery; + if ( !jQuery ) { + return; + } + // set local variable + $ = jQuery; + // $().imagesLoaded() + $.fn.imagesLoaded = function( options, callback ) { + var instance = new ImagesLoaded( this, options, callback ); + return instance.jqDeferred.promise( $(this) ); + }; +}; +// try making plugin +ImagesLoaded.makeJQueryPlugin(); + +// -------------------------- -------------------------- // + +return ImagesLoaded; + +}); + diff --git a/library/imagesloaded/imagesloaded.pkgd.min.js b/library/imagesloaded/imagesloaded.pkgd.min.js new file mode 100644 index 000000000..c3e71fadc --- /dev/null +++ b/library/imagesloaded/imagesloaded.pkgd.min.js @@ -0,0 +1,7 @@ +/*! + * imagesLoaded PACKAGED v4.1.0 + * JavaScript is all like "You images are done yet or what?" + * MIT License + */ + +!function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}(this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return-1==n.indexOf(e)&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},n=i[t]=i[t]||[];return n[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return-1!=n&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=0,o=i[n];e=e||[];for(var r=this._onceEvents&&this._onceEvents[t];o;){var s=r&&r[o];s&&(this.off(t,o),delete r[o]),o.apply(this,e),n+=s?0:1,o=i[n]}return this}},t}),function(t,e){"use strict";"function"==typeof define&&define.amd?define(["ev-emitter/ev-emitter"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.imagesLoaded=e(t,t.EvEmitter)}(window,function(t,e){function i(t,e){for(var i in e)t[i]=e[i];return t}function n(t){var e=[];if(Array.isArray(t))e=t;else if("number"==typeof t.length)for(var i=0;i<t.length;i++)e.push(t[i]);else e.push(t);return e}function o(t,e,r){return this instanceof o?("string"==typeof t&&(t=document.querySelectorAll(t)),this.elements=n(t),this.options=i({},this.options),"function"==typeof e?r=e:i(this.options,e),r&&this.on("always",r),this.getImages(),h&&(this.jqDeferred=new h.Deferred),void setTimeout(function(){this.check()}.bind(this))):new o(t,e,r)}function r(t){this.img=t}function s(t,e){this.url=t,this.element=e,this.img=new Image}var h=t.jQuery,a=t.console;o.prototype=Object.create(e.prototype),o.prototype.options={},o.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)},o.prototype.addElementImages=function(t){"IMG"==t.nodeName&&this.addImage(t),this.options.background===!0&&this.addElementBackgroundImages(t);var e=t.nodeType;if(e&&d[e]){for(var i=t.querySelectorAll("img"),n=0;n<i.length;n++){var o=i[n];this.addImage(o)}if("string"==typeof this.options.background){var r=t.querySelectorAll(this.options.background);for(n=0;n<r.length;n++){var s=r[n];this.addElementBackgroundImages(s)}}}};var d={1:!0,9:!0,11:!0};return o.prototype.addElementBackgroundImages=function(t){var e=getComputedStyle(t);if(e)for(var i=/url\((['"])?(.*?)\1\)/gi,n=i.exec(e.backgroundImage);null!==n;){var o=n&&n[2];o&&this.addBackground(o,t),n=i.exec(e.backgroundImage)}},o.prototype.addImage=function(t){var e=new r(t);this.images.push(e)},o.prototype.addBackground=function(t,e){var i=new s(t,e);this.images.push(i)},o.prototype.check=function(){function t(t,i,n){setTimeout(function(){e.progress(t,i,n)})}var e=this;return this.progressedCount=0,this.hasAnyBroken=!1,this.images.length?void this.images.forEach(function(e){e.once("progress",t),e.check()}):void this.complete()},o.prototype.progress=function(t,e,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded,this.emitEvent("progress",[this,t,e]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,t),this.progressedCount==this.images.length&&this.complete(),this.options.debug&&a&&a.log("progress: "+i,t,e)},o.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(t,[this]),this.emitEvent("always",[this]),this.jqDeferred){var e=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[e](this)}},r.prototype=Object.create(e.prototype),r.prototype.check=function(){var t=this.getIsImageComplete();return t?void this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),void(this.proxyImage.src=this.img.src))},r.prototype.getIsImageComplete=function(){return this.img.complete&&void 0!==this.img.naturalWidth},r.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.img,e])},r.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},r.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},r.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},r.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype=Object.create(r.prototype),s.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url;var t=this.getIsImageComplete();t&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},s.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.element,e])},o.makeJQueryPlugin=function(e){e=e||t.jQuery,e&&(h=e,h.fn.imagesLoaded=function(t,e){var i=new o(this,t,e);return i.jqDeferred.promise(h(this))})},o.makeJQueryPlugin(),o});
\ No newline at end of file diff --git a/library/jgrowl/jquery.jgrowl.map b/library/jgrowl/jquery.jgrowl.map new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/library/jgrowl/jquery.jgrowl.map diff --git a/library/jqupload/server/node/server.js b/library/jqupload/server/node/server.js index 5eb07a6ed..e489772b5 100755 --- a/library/jqupload/server/node/server.js +++ b/library/jqupload/server/node/server.js @@ -1,4 +1,4 @@ -#!/usr/bin/env node +#!/usr/bin/nodejs /* * jQuery File Upload Plugin Node.js Example 2.1.1 * https://github.com/blueimp/jQuery-File-Upload diff --git a/library/readmore.js/readmore.js b/library/readmore.js/readmore.js index d4c1cf723..fb5a0e0f9 100644 --- a/library/readmore.js/readmore.js +++ b/library/readmore.js/readmore.js @@ -11,7 +11,18 @@ /* global jQuery */ -(function($) { +(function(factory) { + if (typeof define === 'function' && define.amd) { + // AMD + define(['jquery'], factory); + } else if (typeof exports === 'object') { + // CommonJS + module.exports = factory(require('jquery')); + } else { + // Browser globals + factory(jQuery); + } +}(function($) { 'use strict'; var readmore = 'readmore', @@ -61,20 +72,19 @@ } function setBoxHeights(element) { - var el = element, - expandedHeight = el.outerHeight(true), + var el = element.clone().css({ + height: 'auto', + width: element.width(), + maxHeight: 'none', + overflow: 'hidden' + }).insertAfter(element), + expandedHeight = el.outerHeight(), cssMaxHeight = parseInt(el.css({maxHeight: ''}).css('max-height').replace(/[^-\d\.]/g, ''), 10), defaultHeight = element.data('defaultHeight'); -console.log("el height: " + expandedHeight); - var collapsedHeight = element.data('collapsedHeight') || defaultHeight; + el.remove(); - if (!cssMaxHeight) { - collapsedHeight = defaultHeight; - } - else if (cssMaxHeight > collapsedHeight) { - collapsedHeight = cssMaxHeight; - } + var collapsedHeight = cssMaxHeight || element.data('collapsedHeight') || defaultHeight; // Store our measurements. element.data({ @@ -137,69 +147,75 @@ console.log("el height: " + expandedHeight); } function Readmore(element, options) { - var $this = this; - this.element = element; this.options = $.extend({}, defaults, options); - $(this.element).data({ - defaultHeight: this.options.collapsedHeight, - heightMargin: this.options.heightMargin - }); embedCSS(this.options); this._defaults = defaults; this._name = readmore; - // Waiting for the page to load doesn't work when there is dynamic content - // But usually we already have the content, so no need to wait - //window.addEventListener('load', function() { - $this.init(); - //}); + this.init(); + + // IE8 chokes on `window.addEventListener`, so need to test for support. + if (window.addEventListener) { + // Need to resize boxes when the page has fully loaded. + window.addEventListener('load', resizeBoxes); + window.addEventListener('resize', resizeBoxes); + } + else { + window.attachEvent('load', resizeBoxes); + window.attachEvent('resize', resizeBoxes); + } } Readmore.prototype = { init: function() { - var $this = this; + var current = $(this.element); - $(this.element).each(function() { - var current = $(this); + current.data({ + defaultHeight: this.options.collapsedHeight, + heightMargin: this.options.heightMargin + }); - setBoxHeights(current); + setBoxHeights(current); - var collapsedHeight = current.data('collapsedHeight'), - heightMargin = current.data('heightMargin'); + var collapsedHeight = current.data('collapsedHeight'), + heightMargin = current.data('heightMargin'); - if (current.outerHeight(true) <= collapsedHeight + heightMargin) { - // The block is shorter than the limit, so there's no need to truncate it. - return true; - } - else { - var id = current.attr('id') || uniqueId(), - useLink = $this.options.startOpen ? $this.options.lessLink : $this.options.moreLink; + if (current.outerHeight(true) <= collapsedHeight + heightMargin) { + // The block is shorter than the limit, so there's no need to truncate it. + return true; + } + else { + var id = current.attr('id') || uniqueId(), + useLink = this.options.startOpen ? this.options.lessLink : this.options.moreLink; - current.attr({ - 'data-readmore': '', - 'aria-expanded': false, - 'id': id - }); + current.attr({ + 'data-readmore': '', + 'aria-expanded': this.options.startOpen, + 'id': id + }); + + current.after($(useLink) + .on('click', (function(_this) { + return function(event) { + _this.toggle(this, current[0], event); + }; + })(this)) + .attr({ + 'data-readmore-toggle': '', + 'aria-controls': id + })); - current.after($(useLink) - .on('click', function(event) { $this.toggle(this, current[0], event); }) - .attr({ - 'data-readmore-toggle': '', - 'aria-controls': id - })); - - if (! $this.options.startOpen) { - current.css({ - height: collapsedHeight - }); - } + if (! this.options.startOpen) { + current.css({ + height: collapsedHeight + }); } - }); + } }, toggle: function(trigger, element, event) { @@ -208,22 +224,21 @@ console.log("el height: " + expandedHeight); } if (! trigger) { - trigger = $('[aria-controls="' + this.element.id + '"]')[0]; + trigger = $('[aria-controls="' + _this.element.id + '"]')[0]; } if (! element) { - element = this.element; + element = _this.element; } - var $this = this, - $element = $(element), + var $element = $(element), newHeight = '', newLink = '', expanded = false, collapsedHeight = $element.data('collapsedHeight'); if ($element.height() <= collapsedHeight) { - newHeight = $element.data('expandedHeight') + 'px'; + newHeight = 100 + '%'; newLink = 'lessLink'; expanded = true; } @@ -235,25 +250,31 @@ console.log("el height: " + expandedHeight); // Fire beforeToggle callback // Since we determined the new "expanded" state above we're now out of sync // with our true current state, so we need to flip the value of `expanded` - $this.options.beforeToggle(trigger, element, ! expanded); + this.options.beforeToggle(trigger, $element, ! expanded); $element.css({'height': newHeight}); // Fire afterToggle callback - $element.on('transitionend', function() { - $this.options.afterToggle(trigger, element, expanded); + $element.on('transitionend', (function(_this) { + return function() { + _this.options.afterToggle(trigger, $element, expanded); - $(this).attr({ - 'aria-expanded': expanded - }).off('transitionend'); - }); - - $(trigger).replaceWith($($this.options[newLink]) - .on('click', function(event) { $this.toggle(this, element, event); }) - .attr({ - 'data-readmore-toggle': '', - 'aria-controls': $element.attr('id') - })); + $(this).attr({ + 'aria-expanded': expanded + }).off('transitionend'); + } + })(this)); + + $(trigger).replaceWith($(this.options[newLink]) + .on('click', (function(_this) { + return function(event) { + _this.toggle(this, element, event); + }; + })(this)) + .attr({ + 'data-readmore-toggle': '', + 'aria-controls': $element.attr('id') + })); }, destroy: function() { @@ -305,6 +326,5 @@ console.log("el height: " + expandedHeight); } }; -})(jQuery); - +})); diff --git a/library/stylish_select/stylish-select.css b/library/stylish_select/stylish-select.css index 1f3dcd28d..1f3dcd28d 100755..100644 --- a/library/stylish_select/stylish-select.css +++ b/library/stylish_select/stylish-select.css |