fix slider

This commit is contained in:
Xuan Sang LE 2018-03-21 11:59:01 +01:00
parent da342ea574
commit 278ee54b2e
5 changed files with 26 additions and 11 deletions

View File

@ -16,9 +16,9 @@
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
class BaseEvent
constructor: (@name) ->
constructor: (@name, @force) ->
@prevent = false
preventDefault:()->
@prevent = true
preventDefault: () ->
@prevent = true if not @force
this.OS.GUI.BaseEvent = BaseEvent

View File

@ -33,9 +33,9 @@ class BaseModel
_GUI.loadScheme p, @, @host
quit: (force) ->
evt = new _GUI.BaseEvent("exit")
@onexit(evt) if not force
if force or not evt.prevent
evt = new _GUI.BaseEvent("exit", force)
@onexit(evt)
if not evt.prevent
delete @.observable
@dialog.quit() if @dialog
_PM.kill @

View File

@ -132,14 +132,14 @@ self.OS.GUI =
, __("Open with"), list
forceLaunch: (app, args) ->
console.log "This method is used for developing only, please use the launch method instead"
console.warn "This method is used for developing only, please use the launch method instead"
_GUI.unloadApp app
_GUI.launch app, args
unloadApp: (app) ->
_PM.killAll app, true
($ _OS.APP[app].style).remove() if _OS.APP[app] and _OS.APP[app].style
_OS.APP[app] = undefined
delete _OS.APP[app]
loadApp: (app, ok, err) ->
path = "os://packages/#{app}"

View File

@ -10,6 +10,7 @@
this.dragable = eval(opts.dragable)
else
this.dragable = true
this.onchanging = opts.onchanging
this.onchange = opts.onchange
//this.rid = $(self.root).attr("data-id") || Math.floor(Math.random() * 100000) + 1
var self = this
@ -20,8 +21,11 @@
self[i] = v[i]
else
self[k] = v
if(k == "value" && self.onchange)
self.onchange(self.value)
if(k == "value")
{
if(self.onchange) self.onchange(self.value)
if(self.onchanging) self.onchanging(self.value)
}
self.update()
}
self.root.get = function(k)
@ -60,9 +64,10 @@
left = left > maxw?maxw : left
self.value = left*self.max/maxw
calibrate()
if(self.onchange) self.onchange(self.value)
if(self.onchanging) self.onchanging(self.value)
})
$(window).on("mouseup", function(e){
if(self.onchange) self.onchange(self.value)
$(window).unbind("mousemove", null)
})
})
@ -80,6 +85,15 @@
})
enable_dragging()
}
$(self.refs.container).click( function(e){
var offset = $(self.refs.container).offset()
var left = e.clientX - offset.left
var maxw = $(self.refs.container).width()
self.value = left*self.max/maxw
calibrate()
if(self.onchange) self.onchange(self.value)
if(self.onchanging) self.onchanging(self.value)
})
self.root.observable.on("calibrate",function(){
calibrate()
})

View File

@ -11,6 +11,7 @@ afx-slider div.container{
background-color: #e6e6e6;
position: relative;
padding:0;
cursor: pointer;
}
afx-slider div.progress {