JAVASCRIPT   150

styler-set.js

Guest on 19th July 2021 07:05:03 PM

  1.  
  2.  
  3. /************************************************************************************* Base ***************************************************************************************************/
  4. function SmartFormsBaseStyleSet(formElement,jQueryElementToStyle,attributesCointainer,elementName)
  5. {
  6.     this.FormElement=formElement;
  7.     this.JQueryElementToStyle=jQueryElementToStyle;
  8.     this.ElementName=elementName;
  9.     this.AttributesCointainer=attributesCointainer;
  10.  
  11.     this.SetupElementHighlight();
  12. }
  13.  
  14. SmartFormsBaseStyleSet.prototype.SetupElementHighlight=function()
  15. {
  16.     var self=this;
  17.     this.JQueryElementToStyle.find('.'+this.ElementName).hover(
  18.         function(event){
  19.             event.stopPropagation();
  20.             self.JQueryElementToStyle.find('.'+self.ElementName).addClass('redNaoStylerHighlight');
  21.         },
  22.         //unhover
  23.         function(event){
  24.             event.stopPropagation();
  25.             self.JQueryElementToStyle.find('.'+self.ElementName).removeClass('redNaoStylerHighlight');
  26.  
  27.  
  28.         }).click(function(){
  29.             self.StartEdition();
  30.         });
  31.  
  32. };
  33.  
  34. SmartFormsBaseStyleSet.prototype.StartEdition=function(jQueryTable)
  35. {
  36.     rnJQuery('.rnEditorContainer').show();
  37.     this.AttributesCointainer.empty();
  38.     var properties=this.GetSetProperties();
  39.     var Style=this.GetCurrentElementStyle();
  40.     rnJQuery('#rnCustomStyleContent').val('');
  41.     if(Style!=null)
  42.     {
  43.         rnJQuery('#rnStyleApplyTo').val(Style.Scope);
  44.         if(typeof Style.CustomCSS!='undefined')
  45.             rnJQuery('#rnCustomStyleContent').val(Style.CustomCSS.CSS);
  46.     }
  47.     else
  48.     {
  49.         rnJQuery('#rnStyleApplyTo').val(1);
  50.     }
  51.     for(var i=0;i<properties.length;i++)
  52.     {
  53.         properties[i].AppendToElement(this.AttributesCointainer);
  54.     }
  55.  
  56.     var self=this;
  57.     rnJQuery('#rnStyleApplyTo').unbind('click').bind('click',function(){self.ScopeChanged();});
  58.     rnJQuery('#rnApplyCustomRule').unbind('click').bind('click',function(){self.ApplyCustomCSS();});
  59.  
  60. };
  61.  
  62. SmartFormsBaseStyleSet.prototype.ApplyCustomCSS=function()
  63. {
  64.     var cssText=rnJQuery.trim(rnJQuery('#rnCustomStyleContent').val());
  65.     if(cssText.length==0)
  66.     {
  67.         this.RemoveSection('CustomCSS');
  68.         return;
  69.     }
  70.  
  71.     var section=this.GetOrCreateSection('CustomCSS');
  72.     section.CSS=cssText;
  73.     this.FormElement.ApplyTagStyleForElement(this.ElementName);
  74. };
  75.  
  76. SmartFormsBaseStyleSet.prototype.GetOrCreateSection=function(sectionName)
  77. {
  78.     if(typeof this.FormElement.Options.Styles[this.ElementName]=='undefined')
  79.         this.FormElement.Options.Styles[this.ElementName]={Scope:rnJQuery('#rnStyleApplyTo').val(),Properties:{}};
  80.     if(typeof this.FormElement.Options.Styles[this.ElementName][sectionName]=='undefined')
  81.         this.FormElement.Options.Styles[this.ElementName][sectionName]={};
  82.  
  83.     return this.FormElement.Options.Styles[this.ElementName][sectionName];
  84.  
  85. };
  86.  
  87.  
  88. SmartFormsBaseStyleSet.prototype.RemoveSection=function(sectionName)
  89. {
  90.     delete this.FormElement.Options.Styles[this.ElementName][sectionName];
  91.     var count=0;
  92.     for(var i=0 in this.FormElement.Options.Styles[this.ElementName])
  93.         count++;
  94.  
  95.     if(count==0)
  96.         delete this.FormElement.Options.Styles[sectionName];
  97.  
  98. };
  99.  
  100. SmartFormsBaseStyleSet.prototype.ScopeChanged=function()
  101. {
  102.     var Style=this.GetCurrentElementStyle();
  103.     if(Style==null)
  104.         return;
  105.     Style.Scope=rnJQuery('#rnStyleApplyTo').val();
  106.     this.FormElement.ApplyTagStyleForElement(this.ElementName);
  107. };
  108.  
  109. SmartFormsBaseStyleSet.prototype.GetCurrentElementStyle=function()
  110. {
  111.     if(!RedNaoPathExists(this.FormElement,'Options.Styles.'+this.ElementName))
  112.         return null;
  113.  
  114.     return this.FormElement.Options.Styles[this.ElementName];
  115. };
  116.  
  117. SmartFormsBaseStyleSet.prototype.GetSetProperties=function()
  118. {
  119.  
  120. };
  121.  
  122. /************************************************************************************* Title Style Set ***************************************************************************************************/
  123. function SmartFormsTitleStyleSet(formElement,jQueryElementToStyle,attributesCointainer,elementName)
  124. {
  125.     SmartFormsBaseStyleSet.call(this,formElement,jQueryElementToStyle,attributesCointainer,elementName);
  126. }
  127. SmartFormsTitleStyleSet.prototype=Object.create(SmartFormsBaseStyleSet.prototype);
  128.  
  129.  
  130. SmartFormsTitleStyleSet.prototype.GetSetProperties=function()
  131. {
  132.     var properties=[];
  133.     properties.push(new RedNaoFontFamilyStyleProperty(this,this.FormElement,this.ElementName,"Font-Family","Font Family"));
  134.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"Color","Title Color"));
  135.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"border-bottom-color","Border Color"));
  136.     return properties;
  137. };
  138.  
  139.  
  140.  
  141. /************************************************************************************* Label Style Set ***************************************************************************************************/
  142. function SmartFormsLabelStyleSet(formElement,jQueryElementToStyle,attributesCointainer,elementName)
  143. {
  144.     SmartFormsBaseStyleSet.call(this,formElement,jQueryElementToStyle,attributesCointainer,elementName);
  145. }
  146. SmartFormsLabelStyleSet.prototype=Object.create(SmartFormsBaseStyleSet.prototype);
  147.  
  148. SmartFormsLabelStyleSet.prototype.GetSetProperties=function()
  149. {
  150.     var properties=[];
  151.     properties.push(new RedNaoFontFamilyStyleProperty(this,this.FormElement,this.ElementName,"Font-Family","Font Family"));
  152.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"Color","Color"));
  153.     return properties;
  154. };
  155.  
  156. /************************************************************************************* Input Style Set ***************************************************************************************************/
  157. function SmartFormsInputStyleSet(formElement,jQueryElementToStyle,attributesCointainer,elementName)
  158. {
  159.     SmartFormsBaseStyleSet.call(this,formElement,jQueryElementToStyle,attributesCointainer,elementName);
  160. }
  161. SmartFormsInputStyleSet.prototype=Object.create(SmartFormsBaseStyleSet.prototype);
  162.  
  163. SmartFormsInputStyleSet.prototype.GetSetProperties=function()
  164. {
  165.     var properties=[];
  166.     properties.push(new RedNaoFontFamilyStyleProperty(this,this.FormElement,this.ElementName,"Font-Family","Font Family"));
  167.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"Color","Color"));
  168.     return properties;
  169. };
  170.  
  171. /************************************************************************************* Prepend Style Set ***************************************************************************************************/
  172. function SmartFormsPrependStyleSet(formElement,jQueryElementToStyle,attributesCointainer,elementName)
  173. {
  174.     SmartFormsBaseStyleSet.call(this,formElement,jQueryElementToStyle,attributesCointainer,elementName);
  175. }
  176. SmartFormsPrependStyleSet.prototype=Object.create(SmartFormsBaseStyleSet.prototype);
  177.  
  178. SmartFormsPrependStyleSet.prototype.GetSetProperties=function()
  179. {
  180.     var properties=[];
  181.     properties.push(new RedNaoFontFamilyStyleProperty(this,this.FormElement,this.ElementName,"Font-Family","Font Family"));
  182.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"Color","Color"));
  183.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"background-color","Background Color"));
  184.     return properties;
  185. };
  186.  
  187. /************************************************************************************* Checkbox Style Set ***************************************************************************************************/
  188. function SmartFormsCheckBoxStyleSet(formElement,jQueryElementToStyle,attributesCointainer,elementName)
  189. {
  190.     SmartFormsBaseStyleSet.call(this,formElement,jQueryElementToStyle,attributesCointainer,elementName);
  191. }
  192. SmartFormsCheckBoxStyleSet.prototype=Object.create(SmartFormsBaseStyleSet.prototype);
  193.  
  194. SmartFormsCheckBoxStyleSet.prototype.GetSetProperties=function()
  195. {
  196.     var properties=[];
  197.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"background-color","Background Color"));
  198.     return properties;
  199. };
  200.  
  201. /************************************************************************************* Button Style Set ***************************************************************************************************/
  202. function SmartFormsButtonStyleSet(formElement,jQueryElementToStyle,attributesCointainer,elementName)
  203. {
  204.     SmartFormsBaseStyleSet.call(this,formElement,jQueryElementToStyle,attributesCointainer,elementName);
  205. }
  206. SmartFormsButtonStyleSet.prototype=Object.create(SmartFormsBaseStyleSet.prototype);
  207.  
  208. SmartFormsButtonStyleSet.prototype.GetSetProperties=function()
  209. {
  210.     var properties=[];
  211.     properties.push(new RedNaoFontFamilyStyleProperty(this,this.FormElement,this.ElementName,"Font-Family","Font Family"));
  212.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"Color","Color"));
  213.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"background-color","Background Color"));
  214.  
  215.     return properties;
  216. };
  217.  
  218. /************************************************************************************* File Button Style Set ***************************************************************************************************/
  219. function SmartFormsFileButtonStyleSet(formElement,jQueryElementToStyle,attributesCointainer,elementName)
  220. {
  221.     SmartFormsBaseStyleSet.call(this,formElement,jQueryElementToStyle,attributesCointainer,elementName);
  222. }
  223. SmartFormsFileButtonStyleSet.prototype=Object.create(SmartFormsBaseStyleSet.prototype);
  224.  
  225. SmartFormsFileButtonStyleSet.prototype.GetSetProperties=function()
  226. {
  227.     var properties=[];
  228.     properties.push(new RedNaoFontFamilyStyleProperty(this,this.FormElement,this.ElementName,"Font-Family","Font Family"));
  229.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"Color","Color"));
  230.     properties.push(new RedNaoColorStyleProperty(this,this.FormElement,this.ElementName,"background-color","Background Color"));
  231.  
  232.     return properties;
  233. };

Raw Paste


Login or Register to edit or fork this paste. It's free.