1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 'use strict';
- define(['../../lib/@waca/dashboard-common/dist/core/Model'], function (Model) {
- var WidgetModel = null;
- WidgetModel = Model.extend({
- runtimeAttrs: ['filters'],
- validLocalizedProps: ['content', 'title', 'altText', 'name'],
- validWidgetTypesForLocalizationProps: ['text', 'image', 'media', 'webpage'],
- init: function init(spec) {
- this._addLocalizedProps(spec);
- WidgetModel.inherited('init', this, arguments);
- if (spec) {
- this.whitelistAttrs = ['id'];
- for (var item in spec) {
- if (spec.hasOwnProperty(item)) {
- this.whitelistAttrs.push(item);
- }
- }
- }
- },
-
- _addLocalizedProps: function _addLocalizedProps(spec) {
- var localizedProps = [];
-
-
- if (spec && this.validWidgetTypesForLocalizationProps.indexOf(spec.type) !== -1) {
- for (var item in spec) {
- if (spec.hasOwnProperty(item)) {
- if (this.validLocalizedProps.indexOf(item) !== -1) {
- localizedProps.push(item);
- }
- }
- }
- }
- this.localizedProps = localizedProps;
- },
- cloneWidget: function cloneWidget(idMap) {
- var clone = new WidgetModel(this.toJSON());
- clone.replaceIds(idMap);
- return clone;
- }
- });
- return WidgetModel;
- });
|