assets/bedrock/js/bedrock.js in bedrock_sass-0.1.3 vs assets/bedrock/js/bedrock.js in bedrock_sass-0.1.4
- old
+ new
@@ -61,11 +61,11 @@
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 52);
+/******/ return __webpack_require__(__webpack_require__.s = 53);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
@@ -15756,14 +15756,14 @@
var _whatInput = __webpack_require__(39);
var _whatInput2 = _interopRequireDefault(_whatInput);
+__webpack_require__(52);
+
__webpack_require__(51);
-__webpack_require__(50);
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
window.$ = _jquery2.default;
(0, _jquery2.default)(document).foundation();
@@ -31080,10 +31080,11 @@
*/
}, {
key: '_init',
value: function _init() {
+ this._handleEvents();
this.dropzone = new _dropzone2.default('#' + this.id, this.options);
}
/**
* Get the dropzone preview template.
@@ -31116,10 +31117,35 @@
}, {
key: '_events',
value: function _events() {}
/**
+ * Handles events from the dropzone.
+ * @function
+ * @private
+ */
+
+ }, {
+ key: '_handleEvents',
+ value: function _handleEvents() {
+ this.options.queuecomplete = function () {
+ this.$element.trigger('queuecomplete.zf.dropzone.upload');
+ }.bind(this);
+ }
+
+ /**
+ * Removes all uploaded items.
+ * @function
+ */
+
+ }, {
+ key: 'clear',
+ value: function clear() {
+ this.dropzone.removeAllFiles();
+ }
+
+ /**
* Destroys the dropzone-upload plugin.
* @function
* @private
*/
@@ -31143,10 +31169,147 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
+exports.FileInput = undefined;
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _jquery = __webpack_require__(0);
+
+var _jquery2 = _interopRequireDefault(_jquery);
+
+var _foundation = __webpack_require__(1);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+/**
+ * FileInput module.
+ * @module fileInput
+ */
+
+var FileInput = function (_Plugin) {
+ _inherits(FileInput, _Plugin);
+
+ function FileInput() {
+ _classCallCheck(this, FileInput);
+
+ return _possibleConstructorReturn(this, (FileInput.__proto__ || Object.getPrototypeOf(FileInput)).apply(this, arguments));
+ }
+
+ _createClass(FileInput, [{
+ key: '_setup',
+
+ /**
+ * Creates a new instance of an file-input.
+ * @class
+ * @name FileInput
+ * @fires FileInput#init
+ * @param {Object} element - jQuery object to initialize.
+ * @param {Object} options - Overrides to the default plugin settings.
+ */
+ value: function _setup(element, options) {
+ this.className = 'FileInput'; // ie9 back compat
+ this.$element = element;
+ this.options = _jquery2.default.extend({}, FileInput.defaults, this.$element.data(), options);
+
+ this._init();
+ }
+
+ /**
+ * Initializes the file-input wrapper.
+ * @function
+ * @private
+ */
+
+ }, {
+ key: '_init',
+ value: function _init() {
+ this.id = this.$element.attr('id');
+ this.template = (0, _jquery2.default)('#' + this.id + '-preview-template').html();
+ this.$item = (0, _jquery2.default)(this.template);
+ this.$preview = (0, _jquery2.default)(this.options.previewsContainer);
+ this.$empty = this.$element.find('.dz-message');
+ this.$input = this.$element.find('input[type="file"]');
+
+ if (this.$preview.children().length) {
+ this.$empty.hide();
+ }
+
+ this._events();
+ }
+
+ /**
+ * Adds event handlers to the file-input.
+ * @function
+ * @private
+ */
+
+ }, {
+ key: '_events',
+ value: function _events() {
+ var input = this.$input.get(0);
+
+ this.$input.on('change', function (event) {
+ if (input.files && input.files[0]) {
+ var reader = new FileReader();
+
+ reader.onload = function (e) {
+ var preview = this.$item.clone();
+ preview.find('[dz-thumbnail]').attr('src', e.target.result);
+
+ this.$empty.hide();
+ this.$preview.html(preview);
+ }.bind(this);
+
+ reader.readAsDataURL(input.files[0]);
+ }
+ }.bind(this));
+
+ this.$element.on('click', '[dz-remove]', function (event) {
+ event.preventDefault();
+
+ this.$empty.show();
+ this.$preview.html('');
+ }.bind(this));
+ }
+
+ /**
+ * Destroys the file-input plugin.
+ * @function
+ * @private
+ */
+
+ }, {
+ key: '_destroy',
+ value: function _destroy() {}
+ }]);
+
+ return FileInput;
+}(_foundation.Plugin);
+
+FileInput.defaults = {};
+
+exports.FileInput = FileInput;
+
+/***/ }),
+/* 42 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
exports.InlineEditBox = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _jquery = __webpack_require__(0);
@@ -31371,11 +31534,11 @@
InlineEditBox.defaults = {};
exports.InlineEditBox = InlineEditBox;
/***/ }),
-/* 42 */
+/* 43 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -31537,11 +31700,11 @@
ListRemove.defaults = {};
exports.ListRemove = ListRemove;
/***/ }),
-/* 43 */
+/* 44 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -31805,11 +31968,11 @@
ListSelect.defaults = {};
exports.ListSelect = ListSelect;
/***/ }),
-/* 44 */
+/* 45 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -32042,11 +32205,11 @@
MediaAttach.defaults = {};
exports.MediaAttach = MediaAttach;
/***/ }),
-/* 45 */
+/* 46 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -32099,27 +32262,17 @@
* @param {Object} options - Overrides to the default plugin settings.
*/
value: function _setup(element, options) {
this.className = 'MediaReveal'; // ie9 back compat
this.$element = element;
- this.id = this.$element.attr('id');
+ this.$dropzone = this.$element.find('[data-dropzone-upload]');
this.options = _jquery2.default.extend({}, MediaReveal.defaults, this.$element.data(), options);
- this.template = (0, _jquery2.default)('#' + this.id + '-item-template').html();
+ this.reveal = new Foundation.Reveal(element, this.options);
this.items = [];
this.selectedItems = [];
- this.reveal = new Foundation.Reveal(element, this.options);
- this.mediaUrl = this.options.mediaUrl;
- this.mediaKey = this.options.mediaKey;
- this.$insert = this.$element.find('[data-insert]');
- this.$grid = this.$element.find('[data-list-select]');
- this.$item = (0, _jquery2.default)(this.template);
- this.imageKey = this.$item.find('[data-src]').attr('data-src');
- this.imageUrl = this.$item.find('[data-url]').attr('data-url') || '[src]';
- this.titleKey = this.$item.find('[data-text]').attr('data-text');
this._init();
- this._events();
}
/**
* Initializes the media-reveal wrapper.
* @function
@@ -32127,11 +32280,25 @@
*/
}, {
key: '_init',
value: function _init() {
+ this.id = this.$element.attr('id');
+ this.template = (0, _jquery2.default)('#' + this.id + '-item-template').html();
+ this.mediaUrl = this.options.mediaUrl;
+ this.mediaKey = this.options.mediaKey;
+ this.uniqueKey = this.options.uniqueKey || 'id';
+ this.$insert = this.$element.find('[data-insert]');
+ this.$grid = this.$element.find('[data-list-select]');
+ this.$item = (0, _jquery2.default)(this.template);
+ this.imageKey = this.$item.find('[data-src]').attr('data-src');
+ this.imageUrl = this.$item.find('[data-url]').attr('data-url') || '[src]';
+ this.titleKey = this.$item.find('[data-text]').attr('data-text');
+
this.$insert.addClass('disabled');
+
+ this._events();
}
/**
* Adds event handlers to the media-reveal.
* @function
@@ -32151,10 +32318,14 @@
});
this.$insert.off('click').on({
'click': this.insert.bind(this)
});
+
+ this.$dropzone.off('.zf.dropzone.upload').on({
+ 'queuecomplete.zf.dropzone.upload': this._uploadComplete.bind(this)
+ });
}
/**
* Gets media items JSON from url.
* @function
@@ -32196,16 +32367,18 @@
}, {
key: '_buildItem',
value: function _buildItem(data) {
var item = this.$item.clone();
+ var key = this._getObjectValue(data, this.uniqueKey);
var url = this._getObjectValue(data, this.imageKey);
var title = this._getObjectValue(data, this.titleKey);
item.find('[data-src]').attr('src', this.imageUrl.replace('[src]', url));
item.find('[data-text]').text(title);
item.data('imageObject', data);
+ item.data('uniqueKey', key);
return item;
}
/**
@@ -32225,10 +32398,32 @@
this.$grid.append(this.items);
}
/**
+ * Switches ui elements when uploads are completed.
+ * @param {Object} event - Event object passed from listener.
+ * @function
+ * @private
+ */
+
+ }, {
+ key: '_uploadComplete',
+ value: function _uploadComplete(event) {
+ var tabs = this.$element.find('[data-tabs]');
+ var tab = this.$grid.parents('.tabs-panel:first');
+
+ tabs.foundation('selectTab', tab);
+ this.$grid.empty();
+
+ this.items = [];
+ this._getItems();
+
+ this.$dropzone.foundation('clear');
+ }
+
+ /**
* Switches multi select mode.
* @param {Boolean} enable - Enable/disable multiple mode.
* @function
*/
@@ -32328,10 +32523,11 @@
value: function _destroy() {
this.reveal.destroy();
this.$element.off('.zf.reveal');
this.$grid.off('changed.zf.select.list');
this.$insert.off('click');
+ this.$dropzone.off('.zf.dropzone.upload');
}
}]);
return MediaReveal;
}(_foundation.Plugin);
@@ -32339,11 +32535,11 @@
MediaReveal.defaults = {};
exports.MediaReveal = MediaReveal;
/***/ }),
-/* 46 */
+/* 47 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -32617,11 +32813,11 @@
OffCanvasMenu.defaults = {};
exports.OffCanvasMenu = OffCanvasMenu;
/***/ }),
-/* 47 */
+/* 48 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -32678,10 +32874,14 @@
value: function _setup(element, options) {
this.className = 'SelectBox'; // ie9 back compat
this.$element = element;
this.options = _jquery2.default.extend({}, SelectBox.defaults, this.$element.data(), options);
+ if (this.options.list) {
+ this.options['theme'] = 'list';
+ }
+
this._init();
}
/**
* Initializes the select-box wrapper.
@@ -32690,49 +32890,155 @@
*/
}, {
key: '_init',
value: function _init() {
- var options = {};
+ this.$element.select2(this.options);
- if (this.options.list) {
- options['theme'] = 'list';
- }
+ this.select2 = this.$element.data('select2');
+ this.$container = this.select2.$container;
+ this.$dropdown = this.select2.$dropdown;
- this.$element.select2(options);
+ this._events();
+ this._keepPlaceholder();
}
/**
* Adds event handlers to the select-box.
* @function
* @private
*/
}, {
key: '_events',
- value: function _events() {}
+ value: function _events() {
+ this.$element.off(['select2:select', 'select2:unselect', 'select2:open']).on({
+ 'select2:open': this._handleEvent.bind(this),
+ 'select2:select': this._handleEvent.bind(this),
+ 'select2:unselect': this._handleEvent.bind(this)
+ });
+ this.$element.off('.zf.trigger').on({
+ 'open.zf.trigger': this.open.bind(this),
+ 'select.zf.trigger': this.select.bind(this),
+ 'unselect.zf.trigger': this.unselect.bind(this)
+ });
+ }
+
/**
+ * Keeps placeholder on search field.
+ * @function
+ * @private
+ */
+
+ }, {
+ key: '_keepPlaceholder',
+ value: function _keepPlaceholder() {
+ var search = this.$container.find('.select2-search__field');
+
+ if (search.length && this.options.list) {
+ search.attr('placeholder', this.options.placeholder);
+ }
+ }
+
+ /**
+ * Updates position on dropdown.
+ * @function
+ * @private
+ */
+
+ }, {
+ key: '_updatePosition',
+ value: function _updatePosition() {
+ var search = this.$container.find('.select2-search__field');
+ var dropdown = this.$dropdown.find('.select2-dropdown');
+
+ if (search.length && this.options.list) {
+ if (dropdown.hasClass('select2-dropdown--above')) {
+ var position = this.$container.innerHeight() - search.outerHeight();
+ dropdown.css('margin-top', position);
+ } else {
+ dropdown.css('margin-top', false);
+ }
+ }
+ }
+
+ /**
+ * Handles events on element.
+ * @param {Object} event - Event object passed from listener.
+ * @function
+ * @private
+ */
+
+ }, {
+ key: '_handleEvent',
+ value: function _handleEvent(event) {
+ this.$element.trigger(event.type.replace('select2:', ''));
+ this._keepPlaceholder();
+ }
+
+ /**
+ * Opens the select dropdown.
+ * @param {Object} event - Event object passed from listener.
+ * @function
+ */
+
+ }, {
+ key: 'open',
+ value: function open(event) {
+ this._updatePosition();
+ this.$element.trigger('open.zf.select.box');
+ }
+
+ /**
+ * Selects a list item.
+ * @param {Object} event - Event object passed from listener.
+ * @function
+ */
+
+ }, {
+ key: 'select',
+ value: function select(event) {
+ this.$element.trigger('changed.zf.select.box');
+ }
+
+ /**
+ * Unselects a list item.
+ * @param {Object} event - Event object passed from listener.
+ * @function
+ */
+
+ }, {
+ key: 'unselect',
+ value: function unselect(event) {
+ this.$element.trigger('changed.zf.select.box');
+ }
+
+ /**
* Destroys the select-box plugin.
* @function
* @private
*/
}, {
key: '_destroy',
- value: function _destroy() {}
+ value: function _destroy() {
+ this.$element.select2('destroy');
+ this.$element.off(['select2:select', 'select2:unselect', 'select2:open']);
+ this.$element.off('.zf.trigger');
+ }
}]);
return SelectBox;
}(_foundation.Plugin);
SelectBox.defaults = {};
exports.SelectBox = SelectBox;
/***/ }),
-/* 48 */
+/* 49 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -33049,11 +33355,11 @@
TableCheckbox.defaults = {};
exports.TableCheckbox = TableCheckbox;
/***/ }),
-/* 49 */
+/* 50 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -33191,49 +33497,52 @@
};
exports.TinyMceEditor = TinyMceEditor;
/***/ }),
-/* 50 */
+/* 51 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
-var _offcanvasMenu = __webpack_require__(46);
+var _offcanvasMenu = __webpack_require__(47);
-var _tinyMceEditor = __webpack_require__(49);
+var _tinyMceEditor = __webpack_require__(50);
-var _tableCheckbox = __webpack_require__(48);
+var _tableCheckbox = __webpack_require__(49);
-var _listSelect = __webpack_require__(43);
+var _listSelect = __webpack_require__(44);
-var _listRemove = __webpack_require__(42);
+var _listRemove = __webpack_require__(43);
-var _mediaReveal = __webpack_require__(45);
+var _mediaReveal = __webpack_require__(46);
-var _mediaAttach = __webpack_require__(44);
+var _mediaAttach = __webpack_require__(45);
var _dropzoneUpload = __webpack_require__(40);
-var _inlineEditBox = __webpack_require__(41);
+var _inlineEditBox = __webpack_require__(42);
-var _selectBox = __webpack_require__(47);
+var _selectBox = __webpack_require__(48);
+var _fileInput = __webpack_require__(41);
+
Foundation.plugin(_offcanvasMenu.OffCanvasMenu, 'OffCanvasMenu');
Foundation.plugin(_tinyMceEditor.TinyMceEditor, 'TinyMceEditor');
Foundation.plugin(_tableCheckbox.TableCheckbox, 'TableCheckbox');
Foundation.plugin(_listSelect.ListSelect, 'ListSelect');
Foundation.plugin(_listRemove.ListRemove, 'ListRemove');
Foundation.plugin(_mediaReveal.MediaReveal, 'MediaReveal');
Foundation.plugin(_mediaAttach.MediaAttach, 'MediaAttach');
Foundation.plugin(_dropzoneUpload.DropzoneUpload, 'DropzoneUpload');
Foundation.plugin(_inlineEditBox.InlineEditBox, 'InlineEditBox');
Foundation.plugin(_selectBox.SelectBox, 'SelectBox');
+Foundation.plugin(_fileInput.FileInput, 'FileInput');
/***/ }),
-/* 51 */
+/* 52 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -33375,10 +33684,10 @@
_foundation.Foundation.plugin(_foundation22.ResponsiveAccordionTabs, 'ResponsiveAccordionTabs');
module.exports = _foundation.Foundation;
/***/ }),
-/* 52 */
+/* 53 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(22);
\ No newline at end of file