Implement remove
This commit is contained in:
@@ -75,6 +75,7 @@ class WSF_CONTROL
|
|||||||
@state = @fullstate.state
|
@state = @fullstate.state
|
||||||
@load_subcontrols()
|
@load_subcontrols()
|
||||||
@isolation = (""+@$el.data('isolation')=="1")
|
@isolation = (""+@$el.data('isolation')=="1")
|
||||||
|
@$el.data('control',@)
|
||||||
return
|
return
|
||||||
|
|
||||||
load_subcontrols: ()->
|
load_subcontrols: ()->
|
||||||
@@ -93,6 +94,7 @@ class WSF_CONTROL
|
|||||||
|
|
||||||
update: (state)->
|
update: (state)->
|
||||||
return
|
return
|
||||||
|
|
||||||
process_actions: (actions)->
|
process_actions: (actions)->
|
||||||
for action in actions
|
for action in actions
|
||||||
try
|
try
|
||||||
@@ -146,6 +148,7 @@ class WSF_CONTROL
|
|||||||
if new_states.actions?
|
if new_states.actions?
|
||||||
self.process_actions(new_states.actions)
|
self.process_actions(new_states.actions)
|
||||||
self.process_update(new_states)
|
self.process_update(new_states)
|
||||||
|
|
||||||
#Simple event listener
|
#Simple event listener
|
||||||
|
|
||||||
#subscribe to an event
|
#subscribe to an event
|
||||||
@@ -165,6 +168,11 @@ class WSF_CONTROL
|
|||||||
ev.callback.call(ev.context)
|
ev.callback.call(ev.context)
|
||||||
return @
|
return @
|
||||||
|
|
||||||
|
remove:()->
|
||||||
|
console.log "Removed #{@control_name}"
|
||||||
|
@$el.remove()
|
||||||
|
|
||||||
|
|
||||||
class WSF_PAGE_CONTROL extends WSF_CONTROL
|
class WSF_PAGE_CONTROL extends WSF_CONTROL
|
||||||
constructor: (@fullstate)->
|
constructor: (@fullstate)->
|
||||||
@state = @fullstate.state
|
@state = @fullstate.state
|
||||||
@@ -173,11 +181,16 @@ class WSF_PAGE_CONTROL extends WSF_CONTROL
|
|||||||
@control_name = @state.id
|
@control_name = @state.id
|
||||||
@url = @state['url']
|
@url = @state['url']
|
||||||
@url_params = jQuery.unparam(@state['url_params'])
|
@url_params = jQuery.unparam(@state['url_params'])
|
||||||
|
@$el.data('control',@)
|
||||||
@load_subcontrols()
|
@load_subcontrols()
|
||||||
|
|
||||||
wrap : (cname,state)->
|
wrap : (cname,state)->
|
||||||
state
|
state
|
||||||
|
|
||||||
|
remove:()->
|
||||||
|
console.log "Removed #{@control_name}"
|
||||||
|
@$el.remove()
|
||||||
|
|
||||||
controls = {}
|
controls = {}
|
||||||
|
|
||||||
class WSF_BUTTON_CONTROL extends WSF_CONTROL
|
class WSF_BUTTON_CONTROL extends WSF_CONTROL
|
||||||
@@ -357,14 +370,17 @@ class WSF_PROGRESS_CONTROL extends WSF_CONTROL
|
|||||||
|
|
||||||
fetch: ()->
|
fetch: ()->
|
||||||
@trigger_callback(@control_name, 'progress_fetch')
|
@trigger_callback(@control_name, 'progress_fetch')
|
||||||
if @$el.closest('body').length <= 0
|
|
||||||
clearInterval(@int)
|
|
||||||
|
|
||||||
update: (state)->
|
update: (state)->
|
||||||
if state.progress?
|
if state.progress?
|
||||||
@state['progress'] = state.progress
|
@state['progress'] = state.progress
|
||||||
@$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%')
|
@$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%')
|
||||||
|
|
||||||
|
remove: ()->
|
||||||
|
clearInterval(@int)
|
||||||
|
super
|
||||||
|
|
||||||
class WSF_PAGINATION_CONTROL extends WSF_CONTROL
|
class WSF_PAGINATION_CONTROL extends WSF_CONTROL
|
||||||
|
|
||||||
attach_events: ()->
|
attach_events: ()->
|
||||||
@@ -436,7 +452,10 @@ start_modal = (action)->
|
|||||||
modal.appendTo('body')
|
modal.appendTo('body')
|
||||||
modal.modal('show')
|
modal.modal('show')
|
||||||
modal.on 'hidden.bs.modal', ()->
|
modal.on 'hidden.bs.modal', ()->
|
||||||
modal.remove()
|
$(modal.find('[data-name]').get().reverse()).each (i,value)->
|
||||||
|
$(value).data('control').remove()
|
||||||
|
return
|
||||||
|
return
|
||||||
$.get( action.url, { ajax: 1 } )
|
$.get( action.url, { ajax: 1 } )
|
||||||
.done (data) ->
|
.done (data) ->
|
||||||
modal.find('.modal-body').append(data)
|
modal.find('.modal-body').append(data)
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ WSF_CONTROL = (function() {
|
|||||||
this.state = this.fullstate.state;
|
this.state = this.fullstate.state;
|
||||||
this.load_subcontrols();
|
this.load_subcontrols();
|
||||||
this.isolation = "" + this.$el.data('isolation') === "1";
|
this.isolation = "" + this.$el.data('isolation') === "1";
|
||||||
|
this.$el.data('control', this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +288,11 @@ WSF_CONTROL = (function() {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WSF_CONTROL.prototype.remove = function() {
|
||||||
|
console.log("Removed " + this.control_name);
|
||||||
|
return this.$el.remove();
|
||||||
|
};
|
||||||
|
|
||||||
return WSF_CONTROL;
|
return WSF_CONTROL;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
@@ -303,6 +309,7 @@ WSF_PAGE_CONTROL = (function(_super) {
|
|||||||
this.control_name = this.state.id;
|
this.control_name = this.state.id;
|
||||||
this.url = this.state['url'];
|
this.url = this.state['url'];
|
||||||
this.url_params = jQuery.unparam(this.state['url_params']);
|
this.url_params = jQuery.unparam(this.state['url_params']);
|
||||||
|
this.$el.data('control', this);
|
||||||
this.load_subcontrols();
|
this.load_subcontrols();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,6 +317,11 @@ WSF_PAGE_CONTROL = (function(_super) {
|
|||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WSF_PAGE_CONTROL.prototype.remove = function() {
|
||||||
|
console.log("Removed " + this.control_name);
|
||||||
|
return this.$el.remove();
|
||||||
|
};
|
||||||
|
|
||||||
return WSF_PAGE_CONTROL;
|
return WSF_PAGE_CONTROL;
|
||||||
|
|
||||||
})(WSF_CONTROL);
|
})(WSF_CONTROL);
|
||||||
@@ -642,10 +654,7 @@ WSF_PROGRESS_CONTROL = (function(_super) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
WSF_PROGRESS_CONTROL.prototype.fetch = function() {
|
WSF_PROGRESS_CONTROL.prototype.fetch = function() {
|
||||||
this.trigger_callback(this.control_name, 'progress_fetch');
|
return this.trigger_callback(this.control_name, 'progress_fetch');
|
||||||
if (this.$el.closest('body').length <= 0) {
|
|
||||||
return clearInterval(this.int);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WSF_PROGRESS_CONTROL.prototype.update = function(state) {
|
WSF_PROGRESS_CONTROL.prototype.update = function(state) {
|
||||||
@@ -655,6 +664,11 @@ WSF_PROGRESS_CONTROL = (function(_super) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WSF_PROGRESS_CONTROL.prototype.remove = function() {
|
||||||
|
clearInterval(this.int);
|
||||||
|
return WSF_PROGRESS_CONTROL.__super__.remove.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
return WSF_PROGRESS_CONTROL;
|
return WSF_PROGRESS_CONTROL;
|
||||||
|
|
||||||
})(WSF_CONTROL);
|
})(WSF_CONTROL);
|
||||||
@@ -763,7 +777,9 @@ start_modal = function(action) {
|
|||||||
modal.appendTo('body');
|
modal.appendTo('body');
|
||||||
modal.modal('show');
|
modal.modal('show');
|
||||||
modal.on('hidden.bs.modal', function() {
|
modal.on('hidden.bs.modal', function() {
|
||||||
return modal.remove();
|
$(modal.find('[data-name]').get().reverse()).each(function(i, value) {
|
||||||
|
$(value).data('control').remove();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return $.get(action.url, {
|
return $.get(action.url, {
|
||||||
ajax: 1
|
ajax: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user