Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- Base: wintercms/winter branch 1.2 (full framework) - Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS - Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication - Partials: hero (offline-first), features, modes (offline/nube toggle), screenshots, pricing (3 planes), comparison, FAQ, CTA - Plugin VivesPOS.Site with ContactForm - Dockerfile: PHP 8.2 Apache, port 80, healthcheck - Added winter/wn-pages, blog, sitemap, seo plugins - Active theme set to vivespos
81 lines
2.3 KiB
JavaScript
81 lines
2.3 KiB
JavaScript
/*
|
|
* Winter JavaScript foundation library.
|
|
*
|
|
* Base class for Winter CMS back-end classes.
|
|
*
|
|
* The class defines base functionality for dealing with memory management
|
|
* and cleaning up bound (proxied) methods.
|
|
*
|
|
* The base class defines the dispose method that cleans up proxied methods.
|
|
* If child classes implement their own dispose() method, they should call
|
|
* the base class dispose method (see the example below).
|
|
*
|
|
* Use the simple parasitic combination inheritance pattern to create child classes:
|
|
*
|
|
* var Base = $.wn.foundation.base,
|
|
* BaseProto = Base.prototype
|
|
*
|
|
* var SubClass = function(params) {
|
|
* // Call the parent constructor
|
|
* Base.call(this)
|
|
* }
|
|
*
|
|
* SubClass.prototype = Object.create(BaseProto)
|
|
* SubClass.prototype.constructor = SubClass
|
|
*
|
|
* // Child class methods can be defined only after the
|
|
* // prototype is updated in the two previous lines
|
|
*
|
|
* SubClass.prototype.dispose = function() {
|
|
* // Call the parent method
|
|
* BaseProto.dispose.call(this)
|
|
* };
|
|
*
|
|
* See:
|
|
*
|
|
* - https://developers.google.com/speed/articles/optimizing-javascript
|
|
* - http://javascriptissexy.com/oop-in-javascript-what-you-need-to-know/
|
|
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript
|
|
*
|
|
*/
|
|
+function ($) { "use strict";
|
|
if ($.wn === undefined)
|
|
$.wn = {}
|
|
if ($.oc === undefined)
|
|
$.oc = $.wn
|
|
|
|
if ($.wn.foundation === undefined)
|
|
$.wn.foundation = {}
|
|
|
|
$.wn.foundation._proxyCounter = 0
|
|
|
|
var Base = function() {
|
|
this.proxiedMethods = {}
|
|
}
|
|
|
|
Base.prototype.dispose = function() {
|
|
for (var key in this.proxiedMethods) {
|
|
this.proxiedMethods[key] = null
|
|
}
|
|
|
|
this.proxiedMethods = null
|
|
}
|
|
|
|
/*
|
|
* Creates a proxied method reference or returns an existing proxied method.
|
|
*/
|
|
Base.prototype.proxy = function(method) {
|
|
if (method.ocProxyId === undefined) {
|
|
$.wn.foundation._proxyCounter++
|
|
method.ocProxyId = $.wn.foundation._proxyCounter
|
|
}
|
|
|
|
if (this.proxiedMethods[method.ocProxyId] !== undefined)
|
|
return this.proxiedMethods[method.ocProxyId]
|
|
|
|
this.proxiedMethods[method.ocProxyId] = method.bind(this)
|
|
return this.proxiedMethods[method.ocProxyId]
|
|
}
|
|
|
|
$.wn.foundation.base = Base;
|
|
}(window.jQuery); |