', {id: pfx + 'placeholder'}).css({'pointer-events':'none'}).hide();
- this.$plh.append( $('
', {id: pfx + "plh-int", class: pfx + 'insert'} ) );
-
- if(!this.$el.length)
- this.$el = $('.'+this.pfx+this.config.containerId);
-
- this.$plh.appendTo(this.$el);
- }
- this.$plh.data('hide',1);
- eV.freeze();
- this.$el.on('mousemove',this.onMove);
- $(document).on('mouseup',this.endMove);
- $(document).on('keypress',this.rollback);
- },
-
- /**
- * Get children dimensions
- * @param {Object} Parent element
- *
- * @retun {Array}
- * */
- getChildrenDim: function(el){
- var dim = [],
- p = el || this.$targetEl.parent(),
- oT = this.elT,
- oL = this.elL,
- ch = p.children('.' + this.pfx + this.config.itemClass);
- ch.each(function(){
- var $el = $(this),
- $elO = $el.offset();
- dim.push( [ $elO.top - oT, $elO.left - oL, $el.outerHeight(), $el.outerWidth(), true, this]);
- });
- return dim;
- },
-
- /**
- * During move
- * @param {Object} Event
- *
- * @return void
- * */
- onMove: function(e){
- this.moved = true;
-
- if(this.$plh.data('hide')){
- this.$plh.show();
- this.$plh.data('hide',0);
- }
- var eO = this.$el.offset();
- this.elT = eO.top;
- this.elL = eO.left;
- this.rY = (e.pageY - this.elT) + this.$el.scrollTop();
- this.rX = (e.pageX - this.elL) + this.$el.scrollLeft();
- this.inspect(e);
- this.updatePosition(this.rX, this.rY);
- var actualPos = this.posIndex+':'+this.posMethod;
-
- //If there is a significant changes with the pointer
- if(!this.lastPos || (this.lastPos != actualPos)){
- this.updatePlaceholderPos(this.posIndex, this.posMethod);
- this.lastPos = this.posIndex+':'+this.posMethod;
- }
- //Working alternative for find taget element
- //var $targetEl = this.$selParent.children('.'+this.pfx+this.config.itemClass).eq(this.aIndex);
- },
-
- /**
- * Search where to put placeholder
- * @param int X position of the mouse
- * @param int Y position of the mouse
- * @retun void
- * */
- updatePosition: function( posX, posY ){
- this.posMethod = "before";
- this.posIndex = 0;
- var leftLimit = 0, xLimit = 0, dimRight = 0, yLimit = 0, xCenter = 0, yCenter = 0, dimDown = 0, dim = 0;
- for(var i = 0; i < this.cDim.length; i++){ //Dim => t,l,h,w
- dim = this.cDim[i];
- dimDown = dim[0] + dim[2];
- yCenter = dim[0] + (dim[2] / 2); //Horizontal center
- xCenter = dim[1] + (dim[3] / 2); //Vertical center
- dimRight = dim[1] + dim[3];
- if( (xLimit && dim[1] > xLimit) || (yLimit && yCenter > yLimit) ||
- (leftLimit && dimRight < leftLimit)) //No need with this one if over the limit
- continue;
- if(!dim[4]){ //If it's not inFlow (like float element)
- if( posY < dimDown)
- yLimit = dimDown;
- if( posX < xCenter){ //If mouse lefter than center
- xLimit = xCenter;
- this.posMethod = "before";
- }else{
- leftLimit = xCenter;
- this.posMethod = "after";
- }
- this.posIndex = i;
- }else{
- this.posIndex = this.aIndex = i;
- if( posY < yCenter ){ //If mouse upper than center
- this.posMethod = "before"; //Should place helper before
- if(posY < dim[0])
- this.aIndex = i - 1;
- break; //No need to continue under inFlow element
- }else
- this.posMethod = "after";
- }
- }
- },
-
- /**
- * Updates the position of the placeholder
- * @param int Index of the nearest child
- * @param str Before or after position
- * @return void
- * */
- updatePlaceholderPos: function(index, method){
- var marg = 0, t = 0, l = 0, w = 0, h = 0,
- un = 'px',
- margI = 5,
- plh = this.$plh[0];
- if( this.cDim[index] ){
- var elDim = this.cDim[index];
- //If it's like with 'float' style
- if(!elDim[4]){
- w = 'auto';
- h = elDim[2] - (marg * 2) + un;
- t = elDim[0] + marg;
- l = (method == 'before') ? (elDim[1] - marg) : (elDim[1] + elDim[3] - marg);
- }else{
- //w = '100%';
- w = elDim[3] + un;
- //h = elDim[3] + un;
- t = (method == 'before') ? (elDim[0] - marg) : (elDim[0] + elDim[2] - marg);
- l = elDim[1];
- }
- }else{
- if(this.$targetEl){
- var trg = this.$targetEl[0],
- $elO = this.$targetEl.offset();
- t = $elO.top - this.elT + margI + 17;
- l = $elO.left - this.elL + margI * 7;
- w = (parseInt(trg.offsetWidth) - margI * 14) + un;
- }
- }
- plh.style.top = t + un;
- plh.style.left = l + un;
- if(w)
- plh.style.width = w;
- if(h)
- plh.style.height = h;
- },
-
- /**
- * Leave item
- * @param event
- *
- * @return void
- * */
- endMove: function(e){
- this.$el.off('mousemove',this.onMove);
- $(document).off('mouseup', this.endMove);
- $(document).off('keypress', this.rollback);
- this.eV.unfreeze();
- this.$plh.hide();
- if(this.moved)
- this.move(this.$targetEl, this.$sel, this.posIndex, this.posMethod);
- this.itemLeft();
- },
-
- /**
- * Move component to new position
- * @param {Object} Component to move
- * @param {Object} Target component
- * @param {Integer} Indicates the position inside the collection
- * @param {String} Before of after component
- *
- * @return void
- * */
- move: function(target, el, posIndex, method){
- var trg = target|| this.$targetEl;
- trg = trg || this.$backupEl;
- if(!trg)
- return;
- var index = posIndex || 0;
- var model = el.data("model");
- var collection = model.collection;
- var targetModel = trg.data('model');
- var targetCollection = targetModel.collection;
-
- if(!this.cDim.length)
- targetCollection = targetModel.get('components');
-
- if(targetCollection && targetModel.get('droppable')){
- index = method == 'after' ? index + 1 : index;
- var modelTemp = targetCollection.add({style:{}}, { at: index});
- var modelRemoved = collection.remove(model, { silent:false });
- targetCollection.add(modelRemoved, { at: index, silent:false });
- targetCollection.remove(modelTemp);
- }else
- console.warn("Invalid target position");
- },
-
- /**
- * Track inside which element pointer entered
- * @param event
- *
- * @return void
- * */
- inspect: function(e){
- var item = $(e.target).closest(this.itemClass);
- if(!this.$targetEl || (item.length && item[0] != this.$targetEl[0]) ){
- this.status = 1;
- if(item.length){
- this.$targetEl = this.$backupEl = item;
- this.$targetElP = this.$targetEl.parent();
- this.$targetsEl = this.$targetEl.find(this.itemsClass + ':first');
- this.$targetEl.on('mouseleave', this.itemLeft);
- this.targetM = this.$targetEl.data('model');
- this.dimT = this.getTargetDim(this.$targetEl[0]);
- this.cDim = this.getChildrenDim();
- }
- }else if( this.nearToBorders(this.$targetEl[0]) || this.$targetEl[0] == this.$sel[0] ){
- if(this.status == 1){
- this.status = 2;
- this.lastPos = null;
- this.cDim = this.getChildrenDim(this.$targetElP);
- }
- }else if( !this.nearToBorders(this.$targetEl[0]) ){
- if(this.status == 2){
- this.status = 1;
- this.lastPos = null;
- }
- this.cDim = [];
- }
- },
-
- /**
- * Triggered when pointer leaves item
- * @param event
- *
- * @return void
- * */
- itemLeft: function(e){
- if(this.$targetEl){
- this.$targetEl.off('mouseleave',this.itemLeft);
- this.$targetEl = null;
- }
- },
-
- /**
- * Returns dimension of the target
- * @param Event
- *
- * @return Array
- * */
- getTargetDim: function(e){
- var $el = $(e),
- $elO = $el.offset();
- return [ $elO.top - this.elT, $elO.left - this.elL, $el.outerHeight(), $el.outerWidth() ];
- },
-
- /**
- * Check if pointer is near to the borders of the target
- * @param event
- * @return Bool
- * */
- nearToBorders: function(e){
- var m = 10; //Limit in pixels for be near
- if(!this.dimT)
- return;
- var dimT = this.dimT;
- if( ((dimT[0] + m) > this.rY) || (this.rY > (dimT[0] + dimT[2] - m)) ||
- ((dimT[1] + m) > this.rX) || (this.rX > (dimT[1] + dimT[3] - m)) )
- return 1;
- else
- return 0;
- },
-
- /**
- * Rollback to previous situation
- * @param Event
- * @param Bool Indicates if rollback in anycase
- * @return void
- * */
- rollback: function(e, force){
- var key = e.which || e.keyCode;
- if(key == 27 || force){
- this.moved = false;
- this.endMove();
- }
- return;
- },
- });
- });
-define('Navigator/main',['require','./config/config','./view/ItemsView','./view/ItemSort'],function(require) {
- /**
- * @class Navigator
- * @param {Object} Collection
- * @param {Object} Configurations
- * */
- function Navigator(collection, c)
- {
- var config = c,
- defaults = require('./config/config'),
- ItemsView = require('./view/ItemsView');
-
- // Set default options
- for (var name in defaults) {
- if (!(name in config))
- config[name] = defaults[name];
- }
-
- var obj = {
- collection : collection,
- config : config,
- };
-
- // Check if sort is required
- if(config.sortable){
- var ItemSort = require('./view/ItemSort');
- obj.sorter = new ItemSort({config : config});
- }
-
- this.ItemsView = new ItemsView(obj);
- }
-
- Navigator.prototype = {
- render : function(){
- return this.ItemsView.render().$el;
- },
- };
-
- return Navigator;
-});
-define('Navigator', ['Navigator/main'], function (main) { return main; });
-
-define('Commands/view/OpenLayers',['Navigator'], function(Layers) {
- /**
- * @class OpenStyleManager
- * */
- return {
-
- run: function(em, sender)
- {
- if(!this.$layers){
- var collection = em.get('Components').getComponent().get('components'),
- config = em.get('Config'),
- panels = em.get('Panels'),
- lyStylePfx = config.layers.stylePrefix || 'nv-';
-
- config.layers.stylePrefix = config.stylePrefix + lyStylePfx;
- var layers = new Layers(collection, config.layers);
- this.$layers = layers.render();
-
- if(!panels.getPanel('views-container'))
- this.panel = panels.addPanel({ id: 'views-container'});
- else
- this.panel = panels.getPanel('views-container');
-
- this.panel.set('appendContent', this.$layers).trigger('change:appendContent');
- }
- this.$layers.show();
- },
-
- stop: function()
- {
- if(this.$layers)
- this.$layers.hide();
- }
- };
- });
-define('StyleManager/config/config',[],function () {
- return {
-
- stylePrefix : 'sm-',
-
- target : null,
-
- sectors : [],
-
- };
-});
-define('StyleManager/model/Sector',['backbone'],
- function(Backbone) {
- /**
- * @class Sector
- * */
- return Backbone.Model.extend({
-
- defaults: {
- name : '',
- open: true,
- properties : {},
- }
-
- });
- });
-define('StyleManager/model/Property',['backbone'],
- function(Backbone) {
- /**
- * @class Property
- * */
- return Backbone.Model.extend({
-
- defaults: {
- name : '', //Name of the property
- property: '', //CSS property, eg. min-height
- type: '', //Type of the property: integer | radio | select | color | file | composite | stack
- units: [], //Unit of measure available, eg. ['px','%','em']
- unit: '', //Unit selected
- defaults: '', //Default value
- info: '', //Description HTML
- value: '', //Selected value of the property
- icon: '', //If exists, a custom class will be attached and no text will be displayed
- preview: false, //Show layers preview. Available only for stack property
- functionName: '', //Indicates if value need to be wrapped in some function, for istance: transform: rotate(90deg)
- properties : {}, //For composite properties
- layers : {}, //For stack properties
- list: [], //If exits, ignore type attribute ad display as multi-optional property
- //Any element could be as:
- // value : 'auto',
- // icon: 'auto',
- // defaults : true,
- // style: '', //custom style to the value of propriety
- // name:'' //alternative view to value
- }
-
- });
- });
-define('StyleManager/model/Properties',[ 'backbone','./Property'],
- function (Backbone,Property) {
- /**
- * @class Properties
- * */
- return Backbone.Collection.extend({
-
- model: Property,
-
- });
-});
-
-define('StyleManager/model/Sectors',[ 'backbone','./Sector','./Properties'],
- function (Backbone,Sector, Properties) {
- /**
- * @class Sectors
- * */
- return Backbone.Collection.extend({
-
- model: Sector,
-
- initialize: function(collection) {
-
- _.each(collection, function(obj){
-
- if(obj.properties instanceof Array){
- obj.properties = new Properties(obj.properties);
- }
-
- },this);
-
- },
-
- });
-});
-
-
-define('text!StyleManager/templates/propertyLabel.html',[],function () { return '
\n\t
\n\t\t<%= label %>\n\t
\n
';});
-
-define('StyleManager/view/PropertyView',['backbone', 'text!./../templates/propertyLabel.html'],
- function (Backbone, propertyTemplate) {
- /**
- * @class PropertyView
- * */
- return Backbone.View.extend({
-
- template: _.template(propertyTemplate),
- templateLabel: _.template(propertyTemplate),
-
- events: {
- 'change' : 'valueChanged',
- },
-
- initialize: function(o) {
- this.config = o.config;
- this.pfx = this.config.stylePrefix;
- this.target = o.target || {};
- this.onChange = o.onChange || {};
- this.onInputRender = o.onInputRender || {};
- this.customValue = o.customValue || {};
- this.func = this.model.get('functionName');
- this.defaultValue = this.model.get('defaults');
- this.property = this.model.get('property');
- this.units = this.model.get('units');
- this.min = this.model.get('min') || this.model.get('min')===0 ? this.model.get('min') : -5000;
- this.max = this.model.get('max') || this.model.get('max')===0 ? this.model.get('max') : 5000;
- this.unit = this.model.get('unit') ? this.model.get('unit') : (this.units.length ? this.units[0] : '');
- this.list = this.model.get('list');
- this.input = this.$input = null;
- this.className = this.pfx + 'property';
- this.selectedComponent = this.target.get('selectedComponent');
-
- if(this.selectedComponent){
- this.componentValue = this.selectedComponent.get('style')[this.property];
- }
-
- this.listenTo( this.target ,'change:selectedComponent',this.componentSelected);
- this.listenTo( this.model ,'change:value', this.valueChanged);
- },
-
- /**
- * Rerender property for the new selected component, if necessary
- * @param Array [Model, value, options]
- *
- * @return void
- * */
- componentSelected: function(e){
- this.selectedComponent = this.target.get('selectedComponent');
- if(this.selectedComponent){
- //I will rerender it only if the assigned one is different from the actuale value
- //console.log('property '+this.property+" view: "+this.componentValue+" model: "+ this.model.get('value'));
- if( !this.sameValue() ){
- this.renderInputRequest();
- }
- }
- },
-
- /**
- * Checks if the value from selected component is the same with
- * the value of the model
- *
- * @return boolean
- * */
- sameValue: function(){
- return this.getComponentValue() == (this.model.get('value')+this.model.get('unit'));
- },
-
-
- /**
- * Get the value from the selected component of this property
- *
- * @return string
- * */
- getComponentValue: function(){
- if(!this.selectedComponent)
- return;
-
- if(this.selectedComponent.get('style')[this.property])
- this.componentValue = this.selectedComponent.get('style')[this.property];
- else
- this.componentValue = this.defaultValue + (this.unit ? this.unit : '');
-
- // Check if wrap inside function is required
- if(this.func){
- var v = this.fetchFromFunction(this.componentValue);
- if(v)
- this.componentValue = v;
- }
-
- //This allow to ovveride the normal flow of selecting component value,
- //useful in composite properties
- if(this.customValue && typeof this.customValue === "function"){
- var index = this.model.collection.indexOf(this.model);
- var t = this.customValue(this, index);
- if(t)
- this.componentValue = t;
- }
-
- return this.componentValue;
- },
-
- /**
- * Fetch string from function type value
- * @param string Function type value
- *
- * @return string
- * */
- fetchFromFunction: function(v){
- return v.substring(v.indexOf("(") + 1, v.lastIndexOf(")"));
- },
-
- /**
- * Property was changed, so I need to update the component too
- * @param {Object} e Events
- * @param {Mixed} val Value
- * @param {Object} opt Options
- *
- * @return void
- * */
- valueChanged: function(e, val, opt){
- if(!this.selectedComponent)
- return;
-
- // Check if component is allowed to be styled
- var stylable = this.selectedComponent.get('stylable');
- if( (stylable instanceof Array && _.indexOf(stylable, this.property) < 0) || !stylable )
- return;
- var v = e && e.currentTarget ? this.$input.val() : this.model.get('value'),
- value = v + (this.$unit ? this.$unit.val() : ''),
- avSt = opt ? opt.avoidStore : 0;
-
- //The easiest way to deal with radio inputs
- if(this.model.get('type') == 'radio')
- value = this.$el.find('input:checked').val();
-
- if(this.$input)
- this.$input.val(v);
- this.model.set({ value : v },{ silent : true });
-
- if(this.func)
- value = this.func + '(' + value + ')';
-
- if( !this.model.get('doNotStyle') ){
- var componentCss = _.clone( this.selectedComponent.get('style') );
- componentCss[this.property] = value;
- this.selectedComponent.set('style', componentCss, { avoidStore : avSt});
- }
- this.selectedValue = value;//TODO ?
-
- if(this.onChange && typeof this.onChange === "function"){
- this.onChange(this.selectedComponent, this.model);
- }
- },
-
- /**
- * Set value to the input
- * @param String value
- *
- * @return void
- * */
- setValue: function(value, force){
- var f = force===0 ? 0 : 1;
- var v = this.model.get('value') || this.defaultValue;
- if(value || f){
- v = value;
- }
- if(this.$input)
- this.$input.val(v);
- this.model.set({value: v},{silent: true});
- },
-
- /**
- * Render label
- *
- * @return void
- * */
- renderLabel: function(){
- this.$el.html( this.templateLabel({
- pfx : this.pfx,
- icon : this.model.get('icon'),
- info : this.model.get('info'),
- label : this.model.get('name'),
- }) );
- },
-
- /**
- * Render field property
- *
- * @return void
- * */
- renderField : function() {
- this.renderTemplate();
- this.renderInput();
- delete this.componentValue;
- },
-
- /**
- * Render loaded template
- *
- * @return void
- * */
- renderTemplate: function(){
- this.$el.append( this.template({
- pfx : this.pfx,
- icon : this.model.get('icon'),
- info : this.model.get('info'),
- label : this.model.get('name'),
- }));
- },
-
- /**
- * Renders input, to override
- *
- * @return void
- * */
- renderInput: function(){
- console.warn("No render input implemented for '"+this.model.get('type')+"'");
- },
-
- /**
- * Request to render input of the property
- *
- * @return void
- * */
- renderInputRequest: function(){
- this.renderInput();
- if(this.onInputRender && typeof this.onInputRender === "function"){
- var index = this.model.collection.indexOf(this.model);
- this.onInputRender(this, index);
- }
- },
-
- /**
- * Clean input
- *
- * @return void
- * */
- cleanValue: function(){
- this.setValue('');
- },
-
- render : function(){
- this.renderLabel();
- this.renderField();
- this.$el.attr('class', this.className);
- return this;
- },
-
- });
-});
-
-
-define('text!StyleManager/templates/propertyInteger.html',[],function () { return '
\n\t
input-holder\'> \n\t
units-holder\'> \n\t
\n
';});
-
-define('StyleManager/view/PropertyIntegerView',['backbone','./PropertyView', 'text!./../templates/propertyInteger.html'],
- function (Backbone, PropertyView, propertyTemplate) {
- /**
- * @class PropertyIntegerView
- * */
- return PropertyView.extend({
-
- template: _.template(propertyTemplate),
-
- initialize: function(options) {
- PropertyView.prototype.initialize.apply(this, arguments);
- _.bindAll(this, 'moveIncrement', 'upIncrement');
- this.events['click .'+this.pfx+'u-arrow'] = 'upArrowClick';
- this.events['click .'+this.pfx+'d-arrow'] = 'downArrowClick';
- this.events['mousedown .'+this.pfx+'int-arrows'] = 'downIncrement';
- this.delegateEvents();
- },
-
- /**
- * Invoked when the up arrow is clicked
- * @param Event
- *
- * @return void
- * */
- upArrowClick: function(e){
- var value = this.model.get('value');
- value = isNaN(value) ? 1 : parseInt(value,10) + 1;
- value = value > this.max ? this.max : value;
- this.model.set('value',value);
- },
-
- /**
- * Invoked when the down arrow is clicked
- * @param Event
- *
- * @return void
- * */
- downArrowClick: function(e){
- var value = this.model.get('value');
- value = isNaN(value) ? 0 : parseInt(value,10) - 1;
- value = value < this.min ? this.min : value;
- this.model.set('value',value);
- },
-
- /**
- * Change easily integer input value with click&drag method
- * @param Event
- *
- * @return void
- * */
- downIncrement: function(e) {
- e.preventDefault();
- this.moved = 0;
- var value = this.model.get('value');
- value = isNaN(value) ? 0 : parseInt(value,10);
- var current = {y: e.pageY, val: value };
- $(document).mouseup(current, this.upIncrement);
- $(document).mousemove(current, this.moveIncrement);
- },
-
- /** While the increment is clicked, moving the mouse will update input value
- * @param Object
- *
- * @return bool
- * */
- moveIncrement: function (ev) {
- this.moved = 1;
- this.prValue = Math.max(this.min, Math.min(this.max, parseInt(ev.data.val - ev.pageY + ev.data.y, 10) ) );
- this.model.set( 'value', this.prValue, { avoidStore: 1 });
- return false;
- },
-
- /**
- * Stop moveIncrement method
- * @param Object
- *
- * @return void
- * */
- upIncrement: function (e) {
- $(document).off('mouseup', this.upIncrement);
- $(document).off('mousemove', this.moveIncrement);
-
- if(this.prValue && this.moved)
- this.model.set('value', this.prValue - 1, {silent:1}).set('value', this.prValue + 1);
- },
-
- /** @inheritdoc */
- renderInput: function() {
- var pfx = this.pfx;
- if(!this.$input){
- this.$input = $('
', {placeholder: 'auto', type: 'text' });
- this.$el.find('#'+ pfx +'input-holder').html(this.$input);
- }
- if(!this.$unit){
- if(this.units && this.units.length){
- this.unitS = '
';
- _.each(this.units,function(unit){
- var selected = unit == this.selectedUnit ? 'selected': '';
- this.unitS += ''+unit+' ';
- },this);
- this.unitS += ' ';
- this.$unit = $(this.unitS);
- this.$el.find('#' + pfx + 'units-holder').html(this.$unit);
- }
- }
- this.setValue(this.componentValue);
- },
-
- /** @inheritdoc */
- setValue: function(value){
- var u = this.unit,
- v = this.model.get('value') || this.defaultValue;
-
- if(value){
- v = parseInt(value, 10);
- v = !isNaN(v) ? v : this.defaultValue;
- var uN = value.replace(v,'');
- if(_.indexOf(this.units, uN) > -1)
- u = uN;
- }
-
- if(this.$input)
- this.$input.val(v);
- if(this.$unit)
- this.$unit.val(u);
- this.model.set({value: v, unit: u,},{silent: true});
- },
-
- });
-});
-
-
-define('text!StyleManager/templates/propertyRadio.html',[],function () { return '
\n\tinput-holder\'> \n
\n
';});
-
-define('StyleManager/view/PropertyRadioView',['backbone','./PropertyView', 'text!./../templates/propertyRadio.html'],
- function (Backbone, PropertyView, propertyTemplate) {
- /**
- * @class PropertyRadioView
- * */
- return PropertyView.extend({
-
- template: _.template(propertyTemplate),
-
- initialize: function(options) {
- PropertyView.prototype.initialize.apply(this, arguments);
- this.className = this.className + ' '+ this.pfx +'list';
- },
-
- /** @inheritdoc */
- renderInput: function() {
- var pfx = this.pfx;
- if(!this.$input){
- if(this.list && this.list.length){
- this.input = '';
- _.each(this.list,function(el){
- var cl = el.className ? el.className+' '+ pfx + 'icon' : '',
- title = el.title ? el.title : '',
- id = this.property+'-'+el.value;
- this.input += '
'+
- ' '+
- '' + (cl ? '' : el.value) + '
';
- },this);
- this.$input = $(this.input);
- this.$el.find('#'+ pfx +'input-holder').html(this.$input);
- this.$inputRadio = this.$input.find('input[name="'+this.property+'"]');
- }
- }
- this.setValue(this.componentValue);
- },
-
- /** @inheritdoc */
- setValue: function(value){
- var v = this.model.get('value') || this.defaultValue;
- if(value){
- v = value;
- }
- if(this.$inputRadio){
- this.$inputRadio.filter('[value="'+v+'"]').prop('checked', true);
- }
- this.model.set({value: v},{silent: true});
- },
-
- });
-});
-
-
-define('text!StyleManager/templates/propertySelect.html',[],function () { return '
\n\t
input-holder\'> \n\t
\n
\n
';});
-
-define('StyleManager/view/PropertySelectView',['backbone','./PropertyView', 'text!./../templates/propertySelect.html'],
- function (Backbone, PropertyView, propertyTemplate) {
- /**
- * @class PropertySelectView
- * */
- return PropertyView.extend({
-
- template: _.template(propertyTemplate),
-
- /** @inheritdoc */
- renderInput: function() {
- var pfx = this.pfx;
- if(!this.$input){
- if(this.list && this.list.length){
- this.input = '
';
- _.each(this.list,function(el){
- var name = el.name ? el.name : el.value;
- var style = el.style ? el.style.replace(/"/g,'"') : '';
- this.input += ''+name+' ';
- },this);
- this.input += ' ';
- this.$input = $(this.input);
- this.$el.find('#'+ pfx +'input-holder').html(this.$input);
- }
- }
- this.setValue(this.componentValue, 0);
- },
-
- });
-});
-
-// Spectrum Colorpicker v1.8.0
-// https://github.com/bgrins/spectrum
-// Author: Brian Grinstead
-// License: MIT
-
-(function (factory) {
- "use strict";
-
- if (typeof define === 'function' && define.amd) { // AMD
- define('Spectrum',['jquery'], factory);
- }
- else if (typeof exports == "object" && typeof module == "object") { // CommonJS
- module.exports = factory(require('jquery'));
- }
- else { // Browser
- factory(jQuery);
- }
-})(function($, undefined) {
- "use strict";
-
- var defaultOpts = {
-
- // Callbacks
- beforeShow: noop,
- move: noop,
- change: noop,
- show: noop,
- hide: noop,
-
- // Options
- color: false,
- flat: false,
- showInput: false,
- allowEmpty: false,
- showButtons: true,
- clickoutFiresChange: true,
- showInitial: false,
- showPalette: false,
- showPaletteOnly: false,
- hideAfterPaletteSelect: false,
- togglePaletteOnly: false,
- showSelectionPalette: true,
- localStorageKey: false,
- appendTo: "body",
- maxSelectionSize: 7,
- cancelText: "cancel",
- chooseText: "choose",
- togglePaletteMoreText: "more",
- togglePaletteLessText: "less",
- clearText: "Clear Color Selection",
- noColorSelectedText: "No Color Selected",
- preferredFormat: false,
- className: "", // Deprecated - use containerClassName and replacerClassName instead.
- containerClassName: "",
- replacerClassName: "",
- showAlpha: false,
- theme: "sp-light",
- palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]],
- selectionPalette: [],
- disabled: false,
- offset: null
- },
- spectrums = [],
- IE = !!/msie/i.exec( window.navigator.userAgent ),
- rgbaSupport = (function() {
- function contains( str, substr ) {
- return !!~('' + str).indexOf(substr);
- }
-
- var elem = document.createElement('div');
- var style = elem.style;
- style.cssText = 'background-color:rgba(0,0,0,.5)';
- return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
- })(),
- replaceInput = [
- "
"
- ].join(''),
- markup = (function () {
-
- // IE does not support gradients with multiple stops, so we need to simulate
- // that for the rainbow slider with 8 divs that each have a single gradient
- var gradientFix = "";
- if (IE) {
- for (var i = 1; i <= 6; i++) {
- gradientFix += "
";
- }
- }
-
- return [
- "
",
- "
",
- "
",
- "
",
- " ",
- "
",
- "
",
- "
",
- "
",
- "
",
- "
",
- "
",
- "
",
- "
",
- "
",
- "
",
- gradientFix,
- "
",
- "
",
- "
",
- "
",
- "
",
- " ",
- "
",
- "
",
- "
",
- "
",
- "
"
- ].join("");
- })();
-
- function paletteTemplate (p, color, className, opts) {
- var html = [];
- for (var i = 0; i < p.length; i++) {
- var current = p[i];
- if(current) {
- var tiny = tinycolor(current);
- var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light";
- c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : "";
- var formattedString = tiny.toString(opts.preferredFormat || "rgb");
- var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter();
- html.push('
');
- } else {
- var cls = 'sp-clear-display';
- html.push($('
')
- .append($('
')
- .attr('title', opts.noColorSelectedText)
- )
- .html()
- );
- }
- }
- return "
" + html.join('') + "
";
- }
-
- function hideAll() {
- for (var i = 0; i < spectrums.length; i++) {
- if (spectrums[i]) {
- spectrums[i].hide();
- }
- }
- }
-
- function instanceOptions(o, callbackContext) {
- var opts = $.extend({}, defaultOpts, o);
- opts.callbacks = {
- 'move': bind(opts.move, callbackContext),
- 'change': bind(opts.change, callbackContext),
- 'show': bind(opts.show, callbackContext),
- 'hide': bind(opts.hide, callbackContext),
- 'beforeShow': bind(opts.beforeShow, callbackContext)
- };
-
- return opts;
- }
-
- function spectrum(element, o) {
-
- var opts = instanceOptions(o, element),
- flat = opts.flat,
- showSelectionPalette = opts.showSelectionPalette,
- localStorageKey = opts.localStorageKey,
- theme = opts.theme,
- callbacks = opts.callbacks,
- resize = throttle(reflow, 10),
- visible = false,
- isDragging = false,
- dragWidth = 0,
- dragHeight = 0,
- dragHelperHeight = 0,
- slideHeight = 0,
- slideWidth = 0,
- alphaWidth = 0,
- alphaSlideHelperWidth = 0,
- slideHelperHeight = 0,
- currentHue = 0,
- currentSaturation = 0,
- currentValue = 0,
- currentAlpha = 1,
- palette = [],
- paletteArray = [],
- paletteLookup = {},
- selectionPalette = opts.selectionPalette.slice(0),
- maxSelectionSize = opts.maxSelectionSize,
- draggingClass = "sp-dragging",
- shiftMovementDirection = null;
-
- var doc = element.ownerDocument,
- body = doc.body,
- boundElement = $(element),
- disabled = false,
- container = $(markup, doc).addClass(theme),
- pickerContainer = container.find(".sp-picker-container"),
- dragger = container.find(".sp-color"),
- dragHelper = container.find(".sp-dragger"),
- slider = container.find(".sp-hue"),
- slideHelper = container.find(".sp-slider"),
- alphaSliderInner = container.find(".sp-alpha-inner"),
- alphaSlider = container.find(".sp-alpha"),
- alphaSlideHelper = container.find(".sp-alpha-handle"),
- textInput = container.find(".sp-input"),
- paletteContainer = container.find(".sp-palette"),
- initialColorContainer = container.find(".sp-initial"),
- cancelButton = container.find(".sp-cancel"),
- clearButton = container.find(".sp-clear"),
- chooseButton = container.find(".sp-choose"),
- toggleButton = container.find(".sp-palette-toggle"),
- isInput = boundElement.is("input"),
- isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(),
- shouldReplace = isInput && !flat,
- replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]),
- offsetElement = (shouldReplace) ? replacer : boundElement,
- previewElement = replacer.find(".sp-preview-inner"),
- initialColor = opts.color || (isInput && boundElement.val()),
- colorOnShow = false,
- currentPreferredFormat = opts.preferredFormat,
- clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange,
- isEmpty = !initialColor,
- allowEmpty = opts.allowEmpty && !isInputTypeColor;
-
- function applyOptions() {
-
- if (opts.showPaletteOnly) {
- opts.showPalette = true;
- }
-
- toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
-
- if (opts.palette) {
- palette = opts.palette.slice(0);
- paletteArray = $.isArray(palette[0]) ? palette : [palette];
- paletteLookup = {};
- for (var i = 0; i < paletteArray.length; i++) {
- for (var j = 0; j < paletteArray[i].length; j++) {
- var rgb = tinycolor(paletteArray[i][j]).toRgbString();
- paletteLookup[rgb] = true;
- }
- }
- }
-
- container.toggleClass("sp-flat", flat);
- container.toggleClass("sp-input-disabled", !opts.showInput);
- container.toggleClass("sp-alpha-enabled", opts.showAlpha);
- container.toggleClass("sp-clear-enabled", allowEmpty);
- container.toggleClass("sp-buttons-disabled", !opts.showButtons);
- container.toggleClass("sp-palette-buttons-disabled", !opts.togglePaletteOnly);
- container.toggleClass("sp-palette-disabled", !opts.showPalette);
- container.toggleClass("sp-palette-only", opts.showPaletteOnly);
- container.toggleClass("sp-initial-disabled", !opts.showInitial);
- container.addClass(opts.className).addClass(opts.containerClassName);
-
- reflow();
- }
-
- function initialize() {
-
- if (IE) {
- container.find("*:not(input)").attr("unselectable", "on");
- }
-
- applyOptions();
-
- if (shouldReplace) {
- boundElement.after(replacer).hide();
- }
-
- if (!allowEmpty) {
- clearButton.hide();
- }
-
- if (flat) {
- boundElement.after(container).hide();
- }
- else {
-
- var appendTo = opts.appendTo === "parent" ? boundElement.parent() : $(opts.appendTo);
- if (appendTo.length !== 1) {
- appendTo = $("body");
- }
-
- appendTo.append(container);
- }
-
- updateSelectionPaletteFromStorage();
-
- offsetElement.bind("click.spectrum touchstart.spectrum", function (e) {
- if (!disabled) {
- toggle();
- }
-
- e.stopPropagation();
-
- if (!$(e.target).is("input")) {
- e.preventDefault();
- }
- });
-
- if(boundElement.is(":disabled") || (opts.disabled === true)) {
- disable();
- }
-
- // Prevent clicks from bubbling up to document. This would cause it to be hidden.
- container.click(stopPropagation);
-
- // Handle user typed input
- textInput.change(setFromTextInput);
- textInput.bind("paste", function () {
- setTimeout(setFromTextInput, 1);
- });
- textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } });
-
- cancelButton.text(opts.cancelText);
- cancelButton.bind("click.spectrum", function (e) {
- e.stopPropagation();
- e.preventDefault();
- revert();
- hide();
- });
-
- clearButton.attr("title", opts.clearText);
- clearButton.bind("click.spectrum", function (e) {
- e.stopPropagation();
- e.preventDefault();
- isEmpty = true;
- move();
-
- if(flat) {
- //for the flat style, this is a change event
- updateOriginalInput(true);
- }
- });
-
- chooseButton.text(opts.chooseText);
- chooseButton.bind("click.spectrum", function (e) {
- e.stopPropagation();
- e.preventDefault();
-
- if (IE && textInput.is(":focus")) {
- textInput.trigger('change');
- }
-
- if (isValid()) {
- updateOriginalInput(true);
- hide();
- }
- });
-
- toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
- toggleButton.bind("click.spectrum", function (e) {
- e.stopPropagation();
- e.preventDefault();
-
- opts.showPaletteOnly = !opts.showPaletteOnly;
-
- // To make sure the Picker area is drawn on the right, next to the
- // Palette area (and not below the palette), first move the Palette
- // to the left to make space for the picker, plus 5px extra.
- // The 'applyOptions' function puts the whole container back into place
- // and takes care of the button-text and the sp-palette-only CSS class.
- if (!opts.showPaletteOnly && !flat) {
- container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5));
- }
- applyOptions();
- });
-
- draggable(alphaSlider, function (dragX, dragY, e) {
- currentAlpha = (dragX / alphaWidth);
- isEmpty = false;
- if (e.shiftKey) {
- currentAlpha = Math.round(currentAlpha * 10) / 10;
- }
-
- move();
- }, dragStart, dragStop);
-
- draggable(slider, function (dragX, dragY) {
- currentHue = parseFloat(dragY / slideHeight);
- isEmpty = false;
- if (!opts.showAlpha) {
- currentAlpha = 1;
- }
- move();
- }, dragStart, dragStop);
-
- draggable(dragger, function (dragX, dragY, e) {
-
- // shift+drag should snap the movement to either the x or y axis.
- if (!e.shiftKey) {
- shiftMovementDirection = null;
- }
- else if (!shiftMovementDirection) {
- var oldDragX = currentSaturation * dragWidth;
- var oldDragY = dragHeight - (currentValue * dragHeight);
- var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY);
-
- shiftMovementDirection = furtherFromX ? "x" : "y";
- }
-
- var setSaturation = !shiftMovementDirection || shiftMovementDirection === "x";
- var setValue = !shiftMovementDirection || shiftMovementDirection === "y";
-
- if (setSaturation) {
- currentSaturation = parseFloat(dragX / dragWidth);
- }
- if (setValue) {
- currentValue = parseFloat((dragHeight - dragY) / dragHeight);
- }
-
- isEmpty = false;
- if (!opts.showAlpha) {
- currentAlpha = 1;
- }
-
- move();
-
- }, dragStart, dragStop);
-
- if (!!initialColor) {
- set(initialColor);
-
- // In case color was black - update the preview UI and set the format
- // since the set function will not run (default color is black).
- updateUI();
- currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format;
-
- addColorToSelectionPalette(initialColor);
- }
- else {
- updateUI();
- }
-
- if (flat) {
- show();
- }
-
- function paletteElementClick(e) {
- if (e.data && e.data.ignore) {
- set($(e.target).closest(".sp-thumb-el").data("color"));
- move();
- }
- else {
- set($(e.target).closest(".sp-thumb-el").data("color"));
- move();
- updateOriginalInput(true);
- if (opts.hideAfterPaletteSelect) {
- hide();
- }
- }
-
- return false;
- }
-
- var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum";
- paletteContainer.delegate(".sp-thumb-el", paletteEvent, paletteElementClick);
- initialColorContainer.delegate(".sp-thumb-el:nth-child(1)", paletteEvent, { ignore: true }, paletteElementClick);
- }
-
- function updateSelectionPaletteFromStorage() {
-
- if (localStorageKey && window.localStorage) {
-
- // Migrate old palettes over to new format. May want to remove this eventually.
- try {
- var oldPalette = window.localStorage[localStorageKey].split(",#");
- if (oldPalette.length > 1) {
- delete window.localStorage[localStorageKey];
- $.each(oldPalette, function(i, c) {
- addColorToSelectionPalette(c);
- });
- }
- }
- catch(e) { }
-
- try {
- selectionPalette = window.localStorage[localStorageKey].split(";");
- }
- catch (e) { }
- }
- }
-
- function addColorToSelectionPalette(color) {
- if (showSelectionPalette) {
- var rgb = tinycolor(color).toRgbString();
- if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) {
- selectionPalette.push(rgb);
- while(selectionPalette.length > maxSelectionSize) {
- selectionPalette.shift();
- }
- }
-
- if (localStorageKey && window.localStorage) {
- try {
- window.localStorage[localStorageKey] = selectionPalette.join(";");
- }
- catch(e) { }
- }
- }
- }
-
- function getUniqueSelectionPalette() {
- var unique = [];
- if (opts.showPalette) {
- for (var i = 0; i < selectionPalette.length; i++) {
- var rgb = tinycolor(selectionPalette[i]).toRgbString();
-
- if (!paletteLookup[rgb]) {
- unique.push(selectionPalette[i]);
- }
- }
- }
-
- return unique.reverse().slice(0, opts.maxSelectionSize);
- }
-
- function drawPalette() {
-
- var currentColor = get();
-
- var html = $.map(paletteArray, function (palette, i) {
- return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i, opts);
- });
-
- updateSelectionPaletteFromStorage();
-
- if (selectionPalette) {
- html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection", opts));
- }
-
- paletteContainer.html(html.join(""));
- }
-
- function drawInitial() {
- if (opts.showInitial) {
- var initial = colorOnShow;
- var current = get();
- initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial", opts));
- }
- }
-
- function dragStart() {
- if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) {
- reflow();
- }
- isDragging = true;
- container.addClass(draggingClass);
- shiftMovementDirection = null;
- boundElement.trigger('dragstart.spectrum', [ get() ]);
- }
-
- function dragStop() {
- isDragging = false;
- container.removeClass(draggingClass);
- boundElement.trigger('dragstop.spectrum', [ get() ]);
- }
-
- function setFromTextInput() {
-
- var value = textInput.val();
-
- if ((value === null || value === "") && allowEmpty) {
- set(null);
- updateOriginalInput(true);
- }
- else {
- var tiny = tinycolor(value);
- if (tiny.isValid()) {
- set(tiny);
- updateOriginalInput(true);
- }
- else {
- textInput.addClass("sp-validation-error");
- }
- }
- }
-
- function toggle() {
- if (visible) {
- hide();
- }
- else {
- show();
- }
- }
-
- function show() {
- var event = $.Event('beforeShow.spectrum');
-
- if (visible) {
- reflow();
- return;
- }
-
- boundElement.trigger(event, [ get() ]);
-
- if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) {
- return;
- }
-
- hideAll();
- visible = true;
-
- $(doc).bind("keydown.spectrum", onkeydown);
- $(doc).bind("click.spectrum", clickout);
- $(window).bind("resize.spectrum", resize);
- replacer.addClass("sp-active");
- container.removeClass("sp-hidden");
-
- reflow();
- updateUI();
-
- colorOnShow = get();
-
- drawInitial();
- callbacks.show(colorOnShow);
- boundElement.trigger('show.spectrum', [ colorOnShow ]);
- }
-
- function onkeydown(e) {
- // Close on ESC
- if (e.keyCode === 27) {
- hide();
- }
- }
-
- function clickout(e) {
- // Return on right click.
- if (e.button == 2) { return; }
-
- // If a drag event was happening during the mouseup, don't hide
- // on click.
- if (isDragging) { return; }
-
- if (clickoutFiresChange) {
- updateOriginalInput(true);
- }
- else {
- revert();
- }
- hide();
- }
-
- function hide() {
- // Return if hiding is unnecessary
- if (!visible || flat) { return; }
- visible = false;
-
- $(doc).unbind("keydown.spectrum", onkeydown);
- $(doc).unbind("click.spectrum", clickout);
- $(window).unbind("resize.spectrum", resize);
-
- replacer.removeClass("sp-active");
- container.addClass("sp-hidden");
-
- callbacks.hide(get());
- boundElement.trigger('hide.spectrum', [ get() ]);
- }
-
- function revert() {
- set(colorOnShow, true);
- }
-
- function set(color, ignoreFormatChange) {
- if (tinycolor.equals(color, get())) {
- // Update UI just in case a validation error needs
- // to be cleared.
- updateUI();
- return;
- }
-
- var newColor, newHsv;
- if (!color && allowEmpty) {
- isEmpty = true;
- } else {
- isEmpty = false;
- newColor = tinycolor(color);
- newHsv = newColor.toHsv();
-
- currentHue = (newHsv.h % 360) / 360;
- currentSaturation = newHsv.s;
- currentValue = newHsv.v;
- currentAlpha = newHsv.a;
- }
- updateUI();
-
- if (newColor && newColor.isValid() && !ignoreFormatChange) {
- currentPreferredFormat = opts.preferredFormat || newColor.getFormat();
- }
- }
-
- function get(opts) {
- opts = opts || { };
-
- if (allowEmpty && isEmpty) {
- return null;
- }
-
- return tinycolor.fromRatio({
- h: currentHue,
- s: currentSaturation,
- v: currentValue,
- a: Math.round(currentAlpha * 100) / 100
- }, { format: opts.format || currentPreferredFormat });
- }
-
- function isValid() {
- return !textInput.hasClass("sp-validation-error");
- }
-
- function move() {
- updateUI();
-
- callbacks.move(get());
- boundElement.trigger('move.spectrum', [ get() ]);
- }
-
- function updateUI() {
-
- textInput.removeClass("sp-validation-error");
-
- updateHelperLocations();
-
- // Update dragger background color (gradients take care of saturation and value).
- var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 });
- dragger.css("background-color", flatColor.toHexString());
-
- // Get a format that alpha will be included in (hex and names ignore alpha)
- var format = currentPreferredFormat;
- if (currentAlpha < 1 && !(currentAlpha === 0 && format === "name")) {
- if (format === "hex" || format === "hex3" || format === "hex6" || format === "name") {
- format = "rgb";
- }
- }
-
- var realColor = get({ format: format }),
- displayColor = '';
-
- //reset background info for preview element
- previewElement.removeClass("sp-clear-display");
- previewElement.css('background-color', 'transparent');
-
- if (!realColor && allowEmpty) {
- // Update the replaced elements background with icon indicating no color selection
- previewElement.addClass("sp-clear-display");
- }
- else {
- var realHex = realColor.toHexString(),
- realRgb = realColor.toRgbString();
-
- // Update the replaced elements background color (with actual selected color)
- if (rgbaSupport || realColor.alpha === 1) {
- previewElement.css("background-color", realRgb);
- }
- else {
- previewElement.css("background-color", "transparent");
- previewElement.css("filter", realColor.toFilter());
- }
-
- if (opts.showAlpha) {
- var rgb = realColor.toRgb();
- rgb.a = 0;
- var realAlpha = tinycolor(rgb).toRgbString();
- var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")";
-
- if (IE) {
- alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex));
- }
- else {
- alphaSliderInner.css("background", "-webkit-" + gradient);
- alphaSliderInner.css("background", "-moz-" + gradient);
- alphaSliderInner.css("background", "-ms-" + gradient);
- // Use current syntax gradient on unprefixed property.
- alphaSliderInner.css("background",
- "linear-gradient(to right, " + realAlpha + ", " + realHex + ")");
- }
- }
-
- displayColor = realColor.toString(format);
- }
-
- // Update the text entry input as it changes happen
- if (opts.showInput) {
- textInput.val(displayColor);
- }
-
- if (opts.showPalette) {
- drawPalette();
- }
-
- drawInitial();
- }
-
- function updateHelperLocations() {
- var s = currentSaturation;
- var v = currentValue;
-
- if(allowEmpty && isEmpty) {
- //if selected color is empty, hide the helpers
- alphaSlideHelper.hide();
- slideHelper.hide();
- dragHelper.hide();
- }
- else {
- //make sure helpers are visible
- alphaSlideHelper.show();
- slideHelper.show();
- dragHelper.show();
-
- // Where to show the little circle in that displays your current selected color
- var dragX = s * dragWidth;
- var dragY = dragHeight - (v * dragHeight);
- dragX = Math.max(
- -dragHelperHeight,
- Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)
- );
- dragY = Math.max(
- -dragHelperHeight,
- Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)
- );
- dragHelper.css({
- "top": dragY + "px",
- "left": dragX + "px"
- });
-
- var alphaX = currentAlpha * alphaWidth;
- alphaSlideHelper.css({
- "left": (alphaX - (alphaSlideHelperWidth / 2)) + "px"
- });
-
- // Where to show the bar that displays your current selected hue
- var slideY = (currentHue) * slideHeight;
- slideHelper.css({
- "top": (slideY - slideHelperHeight) + "px"
- });
- }
- }
-
- function updateOriginalInput(fireCallback) {
- var color = get(),
- displayColor = '',
- hasChanged = !tinycolor.equals(color, colorOnShow);
-
- if (color) {
- displayColor = color.toString(currentPreferredFormat);
- // Update the selection palette with the current color
- addColorToSelectionPalette(color);
- }
-
- if (isInput) {
- boundElement.val(displayColor);
- }
-
- if (fireCallback && hasChanged) {
- callbacks.change(color);
- boundElement.trigger('change', [ color ]);
- }
- }
-
- function reflow() {
- if (!visible) {
- return; // Calculations would be useless and wouldn't be reliable anyways
- }
- dragWidth = dragger.width();
- dragHeight = dragger.height();
- dragHelperHeight = dragHelper.height();
- slideWidth = slider.width();
- slideHeight = slider.height();
- slideHelperHeight = slideHelper.height();
- alphaWidth = alphaSlider.width();
- alphaSlideHelperWidth = alphaSlideHelper.width();
-
- if (!flat) {
- container.css("position", "absolute");
- if (opts.offset) {
- container.offset(opts.offset);
- } else {
- container.offset(getOffset(container, offsetElement));
- }
- }
-
- updateHelperLocations();
-
- if (opts.showPalette) {
- drawPalette();
- }
-
- boundElement.trigger('reflow.spectrum');
- }
-
- function destroy() {
- boundElement.show();
- offsetElement.unbind("click.spectrum touchstart.spectrum");
- container.remove();
- replacer.remove();
- spectrums[spect.id] = null;
- }
-
- function option(optionName, optionValue) {
- if (optionName === undefined) {
- return $.extend({}, opts);
- }
- if (optionValue === undefined) {
- return opts[optionName];
- }
-
- opts[optionName] = optionValue;
-
- if (optionName === "preferredFormat") {
- currentPreferredFormat = opts.preferredFormat;
- }
- applyOptions();
- }
-
- function enable() {
- disabled = false;
- boundElement.attr("disabled", false);
- offsetElement.removeClass("sp-disabled");
- }
-
- function disable() {
- hide();
- disabled = true;
- boundElement.attr("disabled", true);
- offsetElement.addClass("sp-disabled");
- }
-
- function setOffset(coord) {
- opts.offset = coord;
- reflow();
- }
-
- initialize();
-
- var spect = {
- show: show,
- hide: hide,
- toggle: toggle,
- reflow: reflow,
- option: option,
- enable: enable,
- disable: disable,
- offset: setOffset,
- set: function (c) {
- set(c);
- updateOriginalInput();
- },
- get: get,
- destroy: destroy,
- container: container
- };
-
- spect.id = spectrums.push(spect) - 1;
-
- return spect;
- }
-
- /**
- * checkOffset - get the offset below/above and left/right element depending on screen position
- * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js
- */
- function getOffset(picker, input) {
- var extraY = 0;
- var dpWidth = picker.outerWidth();
- var dpHeight = picker.outerHeight();
- var inputHeight = input.outerHeight();
- var doc = picker[0].ownerDocument;
- var docElem = doc.documentElement;
- var viewWidth = docElem.clientWidth + $(doc).scrollLeft();
- var viewHeight = docElem.clientHeight + $(doc).scrollTop();
- var offset = input.offset();
- offset.top += inputHeight;
-
- offset.left -=
- Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
- Math.abs(offset.left + dpWidth - viewWidth) : 0);
-
- offset.top -=
- Math.min(offset.top, ((offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
- Math.abs(dpHeight + inputHeight - extraY) : extraY));
-
- return offset;
- }
-
- /**
- * noop - do nothing
- */
- function noop() {
-
- }
-
- /**
- * stopPropagation - makes the code only doing this a little easier to read in line
- */
- function stopPropagation(e) {
- e.stopPropagation();
- }
-
- /**
- * Create a function bound to a given object
- * Thanks to underscore.js
- */
- function bind(func, obj) {
- var slice = Array.prototype.slice;
- var args = slice.call(arguments, 2);
- return function () {
- return func.apply(obj, args.concat(slice.call(arguments)));
- };
- }
-
- /**
- * Lightweight drag helper. Handles containment within the element, so that
- * when dragging, the x is within [0,element.width] and y is within [0,element.height]
- */
- function draggable(element, onmove, onstart, onstop) {
- onmove = onmove || function () { };
- onstart = onstart || function () { };
- onstop = onstop || function () { };
- var doc = document;
- var dragging = false;
- var offset = {};
- var maxHeight = 0;
- var maxWidth = 0;
- var hasTouch = ('ontouchstart' in window);
-
- var duringDragEvents = {};
- duringDragEvents["selectstart"] = prevent;
- duringDragEvents["dragstart"] = prevent;
- duringDragEvents["touchmove mousemove"] = move;
- duringDragEvents["touchend mouseup"] = stop;
-
- function prevent(e) {
- if (e.stopPropagation) {
- e.stopPropagation();
- }
- if (e.preventDefault) {
- e.preventDefault();
- }
- e.returnValue = false;
- }
-
- function move(e) {
- if (dragging) {
- // Mouseup happened outside of window
- if (IE && doc.documentMode < 9 && !e.button) {
- return stop();
- }
-
- var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0];
- var pageX = t0 && t0.pageX || e.pageX;
- var pageY = t0 && t0.pageY || e.pageY;
-
- var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
- var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
-
- if (hasTouch) {
- // Stop scrolling in iOS
- prevent(e);
- }
-
- onmove.apply(element, [dragX, dragY, e]);
- }
- }
-
- function start(e) {
- var rightclick = (e.which) ? (e.which == 3) : (e.button == 2);
-
- if (!rightclick && !dragging) {
- if (onstart.apply(element, arguments) !== false) {
- dragging = true;
- maxHeight = $(element).height();
- maxWidth = $(element).width();
- offset = $(element).offset();
-
- $(doc).bind(duringDragEvents);
- $(doc.body).addClass("sp-dragging");
-
- move(e);
-
- prevent(e);
- }
- }
- }
-
- function stop() {
- if (dragging) {
- $(doc).unbind(duringDragEvents);
- $(doc.body).removeClass("sp-dragging");
-
- // Wait a tick before notifying observers to allow the click event
- // to fire in Chrome.
- setTimeout(function() {
- onstop.apply(element, arguments);
- }, 0);
- }
- dragging = false;
- }
-
- $(element).bind("touchstart mousedown", start);
- }
-
- function throttle(func, wait, debounce) {
- var timeout;
- return function () {
- var context = this, args = arguments;
- var throttler = function () {
- timeout = null;
- func.apply(context, args);
- };
- if (debounce) clearTimeout(timeout);
- if (debounce || !timeout) timeout = setTimeout(throttler, wait);
- };
- }
-
- function inputTypeColorSupport() {
- return $.fn.spectrum.inputTypeColorSupport();
- }
-
- /**
- * Define a jQuery plugin
- */
- var dataID = "spectrum.id";
- $.fn.spectrum = function (opts, extra) {
-
- if (typeof opts == "string") {
-
- var returnValue = this;
- var args = Array.prototype.slice.call( arguments, 1 );
-
- this.each(function () {
- var spect = spectrums[$(this).data(dataID)];
- if (spect) {
- var method = spect[opts];
- if (!method) {
- throw new Error( "Spectrum: no such method: '" + opts + "'" );
- }
-
- if (opts == "get") {
- returnValue = spect.get();
- }
- else if (opts == "container") {
- returnValue = spect.container;
- }
- else if (opts == "option") {
- returnValue = spect.option.apply(spect, args);
- }
- else if (opts == "destroy") {
- spect.destroy();
- $(this).removeData(dataID);
- }
- else {
- method.apply(spect, args);
- }
- }
- });
-
- return returnValue;
- }
-
- // Initializing a new instance of spectrum
- return this.spectrum("destroy").each(function () {
- var options = $.extend({}, opts, $(this).data());
- var spect = spectrum(this, options);
- $(this).data(dataID, spect.id);
- });
- };
-
- $.fn.spectrum.load = true;
- $.fn.spectrum.loadOpts = {};
- $.fn.spectrum.draggable = draggable;
- $.fn.spectrum.defaults = defaultOpts;
- $.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() {
- if (typeof inputTypeColorSupport._cachedResult === "undefined") {
- var colorInput = $("
")[0]; // if color element is supported, value will default to not null
- inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== "";
- }
- return inputTypeColorSupport._cachedResult;
- };
-
- $.spectrum = { };
- $.spectrum.localization = { };
- $.spectrum.palettes = { };
-
- $.fn.spectrum.processNativeColorInputs = function () {
- var colorInputs = $("input[type=color]");
- if (colorInputs.length && !inputTypeColorSupport()) {
- colorInputs.spectrum({
- preferredFormat: "hex6"
- });
- }
- };
-
- // TinyColor v1.1.2
- // https://github.com/bgrins/TinyColor
- // Brian Grinstead, MIT License
-
- (function() {
-
- var trimLeft = /^[\s,#]+/,
- trimRight = /\s+$/,
- tinyCounter = 0,
- math = Math,
- mathRound = math.round,
- mathMin = math.min,
- mathMax = math.max,
- mathRandom = math.random;
-
- var tinycolor = function(color, opts) {
-
- color = (color) ? color : '';
- opts = opts || { };
-
- // If input is already a tinycolor, return itself
- if (color instanceof tinycolor) {
- return color;
- }
- // If we are called as a function, call using new instead
- if (!(this instanceof tinycolor)) {
- return new tinycolor(color, opts);
- }
-
- var rgb = inputToRGB(color);
- this._originalInput = color,
- this._r = rgb.r,
- this._g = rgb.g,
- this._b = rgb.b,
- this._a = rgb.a,
- this._roundA = mathRound(100*this._a) / 100,
- this._format = opts.format || rgb.format;
- this._gradientType = opts.gradientType;
-
- // Don't let the range of [0,255] come back in [0,1].
- // Potentially lose a little bit of precision here, but will fix issues where
- // .5 gets interpreted as half of the total, instead of half of 1
- // If it was supposed to be 128, this was already taken care of by `inputToRgb`
- if (this._r < 1) { this._r = mathRound(this._r); }
- if (this._g < 1) { this._g = mathRound(this._g); }
- if (this._b < 1) { this._b = mathRound(this._b); }
-
- this._ok = rgb.ok;
- this._tc_id = tinyCounter++;
- };
-
- tinycolor.prototype = {
- isDark: function() {
- return this.getBrightness() < 128;
- },
- isLight: function() {
- return !this.isDark();
- },
- isValid: function() {
- return this._ok;
- },
- getOriginalInput: function() {
- return this._originalInput;
- },
- getFormat: function() {
- return this._format;
- },
- getAlpha: function() {
- return this._a;
- },
- getBrightness: function() {
- var rgb = this.toRgb();
- return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
- },
- setAlpha: function(value) {
- this._a = boundAlpha(value);
- this._roundA = mathRound(100*this._a) / 100;
- return this;
- },
- toHsv: function() {
- var hsv = rgbToHsv(this._r, this._g, this._b);
- return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
- },
- toHsvString: function() {
- var hsv = rgbToHsv(this._r, this._g, this._b);
- var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
- return (this._a == 1) ?
- "hsv(" + h + ", " + s + "%, " + v + "%)" :
- "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
- },
- toHsl: function() {
- var hsl = rgbToHsl(this._r, this._g, this._b);
- return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
- },
- toHslString: function() {
- var hsl = rgbToHsl(this._r, this._g, this._b);
- var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
- return (this._a == 1) ?
- "hsl(" + h + ", " + s + "%, " + l + "%)" :
- "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
- },
- toHex: function(allow3Char) {
- return rgbToHex(this._r, this._g, this._b, allow3Char);
- },
- toHexString: function(allow3Char) {
- return '#' + this.toHex(allow3Char);
- },
- toHex8: function() {
- return rgbaToHex(this._r, this._g, this._b, this._a);
- },
- toHex8String: function() {
- return '#' + this.toHex8();
- },
- toRgb: function() {
- return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
- },
- toRgbString: function() {
- return (this._a == 1) ?
- "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
- "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
- },
- toPercentageRgb: function() {
- return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
- },
- toPercentageRgbString: function() {
- return (this._a == 1) ?
- "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
- "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
- },
- toName: function() {
- if (this._a === 0) {
- return "transparent";
- }
-
- if (this._a < 1) {
- return false;
- }
-
- return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
- },
- toFilter: function(secondColor) {
- var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a);
- var secondHex8String = hex8String;
- var gradientType = this._gradientType ? "GradientType = 1, " : "";
-
- if (secondColor) {
- var s = tinycolor(secondColor);
- secondHex8String = s.toHex8String();
- }
-
- return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
- },
- toString: function(format) {
- var formatSet = !!format;
- format = format || this._format;
-
- var formattedString = false;
- var hasAlpha = this._a < 1 && this._a >= 0;
- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name");
-
- if (needsAlphaFormat) {
- // Special case for "transparent", all other non-alpha formats
- // will return rgba when there is transparency.
- if (format === "name" && this._a === 0) {
- return this.toName();
- }
- return this.toRgbString();
- }
- if (format === "rgb") {
- formattedString = this.toRgbString();
- }
- if (format === "prgb") {
- formattedString = this.toPercentageRgbString();
- }
- if (format === "hex" || format === "hex6") {
- formattedString = this.toHexString();
- }
- if (format === "hex3") {
- formattedString = this.toHexString(true);
- }
- if (format === "hex8") {
- formattedString = this.toHex8String();
- }
- if (format === "name") {
- formattedString = this.toName();
- }
- if (format === "hsl") {
- formattedString = this.toHslString();
- }
- if (format === "hsv") {
- formattedString = this.toHsvString();
- }
-
- return formattedString || this.toHexString();
- },
-
- _applyModification: function(fn, args) {
- var color = fn.apply(null, [this].concat([].slice.call(args)));
- this._r = color._r;
- this._g = color._g;
- this._b = color._b;
- this.setAlpha(color._a);
- return this;
- },
- lighten: function() {
- return this._applyModification(lighten, arguments);
- },
- brighten: function() {
- return this._applyModification(brighten, arguments);
- },
- darken: function() {
- return this._applyModification(darken, arguments);
- },
- desaturate: function() {
- return this._applyModification(desaturate, arguments);
- },
- saturate: function() {
- return this._applyModification(saturate, arguments);
- },
- greyscale: function() {
- return this._applyModification(greyscale, arguments);
- },
- spin: function() {
- return this._applyModification(spin, arguments);
- },
-
- _applyCombination: function(fn, args) {
- return fn.apply(null, [this].concat([].slice.call(args)));
- },
- analogous: function() {
- return this._applyCombination(analogous, arguments);
- },
- complement: function() {
- return this._applyCombination(complement, arguments);
- },
- monochromatic: function() {
- return this._applyCombination(monochromatic, arguments);
- },
- splitcomplement: function() {
- return this._applyCombination(splitcomplement, arguments);
- },
- triad: function() {
- return this._applyCombination(triad, arguments);
- },
- tetrad: function() {
- return this._applyCombination(tetrad, arguments);
- }
- };
-
- // If input is an object, force 1 into "1.0" to handle ratios properly
- // String input requires "1.0" as input, so 1 will be treated as 1
- tinycolor.fromRatio = function(color, opts) {
- if (typeof color == "object") {
- var newColor = {};
- for (var i in color) {
- if (color.hasOwnProperty(i)) {
- if (i === "a") {
- newColor[i] = color[i];
- }
- else {
- newColor[i] = convertToPercentage(color[i]);
- }
- }
- }
- color = newColor;
- }
-
- return tinycolor(color, opts);
- };
-
- // Given a string or object, convert that input to RGB
- // Possible string inputs:
- //
- // "red"
- // "#f00" or "f00"
- // "#ff0000" or "ff0000"
- // "#ff000000" or "ff000000"
- // "rgb 255 0 0" or "rgb (255, 0, 0)"
- // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
- // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
- // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
- // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
- // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
- // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
- //
- function inputToRGB(color) {
-
- var rgb = { r: 0, g: 0, b: 0 };
- var a = 1;
- var ok = false;
- var format = false;
-
- if (typeof color == "string") {
- color = stringInputToObject(color);
- }
-
- if (typeof color == "object") {
- if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) {
- rgb = rgbToRgb(color.r, color.g, color.b);
- ok = true;
- format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
- }
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) {
- color.s = convertToPercentage(color.s);
- color.v = convertToPercentage(color.v);
- rgb = hsvToRgb(color.h, color.s, color.v);
- ok = true;
- format = "hsv";
- }
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) {
- color.s = convertToPercentage(color.s);
- color.l = convertToPercentage(color.l);
- rgb = hslToRgb(color.h, color.s, color.l);
- ok = true;
- format = "hsl";
- }
-
- if (color.hasOwnProperty("a")) {
- a = color.a;
- }
- }
-
- a = boundAlpha(a);
-
- return {
- ok: ok,
- format: color.format || format,
- r: mathMin(255, mathMax(rgb.r, 0)),
- g: mathMin(255, mathMax(rgb.g, 0)),
- b: mathMin(255, mathMax(rgb.b, 0)),
- a: a
- };
- }
-
-
- // Conversion Functions
- // --------------------
-
- // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
- //
-
- // `rgbToRgb`
- // Handle bounds / percentage checking to conform to CSS color spec
- //
- // *Assumes:* r, g, b in [0, 255] or [0, 1]
- // *Returns:* { r, g, b } in [0, 255]
- function rgbToRgb(r, g, b){
- return {
- r: bound01(r, 255) * 255,
- g: bound01(g, 255) * 255,
- b: bound01(b, 255) * 255
- };
- }
-
- // `rgbToHsl`
- // Converts an RGB color value to HSL.
- // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
- // *Returns:* { h, s, l } in [0,1]
- function rgbToHsl(r, g, b) {
-
- r = bound01(r, 255);
- g = bound01(g, 255);
- b = bound01(b, 255);
-
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
- var h, s, l = (max + min) / 2;
-
- if(max == min) {
- h = s = 0; // achromatic
- }
- else {
- var d = max - min;
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
- switch(max) {
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
- case g: h = (b - r) / d + 2; break;
- case b: h = (r - g) / d + 4; break;
- }
-
- h /= 6;
- }
-
- return { h: h, s: s, l: l };
- }
-
- // `hslToRgb`
- // Converts an HSL color value to RGB.
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
- // *Returns:* { r, g, b } in the set [0, 255]
- function hslToRgb(h, s, l) {
- var r, g, b;
-
- h = bound01(h, 360);
- s = bound01(s, 100);
- l = bound01(l, 100);
-
- function hue2rgb(p, q, t) {
- if(t < 0) t += 1;
- if(t > 1) t -= 1;
- if(t < 1/6) return p + (q - p) * 6 * t;
- if(t < 1/2) return q;
- if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
- return p;
- }
-
- if(s === 0) {
- r = g = b = l; // achromatic
- }
- else {
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
- var p = 2 * l - q;
- r = hue2rgb(p, q, h + 1/3);
- g = hue2rgb(p, q, h);
- b = hue2rgb(p, q, h - 1/3);
- }
-
- return { r: r * 255, g: g * 255, b: b * 255 };
- }
-
- // `rgbToHsv`
- // Converts an RGB color value to HSV
- // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
- // *Returns:* { h, s, v } in [0,1]
- function rgbToHsv(r, g, b) {
-
- r = bound01(r, 255);
- g = bound01(g, 255);
- b = bound01(b, 255);
-
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
- var h, s, v = max;
-
- var d = max - min;
- s = max === 0 ? 0 : d / max;
-
- if(max == min) {
- h = 0; // achromatic
- }
- else {
- switch(max) {
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
- case g: h = (b - r) / d + 2; break;
- case b: h = (r - g) / d + 4; break;
- }
- h /= 6;
- }
- return { h: h, s: s, v: v };
- }
-
- // `hsvToRgb`
- // Converts an HSV color value to RGB.
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
- // *Returns:* { r, g, b } in the set [0, 255]
- function hsvToRgb(h, s, v) {
-
- h = bound01(h, 360) * 6;
- s = bound01(s, 100);
- v = bound01(v, 100);
-
- var i = math.floor(h),
- f = h - i,
- p = v * (1 - s),
- q = v * (1 - f * s),
- t = v * (1 - (1 - f) * s),
- mod = i % 6,
- r = [v, q, p, p, t, v][mod],
- g = [t, v, v, q, p, p][mod],
- b = [p, p, t, v, v, q][mod];
-
- return { r: r * 255, g: g * 255, b: b * 255 };
- }
-
- // `rgbToHex`
- // Converts an RGB color to hex
- // Assumes r, g, and b are contained in the set [0, 255]
- // Returns a 3 or 6 character hex
- function rgbToHex(r, g, b, allow3Char) {
-
- var hex = [
- pad2(mathRound(r).toString(16)),
- pad2(mathRound(g).toString(16)),
- pad2(mathRound(b).toString(16))
- ];
-
- // Return a 3 character hex if possible
- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
- }
-
- return hex.join("");
- }
- // `rgbaToHex`
- // Converts an RGBA color plus alpha transparency to hex
- // Assumes r, g, b and a are contained in the set [0, 255]
- // Returns an 8 character hex
- function rgbaToHex(r, g, b, a) {
-
- var hex = [
- pad2(convertDecimalToHex(a)),
- pad2(mathRound(r).toString(16)),
- pad2(mathRound(g).toString(16)),
- pad2(mathRound(b).toString(16))
- ];
-
- return hex.join("");
- }
-
- // `equals`
- // Can be called with any tinycolor input
- tinycolor.equals = function (color1, color2) {
- if (!color1 || !color2) { return false; }
- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
- };
- tinycolor.random = function() {
- return tinycolor.fromRatio({
- r: mathRandom(),
- g: mathRandom(),
- b: mathRandom()
- });
- };
-
-
- // Modification Functions
- // ----------------------
- // Thanks to less.js for some of the basics here
- //
-
- function desaturate(color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var hsl = tinycolor(color).toHsl();
- hsl.s -= amount / 100;
- hsl.s = clamp01(hsl.s);
- return tinycolor(hsl);
- }
-
- function saturate(color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var hsl = tinycolor(color).toHsl();
- hsl.s += amount / 100;
- hsl.s = clamp01(hsl.s);
- return tinycolor(hsl);
- }
-
- function greyscale(color) {
- return tinycolor(color).desaturate(100);
- }
-
- function lighten (color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var hsl = tinycolor(color).toHsl();
- hsl.l += amount / 100;
- hsl.l = clamp01(hsl.l);
- return tinycolor(hsl);
- }
-
- function brighten(color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var rgb = tinycolor(color).toRgb();
- rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
- rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
- rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
- return tinycolor(rgb);
- }
-
- function darken (color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var hsl = tinycolor(color).toHsl();
- hsl.l -= amount / 100;
- hsl.l = clamp01(hsl.l);
- return tinycolor(hsl);
- }
-
- // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
- // Values outside of this range will be wrapped into this range.
- function spin(color, amount) {
- var hsl = tinycolor(color).toHsl();
- var hue = (mathRound(hsl.h) + amount) % 360;
- hsl.h = hue < 0 ? 360 + hue : hue;
- return tinycolor(hsl);
- }
-
- // Combination Functions
- // ---------------------
- // Thanks to jQuery xColor for some of the ideas behind these
- //
-
- function complement(color) {
- var hsl = tinycolor(color).toHsl();
- hsl.h = (hsl.h + 180) % 360;
- return tinycolor(hsl);
- }
-
- function triad(color) {
- var hsl = tinycolor(color).toHsl();
- var h = hsl.h;
- return [
- tinycolor(color),
- tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
- ];
- }
-
- function tetrad(color) {
- var hsl = tinycolor(color).toHsl();
- var h = hsl.h;
- return [
- tinycolor(color),
- tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
- ];
- }
-
- function splitcomplement(color) {
- var hsl = tinycolor(color).toHsl();
- var h = hsl.h;
- return [
- tinycolor(color),
- tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
- tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
- ];
- }
-
- function analogous(color, results, slices) {
- results = results || 6;
- slices = slices || 30;
-
- var hsl = tinycolor(color).toHsl();
- var part = 360 / slices;
- var ret = [tinycolor(color)];
-
- for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
- hsl.h = (hsl.h + part) % 360;
- ret.push(tinycolor(hsl));
- }
- return ret;
- }
-
- function monochromatic(color, results) {
- results = results || 6;
- var hsv = tinycolor(color).toHsv();
- var h = hsv.h, s = hsv.s, v = hsv.v;
- var ret = [];
- var modification = 1 / results;
-
- while (results--) {
- ret.push(tinycolor({ h: h, s: s, v: v}));
- v = (v + modification) % 1;
- }
-
- return ret;
- }
-
- // Utility Functions
- // ---------------------
-
- tinycolor.mix = function(color1, color2, amount) {
- amount = (amount === 0) ? 0 : (amount || 50);
-
- var rgb1 = tinycolor(color1).toRgb();
- var rgb2 = tinycolor(color2).toRgb();
-
- var p = amount / 100;
- var w = p * 2 - 1;
- var a = rgb2.a - rgb1.a;
-
- var w1;
-
- if (w * a == -1) {
- w1 = w;
- } else {
- w1 = (w + a) / (1 + w * a);
- }
-
- w1 = (w1 + 1) / 2;
-
- var w2 = 1 - w1;
-
- var rgba = {
- r: rgb2.r * w1 + rgb1.r * w2,
- g: rgb2.g * w1 + rgb1.g * w2,
- b: rgb2.b * w1 + rgb1.b * w2,
- a: rgb2.a * p + rgb1.a * (1 - p)
- };
-
- return tinycolor(rgba);
- };
-
-
- // Readability Functions
- // ---------------------
- //
-
- // `readability`
- // Analyze the 2 colors and returns an object with the following properties:
- // `brightness`: difference in brightness between the two colors
- // `color`: difference in color/hue between the two colors
- tinycolor.readability = function(color1, color2) {
- var c1 = tinycolor(color1);
- var c2 = tinycolor(color2);
- var rgb1 = c1.toRgb();
- var rgb2 = c2.toRgb();
- var brightnessA = c1.getBrightness();
- var brightnessB = c2.getBrightness();
- var colorDiff = (
- Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) +
- Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) +
- Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b)
- );
-
- return {
- brightness: Math.abs(brightnessA - brightnessB),
- color: colorDiff
- };
- };
-
- // `readable`
- // http://www.w3.org/TR/AERT#color-contrast
- // Ensure that foreground and background color combinations provide sufficient contrast.
- // *Example*
- // tinycolor.isReadable("#000", "#111") => false
- tinycolor.isReadable = function(color1, color2) {
- var readability = tinycolor.readability(color1, color2);
- return readability.brightness > 125 && readability.color > 500;
- };
-
- // `mostReadable`
- // Given a base color and a list of possible foreground or background
- // colors for that base, returns the most readable color.
- // *Example*
- // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000"
- tinycolor.mostReadable = function(baseColor, colorList) {
- var bestColor = null;
- var bestScore = 0;
- var bestIsReadable = false;
- for (var i=0; i < colorList.length; i++) {
-
- // We normalize both around the "acceptable" breaking point,
- // but rank brightness constrast higher than hue.
-
- var readability = tinycolor.readability(baseColor, colorList[i]);
- var readable = readability.brightness > 125 && readability.color > 500;
- var score = 3 * (readability.brightness / 125) + (readability.color / 500);
-
- if ((readable && ! bestIsReadable) ||
- (readable && bestIsReadable && score > bestScore) ||
- ((! readable) && (! bestIsReadable) && score > bestScore)) {
- bestIsReadable = readable;
- bestScore = score;
- bestColor = tinycolor(colorList[i]);
- }
- }
- return bestColor;
- };
-
-
- // Big List of Colors
- // ------------------
- //
- var names = tinycolor.names = {
- aliceblue: "f0f8ff",
- antiquewhite: "faebd7",
- aqua: "0ff",
- aquamarine: "7fffd4",
- azure: "f0ffff",
- beige: "f5f5dc",
- bisque: "ffe4c4",
- black: "000",
- blanchedalmond: "ffebcd",
- blue: "00f",
- blueviolet: "8a2be2",
- brown: "a52a2a",
- burlywood: "deb887",
- burntsienna: "ea7e5d",
- cadetblue: "5f9ea0",
- chartreuse: "7fff00",
- chocolate: "d2691e",
- coral: "ff7f50",
- cornflowerblue: "6495ed",
- cornsilk: "fff8dc",
- crimson: "dc143c",
- cyan: "0ff",
- darkblue: "00008b",
- darkcyan: "008b8b",
- darkgoldenrod: "b8860b",
- darkgray: "a9a9a9",
- darkgreen: "006400",
- darkgrey: "a9a9a9",
- darkkhaki: "bdb76b",
- darkmagenta: "8b008b",
- darkolivegreen: "556b2f",
- darkorange: "ff8c00",
- darkorchid: "9932cc",
- darkred: "8b0000",
- darksalmon: "e9967a",
- darkseagreen: "8fbc8f",
- darkslateblue: "483d8b",
- darkslategray: "2f4f4f",
- darkslategrey: "2f4f4f",
- darkturquoise: "00ced1",
- darkviolet: "9400d3",
- deeppink: "ff1493",
- deepskyblue: "00bfff",
- dimgray: "696969",
- dimgrey: "696969",
- dodgerblue: "1e90ff",
- firebrick: "b22222",
- floralwhite: "fffaf0",
- forestgreen: "228b22",
- fuchsia: "f0f",
- gainsboro: "dcdcdc",
- ghostwhite: "f8f8ff",
- gold: "ffd700",
- goldenrod: "daa520",
- gray: "808080",
- green: "008000",
- greenyellow: "adff2f",
- grey: "808080",
- honeydew: "f0fff0",
- hotpink: "ff69b4",
- indianred: "cd5c5c",
- indigo: "4b0082",
- ivory: "fffff0",
- khaki: "f0e68c",
- lavender: "e6e6fa",
- lavenderblush: "fff0f5",
- lawngreen: "7cfc00",
- lemonchiffon: "fffacd",
- lightblue: "add8e6",
- lightcoral: "f08080",
- lightcyan: "e0ffff",
- lightgoldenrodyellow: "fafad2",
- lightgray: "d3d3d3",
- lightgreen: "90ee90",
- lightgrey: "d3d3d3",
- lightpink: "ffb6c1",
- lightsalmon: "ffa07a",
- lightseagreen: "20b2aa",
- lightskyblue: "87cefa",
- lightslategray: "789",
- lightslategrey: "789",
- lightsteelblue: "b0c4de",
- lightyellow: "ffffe0",
- lime: "0f0",
- limegreen: "32cd32",
- linen: "faf0e6",
- magenta: "f0f",
- maroon: "800000",
- mediumaquamarine: "66cdaa",
- mediumblue: "0000cd",
- mediumorchid: "ba55d3",
- mediumpurple: "9370db",
- mediumseagreen: "3cb371",
- mediumslateblue: "7b68ee",
- mediumspringgreen: "00fa9a",
- mediumturquoise: "48d1cc",
- mediumvioletred: "c71585",
- midnightblue: "191970",
- mintcream: "f5fffa",
- mistyrose: "ffe4e1",
- moccasin: "ffe4b5",
- navajowhite: "ffdead",
- navy: "000080",
- oldlace: "fdf5e6",
- olive: "808000",
- olivedrab: "6b8e23",
- orange: "ffa500",
- orangered: "ff4500",
- orchid: "da70d6",
- palegoldenrod: "eee8aa",
- palegreen: "98fb98",
- paleturquoise: "afeeee",
- palevioletred: "db7093",
- papayawhip: "ffefd5",
- peachpuff: "ffdab9",
- peru: "cd853f",
- pink: "ffc0cb",
- plum: "dda0dd",
- powderblue: "b0e0e6",
- purple: "800080",
- rebeccapurple: "663399",
- red: "f00",
- rosybrown: "bc8f8f",
- royalblue: "4169e1",
- saddlebrown: "8b4513",
- salmon: "fa8072",
- sandybrown: "f4a460",
- seagreen: "2e8b57",
- seashell: "fff5ee",
- sienna: "a0522d",
- silver: "c0c0c0",
- skyblue: "87ceeb",
- slateblue: "6a5acd",
- slategray: "708090",
- slategrey: "708090",
- snow: "fffafa",
- springgreen: "00ff7f",
- steelblue: "4682b4",
- tan: "d2b48c",
- teal: "008080",
- thistle: "d8bfd8",
- tomato: "ff6347",
- turquoise: "40e0d0",
- violet: "ee82ee",
- wheat: "f5deb3",
- white: "fff",
- whitesmoke: "f5f5f5",
- yellow: "ff0",
- yellowgreen: "9acd32"
- };
-
- // Make it easy to access colors via `hexNames[hex]`
- var hexNames = tinycolor.hexNames = flip(names);
-
-
- // Utilities
- // ---------
-
- // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
- function flip(o) {
- var flipped = { };
- for (var i in o) {
- if (o.hasOwnProperty(i)) {
- flipped[o[i]] = i;
- }
- }
- return flipped;
- }
-
- // Return a valid alpha value [0,1] with all invalid values being set to 1
- function boundAlpha(a) {
- a = parseFloat(a);
-
- if (isNaN(a) || a < 0 || a > 1) {
- a = 1;
- }
-
- return a;
- }
-
- // Take input from [0, n] and return it as [0, 1]
- function bound01(n, max) {
- if (isOnePointZero(n)) { n = "100%"; }
-
- var processPercent = isPercentage(n);
- n = mathMin(max, mathMax(0, parseFloat(n)));
-
- // Automatically convert percentage into number
- if (processPercent) {
- n = parseInt(n * max, 10) / 100;
- }
-
- // Handle floating point rounding errors
- if ((math.abs(n - max) < 0.000001)) {
- return 1;
- }
-
- // Convert into [0, 1] range if it isn't already
- return (n % max) / parseFloat(max);
- }
-
- // Force a number between 0 and 1
- function clamp01(val) {
- return mathMin(1, mathMax(0, val));
- }
-
- // Parse a base-16 hex value into a base-10 integer
- function parseIntFromHex(val) {
- return parseInt(val, 16);
- }
-
- // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
- //
- function isOnePointZero(n) {
- return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
- }
-
- // Check to see if string passed in is a percentage
- function isPercentage(n) {
- return typeof n === "string" && n.indexOf('%') != -1;
- }
-
- // Force a hex value to have 2 characters
- function pad2(c) {
- return c.length == 1 ? '0' + c : '' + c;
- }
-
- // Replace a decimal with it's percentage value
- function convertToPercentage(n) {
- if (n <= 1) {
- n = (n * 100) + "%";
- }
-
- return n;
- }
-
- // Converts a decimal to a hex value
- function convertDecimalToHex(d) {
- return Math.round(parseFloat(d) * 255).toString(16);
- }
- // Converts a hex value to a decimal
- function convertHexToDecimal(h) {
- return (parseIntFromHex(h) / 255);
- }
-
- var matchers = (function() {
-
- //
- var CSS_INTEGER = "[-\\+]?\\d+%?";
-
- //
- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
-
- // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
-
- // Actual matching.
- // Parentheses and commas are optional, but not required.
- // Whitespace can take the place of commas or opening paren
- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
-
- return {
- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
- hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
- hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
- hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
- hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
- };
- })();
-
- // `stringInputToObject`
- // Permissive string parsing. Take in a number of formats, and output an object
- // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
- function stringInputToObject(color) {
-
- color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
- var named = false;
- if (names[color]) {
- color = names[color];
- named = true;
- }
- else if (color == 'transparent') {
- return { r: 0, g: 0, b: 0, a: 0, format: "name" };
- }
-
- // Try to match string input using regular expressions.
- // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
- // Just return an object and let the conversion functions handle that.
- // This way the result will be the same whether the tinycolor is initialized with string or object.
- var match;
- if ((match = matchers.rgb.exec(color))) {
- return { r: match[1], g: match[2], b: match[3] };
- }
- if ((match = matchers.rgba.exec(color))) {
- return { r: match[1], g: match[2], b: match[3], a: match[4] };
- }
- if ((match = matchers.hsl.exec(color))) {
- return { h: match[1], s: match[2], l: match[3] };
- }
- if ((match = matchers.hsla.exec(color))) {
- return { h: match[1], s: match[2], l: match[3], a: match[4] };
- }
- if ((match = matchers.hsv.exec(color))) {
- return { h: match[1], s: match[2], v: match[3] };
- }
- if ((match = matchers.hsva.exec(color))) {
- return { h: match[1], s: match[2], v: match[3], a: match[4] };
- }
- if ((match = matchers.hex8.exec(color))) {
- return {
- a: convertHexToDecimal(match[1]),
- r: parseIntFromHex(match[2]),
- g: parseIntFromHex(match[3]),
- b: parseIntFromHex(match[4]),
- format: named ? "name" : "hex8"
- };
- }
- if ((match = matchers.hex6.exec(color))) {
- return {
- r: parseIntFromHex(match[1]),
- g: parseIntFromHex(match[2]),
- b: parseIntFromHex(match[3]),
- format: named ? "name" : "hex"
- };
- }
- if ((match = matchers.hex3.exec(color))) {
- return {
- r: parseIntFromHex(match[1] + '' + match[1]),
- g: parseIntFromHex(match[2] + '' + match[2]),
- b: parseIntFromHex(match[3] + '' + match[3]),
- format: named ? "name" : "hex"
- };
- }
-
- return false;
- }
-
- window.tinycolor = tinycolor;
- })();
-
- $(function () {
- if ($.fn.spectrum.load) {
- $.fn.spectrum.processNativeColorInputs();
- }
- });
-
-});
-
-
-define('text!StyleManager/templates/propertyColor.html',[],function () { return '\n\tinput-holder\'> \n
\n
';});
-
-define('StyleManager/view/PropertyColorView',['backbone','./PropertyView', 'Spectrum', 'text!./../templates/propertyColor.html'],
- function (Backbone, PropertyView, Spectrum, propertyTemplate) {
- /**
- * @class PropertyColorView
- * */
- return PropertyView.extend({
-
- template: _.template(propertyTemplate),
-
- /**
- * @inheritdoc
- * */
- valueChanged: function(){
- PropertyView.prototype.valueChanged.apply(this, arguments);
- if(this.$colorPicker){
- var v = this.model.get('value');
- this.$colorPicker.spectrum("set", v).css('background-color', v);
- }
- },
-
- /** @inheritdoc */
- renderInput: function() {
- if(!this.$input){
- this.$input = $(' ', {placeholder: this.defaultValue, type: 'text' });
- this.$el.find('#' + this.pfx + 'input-holder').html(this.$input);
- }
- if(!this.$colorPicker){
- this.$colorPicker = $('', {class: this.pfx + "color-picker"});
- var that = this;
- this.$colorPicker.spectrum({
- showAlpha: true,
- chooseText: 'Ok',
- cancelText: '⨯',
- move: function(color) {
- var c = color.getAlpha() == 1 ? color.toHexString() : color.toRgbString();
- that.$colorPicker.css('background-color', c);
- },
- change: function(color) {
- var c = color.getAlpha() == 1 ? color.toHexString() : color.toRgbString();
- c = c.replace(/ /g,'');
- that.$colorPicker.css('background-color', c);
- that.model.set('value', c);
- }
- });
- this.$el.find('#' + this.pfx + 'input-holder').append(this.$colorPicker);
- }
- this.setValue(this.componentValue,0);
- },
-
- /** @inheritdoc */
- setValue: function(value, f){
- PropertyView.prototype.setValue.apply(this, arguments);
- var v = this.model.get('value') || this.defaultValue;
- v = value || v;
- if(this.$colorPicker)
- this.$colorPicker.spectrum("set", v).css('background-color',v);
- },
-
- });
-});
-
-
-define('text!StyleManager/templates/propertyFile.html',[],function () { return '
\n\t
input-holder\'>\n\t\t
\n\t\t\t<%= assets %> \n\t\t
\n\t\t
\n\t
\n\t
\n
\n
';});
-
-define('StyleManager/view/PropertyFileView',['backbone','./PropertyView', 'text!./../templates/propertyFile.html'],
- function (Backbone, PropertyView, propertyTemplate) {
- /**
- * @class PropertyColorView
- * */
- return PropertyView.extend({
-
- template: _.template(propertyTemplate),
-
- initialize: function(options) {
- PropertyView.prototype.initialize.apply(this, arguments);
- this.assets = this.target.get('assets');
- this.modal = this.target.get('Modal');
- this.am = this.target.get('AssetManager');
- this.className = this.className + ' '+ this.pfx +'file';
- this.events['click #'+this.pfx+'close'] = 'removeFile';
- this.events['click #'+this.pfx+'images'] = 'openAssetManager';
- this.delegateEvents();
- },
-
- /** @inheritdoc */
- renderInput: function() {
-
- if(!this.$input){
- this.$input = $('
', {placeholder: this.defaultValue, type: 'text' });
- }
-
- if(!this.$preview){
- this.$preview = this.$el.find('#' + this.pfx + 'preview-file');
- }
-
- if(!this.$previewBox){
- this.$previewBox = this.$el.find('#' + this.pfx + 'preview-box');
- }
-
- if(!this.componentValue || this.componentValue == this.defaultValue)
- this.setPreviewView(0);
- else
- this.setPreviewView(1);
-
- this.setValue(this.componentValue,0);
- },
-
- /**
- * Change visibility of the preview box
- * @param bool Visibility
- *
- * @return void
- * */
- setPreviewView: function(v){
- if(!this.$previewBox)
- return;
- if(v)
- this.$previewBox.addClass(this.pfx + 'show');
- else
- this.$previewBox.removeClass(this.pfx + 'show');
- },
-
- /**
- * Spread url
- * @param string Url
- *
- * @return void
- * */
- spreadUrl: function(url){
- this.setValue('url("'+url+'")');
- this.setPreviewView(1);
- },
-
- /**
- * Shows file preview
- * @param string Value
- * */
- setPreview: function(v){
- if(this.$preview)
- this.$preview.css('background-image',v);
- },
-
- /** @inheritdoc */
- setValue: function(value, f){
- PropertyView.prototype.setValue.apply(this, arguments);
- this.setPreview(value);
- },
-
- /** @inheritdoc */
- renderTemplate: function(){
- this.$el.append( this.template({
- upload : 'Upload',
- assets : 'Images',
- pfx : this.pfx
- }));
- },
-
- /** @inheritdoc */
- cleanValue: function(){
- this.setPreviewView(0);
- this.model.set({value: ''},{silent: true});
- },
-
- /**
- * Remove file from input
- *
- * @return void
- * */
- removeFile:function(){
- this.model.set('value',this.defaultValue);
- PropertyView.prototype.cleanValue.apply(this, arguments);
- this.setPreviewView(0);
- },
-
- /**
- * Open dialog for image selecting
- * @param {Object} e Event
- *
- * @return void
- * */
- openAssetManager: function(e){
- var that = this;
- if(this.modal && this.am){
- this.modal.setTitle('Select image');
- this.modal.setContent(this.am.render());
- this.am.setTarget(null);
- this.modal.show();
- this.am.onSelect(function(model){
- that.modal.hide();
- that.spreadUrl(model.get('src'));
- that.valueChanged(e);
- });
- }
- },
-
-
- });
-});
-
-
-define('text!StyleManager/templates/propertyComposite.html',[],function () { return '
\n\tinput-holder\'> \n
\n
';});
-
-define('StyleManager/view/PropertyCompositeView',['backbone','./PropertyView', 'text!./../templates/propertyComposite.html','require'],
- function (Backbone, PropertyView, propertyTemplate, require) {
- /**
- * @class PropertyCompositeView
- * */
- return PropertyView.extend({
-
- template: _.template(propertyTemplate),
-
- initialize: function(o) {
- PropertyView.prototype.initialize.apply(this, arguments);
- _.bindAll(this, 'build');
- this.config = o.config;
- this.className = this.className + ' '+ this.pfx +'composite';
- },
-
- /**
- * Renders input
- *
- * @return void
- * */
- renderInput: function() {
- var props = this.model.get('properties');
- if(props && props.length){
- if(!this.$input)
- this.$input = $('
', {value: 0, type: 'hidden' });
-
- if(!this.props){
- var Properties = require('./../model/Properties');
- this.props = new Properties(props);
- this.model.set('properties', this.props);
- }
-
- if(!this.$props){
- //Avoid style for children
- this.props.each(function(prop, index){
- prop.set('doNotStyle', true);
- });
- //Not yet supported nested composite
- this.props.each(function(prop, index){
- if(prop && prop.get('type') == 'composite'){
- this.props.remove(prop);
- console.warn(prop.get('property')+' of type composite not yet allowed.');
- }
- },this);
-
- var PropertiesView = require('./PropertiesView');
- var that = this;
- var propsView = new PropertiesView({
- config : this.config,
- collection : this.props,
- target : this.target,
- onChange : function(el, model){
- var result = that.build(el, model);
- that.model.set('value', result);
- },
- onInputRender : function(property, mIndex){
- var value = that.valueOnIndex(mIndex, property.model);
- property.setValue(value);
- },
- customValue : function(property, mIndex){
- return that.valueOnIndex(mIndex, property.model);
- },
- });
- this.$props = propsView.render().$el;
- this.$el.find('#'+ this.pfx +'input-holder').html(this.$props);
- }
- }
- },
-
- /**
- * Get default value of the property
- *
- * @return string
- * */
- getDefaultValue: function(){
- var str = '';
- this.props.each(function(prop, index){
- str += prop.get('defaults') + prop.get('unit') + ' ';
- });
- return str.replace(/ +$/,'');
- },
-
- /**
- * Extract string from composite value
- * @param integer Index
- * @param object Property model
- *
- * @return string
- * */
- valueOnIndex: function(index, model){
- var result = null;
- var a = this.getComponentValue().split(' ');
- if(a.length && a[index]){
- result = a[index];
- //Check for function type values
- if(model && model.get('functionName')){
- var v = this.fetchFromFunction(result);
- if(v)
- result = v;
- }
- }
- return result;
- },
-
- /**
- * Build composite value
- * @param Object Selected element
- * @param Object Property model
- *
- * @return string
- * */
- build: function(selectedEl, propertyModel){
- var result = '';
- this.model.get('properties').each(function(prop){
- var v = (prop.get('value') || prop.get('defaults')) + prop.get('unit'),
- func = prop.get('functionName');
- if(func)
- v = func + '(' + v + ')';
- result += v + ' ';
- });
- //Remove also the last white space
- return result.replace(/ +$/,'');
- },
-
- });
-});
-
-
-define('text!StyleManager/templates/propertyStack.html',[],function () { return '
\n\tadd\'>+ \n\tinput-holder\'> \n
\n
';});
-
-define('StyleManager/model/Layer',['backbone'],
- function(Backbone) {
- /**
- * @class Layer
- * */
- return Backbone.Model.extend({
-
- defaults: {
- name : '',
- active : true,
- value : '',
- preview : false,
- }
-
- });
- });
-define('StyleManager/model/Layers',[ 'backbone','./Layer'],
- function (Backbone,Layer) {
- /**
- * @class Layers
- * */
- return Backbone.Collection.extend({
-
- model: Layer,
-
- });
-});
-
-
-define('text!StyleManager/templates/layer.html',[],function () { return '
<%= label %>
\n
\n\t
:<%= vPreview %>\'>
\n
\n
⨯
\n
\n
';});
-
-define('StyleManager/view/LayerView',['backbone', 'text!./../templates/layer.html'],
- function (Backbone, layerTemplate) {
- /**
- * @class LayerView
- * */
- return Backbone.View.extend({
-
- events:{
- 'click' : 'updateIndex',
- },
-
- template: _.template(layerTemplate),
-
- initialize: function(o) {
- this.stackModel = o.stackModel || {};
- this.config = o.config;
- this.pfx = this.config.stylePrefix;
- this.className = this.pfx + 'layer';
- this.listenTo( this.model, 'destroy remove', this.remove );
- this.listenTo( this.model, 'change:valuePreview', this.previewChanged );
- this.listenTo( this.model, 'change:props', this.showProps );
- this.events['click #' + this.pfx + 'close-layer'] = 'remove';
-
- if( !this.model.get('preview') ){
- this.$el.addClass(this.pfx + 'no-preview');
- }
-
- // Parse preview value if requested
- var pPattern = this.model.get('patternPreview');
- if(this.model.get('valuePreview') && pPattern){
- this.model.set('preview',true);
- var nV = this.formatPreviewValue(pPattern);
- this.model.set({valuePreview: nV}, {silent: true});
- }
-
- this.delegateEvents();
- },
-
- /**
- * Format preview value by pattern of property models
- * @param Objects Property models
- *
- * @return string
- * */
- formatPreviewValue: function(props){
- var aV = this.model.get('valuePreview').split(' '),
- lim = 3,
- nV = '';
- props.each(function(p, index){
- var v = aV[index];
- if(v){
- if(p.get('type') == 'integer'){
- var vI = parseInt(v, 10),
- u = v.replace(vI,'');
- vI = !isNaN(vI) ? vI : 0;
- if(vI > lim) vI = lim;
- if(vI < -lim) vI = -lim;
- v = vI + u;
- }
- }
- nV += v + ' ';
- });
- return nV;
- },
-
- /**
- * Show inputs on this layer
- *
- * @return void
- * */
- showProps:function(){
- this.$props = this.model.get('props');
- this.$el.find('#' + this.pfx + 'inputs').html(this.$props.show());
- this.model.set({ props: null },{ silent: true });
- },
-
- /**
- * Triggered when the value for the preview is changed
- *
- * @return void
- * */
- previewChanged:function(){
- if( this.model.get('preview') ){
- if(!this.$preview)
- this.$preview = this.$el.find('#'+ this.pfx + 'preview');
- var property = this.model.get('propertyPreview');
- if(property)
- this.$preview.css(property,this.model.get('valuePreview'));
- }
- },
-
- /** @inheritdoc */
- remove: function(e){
- // Prevent from revoming all events on props
- if(this.$props)
- this.$props.detach();
- e.stopPropagation();
- Backbone.View.prototype.remove.apply(this, arguments);
- this.model.collection.remove(this.model);
- this.stackModel.trigger('refreshValue');
- this.stackModel.set({stackIndex: null},{silent: true});
- },
-
- /**
- * Update index
- * @param Event
- *
- * @return void
- * */
- updateIndex: function(e){
- var index = this.model.collection.indexOf(this.model);
- this.stackModel.set('stackIndex', index);
- this.model.collection.trigger('deselectAll');
- this.$el.addClass(this.pfx + 'active');
- },
-
- render : function(){
- var index = this.model.collection.indexOf(this.model);
- this.$el.html( this.template({
- label : 'Layer '+index,
- name : this.model.get('name'),
- vPreview : this.model.get('valuePreview'),
- pPreview : this.model.get('propertyPreview'),
- pfx : this.pfx,
- }));
- this.$el.attr('class', this.className);
- return this;
- },
-
- });
-});
-
-define('StyleManager/view/LayersView',['backbone','./LayerView'],
- function (Backbone, LayerView) {
- /**
- * @class LayersView
- * */
- return Backbone.View.extend({
-
- initialize: function(o) {
- this.config = o.config;
- this.stackModel = o.stackModel;
- this.preview = o.preview;
- this.pfx = this.config.stylePrefix;
- this.className = this.pfx + 'layers';
- this.listenTo( this.collection, 'add', this.addTo );
- this.listenTo( this.collection, 'deselectAll', this.deselectAll );
- this.listenTo( this.collection, 'reset', this.render );
- },
-
- /**
- * Add to collection
- * @param Object Model
- *
- * @return Object
- * */
- addTo: function(model){
- this.addToCollection(model);
- },
-
- /**
- * Add new object to collection
- * @param Object Model
- * @param Object Fragment collection
- *
- * @return Object Object created
- * */
- addToCollection: function(model, fragmentEl){
- var fragment = fragmentEl || null;
- var viewObject = LayerView;
-
- if(typeof this.preview != 'undefined'){
- model.set('preview', this.preview);
- }
-
- var view = new viewObject({
- model : model,
- stackModel : this.stackModel,
- preview : this.preview,
- config : this.config,
- });
- var rendered = view.render().el;
-
- if(fragment){
- fragment.appendChild( rendered );
- }else{
- this.$el.append(rendered);
- }
-
- return rendered;
- },
-
- /**
- * Deselect all
- *
- * @return void
- * */
- deselectAll: function(){
- this.$el.find('.'+ this.pfx +'layer').removeClass(this.pfx + 'active');
- },
-
- render: function() {
- var fragment = document.createDocumentFragment();
- this.$el.empty();
-
- this.collection.each(function(model){
- this.addToCollection(model, fragment);
- },this);
-
- this.$el.append(fragment);
- this.$el.attr('class', this.className);
- return this;
- }
- });
-});
-
-define('StyleManager/view/PropertyStackView',['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack.html','./../model/Layers','./LayersView'],
- function (Backbone, PropertyCompositeView, propertyTemplate, Layers, LayersView) {
- /**
- * @class PropertyStackView
- * */
- return PropertyCompositeView.extend({
-
- template: _.template(propertyTemplate),
-
- initialize: function(o) {
- PropertyCompositeView.prototype.initialize.apply(this, arguments);
- this.model.set('stackIndex', null);
- this.listenTo( this.model ,'change:stackIndex', this.indexChanged);
- this.listenTo( this.model ,'refreshValue', this.refreshValue);
- this.className = this.pfx + 'property '+ this.pfx +'stack';
- this.events['click #'+this.pfx+'add'] = 'addLayer';
-
- if(!this.layers){
- this.layers = new Layers();
- this.model.set('layers', this.layers);
- this.$layers = new LayersView({
- collection : this.layers,
- stackModel : this.model,
- preview : this.model.get('preview'),
- config : o.config
- });
- }
-
- this.delegateEvents();
- },
-
- /**
- * Triggered when another layer has been selected
- * @param Event
- *
- * @return Object
- * */
- indexChanged: function(e){
- var layer = this.layers.at(this.model.get('stackIndex'));
- layer.set('props', this.$props);
- this.target.trigger('change:selectedComponent');
- },
-
- /**
- * Get array of values from layers
- *
- * @return Array
- * */
- getStackValues: function(){
- var a = [];
- this.layers.each(function(layer){
- a.push( layer.get('value') );
- });
- return a;
- },
-
- /**
- * Extract string from composite value
- * @param integer Index
- *
- * @return string
- * */
- valueOnIndex: function(index){
- var result = null;
- var aStack = this.getStackValues();
- var strVar = aStack[this.model.get('stackIndex')];
-
- if(!strVar)
- return;
- var a = strVar.split(' ');
- if(a.length && a[index]){
- result = a[index];
- }
- return result;
- },
-
- /** @inheritdoc */
- build: function(selectedEl, propertyModel){
- if(this.model.get('stackIndex') === null)
- return;
- var result = PropertyCompositeView.prototype.build.apply(this, arguments);
- var model = this.layers.at(this.model.get('stackIndex'));
- if(!model)
- return;
- model.set('value',result);
- // Update data for preview
- if(this.onPreview && typeof this.onPreview === "function"){
- var v = this.onPreview(this.model.get('properties'));
- if(v)
- result = v;
- model.set('propertyPreview', this.property);
- model.set('valuePreview',result);
- }
-
- return this.createValue();
- },
-
- /**
- * Change preview value. Limited integer values
- * @param Models
- *
- * @return string
- * */
- onPreview: function(properties){
- var str = '',
- lim = 3;
- properties.each(function(p){
- var v = p.get('value');
- if(p.get('type') == 'integer'){
- if(v > lim) v = lim;
- if(v < -lim) v = -lim;
- }
- str += v + p.get('unit')+' ';
- });
-
- return str;
- },
-
- /**
- * Add layer
- * @param Event
- *
- * @return Object
- * */
- addLayer: function(e){
- if(this.selectedComponent){
- var layer = this.layers.add({ name : 'test' });
- var index = this.layers.indexOf(layer);
- layer.set('value', this.getDefaultValue());
- this.refreshValue();
- this.model.set('stackIndex', index);
- return layer;
- }
- },
-
- /**
- * Refresh value
- *
- * @return void
- * */
- refreshValue: function(){
- this.model.set('value', this.createValue());
- },
-
- /**
- * Create value by layers
- * @return string
- * */
- createValue: function(){
- return this.getStackValues().join(', ');
- },
-
- /**
- * Render layers
- *
- * @return self
- * */
- renderLayers: function() {
- this.$el.find('> .'+this.pfx+'field').append(this.$layers.render().el);
- this.$props.hide();
- return this;
- },
-
- /** @inheritdoc */
- renderInput: function() {
- PropertyCompositeView.prototype.renderInput.apply(this, arguments);
- this.refreshLayers();
- },
-
- /**
- * Refresh layers
- *
- * @return void
- * */
- refreshLayers: function(){
- var v = this.getComponentValue();
- var n = [];
- if(v){
- var a = v.split(', ');
- _.each(a,function(e){
- n.push({ value: e,
- valuePreview: e,
- propertyPreview: this.property,
- patternPreview: this.props
- });
- },this);
- }
- this.$props.detach();
- this.layers.reset(n);
- this.refreshValue();
- this.model.set({stackIndex: null},{silent: true});
- },
-
- /** @inheritdoc */
- render : function(){
- this.renderLabel();
- this.renderField();
- this.renderLayers();
- this.$el.attr('class', this.className);
- return this;
- },
-
- });
-});
-
-define('StyleManager/view/PropertiesView',['backbone','./PropertyView', './PropertyIntegerView', './PropertyRadioView', './PropertySelectView',
- './PropertyColorView', './PropertyFileView', './PropertyCompositeView', './PropertyStackView'],
- function (Backbone, PropertyView, PropertyIntegerView, PropertyRadioView, PropertySelectView,
- PropertyColorView, PropertyFileView, PropertyCompositeView, PropertyStackView) {
- /**
- * @class PropertiesView
- * */
- return Backbone.View.extend({
-
- initialize: function(o) {
- this.config = o.config;
- this.pfx = this.config.stylePrefix;
- this.target = o.target || {};
- this.onChange = o.onChange || {};
- this.onInputRender = o.onInputRender || {};
- this.customValue = o.customValue || {};
- },
-
- render: function() {
- var fragment = document.createDocumentFragment();
-
- this.collection.each(function(model){
- var objView = PropertyView;
-
- switch(model.get('type')){
- case 'integer':
- objView = PropertyIntegerView; break;
- case 'radio':
- objView = PropertyRadioView; break;
- case 'select':
- objView = PropertySelectView; break;
- case 'color':
- objView = PropertyColorView; break;
- case 'file':
- objView = PropertyFileView; break;
- case 'composite':
- objView = PropertyCompositeView;break;
- case 'stack':
- objView = PropertyStackView; break;
- }
-
- var view = new objView({
- model : model,
- name : model.get('name'),
- id : this.pfx + model.get('property'),
- target : this.target,
- onChange : this.onChange,
- onInputRender : this.onInputRender,
- config : this.config,
- });
-
- if(model.get('type') != 'composite'){
- view.customValue = this.customValue;
- }
-
- fragment.appendChild(view.render().el);
- },this);
-
- this.$el.append(fragment);
- this.$el.append($('
', {class: "clear"}));
- this.$el.attr('class', this.pfx + 'properties');
- return this;
- }
- });
-});
-
-define('StyleManager/view/SectorView',['backbone','./PropertiesView'],
- function (Backbone,PropertiesView) {
- /**
- * @class SectorView
- * */
- return Backbone.View.extend({
-
- events:{},
-
- initialize: function(o) {
- this.config = o.config;
- this.pfx = this.config.stylePrefix;
- this.target = o.target || {};
- this.open = this.model.get('open');
- this.events['click .' + this.pfx + 'title'] = 'toggle';
- this.delegateEvents();
- },
-
- /**
- * Show the content of the sector
- * */
- show : function(){
- this.$el.addClass(this.pfx + "open");
- this.$el.find('.' + this.pfx + 'properties').show();
- this.open = true;
- },
-
- /**
- * Hide the content of the sector
- * */
- hide : function(){
- this.$el.removeClass(this.pfx + "open");
- this.$el.find('.' + this.pfx + 'properties').hide();
- this.open = false;
- },
-
- /**
- * Toggle visibility of the content
- * */
- toggle: function(){
- if(this.open)
- this.hide();
- else
- this.show();
- },
-
- render : function(){
- if(this.open)
- this.show();
- else
- this.hide();
- this.$el.html('
'+this.model.get('name')+'
');
- this.renderProperties();
- this.$el.attr('class', this.pfx + 'sector no-select');
- return this;
- },
-
- renderProperties: function(){
- var objs = this.model.get('properties');
-
- if(objs){
- var view = new PropertiesView({
- collection : objs,
- target : this.target,
- config : this.config,
- });
- this.$el.append(view.render().el);
- }
- },
- });
-});
-
-define('StyleManager/view/SectorsView',['backbone','./SectorView'],
- function (Backbone, SectorView) {
- /**
- * @class sectorsView
- * */
- return Backbone.View.extend({
-
- initialize: function(o) {
- this.config = o.config;
- this.pfx = this.config.stylePrefix;
- this.target = o.target || {};
- },
-
- render: function() {
- var fragment = document.createDocumentFragment();
-
- this.collection.each(function(obj){
- var view = new SectorView({
- model : obj,
- id : this.pfx + obj.get('name').replace(' ','_').toLowerCase(),
- name : obj.get('name'),
- properties : obj.get('properties'),
- target : this.target,
- config : this.config,
- });
- fragment.appendChild(view.render().el);
- }, this);
-
- this.$el.attr('id', this.pfx + 'sectors');
- this.$el.append(fragment);
- return this;
- }
- });
-});
-
-define('StyleManager/main',['require','./config/config','./model/Sectors','./view/SectorsView'],function(require) {
- /**
- * @class StyleManager
- * @param {Object} Configurations
- *
- * @return {Object}
- * */
- function StyleManager(config)
- {
- var c = config || {},
- defaults = require('./config/config'),
- Sectors = require('./model/Sectors'),
- SectorsView = require('./view/SectorsView');
-
- for (var name in defaults) {
- if (!(name in c))
- c[name] = defaults[name];
- }
-
- this.sectors = new Sectors(c.sectors);
- var obj = {
- collection : this.sectors,
- target : c.target,
- config : c,
- };
-
- this.SectorsView = new SectorsView(obj);
- }
-
- StyleManager.prototype = {
-
- /**
- * Get all sectors
- *
- * @return {Sectors}
- * */
- getSectors : function()
- {
- return this.sectors;
- },
-
- /**
- * Get sector by id
- * @param {String} id Object id
- *
- * @return {Sector}|{null}
- * */
- getSector : function(id)
- {
- var res = this.sectors.where({id: id});
- return res.length ? res[0] : null;
- },
-
- /**
- * Add new Sector
- * @param {String} id Object id
- * @param {Object} obj Object data
- *
- * @return {Sector}
- * */
- addSector : function(id, obj)
- {
- if(!this.getSector(id)){
- obj.id = id;
- return this.sectors.add(obj);
- }
- },
-
- /**
- * Render sectors
- *
- * @return {String}
- * */
- render : function(){
- return this.SectorsView.render().$el;
- },
- };
-
- return StyleManager;
-});
-define('StyleManager', ['StyleManager/main'], function (main) { return main; });
-
-define('Commands/view/OpenStyleManager',['StyleManager'], function(StyleManager) {
- /**
- * @class OpenStyleManager
- * */
- return {
-
- run: function(em, sender)
- {
- if(!this.$sm){
- var config = em.get('Config'),
- panels = em.get('Panels'),
- smStylePfx = config.styleManager.stylePrefix || 'sm-';
-
- config.styleManager.stylePrefix = config.stylePrefix + smStylePfx;
- config.styleManager.target = em;
-
- var sm = new StyleManager(config.styleManager);
- this.$sm = sm.render();
-
- if(!panels.getPanel('views-container'))
- this.panel = panels.addPanel({ id: 'views-container'});
- else
- this.panel = panels.getPanel('views-container');
-
- this.panel.set('appendContent', this.$sm).trigger('change:appendContent');
- }
- this.$sm.show();
- },
-
- stop: function()
- {
- if(this.$sm)
- this.$sm.hide();
- }
- };
- });
-define('Commands/main',['require','./config/config','./view/CommandAbstract','./view/SelectComponent','./view/CreateComponent','./view/DeleteComponent','./view/ImageComponent','./view/MoveComponent','./view/TextComponent','./view/InsertCustom','./view/ExportTemplate','./view/SwitchVisibility','./view/OpenLayers','./view/OpenStyleManager'],function(require) {
- /**
- * @class Commands
- * @param {Object} Configurations
- *
- * @return {Object}
- * */
- function Commands(config)
- {
- var c = config || {},
- defaults = require('./config/config'),
- AbsCommands = require('./view/CommandAbstract');
-
- for (var name in defaults) {
- if (!(name in c))
- c[name] = defaults[name];
- }
-
- this.commands = {};
- this.config = c;
- this.Abstract = AbsCommands;
-
- this.defaultCommands = {};
- this.defaultCommands['select-comp'] = require('./view/SelectComponent');
- this.defaultCommands['create-comp'] = require('./view/CreateComponent');
- this.defaultCommands['delete-comp'] = require('./view/DeleteComponent');
- //this.defaultCommands['resize-comp'] = require('./view/ResizeComponent');
- this.defaultCommands['image-comp'] = require('./view/ImageComponent');
- this.defaultCommands['move-comp'] = require('./view/MoveComponent');
- this.defaultCommands['text-comp'] = require('./view/TextComponent');
- this.defaultCommands['insert-custom'] = require('./view/InsertCustom');
- this.defaultCommands['export-template'] = require('./view/ExportTemplate');
- this.defaultCommands['sw-visibility'] = require('./view/SwitchVisibility');
- this.defaultCommands['open-layers'] = require('./view/OpenLayers');
- this.defaultCommands['open-sm'] = require('./view/OpenStyleManager');
-
- this.config.model = this.config.em.get('Canvas');
- }
-
- Commands.prototype = {
-
- /**
- * Add new command
- * @param {String} id
- * @param {Object} obj
- *
- * @return this
- * */
- add : function(id, obj)
- {
- delete obj.initialize;
- this.commands[id] = this.Abstract.extend(obj);
- return this;
- },
-
- /**
- * Get command
- * @param {String} id
- *
- * @return Command
- * */
- get : function(id)
- {
- var el = this.commands[id];
-
- if(typeof el == 'function'){
- el = new el(this.config);
- this.commands[id] = el;
- }
-
- return el;
- },
-
- /**
- * Load default commands
- *
- * @return this
- * */
- loadDefaultCommands : function()
- {
- for (var id in this.defaultCommands) {
- this.add(id, this.defaultCommands[id]);
- }
-
- return this;
- },
- };
-
- return Commands;
-});
-define('Commands', ['Commands/main'], function (main) { return main; });
-
-define('Canvas/config/config',[],function () {
- return {
-
- stylePrefix : 'cv-',
-
- // Coming soon
- rulers : false,
-
- };
-});
-define('Canvas/model/Canvas',['backbone'],
- function(Backbone){
- /**
- * @class Canvas
- * */
- return Backbone.Model.extend({
-
- defaults :{
- wrapper : '',
- rulers : false,
- },
-
- });
- });
-
-define('Canvas/view/CanvasView',['backbone'],
-function(Backbone) {
- /**
- * @class CanvasView
- * */
- return Backbone.View.extend({
-
- //id: 'canvas',
-
- initialize: function(o) {
- this.config = o.config;
- this.className = this.config.stylePrefix + 'canvas';
- },
-
- render: function() {
- this.wrapper = this.model.get('wrapper');
- if(this.wrapper && typeof this.wrapper.render == 'function'){
- this.$el.append( this.wrapper.render() );
- }
- this.$el.attr({class: this.className, id: this.config.canvasId});
- return this;
- },
-
- });
-});
-define('Canvas/main',['require','./config/config','./model/Canvas','./view/CanvasView'],function(require) {
- /**
- * @class Canvas
- * @param {Object} Configurations
- *
- * @return {Object}
- * */
- var Canvas = function(config)
- {
- var c = config || {},
- defaults = require('./config/config'),
- Canvas = require('./model/Canvas'),
- CanvasView = require('./view/CanvasView');
-
- for (var name in defaults) {
- if (!(name in c))
- c[name] = defaults[name];
- }
-
- this.canvas = new Canvas(config);
- var obj = {
- model : this.canvas,
- config : c,
- };
-
- this.CanvasView = new CanvasView(obj);
- };
-
- Canvas.prototype = {
- /**
- * Add wrapper
- * @param {Object} wrp Wrapper
- *
- * */
- setWrapper : function(wrp)
- {
- this.canvas.set('wrapper', wrp);
- },
-
- /**
- * Get wrapper
- *
- * @return {Object}
- * */
- getWrapper : function()
- {
- return this.canvas.get('wrapper').getComponent();
- },
-
- /**
- * Render canvas
- * */
- render : function()
- {
- return this.CanvasView.render().$el;
- },
- };
-
- return Canvas;
-});
-define('Canvas', ['Canvas/main'], function (main) { return main; });
-
-define('RichTextEditor/config/config',[],function () {
- return {
- stylePrefix : 'rte-',
- toolbarId : 'toolbar',
- containerId : 'wrapper',
- commands : [{
- command: 'bold',
- title: 'Bold',
- class: 'fa fa-bold',
- group: 'format'
- },{
- command: 'italic',
- title: 'Italic',
- class: 'fa fa-italic',
- group: 'format'
- },{
- command: 'underline',
- title: 'Underline',
- class: 'fa fa-underline',
- group: 'format'
- },],
- };
-});
-/*jslint browser:true*/
-define('RichTextEditor/view/TextEditorView',['jquery'],
- function ($) {
-
- var readFileIntoDataUrl = function (fileInfo) {
- var loader = $.Deferred(),
- fReader = new FileReader();
- fReader.onload = function (e) {
- loader.resolve(e.target.result);
- };
- fReader.onerror = loader.reject;
- fReader.onprogress = loader.notify;
- fReader.readAsDataURL(fileInfo);
- return loader.promise();
- };
- $.fn.cleanHtml = function () {
- var html = $(this).html();
- return html && html.replace(/(
|\s|
<\/div>| )*$/, '');
- };
- $.fn.wysiwyg = function (userOptions) {
- var editor = this,
- selectedRange,
- options,
- toolbarBtnSelector,
- updateToolbar = function () {
- if (options.activeToolbarClass) {
- $(options.toolbarSelector).find(toolbarBtnSelector).each(function () {
- var command = $(this).data(options.commandRole);
- if (document.queryCommandState(command)) {
- $(this).addClass(options.activeToolbarClass);
- } else {
- $(this).removeClass(options.activeToolbarClass);
- }
- });
- }
- },
- execCommand = function (commandWithArgs, valueArg) {
- var commandArr = commandWithArgs.split(' '),
- command = commandArr.shift(),
- args = commandArr.join(' ') + (valueArg || '');
- document.execCommand(command, 0, args);
- updateToolbar();
- },
- bindHotkeys = function (hotKeys) {
- $.each(hotKeys, function (hotkey, command) {
- editor.keydown(hotkey, function (e) {
- if (editor.attr('contenteditable') && editor.is(':visible')) {
- e.preventDefault();
- e.stopPropagation();
- execCommand(command);
- }
- }).keyup(hotkey, function (e) {
- if (editor.attr('contenteditable') && editor.is(':visible')) {
- e.preventDefault();
- e.stopPropagation();
- }
- });
- });
- },
- getCurrentRange = function () {
- var sel = window.getSelection();
- if (sel.getRangeAt && sel.rangeCount) {
- return sel.getRangeAt(0);
- }
- },
- saveSelection = function () {
- selectedRange = getCurrentRange();
- },
- restoreSelection = function () {
- var selection = window.getSelection();
- if (selectedRange) {
- try {
- selection.removeAllRanges();
- } catch (ex) {
- document.body.createTextRange().select();
- document.selection.empty();
- }
-
- selection.addRange(selectedRange);
- }
- },
- insertFiles = function (files) {
- editor.focus();
- $.each(files, function (idx, fileInfo) {
- if (/^image\//.test(fileInfo.type)) {
- $.when(readFileIntoDataUrl(fileInfo)).done(function (dataUrl) {
- execCommand('insertimage', dataUrl);
- }).fail(function (e) {
- options.fileUploadError("file-reader", e);
- });
- } else {
- options.fileUploadError("unsupported-file-type", fileInfo.type);
- }
- });
- },
- markSelection = function (input, color) {
- restoreSelection();
- if (document.queryCommandSupported('hiliteColor')) {
- document.execCommand('hiliteColor', 0, color || 'transparent');
- }
- saveSelection();
- input.data(options.selectionMarker, color);
- },
- bindToolbar = function (toolbar, options) {
- toolbar.find(toolbarBtnSelector).click(function () {
- restoreSelection();
- editor.focus();
- execCommand($(this).data(options.commandRole));
- saveSelection();
- });
- toolbar.find('[data-toggle=dropdown]').click(restoreSelection);
-
- toolbar.find('input[type=text][data-' + options.commandRole + ']').on('webkitspeechchange change', function () {
- var newValue = this.value; /* ugly but prevents fake double-calls due to selection restoration */
- this.value = '';
- restoreSelection();
- if (newValue) {
- editor.focus();
- execCommand($(this).data(options.commandRole), newValue);
- }
- saveSelection();
- }).on('focus', function () {
- var input = $(this);
- if (!input.data(options.selectionMarker)) {
- markSelection(input, options.selectionColor);
- input.focus();
- }
- }).on('blur', function () {
- var input = $(this);
- if (input.data(options.selectionMarker)) {
- markSelection(input, false);
- }
- });
- toolbar.find('input[type=file][data-' + options.commandRole + ']').change(function () {
- restoreSelection();
- if (this.type === 'file' && this.files && this.files.length > 0) {
- insertFiles(this.files);
- }
- saveSelection();
- this.value = '';
- });
- },
- initFileDrops = function () {
- editor.on('dragenter dragover', false)
- .on('drop', function (e) {
- var dataTransfer = e.originalEvent.dataTransfer;
- e.stopPropagation();
- e.preventDefault();
- if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
- insertFiles(dataTransfer.files);
- }
- });
- };
- /** Disable the editor
- * @date 2015-03-19 */
- if(typeof userOptions=='string' && userOptions=='destroy'){
- editor.attr('contenteditable', false).unbind('mouseup keyup mouseout dragenter dragover');
- $(window).unbind('touchend');
- return this;
- }
- options = $.extend({}, $.fn.wysiwyg.defaults, userOptions);
- toolbarBtnSelector = 'a[data-' + options.commandRole + '],button[data-' + options.commandRole + '],input[type=button][data-' + options.commandRole + ']';
- bindHotkeys(options.hotKeys);
- if (options.dragAndDropImages) {
- initFileDrops();
- }
- bindToolbar($(options.toolbarSelector), options);
- editor.attr('contenteditable', true)
- .on('mouseup keyup mouseout', function () {
- saveSelection();
- updateToolbar();
- });
- $(window).bind('touchend', function (e) {
- var isInside = (editor.is(e.target) || editor.has(e.target).length > 0),
- currentRange = getCurrentRange(),
- clear = currentRange && (currentRange.startContainer === currentRange.endContainer && currentRange.startOffset === currentRange.endOffset);
- if (!clear || isInside) {
- saveSelection();
- updateToolbar();
- }
- });
- return this;
- };
- $.fn.wysiwyg.defaults = {
- hotKeys: {
- 'ctrl+b meta+b': 'bold',
- 'ctrl+i meta+i': 'italic',
- 'ctrl+u meta+u': 'underline',
- 'ctrl+z meta+z': 'undo',
- 'ctrl+y meta+y meta+shift+z': 'redo',
- 'ctrl+l meta+l': 'justifyleft',
- 'ctrl+r meta+r': 'justifyright',
- 'ctrl+e meta+e': 'justifycenter',
- 'ctrl+j meta+j': 'justifyfull',
- 'shift+tab': 'outdent',
- 'tab': 'indent'
- },
- toolbarSelector: '[data-role=editor-toolbar]',
- commandRole: 'edit',
- activeToolbarClass: 'btn-info',
- selectionMarker: 'edit-focus-marker',
- selectionColor: 'darkgrey',
- dragAndDropImages: true,
- fileUploadError: function (reason, detail) { console.log("File upload error", reason, detail); }
- };
-
- return $;
-});
-
-
-define('RichTextEditor/model/CommandButton',['backbone'],
- function (Backbone) {
- /**
- * @class CommandButton
- * */
- return Backbone.Model.extend({
-
- defaults: {
- command : '',
- title : '',
- class : '',
- group : '',
- },
-
- });
-});
-
-define('RichTextEditor/model/CommandButtons',[ 'backbone','./CommandButton'],
- function (Backbone, CommandButton) {
- /**
- * @class CommandButtons
- * */
- return Backbone.Collection.extend({
-
- model: CommandButton,
-
- });
-});
-
-define('RichTextEditor/view/CommandButtonView',['backbone'],
- function (Backbone) {
- /**
- * @class CommandButtonView
- * */
- return Backbone.View.extend({
-
- tagName: 'a',
-
- initialize: function(o){
- this.config = o.config || {};
- this.className = this.config.stylePrefix + 'btn ' + this.model.get('class');
- },
-
- render: function() {
- this.$el.attr('class', _.result( this, 'className' ) );
- return this;
- }
- });
-});
-
-define('RichTextEditor/view/CommandButtonsView',['backbone','./CommandButtonView'],
- function (Backbone, CommandButtonView) {
- /**
- * @class CommandButtonsView
- * */
- return Backbone.View.extend({
-
- className: 'no-dots',
-
- attributes : {
- 'data-role' : 'editor-toolbar',
- },
-
- initialize: function(o){
- this.config = o.config || {};
- this.id = this.config.stylePrefix + this.config.toolbarId;
- this.$el.data('helper',1);
- },
-
- /**
- * Update RTE target pointer
- * @param {String} target
- *
- * @return this
- * */
- updateTarget: function(target){
- this.$el.attr('data-target',target);
- return this;
- },
-
- render: function() {
- var fragment = document.createDocumentFragment();
- this.$el.empty();
-
- this.collection.each(function(item){
- var view = new CommandButtonView({
- model : item,
- config : this.config,
- attributes : {
- 'title' : item.get('title'),
- 'data-edit' : item.get('command'),
- },
- });
- fragment.appendChild(view.render().el);
- },this);
- this.$el.append(fragment);
- this.$el.attr('id', _.result( this, 'id' ) );
- return this;
- }
- });
-});
-
-define('RichTextEditor/main',['require','./config/config','./view/TextEditorView','./model/CommandButtons','./view/CommandButtonsView'],function(require) {
- /**
- * @class RichTextEditor
- * @param {Object} Configurations
- *
- * @return {Object}
- * */
- function RichTextEditor(config)
- {
- var c = config || {},
- defaults = require('./config/config'),
- rte = require('./view/TextEditorView'),
- CommandButtons = require('./model/CommandButtons'),
- CommandButtonsView = require('./view/CommandButtonsView');
-
- for (var name in defaults) {
- if (!(name in c))
- c[name] = defaults[name];
- }
-
- this.tlbPfx = c.stylePrefix;
- this.commands = new CommandButtons(c.commands);
- var obj = {
- collection : this.commands,
- config : c,
- };
-
- this.toolbar = new CommandButtonsView(obj);
- this.$toolbar = this.toolbar.render().$el;
- }
-
- RichTextEditor.prototype = {
-
- /**
- * Bind rich text editor to element
- * @param {Object} view
- * @param {Object} container
- *
- * */
- bind : function(view, container){
- if(!this.$contaniner){
- this.$container = container;
- this.$toolbar.appendTo(this.$container);
- }
- view.$el.wysiwyg({hotKeys: {}}).focus();
- this.updatePosition(view.$el);
- this.bindToolbar(view).show();
- //Avoid closing edit mode clicking on toolbar
- this.$toolbar.on('mousedown', this.disableProp);
- },
-
- /**
- * Unbind rich text editor from element
- * @param {Object} view
- *
- * */
- unbind : function(view){
- view.$el.wysiwyg('destroy');
- this.hide();
- this.$toolbar.off('mousedown', this.disableProp);
- },
-
- /**
- * Bind toolbar to element
- * @param {Object} view
- *
- * @return this
- * */
- bindToolbar : function(view){
- var id = this.tlbPfx + view.model.cid,
- dId = this.tlbPfx + 'inited';
- if(!view.$el.data(dId)){
- view.$el.data(dId, 1);
- view.$el.attr('id',id);
- }
- this.toolbar.updateTarget('#' + id);
- return this;
- },
-
- /**
- * Update toolbar position
- * @param {Object} $el Element
- *
- */
- updatePosition: function($el){
- var cOffset = this.$container.offset(),
- cTop = cOffset ? cOffset.top : 0,
- cLeft = cOffset ? cOffset.left : 0,
- eOffset = $el.offset(),
- rTop = eOffset.top - cTop + this.$container.scrollTop(),
- rLeft = eOffset.left - cLeft + this.$container.scrollLeft();
- if(!this.tlbH)
- this.tlbH = this.$toolbar.outerHeight();
- this.$toolbar.css({
- top : (rTop - this.tlbH - 5),
- left : rLeft
- });
- },
-
- /**
- * Show toolbar
- *
- * */
- show : function(){
- this.$toolbar.show();
- },
-
- /**
- * Hide toolbar
- *
- * */
- hide : function(){
- this.$toolbar.hide();
- },
-
- /**
- * Isolate disable propagation method
- *
- * */
- disableProp: function(e){
- e.stopPropagation();
- },
- };
-
- return RichTextEditor;
-});
-define('RichTextEditor', ['RichTextEditor/main'], function (main) { return main; });
-
-define('DomComponents/config/config',[],function () {
- return {
- stylePrefix : 'comp-',
-
- wrapperId : 'wrapper',
-
- // Default wrapper configuration
- wrapper : {
- removable : false,
- stylable : ['background','background-color','background-image', 'background-repeat','background-attachment','background-position'],
- movable : false,
- badgable : false,
- },
-
- // Could be used for default components
- components : {},
-
- rte : {},
-
- em : {},
-
- // Class for new image component
- imageCompClass : 'fa fa-picture-o',
-
- // Open assets manager on create of image component
- oAssetsOnCreate : true,
- };
-});
-define('DomComponents/model/Components',[ 'backbone', 'require'],
- function (Backbone, require) {
- /**
- * @class Components
- * */
-
- return Backbone.Collection.extend({
-
- initialize: function(models, opt){
-
- this.model = function(attrs, options) {
- var model;
-
- switch(attrs.type){
-
- case 'text':
- if(!this.mComponentText)
- this.mComponentText = require("./ComponentText");
- model = new this.mComponentText(attrs, options);
- break;
-
- case 'image':
- if(!this.mComponentImage)
- this.mComponentImage = require("./ComponentImage");
- model = new this.mComponentImage(attrs, options);
- break;
-
- default:
- if(!this.mComponent)
- this.mComponent = require("./Component");
- model = new this.mComponent(attrs, options);
-
- }
-
- return model;
- };
-
- },
-
- });
-});
-
-define('DomComponents/model/Component',['backbone','./Components'],
- function (Backbone, Components) {
- /**
- * @class Component
- * */
- return Backbone.Model.extend({
-
- defaults: {
- tagName : 'div',
- type : '',
- editable : false,
- removable : true,
- movable : true,
- droppable : true,
- badgable : true,
- stylable : true,
- status : '',
- previousModel : '',
- content : '',
- style : {},
- attributes : {},
- },
-
- initialize: function(options) {
- this.defaultC = options.components || [];
- this.components = new Components(this.defaultC);
- this.set('components', this.components);
- },
-
- /**
- * Get name of the component
- *
- * @return string
- * */
- getName: function(){
- if(!this.name){
- var id = this.cid.replace(/\D/g,''),
- type = this.get('type');
- this.name = type.charAt(0).toUpperCase() + type.slice(1) + 'Box' + id;
- }
- return this.name;
- },
-
- });
-});
-
-define('DomComponents/model/ComponentText',['./Component'],
- function (Component) {
- /**
- * @class ComponentText
- * */
- return Component.extend({
-
- defaults: _.extend({}, Component.prototype.defaults, {
- content : '',
- droppable : false,
- }),
-
- });
-});
-
-define('DomComponents/model/ComponentImage',['./Component'],
- function (Component) {
- /**
- * @class ComponentImage
- * */
- return Component.extend({
-
- defaults: _.extend({}, Component.prototype.defaults, {
- src : '',
- droppable : false,
- }),
-
- });
-});
-
-define('DomComponents/view/ComponentsView',['backbone','require'],
-function(Backbone, require) {
- /**
- * @class ComponentsView
- * */
- return Backbone.View.extend({
-
- initialize: function(o) {
- this.config = o.config;
- this.listenTo( this.collection, 'add', this.addTo );
- this.listenTo( this.collection, 'reset', this.render );
- },
-
- /**
- * Add to collection
- * @param {Object} Model
- *
- * @return void
- * */
- addTo: function(model){
- var i = this.collection.indexOf(model);
- this.addToCollection(model, null, i);
- },
-
- /**
- * Add new object to collection
- * @param {Object} Model
- * @param {Object} Fragment collection
- * @param {Integer} Index of append
- *
- * @return {Object} Object rendered
- * */
- addToCollection: function(model, fragmentEl, index){
- if(!this.compView)
- this.compView = require('./ComponentView');
- var fragment = fragmentEl || null,
- viewObject = this.compView;
-
- switch(model.get('type')){
- case 'text':
- if(!this.compViewText)
- this.compViewText = require('./ComponentTextView');
- viewObject = this.compViewText;
- break;
- case 'image':
- if(!this.compViewImage)
- this.compViewImage = require('./ComponentImageView');
- viewObject = this.compViewImage;
- break;
- }
-
- var view = new viewObject({
- model : model,
- config : this.config,
- });
- var rendered = view.render().el;
-
- if(fragment){
- fragment.appendChild(rendered);
- }else{
- var p = this.$parent;
- if(typeof index != 'undefined'){
- var method = 'before';
- // If the added model is the last of collection
- // need to change the logic of append
- if(p.children().length == index){
- index--;
- method = 'after';
- }
- // In case the added is new in the collection index will be -1
- if(index < 0){
- p.append(rendered);
- }else
- p.children().eq(index)[method](rendered);
- }else{
- p.append(rendered);
- }
- }
-
- return rendered;
- },
-
- render: function($p) {
- var fragment = document.createDocumentFragment();
- this.$parent = $p || this.$el;
- this.$el.empty();
- this.collection.each(function(model){
- this.addToCollection(model, fragment);
- },this);
- this.$el.append(fragment);
-
- return this;
- }
-
- });
-});
-define('DomComponents/view/ComponentView',['backbone', './ComponentsView'],
- function (Backbone, ComponentsView) {
- /**
- * @class ComponentView
- * */
- return Backbone.View.extend({
-
- className : function(){ //load classes from model
- return this.getClasses();
- },
-
- tagName: function(){ //load tagName from model
- return this.model.get('tagName');
- },
-
- initialize: function(opt){
- this.config = opt.config;
- this.components = this.model.get('components');
- this.attr = this.model.get("attributes");
- this.classe = this.attr.class || [];
- this.listenTo( this.model, 'destroy remove', this.remove);
- this.listenTo( this.model, 'change:style', this.updateStyle);
- this.listenTo( this.model, 'change:attributes', this.updateAttributes);
- this.$el.data("model", this.model);
- this.$el.data("model-comp", this.components);
- },
-
- /**
- * Get classes from attributes.
- * This method is called before initialize
- *
- * @return {Array}|null
- * */
- getClasses: function(){
- var attr = this.model.get("attributes"),
- classes = attr['class'] || [];
- if(classes.length){
- return classes.join(" ");
- }else
- return null;
- },
-
- /**
- * Update attributes
- *
- * @return void
- * */
- updateAttributes: function(){
- var attributes = {},
- attr = this.model.get("attributes");
- for(var key in attr) {
- if(attr.hasOwnProperty(key))
- attributes[key] = attr[key];
- }
- // Update src
- if(this.model.get("src"))
- attributes.src = this.model.get("src");
-
- attributes.style = this.getStyleString();
-
- this.$el.attr(attributes);
- },
-
- /**
- * Update style attribute
- *
- * @return void
- * */
- updateStyle: function(){
- this.$el.attr('style', this.getStyleString());
- },
-
- /**
- * Return style string
- *
- * @return {String}
- * */
- getStyleString: function(){
- var style = '';
- this.style = this.model.get('style');
- for(var key in this.style) {
- if(this.style.hasOwnProperty(key))
- style += key + ':' + this.style[key] + ';';
- }
-
- return style;
- },
-
- /**
- * Update classe attribute
- *
- * @return void
- * */
- updateClasses: function(){
- if(this.classe.length)
- this.$el.attr('class', this.classe.join(" "));
- },
-
- /**
- * Reply to event call
- * @param object Event that generated the request
- * */
- eventCall: function(event){
- event.viewResponse = this;
- },
-
- render: function() {
- this.updateAttributes();
- this.$el.html(this.model.get('content'));
- var view = new ComponentsView({
- collection : this.components,
- config : this.config,
- });
- this.$components = view;
- // With childNodes lets avoid wrapping 'div'
- this.$el.append(view.render(this.$el).el.childNodes);
- return this;
- },
-
- });
-});
-
-define('DomComponents/view/ComponentImageView',['backbone', './ComponentView'],
- function (Backbone, ComponentView) {
- /**
- * @class ComponentImageView
- * */
-
- return ComponentView.extend({
-
- tagName : 'img',
-
- events : {
- 'dblclick' : 'openModal',
- },
-
- initialize: function(o){
- ComponentView.prototype.initialize.apply(this, arguments);
- this.listenTo( this.model, 'change:src', this.updateSrc);
- this.listenTo( this.model, 'dblclick', this.openModal);
- this.classEmpty = this.config.stylePrefix + 'image-placeholder ' + this.config.imageCompClass;
-
- if(!this.model.get('src'))
- this.$el.attr('class', this.classEmpty);
-
- if(this.config.modal)
- this.modal = this.config.modal;
-
- if(this.config.am)
- this.am = this.config.am;
- },
-
- /**
- * Update src attribute
- *
- * @return void
- * */
- updateSrc: function(){
- this.$el.attr('src',this.model.get("src"));
- },
-
- /**
- * Open dialog for image changing
- * @param {Object} e Event
- *
- * @return void
- * */
- openModal: function(e){
- var that = this;
- if(this.modal && this.am){
- this.modal.setTitle('Select image');
- this.modal.setContent(this.am.render());
- this.am.setTarget(this.model);
- this.modal.show();
- this.am.onSelect(function(){
- that.modal.hide();
- that.am.setTarget(null);
- });
- }
- },
-
- render: function() {
- this.updateAttributes();
- return this;
- },
- });
-});
-
-define('DomComponents/view/ComponentTextView',['backbone', './ComponentView'],
- function (Backbone, ComponentView) {
- /**
- * @class ComponentTextView
- * */
-
- return ComponentView.extend({
-
- events: {
- 'dblclick' : 'enableEditing',
- },
-
- initialize: function(o){
- ComponentView.prototype.initialize.apply(this, arguments);
- _.bindAll(this,'disableEditing');
- this.listenTo( this.model, 'focus', this.enableEditing);
- if(this.config.rte){
- this.rte = this.config.rte;
- }
- },
-
- /**
- * Enable this component to be editable,
- * load also the mini toolbar for quick editing
- * @param Event
- * */
- enableEditing: function(e){
- if(this.rte){
- var $e = this.config.em.get('$editor');
- if(!this.$wrapper && $e.length)
- this.$wrapper = $e.find('#'+this.config.wrapperId);
- this.rte.bind(this, this.$wrapper);
- }
- $(document).on('mousedown', this.disableEditing); //Close edit mode
- this.$el.on('mousedown', this.disablePropagation); //Avoid closing edit mode on component click
- },
-
- /**
- * Disable this component to be editable
- * @param Event
- * */
- disableEditing: function(e){
- if(this.rte){
- this.rte.unbind(this);
- }
- $(document).off('mousedown', this.disableEditing);
- this.$el.off('mousedown',this.disablePropagation);
- this.updateContents();
- },
-
- /** Isolate disable propagation method
- * @param Event
- * */
- disablePropagation: function(e){
- e.stopPropagation();
- },
-
- /**
- * Update contents of the element
- *
- * @return void
- **/
- updateContents : function(){
- this.model.set('content', this.$el.html());
- },
-
- render: function() {
- this.updateAttributes();
- this.$el.html(this.model.get('content'));
- return this;
- },
- });
-});
-
-define('DomComponents/main',['require','./config/config','./model/Component','./model/ComponentText','./model/ComponentImage','./view/ComponentView','./view/ComponentImageView','./view/ComponentTextView'],function(require) {
- /**
- * @class Components
- * @param {Object} Configurations
- *
- * @return {Object}
- * */
- function Components(config)
- {
- var c = config || {},
- defaults = require('./config/config'),
- Component = require('./model/Component'),
- ComponentText = require('./model/ComponentText'),
- ComponentImage = require('./model/ComponentImage'),
- ComponentView = require('./view/ComponentView'),
- ComponentImageView = require('./view/ComponentImageView'),
- ComponentTextView = require('./view/ComponentTextView');
-
- // Set default options
- for (var name in defaults) {
- if (!(name in c))
- c[name] = defaults[name];
- }
-
- if(!c.wrapper.attributes)
- c.wrapper.attributes = {};
- c.wrapper.attributes.id = 'wrapper';
-
- if(!c.wrapper.style)
- c.wrapper.style = {};
- c.wrapper.style.position = 'relative';
-
- this.component = new Component(c.wrapper);
- var obj = {
- model : this.component,
- config : c,
- };
-
- this.ComponentView = new ComponentView(obj);
- }
-
- Components.prototype = {
-
- render : function(){
- return this.ComponentView.render().$el;
- },
-
- getComponent : function(){
- return this.component;
- },
- };
-
- return Components;
-});
-define('DomComponents', ['DomComponents/main'], function (main) { return main; });
-
-define('Panels/config/config',[],function () {
- return {
- stylePrefix : 'pn-',
-
- // Default panels
- defaults : [],
-
- // Editor model
- em : null,
-
- // Delay before show children buttons (in milliseconds)
- delayBtnsShow : 300,
- };
-});
-define('Panels/model/Button',[ 'backbone','require'],
- function (Backbone, require) {
- /**
- * @class Button
- * */
- return Backbone.Model.extend({
-
- defaults :{
- id : '',
- className : '',
- command : '',
- context : '',
- buttons : [],
- attributes : {},
- active : false,
- },
-
- initialize: function(options) {
- if(this.get('buttons').length){
- var Buttons = require('./Buttons');
- this.set('buttons', new Buttons(this.get('buttons')) );
- }
- },
-
- });
-});
-
-define('Panels/model/Buttons',[ 'backbone','./Button'],
- function (Backbone, Button) {
- /**
- * @class Buttons
- * */
- return Backbone.Collection.extend({
-
- model: Button,
-
- /**
- * Deactivate all buttons, except one passed
- * @param {Object} except Model to ignore
- * @param {Boolean} r Recursive flag
- *
- * @return void
- * */
- deactivateAllExceptOne: function(except, r){
- this.forEach(function(model, index) {
- if(model !== except){
- model.set('active', false);
- if(r && model.get('buttons').length)
- model.get('buttons').deactivateAllExceptOne(except,r);
- }
- });
- },
-
- /**
- * Deactivate all buttons
- * @param {String} context Context string
- *
- * @return void
- * */
- deactivateAll: function(context){
- this.forEach(function(model, index) {
- if( model.get('context') == context ){
- model.set('active', false);
- if(model.get('buttons').length)
- model.get('buttons').deactivateAll(context);
- }
- });
- },
-
- });
-});
-
-define('Panels/model/Panel',[ 'backbone','./Buttons'],
- function (Backbone, Buttons) {
- /**
- * @class Panel
- * */
- return Backbone.Model.extend({
-
- defaults :{
- id : '',
- content : '',
- visible : true,
- buttons : [],
- },
-
- initialize: function(options) {
- this.btn = this.get('buttons') || [];
- this.buttons = new Buttons(this.btn);
- this.set('buttons', this.buttons);
- },
-
- });
-});
-
-define('Panels/model/Panels',[ 'backbone','./Panel'],
- function (Backbone, Panel) {
- /**
- * @class Panels
- * */
- return Backbone.Collection.extend({
-
- model: Panel,
-
- });
-});
-
-define('Panels/view/ButtonView',['backbone','require'],
-function(Backbone, require) {
- /**
- * @class ButtonView
- * */
- return Backbone.View.extend({
-
- tagName : 'span',
-
- events : { 'click' : 'clicked' },
-
- initialize: function(o){
- _.bindAll(this, 'startTimer', 'stopTimer', 'showButtons', 'hideButtons','closeOnKeyPress');
- this.config = o.config;
- this.em = this.config.em || {};
- this.pfx = this.config.stylePrefix;
- this.id = this.pfx + this.model.get('id');
- this.className = this.pfx + 'btn ' + this.model.get('className');
- this.activeCls = this.pfx + 'active';
- this.btnsVisCls = this.pfx + 'visible';
- this.parentM = o.parentM || null;
- this.listenTo(this.model, 'change:active updateActive', this.updateActive);
- this.listenTo(this.model, 'checkActive', this.checkActive);
- this.listenTo(this.model, 'change:bntsVis', this.updateBtnsVis);
- this.listenTo(this.model, 'change:attributes', this.updateAttributes);
- this.listenTo(this.model, 'change:className', this.updateClassName);
-
- if(this.model.get('buttons').length){
- this.$el.on('mousedown', this.startTimer);
- this.$el.append($('
',{class: this.pfx + 'arrow-rd'}));
- }
-
- if(this.em)
- this.commands = this.em.get('Commands');
- },
-
- /**
- * Updates class name of the button
- *
- * @return void
- * */
- updateClassName: function()
- {
- this.$el.attr('class', this.pfx + 'btn ' + this.model.get('className'));
- },
-
- /**
- * Updates attributes of the button
- *
- * @return void
- * */
- updateAttributes: function()
- {
- this.$el.attr(this.model.get("attributes"));
- },
-
- /**
- * Updates visibility of children buttons
- *
- * @return void
- * */
- updateBtnsVis: function()
- {
- if(!this.$buttons)
- return;
-
- if(this.model.get('bntsVis'))
- this.$buttons.addClass(this.btnsVisCls);
- else
- this.$buttons.removeClass(this.btnsVisCls);
- },
-
- /**
- * Start timer for showing children buttons
- *
- * @return void
- * */
- startTimer: function()
- {
- this.timeout = setTimeout(this.showButtons, this.config.delayBtnsShow);
- $(document).on('mouseup', this.stopTimer);
- },
-
- /**
- * Stop timer for showing children buttons
- *
- * @return void
- * */
- stopTimer: function()
- {
- $(document).off('mouseup', this.stopTimer);
- if(this.timeout)
- clearTimeout(this.timeout);
- },
-
- /**
- * Show children buttons
- *
- * @return void
- * */
- showButtons: function()
- {
- clearTimeout(this.timeout);
- this.model.set('bntsVis', true);
- $(document).on('mousedown', this.hideButtons);
- $(document).on('keypress', this.closeOnKeyPress);
- },
- /**
- * Hide children buttons
- *
- * @return void
- * */
- hideButtons: function(e)
- {
- if(e){ $(e.target).trigger('click'); }
- this.model.set('bntsVis', false);
- $(document).off('mousedown', this.hideButtons);
- $(document).off('keypress', this.closeOnKeyPress);
- },
-
- /**
- * Close buttons on ESC key press
- * @param {Object} e Event
- *
- * @return void
- * */
- closeOnKeyPress: function(e)
- {
- var key = e.which || e.keyCode;
- if(key == 27)
- this.hideButtons();
- },
-
- /**
- * Update active status of the button
- *
- * @return void
- * */
- updateActive: function(){
- var command = null;
-
- if(this.commands)
- command = this.commands.get(this.model.get('command'));
-
- if(this.model.get('active')){
-
- this.model.collection.deactivateAll(this.model.get('context'));
- this.model.set('active', true, { silent: true }).trigger('checkActive');
-
- if(this.parentM)
- this.parentM.set('active', true, { silent: true }).trigger('checkActive');
-
- if(command)
- command.run(this.em, this.model);
- }else{
- this.$el.removeClass(this.activeCls);
-
- this.model.collection.deactivateAll(this.model.get('context'));
-
- if(this.parentM)
- this.parentM.set('active', false, { silent: true }).trigger('checkActive');
-
- if(command)
- command.stop(this.em, this.model);
- }
- },
-
- /**
- * Update active style status
- *
- * @return void
- * */
- checkActive: function(){
- if(this.model.get('active'))
- this.$el.addClass(this.activeCls);
- else
- this.$el.removeClass(this.activeCls);
- },
-
- /**
- * Triggered when button is clicked
- * @param {Object} e Event
- *
- * @return void
- * */
- clicked: function(e)
- {
- if(this.model.get('bntsVis') )
- return;
-
- if(this.parentM)
- this.swapParent();
-
- this.model.set('active', !this.model.get('active'));
- },
-
- /**
- * Updates parent model swapping properties
- *
- * @return void
- * */
- swapParent: function()
- {
- this.parentM.collection.deactivateAll(this.model.get('context'));
- this.parentM.set('attributes', this.model.get('attributes'));
- this.parentM.set('options', this.model.get('options'));
- this.parentM.set('command', this.model.get('command'));
- this.parentM.set('className', this.model.get('className'));
- this.parentM.set('active', true, { silent: true }).trigger('checkActive');
- },
-
- render: function()
- {
- this.updateAttributes();
- this.$el.attr('class', this.className);
-
- if(this.model.get('buttons').length){
- var btnsView = require('./ButtonsView'); //Avoid Circular Dependencies
- var view = new btnsView({
- collection : this.model.get('buttons'),
- config : this.config,
- parentM : this.model
- });
- this.$buttons = view.render().$el;
- this.$buttons.append($('
',{class: this.pfx + 'arrow-l'}));
- this.$el.append(this.$buttons); //childNodes avoids wrapping 'div'
- }
-
- return this;
- },
-
- });
-});
-define('Panels/view/ButtonsView',['backbone','./ButtonView'],
- function (Backbone, ButtonView) {
- /**
- * @class ButtonsView
- * */
- return Backbone.View.extend({
-
- initialize: function(o) {
- this.opt = o;
- this.config = o.config;
- this.pfx = o.config.stylePrefix;
- this.parentM = o.parentM || null;
- this.listenTo( this.collection, 'add', this.addTo );
- this.listenTo( this.collection, 'reset', this.render );
- this.className = this.pfx + 'buttons';
- },
-
- /**
- * Add to collection
- * @param Object Model
- *
- * @return Object
- * */
- addTo: function(model){
- this.addToCollection(model);
- },
-
- /**
- * Add new object to collection
- * @param Object Model
- * @param Object Fragment collection
- *
- * @return Object Object created
- * */
- addToCollection: function(model, fragmentEl){
- var fragment = fragmentEl || null;
- var viewObject = ButtonView;
-
- var view = new viewObject({
- model : model,
- config : this.config,
- parentM : this.parentM
- });
- var rendered = view.render().el;
-
- if(fragment){
- fragment.appendChild(rendered);
- }else{
- this.$el.append(rendered);
- }
-
- return rendered;
- },
-
- render: function() {
- var fragment = document.createDocumentFragment();
- this.$el.empty();
-
- this.collection.each(function(model){
- this.addToCollection(model, fragment);
- }, this);
-
- this.$el.append(fragment);
- this.$el.attr('class', _.result(this, 'className'));
- return this;
- }
- });
-});
-
-define('Panels/view/PanelView',['backbone','./ButtonsView'],
-function(Backbone, ButtonsView) {
- /**
- * @class PanelView
- * */
- return Backbone.View.extend({
-
- initialize: function(o){
- this.config = o.config;
- this.pfx = this.config.stylePrefix;
- this.buttons = this.model.get('buttons');
- this.className = this.pfx + 'panel';
- this.id = this.pfx + this.model.get('id');
- this.listenTo(this.model, 'change:appendContent', this.appendContent);
- this.listenTo(this.model, 'change:content', this.updateContent);
- },
-
- /**
- * Append content of the panel
- * */
- appendContent: function()
- {
- this.$el.append(this.model.get('appendContent'));
- },
-
- /**
- * Update content
- * */
- updateContent: function()
- {
- this.$el.html(this.model.get('content'));
- },
-
-
- render: function() {
- this.$el.attr('class', _.result(this, 'className'));
- this.$el.attr('id', this.id);
- if(this.buttons.length){
- var buttons = new ButtonsView({
- collection : this.buttons,
- config : this.config,
- });
- this.$el.append(buttons.render().el);
- }
- this.$el.append(this.model.get('content'));
- return this;
- },
-
- });
-});
-define('Panels/view/PanelsView',['backbone','./PanelView'],
- function (Backbone, PanelView) {
- /**
- * @class ItemsView
- * */
- return Backbone.View.extend({
-
- initialize: function(o) {
- this.opt = o;
- this.config = o.config;
- this.pfx = o.config.stylePrefix;
- this.listenTo( this.collection, 'add', this.addTo );
- this.listenTo( this.collection, 'reset', this.render );
- this.className = this.pfx + 'panels';
- },
-
- /**
- * Add to collection
- * @param Object Model
- *
- * @return Object
- * */
- addTo: function(model){
- this.addToCollection(model);
- },
-
- /**
- * Add new object to collection
- * @param Object Model
- * @param Object Fragment collection
- * @param integer Index of append
- *
- * @return Object Object created
- * */
- addToCollection: function(model, fragmentEl){
- var fragment = fragmentEl || null;
- var viewObject = PanelView;
-
- var view = new viewObject({
- model : model,
- config : this.config,
- });
- var rendered = view.render().el;
-
- if(fragment){
- fragment.appendChild(rendered);
- }else{
- this.$el.append(rendered);
- }
-
- return rendered;
- },
-
- render: function() {
- var fragment = document.createDocumentFragment();
- this.$el.empty();
-
- this.collection.each(function(model){
- this.addToCollection(model, fragment);
- }, this);
-
- this.$el.append(fragment);
- this.$el.attr('class', _.result(this, 'className'));
- return this;
- }
- });
-});
-
-define('Panels/main',['require','./config/config','./model/Panels','./view/PanelsView'],function(require) {
- /**
- * @class Panel
- * @param {Object} Configurations
- *
- * @return {Object}
- * */
- function Panel(config)
- {
- var c = config || {},
- defaults = require('./config/config'),
- Panels = require('./model/Panels'),
- PanelsView = require('./view/PanelsView');
-
- // Set default options
- for (var name in defaults) {
- if (!(name in c))
- c[name] = defaults[name];
- }
-
- this.panels = new Panels(c.defaults);
- var obj = {
- collection : this.panels,
- config : c,
- };
-
- this.PanelsView = new PanelsView(obj);
- }
-
- Panel.prototype = {
-
- getPanels : function(){
- return this.panels;
- },
-
- addPanel : function(obj){
- return this.panels.add(obj);
- },
-
- getPanel : function(id){
- var res = this.panels.where({id: id});
- return res.length ? res[0] : null;
- },
-
- addButton : function(panelId, obj){
- var pn = this.getPanel(panelId);
- return pn ? pn.get('buttons').add(obj) : null;
- },
-
- getButton : function(panelId, id){
- var pn = this.getPanel(panelId);
- if(pn){
- var res = pn.get('buttons').where({id: id});
- return res.length ? res[0] : null;
- }
- return null;
- },
-
- active : function(){
- this.getPanels().each(function(p){
- p.get('buttons').each(function(btn){
- if(btn.get('active'))
- btn.trigger('updateActive');
- });
- });
- },
-
- render : function(){
- return this.PanelsView.render().el;
- },
- };
-
- return Panel;
-});
-define('Panels', ['Panels/main'], function (main) { return main; });
-
-define('editor/model/Editor',[
- 'backbone',
- 'backboneUndo',
- 'keymaster',
- 'AssetManager',
- 'StorageManager',
- 'ModalDialog',
- 'CodeManager',
- 'Commands',
- 'Canvas',
- 'RichTextEditor',
- 'DomComponents',
- 'Panels'],
- function(
- Backbone,
- UndoManager,
- Keymaster,
- AssetManager,
- StorageManager,
- ModalDialog,
- CodeManager,
- Commands,
- Canvas,
- RichTextEditor,
- DomComponents,
- Panels
- ){
- return Backbone.Model.extend({
-
- defaults:{
- selectedComponent: null,
- changesCount: 0,
- },
-
- initialize: function(c)
- {
- this.config = c;
- this.compName = this.config.storagePrefix + 'components' + this.config.id;
- this.set('Config', c);
-
- this.initStorage();
- this.initModal();
- this.initAssetManager();
- this.initCodeManager();
- this.initCommands();
- this.initPanels();
- this.initRichTextEditor();
- this.initComponents();
- this.initCanvas();
- this.initUndoManager();
-
- this.on('change:selectedComponent', this.componentSelected, this);
- },
-
- /**
- * Initialize components
- * */
- initComponents: function()
- {
- var cfg = this.config.components,
- comp = this.loadComponentsTree(),
- cmpStylePfx = cfg.stylePrefix || 'comp-';
-
- cfg.stylePrefix = this.config.stylePrefix + cmpStylePfx;
- if(comp)
- cfg.wrapper = comp;
-
- if(this.rte)
- cfg.rte = this.rte;
-
- if(this.modal)
- cfg.modal = this.modal;
-
- if(this.am)
- cfg.am = this.am;
-
- cfg.em = this;
-
- this.cmp = new DomComponents(cfg);
-
- if(this.stm.isAutosave()){ // TODO Currently doesn't listen already created models
- this.updateComponents( this.cmp.getComponent(), null, { avoidStore : 1 });
- }
-
- this.set('Components', this.cmp);
- },
-
- /**
- * Initialize canvas
- * */
- initCanvas: function()
- {
- var cfg = this.config.canvas,
- pfx = cfg.stylePrefix || 'cv-';
- cfg.stylePrefix = this.config.stylePrefix + pfx;
- cfg.canvasId = this.config.idCanvas;
- this.cv = new Canvas(this.config.canvas);
-
- if(this.cmp)
- this.cv.setWrapper(this.cmp);
-
- this.set('Canvas', this.cv);
- },
-
- /**
- * Initialize rich text editor
- * */
- initRichTextEditor: function()
- {
- var cfg = this.config.rte,
- rteStylePfx = cfg.stylePrefix || 'rte-';
- cfg.stylePrefix = this.config.stylePrefix + rteStylePfx;
- this.rte = new RichTextEditor(cfg);
- this.set('RichTextEditor', this.rte);
- },
-
- /**
- * Initialize storage
- * */
- initStorage: function()
- {
- this.stm = new StorageManager(this.config.storageManager);
- this.stm.loadDefaultProviders().setCurrentProvider(this.config.storageType);
- this.set('StorageManager', this.stm);
- },
-
- /**
- * Initialize asset manager
- * */
- initAssetManager: function()
- {
- var cfg = this.config.assetManager,
- pfx = cfg.stylePrefix || 'am-';
- cfg.stylePrefix = this.config.stylePrefix + pfx;
-
- if(this.stm)
- cfg.stm = this.stm;
-
- this.am = new AssetManager(cfg);
- this.set('AssetManager', this.am);
- },
-
- /**
- * Initialize modal
- * */
- initModal: function()
- {
- var cfg = this.config.modal,
- pfx = cfg.stylePrefix || 'mdl-';
- cfg.stylePrefix = this.config.stylePrefix + pfx;
- this.modal = new ModalDialog(cfg);
- this.modal.render().appendTo('body');
- this.set('Modal', this.modal);
- },
-
- /**
- * Initialize Code Manager
- * */
- initCodeManager: function()
- {
- var cfg = this.config.codeManager,
- pfx = cfg.stylePrefix || 'cm-';
- cfg.stylePrefix = this.config.stylePrefix + pfx;
- this.cm = new CodeManager(cfg);
- this.cm.loadDefaultGenerators().loadDefaultEditors();
- this.set('CodeManager', this.cm);
- },
-
- /**
- * Initialize Commands
- * */
- initCommands: function()
- {
- var cfg = this.config.commands,
- pfx = cfg.stylePrefix || 'com-';
- cfg.stylePrefix = this.config.stylePrefix + pfx;
- cfg.em = this;
- cfg.canvasId = this.config.idCanvas;
- cfg.wrapperId = this.config.idWrapper;
- this.com = new Commands(cfg);
- this.com.loadDefaultCommands();
- this.set('Commands', this.com);
- },
-
- /**
- * Initialize Panels
- * */
- initPanels: function()
- {
- var cfg = this.config.panels,
- pfx = cfg.stylePrefix || 'pn-';
- cfg.stylePrefix = this.config.stylePrefix + pfx;
- cfg.em = this;
- this.pn = new Panels(cfg);
- this.pn.addPanel({ id: 'views-container'});
- this.set('Panels', this.pn);
- },
-
- /**
- * Initialize Undo manager
- * */
- initUndoManager: function(){
- if(this.cmp && this.config.undoManager){
- var backboneUndo = new Backbone.UndoManager({
- register: [this.cmp.getComponent().get('components')],
- track: true
- });
- key('⌘+z, ctrl+z', function(){
- backboneUndo.undo();
- });
- key('⌘+shift+z, ctrl+shift+z', function(){
- backboneUndo.redo();
- });
-
- Backbone.UndoManager.removeUndoType("change");
- var beforeCache;
- Backbone.UndoManager.addUndoType("change:style", {
- "on": function (model, value, opt) {
- if(!beforeCache)
- beforeCache = model.toJSON();
- if (opt && opt.avoidStore) {
- return;
- } else {
- var obj = {
- "object": model,
- "before": beforeCache,
- "after": model.toJSON()
- };
- beforeCache = null;
- return obj;
- }
- },
- "undo": function (model, bf, af, opt) {
- model.set(bf);
- },
- "redo": function (model, bf, af, opt) {
- model.set(af);
- }
- });
-
- //TODO when, for example, undo delete cant redelete it, so need to
- //recall 'remove command'
- }
- },
-
- /**
- * Triggered when components are updated
- * */
- componentsUpdated: function()
- {
- var updatedCount = this.get('changesCount') + 1;
- this.set('changesCount', updatedCount);
- if(this.stm.isAutosave() && updatedCount < this.stm.getChangesBeforeSave()){
- return;
- }
- this.storeComponentsTree();
- this.set('changesCount', 0 );
- },
-
- /**
- * Callback on component selection
- * @param {Object} Model
- * @param {Mixed} New value
- * @param {Object} Options
- *
- * */
- componentSelected: function(model, val, options)
- {
- if(!this.get('selectedComponent'))
- this.trigger('deselect-comp');
- else
- this.trigger('select-comp',[model,val,options]);
- },
-
- /**
- * Load components from storage
- *
- * @return {Object}
- * */
- loadComponentsTree: function(){
- var result = null;
- try{
- result = JSON.parse(this.stm.load(this.compName));
- }catch(err){
- console.warn("Error encountered while parsing JSON response");
- }
- return result;
- },
-
- /**
- * Save components to storage
- *
- * @return void
- * */
- storeComponentsTree: function(){
- var wrp = this.cmp.getComponent();
- if(wrp && this.cm){
- var res = this.cm.getCode(wrp, 'json');
- this.stm.store(this.compName, JSON.stringify(res));
- }
- },
-
- /**
- * Triggered when components are updated
- * @param {Object} model
- * @param {Mixed} val Value
- * @param {Object} opt Options
- *
- * */
- updateComponents: function(model, val, opt){
- var comps = model.get('components'),
- avSt = opt ? opt.avoidStore : 0;
-
- // Call stopListening for not creating nested listenings
- this.stopListening(comps, 'add', this.updateComponents);
- this.stopListening(comps, 'remove', this.rmComponents);
- this.listenTo(comps, 'add', this.updateComponents);
- this.listenTo(comps, 'remove', this.rmComponents);
-
- this.stopListening(model, 'change:style change:content', this.updateComponents);
- this.listenTo(model, 'change:style change:content', this.updateComponents);
-
- if(!avSt)
- this.componentsUpdated();
- },
-
- /**
- * Triggered when some component is removed updated
- * @param {Object} model
- * @param {Mixed} val Value
- * @param {Object} opt Options
- *
- * */
- rmComponents: function(model, val, opt){
- var avSt = opt ? opt.avoidStore : 0;
-
- if(!avSt)
- this.componentsUpdated();
- }
-
- });
- });
-
-define('editor/view/EditorView',['backbone'],
-function(Backbone){
- /**
- * @class EditorView
- * */
- return Backbone.View.extend({
-
- initialize: function() {
- this.cv = this.model.get('Canvas');
- this.pn = this.model.get('Panels');
- this.className = this.model.config.stylePrefix + 'editor';
- },
-
- render: function(){
- this.$el.empty();
-
- this.$cont = $('body ' + this.model.config.container);
-
- this.model.set('$editor', this.$el);
-
- if(this.cv)
- this.$el.append(this.cv.render());
-
- if(this.pn)
- this.$el.append(this.pn.render());
-
- this.$el.attr('class', this.className);
-
- this.$cont.html(this.$el);
-
- if(this.pn)
- this.pn.active();
-
- return this;
- }
- });
-});
-define('editor/main',['require','./config/config','./model/Editor','./view/EditorView'],function (require){
- /**
- * @class Grapes
- * @param {Object} Configurations
- *
- * @return {Object}
- * */
- var Grapes = function(config)
- {
- var c = config || {},
- defaults = require('./config/config'),
- Editor = require('./model/Editor'),
- EditorView = require('./view/EditorView');
-
- for (var name in defaults) {
- if (!(name in c))
- c[name] = defaults[name];
- }
-
- this.editor = new Editor(c);
- var obj = {
- model : this.editor,
- config : c,
- };
-
- this.editorView = new EditorView(obj);
- };
-
- Grapes.prototype = {
-
- render : function()
- {
- return this.editorView.render().$el;
- }
-
- };
-
- return Grapes;
-});
-
-require(['src/config/require-config.js'], function() {
-
- require(['editor/main'],function (g){
- return g;
- });
-
-});
-define("main", function(){});
-
-return require('editor/main'); }));
\ No newline at end of file
diff --git a/styles/main.css b/styles/main.css
deleted file mode 100644
index c9497f664..000000000
--- a/styles/main.css
+++ /dev/null
@@ -1,761 +0,0 @@
-body{
- background-color:#eee;
- font-family: Helvetica, sans-serif;
- margin: 0;
-}
-html,body,#wte-app,#editor,#canvas{height: 100%;}
-.clear{clear:both}
-.no-select{
- -moz-user-select: none;
- -khtml-user-select: none;
- -webkit-user-select: none;
- -ms-user-select: none;
- -o-user-select: none;
- user-select: none;
-}
-#wte-app{height: 100%; min-width: 1250px;}
-#editor{
- position:relative;
- border: 3px solid #4b4b4b;
- border-left:none; border-right:none;
- box-sizing: border-box;
-}
-#canvas {
- position: absolute;
- width: 80%;
- height: 100%;
- top: 0; left: 3.5%;
- overflow: auto;
- z-index:1;
- /*********TEST**********outline: 2px dashed #555; outline-offset: -2px;*/
-}
-#canvas *{box-sizing: border-box;}
-/************* WRAPPER ****************/
-#canvas > div {
- height: 100%;
- overflow: auto;
- width: 100%;
-}
-/************* RTE ****************/
-#canvas-overlay{
- position: absolute;
- height: 100%; width:100%;
- z-index:1; top:0; left:0;
-}
-#commands.panel {
- min-width: 35px;
- height: 100%;
- z-index:3;
-}
-#options.panel{ z-index:4; bottom: 0;}
-#views.panel {
- width: 16.5%;
- font-weight: lighter;
- color: #fff;
- right:0; top:0;
- z-index: 3;
- height: 100%;
- padding:0;
-}
-#views.panel .c{height:100%}
-#commands.panel, #options.panel {width: 3.5%; left:0;}
-#options .c { display: table; margin: 0 auto; }
-
-/*********TEST**********/
-body.dragging, body.dragging * { cursor: move !important;}
-.dragged { position: absolute; opacity: 0.5; z-index: 2000;}
-ol.example li.placeholder {position: relative;}
-ol.example li.placeholder:before {position: absolute;}
-/*********END-TEST**********/
-.view-components #canvas div {/*highlights*/
- /*border: 0.1px dashed #888; margin: -0.1px; override margin properties*/
- outline: 1px dashed #888; outline-offset: -2px;
- box-sizing: border-box;
- /*-moz-user-select: none;
- -khtml-user-select: none;
- -webkit-user-select: none;
- -ms-user-select: none;
- -o-user-select: none;
- user-select: none;*/
-}
-.no-dots, .ui-resizable-handle{ border: none !important; margin:0 !important; outline: none !important; }
-body #canvas .hover-component, body #canvas .hover-delete-component, body #canvas .hover-move-component{ outline: 1px solid #3b97e3;}
-body #canvas .hover-delete-component{
- outline: 2px solid #DD3636;/*f46161*/
- opacity: 0.5;
- filter: alpha(opacity=50);
-}
-body #canvas .hover-move-component{ outline: 3px solid #ffca6f;}
-body #canvas .selected-component{
- /*border: 3px solid #3b97e3; /*First was: outline: ...; outline-offset: -2px; changed after strange artefacts on FF */
- outline: 3px solid #3b97e3;
-}
-.panel {
- background-color: #4b4b4b;
- display: inline-block;
- padding: 5px;
- position:absolute;
- box-sizing: border-box;
- z-index:2;
-}
-.panel .btn {
- background-color: transparent;
- border:none;
- display: block;
- height: 35px;
- width: 35px;
- cursor:pointer;
- background-repeat: no-repeat;
- background-position:center;
- border-radius: 2px;
- opacity: 0.85;
- filter: alpha(opacity=85);
-}
-.panel .btn.expand {
- background-size: 100% auto;
- display: inline;
- margin-right: 5px;
- padding: 0 7px 0 0;
-}
-.btn {position:relative;}
-.btn .wte-buttons{
- background-color:#4b4b4b;
- border-radius: 2px;
- position:absolute;
- padding: 5px;
- display:none;
- left:50px;
-}
-.btn .wte-buttons.visible{ display:block; }
-.btn .btn-arrow {
- border-bottom: 5px solid white;
- border-left: 5px solid transparent;
- bottom: 2px; right: 2px;
- position: absolute;
-}
-.btn .btns-arrow {
- border-bottom: 5px solid transparent;
- border-right: 5px solid #4b4b4b;
- border-top: 5px solid transparent;
- left: -5px;
- position: absolute;
- top: 15px;
-}
-.panel .btn:hover{
- opacity:1;
- filter: alpha(opacity=100);
-}
-.panel .btn.active{
- background-color: #3a3a3a;
- box-shadow: inset 0 0 3px #202020;
-}
-.tab {
- background-repeat: no-repeat;
- background-position:center;
- height: 25px; width: 25px;
- padding: 10px 10px 9px;
- float:left; cursor:pointer;
- background-color: #3a3a3a;
-}
-.tabs .tab{ border-left: 1px solid #303030;}
-.tabs .tab:hover{ background-color: #3e3e3e;}
-.tabs .tab.active:hover{ background-color: transparent;}
-.tabs .tab:first-child{border:none}
-.tab.active{ background-color: transparent;}
-.nav-component, .nv-item {
- position: relative;
- background-color: #333333;
-}
-.nv-item #counter {
- font-size: 10px;
- position: absolute;
- right: 10px;
- top: 9px;
-}
-.nv-item #btn-eye{
- background-image: url('../images/icon-eye-o.svg');
- position: absolute;
- top: 0;
- height: 30px;
- width: 30px;
- background-size: 100% auto;
-}
-#style.tabInner .title, .nav-component .title {
- background-color: #3a3a3a;
- font-size: 13px;
- letter-spacing: 1px;
- padding: 7px 10px;
- text-shadow: 0 1px 0 #252525;
- border-bottom: 1px solid #303030;
- border-top: 1px solid #414141;
- cursor:pointer;
-}
-.nav-component .title {font-size: 11px;}
-.nav-component .children .title{ border-left: 1px solid #404040; }
-.nav-component > .children {
- margin-left: 15px;
- display: none;
-}
-.nav-component.open > .children {
- display: block;
-}
-.btn#icon-create-comp{ background-image:url('../images/icon-create2.png');}
-.btn#icon-delete-comp{ background-image:url('../images/icon-delete.png');}
-.btn#icon-move-comp{ background-image:url('../images/icon-move.png');}
-.btn#icon-resize-comp{ background-image:url('../images/icon-resize.png');}
-.btn#icon-select-comp{ background-image:url('../images/icon-select2.png');}
-.btn#icon-text-comp{ background-image:url('../images/icon-text.png');}
-.btn#icon-image-comp{ background-image:url('../images/icon-image.png');}
-.btn#icon-var-comp{ background-image:url('../images/icon-vars3.png');}
-.btn#icon-view-comp{ background-image:url('../images/icon-eye.png');}
-.btn#icon-export{ background-image:url('../images/icon-export2.png');}
-.btn#icon-import{ background-image:url('../images/icon-import.png');}
-.tab#style{ background-image:url('../images/icon-style.png');}
-.tab#navigator{ background-image:url('../images/icon-layers.png');}
-.btn.expand{ background-image:url('../images/arrow-r.png');}
-.open > .title > .expand{ background-image:url('../images/arrow-d.png');}
-.no-chld .expand{ background-image:none !important;}
-#views.panel #tabsInner {
- clear: both;
- border-top: 1px solid #303030;
- padding-top: 5px;
- height:90%; overflow:auto;
-}
-#icon-pick-color {
- border: 3px solid #ddd;
- margin: 15px auto 7px !important;
- border-radius: 0;
- padding: 0;
- box-shadow: none;
- height: 20px; width: 20px;
- background:#3b97e3;
- opacity:1; filter: alpha(opacity=100);
-}
-#icon-export{
- box-shadow: none;
- background-color: transparent;
-}
-#commands .btn, #options .btn { margin: 0 auto 5px; }
-.tempComp{
- background-color: #5b5b5b;
- border: 2px dashed #ccc;
- outline:none !important;
- position: absolute; z-index: 55;
- opacity:0.55;
- filter: alpha(opacity=55);
-}
-.freezed{opacity:0.35; filter: alpha(opacity=35);}
-.placeholder-helper{ position:absolute; }
-.sort-placeholder, .insert-placeholder {
- background-color: #ffca6f;
- padding:3px;
- /*margin: 3px 0 !important;*/
- /*outline: none !important;*/
-}
-.image-placeholder {
- background-image:url('../images/image-placeholder.svg');
- background-size: cover;
- background-color: #eee;
- height: 50px;
- outline: 3px solid #ffca6f;
- outline-offset: -3px;
- width: 50px;
-}
-.insert-placeholder, .change-placeholder{
- background-color: transparent;
- height: 0px; width: 0px;
- padding:0;
-}
-.insert-placeholder .plh-int{
- background-color: #62C462;
- height: 100%; width: 100%;
- pointer-events: 'none';
- padding: 2px;
-}
-.change-placeholder .plh-int{ background-color: #ffca6f; }
-/*********** Helpers *************/
-.componentBadge, .componentBadgeWarn, .componentBadgeWarn2{
- pointer-events: none;
- background-color: #3B97E3; color: #fff;
- padding: 2px 5px;
- position: absolute; z-index: 1;
- font-size: 12px;
-}
-.componentBadgeWarn{ background-color:#DD3636; }
-.componentBadgeWarn2{ background-color:#ffca6f; }
-/********* Style Manager **********/
-#styleManager #sm-head, .utilities .head {
- font-size: 11px;
- padding: 5px 10px;
- border-bottom: 1px solid #3e3e3e;
- text-shadow: 0 1px 0 #3a3a3a;
-}
-.sm-sector{clear:both; border-bottom: 1px solid #303030;}
-.sm-label { margin: 5px 5px 2px 0;}
-.sm-field {
- width: 100%;
- position:relative;
-}
-.sm-field.integer, .sm-field.select, .sm-field.list, .sm-field.color, .sm-field.composite {
- background-color: #333;
- border: 1px solid #292929;
- box-shadow: 1px 1px 0 #575757;
- border-radius: 2px;
- color: #d3d3d3;
- box-sizing: border-box;
- padding: 0 5px;
-}
-.sm-field.composite{
- background-color: transparent;
- border: 1px solid #353535;
-}
-.sm-property.file, .sm-property.composite, .sm-property#background-position{
- width:100%;
-}
-.sm-field.list{
- width:auto;
- padding:0;
- overflow: hidden;
- float:left;
-}
-.sm-field.list .el{
- float:left;
- border-left: 1px solid #252525;
- padding: 5px 0;
- text-shadow: 0 1px 0 #222222;
-}
-.sm-field.list .el:first-child{border:none}
-.sm-field.list .el:hover{background:#3d3d3d}
-.sm-field.list input{display:none;}
-.sm-field.list label{cursor:pointer; padding: 5px;}
-.sm-field.list .radio:checked + label{
- background-color:#5c5c5c;
-}
-.sm-field.select{padding:0;}
-.sm-field input {
- box-sizing: border-box;
- width: 30px; color: #d3d3d3;
- background:none; border:none;
- padding: 3px 0;
-}
-.sm-field select {
- background: none; border: none;
- color: #d3d3d3; color: transparent;
- width: 100%; padding: 2px 0;
- text-shadow: 0 0 0 #d3d3d3;
- position: relative; z-index:1;
- -webkit-appearance: none;
- -moz-appearance: none;
- appearance: none;
-}
-.sm-field select::-ms-expand { display: none;}
-.sm-field.select option { margin: 5px 0;}
-.sm-field.integer select{ width:auto; padding: 0; color: transparent;}
-.sm-field.color input{ width:50px; }
-.sm-color-picker {
- /*background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==");*/
- background-color: #fff;
- border: 2px solid #555;
- box-sizing: border-box;
- cursor: pointer;
- height: 100%; width: 20px;
- position: absolute;
- right: 0; top: 0;
-}
-.sm-field .unit {
- position: absolute;
- right: 10px; top: 3px;
- font-size: 10px;
- color:#aaa;
- cursor:pointer;
-}
-.sm-field .int-arrows, .sm-field .sel-arrow{
- height: 100%; width: 9px;
- position: absolute;
- right: 0; top: 0;
- cursor: ns-resize;
-}
-.sm-field .sel-arrow{cursor:pointer}
-.sm-field .u-arrow,.sm-field .d-arrow, .sm-field .d-s-arrow{
- position: absolute;
- height: 0; width: 0;
- border-left: 3px solid transparent;
- border-right: 4px solid transparent;
- cursor:pointer;
-}
-.sm-field .u-arrow {
- border-bottom: 4px solid #aaa;
- top: 4px;
-}
-.sm-field .d-arrow, .sm-field .d-s-arrow {
- border-top: 4px solid #aaa;
- bottom: 4px;
-}
-.sm-field .d-s-arrow{ bottom: 7px; }
-.sm-properties {
- font-size: 11px;
- padding: 10px 5px;
-}
-.stack .sm-properties{padding-top: 5px;}
-.sm-property{
- box-sizing: border-box;
- float:left; width:50%;
- margin-bottom: 5px;
- padding: 0 5px;
-}
-.sm-field.list .icon{
- background-repeat: no-repeat;
- background-position:center;
- color: transparent;
- text-shadow: none;
- padding: 5px 19px;
-}
-.sm-property .btn{
- background-color: #5d5d5d;
- border-radius: 2px;
- box-shadow: 1px 1px 0 #3f3f3f, 1px 1px 0 #656565 inset;
- padding: 5px;
- position: relative;
- text-align: center;
- height: auto; width: 100%;
- cursor: pointer;
- color: #fff;
- box-sizing: border-box;
- text-shadow: -1px -1px 0 #444;
-}
-.sm-property .btn-c {
- box-sizing: border-box;
- float: left;
- width: 50%;
- padding: 0 5px;
-}
-.btn-upload #upload {
- left: 0; top: 0;
- position: absolute;
- width: 100%;
- opacity: 0;
- cursor: pointer;
-}
-.sm-field.stack #add {
- background: none;
- border: none;
- color: white;
- cursor: pointer;
- font-size: 22px;
- line-height: 10px;
- position: absolute;
- right: 0; top: -20px;
- opacity: 0.75;
-}
-.sm-field.stack #add:hover{ opacity: 1;}
-.sm-field .layers, .sm-property .sm-layers {
- background-color: #3d3d3d;
- border: 1px solid #353535;
- border-radius: 2px;
- box-shadow: 1px 1px 0 #575757;
- margin-top: 5px;
- min-height: 30px;
-}
-.sm-layers .sm-layer {
- background-color: #454545;
- border-radius: 2px;
- box-shadow: 1px 1px 0 #333333, 1px 1px 0 #505050 inset;
- margin: 2px;
- padding: 7px;
- position: relative;
- cursor: pointer;
-}
-.sm-property.file #preview-box {
- background-color: #404040;
- border-radius: 2px;
- margin-top: 5px;
- position:relative;
- overflow: hidden;
-}
-.sm-property.file #preview-box.show{
- border: 1px solid #3d3d3d;
- padding: 3px 5px;
-}
-.sm-property.file .show #preview-file{
- height: 50px;
-}
-.sm-property.file #preview-file {
- background-size: auto 100%;
- background-repeat: no-repeat;
- background-position: center center;
-}
-.sm-layer > #preview-box {
- background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==");
- height: 15px;
- position: absolute;
- right: 27px;
- top: 6px;
- width: 15px;
-}
-.sm-layer > #preview-box #preview {
- background-color: white;
- height: 100%;
- width: 100%;
-}
-.sm-layer.active {
- background-color: #4c4c4c;
- border: 1px solid #555555;
-}
-.sm-layer #preview-box,.sm-layer #preview{border-radius:2px;}
-.sm-layer.no-preview #preview-box{display:none;}
-.sm-property.file #preview-box #close{display:block;}
-.btn-upload #label { padding: 2px 0;}
-.sm-field.list .icon.float-left{ background-image:url('../images/icon-box-l.png'); }
-.sm-field.list .icon.float-right{ background-image:url('../images/icon-box-r.png'); }
-.sm-field.list .icon.float-center{ background-image:url('../images/icon-box-c.png'); }
-.sm-field.list .icon.none{ background-image:url('../images/icon-none.png'); }
-/********* customs **********/
-.sm-property#width .sm-label, .sm-property#height .sm-label{float:left;}
-.sm-property#width .sm-field, .sm-property#height .sm-field{float:left; /*width: 59px;*/}
-.sm-property#position, .sm-property#float,.sm-property#font-family,.sm-property#text-align,
-.sm-property#background-color{width:100%}
-.sm-property#background-color input{width:130px;}
-/*********Modal dialog**********/
-.dialog-container {
- background-color: #000;
- position: absolute;
- top: 0; z-index: 10;
- width:100%; height:100%;
- background: rgba(0, 0, 0, 0.5);
- filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#66000000, endColorstr=#66000000);
- -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#66000000, endColorstr=#66000000)";
-}
-.modal-dialog {
- background-color: #4b4b4b;
- border-bottom: 2px solid #353535;
- text-shadow: -1px -1px 0 #353535;
- margin: 30px auto 0;
- max-width: 850px;
- width: 90%;
- color: #eee;
- border-radius: 3px;
- font-weight: lighter;
-}
-.dialog-header, .dialog-content{padding:10px 15px; clear: both;}
-.dialog-header{ border-bottom: 1px solid #3d3d3d;}
-.dialog-content { border-top: 1px solid #575757;}
-.modal-dialog .title { float: left; }
-.modal-dialog .btn-close {
- cursor: pointer;
- float: right;
- background-image: url("../images/icon-none.png");
- background-position: center center;
- background-repeat: no-repeat;
- height: 20px; width: 20px;
-}
-/********* File uploader **********/
-.wte-file-uploader {width: 55%; float:left;}
-.wte-file-uploader > form {
- background-color: #3d3d3d;
- border: 2px dashed #999999;
- border-radius: 3px;
- position: relative;
- text-align: center;
- margin-bottom: 15px;
-}
-.wte-file-uploader > form #wte-uploadFile,
-.wte-file-uploader #title{ padding: 150px 10px; }
-.wte-file-uploader > form #wte-uploadFile{
- opacity: 0; filter: alpha(opacity=0);
- width: 100%;
-}
-.wte-file-uploader #title { position: absolute;width: 100%;}
-.wte-file-uploader > form.hover {
- border: 2px solid #62c462;
- color:#7ee07e;
-}
-/********* Assets Manager **********/
-.wte-assets {
- background-color: #3d3d3d;
- border-radius: 3px;
- box-sizing: border-box;
- margin-left: 3%;
- padding: 5px;
- width: 42%;
- float:right;
- height: 325px;
- overflow: auto;
-}
-.wte-asset {
- border-bottom: 1px solid #343434;
- padding: 5px 0;
- cursor:pointer;
- position: relative;
-}
-.wte-asset #close, .sm-property.file #close, .btn-close {
- font-size: 20px;
- display: none;
- opacity: 0.3; filter: alpha(opacity=30);
- position: absolute;
- cursor: pointer;
- right: 5px;
- top: 0;
-}
-.sm-layers .sm-layer #close-layer{
- display:block;
- opacity: 0.2;
- font-size: 23px;
-}
-.sm-layers .sm-layer #close-layer:hover{ opacity: 0.7;}
-.wte-asset #close:hover{
- opacity: 0.7; filter: alpha(opacity=70);
-}
-.wte-asset:hover #close { display: block;}
-.wte-asset.wte-highlight {
- background-color: #444444;
-}
-.wte-asset #meta {
- width: 70%;
- float: left;
- font-size: 12px;
- padding: 5px 0 0 5px;
- box-sizing: border-box;
-}
-.wte-asset #meta > div { margin-bottom: 5px;}
-.wte-asset #preview{
- height: 70px; width: 30%;
- background-position: center center;
- background-size: cover;
- background-repeat: no-repeat;
- background-color: #444;
- border-radius: 2px;
- float: left;
-}
-.wte-asset #meta #dimensions {
- font-size: 10px;
- opacity: 0.5;
-}
-
-/********* Export template **********/
-.editor#html, .editor#css{
- float:left;
- box-sizing: border-box;
- width:50%;
-}
-.editor#html { padding-right: 10px; border-right: 1px solid #3d3d3d;}
-.editor#css { padding-left: 10px; border-left: 1px solid #575757;}
-.editor #mode {
- background-color: #353535;
- font-size: 12px;
- padding: 5px 10px 3px;
- text-align: right;
-}
-#html.editor #mode { color: #a97d44;}
-#css.editor #mode { color: #ddca7e;}
-
-/********* Spectrum **********/
-.sp-hue, .sp-slider{ cursor: row-resize;}
-.sp-color, .sp-dragger{ cursor: crosshair;}
-.sp-alpha-inner, .sp-alpha-handle{cursor: col-resize;}
-.sp-hue{ left: 90%; }
-.sp-color{right: 15%;}
-.sp-container {
- background-color: #454545;
- border: 1px solid #333333;
- box-shadow: 0 0 7px #111;
- border-radius: 3px;
-}
-.sp-picker-container{border:none;}
-.colpick_dark .colpick_color { outline: 1px solid #333;}
-.sp-cancel, .sp-cancel:hover {
- bottom: -8px;
- color: #777 !important;
- font-size: 25px;
- left: 0;
- position: absolute;
- text-decoration:none;
-}
-.sp-alpha-handle {
- background-color: #ccc;
- border: 1px solid #555;
- width: 4px;
-}
-.sp-color, .sp-hue { border: 1px solid #333333;}
-.sp-slider {
- background-color: #ccc;
- border: 1px solid #555;
- height: 3px;
- left: -4px;
- width: 22px;
-}
-.sp-dragger{background:transparent; box-shadow: 0 0 0 1px #111;}
-.sp-button-container{
- float: none;
- width: 100%;
- position: relative;
- text-align: right;
-}
-.sp-container button, .sp-container button:hover, .sp-container button:active{
- background: #333;
- border-color: #292929;
- color: #757575;
- text-shadow: none;
- box-shadow: none;
- padding: 3px 5px;
-}
-
-/*********JQuery-UI**********/
-.ui-sortable-helper{
- opacity: 0.7; filter: alpha(opacity=70);
-}
-.ui-sort-highlight{/*ui-sortable-placeholder*/
- background:#123;
- height:20px;
-}
-.ui-resizable{ position:relative;}
-.ui-resizable-se, .ui-resizable-s,.ui-resizable-e{
- position:absolute;
- right: 0;
- bottom:0;
- cursor: nwse-resize;
- height:15px;
- width:15px;
- outline: none !important;
-}
-.ui-resizable-se{
- background-image:url('../images/resize-dots.png');
- opacity: 0; filter: alpha(opacity=0);
-}
-.ui-resizable:hover > .ui-resizable-se{ opacity: 0.3; filter: alpha(opacity=30); }
-.ui-resizable-s{
- height:10px;
- width:100%;
- cursor: ns-resize;
-}
-.ui-resizable-e{
- width:10px;
- height:100%;
- cursor: ew-resize;
-}
-/*************RTE****************/
-.rte-editor { position: relative; z-index: 2; }
-#rte-toolbar {
- background-color: #4b4b4b;
- border: 1px solid #3f3f3f;
- position: absolute;
- border-radius: 3px;
- overflow: hidden;
- z-index: 5;
-}
-#rte-toolbar .btn {
- float: left;
- padding: 5px;
- box-sizing: border-box;
- height:25px; width:25px;
- background-position: center;
- background-repeat: no-repeat;
- background-size: 60% auto;
- border-right: 1px solid #353535;
- cursor: pointer
-}
-#rte-toolbar .btn:last-child{ border-right:none; }
-#rte-toolbar .btn.btn-info{ background-color:#3a3a3a; }
-#rte-toolbar .btn[data-edit=bold]{ background-image:url('../images/icon-bold.png');}
-#rte-toolbar .btn[data-edit=italic]{ background-image:url('../images/icon-italic.png');}
-#rte-toolbar .btn[data-edit=underline]{ background-image:url('../images/icon-underline.png');}
-#rte-toolbar .btn:hover { background-color: #5f5f5f;}
\ No newline at end of file
diff --git a/styles/spectrum.css b/styles/spectrum.css
deleted file mode 100644
index ecf6fe482..000000000
--- a/styles/spectrum.css
+++ /dev/null
@@ -1,507 +0,0 @@
-/***
-Spectrum Colorpicker v1.7.1
-https://github.com/bgrins/spectrum
-Author: Brian Grinstead
-License: MIT
-***/
-
-.sp-container {
- position:absolute;
- top:0;
- left:0;
- display:inline-block;
- *display: inline;
- *zoom: 1;
- /* https://github.com/bgrins/spectrum/issues/40 */
- z-index: 9999994;
- overflow: hidden;
-}
-.sp-container.sp-flat {
- position: relative;
-}
-
-/* Fix for * { box-sizing: border-box; } */
-.sp-container,
-.sp-container * {
- -webkit-box-sizing: content-box;
- -moz-box-sizing: content-box;
- box-sizing: content-box;
-}
-
-/* http://ansciath.tumblr.com/post/7347495869/css-aspect-ratio */
-.sp-top {
- position:relative;
- width: 100%;
- display:inline-block;
-}
-.sp-top-inner {
- position:absolute;
- top:0;
- left:0;
- bottom:0;
- right:0;
-}
-.sp-color {
- position: absolute;
- top:0;
- left:0;
- bottom:0;
- right:20%;
-}
-.sp-hue {
- position: absolute;
- top:0;
- right:0;
- bottom:0;
- left:84%;
- height: 100%;
-}
-
-.sp-clear-enabled .sp-hue {
- top:33px;
- height: 77.5%;
-}
-
-.sp-fill {
- padding-top: 80%;
-}
-.sp-sat, .sp-val {
- position: absolute;
- top:0;
- left:0;
- right:0;
- bottom:0;
-}
-
-.sp-alpha-enabled .sp-top {
- margin-bottom: 18px;
-}
-.sp-alpha-enabled .sp-alpha {
- display: block;
-}
-.sp-alpha-handle {
- position:absolute;
- top:-4px;
- bottom: -4px;
- width: 6px;
- left: 50%;
- cursor: pointer;
- border: 1px solid black;
- background: white;
- opacity: .8;
-}
-.sp-alpha {
- display: none;
- position: absolute;
- bottom: -14px;
- right: 0;
- left: 0;
- height: 8px;
-}
-.sp-alpha-inner {
- border: solid 1px #333;
-}
-
-.sp-clear {
- display: none;
-}
-
-.sp-clear.sp-clear-display {
- background-position: center;
-}
-
-.sp-clear-enabled .sp-clear {
- display: block;
- position:absolute;
- top:0px;
- right:0;
- bottom:0;
- left:84%;
- height: 28px;
-}
-
-/* Don't allow text selection */
-.sp-container, .sp-replacer, .sp-preview, .sp-dragger, .sp-slider, .sp-alpha, .sp-clear, .sp-alpha-handle, .sp-container.sp-dragging .sp-input, .sp-container button {
- -webkit-user-select:none;
- -moz-user-select: -moz-none;
- -o-user-select:none;
- user-select: none;
-}
-
-.sp-container.sp-input-disabled .sp-input-container {
- display: none;
-}
-.sp-container.sp-buttons-disabled .sp-button-container {
- display: none;
-}
-.sp-container.sp-palette-buttons-disabled .sp-palette-button-container {
- display: none;
-}
-.sp-palette-only .sp-picker-container {
- display: none;
-}
-.sp-palette-disabled .sp-palette-container {
- display: none;
-}
-
-.sp-initial-disabled .sp-initial {
- display: none;
-}
-
-
-/* Gradients for hue, saturation and value instead of images. Not pretty... but it works */
-.sp-sat {
- background-image: -webkit-gradient(linear, 0 0, 100% 0, from(#FFF), to(rgba(204, 154, 129, 0)));
- background-image: -webkit-linear-gradient(left, #FFF, rgba(204, 154, 129, 0));
- background-image: -moz-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
- background-image: -o-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
- background-image: -ms-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
- background-image: linear-gradient(to right, #fff, rgba(204, 154, 129, 0));
- -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr=#FFFFFFFF, endColorstr=#00CC9A81)";
- filter : progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr='#FFFFFFFF', endColorstr='#00CC9A81');
-}
-.sp-val {
- background-image: -webkit-gradient(linear, 0 100%, 0 0, from(#000000), to(rgba(204, 154, 129, 0)));
- background-image: -webkit-linear-gradient(bottom, #000000, rgba(204, 154, 129, 0));
- background-image: -moz-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
- background-image: -o-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
- background-image: -ms-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
- background-image: linear-gradient(to top, #000, rgba(204, 154, 129, 0));
- -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00CC9A81, endColorstr=#FF000000)";
- filter : progid:DXImageTransform.Microsoft.gradient(startColorstr='#00CC9A81', endColorstr='#FF000000');
-}
-
-.sp-hue {
- background: -moz-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
- background: -ms-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
- background: -o-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
- background: -webkit-gradient(linear, left top, left bottom, from(#ff0000), color-stop(0.17, #ffff00), color-stop(0.33, #00ff00), color-stop(0.5, #00ffff), color-stop(0.67, #0000ff), color-stop(0.83, #ff00ff), to(#ff0000));
- background: -webkit-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
- background: linear-gradient(to bottom, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
-}
-
-/* IE filters do not support multiple color stops.
- Generate 6 divs, line them up, and do two color gradients for each.
- Yes, really.
- */
-.sp-1 {
- height:17%;
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0000', endColorstr='#ffff00');
-}
-.sp-2 {
- height:16%;
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff00', endColorstr='#00ff00');
-}
-.sp-3 {
- height:17%;
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ff00', endColorstr='#00ffff');
-}
-.sp-4 {
- height:17%;
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ffff', endColorstr='#0000ff');
-}
-.sp-5 {
- height:16%;
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0000ff', endColorstr='#ff00ff');
-}
-.sp-6 {
- height:17%;
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff00ff', endColorstr='#ff0000');
-}
-
-.sp-hidden {
- display: none !important;
-}
-
-/* Clearfix hack */
-.sp-cf:before, .sp-cf:after { content: ""; display: table; }
-.sp-cf:after { clear: both; }
-.sp-cf { *zoom: 1; }
-
-/* Mobile devices, make hue slider bigger so it is easier to slide */
-@media (max-device-width: 480px) {
- .sp-color { right: 40%; }
- .sp-hue { left: 63%; }
- .sp-fill { padding-top: 60%; }
-}
-.sp-dragger {
- border-radius: 5px;
- height: 5px;
- width: 5px;
- border: 1px solid #fff;
- background: #000;
- cursor: pointer;
- position:absolute;
- top:0;
- left: 0;
-}
-.sp-slider {
- position: absolute;
- top:0;
- cursor:pointer;
- height: 3px;
- left: -1px;
- right: -1px;
- border: 1px solid #000;
- background: white;
- opacity: .8;
-}
-
-/*
-Theme authors:
-Here are the basic themeable display options (colors, fonts, global widths).
-See http://bgrins.github.io/spectrum/themes/ for instructions.
-*/
-
-.sp-container {
- border-radius: 0;
- background-color: #ECECEC;
- border: solid 1px #f0c49B;
- padding: 0;
-}
-.sp-container, .sp-container button, .sp-container input, .sp-color, .sp-hue, .sp-clear {
- font: normal 12px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- -ms-box-sizing: border-box;
- box-sizing: border-box;
-}
-.sp-top {
- margin-bottom: 3px;
-}
-.sp-color, .sp-hue, .sp-clear {
- border: solid 1px #666;
-}
-
-/* Input */
-.sp-input-container {
- float:right;
- width: 100px;
- margin-bottom: 4px;
-}
-.sp-initial-disabled .sp-input-container {
- width: 100%;
-}
-.sp-input {
- font-size: 12px !important;
- border: 1px inset;
- padding: 4px 5px;
- margin: 0;
- width: 100%;
- background:transparent;
- border-radius: 3px;
- color: #222;
-}
-.sp-input:focus {
- border: 1px solid orange;
-}
-.sp-input.sp-validation-error {
- border: 1px solid red;
- background: #fdd;
-}
-.sp-picker-container , .sp-palette-container {
- float:left;
- position: relative;
- padding: 10px;
- padding-bottom: 300px;
- margin-bottom: -290px;
-}
-.sp-picker-container {
- width: 172px;
- border-left: solid 1px #fff;
-}
-
-/* Palettes */
-.sp-palette-container {
- border-right: solid 1px #ccc;
-}
-
-.sp-palette-only .sp-palette-container {
- border: 0;
-}
-
-.sp-palette .sp-thumb-el {
- display: block;
- position:relative;
- float:left;
- width: 24px;
- height: 15px;
- margin: 3px;
- cursor: pointer;
- border:solid 2px transparent;
-}
-.sp-palette .sp-thumb-el:hover, .sp-palette .sp-thumb-el.sp-thumb-active {
- border-color: orange;
-}
-.sp-thumb-el {
- position:relative;
-}
-
-/* Initial */
-.sp-initial {
- float: left;
- border: solid 1px #333;
-}
-.sp-initial span {
- width: 30px;
- height: 25px;
- border:none;
- display:block;
- float:left;
- margin:0;
-}
-
-.sp-initial .sp-clear-display {
- background-position: center;
-}
-
-/* Buttons */
-.sp-palette-button-container,
-.sp-button-container {
- float: right;
-}
-
-/* Replacer (the little preview div that shows up instead of the ) */
-.sp-replacer {
- margin:0;
- overflow:hidden;
- cursor:pointer;
- padding: 4px;
- display:inline-block;
- *zoom: 1;
- *display: inline;
- border: solid 1px #91765d;
- background: #eee;
- color: #333;
- vertical-align: middle;
-}
-.sp-replacer:hover, .sp-replacer.sp-active {
- border-color: #F0C49B;
- color: #111;
-}
-.sp-replacer.sp-disabled {
- cursor:default;
- border-color: silver;
- color: silver;
-}
-.sp-dd {
- padding: 2px 0;
- height: 16px;
- line-height: 16px;
- float:left;
- font-size:10px;
-}
-.sp-preview {
- position:relative;
- width:25px;
- height: 20px;
- border: solid 1px #222;
- margin-right: 5px;
- float:left;
- z-index: 0;
-}
-
-.sp-palette {
- *width: 220px;
- max-width: 220px;
-}
-.sp-palette .sp-thumb-el {
- width:16px;
- height: 16px;
- margin:2px 1px;
- border: solid 1px #d0d0d0;
-}
-
-.sp-container {
- padding-bottom:0;
-}
-
-
-/* Buttons: http://hellohappy.org/css3-buttons/ */
-.sp-container button {
- background-color: #eeeeee;
- background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
- background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
- background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
- background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
- background-image: linear-gradient(to bottom, #eeeeee, #cccccc);
- border: 1px solid #ccc;
- border-bottom: 1px solid #bbb;
- border-radius: 3px;
- color: #333;
- font-size: 14px;
- line-height: 1;
- padding: 5px 4px;
- text-align: center;
- text-shadow: 0 1px 0 #eee;
- vertical-align: middle;
-}
-.sp-container button:hover {
- background-color: #dddddd;
- background-image: -webkit-linear-gradient(top, #dddddd, #bbbbbb);
- background-image: -moz-linear-gradient(top, #dddddd, #bbbbbb);
- background-image: -ms-linear-gradient(top, #dddddd, #bbbbbb);
- background-image: -o-linear-gradient(top, #dddddd, #bbbbbb);
- background-image: linear-gradient(to bottom, #dddddd, #bbbbbb);
- border: 1px solid #bbb;
- border-bottom: 1px solid #999;
- cursor: pointer;
- text-shadow: 0 1px 0 #ddd;
-}
-.sp-container button:active {
- border: 1px solid #aaa;
- border-bottom: 1px solid #888;
- -webkit-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
- -moz-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
- -ms-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
- -o-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
- box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
-}
-.sp-cancel {
- font-size: 11px;
- color: #d93f3f !important;
- margin:0;
- padding:2px;
- margin-right: 5px;
- vertical-align: middle;
- text-decoration:none;
-
-}
-.sp-cancel:hover {
- color: #d93f3f !important;
- text-decoration: underline;
-}
-
-
-.sp-palette span:hover, .sp-palette span.sp-thumb-active {
- border-color: #000;
-}
-
-.sp-preview, .sp-alpha, .sp-thumb-el {
- position:relative;
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==);
-}
-.sp-preview-inner, .sp-alpha-inner, .sp-thumb-inner {
- display:block;
- position:absolute;
- top:0;left:0;bottom:0;right:0;
-}
-
-.sp-palette .sp-thumb-inner {
- background-position: 50% 50%;
- background-repeat: no-repeat;
-}
-
-.sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner {
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIVJREFUeNpiYBhsgJFMffxAXABlN5JruT4Q3wfi/0DsT64h8UD8HmpIPCWG/KemIfOJCUB+Aoacx6EGBZyHBqI+WsDCwuQ9mhxeg2A210Ntfo8klk9sOMijaURm7yc1UP2RNCMbKE9ODK1HM6iegYLkfx8pligC9lCD7KmRof0ZhjQACDAAceovrtpVBRkAAAAASUVORK5CYII=);
-}
-
-.sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner {
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAMdJREFUOE+tkgsNwzAMRMugEAahEAahEAZhEAqlEAZhEAohEAYh81X2dIm8fKpEspLGvudPOsUYpxE2BIJCroJmEW9qJ+MKaBFhEMNabSy9oIcIPwrB+afvAUFoK4H0tMaQ3XtlrggDhOVVMuT4E5MMG0FBbCEYzjYT7OxLEvIHQLY2zWwQ3D+9luyOQTfKDiFD3iUIfPk8VqrKjgAiSfGFPecrg6HN6m/iBcwiDAo7WiBeawa+Kwh7tZoSCGLMqwlSAzVDhoK+6vH4G0P5wdkAAAAASUVORK5CYII=);
-}
-
-.sp-clear-display {
- background-repeat:no-repeat;
- background-position: center;
- background-image: url(data:image/gif;base64,R0lGODlhFAAUAPcAAAAAAJmZmZ2dnZ6enqKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq/Hx8fLy8vT09PX19ff39/j4+Pn5+fr6+vv7+wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAP8ALAAAAAAUABQAAAihAP9FoPCvoMGDBy08+EdhQAIJCCMybCDAAYUEARBAlFiQQoMABQhKUJBxY0SPICEYHBnggEmDKAuoPMjS5cGYMxHW3IiT478JJA8M/CjTZ0GgLRekNGpwAsYABHIypcAgQMsITDtWJYBR6NSqMico9cqR6tKfY7GeBCuVwlipDNmefAtTrkSzB1RaIAoXodsABiZAEFB06gIBWC1mLVgBa0AAOw==);
-}