PHP Classes

File: modules/system/assets/ui/js/foundation.controlutils.js

Recommend this page to a friend!
  Packages of Luke Towers   Winter   modules/system/assets/ui/js/foundation.controlutils.js   Download  
File: modules/system/assets/ui/js/foundation.controlutils.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Winter
Content management system that uses MVC
Author: By
Last change:
Date: 7 months ago
Size: 1,514 bytes
 

Contents

Class file image Download
/* * Winter JavaScript foundation library. * * Utility functions for working back-end client-side UI controls. * * Usage examples: * * $.wn.foundation.controlUtils.markDisposable(el) * $.wn.foundation.controlUtils.disposeControls(container) * */ +function ($) { "use strict"; if ($.wn === undefined) $.wn = {} if ($.oc === undefined) $.oc = $.wn if ($.wn.foundation === undefined) $.wn.foundation = {} var ControlUtils = { markDisposable: function(el) { el.setAttribute('data-disposable', '') }, /* * Destroys all disposable controls in a container. * The disposable controls should watch the dispose-control * event. */ disposeControls: function(container) { var controls = container.querySelectorAll('[data-disposable]') for (var i=0, len=controls.length; i<len; i++) $(controls[i]).triggerHandler('dispose-control') if (container.hasAttribute('data-disposable')) $(container).triggerHandler('dispose-control') } } $.wn.foundation.controlUtils = ControlUtils; $(document).on('ajaxBeforeReplace', function(ev){ // Automatically dispose controls in an element // before the element contents is replaced. // The ajaxBeforeReplace event is triggered in // framework.js $.wn.foundation.controlUtils.disposeControls(ev.target) }) }(window.jQuery);